draft markdown header + bit test
authorMichael Göhler <somebody.here@gmx.de>
Fri, 15 Aug 2014 21:37:56 +0000 (23:37 +0200)
committerMichael Göhler <somebody.here@gmx.de>
Fri, 15 Aug 2014 21:37:56 +0000 (23:37 +0200)
include/markdown.h [new file with mode: 0644]
test/bits.c [new file with mode: 0644]

diff --git a/include/markdown.h b/include/markdown.h
new file mode 100644 (file)
index 0000000..357de78
--- /dev/null
@@ -0,0 +1,44 @@
+#if !defined( MARKDOWN_H )
+#define MARKDOWN_H
+
+/*
+ * A implementation of markdown objects.
+ *
+ */
+
+#include "cstring.h"
+
+#define SET_BIT(var, pos)    ((var) |= (1<<(pos)))
+#define CLEAR_BIT(var, pos)  ((var) &= (~(1<<(pos))))
+#define TOGGLE_BIT(var, pos) ((var) ^= (1<<(pos)))
+#define CHECK_BIT(var, pos)  ((var) &  (1<<(pos)))
+
+enum line_bitmask {
+    IS_HEADER,
+    IS_HEADER2,
+    IS_QUOTE,
+    IS_CODE,
+    IS_LIST,
+    IS_NUMLIST
+};
+
+typedef struct _line_t {
+    cstring_t *text;
+    struct _line_t *next;
+    int bits;
+    int left_white_space;
+} line_t;
+
+typedef struct _page_t {
+    line_t *lines;
+    struct _page_t *next;
+} page_t;
+
+typedef struct _document_t {
+    line_t *title;
+    line_t *author;
+    line_t *date;
+    page_t *pages;
+} document_t;
+
+#endif // !defined( MARKDOWN_H )
diff --git a/test/bits.c b/test/bits.c
new file mode 100644 (file)
index 0000000..58eb687
--- /dev/null
@@ -0,0 +1,29 @@
+#include <stdio.h>
+
+#include "../include/markdown.h"
+
+int main(int argc, char *argv[]) {
+
+    int i;
+    printf("INIT: %i\n", i);
+
+    SET_BIT(i, IS_HEADER);
+    printf("SET_BIT(%i): %i\n", IS_HEADER, i);
+
+    printf("CHECK_BIT(%i): %i\n", IS_HEADER, CHECK_BIT(i, IS_HEADER));
+
+    TOGGLE_BIT(i, IS_HEADER2);
+    printf("TOGGLE_BIT(%i): %i\n", IS_HEADER2, i);
+
+    printf("CHECK_BIT(%i): %i\n", IS_HEADER2, CHECK_BIT(i, IS_HEADER2));
+
+    TOGGLE_BIT(i, IS_HEADER2);
+    printf("TOGGLE_BIT(%i): %i\n", IS_HEADER2, i);
+
+    CLEAR_BIT(i, IS_HEADER);
+    printf("CLEAR_BIT(%i): %i\n", IS_HEADER, i);
+
+    printf("CHECK_BIT(%i): %i\n", IS_HEADER, CHECK_BIT(i, IS_HEADER));
+    printf("CHECK_BIT(%i): %i\n", IS_HEADER2, CHECK_BIT(i, IS_HEADER2));
+}
+