o Eliminate __P

o Use new-style function definitions
o remove some !__STDC__ code
o eliminate register
This commit is contained in:
Warner Losh 2002-02-03 15:53:02 +00:00
parent 63d770d8ea
commit e4bc453cc2
7 changed files with 149 additions and 272 deletions

View File

@ -86,7 +86,7 @@ static const char rcsid[] =
static debug = 0;
void perr(const char *a);
static void usage __P((void));
static void usage(void);
/* Local functions */
static int
@ -98,7 +98,7 @@ write_string(int fd, const char* a)
#undef DEBUG_FORK
#ifdef DEBUG_FORK
static pid_t
myfork()
myfork(void)
{
pid_t res;
res = fork();
@ -491,7 +491,7 @@ main(int argc, char *argv[])
}
static void
usage()
usage(void)
{
if (debug)
fprintf(stderr, "usage: atrun [-l load_avg] [-d]\n");

View File

@ -78,19 +78,17 @@ struct utmp *utmp = NULL;
time_t lastmsgtime;
int nutmp, uf;
void jkfprintf __P((FILE *, char[], char[], off_t));
void mailfor __P((char *));
void notify __P((struct utmp *, char[], off_t, int));
void onalrm __P((int));
void reapchildren __P((int));
void jkfprintf(FILE *, char[], char[], off_t);
void mailfor(char *);
void notify(struct utmp *, char[], off_t, int);
void onalrm(int);
void reapchildren(int);
int
main(argc, argv)
int argc;
char *argv[];
main(int argc, char *argv[])
{
struct sockaddr_in from;
register int cc;
int cc;
int fromlen;
char msgbuf[256];
@ -134,15 +132,13 @@ main(argc, argv)
}
void
reapchildren(signo)
int signo;
reapchildren(int signo)
{
while (wait3(NULL, WNOHANG, NULL) > 0);
}
void
onalrm(signo)
int signo;
onalrm(int signo)
{
static u_int utmpsize; /* last malloced size for utmp */
static u_int utmpmtime; /* last modification time for utmp */
@ -167,11 +163,10 @@ onalrm(signo)
}
void
mailfor(name)
char *name;
mailfor(char *name)
{
register struct utmp *utp = &utmp[nutmp];
register char *cp;
struct utmp *utp = &utmp[nutmp];
char *cp;
char *file;
off_t offset;
int folder;
@ -202,11 +197,7 @@ mailfor(name)
static char *cr;
void
notify(utp, file, offset, folder)
register struct utmp *utp;
char file[];
off_t offset;
int folder;
notify(struct utmp *utp, char file[], off_t offset, int folder)
{
FILE *tp;
struct stat stb;
@ -247,16 +238,12 @@ notify(utp, file, offset, folder)
}
void
jkfprintf(tp, user, file, offset)
register FILE *tp;
char user[];
char file[];
off_t offset;
jkfprintf(FILE *tp, char user[], char file[], off_t offset)
{
register unsigned char *cp, ch;
register FILE *fi;
register int linecnt, charcnt, inheader;
register struct passwd *p;
unsigned char *cp, ch;
FILE *fi;
int linecnt, charcnt, inheader;
struct passwd *p;
unsigned char line[BUFSIZ];
/* Set effective uid to user in case mail drop is on nfs */

View File

@ -62,16 +62,14 @@ static const char rcsid[] =
#include <strings.h>
#include "pathnames.h"
void logerr __P((const char *, ...));
void logerr(const char *, ...);
int
main(argc, argv)
int argc;
char *argv[];
main(int argc, char *argv[])
{
register FILE *fp;
register int ch;
register char *lp;
FILE *fp;
int ch;
char *lp;
struct sockaddr_storage ss;
int p[2], logging, secure, sval;
#define ENTRIES 50
@ -199,27 +197,13 @@ main(argc, argv)
exit(0);
}
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
void
#if __STDC__
logerr(const char *fmt, ...)
#else
logerr(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
va_list ap;
#if __STDC__
va_start(ap, fmt);
#else
va_start(ap);
#endif
(void)vsyslog(LOG_ERR, fmt, ap);
va_end(ap);
exit(1);

View File

@ -37,41 +37,41 @@
#include <sys/types.h>
#include <sys/socket.h>
void blkfree __P((char **));
char **copyblk __P((char **));
void cwd __P((char *));
void delete __P((char *));
void dologout __P((int));
void fatalerror __P((char *));
void ftpd_logwtmp __P((char *, char *, struct sockaddr *addr));
int ftpd_pclose __P((FILE *));
FILE *ftpd_popen __P((char *, char *));
char *getline __P((char *, int, FILE *));
void lreply __P((int, const char *, ...));
void makedir __P((char *));
void nack __P((char *));
void pass __P((char *));
void passive __P((void));
void long_passive __P((char *, int));
void perror_reply __P((int, char *));
void pwd __P((void));
void removedir __P((char *));
void renamecmd __P((char *, char *));
char *renamefrom __P((char *));
void reply __P((int, const char *, ...));
void retrieve __P((char *, char *));
void send_file_list __P((char *));
void blkfree(char **);
char **copyblk(char **);
void cwd(char *);
void delete(char *);
void dologout(int);
void fatalerror(char *);
void ftpd_logwtmp(char *, char *, struct sockaddr *addr);
int ftpd_pclose(FILE *);
FILE *ftpd_popen(char *, char *);
char *getline(char *, int, FILE *);
void lreply(int, const char *, ...);
void makedir(char *);
void nack(char *);
void pass(char *);
void passive(void);
void long_passive(char *, int);
void perror_reply(int, char *);
void pwd(void);
void removedir(char *);
void renamecmd(char *, char *);
char *renamefrom(char *);
void reply(int, const char *, ...);
void retrieve(char *, char *);
void send_file_list(char *);
#ifdef OLD_SETPROCTITLE
void setproctitle __P((const char *, ...));
void setproctitle(const char *, ...);
#endif
void statcmd __P((void));
void statfilecmd __P((char *));
void store __P((char *, char *, int));
void upper __P((char *));
void user __P((char *));
void yyerror __P((char *));
int yyparse __P((void));
int ls_main __P((int, char **));
void statcmd(void);
void statfilecmd(char *);
void store(char *, char *, int);
void upper(char *);
void user(char *);
void yyerror(char *);
int yyparse(void);
int ls_main(int, char **);
struct sockaddr_in;
struct sockaddr_in6;

View File

@ -1133,21 +1133,19 @@ struct tab sitetab[] = {
{ NULL, 0, 0, 0, 0 }
};
static char *copy __P((char *));
static void help __P((struct tab *, char *));
static char *copy(char *);
static void help(struct tab *, char *);
static struct tab *
lookup __P((struct tab *, char *));
static int port_check __P((const char *));
static int port_check_v6 __P((const char *));
static void sizecmd __P((char *));
static void toolong __P((int));
static void v4map_data_dest __P((void));
static int yylex __P((void));
lookup(struct tab *, char *);
static int port_check(const char *);
static int port_check_v6(const char *);
static void sizecmd(char *);
static void toolong(int);
static void v4map_data_dest(void);
static int yylex(void);
static struct tab *
lookup(p, cmd)
struct tab *p;
char *cmd;
lookup(struct tab *p, char *cmd)
{
for (; p->name != NULL; p++)
@ -1162,10 +1160,7 @@ lookup(p, cmd)
* getline - a hacked up version of fgets to ignore TELNET escape codes.
*/
char *
getline(s, n, iop)
char *s;
int n;
FILE *iop;
getline(char *s, int n, FILE *iop)
{
int c;
register char *cs;
@ -1238,8 +1233,7 @@ getline(s, n, iop)
}
static void
toolong(signo)
int signo;
toolong(int signo)
{
reply(421,
@ -1251,7 +1245,7 @@ toolong(signo)
}
static int
yylex()
yylex(void)
{
static int cpos;
char *cp, *cp2;
@ -1471,8 +1465,7 @@ yylex()
}
void
upper(s)
char *s;
upper(char *s)
{
while (*s != '\0') {
if (islower(*s))
@ -1482,8 +1475,7 @@ upper(s)
}
static char *
copy(s)
char *s;
copy(char *s)
{
char *p;
@ -1495,9 +1487,7 @@ copy(s)
}
static void
help(ctab, s)
struct tab *ctab;
char *s;
help(struct tab *ctab, char *s)
{
struct tab *c;
int width, NCMDS;
@ -1560,8 +1550,7 @@ help(ctab, s)
}
static void
sizecmd(filename)
char *filename;
sizecmd(char *filename)
{
switch (type) {
case TYPE_L:
@ -1611,8 +1600,7 @@ sizecmd(filename)
/* Return 1, if port check is done. Return 0, if not yet. */
static int
port_check(pcmd)
const char *pcmd;
port_check(const char *pcmd)
{
if (his_addr.su_family == AF_INET) {
if (data_dest.su_family != AF_INET) {
@ -1641,7 +1629,7 @@ port_check(pcmd)
}
static int
check_login1()
check_login1(void)
{
if (logged_in)
return 1;
@ -1654,8 +1642,7 @@ check_login1()
#ifdef INET6
/* Return 1, if port check is done. Return 0, if not yet. */
static int
port_check_v6(pcmd)
const char *pcmd;
port_check_v6(const char *pcmd)
{
if (his_addr.su_family == AF_INET6) {
if (IN6_IS_ADDR_V4MAPPED(&his_addr.su_sin6.sin6_addr))
@ -1687,7 +1674,7 @@ port_check_v6(pcmd)
}
static void
v4map_data_dest()
v4map_data_dest(void)
{
struct in_addr savedaddr;
int savedport;

View File

@ -182,7 +182,7 @@ static char ttyline[20];
char *tty = ttyline; /* for klogin */
#ifdef USE_PAM
static int auth_pam __P((struct passwd**, const char*));
static int auth_pam(struct passwd**, const char*);
pam_handle_t *pamh = NULL;
#endif
@ -238,31 +238,31 @@ char proctitle[LINE_MAX]; /* initial part of title */
}
#ifdef VIRTUAL_HOSTING
static void inithosts __P((void));
static void selecthost __P((union sockunion *));
static void inithosts(void);
static void selecthost(union sockunion *);
#endif
static void ack __P((char *));
static void sigurg __P((int));
static void myoob __P((void));
static int checkuser __P((char *, char *, int));
static FILE *dataconn __P((char *, off_t, char *));
static void dolog __P((struct sockaddr *));
static char *curdir __P((void));
static void end_login __P((void));
static FILE *getdatasock __P((char *));
static char *gunique __P((char *));
static void lostconn __P((int));
static void sigquit __P((int));
static int receive_data __P((FILE *, FILE *));
static int send_data __P((FILE *, FILE *, off_t, off_t, int));
static void ack(char *);
static void sigurg(int);
static void myoob(void);
static int checkuser(char *, char *, int);
static FILE *dataconn(char *, off_t, char *);
static void dolog(struct sockaddr *);
static char *curdir(void);
static void end_login(void);
static FILE *getdatasock(char *);
static char *gunique(char *);
static void lostconn(int);
static void sigquit(int);
static int receive_data(FILE *, FILE *);
static int send_data(FILE *, FILE *, off_t, off_t, int);
static struct passwd *
sgetpwnam __P((char *));
static char *sgetsave __P((char *));
static void reapchild __P((int));
static void logxfer __P((char *, off_t, time_t));
sgetpwnam(char *);
static char *sgetsave(char *);
static void reapchild(int);
static void logxfer(char *, off_t, time_t);
static char *
curdir()
curdir(void)
{
static char path[MAXPATHLEN+1+1]; /* path + '/' + '\0' */
@ -275,10 +275,7 @@ curdir()
}
int
main(argc, argv, envp)
int argc;
char *argv[];
char **envp;
main(int argc, char *argv[], char **envp)
{
int addrlen, ch, on = 1, tos;
char *cp, line[LINE_MAX];
@ -634,8 +631,7 @@ main(argc, argv, envp)
}
static void
lostconn(signo)
int signo;
lostconn(int signo)
{
if (ftpdebug)
@ -644,8 +640,7 @@ lostconn(signo)
}
static void
sigquit(signo)
int signo;
sigquit(int signo)
{
syslog(LOG_ERR, "got signal %d", signo);
@ -658,7 +653,7 @@ sigquit(signo)
*/
static void
inithosts()
inithosts(void)
{
FILE *fp;
char *cp;
@ -819,8 +814,7 @@ inithosts()
}
static void
selecthost(su)
union sockunion *su;
selecthost(union sockunion *su)
{
struct ftphost *hrp;
u_int16_t port;
@ -872,8 +866,7 @@ selecthost(su)
* Helper function for sgetpwnam().
*/
static char *
sgetsave(s)
char *s;
sgetsave(char *s)
{
char *new = malloc((unsigned) strlen(s) + 1);
@ -892,8 +885,7 @@ sgetsave(s)
* (e.g., globbing).
*/
static struct passwd *
sgetpwnam(name)
char *name;
sgetpwnam(char *name)
{
static struct passwd save;
struct passwd *p;
@ -932,8 +924,7 @@ static char curname[MAXLOGNAME]; /* current USER name */
* _PATH_FTPUSERS to allow people such as root and uucp to be avoided.
*/
void
user(name)
char *name;
user(char *name)
{
char *cp, *shell;
@ -1022,10 +1013,7 @@ user(name)
* Check if a user is in the file "fname"
*/
static int
checkuser(fname, name, pwset)
char *fname;
char *name;
int pwset;
checkuser(char *fname, char *name, int pwset)
{
FILE *fd;
int found = 0;
@ -1075,7 +1063,7 @@ checkuser(fname, name, pwset)
* used when USER command is given or login fails.
*/
static void
end_login()
end_login(void)
{
#ifdef USE_PAM
int e;
@ -1252,8 +1240,7 @@ auth_pam(struct passwd **ppw, const char *pass)
#endif /* USE_PAM */
void
pass(passwd)
char *passwd;
pass(char *passwd)
{
int rval;
FILE *fd;
@ -1480,12 +1467,11 @@ pass(passwd)
}
void
retrieve(cmd, name)
char *cmd, *name;
retrieve(char *cmd, char *name)
{
FILE *fin, *dout;
struct stat st;
int (*closefunc) __P((FILE *));
int (*closefunc)(FILE *);
time_t start;
if (cmd == 0) {
@ -1551,13 +1537,11 @@ retrieve(cmd, name)
}
void
store(name, mode, unique)
char *name, *mode;
int unique;
store(char *name, char *mode, int unique)
{
FILE *fout, *din;
struct stat st;
int (*closefunc) __P((FILE *));
int (*closefunc)(FILE *);
if ((unique || guest) && stat(name, &st) == 0 &&
(name = gunique(name)) == NULL) {
@ -1623,8 +1607,7 @@ store(name, mode, unique)
}
static FILE *
getdatasock(mode)
char *mode;
getdatasock(char *mode)
{
int on = 1, s, t, tries;
@ -1686,10 +1669,7 @@ getdatasock(mode)
}
static FILE *
dataconn(name, size, mode)
char *name;
off_t size;
char *mode;
dataconn(char *name, off_t size, char *mode)
{
char sizebuf[32];
FILE *file;
@ -1797,11 +1777,7 @@ dataconn(name, size, mode)
* NB: Form isn't handled.
*/
static int
send_data(instr, outstr, blksize, filesize, isreg)
FILE *instr, *outstr;
off_t blksize;
off_t filesize;
int isreg;
send_data(FILE *instr, FILE *outstr, off_t blksize, off_t filesize, int isreg)
{
int c, filefd, netfd;
char *buf;
@ -1921,8 +1897,7 @@ send_data(instr, outstr, blksize, filesize, isreg)
* N.B.: Form isn't handled.
*/
static int
receive_data(instr, outstr)
FILE *instr, *outstr;
receive_data(FILE *instr, FILE *outstr)
{
int c;
int cnt, bare_lfs;
@ -2012,8 +1987,7 @@ receive_data(instr, outstr)
}
void
statfilecmd(filename)
char *filename;
statfilecmd(char *filename)
{
FILE *fin;
int c;
@ -2044,7 +2018,7 @@ statfilecmd(filename)
}
void
statcmd()
statcmd(void)
{
union sockunion *su;
u_char *a, *p;
@ -2170,8 +2144,7 @@ epsvonly:;
}
void
fatalerror(s)
char *s;
fatalerror(char *s)
{
reply(451, "Error in server: %s\n", s);
@ -2181,21 +2154,11 @@ fatalerror(s)
}
void
#if __STDC__
reply(int n, const char *fmt, ...)
#else
reply(n, fmt, va_alist)
int n;
char *fmt;
va_dcl
#endif
{
va_list ap;
#if __STDC__
va_start(ap, fmt);
#else
va_start(ap);
#endif
(void)printf("%d ", n);
(void)vprintf(fmt, ap);
(void)printf("\r\n");
@ -2207,21 +2170,11 @@ reply(n, fmt, va_alist)
}
void
#if __STDC__
lreply(int n, const char *fmt, ...)
#else
lreply(n, fmt, va_alist)
int n;
char *fmt;
va_dcl
#endif
{
va_list ap;
#if __STDC__
va_start(ap, fmt);
#else
va_start(ap);
#endif
(void)printf("%d- ", n);
(void)vprintf(fmt, ap);
(void)printf("\r\n");
@ -2233,16 +2186,14 @@ lreply(n, fmt, va_alist)
}
static void
ack(s)
char *s;
ack(char *s)
{
reply(250, "%s command successful.", s);
}
void
nack(s)
char *s;
nack(char *s)
{
reply(502, "%s command not implemented.", s);
@ -2250,8 +2201,7 @@ nack(s)
/* ARGSUSED */
void
yyerror(s)
char *s;
yyerror(char *s)
{
char *cp;
@ -2261,8 +2211,7 @@ yyerror(s)
}
void
delete(name)
char *name;
delete(char *name)
{
struct stat st;
@ -2287,8 +2236,7 @@ delete(name)
}
void
cwd(path)
char *path;
cwd(char *path)
{
if (chdir(path) < 0)
@ -2298,8 +2246,7 @@ cwd(path)
}
void
makedir(name)
char *name;
makedir(char *name)
{
LOGCMD("mkdir", name);
@ -2310,8 +2257,7 @@ makedir(name)
}
void
removedir(name)
char *name;
removedir(char *name)
{
LOGCMD("rmdir", name);
@ -2322,7 +2268,7 @@ removedir(name)
}
void
pwd()
pwd(void)
{
char path[MAXPATHLEN + 1];
@ -2333,8 +2279,7 @@ pwd()
}
char *
renamefrom(name)
char *name;
renamefrom(char *name)
{
struct stat st;
@ -2347,8 +2292,7 @@ renamefrom(name)
}
void
renamecmd(from, to)
char *from, *to;
renamecmd(char *from, char *to)
{
struct stat st;
@ -2366,8 +2310,7 @@ renamecmd(from, to)
}
static void
dolog(who)
struct sockaddr *who;
dolog(struct sockaddr *who)
{
int error;
@ -2410,8 +2353,7 @@ dolog(who)
* and exit with supplied status.
*/
void
dologout(status)
int status;
dologout(int status)
{
/*
* Prevent reception of SIGURG from resulting in a resumption
@ -2428,15 +2370,14 @@ dologout(status)
}
static void
sigurg(signo)
int signo;
sigurg(int signo)
{
recvurg = 1;
}
static void
myoob()
myoob(void)
{
char *cp;
@ -2471,7 +2412,7 @@ myoob()
* with Rick Adams on 25 Jan 89.
*/
void
passive()
passive(void)
{
int len;
char *p, *a;
@ -2551,9 +2492,7 @@ passive()
*/
void
long_passive(cmd, pf)
char *cmd;
int pf;
long_passive(char *cmd, int pf)
{
int len;
char *p, *a;
@ -2686,8 +2625,7 @@ long_passive(cmd, pf)
* Generates failure reply on error.
*/
static char *
gunique(local)
char *local;
gunique(char *local)
{
static char new[MAXPATHLEN];
struct stat st;
@ -2720,9 +2658,7 @@ gunique(local)
* Format and send reply containing system error number.
*/
void
perror_reply(code, string)
int code;
char *string;
perror_reply(int code, char *string)
{
reply(code, "%s: %s.", string, strerror(errno));
@ -2734,8 +2670,7 @@ static char *onefile[] = {
};
void
send_file_list(whichf)
char *whichf;
send_file_list(char *whichf)
{
struct stat st;
DIR *dirp = NULL;
@ -2870,8 +2805,7 @@ send_file_list(whichf)
}
void
reapchild(signo)
int signo;
reapchild(int signo)
{
while (wait3(NULL, WNOHANG, NULL) > 0);
}
@ -2883,24 +2817,14 @@ reapchild(signo)
* have much of an environment or arglist to overwrite.
*/
void
#if __STDC__
setproctitle(const char *fmt, ...)
#else
setproctitle(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
int i;
va_list ap;
char *p, *bp, ch;
char buf[LINE_MAX];
#if __STDC__
va_start(ap, fmt);
#else
va_start(ap);
#endif
(void)vsnprintf(buf, sizeof(buf), fmt, ap);
/* make ps print our process name */
@ -2922,10 +2846,7 @@ setproctitle(fmt, va_alist)
#endif /* OLD_SETPROCTITLE */
static void
logxfer(name, size, start)
char *name;
off_t size;
time_t start;
logxfer(char *name, off_t size, time_t start)
{
char buf[1024];
char path[MAXPATHLEN + 1];

View File

@ -72,8 +72,7 @@ static int *pids;
static int fds;
FILE *
ftpd_popen(program, type)
char *program, *type;
ftpd_popen(char *program, char *type)
{
char *cp;
FILE *iop;
@ -177,8 +176,7 @@ pfree: for (argc = 1; gargv[argc] != NULL; argc++)
}
int
ftpd_pclose(iop)
FILE *iop;
ftpd_pclose(FILE *iop)
{
int fdes, omask, status;
pid_t pid;