09e650e0af5bfd6c248e4916e0577d932aeeb4c6
[tinc] / lib / dropin.h
1 /*
2     dropin.h -- header file for dropin.c
3     Copyright (C) 2000,2001 Ivo Timmermans <itimmermans@bigfoot.com>,
4                   2000,2001 Guus Sliepen <guus@sliepen.warande.net>
5
6     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with this program; if not, write to the Free Software
18     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
20     $Id: dropin.h,v 1.1.2.5 2001/11/16 17:37:08 zarq Exp $
21 */
22
23 #ifndef __DROPIN_H__
24 #define __DROPIN_H__
25
26 #ifndef HAVE_DAEMON
27 extern int daemon(int, int);
28 #endif
29
30 #ifndef HAVE_GET_CURRENT_DIR_NAME
31 extern char* get_current_dir_name(void);
32 #endif
33
34 #ifndef HAVE_ASPRINTF
35 extern int asprintf(char **, const char *, ...);
36 #endif
37
38 #ifndef HAVE_STRUCT_ADDRINFO
39 struct addrinfo {
40         int     ai_flags;       /* AI_PASSIVE, AI_CANONNAME */
41         int     ai_family;      /* PF_xxx */
42         int     ai_socktype;    /* SOCK_xxx */
43         int     ai_protocol;    /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
44         size_t  ai_addrlen;     /* length of ai_addr */
45         char    *ai_canonname;  /* canonical name for hostname */
46         struct sockaddr *ai_addr;       /* binary address */
47         struct addrinfo *ai_next;       /* next structure in linked list */
48 };
49 #endif /* !HAVE_STRUCT_ADDRINFO */
50
51 #ifndef HAVE_GETADDRINFO
52 int getaddrinfo(const char *hostname, const char *servname, 
53                 const struct addrinfo *hints, struct addrinfo **res);
54 #endif /* !HAVE_GETADDRINFO */
55
56 #ifndef HAVE_GAI_STRERROR
57 char *gai_strerror(int ecode);
58 #endif /* !HAVE_GAI_STRERROR */
59
60 #ifndef HAVE_FREEADDRINFO
61 void freeaddrinfo(struct addrinfo *ai);
62 #endif /* !HAVE_FREEADDRINFO */
63
64 #ifndef HAVE_GETNAMEINFO
65 int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, 
66                 size_t hostlen, char *serv, size_t servlen, int flags);
67 #endif /* !HAVE_GETNAMEINFO */
68
69 #ifndef NI_MAXSERV
70 # define NI_MAXSERV 32
71 #endif /* !NI_MAXSERV */
72 #ifndef NI_MAXHOST
73 # define NI_MAXHOST 1025
74 #endif /* !NI_MAXHOST */
75
76 #ifndef AI_PASSIVE
77 # define AI_PASSIVE        1
78 # define AI_CANONNAME      2
79 #endif
80
81 #ifndef NI_NUMERICHOST
82 # define NI_NUMERICHOST    2
83 # define NI_NAMEREQD       4
84 # define NI_NUMERICSERV    8
85 #endif
86
87 #endif /* __DROPIN_H__ */