home *** CD-ROM | disk | FTP | other *** search
- #ifdef MSDOS
- #ifndef __MSDOSTCP_H
- #define __MSDOSTCP_H
- /*
- * NOTE: BIG HACK on WATTCP that you will have to do.
- * Take care to change the wattcp *.c and *.h files so that the tokens
- * #include<tcp.h>
- * getsockname
- * sockaddr
- * sockaddr_in
- * in_addr
- * are now
- * #include"c:\wattcp\include\tcp.h" or whatever the path is
- * hack_getsockname
- * hack_sockaddr
- * hack_in_addr
- *
- * By using #define statements at the start of important wattcp headers,
- * it should be very easy to do.
- * This is to avoid name clashes only with tokens that I will code
- * for better WWW and Berkeley socket compatibility.
- * As for the header file tcp.h, there is one in WWW and Wattcp. To
- * avoid confusion, make sure the WWW\LIBRARY\IMPLEMEN directory is
- * first in the include path search, and in all the wattcp code,
- * specify the full path for the tcp.h file as above.
- */
-
- /*
- * Wattcp fails to implement sockets in a directly compatible manner.
- * Must define some common things used in WWW and implement functions
- * to do the same thing as open, socket, bind, etc... in unix.
- * The compatible(?) implementation can be found in msdostcp.c
- */
- #include<time.h>
- #include<sys\stat.h>
- #include"..\wattcp\include\tcp.h"
-
- /*
- * Range of ports assignable by the system.
- */
- #define MIN_TCP_PORT 1024
- #define MAX_TCP_PORT 5999
-
- /*
- * Undefine those things that clash from wattcp.
- * We will have to call wattcp code that uses these things by using
- * the prefix hack_, except sockaddr_in, which we will substitute
- * hack_sockaddr directly. See above.
- */
- #undef getsockname
- #undef sockaddr
- #undef sockaddr_in
- #undef in_addr
-
- #undef NETREAD
- #undef NETWRITE
- #undef NETCLOSE
- #define NETREAD(s, b, l) s_read(s, b, l)
- #define NETWRITE(s, b, l) s_write(s, b, l)
- #define NETCLOSE(s) s_close(s)
-
- #define SOCK_STREAM 1
- #define AF_INET 2
- #define IPPROTO_TCP 6
- #define INADDR_ANY (unsigned long)0x00000000
-
- struct hostent {
- char *h_name;
- char **h_aliases;
- int h_addrtype;
- int h_length;
- char **h_addr_list;
- };
- #define h_addr h_addr_list[0]
-
- struct servent {
- char *s_name;
- char **s_aliases;
- int s_port;
- char *s_proto;
- };
-
- struct sockaddr {
- unsigned short sa_family;
- char sa_data[14];
- };
-
- struct in_addr {
- unsigned long s_addr;
- };
-
- struct sockaddr_in {
- short sin_family;
- unsigned short sin_port;
- struct in_addr sin_addr;
- char sin_zero[8];
- };
-
- int socket(int family, int type, int protocol);
- int connect(int sockfd, struct sockaddr *servaddr, int addrlen);
- struct hostent *gethostbyname(char *hostname);
- struct servent *getservbyname(char *servname, char *protname);
- int s_read(int fildes, char *buff, unsigned int nbytes);
- int s_write(int fildes, char *buff, unsigned int nbytes);
- int s_close(int fildes);
- int accept(int sockfd, struct sockaddr *peer, int *addrlen);
- int bind(int sockfd, struct sockaddr *myaddr, int addrlen);
- int listen(int sockfd, int backlog);
-
- /*
- * Functions may not be implemented yet.
- * Check msdostcp.c
- */
- int getsockname(int sockfd, struct sockaddr *peer, int *addrlen);
-
- /*
- * Socket structure used in msdostcp
- */
- typedef struct socket_info_tag {
- int i_family, i_type, i_protocol;
- void *vp_sockfd;
- unsigned short int usi_EOF, usi_IO, usi_OPEN;
- unsigned long int uli_read, uli_written;
- unsigned long int uli_bindmyaddr;
- unsigned short int usi_bindmyport;
- unsigned char uc_used;
- signed short int ssi_backlog;
- signed short int *ssip_backlogfd;
- }
- socket_info;
-
- /*
- * MAXSOCKETS thought to be the limit of open sockets with WATTCP.
- * Global variable for outside routines to recognize which socket
- * is being referenced and the table to use the reference in. -1 if
- * invalid or not referencing anything.
- */
- #define MAXSOCKETS 16
- extern signed short int ssi_sockfd;
- extern socket_info sock_table[MAXSOCKETS];
-
- #ifdef WWW
- /*
- * The following is to help in converting the WWW library to dos.
- * The code can still be found in msdostcp.c although it has nothing
- * to do with Berkeley sockets so to speak.
- */
- char *crypt(char *key, char *salt);
-
- /*
- * The following is a function to be passed to wattcp's sock_yield
- * function.
- * Application specific; source defined elsewhere.
- */
- extern void yield(void);
-
- #endif /* WWW */
- #endif /* __MSDOSTCP_H */
- #endif /* MSDOS */