diff options
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 185 | ||||
-rw-r--r-- | usr.bin/find/extern.h | 80 | ||||
-rw-r--r-- | usr.bin/find/find.c | 12 | ||||
-rw-r--r-- | usr.bin/find/find.h | 14 | ||||
-rw-r--r-- | usr.bin/find/function.c | 157 | ||||
-rw-r--r-- | usr.bin/find/ls.c | 19 | ||||
-rw-r--r-- | usr.bin/find/misc.c | 29 | ||||
-rw-r--r-- | usr.bin/find/operator.c | 22 | ||||
-rw-r--r-- | usr.bin/find/option.c | 20 |
9 files changed, 269 insertions, 269 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 13f6fb2d76b..55e39d4c2bd 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.76 2003/06/11 06:22:13 deraadt Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.77 2003/06/26 07:27:32 deraadt Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -77,7 +77,7 @@ static const char copyright[] = #if 0 static const char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94"; #else -static const char rcsid[] = "$OpenBSD: ifconfig.c,v 1.76 2003/06/11 06:22:13 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: ifconfig.c,v 1.77 2003/06/26 07:27:32 deraadt Exp $"; #endif #endif /* not lint */ @@ -158,44 +158,44 @@ int explicit_prefix = 0; int Lflag = 1; #endif -void notealias(char *, int); -void notrailers(char *, int); -void setifaddr(char *, int); -void setifdstaddr(char *, int); -void setifflags(char *, int); -void setifbroadaddr(char *); -void setifipdst(char *); -void setifmetric(char *); -void setifmtu(char *, int); +void notealias(const char *, int); +void notrailers(const char *, int); +void setifaddr(const char *, int); +void setifdstaddr(const char *, int); +void setifflags(const char *, int); +void setifbroadaddr(const char *, int); +void setifipdst(const char *, int); +void setifmetric(const char *, int); +void setifmtu(const char *, int); void setifnwid(const char *, int); void setifnwkey(const char *, int); void setifpowersave(const char *, int); void setifpowersavesleep(const char *, int); -void setifnetmask(char *); -void setifprefixlen(char *, int); -void setnsellength(char *); -void setsnpaoffset(char *); -void setipxframetype(char *, int); -void setatrange(char *, int); -void setatphase(char *, int); -void settunnel(char *, char *); -void deletetunnel(void); +void setifnetmask(const char *, int); +void setifprefixlen(const char *, int); +void setnsellength(const char *, int); +void setsnpaoffset(const char *, int); +void setipxframetype(const char *, int); +void setatrange(const char *, int); +void setatphase(const char *, int); +void settunnel(const char *, const char *); +void deletetunnel(const char *, int); #ifdef INET6 -void setia6flags(char *, int); -void setia6pltime(char *, int); -void setia6vltime(char *, int); -void setia6lifetime(char *, char *); +void setia6flags(const char *, int); +void setia6pltime(const char *, int); +void setia6vltime(const char *, int); +void setia6lifetime(const char *, const char *); void setia6eui64(const char *, int); #endif void checkatrange(struct sockaddr_at *); -void setmedia(char *, int); -void setmediaopt(char *, int); -void unsetmediaopt(char *, int); -void setmediainst(char *, int); -void setvlantag(char *, int); -void setvlandev(char *, int); -void unsetvlandev(char *, int); -void vlan_status (); +void setmedia(const char *, int); +void setmediaopt(const char *, int); +void unsetmediaopt(const char *, int); +void setmediainst(const char *, int); +void setvlantag(const char *, int); +void setvlandev(const char *, int); +void unsetvlandev(const char *, int); +void vlan_status(void); void fixnsel(struct sockaddr_iso *); int main(int, char *[]); int prefix(void *val, int); @@ -226,7 +226,8 @@ const struct cmd { char *c_name; int c_parameter; /* NEXTARG means next argv */ int c_action; /* defered action */ - void (*c_func)(); + void (*c_func)(const char *, int); + void (*c_func2)(const char *, const char *); } cmds[] = { { "up", IFF_UP, 0, setifflags } , { "down", -IFF_UP, 0, setifflags }, @@ -280,8 +281,8 @@ const struct cmd { { "-vlandev", 1, 0, unsetvlandev }, #endif /* INET_ONLY */ /* giftunnel is for backward compat */ - { "giftunnel", NEXTARG2, 0, settunnel } , - { "tunnel", NEXTARG2, 0, settunnel } , + { "giftunnel", NEXTARG2, 0, NULL, settunnel } , + { "tunnel", NEXTARG2, 0, NULL, settunnel } , { "deletetunnel", 0, 0, deletetunnel } , { "link0", IFF_LINK0, 0, setifflags } , { "-link0", -IFF_LINK0, 0, setifflags } , @@ -299,13 +300,13 @@ const struct cmd { { NULL, /*illegal*/0, 0, NULL }, }; -void adjust_nsellength(); +void adjust_nsellength(void); int getinfo(struct ifreq *); void getsock(int); void printif(struct ifreq *, int); void printb(char *, unsigned short, char *); void status(int, struct sockaddr_dl *); -void usage(); +void usage(void); const char *get_string(const char *, const char *, u_int8_t *, int *); void print_string(const u_int8_t *, int); char *sec2str(time_t); @@ -325,32 +326,32 @@ void init_current_media(void); * Maryland principally by James O'Toole and Chris Torek. */ void in_status(int); -void in_getaddr(char *, int); -void in_getprefix(char *, int); +void in_getaddr(const char *, int); +void in_getprefix(const char *, int); #ifdef INET6 void in6_fillscopeid(struct sockaddr_in6 *sin6); void in6_alias(struct in6_ifreq *); void in6_status(int); -void in6_getaddr(char *, int); -void in6_getprefix(char *, int); +void in6_getaddr(const char *, int); +void in6_getprefix(const char *, int); #endif void at_status(int); -void at_getaddr(char *, int); +void at_getaddr(const char *, int); void xns_status(int); -void xns_getaddr(char *, int); +void xns_getaddr(const char *, int); void ipx_status(int); -void ipx_getaddr(char *, int); +void ipx_getaddr(const char *, int); void iso_status(int); -void iso_getaddr(char *, int); +void iso_getaddr(const char *, int); void ieee80211_status(void); /* Known address families */ const struct afswtch { char *af_name; short af_af; - void (*af_status)(); - void (*af_getaddr)(); - void (*af_getprefix)(); + void (*af_status)(int); + void (*af_getaddr)(const char *, int); + void (*af_getprefix)(const char *, int); u_long af_difaddr; u_long af_aifaddr; caddr_t af_ridreq; @@ -448,22 +449,22 @@ main(int argc, char *argv[]) if (p->c_name == 0 && setaddr) for (i = setaddr; i > 0; i--) { p++; - if (p->c_func == NULL) + if (p->c_func == NULL && p->c_func2) errx(1, "extra address not accepted"); } - if (p->c_func) { + if (p->c_func || p->c_func2) { if (p->c_parameter == NEXTARG) { if (argv[1] == NULL) errx(1, "'%s' requires argument", p->c_name); - (*p->c_func)(argv[1]); + (*p->c_func)(argv[1], 0); argc--, argv++; } else if (p->c_parameter == NEXTARG2) { if ((argv[1] == NULL) || (argv[2] == NULL)) errx(1, "'%s' requires 2 arguments", p->c_name); - (*p->c_func)(argv[1], argv[2]); + (*p->c_func2)(argv[1], argv[2]); argc -= 2; argv += 2; } else @@ -748,7 +749,7 @@ printif(struct ifreq *ifrm, int ifaliases) /*ARGSUSED*/ void -setifaddr(char *addr, int param) +setifaddr(const char *addr, int param) { /* * Delay the ioctl to set the interface addr until flags are all set. @@ -763,7 +764,7 @@ setifaddr(char *addr, int param) } void -settunnel(char *src, char *dst) +settunnel(const char *src, const char *dst) { struct addrinfo hints, *srcres, *dstres; int ecode; @@ -801,7 +802,7 @@ settunnel(char *src, char *dst) } void -deletetunnel(void) +deletetunnel(const char *ignored, int alsoignored) { if (ioctl(s, SIOCDIFPHYADDR, &ifr) < 0) warn("SIOCDIFPHYADDR"); @@ -809,19 +810,19 @@ deletetunnel(void) void -setifnetmask(char *addr) +setifnetmask(const char *addr, int ignored) { (*afp->af_getaddr)(addr, MASK); } void -setifbroadaddr(char *addr) +setifbroadaddr(const char *addr, int ignored) { (*afp->af_getaddr)(addr, DSTADDR); } void -setifipdst(char *addr) +setifipdst(const char *addr, int ignored) { in_getaddr(addr, DSTADDR); setipdst++; @@ -832,7 +833,7 @@ setifipdst(char *addr) #define rqtosa(x) (&(((struct ifreq *)(afp->x))->ifr_addr)) /*ARGSUSED*/ void -notealias(char *addr, int param) +notealias(const char *addr, int param) { if (setaddr && doalias == 0 && param < 0) memcpy(rqtosa(af_ridreq), rqtosa(af_addreq), @@ -847,14 +848,14 @@ notealias(char *addr, int param) /*ARGSUSED*/ void -notrailers(char *vname, int value) +notrailers(const char *vname, int value) { printf("Note: trailers are no longer sent, but always received\n"); } /*ARGSUSED*/ void -setifdstaddr(char *addr, int param) +setifdstaddr(const char *addr, int param) { setaddr++; (*afp->af_getaddr)(addr, DSTADDR); @@ -866,7 +867,7 @@ setifdstaddr(char *addr, int param) * Make a private copy so we can avoid that. */ void -setifflags(char *vname, int value) +setifflags(const char *vname, int value) { struct ifreq my_ifr; @@ -889,7 +890,7 @@ setifflags(char *vname, int value) #ifdef INET6 void -setia6flags(char *vname, int value) +setia6flags(const char *vname, int value) { if (value < 0) { @@ -900,21 +901,21 @@ setia6flags(char *vname, int value) } void -setia6pltime(char *val, int d) +setia6pltime(const char *val, int d) { setia6lifetime("pltime", val); } void -setia6vltime(char *val, int d) +setia6vltime(const char *val, int d) { setia6lifetime("vltime", val); } void -setia6lifetime(char *cmd, char *val) +setia6lifetime(const char *cmd, const char *val) { time_t newval, t; char *ep; @@ -969,7 +970,7 @@ setia6eui64(const char *cmd, int val) #endif void -setifmetric(char *val) +setifmetric(const char *val, int ignored) { char *ep = NULL; @@ -982,7 +983,7 @@ setifmetric(char *val) } void -setifmtu(char *val, int d) +setifmtu(const char *val, int d) { char *ep = NULL; @@ -1329,7 +1330,7 @@ process_media_commands(void) } void -setmedia(char *val, int d) +setmedia(const char *val, int d) { int type, subtype, inst; @@ -1361,7 +1362,7 @@ setmedia(char *val, int d) } void -setmediaopt(char *val, int d) +setmediaopt(const char *val, int d) { init_current_media(); @@ -1380,7 +1381,7 @@ setmediaopt(char *val, int d) } void -unsetmediaopt(char *val, int d) +unsetmediaopt(const char *val, int d) { init_current_media(); @@ -1404,7 +1405,7 @@ unsetmediaopt(char *val, int d) } void -setmediainst(char *val, int d) +setmediainst(const char *val, int d) { int type, subtype, options, inst; @@ -1727,7 +1728,6 @@ void in_status(int force) { struct sockaddr_in *sin, sin2; - char *inet_ntoa(); getsock(AF_INET); if (s < 0) { @@ -1785,7 +1785,7 @@ in_status(int force) } void -setifprefixlen(char *addr, int d) +setifprefixlen(const char *addr, int d) { if (*afp->af_getprefix) (*afp->af_getprefix)(addr, MASK); @@ -2025,7 +2025,7 @@ xns_status(int force) } void -setipxframetype(char *vname, int type) +setipxframetype(const char *vname, int type) { struct sockaddr_ipx *sipx; @@ -2145,15 +2145,13 @@ iso_status(int force) #endif /* INET_ONLY */ -struct in_addr inet_makeaddr(); - #define SIN(x) ((struct sockaddr_in *) &(x)) struct sockaddr_in *sintab[] = { SIN(ridreq.ifr_addr), SIN(in_addreq.ifra_addr), SIN(in_addreq.ifra_mask), SIN(in_addreq.ifra_broadaddr)}; void -in_getaddr(char *s, int which) +in_getaddr(const char *s, int which) { struct sockaddr_in *sin = sintab[which]; struct hostent *hp; @@ -2174,7 +2172,7 @@ in_getaddr(char *s, int which) } void -in_getprefix(char *plen, int which) +in_getprefix(const char *plen, int which) { struct sockaddr_in *sin = sintab[which]; u_char *cp; @@ -2234,7 +2232,7 @@ SIN6(in6_ridreq.ifr_addr), SIN6(in6_addreq.ifra_addr), SIN6(in6_addreq.ifra_prefixmask), SIN6(in6_addreq.ifra_dstaddr)}; void -in6_getaddr(char *s, int which) +in6_getaddr(const char *s, int which) { #ifndef KAME_SCOPEID struct sockaddr_in6 *sin6 = sin6tab[which]; @@ -2273,7 +2271,7 @@ in6_getaddr(char *s, int which) } void -in6_getprefix(char *plen, int which) +in6_getprefix(const char *plen, int which) { struct sockaddr_in6 *sin6 = sin6tab[which]; u_char *cp; @@ -2322,7 +2320,7 @@ prefix(void *val, int size) #ifndef INET_ONLY void -at_getaddr(char *addr, int which) +at_getaddr(const char *addr, int which) { struct sockaddr_at *sat = (struct sockaddr_at *) &addreq.ifra_addr; u_int net, node; @@ -2339,7 +2337,7 @@ at_getaddr(char *addr, int which) } void -setatrange(char *range, int d) +setatrange(const char *range, int d) { u_short first = 123, last = 123; @@ -2352,7 +2350,7 @@ setatrange(char *range, int d) } void -setatphase(char *phase, int d) +setatphase(const char *phase, int d) { if (!strcmp(phase, "1")) at_nr.nr_phase = 1; @@ -2386,10 +2384,9 @@ SNS(ridreq.ifr_addr), SNS(addreq.ifra_addr), SNS(addreq.ifra_mask), SNS(addreq.ifra_broadaddr)}; void -xns_getaddr(char *addr, int which) +xns_getaddr(const char *addr, int which) { struct sockaddr_ns *sns = snstab[which]; - struct ns_addr ns_addr(); sns->sns_family = AF_NS; sns->sns_len = sizeof(*sns); @@ -2404,10 +2401,9 @@ SIPX(ridreq.ifr_addr), SIPX(addreq.ifra_addr), SIPX(addreq.ifra_mask), SIPX(addreq.ifra_broadaddr)}; void -ipx_getaddr(char *addr, int which) +ipx_getaddr(const char *addr, int which) { struct sockaddr_ipx *sipx = sipxtab[which]; - struct ipx_addr ipx_addr(); sipx->sipx_family = AF_IPX; sipx->sipx_len = sizeof(*sipx); @@ -2423,10 +2419,9 @@ SISO(iso_ridreq.ifr_Addr), SISO(iso_addreq.ifra_addr), SISO(iso_addreq.ifra_mask), SISO(iso_addreq.ifra_dstaddr)}; void -iso_getaddr(char *addr, int which) +iso_getaddr(const char *addr, int which) { struct sockaddr_iso *siso = sisotab[which]; - struct iso_addr *iso_addr(); siso->siso_addr = *iso_addr(addr); if (which == MASK) { @@ -2439,13 +2434,13 @@ iso_getaddr(char *addr, int which) } void -setsnpaoffset(char *val) +setsnpaoffset(const char *val, int ignored) { iso_addreq.ifra_snpaoffset = atoi(val); } void -setnsellength(char *val) +setnsellength(const char *val, int ignored) { nsellength = atoi(val); if (nsellength < 0) @@ -2520,7 +2515,7 @@ vlan_status(void) } void -setvlantag(char *val, int d) +setvlantag(const char *val, int d) { u_int16_t tag; struct vlanreq vreq; @@ -2543,7 +2538,7 @@ setvlantag(char *val, int d) } void -setvlandev(char *val, int d) +setvlandev(const char *val, int d) { struct vlanreq vreq; @@ -2566,7 +2561,7 @@ setvlandev(char *val, int d) } void -unsetvlandev(char *val, int d) +unsetvlandev(const char *val, int d) { struct vlanreq vreq; diff --git a/usr.bin/find/extern.h b/usr.bin/find/extern.h index 390e2a595a4..525a6058962 100644 --- a/usr.bin/find/extern.h +++ b/usr.bin/find/extern.h @@ -1,4 +1,4 @@ -/* * $OpenBSD: extern.h,v 1.13 2003/06/03 02:56:08 millert Exp $*/ +/* * $OpenBSD: extern.h,v 1.14 2003/06/26 07:27:29 deraadt Exp $*/ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -46,44 +46,44 @@ void printlong(char *, char *, struct stat *); int queryuser(char **); void show_path(int); -PLAN *c_amin(char *); -PLAN *c_anewer(char *); -PLAN *c_atime(char *); -PLAN *c_cmin(char *); -PLAN *c_cnewer(char *); -PLAN *c_ctime(char *); -PLAN *c_depth(void); -PLAN *c_empty(void); -PLAN *c_exec(char ***, int); -PLAN *c_execdir(char ***); -PLAN *c_flags(char *); -PLAN *c_follow(void); -PLAN *c_fstype(char *); -PLAN *c_group(char *); -PLAN *c_iname(char *); -PLAN *c_inum(char *); -PLAN *c_links(char *); -PLAN *c_ls(void); -PLAN *c_maxdepth(char *); -PLAN *c_mindepth(char *); -PLAN *c_mmin(char *); -PLAN *c_name(char *); -PLAN *c_newer(char *); -PLAN *c_nogroup(void); -PLAN *c_nouser(void); -PLAN *c_path(char *); -PLAN *c_perm(char *); -PLAN *c_print(void); -PLAN *c_print0(void); -PLAN *c_prune(void); -PLAN *c_size(char *); -PLAN *c_type(char *); -PLAN *c_user(char *); -PLAN *c_xdev(void); -PLAN *c_openparen(void); -PLAN *c_closeparen(void); -PLAN *c_mtime(char *); -PLAN *c_not(void); -PLAN *c_or(void); +PLAN *c_amin(char *, char ***, int); +PLAN *c_anewer(char *, char ***, int); +PLAN *c_atime(char *, char ***, int); +PLAN *c_cmin(char *, char ***, int); +PLAN *c_cnewer(char *, char ***, int); +PLAN *c_ctime(char *, char ***, int); +PLAN *c_depth(char *, char ***, int); +PLAN *c_empty(char *, char ***, int); +PLAN *c_exec(char *, char ***, int); +PLAN *c_execdir(char *, char ***, int); +PLAN *c_flags(char *, char ***, int); +PLAN *c_follow(char *, char ***, int); +PLAN *c_fstype(char *, char ***, int); +PLAN *c_group(char *, char ***, int); +PLAN *c_iname(char *, char ***, int); +PLAN *c_inum(char *, char ***, int); +PLAN *c_links(char *, char ***, int); +PLAN *c_ls(char *, char ***, int); +PLAN *c_maxdepth(char *, char ***, int); +PLAN *c_mindepth(char *, char ***, int); +PLAN *c_mmin(char *, char ***, int); +PLAN *c_name(char *, char ***, int); +PLAN *c_newer(char *, char ***, int); +PLAN *c_nogroup(char *, char ***, int); +PLAN *c_nouser(char *, char ***, int); +PLAN *c_path(char *, char ***, int); +PLAN *c_perm(char *, char ***, int); +PLAN *c_print(char *, char ***, int); +PLAN *c_print0(char *, char ***, int); +PLAN *c_prune(char *, char ***, int); +PLAN *c_size(char *, char ***, int); +PLAN *c_type(char *, char ***, int); +PLAN *c_user(char *, char ***, int); +PLAN *c_xdev(char *, char ***, int); +PLAN *c_openparen(char *, char ***, int); +PLAN *c_closeparen(char *, char ***, int); +PLAN *c_mtime(char *, char ***, int); +PLAN *c_not(char *, char ***, int); +PLAN *c_or(char *, char ***, int); extern int ftsoptions, isdeprecated, isdepth, isoutput, isxargs; diff --git a/usr.bin/find/find.c b/usr.bin/find/find.c index ba15fdd4a25..6c9cfdcf8f2 100644 --- a/usr.bin/find/find.c +++ b/usr.bin/find/find.c @@ -1,4 +1,4 @@ -/* $OpenBSD: find.c,v 1.9 2003/06/03 02:56:08 millert Exp $ */ +/* $OpenBSD: find.c,v 1.10 2003/06/26 07:27:29 deraadt Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -34,7 +34,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)find.c 8.1 (Berkeley) 6/6/93";*/ -static char rcsid[] = "$OpenBSD: find.c,v 1.9 2003/06/03 02:56:08 millert Exp $"; +static char rcsid[] = "$OpenBSD: find.c,v 1.10 2003/06/26 07:27:29 deraadt Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -95,16 +95,16 @@ find_formplan(argv) */ if (!isoutput) { if (plan == NULL) { - new = c_print(); + new = c_print(NULL, NULL, 0); tail = plan = new; } else { - new = c_openparen(); + new = c_openparen(NULL, NULL, 0); new->next = plan; plan = new; - new = c_closeparen(); + new = c_closeparen(NULL, NULL, 0); tail->next = new; tail = new; - new = c_print(); + new = c_print(NULL, NULL, 0); tail->next = new; tail = new; } diff --git a/usr.bin/find/find.h b/usr.bin/find/find.h index d97b2647e57..37af2a433e9 100644 --- a/usr.bin/find/find.h +++ b/usr.bin/find/find.h @@ -1,4 +1,4 @@ -/* * $OpenBSD: find.h,v 1.12 2003/06/03 02:56:08 millert Exp $*/ +/* * $OpenBSD: find.h,v 1.13 2003/06/26 07:27:29 deraadt Exp $*/ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -106,12 +106,12 @@ typedef struct _plandata { #define e_len p_un.ex._e_len typedef struct _option { - char *name; /* option name */ - enum ntype token; /* token type */ - PLAN *(*create)(); /* create function: DON'T PROTOTYPE! */ -#define O_NONE 0x01 /* no call required */ -#define O_ZERO 0x02 /* pass: nothing */ -#define O_ARGV 0x04 /* pass: argv, increment argv */ + char *name; /* option name */ + enum ntype token; /* token type */ + PLAN *(*create)(char *, char ***, int); /* create function */ +#define O_NONE 0x01 /* no call required */ +#define O_ZERO 0x02 /* pass: nothing */ +#define O_ARGV 0x04 /* pass: argv, increment argv */ #define O_ARGVP 0x08 /* pass: *argv, N_OK || N_EXEC || N_EXECDIR */ int flags; } OPTION; diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c index b01a36a4480..569b8d0a763 100644 --- a/usr.bin/find/function.c +++ b/usr.bin/find/function.c @@ -1,4 +1,4 @@ -/* $OpenBSD: function.c,v 1.27 2003/06/10 22:20:46 deraadt Exp $ */ +/* $OpenBSD: function.c,v 1.28 2003/06/26 07:27:29 deraadt Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -34,7 +34,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)function.c 8.1 (Berkeley) 6/6/93";*/ -static char rcsid[] = "$OpenBSD: function.c,v 1.27 2003/06/10 22:20:46 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: function.c,v 1.28 2003/06/26 07:27:29 deraadt Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -59,6 +59,7 @@ static char rcsid[] = "$OpenBSD: function.c,v 1.27 2003/06/10 22:20:46 deraadt E #include <unistd.h> #include "find.h" +#include "extern.h" #define COMPARE(a, b) { \ switch (plan->flags) { \ @@ -74,6 +75,46 @@ static char rcsid[] = "$OpenBSD: function.c,v 1.27 2003/06/10 22:20:46 deraadt E } static PLAN *palloc(enum ntype, int (*)(PLAN *, FTSENT *)); +static long find_parsenum(PLAN *plan, char *option, char *vp, char *endch); +static PLAN *palloc(enum ntype t, int (*f)(PLAN *, FTSENT *)); + +int f_amin(PLAN *, FTSENT *); +int f_atime(PLAN *, FTSENT *); +int f_cmin(PLAN *, FTSENT *); +int f_ctime(PLAN *, FTSENT *); +int f_always_true(PLAN *, FTSENT *); +int f_empty(PLAN *, FTSENT *); +int f_exec(PLAN *, FTSENT *); +int f_execdir(PLAN *, FTSENT *); +int f_flags(PLAN *, FTSENT *); +int f_fstype(PLAN *, FTSENT *); +int f_group(PLAN *, FTSENT *); +int f_inum(PLAN *, FTSENT *); +int f_empty(PLAN *, FTSENT *); +int f_links(PLAN *, FTSENT *); +int f_ls(PLAN *, FTSENT *); +int f_maxdepth(PLAN *, FTSENT *); +int f_mindepth(PLAN *, FTSENT *); +int f_mtime(PLAN *, FTSENT *); +int f_mmin(PLAN *, FTSENT *); +int f_name(PLAN *, FTSENT *); +int f_iname(PLAN *, FTSENT *); +int f_newer(PLAN *, FTSENT *); +int f_anewer(PLAN *, FTSENT *); +int f_cnewer(PLAN *, FTSENT *); +int f_nogroup(PLAN *, FTSENT *); +int f_nouser(PLAN *, FTSENT *); +int f_path(PLAN *, FTSENT *); +int f_perm(PLAN *, FTSENT *); +int f_print(PLAN *, FTSENT *); +int f_print0(PLAN *, FTSENT *); +int f_prune(PLAN *, FTSENT *); +int f_size(PLAN *, FTSENT *); +int f_type(PLAN *, FTSENT *); +int f_user(PLAN *, FTSENT *); +int f_expr(PLAN *, FTSENT *); +int f_not(PLAN *, FTSENT *); +int f_or(PLAN *, FTSENT *); extern int dotfd; extern time_t now; @@ -150,8 +191,7 @@ f_amin(plan, entry) } PLAN * -c_amin(arg) - char *arg; +c_amin(char *arg, char ***ignored, int unused) { PLAN *new; @@ -180,8 +220,7 @@ f_atime(plan, entry) } PLAN * -c_atime(arg) - char *arg; +c_atime(char *arg, char ***ignored, int unused) { PLAN *new; @@ -211,8 +250,7 @@ f_cmin(plan, entry) } PLAN * -c_cmin(arg) - char *arg; +c_cmin(char *arg, char ***ignored, int unused) { PLAN *new; @@ -241,8 +279,7 @@ f_ctime(plan, entry) } PLAN * -c_ctime(arg) - char *arg; +c_ctime(char *arg, char ***ignored, int unused) { PLAN *new; @@ -270,7 +307,7 @@ f_always_true(plan, entry) } PLAN * -c_depth(void) +c_depth(char *ignore, char ***ignored, int unused) { isdepth = 1; @@ -312,7 +349,7 @@ f_empty(plan, entry) } PLAN * -c_empty(void) +c_empty(char *ignore, char ***ignored, int unused) { ftsoptions &= ~FTS_NOSTAT; @@ -377,9 +414,7 @@ f_exec(plan, entry) * strings, but also flags meaning that the string has to be massaged. */ PLAN * -c_exec(argvp, isok) - char ***argvp; - int isok; +c_exec(char *unused, char ***argvp, int isok) { PLAN *new; /* node returned */ int cnt; @@ -498,8 +533,7 @@ f_execdir(plan, entry) * strings, but also flags meaning that the string has to be massaged. */ PLAN * -c_execdir(argvp) - char ***argvp; +c_execdir(char *ignored, char ***argvp, int unused) { PLAN *new; /* node returned */ int cnt; @@ -567,8 +601,7 @@ f_flags(plan, entry) } PLAN * -c_flags(flags_str) - char *flags_str; +c_flags(char *flags_str, char ***ignored, int unused) { PLAN *new; u_int32_t flags, notflags; @@ -597,7 +630,7 @@ c_flags(flags_str) * basis. */ PLAN * -c_follow(void) +c_follow(char *ignore, char ***ignored, int unused) { ftsoptions &= ~FTS_PHYSICAL; ftsoptions |= FTS_LOGICAL; @@ -672,8 +705,7 @@ f_fstype(plan, entry) } PLAN * -c_fstype(arg) - char *arg; +c_fstype(char *arg, char ***ignored, int unused) { PLAN *new; @@ -718,8 +750,7 @@ f_group(plan, entry) } PLAN * -c_group(gname) - char *gname; +c_group(char *gname, char ***ignored, int unused) { PLAN *new; struct group *g; @@ -754,8 +785,7 @@ f_inum(plan, entry) } PLAN * -c_inum(arg) - char *arg; +c_inum(char *arg, char ***ignored, int unused) { PLAN *new; @@ -780,8 +810,7 @@ f_links(plan, entry) } PLAN * -c_links(arg) - char *arg; +c_links(char *arg, char ***ignored, int unused) { PLAN *new; @@ -807,7 +836,7 @@ f_ls(plan, entry) } PLAN * -c_ls(void) +c_ls(char *ignore, char ***ignored, int unused) { ftsoptions &= ~FTS_NOSTAT; isoutput = 1; @@ -833,8 +862,7 @@ f_maxdepth(plan, entry) } PLAN * -c_maxdepth(arg) - char *arg; +c_maxdepth(char *arg, char ***ignored, int unused) { PLAN *new; @@ -859,8 +887,7 @@ f_mindepth(plan, entry) } PLAN * -c_mindepth(arg) - char *arg; +c_mindepth(char *arg, char ***ignored, int unused) { PLAN *new; @@ -886,8 +913,7 @@ f_mtime(plan, entry) } PLAN * -c_mtime(arg) - char *arg; +c_mtime(char *arg, char ***ignored, int unused) { PLAN *new; @@ -917,8 +943,7 @@ f_mmin(plan, entry) } PLAN * -c_mmin(arg) - char *arg; +c_mmin(char *arg, char ***ignored, int unused) { PLAN *new; @@ -945,8 +970,7 @@ f_name(plan, entry) } PLAN * -c_name(pattern) - char *pattern; +c_name(char *pattern, char ***ignored, int unused) { PLAN *new; @@ -970,8 +994,7 @@ f_iname(plan, entry) } PLAN * -c_iname(pattern) - char *pattern; +c_iname(char *pattern, char ***ignored, int unused) { PLAN *new; @@ -999,8 +1022,7 @@ f_newer(plan, entry) } PLAN * -c_newer(filename) - char *filename; +c_newer(char *filename, char ***ignored, int unused) { PLAN *new; struct stat sb; @@ -1033,8 +1055,7 @@ f_anewer(plan, entry) } PLAN * -c_anewer(filename) - char *filename; +c_anewer(char *filename, char ***ignored, int unused) { PLAN *new; struct stat sb; @@ -1067,8 +1088,7 @@ f_cnewer(plan, entry) } PLAN * -c_cnewer(filename) - char *filename; +c_cnewer(char *filename, char ***ignored, int unused) { PLAN *new; struct stat sb; @@ -1097,7 +1117,7 @@ f_nogroup(plan, entry) } PLAN * -c_nogroup(void) +c_nogroup(char *ignore, char ***ignored, int unused) { ftsoptions &= ~FTS_NOSTAT; @@ -1119,7 +1139,7 @@ f_nouser(plan, entry) } PLAN * -c_nouser(void) +c_nouser(char *ignore, char ***ignored, int unused) { ftsoptions &= ~FTS_NOSTAT; @@ -1141,8 +1161,7 @@ f_path(plan, entry) } PLAN * -c_path(pattern) - char *pattern; +c_path(char *pattern, char ***ignored, int unused) { PLAN *new; @@ -1175,8 +1194,7 @@ f_perm(plan, entry) } PLAN * -c_perm(perm) - char *perm; +c_perm(char *perm, char ***ignored, int unused) { PLAN *new; mode_t *set; @@ -1225,7 +1243,7 @@ f_print0(plan, entry) } PLAN * -c_print(void) +c_print(char *ignore, char ***ignored, int unused) { isoutput = 1; @@ -1233,7 +1251,7 @@ c_print(void) } PLAN * -c_print0(void) +c_print0(char *ignore, char ***ignored, int unused) { isoutput = 1; @@ -1257,7 +1275,7 @@ f_prune(plan, entry) } PLAN * -c_prune(void) +c_prune(char *ignore, char ***ignored, int unused) { return (palloc(N_PRUNE, f_prune)); } @@ -1285,8 +1303,7 @@ f_size(plan, entry) } PLAN * -c_size(arg) - char *arg; +c_size(char *arg, char ***ignored, int unused) { PLAN *new; char endch; @@ -1317,8 +1334,7 @@ f_type(plan, entry) } PLAN * -c_type(typestring) - char *typestring; +c_type(char *typestring, char ***ignored, int unused) { PLAN *new; mode_t mask; @@ -1379,8 +1395,7 @@ f_user(plan, entry) } PLAN * -c_user(username) - char *username; +c_user(char *username, char ***ignored, int unused) { PLAN *new; struct passwd *p; @@ -1408,7 +1423,7 @@ c_user(username) * different device ID (st_dev, see stat() S5.6.2 [POSIX.1]) */ PLAN * -c_xdev(void) +c_xdev(char *ignore, char ***ignored, int unused) { ftsoptions |= FTS_XDEV; @@ -1439,15 +1454,15 @@ f_expr(plan, entry) * to a N_EXPR node containing the expression and the ')' node is discarded. */ PLAN * -c_openparen(void) +c_openparen(char *ignore, char ***ignored, int unused) { - return (palloc(N_OPENPAREN, (int (*)())-1)); + return (palloc(N_OPENPAREN, (int (*)(PLAN *, FTSENT *))-1)); } PLAN * -c_closeparen(void) +c_closeparen(char *ignore, char ***ignored, int unused) { - return (palloc(N_CLOSEPAREN, (int (*)())-1)); + return (palloc(N_CLOSEPAREN, (int (*)(PLAN *, FTSENT *))-1)); } /* @@ -1469,7 +1484,7 @@ f_not(plan, entry) } PLAN * -c_not(void) +c_not(char *ignore, char ***ignored, int unused) { return (palloc(N_NOT, f_not)); } @@ -1500,15 +1515,13 @@ f_or(plan, entry) } PLAN * -c_or(void) +c_or(char *ignore, char ***ignored, int unused) { return (palloc(N_OR, f_or)); } static PLAN * -palloc(t, f) - enum ntype t; - int (*f)(PLAN *, FTSENT *); +palloc(enum ntype t, int (*f)(PLAN *, FTSENT *)) { PLAN *new; diff --git a/usr.bin/find/ls.c b/usr.bin/find/ls.c index 1406c6cbc43..9ada82bd191 100644 --- a/usr.bin/find/ls.c +++ b/usr.bin/find/ls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ls.c,v 1.10 2003/06/03 02:56:08 millert Exp $ */ +/* $OpenBSD: ls.c,v 1.11 2003/06/26 07:27:29 deraadt Exp $ */ /* * Copyright (c) 1989, 1993 @@ -31,7 +31,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)ls.c 8.1 (Berkeley) 6/6/93";*/ -static char rcsid[] = "$OpenBSD: ls.c,v 1.10 2003/06/03 02:56:08 millert Exp $"; +static char rcsid[] = "$OpenBSD: ls.c,v 1.11 2003/06/26 07:27:29 deraadt Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -45,6 +45,8 @@ static char rcsid[] = "$OpenBSD: ls.c,v 1.10 2003/06/03 02:56:08 millert Exp $"; #include <tzfile.h> #include <unistd.h> #include <utmp.h> +#include <pwd.h> +#include <grp.h> /* Derived from the print routines in the ls(1) source code. */ @@ -54,12 +56,9 @@ static void printtime(time_t); #define NAME_WIDTH 8 void -printlong(name, accpath, sb) - char *name; /* filename to print */ - char *accpath; /* current valid path to filename */ - struct stat *sb; /* stat buffer */ +printlong(char *name, char *accpath, struct stat *sb) { - char modep[15], *user_from_uid(), *group_from_gid(); + char modep[15]; (void)printf("%6u %4lld ", sb->st_ino, (long long)sb->st_blocks); (void)strmode(sb->st_mode, modep); @@ -80,8 +79,7 @@ printlong(name, accpath, sb) } static void -printtime(ftime) - time_t ftime; +printtime(time_t ftime) { int i; char *longstring; @@ -103,8 +101,7 @@ printtime(ftime) } static void -printlink(name) - char *name; +printlink(char *name) { int lnklen; char path[MAXPATHLEN]; diff --git a/usr.bin/find/misc.c b/usr.bin/find/misc.c index db0fd3bb77b..ad343b56e18 100644 --- a/usr.bin/find/misc.c +++ b/usr.bin/find/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.8 2003/06/03 02:56:08 millert Exp $ */ +/* $OpenBSD: misc.c,v 1.9 2003/06/26 07:27:29 deraadt Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -34,11 +34,12 @@ #ifndef lint /*static char sccsid[] = "from: @(#)misc.c 8.1 (Berkeley) 6/6/93";*/ -static char rcsid[] = "$OpenBSD: misc.c,v 1.8 2003/06/03 02:56:08 millert Exp $"; +static char rcsid[] = "$OpenBSD: misc.c,v 1.9 2003/06/26 07:27:29 deraadt Exp $"; #endif /* not lint */ #include <sys/types.h> #include <sys/stat.h> +#include <sys/uio.h> #include <err.h> #include <errno.h> @@ -55,9 +56,7 @@ static char rcsid[] = "$OpenBSD: misc.c,v 1.8 2003/06/03 02:56:08 millert Exp $" * Replace occurrences of {} in s1 with s2 and return the result string. */ void -brace_subst(orig, store, path, len) - char *orig, **store, *path; - int len; +brace_subst(char *orig, char **store, char *path, int len) { int plen; char ch, *p; @@ -82,8 +81,7 @@ brace_subst(orig, store, path, len) * input. If the input is 'y' then 1 is returned. */ int -queryuser(argv) - char **argv; +queryuser(char **argv) { int ch, first, nl; @@ -116,8 +114,7 @@ queryuser(argv) * malloc with error checking. */ void * -emalloc(len) - u_int len; +emalloc(u_int len) { void *p; @@ -132,16 +129,20 @@ emalloc(len) */ /* ARGSUSED */ void -show_path(sig) - int sig; +show_path(int signo) { int save_errno = errno; extern FTSENT *entry; + struct iovec iov[3]; if (entry != NULL) { - write(STDERR_FILENO, "find path: ", 11); - write(STDERR_FILENO, entry->fts_path, entry->fts_pathlen); - write(STDERR_FILENO, "\n", 1); + iov[0].iov_base = "find path: "; + iov[0].iov_len = strlen(iov[0].iov_base); + iov[1].iov_base = entry->fts_path; + iov[1].iov_len = entry->fts_pathlen; + iov[2].iov_base = "\n"; + iov[2].iov_len = strlen(iov[2].iov_base); + writev(STDERR_FILENO, iov, 3); errno = save_errno; } } diff --git a/usr.bin/find/operator.c b/usr.bin/find/operator.c index 28fe6a57aae..2c977292c5d 100644 --- a/usr.bin/find/operator.c +++ b/usr.bin/find/operator.c @@ -1,4 +1,4 @@ -/* $OpenBSD: operator.c,v 1.7 2003/06/03 02:56:08 millert Exp $ */ +/* $OpenBSD: operator.c,v 1.8 2003/06/26 07:27:29 deraadt Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -34,7 +34,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)operator.c 8.1 (Berkeley) 6/6/93";*/ -static char rcsid[] = "$OpenBSD: operator.c,v 1.7 2003/06/03 02:56:08 millert Exp $"; +static char rcsid[] = "$OpenBSD: operator.c,v 1.8 2003/06/26 07:27:29 deraadt Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -45,14 +45,14 @@ static char rcsid[] = "$OpenBSD: operator.c,v 1.7 2003/06/03 02:56:08 millert Ex #include <stdio.h> #include "find.h" +#include "extern.h" /* * yanknode -- * destructively removes the top from the plan */ static PLAN * -yanknode(planp) - PLAN **planp; /* pointer to top of plan (modified) */ +yanknode(PLAN **planp) /* pointer to top of plan (modified) */ { PLAN *node; /* top node removed from the plan */ @@ -70,14 +70,13 @@ yanknode(planp) * simple node or a N_EXPR node containing a list of simple nodes. */ static PLAN * -yankexpr(planp) - PLAN **planp; /* pointer to top of plan (modified) */ +yankexpr(PLAN **planp) /* pointer to top of plan (modified) */ { PLAN *next; /* temp node holding subexpression results */ PLAN *node; /* pointer to returned node or expression */ PLAN *tail; /* pointer to tail of subplan */ PLAN *subplan; /* pointer to head of ( ) expression */ - int f_expr(); + extern int f_expr(PLAN *, FTSENT *); /* first pull the top node from the plan */ if ((node = yanknode(planp)) == NULL) @@ -125,8 +124,7 @@ yankexpr(planp) * replaces "parentheisized" plans in our search plan with "expr" nodes. */ PLAN * -paren_squish(plan) - PLAN *plan; /* plan with ( ) nodes */ +paren_squish(PLAN *plan) /* plan with ( ) nodes */ { PLAN *expr; /* pointer to next expression */ PLAN *tail; /* pointer to tail of result plan */ @@ -163,8 +161,7 @@ paren_squish(plan) * compresses "!" expressions in our search plan. */ PLAN * -not_squish(plan) - PLAN *plan; /* plan to process */ +not_squish(PLAN *plan) /* plan to process */ { PLAN *next; /* next node being processed */ PLAN *node; /* temporary node used in N_NOT processing */ @@ -223,8 +220,7 @@ not_squish(plan) * compresses -o expressions in our search plan. */ PLAN * -or_squish(plan) - PLAN *plan; /* plan with ors to be squished */ +or_squish(PLAN *plan) /* plan with ors to be squished */ { PLAN *next; /* next node being processed */ PLAN *tail; /* pointer to tail of result plan */ diff --git a/usr.bin/find/option.c b/usr.bin/find/option.c index 86580203e7a..d8f6a515a50 100644 --- a/usr.bin/find/option.c +++ b/usr.bin/find/option.c @@ -1,4 +1,4 @@ -/* $OpenBSD: option.c,v 1.15 2003/06/03 02:56:08 millert Exp $ */ +/* $OpenBSD: option.c,v 1.16 2003/06/26 07:27:29 deraadt Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -34,7 +34,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)option.c 8.1 (Berkeley) 6/6/93";*/ -static char rcsid[] = "$OpenBSD: option.c,v 1.15 2003/06/03 02:56:08 millert Exp $"; +static char rcsid[] = "$OpenBSD: option.c,v 1.16 2003/06/26 07:27:29 deraadt Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -47,6 +47,7 @@ static char rcsid[] = "$OpenBSD: option.c,v 1.15 2003/06/03 02:56:08 millert Exp #include <string.h> #include "find.h" +#include "extern.h" /* NB: the following table must be sorted lexically. */ static OPTION options[] = { @@ -105,8 +106,7 @@ static OPTION options[] = { * this switch stuff. */ PLAN * -find_create(argvp) - char ***argvp; +find_create(char ***argvp) { OPTION *p; PLAN *new; @@ -125,13 +125,13 @@ find_create(argvp) new = NULL; break; case O_ZERO: - new = (p->create)(); + new = (p->create)(NULL, NULL, 0); break; case O_ARGV: - new = (p->create)(*argv++); + new = (p->create)(*argv++, NULL, 0); break; case O_ARGVP: - new = (p->create)(&argv, p->token == N_OK); + new = (p->create)(NULL, &argv, p->token == N_OK); break; default: abort(); @@ -141,8 +141,7 @@ find_create(argvp) } OPTION * -option(name) - char *name; +option(char *name) { OPTION tmp; int typecompare(const void *, const void *); @@ -153,8 +152,7 @@ option(name) } int -typecompare(a, b) - const void *a, *b; +typecompare(const void *a, const void *b) { return (strcmp(((OPTION *)a)->name, ((OPTION *)b)->name)); } |