USG_PG3/usr/source/sccscommon/rwpfile.c

Compare this file to the similar file:
Show the results in this format:

# include "../sccshead/sfile.h"
# include "../sccshead/sint.h"
char rwpfl__[] "~|^`rwpfile.c:	3.4";
/*
	Reads and writes p-file, which is used to pass info from get to
	delta.  See call of stringf below for format of file.

	Users doing simultaneous gets with e args on the same SCCS file
	can interfere with one another.  However, the worst thing that
	can happen is that one of them will be inconvenienced when he
	executes delta, and the cost of avoiding this is too high.
*/

wrtpfile(f,r)
char f[];
int r;
{
	register int fd;
	register char *p;

	fd = xcreat(f,0444);
	p = stringf("%d   %s\n",r,getlnam());
	xwrite(fd,p,size(p)-1);
	close(fd);
}


char bpf[] "bad p-file (216)";

rdpfile(f,rp,un)
char f[], un[];
int *rp;
{
	register int fd, i;
	register char *p;
	char s[65], *name;

	fd = xopen(f,0);
	if ((i=read(fd,s,64))<=0)
		fatal(bpf);
	close(fd);
	p = s;
	p[i] = 0;
	for (; *p != ' '; p++)
		if (*p == 0)
			fatal(bpf);
	*p = 0;
	if ((*rp=patoi(s)) == -1)
		fatal(bpf);
	++p;
	while (*p++ == ' ') ;
	name = --p;
	for (; *p != '\n'; p++)
		if (*p == 0)
			fatal(bpf);
	*p = 0;
	if ((p-name)>SZLNAM)
		fatal(bpf);
	copy(name,un);
}


ckpfile(file)
register char *file;
{
	int r;
	char un[SZLNAM];

	if(exists(file)) {
		rdpfile(file,&r,un);
		fatal(stringf("being edited at release %d by `%s' (228)",
		  r,un));
	}
}