-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathksx.h
92 lines (70 loc) · 1.83 KB
/
ksx.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <assert.h>
extern struct XMLNode ** getElementsByTagName(char *name, int*);
extern struct XMLattributeNode** getAttributeNodes(struct XMLNode*, int*);
extern struct XMLNode** getChildrenNodes(struct XMLNode*, int*);
extern struct XMLNode* getParent(struct XMLNode*);
extern struct XMLNode* firstChild(struct XMLNode*);
extern struct XMLNode* lastChild(struct XMLNode*);
extern struct XMLNode* nextSibling(struct XMLNode*);
extern struct XMLNode* previousSibling(struct XMLNode*);
extern char* getAttributeValue(struct XMLNode*, char *name);
typedef struct XMLNode{
int type;
char* name;
char* value;
struct XMLNode* next;
struct XMLNode* prev;
struct XMLNode* children;
int childrenCount;
struct XMLattributeNode* attributes;
int attributeCount;
struct XMLNode* parent;
char *id;
} *XMLNodeP;
struct XMLattributeNode{
char* key;
char* value;
struct XMLattributeNode* next;
struct XMLattributeNode* prev;
} *XMLattributeNodeP;
typedef struct XMLprolog{
char *version;
char *encoding;
char *standlone;
} *XMLprologP;
typedef struct node{
struct XMLNode* key;
struct node* next;
} *Node;
typedef struct queue{
Node root;
Node tail;
size_t size;
} *Queue;
/*
Queue api
*/
extern Queue Queue_init();
extern Node enqueue(struct XMLNode* key, Queue q);
extern void _enqueue(Node x, Queue q);
extern Node dequeue(Queue q);
extern Node top(Queue q);
extern int isEmpty(Queue q);
/*
Stack api
*/
typedef struct stack{
Node root;
Node tail;
size_t size;
} *Stack;
extern Stack Stack_init();
extern Node push(struct XMLNode* key, Stack q);
extern void _push(Node x, Stack q);
extern Node pop(Stack q);
extern Node stack_top(Stack q);
extern int stack_isEmpty(Stack q);