forked from haberman/vtparse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtparse.h
44 lines (34 loc) · 1.03 KB
/
vtparse.h
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
/*
* VTParse - an implementation of Paul Williams' DEC compatible state machine parser
*
* Author: Joshua Haberman <[email protected]>
*
* This code is in the public domain.
*/
#ifndef VTPARSE_DOT_H
#define VTPARSE_DOT_H
#ifdef __cplusplus
extern "C" {
#endif
#include "vtparse_table.h"
#define MAX_INTERMEDIATE_CHARS 2
#define ACTION(state_change) (state_change & 0x0F)
#define STATE(state_change) (state_change >> 4)
struct vtparse;
typedef void (*vtparse_callback_t)(struct vtparse*, vtparse_action_t, unsigned char);
typedef struct vtparse {
vtparse_state_t state;
vtparse_callback_t cb;
unsigned char intermediate_chars[MAX_INTERMEDIATE_CHARS+1];
int num_intermediate_chars;
char ignore_flagged;
int params[16];
int num_params;
void* user_data;
} vtparse_t;
void vtparse_init(vtparse_t *parser, vtparse_callback_t cb);
void vtparse(vtparse_t *parser, unsigned char *data, int len);
#ifdef __cplusplus
}
#endif
#endif