/[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 129 by siliconforks, Mon Jun 2 23:15:29 2008 UTC
# Line 34  Line 34 
34    }    }
35    *a = *((struct in_addr *) p->h_addr);    *a = *((struct in_addr *) p->h_addr);
36    return 0;    return 0;
37  #else  #elif HAVE_GETADDRINFO
38      struct addrinfo hints;
39      hints.ai_flags = 0;
40      hints.ai_family = PF_INET;
41      hints.ai_socktype = 0;
42      hints.ai_protocol = 0;
43      hints.ai_addrlen = 0;
44      hints.ai_addr = NULL;
45      hints.ai_canonname = NULL;
46      hints.ai_next = NULL;
47      struct addrinfo * p;
48      int result = getaddrinfo(host, NULL, &hints, &p);
49      if (result != 0 || p == NULL) {
50        return -1;
51      }
52      if (p->ai_family != PF_INET) {
53        freeaddrinfo(p);
54        return -1;
55      }
56      struct sockaddr_in * address_and_port = (struct sockaddr_in *) p->ai_addr;
57      *a = address_and_port->sin_addr;
58      freeaddrinfo(p);
59      return 0;
60    #elif HAVE_GETHOSTBYNAME_R
61    struct hostent h;    struct hostent h;
62    struct hostent * p;    struct hostent * p;
63    char * buffer;    char * buffer;
# Line 55  Line 78 
78    *a = *((struct in_addr *) p->h_addr);    *a = *((struct in_addr *) p->h_addr);
79    free(buffer);    free(buffer);
80    return 0;    return 0;
81    #else
82    #error "No thread-safe host lookup available"
83  #endif  #endif
84  }  }
85    

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

  ViewVC Help
Powered by ViewVC 1.1.24