aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/9660/uid.c
blob: a63484249dafe70702b1641d10dff2a421e48f60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <u.h>
#include <libc.h>

/*
 * /adm/users is
 *	id:user/group:head member:other members
 *
 * /etc/{passwd,group}
 *	name:x:nn:other stuff
 */

static int isnumber(char *s);

sniff(Biobuf *b)
{
	read first line of file into p;

	nf = getfields(p, f, nelem(f), ":");
	if(nf < 4)
		return nil;

	if(isnumber(f[0]) && !isnumber(f[2]))
		return _plan9;

	if(!isnumber(f[0]) && isnumber(f[2]))
		return _unix;

	return nil;
}


int
isnumber(char *s)
{
	char *q;

	strtol(s, &q, 10);
	return *q == '\0';
}

/* EOF */