29 |
|
#include <unistd.h> |
30 |
|
#include <stdlib.h> |
31 |
|
#include <ukcprog.h> |
32 |
+ |
#include <netdb.h> |
33 |
|
|
34 |
|
#include <libxml/xmlmemory.h> |
35 |
|
#include <libxml/parser.h> |
236 |
|
} |
237 |
|
} |
238 |
|
*/ |
239 |
+ |
|
240 |
+ |
#ifndef HAVE_ATOLL |
241 |
+ |
long long int atoll (const char *nptr){ |
242 |
+ |
return strtoll (nptr, (char **) NULL, 10); |
243 |
+ |
} |
244 |
+ |
#endif |
245 |
+ |
|
246 |
+ |
#ifndef HAVE_STRLCPY |
247 |
+ |
/* |
248 |
+ |
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> |
249 |
+ |
* All rights reserved. |
250 |
+ |
* |
251 |
+ |
* Redistribution and use in source and binary forms, with or without |
252 |
+ |
* modification, are permitted provided that the following conditions |
253 |
+ |
* are met: |
254 |
+ |
* 1. Redistributions of source code must retain the above copyright |
255 |
+ |
* notice, this list of conditions and the following disclaimer. |
256 |
+ |
* 2. Redistributions in binary form must reproduce the above copyright |
257 |
+ |
* notice, this list of conditions and the following disclaimer in the |
258 |
+ |
* documentation and/or other materials provided with the distribution. |
259 |
+ |
* 3. The name of the author may not be used to endorse or promote products |
260 |
+ |
* derived from this software without specific prior written permission. |
261 |
+ |
* |
262 |
+ |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, |
263 |
+ |
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
264 |
+ |
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
265 |
+ |
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
266 |
+ |
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
267 |
+ |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
268 |
+ |
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
269 |
+ |
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
270 |
+ |
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
271 |
+ |
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
272 |
+ |
*/ |
273 |
+ |
|
274 |
+ |
/* |
275 |
+ |
* Copy src to string dst of size siz. At most siz-1 characters |
276 |
+ |
* will be copied. Always NUL terminates (unless siz == 0). |
277 |
+ |
* Returns strlen(src); if retval >= siz, truncation occurred. |
278 |
+ |
*/ |
279 |
+ |
size_t |
280 |
+ |
strlcpy(dst, src, siz) |
281 |
+ |
char *dst; |
282 |
+ |
const char *src; |
283 |
+ |
size_t siz; |
284 |
+ |
{ |
285 |
+ |
register char *d = dst; |
286 |
+ |
register const char *s = src; |
287 |
+ |
register size_t n = siz; |
288 |
+ |
|
289 |
+ |
/* Copy as many bytes as will fit */ |
290 |
+ |
if (n != 0 && --n != 0) { |
291 |
+ |
do { |
292 |
+ |
if ((*d++ = *s++) == 0) |
293 |
+ |
break; |
294 |
+ |
} while (--n != 0); |
295 |
+ |
} |
296 |
+ |
|
297 |
+ |
/* Not enough room in dst, add NUL and traverse rest of src */ |
298 |
+ |
if (n == 0) { |
299 |
+ |
if (siz != 0) |
300 |
+ |
*d = '\0'; /* NUL-terminate dst */ |
301 |
+ |
while (*s++) |
302 |
+ |
; |
303 |
+ |
} |
304 |
+ |
|
305 |
+ |
return(s - src - 1); /* count does not include NUL */ |
306 |
+ |
} |
307 |
+ |
|
308 |
+ |
#endif |
309 |
+ |
|
310 |
|
|
311 |
|
FILE *create_tcp_connection(char *hostname, int port){ |
312 |
|
int sock; |