#ifndef GEMTEXT_PARSER_H #define GEMTEXT_PARSER_H 1 #include #include #include #define LBUF_SIZE 512 typedef enum { normalMode, preformattedMode, quoteMode, } gemtextParserMode; typedef enum { lineStart, firstLinkChar, firstLinkWord, firstHashChar, secondHashChar, thirdHashChar, firstBacktickChar, secondBacktickChar, thirdBacktickChar, normalState, } gemtextParserState; typedef enum { normalLine, linkLine, listLine, h1Line, h2Line, h3Line, preformattedLine, quoteLine, endOfStream, } gemtextLineType; typedef struct { size_t capacity; size_t len; char *cursor; char *buf; } lineBuffer; typedef struct { char *url; char *display; } gemtextLink; typedef struct { FILE *stream; gemtextParserMode mode; gemtextParserState state; } gemtextParser; struct _gemtextLine { struct _gemtextLine *next; struct _gemtextLine *prev; gemtextLineType lineType; char *line; }; typedef struct _gemtextLine gemtextLine; typedef struct { pthread_cond_t cond; size_t count; pthread_mutex_t mutex; gemtextLine *head; gemtextLine *tail; } gemtextLineQueue; #endif