version 1.7, 1997/05/30 23:35:51 |
version 1.8, 1998/07/10 15:45:15 |
|
|
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
#include <time.h> |
#include <time.h> |
|
#include <err.h> |
#include "finger.h" |
#include "finger.h" |
#include "extern.h" |
#include "extern.h" |
|
|
|
|
char **argv; |
char **argv; |
{ |
{ |
extern int optind; |
extern int optind; |
|
extern char *__progname; |
int ch; |
int ch; |
char domain[256]; |
char domain[256]; |
|
|
|
|
case '?': |
case '?': |
default: |
default: |
(void)fprintf(stderr, |
(void)fprintf(stderr, |
"usage: finger [-lmMpsho] [login ...]\n"); |
"usage: %s [-lmMpsho] [login ...]\n", __progname); |
exit(1); |
exit(1); |
} |
} |
argc -= optind; |
argc -= optind; |
|
|
struct utmp user; |
struct utmp user; |
char name[UT_NAMESIZE + 1]; |
char name[UT_NAMESIZE + 1]; |
|
|
if (!freopen(_PATH_UTMP, "r", stdin)) { |
if (!freopen(_PATH_UTMP, "r", stdin)) |
(void)fprintf(stderr, "finger: can't read %s.\n", _PATH_UTMP); |
err(2, _PATH_UTMP); |
exit(2); |
|
} |
|
name[UT_NAMESIZE] = '\0'; |
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]) |
|
|
struct passwd *pw; |
struct passwd *pw; |
int dolocal, *used; |
int dolocal, *used; |
|
|
if (!(used = (int *)calloc((u_int)argc, (u_int)sizeof(int)))) { |
if (!(used = (int *)calloc((u_int)argc, (u_int)sizeof(int)))) |
(void)fprintf(stderr, "finger: out of space.\n"); |
err(2, "malloc"); |
exit(1); |
|
} |
|
|
|
/* pull out all network requests */ |
/* pull out all network requests */ |
for (i = 0, dolocal = 0, nettail = &nethead; i < argc; i++) { |
for (i = 0, dolocal = 0, nettail = &nethead; i < argc; i++) { |
|
|
/* list errors */ |
/* list errors */ |
for (i = 0; i < argc; i++) |
for (i = 0; i < argc; i++) |
if (!used[i]) |
if (!used[i]) |
(void)fprintf(stderr, |
warnx("%s: no such user.", argv[i]); |
"finger: %s: no such user.\n", argv[i]); |
|
|
|
/* handle network requests */ |
/* handle network requests */ |
net: for (pn = nethead; pn; pn = pn->next) { |
net: for (pn = nethead; pn; pn = pn->next) { |
|
|
* Scan thru the list of users currently logged in, saving |
* Scan thru the list of users currently logged in, saving |
* appropriate data whenever a match occurs. |
* appropriate data whenever a match occurs. |
*/ |
*/ |
if (!freopen(_PATH_UTMP, "r", stdin)) { |
if (!freopen(_PATH_UTMP, "r", stdin)) |
(void)fprintf( stderr, "finger: can't read %s.\n", _PATH_UTMP); |
err(1, _PATH_UTMP); |
exit(1); |
|
} |
|
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; |