123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- #ifndef __INTERNAL_PARSE_CONFIG_H
- #define __INTERNAL_PARSE_CONFIG_H
- #include <stdio.h>
- #ifndef FAST_FUNC
- # define FAST_FUNC
- #endif
- enum {
- PARSE_COLLAPSE = 0x00010000,
- PARSE_TRIM = 0x00020000,
- PARSE_GREEDY = 0x00040000,
- PARSE_MIN_DIE = 0x00100000,
-
- PARSE_KEEP_COPY = 0x00200000 * 0,
-
-
- PARSE_NORMAL = PARSE_COLLAPSE | PARSE_TRIM | PARSE_GREEDY,
- };
- typedef struct parser_t {
- FILE *fp;
- char *data;
- size_t data_len;
- char *line;
- size_t line_len;
- smalluint allocated;
- } parser_t;
- parser_t* config_open(const char *filename) FAST_FUNC attribute_hidden;
- libc_hidden_proto(config_open)
- int config_read(parser_t *parser, char ***tokens, unsigned flags, const char *delims) FAST_FUNC attribute_hidden;
- libc_hidden_proto(config_read)
- #define config_read(parser, tokens, max, min, str, flags) \
- config_read(parser, tokens, ((flags) | (((min) & 0xFF) << 8) | ((max) & 0xFF)), str)
- void config_close(parser_t *parser) FAST_FUNC attribute_hidden;
- libc_hidden_proto(config_close)
- #endif
|