Blame


1 6ab857d5 2024-01-23 op /*
2 6ab857d5 2024-01-23 op * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
3 6ab857d5 2024-01-23 op *
4 6ab857d5 2024-01-23 op * Permission to use, copy, modify, and distribute this software for any
5 6ab857d5 2024-01-23 op * purpose with or without fee is hereby granted, provided that the above
6 6ab857d5 2024-01-23 op * copyright notice and this permission notice appear in all copies.
7 6ab857d5 2024-01-23 op *
8 6ab857d5 2024-01-23 op * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 6ab857d5 2024-01-23 op * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 6ab857d5 2024-01-23 op * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 6ab857d5 2024-01-23 op * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 6ab857d5 2024-01-23 op * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 6ab857d5 2024-01-23 op * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 6ab857d5 2024-01-23 op * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 6ab857d5 2024-01-23 op */
16 6ab857d5 2024-01-23 op
17 6ab857d5 2024-01-23 op #ifndef PARSER_H
18 6ab857d5 2024-01-23 op #define PARSER_H
19 6ab857d5 2024-01-23 op
20 c1d27b0e 2024-06-14 op struct buffer;
21 c1d27b0e 2024-06-14 op struct tab;
22 6ab857d5 2024-01-23 op
23 c1d27b0e 2024-06-14 op struct parser {
24 c1d27b0e 2024-06-14 op const char *name;
25 c1d27b0e 2024-06-14 op int initflags;
26 6ab857d5 2024-01-23 op
27 c1d27b0e 2024-06-14 op int (*parse)(struct buffer *, const char *, size_t);
28 c1d27b0e 2024-06-14 op int (*parseline)(struct buffer *, const char *, size_t);
29 c1d27b0e 2024-06-14 op int (*free)(struct buffer *);
30 c1d27b0e 2024-06-14 op int (*serialize)(struct buffer *, FILE *);
31 c1d27b0e 2024-06-14 op };
32 c1d27b0e 2024-06-14 op
33 fd1c80ce 2024-06-14 op void parser_init(struct buffer *, const struct parser *);
34 c1d27b0e 2024-06-14 op int parser_parse(struct buffer *, const char *, size_t);
35 c1d27b0e 2024-06-14 op int parser_parsef(struct buffer *, const char *, ...);
36 6ab857d5 2024-01-23 op int parser_free(struct tab *);
37 c1d27b0e 2024-06-14 op int parser_serialize(struct buffer *, FILE *);
38 6ab857d5 2024-01-23 op
39 fd1c80ce 2024-06-14 op extern const struct parser gemtext_parser;
40 fd1c80ce 2024-06-14 op extern const struct parser gophermap_parser;
41 fd1c80ce 2024-06-14 op extern const struct parser textpatch_parser;
42 fd1c80ce 2024-06-14 op extern const struct parser textplain_parser;
43 6ab857d5 2024-01-23 op
44 6ab857d5 2024-01-23 op #endif