Plan 9 from Bell Labs’s /usr/web/sources/plan9/sys/src/cmd/auth/lib/wrbio.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include <u.h>
#include <libc.h>
#include <bio.h>
#include <ctype.h>
#include "authcmdlib.h"

void
wrbio(char *file, Acctbio *a)
{
	char buf[1024];
	int i, fd, n;

	fd = open(file, OWRITE);
	if(fd < 0)
		error("can't open %s", file);
	if(seek(fd, 0, 2) < 0)
		error("can't seek %s", file);

	if(a->postid == 0)
		a->postid = "";
	if(a->name == 0)
		a->name = "";
	if(a->dept == 0)
		a->dept = "";
	if(a->email[0] == 0)
		a->email[0] = strdup(a->user);

	n = 0;
	n += snprint(buf+n, sizeof(buf)-n, "%s|%s|%s|%s",
		a->user, a->postid, a->name, a->dept);
	for(i = 0; i < Nemail; i++){
		if(a->email[i] == 0)
			break;
		n += snprint(buf+n, sizeof(buf)-n, "|%s", a->email[i]);
	}
	n += snprint(buf+n, sizeof(buf)-n, "\n");

	write(fd, buf, n);
	close(fd);
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.