summaryrefslogtreecommitdiffstats
path: root/xsd2c
diff options
context:
space:
mode:
Diffstat (limited to 'xsd2c')
-rwxr-xr-xxsd2c/main.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/xsd2c/main.c b/xsd2c/main.c
new file mode 100755
index 0000000..6e866c6
--- /dev/null
+++ b/xsd2c/main.c
@@ -0,0 +1,62 @@
+#include "xsd2c.h"
+#include "formatter.h"
+
+#include <string.h>
+
+
+void usage(const char* execName);
+
+int main(int argc, char *argv[])
+{
+ int i;
+ char outDir[1054];
+ xmlNodePtr xsdNode = NULL;
+ char fname[255];
+ int wsdl = 0;
+
+ if (argc < 2) {
+ usage(argv[0]);
+ return 1;
+ }
+
+
+ strcpy(outDir, ".");
+
+ for (i=1;i<argc;i++)
+ {
+ if (!strcmp(argv[i], "-d"))
+ if (i==argc-1) usage(argv[0]);
+ else strcpy(outDir, argv[++i]);
+ else if (!strcmp(argv[i], "-S"))
+ formatter_generate_sax_serializer = 1;
+ else if (!strcmp(argv[i], "-wsdl"))
+ wsdl = 1;
+ else strcpy(fname, argv[i]);
+ }
+
+
+ if (wsdl)
+ xsdNode = wsdlLoadFile(fname);
+ else
+ xsdNode = xsdLoadFile(fname);
+
+ if (xsdNode == NULL) {
+ fprintf(stderr, "can not load xsd file!\n");
+ return 1;
+ }
+
+ xsdEngineRun(xsdNode, outDir);
+
+ xmlFreeDoc(xsdNode->doc);
+
+ return 0;
+}
+
+
+
+void usage(const char* execName)
+{
+ printf("usage: %s [-d <destdir> -S -D] <xsd filename>\n", execName);
+}
+
+