xref: /freebsd/lib/libc/net/netdb_private.h (revision bcb131aa3c3ddaaf3a4073864b6cf7bf1aa265c6)
1 /*-
2  * Copyright (C) 2005 The FreeBSD Project.  All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
17  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23  * SUCH DAMAGE.
24  *
25  * $FreeBSD$
26  */
27 
28 #ifndef _NETDB_PRIVATE_H_
29 #define _NETDB_PRIVATE_H_
30 
31 #include <stdio.h>				/* XXX: for BUFSIZ */
32 
33 #define	PROTOENT_MAXALIASES	35
34 #define	SERVENT_MAXALIASES	35
35 
36 struct protoent_data {
37 	FILE *fp;
38 	char *aliases[PROTOENT_MAXALIASES];
39 	int stayopen;
40 	char line[BUFSIZ + 1];
41 };
42 
43 struct protodata {
44 	struct protoent proto;
45 	struct protoent_data data;
46 };
47 
48 struct servent_data {
49 	FILE *fp;
50 	char *aliases[SERVENT_MAXALIASES];
51 	int stayopen;
52 	char line[BUFSIZ + 1];
53 #ifdef YP
54 	int yp_stepping;
55 	char *yp_name;
56 	char *yp_proto;
57 	int yp_port;
58 	char *yp_domain;
59 	char *yp_key;
60 	int yp_keylen;
61 #endif
62 };
63 
64 struct servdata {
65 	struct servent serv;
66 	struct servent_data data;
67 };
68 
69 #define	endprotoent_r		__endprotoent_r
70 #define	endservent_r		__endservent_r
71 #define	getprotobyname_r	__getprotobyname_r
72 #define	getprotobynumber_r	__getprotobynumber_r
73 #define	getprotoent_r		__getprotoent_r
74 #define	getservbyname_r		__getservbyname_r
75 #define	getservbyport_r		__getservbyport_r
76 #define	getservent_r		__getservent_r
77 #define	setprotoent_r		__setprotoent_r
78 #define	setservent_r		__setservent_r
79 
80 struct protodata *__protodata_init(void);
81 struct servdata *__servdata_init(void);
82 void _endhostdnsent(void);
83 void _endhosthtent(void);
84 void _endnetdnsent(void);
85 void _endnethtent(void);
86 struct hostent *_gethostbynisaddr(const char *, int, int);
87 struct hostent *_gethostbynisname(const char *, int);
88 void _map_v4v6_address(const char *, char *);
89 void _map_v4v6_hostent(struct hostent *, char **, char **);
90 void _sethostdnsent(int);
91 void _sethosthtent(int);
92 void _setnetdnsent(int);
93 void _setnethtent(int);
94 void endprotoent_r(struct protoent_data *);
95 void endservent_r(struct servent_data *);
96 int getprotobyname_r(const char *, struct protoent *, struct protoent_data *);
97 int getprotobynumber_r(int, struct protoent *, struct protoent_data *);
98 int getprotoent_r(struct protoent *, struct protoent_data *);
99 int getservbyname_r(const char *, const char *, struct servent *,
100 	struct servent_data *);
101 int getservbyport_r(int, const char *, struct servent *,
102 	struct servent_data *);
103 int getservent_r(struct servent *, struct servent_data *);
104 void setprotoent_r(int, struct protoent_data *);
105 void setservent_r(int, struct servent_data *);
106 
107 #endif /* _NETDB_PRIVATE_H_ */
108