Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

utils.c File Reference

#include <ctype.h>
#include <string.h>
#include <asterisk/lock.h>
#include <asterisk/utils.h>

Include dependency graph for utils.c:

Include dependency graph

Go to the source code of this file.

Functions

hostent * ast_gethostbyname (const char *host, struct ast_hostent *hp)


Function Documentation

struct hostent* ast_gethostbyname const char *  host,
struct ast_hostent hp
 

Definition at line 122 of file utils.c.

References ast_hostent::buf, ast_hostent::hp, and s.

Referenced by ast_get_ip().

00123 { 00124 int res; 00125 int herrno; 00126 const char *s; 00127 struct hostent *result = NULL; 00128 /* Although it is perfectly legitimate to lookup a pure integer, for 00129 the sake of the sanity of people who like to name their peers as 00130 integers, we break with tradition and refuse to look up a 00131 pure integer */ 00132 s = host; 00133 while(s && *s) { 00134 if (!isdigit(*s)) 00135 break; 00136 s++; 00137 } 00138 if (!s || !*s) 00139 return NULL; 00140 res = gethostbyname_r(host, &hp->hp, hp->buf, sizeof(hp->buf), &result, &herrno); 00141 00142 if (res || !result || !hp->hp.h_addr_list || !hp->hp.h_addr_list[0]) 00143 return NULL; 00144 return &hp->hp; 00145 }


Generated on Sat Jun 12 16:41:49 2004 for Asterisk by doxygen 1.3.7