diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/libbb.h | 51 |
1 files changed, 47 insertions, 4 deletions
diff --git a/include/libbb.h b/include/libbb.h index 1f5b211c1..9313a557a 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -353,6 +353,8 @@ extern int *const bb_errno; | |||
353 | uint64_t bb_bswap_64(uint64_t x) FAST_FUNC; | 353 | uint64_t bb_bswap_64(uint64_t x) FAST_FUNC; |
354 | #endif | 354 | #endif |
355 | 355 | ||
356 | unsigned long FAST_FUNC isqrt(unsigned long long N); | ||
357 | |||
356 | unsigned long long monotonic_ns(void) FAST_FUNC; | 358 | unsigned long long monotonic_ns(void) FAST_FUNC; |
357 | unsigned long long monotonic_us(void) FAST_FUNC; | 359 | unsigned long long monotonic_us(void) FAST_FUNC; |
358 | unsigned long long monotonic_ms(void) FAST_FUNC; | 360 | unsigned long long monotonic_ms(void) FAST_FUNC; |
@@ -1193,6 +1195,26 @@ extern const char *applet_long_options; | |||
1193 | #endif | 1195 | #endif |
1194 | extern uint32_t option_mask32; | 1196 | extern uint32_t option_mask32; |
1195 | extern uint32_t getopt32(char **argv, const char *applet_opts, ...) FAST_FUNC; | 1197 | extern uint32_t getopt32(char **argv, const char *applet_opts, ...) FAST_FUNC; |
1198 | /* BSD-derived getopt() functions require that optind be set to 1 in | ||
1199 | * order to reset getopt() state. This used to be generally accepted | ||
1200 | * way of resetting getopt(). However, glibc's getopt() | ||
1201 | * has additional getopt() state beyond optind (specifically, glibc | ||
1202 | * extensions such as '+' and '-' at the start of the string), and requires | ||
1203 | * that optind be set to zero to reset its state. BSD-derived versions | ||
1204 | * of getopt() misbehaved if optind is set to 0 in order to reset getopt(), | ||
1205 | * and glibc's getopt() used to coredump if optind is set 1 in order | ||
1206 | * to reset getopt(). | ||
1207 | * Then BSD introduced additional variable "optreset" which should be | ||
1208 | * set to 1 in order to reset getopt(). Sigh. Standards, anyone? | ||
1209 | * | ||
1210 | * By ~2008, OpenBSD 3.4 was changed to survive glibc-like optind = 0 | ||
1211 | * (to interpret it as if optreset was set). | ||
1212 | */ | ||
1213 | #if defined(__GLIBC__) || ENABLE_PLATFORM_MINGW32 | ||
1214 | #define GETOPT_RESET() (optind = 0) | ||
1215 | #else /* BSD style */ | ||
1216 | #define GETOPT_RESET() (optind = 1) | ||
1217 | #endif | ||
1196 | 1218 | ||
1197 | 1219 | ||
1198 | /* Having next pointer as a first member allows easy creation | 1220 | /* Having next pointer as a first member allows easy creation |
@@ -1264,7 +1286,7 @@ extern void bb_logenv_override(void) FAST_FUNC; | |||
1264 | 1286 | ||
1265 | 1287 | ||
1266 | /* Applets which are useful from another applets */ | 1288 | /* Applets which are useful from another applets */ |
1267 | int bb_cat(char** argv); | 1289 | int bb_cat(char** argv) FAST_FUNC; |
1268 | /* If shell needs them, they exist even if not enabled as applets */ | 1290 | /* If shell needs them, they exist even if not enabled as applets */ |
1269 | int echo_main(int argc, char** argv) IF_ECHO(MAIN_EXTERNALLY_VISIBLE); | 1291 | int echo_main(int argc, char** argv) IF_ECHO(MAIN_EXTERNALLY_VISIBLE); |
1270 | int printf_main(int argc, char **argv) IF_PRINTF(MAIN_EXTERNALLY_VISIBLE); | 1292 | int printf_main(int argc, char **argv) IF_PRINTF(MAIN_EXTERNALLY_VISIBLE); |
@@ -1290,6 +1312,16 @@ int bunzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | |||
1290 | void bb_displayroutes(int noresolve, int netstatfmt) FAST_FUNC; | 1312 | void bb_displayroutes(int noresolve, int netstatfmt) FAST_FUNC; |
1291 | #endif | 1313 | #endif |
1292 | 1314 | ||
1315 | struct number_state { | ||
1316 | unsigned width; | ||
1317 | unsigned start; | ||
1318 | unsigned inc; | ||
1319 | const char *sep; | ||
1320 | const char *empty_str; | ||
1321 | smallint all, nonempty; | ||
1322 | }; | ||
1323 | void print_numbered_lines(struct number_state *ns, const char *filename) FAST_FUNC; | ||
1324 | |||
1293 | 1325 | ||
1294 | /* Networking */ | 1326 | /* Networking */ |
1295 | /* This structure defines protocol families and their handlers. */ | 1327 | /* This structure defines protocol families and their handlers. */ |
@@ -1348,10 +1380,15 @@ extern int get_linux_version_code(void) FAST_FUNC; | |||
1348 | 1380 | ||
1349 | extern char *query_loop(const char *device) FAST_FUNC; | 1381 | extern char *query_loop(const char *device) FAST_FUNC; |
1350 | extern int del_loop(const char *device) FAST_FUNC; | 1382 | extern int del_loop(const char *device) FAST_FUNC; |
1351 | /* If *devname is not NULL, use that name, otherwise try to find free one, | 1383 | /* |
1384 | * If *devname is not NULL, use that name, otherwise try to find free one, | ||
1352 | * malloc and return it in *devname. | 1385 | * malloc and return it in *devname. |
1353 | * return value: 1: read-only loopdev was setup, 0: rw, < 0: error */ | 1386 | * return value is the opened fd to the loop device, or < on error |
1354 | extern int set_loop(char **devname, const char *file, unsigned long long offset, int ro) FAST_FUNC; | 1387 | */ |
1388 | extern int set_loop(char **devname, const char *file, unsigned long long offset, unsigned flags) FAST_FUNC; | ||
1389 | /* These constants match linux/loop.h (without BB_ prefix): */ | ||
1390 | #define BB_LO_FLAGS_READ_ONLY 1 | ||
1391 | #define BB_LO_FLAGS_AUTOCLEAR 4 | ||
1355 | 1392 | ||
1356 | /* Like bb_ask below, but asks on stdin with no timeout. */ | 1393 | /* Like bb_ask below, but asks on stdin with no timeout. */ |
1357 | char *bb_ask_stdin(const char * prompt) FAST_FUNC; | 1394 | char *bb_ask_stdin(const char * prompt) FAST_FUNC; |
@@ -1463,6 +1500,12 @@ extern void selinux_or_die(void) FAST_FUNC; | |||
1463 | #define SETUP_ENV_NO_CHDIR (1 << 4) | 1500 | #define SETUP_ENV_NO_CHDIR (1 << 4) |
1464 | void setup_environment(const char *shell, int flags, const struct passwd *pw) FAST_FUNC; | 1501 | void setup_environment(const char *shell, int flags, const struct passwd *pw) FAST_FUNC; |
1465 | void nuke_str(char *str) FAST_FUNC; | 1502 | void nuke_str(char *str) FAST_FUNC; |
1503 | #if ENABLE_FEATURE_SECURETTY && !ENABLE_PAM | ||
1504 | int is_tty_secure(const char *short_tty) FAST_FUNC; | ||
1505 | #else | ||
1506 | static ALWAYS_INLINE int is_tty_secure(const char *short_tty UNUSED_PARAM) { return 1; } | ||
1507 | #endif | ||
1508 | #define CHECKPASS_PW_HAS_EMPTY_PASSWORD 2 | ||
1466 | int check_password(const struct passwd *pw, const char *plaintext) FAST_FUNC; | 1509 | int check_password(const struct passwd *pw, const char *plaintext) FAST_FUNC; |
1467 | int ask_and_check_password_extended(const struct passwd *pw, int timeout, const char *prompt) FAST_FUNC; | 1510 | int ask_and_check_password_extended(const struct passwd *pw, int timeout, const char *prompt) FAST_FUNC; |
1468 | int ask_and_check_password(const struct passwd *pw) FAST_FUNC; | 1511 | int ask_and_check_password(const struct passwd *pw) FAST_FUNC; |