include <malloc.h> only if HAVE_MALLOC_H and NEED_MALLOC_H are both defined.
[platform/upstream/curl.git] / lib / hostsyn.c
1 /***************************************************************************
2  *                                  _   _ ____  _
3  *  Project                     ___| | | |  _ \| |
4  *                             / __| | | | |_) | |
5  *                            | (__| |_| |  _ <| |___
6  *                             \___|\___/|_| \_\_____|
7  *
8  * Copyright (C) 1998 - 2006, 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
28 #if defined(HAVE_MALLOC_H) && defined(NEED_MALLOC_H)
29 #include <malloc.h>
30 #endif
31 #ifdef HAVE_SYS_TYPES_H
32 #include <sys/types.h>
33 #endif
34 #ifdef HAVE_SYS_SOCKET_H
35 #include <sys/socket.h>
36 #endif
37 #ifdef HAVE_NETINET_IN_H
38 #include <netinet/in.h>
39 #endif
40 #ifdef HAVE_NETDB_H
41 #include <netdb.h>
42 #endif
43 #ifdef HAVE_ARPA_INET_H
44 #include <arpa/inet.h>
45 #endif
46 #ifdef HAVE_STDLIB_H
47 #include <stdlib.h>     /* required for free() prototypes */
48 #endif
49 #ifdef HAVE_UNISTD_H
50 #include <unistd.h>     /* for the close() proto */
51 #endif
52 #ifdef  VMS
53 #include <in.h>
54 #include <inet.h>
55 #include <stdlib.h>
56 #endif
57
58 #ifdef HAVE_SETJMP_H
59 #include <setjmp.h>
60 #endif
61
62 #ifdef HAVE_PROCESS_H
63 #include <process.h>
64 #endif
65
66 #include "urldata.h"
67 #include "sendf.h"
68 #include "hostip.h"
69 #include "hash.h"
70 #include "share.h"
71 #include "strerror.h"
72 #include "url.h"
73
74 #define _MPRINTF_REPLACE /* use our functions only */
75 #include <curl/mprintf.h>
76
77 #if defined(HAVE_INET_NTOA_R) && !defined(HAVE_INET_NTOA_R_DECL)
78 #include "inet_ntoa_r.h"
79 #endif
80
81 #include "memory.h"
82 /* The last #include file should be: */
83 #include "memdebug.h"
84
85 /***********************************************************************
86  * Only for builds using synchronous name resolves
87  **********************************************************************/
88 #ifdef CURLRES_SYNCH
89
90 /*
91  * Curl_wait_for_resolv() for synch-builds.  Curl_resolv() can never return
92  * wait==TRUE, so this function will never be called. If it still gets called,
93  * we return failure at once.
94  *
95  * We provide this function only to allow multi.c to remain unaware if we are
96  * doing asynch resolves or not.
97  */
98 CURLcode Curl_wait_for_resolv(struct connectdata *conn,
99                               struct Curl_dns_entry **entry)
100 {
101   (void)conn;
102   *entry=NULL;
103   return CURLE_COULDNT_RESOLVE_HOST;
104 }
105
106 /*
107  * This function will never be called when synch-built. If it still gets
108  * called, we return failure at once.
109  *
110  * We provide this function only to allow multi.c to remain unaware if we are
111  * doing asynch resolves or not.
112  */
113 CURLcode Curl_is_resolved(struct connectdata *conn,
114                           struct Curl_dns_entry **dns)
115 {
116   (void)conn;
117   *dns = NULL;
118
119   return CURLE_COULDNT_RESOLVE_HOST;
120 }
121
122 /*
123  * We just return OK, this function is never actually used for synch builds.
124  * It is present here to keep #ifdefs out from multi.c
125  */
126
127 int Curl_resolv_getsock(struct connectdata *conn,
128                         curl_socket_t *sock,
129                         int numsocks)
130 {
131   (void)conn;
132   (void)sock;
133   (void)numsocks;
134
135   return 0; /* no bits since we don't use any socks */
136 }
137
138 #endif /* truly sync */