summaryrefslogtreecommitdiffstats
path: root/examples/xsd2c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/xsd2c')
-rw-r--r--examples/xsd2c/utils.c37
-rw-r--r--examples/xsd2c/utils.h11
2 files changed, 48 insertions, 0 deletions
diff --git a/examples/xsd2c/utils.c b/examples/xsd2c/utils.c
new file mode 100644
index 0000000..0be002b
--- /dev/null
+++ b/examples/xsd2c/utils.c
@@ -0,0 +1,37 @@
+
+#include "utils.h"
+
+
+int Writer_Tab = 0;
+int Writer_Ret = 0;
+
+void Writer_StartElement(const char* element_name, int attr_count, char **keys, char **values, void* userData)
+{
+ int i, j;
+ if (Writer_Ret) printf("\n");
+ for (j=0;j<Writer_Tab;j++) printf("\t");
+ printf("<%s", element_name);
+ for (i=0;i<attr_count;i++)
+ {
+ printf(" %s = \"%s\"", keys[i], values[i]);
+ }
+ printf(">");
+ Writer_Tab++;
+ Writer_Ret = 1;
+}
+
+void Writer_Characters(const char* element_name, const char* chars, void* userData)
+{
+ printf("%s", chars);
+}
+
+void Writer_EndElement(const char* element_name, void* userData)
+{
+ int j;
+ Writer_Tab--;
+ if (!Writer_Ret)
+ for (j=0;j<Writer_Tab;j++) printf("\t");
+ printf("</%s>\n", element_name);
+ Writer_Ret = 0;
+}
+
diff --git a/examples/xsd2c/utils.h b/examples/xsd2c/utils.h
new file mode 100644
index 0000000..17a2140
--- /dev/null
+++ b/examples/xsd2c/utils.h
@@ -0,0 +1,11 @@
+
+#ifndef _EX_UTILS_H_
+#define _EX_UTILS_H_
+
+
+void Writer_StartElement(const char* element_name, int attr_count, char **keys, char **values, void* userData);
+void Writer_Characters(const char* element_name, const char* chars, void* userData);
+void Writer_EndElement(const char* element_name, void* userData);
+
+
+#endif