netdb.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #ifndef __NETDB_H__
  2. #define __NETDB_H__
  3. #ifndef _BSD_EXTENSION
  4. This header file is an extension to ANSI/POSIX
  5. #endif
  6. #pragma lib "/$M/lib/ape/libbsd.a"
  7. /*-
  8. * Copyright (c) 1980, 1983, 1988 Regents of the University of California.
  9. * All rights reserved.
  10. *
  11. * Redistribution and use in source and binary forms are permitted
  12. * provided that: (1) source distributions retain this entire copyright
  13. * notice and comment, and (2) distributions including binaries display
  14. * the following acknowledgement: ``This product includes software
  15. * developed by the University of California, Berkeley and its contributors''
  16. * in the documentation or other materials provided with the distribution
  17. * and in all advertising materials mentioning features or use of this
  18. * software. Neither the name of the University nor the names of its
  19. * contributors may be used to endorse or promote products derived
  20. * from this software without specific prior written permission.
  21. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  22. * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  23. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  24. *
  25. * @(#)netdb.h 5.11 (Berkeley) 5/21/90
  26. */
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /*
  31. * Structures returned by network data base library. All addresses are
  32. * supplied in host order, and returned in network order (suitable for
  33. * 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. * Assumption here is that a network number
  45. * fits in 32 bits -- probably a poor one.
  46. */
  47. struct netent {
  48. char *n_name; /* official name of net */
  49. char **n_aliases; /* alias list */
  50. int n_addrtype; /* net address type */
  51. unsigned long n_net; /* network # */
  52. };
  53. struct servent {
  54. char *s_name; /* official service name */
  55. char **s_aliases; /* alias list */
  56. int s_port; /* port # */
  57. char *s_proto; /* protocol to use */
  58. };
  59. struct protoent {
  60. char *p_name; /* official protocol name */
  61. char **p_aliases; /* alias list */
  62. int p_proto; /* protocol # */
  63. };
  64. /* from 4.0 RPCSRC */
  65. struct rpcent {
  66. char *r_name; /* name of server for this rpc program */
  67. char **r_aliases; /* alias list */
  68. int r_number; /* rpc program number */
  69. };
  70. extern struct hostent *gethostbyname(const char *),
  71. *gethostbyaddr(const void *, int, int),
  72. *gethostent(void);
  73. extern struct netent *getnetbyname(const char *),
  74. *getnetbyaddr(long, int),
  75. *getnetent(void);
  76. extern struct servent *getservbyname(const char *, const char *),
  77. *getservbyport(int, const char *),
  78. *getservent(void);
  79. extern struct protoent *getprotobyname(const char *),
  80. *getprotobynumber(int),
  81. *getprotoent(void);
  82. extern struct rpcent *getrpcbyname(const char *),
  83. *getrpcbynumber(int),
  84. *getrpcent(void);
  85. extern void sethostent(int), endhostent(void),
  86. setnetent(int), endnetent(void),
  87. setservent(int), endservent(void),
  88. setprotoent(int), endprotoent(void),
  89. setrpcent(int), endrpcent(void);
  90. /*
  91. * Error return codes from gethostbyname() and gethostbyaddr()
  92. * (left in extern int h_errno).
  93. */
  94. extern int h_errno;
  95. extern void herror(const char *);
  96. extern char *hstrerror(int);
  97. #define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */
  98. #define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */
  99. #define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
  100. #define NO_DATA 4 /* Valid name, no data record of requested type */
  101. #define NO_ADDRESS NO_DATA /* no address, look for MX record */
  102. #define __HOST_SVC_NOT_AVAIL 99 /* libc internal use only */
  103. #ifdef __cplusplus
  104. }
  105. #endif
  106. #endif /* !__NETDB_H__ */