only define _REENTRANT if not already defined, and only in setup.h
[platform/upstream/curl.git] / lib / hostsyn.c
1 /***************************************************************************
2  *                                  _   _ ____  _
3  *  Project                     ___| | | |  _ \| |
4  *                             / __| | | | |_) | |
5  *                            | (__| |_| |  _ <| |___
6  *                             \___|\___/|_| \_\_____|
7  *
8  * Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
9  *
10  * This software is licensed as described in the file COPYING, which
11  * you should have received as part of this distribution. The terms
12  * are also available at http://curl.haxx.se/docs/copyright.html.
13  *
14  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15  * copies of the Software, and permit persons to whom the Software is
16  * furnished to do so, under the terms of the COPYING file.
17  *
18  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19  * KIND, either express or implied.
20  *
21  * $Id$
22  ***************************************************************************/
23
24 #include "setup.h"
25
26 #include <string.h>
27 #include <errno.h>
28
29 #if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__)
30 #include <malloc.h>
31 #else
32 #ifdef HAVE_SYS_TYPES_H
33 #include <sys/types.h>
34 #endif
35 #ifdef HAVE_SYS_SOCKET_H
36 #include <sys/socket.h>
37 #endif
38 #ifdef HAVE_NETINET_IN_H
39 #include <netinet/in.h>
40 #endif
41 #ifdef HAVE_NETDB_H
42 #include <netdb.h>
43 #endif
44 #ifdef HAVE_ARPA_INET_H
45 #include <arpa/inet.h>
46 #endif
47 #ifdef HAVE_STDLIB_H
48 #include <stdlib.h>     /* required for free() prototypes */
49 #endif
50 #ifdef HAVE_UNISTD_H
51 #include <unistd.h>     /* for the close() proto */
52 #endif
53 #ifdef  VMS
54 #include <in.h>
55 #include <inet.h>
56 #include <stdlib.h>
57 #endif
58 #endif
59
60 #ifdef HAVE_SETJMP_H
61 #include <setjmp.h>
62 #endif
63
64 #ifdef WIN32
65 #include <process.h>
66 #endif
67
68 #include "urldata.h"
69 #include "sendf.h"
70 #include "hostip.h"
71 #include "hash.h"
72 #include "share.h"
73 #include "strerror.h"
74 #include "url.h"
75
76 #define _MPRINTF_REPLACE /* use our functions only */
77 #include <curl/mprintf.h>
78
79 #if defined(HAVE_INET_NTOA_R) && !defined(HAVE_INET_NTOA_R_DECL)
80 #include "inet_ntoa_r.h"
81 #endif
82
83 #include "memory.h"
84 /* The last #include file should be: */
85 #include "memdebug.h"
86
87 /***********************************************************************
88  * Only for builds using synchronous name resolves
89  **********************************************************************/
90 #ifdef CURLRES_SYNCH
91
92 /*
93  * Curl_wait_for_resolv() for synch-builds.  Curl_resolv() can never return
94  * wait==TRUE, so this function will never be called. If it still gets called,
95  * we return failure at once.
96  *
97  * We provide this function only to allow multi.c to remain unaware if we are
98  * doing asynch resolves or not.
99  */
100 CURLcode Curl_wait_for_resolv(struct connectdata *conn,
101                               struct Curl_dns_entry **entry)
102 {
103   (void)conn;
104   *entry=NULL;
105   return CURLE_COULDNT_RESOLVE_HOST;
106 }
107
108 /*
109  * This function will never be called when synch-built. If it still gets
110  * called, we return failure at once.
111  *
112  * We provide this function only to allow multi.c to remain unaware if we are
113  * doing asynch resolves or not.
114  */
115 CURLcode Curl_is_resolved(struct connectdata *conn,
116                           struct Curl_dns_entry **dns)
117 {
118   (void)conn;
119   *dns = NULL;
120
121   return CURLE_COULDNT_RESOLVE_HOST;
122 }
123
124 /*
125  * We just return OK, this function is never actually used for synch builds.
126  * It is present here to keep #ifdefs out from multi.c
127  */
128
129 CURLcode Curl_resolv_fdset(struct connectdata *conn,
130                            fd_set *read_fd_set,
131                            fd_set *write_fd_set,
132                            int *max_fdp)
133 {
134   (void)conn;
135   (void)read_fd_set;
136   (void)write_fd_set;
137   (void)max_fdp;
138
139   return CURLE_OK;
140 }
141
142 #endif /* truly sync */