1 | /*
|
---|
2 | =============================================================================
|
---|
3 | seccpy.c -- section operation functions
|
---|
4 | Version 12 -- 1988-07-16 -- D.N. Lynx Crowe
|
---|
5 |
|
---|
6 | This file contains the section operation functions for:
|
---|
7 |
|
---|
8 | SOP_CPY copy sec_cpy()
|
---|
9 | SOP_MRG merge sec_mrg()
|
---|
10 | SOP_MOV move sec_mov()
|
---|
11 | SOP_RMV remove sec_rmv()
|
---|
12 | SOP_GRP regroup sec_grp()
|
---|
13 | SOP_DGR delete groups sec_dgr()
|
---|
14 | SOP_DEV delete events sec_dev()
|
---|
15 | =============================================================================
|
---|
16 | */
|
---|
17 |
|
---|
18 | #undef DEBUGGER /* define to enable debug trace */
|
---|
19 | #define DEBUGIT 0
|
---|
20 |
|
---|
21 | #include "stddefs.h"
|
---|
22 | #include "debug.h"
|
---|
23 | #include "score.h"
|
---|
24 | #include "scfns.h"
|
---|
25 | #include "secops.h"
|
---|
26 | #include "secdefs.h"
|
---|
27 |
|
---|
28 | #if DEBUGIT
|
---|
29 | extern short debugsw;
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | extern short chksec(short ns);
|
---|
33 | extern short oktocm(struct s_entry *ep);
|
---|
34 | extern short oktode(struct s_entry *ep);
|
---|
35 | extern short oktodg(struct s_entry *ep);
|
---|
36 |
|
---|
37 | extern long sizesec(void);
|
---|
38 |
|
---|
39 | extern struct s_entry *madjsec(struct s_entry *sbp, long btime);
|
---|
40 |
|
---|
41 | extern short grptran;
|
---|
42 |
|
---|
43 | extern char cmgtags[];
|
---|
44 | extern char cmgtype[];
|
---|
45 |
|
---|
46 | extern short ehdlist[];
|
---|
47 | extern short grptmap[];
|
---|
48 |
|
---|
49 | /* |
---|
50 |
|
---|
51 | */
|
---|
52 |
|
---|
53 | /*
|
---|
54 | =============================================================================
|
---|
55 | sec_cpy() -- copy section 'ns' into the score at t_cur
|
---|
56 |
|
---|
57 | ns section number to be copied
|
---|
58 |
|
---|
59 | returns SUCCESS or FAILURE
|
---|
60 | =============================================================================
|
---|
61 | */
|
---|
62 |
|
---|
63 | short sec_cpy(short ns)
|
---|
64 | {
|
---|
65 | register struct s_entry *cp, *lp, *rp;
|
---|
66 | register long newet;
|
---|
67 |
|
---|
68 | DB_ENTR("sec_cpy");
|
---|
69 |
|
---|
70 | secopok = TRUE;
|
---|
71 |
|
---|
72 | if (chksec(ns)) { /* check that section is OK */
|
---|
73 |
|
---|
74 | DB_EXIT("sec_cpy - FAILED chksec");
|
---|
75 | return(FAILURE);
|
---|
76 | }
|
---|
77 |
|
---|
78 | /* see if we have enough free event space to make the copy */
|
---|
79 |
|
---|
80 | if (sizesec() > evleft()) {
|
---|
81 |
|
---|
82 | DB_EXIT("sec_cpy - FAILED sizesec");
|
---|
83 | return(FAILURE);
|
---|
84 | }
|
---|
85 |
|
---|
86 | /* make sure we won't overflow the time range */
|
---|
87 |
|
---|
88 | newet = t_sect + ((scp->e_bak)->e_bak)->e_time;
|
---|
89 |
|
---|
90 | if ((newet < 0) OR (newet GE 0x00FFFFFFL)) {
|
---|
91 |
|
---|
92 | DB_EXIT("sec_cpy - FAILED time check");
|
---|
93 | return(FAILURE);
|
---|
94 | }
|
---|
95 |
|
---|
96 | /* |
---|
97 |
|
---|
98 | */
|
---|
99 | /* make a time adjusted copy of the section */
|
---|
100 |
|
---|
101 | if (E_NULL EQ (cp = madjsec(p_sbgn, t_cur))) {
|
---|
102 |
|
---|
103 | DB_EXIT("sec_cpy - FAILED madjsec");
|
---|
104 | return(FAILURE);
|
---|
105 | }
|
---|
106 |
|
---|
107 | /* point at the events in the score that will surround the copy */
|
---|
108 |
|
---|
109 | lp = ep_adj(p_cur, 0, t_cur); /* events left of the copy */
|
---|
110 | rp = lp->e_fwd; /* events right of the copy */
|
---|
111 |
|
---|
112 | /* adjust the times in the score past the copy */
|
---|
113 |
|
---|
114 | edelta(lp, t_cur, t_sect);
|
---|
115 |
|
---|
116 | /* insert the copy into the score */
|
---|
117 |
|
---|
118 | lp->e_fwd = p_cbgn; /* link copy to left events */
|
---|
119 | p_cbgn->e_bak = lp;
|
---|
120 |
|
---|
121 | rp->e_bak = p_cend; /* link copy to right events */
|
---|
122 | p_cend->e_fwd = rp;
|
---|
123 |
|
---|
124 | /* fix-up the event headers in the copy */
|
---|
125 |
|
---|
126 | ehfix(p_cbgn, p_cend);
|
---|
127 |
|
---|
128 | DB_EXIT("sec_cpy - SUCCESS");
|
---|
129 | return(SUCCESS);
|
---|
130 | }
|
---|
131 |
|
---|
132 | /* |
---|
133 |
|
---|
134 | */
|
---|
135 |
|
---|
136 | /*
|
---|
137 | =============================================================================
|
---|
138 | sec_mrg() -- merge section 'ns' into the score at t_cur
|
---|
139 |
|
---|
140 | ns section number to be merged
|
---|
141 |
|
---|
142 | returns SUCCESS or FAILURE
|
---|
143 | =============================================================================
|
---|
144 | */
|
---|
145 |
|
---|
146 | short sec_mrg(short ns)
|
---|
147 | {
|
---|
148 | register struct s_entry *cp, *lp, *rp;
|
---|
149 | register long newet;
|
---|
150 | register short et;
|
---|
151 |
|
---|
152 | DB_ENTR("sec_mrg");
|
---|
153 |
|
---|
154 | secopok = TRUE;
|
---|
155 |
|
---|
156 | if (chksec(ns)) { /* check that section is OK */
|
---|
157 |
|
---|
158 | DB_EXIT("sec_mrg - FAILED chksec");
|
---|
159 | return(FAILURE);
|
---|
160 | }
|
---|
161 |
|
---|
162 | /* see if we have enough free event space to make the copy */
|
---|
163 |
|
---|
164 | if (sizesec() > evleft()) {
|
---|
165 |
|
---|
166 | DB_EXIT("sec_mrg - FAILED sizesec");
|
---|
167 | return(FAILURE);
|
---|
168 | }
|
---|
169 |
|
---|
170 | /* make sure we won't overflow the time range */
|
---|
171 |
|
---|
172 | newet = t_sect + ((scp->e_bak)->e_bak)->e_time;
|
---|
173 |
|
---|
174 | if ((newet < 0) OR (newet GE 0x00FFFFFFL)) {
|
---|
175 |
|
---|
176 | DB_EXIT("sec_mrg - FAILED time check");
|
---|
177 | return(FAILURE);
|
---|
178 | }
|
---|
179 |
|
---|
180 | /* |
---|
181 |
|
---|
182 | */
|
---|
183 | /* make a time adjusted copy of the section */
|
---|
184 |
|
---|
185 | if (E_NULL EQ (cp = madjsec(p_sbgn, t_cur))) {
|
---|
186 |
|
---|
187 | DB_EXIT("sec_mrg - FAILED madjsec");
|
---|
188 | return(FAILURE);
|
---|
189 | }
|
---|
190 |
|
---|
191 | DB_CMNT("sec_mrg - merging events");
|
---|
192 |
|
---|
193 | lp = ep_adj(p_cur, 0, t_cur); /* get merge point */
|
---|
194 |
|
---|
195 | while (cp) { /* merge events into score starting at p_cur */
|
---|
196 |
|
---|
197 | rp = cp->e_fwd; /* point at next event */
|
---|
198 | lp = ep_adj(lp, 0, cp->e_time); /* update merge point */
|
---|
199 | lp = e_ins(cp, lp); /* insert the element */
|
---|
200 | et = cp->e_type & 0x007F; /* get event type */
|
---|
201 |
|
---|
202 | if (-1 NE ehdlist[et]) /* see if it's a header */
|
---|
203 | eh_ins(cp, ehdlist[et]); /* update header list */
|
---|
204 |
|
---|
205 | cp = rp; /* update copy pointer */
|
---|
206 | }
|
---|
207 |
|
---|
208 | DB_EXIT("sec_mrg - SUCCESS");
|
---|
209 | return(SUCCESS);
|
---|
210 | }
|
---|
211 |
|
---|
212 | /* |
---|
213 |
|
---|
214 | */
|
---|
215 |
|
---|
216 | /*
|
---|
217 | =============================================================================
|
---|
218 | sec_grp() -- regroup section 'ns'
|
---|
219 |
|
---|
220 | ns section number to be re-grouped
|
---|
221 |
|
---|
222 | returns SUCCESS or FAILURE
|
---|
223 | =============================================================================
|
---|
224 | */
|
---|
225 |
|
---|
226 | short sec_grp(short ns)
|
---|
227 | {
|
---|
228 | register struct s_entry *cp, *rp;
|
---|
229 | register short et, nv, grp;
|
---|
230 |
|
---|
231 | DB_ENTR("sec_grp");
|
---|
232 |
|
---|
233 | secopok = TRUE;
|
---|
234 |
|
---|
235 | if (chksec(ns)) { /* check that section is OK */
|
---|
236 |
|
---|
237 | DB_EXIT("sec_grp - FAILED chksec");
|
---|
238 | return(FAILURE);
|
---|
239 | }
|
---|
240 |
|
---|
241 | cp = p_sbgn; /* point at start of section */
|
---|
242 |
|
---|
243 | while (cp NE p_send) { /* regroup events in section */
|
---|
244 |
|
---|
245 | rp = cp->e_fwd; /* point at next event */
|
---|
246 | et = cp->e_type & 0x007F; /* get event type */
|
---|
247 |
|
---|
248 | if (cmgtags[et]) { /* group sensitive ? */
|
---|
249 |
|
---|
250 | grp = 0x000F & (cmgtype[et] ?
|
---|
251 | cp->e_data2 : cp->e_data1);
|
---|
252 |
|
---|
253 | if ((et EQ EV_NBEG) OR (et EQ EV_NEND)) {
|
---|
254 |
|
---|
255 | /* regroup */
|
---|
256 |
|
---|
257 | cp->e_data2 = (cp->e_data2 & 0x00F0) |
|
---|
258 | grptmap[grp];
|
---|
259 |
|
---|
260 | /* transpose */
|
---|
261 |
|
---|
262 | nv = cp->e_data1 + grptran;
|
---|
263 |
|
---|
264 | if (nv > 127)
|
---|
265 | nv = 127;
|
---|
266 | else if (nv < 0)
|
---|
267 | nv = 0;
|
---|
268 |
|
---|
269 | cp->e_data1 = nv;
|
---|
270 |
|
---|
271 | } else if ((et EQ EV_ANRS) OR (et EQ EV_ANVL)) {
|
---|
272 |
|
---|
273 | /* regroup */
|
---|
274 |
|
---|
275 | cp->e_data1 = (cp->e_data1 & 0x000F) |
|
---|
276 | (grptmap[grp] << 4);
|
---|
277 |
|
---|
278 | } else {
|
---|
279 |
|
---|
280 | /* regroup */
|
---|
281 |
|
---|
282 | if (cmgtype[et])
|
---|
283 | cp->e_data2 = (cp->e_data2 & 0x00F0) |
|
---|
284 | grptmap[grp];
|
---|
285 | else
|
---|
286 | cp->e_data1 = (cp->e_data1 & 0x00F0) |
|
---|
287 | grptmap[grp];
|
---|
288 | }
|
---|
289 | }
|
---|
290 |
|
---|
291 | cp = rp; /* update event pointer */
|
---|
292 | }
|
---|
293 |
|
---|
294 | DB_EXIT("sec_grp - SUCCESS");
|
---|
295 | return(SUCCESS);
|
---|
296 | }
|
---|
297 |
|
---|
298 | /* |
---|
299 |
|
---|
300 | */
|
---|
301 |
|
---|
302 | /*
|
---|
303 | =============================================================================
|
---|
304 | sec_mov() -- move section 'ns' to t_cur
|
---|
305 |
|
---|
306 | ns section number to be moved
|
---|
307 |
|
---|
308 | returns SUCCESS or FAILURE
|
---|
309 | =============================================================================
|
---|
310 | */
|
---|
311 |
|
---|
312 | short sec_mov(short ns)
|
---|
313 | {
|
---|
314 | register struct s_entry *cp, *lp, *rp;
|
---|
315 | register long newet;
|
---|
316 | register short et, grp, nv;
|
---|
317 |
|
---|
318 | DB_ENTR("sec_mov");
|
---|
319 |
|
---|
320 | secopok = TRUE;
|
---|
321 |
|
---|
322 | if (chksec(ns)) { /* check that section is OK */
|
---|
323 |
|
---|
324 | DB_EXIT("sec_mov - FAILED chksec");
|
---|
325 | return(FAILURE);
|
---|
326 | }
|
---|
327 |
|
---|
328 | #if DEBUGIT
|
---|
329 | if (debugsw) {
|
---|
330 |
|
---|
331 | printf("sec_mov: t_cur = %ld, t_sbgn = %ld, t_send = %ld, t_sect = %ld\n",
|
---|
332 | t_cur, t_sbgn, t_send, t_sect);
|
---|
333 |
|
---|
334 | printf("sec_mov: p_cur = $%08lX, p_sbgn = $%08lX, p_send = $%08lX\n",
|
---|
335 | p_cur, p_sbgn, p_send);
|
---|
336 | }
|
---|
337 | #endif
|
---|
338 |
|
---|
339 | /* verify that section isn't being moved into itself */
|
---|
340 |
|
---|
341 | if ((t_cur GE t_sbgn) AND (t_cur LE t_send)) {
|
---|
342 |
|
---|
343 | DB_EXIT("sec_mov -- bad target");
|
---|
344 | return(FAILURE);
|
---|
345 | }
|
---|
346 |
|
---|
347 | /* |
---|
348 |
|
---|
349 | */
|
---|
350 | lp = ep_adj(p_cur, 0, t_cur); /* get left move point */
|
---|
351 | cp = p_send->e_fwd; /* get adjustment point */
|
---|
352 |
|
---|
353 | #if DEBUGIT
|
---|
354 | if (debugsw)
|
---|
355 | printf("sec_mov: lp = $%08lX, cp = $%08lX\n", lp, cp);
|
---|
356 | #endif
|
---|
357 |
|
---|
358 | /* clip out the section and close up the hole */
|
---|
359 |
|
---|
360 | (p_sbgn->e_bak)->e_fwd = p_send->e_fwd;
|
---|
361 | (p_send->e_fwd)->e_bak = p_sbgn->e_bak;
|
---|
362 | p_sbgn->e_bak = E_NULL;
|
---|
363 | p_send->e_fwd = E_NULL;
|
---|
364 |
|
---|
365 | /* adjust the times above the clip point to end of score */
|
---|
366 |
|
---|
367 | if (t_cur GE t_send) /* adjust t_cur if above clip point */
|
---|
368 | t_cur -= t_sect;
|
---|
369 |
|
---|
370 | #if DEBUGIT
|
---|
371 | if (debugsw)
|
---|
372 | printf("sec_mov: adjusted t_cur = %ld\n", t_cur);
|
---|
373 | #endif
|
---|
374 |
|
---|
375 | while (EV_FINI NE (et = 0x007F & cp->e_type)) {
|
---|
376 |
|
---|
377 | cp->e_time -= t_sect; /* adjust event time */
|
---|
378 | cp = cp->e_fwd; /* point at next event */
|
---|
379 | }
|
---|
380 |
|
---|
381 | /* |
---|
382 |
|
---|
383 | */
|
---|
384 | #if DEBUGIT
|
---|
385 | if (debugsw)
|
---|
386 | printf("sec_mov: adjusted p_cur->e_time = %ld\n",
|
---|
387 | p_cur->e_time);
|
---|
388 | #endif
|
---|
389 |
|
---|
390 | /* relativize the section to 0 and unlink event headers from hplist */
|
---|
391 |
|
---|
392 | rp = p_sbgn; /* start at the beginning */
|
---|
393 | newet = p_sbgn->e_time; /* relativize to begin time EQ 0 */
|
---|
394 |
|
---|
395 | while (rp) {
|
---|
396 |
|
---|
397 | rp->e_time -= newet; /* relativize the time */
|
---|
398 | et = 0x007F & rp->e_type; /* get event type */
|
---|
399 |
|
---|
400 | if (cmgtags[et]) { /* group sensitive ? */
|
---|
401 |
|
---|
402 | grp = 0x000F & (cmgtype[et] ?
|
---|
403 | rp->e_data2 : rp->e_data1);
|
---|
404 |
|
---|
405 | if ((et EQ EV_NBEG) OR (et EQ EV_NEND)) {
|
---|
406 |
|
---|
407 | /* regroup */
|
---|
408 |
|
---|
409 | rp->e_data2 = (rp->e_data2 & 0x00F0) |
|
---|
410 | grptmap[grp];
|
---|
411 |
|
---|
412 | /* transpose */
|
---|
413 |
|
---|
414 | nv = rp->e_data1 + grptran;
|
---|
415 |
|
---|
416 | if (nv > 127)
|
---|
417 | nv = 127;
|
---|
418 | else if (nv < 0)
|
---|
419 | nv = 0;
|
---|
420 |
|
---|
421 | rp->e_data1 = nv;
|
---|
422 |
|
---|
423 | } else if ((et EQ EV_ANRS) OR (et EQ EV_ANVL)) {
|
---|
424 |
|
---|
425 | /* regroup */
|
---|
426 |
|
---|
427 | rp->e_data1 = (rp->e_data1 & 0x000F) |
|
---|
428 | (grptmap[grp] << 4);
|
---|
429 |
|
---|
430 | } else {
|
---|
431 |
|
---|
432 | /* regroup */
|
---|
433 |
|
---|
434 | if (cmgtype[et])
|
---|
435 | rp->e_data2 = (rp->e_data2 & 0x00F0) |
|
---|
436 | grptmap[grp];
|
---|
437 | else
|
---|
438 | rp->e_data1 = (rp->e_data1 & 0x00F0) |
|
---|
439 | grptmap[grp];
|
---|
440 | }
|
---|
441 | }
|
---|
442 |
|
---|
443 | if (-1 NE ehdlist[et]) /* if it's a header ... */
|
---|
444 | eh_rmv(rp, ehdlist[et]); /* ... remove it from hplist */
|
---|
445 |
|
---|
446 | rp = rp->e_fwd; /* point at the next event */
|
---|
447 | }
|
---|
448 |
|
---|
449 | rp = lp->e_fwd; /* get right insert pointer */
|
---|
450 |
|
---|
451 | /* insert the moved section */
|
---|
452 |
|
---|
453 | p_sbgn->e_bak = lp;
|
---|
454 | p_send->e_fwd = rp;
|
---|
455 | lp->e_fwd = p_sbgn;
|
---|
456 | rp->e_bak = p_send;
|
---|
457 |
|
---|
458 | /* |
---|
459 |
|
---|
460 | */
|
---|
461 | /* derelativize the moved section and put headers back on hplist */
|
---|
462 |
|
---|
463 | cp = p_sbgn;
|
---|
464 | newet = t_cur;
|
---|
465 |
|
---|
466 | #if DEBUGIT
|
---|
467 | if (debugsw)
|
---|
468 | printf("sec_mov: lp = $%08lX, cp = $%08lX, rp = $%08lX, newet = %ld\n",
|
---|
469 | lp, cp, rp, newet);
|
---|
470 | #endif
|
---|
471 |
|
---|
472 | while (cp NE rp) {
|
---|
473 |
|
---|
474 | et = 0x007F & cp->e_type; /* get event type */
|
---|
475 | cp->e_time += newet; /* derelativize the time */
|
---|
476 |
|
---|
477 | if (-1 NE ehdlist[et]) /* if event is a header ... */
|
---|
478 | eh_ins(cp, ehdlist[et]); /* ... put event on hplist */
|
---|
479 |
|
---|
480 | cp = cp->e_fwd; /* point at next event */
|
---|
481 | }
|
---|
482 |
|
---|
483 | #if DEBUGIT
|
---|
484 | if (debugsw)
|
---|
485 | printf("sec_mov: adjusting times above $%08lx (%ld) by %ld\n",
|
---|
486 | cp, cp->e_time, t_sect);
|
---|
487 | #endif
|
---|
488 |
|
---|
489 | /* adjust times above move point */
|
---|
490 |
|
---|
491 | while (EV_FINI NE (et = 0x007F & cp->e_type)) {
|
---|
492 |
|
---|
493 | cp->e_time += t_sect; /* adjust the time */
|
---|
494 | cp = cp->e_fwd; /* point at next event */
|
---|
495 | }
|
---|
496 |
|
---|
497 | DB_EXIT("sec_mov - SUCCESS");
|
---|
498 | return(SUCCESS);
|
---|
499 | }
|
---|
500 |
|
---|
501 | /* |
---|
502 |
|
---|
503 | */
|
---|
504 |
|
---|
505 | /*
|
---|
506 | =============================================================================
|
---|
507 | sec_rmv() --remove section 'ns'
|
---|
508 |
|
---|
509 | ns section number to be removed
|
---|
510 |
|
---|
511 | returns SUCCESS or FAILURE
|
---|
512 | =============================================================================
|
---|
513 | */
|
---|
514 |
|
---|
515 | short sec_rmv(short ns)
|
---|
516 | {
|
---|
517 | register struct s_entry *cp, *lp, *rp;
|
---|
518 | register short et;
|
---|
519 | struct s_entry *pp;
|
---|
520 |
|
---|
521 | DB_ENTR("sec_rmv");
|
---|
522 |
|
---|
523 | secopok = TRUE;
|
---|
524 |
|
---|
525 | if (chksec(ns)) { /* check that section is OK */
|
---|
526 |
|
---|
527 | DB_EXIT("sec_rmv - FAILED chksec");
|
---|
528 | return(FAILURE);
|
---|
529 | }
|
---|
530 |
|
---|
531 | pp = cp = p_send->e_fwd; /* get adjustment point */
|
---|
532 |
|
---|
533 | #if DEBUGIT
|
---|
534 | if (debugsw) {
|
---|
535 |
|
---|
536 | printf("sec_rmv: t_cur = %ld, t_sbgn = %ld, t_send = %ld, t_sect = %ld\n",
|
---|
537 | t_cur, t_sbgn, t_send, t_sect);
|
---|
538 |
|
---|
539 | printf("sec_rmv: p_cur = $%08lX, p_sbgn = $%08lX, p_send = $%08lX\n",
|
---|
540 | p_cur, p_sbgn, p_send);
|
---|
541 |
|
---|
542 | printf("sec_rmv: cp = $%08lX\n", cp);
|
---|
543 | }
|
---|
544 | #endif
|
---|
545 |
|
---|
546 | /* |
---|
547 |
|
---|
548 | */
|
---|
549 | /* clip out the section and close up the hole */
|
---|
550 |
|
---|
551 | (p_sbgn->e_bak)->e_fwd = p_send->e_fwd;
|
---|
552 | (p_send->e_fwd)->e_bak = p_sbgn->e_bak;
|
---|
553 | p_sbgn->e_bak = E_NULL;
|
---|
554 | p_send->e_fwd = E_NULL;
|
---|
555 |
|
---|
556 | /* adjust the times above the clip point to end of score */
|
---|
557 |
|
---|
558 | if (t_cur GE t_send) /* adjust t_cur if above clip point */
|
---|
559 | t_cur -= t_sect;
|
---|
560 |
|
---|
561 | #if DEBUGIT
|
---|
562 | if (debugsw)
|
---|
563 | printf("sec_rmv: adjusted t_cur = %ld\n", t_cur);
|
---|
564 | #endif
|
---|
565 |
|
---|
566 | while (EV_FINI NE (et = 0x007F & cp->e_type)) {
|
---|
567 |
|
---|
568 | cp->e_time -= t_sect; /* adjust event time */
|
---|
569 | cp = cp->e_fwd; /* point at next event */
|
---|
570 | }
|
---|
571 |
|
---|
572 | #if DEBUGIT
|
---|
573 | if (debugsw)
|
---|
574 | printf("sec_rmv: adjusted p_cur->e_time = %ld\n",
|
---|
575 | p_cur->e_time);
|
---|
576 | #endif
|
---|
577 |
|
---|
578 | /* unlink event headers from hplist, fix pointers, and delete events */
|
---|
579 |
|
---|
580 | rp = p_sbgn; /* start at the beginning */
|
---|
581 |
|
---|
582 | while (rp) {
|
---|
583 |
|
---|
584 | lp = rp->e_fwd; /* get next event pointer */
|
---|
585 | et = 0x007F & rp->e_type; /* get event type */
|
---|
586 |
|
---|
587 | if (p_bak EQ rp) /* fix p_bak */
|
---|
588 | p_bak = pp;
|
---|
589 |
|
---|
590 | if (p_cur EQ rp) /* fix p_cur */
|
---|
591 | p_cur = pp;
|
---|
592 |
|
---|
593 | if (p_ctr EQ rp) /* fix p_ctr */
|
---|
594 | p_ctr = pp;
|
---|
595 |
|
---|
596 | if (p_fwd EQ rp) /* fix p_fwd */
|
---|
597 | p_fwd = pp;
|
---|
598 |
|
---|
599 | if (-1 NE ehdlist[et]) /* if it's a header ... */
|
---|
600 | eh_rmv(rp, ehdlist[et]); /* ... remove it from hplist */
|
---|
601 |
|
---|
602 | e_del(e_rmv(rp)); /* delete the event */
|
---|
603 | rp = lp; /* point at next event */
|
---|
604 | }
|
---|
605 |
|
---|
606 | seclist[curscor][ns] = E_NULL; /* delete section from seclist */
|
---|
607 | DB_EXIT("sec_rmv");
|
---|
608 | return(SUCCESS);
|
---|
609 | }
|
---|
610 |
|
---|
611 | /* |
---|
612 |
|
---|
613 | */
|
---|
614 |
|
---|
615 | /*
|
---|
616 | =============================================================================
|
---|
617 | sec_dgr() --delete notes in enabled groups in section 'ns'
|
---|
618 |
|
---|
619 | ns section number to be processed
|
---|
620 |
|
---|
621 | returns SUCCESS or FAILURE
|
---|
622 | =============================================================================
|
---|
623 | */
|
---|
624 |
|
---|
625 | short sec_dgr(short ns)
|
---|
626 | {
|
---|
627 | register struct s_entry *lp, *rp;
|
---|
628 |
|
---|
629 | DB_ENTR("sec_dgr");
|
---|
630 |
|
---|
631 | secopok = TRUE;
|
---|
632 |
|
---|
633 | if (chksec(ns)) { /* check that section is OK */
|
---|
634 |
|
---|
635 | DB_EXIT("sec_dgr - FAILED chksec");
|
---|
636 | return(FAILURE);
|
---|
637 | }
|
---|
638 |
|
---|
639 | #if DEBUGIT
|
---|
640 | if (debugsw) {
|
---|
641 |
|
---|
642 | printf("sec_dgr: t_cur = %ld, t_sbgn = %ld, t_send = %ld, t_sect = %ld\n",
|
---|
643 | t_cur, t_sbgn, t_send, t_sect);
|
---|
644 |
|
---|
645 | printf("sec_dgr: p_cur = $%08lX, p_sbgn = $%08lX, p_send = $%08lX\n",
|
---|
646 | p_cur, p_sbgn, p_send);
|
---|
647 | }
|
---|
648 | #endif
|
---|
649 |
|
---|
650 | /* |
---|
651 |
|
---|
652 | */
|
---|
653 | /* delete note events for record enabled groups */
|
---|
654 |
|
---|
655 | DB_CMNT("sec_dgr - deleting");
|
---|
656 |
|
---|
657 | rp = p_sbgn->e_fwd; /* start at the beginning */
|
---|
658 |
|
---|
659 | while (rp NE p_send) {
|
---|
660 |
|
---|
661 | lp = rp->e_fwd; /* get next event pointer */
|
---|
662 |
|
---|
663 | if (oktodg(rp)) { /* if it's one we want ... */
|
---|
664 |
|
---|
665 | if (p_bak EQ rp) /* fix p_bak */
|
---|
666 | p_bak = lp;
|
---|
667 |
|
---|
668 | if (p_cur EQ rp) /* fix p_cur */
|
---|
669 | p_cur = lp;
|
---|
670 |
|
---|
671 | if (p_ctr EQ rp) /* fix p_ctr */
|
---|
672 | p_ctr = lp;
|
---|
673 |
|
---|
674 | if (p_fwd EQ rp) /* fix p_fwd */
|
---|
675 | p_fwd = lp;
|
---|
676 |
|
---|
677 | e_del(e_rmv(rp)); /* ... delete it */
|
---|
678 | }
|
---|
679 |
|
---|
680 | rp = lp; /* point at next event */
|
---|
681 | }
|
---|
682 |
|
---|
683 | DB_EXIT("sec_dgr");
|
---|
684 | return(SUCCESS);
|
---|
685 | }
|
---|
686 |
|
---|
687 | /* |
---|
688 |
|
---|
689 | */
|
---|
690 |
|
---|
691 | /*
|
---|
692 | =============================================================================
|
---|
693 | sec_dev() --delete non-note events in enabled groups in section 'ns'
|
---|
694 |
|
---|
695 | ns section number to be processed
|
---|
696 |
|
---|
697 | returns SUCCESS or FAILURE
|
---|
698 | =============================================================================
|
---|
699 | */
|
---|
700 |
|
---|
701 | short sec_dev(short ns)
|
---|
702 | {
|
---|
703 | register struct s_entry *lp, *rp;
|
---|
704 |
|
---|
705 | DB_ENTR("sec_dev");
|
---|
706 |
|
---|
707 | secopok = TRUE;
|
---|
708 |
|
---|
709 | if (chksec(ns)) { /* check that section is OK */
|
---|
710 |
|
---|
711 | DB_EXIT("sec_dev - FAILED chksec");
|
---|
712 | return(FAILURE);
|
---|
713 | }
|
---|
714 |
|
---|
715 | #if DEBUGIT
|
---|
716 | if (debugsw) {
|
---|
717 |
|
---|
718 | printf("sec_dev: t_cur = %ld, t_sbgn = %ld, t_send = %ld, t_sect = %ld\n",
|
---|
719 | t_cur, t_sbgn, t_send, t_sect);
|
---|
720 |
|
---|
721 | printf("sec_dev: p_cur = $%08lX, p_sbgn = $%08lX, p_send = $%08lX\n",
|
---|
722 | p_cur, p_sbgn, p_send);
|
---|
723 | }
|
---|
724 | #endif
|
---|
725 |
|
---|
726 | /* |
---|
727 |
|
---|
728 | */
|
---|
729 | /* delete non-note events for record enabled groups */
|
---|
730 |
|
---|
731 | DB_CMNT("sec_dev - deleting");
|
---|
732 |
|
---|
733 | rp = p_sbgn->e_fwd; /* start at the beginning */
|
---|
734 |
|
---|
735 | while (rp NE p_send) {
|
---|
736 |
|
---|
737 | lp = rp->e_fwd; /* get next event pointer */
|
---|
738 |
|
---|
739 | if (oktode(rp)) { /* if it's one we want ... */
|
---|
740 |
|
---|
741 | if (p_bak EQ rp) /* fix p_bak */
|
---|
742 | p_bak = lp;
|
---|
743 |
|
---|
744 | if (p_cur EQ rp) /* fix p_cur */
|
---|
745 | p_cur = lp;
|
---|
746 |
|
---|
747 | if (p_ctr EQ rp) /* fix p_ctr */
|
---|
748 | p_ctr = lp;
|
---|
749 |
|
---|
750 | if (p_fwd EQ rp) /* fix p_fwd */
|
---|
751 | p_fwd = lp;
|
---|
752 |
|
---|
753 | e_del(e_rmv(rp)); /* ... delete it */
|
---|
754 | }
|
---|
755 |
|
---|
756 | rp = lp; /* point at next event */
|
---|
757 | }
|
---|
758 |
|
---|
759 | DB_EXIT("sec_dev");
|
---|
760 | return(SUCCESS);
|
---|
761 | }
|
---|