Grid Community Toolkit  6.2.1629922860 (tag: v6.2.20210826)
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vparse.h
1 /*
2  * vparse.h
3  *
4  * Routines for parsing a configuration file. A beefed up strtok().
5  */
6 
7 #ifndef __VPARSE_H
8 #define __VPARSE_H
9 
10 #include <stdio.h>
11 
12 struct vparse_options {
13  char *whitespace_chars;
14  char *quoting_chars;
15  char *escaping_chars;
16  char *comment_chars;
17 };
18 
19 /*
20  * Defaults for above
21  */
22 #define VPARSE_DEFAULT_WHITESPACE_CHARS " \t\n"
23 #define VPARSE_DEFAULT_QUOTING_CHARS "\""
24 #define VPARSE_DEFAULT_ESCAPING_CHARS "\\"
25 #define VPARSE_DEFAULT_COMMENT_CHARS "#"
26 
27 /*
28  * vparse_stream()
29  *
30  * Parse the given stream using the given options and line parsing function.
31  * options may be NULL indicating that defaults should be used.
32  * The line parsing function will be called with the given argument
33  * (line_parse_arg), the current line number, and a array of strings
34  * holding all the tokens on the line. The function should return -1
35  * if it wishes parsing to discontinue, 0 otherwise.
36  *
37  * Return -1 on a read error, 0 otherwise.
38  */
39 int
40 vparse_stream(FILE *stream,
41  const struct vparse_options *options,
42  int (*line_parse)(void *arg,
43  int line_number,
44  const char **tokens),
45  void *line_parse_arg);
46 
47 #endif /* !__VPARSE_H */