You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

160 lines
3.4 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /** Generated by xsd2c */
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <stdlib.h>
  5. #include "CallFunc.h"
  6. struct CallFunc* CallFunc_Create()
  7. {
  8. struct CallFunc* _res;
  9. _res = (struct CallFunc*)malloc(sizeof(struct CallFunc));
  10. _res->name = NULL;
  11. _res->in_head = NULL;
  12. _res->in_tail = NULL;
  13. _res->out = NULL;
  14. return _res;
  15. }
  16. void CallFunc_Free(struct CallFunc* obj)
  17. {
  18. struct CallVar_List* in_cur;
  19. struct CallVar_List* in_tmp;
  20. if (obj == NULL) return;
  21. if (obj->name != NULL)
  22. {
  23. free(obj->name);
  24. obj->name = NULL;
  25. }
  26. in_cur = obj->in_head;
  27. while (in_cur != NULL)
  28. {
  29. in_tmp = in_cur->next;
  30. free(in_cur);
  31. in_cur = in_tmp;
  32. }
  33. free(obj);
  34. }
  35. void CallFunc_Sax_Serialize(struct CallFunc* obj,
  36. const char *root_element_name,
  37. void (*OnStartElement)(const char* element_name, int attr_count, char **keys, char **values, void* userData),
  38. void (*OnCharacters)(const char* element_name, const char* chars, void* userData),
  39. void (*OnEndElement)(const char* element_name, void* userData),
  40. void* userData)
  41. {
  42. int attrCount, curCount;
  43. char **keys;
  44. char **values;
  45. char buffer[255];
  46. struct CallVar_List* in_cur;
  47. attrCount = 0;
  48. keys = (char**)malloc(sizeof(char*)*attrCount);
  49. values = (char**)malloc(sizeof(char*)*attrCount);
  50. curCount = 0;
  51. OnStartElement(root_element_name, attrCount, keys, values, userData);
  52. OnStartElement("name", 0, NULL, NULL, userData);
  53. if (obj->name != NULL)
  54. OnCharacters("name", obj->name, userData);
  55. OnEndElement("name", userData);
  56. in_cur = obj->in_head;
  57. while (in_cur != NULL)
  58. {
  59. if (in_cur->value)
  60. CallVar_Sax_Serialize(in_cur->value, "in", OnStartElement, OnCharacters, OnEndElement, userData);
  61. in_cur = in_cur->next;
  62. }
  63. if (obj->out)
  64. CallVar_Sax_Serialize(obj->out, "out", OnStartElement, OnCharacters, OnEndElement, userData);
  65. OnEndElement(root_element_name, userData);
  66. }
  67. #ifndef _DESERIALIZER_DISABLED_
  68. struct CallFunc* CallFunc_Deserialize(xmlNodePtr xmlRoot)
  69. {
  70. xmlNodePtr cur;
  71. xmlChar *key;
  72. struct CallFunc* obj;
  73. obj = CallFunc_Create();
  74. cur = xmlRoot->xmlChildrenNode;
  75. while (cur != NULL) {
  76. if (cur->type != XML_ELEMENT_NODE) {
  77. cur = cur->next;
  78. continue;
  79. }
  80. printf("CallFunc->%s\n", cur->name);
  81. if ((!xmlStrcmp(cur->name, (const xmlChar *)"name"))){
  82. key = xmlNodeListGetString(cur->doc, cur->xmlChildrenNode, 1);
  83. CallFunc_Set_name(obj, (const char*)key);
  84. /*xmlFree(key);*/
  85. }
  86. if ((!xmlStrcmp(cur->name, (const xmlChar *)"in"))){
  87. CallFunc_Add_in( obj, CallVar_Deserialize(cur) );
  88. }
  89. if ((!xmlStrcmp(cur->name, (const xmlChar *)"out"))){
  90. CallFunc_Set_out( obj, CallVar_Deserialize(cur) );
  91. }
  92. // TODO:
  93. cur = cur->next;
  94. }
  95. return obj;
  96. }
  97. #endif
  98. char* CallFunc_Get_name(struct CallFunc* obj)
  99. {
  100. return obj->name;
  101. }
  102. struct CallVar_List* CallFunc_Get_in(struct CallFunc* obj)
  103. {
  104. return obj->in_head;
  105. }
  106. struct CallVar* CallFunc_Get_out(struct CallFunc* obj)
  107. {
  108. return obj->out;
  109. }
  110. void CallFunc_Set_name(struct CallFunc* obj, const char* name)
  111. {
  112. if (obj->name != NULL) free(obj->name);
  113. obj->name = (char*)malloc(strlen(name)+1);
  114. strcpy(obj->name, name);
  115. }
  116. void CallFunc_Set_out(struct CallFunc* obj, struct CallVar* out)
  117. {
  118. obj->out = out;
  119. }
  120. void CallFunc_Add_in(struct CallFunc* obj, struct CallVar* in)
  121. {
  122. struct CallVar_List* in_node;
  123. in_node = (struct CallVar_List*)malloc(sizeof(struct CallVar_List));
  124. in_node->value = in;
  125. in_node->next = NULL;
  126. if (obj->in_tail)
  127. {
  128. obj->in_tail->next = in_node;
  129. }
  130. if (obj->in_head == NULL)
  131. {
  132. obj->in_head = in_node;
  133. }
  134. obj->in_tail = in_node;
  135. }