version 1.78, 2005/04/10 19:43:34 |
version 1.79, 2005/05/24 20:13:28 |
|
|
#include <string.h> |
#include <string.h> |
#include <unistd.h> |
#include <unistd.h> |
#include <fcntl.h> |
#include <fcntl.h> |
|
#include "atomicio.h" |
|
|
#ifndef SUN_LEN |
#ifndef SUN_LEN |
#define SUN_LEN(su) \ |
#define SUN_LEN(su) \ |
|
|
int family = AF_UNSPEC; |
int family = AF_UNSPEC; |
char *portlist[PORT_MAX+1]; |
char *portlist[PORT_MAX+1]; |
|
|
ssize_t atomicio(ssize_t (*)(int, void *, size_t), int, void *, size_t); |
|
void atelnet(int, unsigned char *, unsigned int); |
void atelnet(int, unsigned char *, unsigned int); |
void build_ports(char *); |
void build_ports(char *); |
void help(void); |
void help(void); |
|
|
{ |
{ |
struct pollfd pfd[2]; |
struct pollfd pfd[2]; |
unsigned char buf[BUFSIZ]; |
unsigned char buf[BUFSIZ]; |
int wfd = fileno(stdin), n; |
int n, wfd = fileno(stdin); |
int lfd = fileno(stdout); |
int lfd = fileno(stdout); |
|
|
/* Setup Network FD */ |
/* Setup Network FD */ |
|
|
} else { |
} else { |
if (tflag) |
if (tflag) |
atelnet(nfd, buf, n); |
atelnet(nfd, buf, n); |
if (atomicio((ssize_t (*)(int, void *, size_t))write, |
if (atomicio(vwrite, lfd, buf, n) != n) |
lfd, buf, n) != n) |
|
return; |
return; |
} |
} |
} |
} |
|
|
pfd[1].fd = -1; |
pfd[1].fd = -1; |
pfd[1].events = 0; |
pfd[1].events = 0; |
} else { |
} else { |
if (atomicio((ssize_t (*)(int, void *, size_t))write, |
if (atomicio(vwrite, nfd, buf, n) != n) |
nfd, buf, n) != n) |
|
return; |
return; |
} |
} |
} |
} |
|
|
p++; |
p++; |
obuf[2] = *p; |
obuf[2] = *p; |
obuf[3] = '\0'; |
obuf[3] = '\0'; |
if (atomicio((ssize_t (*)(int, void *, size_t))write, |
if (atomicio(vwrite, nfd, obuf, 3) != 3) |
nfd, obuf, 3) != 3) |
warn("Write Error!"); |
warnx("Write Error!"); |
|
obuf[0] = '\0'; |
obuf[0] = '\0'; |
} |
} |
} |
} |