Fix FSF address (Tobias Mueller, #470445)
[platform/upstream/evolution-data-server.git] / camel / camel-net-utils.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2  * 
3  * Authors: Michael Zucchi <notzed@ximian.com>
4  *          Jeffrey Stedfast <fejj@ximian.com>
5  *
6  * Copyright (C) 2004 Ximian, Inc.
7  *
8  * This program is free software; you can redistribute it and/or 
9  * modify it under the terms of version 2 of the GNU Lesser General Public 
10  * License as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
20  * USA
21  */
22
23 #ifndef CAMEL_NET_UTILS_H
24 #define CAMEL_NET_UTILS_H 1
25
26 #include <sys/types.h>
27
28 #ifndef _WIN32
29 #include <sys/socket.h>
30 #include <netdb.h>
31 #else
32 #include <winsock2.h>
33 #include <ws2tcpip.h>
34 #endif
35
36 G_BEGIN_DECLS
37
38 struct _CamelException;
39
40 #ifndef _WIN32
41 #ifdef NEED_ADDRINFO
42 /* Some of this is copied from GNU's netdb.h
43
44   Copyright (C) 1996-2002, 2003, 2004 Free Software Foundation, Inc.
45   This file is part of the GNU C Library.
46
47    The GNU C Library is free software; you can redistribute it and/or
48    modify it under the terms of the GNU Lesser General Public
49    License as published by the Free Software Foundation; either
50    version 2.1 of the License, or (at your option) any later version.
51 */
52 struct addrinfo {
53         int ai_flags;
54         int ai_family;
55         int ai_socktype;
56         int ai_protocol;
57         size_t ai_addrlen;
58         struct sockaddr *ai_addr;
59         char *ai_canonname;
60         struct addrinfo *ai_next;
61 };
62
63 #define AI_CANONNAME    0x0002  /* Request for canonical name.  */
64 #define AI_NUMERICHOST  0x0004  /* Don't use name resolution.  */
65
66 /* Error values for `getaddrinfo' function.  */
67 #define EAI_BADFLAGS      -1    /* Invalid value for `ai_flags' field.  */
68 #define EAI_NONAME        -2    /* NAME or SERVICE is unknown.  */
69 #define EAI_AGAIN         -3    /* Temporary failure in name resolution.  */
70 #define EAI_FAIL          -4    /* Non-recoverable failure in name res.  */
71 #define EAI_NODATA        -5    /* No address associated with NAME.  */
72 #define EAI_FAMILY        -6    /* `ai_family' not supported.  */
73 #define EAI_SOCKTYPE      -7    /* `ai_socktype' not supported.  */
74 #define EAI_SERVICE       -8    /* SERVICE not supported for `ai_socktype'.  */
75 #define EAI_ADDRFAMILY    -9    /* Address family for NAME not supported.  */
76 #define EAI_MEMORY        -10   /* Memory allocation failure.  */
77 #define EAI_SYSTEM        -11   /* System error returned in `errno'.  */
78 #define EAI_OVERFLOW      -12   /* Argument buffer overflow.  */
79
80 #define NI_MAXHOST      1025
81 #define NI_MAXSERV      32
82
83 #define NI_NUMERICHOST  1       /* Don't try to look up hostname.  */
84 #define NI_NUMERICSERV  2       /* Don't convert port number to name.  */
85 #define NI_NOFQDN       4       /* Only return nodename portion.  */
86 #define NI_NAMEREQD     8       /* Don't return numeric addresses.  */
87 #define NI_DGRAM        16      /* Look up UDP service rather than TCP.  */
88 #endif
89 #endif
90
91 struct addrinfo *camel_getaddrinfo(const char *name, const char *service,
92                                    const struct addrinfo *hints, struct _CamelException *ex);
93 void camel_freeaddrinfo(struct addrinfo *host);
94 int camel_getnameinfo(const struct sockaddr *sa, socklen_t salen, char **host, char **serv,
95                       int flags, struct _CamelException *ex);
96
97 G_END_DECLS
98
99 #endif /* CAMEL_NET_UTILS_H */