Add rcsid, usage(). Silent -Wall. Use warn(3).
This commit is contained in:
parent
370ad8d767
commit
b14d8277cc
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=27169
@ -41,6 +41,7 @@ void enter_lastlog __P((PERSON *));
|
|||||||
PERSON *enter_person __P((struct passwd *));
|
PERSON *enter_person __P((struct passwd *));
|
||||||
void enter_where __P((struct utmp *, PERSON *));
|
void enter_where __P((struct utmp *, PERSON *));
|
||||||
PERSON *find_person __P((char *));
|
PERSON *find_person __P((char *));
|
||||||
|
int hide __P((struct passwd *));
|
||||||
void lflag_print __P((void));
|
void lflag_print __P((void));
|
||||||
int match __P((struct passwd *, char *));
|
int match __P((struct passwd *, char *));
|
||||||
void netfinger __P((char *));
|
void netfinger __P((char *));
|
||||||
|
@ -51,7 +51,12 @@ static char copyright[] =
|
|||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
|
#if 0
|
||||||
static char sccsid[] = "@(#)finger.c 8.5 (Berkeley) 5/4/95";
|
static char sccsid[] = "@(#)finger.c 8.5 (Berkeley) 5/4/95";
|
||||||
|
#else
|
||||||
|
static const char rcsid[] =
|
||||||
|
"$Id$";
|
||||||
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -92,6 +97,7 @@ int entries, lflag, mflag, pplan, sflag, oflag, Tflag;
|
|||||||
char tbuf[1024];
|
char tbuf[1024];
|
||||||
|
|
||||||
static void loginlist __P((void));
|
static void loginlist __P((void));
|
||||||
|
static void usage __P((void));
|
||||||
static void userlist __P((int, char **));
|
static void userlist __P((int, char **));
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -128,19 +134,25 @@ option(argc, argv)
|
|||||||
break;
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
default:
|
default:
|
||||||
(void)fprintf(stderr,
|
usage();
|
||||||
"usage: finger [-lmpshoT] [login ...]\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return optind;
|
return optind;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
usage()
|
||||||
|
{
|
||||||
|
(void)fprintf(stderr, "usage: finger [-lmpshoT] [login ...]\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
main(argc, argv)
|
main(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
char **argv;
|
char **argv;
|
||||||
{
|
{
|
||||||
int ch, envargc, argcnt;
|
int envargc, argcnt;
|
||||||
char *envargv[3];
|
char *envargv[3];
|
||||||
|
|
||||||
(void) setlocale(LC_ALL, "");
|
(void) setlocale(LC_ALL, "");
|
||||||
@ -205,7 +217,7 @@ loginlist()
|
|||||||
|
|
||||||
if (!freopen(_PATH_UTMP, "r", stdin))
|
if (!freopen(_PATH_UTMP, "r", stdin))
|
||||||
err(1, "%s", _PATH_UTMP);
|
err(1, "%s", _PATH_UTMP);
|
||||||
name[UT_NAMESIZE] = NULL;
|
name[UT_NAMESIZE] = '\0';
|
||||||
while (fread((char *)&user, sizeof(user), 1, stdin) == 1) {
|
while (fread((char *)&user, sizeof(user), 1, stdin) == 1) {
|
||||||
if (!user.ut_name[0])
|
if (!user.ut_name[0])
|
||||||
continue;
|
continue;
|
||||||
@ -271,8 +283,7 @@ userlist(argc, argv)
|
|||||||
if (((pw = getpwnam(*p)) != NULL) && !hide(pw))
|
if (((pw = getpwnam(*p)) != NULL) && !hide(pw))
|
||||||
enter_person(pw);
|
enter_person(pw);
|
||||||
else
|
else
|
||||||
(void)fprintf(stderr,
|
warnx("%s: no such user", *p);
|
||||||
"finger: %s: no such user\n", *p);
|
|
||||||
else {
|
else {
|
||||||
while ((pw = getpwent()) != NULL) {
|
while ((pw = getpwent()) != NULL) {
|
||||||
for (p = argv, ip = used; *p; ++p, ++ip)
|
for (p = argv, ip = used; *p; ++p, ++ip)
|
||||||
@ -283,8 +294,7 @@ userlist(argc, argv)
|
|||||||
}
|
}
|
||||||
for (p = argv, ip = used; *p; ++p, ++ip)
|
for (p = argv, ip = used; *p; ++p, ++ip)
|
||||||
if (!*ip)
|
if (!*ip)
|
||||||
(void)fprintf(stderr,
|
warnx("%s: no such user", *p);
|
||||||
"finger: %s: no such user\n", *p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle network requests. */
|
/* Handle network requests. */
|
||||||
|
@ -35,7 +35,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
|
#if 0
|
||||||
static char sccsid[] = "@(#)lprint.c 8.3 (Berkeley) 4/28/95";
|
static char sccsid[] = "@(#)lprint.c 8.3 (Berkeley) 4/28/95";
|
||||||
|
#else
|
||||||
|
static const char rcsid[] =
|
||||||
|
"$Id$";
|
||||||
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -35,7 +35,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
|
#if 0
|
||||||
static char sccsid[] = "@(#)net.c 8.4 (Berkeley) 4/28/95";
|
static char sccsid[] = "@(#)net.c 8.4 (Berkeley) 4/28/95";
|
||||||
|
#else
|
||||||
|
static const char rcsid[] =
|
||||||
|
"$Id$";
|
||||||
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -44,6 +49,7 @@ static char sccsid[] = "@(#)net.c 8.4 (Berkeley) 4/28/95";
|
|||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <db.h>
|
#include <db.h>
|
||||||
|
#include <err.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <utmp.h>
|
#include <utmp.h>
|
||||||
@ -72,7 +78,7 @@ netfinger(name)
|
|||||||
|
|
||||||
if (!(host = rindex(name, '@')))
|
if (!(host = rindex(name, '@')))
|
||||||
return;
|
return;
|
||||||
*host++ = NULL;
|
*host++ = '\0';
|
||||||
if (isdigit(*host) && (defaddr.s_addr = inet_addr(host)) != -1) {
|
if (isdigit(*host) && (defaddr.s_addr = inet_addr(host)) != -1) {
|
||||||
def.h_name = host;
|
def.h_name = host;
|
||||||
def.h_addr_list = alist;
|
def.h_addr_list = alist;
|
||||||
@ -82,12 +88,11 @@ netfinger(name)
|
|||||||
def.h_aliases = 0;
|
def.h_aliases = 0;
|
||||||
hp = &def;
|
hp = &def;
|
||||||
} else if (!(hp = gethostbyname(host))) {
|
} else if (!(hp = gethostbyname(host))) {
|
||||||
(void)fprintf(stderr,
|
warnx("unknown host: %s", host);
|
||||||
"finger: unknown host: %s\n", host);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!(sp = getservbyname("finger", "tcp"))) {
|
if (!(sp = getservbyname("finger", "tcp"))) {
|
||||||
(void)fprintf(stderr, "finger: tcp/finger: unknown service\n");
|
warnx("tcp/finger: unknown service");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sin.sin_family = hp->h_addrtype;
|
sin.sin_family = hp->h_addrtype;
|
||||||
|
@ -35,7 +35,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
|
#if 0
|
||||||
static char sccsid[] = "@(#)sprint.c 8.3 (Berkeley) 4/28/95";
|
static char sccsid[] = "@(#)sprint.c 8.3 (Berkeley) 4/28/95";
|
||||||
|
#else
|
||||||
|
static const char rcsid[] =
|
||||||
|
"$Id$";
|
||||||
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -35,7 +35,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
|
#if 0
|
||||||
static char sccsid[] = "@(#)util.c 8.3 (Berkeley) 4/28/95";
|
static char sccsid[] = "@(#)util.c 8.3 (Berkeley) 4/28/95";
|
||||||
|
#else
|
||||||
|
static const char rcsid[] =
|
||||||
|
"$Id$";
|
||||||
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
@ -114,7 +119,7 @@ enter_lastlog(pn)
|
|||||||
(long)pn->uid * sizeof(ll) ||
|
(long)pn->uid * sizeof(ll) ||
|
||||||
read(fd, (char *)&ll, sizeof(ll)) != sizeof(ll)) {
|
read(fd, (char *)&ll, sizeof(ll)) != sizeof(ll)) {
|
||||||
/* as if never logged in */
|
/* as if never logged in */
|
||||||
ll.ll_line[0] = ll.ll_host[0] = NULL;
|
ll.ll_line[0] = ll.ll_host[0] = '\0';
|
||||||
ll.ll_time = 0;
|
ll.ll_time = 0;
|
||||||
}
|
}
|
||||||
if ((w = pn->whead) == NULL)
|
if ((w = pn->whead) == NULL)
|
||||||
@ -368,8 +373,7 @@ userinfo(pn, pw)
|
|||||||
pn->mailrecv = -1; /* -1 == not_valid */
|
pn->mailrecv = -1; /* -1 == not_valid */
|
||||||
if (stat(tbuf, &sb) < 0) {
|
if (stat(tbuf, &sb) < 0) {
|
||||||
if (errno != ENOENT) {
|
if (errno != ENOENT) {
|
||||||
(void)fprintf(stderr,
|
warn("%s", tbuf);
|
||||||
"finger: %s: %s\n", tbuf, strerror(errno));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (sb.st_size != 0) {
|
} else if (sb.st_size != 0) {
|
||||||
@ -387,7 +391,6 @@ int
|
|||||||
hide(pw)
|
hide(pw)
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
{
|
{
|
||||||
int fd;
|
|
||||||
char buf[MAXPATHLEN+1];
|
char buf[MAXPATHLEN+1];
|
||||||
|
|
||||||
if (!pw->pw_dir)
|
if (!pw->pw_dir)
|
||||||
|
Loading…
Reference in New Issue
Block a user