/[jscoverage]/trunk/http-host.c
ViewVC logotype

Diff of /trunk/http-host.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 125 by siliconforks, Mon Jun 2 17:52:38 2008 UTC revision 303 by siliconforks, Mon Oct 13 05:27:41 2008 UTC
# Line 21  Line 21 
21    
22  #include "http-server.h"  #include "http-server.h"
23    
 #include <errno.h>  
   
24  #include "util.h"  #include "util.h"
25    
26  int xgethostbyname(const char * host, struct in_addr * a) {  int xgethostbyname(const char * host, struct in_addr * a) {
# Line 34  Line 32 
32    }    }
33    *a = *((struct in_addr *) p->h_addr);    *a = *((struct in_addr *) p->h_addr);
34    return 0;    return 0;
35  #else  #elif HAVE_GETADDRINFO
36      struct addrinfo hints;
37      hints.ai_flags = 0;
38      hints.ai_family = PF_INET;
39      hints.ai_socktype = 0;
40      hints.ai_protocol = 0;
41      hints.ai_addrlen = 0;
42      hints.ai_addr = NULL;
43      hints.ai_canonname = NULL;
44      hints.ai_next = NULL;
45      struct addrinfo * p;
46      int result = getaddrinfo(host, NULL, &hints, &p);
47      if (result != 0 || p == NULL) {
48        return -1;
49      }
50      if (p->ai_family != PF_INET) {
51        freeaddrinfo(p);
52        return -1;
53      }
54      struct sockaddr_in * address_and_port = (struct sockaddr_in *) p->ai_addr;
55      *a = address_and_port->sin_addr;
56      freeaddrinfo(p);
57      return 0;
58    #elif HAVE_GETHOSTBYNAME_R
59    struct hostent h;    struct hostent h;
60    struct hostent * p;    struct hostent * p;
61    char * buffer;    char * buffer;
# Line 55  Line 76 
76    *a = *((struct in_addr *) p->h_addr);    *a = *((struct in_addr *) p->h_addr);
77    free(buffer);    free(buffer);
78    return 0;    return 0;
79    #else
80    #error "No thread-safe host lookup available"
81  #endif  #endif
82  }  }
83    

Legend:
Removed from v.125  
changed lines
  Added in v.303

  ViewVC Help
Powered by ViewVC 1.1.24