1
0
Files
irix-657m-src/eoe/cmd/sccs/lib/comobj/sinit.c
2022-09-29 17:59:04 +03:00

55 lines
1.4 KiB
C

/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */
/* UNIX System Laboratories, Inc. */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
/* #ident "@(#)sccs:lib/comobj/sinit.c 6.5" */
#ident "$Revision: 1.6 $"
# include "../../hdr/defines.h"
/*
Does initialization for sccs files and packet.
*/
void
sinit(pkt,file,openflag)
register struct packet *pkt;
register char *file;
{
extern char *satoi();
register char *p;
FILE *fdfopen();
char *getline();
unsigned strlen();
int fatal(), imatch(), xopen(), fstat64();
void fmterr();
zero((char *)pkt, sizeof(*pkt));
if (size(file) > FILESIZE)
fatal("too long (co7)");
if (!sccsfile(file))
fatal("not an SCCS file (co1)");
copy(file,pkt->p_file);
pkt->p_wrttn = 1;
pkt->do_chksum = 1; /* turn on checksum check for getline */
if (openflag) {
pkt->p_iop = xfopen(file,0);
setbuf(pkt->p_iop,pkt->p_buf);
fstat64((int)fileno(pkt->p_iop),&Statbuf);
if (Statbuf.st_nlink > 1)
fatal("more than one link (co3)");
if ((p = getline(pkt)) == NULL || *p++ != CTLCHAR || *p++ != HEAD) {
(void) fclose(pkt->p_iop);
fmterr(pkt);
}
p = satoi(p,&pkt->p_ihash);
if (*p != '\n')
fmterr(pkt);
}
pkt->p_chash = 0;
}