comparison src/dns.c @ 0:d39e1d0d75b6

initial add
author paulo@hit-nxdomain.opendns.com
date Sat, 20 Feb 2010 21:18:28 -0800
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4157424d6cda
1 /*
2 * $Id: dns.c,v 1.2 2003/12/26 12:02:20 mkern Exp $
3 *
4 * Copyright (C) 2003 giFT project (gift.sourceforge.net)
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 */
16
17 #include "gt_gnutella.h"
18 #include "dns.h"
19
20 /*****************************************************************************/
21
22 struct hostent *gt_dns_lookup (const char *name)
23 {
24 return gethostbyname (name);
25 }
26
27 int gt_dns_get_errno (void)
28 {
29 #ifdef HAVE_HSTRERROR /* assume h_errno present if hstrerror() is */
30 return h_errno;
31 #else
32 #ifdef WIN32
33 return WSAGetLastError ();
34 #endif /* WIN32 */
35 return 0;
36 #endif
37 }
38
39 void gt_dns_set_errno (int error_code)
40 {
41 #ifdef HAVE_HSTRERROR
42 h_errno = 0;
43 #else
44 #ifdef WIN32
45 WSASetLastError (error_code);
46 #endif /* WIN32 */
47 #endif
48 }
49
50 const char *gt_dns_strerror (int error_code)
51 {
52 #ifdef HAVE_HSTRERROR
53 return hstrerror (error_code);
54 #else
55 return "Host name lookup failure";
56 #endif
57 }