blob: d23d5ee09e5048016ad664cb4abbcce2665197d5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#include <u.h>
#include <ctype.h>
/*
* return ndb attribute type of an ip name
*/
char*
ipattr(char *name)
{
char *p, c;
int dot = 0;
int alpha = 0;
int colon = 0;
int hex = 0;
for(p = name; *p; p++){
c = *p;
if(isdigit(c))
continue;
if(isxdigit(c))
hex = 1;
else if(isalpha(c) || c == '-')
alpha = 1;
else if(c == '.')
dot = 1;
else if(c == ':')
colon = 1;
else
return "sys";
}
if(alpha){
if(dot)
return "dom";
else
return "sys";
}
if(colon)
return "ip"; /* ip v6 */
if(dot && !hex)
return "ip";
else
return "sys";
}
|