blob: a63484249dafe70702b1641d10dff2a421e48f60 [file] [log] [blame]
wkj7285a492004-06-17 01:47:21 +00001#include <u.h>
2#include <libc.h>
3
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 */
11
12static int isnumber(char *s);
13
14sniff(Biobuf *b)
15{
16 read first line of file into p;
17
18 nf = getfields(p, f, nelem(f), ":");
19 if(nf < 4)
20 return nil;
21
22 if(isnumber(f[0]) && !isnumber(f[2]))
23 return _plan9;
24
25 if(!isnumber(f[0]) && isnumber(f[2]))
26 return _unix;
27
28 return nil;
29}
30
31
32int
33isnumber(char *s)
34{
35 char *q;
36
37 strtol(s, &q, 10);
38 return *q == '\0';
39}
40
41/* EOF */