version 1.4, 1997/04/23 19:17:29 |
version 1.5, 1997/05/30 23:35:52 |
|
|
#include <stdio.h> |
#include <stdio.h> |
#include <string.h> |
#include <string.h> |
#include <ctype.h> |
#include <ctype.h> |
|
#include <unistd.h> |
|
#include "finger.h" |
|
#include "extern.h" |
|
|
|
void |
netfinger(name) |
netfinger(name) |
char *name; |
char *name; |
{ |
{ |
extern int lflag; |
FILE *fp; |
register FILE *fp; |
int c, lastc; |
register int c, lastc; |
struct hostent *hp; |
struct hostent *hp, def; |
|
struct servent *sp; |
struct servent *sp; |
struct sockaddr_in sin; |
struct sockaddr_in sin; |
int s; |
int s; |
char *alist[1], *host; |
char *host; |
|
|
|
lastc = 0; |
if (!(host = strrchr(name, '@'))) |
if (!(host = strrchr(name, '@'))) |
return; |
return; |
*host++ = NULL; |
*host++ = '\0'; |
if (*host == NULL) |
|
host = "localhost"; |
|
if (inet_aton(host, &sin.sin_addr) == 0) { |
if (inet_aton(host, &sin.sin_addr) == 0) { |
hp = gethostbyname(host); |
hp = gethostbyname(host); |
if (hp == 0) { |
if (hp == 0) { |
|
|
* Otherwise, all high bits are stripped; if it isn't printable and |
* Otherwise, all high bits are stripped; if it isn't printable and |
* it isn't a space, we can simply set the 7th bit. Every ASCII |
* it isn't a space, we can simply set the 7th bit. Every ASCII |
* character with bit 7 set is printable. |
* character with bit 7 set is printable. |
*/ |
*/ |
if (fp = fdopen(s, "r")) |
if ((fp = fdopen(s, "r")) != NULL) |
while ((c = getc(fp)) != EOF) { |
while ((c = getc(fp)) != EOF) { |
c &= 0x7f; |
c &= 0x7f; |
if (c == '\r') { |
if (c == '\r') { |