#include <features.h>
#include "config.h"
+#ifdef CONFIG_SELINUX
+#include <proc_secure.h>
+#endif
#include "pwd_.h"
#include "grp_.h"
# define inline
#endif
-#if (__GNU_LIBRARY__ < 5) && (!defined __dietlibc__)
-/* libc5 doesn't define socklen_t */
-#ifndef _SOCKLEN_T
-#define _SOCKLEN_T
-typedef unsigned int socklen_t;
+/* Convenience macros to test the version of gcc. */
+#if defined __GNUC__ && defined __GNUC_MINOR__
+# define __GNUC_PREREQ(maj, min) \
+ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
+#else
+# define __GNUC_PREREQ(maj, min) 0
+#endif
+
+/* __restrict is known in EGCS 1.2 and above. */
+#if !__GNUC_PREREQ (2,92)
+# define __restrict /* Ignore */
#endif
-/* libc5 doesn't implement BSD 4.4 daemon() */
-extern int daemon (int nochdir, int noclose);
-/* libc5 doesn't implement strtok_r */
-char *strtok_r(char *s, const char *delim, char **ptrptr);
-#endif
/* Some useful definitions */
#define FALSE ((int) 0)
void* userData);
extern int bb_parse_mode( const char* s, mode_t* theMode);
-extern long bb_xgetlarg(char *arg, int base, long lower, long upper);
+extern long bb_xgetlarg(const char *arg, int base, long lower, long upper);
extern unsigned long bb_baud_to_value(speed_t speed);
extern speed_t bb_value_to_baud(unsigned long value);
//#warning rename?
extern int bb_fclose_nonstdin(FILE *f);
extern void bb_fflush_stdout_and_exit(int retval) __attribute__ ((noreturn));
-extern unsigned long bb_getopt_ulflags(int argc, char **argv, const char *applet_opts);
+
+extern const char *bb_opt_complementaly;
+extern const struct option *bb_applet_long_options;
+extern unsigned long bb_getopt_ulflags(int argc, char **argv, const char *applet_opts, ...);
+
//#warning rename?
extern FILE *bb_wfopen_input(const char *filename);
extern void *xmalloc (size_t size);
extern void *xrealloc(void *old, size_t size);
extern void *xcalloc(size_t nmemb, size_t size);
-extern char *bb_xstrdup (const char *s);
#endif
+extern char *bb_xstrdup (const char *s);
extern char *bb_xstrndup (const char *s, int n);
extern char * safe_strncpy(char *dst, const char *src, size_t size);
char *xgetcwd(char *cwd);
char *xreadlink(const char *path);
char *concat_path_file(const char *path, const char *filename);
+char *concat_subpath_file(const char *path, const char *filename);
char *last_char_is(const char *s, int c);
extern long arith (const char *startbuf, int *errcode);
# define VC_3 "/dev/vc/3"
# define VC_4 "/dev/vc/4"
# define VC_5 "/dev/vc/5"
-# define SC_0 "/dev/tts/0"
-# define SC_1 "/dev/tts/1"
+#if defined(__sh__) || defined(__H8300H__) || defined(__H8300S__)
+/* Yes, this sucks, but both SH (including sh64) and H8 have a SCI(F) for their
+ respective serial ports .. as such, we can't use the common device paths for
+ these. -- PFM */
+# define SC_0 "/dev/ttsc/0"
+# define SC_1 "/dev/ttsc/1"
+# define SC_FORMAT "/dev/ttsc/%d"
+#else
+# define SC_0 "/dev/tts/0"
+# define SC_1 "/dev/tts/1"
+# define SC_FORMAT "/dev/tts/%d"
+#endif
# define VC_FORMAT "/dev/vc/%d"
-# define SC_FORMAT "/dev/tts/%d"
# define LOOP_FORMAT "/dev/loop/%d"
#else
# define CURRENT_VC "/dev/tty0"
# define VC_3 "/dev/tty3"
# define VC_4 "/dev/tty4"
# define VC_5 "/dev/tty5"
-# define SC_0 "/dev/ttyS0"
-# define SC_1 "/dev/ttyS1"
+#if defined(__sh__) || defined(__H8300H__) || defined(__H8300S__)
+# define SC_0 "/dev/ttySC0"
+# define SC_1 "/dev/ttySC1"
+# define SC_FORMAT "/dev/ttySC%d"
+#else
+# define SC_0 "/dev/ttyS0"
+# define SC_1 "/dev/ttyS1"
+# define SC_FORMAT "/dev/ttyS%d"
+#endif
# define VC_FORMAT "/dev/tty%d"
-# define SC_FORMAT "/dev/ttyS%d"
# define LOOP_FORMAT "/dev/loop%d"
#endif
#define FAIL_DELAY 3
extern void change_identity ( const struct passwd *pw );
-extern void run_shell ( const char *shell, int loginshell, const char *command, const char **additional_args );
+extern void run_shell ( const char *shell, int loginshell, const char *command, const char **additional_args
+#ifdef CONFIG_SELINUX
+ , security_id_t sid
+#endif
+);
extern int run_parts(char **args, const unsigned char test_mode);
extern int restricted_shell ( const char *shell );
extern void setup_environment ( const char *shell, int loginshell, int changeenv, const struct passwd *pw );
char short_cmd[16];
} procps_status_t;
-extern procps_status_t * procps_scan(int save_user_arg0);
+extern procps_status_t * procps_scan(int save_user_arg0
+#ifdef CONFIG_SELINUX
+ , int use_selinux, security_id_t *sid
+#endif
+);
extern unsigned short compare_string_array(const char *string_array[], const char *key);
extern int my_query_module(const char *name, int which, void **buf, size_t *bufsize, size_t *ret);