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