]> git.lizzy.rs Git - plan9front.git/blob - sys/src/ape/lib/bsd/_sock_ipattr.c
audiohda: fix syntax error
[plan9front.git] / sys / src / ape / lib / bsd / _sock_ipattr.c
1 /* posix */
2 #include <sys/types.h>
3 #include <unistd.h>
4 #include <ctype.h>
5
6 /* bsd extensions */
7 #include <sys/uio.h>
8 #include <sys/socket.h>
9 #include <netinet/in.h>
10
11 #include "priv.h"
12
13 /*
14  *  return ndb attribute type of an ip name
15  */
16 int
17 _sock_ipattr(char *name)
18 {
19         char *p;
20         int dot = 0;
21         int alpha = 0;
22
23         for(p = name; *p; p++){
24                 if(isdigit(*p))
25                         ;
26                 else if(isalpha(*p) || *p == '-')
27                         alpha = 1;
28                 else if(*p == '.')
29                         dot = 1;
30                 else if(*p == ':')
31                         return Tip;
32                 else
33                         return Tsys;
34         }
35
36         if(alpha){
37                 if(dot)
38                         return Tdom;
39                 else
40                         return Tsys;
41         }
42
43         if(dot)
44                 return Tip;
45         else
46                 return Tsys;
47 }