Merge from Lite2

This commit is contained in:
Peter Wemm 1997-03-11 13:43:33 +00:00
parent 18dac96b7b
commit df3f5d9dd5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=23693
17 changed files with 117 additions and 94 deletions

View File

@ -41,7 +41,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
static char sccsid[] = "@(#)col.c 8.3 (Berkeley) 4/2/94";
static char sccsid[] = "@(#)col.c 8.5 (Berkeley) 5/4/95";
#endif /* not lint */
#include <ctype.h>
@ -49,6 +49,7 @@ static char sccsid[] = "@(#)col.c 8.3 (Berkeley) 4/2/94";
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <locale.h>
#define BS '\b' /* backspace */
@ -299,6 +300,9 @@ main(argc, argv)
l->l_max_col = cur_col;
cur_col++;
}
if (max_line == 0)
exit(0); /* no lines, so just exit */
/* goto the last line that had a character on it */
for (; l->l_next; l = l->l_next)
this_line++;

View File

@ -41,7 +41,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
static char sccsid[] = "@(#)cut.c 8.1 (Berkeley) 6/6/93";
static char sccsid[] = "@(#)cut.c 8.3 (Berkeley) 5/4/95";
#endif /* not lint */
#include <ctype.h>
@ -50,6 +50,7 @@ static char sccsid[] = "@(#)cut.c 8.1 (Berkeley) 6/6/93";
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int cflag;
char dchar;

View File

@ -38,11 +38,12 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
static char sccsid[] = "@(#)dirname.c 8.3 (Berkeley) 4/2/94";
static char sccsid[] = "@(#)dirname.c 8.4 (Berkeley) 5/4/95";
#endif /* not lint */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void usage __P((void));

View File

@ -41,7 +41,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
static char sccsid[] = "@(#)du.c 8.4 (Berkeley) 4/1/94";
static char sccsid[] = "@(#)du.c 8.5 (Berkeley) 5/4/95";
#endif /* not lint */
#include <sys/param.h>
@ -54,6 +54,7 @@ static char sccsid[] = "@(#)du.c 8.4 (Berkeley) 4/1/94";
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int linkchk __P((FTSENT *));
void usage __P((void));

View File

@ -1,4 +1,4 @@
.\" Copyright (c) 1989, 1990, 1993
.\" Copyright (c) 1989, 1990, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@ -29,9 +29,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)finger.1 8.2 (Berkeley) 2/16/94
.\" @(#)finger.1 8.3 (Berkeley) 5/5/94
.\"
.Dd February 16, 1994
.Dd May 5, 1994
.Dt FINGER 1
.Os BSD 4
.Sh NAME
@ -192,6 +192,11 @@ utilizes the following environment variable, if it exists:
This variable may be set with favored options to
.Nm finger .
.El
.Sh FILES
.Bl -tag -width /var/log/lastlog -compact
.It Pa /var/log/lastlog
last login data base
.El
.Sh SEE ALSO
.Xr chpass 1 ,
.Xr w 1 ,

View File

@ -51,7 +51,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
static char sccsid[] = "@(#)finger.c 8.2 (Berkeley) 9/30/93";
static char sccsid[] = "@(#)finger.c 8.5 (Berkeley) 5/4/95";
#endif /* not lint */
/*
@ -69,16 +69,21 @@ static char sccsid[] = "@(#)finger.c 8.2 (Berkeley) 9/30/93";
*/
#include <sys/param.h>
#include <fcntl.h>
#include <time.h>
#include <pwd.h>
#include <utmp.h>
#include <db.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <utmp.h>
#include <db.h>
#include <locale.h>
#include "finger.h"
DB *db;
@ -185,7 +190,7 @@ main(argc, argv)
lflag_print();
else
sflag_print();
exit(0);
return (0);
}
static void
@ -199,7 +204,7 @@ loginlist()
char name[UT_NAMESIZE + 1];
if (!freopen(_PATH_UTMP, "r", stdin))
err("%s: %s", _PATH_UTMP, strerror(errno));
err(1, "%s", _PATH_UTMP);
name[UT_NAMESIZE] = NULL;
while (fread((char *)&user, sizeof(user), 1, stdin) == 1) {
if (!user.ut_name[0])
@ -216,12 +221,15 @@ loginlist()
}
if (db && lflag)
for (sflag = R_FIRST;; sflag = R_NEXT) {
PERSON *tmp;
r = (*db->seq)(db, &key, &data, sflag);
if (r == -1)
err("db seq: %s", strerror(errno));
err(1, "db seq");
if (r == 1)
break;
enter_lastlog(*(PERSON **)data.data);
memmove(&tmp, data.data, sizeof tmp);
enter_lastlog(tmp);
}
}
@ -239,7 +247,7 @@ userlist(argc, argv)
if ((nargv = malloc((argc+1) * sizeof(char *))) == NULL ||
(used = calloc(argc, sizeof(int))) == NULL)
err("%s", strerror(errno));
err(1, NULL);
/* Pull out all network requests. */
for (ap = p = argv, np = nargv; *p; ++p)
@ -260,13 +268,13 @@ userlist(argc, argv)
*/
if (mflag)
for (p = argv; *p; ++p)
if ((pw = getpwnam(*p)) && !hide(pw))
if (((pw = getpwnam(*p)) != NULL) && !hide(pw))
enter_person(pw);
else
(void)fprintf(stderr,
"finger: %s: no such user\n", *p);
else {
while (pw = getpwent()) {
while ((pw = getpwent()) != NULL) {
for (p = argv, ip = used; *p; ++p, ++ip)
if (match(pw, *p) && !hide(pw)) {
enter_person(pw);
@ -294,7 +302,7 @@ net: for (p = nargv; *p;) {
* appropriate data whenever a match occurs.
*/
if (!freopen(_PATH_UTMP, "r", stdin))
err("%s: %s", _PATH_UTMP, strerror(errno));
err(1, "%s", _PATH_UTMP);
while (fread((char *)&user, sizeof(user), 1, stdin) == 1) {
if (!user.ut_name[0])
continue;
@ -304,11 +312,14 @@ net: for (p = nargv; *p;) {
}
if (db)
for (sflag = R_FIRST;; sflag = R_NEXT) {
PERSON *tmp;
r = (*db->seq)(db, &key, &data, sflag);
if (r == -1)
err("db seq: %s", strerror(errno));
err(1, "db seq");
if (r == 1)
break;
enter_lastlog(*(PERSON **)data.data);
memmove(&tmp, data.data, sizeof tmp);
enter_lastlog(tmp);
}
}

View File

@ -35,7 +35,7 @@
*/
#ifndef lint
static char sccsid[] = "@(#)lprint.c 8.1 (Berkeley) 6/6/93";
static char sccsid[] = "@(#)lprint.c 8.3 (Berkeley) 4/28/95";
#endif /* not lint */
#include <sys/types.h>
@ -44,6 +44,7 @@ static char sccsid[] = "@(#)lprint.c 8.1 (Berkeley) 6/6/93";
#include <fcntl.h>
#include <time.h>
#include <db.h>
#include <err.h>
#include <pwd.h>
#include <utmp.h>
#include <errno.h>
@ -71,15 +72,17 @@ lflag_print()
extern int pplan;
register PERSON *pn;
register int sflag, r;
PERSON *tmp;
DBT data, key;
for (sflag = R_FIRST;; sflag = R_NEXT) {
r = (*db->seq)(db, &key, &data, sflag);
if (r == -1)
err("db seq: %s", strerror(errno));
err(1, "db seq");
if (r == 1)
break;
pn = *(PERSON **)data.data;
memmove(&tmp, data.data, sizeof tmp);
pn = tmp;
if (sflag != R_FIRST)
putchar('\n');
lprint(pn);

View File

@ -35,7 +35,7 @@
*/
#ifndef lint
static char sccsid[] = "@(#)net.c 8.3 (Berkeley) 1/2/94";
static char sccsid[] = "@(#)net.c 8.4 (Berkeley) 4/28/95";
#endif /* not lint */
#include <sys/types.h>
@ -144,9 +144,8 @@ netfinger(name)
* it isn't a space, we can simply set the 7th bit. Every ASCII
* character with bit 7 set is printable.
*/
if (fp = fdopen(s, "r")) {
int lastc = '\n';
lastc = 0;
if ((fp = fdopen(s, "r")) != NULL) {
while ((c = getc(fp)) != EOF) {
if (c == 0x0d) {
if (lastc == '\r') /* ^M^M - skip dupes */

View File

@ -35,13 +35,14 @@
*/
#ifndef lint
static char sccsid[] = "@(#)sprint.c 8.1 (Berkeley) 6/6/93";
static char sccsid[] = "@(#)sprint.c 8.3 (Berkeley) 4/28/95";
#endif /* not lint */
#include <sys/types.h>
#include <sys/time.h>
#include <time.h>
#include <db.h>
#include <err.h>
#include <pwd.h>
#include <errno.h>
#include <utmp.h>
@ -61,6 +62,7 @@ sflag_print()
register WHERE *w;
register int sflag, r, namelen;
char p[80];
PERSON *tmp;
DBT data, key;
/*
@ -88,10 +90,11 @@ sflag_print()
for (sflag = R_FIRST;; sflag = R_NEXT) {
r = (*db->seq)(db, &key, &data, sflag);
if (r == -1)
err("db seq: %s", strerror(errno));
err(1, "db seq");
if (r == 1)
break;
pn = *(PERSON **)data.data;
memmove(&tmp, data.data, sizeof tmp);
pn = tmp;
for (w = pn->whead; w != NULL; w = w->next) {
namelen = MAXREALNAME;

View File

@ -35,13 +35,14 @@
*/
#ifndef lint
static char sccsid[] = "@(#)util.c 8.1 (Berkeley) 6/6/93";
static char sccsid[] = "@(#)util.c 8.3 (Berkeley) 4/28/95";
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <db.h>
#include <err.h>
#include <pwd.h>
#include <utmp.h>
#include <errno.h>
@ -81,14 +82,14 @@ match(pw, user)
if ((p = strtok(p, ",")) == NULL)
return(0);
for (t = name; *t = *p; ++p)
for (t = name; (*t = *p) != '\0'; ++p)
if (*t == '&') {
(void)strcpy(t, pw->pw_name);
while (*++t);
}
else
++t;
for (t = name; p = strtok(t, "\t "); t = NULL)
for (t = name; (p = strtok(t, "\t ")) != NULL; t = NULL)
if (!strcasecmp(p, user))
return(1);
return(0);
@ -170,17 +171,18 @@ enter_person(pw)
if (db == NULL &&
(db = dbopen(NULL, O_RDWR, 0, DB_BTREE, NULL)) == NULL)
err("%s", strerror(errno));
err(1, NULL);
key.data = pw->pw_name;
key.size = strlen(pw->pw_name);
switch((*db->get)(db, &key, &data, 0)) {
switch ((*db->get)(db, &key, &data, 0)) {
case 0:
return(*(PERSON **)data.data);
memmove(&pn, data.data, sizeof pn);
return (pn);
default:
case -1:
err("db get: %s", strerror(errno));
err(1, "db get");
/* NOTREACHED */
case 1:
++entries;
@ -191,8 +193,8 @@ enter_person(pw)
data.size = sizeof(PERSON *);
data.data = &pn;
if ((*db->put)(db, &key, &data, 0))
err("%s", strerror(errno));
return(pn);
err(1, "db put");
return (pn);
}
}
@ -204,6 +206,7 @@ find_person(name)
register int cnt;
DBT data, key;
PERSON *p;
char buf[UT_NAMESIZE + 1];
if (!db)
@ -219,7 +222,10 @@ find_person(name)
key.data = buf;
key.size = cnt;
return((*db->get)(db, &key, &data, 0) ? NULL : *(PERSON **)data.data);
if ((*db->get)(db, &key, &data, 0))
return (NULL);
memmove(&p, data.data, sizeof p);
return (p);
}
PERSON *
@ -228,7 +234,7 @@ palloc()
PERSON *p;
if ((p = malloc((u_int) sizeof(PERSON))) == NULL)
err("%s", strerror(errno));
err(1, NULL);
return(p);
}
@ -239,7 +245,7 @@ walloc(pn)
register WHERE *w;
if ((w = malloc((u_int) sizeof(WHERE))) == NULL)
err("%s", strerror(errno));
err(1, NULL);
if (pn->whead == NULL)
pn->whead = pn->wtail = w;
else {
@ -309,8 +315,7 @@ find_idle_and_ttywrite(w)
(void)snprintf(tbuf, sizeof(tbuf), "%s/%s", _PATH_DEV, w->tty);
if (stat(tbuf, &sb) < 0) {
(void)fprintf(stderr,
"finger: %s: %s\n", tbuf, strerror(errno));
warn(tbuf);
return;
}
w->idletime = now < sb.st_atime ? 0 : now - sb.st_atime;
@ -343,7 +348,7 @@ userinfo(pn, pw)
/* ampersands get replaced by the login name */
if (!(p = strsep(&bp, ",")))
return;
for (t = name; *t = *p; ++p)
for (t = name; (*t = *p) != '\0'; ++p)
if (*t == '&') {
(void)strcpy(t, pw->pw_name);
if (islower(*t))
@ -373,35 +378,6 @@ userinfo(pn, pw)
}
}
#if __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
void
#if __STDC__
err(const char *fmt, ...)
#else
err(fmt, va_alist)
char *fmt;
va_dcl
#endif
{
va_list ap;
#if __STDC__
va_start(ap, fmt);
#else
va_start(ap);
#endif
(void)fprintf(stderr, "finger: ");
(void)vfprintf(stderr, fmt, ap);
va_end(ap);
(void)fprintf(stderr, "\n");
exit(1);
/* NOTREACHED */
}
/*
* Is this user hiding from finger?
* If ~<user>/.nofinger exists, return 1 (hide), else return 0 (nohide).

View File

@ -38,7 +38,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
static char sccsid[] = "@(#)fstat.c 8.1 (Berkeley) 6/6/93";
static char sccsid[] = "@(#)fstat.c 8.3 (Berkeley) 5/2/95";
#endif /* not lint */
#include <sys/param.h>
@ -65,7 +65,9 @@ static char sccsid[] = "@(#)fstat.c 8.1 (Berkeley) 6/6/93";
#include <sys/mount.h>
#include <nfs/nfsproto.h>
#include <nfs/rpcv2.h>
#define KERNEL
#include <nfs/nfs.h>
#undef KERNEL
#include <nfs/nfsnode.h>
#undef NFS
@ -79,12 +81,14 @@ static char sccsid[] = "@(#)fstat.c 8.1 (Berkeley) 6/6/93";
#include <errno.h>
#include <fcntl.h>
#include <kvm.h>
#include <limits.h>
#include <nlist.h>
#include <paths.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define TEXT -1
#define CDIR -2
@ -164,6 +168,7 @@ main(argc, argv)
struct kinfo_proc *p, *plast;
int arg, ch, what;
char *memf, *nlistf;
char buf[_POSIX2_LINE_MAX];
int cnt;
arg = 0;
@ -238,8 +243,8 @@ main(argc, argv)
if (nlistf != NULL || memf != NULL)
setgid(getgid());
if ((kd = kvm_open(nlistf, memf, NULL, O_RDONLY, NULL)) == NULL) {
fprintf(stderr, "fstat: %s\n", kvm_geterr(kd));
if ((kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, buf)) == NULL) {
fprintf(stderr, "fstat: %s\n", buf);
exit(1);
}
#ifdef notdef

View File

@ -38,15 +38,17 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
static char sccsid[] = "@(#)head.c 8.1 (Berkeley) 6/6/93";
static char sccsid[] = "@(#)head.c 8.2 (Berkeley) 5/4/95";
#endif /* not lint */
#include <sys/types.h>
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <unistd.h>
/*
* head - give the first few lines of a stream or of each of a set of files

View File

@ -32,7 +32,7 @@
*/
#ifndef lint
static char sccsid[] = "@(#)hexsyntax.c 8.1 (Berkeley) 6/6/93";
static char sccsid[] = "@(#)hexsyntax.c 8.2 (Berkeley) 5/4/95";
#endif /* not lint */
#include <sys/types.h>
@ -40,6 +40,8 @@ static char sccsid[] = "@(#)hexsyntax.c 8.1 (Berkeley) 6/6/93";
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "hexdump.h"
off_t skip; /* bytes to skip */

View File

@ -32,14 +32,16 @@
*/
#ifndef lint
static char sccsid[] = "@(#)odsyntax.c 8.1 (Berkeley) 6/6/93";
static char sccsid[] = "@(#)odsyntax.c 8.2 (Berkeley) 5/4/95";
#endif /* not lint */
#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "hexdump.h"
int deprecated;

View File

@ -41,7 +41,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
static char sccsid[] = "@(#)look.c 8.1 (Berkeley) 6/14/93";
static char sccsid[] = "@(#)look.c 8.2 (Berkeley) 5/4/95";
#endif /* not lint */
/*
@ -58,12 +58,15 @@ static char sccsid[] = "@(#)look.c 8.1 (Berkeley) 6/14/93";
#include <limits.h>
#include <locale.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include "pathnames.h"
/*

View File

@ -38,7 +38,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
static char sccsid[] = "@(#)mt.c 8.1 (Berkeley) 6/6/93";
static char sccsid[] = "@(#)mt.c 8.2 (Berkeley) 5/4/95";
#endif /* not lint */
/*
@ -48,12 +48,14 @@ static char sccsid[] = "@(#)mt.c 8.1 (Berkeley) 6/6/93";
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/mtio.h>
#include <fcntl.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
/* the appropriate sections of <sys/mtio.h> are also #ifdef'd for FreeBSD */
#if defined(__FreeBSD__)

View File

@ -38,14 +38,17 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
static char sccsid[] = "@(#)tr.c 8.1 (Berkeley) 6/6/93";
static char sccsid[] = "@(#)tr.c 8.2 (Berkeley) 5/4/95";
#endif /* not lint */
#include <locale.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "extern.h"
static int string1[NCHARS] = {