home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / header45.zip / stack16 / netdb.h < prev    next >
Text File  |  1999-05-11  |  5KB  |  141 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. #ifdef __BORLANDC__              /* DRC01 */
  19. #ifndef _System
  20. #define _System _syscall
  21. #endif
  22. #endif
  23.  
  24. #ifdef __HIGHC__                  /* DRC01 */
  25. #define _System
  26. #endif
  27.  
  28. /*
  29.  * Structures returned by network
  30.  * data base library.  All addresses
  31.  * are supplied in host order, and
  32.  * returned in network order (suitable
  33.  * for use in system calls).
  34.  */
  35. struct  hostent {
  36.       char    *h_name;        /* official name of host */
  37.       char    **h_aliases;    /* alias list */
  38.       int     h_addrtype;     /* host address type */
  39.       int     h_length;       /* length of address */
  40.       char    **h_addr_list;  /* list of addresses from name server */
  41. #define h_addr  h_addr_list[0]  /* address, for backward compatiblity */
  42. };
  43.  
  44. /*
  45.  * Assumption here is that a network number
  46.  * fits in 32 bits -- probably a poor one.
  47.  */
  48. struct  netent {
  49.       char            *n_name;        /* official name of net */
  50.         char            **n_aliases;    /* alias list */
  51.         int             n_addrtype;     /* net address type */
  52.         unsigned long   n_net;          /* network # */
  53. };
  54.  
  55. struct  servent {
  56.         char    *s_name;        /* official service name */
  57.         char    **s_aliases;    /* alias list */
  58.         int     s_port;         /* port # */
  59.         char    *s_proto;       /* protocol to use */
  60. };
  61.  
  62. struct  protoent {
  63.         char    *p_name;        /* official protocol name */
  64.         char    **p_aliases;    /* alias list */
  65.         int     p_proto;        /* protocol # */
  66. };
  67.  
  68. #include <stdio.h>
  69. #include <string.h>
  70. #include <netinet\in.h>
  71. #define _MAXALIASES     35
  72. #define _MAXADDRS       35
  73. #define _MAXLINELEN     1024
  74. #define _HOSTBUFSIZE    (BUFSIZ + 1)
  75.  
  76. /*
  77.  * After a successful call to gethostbyname_r()/gethostbyaddr_r(), the
  78.  * structure hostent_data will contain the data to which pointers in
  79.  * the hostent structure will point to.
  80.  */
  81.  
  82. struct  hostent_data {
  83.         struct    in_addr host_addr;              /* host address pointer */
  84.         char      *h_addr_ptrs[_MAXADDRS + 1];    /* host address         */
  85.         char      hostaddr[_MAXADDRS];
  86.         char      hostbuf[_HOSTBUFSIZE + 1];      /* host data            */
  87.         char      *host_aliases[_MAXALIASES];
  88.         char      *host_addrs[2];
  89.         FILE      *hostf;
  90.         int       stayopen;                       /* AIX addon            */
  91.         unsigned  long  host_addresses[_MAXADDRS];/* As per defect 48367. */
  92. };                                                /*    Actual Addresses. */
  93.  
  94. struct  servent_data {          /* should be considered opaque */
  95.         FILE *serv_fp;
  96.         char line[_MAXLINELEN];
  97.         char *serv_aliases[_MAXALIASES];
  98.         int _serv_stayopen;
  99. };
  100.  
  101. int _System gethostname( char *, int );
  102. struct hostent * _System gethostbyname( char * );
  103. struct hostent * _System gethostbyaddr( char *, int, int );
  104. struct netent * _System getnetbyname( char * );
  105. struct netent * _System getnetbyaddr( unsigned long, int );
  106. struct servent * _System getservbyname( char *, char * );
  107. struct servent * _System getservbyport( int, char * );
  108. struct servent * _System getservent( void );
  109. struct protoent * _System getprotobyname( char * );
  110. struct protoent * _System getprotobynumber( int );
  111. void _System sethostent( int );
  112. struct hostent * _System gethostent( void );
  113. void _System endhostent(void);
  114. void _System setnetent( int );
  115. struct netent * _System getnetent( void );
  116. void _System endnetent(void);
  117. void _System setprotoent( int );
  118. struct protoent * _System getprotoent( void );
  119. void _System endprotoent(void);
  120. void _System setservent( int );
  121. struct servent * _System getservent( void );
  122. void _System endservent(void);
  123. int _System tcp_h_errno(void);
  124. struct hostent * _System Rgethostbyname(char *);
  125.  
  126. /*
  127.  * Error return codes from gethostbyname() and gethostbyaddr()
  128.  * (left in extern int h_errno).
  129.  */
  130.  
  131. #define h_errno (tcp_h_errno())   /* Thread Re-entrant */
  132.  
  133. #define HOST_NOT_FOUND  1 /* Authoritative Answer Host not found */
  134. #define TRY_AGAIN       2 /* Non-Authoritive Host not found, or SERVERFAIL */
  135. #define NO_RECOVERY     3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
  136. #define NO_DATA         4 /* Valid name, no data record of requested type */
  137. #define NO_ADDRESS      NO_DATA         /* no address, look for MX record */
  138.  
  139. #endif /* __NETDB_32H  */
  140.  
  141.