genericopenlibs/cstdlib/LINC/NETDB.H
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 /* NETDB.H
       
     2  * 
       
     3  * Portions Copyright (c) 1993-1999 Nokia Corporation and/or its subsidiary(-ies).
       
     4  * All rights reserved.
       
     5  */
       
     6 
       
     7 /*-
       
     8  * Copyright (c) 1980, 1983, 1988, 1993
       
     9  *	The Regents of the University of California.  All rights reserved.
       
    10  *
       
    11  * Redistribution and use in source and binary forms, with or without
       
    12  * modification, are permitted provided that the following conditions
       
    13  * are met:
       
    14  * 1. Redistributions of source code must retain the above copyright
       
    15  *    notice, this list of conditions and the following disclaimer.
       
    16  * 2. Redistributions in binary form must reproduce the above copyright
       
    17  *    notice, this list of conditions and the following disclaimer in the
       
    18  *    documentation and/or other materials provided with the distribution.
       
    19  * 3. All advertising materials mentioning features or use of this software
       
    20  *    must display the following acknowledgement:
       
    21  *	This product includes software developed by the University of
       
    22  *	California, Berkeley and its contributors.
       
    23  * 4. Neither the name of the University nor the names of its contributors
       
    24  *    may be used to endorse or promote products derived from this software
       
    25  *    without specific prior written permission.
       
    26  *
       
    27  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
       
    28  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
       
    29  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
       
    30  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
       
    31  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
       
    32  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
       
    33  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
       
    34  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
       
    35  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
       
    36  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
       
    37  * SUCH DAMAGE.
       
    38  *
       
    39  * Portions Copyright (c) 1993 by Digital Equipment Corporation.
       
    40  *
       
    41  * Permission to use, copy, modify, and distribute this software for any
       
    42  * purpose with or without fee is hereby granted, provided that the above
       
    43  * copyright notice and this permission notice appear in all copies, and that
       
    44  * the name of Digital Equipment Corporation not be used in advertising or
       
    45  * publicity pertaining to distribution of the document or software without
       
    46  * specific, written prior permission.
       
    47  *
       
    48  * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
       
    49  * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
       
    50  * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
       
    51  * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
       
    52  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
       
    53  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
       
    54  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
       
    55  * SOFTWARE.
       
    56  * -
       
    57  * --Copyright--
       
    58  */
       
    59 
       
    60 /** @file
       
    61 @publishedAll
       
    62 @released
       
    63 */
       
    64 
       
    65 #ifndef _NETDB_H_
       
    66 #define _NETDB_H_
       
    67 
       
    68 #ifdef __cplusplus
       
    69 extern "C" {
       
    70 #endif
       
    71 
       
    72 #include <_ansi.h>
       
    73 #include <sys/errno.h>
       
    74 
       
    75 #define	_PATH_HEQUIV	"/etc/hosts.equiv"
       
    76 #define	_PATH_HOSTS	"/etc/hosts"
       
    77 #define	_PATH_NETWORKS	"/etc/networks"
       
    78 #define	_PATH_PROTOCOLS	"/etc/protocols"
       
    79 #define	_PATH_SERVICES	"/etc/services"
       
    80 
       
    81 #define h_errno	errno
       
    82 
       
    83 /**
       
    84 Structures returned by network data base library.  All addresses are
       
    85 supplied in host order, and returned in network order (suitable for
       
    86 use in system calls).
       
    87 */
       
    88 struct	hostent {
       
    89 	char	*h_name;	/* official name of host */
       
    90 	char	**h_aliases;	/* alias list */
       
    91 	int	h_addrtype;	/* host address type */
       
    92 	int	h_length;	/* length of address */
       
    93 	char	**h_addr_list;	/* list of addresses from name server */
       
    94 #define	h_addr	h_addr_list[0]	/* address, for backward compatibility */
       
    95 };
       
    96 
       
    97 /**
       
    98 Assumption here is that a network number
       
    99 fits in an unsigned long -- probably a poor one.
       
   100 */
       
   101 struct	netent {
       
   102 	char		*n_name;	/* official name of net */
       
   103 	char		**n_aliases;	/* alias list */
       
   104 	int		n_addrtype;	/* net address type */
       
   105 	unsigned long	n_net;		/* network # */
       
   106 };
       
   107 
       
   108 struct	servent {
       
   109 	char	*s_name;	/* official service name */
       
   110 	char	**s_aliases;	/* alias list */
       
   111 	int	s_port;		/* port # */
       
   112 	char	*s_proto;	/* protocol to use */
       
   113 };
       
   114 
       
   115 struct	protoent {
       
   116 	char	*p_name;	/* official protocol name */
       
   117 	char	**p_aliases;	/* alias list */
       
   118 	int	p_proto;	/* protocol # */
       
   119 };
       
   120 
       
   121 /**
       
   122 Error return codes from gethostbyname() and gethostbyaddr()
       
   123 */
       
   124 #define	NETDB_INTERNAL	-1	/* see errno */
       
   125 #define	NETDB_SUCCESS	0	/* no problem */
       
   126 #define	HOST_NOT_FOUND	ENOENT		/* Authoritative Answer Host not found */
       
   127 #define	TRY_AGAIN	ETIMEDOUT	/* Non-Authoritative Host not found, or SERVERFAIL */
       
   128 #define	NO_RECOVERY	ECOMM		/* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
       
   129 #define	NO_DATA		4		/* Valid name, no data record of requested type */
       
   130 #define	NO_ADDRESS	NO_DATA		/* no address, look for MX record */
       
   131 
       
   132 IMPORT_C struct hostent	*gethostbyaddr (const char *, int, int);
       
   133 IMPORT_C struct hostent	*gethostbyname (const char *);
       
   134 struct servent	*getservbyname (const char *, const char *);
       
   135 struct servent	*getservbyport (int, const char *);
       
   136 struct netent	*getnetbyaddr (unsigned long, int);
       
   137 struct netent	*getnetbyname (const char *);
       
   138 struct protoent	*getprotobyname (const char *);
       
   139 struct protoent	*getprotobynumber (int);
       
   140 
       
   141 #ifdef __cplusplus
       
   142 }
       
   143 #endif
       
   144 
       
   145 #endif /* !_NETDB_H_ */