↑ 1 #ifndef BUFFER_READLINE
↑ 2 #define BUFFER_READLINE
↑ 3
↑ 4 /*
↑ 5 *
↑ 6 * splits a buffer into lines
↑ 7 *
↑ 8 * intend: should be used to parse files line by line
↑ 9 *
↑10 */
↑11
↑12 struct buffer_readline {
↑13 const char *data;
↑14 size_t ndata;
↑15
↑16 const char *line;
↑17 size_t nline;
↑18
↑19 unsigned char seperator[256];
↑20
↑21 size_t lineno;
↑22 };
↑23
↑24 #define BUFFER_READLINE_INIT(_readline,_data,_ndata) \
↑25 { \
↑26 (_readline)->line = NULL; \
↑27 (_readline)->nline = 0; \
↑28 (_readline)->data = (const char*)(_data); \
↑29 (_readline)->ndata = (_ndata); \
↑30 (_readline)->lineno = (size_t)-1; \
↑31 }
↑32
↑33 int buffer_readline (struct buffer_readline *readline);
↑34 void buffer_readline_strip_comment (struct buffer_readline *readline);
↑35
↑36
↑37
↑38 void buffer_split_init (struct buffer_readline *readline,
↑39 const char *data, size_t ndata, const char *seperator);
↑40
↑41 int buffer_split (struct buffer_readline *readline);
↑42
↑43 #endif /* BUFFER_READLINE */
syntax highlighted by Code2HTML, v. 0.9.1