Blob


1 #include <u.h>
2 #include <libc.h>
4 /*
5 * /adm/users is
6 * id:user/group:head member:other members
7 *
8 * /etc/{passwd,group}
9 * name:x:nn:other stuff
10 */
12 static int isnumber(char *s);
14 sniff(Biobuf *b)
15 {
16 read first line of file into p;
18 nf = getfields(p, f, nelem(f), ":");
19 if(nf < 4)
20 return nil;
22 if(isnumber(f[0]) && !isnumber(f[2]))
23 return _plan9;
25 if(!isnumber(f[0]) && isnumber(f[2]))
26 return _unix;
28 return nil;
29 }
32 int
33 isnumber(char *s)
34 {
35 char *q;
37 strtol(s, &q, 10);
38 return *q == '\0';
39 }
41 /* EOF */