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