home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tcp30tkt.zip / PGMG1.ZIP / INCLUDE / NETDB.H < prev    next >
Text File  |  1995-12-04  |  5KB  |  134 lines

  1. #ifndef __NETDB_32H
  2. #define __NETDB_32H
  3. /*
  4.  * Copyright (c) 1980,1983,1988 Regents of the University of California.
  5.  * All rights reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms are permitted
  8.  * provided that this notice is preserved and that due credit is given
  9.  * to the University of California at Berkeley. The name of the University
  10.  * may not be used to endorse or promote products derived from this
  11.  * software without specific prior written permission. This software
  12.  * is provided ``as is'' without express or implied warranty.
  13.  *
  14.  *      @(#)netdb.h     5.9 (Berkeley) 4/5/88
  15.  */
  16.  
  17.  
  18. /*
  19.  * Structures returned by network
  20.  * data base library.  All addresses
  21.  * are supplied in host order, and
  22.  * returned in network order (suitable
  23.  * for use in system calls).
  24.  */
  25. struct  hostent {
  26.         char    *h_name;        /* official name of host */
  27.         char    **h_aliases;    /* alias list */
  28.         int     h_addrtype;     /* host address type */
  29.         int     h_length;       /* length of address */
  30.         char    **h_addr_list;  /* list of addresses from name server */
  31. #define h_addr  h_addr_list[0]  /* address, for backward compatiblity */
  32. };
  33.  
  34. /*
  35.  * Assumption here is that a network number
  36.  * fits in 32 bits -- probably a poor one.
  37.  */
  38. struct  netent {
  39.         char            *n_name;        /* official name of net */
  40.         char            **n_aliases;    /* alias list */
  41.         int             n_addrtype;     /* net address type */
  42.         unsigned long   n_net;          /* network # */
  43. };
  44.  
  45. struct  servent {
  46.         char    *s_name;        /* official service name */
  47.         char    **s_aliases;    /* alias list */
  48.         int     s_port;         /* port # */
  49.         char    *s_proto;       /* protocol to use */
  50. };
  51.  
  52. struct  protoent {
  53.         char    *p_name;        /* official protocol name */
  54.         char    **p_aliases;    /* alias list */
  55.         int     p_proto;        /* protocol # */
  56. };
  57.  
  58. #include <stdio.h>
  59. #include <string.h>
  60. #include <netinet\in.h>
  61. #define _MAXALIASES     35
  62. #define _MAXADDRS       35
  63. #define _MAXLINELEN     1024
  64. #define _HOSTBUFSIZE    (BUFSIZ + 1)
  65.  
  66. /*
  67.  * After a successful call to gethostbyname_r()/gethostbyaddr_r(), the
  68.  * structure hostent_data will contain the data to which pointers in
  69.  * the hostent structure will point to.
  70.  */
  71.  
  72. struct  hostent_data {
  73.         struct    in_addr host_addr;              /* host address pointer */
  74.         char      *h_addr_ptrs[_MAXADDRS + 1];    /* host address         */
  75.         char      hostaddr[_MAXADDRS];
  76.         char      hostbuf[_HOSTBUFSIZE + 1];      /* host data            */
  77.         char      *host_aliases[_MAXALIASES];
  78.         char      *host_addrs[2];
  79.         FILE      *hostf;
  80.         int       stayopen;                       /* AIX addon            */
  81.         unsigned  long  host_addresses[_MAXADDRS];/* As per defect 48367. */
  82. };                                                /*    Actual Addresses. */
  83.  
  84. struct  servent_data {          /* should be considered opaque */
  85.         FILE *serv_fp;
  86.         char line[_MAXLINELEN];
  87.         char *serv_aliases[_MAXALIASES];
  88.         int _serv_stayopen;
  89. };
  90.  
  91. int _System gethostbyname_r(char *, struct hostent *, struct hostent_data *);
  92. int _System gethostbyaddr_r(char *, int, int, struct hostent *, struct hostent_data *);
  93. int _System getservbyname_r(char *, char *, struct servent *, struct servent_data *);
  94. int _System gethostname( char *, int );
  95. struct hostent * _System gethostbyname( char * );
  96. struct hostent * _System _gethtbyname( char * );
  97. struct hostent * _System gethostbyaddr( char *, int, int );
  98. struct hostent * _System _gethtbyaddr( char *, int, int );
  99. struct netent * _System getnetbyname( char * );
  100. struct netent * _System getnetbyaddr( unsigned long, int );
  101. struct servent * _System getservbyname( char *, char * );
  102. struct servent * _System getservbyport( int, char * );
  103. struct servent * _System getservent( void );
  104. struct protoent * _System getprotobyname( char * );
  105. struct protoent * _System getprotobynumber( int );
  106. void _System sethostent( int );
  107. struct hostent * _System gethostent( void );
  108. void _System endhostent(void);
  109. void _System setnetent( int );
  110. struct netent * _System getnetent( void );
  111. void _System endnetent(void);
  112. void _System setprotoent( int );
  113. struct protoent * _System getprotoent( void );
  114. void _System endprotoent(void);
  115. void _System setservent( int );
  116. struct servent * _System getservent( void );
  117. void _System endservent(void);
  118. int _System tcp_h_errno(void);
  119.  
  120. /*
  121.  * Error return codes from gethostbyname() and gethostbyaddr()
  122.  * (left in extern int h_errno).
  123.  */
  124.  
  125. #define h_errno (tcp_h_errno())   /* Thread Re-entrant */
  126.  
  127. #define HOST_NOT_FOUND  1 /* Authoritative Answer Host not found */
  128. #define TRY_AGAIN       2 /* Non-Authoritive Host not found, or SERVERFAIL */
  129. #define NO_RECOVERY     3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
  130. #define NO_DATA         4 /* Valid name, no data record of requested type */
  131. #define NO_ADDRESS      NO_DATA         /* no address, look for MX record */
  132.  
  133. #endif /* __NETDB_32H  */
  134.