SCCS-vsn: usr.bin/finger/finger.c 5.18
SCCS-vsn: usr.bin/finger/lprint.c 5.6
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)finger.c 5.17 (Berkeley) %G%";
+static char sccsid[] = "@(#)finger.c 5.18 (Berkeley) %G%";
loginlist()
{
register PERSON *pn;
loginlist()
{
register PERSON *pn;
struct passwd *pw;
struct utmp user;
char name[UT_NAMESIZE + 1];
struct passwd *pw;
struct utmp user;
char name[UT_NAMESIZE + 1];
- if ((fp = fopen(_PATH_UTMP, "r")) == NULL) {
+ if (!freopen(_PATH_UTMP, "r", stdin)) {
(void)fprintf(stderr, "finger: can't read %s.\n", _PATH_UTMP);
exit(2);
}
name[UT_NAMESIZE] = NULL;
(void)fprintf(stderr, "finger: can't read %s.\n", _PATH_UTMP);
exit(2);
}
name[UT_NAMESIZE] = NULL;
- while (fread((char *)&user, sizeof(user), 1, fp) == 1) {
+ while (fread((char *)&user, sizeof(user), 1, stdin) == 1) {
if (!user.ut_name[0])
continue;
if ((pn = find_person(user.ut_name)) == NULL) {
if (!user.ut_name[0])
continue;
if ((pn = find_person(user.ut_name)) == NULL) {
}
enter_where(&user, pn);
}
}
enter_where(&user, pn);
}
for (pn = phead; lflag && pn != NULL; pn = pn->next)
enter_lastlog(pn);
}
for (pn = phead; lflag && pn != NULL; pn = pn->next)
enter_lastlog(pn);
}
struct utmp user;
struct passwd *pw;
int dolocal, *used;
struct utmp user;
struct passwd *pw;
int dolocal, *used;
char *index();
if (!(used = (int *)calloc((u_int)argc, (u_int)sizeof(int)))) {
char *index();
if (!(used = (int *)calloc((u_int)argc, (u_int)sizeof(int)))) {
* Scan thru the list of users currently logged in, saving
* appropriate data whenever a match occurs.
*/
* Scan thru the list of users currently logged in, saving
* appropriate data whenever a match occurs.
*/
- if ((fp = fopen(_PATH_UTMP, "r")) == NULL) {
+ if (!freopen(_PATH_UTMP, "r", stdin)) {
(void)fprintf( stderr, "finger: can't read %s.\n", _PATH_UTMP);
exit(1);
}
(void)fprintf( stderr, "finger: can't read %s.\n", _PATH_UTMP);
exit(1);
}
- while (fread((char *)&user, sizeof(user), 1, fp) == 1) {
+ while (fread((char *)&user, sizeof(user), 1, stdin) == 1) {
if (!user.ut_name[0])
continue;
if ((pn = find_person(user.ut_name)) == NULL)
continue;
enter_where(&user, pn);
}
if (!user.ut_name[0])
continue;
if ((pn = find_person(user.ut_name)) == NULL)
continue;
enter_where(&user, pn);
}
for (pn = phead; pn != NULL; pn = pn->next)
enter_lastlog(pn);
}
for (pn = phead; pn != NULL; pn = pn->next)
enter_lastlog(pn);
}
-static char sccsid[] = "@(#)lprint.c 5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)lprint.c 5.6 (Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
#include <sys/time.h>
#include <tzfile.h>
#include <stdio.h>
#include <sys/time.h>
#include <tzfile.h>
#include <stdio.h>
#include "finger.h"
#include "pathnames.h"
#include "finger.h"
#include "pathnames.h"
show_text(directory, file_name, header)
char *directory, *file_name, *header;
{
show_text(directory, file_name, header)
char *directory, *file_name, *header;
{
(void)sprintf(tbuf, "%s/%s", directory, file_name);
(void)sprintf(tbuf, "%s/%s", directory, file_name);
- if ((fd = open(tbuf, O_RDONLY, 0)) < 0)
+ if (!freopen(tbuf, "r", stdin))
return(0);
(void)printf("%s\n", header);
return(0);
(void)printf("%s\n", header);
- (void)fflush(stdout);
- while ((n = read(fd, tbuf, sizeof(tbuf))) > 0)
- if (write(1, tbuf, n) != n)
- break;
- (void)close(fd);
+ while ((ch = getchar(fp)) != EOF)
+ vputc(ch);
+ if (ch != '\n')
+ (void)putchar('\n');
+
+vputc(ch)
+ register int ch;
+{
+ int meta;
+
+ if (!isascii(ch)) {
+ (void)putchar('M');
+ (void)putchar('-');
+ ch = toascii(ch);
+ meta = 1;
+ } else
+ meta = 0;
+ if (isprint(ch) || !meta && isspace(ch))
+ (void)putchar(ch);
+ else {
+ (void)putchar('^');
+ (void)putchar(ch == '\177' ? '?' : ch | 0100);
+ }
+}