draft main application with file io + fixed Makefiles
[smdp.git] / tmp.c
diff --git a/tmp.c b/tmp.c
new file mode 100644 (file)
index 0000000..bcdfeed
--- /dev/null
+++ b/tmp.c
@@ -0,0 +1,29 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include "include/markdown.h"
+
+int main(int argc, char *argv[]) {
+
+    FILE *input;
+    document_t *doc;
+
+    if (argc > 1) {
+        if(!strcmp(argv[1], "-")) {
+            input = stdin;
+        } else {
+            input = fopen(argv[1],"r");
+            if(!input) {
+                fprintf(stderr, "Unable to open '%s': %s\n",
+                    argv[1], strerror(errno));
+                exit(EXIT_FAILURE);
+            }
+        }
+    } else {
+        input = stdin;
+    }
+
+    doc = markdown_load(input);
+}
+