URI:
       tipattr.c - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
       tipattr.c (607B)
       ---
            1 #include <u.h>
            2 #include <ctype.h>
            3 
            4 /*
            5  *  return ndb attribute type of an ip name
            6  */
            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;
           15 
           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                 else
           29                         return "sys";
           30         }
           31 
           32         if(alpha){
           33                 if(dot)
           34                         return "dom";
           35                 else
           36                         return "sys";
           37         }
           38 
           39         if(colon)
           40                 return "ip";        /* ip v6 */
           41 
           42         if(dot && !hex)
           43                 return "ip";
           44         else
           45                 return "sys";
           46 }