aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-07-21 23:05:26 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-07-21 23:05:26 +0000
commit5415c856eaccd1bc5d064022770a288f43b2e94f (patch)
tree5973db4e6f81b5e311e8944700ded5db1083d440 /include
parentb74a2dba571d1c5a6127c683fb50923336d9c59f (diff)
downloadbusybox-5415c856eaccd1bc5d064022770a288f43b2e94f.tar.gz
libbb: [x]fopen_for_{read,write} introduced and used.
(by Valdimir) function old new delta config_open2 - 41 +41 config_read 507 542 +35 find_pair 169 187 +18 fopen_for_write - 14 +14 fopen_for_read - 14 +14 find_main 406 418 +12 xfopen_for_write - 10 +10 xfopen_for_read - 10 +10 popstring 134 140 +6 parse_inittab 396 401 +5 next_token 923 928 +5 pack_gzip 1659 1661 +2 bb__parsespent 117 119 +2 fallbackSort 1719 1717 -2 evalvar 1376 1374 -2 qrealloc 36 33 -3 ... ... ... ... singlemount 4579 4569 -10 process_stdin 443 433 -10 patch_main 1111 1101 -10 ifupdown_main 2175 2165 -10 file_action_grep 90 80 -10 uuidcache_init 649 637 -12 hush_main 797 785 -12 read_config 230 217 -13 dpkg_main 3835 3820 -15 read_line_input 3134 3110 -24 sysctl_main 232 203 -29 config_open 40 10 -30 WARN_BAD_LINE 44 - -44 login_main 1714 1575 -139 ------------------------------------------------------------------------------ (add/remove: 5/1 grow/shrink: 8/74 up/down: 174/-737) Total: -563 bytes
Diffstat (limited to 'include')
-rw-r--r--include/libbb.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 4b2a839a5..684e130c9 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -631,6 +631,10 @@ extern FILE *fopen_or_warn(const char *filename, const char *mode) FAST_FUNC;
/* "Opens" stdin if filename is special, else just opens file: */
extern FILE *xfopen_stdin(const char *filename) FAST_FUNC;
extern FILE *fopen_or_warn_stdin(const char *filename) FAST_FUNC;
+extern FILE* fopen_for_read(const char *path) FAST_FUNC;
+extern FILE* xfopen_for_read(const char *path) FAST_FUNC;
+extern FILE* fopen_for_write(const char *path) FAST_FUNC;
+extern FILE* xfopen_for_write(const char *path) FAST_FUNC;
int bb_pstrcmp(const void *a, const void *b) /* not FAST_FUNC! */;
void qsort_string_vector(char **sv, unsigned count) FAST_FUNC;
@@ -993,10 +997,12 @@ int bb_parse_mode(const char* s, mode_t* theMode) FAST_FUNC;
* Config file parser
*/
enum {
+ PARSE_VANILLA = 0x00000000, // trim line, collapse delimiters, warn and continue if less than mintokens
PARSE_DONT_REDUCE = 0x00010000, // do not treat consecutive delimiters as one
PARSE_DONT_TRIM = 0x00020000, // do not trim line of leading and trailing delimiters
PARSE_LAST_IS_GREEDY = 0x00040000, // last token takes whole remainder of the line
// PARSE_DONT_NULL = 0x00080000, // do not set tokens[] to NULL
+ PARSE_MIN_DIE = 0x00100000, // die if less tokens found
// keep a copy of current line
PARSE_KEEP_COPY = 0x00200000 * ENABLE_DEBUG_CROND_OPTION,
};
@@ -1007,6 +1013,7 @@ typedef struct parser_t {
int lineno;
} parser_t;
parser_t* config_open(const char *filename) FAST_FUNC;
+parser_t* config_open2(const char *filename, FILE* FAST_FUNC (*fopen_func)(const char *path)) 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)