-# set some compiler flags
-CFLAGS=-lncurses
-
-# find *.c in the current directory
-SOURCES=$(wildcard *.c)
-TESTS=$(wildcard test/*.c)
-
-# define the output objects by replacing .c with .o
-TARGETS=$(SOURCES:.c=)
-TEST_TARGETS=$(TESTS:.c=)
-
-# this will make all objects
-all: $(TEST_TARGETS) $(TARGETS)
-test: $(TEST_TARGETS)
-
-# each objects will be build by a *.c file
-#%.o: %.c
-%: %.c
- cc $(CFLAGS) -o $@ $^
-
-# this will delete all objects
-# if not all objects are there, they will be compiled first
-clean: $(TARGETS) $(TEST_TARGETS)
- rm -f $^
+tmp: tmp.c cstring.o markdown.o markdown_io.o
+ cc -g -o tmp tmp.c cstring.o markdown.o markdown_io.o
+
+markdown_io.o: markdown_io.c cstring.o markdown.o
+ cc -g -c markdown_io.c -o markdown_io.o -lmarkdown
+
+markdown.o: markdown.c cstring.o
+ cc -g -c markdown.c -o markdown.o -lcstring
+
+cstring.o: cstring.c
+ cc -g -c cstring.c -o cstring.o
+
+all: tmp
+
+.PHONY: test
+
+test:
+ $(MAKE) -C test
+
+clean:
+ rm -f tmp *.o
+ $(MAKE) -C test clean
--- /dev/null
+# set some compiler flags
+CFLAGS=
+
+# find *.c in the current directory
+SOURCES=$(wildcard *.c)
+
+# define the output objects by replacing .c with .o
+TARGETS=$(SOURCES:.c=)
+
+# this will make all objects
+all: $(TARGETS)
+
+# each objects will be build by a *.c file
+#%.o: %.c
+%: %.c
+ cc $(CFLAGS) -o $@ $^
+
+# this will delete all objects
+# if not all objects are there, they will be compiled first
+clean: $(TARGETS)
+ rm -f $^
+
#include <stdio.h>
#include "../include/cstring.h"
+#include "../cstring.c"
int main(int argc, char *argv[]) {
--- /dev/null
+#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);
+}
+