Commit | Line | Data |
---|---|---|
d57d66b9 EA |
1 | # include "../hdr/defines.h" |
2 | ||
4e7d4c80 | 3 | static char Sccsid[] = "@(#)dolist.c 4.3 %G%"; |
d57d66b9 | 4 | |
4e7d4c80 | 5 | static char br[] = "bad range (co12)"; |
d57d66b9 EA |
6 | |
7 | dolist(pkt,list,ch) | |
8 | struct packet *pkt; | |
9 | register char *list; | |
10 | char ch; | |
11 | { | |
12 | char str[32]; | |
13 | struct sid lowsid, highsid, sid; | |
14 | int n; | |
15 | ||
16 | while (*list) { | |
17 | list = getasid(list,&lowsid); | |
18 | if (*list == '-') { | |
19 | ++list; | |
20 | list = getasid(list,&highsid); | |
21 | if (lowsid.s_br == 0) { | |
22 | if ((highsid.s_br || highsid.s_seq || | |
23 | highsid.s_rel < lowsid.s_rel || | |
24 | (highsid.s_rel == lowsid.s_rel && | |
25 | highsid.s_lev < lowsid.s_lev))) | |
26 | fatal(br); | |
27 | sid.s_br = sid.s_seq = 0; | |
28 | for (sid.s_rel = lowsid.s_rel; sid.s_rel <= highsid.s_rel; sid.s_rel++) { | |
29 | sid.s_lev = (sid.s_rel == lowsid.s_rel ? lowsid.s_lev : 1); | |
757f131f EA |
30 | for ( ; (sid.s_rel < highsid.s_rel || |
31 | sid.s_lev <= highsid.s_lev) && | |
32 | (n = sidtoser(&sid,pkt)); sid.s_lev++) | |
d57d66b9 EA |
33 | enter(pkt,ch,n,&sid); |
34 | } | |
35 | } | |
36 | else { | |
37 | if (!(highsid.s_rel == lowsid.s_rel && | |
38 | highsid.s_lev == lowsid.s_lev && | |
39 | highsid.s_br == lowsid.s_br && | |
40 | highsid.s_seq >= lowsid.s_seq)) | |
41 | fatal(br); | |
42 | for (; lowsid.s_seq <= highsid.s_seq && | |
43 | (n = sidtoser(&lowsid,pkt)); lowsid.s_seq++) | |
44 | enter(pkt,ch,n,&lowsid); | |
45 | } | |
46 | } | |
47 | else { | |
48 | if (n = sidtoser(&lowsid,pkt)) | |
49 | enter(pkt,ch,n,&lowsid); | |
50 | } | |
51 | if (*list == ',') | |
52 | ++list; | |
53 | } | |
54 | } | |
55 | ||
56 | ||
4e7d4c80 | 57 | static char dls[] = "delta list syntax (co13)"; |
d57d66b9 EA |
58 | |
59 | getasid(p,sp) | |
60 | register char *p; | |
61 | register struct sid *sp; | |
62 | { | |
63 | register char *old; | |
64 | ||
65 | p = sid_ab(old = p,sp); | |
66 | if (old == p || sp->s_rel == 0) | |
67 | fatal(dls); | |
68 | if (sp->s_lev == 0) { | |
69 | sp->s_lev = MAX; | |
70 | if (sp->s_br || sp->s_seq) | |
71 | fatal(dls); | |
72 | } | |
73 | else if (sp->s_br) { | |
74 | if (sp->s_seq == 0) | |
75 | sp->s_seq = MAX; | |
76 | } | |
77 | else if (sp->s_seq) | |
78 | fatal(dls); | |
79 | return(p); | |
80 | } |