finger.c (1591) | finger.c (2537) |
---|---|
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 --- 20 unchanged lines hidden (view full) --- 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 */ 36 | 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 --- 20 unchanged lines hidden (view full) --- 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 * SUCH DAMAGE. 35 */ 36 |
37/* 38 * Luke Mewburn <lm@rmit.edu.au> added the following on 940622: 39 * - mail status ("No Mail", "Mail read:...", or "New Mail ..., 40 * Unread since ...".) 41 * - 4 digit phone extensions (3210 is printed as x3210.) 42 * - host/office toggling in short format with -h & -o. 43 * - short day names (`Tue' printed instead of `Jun 21' if the 44 * login time is < 6 days. 45 */ 46 |
|
37#ifndef lint 38static char copyright[] = 39"@(#) Copyright (c) 1989, 1993\n\ 40 The Regents of the University of California. All rights reserved.\n"; 41#endif /* not lint */ 42 43#ifndef lint 44static char sccsid[] = "@(#)finger.c 8.2 (Berkeley) 9/30/93"; 45#endif /* not lint */ 46 47/* 48 * Finger prints out information about users. It is not portable since 49 * certain fields (e.g. the full user name, office, and phone numbers) are 50 * extracted from the gecos field of the passwd file which other UNIXes 51 * may not have or may use for other things. 52 * 53 * There are currently two output formats; the short format is one line 54 * per user and displays login name, tty, login time, real name, idle time, | 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 54static char sccsid[] = "@(#)finger.c 8.2 (Berkeley) 9/30/93"; 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 * 63 * There are currently two output formats; the short format is one line 64 * per user and displays login name, tty, login time, real name, idle time, |
55 * and office location/phone number. The long format gives the same 56 * information (in a more legible format) as well as home directory, shell, 57 * mail info, and .plan/.project files. | 65 * and either remote host information (default) or office location/phone 66 * number, depending on if -h or -o is used respectively. 67 * The long format gives the same information (in a more legible format) as 68 * well as home directory, shell, mail info, and .plan/.project files. |
58 */ 59 60#include <sys/param.h> 61#include <fcntl.h> 62#include <time.h> 63#include <pwd.h> 64#include <utmp.h> 65#include <errno.h> 66#include <stdio.h> 67#include <stdlib.h> 68#include <string.h> 69#include <db.h> 70#include "finger.h" 71 72DB *db; 73time_t now; | 69 */ 70 71#include <sys/param.h> 72#include <fcntl.h> 73#include <time.h> 74#include <pwd.h> 75#include <utmp.h> 76#include <errno.h> 77#include <stdio.h> 78#include <stdlib.h> 79#include <string.h> 80#include <db.h> 81#include "finger.h" 82 83DB *db; 84time_t now; |
74int entries, lflag, mflag, pplan, sflag; | 85int entries, lflag, mflag, pplan, sflag, oflag; |
75char tbuf[1024]; 76 77static void loginlist __P((void)); 78static void userlist __P((int, char **)); 79 80main(argc, argv) 81 int argc; 82 char **argv; 83{ 84 int ch; 85 | 86char tbuf[1024]; 87 88static void loginlist __P((void)); 89static void userlist __P((int, char **)); 90 91main(argc, argv) 92 int argc; 93 char **argv; 94{ 95 int ch; 96 |
86 while ((ch = getopt(argc, argv, "lmps")) != EOF) | 97 /* delete this for sun behavior */ 98 oflag = 1; /* default to old behavior for now */ 99 100 while ((ch = getopt(argc, argv, "lmpsho")) != EOF) |
87 switch(ch) { 88 case 'l': 89 lflag = 1; /* long format */ 90 break; 91 case 'm': 92 mflag = 1; /* force exact match of names */ 93 break; 94 case 'p': 95 pplan = 1; /* don't show .plan/.project */ 96 break; 97 case 's': 98 sflag = 1; /* short format */ 99 break; | 101 switch(ch) { 102 case 'l': 103 lflag = 1; /* long format */ 104 break; 105 case 'm': 106 mflag = 1; /* force exact match of names */ 107 break; 108 case 'p': 109 pplan = 1; /* don't show .plan/.project */ 110 break; 111 case 's': 112 sflag = 1; /* short format */ 113 break; |
114 case 'h': 115 oflag = 0; /* remote host info */ 116 break; 117 case 'o': 118 oflag = 1; /* office info */ 119 break; |
|
100 case '?': 101 default: 102 (void)fprintf(stderr, | 120 case '?': 121 default: 122 (void)fprintf(stderr, |
103 "usage: finger [-lmps] [login ...]\n"); | 123 "usage: finger [-lmpsho] [login ...]\n"); |
104 exit(1); 105 } 106 argc -= optind; 107 argv += optind; 108 109 (void)time(&now); 110 setpassent(1); 111 if (!*argv) { --- 146 unchanged lines hidden --- | 124 exit(1); 125 } 126 argc -= optind; 127 argv += optind; 128 129 (void)time(&now); 130 setpassent(1); 131 if (!*argv) { --- 146 unchanged lines hidden --- |