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.

116 lines
2.7 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /** Generated by xsd2c */
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <stdlib.h>
  5. #include "CallList.h"
  6. struct CallList* CallList_Create()
  7. {
  8. struct CallList* _res;
  9. _res = (struct CallList*)malloc(sizeof(struct CallList));
  10. _res->operation_head = NULL;
  11. _res->operation_tail = NULL;
  12. return _res;
  13. }
  14. void CallList_Free(struct CallList* obj)
  15. {
  16. struct CallFunc_List* operation_cur;
  17. struct CallFunc_List* operation_tmp;
  18. if (obj == NULL) return;
  19. operation_cur = obj->operation_head;
  20. while (operation_cur != NULL)
  21. {
  22. operation_tmp = operation_cur->next;
  23. free(operation_cur);
  24. operation_cur = operation_tmp;
  25. }
  26. free(obj);
  27. }
  28. void CallList_Sax_Serialize(struct CallList* obj,
  29. const char *root_element_name,
  30. void (*OnStartElement)(const char* element_name, int attr_count, char **keys, char **values, void* userData),
  31. void (*OnCharacters)(const char* element_name, const char* chars, void* userData),
  32. void (*OnEndElement)(const char* element_name, void* userData),
  33. void* userData)
  34. {
  35. int attrCount, curCount;
  36. char **keys;
  37. char **values;
  38. char buffer[255];
  39. struct CallFunc_List* operation_cur;
  40. attrCount = 0;
  41. keys = (char**)malloc(sizeof(char*)*attrCount);
  42. values = (char**)malloc(sizeof(char*)*attrCount);
  43. curCount = 0;
  44. OnStartElement(root_element_name, attrCount, keys, values, userData);
  45. operation_cur = obj->operation_head;
  46. while (operation_cur != NULL)
  47. {
  48. if (operation_cur->value)
  49. CallFunc_Sax_Serialize(operation_cur->value, "operation", OnStartElement, OnCharacters, OnEndElement, userData);
  50. operation_cur = operation_cur->next;
  51. }
  52. OnEndElement(root_element_name, userData);
  53. }
  54. #ifndef _DESERIALIZER_DISABLED_
  55. struct CallList* CallList_Deserialize(xmlNodePtr xmlRoot)
  56. {
  57. xmlNodePtr cur;
  58. xmlChar *key;
  59. struct CallList* obj;
  60. obj = CallList_Create();
  61. cur = xmlRoot->xmlChildrenNode;
  62. while (cur != NULL) {
  63. if (cur->type != XML_ELEMENT_NODE) {
  64. cur = cur->next;
  65. continue;
  66. }
  67. printf("CallList->%s\n", cur->name);
  68. if ((!xmlStrcmp(cur->name, (const xmlChar *)"operation"))){
  69. CallList_Add_operation( obj, CallFunc_Deserialize(cur) );
  70. }
  71. // TODO:
  72. cur = cur->next;
  73. }
  74. return obj;
  75. }
  76. #endif
  77. struct CallFunc_List* CallList_Get_operation(struct CallList* obj)
  78. {
  79. return obj->operation_head;
  80. }
  81. void CallList_Add_operation(struct CallList* obj, struct CallFunc* operation)
  82. {
  83. struct CallFunc_List* operation_node;
  84. operation_node = (struct CallFunc_List*)malloc(sizeof(struct CallFunc_List));
  85. operation_node->value = operation;
  86. operation_node->next = NULL;
  87. if (obj->operation_tail)
  88. {
  89. obj->operation_tail->next = operation_node;
  90. }
  91. if (obj->operation_head == NULL)
  92. {
  93. obj->operation_head = operation_node;
  94. }
  95. obj->operation_tail = operation_node;
  96. }