diff options
Diffstat (limited to 'include/libbb.h')
-rw-r--r-- | include/libbb.h | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/include/libbb.h b/include/libbb.h index ac5722c89..363fe53df 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -173,6 +173,30 @@ int sysinfo(struct sysinfo* info); | |||
173 | # include "mingw.h" | 173 | # include "mingw.h" |
174 | #endif | 174 | #endif |
175 | 175 | ||
176 | /* Busybox does not use threads, we can speed up stdio. */ | ||
177 | #ifdef HAVE_UNLOCKED_STDIO | ||
178 | # undef getc | ||
179 | # define getc(stream) getc_unlocked(stream) | ||
180 | # undef getchar | ||
181 | # define getchar() getchar_unlocked() | ||
182 | # undef putc | ||
183 | # define putc(c, stream) putc_unlocked(c, stream) | ||
184 | # undef putchar | ||
185 | # define putchar(c) putchar_unlocked(c) | ||
186 | # undef fgetc | ||
187 | # define fgetc(stream) getc_unlocked(stream) | ||
188 | # undef fputc | ||
189 | # define fputc(c, stream) putc_unlocked(c, stream) | ||
190 | #endif | ||
191 | /* Above functions are required by POSIX.1-2008, below ones are extensions */ | ||
192 | #ifdef HAVE_UNLOCKED_LINE_OPS | ||
193 | # undef fgets | ||
194 | # define fgets(s, n, stream) fgets_unlocked(s, n, stream) | ||
195 | # undef fputs | ||
196 | # define fputs(s, stream) fputs_unlocked(s, stream) | ||
197 | #endif | ||
198 | |||
199 | |||
176 | /* Make all declarations hidden (-fvisibility flag only affects definitions) */ | 200 | /* Make all declarations hidden (-fvisibility flag only affects definitions) */ |
177 | /* (don't include system headers after this until corresponding pop!) */ | 201 | /* (don't include system headers after this until corresponding pop!) */ |
178 | PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN | 202 | PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN |
@@ -743,8 +767,12 @@ extern void xclose(int fd) FAST_FUNC; | |||
743 | /* Reads and prints to stdout till eof, then closes FILE. Exits on error: */ | 767 | /* Reads and prints to stdout till eof, then closes FILE. Exits on error: */ |
744 | extern void xprint_and_close_file(FILE *file) FAST_FUNC; | 768 | extern void xprint_and_close_file(FILE *file) FAST_FUNC; |
745 | 769 | ||
770 | /* Reads a line from a text file, up to a newline or NUL byte, inclusive. | ||
771 | * Returns malloc'ed char*. If end is NULL '\n' isn't considered | ||
772 | * end of line. If end isn't NULL, length of the chunk is stored in it. | ||
773 | * Returns NULL if EOF/error. | ||
774 | */ | ||
746 | extern char *bb_get_chunk_from_file(FILE *file, int *end) FAST_FUNC; | 775 | extern char *bb_get_chunk_from_file(FILE *file, int *end) FAST_FUNC; |
747 | extern char *bb_get_chunk_with_continuation(FILE *file, int *end, int *lineno) FAST_FUNC; | ||
748 | /* Reads up to (and including) TERMINATING_STRING: */ | 776 | /* Reads up to (and including) TERMINATING_STRING: */ |
749 | extern char *xmalloc_fgets_str(FILE *file, const char *terminating_string) FAST_FUNC RETURNS_MALLOC; | 777 | extern char *xmalloc_fgets_str(FILE *file, const char *terminating_string) FAST_FUNC RETURNS_MALLOC; |
750 | /* Same, with limited max size, and returns the length (excluding NUL): */ | 778 | /* Same, with limited max size, and returns the length (excluding NUL): */ |
@@ -1196,8 +1224,9 @@ enum { | |||
1196 | }; | 1224 | }; |
1197 | typedef struct parser_t { | 1225 | typedef struct parser_t { |
1198 | FILE *fp; | 1226 | FILE *fp; |
1199 | char *line; | ||
1200 | char *data; | 1227 | char *data; |
1228 | char *line, *nline; | ||
1229 | size_t line_alloc, nline_alloc; | ||
1201 | int lineno; | 1230 | int lineno; |
1202 | } parser_t; | 1231 | } parser_t; |
1203 | parser_t* config_open(const char *filename) FAST_FUNC; | 1232 | parser_t* config_open(const char *filename) FAST_FUNC; |
@@ -1560,13 +1589,6 @@ enum { | |||
1560 | PSSCAN_NICE = (1 << 20) * ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS, | 1589 | PSSCAN_NICE = (1 << 20) * ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS, |
1561 | PSSCAN_RUIDGID = (1 << 21) * ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS, | 1590 | PSSCAN_RUIDGID = (1 << 21) * ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS, |
1562 | PSSCAN_TASKS = (1 << 22) * ENABLE_FEATURE_SHOW_THREADS, | 1591 | PSSCAN_TASKS = (1 << 22) * ENABLE_FEATURE_SHOW_THREADS, |
1563 | /* These are all retrieved from proc/NN/stat in one go: */ | ||
1564 | PSSCAN_STAT = PSSCAN_PPID | PSSCAN_PGID | PSSCAN_SID | ||
1565 | /**/ | PSSCAN_COMM | PSSCAN_STATE | ||
1566 | /**/ | PSSCAN_VSZ | PSSCAN_RSS | ||
1567 | /**/ | PSSCAN_STIME | PSSCAN_UTIME | PSSCAN_START_TIME | ||
1568 | /**/ | PSSCAN_TTY | PSSCAN_NICE | ||
1569 | /**/ | PSSCAN_CPU | ||
1570 | }; | 1592 | }; |
1571 | //procps_status_t* alloc_procps_scan(void) FAST_FUNC; | 1593 | //procps_status_t* alloc_procps_scan(void) FAST_FUNC; |
1572 | void free_procps_scan(procps_status_t* sp) FAST_FUNC; | 1594 | void free_procps_scan(procps_status_t* sp) FAST_FUNC; |