113715Ssam # include	<stdio.h>
213715Ssam # include	<sys/time.h>
33502Seric # include	"../hdr/macros.h"
43502Seric # include	"../hdr/fatal.h"
53502Seric 
63502Seric /*
73502Seric  *	defines.h 2.3 of 5/18/78
8*13740Ssam  *	defines.h 4.4 of 07/03/83
93502Seric  */
103502Seric 
113502Seric # define CTLSTR		"%c%c\n"
123502Seric 
133502Seric # define CTLCHAR	1
143502Seric # define HEAD		'h'
153502Seric 
163502Seric # define STATS		's'
173502Seric 
183502Seric # define BDELTAB	'd'
193502Seric # define INCLUDE	'i'
203502Seric # define EXCLUDE	'x'
213502Seric # define IGNORE		'g'
223502Seric # define MRNUM		'm'
233502Seric # define COMMENTS	'c'
243502Seric # define EDELTAB	'e'
253502Seric 
263502Seric # define BUSERNAM	'u'
273502Seric # define EUSERNAM	'U'
283502Seric 
293502Seric # define NFLAGS	26
303502Seric 
313502Seric # define FLAG		'f'
323502Seric # define NULLFLAG	'n'
333502Seric # define DEFTFLAG	'd'
343502Seric # define TYPEFLAG	't'
353502Seric # define VALFLAG	'v'
363502Seric # define BRCHFLAG	'b'
373502Seric # define IDFLAG		'i'
383502Seric # define MODFLAG	'm'
393502Seric # define FLORFLAG	'f'
403502Seric # define CEILFLAG	'c'
413502Seric 
423502Seric # define BUSERTXT	't'
433502Seric # define EUSERTXT	'T'
443502Seric 
453502Seric # define INS		'I'
463502Seric # define DEL		'D'
473502Seric # define END		'E'
483502Seric 
493502Seric # define FILESIZE	510
50*13740Ssam #ifdef MAX
51*13740Ssam #undef MAX
52*13740Ssam #endif
533502Seric # define MAX		9999
543502Seric # define DELIVER	'*'
553502Seric 
563502Seric /*
573502Seric 	Declares for external subroutines and/or functions
583502Seric */
593502Seric 
603502Seric extern	char	*sname();
613502Seric extern	char	*cat();
623502Seric extern	char	*dname();
633502Seric extern	char	*repeat();
643502Seric extern	char	*satoi();
653502Seric extern	char	*strend();
663502Seric extern	char	*substr();
673502Seric extern	char	*trnslat();
683502Seric extern	char	*zero();
693502Seric extern	char	*zeropad();
703502Seric 
713502Seric /*
723510Seric 	size of login name
733510Seric */
743510Seric # define SZLNAM	9	/* size of login name */
753510Seric # define LNLNAM	8	/* length of login name */
763510Seric 
773510Seric /*
783502Seric 	SCCS Internal Structures.
793502Seric */
803502Seric 
813502Seric struct apply {
823502Seric 	char	a_inline;	/* in the line of normally applied deltas */
833502Seric 	char	a_code;		/* APPLY, NOAPPLY or EMPTY */
843502Seric 	int	a_reason;
853502Seric };
863502Seric #define APPLY	  (1)
873502Seric #define NOAPPLY  (-1)
883502Seric #define EMPTY	  (0)
893502Seric 
903502Seric # define IGNR		0100
913502Seric # define USER		040
923502Seric # define INCL		1
933502Seric # define EXCL		2
943502Seric # define CUTOFF		4
953502Seric # define INCLUSER	(USER | INCL)
963502Seric # define EXCLUSER	(USER | EXCL)
973502Seric # define IGNRUSER	(USER | IGNR)
983502Seric 
993502Seric 
1003502Seric struct queue {
1013502Seric 	struct queue *q_next;
1023502Seric 	int    q_sernum;	/* serial number */
1033502Seric 	char    q_keep;		/* keep switch setting */
1043502Seric 	char	q_iord;		/* INS or DEL */
1053502Seric 	char	q_ixmsg;	/* caused inex msg */
1063502Seric 	char	q_user;		/* inex'ed by user */
1073502Seric };
1083502Seric #define YES	 (1)
1093502Seric #define NO	(-1)
1103502Seric 
1113502Seric 
1123502Seric struct	sid {
1133502Seric 	int	s_rel;
1143502Seric 	int	s_lev;
1153502Seric 	int	s_br;
1163502Seric 	int	s_seq;
1173502Seric };
1183502Seric 
1193502Seric 
1203502Seric struct	deltab {
1213502Seric 	struct	sid	d_sid;
1223502Seric 	int	d_serial;
1233502Seric 	int	d_pred;
1243502Seric 	long	d_datetime;
1253508Seric 	char	d_pgmr[SZLNAM];
1263502Seric 	char	d_type;
1273502Seric };
1283502Seric 
1293502Seric struct	ixg {
1303502Seric 	struct	ixg	*i_next;
1313502Seric 	char	i_type;
1323502Seric 	char	i_cnt;
1333502Seric 	int	i_ser[1];
1343502Seric };
1353502Seric 
1363502Seric 
1373502Seric struct	idel {
1383502Seric 	struct	sid	i_sid;
1393502Seric 	struct	ixg	*i_ixg;
1403502Seric 	int	i_pred;
1413502Seric 	long	i_datetime;
1423502Seric };
1433502Seric 
1443502Seric 
1453502Seric # define maxser(pkt)	((pkt)->p_idel->i_pred)
1463502Seric # define sccsfile(f)	imatch("s.", sname(f))
1473502Seric 
1483502Seric struct packet {
1493502Seric 	char	p_file[FILESIZE];	/* file name containing module */
1503502Seric 	struct	sid	p_reqsid;	/* requested SID, then new SID */
1513502Seric 	struct	sid	p_gotsid;	/* gotten SID */
1523502Seric 	struct	sid	p_inssid;	/* SID which inserted current line */
1533502Seric 	char	p_verbose;	/* verbose flags (see #define's below) */
1543502Seric 	char	p_upd;		/* update flag (!0 = update mode) */
1553502Seric 	long	p_cutoff;	/* specified cutoff date-time */
1563502Seric 	int	p_ihash;	/* initial (input) hash */
1573502Seric 	int	p_chash;	/* current (input) hash */
1583502Seric 	int	p_nhash;	/* new (output) hash */
1593502Seric 	int	p_glnno;	/* line number of current gfile line */
1603502Seric 	int	p_slnno;	/* line number of current input line */
1613502Seric 	char	p_wrttn;		/* written flag (!0 = written) */
1623502Seric 	char	p_keep;		/* keep switch for readmod() */
1633502Seric 	struct	apply	*p_apply;	/* ptr to apply array */
1643502Seric 	struct	queue	*p_q;	/* ptr to control queue */
1653502Seric 	FILE	*p_iop;		/* input file */
1663502Seric 	char	p_buf[BUFSIZ];	/* input file buffer */
1673502Seric 	char	p_line[BUFSIZ];	/* buffer for getline() */
1683502Seric 	long	p_cdt;		/* date/time of newest applied delta */
1693502Seric 	char	*p_lfile;	/* 0 = no l-file; else ptr to l arg */
1703502Seric 	struct	idel	*p_idel;	/* ptr to internal delta table */
1713502Seric 	FILE	*p_stdout;	/* standard output for warnings and messages */
1723502Seric 	FILE	*p_gout;	/* g-file output file */
1733502Seric 	char	p_user;		/* !0 = user on user list */
1743502Seric 	char	p_chkeof;	/* 0 = eof generates error */
1753502Seric 	int	p_maxr;		/* largest release number */
1763502Seric 	int	p_ixmsg;	/* inex msg counter */
1773502Seric 	int	p_reopen;	/* reopen flag used by getline on eof */
1783502Seric 	int	p_ixuser;	/* HADI | HADX (in get) */
1793502Seric 	int	do_chksum;	/* for getline(), 1 = do check sum */
1803502Seric };
1813502Seric /*
1823502Seric 	Masks for p_verbose
1833502Seric */
1843502Seric 
1853502Seric # define RLACCESS	(1)
1863502Seric # define NLINES		(2)
1873502Seric # define DOLIST		(4)
1883502Seric # define UNACK		(8)
1893502Seric # define NEWRL		(16)
1903502Seric # define WARNING	(32)
1913502Seric 
1923502Seric 
1933502Seric struct	stats {
1943502Seric 	int	s_ins;
1953502Seric 	int	s_del;
1963502Seric 	int	s_unc;
1973502Seric };
1983502Seric 
1993502Seric 
2003502Seric struct	pfile	{
2013502Seric 	struct	sid	pf_gsid;
2023502Seric 	struct	sid	pf_nsid;
2033508Seric 	char	pf_user[SZLNAM];
2043502Seric 	long	pf_date;
2053502Seric 	char	*pf_ilist;
2063502Seric 	char	*pf_elist;
2073502Seric };
2083502Seric 
2093502Seric 
2103502Seric # define RESPSIZE	512
2113502Seric # define NVARGS	64
2123502Seric # define VSTART 3
213