This repository was archived by the owner on Jul 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathparser.h
More file actions
46 lines (40 loc) · 1.2 KB
/
parser.h
File metadata and controls
46 lines (40 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef PARSER_H
#define PARSER_H
struct tag;
struct tag {
int code;
struct tag *prev;
};
struct bc_parser;
/* Callback function whose arguments are the parser that calls it and pointer
* to the start of the match, plus length. */
typedef void (*bc_callback) (struct bc_parser *, const char *, size_t);
/* Callback function for notification, carries no data (just the pointer to the
* parser) */
typedef void (*bc_notify) (struct bc_parser *);
struct bc_parser {
/* Public */
/* Called with data pointer to regular text. */
bc_callback on_text;
/* Called with data pointer inside BC tag. */
bc_callback on_tag_text;
/* Called when tag's opening argument ends, ie. at 'ESC|'. */
bc_notify on_arg_end;
/* Called when a tag is opened. */
bc_notify on_open;
/* Called when a tag is closed. */
bc_notify on_close;
/* Called upon TELNET GOAHEAD after closing tag number 10, ie. ESC
* 10\xFF\xF9 */
bc_notify on_prompt;
/* Called on any other TELNET commands */
bc_callback on_telnet_command;
/* application data pointer; not used by parser */
void *data;
struct tag *tag;
/* Private */
int partial_code;
int state;
};
void bc_parse(struct bc_parser *, const char *, size_t);
#endif /* PARSER_H */