mirror of
https://github.com/xcat2/xNBA.git
synced 2025-01-05 19:15:05 +00:00
88e38fa148
defined in vsprintf.h. (This may change, since vsprintf.h is a non-standard name, but for now it's the one to use.) There should be no need to include vsprintf.h just for DBG() statements, since include/compiler.h forces it in for a debug build anyway.
32 lines
835 B
C
32 lines
835 B
C
#include "resolv.h"
|
|
|
|
static struct resolver resolvers[0] __table_start(resolver);
|
|
static struct resolver resolvers_end[0] __table_end(resolver);
|
|
|
|
/*
|
|
* Resolve a name (which may be just a dotted quad IP address) to an
|
|
* IP address.
|
|
*
|
|
*/
|
|
int resolv ( struct in_addr *address, const char *name ) {
|
|
struct resolver *resolver;
|
|
|
|
/* Check for a dotted quad IP address first */
|
|
if ( inet_aton ( name, address ) ) {
|
|
DBG ( "RESOLV saw valid IP address %s\n", name );
|
|
return 1;
|
|
}
|
|
|
|
/* Try any compiled-in name resolution modules */
|
|
for ( resolver = resolvers ; resolver < resolvers_end ; resolver++ ) {
|
|
if ( resolver->resolv ( address, name ) ) {
|
|
DBG ( "RESOLV resolved \"%s\" to %@ using %s\n",
|
|
name, address->s_addr, resolver->name );
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
DBG ( "RESOLV failed to resolve %s\n", name );
|
|
return 0;
|
|
}
|