finger.c (24360) | finger.c (27169) |
---|---|
1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Tony Nardo of the Johns Hopkins University/Applied Physics Lab. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 37 unchanged lines hidden (view full) --- 46 47#ifndef lint 48static char copyright[] = 49"@(#) Copyright (c) 1989, 1993\n\ 50 The Regents of the University of California. All rights reserved.\n"; 51#endif /* not lint */ 52 53#ifndef lint | 1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Tony Nardo of the Johns Hopkins University/Applied Physics Lab. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 37 unchanged lines hidden (view full) --- 46 47#ifndef lint 48static char copyright[] = 49"@(#) Copyright (c) 1989, 1993\n\ 50 The Regents of the University of California. All rights reserved.\n"; 51#endif /* not lint */ 52 53#ifndef lint |
54#if 0 |
|
54static char sccsid[] = "@(#)finger.c 8.5 (Berkeley) 5/4/95"; | 55static char sccsid[] = "@(#)finger.c 8.5 (Berkeley) 5/4/95"; |
56#else 57static const char rcsid[] = 58 "$Id$"; 59#endif |
|
55#endif /* not lint */ 56 57/* 58 * Finger prints out information about users. It is not portable since 59 * certain fields (e.g. the full user name, office, and phone numbers) are 60 * extracted from the gecos field of the passwd file which other UNIXes 61 * may not have or may use for other things. 62 * --- 24 unchanged lines hidden (view full) --- 87#include "finger.h" 88 89DB *db; 90time_t now; 91int entries, lflag, mflag, pplan, sflag, oflag, Tflag; 92char tbuf[1024]; 93 94static void loginlist __P((void)); | 60#endif /* not lint */ 61 62/* 63 * Finger prints out information about users. It is not portable since 64 * certain fields (e.g. the full user name, office, and phone numbers) are 65 * extracted from the gecos field of the passwd file which other UNIXes 66 * may not have or may use for other things. 67 * --- 24 unchanged lines hidden (view full) --- 92#include "finger.h" 93 94DB *db; 95time_t now; 96int entries, lflag, mflag, pplan, sflag, oflag, Tflag; 97char tbuf[1024]; 98 99static void loginlist __P((void)); |
100static void usage __P((void)); |
|
95static void userlist __P((int, char **)); 96 97int 98option(argc, argv) 99 int argc; 100 char **argv; 101{ 102 int ch; --- 20 unchanged lines hidden (view full) --- 123 case 'o': 124 oflag = 1; /* office info */ 125 break; 126 case 'T': 127 Tflag = 1; /* disable T/TCP */ 128 break; 129 case '?': 130 default: | 101static void userlist __P((int, char **)); 102 103int 104option(argc, argv) 105 int argc; 106 char **argv; 107{ 108 int ch; --- 20 unchanged lines hidden (view full) --- 129 case 'o': 130 oflag = 1; /* office info */ 131 break; 132 case 'T': 133 Tflag = 1; /* disable T/TCP */ 134 break; 135 case '?': 136 default: |
131 (void)fprintf(stderr, 132 "usage: finger [-lmpshoT] [login ...]\n"); 133 exit(1); | 137 usage(); |
134 } 135 136 return optind; 137} 138 | 138 } 139 140 return optind; 141} 142 |
143static void 144usage() 145{ 146 (void)fprintf(stderr, "usage: finger [-lmpshoT] [login ...]\n"); 147 exit(1); 148} 149 150int |
|
139main(argc, argv) 140 int argc; 141 char **argv; 142{ | 151main(argc, argv) 152 int argc; 153 char **argv; 154{ |
143 int ch, envargc, argcnt; | 155 int envargc, argcnt; |
144 char *envargv[3]; 145 146 (void) setlocale(LC_ALL, ""); 147 148 /* remove this line to get remote host */ 149 oflag = 1; /* default to old "office" behavior */ 150 151 /* --- 48 unchanged lines hidden (view full) --- 200 DBT data, key; 201 struct passwd *pw; 202 struct utmp user; 203 int r, sflag; 204 char name[UT_NAMESIZE + 1]; 205 206 if (!freopen(_PATH_UTMP, "r", stdin)) 207 err(1, "%s", _PATH_UTMP); | 156 char *envargv[3]; 157 158 (void) setlocale(LC_ALL, ""); 159 160 /* remove this line to get remote host */ 161 oflag = 1; /* default to old "office" behavior */ 162 163 /* --- 48 unchanged lines hidden (view full) --- 212 DBT data, key; 213 struct passwd *pw; 214 struct utmp user; 215 int r, sflag; 216 char name[UT_NAMESIZE + 1]; 217 218 if (!freopen(_PATH_UTMP, "r", stdin)) 219 err(1, "%s", _PATH_UTMP); |
208 name[UT_NAMESIZE] = NULL; | 220 name[UT_NAMESIZE] = '\0'; |
209 while (fread((char *)&user, sizeof(user), 1, stdin) == 1) { 210 if (!user.ut_name[0]) 211 continue; 212 if ((pn = find_person(user.ut_name)) == NULL) { 213 bcopy(user.ut_name, name, UT_NAMESIZE); 214 if ((pw = getpwnam(name)) == NULL) 215 continue; 216 if (hide(pw)) --- 49 unchanged lines hidden (view full) --- 266 * Traverse the list of possible login names and check the login name 267 * and real name against the name specified by the user. 268 */ 269 if (mflag) 270 for (p = argv; *p; ++p) 271 if (((pw = getpwnam(*p)) != NULL) && !hide(pw)) 272 enter_person(pw); 273 else | 221 while (fread((char *)&user, sizeof(user), 1, stdin) == 1) { 222 if (!user.ut_name[0]) 223 continue; 224 if ((pn = find_person(user.ut_name)) == NULL) { 225 bcopy(user.ut_name, name, UT_NAMESIZE); 226 if ((pw = getpwnam(name)) == NULL) 227 continue; 228 if (hide(pw)) --- 49 unchanged lines hidden (view full) --- 278 * Traverse the list of possible login names and check the login name 279 * and real name against the name specified by the user. 280 */ 281 if (mflag) 282 for (p = argv; *p; ++p) 283 if (((pw = getpwnam(*p)) != NULL) && !hide(pw)) 284 enter_person(pw); 285 else |
274 (void)fprintf(stderr, 275 "finger: %s: no such user\n", *p); | 286 warnx("%s: no such user", *p); |
276 else { 277 while ((pw = getpwent()) != NULL) { 278 for (p = argv, ip = used; *p; ++p, ++ip) 279 if (match(pw, *p) && !hide(pw)) { 280 enter_person(pw); 281 *ip = 1; 282 } 283 } 284 for (p = argv, ip = used; *p; ++p, ++ip) 285 if (!*ip) | 287 else { 288 while ((pw = getpwent()) != NULL) { 289 for (p = argv, ip = used; *p; ++p, ++ip) 290 if (match(pw, *p) && !hide(pw)) { 291 enter_person(pw); 292 *ip = 1; 293 } 294 } 295 for (p = argv, ip = used; *p; ++p, ++ip) 296 if (!*ip) |
286 (void)fprintf(stderr, 287 "finger: %s: no such user\n", *p); | 297 warnx("%s: no such user", *p); |
288 } 289 290 /* Handle network requests. */ 291net: for (p = nargv; *p;) { 292 netfinger(*p++); 293 if (*p || entries) 294 printf("\n"); 295 } --- 30 unchanged lines hidden --- | 298 } 299 300 /* Handle network requests. */ 301net: for (p = nargv; *p;) { 302 netfinger(*p++); 303 if (*p || entries) 304 printf("\n"); 305 } --- 30 unchanged lines hidden --- |