1*19927Ssam # include	"../hdr/defines.h"
2*19927Ssam 
3*19927Ssam SCCSID(@(#)sinit	2.1);
4*19927Ssam /*
5*19927Ssam 	Does initialization for sccs files and packet.
6*19927Ssam */
7*19927Ssam 
8*19927Ssam sinit(pkt,file,openflag)
9*19927Ssam register struct packet *pkt;
10*19927Ssam register char *file;
11*19927Ssam {
12*19927Ssam 	extern	char	*satoi();
13*19927Ssam 	register char *p;
14*19927Ssam 
15*19927Ssam 	zero(pkt,sizeof(*pkt));
16*19927Ssam 	if (size(file) > FILESIZE)
17*19927Ssam 		fatal("too long (co7)");
18*19927Ssam 	if (!sccsfile(file))
19*19927Ssam 		fatal("not an SCCS file (co1)");
20*19927Ssam 	copy(file,pkt->p_file);
21*19927Ssam 	pkt->p_wrttn = 1;
22*19927Ssam 	pkt->do_chksum = 1;	/* turn on checksum check for getline */
23*19927Ssam 	if (openflag) {
24*19927Ssam 		pkt->p_iop = xfopen(file,0);
25*19927Ssam 		setbuf(pkt->p_iop,pkt->p_buf);
26*19927Ssam 		fstat(fileno(pkt->p_iop),&Statbuf);
27*19927Ssam 		if (Statbuf.st_nlink > 1)
28*19927Ssam 			fatal("more than one link (co3)");
29*19927Ssam 		if ((p = getline(pkt)) == NULL || *p++ != CTLCHAR || *p++ != HEAD) {
30*19927Ssam 			fclose(pkt->p_iop);
31*19927Ssam 			fmterr(pkt);
32*19927Ssam 		}
33*19927Ssam 		p = satoi(p,&pkt->p_ihash);
34*19927Ssam 		if (*p != '\n')
35*19927Ssam 			fmterr(pkt);
36*19927Ssam 	}
37*19927Ssam 	pkt->p_chash = 0;
38*19927Ssam }
39