/* * Copyright (c) 1993 W. Richard Stevens. All rights reserved. * Permission to use or modify this software and its documentation only for * educational purposes and without fee is hereby granted, provided that * the above copyright notice appear in all copies. The author makes no * representations about the suitability of this software for any purpose. * It is provided "as is" without express or implied warranty. */ #include #include #include #include /* struct timeval for select() */ #ifdef _AIX #include #endif #include #ifdef __bsdi__ #include /* required before tcp.h, for BYTE_ORDER */ #endif #include /* TCP_NODELAY */ #include /* getservbyname(), gethostbyname() */ #include /* inet_addr() */ #include #include #include "ourhdr.h" /* declare global variables */ extern int bindport; extern int broadcast; extern int cbreak; extern int client; extern int crlf; extern int debug; extern int dofork; extern char foreignip[]; extern int foreignport; extern int halfclose; extern int keepalive; extern long linger; extern int listenq; extern int nodelay; extern int nbuf; extern int pauseclose; extern int pauseinit; extern int pauselisten; extern int pauserw; extern int reuseaddr; extern int readlen; extern int writelen; extern int recvdstaddr; extern int rcvbuflen; extern int sndbuflen; extern char *rbuf; extern char *wbuf; extern int server; extern int sourcesink; extern int udp; extern int urgwrite; extern int verbose; #ifndef INADDR_NONE #define INADDR_NONE 0xffffffff /* should be in */ #endif /* Earlier versions of gcc under SunOS 4.x have problems passing arguments that are structs (as opposed to pointers to structs). This shows up with inet_ntoa, whose argument is a "struct in_addr". */ #if defined(sun) && defined(__GNUC__) && defined(GCC_STRUCT_PROBLEM) #define INET_NTOA(foo) inet_ntoa(&foo) #else #define INET_NTOA(foo) inet_ntoa(foo) #endif /* function prototypes */ void bcopy(const void *, void *, size_t); void bzero(void *, size_t); void buffers(int); int cliopen(char *host, char *port); int crlf_add(char *dst, int dstsize, const char *src, int lenin); int crlf_strip(char *dst, int dstsize, const char *src, int lenin); void loop(int); int servopen(char *host, char *port); void sink(int sockfd); void sockopts(int sockfd, int doall);