summaryrefslogtreecommitdiffstats
path: root/misc-utils
diff options
context:
space:
mode:
authorKarel Zak2006-12-07 00:25:35 +0100
committerKarel Zak2006-12-07 00:25:35 +0100
commit2b6fc908bc368b540845a313c3b8a867c5ad9a42 (patch)
tree6fad48a239bc90515a5dc4084d6e3c3ee1f41e29 /misc-utils
parentImported from util-linux-2.7.1 tarball. (diff)
downloadkernel-qcow2-util-linux-2b6fc908bc368b540845a313c3b8a867c5ad9a42.tar.gz
kernel-qcow2-util-linux-2b6fc908bc368b540845a313c3b8a867c5ad9a42.tar.xz
kernel-qcow2-util-linux-2b6fc908bc368b540845a313c3b8a867c5ad9a42.zip
Imported from util-linux-2.8 tarball.
Diffstat (limited to 'misc-utils')
-rw-r--r--misc-utils/Makefile24
-rw-r--r--misc-utils/cal.c6
-rw-r--r--misc-utils/getoptprog.1104
-rw-r--r--misc-utils/getoptprog.c32
-rw-r--r--misc-utils/hostid.123
-rw-r--r--misc-utils/hostid.c36
-rw-r--r--misc-utils/logger.c10
-rw-r--r--misc-utils/look.c10
-rw-r--r--misc-utils/namei.c7
-rw-r--r--misc-utils/script.c11
-rw-r--r--misc-utils/setterm.c1
-rw-r--r--misc-utils/tsort.c10
-rw-r--r--misc-utils/whereis.161
-rw-r--r--misc-utils/whereis.c253
-rw-r--r--misc-utils/write.c20
15 files changed, 104 insertions, 504 deletions
diff --git a/misc-utils/Makefile b/misc-utils/Makefile
index 1ae67df3f..e33165f7f 100644
--- a/misc-utils/Makefile
+++ b/misc-utils/Makefile
@@ -9,7 +9,7 @@ include ../MCONFIG
# Where to put man pages?
-MAN1= cal.1 chkdupexe.1 ddate.1 hostid.1 kill.1 \
+MAN1= cal.1 chkdupexe.1 ddate.1 kill.1 \
logger.1 look.1 mcookie.1 namei.1 script.1 \
setterm.1 tsort.1 whereis.1 write.1
@@ -18,7 +18,7 @@ MAN1= cal.1 chkdupexe.1 ddate.1 hostid.1 kill.1 \
BIN= kill
-USRBIN= cal chkdupexe ddate hostid logger look mcookie \
+USRBIN= cal chkdupexe ddate logger look mcookie \
namei script setterm tsort whereis write
ifeq "$(HAVE_CLEAR)" "no"
@@ -39,10 +39,14 @@ endif
NEEDS_CURSES= setterm
-all: $(BIN) $(USRBIN) $(USRBIN.NONSHADOW) $(USRGAMES) getoptprog
+all: $(BIN) $(USRBIN) $(USRBIN.NONSHADOW) $(USRGAMES)
$(NEEDS_CURSES):
+ifeq "$(HAVE_NCURSES)" "yes"
$(CC) $(LDFLAGS) $^ -o $@ $(LIBCURSES)
+else
+ @echo $@ not made since it requires ncurses
+endif
%: %.sh
cp $@.sh $@
@@ -57,28 +61,24 @@ $(NEEDS_CURSES):
cal: cal.o $(BSD)/getopt.o $(BSD)/err.o
chkdupexe: chkdupexe.pl
clear: clear.sh
-getoptprog: getoptprog.o $(BSD)/getopt.o
-hostid: hostid.o
kill: kill.o procs.o
logger: logger.o $(BSD)/getopt.o
mcookie: mcookie.o md5.o
mcookie.o: mcookie.c md5.h
md5.o: md5.c md5.h
-namei: namei.o
reset: reset.sh
-script: script.o
-setterm: setterm.o
-tsort: tsort.o
# pidof: pidof.o procs.o
+ifeq "$(HAVE_NCURSES)" "yes"
+setterm: setterm.o
+endif
+
install: all
$(INSTALLDIR) $(BINDIR) $(USRBINDIR)
$(INSTALLBIN) $(BIN) $(BINDIR)
$(INSTALLBIN) $(USRBIN) $(USRBINDIR)
- $(INSTALLBIN) getoptprog $(USRBINDIR)/getopt
$(INSTALLDIR) $(MAN1DIR) $(MAN8DIR)
$(INSTALLMAN) $(MAN1) $(MAN1DIR)
- $(INSTALLMAN) getoptprog.1 $(MAN1DIR)/getopt.1
ifeq "$(USE_TTY_GROUP)" "yes"
chgrp tty $(USRBINDIR)/write
chmod g+s $(USRBINDIR)/write
@@ -86,4 +86,4 @@ endif
.PHONY: clean
clean:
- -rm -f *.o *~ core $(BIN) $(USRBIN) getoptprog
+ -rm -f *.o *~ core $(BIN) $(USRBIN)
diff --git a/misc-utils/cal.c b/misc-utils/cal.c
index ecdc79987..9d44d327b 100644
--- a/misc-utils/cal.c
+++ b/misc-utils/cal.c
@@ -34,12 +34,6 @@
* SUCH DAMAGE.
*/
-static char copyright[] =
-"@(#) Copyright (c) 1989, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-static char sccsid[] = "@(#)cal.c 8.4 (Berkeley) 4/2/94";
-
-
/* This defines _LINUX_C_LIB_VERSION_MAJOR, dunno about gnulibc. We
don't want it to read /usr/i586-unknown-linux/include/_G_config.h
so we specify fill path. Were we got /usr/i586-unknown-linux from?
diff --git a/misc-utils/getoptprog.1 b/misc-utils/getoptprog.1
deleted file mode 100644
index 12853af7d..000000000
--- a/misc-utils/getoptprog.1
+++ /dev/null
@@ -1,104 +0,0 @@
-.Dd June 21, 1993
-.Dt GETOPT 1
-.Os
-.Sh NAME
-.Nm getopt
-.Nd parse command options
-.Sh SYNOPSIS
-.Nm set \-\- \`getopt optstring $*\`
-.Sh DESCRIPTION
-.Nm Getopt
-is used to break up options in command lines for easy parsing by
-shell procedures, and to check for legal options.
-.Op Optstring
-is a string of recognized option letters (see
-.Xr getopt 3
-);
-if a letter is followed by a colon, the option
-is expected to have an argument which may or may not be
-separated from it by white space.
-The special option
-.B \-\-
-is used to delimit the end of the options.
-.Nm Getopt
-will place
-.B \-\-
-in the arguments at the end of the options,
-or recognize it if used explicitly.
-The shell arguments
-(\fB$1 $2\fR ...) are reset so that each option is
-preceded by a
-.B \-
-and in its own shell argument;
-each option argument is also in its own shell argument.
-.Sh EXAMPLE
-The following code fragment shows how one might process the arguments
-for a command that can take the options
-.Op a
-and
-.Op b ,
-and the option
-.Op o ,
-which requires an argument.
-.Pp
-.Bd -literal -offset indent
-set \-\- \`getopt abo: $*\`
-if test $? != 0
-then
- echo 'Usage: ...'
- exit 2
-fi
-for i
-do
- case "$i"
- in
- \-a|\-b)
- flag=$i; shift;;
- \-o)
- oarg=$2; shift; shift;;
- \-\-)
- shift; break;;
- esac
-done
-.Ed
-.Pp
-This code will accept any of the following as equivalent:
-.Pp
-.Bd -literal -offset indent
-cmd \-aoarg file file
-cmd \-a \-o arg file file
-cmd \-oarg -a file file
-cmd \-a \-oarg \-\- file file
-.Ed
-.Sh SEE ALSO
-.Xr sh 1 ,
-.Xr getopt 3
-.Sh DIAGNOSTICS
-.Nm Getopt
-prints an error message on the standard error output when it
-encounters an option letter not included in
-.Op optstring .
-.Sh HISTORY
-Written by Henry Spencer, working from a Bell Labs manual page.
-Behavior believed identical to the Bell version.
-.Sh BUGS
-Whatever
-.Xr getopt 3
-has.
-.Pp
-Arguments containing white space or imbedded shell metacharacters
-generally will not survive intact; this looks easy to fix but isn't.
-.Pp
-The error message for an invalid option is identified as coming
-from
-.Nm getopt
-rather than from the shell procedure containing the invocation
-of
-.Nm getopt ;
-this again is hard to fix.
-.Pp
-The precise best way to use the
-.Nm set
-command to set the arguments without disrupting the value(s) of
-shell options varies from one shell version to another.
-varies from one shell version to another.
diff --git a/misc-utils/getoptprog.c b/misc-utils/getoptprog.c
deleted file mode 100644
index 94eac145a..000000000
--- a/misc-utils/getoptprog.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include <stdio.h>
-#include <unistd.h>
-
-int
-main(argc, argv)
-int argc;
-char *argv[];
-{
- extern int optind;
- extern char *optarg;
- int c;
- int status = 0;
-
- optind = 2; /* Past the program name and the option letters. */
- while ((c = getopt(argc, argv, argv[1])) != EOF)
- switch (c) {
- case '?':
- status = 1; /* getopt routine gave message */
- break;
- default:
- if (optarg != NULL)
- printf(" -%c %s", c, optarg);
- else
- printf(" -%c", c);
- break;
- }
- printf(" --");
- for (; optind < argc; optind++)
- printf(" %s", argv[optind]);
- printf("\n");
- return status;
-}
diff --git a/misc-utils/hostid.1 b/misc-utils/hostid.1
deleted file mode 100644
index 9830a53d8..000000000
--- a/misc-utils/hostid.1
+++ /dev/null
@@ -1,23 +0,0 @@
-.TH hostid 1
-.SH NAME
-hostid \- set or print system's host id.
-.SH SYNTAX
-.B hostid
-[\-v] [\|\fIdecimal-id\fR\|]
-.SH DESCRIPTION
-.\".NXR "hostid command"
-The
-.B hostid
-command prints the current host id number in hexadecimal and both
-decimal and hexadecimal in parenthesis if the \-v option is given.
-This numeric value is expected to be unique across all hosts
-and is normally set to resemble the host's Internet address.
-
-Only the super-user can set the hostid by giving an argument. This value is
-stored in the file /etc/hostid and need only be performed once.
-
-.SH AUTHOR
-Hostid is written by Mitch DSouza \- (m.dsouza@mrc-apu.cam.ac.uk)
-
-.SH SEE ALSO
-gethostid(2), sethostid(2)
diff --git a/misc-utils/hostid.c b/misc-utils/hostid.c
deleted file mode 100644
index 211e4ce5a..000000000
--- a/misc-utils/hostid.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Mitch DSouza - (m.dsouza@mrc-apu.cam.ac.uk) */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-#include <getopt.h>
-
-int main (int argc, char **argv)
-{
- int verbose = 0;
-
- if(argc == 2 && strcmp(argv[1], "-v") == 0) {
- verbose = 1;
- argc--;
- argv++;
- }
-
- if (argc==2) {
- if (sethostid(atoi(argv[1]))!=0) {
- perror("sethostid");
- exit(1);
- }
- } else if (argc==1) {
- unsigned long id = gethostid();
-
- if(id && verbose) {
- printf("Hostid is %lu (0x%lx)\n",id,id);
- } else if(id) {
- printf("0x%lx\n", id);
- } else {
- printf("Usage: %s hostid_number\n",*argv);
- }
- }
- return 0;
-}
diff --git a/misc-utils/logger.c b/misc-utils/logger.c
index 3fd3b6b20..e59fe12bf 100644
--- a/misc-utils/logger.c
+++ b/misc-utils/logger.c
@@ -31,16 +31,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1983, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)logger.c 8.1 (Berkeley) 6/6/93";
-#endif /* not lint */
-
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
diff --git a/misc-utils/look.c b/misc-utils/look.c
index 13cb67872..1d2848b59 100644
--- a/misc-utils/look.c
+++ b/misc-utils/look.c
@@ -34,16 +34,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1991, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)look.c 8.1 (Berkeley) 6/14/93";
-#endif /* not lint */
-
/*
* look -- find lines in a sorted list.
*
diff --git a/misc-utils/namei.c b/misc-utils/namei.c
index 2c9850028..36a17dfd6 100644
--- a/misc-utils/namei.c
+++ b/misc-utils/namei.c
@@ -41,10 +41,6 @@ chdir to /, or if it encounters an unknown file type.
-------------------------------------------------------------*/
-#ifndef lint
-static char *RCSid = "$Id: namei.c,v 1.6 1997/07/06 00:13:09 aebr Exp $";
-#endif
-
#include <stdio.h>
#include <unistd.h>
#include <string.h>
@@ -75,7 +71,6 @@ int argc;
char *argv[];
{
void namei(), usage();
- char *getwd();
int getopt();
extern int optind;
register int c;
@@ -100,7 +95,7 @@ char *argv[];
}
}
- if(getwd(curdir) == NULL){
+ if(getcwd(curdir, sizeof(curdir)) == NULL){
(void)fprintf(stderr, "namei: unable to get current directory - %s\n", curdir);
exit(1);
}
diff --git a/misc-utils/script.c b/misc-utils/script.c
index ba322fe5c..af4013d30 100644
--- a/misc-utils/script.c
+++ b/misc-utils/script.c
@@ -31,16 +31,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-char copyright[] =
-"@(#) Copyright (c) 1980 Regents of the University of California.\n\
- All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)script.c 5.13 (Berkeley) 3/5/91";
-#endif /* not lint */
-
/*
* script
*/
@@ -88,7 +78,6 @@ main(argc, argv)
int argc;
char *argv[];
{
- extern char *optarg;
extern int optind;
int ch;
void finish();
diff --git a/misc-utils/setterm.c b/misc-utils/setterm.c
index 60145d9fa..49903f3b7 100644
--- a/misc-utils/setterm.c
+++ b/misc-utils/setterm.c
@@ -118,6 +118,7 @@ _syscall3(int, klogctl, int, type, char*, buf, int, len);
#define klogctl syslog
#endif
#endif
+extern int klogctl(int type, char *buf, int len);
/* Constants. */
diff --git a/misc-utils/tsort.c b/misc-utils/tsort.c
index a5a44dae8..61e9e8442 100644
--- a/misc-utils/tsort.c
+++ b/misc-utils/tsort.c
@@ -34,16 +34,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-char copyright[] =
-"@(#) Copyright (c) 1989 The Regents of the University of California.\n\
- All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)tsort.c 5.3 (Berkeley) 6/1/90";
-#endif /* not lint */
-
#include <sys/types.h>
#include <errno.h>
#include <stdio.h>
diff --git a/misc-utils/whereis.1 b/misc-utils/whereis.1
index 4d55ac6d3..ff44513ce 100644
--- a/misc-utils/whereis.1
+++ b/misc-utils/whereis.1
@@ -62,53 +62,7 @@ Prefixes of
resulting from use of source code control are also dealt with.
.B whereis
then attempts to locate the desired program in
-a list of standard Linux places:
-.IP
-.nf
-.ft B
-/bin
-/usr/bin
-/etc
-/usr/etc
-/sbin
-/usr/sbin
-/usr/games
-/usr/games/bin
-/usr/emacs/etc
-/usr/lib/emacs/19.22/etc
-/usr/lib/emacs/19.23/etc
-/usr/lib/emacs/19.24/etc
-/usr/lib/emacs/19.25/etc
-/usr/lib/emacs/19.26/etc
-/usr/lib/emacs/19.27/etc
-/usr/lib/emacs/19.28/etc
-/usr/lib/emacs/19.29/etc
-/usr/lib/emacs/19.30/etc
-/usr/TeX/bin
-/usr/tex/bin
-/usr/interviews/bin/LINUX
-/usr/bin/X11
-/usr/X11/bin
-/usr/X11R5/bin
-/usr/X11R6/bin
-/usr/X386/bin
-/usr/local/bin
-/usr/local/etc
-/usr/local/sbin
-/usr/local/games
-/usr/local/games/bin
-/usr/local/emacs/etc
-/usr/local/TeX/bin
-/usr/local/tex/bin
-/usr/local/bin/X11
-
-/usr/contrib",
-/usr/hosts",
-/usr/include",
-
-/usr/g++-include",
-.ft R
-.fi
+a list of standard Linux places.
.SH OPTIONS
.TP
\fB\-b
@@ -170,19 +124,14 @@ example% whereis \-u \-M /usr/man/man1 \-S /usr/src \-f *
.fi
.ft R
.SH FILES
-.PD 0
.TP 20
.B /{bin,sbin,etc}
.TP
.B /usr/{lib,bin,old,new,local,games,include,etc,src,man,sbin,
.B X386,TeX,g++-include}
.TP
-.B /usr/local/{X386,TeX,X11,include,lib,man,etc,bin,games,
-.B emacs}
-.TP
-.B
-.PD
-.SH SEE ALSO
+.B /usr/local/{X386,TeX,X11,include,lib,man,etc,bin,games,emacs}
+.SH "SEE ALSO"
.BR chdir (2V)
.SH BUGS
Since
@@ -196,3 +145,7 @@ or
.B \-B
must be full; that is, they must begin with a
.RB ` / '.
+.PP
+.B whereis
+has a hard-coded path, so may not always find what
+you're looking for.
diff --git a/misc-utils/whereis.c b/misc-utils/whereis.c
index 841360116..1a8e1edd7 100644
--- a/misc-utils/whereis.c
+++ b/misc-utils/whereis.c
@@ -31,18 +31,11 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-char copyright[] =
-"@(#) Copyright (c) 1980 The Regents of the University of California.\n\
- All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)whereis.c 5.5 (Berkeley) 4/18/91";
-#endif /* not lint */
+/* *:aeb */
#include <sys/param.h>
#include <sys/dir.h>
+#include <sys/stat.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
@@ -59,40 +52,33 @@ void findin(char *, char *);
int itsit(char *, char *);
static char *bindirs[] = {
-#ifdef __linux__
"/bin",
"/usr/bin",
- "/etc",
- "/usr/etc",
"/sbin",
"/usr/sbin",
+ "/etc",
+ "/usr/etc",
+ "/lib",
+ "/usr/lib",
"/usr/games",
"/usr/games/bin",
+ "/usr/games/lib",
"/usr/emacs/etc",
- "/usr/lib/emacs/19.22/etc",
- "/usr/lib/emacs/19.23/etc",
- "/usr/lib/emacs/19.24/etc",
- "/usr/lib/emacs/19.25/etc",
- "/usr/lib/emacs/19.26/etc",
- "/usr/lib/emacs/19.27/etc",
- "/usr/lib/emacs/19.28/etc",
- "/usr/lib/emacs/19.29/etc",
- "/usr/lib/emacs/19.30/etc",
- "/usr/lib/emacs/19.31/etc",
- "/usr/lib/emacs/19.32/etc",
+ "/usr/lib/emacs/*/etc",
"/usr/TeX/bin",
"/usr/tex/bin",
"/usr/interviews/bin/LINUX",
+ "/usr/X11R6/bin",
+ "/usr/X386/bin",
"/usr/bin/X11",
"/usr/X11/bin",
"/usr/X11R5/bin",
- "/usr/X11R6/bin",
- "/usr/X386/bin",
"/usr/local/bin",
- "/usr/local/etc",
"/usr/local/sbin",
+ "/usr/local/etc",
+ "/usr/local/lib",
"/usr/local/games",
"/usr/local/games/bin",
"/usr/local/emacs/etc",
@@ -105,129 +91,33 @@ static char *bindirs[] = {
"/usr/include",
"/usr/g++-include",
-#else
- "/bin",
- "/sbin",
- "/usr/ucb",
- "/usr/bin",
- "/usr/sbin",
- "/usr/old",
- "/usr/contrib",
- "/usr/games",
- "/usr/local",
- "/usr/libexec",
- "/usr/include",
- "/usr/hosts",
- "/usr/share", /*?*/
- "/etc",
-#ifdef notdef
- /* before reorg */
- "/etc",
- "/bin",
- "/usr/bin",
- "/usr/games",
- "/lib",
- "/usr/ucb",
- "/usr/lib",
- "/usr/local",
- "/usr/new",
- "/usr/old",
- "/usr/hosts",
- "/usr/include",
-#endif
-#endif
+
+ "/usr/ucb",
+ "/usr/old",
+ "/usr/new",
+ "/usr/local",
+ "/usr/libexec",
+ "/usr/share",
+
0
};
-/* This needs to be redone - man pages live with sources */
+
static char *mandirs[] = {
- "/usr/man/man1",
- "/usr/man/man2",
- "/usr/man/man3",
- "/usr/man/man4",
- "/usr/man/man5",
- "/usr/man/man6",
- "/usr/man/man7",
- "/usr/man/man8",
-#ifdef __linux__
- "/usr/man/man9",
-#endif
- "/usr/man/manl",
- "/usr/man/mann",
- "/usr/man/mano",
-#ifdef __linux__
- "/usr/X386/man/man1",
- "/usr/X386/man/man2",
- "/usr/X386/man/man3",
- "/usr/X386/man/man4",
- "/usr/X386/man/man5",
- "/usr/X386/man/man6",
- "/usr/X386/man/man7",
- "/usr/X386/man/man8",
- "/usr/X11/man/man1",
- "/usr/X11/man/man2",
- "/usr/X11/man/man3",
- "/usr/X11/man/man4",
- "/usr/X11/man/man5",
- "/usr/X11/man/man6",
- "/usr/X11/man/man7",
- "/usr/X11/man/man8",
- "/usr/TeX/man/man1",
- "/usr/TeX/man/man2",
- "/usr/TeX/man/man3",
- "/usr/TeX/man/man4",
- "/usr/TeX/man/man5",
- "/usr/TeX/man/man6",
- "/usr/TeX/man/man7",
- "/usr/TeX/man/man8",
+ "/usr/man/*",
+ "/usr/X386/man/*",
+ "/usr/X11/man/*",
+ "/usr/TeX/man/*",
"/usr/interviews/man/mann",
-#endif
0
};
+
static char *srcdirs[] = {
- "/usr/src/bin",
- "/usr/src/sbin",
- "/usr/src/etc",
- "/usr/src/pgrm",
- "/usr/src/usr.bin",
- "/usr/src/usr.sbin",
- "/usr/src/usr.ucb",
- "/usr/src/usr.new",
- "/usr/src/usr.lib",
- "/usr/src/libexec",
- "/usr/src/libdata",
- "/usr/src/share",
- "/usr/src/contrib",
- "/usr/src/athena",
- "/usr/src/devel",
- "/usr/src/games",
- "/usr/src/local",
- "/usr/src/man",
- "/usr/src/root",
- "/usr/src/old",
- "/usr/src/include",
- /* still need libs */
-#ifdef notdef /* before reorg */
- "/usr/src/bin",
- "/usr/src/usr.bin",
- "/usr/src/etc",
- "/usr/src/ucb",
- "/usr/src/games",
- "/usr/src/usr.lib",
- "/usr/src/lib",
- "/usr/src/local",
- "/usr/src/new",
- "/usr/src/old",
- "/usr/src/include",
- "/usr/src/lib/libc/gen",
- "/usr/src/lib/libc/stdio",
- "/usr/src/lib/libc/sys",
- "/usr/src/lib/libc/net/common",
- "/usr/src/lib/libc/net/inet",
- "/usr/src/lib/libc/net/misc",
+ "/usr/src/*",
+ "/usr/src/lib/libc/*",
+ "/usr/src/lib/libc/net/*",
"/usr/src/ucb/pascal",
"/usr/src/ucb/pascal/utilities",
"/usr/src/undoc",
-#endif
0
};
@@ -307,13 +197,7 @@ usage:
}
void
-getlist(argcp, argvp, flagp, cntp)
- char ***argvp;
- int *argcp;
- char ***flagp;
- int *cntp;
-{
-
+getlist(int *argcp, char ***argvp, char ***flagp, int *cntp) {
(*argvp)++;
*flagp = *argvp;
*cntp = 0;
@@ -335,9 +219,7 @@ int count;
int print;
void
-lookup(cp)
- register char *cp;
-{
+lookup(char *cp) {
register char *dp;
for (dp = cp; *dp; dp++)
@@ -387,9 +269,7 @@ again:
}
void
-looksrc(cp)
- char *cp;
-{
+looksrc(char *cp) {
if (Sflag == 0) {
find(srcdirs, cp);
} else
@@ -397,9 +277,7 @@ looksrc(cp)
}
void
-lookbin(cp)
- char *cp;
-{
+lookbin(char *cp) {
if (Bflag == 0)
find(bindirs, cp);
else
@@ -407,9 +285,7 @@ lookbin(cp)
}
void
-lookman(cp)
- char *cp;
-{
+lookman(char *cp) {
if (Mflag == 0) {
find(mandirs, cp);
} else
@@ -417,33 +293,54 @@ lookman(cp)
}
void
-findv(dirv, dirc, cp)
- char **dirv;
- int dirc;
- char *cp;
-{
-
+findv(char **dirv, int dirc, char *cp) {
while (dirc > 0)
findin(*dirv++, cp), dirc--;
}
void
-find(dirs, cp)
- char **dirs;
- char *cp;
-{
-
+find(char **dirs, char *cp) {
while (*dirs)
findin(*dirs++, cp);
}
void
-findin(dir, cp)
- char *dir, *cp;
-{
+findin(char *dir, char *cp) {
DIR *dirp;
struct direct *dp;
+ char *d, *dd;
+ int l;
+ char dirbuf[1024];
+ struct stat statbuf;
+
+ dd = index(dir, '*');
+ if (!dd)
+ goto noglob;
+
+ l = strlen(dir);
+ if (l < sizeof(dirbuf)) { /* refuse excessively long names */
+ strcpy (dirbuf, dir);
+ d = index(dirbuf, '*');
+ *d = 0;
+ dirp = opendir(dirbuf);
+ if (dirp == NULL)
+ return;
+ while ((dp = readdir(dirp)) != NULL) {
+ if (strlen(dp->d_name) + l > sizeof(dirbuf))
+ continue;
+ sprintf(d, "%s", dp->d_name);
+ if (stat(dirbuf, &statbuf))
+ continue;
+ if (!S_ISDIR(statbuf.st_mode))
+ continue;
+ strcat(d, dd+1);
+ findin(dirbuf, cp);
+ }
+ closedir(dirp);
+ }
+ return;
+ noglob:
dirp = opendir(dir);
if (dirp == NULL)
return;
@@ -458,13 +355,17 @@ findin(dir, cp)
}
int
-itsit(cp, dp)
- register char *cp, *dp;
-{
- register int i = strlen(dp);
+itsit(char *cp, char *dp) {
+ int i = strlen(dp);
if (dp[0] == 's' && dp[1] == '.' && itsit(cp, dp+2))
return (1);
+ if (!strcmp(dp+i-2, ".Z"))
+ i -= 2;
+ else if (!strcmp(dp+i-3, ".gz"))
+ i -= 3;
+ else if (!strcmp(dp+i-4, ".bz2"))
+ i -= 4;
while (*cp && *dp && *cp == *dp)
cp++, dp++, i--;
if (*cp == 0 && *dp == 0)
diff --git a/misc-utils/write.c b/misc-utils/write.c
index 545404b48..e43b0bf9a 100644
--- a/misc-utils/write.c
+++ b/misc-utils/write.c
@@ -42,18 +42,6 @@
* - ANSIed it since I was working on it anyway.
*/
-#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1989, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)write.c 8.1 (Berkeley) 6/6/93";
-#endif /* not lint */
-
-#define _GNU_SOURCE /* for snprintf */
-
#include <unistd.h>
#include <utmp.h>
#include <ctype.h>
@@ -276,7 +264,9 @@ int term_chk(char *tty, int *msgsokP, time_t *atimeP, int showerror)
struct stat s;
char path[MAXPATHLEN];
- (void)snprintf(path, sizeof(path), "/dev/%s", tty);
+ if (strlen(tty) + 6 > sizeof(path))
+ return(1);
+ (void)sprintf(path, "/dev/%s", tty);
if (stat(path, &s) < 0) {
if (showerror)
(void)fprintf(stderr,
@@ -307,7 +297,9 @@ void do_write(char *tty, char *mytty, uid_t myuid)
else
login = "???";
- (void)snprintf(path, sizeof(path), "/dev/%s", tty);
+ if (strlen(tty) + 6 > sizeof(path))
+ exit(1);
+ (void)sprintf(path, "/dev/%s", tty);
if ((freopen(path, "w", stdout)) == NULL) {
(void)fprintf(stderr, "write: %s: %s\n", path, strerror(errno));
exit(1);