hush: handle LINENO the same way as RANDOM: variable is "ephemeral"
[oweals/busybox.git] / include / libbb.h
index affff58748629b0d6adfb4b49e56035130ee866f..57cfce385336efafb6b089a47c6850ece2d2c110 100644 (file)
@@ -544,6 +544,8 @@ void sig_unblock(int sig) FAST_FUNC;
 int sigaction_set(int sig, const struct sigaction *act) FAST_FUNC;
 /* SIG_BLOCK/SIG_UNBLOCK all signals: */
 int sigprocmask_allsigs(int how) FAST_FUNC;
+/* Return old set in the same set: */
+int sigprocmask2(int how, sigset_t *set) FAST_FUNC;
 /* Standard handler which just records signo */
 extern smallint bb_got_signal;
 void record_signo(int signo); /* not FAST_FUNC! */
@@ -736,18 +738,25 @@ struct hostent *xgethostbyname(const char *name) FAST_FUNC;
 // + inet_common.c has additional IPv4-only stuff
 
 
+struct tls_aes {
+       uint32_t key[60];
+       unsigned rounds;
+};
 #define TLS_MAX_MAC_SIZE 32
 #define TLS_MAX_KEY_SIZE 32
+#define TLS_MAX_IV_SIZE   4
 struct tls_handshake_data; /* opaque */
 typedef struct tls_state {
+       unsigned flags;
+
        int ofd;
        int ifd;
 
        unsigned min_encrypted_len_on_read;
        uint16_t cipher_id;
-       uint8_t  encrypt_on_write;
        unsigned MAC_size;
        unsigned key_size;
+       unsigned IV_size;
 
        uint8_t *outbuf;
        int     outbuf_size;
@@ -769,12 +778,21 @@ typedef struct tls_state {
        /*uint64_t read_seq64_be;*/
        uint64_t write_seq64_be;
 
+       /*uint8_t *server_write_MAC_key;*/
        uint8_t *client_write_key;
        uint8_t *server_write_key;
+       uint8_t *client_write_IV;
+       uint8_t *server_write_IV;
        uint8_t client_write_MAC_key[TLS_MAX_MAC_SIZE];
        uint8_t server_write_MAC_k__[TLS_MAX_MAC_SIZE];
        uint8_t client_write_k__[TLS_MAX_KEY_SIZE];
        uint8_t server_write_k__[TLS_MAX_KEY_SIZE];
+       uint8_t client_write_I_[TLS_MAX_IV_SIZE];
+       uint8_t server_write_I_[TLS_MAX_IV_SIZE];
+
+       struct tls_aes aes_encrypt;
+       struct tls_aes aes_decrypt;
+       uint8_t H[16]; //used by AES_GCM
 } tls_state_t;
 
 static inline tls_state_t *new_tls_state(void)
@@ -1022,9 +1040,11 @@ uint16_t xatou16(const char *numstr) FAST_FUNC;
 #if ENABLE_FLOAT_DURATION
 typedef double duration_t;
 void sleep_for_duration(duration_t duration) FAST_FUNC;
+#define DURATION_FMT "f"
 #else
 typedef unsigned duration_t;
 #define sleep_for_duration(duration) sleep(duration)
+#define DURATION_FMT "u"
 #endif
 duration_t parse_duration_str(char *str) FAST_FUNC;
 
@@ -1183,11 +1203,11 @@ void set_task_comm(const char *comm) FAST_FUNC;
  * to /dev/null if they are not.
  */
 enum {
-       DAEMON_CHDIR_ROOT = 1,
-       DAEMON_DEVNULL_STDIO = 2,
-       DAEMON_CLOSE_EXTRA_FDS = 4,
-       DAEMON_ONLY_SANITIZE = 8, /* internal use */
-       DAEMON_DOUBLE_FORK = 16, /* double fork to avoid controlling tty */
+       DAEMON_CHDIR_ROOT      = 1 << 0,
+       DAEMON_DEVNULL_STDIO   = 1 << 1,
+       DAEMON_CLOSE_EXTRA_FDS = 1 << 2,
+       DAEMON_ONLY_SANITIZE   = 1 << 3, /* internal use */
+       //DAEMON_DOUBLE_FORK     = 1 << 4, /* double fork to avoid controlling tty */
 };
 #if BB_MMU
   enum { re_execed = 0 };
@@ -1278,9 +1298,13 @@ llist_t *llist_find_str(llist_t *first, const char *str) FAST_FUNC;
 /* True only if we created pidfile which is *file*, not /dev/null etc */
 extern smallint wrote_pidfile;
 void write_pidfile(const char *path) FAST_FUNC;
+void write_pidfile_std_path_and_ext(const char *path) FAST_FUNC;
+void remove_pidfile_std_path_and_ext(const char *path) FAST_FUNC;
 #define remove_pidfile(path) do { if (wrote_pidfile) unlink(path); } while (0)
 #else
 enum { wrote_pidfile = 0 };
+#define write_pidfile_std_path_and_ext(path)  ((void)0)
+#define remove_pidfile_std_path_and_ext(path) ((void)0)
 #define write_pidfile(path)  ((void)0)
 #define remove_pidfile(path) ((void)0)
 #endif
@@ -1292,7 +1316,6 @@ enum {
        LOGMODE_BOTH = LOGMODE_SYSLOG + LOGMODE_STDIO,
 };
 extern const char *msg_eol;
-extern smallint syslog_level;
 extern smallint logmode;
 extern uint8_t xfunc_error_retval;
 extern void (*die_func)(void);
@@ -1312,6 +1335,14 @@ void bb_verror_msg(const char *s, va_list p, const char *strerr) FAST_FUNC;
 void bb_die_memory_exhausted(void) NORETURN FAST_FUNC;
 void bb_logenv_override(void) FAST_FUNC;
 
+#if ENABLE_FEATURE_SYSLOG_INFO
+void bb_info_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))) FAST_FUNC;
+void bb_vinfo_msg(const char *s, va_list p) FAST_FUNC;
+#else
+#define bb_info_msg bb_error_msg
+#define bb_vinfo_msg(s,p) bb_verror_msg(s,p,NULL)
+#endif
+
 /* We need to export XXX_main from libbusybox
  * only if we build "individual" binaries
  */
@@ -1322,8 +1353,8 @@ void bb_logenv_override(void) FAST_FUNC;
 #endif
 
 /* Embedded script support */
-//int find_script_by_name(const char *arg IF_FEATURE_SH_STANDALONE(, int offset)) FAST_FUNC;
 char *get_script_content(unsigned n) FAST_FUNC;
+int scripted_main(int argc, char** argv) MAIN_EXTERNALLY_VISIBLE;
 
 /* Applets which are useful from another applets */
 int bb_cat(char** argv) FAST_FUNC;
@@ -1332,6 +1363,11 @@ int ash_main(int argc, char** argv)
                MAIN_EXTERNALLY_VISIBLE
 #endif
 ;
+int hush_main(int argc, char** argv)
+#if ENABLE_HUSH || ENABLE_SH_IS_HUSH || ENABLE_BASH_IS_HUSH
+               MAIN_EXTERNALLY_VISIBLE
+#endif
+;
 /* If shell needs them, they exist even if not enabled as applets */
 int echo_main(int argc, char** argv) IF_ECHO(MAIN_EXTERNALLY_VISIBLE);
 int printf_main(int argc, char **argv) IF_PRINTF(MAIN_EXTERNALLY_VISIBLE);
@@ -1365,7 +1401,7 @@ struct number_state {
        const char *empty_str;
        smallint all, nonempty;
 };
-void print_numbered_lines(struct number_state *ns, const char *filename) FAST_FUNC;
+int print_numbered_lines(struct number_state *ns, const char *filename) FAST_FUNC;
 
 
 /* Networking */
@@ -1765,7 +1801,7 @@ enum {
        FOR_SHELL        = DO_HISTORY | TAB_COMPLETION | USERNAME_COMPLETION,
 };
 line_input_t *new_line_input_t(int flags) FAST_FUNC;
-/* So far static: void free_line_input_t(line_input_t *n) FAST_FUNC; */
+void free_line_input_t(line_input_t *n) FAST_FUNC;
 /*
  * maxsize must be >= 2.
  * Returns:
@@ -1805,7 +1841,12 @@ struct smaprec {
        unsigned long stack;
        unsigned long smap_pss, smap_swap;
        unsigned long smap_size;
-       unsigned long smap_start;
+       // For mixed 32/64 userspace, 32-bit pmap still needs
+       // 64-bit field here to correctly show 64-bit processes:
+       unsigned long long smap_start;
+       // (strictly speaking, other fields need to be wider too,
+       // but they are in kbytes, not bytes, and they hold sizes,
+       // not start addresses, sizes tend to be less than 4 terabytes)
        char smap_mode[5];
        char *smap_name;
 };
@@ -1990,7 +2031,7 @@ typedef struct bb_progress_t {
        (p)->curfile = NULL; \
 } while (0)
 void bb_progress_init(bb_progress_t *p, const char *curfile) FAST_FUNC;
-void bb_progress_update(bb_progress_t *p,
+int bb_progress_update(bb_progress_t *p,
                        uoff_t beg_range,
                        uoff_t transferred,
                        uoff_t totalsize) FAST_FUNC;