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