summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvan Jegen <s.jegen@gmail.com>2016-09-01 19:54:12 +0200
committerSilvan Jegen <s.jegen@gmail.com>2016-09-01 19:54:12 +0200
commitecc6234c722a47257877442787d6c8a0112493d8 (patch)
treecf50fbfbb57f1671c4c7b2f2a9f23cbb58042fb5
parent06e15e2b15dae38a13b872c6173b21f8ae2c0777 (diff)
Implement first version of the processing function
-rw-r--r--mxml.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/mxml.c b/mxml.c
index c773d78..0b503e4 100644
--- a/mxml.c
+++ b/mxml.c
@@ -3,7 +3,42 @@
#include <mxml.h>
+mxml_type_t type_cb(mxml_node_t *node) {
+ const char *type;
+
+ type = mxmlElementGetAttr(node, "type");
+ if (type == NULL)
+ type = mxmlGetElement(node);
+
+ if (!strcmp(type, "integer"))
+ return (MXML_INTEGER);
+ else if (!strcmp(type, "opaque"))
+ return (MXML_OPAQUE) ;
+ else if (!strcmp(type, "real"))
+ return (MXML_REAL);
+ else
+ return (MXML_TEXT);
+}
+
+int process(FILE *f) {
+ mxml_node_t *root;
+ const char* elename;
+
+ root = mxmlLoadFile(NULL, f, type_cb);
+ elename = mxmlGetElement(root);
+ if (elename)
+ printf("%s\n", elename);
+}
+
int main(int argc, char *argv[]) {
+ FILE *f;
+
+ for (int i = 0; i < argc; i++) {
+ printf("%s\n", argv[i]);
+ f = fopen(argv[i], "r");
+ process(f);
+ fclose(f);
+ }
return 0;
}