1 # include	"../hdr/defines.h"
2 
3 static char Sccsid[] = "@(#)setup.c	1.3	02/15/87";
4 
5 setup(pkt,serial)
6 register struct packet *pkt;
7 int serial;
8 {
9 	register int n;
10 	register struct apply *rap;
11 	int	first_app = 1;
12 
13 	pkt->p_apply[serial].a_inline = 1;
14 	for (n = maxser(pkt); n; n--) {
15 		rap = &pkt->p_apply[n];
16 		if (rap->a_inline) {
17 			if (n != 1 && pkt->p_idel[n].i_pred == 0)
18 				fmterr(pkt);
19 			pkt->p_apply[pkt->p_idel[n].i_pred].a_inline = 1;
20 			if (pkt->p_idel[n].i_datetime > pkt->p_cutoff)
21 				condset(rap,NOAPPLY,CUTOFF);
22 			else {
23 				if (first_app)
24 					bcopy(&pkt->p_idel[n].i_sid,
25 					     &pkt->p_gotsid,
26 					     sizeof(pkt->p_gotsid));
27 				first_app = 0;
28 				condset(rap,APPLY,EMPTY);
29 			}
30 		}
31 		else
32 			condset(rap,NOAPPLY,EMPTY);
33 		if (rap->a_code == APPLY)
34 			ixgsetup(pkt->p_apply,&(pkt->p_idel[n].i_ixg));
35 	}
36 }
37 
38 
39 ixgsetup(ap,ixgp)
40 struct apply *ap;
41 struct ixg *ixgp;
42 {
43 	int n;
44 	int code, reason;
45 	register int *ip;
46 	register struct ixg *cur, *prev;
47 
48 	for (cur = ixgp; cur = (prev = cur)->i_next; ) {
49 		switch (cur->i_type) {
50 
51 		case INCLUDE:
52 			code = APPLY;
53 			reason = INCL;
54 			break;
55 		case EXCLUDE:
56 			code = NOAPPLY;
57 			reason = EXCL;
58 			break;
59 		case IGNORE:
60 			code = EMPTY;
61 			reason = IGNR;
62 			break;
63 		}
64 		ip = cur->i_ser;
65 		for (n = cur->i_cnt; n; n--)
66 			condset(&ap[*ip++],code,reason);
67 	}
68 }
69 
70 
71 condset(ap,code,reason)
72 register struct apply *ap;
73 int code, reason;
74 {
75 	if (code == EMPTY)
76 		ap->a_reason |= reason;
77 	else if (ap->a_code == EMPTY) {
78 		ap->a_code = code;
79 		ap->a_reason |= reason;
80 	}
81 }
82