mirror of
https://github.com/xcat2/xNBA.git
synced 2024-12-14 23:31:39 +00:00
First version
This commit is contained in:
parent
e4131ebb84
commit
65dc273d78
25
src/core/resolv.c
Normal file
25
src/core/resolv.c
Normal file
@ -0,0 +1,25 @@
|
||||
#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 ) )
|
||||
return 1;
|
||||
|
||||
/* Try any compiled-in name resolution modules */
|
||||
for ( resolver = resolvers ; resolver < resolvers_end ; resolver++ ) {
|
||||
if ( resolver->resolv ( address, name ) )
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
15
src/include/resolv.h
Normal file
15
src/include/resolv.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef RESOLV_H
|
||||
#define RESOLV_H
|
||||
|
||||
#include "in.h"
|
||||
#include "tables.h"
|
||||
|
||||
struct resolver {
|
||||
int ( * resolv ) ( struct in_addr *address, const char *name );
|
||||
};
|
||||
|
||||
#define __resolver __table(resolver,01)
|
||||
|
||||
extern int resolv ( struct in_addr *address, const char *name );
|
||||
|
||||
#endif /* RESOLV_H */
|
Loading…
Reference in New Issue
Block a user