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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/** Generated by xsd2c */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "CallList.h"
struct CallList* CallList_Create()
{
struct CallList* _res;
_res = (struct CallList*)malloc(sizeof(struct CallList));
_res->operation_head = NULL;
_res->operation_tail = NULL;
return _res;
}
void CallList_Free(struct CallList* obj)
{
struct CallFunc_List* operation_cur;
struct CallFunc_List* operation_tmp;
if (obj == NULL) return;
operation_cur = obj->operation_head;
while (operation_cur != NULL)
{
operation_tmp = operation_cur->next;
free(operation_cur);
operation_cur = operation_tmp;
}
free(obj);
}
void CallList_Sax_Serialize(struct CallList* obj,
const char *root_element_name,
void (*OnStartElement)(const char* element_name, int attr_count, char **keys, char **values, void* userData),
void (*OnCharacters)(const char* element_name, const char* chars, void* userData),
void (*OnEndElement)(const char* element_name, void* userData),
void* userData)
{
int attrCount, curCount;
char **keys;
char **values;
char buffer[255];
struct CallFunc_List* operation_cur;
attrCount = 0;
keys = (char**)malloc(sizeof(char*)*attrCount);
values = (char**)malloc(sizeof(char*)*attrCount);
curCount = 0;
OnStartElement(root_element_name, attrCount, keys, values, userData);
operation_cur = obj->operation_head;
while (operation_cur != NULL)
{
if (operation_cur->value)
CallFunc_Sax_Serialize(operation_cur->value, "operation", OnStartElement, OnCharacters, OnEndElement, userData);
operation_cur = operation_cur->next;
}
OnEndElement(root_element_name, userData);
}
#ifndef _DESERIALIZER_DISABLED_
struct CallList* CallList_Deserialize(xmlNodePtr xmlRoot)
{
xmlNodePtr cur;
xmlChar *key;
struct CallList* obj;
obj = CallList_Create();
cur = xmlRoot->xmlChildrenNode;
while (cur != NULL) {
if (cur->type != XML_ELEMENT_NODE) {
cur = cur->next;
continue;
}
printf("CallList->%s\n", cur->name);
if ((!xmlStrcmp(cur->name, (const xmlChar *)"operation"))){
CallList_Add_operation( obj, CallFunc_Deserialize(cur) );
}
// TODO:
cur = cur->next;
}
return obj;
}
#endif
struct CallFunc_List* CallList_Get_operation(struct CallList* obj)
{
return obj->operation_head;
}
void CallList_Add_operation(struct CallList* obj, struct CallFunc* operation)
{
struct CallFunc_List* operation_node;
operation_node = (struct CallFunc_List*)malloc(sizeof(struct CallFunc_List));
operation_node->value = operation;
operation_node->next = NULL;
if (obj->operation_tail)
{
obj->operation_tail->next = operation_node;
}
if (obj->operation_head == NULL)
{
obj->operation_head = operation_node;
}
obj->operation_tail = operation_node;
}
|