From 90c76cbe1ef31e40c4b9b9cd46731d2716307ef0 Mon Sep 17 00:00:00 2001 From: imp Date: Wed, 20 Mar 2002 22:53:13 +0000 Subject: o remove __P o Use ansi function definitions o unifdef -D__STDC__ --- sbin/init/init.c | 224 ++++++++++++++++--------------------------------------- 1 file changed, 64 insertions(+), 160 deletions(-) diff --git a/sbin/init/init.c b/sbin/init/init.c index 71b653f..6d3ecad 100644 --- a/sbin/init/init.c +++ b/sbin/init/init.c @@ -71,11 +71,7 @@ static const char rcsid[] = #include #include -#ifdef __STDC__ #include -#else -#include -#endif #ifdef SECURE #include @@ -101,31 +97,31 @@ static const char rcsid[] = #define RESOURCE_WINDOW "default" #define RESOURCE_GETTY "default" -void handle __P((sig_t, ...)); -void delset __P((sigset_t *, ...)); +void handle(sig_t, ...); +void delset(sigset_t *, ...); -void stall __P((const char *, ...)) __printflike(1, 2); -void warning __P((const char *, ...)) __printflike(1, 2); -void emergency __P((const char *, ...)) __printflike(1, 2); -void disaster __P((int)); -void badsys __P((int)); -int runshutdown __P((void)); +void stall(const char *, ...) __printflike(1, 2); +void warning(const char *, ...) __printflike(1, 2); +void emergency(const char *, ...) __printflike(1, 2); +void disaster(int); +void badsys(int); +int runshutdown(void); /* * We really need a recursive typedef... * The following at least guarantees that the return type of (*state_t)() * is sufficiently wide to hold a function pointer. */ -typedef long (*state_func_t) __P((void)); -typedef state_func_t (*state_t) __P((void)); +typedef long (*state_func_t)(void); +typedef state_func_t (*state_t)(void); -state_func_t single_user __P((void)); -state_func_t runcom __P((void)); -state_func_t read_ttys __P((void)); -state_func_t multi_user __P((void)); -state_func_t clean_ttys __P((void)); -state_func_t catatonia __P((void)); -state_func_t death __P((void)); +state_func_t single_user(void); +state_func_t runcom(void); +state_func_t read_ttys(void); +state_func_t multi_user(void); +state_func_t clean_ttys(void); +state_func_t catatonia(void); +state_func_t death(void); enum { AUTOBOOT, FASTBOOT } runcom_mode = AUTOBOOT; #define FALSE 0 @@ -136,10 +132,10 @@ int howto = RB_AUTOBOOT; int devfs; -void transition __P((state_t)); +void transition(state_t); state_t requested_transition = runcom; -void setctty __P((char *)); +void setctty(char *); typedef struct init_session { int se_index; /* index of entry in ttys file */ @@ -161,39 +157,37 @@ typedef struct init_session { struct init_session *se_next; } session_t; -void free_session __P((session_t *)); -session_t *new_session __P((session_t *, int, struct ttyent *)); +void free_session(session_t *); +session_t *new_session(session_t *, int, struct ttyent *); session_t *sessions; -char **construct_argv __P((char *)); -void start_window_system __P((session_t *)); -void collect_child __P((pid_t)); -pid_t start_getty __P((session_t *)); -void transition_handler __P((int)); -void alrm_handler __P((int)); -void setsecuritylevel __P((int)); -int getsecuritylevel __P((void)); -int setupargv __P((session_t *, struct ttyent *)); +char **construct_argv(char *); +void start_window_system(session_t *); +void collect_child(pid_t); +pid_t start_getty(session_t *); +void transition_handler(int); +void alrm_handler(int); +void setsecuritylevel(int); +int getsecuritylevel(void); +int setupargv(session_t *, struct ttyent *); #ifdef LOGIN_CAP -void setprocresources __P((const char *)); +void setprocresources(const char *); #endif int clang; -void clear_session_logs __P((session_t *)); +void clear_session_logs(session_t *); -int start_session_db __P((void)); -void add_session __P((session_t *)); -void del_session __P((session_t *)); -session_t *find_session __P((pid_t)); +int start_session_db(void); +void add_session(session_t *); +void del_session(session_t *); +session_t *find_session(pid_t); DB *session_db; /* * The mother of all processes. */ int -main(argc, argv) - int argc; - char **argv; +main(int argc, char *argv[]) { int c; struct sigaction sa; @@ -346,25 +340,13 @@ invalid: * Associate a function with a signal handler. */ void -#ifdef __STDC__ handle(sig_t handler, ...) -#else -handle(va_alist) - va_dcl -#endif { int sig; struct sigaction sa; sigset_t mask_everything; va_list ap; -#ifndef __STDC__ - sig_t handler; - - va_start(ap); - handler = va_arg(ap, sig_t); -#else va_start(ap, handler); -#endif sa.sa_handler = handler; sigfillset(&mask_everything); @@ -382,23 +364,11 @@ handle(va_alist) * Delete a set of signals from a mask. */ void -#ifdef __STDC__ delset(sigset_t *maskp, ...) -#else -delset(va_alist) - va_dcl -#endif { int sig; va_list ap; -#ifndef __STDC__ - sigset_t *maskp; - - va_start(ap); - maskp = va_arg(ap, sigset_t *); -#else va_start(ap, maskp); -#endif while ((sig = va_arg(ap, int)) != NULL) sigdelset(maskp, sig); @@ -411,22 +381,10 @@ delset(va_alist) * NB: should send a message to the session logger to avoid blocking. */ void -#ifdef __STDC__ stall(const char *message, ...) -#else -stall(va_alist) - va_dcl -#endif { va_list ap; -#ifndef __STDC__ - const char *message; - - va_start(ap); - message = va_arg(ap, char *); -#else va_start(ap, message); -#endif vsyslog(LOG_ALERT, message, ap); va_end(ap); @@ -439,22 +397,10 @@ stall(va_alist) * NB: should send a message to the session logger to avoid blocking. */ void -#ifdef __STDC__ warning(const char *message, ...) -#else -warning(va_alist) - va_dcl -#endif { va_list ap; -#ifndef __STDC__ - const char *message; - - va_start(ap); - message = va_arg(ap, char *); -#else va_start(ap, message); -#endif vsyslog(LOG_ALERT, message, ap); va_end(ap); @@ -465,22 +411,10 @@ warning(va_alist) * NB: should send a message to the session logger to avoid blocking. */ void -#ifdef __STDC__ emergency(const char *message, ...) -#else -emergency(va_alist) - va_dcl -#endif { va_list ap; -#ifndef __STDC__ - const char *message; - - va_start(ap); - message = va_arg(ap, char *); -#else va_start(ap, message); -#endif vsyslog(LOG_EMERG, message, ap); va_end(ap); @@ -493,8 +427,7 @@ emergency(va_alist) * We tolerate up to 25 of these, then throw in the towel. */ void -badsys(sig) - int sig; +badsys(int sig) { static int badcount = 0; @@ -507,8 +440,7 @@ badsys(sig) * Catch an unexpected signal. */ void -disaster(sig) - int sig; +disaster(int sig) { emergency("fatal signal: %s", (unsigned)sig < NSIG ? sys_siglist[sig] : "unknown signal"); @@ -521,7 +453,7 @@ disaster(sig) * Get the security level of the kernel. */ int -getsecuritylevel() +getsecuritylevel(void) { #ifdef KERN_SECURELVL int name[2], curlevel; @@ -545,8 +477,7 @@ getsecuritylevel() * Set the security level of the kernel. */ void -setsecuritylevel(newlevel) - int newlevel; +setsecuritylevel(int newlevel) { #ifdef KERN_SECURELVL int name[2], curlevel; @@ -574,8 +505,7 @@ setsecuritylevel(newlevel) * The initial state is passed as an argument. */ void -transition(s) - state_t s; +transition(state_t s) { for (;;) s = (state_t) (*s)(); @@ -586,8 +516,7 @@ transition(s) * NB: should send a message to the session logger to avoid blocking. */ void -clear_session_logs(sp) - session_t *sp; +clear_session_logs(session_t *sp) { char *line = sp->se_device + sizeof(_PATH_DEV) - 1; @@ -600,8 +529,7 @@ clear_session_logs(sp) * Only called by children of init after forking. */ void -setctty(name) - char *name; +setctty(char *name) { int fd; @@ -620,7 +548,7 @@ setctty(name) * Bring the system up single user. */ state_func_t -single_user() +single_user(void) { pid_t pid, wpid; int status; @@ -771,7 +699,7 @@ single_user() * Run the system startup script. */ state_func_t -runcom() +runcom(void) { pid_t pid, wpid; int status; @@ -866,7 +794,7 @@ runcom() * NB: We could pass in the size here; is it necessary? */ int -start_session_db() +start_session_db(void) { if (session_db && (*session_db->close)(session_db)) emergency("session database close: %s", strerror(errno)); @@ -882,8 +810,7 @@ start_session_db() * Add a new login session. */ void -add_session(sp) - session_t *sp; +add_session(session_t *sp) { DBT key; DBT data; @@ -901,8 +828,7 @@ add_session(sp) * Delete an old login session. */ void -del_session(sp) - session_t *sp; +del_session(session_t *sp) { DBT key; @@ -917,12 +843,7 @@ del_session(sp) * Look up a login session by pid. */ session_t * -#ifdef __STDC__ find_session(pid_t pid) -#else -find_session(pid) - pid_t pid; -#endif { DBT key; DBT data; @@ -940,8 +861,7 @@ find_session(pid) * Construct an argument vector from a command line. */ char ** -construct_argv(command) - char *command; +construct_argv(char *command) { char *strk (char *); int argc = 0; @@ -961,8 +881,7 @@ construct_argv(command) * Deallocate a session descriptor. */ void -free_session(sp) - session_t *sp; +free_session(session_t *sp) { free(sp->se_device); if (sp->se_getty) { @@ -985,10 +904,7 @@ free_session(sp) * Mark it SE_PRESENT. */ session_t * -new_session(sprev, session_index, typ) - session_t *sprev; - int session_index; - struct ttyent *typ; +new_session(session_t *sprev, int session_index, struct ttyent *typ) { session_t *sp; int fd; @@ -1039,9 +955,7 @@ new_session(sprev, session_index, typ) * Calculate getty and if useful window argv vectors. */ int -setupargv(sp, typ) - session_t *sp; - struct ttyent *typ; +setupargv(session_t *sp, struct ttyent *typ) { if (sp->se_getty) { @@ -1090,7 +1004,7 @@ setupargv(sp, typ) * Walk the list of ttys and create sessions for each active line. */ state_func_t -read_ttys() +read_ttys(void) { int session_index = 0; session_t *sp, *snext; @@ -1127,8 +1041,7 @@ read_ttys() * Start a window system running. */ void -start_window_system(sp) - session_t *sp; +start_window_system(session_t *sp) { pid_t pid; sigset_t mask; @@ -1172,8 +1085,7 @@ start_window_system(sp) * Start a login session running. */ pid_t -start_getty(sp) - session_t *sp; +start_getty(session_t *sp) { pid_t pid; sigset_t mask; @@ -1238,12 +1150,7 @@ start_getty(sp) * If an exiting login, start a new login running. */ void -#ifdef __STDC__ collect_child(pid_t pid) -#else -collect_child(pid) - pid_t pid; -#endif { session_t *sp, *sprev, *snext; @@ -1283,8 +1190,7 @@ collect_child(pid) * Catch a signal and request a state transition. */ void -transition_handler(sig) - int sig; +transition_handler(int sig) { switch (sig) { @@ -1313,7 +1219,7 @@ transition_handler(sig) * Take the system multiuser. */ state_func_t -multi_user() +multi_user(void) { pid_t pid; session_t *sp; @@ -1353,7 +1259,7 @@ multi_user() * This is an (n*2)+(n^2) algorithm. We hope it isn't run often... */ state_func_t -clean_ttys() +clean_ttys(void) { session_t *sp, *sprev; struct ttyent *typ; @@ -1451,7 +1357,7 @@ clean_ttys() * Block further logins. */ state_func_t -catatonia() +catatonia(void) { session_t *sp; @@ -1465,8 +1371,7 @@ catatonia() * Note SIGALRM. */ void -alrm_handler(sig) - int sig; +alrm_handler(int sig) { (void)sig; clang = 1; @@ -1476,7 +1381,7 @@ alrm_handler(sig) * Bring the system down to single user. */ state_func_t -death() +death(void) { session_t *sp; int i; @@ -1524,7 +1429,7 @@ death() * >0 some error (exit code) */ int -runshutdown() +runshutdown(void) { pid_t pid, wpid; int status; @@ -1699,8 +1604,7 @@ strk (char *p) #ifdef LOGIN_CAP void -setprocresources(cname) - const char *cname; +setprocresources(const char *cname) { login_cap_t *lc; if ((lc = login_getclassbyname(cname, NULL)) != NULL) { -- cgit v1.1