int bb_parse_mode(const char* s, mode_t* theMode) FAST_FUNC;
/*
- * Uniform config file parser helpers
+ * Config file parser
*/
+enum {
+ 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
+ // keep a copy of current line
+ PARSE_KEEP_COPY = 0x00200000 * ENABLE_DEBUG_CROND_OPTION,
+};
typedef struct parser_t {
FILE *fp;
- char *line, *data;
+ char *line;
+ char *data;
int lineno;
} parser_t;
-FILE* config_open(parser_t *parser, 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;
+parser_t* config_open(const char *filename) 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.
uint8_t shift_pages_to_bytes;
uint8_t shift_pages_to_kb;
/* Fields are set to 0/NULL if failed to determine (or not requested) */
+ uint16_t argv_len;
char *argv0;
USE_SELINUX(char *context;)
/* Everything below must contain no ptrs to malloc'ed data:
PSSCAN_UTIME = 1 << 13,
PSSCAN_TTY = 1 << 14,
PSSCAN_SMAPS = (1 << 15) * ENABLE_FEATURE_TOPMEM,
- PSSCAN_ARGVN = (1 << 16) * (ENABLE_PGREP | ENABLE_PKILL),
+ PSSCAN_ARGVN = (1 << 16) * (ENABLE_PGREP || ENABLE_PKILL || ENABLE_PIDOF),
USE_SELINUX(PSSCAN_CONTEXT = 1 << 17,)
PSSCAN_START_TIME = 1 << 18,
/* These are all retrieved from proc/NN/stat in one go: */