163
|
1 /* ----------------------------------------------------------------------------
|
|
2 * File : input.h
|
|
3 * Purpose : header file for input.c
|
|
4 * ----------------------------------------------------------------------------
|
|
5 */
|
|
6
|
|
7 #define TOKEN_MAXSIZ 1023 /* maximum size of token */
|
|
8 #define INPUT_BUFSIZ TOKEN_MAXSIZ + 1 /* allow for terminating null */
|
|
9 /*
|
|
10 * #define DELIMITER_BEGIN_LIST '{'
|
|
11 * #define DELIMITER_END_LIST '}'
|
167
|
12 */
|
163
|
13
|
|
14 /* Possible token types in file */
|
|
15
|
|
16 enum { TOKEN_LABEL,
|
|
17 /*
|
|
18 * TOKEN_BEGIN_LIST,
|
|
19 * TOKEN_END_LIST,
|
|
20 */
|
|
21 TOKEN_EOF };
|
|
22
|
|
23
|
167
|
24 typedef enum {
|
163
|
25 ERR_OPENFAIL,
|
|
26 ERR_EMPTYFILE,
|
|
27 ERR_MEMALLOC,
|
|
28 ERR_NOBEGIN,
|
|
29 ERR_NOEND,
|
|
30 ERR_NOROOT,
|
|
31 ERR_MANYROOT,
|
167
|
32 ERR_NONE
|
163
|
33 } ErrCode;
|
|
34
|
|
35 #define NUM_ERRS 7 /* don't count ERR_NONE */
|
|
36
|
|
37
|
167
|
38 Tree* ReadTreeFromFile(char *fname, ErrCode *error);
|
|
39 void SetNodeLabelAndValue(Tree *node, char *label_and_value);
|
|
40 int SaveTreeToFile(Tree *tree, char *fname);
|