diff options
author | Denis Vlasenko | 2008-07-19 09:27:19 +0000 |
---|---|---|
committer | Denis Vlasenko | 2008-07-19 09:27:19 +0000 |
commit | 2e157ddf9ecd9d58864425f0e87409ddc218df94 (patch) | |
tree | 18f415d4847897a12d790b545f94c32ae68c199c /include | |
parent | bd28f6bf7f53ede8df39112d40cb52f2a3d00177 (diff) | |
download | busybox-2e157ddf9ecd9d58864425f0e87409ddc218df94.zip busybox-2e157ddf9ecd9d58864425f0e87409ddc218df94.tar.gz |
libbb: updated config_parse() from Vladimir
function old new delta
config_read 385 460 +75
runsvdir_main 1701 1716 +15
readit 331 338 +7
passwd_main 1049 1053 +4
parse_command 1504 1507 +3
decode_format_string 822 824 +2
bb__parsespent 117 119 +2
udhcp_get_option 221 222 +1
changepath 196 194 -2
parse_inittab 400 396 -4
nameif_main 683 679 -4
make_device 1176 1172 -4
config_open 48 40 -8
expand_main 698 689 -9
readcmd 1012 1002 -10
config_free_data 37 21 -16
SynchronizeFile 683 643 -40
sleep_main 474 362 -112
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 8/10 up/down: 109/-209) Total: -100 bytes
Diffstat (limited to 'include')
-rw-r--r-- | include/applets.h | 1 | ||||
-rw-r--r-- | include/libbb.h | 14 | ||||
-rw-r--r-- | include/usage.h | 5 |
3 files changed, 16 insertions, 4 deletions
diff --git a/include/applets.h b/include/applets.h index aff9070..5dd485a 100644 --- a/include/applets.h +++ b/include/applets.h @@ -268,6 +268,7 @@ USE_NOHUP(APPLET(nohup, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_NSLOOKUP(APPLET(nslookup, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_OD(APPLET(od, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_OPENVT(APPLET(openvt, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) +USE_PARSE(APPLET(parse, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_PASSWD(APPLET(passwd, _BB_DIR_USR_BIN, _BB_SUID_ALWAYS)) USE_PATCH(APPLET(patch, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_PGREP(APPLET(pgrep, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) diff --git a/include/libbb.h b/include/libbb.h index 14af136..af6c138 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -988,16 +988,22 @@ int bb_ask_confirmation(void) FAST_FUNC; int bb_parse_mode(const char* s, mode_t* theMode) FAST_FUNC; /* - * Uniform config file parser helpers + * Config file parser */ +#define PARSE_DONT_REDUCE 0x00010000 // do not treat consecutive delimiters as one +#define PARSE_DONT_TRIM 0x00020000 // do not trim line of leading and trailing delimiters +#define PARSE_LAST_IS_GREEDY 0x00040000 // last token takes whole remainder of the line +//#define PARSE_DONT_NULL 0x00080000 // do not set tokens[] to NULL typedef struct parser_t { FILE *fp; - char *line, *data; + char *line; + USE_FEATURE_PARSE_COPY(char *data;) int lineno; } parser_t; parser_t* config_open(const char *filename) FAST_FUNC; -/* TODO: add define magic to collapse ntokens/mintokens/comment into one int param */ -int config_read(parser_t *parser, char **tokens, int ntokens, int mintokens, const char *delims, char comment) FAST_FUNC; +int config_read(parser_t *parser, char **tokens, unsigned flags, const char *delims) FAST_FUNC; +#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; /* Concatenate path and filename to new allocated buffer. diff --git a/include/usage.h b/include/usage.h index f9a993a..61c5c8e 100644 --- a/include/usage.h +++ b/include/usage.h @@ -2903,6 +2903,11 @@ #define openvt_example_usage \ "openvt 2 /bin/ash\n" +#define parse_trivial_usage \ + "[-n maxtokens] [-m mintokens] [-d delims] [-f flags] file ..." +#define parse_full_usage "\n\n" \ + "[-n maxtokens] [-m mintokens] [-d delims] [-f flags] file ..." + #define passwd_trivial_usage \ "[OPTION] [name]" #define passwd_full_usage "\n\n" \ |