Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/planix-v0/sys/src/cmd/auth/lib/rdbio.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <u.h>
2
#include <libc.h>
3
#include <bio.h>
4
#include <ctype.h>
5
#include "authcmdlib.h"
6
 
7
void
8
clrbio(Acctbio *a)
9
{
10
	int i;
11
 
12
	if(a->user)
13
		free(a->user);
14
	if(a->postid)
15
		free(a->postid);
16
	if(a->name)
17
		free(a->name);
18
	if(a->dept)
19
		free(a->dept);
20
	for(i = 0; i < Nemail; i++)
21
		if(a->email[i])
22
			free(a->email[i]);
23
	memset(a, 0, sizeof(Acctbio));
24
}
25
 
26
void
27
rdbio(char *file, char *user, Acctbio *a)
28
{
29
	int i,n;
30
	Biobuf *b;
31
	char *p;
32
	char *field[20];
33
 
34
	memset(a, 0, sizeof(Acctbio));
35
	b = Bopen(file, OREAD);
36
	if(b == 0)
37
		return;
38
	while(p = Brdline(b, '\n')){
39
		p[Blinelen(b)-1] = 0;
40
		n = getfields(p, field, nelem(field), 0, "|");
41
		if(n < 4)
42
			continue;
43
		if(strcmp(field[0], user) != 0)
44
			continue;
45
 
46
		clrbio(a);
47
 
48
		a->postid = strdup(field[1]);
49
		a->name = strdup(field[2]);
50
		a->dept = strdup(field[3]);
51
		if(n-4 >= Nemail)
52
			n = Nemail-4;
53
		for(i = 4; i < n; i++)
54
			a->email[i-4] = strdup(field[i]);
55
	}
56
	a->user = strdup(user);
57
	Bterm(b);
58
}