Michael Brown пре 19 година
родитељ
комит
65dc273d78
2 измењених фајлова са 40 додато и 0 уклоњено
  1. 25
    0
      src/core/resolv.c
  2. 15
    0
      src/include/resolv.h

+ 25
- 0
src/core/resolv.c Прегледај датотеку

@@ -0,0 +1,25 @@
1
+#include "resolv.h"
2
+
3
+static struct resolver resolvers[0] __table_start(resolver);
4
+static struct resolver resolvers_end[0] __table_end(resolver);
5
+
6
+/*
7
+ * Resolve a name (which may be just a dotted quad IP address) to an
8
+ * IP address.
9
+ *
10
+ */
11
+int resolv ( struct in_addr *address, const char *name ) {
12
+	struct resolver *resolver;
13
+
14
+	/* Check for a dotted quad IP address first */
15
+	if ( inet_aton ( name, address ) )
16
+		return 1;
17
+
18
+	/* Try any compiled-in name resolution modules */
19
+	for ( resolver = resolvers ; resolver < resolvers_end ; resolver++ ) {
20
+		if ( resolver->resolv ( address, name ) )
21
+			return 1;
22
+	}
23
+
24
+	return 0;
25
+}

+ 15
- 0
src/include/resolv.h Прегледај датотеку

@@ -0,0 +1,15 @@
1
+#ifndef RESOLV_H
2
+#define RESOLV_H
3
+
4
+#include "in.h"
5
+#include "tables.h"
6
+
7
+struct resolver {
8
+	int ( * resolv ) ( struct in_addr *address, const char *name );
9
+};
10
+
11
+#define __resolver __table(resolver,01)
12
+
13
+extern int resolv ( struct in_addr *address, const char *name );
14
+
15
+#endif /* RESOLV_H */

Loading…
Откажи
Сачувај