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