Subversion Repositories planix.SVN

Rev

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
wrbio(char *file, Acctbio *a)
9
{
10
	char buf[1024];
11
	int i, fd, n;
12
 
13
	fd = open(file, OWRITE);
14
	if(fd < 0)
15
		error("can't open %s", file);
16
	if(seek(fd, 0, 2) < 0)
17
		error("can't seek %s", file);
18
 
19
	if(a->postid == 0)
20
		a->postid = "";
21
	if(a->name == 0)
22
		a->name = "";
23
	if(a->dept == 0)
24
		a->dept = "";
25
	if(a->email[0] == 0)
26
		a->email[0] = strdup(a->user);
27
 
28
	n = 0;
29
	n += snprint(buf+n, sizeof(buf)-n, "%s|%s|%s|%s",
30
		a->user, a->postid, a->name, a->dept);
31
	for(i = 0; i < Nemail; i++){
32
		if(a->email[i] == 0)
33
			break;
34
		n += snprint(buf+n, sizeof(buf)-n, "|%s", a->email[i]);
35
	}
36
	n += snprint(buf+n, sizeof(buf)-n, "\n");
37
 
38
	write(fd, buf, n);
39
	close(fd);
40
}