summaryrefslogtreecommitdiffstats
path: root/wsdl2c/CallFunc.c
blob: db1357903c36be15b3abd05a7c073f8caa2b862c (plain)
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/** Generated by xsd2c */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "CallFunc.h"


struct CallFunc* CallFunc_Create()
{
	struct CallFunc* _res;
	_res = (struct CallFunc*)malloc(sizeof(struct CallFunc));

	_res->name = NULL;
	_res->in_head = NULL;
	_res->in_tail = NULL;
	_res->out = NULL;

	return _res;
}

void CallFunc_Free(struct CallFunc* obj)
{
	struct CallVar_List* in_cur;
	struct CallVar_List* in_tmp;
	if (obj == NULL) return;
	if (obj->name != NULL) 
	{
		free(obj->name);
		obj->name = NULL;
	}

	in_cur = obj->in_head;
	while (in_cur != NULL)
	{
		in_tmp = in_cur->next;
		free(in_cur);
		in_cur = in_tmp;
	}
	free(obj);
}

void CallFunc_Sax_Serialize(struct CallFunc* 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 CallVar_List* in_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);

	OnStartElement("name", 0, NULL, NULL, userData);
	if (obj->name != NULL)
		OnCharacters("name", obj->name, userData);
	OnEndElement("name", userData);
	in_cur = obj->in_head;
	while (in_cur != NULL)
	{
	if (in_cur->value)
		CallVar_Sax_Serialize(in_cur->value, "in", OnStartElement, OnCharacters, OnEndElement, userData);

		in_cur = in_cur->next;
	}
	if (obj->out)
	CallVar_Sax_Serialize(obj->out, "out", OnStartElement, OnCharacters, OnEndElement, userData);

	OnEndElement(root_element_name, userData);
}

#ifndef _DESERIALIZER_DISABLED_

struct CallFunc* CallFunc_Deserialize(xmlNodePtr xmlRoot)
{
	xmlNodePtr cur;
	xmlChar *key;
	struct CallFunc* obj;
	obj = CallFunc_Create();
	cur = xmlRoot->xmlChildrenNode;
	while (cur != NULL) {
		if (cur->type != XML_ELEMENT_NODE) {
			cur = cur->next;
			continue;
		}
		printf("CallFunc->%s\n", cur->name);
		if ((!xmlStrcmp(cur->name, (const xmlChar *)"name"))){
			key = xmlNodeListGetString(cur->doc, cur->xmlChildrenNode, 1);
			CallFunc_Set_name(obj, (const char*)key);
			xmlFree(key);
		}
		if ((!xmlStrcmp(cur->name, (const xmlChar *)"in"))){
			CallFunc_Add_in( obj, CallVar_Deserialize(cur) );
		}
		if ((!xmlStrcmp(cur->name, (const xmlChar *)"out"))){
			CallFunc_Set_out( obj, CallVar_Deserialize(cur) );
		}
	// TODO: 
		cur = cur->next;
	}
	return obj;
}

#endif
char* CallFunc_Get_name(struct CallFunc* obj)
{
	return obj->name;
}

struct CallVar_List* CallFunc_Get_in(struct CallFunc* obj)
{
	return obj->in_head;
}

struct CallVar* CallFunc_Get_out(struct CallFunc* obj)
{
	return obj->out;
}

void CallFunc_Set_name(struct CallFunc* obj, const char* name)
{
	if (obj->name != NULL) free(obj->name);
	obj->name = (char*)malloc(strlen(name)+1);
	strcpy(obj->name, name);
}

void CallFunc_Set_out(struct CallFunc* obj, struct CallVar* out)
{
	obj->out = out;
}

void CallFunc_Add_in(struct CallFunc* obj, struct CallVar* in)
{
	struct CallVar_List* in_node;
	in_node = (struct CallVar_List*)malloc(sizeof(struct CallVar_List));
	in_node->value = in;
	in_node->next = NULL;
	if (obj->in_tail)
	{
		obj->in_tail->next = in_node;
	}
	if (obj->in_head == NULL)
	{
		obj->in_head = in_node;
	}
	obj->in_tail = in_node;
}