2005-02-11 19:41:16 +00:00
|
|
|
#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;
|
2005-07-19 18:00:07 +00:00
|
|
|
if(isdigit((uchar)c))
|
2005-02-11 19:41:16 +00:00
|
|
|
continue;
|
2005-07-19 18:00:07 +00:00
|
|
|
if(isxdigit((uchar)c))
|
2005-02-11 19:41:16 +00:00
|
|
|
hex = 1;
|
2005-07-19 18:00:07 +00:00
|
|
|
else if(isalpha((uchar)c) || c == '-')
|
2005-02-11 19:41:16 +00:00
|
|
|
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";
|
|
|
|
}
|