2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $TOG: sdl.c /main/5 1998/04/06 13:19:43 mgreess $ */
24 /* Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co. */
25 /* Miscellaneous Procedures for HP Tag/TeX translator */
29 #if defined(__osf__) || defined(linux)
30 # include <sys/fcntl.h>
33 # include <sys/access.h>
45 #include "LocaleXlate.h"
46 #include "XlationSvc.h"
48 static char *operantLocale;
50 static char openLoids[] = "<LOIDS COUNT=\"%d\">\n";
51 static char closeLoids[] = "</LOIDS>\n";
54 static char wideCharacterString[] = "wide character string";
58 char *mb_malloc(long size)
67 ssize = (size_t) size;
68 cptr = (char *) malloc(ssize);
71 fprintf(stdout, "malloc 0x%p\n", cptr);
81 void mb_free(char **pptr)
89 fprintf(stdout, "free 0x%p\n", *pptr);
99 char *mb_realloc(char *ptr, long size)
101 char *mb_realloc(ptr, size)
109 ssize = (size_t) size;
110 vptr = realloc((void *) ptr, ssize);
115 fprintf(stdout, "realloc 0x%p 0x%p\n", ptr, vptr);
120 return (char *) vptr;
125 void OpenTag(LOGICAL hasAttributes, LOGICAL newlineOK)
127 void OpenTag(hasAttributes, newlineOK)
128 LOGICAL hasAttributes;
133 PutWString(m_parent(0));
144 static void OpenNamedTag(char *name, LOGICAL hasAttributes, LOGICAL newlineOK)
146 static void OpenNamedTag(name, hasAttributes, newlineOK)
147 LOGICAL hasAttributes;
164 void CloseTag(LOGICAL newlineOK)
166 void CloseTag(newlineOK)
177 PutWString(m_parent(0));
183 static void CloseNamedTag(char *name, LOGICAL newlineOK)
185 static void CloseNamedTag(name, newlineOK)
203 void ImpliedAttribute(char *name, M_WCHAR *value)
205 void ImpliedAttribute(name, value)
222 void RequiredAttribute(char *name, M_WCHAR *value)
224 void RequiredAttribute(name, value)
236 wc_name = MakeWideCharString(name);
237 m_err2("Missing %s in %s", wc_name, m_parent(0));
238 m_free(wc_name, "wide character name");
249 M_WCHAR *CopyWString(M_WCHAR *string)
251 M_WCHAR *CopyWString(string)
257 if (!string) return NULL;
259 retVal = m_malloc(w_strlen(string) + 1, wideCharacterString);
260 w_strcpy(retVal, string);
266 void MakeNewElement(ElementTypes type)
268 void MakeNewElement(type)
272 pCurrentElement = (ElementPtr) mb_malloc(sizeof(Element));
273 memset((void *) pCurrentElement, 0, sizeof(Element));
274 pCurrentElement->type = type;
277 pCurrentElement->u.u_cdata.buffer = m_malloc(256, "u_cdata.buffer");
278 pCurrentElement->u.u_cdata.buffPos = -1;
279 pCurrentElement->u.u_cdata.buffSize = 256;
285 void DeleteElement(ElementPtr pElement)
287 void DeleteElement(pElement)
291 switch (pElement->type)
294 if (pElement->u.u_sdldoc.pub_id)
295 m_free(pElement->u.u_sdldoc.pub_id, wideCharacterString);
296 if (pElement->u.u_sdldoc.doc_id)
297 m_free(pElement->u.u_sdldoc.doc_id, wideCharacterString);
298 if (pElement->u.u_sdldoc.first_page)
299 m_free(pElement->u.u_sdldoc.first_page, wideCharacterString);
300 if (pElement->u.u_sdldoc.timestmp)
301 m_free(pElement->u.u_sdldoc.timestmp, wideCharacterString);
302 if (pElement->u.u_sdldoc.product)
303 m_free(pElement->u.u_sdldoc.product, wideCharacterString);
304 if (pElement->u.u_sdldoc.prodpn)
305 m_free(pElement->u.u_sdldoc.prodpn, wideCharacterString);
306 if (pElement->u.u_sdldoc.prodver)
307 m_free(pElement->u.u_sdldoc.prodver, wideCharacterString);
308 if (pElement->u.u_sdldoc.license)
309 m_free(pElement->u.u_sdldoc.license, wideCharacterString);
310 if (pElement->u.u_sdldoc.language)
311 m_free(pElement->u.u_sdldoc.language, wideCharacterString);
312 if (pElement->u.u_sdldoc.charset)
313 m_free(pElement->u.u_sdldoc.charset, wideCharacterString);
314 if (pElement->u.u_sdldoc.author)
315 m_free(pElement->u.u_sdldoc.author, wideCharacterString);
316 if (pElement->u.u_sdldoc.version)
317 m_free(pElement->u.u_sdldoc.version, wideCharacterString);
318 if (pElement->u.u_sdldoc.sdldtd)
319 m_free(pElement->u.u_sdldoc.sdldtd, wideCharacterString);
320 if (pElement->u.u_sdldoc.srcdtd)
321 m_free(pElement->u.u_sdldoc.srcdtd, wideCharacterString);
324 if (pElement->u.u_virpage.id)
325 m_free(pElement->u.u_virpage.id, wideCharacterString);
326 if (pElement->u.u_virpage.level)
327 m_free(pElement->u.u_virpage.level, wideCharacterString);
328 if (pElement->u.u_virpage.version)
329 m_free(pElement->u.u_virpage.version, wideCharacterString);
330 if (pElement->u.u_virpage.language)
331 m_free(pElement->u.u_virpage.language, wideCharacterString);
332 if (pElement->u.u_virpage.charset)
333 m_free(pElement->u.u_virpage.charset, wideCharacterString);
334 if (pElement->u.u_virpage.doc_id)
335 m_free(pElement->u.u_virpage.doc_id, wideCharacterString);
336 if (pElement->u.u_virpage.ssi)
337 m_free(pElement->u.u_virpage.ssi, wideCharacterString);
340 if (pElement->u.u_snb.version)
341 m_free(pElement->u.u_snb.version, wideCharacterString);
344 if (pElement->u.u_block.id)
345 m_free(pElement->u.u_block.id, wideCharacterString);
346 if (pElement->u.u_block.level)
347 m_free(pElement->u.u_block.level, wideCharacterString);
348 if (pElement->u.u_block.version)
349 m_free(pElement->u.u_block.version, wideCharacterString);
350 if (pElement->u.u_block.class)
351 m_free(pElement->u.u_block.class, wideCharacterString);
352 if (pElement->u.u_block.language)
353 m_free(pElement->u.u_block.language, wideCharacterString);
354 if (pElement->u.u_block.charset)
355 m_free(pElement->u.u_block.charset, wideCharacterString);
356 if (pElement->u.u_block.length)
357 m_free(pElement->u.u_block.length, wideCharacterString);
358 if (pElement->u.u_block.app)
359 m_free(pElement->u.u_block.app, wideCharacterString);
360 if (pElement->u.u_block.timing)
361 m_free(pElement->u.u_block.timing, wideCharacterString);
362 if (pElement->u.u_block.ssi)
363 m_free(pElement->u.u_block.ssi, wideCharacterString);
366 if (pElement->u.u_form.id)
367 m_free(pElement->u.u_form.id, wideCharacterString);
368 if (pElement->u.u_form.level)
369 m_free(pElement->u.u_form.level, wideCharacterString);
370 if (pElement->u.u_form.version)
371 m_free(pElement->u.u_form.version, wideCharacterString);
372 if (pElement->u.u_form.class)
373 m_free(pElement->u.u_form.class, wideCharacterString);
374 if (pElement->u.u_form.language)
375 m_free(pElement->u.u_form.language, wideCharacterString);
376 if (pElement->u.u_form.charset)
377 m_free(pElement->u.u_form.charset, wideCharacterString);
378 if (pElement->u.u_form.length)
379 m_free(pElement->u.u_form.length, wideCharacterString);
380 if (pElement->u.u_form.app)
381 m_free(pElement->u.u_form.app, wideCharacterString);
382 if (pElement->u.u_form.ssi)
383 m_free(pElement->u.u_form.ssi, wideCharacterString);
386 if (pElement->u.u_fstyle.ncols)
387 m_free(pElement->u.u_fstyle.ncols, wideCharacterString);
390 if (pElement->u.u_frowvec.hdr)
391 m_free(pElement->u.u_frowvec.hdr, wideCharacterString);
392 if (pElement->u.u_frowvec.cells)
393 m_free(pElement->u.u_frowvec.cells, wideCharacterString);
398 if (pElement->u.u_p.id)
399 m_free(pElement->u.u_p.id, wideCharacterString);
400 if (pElement->u.u_p.version)
401 m_free(pElement->u.u_p.version, wideCharacterString);
402 if (pElement->u.u_p.type)
403 m_free(pElement->u.u_p.type, wideCharacterString);
404 if (pElement->u.u_p.ssi)
405 m_free(pElement->u.u_p.ssi, wideCharacterString);
408 if (pElement->u.u_cp.id)
409 m_free(pElement->u.u_cp.id, wideCharacterString);
410 if (pElement->u.u_cp.version)
411 m_free(pElement->u.u_cp.version, wideCharacterString);
412 if (pElement->u.u_cp.type)
413 m_free(pElement->u.u_cp.type, wideCharacterString);
414 if (pElement->u.u_cp.ssi)
415 m_free(pElement->u.u_cp.ssi, wideCharacterString);
418 if (pElement->u.u_head.id)
419 m_free(pElement->u.u_head.id, wideCharacterString);
420 if (pElement->u.u_head.version)
421 m_free(pElement->u.u_head.version, wideCharacterString);
422 if (pElement->u.u_head.class)
423 m_free(pElement->u.u_head.class, wideCharacterString);
424 if (pElement->u.u_head.language)
425 m_free(pElement->u.u_head.language, wideCharacterString);
426 if (pElement->u.u_head.charset)
427 m_free(pElement->u.u_head.charset, wideCharacterString);
428 if (pElement->u.u_head.type)
429 m_free(pElement->u.u_head.type, wideCharacterString);
430 if (pElement->u.u_head.ssi)
431 m_free(pElement->u.u_head.ssi, wideCharacterString);
432 if (pElement->u.u_head.abbrev)
433 m_free(pElement->u.u_head.abbrev, wideCharacterString);
436 if (pElement->u.u_subhead.id)
437 m_free(pElement->u.u_subhead.id, wideCharacterString);
438 if (pElement->u.u_subhead.version)
439 m_free(pElement->u.u_subhead.version, wideCharacterString);
440 if (pElement->u.u_subhead.class)
441 m_free(pElement->u.u_subhead.class, wideCharacterString);
442 if (pElement->u.u_subhead.language)
443 m_free(pElement->u.u_subhead.language, wideCharacterString);
444 if (pElement->u.u_subhead.charset)
445 m_free(pElement->u.u_subhead.charset, wideCharacterString);
446 if (pElement->u.u_subhead.type)
447 m_free(pElement->u.u_subhead.type, wideCharacterString);
448 if (pElement->u.u_subhead.ssi)
449 m_free(pElement->u.u_subhead.ssi, wideCharacterString);
450 if (pElement->u.u_subhead.abbrev)
451 m_free(pElement->u.u_subhead.abbrev, wideCharacterString);
454 if (pElement->u.u_anchor.id)
455 m_free(pElement->u.u_anchor.id, wideCharacterString);
458 if (pElement->u.u_link.rid)
459 m_free(pElement->u.u_link.rid, wideCharacterString);
460 if (pElement->u.u_link.button)
461 m_free(pElement->u.u_link.button, wideCharacterString);
462 if (pElement->u.u_link.linkinfo)
463 m_free(pElement->u.u_link.linkinfo, wideCharacterString);
464 if (pElement->u.u_link.descript)
465 m_free(pElement->u.u_link.descript, wideCharacterString);
466 if (pElement->u.u_link.window)
467 m_free(pElement->u.u_link.window, wideCharacterString);
468 if (pElement->u.u_link.traversal)
469 m_free(pElement->u.u_link.traversal, wideCharacterString);
472 if (pElement->u.u_snref.id)
473 m_free(pElement->u.u_snref.id, wideCharacterString);
476 if (pElement->u.u_refitem.rid)
477 m_free(pElement->u.u_refitem.rid, wideCharacterString);
478 if (pElement->u.u_refitem.class)
479 m_free(pElement->u.u_refitem.class, wideCharacterString);
480 if (pElement->u.u_refitem.button)
481 m_free(pElement->u.u_refitem.button, wideCharacterString);
482 if (pElement->u.u_refitem.ssi)
483 m_free(pElement->u.u_refitem.ssi, wideCharacterString);
490 if (pElement->u.u_key.charset)
491 m_free(pElement->u.u_key.charset, wideCharacterString);
492 if (pElement->u.u_key.class)
493 m_free(pElement->u.u_key.class, wideCharacterString);
494 if (pElement->u.u_key.ssi)
495 m_free(pElement->u.u_key.ssi, wideCharacterString);
498 if (pElement->u.u_sphrase.class)
499 m_free(pElement->u.u_sphrase.class, wideCharacterString);
500 if (pElement->u.u_sphrase.ssi)
501 m_free(pElement->u.u_sphrase.ssi, wideCharacterString);
506 if (pElement->u.u_cond.interp)
507 m_free(pElement->u.u_cond.interp, wideCharacterString);
514 if (pElement->u.u_spc.name)
515 m_free(pElement->u.u_spc.name, wideCharacterString);
518 if (pElement->u.u_graphic.id)
519 m_free(pElement->u.u_graphic.id, wideCharacterString);
520 if (pElement->u.u_graphic.format)
521 m_free(pElement->u.u_graphic.format, wideCharacterString);
522 if (pElement->u.u_graphic.method)
523 m_free(pElement->u.u_graphic.method, wideCharacterString);
524 if (pElement->u.u_graphic.xid)
525 m_free(pElement->u.u_graphic.xid, wideCharacterString);
528 if (pElement->u.u_text.id)
529 m_free(pElement->u.u_text.id, wideCharacterString);
530 if (pElement->u.u_text.language)
531 m_free(pElement->u.u_text.language, wideCharacterString);
532 if (pElement->u.u_text.charset)
533 m_free(pElement->u.u_text.charset, wideCharacterString);
536 if (pElement->u.u_audio.id)
537 m_free(pElement->u.u_audio.id, wideCharacterString);
538 if (pElement->u.u_audio.format)
539 m_free(pElement->u.u_audio.format, wideCharacterString);
540 if (pElement->u.u_audio.method)
541 m_free(pElement->u.u_audio.method, wideCharacterString);
542 if (pElement->u.u_audio.xid)
543 m_free(pElement->u.u_audio.xid, wideCharacterString);
546 if (pElement->u.u_video.id)
547 m_free(pElement->u.u_video.id, wideCharacterString);
548 if (pElement->u.u_video.format)
549 m_free(pElement->u.u_video.format, wideCharacterString);
550 if (pElement->u.u_video.method)
551 m_free(pElement->u.u_video.method, wideCharacterString);
552 if (pElement->u.u_video.xid)
553 m_free(pElement->u.u_video.xid, wideCharacterString);
556 if (pElement->u.u_animate.id)
557 m_free(pElement->u.u_animate.id, wideCharacterString);
558 if (pElement->u.u_animate.format)
559 m_free(pElement->u.u_animate.format, wideCharacterString);
560 if (pElement->u.u_animate.method)
561 m_free(pElement->u.u_animate.method, wideCharacterString);
562 if (pElement->u.u_animate.xid)
563 m_free(pElement->u.u_animate.xid, wideCharacterString);
566 if (pElement->u.u_script.id)
567 m_free(pElement->u.u_script.id, wideCharacterString);
568 if (pElement->u.u_script.interp)
569 m_free(pElement->u.u_script.interp, wideCharacterString);
572 if (pElement->u.u_crossdoc.id)
573 m_free(pElement->u.u_crossdoc.id, wideCharacterString);
574 if (pElement->u.u_crossdoc.xid)
575 m_free(pElement->u.u_crossdoc.xid, wideCharacterString);
578 if (pElement->u.u_man_page.id)
579 m_free(pElement->u.u_man_page.id, wideCharacterString);
580 if (pElement->u.u_man_page.xid)
581 m_free(pElement->u.u_man_page.xid, wideCharacterString);
584 if (pElement->u.u_textfile.id)
585 m_free(pElement->u.u_textfile.id, wideCharacterString);
586 if (pElement->u.u_textfile.xid)
587 m_free(pElement->u.u_textfile.xid, wideCharacterString);
588 if (pElement->u.u_textfile.offset)
589 m_free(pElement->u.u_textfile.offset, wideCharacterString);
590 if (pElement->u.u_textfile.format)
591 m_free(pElement->u.u_textfile.format, wideCharacterString);
594 if (pElement->u.u_sys_cmd.id)
595 m_free(pElement->u.u_sys_cmd.id, wideCharacterString);
596 if (pElement->u.u_sys_cmd.command)
597 m_free(pElement->u.u_sys_cmd.command, wideCharacterString);
600 if (pElement->u.u_callback.id)
601 m_free(pElement->u.u_callback.id, wideCharacterString);
602 if (pElement->u.u_callback.data)
603 m_free(pElement->u.u_callback.data, wideCharacterString);
606 if (pElement->u.u_switch.id)
607 m_free(pElement->u.u_switch.id, wideCharacterString);
608 if (pElement->u.u_switch.interp)
609 m_free(pElement->u.u_switch.interp, wideCharacterString);
610 if (pElement->u.u_switch.branches)
611 m_free(pElement->u.u_switch.branches, wideCharacterString);
614 m_free(pElement->u.u_cdata.buffer, "u_cdata.buffer");
625 if (pElement->u.u_id.type)
626 m_free(pElement->u.u_id.type, wideCharacterString);
627 if (pElement->u.u_id.rid)
628 m_free(pElement->u.u_id.rid, wideCharacterString);
629 if (pElement->u.u_id.rssi)
630 m_free(pElement->u.u_id.rssi, wideCharacterString);
631 if (pElement->u.u_id.rlevel)
632 m_free(pElement->u.u_id.rlevel, wideCharacterString);
633 if (pElement->u.u_id.offset)
634 m_free(pElement->u.u_id.offset, wideCharacterString);
639 if (pElement->u.u_entry.id)
640 m_free(pElement->u.u_entry.id, wideCharacterString);
641 if (pElement->u.u_entry.main)
642 m_free(pElement->u.u_entry.main, wideCharacterString);
643 if (pElement->u.u_entry.locs)
644 m_free(pElement->u.u_entry.locs, wideCharacterString);
645 if (pElement->u.u_entry.syns)
646 m_free(pElement->u.u_entry.syns, wideCharacterString);
647 if (pElement->u.u_entry.sort)
648 m_free(pElement->u.u_entry.sort, wideCharacterString);
657 if (pElement->u.u_keystyle.class)
658 m_free(pElement->u.u_keystyle.class, wideCharacterString);
659 if (pElement->u.u_keystyle.ssi)
660 m_free(pElement->u.u_keystyle.ssi, wideCharacterString);
661 if (pElement->u.u_keystyle.rlevel)
662 m_free(pElement->u.u_keystyle.rlevel, wideCharacterString);
663 if (pElement->u.u_keystyle.phrase)
664 m_free(pElement->u.u_keystyle.phrase, wideCharacterString);
665 if (pElement->u.u_keystyle.srch_wt)
666 m_free(pElement->u.u_keystyle.srch_wt, wideCharacterString);
667 if (pElement->u.u_keystyle.enter)
668 m_free(pElement->u.u_keystyle.enter, wideCharacterString);
669 if (pElement->u.u_keystyle.exit)
670 m_free(pElement->u.u_keystyle.exit, wideCharacterString);
671 if (pElement->u.u_keystyle.pointsz)
672 m_free(pElement->u.u_keystyle.pointsz, wideCharacterString);
673 if (pElement->u.u_keystyle.set_width)
674 m_free(pElement->u.u_keystyle.set_width, wideCharacterString);
675 if (pElement->u.u_keystyle.color)
676 m_free(pElement->u.u_keystyle.color, wideCharacterString);
677 if (pElement->u.u_keystyle.xlfd)
678 m_free(pElement->u.u_keystyle.xlfd, wideCharacterString);
679 if (pElement->u.u_keystyle.xlfdi)
680 m_free(pElement->u.u_keystyle.xlfdi, wideCharacterString);
681 if (pElement->u.u_keystyle.xlfdb)
682 m_free(pElement->u.u_keystyle.xlfdb, wideCharacterString);
683 if (pElement->u.u_keystyle.xlfdib)
684 m_free(pElement->u.u_keystyle.xlfdib, wideCharacterString);
685 if (pElement->u.u_keystyle.typenam)
686 m_free(pElement->u.u_keystyle.typenam, wideCharacterString);
687 if (pElement->u.u_keystyle.typenami)
688 m_free(pElement->u.u_keystyle.typenami, wideCharacterString);
689 if (pElement->u.u_keystyle.typenamb)
690 m_free(pElement->u.u_keystyle.typenamb, wideCharacterString);
691 if (pElement->u.u_keystyle.typenamib)
692 m_free(pElement->u.u_keystyle.typenamib, wideCharacterString);
693 if (pElement->u.u_keystyle.style)
694 m_free(pElement->u.u_keystyle.style, wideCharacterString);
695 if (pElement->u.u_keystyle.spacing)
696 m_free(pElement->u.u_keystyle.spacing, wideCharacterString);
697 if (pElement->u.u_keystyle.weight)
698 m_free(pElement->u.u_keystyle.weight, wideCharacterString);
699 if (pElement->u.u_keystyle.slant)
700 m_free(pElement->u.u_keystyle.slant, wideCharacterString);
701 if (pElement->u.u_keystyle.special)
702 m_free(pElement->u.u_keystyle.special, wideCharacterString);
705 if (pElement->u.u_headstyle.class)
706 m_free(pElement->u.u_headstyle.class, wideCharacterString);
707 if (pElement->u.u_headstyle.ssi)
708 m_free(pElement->u.u_headstyle.ssi, wideCharacterString);
709 if (pElement->u.u_headstyle.rlevel)
710 m_free(pElement->u.u_headstyle.rlevel, wideCharacterString);
711 if (pElement->u.u_headstyle.phrase)
712 m_free(pElement->u.u_headstyle.phrase, wideCharacterString);
713 if (pElement->u.u_headstyle.srch_wt)
714 m_free(pElement->u.u_headstyle.srch_wt, wideCharacterString);
715 if (pElement->u.u_headstyle.orient)
716 m_free(pElement->u.u_headstyle.orient, wideCharacterString);
717 if (pElement->u.u_headstyle.vorient)
718 m_free(pElement->u.u_headstyle.vorient, wideCharacterString);
719 if (pElement->u.u_headstyle.placement)
720 m_free(pElement->u.u_headstyle.placement, wideCharacterString);
721 if (pElement->u.u_headstyle.headw)
722 m_free(pElement->u.u_headstyle.headw, wideCharacterString);
723 if (pElement->u.u_headstyle.stack)
724 m_free(pElement->u.u_headstyle.stack, wideCharacterString);
725 if (pElement->u.u_headstyle.flow)
726 m_free(pElement->u.u_headstyle.flow, wideCharacterString);
727 if (pElement->u.u_headstyle.pointsz)
728 m_free(pElement->u.u_headstyle.pointsz, wideCharacterString);
729 if (pElement->u.u_headstyle.set_width)
730 m_free(pElement->u.u_headstyle.set_width, wideCharacterString);
731 if (pElement->u.u_headstyle.color)
732 m_free(pElement->u.u_headstyle.color, wideCharacterString);
733 if (pElement->u.u_headstyle.xlfd)
734 m_free(pElement->u.u_headstyle.xlfd, wideCharacterString);
735 if (pElement->u.u_headstyle.xlfdi)
736 m_free(pElement->u.u_headstyle.xlfdi, wideCharacterString);
737 if (pElement->u.u_headstyle.xlfdb)
738 m_free(pElement->u.u_headstyle.xlfdb, wideCharacterString);
739 if (pElement->u.u_headstyle.xlfdib)
740 m_free(pElement->u.u_headstyle.xlfdib, wideCharacterString);
741 if (pElement->u.u_headstyle.typenam)
742 m_free(pElement->u.u_headstyle.typenam, wideCharacterString);
743 if (pElement->u.u_headstyle.typenami)
744 m_free(pElement->u.u_headstyle.typenami, wideCharacterString);
745 if (pElement->u.u_headstyle.typenamb)
746 m_free(pElement->u.u_headstyle.typenamb, wideCharacterString);
747 if (pElement->u.u_headstyle.typenamib)
748 m_free(pElement->u.u_headstyle.typenamib, wideCharacterString);
749 if (pElement->u.u_headstyle.style)
750 m_free(pElement->u.u_headstyle.style, wideCharacterString);
751 if (pElement->u.u_headstyle.spacing)
752 m_free(pElement->u.u_headstyle.spacing, wideCharacterString);
753 if (pElement->u.u_headstyle.weight)
754 m_free(pElement->u.u_headstyle.weight, wideCharacterString);
755 if (pElement->u.u_headstyle.slant)
756 m_free(pElement->u.u_headstyle.slant, wideCharacterString);
757 if (pElement->u.u_headstyle.special)
758 m_free(pElement->u.u_headstyle.special, wideCharacterString);
759 if (pElement->u.u_headstyle.l_margin)
760 m_free(pElement->u.u_headstyle.l_margin, wideCharacterString);
761 if (pElement->u.u_headstyle.r_margin)
762 m_free(pElement->u.u_headstyle.r_margin, wideCharacterString);
763 if (pElement->u.u_headstyle.t_margin)
764 m_free(pElement->u.u_headstyle.t_margin, wideCharacterString);
765 if (pElement->u.u_headstyle.b_margin)
766 m_free(pElement->u.u_headstyle.b_margin, wideCharacterString);
767 if (pElement->u.u_headstyle.border)
768 m_free(pElement->u.u_headstyle.border, wideCharacterString);
769 if (pElement->u.u_headstyle.vjust)
770 m_free(pElement->u.u_headstyle.vjust, wideCharacterString);
771 if (pElement->u.u_headstyle.justify)
772 m_free(pElement->u.u_headstyle.justify, wideCharacterString);
775 if (pElement->u.u_formstyle.class)
776 m_free(pElement->u.u_formstyle.class, wideCharacterString);
777 if (pElement->u.u_formstyle.ssi)
778 m_free(pElement->u.u_formstyle.ssi, wideCharacterString);
779 if (pElement->u.u_formstyle.rlevel)
780 m_free(pElement->u.u_formstyle.rlevel, wideCharacterString);
781 if (pElement->u.u_formstyle.phrase)
782 m_free(pElement->u.u_formstyle.phrase, wideCharacterString);
783 if (pElement->u.u_formstyle.srch_wt)
784 m_free(pElement->u.u_formstyle.srch_wt, wideCharacterString);
785 if (pElement->u.u_formstyle.colw)
786 m_free(pElement->u.u_formstyle.colw, wideCharacterString);
787 if (pElement->u.u_formstyle.colj)
788 m_free(pElement->u.u_formstyle.colj, wideCharacterString);
789 if (pElement->u.u_formstyle.pointsz)
790 m_free(pElement->u.u_formstyle.pointsz, wideCharacterString);
791 if (pElement->u.u_formstyle.set_width)
792 m_free(pElement->u.u_formstyle.set_width, wideCharacterString);
793 if (pElement->u.u_formstyle.color)
794 m_free(pElement->u.u_formstyle.color, wideCharacterString);
795 if (pElement->u.u_formstyle.xlfd)
796 m_free(pElement->u.u_formstyle.xlfd, wideCharacterString);
797 if (pElement->u.u_formstyle.xlfdi)
798 m_free(pElement->u.u_formstyle.xlfdi, wideCharacterString);
799 if (pElement->u.u_formstyle.xlfdb)
800 m_free(pElement->u.u_formstyle.xlfdb, wideCharacterString);
801 if (pElement->u.u_formstyle.xlfdib)
802 m_free(pElement->u.u_formstyle.xlfdib, wideCharacterString);
803 if (pElement->u.u_formstyle.typenam)
804 m_free(pElement->u.u_formstyle.typenam, wideCharacterString);
805 if (pElement->u.u_formstyle.typenami)
806 m_free(pElement->u.u_formstyle.typenami, wideCharacterString);
807 if (pElement->u.u_formstyle.typenamb)
808 m_free(pElement->u.u_formstyle.typenamb, wideCharacterString);
809 if (pElement->u.u_formstyle.typenamib)
810 m_free(pElement->u.u_formstyle.typenamib, wideCharacterString);
811 if (pElement->u.u_formstyle.style)
812 m_free(pElement->u.u_formstyle.style, wideCharacterString);
813 if (pElement->u.u_formstyle.spacing)
814 m_free(pElement->u.u_formstyle.spacing, wideCharacterString);
815 if (pElement->u.u_formstyle.weight)
816 m_free(pElement->u.u_formstyle.weight, wideCharacterString);
817 if (pElement->u.u_formstyle.slant)
818 m_free(pElement->u.u_formstyle.slant, wideCharacterString);
819 if (pElement->u.u_formstyle.special)
820 m_free(pElement->u.u_formstyle.special, wideCharacterString);
821 if (pElement->u.u_formstyle.l_margin)
822 m_free(pElement->u.u_formstyle.l_margin, wideCharacterString);
823 if (pElement->u.u_formstyle.r_margin)
824 m_free(pElement->u.u_formstyle.r_margin, wideCharacterString);
825 if (pElement->u.u_formstyle.t_margin)
826 m_free(pElement->u.u_formstyle.t_margin, wideCharacterString);
827 if (pElement->u.u_formstyle.b_margin)
828 m_free(pElement->u.u_formstyle.b_margin, wideCharacterString);
829 if (pElement->u.u_formstyle.border)
830 m_free(pElement->u.u_formstyle.border, wideCharacterString);
831 if (pElement->u.u_formstyle.vjust)
832 m_free(pElement->u.u_formstyle.vjust, wideCharacterString);
835 if (pElement->u.u_frmtstyle.class)
836 m_free(pElement->u.u_frmtstyle.class, wideCharacterString);
837 if (pElement->u.u_frmtstyle.ssi)
838 m_free(pElement->u.u_frmtstyle.ssi, wideCharacterString);
839 if (pElement->u.u_frmtstyle.rlevel)
840 m_free(pElement->u.u_frmtstyle.rlevel, wideCharacterString);
841 if (pElement->u.u_frmtstyle.phrase)
842 m_free(pElement->u.u_frmtstyle.phrase, wideCharacterString);
843 if (pElement->u.u_frmtstyle.f_margin)
844 m_free(pElement->u.u_frmtstyle.f_margin, wideCharacterString);
845 if (pElement->u.u_frmtstyle.srch_wt)
846 m_free(pElement->u.u_frmtstyle.srch_wt, wideCharacterString);
847 if (pElement->u.u_frmtstyle.pointsz)
848 m_free(pElement->u.u_frmtstyle.pointsz, wideCharacterString);
849 if (pElement->u.u_frmtstyle.set_width)
850 m_free(pElement->u.u_frmtstyle.set_width, wideCharacterString);
851 if (pElement->u.u_frmtstyle.color)
852 m_free(pElement->u.u_frmtstyle.color, wideCharacterString);
853 if (pElement->u.u_frmtstyle.xlfd)
854 m_free(pElement->u.u_frmtstyle.xlfd, wideCharacterString);
855 if (pElement->u.u_frmtstyle.xlfdi)
856 m_free(pElement->u.u_frmtstyle.xlfdi, wideCharacterString);
857 if (pElement->u.u_frmtstyle.xlfdb)
858 m_free(pElement->u.u_frmtstyle.xlfdb, wideCharacterString);
859 if (pElement->u.u_frmtstyle.xlfdib)
860 m_free(pElement->u.u_frmtstyle.xlfdib, wideCharacterString);
861 if (pElement->u.u_frmtstyle.typenam)
862 m_free(pElement->u.u_frmtstyle.typenam, wideCharacterString);
863 if (pElement->u.u_frmtstyle.typenami)
864 m_free(pElement->u.u_frmtstyle.typenami, wideCharacterString);
865 if (pElement->u.u_frmtstyle.typenamb)
866 m_free(pElement->u.u_frmtstyle.typenamb, wideCharacterString);
867 if (pElement->u.u_frmtstyle.typenamib)
868 m_free(pElement->u.u_frmtstyle.typenamib, wideCharacterString);
869 if (pElement->u.u_frmtstyle.style)
870 m_free(pElement->u.u_frmtstyle.style, wideCharacterString);
871 if (pElement->u.u_frmtstyle.spacing)
872 m_free(pElement->u.u_frmtstyle.spacing, wideCharacterString);
873 if (pElement->u.u_frmtstyle.weight)
874 m_free(pElement->u.u_frmtstyle.weight, wideCharacterString);
875 if (pElement->u.u_frmtstyle.slant)
876 m_free(pElement->u.u_frmtstyle.slant, wideCharacterString);
877 if (pElement->u.u_frmtstyle.special)
878 m_free(pElement->u.u_frmtstyle.special, wideCharacterString);
879 if (pElement->u.u_frmtstyle.l_margin)
880 m_free(pElement->u.u_frmtstyle.l_margin, wideCharacterString);
881 if (pElement->u.u_frmtstyle.r_margin)
882 m_free(pElement->u.u_frmtstyle.r_margin, wideCharacterString);
883 if (pElement->u.u_frmtstyle.t_margin)
884 m_free(pElement->u.u_frmtstyle.t_margin, wideCharacterString);
885 if (pElement->u.u_frmtstyle.b_margin)
886 m_free(pElement->u.u_frmtstyle.b_margin, wideCharacterString);
887 if (pElement->u.u_frmtstyle.border)
888 m_free(pElement->u.u_frmtstyle.border, wideCharacterString);
889 if (pElement->u.u_frmtstyle.vjust)
890 m_free(pElement->u.u_frmtstyle.vjust, wideCharacterString);
891 if (pElement->u.u_frmtstyle.justify)
892 m_free(pElement->u.u_frmtstyle.justify, wideCharacterString);
895 if (pElement->u.u_grphstyle.class)
896 m_free(pElement->u.u_grphstyle.class, wideCharacterString);
897 if (pElement->u.u_grphstyle.ssi)
898 m_free(pElement->u.u_grphstyle.ssi, wideCharacterString);
899 if (pElement->u.u_grphstyle.rlevel)
900 m_free(pElement->u.u_grphstyle.rlevel, wideCharacterString);
901 if (pElement->u.u_grphstyle.phrase)
902 m_free(pElement->u.u_grphstyle.phrase, wideCharacterString);
903 if (pElement->u.u_grphstyle.l_margin)
904 m_free(pElement->u.u_grphstyle.l_margin, wideCharacterString);
905 if (pElement->u.u_grphstyle.r_margin)
906 m_free(pElement->u.u_grphstyle.r_margin, wideCharacterString);
907 if (pElement->u.u_grphstyle.t_margin)
908 m_free(pElement->u.u_grphstyle.t_margin, wideCharacterString);
909 if (pElement->u.u_grphstyle.b_margin)
910 m_free(pElement->u.u_grphstyle.b_margin, wideCharacterString);
911 if (pElement->u.u_grphstyle.border)
912 m_free(pElement->u.u_grphstyle.border, wideCharacterString);
913 if (pElement->u.u_grphstyle.vjust)
914 m_free(pElement->u.u_grphstyle.vjust, wideCharacterString);
915 if (pElement->u.u_grphstyle.justify)
916 m_free(pElement->u.u_grphstyle.justify, wideCharacterString);
920 "internal error - unrecognized element type in DeleteElement");
921 if (m_errfile && (m_errfile != stderr))
923 "internal error - unrecognized element type in DeleteElement");
926 mb_free((char **) &pElement);
930 static ElementPtr *currentElementStack;
931 static int currentElementStackSize = 0;
932 static int currentElementStackTop = -1;
934 void PushCurrentElement()
936 currentElementStackTop++;
937 if (currentElementStackSize == 0)
939 currentElementStack =
940 (ElementPtr *) mb_malloc(100 * sizeof(ElementPtr *));
941 currentElementStackSize = 100;
943 else if (currentElementStackTop == currentElementStackSize)
945 currentElementStackSize += 100;
946 currentElementStack =
947 (ElementPtr *) mb_realloc((char *) currentElementStack,
948 currentElementStackSize * sizeof(ElementPtr *));
950 currentElementStack[currentElementStackTop] = pCurrentElement;
954 static ElementPtr *thisElementStack;
955 static int thisElementStackSize = 0;
956 static int thisElementStackTop = -1;
959 static void PushThisElement(ElementPtr pThis)
961 static void PushThisElement(pThis)
965 thisElementStackTop++;
966 if (thisElementStackSize == 0)
969 (ElementPtr *) mb_malloc(100 * sizeof(ElementPtr *));
970 thisElementStackSize = 100;
972 else if (thisElementStackTop == thisElementStackSize)
974 thisElementStackSize += 100;
976 (ElementPtr *) mb_realloc((char *) thisElementStack,
977 thisElementStackSize * sizeof(ElementPtr *));
979 thisElementStack[thisElementStackTop] = pThis;
983 void PopCurrentElement()
985 pCurrentElement = currentElementStack[currentElementStackTop];
986 if (currentElementStackTop < 0)
988 fprintf(stderr, "internal error - stack underflow in PopCurrentElement");
989 if (m_errfile && (m_errfile != stderr))
991 "internal error - stack underflow in PopCurrentElement");
995 --currentElementStackTop;
999 static ElementPtr PopThisElement()
1001 ElementPtr pThisElement;
1003 pThisElement = thisElementStack[thisElementStackTop];
1004 if (thisElementStackTop < 0)
1006 fprintf(stderr, "internal error - stack underflow in PopThisElement");
1007 if (m_errfile && (m_errfile != stderr))
1009 "internal error - stack underflow in PopThisElement");
1013 --thisElementStackTop;
1014 return pThisElement;
1019 * A routine to remove occurrences of <BLOCK>\n</BLOCK>, if any, from
1020 * the .sdl file. These occurrences are an artifact of translation
1021 * and seem to be easier to get rid of here than in the first pass.
1023 #if defined(M_PROTO)
1024 static void RemoveSuperfluousBlocks(ElementPtr *ppBlockOrForm)
1026 static void RemoveSuperfluousBlocks(ppBlockOrForm)
1027 ElementPtr *ppBlockOrForm;
1030 ElementPtr pElement, pFdata;
1033 if (!(pElement = *ppBlockOrForm))
1036 ppBack = ppBlockOrForm;
1039 if (pElement->type == e_form)
1041 if (pFdata = pElement->u.u_form.pFdata)
1042 RemoveSuperfluousBlocks(&(pFdata->u.u_fdata.pBlockOrForm));
1044 else if (!pElement->u.u_block.level &&
1045 !pElement->u.u_block.version &&
1046 !pElement->u.u_block.class &&
1047 !pElement->u.u_block.language &&
1048 !pElement->u.u_block.charset &&
1049 !pElement->u.u_block.length &&
1050 !pElement->u.u_block.app &&
1051 !pElement->u.u_block.timing &&
1052 !pElement->u.u_block.ssi &&
1053 !pElement->u.u_block.pHead &&
1054 !pElement->u.u_block.pCpOrP)
1056 *ppBack = pElement->pNext;
1057 DeleteElement(pElement);
1061 ppBack = &(pElement->pNext);
1062 pElement = pElement->pNext;
1067 #if defined(M_PROTO)
1068 static void ReplaceFormWithBlock(ElementPtr *ppBlockOrForm)
1070 static void ReplaceFormWithBlock(ppBlockOrForm)
1071 ElementPtr ppBlockOrForm;
1074 ElementPtr pElement, pFstyle, pFrowvec, pFdata, pSubElement;
1076 M_WCHAR *pId, *wc_sdlReservedName, *wc_quote1;
1078 if (!(pElement = *ppBlockOrForm))
1081 wc_sdlReservedName = MakeWideCharString(sdlReservedName);
1082 wc_quote1 = MakeWideCharString("\"1\"");
1084 ppBack = ppBlockOrForm;
1087 if (pElement->type != e_form)
1089 ppBack = &(pElement->pNext);
1090 pElement = pElement->pNext;
1093 if (!(pFdata = pElement->u.u_form.pFdata))
1094 { /* illegal <form> */
1095 ppBack = &(pElement->pNext);
1096 pElement = pElement->pNext;
1099 ReplaceFormWithBlock(&(pFdata->u.u_fdata.pBlockOrForm));
1100 if ((pFstyle = pElement->u.u_form.pFstyle) &&
1101 (pFrowvec = pFstyle->u.u_fstyle.pFrowvec) &&
1103 (!pFstyle->u.u_fstyle.ncols || !w_strcmp(pFstyle->u.u_fstyle.ncols,
1105 { /* found a <form> containing only one element */
1106 if (((pSubElement = pFdata->u.u_fdata.pBlockOrForm)->type == e_form))
1108 if (!pSubElement->u.u_form.level &&
1109 !pSubElement->u.u_form.version &&
1110 !pSubElement->u.u_form.class &&
1111 !pSubElement->u.u_form.language &&
1112 !pSubElement->u.u_form.charset &&
1113 !pSubElement->u.u_form.length &&
1114 !pSubElement->u.u_form.app &&
1115 !pSubElement->u.u_form.ssi)
1117 if ((pId = pSubElement->u.u_form.id) &&
1118 w_strncmp(pId, wc_sdlReservedName, SDLNAMESIZ-1))
1119 { /* user supplied id */
1120 ppBack = &(pElement->pNext);
1121 pElement = pElement->pNext;
1124 if (pElement->u.u_form.pHead)
1126 if (pSubElement->u.u_form.pHead)
1128 ppBack = &(pElement->pNext);
1129 pElement = pElement->pNext;
1134 pSubElement->u.u_form.pHead =
1135 pElement->u.u_form.pHead;
1136 pElement->u.u_form.pHead = NULL;
1140 m_free(pId, wideCharacterString);
1141 *ppBack = pSubElement;
1142 pSubElement->pNext = pElement->pNext;
1143 pSubElement->u.u_form.id = pElement->u.u_form.id;
1144 pSubElement->u.u_form.level = pElement->u.u_form.level;
1145 pSubElement->u.u_form.version = pElement->u.u_form.version;
1146 pSubElement->u.u_form.class = pElement->u.u_form.class;
1147 pSubElement->u.u_form.language = pElement->u.u_form.language;
1148 pSubElement->u.u_form.charset = pElement->u.u_form.charset;
1149 pSubElement->u.u_form.length = pElement->u.u_form.length;
1150 pSubElement->u.u_form.app = pElement->u.u_form.app;
1151 pSubElement->u.u_form.ssi = pElement->u.u_form.ssi;
1152 pElement->u.u_form.id = NULL;
1153 pElement->u.u_form.level = NULL;
1154 pElement->u.u_form.version = NULL;
1155 pElement->u.u_form.class = NULL;
1156 pElement->u.u_form.language = NULL;
1157 pElement->u.u_form.charset = NULL;
1158 pElement->u.u_form.length = NULL;
1159 pElement->u.u_form.app = NULL;
1160 pElement->u.u_form.ssi = NULL;
1161 DeleteElement(pFstyle);
1162 DeleteElement(pFrowvec);
1163 DeleteElement(pFdata);
1167 ppBack = &(pElement->pNext);
1168 pElement = pElement->pNext;
1174 if (!pSubElement->u.u_block.level &&
1175 !pSubElement->u.u_block.version &&
1176 !pSubElement->u.u_block.class &&
1177 !pSubElement->u.u_block.language &&
1178 !pSubElement->u.u_block.charset &&
1179 !pSubElement->u.u_block.length &&
1180 !pSubElement->u.u_block.app &&
1181 !pSubElement->u.u_block.timing &&
1182 !pSubElement->u.u_block.ssi)
1184 if ((pId = pSubElement->u.u_block.id) &&
1185 w_strncmp(pId, wc_sdlReservedName, SDLNAMESIZ-1))
1186 { /* user supplied id */
1187 ppBack = &(pElement->pNext);
1188 pElement = pElement->pNext;
1191 if (pElement->u.u_form.pHead)
1193 if (pSubElement->u.u_block.pHead)
1195 ppBack = &(pElement->pNext);
1196 pElement = pElement->pNext;
1201 pSubElement->u.u_block.pHead =
1202 pElement->u.u_form.pHead;
1203 pElement->u.u_form.pHead = NULL;
1207 m_free(pId, wideCharacterString);
1208 *ppBack = pSubElement;
1209 pSubElement->pNext = pElement->pNext;
1210 pSubElement->u.u_block.id = pElement->u.u_form.id;
1211 pSubElement->u.u_block.level = pElement->u.u_form.level;
1212 pSubElement->u.u_block.version = pElement->u.u_form.version;
1213 pSubElement->u.u_block.class = pElement->u.u_form.class;
1214 pSubElement->u.u_block.language = pElement->u.u_form.language;
1215 pSubElement->u.u_block.charset = pElement->u.u_form.charset;
1216 pSubElement->u.u_block.length = pElement->u.u_form.length;
1217 pSubElement->u.u_block.app = pElement->u.u_form.app;
1218 pSubElement->u.u_block.timing = NULL;
1219 pSubElement->u.u_block.ssi = pElement->u.u_form.ssi;
1220 pElement->u.u_form.id = NULL;
1221 pElement->u.u_form.level = NULL;
1222 pElement->u.u_form.version = NULL;
1223 pElement->u.u_form.class = NULL;
1224 pElement->u.u_form.language = NULL;
1225 pElement->u.u_form.charset = NULL;
1226 pElement->u.u_form.length = NULL;
1227 pElement->u.u_form.app = NULL;
1228 pElement->u.u_form.ssi = NULL;
1229 DeleteElement(pFstyle);
1230 DeleteElement(pFrowvec);
1231 DeleteElement(pFdata);
1235 ppBack = &(pElement->pNext);
1236 pElement = pElement->pNext;
1240 ppBack = &(pSubElement->pNext);
1241 pSubElement = pElement->pNext;
1242 *ppBack = pSubElement;
1243 DeleteElement(pElement);
1244 pElement = pSubElement;
1247 ppBack = &(pElement->pNext);
1248 pElement = pElement->pNext;
1251 m_free(wc_sdlReservedName, wideCharacterString);
1252 m_free(wc_quote1, wideCharacterString);
1256 #if defined(M_PROTO)
1257 static void OptimizeSDL(ElementPtr *ppBlockOrForm)
1259 static void OptimizeSDL(ppBlockOrForm)
1260 ElementPtr ppBlockOrForm;
1263 ReplaceFormWithBlock(ppBlockOrForm);
1264 RemoveSuperfluousBlocks(ppBlockOrForm);
1268 /* build a linked list of the LOIDS, we'll need to postprocess it to
1269 * update the offsets when adding the INDEX and LOIDS; also when
1270 * compressing the VSTRUCT
1272 #if defined(M_PROTO)
1273 static void AddToLOIDS(char *pElementName,
1277 long int virpageOffset)
1279 static void AddToLOIDS(pElementName, pwcId, pwcSSI, pwcLevel, virpageOffset)
1284 long int virpageOffset;
1293 virpageOffset += vstructSize;
1295 pNewId = (LoidsPtr) mb_malloc(sizeof(LoidsRec));
1297 pNewId->type = mb_malloc(strlen(pElementName)+1);
1298 strcpy(pNewId->type, pElementName);
1299 pNewId->rid = MakeMByteString(pwcId);
1301 pNewId->rssi = MakeMByteString(pwcSSI);
1303 pNewId->rssi = NULL;
1305 pNewId->rlevel = MakeMByteString(pwcLevel);
1307 pNewId->rlevel = NULL;
1308 pNewId->offset = virpageOffset;
1309 pNewId->next = NULL;
1311 pLoidsEnd->next = pNewId;
1316 /* compress or decompress a file; return the size after (de)compression
1318 #if defined(M_PROTO)
1319 static int Compress(char *fileName, char *zFileName, LOGICAL doCompress)
1321 int Compress(fileName, zFileName, doCompress)
1330 static char sysStr[] = "system()";
1333 sprintf(cmd, "compress -f < %s > %s", fileName, zFileName);
1335 sprintf(cmd, "compress -d < %s > %s", zFileName, fileName);
1336 errStatus = system(cmd);
1339 fprintf(stderr, "%s: error executing \"%s\"\n", progName, cmd);
1340 if (m_errfile && (m_errfile != stderr))
1341 fprintf(m_errfile, "%s: error executing \"%s\"\n", progName, cmd);
1342 if (errStatus == -1)
1345 if (m_errfile && (m_errfile != stderr))
1346 fprintf(m_errfile, "%s: %s", sysStr, strerror(errno));
1350 if (WIFEXITED(errStatus))
1352 if ((errCode = WEXITSTATUS(errStatus)) == 127)
1357 "error executing command language interpreter");
1358 if (m_errfile && (m_errfile != stderr))
1362 "error executing command language interpreter");
1366 fprintf(stderr, "%s: exited with status %d\n", cmd, errCode);
1367 if (m_errfile && (m_errfile != stderr))
1369 "%s: exited with status %d\n",
1374 else if (WIFSIGNALED(errStatus))
1376 errCode = WTERMSIG(errStatus);
1377 fprintf(stderr, "%s: exited due to signal %d\n", cmd, errCode);
1378 if (m_errfile && (m_errfile != stderr))
1380 "%s: exited due to signal %d\n",
1383 if (WCOREDUMP(errStatus))
1385 fputs("core dumped\n", stderr);
1386 if (m_errfile && (m_errfile != stderr))
1387 fputs("core dumped\n", m_errfile);
1390 else if (WIFSTOPPED(errStatus))
1392 errCode = WSTOPSIG(errStatus);
1393 fprintf(stderr, "%s: stopped due to signal %d\n", cmd, errCode);
1394 if (m_errfile && (m_errfile != stderr))
1396 "%s: stopped due to signal %d\n",
1404 return FileSize(zFileName, xxx);
1406 return FileSize(fileName, xxx);
1410 /* decompress an SDL file */
1411 static void DecompressSDL()
1416 unsigned char buffer[BUFSIZ];
1418 inFile = FopenFile(inFileName, O_RDONLY, xxx);
1419 outFd = OpenFile(tempFileName, O_WRONLY, xxx);
1421 length = FreadFile(inFile, inFileName, (char *) buffer, 4, xxx);
1424 fprintf(stderr, "%s: premature end of %s\n", progName, inFileName);
1425 if (m_errfile && (m_errfile != stderr))
1428 "%s: premature end of %s\n",
1435 if (*buffer) /* file isn't compressed */
1437 length += FreadFile(inFile, inFileName, (char *) (buffer+4), BUFSIZ-4, xxx);
1439 WriteFile(outFd, tempFileName, (char *) buffer, length, xxx);
1440 length = FreadFile(inFile, inFileName, (char *) buffer, BUFSIZ, xxx);
1443 FcloseFile(inFile, inFileName, xxx);
1444 CloseFile(outFd, tempFileName, xxx);
1455 unlink(compZFileName);
1456 zFd = OpenFile(compZFileName, O_WRONLY, xxx);
1457 while (length = FreadFile(inFile,
1463 WriteFile(zFd, compZFileName, (char *) buffer, length, xxx);
1468 fprintf(stderr, "%s: premature end of %s\n", progName, inFileName);
1469 if (m_errfile && (m_errfile != stderr))
1472 "%s: premature end of %s\n",
1478 CloseFile(zFd, compZFileName, xxx);
1479 delta = Compress(compFileName, compZFileName, FALSE);
1480 zFd = OpenFile(compFileName, O_RDONLY, xxx);
1481 while (length = ReadFile(zFd,
1487 WriteFile(outFd, tempFileName, (char *) buffer, length, xxx);
1492 fprintf(stderr, "%s: premature end of %s\n", progName, compFileName);
1493 if (m_errfile && (m_errfile != stderr))
1496 "%s: premature end of %s\n",
1502 CloseFile(zFd, compFileName, xxx);
1503 while ((delta = FreadFile(inFile,
1507 xxx)) && (*buffer == 0xff));
1510 if (*buffer == '<') /* we're at the end, "</SDLDOC>\n" */
1512 delta += FreadFile(inFile,
1514 (char *) (buffer + 1),
1518 delta = 1; /* force a premature end of document */
1521 WriteFile(outFd, tempFileName, (char *) buffer, delta, xxx);
1526 delta += FreadFile(inFile,
1528 (char *) (buffer + 1),
1536 fprintf(stderr, "%s: premature end of %s\n", progName, inFileName);
1537 if (m_errfile && (m_errfile != stderr))
1540 "%s: premature end of %s\n",
1546 FcloseFile(inFile, inFileName, xxx);
1547 CloseFile(outFd, tempFileName, xxx);
1548 unlink(compFileName);
1549 unlink(compZFileName);
1553 /* A function too lookup a TOSS element and mark it as used if the
1556 #if defined(M_PROTO)
1557 static void MarkUsedStyle(M_WCHAR *level, M_WCHAR *class, M_WCHAR *ssi)
1559 static void MarkUsedStyle(level, class, ssi)
1566 M_WCHAR *rlevel = NULL, *rclass = NULL, *rssi = NULL;
1572 switch (pThis->type)
1575 rlevel = pThis->u.u_keystyle.rlevel;
1576 rclass = pThis->u.u_keystyle.class;
1577 rssi = pThis->u.u_keystyle.ssi;
1578 pBeenUsed = &pThis->u.u_keystyle.beenUsed;
1581 rlevel = pThis->u.u_headstyle.rlevel;
1582 rclass = pThis->u.u_headstyle.class;
1583 rssi = pThis->u.u_headstyle.ssi;
1584 pBeenUsed = &pThis->u.u_headstyle.beenUsed;
1587 rlevel = pThis->u.u_formstyle.rlevel;
1588 rclass = pThis->u.u_formstyle.class;
1589 rssi = pThis->u.u_formstyle.ssi;
1590 pBeenUsed = &pThis->u.u_formstyle.beenUsed;
1593 rlevel = pThis->u.u_frmtstyle.rlevel;
1594 rclass = pThis->u.u_frmtstyle.class;
1595 rssi = pThis->u.u_frmtstyle.ssi;
1596 pBeenUsed = &pThis->u.u_frmtstyle.beenUsed;
1599 rlevel = pThis->u.u_grphstyle.rlevel;
1600 rclass = pThis->u.u_grphstyle.class;
1601 rssi = pThis->u.u_grphstyle.ssi;
1602 pBeenUsed = &pThis->u.u_grphstyle.beenUsed;
1605 if ((!rlevel || (w_strcmp(rlevel, level) == 0)) &&
1606 (!rssi || (w_strcmp(rssi, ssi) == 0)) &&
1607 (w_strcmp(rclass, class) == 0))
1609 if (*pBeenUsed == FALSE)
1613 pThis->beenEmitted = FALSE;
1617 pThis = pThis->pNext;
1622 /* Look for "rid" in the "pSnb" list. Return the element if found,
1625 #if defined(M_PROTO)
1626 static ElementPtr LookupInSnb(ElementPtr pSnb, M_WCHAR *rid)
1628 static ElementPtr LookupInSnb(pSnb, rid)
1635 static char errMess[] =
1636 "internal error - unrecognized element type in LookupInSnb";
1638 if (!pSnb) return NULL;
1640 pThis = pSnb->u.u_snb.pSystemNotations;
1644 switch (pThis->type)
1647 pId = &pThis->u.u_graphic.id;
1650 pId = &pThis->u.u_text.id;
1653 pId = &pThis->u.u_audio.id;
1656 pId = &pThis->u.u_video.id;
1659 pId = &pThis->u.u_animate.id;
1662 pId = &pThis->u.u_script.id;
1665 pId = &pThis->u.u_crossdoc.id;
1668 pId = &pThis->u.u_man_page.id;
1671 pId = &pThis->u.u_textfile.id;
1674 pId = &pThis->u.u_sys_cmd.id;
1677 pId = &pThis->u.u_callback.id;
1680 pId = &pThis->u.u_switch.id;
1683 fprintf(stderr, "%s\n", errMess);
1684 if (m_errfile && (m_errfile != stderr))
1685 fprintf(m_errfile, "%s\n", errMess);
1688 if (w_strcmp(rid, *pId) == 0) return pThis;
1689 pThis = pThis->pNext;
1695 /* Clear the tossChecked field in the nodes of a sub-tree starting at
1696 * (and including) the element passed in. The assumption is that all
1697 * nodes in the sub-tree are either marked or all clear. Once a clear
1698 * node is found, the tree is not descended further.
1700 #if defined(M_PROTO)
1701 static void ClearTree(ElementPtr pRoot)
1703 static void ClearTree(pRoot)
1708 static char errMess[] =
1709 "internal error - unrecognized element type in ClearTree";
1715 switch (pThis->type)
1718 pThis->tossChecked = FALSE;
1719 if (pThis->u.u_sdldoc.pHead &&
1720 pThis->u.u_sdldoc.pHead->tossChecked)
1722 PushThisElement(pThis);
1723 pThis = pThis->u.u_sdldoc.pHead;
1726 if (pThis->u.u_sdldoc.pSnb &&
1727 pThis->u.u_sdldoc.pSnb->tossChecked)
1729 PushThisElement(pThis);
1730 pThis = pThis->u.u_sdldoc.pSnb;
1736 pThis->tossChecked = FALSE;
1737 if (pThis->u.u_virpage.pHead &&
1738 pThis->u.u_virpage.pHead->tossChecked)
1740 PushThisElement(pThis);
1741 pThis = pThis->u.u_virpage.pHead;
1744 if (pThis->u.u_virpage.pSnb &&
1745 pThis->u.u_virpage.pSnb->tossChecked)
1747 PushThisElement(pThis);
1748 pThis = pThis->u.u_virpage.pSnb;
1751 if (pThis->u.u_virpage.pBlockOrForm &&
1752 pThis->u.u_virpage.pBlockOrForm->tossChecked)
1754 PushThisElement(pThis);
1755 pThis = pThis->u.u_virpage.pBlockOrForm;
1760 pThis = pThis->pNext;
1766 pThis->tossChecked = FALSE;
1767 if (pThis->u.u_snb.pHead &&
1768 pThis->u.u_snb.pHead->tossChecked)
1770 PushThisElement(pThis);
1771 pThis = pThis->u.u_virpage.pHead;
1774 if (pThis->u.u_snb.pSystemNotations)
1776 PushThisElement(pThis);
1777 pThis = pThis->u.u_snb.pSystemNotations;
1782 pThis = pThis->pNext;
1785 pThis = PopThisElement();
1788 pThis->tossChecked = FALSE;
1789 if (pThis->u.u_block.pHead &&
1790 pThis->u.u_block.pHead->tossChecked)
1792 PushThisElement(pThis);
1793 pThis = pThis->u.u_block.pHead;
1796 if (pThis->u.u_block.pCpOrP &&
1797 pThis->u.u_block.pCpOrP->tossChecked)
1799 PushThisElement(pThis);
1800 pThis = pThis->u.u_block.pCpOrP;
1805 pThis = pThis->pNext;
1808 pThis = PopThisElement();
1811 pThis->tossChecked = FALSE;
1812 if (pThis->u.u_form.pHead &&
1813 pThis->u.u_form.pHead->tossChecked)
1815 PushThisElement(pThis);
1816 pThis = pThis->u.u_form.pHead;
1819 if (pThis->u.u_form.pFdata &&
1820 pThis->u.u_form.pFdata->tossChecked)
1822 PushThisElement(pThis);
1823 pThis = pThis->u.u_form.pFdata;
1826 if (pThis->u.u_form.pFstyle &&
1827 pThis->u.u_form.pFstyle->tossChecked)
1829 PushThisElement(pThis);
1830 pThis = pThis->u.u_form.pFstyle;
1835 pThis = pThis->pNext;
1838 pThis = PopThisElement();
1841 pThis->tossChecked = FALSE;
1842 if (pThis->u.u_fstyle.pFrowvec &&
1843 pThis->u.u_fstyle.pFrowvec->tossChecked)
1845 PushThisElement(pThis);
1846 pThis = pThis->u.u_fstyle.pFrowvec;
1851 pThis = pThis->pNext;
1854 pThis = PopThisElement();
1857 pThis->tossChecked = FALSE;
1860 pThis = pThis->pNext;
1863 pThis = PopThisElement();
1866 pThis->tossChecked = FALSE;
1867 if (pThis->u.u_fdata.pBlockOrForm &&
1868 pThis->u.u_fdata.pBlockOrForm->tossChecked)
1870 PushThisElement(pThis);
1871 pThis = pThis->u.u_fdata.pBlockOrForm;
1876 pThis = pThis->pNext;
1879 pThis = PopThisElement();
1882 pThis->tossChecked = FALSE;
1883 if (pThis->u.u_p.pHead &&
1884 pThis->u.u_p.pHead->tossChecked)
1886 PushThisElement(pThis);
1887 pThis = pThis->u.u_p.pHead;
1890 if (pThis->u.u_p.pAtomicOrPCDATA &&
1891 pThis->u.u_p.pAtomicOrPCDATA->tossChecked)
1893 PushThisElement(pThis);
1894 pThis = pThis->u.u_p.pAtomicOrPCDATA;
1899 pThis = pThis->pNext;
1902 pThis = PopThisElement();
1905 pThis->tossChecked = FALSE;
1906 if (pThis->u.u_cp.pCDATA &&
1907 pThis->u.u_cp.pCDATA->tossChecked)
1909 PushThisElement(pThis);
1910 pThis = pThis->u.u_cp.pCDATA;
1915 pThis = pThis->pNext;
1918 pThis = PopThisElement();
1921 pThis->tossChecked = FALSE;
1922 if (pThis->u.u_head.pAtomicOrPCDATA &&
1923 pThis->u.u_head.pAtomicOrPCDATA->tossChecked)
1925 PushThisElement(pThis);
1926 pThis = pThis->u.u_head.pAtomicOrPCDATA;
1929 if (pThis->u.u_head.pSubhead &&
1930 pThis->u.u_head.pSubhead->tossChecked)
1932 PushThisElement(pThis);
1933 pThis = pThis->u.u_head.pSubhead;
1938 pThis = pThis->pNext;
1941 pThis = PopThisElement();
1944 pThis->tossChecked = FALSE;
1945 if (pThis->u.u_subhead.pAtomicOrPCDATA &&
1946 pThis->u.u_subhead.pAtomicOrPCDATA->tossChecked)
1948 PushThisElement(pThis);
1949 pThis = pThis->u.u_subhead.pAtomicOrPCDATA;
1954 pThis = pThis->pNext;
1957 pThis = PopThisElement();
1960 pThis->tossChecked = FALSE;
1963 pThis = pThis->pNext;
1966 pThis = PopThisElement();
1969 pThis->tossChecked = FALSE;
1970 if (pThis->u.u_link.pAtomicOrPCDATA &&
1971 pThis->u.u_link.pAtomicOrPCDATA->tossChecked)
1973 PushThisElement(pThis);
1974 pThis = pThis->u.u_link.pAtomicOrPCDATA;
1979 pThis = pThis->pNext;
1982 pThis = PopThisElement();
1985 pThis->tossChecked = FALSE;
1986 if (pThis->u.u_snref.pRefitem &&
1987 pThis->u.u_snref.pRefitem->tossChecked)
1989 PushThisElement(pThis);
1990 pThis = pThis->u.u_snref.pRefitem;
1993 if (pThis->u.u_snref.pAlttext &&
1994 pThis->u.u_snref.pAlttext->tossChecked)
1996 PushThisElement(pThis);
1997 pThis = pThis->u.u_snref.pAlttext;
2002 pThis = pThis->pNext;
2005 pThis = PopThisElement();
2008 pThis->tossChecked = FALSE;
2009 pThis->u.u_refitem.pReferencedItem = NULL;
2010 if (pThis->u.u_refitem.pHead &&
2011 pThis->u.u_refitem.pHead->tossChecked)
2013 PushThisElement(pThis);
2014 pThis = pThis->u.u_refitem.pHead;
2019 pThis = pThis->pNext;
2022 pThis = PopThisElement();
2025 pThis->tossChecked = FALSE;
2026 if (pThis->u.u_alttext.pCDATA &&
2027 pThis->u.u_alttext.pCDATA->tossChecked)
2029 PushThisElement(pThis);
2030 pThis = pThis->u.u_alttext.pCDATA;
2035 pThis = pThis->pNext;
2038 pThis = PopThisElement();
2041 pThis->tossChecked = FALSE;
2042 if (pThis->u.u_rev.pAtomicOrPCDATA &&
2043 pThis->u.u_rev.pAtomicOrPCDATA->tossChecked)
2045 PushThisElement(pThis);
2046 pThis = pThis->u.u_rev.pAtomicOrPCDATA;
2051 pThis = pThis->pNext;
2054 pThis = PopThisElement();
2057 pThis->tossChecked = FALSE;
2058 if (pThis->u.u_key.pAtomicOrPCDATA &&
2059 pThis->u.u_key.pAtomicOrPCDATA->tossChecked)
2061 PushThisElement(pThis);
2062 pThis = pThis->u.u_key.pAtomicOrPCDATA;
2067 pThis = pThis->pNext;
2070 pThis = PopThisElement();
2073 pThis->tossChecked = FALSE;
2074 if (pThis->u.u_sphrase.pSpcOrPCDATA &&
2075 pThis->u.u_sphrase.pSpcOrPCDATA->tossChecked)
2077 PushThisElement(pThis);
2078 pThis = pThis->u.u_sphrase.pSpcOrPCDATA;
2083 pThis = pThis->pNext;
2086 pThis = PopThisElement();
2089 pThis->tossChecked = FALSE;
2090 if (pThis->u.u_if.pCond &&
2091 pThis->u.u_if.pCond->tossChecked)
2093 PushThisElement(pThis);
2094 pThis = pThis->u.u_if.pCond;
2097 if (pThis->u.u_if.pThen &&
2098 pThis->u.u_if.pThen->tossChecked)
2100 PushThisElement(pThis);
2101 pThis = pThis->u.u_if.pThen;
2104 if (pThis->u.u_if.pElse &&
2105 pThis->u.u_if.pElse->tossChecked)
2107 PushThisElement(pThis);
2108 pThis = pThis->u.u_if.pElse;
2113 pThis = pThis->pNext;
2116 pThis = PopThisElement();
2119 pThis->tossChecked = FALSE;
2120 if (pThis->u.u_cond.pCDATA &&
2121 pThis->u.u_cond.pCDATA->tossChecked)
2123 PushThisElement(pThis);
2124 pThis = pThis->u.u_cond.pCDATA;
2129 pThis = pThis->pNext;
2132 pThis = PopThisElement();
2135 pThis->tossChecked = FALSE;
2136 if (pThis->u.u_then.pAtomicOrPCDATA &&
2137 pThis->u.u_then.pAtomicOrPCDATA->tossChecked)
2139 PushThisElement(pThis);
2140 pThis = pThis->u.u_then.pAtomicOrPCDATA;
2145 pThis = pThis->pNext;
2148 pThis = PopThisElement();
2151 pThis->tossChecked = FALSE;
2152 if (pThis->u.u_else.pAtomicOrPCDATA &&
2153 pThis->u.u_else.pAtomicOrPCDATA->tossChecked)
2155 PushThisElement(pThis);
2156 pThis = pThis->u.u_else.pAtomicOrPCDATA;
2161 pThis = pThis->pNext;
2164 pThis = PopThisElement();
2167 pThis->tossChecked = FALSE;
2170 pThis = pThis->pNext;
2173 pThis = PopThisElement();
2176 pThis->tossChecked = FALSE;
2179 pThis = pThis->pNext;
2182 pThis = PopThisElement();
2185 pThis->tossChecked = FALSE;
2186 if (pThis->u.u_text.pCpOrP &&
2187 pThis->u.u_text.pCpOrP->tossChecked)
2189 PushThisElement(pThis);
2190 pThis = pThis->u.u_text.pCpOrP;
2195 pThis = pThis->pNext;
2198 pThis = PopThisElement();
2201 pThis->tossChecked = FALSE;
2204 pThis = pThis->pNext;
2207 pThis = PopThisElement();
2210 pThis->tossChecked = FALSE;
2213 pThis = pThis->pNext;
2216 pThis = PopThisElement();
2219 pThis->tossChecked = FALSE;
2222 pThis = pThis->pNext;
2225 pThis = PopThisElement();
2228 pThis->tossChecked = FALSE;
2229 if (pThis->u.u_script.pCDATA &&
2230 pThis->u.u_script.pCDATA->tossChecked)
2232 PushThisElement(pThis);
2233 pThis = pThis->u.u_script.pCDATA;
2238 pThis = pThis->pNext;
2241 pThis = PopThisElement();
2244 pThis->tossChecked = FALSE;
2247 pThis = pThis->pNext;
2250 pThis = PopThisElement();
2253 pThis->tossChecked = FALSE;
2256 pThis = pThis->pNext;
2259 pThis = PopThisElement();
2262 pThis->tossChecked = FALSE;
2265 pThis = pThis->pNext;
2268 pThis = PopThisElement();
2271 pThis->tossChecked = FALSE;
2274 pThis = pThis->pNext;
2277 pThis = PopThisElement();
2280 pThis->tossChecked = FALSE;
2283 pThis = pThis->pNext;
2286 pThis = PopThisElement();
2289 pThis->tossChecked = FALSE;
2290 if (pThis->u.u_switch.pCDATA &&
2291 pThis->u.u_switch.pCDATA->tossChecked)
2293 PushThisElement(pThis);
2294 pThis = pThis->u.u_switch.pCDATA;
2299 pThis = pThis->pNext;
2302 pThis = PopThisElement();
2305 pThis->tossChecked = FALSE;
2308 pThis = pThis->pNext;
2311 pThis = PopThisElement();
2314 pThis->tossChecked = FALSE;
2315 if (pThis->u.u_entry.pSimpleOrPCDATA &&
2316 pThis->u.u_entry.pSimpleOrPCDATA->tossChecked)
2318 PushThisElement(pThis);
2319 pThis = pThis->u.u_entry.pSimpleOrPCDATA;
2322 if (pThis->u.u_entry.pEntry &&
2323 pThis->u.u_entry.pEntry->tossChecked)
2325 PushThisElement(pThis);
2326 pThis = pThis->u.u_entry.pEntry;
2331 pThis = pThis->pNext;
2334 pThis = PopThisElement();
2342 pThis = pThis->pNext;
2345 fprintf(stderr, "%s\n", errMess);
2346 if (m_errfile && (m_errfile != stderr))
2347 fprintf(m_errfile, "%s\n", errMess);
2354 /* A function to mark all elements in the TOSS that have been used
2355 * by the document up to this point.
2357 #if defined(M_PROTO)
2358 static void MarkUsedTOSS(ElementPtr pRoot)
2360 static void MarkUsedTOSS(pRoot)
2364 ElementPtr pParent, pSnb, pItem, pThis;
2365 static char errMess[] =
2366 "internal error - unrecognized element type in MarkUsedTOSS";
2373 switch (pThis->type)
2376 if (!pThis->tossChecked)
2378 pThis->tossChecked = TRUE;
2379 pSnb = pThis->u.u_sdldoc.pSnb;
2381 if (pThis->u.u_sdldoc.pHead &&
2382 !pThis->u.u_sdldoc.pHead->tossChecked)
2384 PushThisElement(pParent);
2386 PushThisElement(pThis);
2387 pThis = pThis->u.u_sdldoc.pHead;
2390 if (pThis->u.u_sdldoc.pSnb &&
2391 !pThis->u.u_sdldoc.pSnb->tossChecked)
2393 PushThisElement(pParent);
2395 PushThisElement(pThis);
2396 pThis = pThis->u.u_sdldoc.pSnb;
2402 if (!pThis->tossChecked)
2404 pThis->inheritedLevel = pThis->u.u_virpage.level;
2405 pThis->inheritedClass = MakeWideCharString("TEXT");
2406 MarkUsedStyle(pThis->inheritedLevel,
2407 pThis->inheritedClass,
2408 pThis->u.u_virpage.ssi);
2409 pThis->tossChecked = TRUE;
2410 pSnb = pThis->u.u_virpage.pSnb;
2412 if (pThis->u.u_virpage.pHead &&
2413 !pThis->u.u_virpage.pHead->tossChecked)
2415 PushThisElement(pParent);
2417 PushThisElement(pThis);
2418 pThis = pThis->u.u_virpage.pHead;
2421 if (pThis->u.u_virpage.pSnb &&
2422 !pThis->u.u_virpage.pSnb->tossChecked)
2424 PushThisElement(pParent);
2426 PushThisElement(pThis);
2427 pThis = pThis->u.u_virpage.pSnb;
2430 if (pThis->u.u_virpage.pBlockOrForm &&
2431 !pThis->u.u_virpage.pBlockOrForm->tossChecked)
2433 PushThisElement(pParent);
2435 PushThisElement(pThis);
2436 pThis = pThis->u.u_virpage.pBlockOrForm;
2441 pThis = pThis->pNext;
2444 m_free(pThis->inheritedClass, "wide character inherited class");
2448 if (!pThis->tossChecked)
2450 pThis->inheritedLevel = pParent->inheritedLevel;
2451 pThis->inheritedClass = pParent->inheritedClass;
2452 pThis->tossChecked = TRUE;
2454 if (pThis->u.u_snb.pHead &&
2455 !pThis->u.u_snb.pHead->tossChecked)
2457 PushThisElement(pParent);
2459 PushThisElement(pThis);
2460 pThis = pThis->u.u_virpage.pHead;
2463 if (pThis->u.u_snb.pSystemNotations)
2464 { /* don't do anything now; wait for <snref> */
2468 pThis = pThis->pNext;
2471 pThis = PopThisElement();
2472 pParent = PopThisElement();
2475 if (!pThis->tossChecked)
2477 if (!(pThis->inheritedLevel = pThis->u.u_block.level))
2478 pThis->inheritedLevel = pParent->inheritedLevel;
2479 if (!(pThis->inheritedClass = pThis->u.u_block.class))
2480 pThis->inheritedClass = pParent->inheritedClass;
2481 if (pThis->u.u_block.level ||
2482 pThis->u.u_block.class ||
2483 pThis->u.u_block.ssi)
2484 MarkUsedStyle(pThis->inheritedLevel,
2485 pThis->inheritedClass,
2486 pThis->u.u_block.ssi);
2487 pThis->tossChecked = TRUE;
2489 if (pThis->u.u_block.pHead &&
2490 !pThis->u.u_block.pHead->tossChecked)
2492 PushThisElement(pParent);
2494 PushThisElement(pThis);
2495 pThis = pThis->u.u_block.pHead;
2498 if (pThis->u.u_block.pCpOrP &&
2499 !pThis->u.u_block.pCpOrP->tossChecked)
2501 PushThisElement(pParent);
2503 PushThisElement(pThis);
2504 pThis = pThis->u.u_block.pCpOrP;
2509 pThis = pThis->pNext;
2512 pThis = PopThisElement();
2513 pParent = PopThisElement();
2516 if (!pThis->tossChecked)
2518 if (!(pThis->inheritedLevel = pThis->u.u_form.level))
2519 pThis->inheritedLevel = pParent->inheritedLevel;
2520 if (!(pThis->inheritedClass = pThis->u.u_form.class))
2521 pThis->inheritedClass = pParent->inheritedClass;
2522 if (pThis->u.u_form.level ||
2523 pThis->u.u_form.class ||
2524 pThis->u.u_form.ssi)
2525 MarkUsedStyle(pThis->inheritedLevel,
2526 pThis->inheritedClass,
2527 pThis->u.u_form.ssi);
2528 pThis->tossChecked = TRUE;
2530 if (pThis->u.u_form.pHead &&
2531 !pThis->u.u_form.pHead->tossChecked)
2533 PushThisElement(pParent);
2535 PushThisElement(pThis);
2536 pThis = pThis->u.u_form.pHead;
2539 if (pThis->u.u_form.pFdata &&
2540 !pThis->u.u_form.pFdata->tossChecked)
2542 PushThisElement(pParent);
2544 PushThisElement(pThis);
2545 pThis = pThis->u.u_form.pFdata;
2548 if (pThis->u.u_form.pFstyle &&
2549 !pThis->u.u_form.pFstyle->tossChecked)
2551 PushThisElement(pParent);
2553 PushThisElement(pThis);
2554 pThis = pThis->u.u_form.pFstyle;
2559 pThis = pThis->pNext;
2562 pThis = PopThisElement();
2563 pParent = PopThisElement();
2566 if (!pThis->tossChecked)
2568 pThis->inheritedLevel = pParent->inheritedLevel;
2569 pThis->inheritedClass = pParent->inheritedClass;
2570 pThis->tossChecked = TRUE;
2572 if (pThis->u.u_fstyle.pFrowvec &&
2573 !pThis->u.u_fstyle.pFrowvec->tossChecked)
2575 PushThisElement(pParent);
2577 PushThisElement(pThis);
2578 pThis = pThis->u.u_fstyle.pFrowvec;
2583 pThis = pThis->pNext;
2586 pThis = PopThisElement();
2587 pParent = PopThisElement();
2590 if (!pThis->tossChecked)
2592 pThis->inheritedLevel = pParent->inheritedLevel;
2593 pThis->inheritedClass = pParent->inheritedClass;
2594 pThis->tossChecked = TRUE;
2598 pThis = pThis->pNext;
2601 pThis = PopThisElement();
2602 pParent = PopThisElement();
2605 if (!pThis->tossChecked)
2607 pThis->inheritedLevel = pParent->inheritedLevel;
2608 pThis->inheritedClass = pParent->inheritedClass;
2609 pThis->tossChecked = TRUE;
2611 if (pThis->u.u_fdata.pBlockOrForm &&
2612 !pThis->u.u_fdata.pBlockOrForm->tossChecked)
2614 PushThisElement(pParent);
2616 PushThisElement(pThis);
2617 pThis = pThis->u.u_fdata.pBlockOrForm;
2622 pThis = pThis->pNext;
2625 pThis = PopThisElement();
2626 pParent = PopThisElement();
2629 if (!pThis->tossChecked)
2631 pThis->inheritedLevel = pParent->inheritedLevel;
2632 pThis->inheritedClass = pParent->inheritedClass;
2633 if (pThis->u.u_p.ssi)
2634 MarkUsedStyle(pThis->inheritedLevel,
2635 pThis->inheritedClass,
2637 pThis->tossChecked = TRUE;
2639 if (pThis->u.u_p.pHead &&
2640 !pThis->u.u_p.pHead->tossChecked)
2642 PushThisElement(pParent);
2644 PushThisElement(pThis);
2645 pThis = pThis->u.u_p.pHead;
2648 if (pThis->u.u_p.pAtomicOrPCDATA &&
2649 !pThis->u.u_p.pAtomicOrPCDATA->tossChecked)
2651 PushThisElement(pParent);
2653 PushThisElement(pThis);
2654 pThis = pThis->u.u_p.pAtomicOrPCDATA;
2659 pThis = pThis->pNext;
2662 pThis = PopThisElement();
2663 pParent = PopThisElement();
2666 if (!pThis->tossChecked)
2668 pThis->inheritedLevel = pParent->inheritedLevel;
2669 pThis->inheritedClass = pParent->inheritedClass;
2670 if (pThis->u.u_cp.ssi)
2671 MarkUsedStyle(pThis->inheritedLevel,
2672 pThis->inheritedClass,
2674 pThis->tossChecked = TRUE;
2676 if (pThis->u.u_cp.pCDATA &&
2677 !pThis->u.u_cp.pCDATA->tossChecked)
2679 PushThisElement(pParent);
2681 PushThisElement(pThis);
2682 pThis = pThis->u.u_cp.pCDATA;
2687 pThis = pThis->pNext;
2690 pThis = PopThisElement();
2691 pParent = PopThisElement();
2694 if (!pThis->tossChecked)
2696 pThis->inheritedLevel = pParent->inheritedLevel;
2697 if (!(pThis->inheritedClass = pThis->u.u_head.class))
2698 pThis->inheritedClass = MakeWideCharString("HEAD");
2699 MarkUsedStyle(pThis->inheritedLevel,
2700 pThis->inheritedClass,
2701 pThis->u.u_head.ssi);
2702 pThis->tossChecked = TRUE;
2704 if (pThis->u.u_head.pAtomicOrPCDATA &&
2705 !pThis->u.u_head.pAtomicOrPCDATA->tossChecked)
2707 PushThisElement(pParent);
2709 PushThisElement(pThis);
2710 pThis = pThis->u.u_head.pAtomicOrPCDATA;
2713 if (pThis->u.u_head.pSubhead &&
2714 !pThis->u.u_head.pSubhead->tossChecked)
2716 PushThisElement(pParent);
2718 PushThisElement(pThis);
2719 pThis = pThis->u.u_head.pSubhead;
2724 pThis = pThis->pNext;
2727 if (!pThis->u.u_head.class)
2728 m_free(pThis->inheritedClass,
2729 "wide character inherited class");
2730 pThis = PopThisElement();
2731 pParent = PopThisElement();
2734 if (!pThis->tossChecked)
2736 pThis->inheritedLevel = pParent->inheritedLevel;
2737 if (!(pThis->inheritedClass = pThis->u.u_subhead.class))
2738 pThis->inheritedClass = pParent->inheritedClass;
2739 if (pThis->u.u_subhead.class || pThis->u.u_subhead.ssi)
2740 MarkUsedStyle(pThis->inheritedLevel,
2741 pThis->inheritedClass,
2742 pThis->u.u_subhead.ssi);
2743 pThis->tossChecked = TRUE;
2745 if (pThis->u.u_subhead.pAtomicOrPCDATA &&
2746 !pThis->u.u_subhead.pAtomicOrPCDATA->tossChecked)
2748 PushThisElement(pParent);
2750 PushThisElement(pThis);
2751 pThis = pThis->u.u_subhead.pAtomicOrPCDATA;
2756 pThis = pThis->pNext;
2759 pThis = PopThisElement();
2760 pParent = PopThisElement();
2763 if (!pThis->tossChecked)
2765 pThis->inheritedLevel = pParent->inheritedLevel;
2766 pThis->inheritedClass = pParent->inheritedClass;
2767 pThis->tossChecked = TRUE;
2771 pThis = pThis->pNext;
2774 pThis = PopThisElement();
2775 pParent = PopThisElement();
2778 if (!pThis->tossChecked)
2780 pThis->inheritedLevel = pParent->inheritedLevel;
2781 pThis->inheritedClass = pParent->inheritedClass;
2782 pThis->tossChecked = TRUE;
2784 if (pThis->u.u_link.pAtomicOrPCDATA &&
2785 !pThis->u.u_link.pAtomicOrPCDATA->tossChecked)
2787 PushThisElement(pParent);
2789 PushThisElement(pThis);
2790 pThis = pThis->u.u_link.pAtomicOrPCDATA;
2795 pThis = pThis->pNext;
2798 pThis = PopThisElement();
2799 pParent = PopThisElement();
2802 if (!pThis->tossChecked)
2804 pThis->inheritedLevel = pParent->inheritedLevel;
2805 pThis->inheritedClass = pParent->inheritedClass;
2806 pThis->tossChecked = TRUE;
2808 if (pThis->u.u_snref.pRefitem &&
2809 !pThis->u.u_snref.pRefitem->tossChecked)
2811 PushThisElement(pParent);
2813 PushThisElement(pThis);
2814 pThis = pThis->u.u_snref.pRefitem;
2817 if (pThis->u.u_snref.pAlttext &&
2818 !pThis->u.u_snref.pAlttext->tossChecked)
2820 PushThisElement(pParent);
2822 PushThisElement(pThis);
2823 pThis = pThis->u.u_snref.pAlttext;
2828 pThis = pThis->pNext;
2831 pThis = PopThisElement();
2832 pParent = PopThisElement();
2835 if (!pThis->tossChecked)
2837 pThis->inheritedLevel = pParent->inheritedLevel;
2838 pThis->inheritedClass = pThis->u.u_refitem.class;
2839 MarkUsedStyle(pThis->inheritedLevel,
2840 pThis->inheritedClass,
2841 pThis->u.u_refitem.ssi);
2842 if ((pItem = LookupInSnb(pSnb, pThis->u.u_refitem.rid)) &&
2843 (pItem->type == e_text))
2845 pThis->u.u_refitem.pReferencedItem = pItem;
2848 pThis->tossChecked = TRUE;
2850 if (pThis->u.u_refitem.pHead &&
2851 !pThis->u.u_refitem.pHead->tossChecked)
2853 PushThisElement(pParent);
2855 PushThisElement(pThis);
2856 pThis = pThis->u.u_refitem.pHead;
2859 if (pThis->u.u_refitem.pReferencedItem &&
2860 !pThis->u.u_refitem.pReferencedItem->tossChecked)
2862 PushThisElement(pParent);
2864 PushThisElement(pThis);
2865 pThis = pThis->u.u_refitem.pReferencedItem;
2870 pThis = pThis->pNext;
2873 pThis = PopThisElement();
2874 pParent = PopThisElement();
2877 if (!pThis->tossChecked)
2879 pThis->inheritedLevel = pParent->inheritedLevel;
2880 pThis->inheritedClass = pParent->inheritedClass;
2881 pThis->tossChecked = TRUE;
2883 if (pThis->u.u_alttext.pCDATA &&
2884 !pThis->u.u_alttext.pCDATA->tossChecked)
2886 PushThisElement(pParent);
2888 PushThisElement(pThis);
2889 pThis = pThis->u.u_alttext.pCDATA;
2894 pThis = pThis->pNext;
2897 pThis = PopThisElement();
2898 pParent = PopThisElement();
2901 if (!pThis->tossChecked)
2903 pThis->inheritedLevel = pParent->inheritedLevel;
2904 pThis->inheritedClass = pParent->inheritedClass;
2905 pThis->tossChecked = TRUE;
2907 if (pThis->u.u_rev.pAtomicOrPCDATA &&
2908 !pThis->u.u_rev.pAtomicOrPCDATA->tossChecked)
2910 PushThisElement(pParent);
2912 PushThisElement(pThis);
2913 pThis = pThis->u.u_rev.pAtomicOrPCDATA;
2918 pThis = pThis->pNext;
2921 pThis = PopThisElement();
2922 pParent = PopThisElement();
2925 if (!pThis->tossChecked)
2927 pThis->inheritedLevel = pParent->inheritedLevel;
2928 pThis->inheritedClass = pThis->u.u_key.class;
2929 MarkUsedStyle(pThis->inheritedLevel,
2930 pThis->inheritedClass,
2931 pThis->u.u_key.ssi);
2932 pThis->tossChecked = TRUE;
2934 if (pThis->u.u_key.pAtomicOrPCDATA &&
2935 !pThis->u.u_key.pAtomicOrPCDATA->tossChecked)
2937 PushThisElement(pParent);
2939 PushThisElement(pThis);
2940 pThis = pThis->u.u_key.pAtomicOrPCDATA;
2945 pThis = pThis->pNext;
2948 pThis = PopThisElement();
2949 pParent = PopThisElement();
2952 if (!pThis->tossChecked)
2954 pThis->inheritedLevel = pParent->inheritedLevel;
2955 pThis->inheritedClass = pThis->u.u_sphrase.class;
2956 MarkUsedStyle(pThis->inheritedLevel,
2957 pThis->inheritedClass,
2958 pThis->u.u_sphrase.ssi);
2959 pThis->tossChecked = TRUE;
2961 if (pThis->u.u_sphrase.pSpcOrPCDATA &&
2962 !pThis->u.u_sphrase.pSpcOrPCDATA->tossChecked)
2964 PushThisElement(pParent);
2966 PushThisElement(pThis);
2967 pThis = pThis->u.u_sphrase.pSpcOrPCDATA;
2972 pThis = pThis->pNext;
2975 pThis = PopThisElement();
2976 pParent = PopThisElement();
2979 if (!pThis->tossChecked)
2981 pThis->inheritedLevel = pParent->inheritedLevel;
2982 pThis->inheritedClass = pParent->inheritedClass;
2983 pThis->tossChecked = TRUE;
2985 if (pThis->u.u_if.pCond &&
2986 !pThis->u.u_if.pCond->tossChecked)
2988 PushThisElement(pParent);
2990 PushThisElement(pThis);
2991 pThis = pThis->u.u_if.pCond;
2994 if (pThis->u.u_if.pThen &&
2995 !pThis->u.u_if.pThen->tossChecked)
2997 PushThisElement(pParent);
2999 PushThisElement(pThis);
3000 pThis = pThis->u.u_if.pThen;
3003 if (pThis->u.u_if.pElse &&
3004 !pThis->u.u_if.pElse->tossChecked)
3006 PushThisElement(pParent);
3008 PushThisElement(pThis);
3009 pThis = pThis->u.u_if.pElse;
3014 pThis = pThis->pNext;
3017 pThis = PopThisElement();
3018 pParent = PopThisElement();
3021 if (!pThis->tossChecked)
3023 pThis->inheritedLevel = pParent->inheritedLevel;
3024 pThis->inheritedClass = pParent->inheritedClass;
3025 pThis->tossChecked = TRUE;
3027 if (pThis->u.u_cond.pCDATA &&
3028 !pThis->u.u_cond.pCDATA->tossChecked)
3030 PushThisElement(pParent);
3032 PushThisElement(pThis);
3033 pThis = pThis->u.u_cond.pCDATA;
3038 pThis = pThis->pNext;
3041 pThis = PopThisElement();
3042 pParent = PopThisElement();
3045 if (!pThis->tossChecked)
3047 pThis->inheritedLevel = pParent->inheritedLevel;
3048 pThis->inheritedClass = pParent->inheritedClass;
3049 pThis->tossChecked = TRUE;
3051 if (pThis->u.u_then.pAtomicOrPCDATA &&
3052 !pThis->u.u_then.pAtomicOrPCDATA->tossChecked)
3054 PushThisElement(pParent);
3056 PushThisElement(pThis);
3057 pThis = pThis->u.u_then.pAtomicOrPCDATA;
3062 pThis = pThis->pNext;
3065 pThis = PopThisElement();
3066 pParent = PopThisElement();
3069 if (!pThis->tossChecked)
3071 pThis->inheritedLevel = pParent->inheritedLevel;
3072 pThis->inheritedClass = pParent->inheritedClass;
3073 pThis->tossChecked = TRUE;
3075 if (pThis->u.u_else.pAtomicOrPCDATA &&
3076 !pThis->u.u_else.pAtomicOrPCDATA->tossChecked)
3078 PushThisElement(pParent);
3080 PushThisElement(pThis);
3081 pThis = pThis->u.u_else.pAtomicOrPCDATA;
3086 pThis = pThis->pNext;
3089 pThis = PopThisElement();
3090 pParent = PopThisElement();
3093 if (!pThis->tossChecked)
3095 pThis->inheritedLevel = pParent->inheritedLevel;
3096 pThis->inheritedClass = pParent->inheritedClass;
3097 pThis->tossChecked = TRUE;
3101 pThis = pThis->pNext;
3104 pThis = PopThisElement();
3105 pParent = PopThisElement();
3108 if (!pThis->tossChecked)
3110 pThis->inheritedLevel = pParent->inheritedLevel;
3111 pThis->inheritedClass = pParent->inheritedClass;
3112 pThis->tossChecked = TRUE;
3116 pThis = pThis->pNext;
3119 pThis = PopThisElement();
3120 pParent = PopThisElement();
3123 if (!pThis->tossChecked)
3125 pThis->inheritedLevel = pParent->inheritedLevel;
3126 pThis->inheritedClass = pParent->inheritedClass;
3127 pThis->tossChecked = TRUE;
3129 if (pThis->u.u_text.pCpOrP &&
3130 !pThis->u.u_text.pCpOrP->tossChecked)
3132 PushThisElement(pParent);
3134 PushThisElement(pThis);
3135 pThis = pThis->u.u_text.pCpOrP;
3140 pThis = pThis->pNext;
3143 pThis = PopThisElement();
3144 pParent = PopThisElement();
3147 if (!pThis->tossChecked)
3149 pThis->inheritedLevel = pParent->inheritedLevel;
3150 pThis->inheritedClass = pParent->inheritedClass;
3151 pThis->tossChecked = TRUE;
3155 pThis = pThis->pNext;
3158 pThis = PopThisElement();
3159 pParent = PopThisElement();
3162 if (!pThis->tossChecked)
3164 pThis->inheritedLevel = pParent->inheritedLevel;
3165 pThis->inheritedClass = pParent->inheritedClass;
3166 pThis->tossChecked = TRUE;
3170 pThis = pThis->pNext;
3173 pThis = PopThisElement();
3174 pParent = PopThisElement();
3177 if (!pThis->tossChecked)
3179 pThis->inheritedLevel = pParent->inheritedLevel;
3180 pThis->inheritedClass = pParent->inheritedClass;
3181 pThis->tossChecked = TRUE;
3185 pThis = pThis->pNext;
3188 pThis = PopThisElement();
3189 pParent = PopThisElement();
3192 if (!pThis->tossChecked)
3194 pThis->inheritedLevel = pParent->inheritedLevel;
3195 pThis->inheritedClass = pParent->inheritedClass;
3196 pThis->tossChecked = TRUE;
3198 if (pThis->u.u_script.pCDATA &&
3199 !pThis->u.u_script.pCDATA->tossChecked)
3201 PushThisElement(pParent);
3203 PushThisElement(pThis);
3204 pThis = pThis->u.u_script.pCDATA;
3209 pThis = pThis->pNext;
3212 pThis = PopThisElement();
3213 pParent = PopThisElement();
3216 if (!pThis->tossChecked)
3218 pThis->inheritedLevel = pParent->inheritedLevel;
3219 pThis->inheritedClass = pParent->inheritedClass;
3220 pThis->tossChecked = TRUE;
3224 pThis = pThis->pNext;
3227 pThis = PopThisElement();
3228 pParent = PopThisElement();
3231 if (!pThis->tossChecked)
3233 pThis->inheritedLevel = pParent->inheritedLevel;
3234 pThis->inheritedClass = pParent->inheritedClass;
3235 pThis->tossChecked = TRUE;
3239 pThis = pThis->pNext;
3242 pThis = PopThisElement();
3243 pParent = PopThisElement();
3246 if (!pThis->tossChecked)
3248 pThis->inheritedLevel = pParent->inheritedLevel;
3249 pThis->inheritedClass = pParent->inheritedClass;
3250 pThis->tossChecked = TRUE;
3254 pThis = pThis->pNext;
3257 pThis = PopThisElement();
3258 pParent = PopThisElement();
3261 if (!pThis->tossChecked)
3263 pThis->inheritedLevel = pParent->inheritedLevel;
3264 pThis->inheritedClass = pParent->inheritedClass;
3265 pThis->tossChecked = TRUE;
3269 pThis = pThis->pNext;
3272 pThis = PopThisElement();
3273 pParent = PopThisElement();
3276 if (!pThis->tossChecked)
3278 pThis->inheritedLevel = pParent->inheritedLevel;
3279 pThis->inheritedClass = pParent->inheritedClass;
3280 pThis->tossChecked = TRUE;
3284 pThis = pThis->pNext;
3287 pThis = PopThisElement();
3288 pParent = PopThisElement();
3291 if (!pThis->tossChecked)
3293 pThis->inheritedLevel = pParent->inheritedLevel;
3294 pThis->inheritedClass = pParent->inheritedClass;
3295 pThis->tossChecked = TRUE;
3297 if (pThis->u.u_switch.pCDATA &&
3298 !pThis->u.u_switch.pCDATA->tossChecked)
3300 PushThisElement(pParent);
3302 PushThisElement(pThis);
3303 pThis = pThis->u.u_switch.pCDATA;
3308 pThis = pThis->pNext;
3311 pThis = PopThisElement();
3312 pParent = PopThisElement();
3315 if (!pThis->tossChecked)
3317 pThis->inheritedLevel = pParent->inheritedLevel;
3318 pThis->inheritedClass = pParent->inheritedClass;
3319 pThis->tossChecked = TRUE;
3323 pThis = pThis->pNext;
3326 pThis = PopThisElement();
3327 pParent = PopThisElement();
3330 if (!pThis->tossChecked)
3332 pThis->inheritedLevel = pParent->inheritedLevel;
3333 pThis->inheritedClass = pParent->inheritedClass;
3334 pThis->tossChecked = TRUE;
3336 if (pThis->u.u_entry.pSimpleOrPCDATA &&
3337 !pThis->u.u_entry.pSimpleOrPCDATA->tossChecked)
3339 PushThisElement(pParent);
3341 PushThisElement(pThis);
3342 pThis = pThis->u.u_entry.pSimpleOrPCDATA;
3345 if (pThis->u.u_entry.pEntry &&
3346 !pThis->u.u_entry.pEntry->tossChecked)
3348 PushThisElement(pParent);
3350 PushThisElement(pThis);
3351 pThis = pThis->u.u_entry.pEntry;
3356 pThis = pThis->pNext;
3359 pThis = PopThisElement();
3360 pParent = PopThisElement();
3368 pThis = pThis->pNext;
3371 fprintf(stderr, "%s\n", errMess);
3372 if (m_errfile && (m_errfile != stderr))
3373 fprintf(m_errfile, "%s\n", errMess);
3380 #if defined(M_PROTO)
3381 void EmitSDL(ElementPtr pRoot)
3387 ElementPtr pThis, pThat;
3388 long int virpageOffset;
3389 LOGICAL doCompression;
3390 int zFileSize, length;
3391 unsigned char zTemp[4];
3393 char buffer[BUFSIZ];
3396 static char errMess[] =
3397 "internal error - unrecognized element type in EmitSDL";
3400 doCompression = FALSE;
3403 if (minimalTossFlag)
3404 MarkUsedTOSS(pRoot);
3405 if (pRoot->type == e_virpage)
3407 virpageOffset = ftell(outFile);
3410 doCompression = TRUE;
3411 saveOutFile = outFile;
3412 outFile = FopenFile(compFileName, O_WRONLY, xxx);
3419 pThis = pElementChain;
3420 sprintf(cCount, " COUNT=\"%d\">\n", nElements);
3422 pElementChain = NULL;
3425 /* push a null so the last <entry> pop will terminate the loop */
3426 if (pThis && (pThis->type == e_entry))
3427 PushThisElement(NULL);
3432 switch (pThis->type)
3435 /* we've already emitted the <sdldoc ...> stuff */
3436 if (pThis->u.u_sdldoc.pHead)
3438 PushThisElement(pThis);
3440 pThis = pThis->u.u_sdldoc.pHead;
3441 pThat->u.u_sdldoc.pHead = NULL;
3444 if (pThis->u.u_sdldoc.pSnb)
3446 PushThisElement(pThis);
3448 pThis = pThis->u.u_sdldoc.pSnb;
3449 pThat->u.u_sdldoc.pSnb = NULL;
3452 DeleteElement(pThis);
3456 if (!pThis->beenEmitted)
3458 OpenNamedTag("VIRPAGE", TRUE, FALSE);
3459 RequiredAttribute("ID", pThis->u.u_virpage.id);
3460 AddToLOIDS("VIRPAGE",
3461 pThis->u.u_virpage.id,
3462 pThis->u.u_virpage.ssi,
3463 pThis->u.u_virpage.level,
3465 RequiredAttribute("LEVEL", pThis->u.u_virpage.level);
3466 ImpliedAttribute("VERSION", pThis->u.u_virpage.version);
3467 ImpliedAttribute("LANGUAGE", pThis->u.u_virpage.language);
3468 ImpliedAttribute("CHARSET", pThis->u.u_virpage.charset);
3469 RequiredAttribute("DOC-ID", pThis->u.u_virpage.doc_id);
3470 ImpliedAttribute("SSI", pThis->u.u_virpage.ssi);
3472 pThis->beenEmitted = TRUE;
3474 if (pThis->u.u_virpage.pHead)
3476 PushThisElement(pThis);
3478 pThis = pThis->u.u_virpage.pHead;
3479 pThat->u.u_virpage.pHead = NULL;
3482 if (pThis->u.u_virpage.pSnb)
3484 PushThisElement(pThis);
3486 pThis = pThis->u.u_virpage.pSnb;
3487 pThat->u.u_virpage.pSnb = NULL;
3490 if (pThis->u.u_virpage.pBlockOrForm)
3492 PushThisElement(pThis);
3494 pThis = pThis->u.u_virpage.pBlockOrForm;
3495 pThat->u.u_virpage.pBlockOrForm = NULL;
3501 pThis = pThat->pNext;
3502 pThat->pNext = NULL;
3503 DeleteElement(pThat);
3504 CloseNamedTag("VIRPAGE", TRUE);
3507 DeleteElement(pThis);
3508 CloseNamedTag("VIRPAGE", TRUE);
3512 if (!pThis->beenEmitted)
3514 OpenNamedTag("SNB", TRUE, FALSE);
3515 ImpliedAttribute("VERSION", pThis->u.u_snb.version);
3517 pThis->beenEmitted = TRUE;
3519 if (pThis->u.u_snb.pHead)
3521 PushThisElement(pThis);
3523 pThis = pThis->u.u_virpage.pHead;
3524 pThat->u.u_virpage.pHead = NULL;
3527 if (pThis->u.u_snb.pSystemNotations)
3529 PushThisElement(pThis);
3531 pThis = pThis->u.u_snb.pSystemNotations;
3532 pThat->u.u_snb.pSystemNotations = NULL;
3538 pThis = pThat->pNext;
3539 pThat->pNext = NULL;
3540 DeleteElement(pThat);
3541 CloseNamedTag("SNB", TRUE);
3544 DeleteElement(pThis);
3545 CloseNamedTag("SNB", TRUE);
3546 pThis = PopThisElement();
3549 if (!pThis->beenEmitted)
3551 OpenNamedTag("BLOCK", TRUE, FALSE);
3552 ImpliedAttribute("ID", pThis->u.u_block.id);
3554 pThis->u.u_block.id,
3555 pThis->u.u_block.ssi,
3556 pThis->u.u_block.level,
3558 ImpliedAttribute("LEVEL", pThis->u.u_block.level);
3559 ImpliedAttribute("VERSION", pThis->u.u_block.version);
3560 ImpliedAttribute("CLASS", pThis->u.u_block.class);
3561 ImpliedAttribute("LANGUAGE", pThis->u.u_block.language);
3562 ImpliedAttribute("CHARSET", pThis->u.u_block.charset);
3563 ImpliedAttribute("LENGTH", pThis->u.u_block.length);
3564 ImpliedAttribute("APP", pThis->u.u_block.app);
3565 ImpliedAttribute("TIMING", pThis->u.u_block.timing);
3566 ImpliedAttribute("SSI", pThis->u.u_block.ssi);
3568 pThis->beenEmitted = TRUE;
3570 if (pThis->u.u_block.pHead)
3572 PushThisElement(pThis);
3574 pThis = pThis->u.u_block.pHead;
3575 pThat->u.u_block.pHead = NULL;
3578 if (pThis->u.u_block.pCpOrP)
3580 PushThisElement(pThis);
3582 pThis = pThis->u.u_block.pCpOrP;
3583 pThat->u.u_block.pCpOrP = NULL;
3589 pThis = pThat->pNext;
3590 pThat->pNext = NULL;
3591 DeleteElement(pThat);
3592 CloseNamedTag("BLOCK", TRUE);
3595 DeleteElement(pThis);
3596 CloseNamedTag("BLOCK", TRUE);
3597 pThis = PopThisElement();
3600 if (!pThis->beenEmitted)
3602 OpenNamedTag("FORM", TRUE, FALSE);
3603 ImpliedAttribute("ID", pThis->u.u_form.id);
3606 pThis->u.u_form.ssi,
3607 pThis->u.u_form.level,
3609 ImpliedAttribute("LEVEL", pThis->u.u_form.level);
3610 ImpliedAttribute("VERSION", pThis->u.u_form.version);
3611 ImpliedAttribute("CLASS", pThis->u.u_form.class);
3612 ImpliedAttribute("LANGUAGE", pThis->u.u_form.language);
3613 ImpliedAttribute("CHARSET", pThis->u.u_form.charset);
3614 ImpliedAttribute("LENGTH", pThis->u.u_form.length);
3615 ImpliedAttribute("APP", pThis->u.u_form.app);
3616 ImpliedAttribute("SSI", pThis->u.u_form.ssi);
3618 pThis->beenEmitted = TRUE;
3620 if (pThis->u.u_form.pHead)
3622 PushThisElement(pThis);
3624 pThis = pThis->u.u_form.pHead;
3625 pThat->u.u_form.pHead = NULL;
3628 if (pThis->u.u_form.pFdata)
3630 PushThisElement(pThis);
3632 pThis = pThis->u.u_form.pFdata;
3633 pThat->u.u_form.pFdata = NULL;
3636 if (pThis->u.u_form.pFstyle)
3638 PushThisElement(pThis);
3640 pThis = pThis->u.u_form.pFstyle;
3641 pThat->u.u_form.pFstyle = NULL;
3647 pThis = pThat->pNext;
3648 pThat->pNext = NULL;
3649 DeleteElement(pThat);
3650 CloseNamedTag("FORM", TRUE);
3653 DeleteElement(pThis);
3654 CloseNamedTag("FORM", TRUE);
3655 pThis = PopThisElement();
3658 if (!pThis->beenEmitted)
3660 OpenNamedTag("FSTYLE", TRUE, FALSE);
3661 ImpliedAttribute("NCOLS", pThis->u.u_fstyle.ncols);
3663 pThis->beenEmitted = TRUE;
3665 if (pThis->u.u_fstyle.pFrowvec)
3667 PushThisElement(pThis);
3669 pThis = pThis->u.u_fstyle.pFrowvec;
3670 pThat->u.u_fstyle.pFrowvec = NULL;
3676 pThis = pThat->pNext;
3677 pThat->pNext = NULL;
3678 DeleteElement(pThat);
3679 CloseNamedTag("FSTYLE", TRUE);
3682 DeleteElement(pThis);
3683 CloseNamedTag("FSTYLE", TRUE);
3684 pThis = PopThisElement();
3687 if (!pThis->beenEmitted)
3689 OpenNamedTag("FROWVEC", TRUE, FALSE);
3690 ImpliedAttribute("HDR", pThis->u.u_frowvec.hdr);
3691 RequiredAttribute("CELLS", pThis->u.u_frowvec.cells);
3693 pThis->beenEmitted = TRUE;
3698 pThis = pThat->pNext;
3699 pThat->pNext = NULL;
3700 DeleteElement(pThat);
3703 DeleteElement(pThis);
3704 pThis = PopThisElement();
3707 if (!pThis->beenEmitted)
3709 OpenNamedTag("FDATA", FALSE, TRUE);
3710 pThis->beenEmitted = TRUE;
3712 if (pThis->u.u_fdata.pBlockOrForm)
3714 PushThisElement(pThis);
3716 pThis = pThis->u.u_fdata.pBlockOrForm;
3717 pThat->u.u_fdata.pBlockOrForm = NULL;
3723 pThis = pThat->pNext;
3724 pThat->pNext = NULL;
3725 DeleteElement(pThat);
3726 CloseNamedTag("FDATA", TRUE);
3729 DeleteElement(pThis);
3730 CloseNamedTag("FDATA", TRUE);
3731 pThis = PopThisElement();
3734 if (!pThis->beenEmitted)
3736 OpenNamedTag("P", TRUE, FALSE);
3737 ImpliedAttribute("ID", pThis->u.u_p.id);
3743 ImpliedAttribute("VERSION", pThis->u.u_p.version);
3744 ImpliedAttribute("TYPE", pThis->u.u_p.type);
3745 ImpliedAttribute("SSI", pThis->u.u_p.ssi);
3747 pThis->beenEmitted = TRUE;
3749 if (pThis->u.u_p.pHead)
3751 PushThisElement(pThis);
3753 pThis = pThis->u.u_p.pHead;
3754 pThat->u.u_p.pHead = NULL;
3757 if (pThis->u.u_p.pAtomicOrPCDATA)
3759 PushThisElement(pThis);
3761 pThis = pThis->u.u_p.pAtomicOrPCDATA;
3762 pThat->u.u_p.pAtomicOrPCDATA = NULL;
3768 pThis = pThat->pNext;
3769 pThat->pNext = NULL;
3770 DeleteElement(pThat);
3771 CloseNamedTag("P", TRUE);
3774 DeleteElement(pThis);
3775 CloseNamedTag("P", TRUE);
3776 pThis = PopThisElement();
3779 if (!pThis->beenEmitted)
3781 OpenNamedTag("CP", TRUE, FALSE);
3782 ImpliedAttribute("ID", pThis->u.u_cp.id);
3788 ImpliedAttribute("VERSION", pThis->u.u_cp.version);
3789 ImpliedAttribute("TYPE", pThis->u.u_cp.type);
3790 ImpliedAttribute("SSI", pThis->u.u_cp.ssi);
3792 pThis->beenEmitted = TRUE;
3794 if (pThis->u.u_cp.pCDATA)
3796 PushThisElement(pThis);
3798 pThis = pThis->u.u_cp.pCDATA;
3799 pThat->u.u_cp.pCDATA = NULL;
3805 pThis = pThat->pNext;
3806 pThat->pNext = NULL;
3807 DeleteElement(pThat);
3808 CloseNamedTag("CP", TRUE);
3811 DeleteElement(pThis);
3812 CloseNamedTag("CP", TRUE);
3813 pThis = PopThisElement();
3816 if (!pThis->beenEmitted)
3818 OpenNamedTag("HEAD", TRUE, FALSE);
3819 ImpliedAttribute("ID", pThis->u.u_head.id);
3822 pThis->u.u_head.ssi,
3825 ImpliedAttribute("VERSION", pThis->u.u_head.version);
3826 ImpliedAttribute("CLASS", pThis->u.u_head.class);
3827 ImpliedAttribute("LANGUAGE", pThis->u.u_head.language);
3828 ImpliedAttribute("CHARSET", pThis->u.u_head.charset);
3829 ImpliedAttribute("TYPE", pThis->u.u_head.type);
3830 ImpliedAttribute("SSI", pThis->u.u_head.ssi);
3831 ImpliedAttribute("ABBREV", pThis->u.u_head.abbrev);
3833 pThis->beenEmitted = TRUE;
3835 if (pThis->u.u_head.pAtomicOrPCDATA)
3837 PushThisElement(pThis);
3839 pThis = pThis->u.u_head.pAtomicOrPCDATA;
3840 pThat->u.u_head.pAtomicOrPCDATA = NULL;
3843 if (pThis->u.u_head.pSubhead)
3845 PushThisElement(pThis);
3847 pThis = pThis->u.u_head.pSubhead;
3848 pThat->u.u_head.pSubhead = NULL;
3854 pThis = pThat->pNext;
3855 pThat->pNext = NULL;
3856 DeleteElement(pThat);
3857 pThat = PopThisElement();
3858 if (pThat->type == e_p)
3859 CloseNamedTag("HEAD", FALSE);
3861 CloseNamedTag("HEAD", TRUE);
3862 PushThisElement(pThat);
3865 DeleteElement(pThis);
3866 pThis = PopThisElement();
3867 if (pThis->type == e_p)
3868 CloseNamedTag("HEAD", FALSE);
3870 CloseNamedTag("HEAD", TRUE);
3873 if (!pThis->beenEmitted)
3875 OpenNamedTag("SUBHEAD", TRUE, FALSE);
3876 ImpliedAttribute("ID", pThis->u.u_subhead.id);
3877 AddToLOIDS("SUBHEAD",
3878 pThis->u.u_subhead.id,
3879 pThis->u.u_subhead.ssi,
3882 ImpliedAttribute("VERSION", pThis->u.u_subhead.version);
3883 ImpliedAttribute("CLASS", pThis->u.u_subhead.class);
3884 ImpliedAttribute("LANGUAGE", pThis->u.u_subhead.language);
3885 ImpliedAttribute("CHARSET", pThis->u.u_subhead.charset);
3886 ImpliedAttribute("TYPE", pThis->u.u_subhead.type);
3887 ImpliedAttribute("SSI", pThis->u.u_subhead.ssi);
3888 ImpliedAttribute("ABBREV", pThis->u.u_subhead.abbrev);
3890 pThis->beenEmitted = TRUE;
3892 if (pThis->u.u_subhead.pAtomicOrPCDATA)
3894 PushThisElement(pThis);
3896 pThis = pThis->u.u_subhead.pAtomicOrPCDATA;
3897 pThat->u.u_subhead.pAtomicOrPCDATA = NULL;
3903 pThis = pThat->pNext;
3904 pThat->pNext = NULL;
3905 DeleteElement(pThat);
3906 CloseNamedTag("SUBHEAD", FALSE);
3909 DeleteElement(pThis);
3910 CloseNamedTag("SUBHEAD", FALSE);
3911 pThis = PopThisElement();
3914 if (!pThis->beenEmitted)
3916 OpenNamedTag("ANCHOR", TRUE, FALSE);
3917 RequiredAttribute("ID", pThis->u.u_anchor.id);
3918 AddToLOIDS("ANCHOR",
3919 pThis->u.u_anchor.id,
3924 pThis->beenEmitted = TRUE;
3929 pThis = pThat->pNext;
3930 pThat->pNext = NULL;
3931 DeleteElement(pThat);
3934 DeleteElement(pThis);
3935 pThis = PopThisElement();
3938 if (!pThis->beenEmitted)
3940 OpenNamedTag("LINK", TRUE, FALSE);
3941 RequiredAttribute("RID", pThis->u.u_link.rid);
3942 ImpliedAttribute("BUTTON", pThis->u.u_link.button);
3943 ImpliedAttribute("LINKINFO", pThis->u.u_link.linkinfo);
3944 ImpliedAttribute("DESCRIPT", pThis->u.u_link.descript);
3945 ImpliedAttribute("WINDOW", pThis->u.u_link.window);
3946 ImpliedAttribute("TRAVERSAL", pThis->u.u_link.traversal);
3948 pThis->beenEmitted = TRUE;
3950 if (pThis->u.u_link.pAtomicOrPCDATA)
3952 PushThisElement(pThis);
3954 pThis = pThis->u.u_link.pAtomicOrPCDATA;
3955 pThat->u.u_link.pAtomicOrPCDATA = NULL;
3961 pThis = pThat->pNext;
3962 pThat->pNext = NULL;
3963 DeleteElement(pThat);
3964 CloseNamedTag("LINK", FALSE);
3967 DeleteElement(pThis);
3968 CloseNamedTag("LINK", FALSE);
3969 pThis = PopThisElement();
3972 if (!pThis->beenEmitted)
3974 OpenNamedTag("SNREF", TRUE, FALSE);
3975 ImpliedAttribute("ID", pThis->u.u_snref.id);
3977 pThis->u.u_snref.id,
3982 pThis->beenEmitted = TRUE;
3984 if (pThis->u.u_snref.pRefitem)
3986 PushThisElement(pThis);
3988 pThis = pThis->u.u_snref.pRefitem;
3989 pThat->u.u_snref.pRefitem = NULL;
3992 if (pThis->u.u_snref.pAlttext)
3994 PushThisElement(pThis);
3996 pThis = pThis->u.u_snref.pAlttext;
3997 pThat->u.u_snref.pAlttext = NULL;
4003 pThis = pThat->pNext;
4004 pThat->pNext = NULL;
4005 DeleteElement(pThat);
4006 CloseNamedTag("SNREF", FALSE);
4009 DeleteElement(pThis);
4010 CloseNamedTag("SNREF", FALSE);
4011 pThis = PopThisElement();
4014 if (!pThis->beenEmitted)
4016 OpenNamedTag("REFITEM", TRUE, FALSE);
4017 RequiredAttribute("RID", pThis->u.u_refitem.rid);
4018 RequiredAttribute("CLASS", pThis->u.u_refitem.class);
4019 ImpliedAttribute("BUTTON", pThis->u.u_refitem.button);
4020 ImpliedAttribute("SSI", pThis->u.u_refitem.ssi);
4022 pThis->beenEmitted = TRUE;
4024 if (pThis->u.u_refitem.pHead)
4026 PushThisElement(pThis);
4028 pThis = pThis->u.u_refitem.pHead;
4029 pThat->u.u_refitem.pHead = NULL;
4035 pThis = pThat->pNext;
4036 pThat->pNext = NULL;
4037 DeleteElement(pThat);
4038 CloseNamedTag("REFITEM", TRUE);
4041 DeleteElement(pThis);
4042 CloseNamedTag("REFITEM", TRUE);
4043 pThis = PopThisElement();
4046 if (!pThis->beenEmitted)
4048 OpenNamedTag("ALTTEXT", FALSE, FALSE);
4049 pThis->beenEmitted = TRUE;
4051 if (pThis->u.u_alttext.pCDATA)
4053 PushThisElement(pThis);
4055 pThis = pThis->u.u_alttext.pCDATA;
4056 pThat->u.u_alttext.pCDATA = NULL;
4062 pThis = pThat->pNext;
4063 pThat->pNext = NULL;
4064 DeleteElement(pThat);
4065 CloseNamedTag("ALTTEXT", TRUE);
4068 DeleteElement(pThis);
4069 CloseNamedTag("ALTTEXT", TRUE);
4070 pThis = PopThisElement();
4073 if (!pThis->beenEmitted)
4075 OpenNamedTag("REV", FALSE, FALSE);
4076 pThis->beenEmitted = TRUE;
4078 if (pThis->u.u_rev.pAtomicOrPCDATA)
4080 PushThisElement(pThis);
4082 pThis = pThis->u.u_rev.pAtomicOrPCDATA;
4083 pThat->u.u_rev.pAtomicOrPCDATA = NULL;
4089 pThis = pThat->pNext;
4090 pThat->pNext = NULL;
4091 DeleteElement(pThat);
4092 CloseNamedTag("REV", FALSE);
4095 DeleteElement(pThis);
4096 CloseNamedTag("REV", FALSE);
4097 pThis = PopThisElement();
4100 if (!pThis->beenEmitted)
4102 OpenNamedTag("KEY", TRUE, FALSE);
4103 ImpliedAttribute("CHARSET", pThis->u.u_key.charset);
4104 RequiredAttribute("CLASS", pThis->u.u_key.class);
4105 ImpliedAttribute("SSI", pThis->u.u_key.ssi);
4107 pThis->beenEmitted = TRUE;
4109 if (pThis->u.u_key.pAtomicOrPCDATA)
4111 PushThisElement(pThis);
4113 pThis = pThis->u.u_key.pAtomicOrPCDATA;
4114 pThat->u.u_key.pAtomicOrPCDATA = NULL;
4120 pThis = pThat->pNext;
4121 pThat->pNext = NULL;
4122 DeleteElement(pThat);
4123 CloseNamedTag("KEY", FALSE);
4126 DeleteElement(pThis);
4127 CloseNamedTag("KEY", FALSE);
4128 pThis = PopThisElement();
4131 if (!pThis->beenEmitted)
4133 OpenNamedTag("SPHRASE", TRUE, FALSE);
4134 RequiredAttribute("CLASS", pThis->u.u_sphrase.class);
4135 ImpliedAttribute("SSI", pThis->u.u_sphrase.ssi);
4137 pThis->beenEmitted = TRUE;
4139 if (pThis->u.u_sphrase.pSpcOrPCDATA)
4141 PushThisElement(pThis);
4143 pThis = pThis->u.u_sphrase.pSpcOrPCDATA;
4144 pThat->u.u_sphrase.pSpcOrPCDATA = NULL;
4150 pThis = pThat->pNext;
4151 pThat->pNext = NULL;
4152 DeleteElement(pThat);
4153 CloseNamedTag("SPHRASE", FALSE);
4156 DeleteElement(pThis);
4157 CloseNamedTag("SPHRASE", FALSE);
4158 pThis = PopThisElement();
4161 if (!pThis->beenEmitted)
4163 OpenNamedTag("IF", FALSE, FALSE);
4164 pThis->beenEmitted = TRUE;
4166 if (pThis->u.u_if.pCond)
4168 PushThisElement(pThis);
4170 pThis = pThis->u.u_if.pCond;
4171 pThat->u.u_if.pCond = NULL;
4174 if (pThis->u.u_if.pThen)
4176 PushThisElement(pThis);
4178 pThis = pThis->u.u_if.pThen;
4179 pThat->u.u_if.pThen = NULL;
4182 if (pThis->u.u_if.pElse)
4184 PushThisElement(pThis);
4186 pThis = pThis->u.u_if.pElse;
4187 pThat->u.u_if.pElse = NULL;
4193 pThis = pThat->pNext;
4194 pThat->pNext = NULL;
4195 DeleteElement(pThat);
4196 CloseNamedTag("IF", FALSE);
4199 DeleteElement(pThis);
4200 CloseNamedTag("IF", FALSE);
4201 pThis = PopThisElement();
4204 if (!pThis->beenEmitted)
4206 OpenNamedTag("COND", TRUE, FALSE);
4207 ImpliedAttribute("INTERP", pThis->u.u_cond.interp);
4209 pThis->beenEmitted = TRUE;
4211 if (pThis->u.u_cond.pCDATA)
4213 PushThisElement(pThis);
4215 pThis = pThis->u.u_cond.pCDATA;
4216 pThat->u.u_cond.pCDATA = NULL;
4222 pThis = pThat->pNext;
4223 pThat->pNext = NULL;
4224 DeleteElement(pThat);
4225 CloseNamedTag("COND", TRUE);
4228 DeleteElement(pThis);
4229 CloseNamedTag("COND", TRUE);
4230 pThis = PopThisElement();
4233 if (!pThis->beenEmitted)
4235 OpenNamedTag("THEN", FALSE, FALSE);
4236 pThis->beenEmitted = TRUE;
4238 if (pThis->u.u_then.pAtomicOrPCDATA)
4240 PushThisElement(pThis);
4242 pThis = pThis->u.u_then.pAtomicOrPCDATA;
4243 pThat->u.u_then.pAtomicOrPCDATA = NULL;
4249 pThis = pThat->pNext;
4250 pThat->pNext = NULL;
4251 DeleteElement(pThat);
4252 CloseNamedTag("THEN", TRUE);
4255 DeleteElement(pThis);
4256 CloseNamedTag("THEN", TRUE);
4257 pThis = PopThisElement();
4260 if (!pThis->beenEmitted)
4262 OpenNamedTag("ELSE", FALSE, FALSE);
4263 pThis->beenEmitted = TRUE;
4265 if (pThis->u.u_else.pAtomicOrPCDATA)
4267 PushThisElement(pThis);
4269 pThis = pThis->u.u_else.pAtomicOrPCDATA;
4270 pThat->u.u_else.pAtomicOrPCDATA = NULL;
4276 pThis = pThat->pNext;
4277 pThat->pNext = NULL;
4278 DeleteElement(pThat);
4279 CloseNamedTag("ELSE", TRUE);
4282 DeleteElement(pThis);
4283 CloseNamedTag("ELSE", TRUE);
4284 pThis = PopThisElement();
4287 if (!pThis->beenEmitted)
4289 OpenNamedTag("SPC", TRUE, FALSE);
4290 RequiredAttribute("NAME", pThis->u.u_spc.name);
4292 pThis->beenEmitted = TRUE;
4297 pThis = pThat->pNext;
4298 pThat->pNext = NULL;
4299 DeleteElement(pThat);
4302 DeleteElement(pThis);
4303 pThis = PopThisElement();
4306 if (!pThis->beenEmitted)
4308 OpenNamedTag("GRAPHIC", TRUE, FALSE);
4309 RequiredAttribute("ID", pThis->u.u_graphic.id);
4310 AddToLOIDS("GRAPHIC",
4311 pThis->u.u_graphic.id,
4315 ImpliedAttribute("FORMAT", pThis->u.u_graphic.format);
4316 ImpliedAttribute("METHOD", pThis->u.u_graphic.method);
4317 RequiredAttribute("XID", pThis->u.u_graphic.xid);
4319 pThis->beenEmitted = TRUE;
4324 pThis = pThat->pNext;
4325 pThat->pNext = NULL;
4326 DeleteElement(pThat);
4329 DeleteElement(pThis);
4330 pThis = PopThisElement();
4333 if (!pThis->beenEmitted)
4335 OpenNamedTag("TEXT", TRUE, FALSE);
4336 RequiredAttribute("ID", pThis->u.u_text.id);
4342 ImpliedAttribute("LANGUAGE", pThis->u.u_text.language);
4343 ImpliedAttribute("CHARSET", pThis->u.u_text.charset);
4345 pThis->beenEmitted = TRUE;
4347 if (pThis->u.u_text.pCpOrP)
4349 PushThisElement(pThis);
4351 pThis = pThis->u.u_text.pCpOrP;
4352 pThat->u.u_text.pCpOrP = NULL;
4358 pThis = pThat->pNext;
4359 pThat->pNext = NULL;
4360 DeleteElement(pThat);
4361 CloseNamedTag("TEXT", TRUE);
4364 DeleteElement(pThis);
4365 CloseNamedTag("TEXT", TRUE);
4366 pThis = PopThisElement();
4369 if (!pThis->beenEmitted)
4371 OpenNamedTag("AUDIO", TRUE, FALSE);
4372 RequiredAttribute("ID", pThis->u.u_audio.id);
4374 pThis->u.u_audio.id,
4378 ImpliedAttribute("FORMAT", pThis->u.u_audio.format);
4379 ImpliedAttribute("METHOD", pThis->u.u_audio.method);
4380 RequiredAttribute("XID", pThis->u.u_audio.xid);
4382 pThis->beenEmitted = TRUE;
4387 pThis = pThat->pNext;
4388 pThat->pNext = NULL;
4389 DeleteElement(pThat);
4392 DeleteElement(pThis);
4393 pThis = PopThisElement();
4396 if (!pThis->beenEmitted)
4398 OpenNamedTag("VIDEO", TRUE, FALSE);
4399 RequiredAttribute("ID", pThis->u.u_video.id);
4401 pThis->u.u_video.id,
4405 ImpliedAttribute("FORMAT", pThis->u.u_video.format);
4406 ImpliedAttribute("METHOD", pThis->u.u_video.method);
4407 RequiredAttribute("XID", pThis->u.u_video.xid);
4409 pThis->beenEmitted = TRUE;
4414 pThis = pThat->pNext;
4415 pThat->pNext = NULL;
4416 DeleteElement(pThat);
4419 DeleteElement(pThis);
4420 pThis = PopThisElement();
4423 if (!pThis->beenEmitted)
4425 OpenNamedTag("ANIMATE", TRUE, FALSE);
4426 RequiredAttribute("ID", pThis->u.u_animate.id);
4427 AddToLOIDS("ANIMATE",
4428 pThis->u.u_animate.id,
4432 ImpliedAttribute("FORMAT", pThis->u.u_animate.format);
4433 ImpliedAttribute("METHOD", pThis->u.u_animate.method);
4434 RequiredAttribute("XID", pThis->u.u_animate.xid);
4436 pThis->beenEmitted = TRUE;
4441 pThis = pThat->pNext;
4442 pThat->pNext = NULL;
4443 DeleteElement(pThat);
4446 DeleteElement(pThis);
4447 pThis = PopThisElement();
4450 if (!pThis->beenEmitted)
4452 OpenNamedTag("SCRIPT", TRUE, FALSE);
4453 RequiredAttribute("ID", pThis->u.u_script.id);
4454 AddToLOIDS("SCRIPT",
4455 pThis->u.u_script.id,
4459 ImpliedAttribute("INTERP", pThis->u.u_script.interp);
4461 pThis->beenEmitted = TRUE;
4463 if (pThis->u.u_script.pCDATA)
4465 PushThisElement(pThis);
4467 pThis = pThis->u.u_script.pCDATA;
4468 pThat->u.u_script.pCDATA = NULL;
4474 pThis = pThat->pNext;
4475 pThat->pNext = NULL;
4476 DeleteElement(pThat);
4477 CloseNamedTag("SCRIPT", TRUE);
4480 DeleteElement(pThis);
4481 CloseNamedTag("SCRIPT", TRUE);
4482 pThis = PopThisElement();
4485 if (!pThis->beenEmitted)
4487 OpenNamedTag("CROSSDOC", TRUE, FALSE);
4488 RequiredAttribute("ID", pThis->u.u_crossdoc.id);
4489 AddToLOIDS("CROSSDOC",
4490 pThis->u.u_crossdoc.id,
4494 RequiredAttribute("XID", pThis->u.u_crossdoc.xid);
4496 pThis->beenEmitted = TRUE;
4501 pThis = pThat->pNext;
4502 pThat->pNext = NULL;
4503 DeleteElement(pThat);
4506 DeleteElement(pThis);
4507 pThis = PopThisElement();
4510 if (!pThis->beenEmitted)
4512 OpenNamedTag("MAN-PAGE", TRUE, FALSE);
4513 RequiredAttribute("ID", pThis->u.u_man_page.id);
4514 AddToLOIDS("MAN-PAGE",
4515 pThis->u.u_man_page.id,
4519 RequiredAttribute("XID", pThis->u.u_man_page.xid);
4521 pThis->beenEmitted = TRUE;
4526 pThis = pThat->pNext;
4527 pThat->pNext = NULL;
4528 DeleteElement(pThat);
4531 DeleteElement(pThis);
4532 pThis = PopThisElement();
4535 if (!pThis->beenEmitted)
4537 OpenNamedTag("TEXTFILE", TRUE, FALSE);
4538 RequiredAttribute("ID", pThis->u.u_textfile.id);
4539 AddToLOIDS("TEXTFILE",
4540 pThis->u.u_textfile.id,
4544 RequiredAttribute("XID", pThis->u.u_textfile.xid);
4545 ImpliedAttribute("OFFSET", pThis->u.u_textfile.offset);
4546 ImpliedAttribute("FORMAT", pThis->u.u_textfile.format);
4548 pThis->beenEmitted = TRUE;
4553 pThis = pThat->pNext;
4554 pThat->pNext = NULL;
4555 DeleteElement(pThat);
4558 DeleteElement(pThis);
4559 pThis = PopThisElement();
4562 if (!pThis->beenEmitted)
4564 OpenNamedTag("SYS-CMD", TRUE, FALSE);
4565 RequiredAttribute("ID", pThis->u.u_sys_cmd.id);
4566 AddToLOIDS("SYS-CMD",
4567 pThis->u.u_sys_cmd.id,
4571 RequiredAttribute("COMMAND", pThis->u.u_sys_cmd.command);
4573 pThis->beenEmitted = TRUE;
4578 pThis = pThat->pNext;
4579 pThat->pNext = NULL;
4580 DeleteElement(pThat);
4583 DeleteElement(pThis);
4584 pThis = PopThisElement();
4587 if (!pThis->beenEmitted)
4589 OpenNamedTag("CALLBACK", TRUE, FALSE);
4590 RequiredAttribute("ID", pThis->u.u_callback.id);
4591 AddToLOIDS("CALLBACK",
4592 pThis->u.u_callback.id,
4596 ImpliedAttribute("DATA", pThis->u.u_callback.data);
4598 pThis->beenEmitted = TRUE;
4603 pThis = pThat->pNext;
4604 pThat->pNext = NULL;
4605 DeleteElement(pThat);
4608 DeleteElement(pThis);
4609 pThis = PopThisElement();
4612 if (!pThis->beenEmitted)
4614 OpenNamedTag("SWITCH", TRUE, FALSE);
4615 RequiredAttribute("ID", pThis->u.u_switch.id);
4616 AddToLOIDS("SWITCH",
4617 pThis->u.u_switch.id,
4621 ImpliedAttribute("INTERP", pThis->u.u_switch.interp);
4622 RequiredAttribute("BRANCHES", pThis->u.u_switch.branches);
4624 pThis->beenEmitted = TRUE;
4626 if (pThis->u.u_switch.pCDATA)
4628 PushThisElement(pThis);
4630 pThis = pThis->u.u_switch.pCDATA;
4631 pThat->u.u_switch.pCDATA = NULL;
4637 pThis = pThat->pNext;
4638 pThat->pNext = NULL;
4639 DeleteElement(pThat);
4640 CloseNamedTag("SWITCH", TRUE);
4643 DeleteElement(pThis);
4644 CloseNamedTag("SWITCH", TRUE);
4645 pThis = PopThisElement();
4648 pCurrentElement = pThis;
4650 PutWString(pThis->u.u_cdata.buffer);
4654 pThis = pThat->pNext;
4655 pThat->pNext = NULL;
4656 DeleteElement(pThat);
4659 DeleteElement(pThis);
4660 pThis = PopThisElement();
4663 if (!pThis->beenEmitted)
4665 OpenNamedTag("ENTRY", TRUE, FALSE);
4666 ImpliedAttribute("ID", pThis->u.u_entry.id);
4667 ImpliedAttribute("MAIN", pThis->u.u_entry.main);
4668 ImpliedAttribute("LOCS", pThis->u.u_entry.locs);
4669 ImpliedAttribute("SYNS", pThis->u.u_entry.syns);
4670 ImpliedAttribute("SORT", pThis->u.u_entry.sort);
4672 pThis->beenEmitted = TRUE;
4674 if (pThis->u.u_entry.pSimpleOrPCDATA)
4676 PushThisElement(pThis);
4678 pThis = pThis->u.u_entry.pSimpleOrPCDATA;
4679 pThat->u.u_entry.pSimpleOrPCDATA = NULL;
4682 if (pThis->u.u_entry.pEntry)
4684 PushThisElement(pThis);
4686 pThis = pThis->u.u_entry.pEntry;
4687 pThat->u.u_entry.pEntry = NULL;
4693 pThis = pThat->pNext;
4694 pThat->pNext = NULL;
4695 DeleteElement(pThat);
4696 CloseNamedTag("ENTRY", TRUE);
4699 DeleteElement(pThis);
4700 CloseNamedTag("ENTRY", TRUE);
4701 pThis = PopThisElement();
4704 OpenNamedTag("PHRASE", TRUE, FALSE);
4705 RequiredAttribute("TEXT", pThis->u.u_phrase.text);
4708 pThis = pThat->pNext;
4709 DeleteElement(pThat);
4712 if (minimalTossFlag && !pThis->u.u_keystyle.beenUsed)
4715 pThis = pThat->pNext;
4716 pThat->pNext = NULL;
4717 DeleteElement(pThat);
4720 OpenNamedTag("KEYSTYLE", TRUE, FALSE);
4721 RequiredAttribute("CLASS", pThis->u.u_keystyle.class);
4722 ImpliedAttribute("SSI", pThis->u.u_keystyle.ssi);
4723 ImpliedAttribute("RLEVEL", pThis->u.u_keystyle.rlevel);
4724 ImpliedAttribute("PHRASE", pThis->u.u_keystyle.phrase);
4725 ImpliedAttribute("SRCH-WT", pThis->u.u_keystyle.srch_wt);
4726 ImpliedAttribute("ENTER", pThis->u.u_keystyle.enter);
4727 ImpliedAttribute("EXIT", pThis->u.u_keystyle.exit);
4728 ImpliedAttribute("POINTSZ", pThis->u.u_keystyle.pointsz);
4729 ImpliedAttribute("SET-WIDTH", pThis->u.u_keystyle.set_width);
4730 ImpliedAttribute("COLOR", pThis->u.u_keystyle.color);
4731 ImpliedAttribute("XLFD", pThis->u.u_keystyle.xlfd);
4732 ImpliedAttribute("XLFDI", pThis->u.u_keystyle.xlfdi);
4733 ImpliedAttribute("XLFDB", pThis->u.u_keystyle.xlfdb);
4734 ImpliedAttribute("XLFDIB", pThis->u.u_keystyle.xlfdib);
4735 ImpliedAttribute("TYPENAM", pThis->u.u_keystyle.typenam);
4736 ImpliedAttribute("TYPENAMI", pThis->u.u_keystyle.typenami);
4737 ImpliedAttribute("TYPENAMB", pThis->u.u_keystyle.typenamb);
4738 ImpliedAttribute("TYPENAMIB", pThis->u.u_keystyle.typenamib);
4739 ImpliedAttribute("STYLE", pThis->u.u_keystyle.style);
4740 ImpliedAttribute("SPACING", pThis->u.u_keystyle.spacing);
4741 ImpliedAttribute("WEIGHT", pThis->u.u_keystyle.weight);
4742 ImpliedAttribute("SLANT", pThis->u.u_keystyle.slant);
4743 ImpliedAttribute("SPECIAL", pThis->u.u_keystyle.special);
4746 pThis = pThat->pNext;
4747 pThat->pNext = NULL;
4748 DeleteElement(pThat);
4751 if (minimalTossFlag && !pThis->u.u_headstyle.beenUsed)
4754 pThis = pThat->pNext;
4755 pThat->pNext = NULL;
4756 DeleteElement(pThat);
4759 OpenNamedTag("HEADSTYLE", TRUE, FALSE);
4760 RequiredAttribute("CLASS", pThis->u.u_headstyle.class);
4761 ImpliedAttribute("SSI", pThis->u.u_headstyle.ssi);
4762 ImpliedAttribute("RLEVEL", pThis->u.u_headstyle.rlevel);
4763 ImpliedAttribute("PHRASE", pThis->u.u_headstyle.phrase);
4764 ImpliedAttribute("SRCH-WT", pThis->u.u_headstyle.srch_wt);
4765 ImpliedAttribute("ORIENT", pThis->u.u_headstyle.orient);
4766 ImpliedAttribute("VORIENT", pThis->u.u_headstyle.vorient);
4767 ImpliedAttribute("PLACEMENT", pThis->u.u_headstyle.placement);
4768 ImpliedAttribute("HEADW", pThis->u.u_headstyle.headw);
4769 ImpliedAttribute("STACK", pThis->u.u_headstyle.stack);
4770 ImpliedAttribute("FLOW", pThis->u.u_headstyle.flow);
4771 ImpliedAttribute("POINTSZ", pThis->u.u_headstyle.pointsz);
4772 ImpliedAttribute("SET-WIDTH", pThis->u.u_headstyle.set_width);
4773 ImpliedAttribute("COLOR", pThis->u.u_headstyle.color);
4774 ImpliedAttribute("XLFD", pThis->u.u_headstyle.xlfd);
4775 ImpliedAttribute("XLFDI", pThis->u.u_headstyle.xlfdi);
4776 ImpliedAttribute("XLFDB", pThis->u.u_headstyle.xlfdb);
4777 ImpliedAttribute("XLFDIB", pThis->u.u_headstyle.xlfdib);
4778 ImpliedAttribute("TYPENAM", pThis->u.u_headstyle.typenam);
4779 ImpliedAttribute("TYPENAMI", pThis->u.u_headstyle.typenami);
4780 ImpliedAttribute("TYPENAMB", pThis->u.u_headstyle.typenamb);
4781 ImpliedAttribute("TYPENAMIB", pThis->u.u_headstyle.typenamib);
4782 ImpliedAttribute("STYLE", pThis->u.u_headstyle.style);
4783 ImpliedAttribute("SPACING", pThis->u.u_headstyle.spacing);
4784 ImpliedAttribute("WEIGHT", pThis->u.u_headstyle.weight);
4785 ImpliedAttribute("SLANT", pThis->u.u_headstyle.slant);
4786 ImpliedAttribute("SPECIAL", pThis->u.u_headstyle.special);
4787 ImpliedAttribute("L-MARGIN", pThis->u.u_headstyle.l_margin);
4788 ImpliedAttribute("R-MARGIN", pThis->u.u_headstyle.r_margin);
4789 ImpliedAttribute("T-MARGIN", pThis->u.u_headstyle.t_margin);
4790 ImpliedAttribute("B-MARGIN", pThis->u.u_headstyle.b_margin);
4791 ImpliedAttribute("BORDER", pThis->u.u_headstyle.border);
4792 ImpliedAttribute("VJUST", pThis->u.u_headstyle.vjust);
4793 ImpliedAttribute("JUSTIFY", pThis->u.u_headstyle.justify);
4796 pThis = pThat->pNext;
4797 pThat->pNext = NULL;
4798 DeleteElement(pThat);
4801 if (minimalTossFlag && !pThis->u.u_formstyle.beenUsed)
4804 pThis = pThat->pNext;
4805 pThat->pNext = NULL;
4806 DeleteElement(pThat);
4809 OpenNamedTag("FORMSTYLE", TRUE, FALSE);
4810 RequiredAttribute("CLASS", pThis->u.u_formstyle.class);
4811 ImpliedAttribute("SSI", pThis->u.u_formstyle.ssi);
4812 ImpliedAttribute("RLEVEL", pThis->u.u_formstyle.rlevel);
4813 ImpliedAttribute("PHRASE", pThis->u.u_formstyle.phrase);
4814 ImpliedAttribute("SRCH-WT", pThis->u.u_formstyle.srch_wt);
4815 ImpliedAttribute("COLW", pThis->u.u_formstyle.colw);
4816 ImpliedAttribute("COLJ", pThis->u.u_formstyle.colj);
4817 ImpliedAttribute("POINTSZ", pThis->u.u_formstyle.pointsz);
4818 ImpliedAttribute("SET-WIDTH", pThis->u.u_formstyle.set_width);
4819 ImpliedAttribute("COLOR", pThis->u.u_formstyle.color);
4820 ImpliedAttribute("XLFD", pThis->u.u_formstyle.xlfd);
4821 ImpliedAttribute("XLFDI", pThis->u.u_formstyle.xlfdi);
4822 ImpliedAttribute("XLFDB", pThis->u.u_formstyle.xlfdb);
4823 ImpliedAttribute("XLFDIB", pThis->u.u_formstyle.xlfdib);
4824 ImpliedAttribute("TYPENAM", pThis->u.u_formstyle.typenam);
4825 ImpliedAttribute("TYPENAMI", pThis->u.u_formstyle.typenami);
4826 ImpliedAttribute("TYPENAMB", pThis->u.u_formstyle.typenamb);
4827 ImpliedAttribute("TYPENAMIB", pThis->u.u_formstyle.typenamib);
4828 ImpliedAttribute("STYLE", pThis->u.u_formstyle.style);
4829 ImpliedAttribute("SPACING", pThis->u.u_formstyle.spacing);
4830 ImpliedAttribute("WEIGHT", pThis->u.u_formstyle.weight);
4831 ImpliedAttribute("SLANT", pThis->u.u_formstyle.slant);
4832 ImpliedAttribute("SPECIAL", pThis->u.u_formstyle.special);
4833 ImpliedAttribute("L-MARGIN", pThis->u.u_formstyle.l_margin);
4834 ImpliedAttribute("R-MARGIN", pThis->u.u_formstyle.r_margin);
4835 ImpliedAttribute("T-MARGIN", pThis->u.u_formstyle.t_margin);
4836 ImpliedAttribute("B-MARGIN", pThis->u.u_formstyle.b_margin);
4837 ImpliedAttribute("BORDER", pThis->u.u_formstyle.border);
4838 ImpliedAttribute("VJUST", pThis->u.u_formstyle.vjust);
4841 pThis = pThat->pNext;
4842 pThat->pNext = NULL;
4843 DeleteElement(pThat);
4846 if (minimalTossFlag && !pThis->u.u_frmtstyle.beenUsed)
4849 pThis = pThat->pNext;
4850 pThat->pNext = NULL;
4851 DeleteElement(pThat);
4854 OpenNamedTag("FRMTSTYLE", TRUE, FALSE);
4855 RequiredAttribute("CLASS", pThis->u.u_frmtstyle.class);
4856 ImpliedAttribute("SSI", pThis->u.u_frmtstyle.ssi);
4857 ImpliedAttribute("RLEVEL", pThis->u.u_frmtstyle.rlevel);
4858 ImpliedAttribute("PHRASE", pThis->u.u_frmtstyle.phrase);
4859 ImpliedAttribute("F-MARGIN", pThis->u.u_frmtstyle.f_margin);
4860 ImpliedAttribute("SRCH-WT", pThis->u.u_frmtstyle.srch_wt);
4861 ImpliedAttribute("POINTSZ", pThis->u.u_frmtstyle.pointsz);
4862 ImpliedAttribute("SET-WIDTH", pThis->u.u_frmtstyle.set_width);
4863 ImpliedAttribute("COLOR", pThis->u.u_frmtstyle.color);
4864 ImpliedAttribute("XLFD", pThis->u.u_frmtstyle.xlfd);
4865 ImpliedAttribute("XLFDI", pThis->u.u_frmtstyle.xlfdi);
4866 ImpliedAttribute("XLFDB", pThis->u.u_frmtstyle.xlfdb);
4867 ImpliedAttribute("XLFDIB", pThis->u.u_frmtstyle.xlfdib);
4868 ImpliedAttribute("TYPENAM", pThis->u.u_frmtstyle.typenam);
4869 ImpliedAttribute("TYPENAMI", pThis->u.u_frmtstyle.typenami);
4870 ImpliedAttribute("TYPENAMB", pThis->u.u_frmtstyle.typenamb);
4871 ImpliedAttribute("TYPENAMIB", pThis->u.u_frmtstyle.typenamib);
4872 ImpliedAttribute("STYLE", pThis->u.u_frmtstyle.style);
4873 ImpliedAttribute("SPACING", pThis->u.u_frmtstyle.spacing);
4874 ImpliedAttribute("WEIGHT", pThis->u.u_frmtstyle.weight);
4875 ImpliedAttribute("SLANT", pThis->u.u_frmtstyle.slant);
4876 ImpliedAttribute("SPECIAL", pThis->u.u_frmtstyle.special);
4877 ImpliedAttribute("L-MARGIN", pThis->u.u_frmtstyle.l_margin);
4878 ImpliedAttribute("R-MARGIN", pThis->u.u_frmtstyle.r_margin);
4879 ImpliedAttribute("T-MARGIN", pThis->u.u_frmtstyle.t_margin);
4880 ImpliedAttribute("B-MARGIN", pThis->u.u_frmtstyle.b_margin);
4881 ImpliedAttribute("BORDER", pThis->u.u_frmtstyle.border);
4882 ImpliedAttribute("VJUST", pThis->u.u_frmtstyle.vjust);
4883 ImpliedAttribute("JUSTIFY", pThis->u.u_frmtstyle.justify);
4886 pThis = pThat->pNext;
4887 pThat->pNext = NULL;
4888 DeleteElement(pThat);
4891 if (minimalTossFlag && !pThis->u.u_grphstyle.beenUsed)
4894 pThis = pThat->pNext;
4895 pThat->pNext = NULL;
4896 DeleteElement(pThat);
4899 OpenNamedTag("GRPHSTYLE", TRUE, FALSE);
4900 RequiredAttribute("CLASS", pThis->u.u_grphstyle.class);
4901 ImpliedAttribute("SSI", pThis->u.u_grphstyle.ssi);
4902 ImpliedAttribute("RLEVEL", pThis->u.u_grphstyle.rlevel);
4903 ImpliedAttribute("PHRASE", pThis->u.u_grphstyle.phrase);
4904 ImpliedAttribute("L-MARGIN", pThis->u.u_grphstyle.l_margin);
4905 ImpliedAttribute("R-MARGIN", pThis->u.u_grphstyle.r_margin);
4906 ImpliedAttribute("T-MARGIN", pThis->u.u_grphstyle.t_margin);
4907 ImpliedAttribute("B-MARGIN", pThis->u.u_grphstyle.b_margin);
4908 ImpliedAttribute("BORDER", pThis->u.u_grphstyle.border);
4909 ImpliedAttribute("VJUST", pThis->u.u_grphstyle.vjust);
4910 ImpliedAttribute("JUSTIFY", pThis->u.u_grphstyle.justify);
4913 pThis = pThat->pNext;
4914 pThat->pNext = NULL;
4915 DeleteElement(pThat);
4918 fprintf(stderr, "%s\n", errMess);
4919 if (m_errfile && (m_errfile != stderr))
4920 fprintf(m_errfile, "%s\n", errMess);
4927 FcloseFile(outFile, compFileName, xxx);
4928 outFile = saveOutFile;
4929 zFileSize = Compress(compFileName, compZFileName, TRUE);
4931 /* write out the magic number and the file size */
4932 zTemp[3] = zFileSize % 256;
4934 zTemp[2] = zFileSize % 256;
4936 zTemp[1] = zFileSize % 256;
4938 FwriteFile(outFile, tempFileName, (char *) zTemp, 4, xxx);
4940 /* copy the compressed virpage to output */
4941 zFd = OpenFile(compZFileName, O_RDONLY, xxx);
4942 while (length = ReadFile(zFd, compZFileName, buffer, BUFSIZ, xxx))
4943 FwriteFile(outFile, tempFileName, buffer, length, xxx);
4944 CloseFile(zFd, compZFileName, xxx);
4945 unlink(compZFileName);
4946 unlink(compFileName);
4951 #if defined(M_PROTO)
4952 void OptimizeAndEmit(ElementPtr pVirpage)
4954 void OptimizeAndEmit(pVirpage)
4955 ElementPtr pVirpage;
4959 OptimizeSDL(&(pVirpage->u.u_virpage.pBlockOrForm));
4964 /* A routine to emit a help message and exit */
4967 printf("The available options to %s are 'c', 'd', 'h', 'o' and 't'.\n\n",
4969 printf("Their meanings are:\n");
4970 printf(" c: compress an SDL document (on a per virtual page basis)\n");
4971 printf(" d: decompress an SDL document\n");
4972 printf(" h: print this message and exit\n");
4973 printf(" o: perform peephole optimizations on this SDL document\n");
4974 printf(" t: eliminate any TOSS elements not used in this SDL document\n\n");
4975 printf("You may specify either one filename or two. If one file is\n");
4976 printf("specified, it will be used as both the input and output file.\n");
4977 printf("If the input file has no .sdl extension, one will be added. If\n");
4978 printf("an explicit output filename is specified, it will be used without\n");
4979 printf("modification.\n\n");
4984 /* A routine to emit a usage message and exit */
4988 "Usage: %s [-cdhot] <inFileName> [<outFileName>]\n",
4990 if (m_errfile && (m_errfile != stderr))
4993 "Usage: %s [-cdhot] <inFileName> [<outFileName>]\n",
5001 * A routine to pre-build all the input, output and intermediate file
5002 * names that we'll need.
5004 static void MakeFileNames()
5012 progName = strrchr(*m_argv, '/');
5013 if (progName) progName++;
5014 else progName = *m_argv;
5017 while ((c = getopt(m_argc, m_argv, "cdhot")) != -1)
5022 compressFlag = TRUE;
5025 decompressFlag = TRUE;
5030 optimizeFlag = TRUE;
5033 minimalTossFlag = TRUE;
5039 argCount += (optind - 1);
5041 if (((m_argc - argCount) < 1) || ((m_argc - argCount) > 2))
5044 inFileName = m_argv[argCount++];
5045 outFileName = m_argv[argCount]; /* may be NULL */
5047 cp = strrchr(inFileName, '.');
5050 if (strcmp(cp, dotSDL) == 0)
5052 length = cp - inFileName;
5053 cp = malloc(length + 1);
5054 strncpy(cp, inFileName, length);
5064 length = strlen(cp);
5065 inFileName = malloc(length + DOTSDLSIZ);
5066 strcpy(inFileName, cp);
5067 strcat(inFileName, dotSDL);
5069 outFileName = inFileName;
5071 errFileName = malloc(length + DOTERRSIZ);
5072 strcpy(errFileName, cp);
5073 strcat(errFileName, dotERR);
5075 idxFileName = malloc(length + DOTIDXSIZ);
5076 strcpy(idxFileName, cp);
5077 strcat(idxFileName, dotIDX);
5079 snbFileName = malloc(length + DOTSNBSIZ);
5080 strcpy(snbFileName, cp);
5081 strcat(snbFileName, dotSNB);
5083 tossFileName = malloc(length + DOTTSSSIZ);
5084 strcpy(tossFileName, cp);
5085 strcat(tossFileName, dotTSS);
5087 tmpDir = getenv("TMPDIR");
5090 sprintf(pid, "%d", getpid());
5091 length = DOTSDLSIZ - 1 + strlen(tmpDir) + strlen(pid) + 1;
5092 tempFileName = malloc(length);
5093 strcpy(tempFileName, tmpDir);
5094 strcat(tempFileName, "/");
5095 strcat(tempFileName, dotSDL + 1); /* skip the "." */
5096 strcat(tempFileName, pid);
5097 compFileName = malloc(length + 4);
5098 strcpy(compFileName, tempFileName);
5099 strcat(compFileName, "comp");
5100 compZFileName = malloc(length + 4 + 2);
5101 strcpy(compZFileName, compFileName);
5102 strcat(compZFileName, ".Z");
5103 sortedIdxFileName = malloc(length + 3);
5104 strcpy(sortedIdxFileName, tempFileName);
5105 strcat(sortedIdxFileName, "idx");
5106 vstructFileName = malloc(length + 4);
5107 strcpy(vstructFileName, tempFileName);
5108 strcat(vstructFileName, "vstr");
5114 * Some small and obvious utility routines for opening,
5115 * reading, writing and closing files. Most have versions for both
5116 * file descriptor and stream operations. When possible, the file
5117 * descriptor (unbuffered) versions are used for performance reasons.
5118 * Of course, when using the unbuffered versions we attempt to read in
5119 * BUFSIZ characters at a time.
5121 #if defined(M_PROTO)
5122 int OpenFile(char *name, int type, int code)
5124 int OpenFile(name, type, code)
5134 if ((oflag = type) == O_WRONLY)
5140 if ((fd = open(name, oflag, mode)) == -1)
5143 "%s: error opening \"%s\" for %s\n",
5146 (type == O_RDONLY) ? "reading" : "writing");
5148 if (m_errfile && (m_errfile != stderr))
5151 "%s: error opening \"%s\" for %s\n",
5154 (type == O_RDONLY) ? "reading" : "writing");
5155 fprintf(m_errfile, "%s: %s", name, strerror(errno));
5163 #if defined(M_PROTO)
5164 int ReadFile(int fd, char *name, char *buffer, int amount, int code)
5166 int ReadFile(fd, name, buffer, amount, code)
5176 if ((length = read(fd, buffer, amount)) == -1)
5178 fprintf(stderr, "%s: error reading from \"%s\"\n", progName, name);
5180 if (m_errfile && (m_errfile != stderr))
5182 fprintf(m_errfile, "%s: error reading from \"%s\"\n", progName, name);
5183 fprintf(m_errfile, "%s: %s", name, strerror(errno));
5191 #if defined(M_PROTO)
5192 int WriteFile(int fd, char *name, char *buffer, int amount, int code)
5194 int WriteFile(fd, name, buffer, amount, code)
5204 if ((length = write(fd, buffer, amount)) == -1)
5206 fprintf(stderr, "%s: error writing to \"%s\"\n", progName, name);
5208 if (m_errfile && (m_errfile != stderr))
5210 fprintf(m_errfile, "%s: error writing to \"%s\"\n", progName, name);
5211 fprintf(m_errfile, "%s: %s", name, strerror(errno));
5219 #if defined(M_PROTO)
5220 int FileExists(char *name)
5222 int FileExists(name)
5226 if (access(name, F_OK) == 0) return 1;
5231 #if defined(M_PROTO)
5232 void AssertFileIsReadable(char *name, int code)
5234 void AssertFileIsReadable(name, code)
5239 if (access(name, R_OK) == -1)
5241 fprintf(stderr, "%s: cannot open \"%s\" for reading\n", progName, name);
5243 if (m_errfile && (m_errfile != stderr))
5246 "%s: cannot open \"%s\" for reading\n",
5249 fprintf(m_errfile, "%s: %s", name, strerror(errno));
5256 #if defined(M_PROTO)
5257 int FileSize(char *name, int code)
5259 int FileSize(name, code)
5266 if (stat(name, &buf) == -1)
5268 fprintf(stderr, "%s: error getting size of \"%s\"\n", progName, name);
5270 if (m_errfile && (m_errfile != stderr))
5273 "%s: error getting size of \"%s\"\n",
5276 fprintf(m_errfile, "%s: %s", name, strerror(errno));
5285 #if defined(M_PROTO)
5286 void CloseFile(int fd, char *name, int code)
5288 void CloseFile(fd, name, code)
5294 if (close(fd) == -1)
5296 fprintf(stderr, "%s: error closing \"%s\"\n", progName, name);
5298 if (m_errfile && (m_errfile != stderr))
5300 fprintf(m_errfile, "%s: error closing \"%s\"\n", progName, name);
5301 fprintf(m_errfile, "%s: %s", name, strerror(errno));
5308 #if defined(M_PROTO)
5309 FILE * FopenFile(char *name, int type, int code)
5311 FILE * FopenFile(name, type, code)
5320 if (type == O_RDONLY)
5322 else if (type == O_WRONLY)
5324 else if (type == (O_WRONLY|O_APPEND))
5329 "%s: bad type (%d) in opening \"%s\"",
5333 if (m_errfile && (m_errfile != stderr))
5336 "%s: bad type (%d) in opening \"%s\"",
5344 if ((file = fopen(name, mode)) == NULL)
5347 "%s: error opening \"%s\" for %s\n",
5350 (*mode == 'r') ? "reading" :
5351 (*mode == 'w') ? "writing" : "appending");
5353 if (m_errfile && (m_errfile != stderr))
5356 "%s: error opening \"%s\" for %s\n",
5359 (*mode == 'r') ? "reading" :
5360 (*mode == 'w') ? "writing" : "appending");
5361 fprintf(m_errfile, "%s: %s", name, strerror(errno));
5369 #if defined(M_PROTO)
5370 int GetALine(FILE *file, char *name, char *line, int max, int code)
5372 int GetALine(file, name, line, max, code)
5383 pc = fgets(line, max, file);
5393 "%s: error getting a line from \"%s\"\n",
5397 if (m_errfile && (m_errfile != stderr))
5400 "%s: error getting a line from \"%s\"\n",
5403 fprintf(m_errfile, "%s: %s", name, strerror(errno));
5409 length = strlen(pc);
5410 if ((length >= (max - 1)) && (line[max-1] != '\n'))
5413 "%s: line longer than %d bytes in file \"%s\"\n",
5417 if (m_errfile && (m_errfile != stderr))
5420 "%s: line longer than %d bytes in file \"%s\"\n",
5431 #if defined(M_PROTO)
5432 int FreadFile(FILE *file, char *name, char *buffer, int amount, int code)
5434 int FreadFile(file, name, buffer, amount, code)
5444 if ((length = fread(buffer, sizeof(char), amount, file)) == -1)
5446 fprintf(stderr, "%s: error reading from \"%s\"\n", progName, name);
5448 if (m_errfile && (m_errfile != stderr))
5450 fprintf(m_errfile, "%s: error reading from \"%s\"\n", progName, name);
5451 fprintf(m_errfile, "%s: %s", name, strerror(errno));
5459 #if defined(M_PROTO)
5460 void FwriteFile(FILE *file, char *name, char *buffer, size_t amount, int code)
5462 void FwriteFile(file, name, buffer, amount, code)
5470 if (fwrite(buffer, 1, amount, file) != amount)
5472 fprintf(stderr, "%s: error writing to \"%s\"\n", progName, name);
5474 if (m_errfile && (m_errfile != stderr))
5476 fprintf(m_errfile, "%s: error writing to \"%s\"\n", progName, name);
5477 fprintf(m_errfile, "%s: %s", name, strerror(errno));
5484 #if defined(M_PROTO)
5485 void FcloseFile(FILE *file, char *name, int code)
5487 void FcloseFile(file, name, code)
5493 if (fclose(file) != 0)
5495 fprintf(stderr, "%s: error closing \"%s\"\n", progName, name);
5497 if (m_errfile && (m_errfile != stderr))
5499 fprintf(m_errfile, "%s: error closing \"%s\"\n", progName, name);
5500 fprintf(m_errfile, "%s: %s", name, strerror(errno));
5507 #if defined(M_PROTO)
5508 int StringToUpper(char *string)
5510 int StringToUpper(string)
5519 if (isalpha(c) && islower(c)) *pc = toupper(c);
5527 * A routine to build the index from the .idx file (if any).
5531 char buffer[BUFSIZ+1], *pFrom, *pTo, *pRestart, thisChar;
5540 static char openIndex[] = "<INDEX COUNT=\"%d\">\n";
5541 static char closeIndex[] = "</INDEX>\n";
5542 static char openEntry[] = "<ENTRY LOCS=\"";
5543 static char closeEntry[] = "</ENTRY>\n";
5544 char sort[BUFSIZ], text[BUFSIZ], rid[BUFSIZ];
5545 char lastsort[BUFSIZ], lasttext[BUFSIZ], lastrid[BUFSIZ];
5548 /* skip the index building step if no .idx file or .idx file is empty */
5549 if (!FileExists(idxFileName) || (FileSize(idxFileName, xxx) == 0))
5552 AssertFileIsReadable(idxFileName, xxx);
5556 sortedIdxFd = OpenFile(sortedIdxFileName, O_WRONLY, xxx);
5557 CloseFile(sortedIdxFd, sortedIdxFileName, xxx);
5561 sprintf(buffer, "env LANG=%s ", operantLocale);
5563 sprintf(buffer + strlen(buffer),
5567 if (status = system(buffer))
5572 "%s: error forking to execute \"%s\"\n",
5576 if (m_errfile && (m_errfile != stderr))
5579 "%s: error forking to execute \"%s\"\n",
5582 fprintf(m_errfile, "%s: %s", buffer, strerror(errno));
5588 fprintf(stderr, "%s: error executing \"%s\"\n", progName, buffer);
5589 if (m_errfile && (m_errfile != stderr))
5592 "%s: error executing \"%s\"\n",
5600 /* get the number of index entries */
5602 sortedIdxFd = OpenFile(sortedIdxFileName, O_RDONLY, xxx);
5607 buffer[BUFSIZ] = '\0';
5612 ((size = ReadFile(sortedIdxFd,
5618 /* add in remnant in case we just got a new buffer load */
5622 /* First split out the "sort", "text" and "rid" fields. They are
5623 separated by an ASCII Record Seperator (036) character */
5629 if ((*pTo++ = *pFrom++) == RS)
5640 while (*pTo++ = *pFrom++);
5641 remnant = pTo - buffer - 1;
5651 thisChar = *pFrom++;
5658 if ((thisChar == '<') || (thisChar == '&'))
5667 while (*pTo++ = *pFrom++);
5668 remnant = pTo - buffer - 1;
5677 if ((*pTo++ = *pFrom++) == '\n')
5688 while (*pTo++ = *pFrom++);
5689 remnant = pTo - buffer - 1;
5695 /* if buffer is consumed, reset ourselves for the next buffer load */
5703 if (strcmp(text, lasttext) == 0)
5705 if (strcmp(rid, lastrid) != 0)
5713 if (strlen(locs) != 0)
5717 strcpy(lasttext, text);
5718 strcpy(lastsort, sort);
5719 strcpy(lastrid, rid);
5721 if (strlen(locs) != 0)
5723 CloseFile(sortedIdxFd, sortedIdxFileName, xxx);
5725 sortedIdxFd = OpenFile(sortedIdxFileName, O_RDONLY, xxx);
5726 unlink(sortedIdxFileName);
5727 sdlIdxFile = FopenFile(sortedIdxFileName, O_WRONLY, xxx);
5729 fprintf(sdlIdxFile, openIndex, lineCount);
5735 buffer[BUFSIZ] = '\0';
5740 ((size = ReadFile(sortedIdxFd,
5746 /* add in remnant in case we just got a new buffer load */
5750 /* First split out the "sort", "text" and "rid" fields. They are
5751 separated by an ASCII Record Seperator (036) character */
5757 if ((*pTo++ = *pFrom++) == RS)
5768 while (*pTo++ = *pFrom++);
5769 remnant = pTo - buffer - 1;
5779 thisChar = *pFrom++;
5786 if ((thisChar == '<') || (thisChar == '&'))
5795 while (*pTo++ = *pFrom++);
5796 remnant = pTo - buffer - 1;
5805 if ((*pTo++ = *pFrom++) == '\n')
5816 while (*pTo++ = *pFrom++);
5817 remnant = pTo - buffer - 1;
5823 /* if buffer is consumed, reset ourselves for the next buffer load */
5831 if (strcmp(text, lasttext) == 0)
5833 if (strcmp(rid, lastrid) != 0)
5841 if (strlen(locs) != 0)
5843 if (strcmp(lastsort, lasttext) != 0)
5845 length = fprintf(sdlIdxFile,
5846 "%s%s\" SORT=\"%s\">%s%s",
5855 length = fprintf(sdlIdxFile,
5865 "%s: error writing to \"%s\"\n",
5868 perror(sortedIdxFileName);
5869 if (m_errfile && (m_errfile != stderr))
5872 "%s: error writing to \"%s\"\n",
5885 strcpy(lasttext, text);
5886 strcpy(lastsort, sort);
5887 strcpy(lastrid, rid);
5889 if (strlen(locs) != 0)
5891 if (strcmp(lastsort, lasttext) != 0)
5893 length = fprintf(sdlIdxFile,
5894 "%s%s\" SORT=\"%s\">%s%s",
5903 length = fprintf(sdlIdxFile,
5913 "%s: error writing to \"%s\"\n",
5916 perror(sortedIdxFileName);
5917 if (m_errfile && (m_errfile != stderr))
5920 "%s: error writing to \"%s\"\n",
5931 CloseFile(sortedIdxFd, sortedIdxFileName, xxx);
5932 FwriteFile(sdlIdxFile,
5935 sizeof(closeIndex)-1,
5937 FcloseFile(sdlIdxFile, sortedIdxFileName, xxx);
5941 static void HandleSNB()
5943 int oldOffset, newOffset;
5946 char line[LINEMAX], buffer[BUFSIZ];
5948 char *realInFileName;
5949 static char openSNB[] = "<SNB>\n";
5950 static char closeSNB[] = "</SNB>\n";
5953 realInFileName = tempFileName;
5955 realInFileName = inFileName;
5959 inFd = OpenFile(realInFileName, O_RDONLY, xxx);
5960 unlink(tempFileName);
5961 outFd = OpenFile(tempFileName, O_WRONLY, xxx);
5963 if (FileExists(snbFileName))
5965 snbFile = FopenFile(snbFileName, O_RDONLY, xxx);
5966 while ((length = GetALine(snbFile,
5980 newOffset = atoi(line);
5981 delta = newOffset - oldOffset;
5984 length = ReadFile(inFd,
5989 WriteFile(outFd, tempFileName, buffer, length, xxx);
5992 WriteFile(outFd, tempFileName, openSNB, sizeof(openSNB)-1, xxx);
5993 oldOffset = newOffset;
5996 WriteFile(outFd, tempFileName, line, length, xxx);
5999 WriteFile(outFd, tempFileName, closeSNB, sizeof(closeSNB)-1, xxx);
6000 FcloseFile(snbFile, snbFileName, xxx);
6002 while (length = ReadFile(inFd, realInFileName, buffer, BUFSIZ, xxx))
6003 WriteFile(outFd, tempFileName, buffer, length, xxx);
6004 CloseFile(inFd, realInFileName, xxx);
6005 CloseFile(outFd, tempFileName, xxx);
6009 /* calculate the size of the TOSS if only the used elements are
6012 static int RestrictedTossSize()
6018 /* in size computations, the constant "4" is for the leading space,
6019 the equals sign and the two quotation marks; the constant preceding
6020 the "4" is the length of the attribute name itself */
6021 size = 16 /* strlen("<TOSS COUNT=\"\">\n"); */;
6022 size += sprintf(buffer, "%d", nStyles);
6026 switch (pThis->type)
6029 if (!pThis->u.u_keystyle.beenUsed)
6031 size += 9 /* strlen("<KEYSTYLE") */;
6032 if (pThis->u.u_keystyle.class)
6033 size += 5 + 4 + w_strlen(pThis->u.u_keystyle.class);
6034 if (pThis->u.u_keystyle.ssi)
6035 size += 3 + 4 + w_strlen(pThis->u.u_keystyle.ssi);
6036 if (pThis->u.u_keystyle.rlevel)
6037 size += 6 + 4 + w_strlen(pThis->u.u_keystyle.rlevel);
6038 if (pThis->u.u_keystyle.phrase)
6039 size += 6 + 4 + w_strlen(pThis->u.u_keystyle.phrase);
6040 if (pThis->u.u_keystyle.srch_wt)
6041 size += 7 + 4 + w_strlen(pThis->u.u_keystyle.srch_wt);
6042 if (pThis->u.u_keystyle.enter)
6043 size += 5 + 4 + w_strlen(pThis->u.u_keystyle.enter);
6044 if (pThis->u.u_keystyle.exit)
6045 size += 4 + 4 + w_strlen(pThis->u.u_keystyle.exit);
6046 if (pThis->u.u_keystyle.pointsz)
6047 size += 7 + 4 + w_strlen(pThis->u.u_keystyle.pointsz);
6048 if (pThis->u.u_keystyle.set_width)
6049 size += 9 + 4 + w_strlen(pThis->u.u_keystyle.set_width);
6050 if (pThis->u.u_keystyle.color)
6051 size += 5 + 4 + w_strlen(pThis->u.u_keystyle.color);
6052 if (pThis->u.u_keystyle.xlfd)
6053 size += 4 + 4 + w_strlen(pThis->u.u_keystyle.xlfd);
6054 if (pThis->u.u_keystyle.xlfdi)
6055 size += 5 + 4 + w_strlen(pThis->u.u_keystyle.xlfdi);
6056 if (pThis->u.u_keystyle.xlfdb)
6057 size += 5 + 4 + w_strlen(pThis->u.u_keystyle.xlfdb);
6058 if (pThis->u.u_keystyle.xlfdib)
6059 size += 6 + 4 + w_strlen(pThis->u.u_keystyle.xlfdib);
6060 if (pThis->u.u_keystyle.typenam)
6061 size += 7 + 4 + w_strlen(pThis->u.u_keystyle.typenam);
6062 if (pThis->u.u_keystyle.typenami)
6063 size += 8 + 4 + w_strlen(pThis->u.u_keystyle.typenami);
6064 if (pThis->u.u_keystyle.typenamb)
6065 size += 8 + 4 + w_strlen(pThis->u.u_keystyle.typenamb);
6066 if (pThis->u.u_keystyle.typenamib)
6067 size += 9 + 4 + w_strlen(pThis->u.u_keystyle.typenamib);
6068 if (pThis->u.u_keystyle.style)
6069 size += 5 + 4 + w_strlen(pThis->u.u_keystyle.style);
6070 if (pThis->u.u_keystyle.spacing)
6071 size += 7 + 4 + w_strlen(pThis->u.u_keystyle.spacing);
6072 if (pThis->u.u_keystyle.weight)
6073 size += 6 + 4 + w_strlen(pThis->u.u_keystyle.weight);
6074 if (pThis->u.u_keystyle.slant)
6075 size += 5 + 4 + w_strlen(pThis->u.u_keystyle.slant);
6076 if (pThis->u.u_keystyle.special)
6077 size += 7 + 4 + w_strlen(pThis->u.u_keystyle.special);
6078 size += 2 /* strlen(">\n") */;
6081 if (!pThis->u.u_headstyle.beenUsed)
6083 size += 10 /* strlen("<HEADSTYLE") */;
6084 if (pThis->u.u_headstyle.class)
6085 size += 5 + 4 + w_strlen(pThis->u.u_headstyle.class);
6086 if (pThis->u.u_headstyle.ssi)
6087 size += 3 + 4 + w_strlen(pThis->u.u_headstyle.ssi);
6088 if (pThis->u.u_headstyle.rlevel)
6089 size += 6 + 4 + w_strlen(pThis->u.u_headstyle.rlevel);
6090 if (pThis->u.u_headstyle.phrase)
6091 size += 6 + 4 + w_strlen(pThis->u.u_headstyle.phrase);
6092 if (pThis->u.u_headstyle.srch_wt)
6093 size += 7 + 4 + w_strlen(pThis->u.u_headstyle.srch_wt);
6094 if (pThis->u.u_headstyle.orient)
6095 size += 6 + 4 + w_strlen(pThis->u.u_headstyle.orient);
6096 if (pThis->u.u_headstyle.vorient)
6097 size += 7 + 4 + w_strlen(pThis->u.u_headstyle.vorient);
6098 if (pThis->u.u_headstyle.placement)
6099 size += 9 + 4 + w_strlen(pThis->u.u_headstyle.placement);
6100 if (pThis->u.u_headstyle.headw)
6101 size += 5 + 4 + w_strlen(pThis->u.u_headstyle.headw);
6102 if (pThis->u.u_headstyle.stack)
6103 size += 5 + 4 + w_strlen(pThis->u.u_headstyle.stack);
6104 if (pThis->u.u_headstyle.flow)
6105 size += 4 + 4 + w_strlen(pThis->u.u_headstyle.flow);
6106 if (pThis->u.u_headstyle.pointsz)
6107 size += 7 + 4 + w_strlen(pThis->u.u_headstyle.pointsz);
6108 if (pThis->u.u_headstyle.set_width)
6109 size += 9 + 4 + w_strlen(pThis->u.u_headstyle.set_width);
6110 if (pThis->u.u_headstyle.color)
6111 size += 5 + 4 + w_strlen(pThis->u.u_headstyle.color);
6112 if (pThis->u.u_headstyle.xlfd)
6113 size += 4 + 4 + w_strlen(pThis->u.u_headstyle.xlfd);
6114 if (pThis->u.u_headstyle.xlfdi)
6115 size += 5 + 4 + w_strlen(pThis->u.u_headstyle.xlfdi);
6116 if (pThis->u.u_headstyle.xlfdb)
6117 size += 5 + 4 + w_strlen(pThis->u.u_headstyle.xlfdb);
6118 if (pThis->u.u_headstyle.xlfdib)
6119 size += 6 + 4 + w_strlen(pThis->u.u_headstyle.xlfdib);
6120 if (pThis->u.u_headstyle.typenam)
6121 size += 7 + 4 + w_strlen(pThis->u.u_headstyle.typenam);
6122 if (pThis->u.u_headstyle.typenami)
6123 size += 8 + 4 + w_strlen(pThis->u.u_headstyle.typenami);
6124 if (pThis->u.u_headstyle.typenamb)
6125 size += 8 + 4 + w_strlen(pThis->u.u_headstyle.typenamb);
6126 if (pThis->u.u_headstyle.typenamib)
6127 size += 9 + 4 + w_strlen(pThis->u.u_headstyle.typenamib);
6128 if (pThis->u.u_headstyle.style)
6129 size += 5 + 4 + w_strlen(pThis->u.u_headstyle.style);
6130 if (pThis->u.u_headstyle.spacing)
6131 size += 7 + 4 + w_strlen(pThis->u.u_headstyle.spacing);
6132 if (pThis->u.u_headstyle.weight)
6133 size += 6 + 4 + w_strlen(pThis->u.u_headstyle.weight);
6134 if (pThis->u.u_headstyle.slant)
6135 size += 5 + 4 + w_strlen(pThis->u.u_headstyle.slant);
6136 if (pThis->u.u_headstyle.special)
6137 size += 7 + 4 + w_strlen(pThis->u.u_headstyle.special);
6138 if (pThis->u.u_headstyle.l_margin)
6139 size += 8 + 4 + w_strlen(pThis->u.u_headstyle.l_margin);
6140 if (pThis->u.u_headstyle.r_margin)
6141 size += 8 + 4 + w_strlen(pThis->u.u_headstyle.r_margin);
6142 if (pThis->u.u_headstyle.t_margin)
6143 size += 8 + 4 + w_strlen(pThis->u.u_headstyle.t_margin);
6144 if (pThis->u.u_headstyle.b_margin)
6145 size += 8 + 4 + w_strlen(pThis->u.u_headstyle.b_margin);
6146 if (pThis->u.u_headstyle.border)
6147 size += 6 + 4 + w_strlen(pThis->u.u_headstyle.border);
6148 if (pThis->u.u_headstyle.vjust)
6149 size += 5 + 4 + w_strlen(pThis->u.u_headstyle.vjust);
6150 if (pThis->u.u_headstyle.justify)
6151 size += 7 + 4 + w_strlen(pThis->u.u_headstyle.justify);
6152 size += 2 /* strlen(">\n") */;
6155 if (!pThis->u.u_formstyle.beenUsed)
6157 size += 10 /* strlen("<FORMSTYLE") */;
6158 if (pThis->u.u_formstyle.class)
6159 size += 5 + 4 + w_strlen(pThis->u.u_formstyle.class);
6160 if (pThis->u.u_formstyle.ssi)
6161 size += 3 + 4 + w_strlen(pThis->u.u_formstyle.ssi);
6162 if (pThis->u.u_formstyle.rlevel)
6163 size += 6 + 4 + w_strlen(pThis->u.u_formstyle.rlevel);
6164 if (pThis->u.u_formstyle.phrase)
6165 size += 6 + 4 + w_strlen(pThis->u.u_formstyle.phrase);
6166 if (pThis->u.u_formstyle.srch_wt)
6167 size += 7 + 4 + w_strlen(pThis->u.u_formstyle.srch_wt);
6168 if (pThis->u.u_formstyle.colw)
6169 size += 4 + 4 + w_strlen(pThis->u.u_formstyle.colw);
6170 if (pThis->u.u_formstyle.colj)
6171 size += 4 + 4 + w_strlen(pThis->u.u_formstyle.colj);
6172 if (pThis->u.u_formstyle.pointsz)
6173 size += 7 + 4 + w_strlen(pThis->u.u_formstyle.pointsz);
6174 if (pThis->u.u_formstyle.set_width)
6175 size += 9 + 4 + w_strlen(pThis->u.u_formstyle.set_width);
6176 if (pThis->u.u_formstyle.color)
6177 size += 5 + 4 + w_strlen(pThis->u.u_formstyle.color);
6178 if (pThis->u.u_formstyle.xlfd)
6179 size += 4 + 4 + w_strlen(pThis->u.u_formstyle.xlfd);
6180 if (pThis->u.u_formstyle.xlfdi)
6181 size += 5 + 4 + w_strlen(pThis->u.u_formstyle.xlfdi);
6182 if (pThis->u.u_formstyle.xlfdb)
6183 size += 5 + 4 + w_strlen(pThis->u.u_formstyle.xlfdb);
6184 if (pThis->u.u_formstyle.xlfdib)
6185 size += 6 + 4 + w_strlen(pThis->u.u_formstyle.xlfdib);
6186 if (pThis->u.u_formstyle.typenam)
6187 size += 7 + 4 + w_strlen(pThis->u.u_formstyle.typenam);
6188 if (pThis->u.u_formstyle.typenami)
6189 size += 8 + 4 + w_strlen(pThis->u.u_formstyle.typenami);
6190 if (pThis->u.u_formstyle.typenamb)
6191 size += 8 + 4 + w_strlen(pThis->u.u_formstyle.typenamb);
6192 if (pThis->u.u_formstyle.typenamib)
6193 size += 9 + 4 + w_strlen(pThis->u.u_formstyle.typenamib);
6194 if (pThis->u.u_formstyle.style)
6195 size += 5 + 4 + w_strlen(pThis->u.u_formstyle.style);
6196 if (pThis->u.u_formstyle.spacing)
6197 size += 7 + 4 + w_strlen(pThis->u.u_formstyle.spacing);
6198 if (pThis->u.u_formstyle.weight)
6199 size += 6 + 4 + w_strlen(pThis->u.u_formstyle.weight);
6200 if (pThis->u.u_formstyle.slant)
6201 size += 5 + 4 + w_strlen(pThis->u.u_formstyle.slant);
6202 if (pThis->u.u_formstyle.special)
6203 size += 7 + 4 + w_strlen(pThis->u.u_formstyle.special);
6204 if (pThis->u.u_formstyle.l_margin)
6205 size += 8 + 4 + w_strlen(pThis->u.u_formstyle.l_margin);
6206 if (pThis->u.u_formstyle.r_margin)
6207 size += 8 + 4 + w_strlen(pThis->u.u_formstyle.r_margin);
6208 if (pThis->u.u_formstyle.t_margin)
6209 size += 8 + 4 + w_strlen(pThis->u.u_formstyle.t_margin);
6210 if (pThis->u.u_formstyle.b_margin)
6211 size += 8 + 4 + w_strlen(pThis->u.u_formstyle.b_margin);
6212 if (pThis->u.u_formstyle.border)
6213 size += 6 + 4 + w_strlen(pThis->u.u_formstyle.border);
6214 if (pThis->u.u_formstyle.vjust)
6215 size += 5 + 4 + w_strlen(pThis->u.u_formstyle.vjust);
6216 size += 2 /* strlen(">\n") */;
6219 if (!pThis->u.u_frmtstyle.beenUsed)
6221 size += 10 /* strlen("<FRMTSTYLE") */;
6222 if (pThis->u.u_frmtstyle.class)
6223 size += 5 + 4 + w_strlen(pThis->u.u_frmtstyle.class);
6224 if (pThis->u.u_frmtstyle.ssi)
6225 size += 3 + 4 + w_strlen(pThis->u.u_frmtstyle.ssi);
6226 if (pThis->u.u_frmtstyle.rlevel)
6227 size += 6 + 4 + w_strlen(pThis->u.u_frmtstyle.rlevel);
6228 if (pThis->u.u_frmtstyle.phrase)
6229 size += 6 + 4 + w_strlen(pThis->u.u_frmtstyle.phrase);
6230 if (pThis->u.u_frmtstyle.f_margin)
6231 size += 8 + 4 + w_strlen(pThis->u.u_frmtstyle.f_margin);
6232 if (pThis->u.u_frmtstyle.srch_wt)
6233 size += 7 + 4 + w_strlen(pThis->u.u_frmtstyle.srch_wt);
6234 if (pThis->u.u_frmtstyle.pointsz)
6235 size += 7 + 4 + w_strlen(pThis->u.u_frmtstyle.pointsz);
6236 if (pThis->u.u_frmtstyle.set_width)
6237 size += 9 + 4 + w_strlen(pThis->u.u_frmtstyle.set_width);
6238 if (pThis->u.u_frmtstyle.color)
6239 size += 5 + 4 + w_strlen(pThis->u.u_frmtstyle.color);
6240 if (pThis->u.u_frmtstyle.xlfd)
6241 size += 4 + 4 + w_strlen(pThis->u.u_frmtstyle.xlfd);
6242 if (pThis->u.u_frmtstyle.xlfdi)
6243 size += 5 + 4 + w_strlen(pThis->u.u_frmtstyle.xlfdi);
6244 if (pThis->u.u_frmtstyle.xlfdb)
6245 size += 5 + 4 + w_strlen(pThis->u.u_frmtstyle.xlfdb);
6246 if (pThis->u.u_frmtstyle.xlfdib)
6247 size += 6 + 4 + w_strlen(pThis->u.u_frmtstyle.xlfdib);
6248 if (pThis->u.u_frmtstyle.typenam)
6249 size += 7 + 4 + w_strlen(pThis->u.u_frmtstyle.typenam);
6250 if (pThis->u.u_frmtstyle.typenami)
6251 size += 8 + 4 + w_strlen(pThis->u.u_frmtstyle.typenami);
6252 if (pThis->u.u_frmtstyle.typenamb)
6253 size += 8 + 4 + w_strlen(pThis->u.u_frmtstyle.typenamb);
6254 if (pThis->u.u_frmtstyle.typenamib)
6255 size += 9 + 4 + w_strlen(pThis->u.u_frmtstyle.typenamib);
6256 if (pThis->u.u_frmtstyle.style)
6257 size += 5 + 4 + w_strlen(pThis->u.u_frmtstyle.style);
6258 if (pThis->u.u_frmtstyle.spacing)
6259 size += 7 + 4 + w_strlen(pThis->u.u_frmtstyle.spacing);
6260 if (pThis->u.u_frmtstyle.weight)
6261 size += 6 + 4 + w_strlen(pThis->u.u_frmtstyle.weight);
6262 if (pThis->u.u_frmtstyle.slant)
6263 size += 5 + 4 + w_strlen(pThis->u.u_frmtstyle.slant);
6264 if (pThis->u.u_frmtstyle.special)
6265 size += 7 + 4 + w_strlen(pThis->u.u_frmtstyle.special);
6266 if (pThis->u.u_frmtstyle.l_margin)
6267 size += 8 + 4 + w_strlen(pThis->u.u_frmtstyle.l_margin);
6268 if (pThis->u.u_frmtstyle.r_margin)
6269 size += 8 + 4 + w_strlen(pThis->u.u_frmtstyle.r_margin);
6270 if (pThis->u.u_frmtstyle.t_margin)
6271 size += 8 + 4 + w_strlen(pThis->u.u_frmtstyle.t_margin);
6272 if (pThis->u.u_frmtstyle.b_margin)
6273 size += 8 + 4 + w_strlen(pThis->u.u_frmtstyle.b_margin);
6274 if (pThis->u.u_frmtstyle.border)
6275 size += 6 + 4 + w_strlen(pThis->u.u_frmtstyle.border);
6276 if (pThis->u.u_frmtstyle.vjust)
6277 size += 5 + 4 + w_strlen(pThis->u.u_frmtstyle.vjust);
6278 if (pThis->u.u_frmtstyle.justify)
6279 size += 7 + 4 + w_strlen(pThis->u.u_frmtstyle.justify);
6280 size += 2 /* strlen(">\n") */;
6283 if (!pThis->u.u_grphstyle.beenUsed)
6285 size += 10 /* strlen("<GRPHSTYLE") */;
6286 if (pThis->u.u_grphstyle.class)
6287 size += 5 + 4 + w_strlen(pThis->u.u_grphstyle.class);
6288 if (pThis->u.u_grphstyle.ssi)
6289 size += 3 + 4 + w_strlen(pThis->u.u_grphstyle.ssi);
6290 if (pThis->u.u_grphstyle.rlevel)
6291 size += 6 + 4 + w_strlen(pThis->u.u_grphstyle.rlevel);
6292 if (pThis->u.u_grphstyle.phrase)
6293 size += 6 + 4 + w_strlen(pThis->u.u_grphstyle.phrase);
6294 if (pThis->u.u_grphstyle.l_margin)
6295 size += 8 + 4 + w_strlen(pThis->u.u_grphstyle.l_margin);
6296 if (pThis->u.u_grphstyle.r_margin)
6297 size += 8 + 4 + w_strlen(pThis->u.u_grphstyle.r_margin);
6298 if (pThis->u.u_grphstyle.t_margin)
6299 size += 8 + 4 + w_strlen(pThis->u.u_grphstyle.t_margin);
6300 if (pThis->u.u_grphstyle.b_margin)
6301 size += 8 + 4 + w_strlen(pThis->u.u_grphstyle.b_margin);
6302 if (pThis->u.u_grphstyle.border)
6303 size += 6 + 4 + w_strlen(pThis->u.u_grphstyle.border);
6304 if (pThis->u.u_grphstyle.vjust)
6305 size += 5 + 4 + w_strlen(pThis->u.u_grphstyle.vjust);
6306 if (pThis->u.u_grphstyle.justify)
6307 size += 7 + 4 + w_strlen(pThis->u.u_grphstyle.justify);
6308 size += 2 /* strlen(">\n") */;
6311 pThis = pThis->pNext;
6313 size += 8 /* strlen("</TOSS>\n") */;
6319 /* iterate over the LOIDS computing the offsets as we remove the old
6320 * LOIDS and INDEX and replace them with the new
6324 int replacing, length, incr, tmp;
6326 char buffer[BUFSIZ];
6329 /* write the loids out */
6330 pLoids = loids.next;
6331 loidsSize = sprintf(buffer, openLoids, nIds);
6334 loidsSize += sprintf(buffer,
6335 "<ID TYPE=\"%s\" RID=\"%s\"",
6339 loidsSize += sprintf(buffer, " RSSI=\"%s\"", pLoids->rssi);
6341 loidsSize += sprintf(buffer, " RLEVEL=\"%s\"", pLoids->rlevel);
6342 loidsSize += sprintf(buffer, " OFFSET=\"%ld\">\n", pLoids->offset);
6343 pLoids = pLoids->next;
6345 loidsSize += sizeof(closeLoids) - 1;
6347 /* compute how much we are deleting from and adding to the <vstruct> */
6348 replacing = endOfLOIDS - startOfLOIDS;
6351 if (startOfIndex != 0)
6352 replacing += (endOfIndex - startOfIndex);
6353 replacing -= FileSize(sortedIdxFileName, xxx);
6355 if (minimalTossFlag)
6357 if (startOfTOSS != 0)
6358 replacing += (endOfTOSS - startOfTOSS);
6359 replacing -= RestrictedTossSize();
6361 incr = length = loidsSize - replacing;
6363 /* Iterate over the <loids>, updating the offsets by "incr" until no
6364 * change in the size of the <loids>. The "incr" may be positive or
6365 * negative based on original sizes of the elements and their
6370 loidsSize = sprintf(buffer, openLoids, nIds);
6371 pLoids = loids.next; /* first one is a dummy (simplified some logic) */
6374 pLoids->offset += incr;
6375 loidsSize += sprintf(buffer,
6376 "<ID TYPE=\"%s\" RID=\"%s\" ",
6380 loidsSize += sprintf(buffer, "RSSI=\"%s\" ", pLoids->rssi);
6382 loidsSize += sprintf(buffer, "RLEVEL=\"%s\" ", pLoids->rlevel);
6383 loidsSize += sprintf(buffer, "OFFSET=\"%ld\">\n", pLoids->offset);
6384 pLoids = pLoids->next;
6386 loidsSize += sizeof(closeLoids) - 1;
6387 tmp = loidsSize - replacing;
6388 incr = tmp - length;
6394 /* iterate compressing vstruct until we have a stable loids; return
6395 * the amount of padding needed in between the vstruct and the first
6396 * virpage to make everything work
6398 static void CompressVstruct()
6400 #define COMPRESS_PAD_LENGTH 10
6401 char buffer[BUFSIZ], zTemp[4];
6403 int length, delta, change, pad;
6404 int newZsize, oldZsize;
6407 static char padString[COMPRESS_PAD_LENGTH];
6410 length = COMPRESS_PAD_LENGTH;
6411 while (--length >= 0)
6414 FcloseFile(outFile, compFileName, xxx);
6415 newZsize = Compress(compFileName, compZFileName, TRUE) + 4;
6416 change = FileSize(compFileName, xxx) - newZsize;
6419 change += COMPRESS_PAD_LENGTH; /* compensate for adding pad on first round */
6422 oldZsize = newZsize;
6424 /* recompute loids taking compression into account */
6425 pLoids = loids.next; /* first one is a dummy (simplified some logic) */
6428 pLoids->offset = pLoids->offset - change + COMPRESS_PAD_LENGTH;
6429 pLoids = pLoids->next;
6432 inFd = OpenFile(compFileName, O_RDONLY, xxx);
6433 unlink(compFileName);
6434 outFile = FopenFile(compFileName, O_WRONLY, xxx);
6436 /* copy inFd to outFile up to start of <loids> */
6437 delta = startOfLOIDS;
6438 while (length = ReadFile(inFd,
6444 FwriteFile(outFile, compFileName, buffer, length, xxx);
6448 /* write out the start-tag for <loids> */
6449 fprintf(outFile, openLoids, nIds);
6451 /* and write out the new <loids> */
6452 pLoids = loids.next; /* first one is a dummy (simplified some logic) */
6456 "<ID TYPE=\"%s\" RID=\"%s\" ",
6460 fprintf(outFile, "RSSI=\"%s\" ", pLoids->rssi);
6462 fprintf(outFile, "RLEVEL=\"%s\" ", pLoids->rlevel);
6463 fprintf(outFile, "OFFSET=\"%ld\">\n", pLoids->offset);
6464 pLoids = pLoids->next;
6467 /* followed by the end-tag for <loids> */
6471 sizeof(closeLoids)-1,
6474 /* and skip over the old <loids> in inFd */
6475 lseek(inFd, endOfLOIDS, SEEK_SET);
6477 /* save new <loids> end */
6478 endOfLOIDS = ftell(outFile);
6480 /* copy the remainder of the vstruct and doc head+snb to outFile */
6481 while (length = ReadFile(inFd, compFileName, buffer, BUFSIZ, xxx))
6482 FwriteFile(outFile, compFileName, buffer, length, xxx);
6483 CloseFile(inFd, compFileName, xxx);
6484 FcloseFile(outFile, compFileName, xxx);
6486 newZsize = Compress(compFileName, compZFileName, TRUE) + 4;
6488 if (newZsize <= (oldZsize + pad))
6490 pad += (oldZsize - newZsize);
6494 change = oldZsize - newZsize;
6495 pad += COMPRESS_PAD_LENGTH;
6498 /* open the final output file */
6499 if ((*outFileName == '-') && (outFileName[1] == '\0'))
6502 outFileName = "<stdout>";
6506 outFile = FopenFile(outFileName, O_WRONLY, xxx);
6509 /* write out the magic number and the file size */
6510 newZsize -= 4; /* remove the magic number and file size byte count */
6511 zTemp[3] = newZsize % 256;
6513 zTemp[2] = newZsize % 256;
6515 zTemp[1] = newZsize % 256;
6517 FwriteFile(outFile, outFileName, zTemp, 4, xxx);
6519 /* copy the compressed vstruct, doc head+snb to output */
6520 inFd = OpenFile(compZFileName, O_RDONLY, xxx);
6521 while (length = ReadFile(inFd, compZFileName, buffer, BUFSIZ, xxx))
6522 FwriteFile(outFile, outFileName, buffer, length, xxx);
6523 CloseFile(inFd, compZFileName, xxx);
6524 unlink(compZFileName);
6525 unlink(compFileName);
6527 /* pad the output to keep the loids happy */
6533 MIN(pad, COMPRESS_PAD_LENGTH),
6535 pad -= COMPRESS_PAD_LENGTH;
6540 /* insert the new loids and index then close the output file */
6541 static void IncorporateVstructElements()
6543 char buffer[BUFSIZ];
6546 char *realOutFileName;
6550 inFd = OpenFile(vstructFileName, O_RDONLY, xxx);
6553 realOutFileName = compFileName;
6554 outFile = FopenFile(compFileName, O_WRONLY, xxx);
6558 if ((*outFileName == '-') && (outFileName[1] == '\0'))
6561 realOutFileName = "<stdout>";
6565 realOutFileName = outFileName;
6566 outFile = FopenFile(outFileName, O_WRONLY, xxx);
6570 /* copy inFd to outFile up to start of <loids> */
6571 delta = startOfLOIDS;
6572 while (length = ReadFile(inFd, inFileName, buffer, MIN(BUFSIZ,delta), xxx))
6574 FwriteFile(outFile, realOutFileName, buffer, length, xxx);
6578 /* write out the start-tag for <loids> */
6579 fprintf(outFile, openLoids, nIds);
6581 /* and write out the new <loids> */
6582 pLoids = loids.next; /* first one is a dummy (simplified some logic) */
6586 "<ID TYPE=\"%s\" RID=\"%s\" ",
6590 fprintf(outFile, "RSSI=\"%s\" ", pLoids->rssi);
6592 fprintf(outFile, "RLEVEL=\"%s\" ", pLoids->rlevel);
6593 fprintf(outFile, "OFFSET=\"%ld\">\n", pLoids->offset + delta);
6594 pLoids = pLoids->next;
6597 /* followed by the end-tag for <loids> */
6601 sizeof(closeLoids)-1,
6604 /* save the new end of <loids> */
6605 newEndOfLOIDS = ftell(outFile);
6607 /* and skip over the old <loids> in inFd */
6608 lseek(inFd, endOfLOIDS, SEEK_SET);
6611 if (!minimalTossFlag) /* use the full <toss> from the document */
6613 if (delta) /* an old <toss> is in the document, copy it to outFile */
6615 delta -= endOfLOIDS;
6616 while (length = ReadFile(inFd,
6622 FwriteFile(outFile, realOutFileName, buffer, length, xxx);
6627 else /* emit only those <toss> elements actually used in the document */
6629 if (delta) /* an old <toss> is in the document, blow it away */
6630 lseek(inFd, delta, SEEK_SET);
6632 /* and emit the restricted <toss> */
6633 OpenNamedTag("TOSS", TRUE, TRUE);
6634 pElementChain = pTossChain;
6635 nElements = nStyles;
6637 CloseNamedTag("TOSS", TRUE);
6640 /* if we have an <lophrases>, copy it over to outFile */
6643 delta = endOfLOPhrases - startOfLOPhrases;
6644 while (length = ReadFile(inFd,
6650 FwriteFile(outFile, realOutFileName, buffer, length, xxx);
6655 /* if we have a new index, write it out to outFile */
6658 idxFd = OpenFile(sortedIdxFileName, O_RDONLY, xxx);
6659 while (length = ReadFile(idxFd, sortedIdxFileName, buffer, BUFSIZ, xxx))
6660 FwriteFile(outFile, realOutFileName, buffer, length, xxx);
6661 unlink(sortedIdxFileName);
6664 /* if we have a new index and there was an old index, blow it away */
6665 if (endOfIndex && haveIndex)
6666 lseek(inFd, endOfIndex, SEEK_SET);
6668 /* update the end of <loids> to reflect new size */
6669 endOfLOIDS = newEndOfLOIDS;
6671 /* copy the remainder of the vstruct and doc head+snb to outFile */
6672 while (length = ReadFile(inFd, vstructFileName, buffer, BUFSIZ, xxx))
6673 FwriteFile(outFile, realOutFileName, buffer, length, xxx);
6674 CloseFile(inFd, vstructFileName, xxx);
6675 unlink(vstructFileName);
6680 /* then copy the virpages over to outFile */
6681 inFd = OpenFile(tempFileName, O_RDONLY, xxx);
6682 while (length = ReadFile(inFd, tempFileName, buffer, BUFSIZ, xxx))
6683 FwriteFile(outFile, outFileName, buffer, length, xxx);
6684 CloseFile(inFd, tempFileName, xxx);
6686 FcloseFile(outFile, outFileName, xxx);
6687 unlink(tempFileName);
6690 /* Below is a modified version of m_cyclent() that returns a pointer
6691 * to the entity content rather than its value. Returning a pointer
6692 * to the entity's content field allows it to be modified.
6694 /* Cyclent.c contains procedure m_cyclent(), callable by interface
6695 designers, to cycle through all defined entities, returning information
6697 #if defined(M_PROTO)
6698 static M_WCHAR *CycleEnt(LOGICAL init,
6699 unsigned char *type,
6701 unsigned char *wheredef)
6703 static M_WCHAR *m_CycleEnt(init, type, content, wheredef)
6705 unsigned char *type ;
6706 M_WCHAR ***content ;
6707 unsigned char *wheredef ;
6710 static M_TRIE *current ;
6711 static M_TRIE *ancestor[M_NAMELEN + 1] ;
6713 static M_WCHAR name[M_NAMELEN + 1] ;
6717 current = m_enttrie->data ;
6721 if (length < 0) return(NULL) ;
6723 while (current->symbol)
6725 ancestor[length] = current ;
6726 name[length++] = current->symbol ;
6727 current = current->data ;
6729 name[length] = M_EOS ;
6731 *type = ((M_ENTITY *) current->data)->type ;
6732 *content = &(((M_ENTITY *) current->data)->content) ;
6733 *wheredef = ((M_ENTITY *) current->data)->wheredef ;
6739 current = current->next ;
6743 if (length < 0) break ;
6744 current = ancestor[length] ;
6750 /* A routine to examine all defined entities looking for ones of type
6751 * M_SYSTEM. When found, if the entity was defined in the interface
6752 * file and its name is "TOSSFILE", change its content to be the
6753 * current file name base plus ".tss".
6755 void UpdateTossFileName()
6758 unsigned char wheredef;
6761 M_WCHAR *newContent;
6762 char *toss_name = "TOSSFILE";
6765 name = CycleEnt(TRUE, &type, &content, &wheredef);
6769 if ((type == M_SYSTEM) && (wheredef == M_DELTDEF) && name && *content)
6771 mb_name = MakeMByteString(name);
6772 if (strcmp(mb_name, toss_name) == 0)
6773 *content = MakeWideCharString(tossFileName);
6774 m_free(mb_name, "multi-byte toss file entity name");
6777 while (name = CycleEnt(FALSE, &type, &content, &wheredef));
6781 /* A function that takes a language/charset pair and:
6782 * if they are standard, leave them unchanged but get local
6783 * versions and setlocale(3) using those
6784 * if they are local, setlocale(3) with them and replace them with
6785 * standard versions.
6788 #if defined(M_PROTO)
6789 SetLocale(M_WCHAR *pLang, M_WCHAR *pCharset)
6791 SetLocale(pLang, pCharset)
6796 const char cString[] = "C";
6797 _DtXlateDb myDb = NULL;
6798 char myPlatform[_DtPLATFORM_MAX_LEN+1];
6799 char myLocale[256]; /* arbitrarily large */
6809 if (!pLang && !pCharset)
6814 mb_lang = MakeMByteString(pLang);
6816 mb_lang = (char *) cString;
6818 mb_charset = MakeMByteString(pCharset);
6820 strcpy(myLocale, mb_lang);
6821 if (mb_charset && *mb_charset)
6823 strcat(myLocale, ".");
6824 strcat(myLocale, mb_charset);
6827 if ((_DtLcxOpenAllDbs(&myDb) != 0) ||
6828 (_DtXlateGetXlateEnv(myDb,myPlatform,&execVer,&compVer) != 0))
6831 "Warning: could not open locale translation database.\n");
6832 if (m_errfile != stderr)
6834 "Warning: could not open locale translation database.\n");
6835 if (mb_lang != cString)
6838 mb_free(&mb_charset);
6840 _DtLcxCloseDb(&myDb);
6844 isStd = !_DtLcxXlateOpToStd(myDb,
6855 { /* already standard - get local versions and set locale */
6856 if (_DtLcxXlateStdToOp(myDb,
6859 DtLCX_OPER_SETLOCALE,
6867 "Warning: could not translate CDE locale to local\n");
6868 if (m_errfile != stderr)
6870 "Warning: could not translate CDE locale to local\n");
6871 _DtLcxCloseDb(&myDb);
6872 if (mb_lang != cString)
6875 mb_free(&mb_charset);
6880 setlocale(LC_CTYPE, locale);
6881 operantLocale = mb_malloc(strlen(locale)+1);
6882 strcpy(operantLocale, locale);
6886 { /* already local - just set locale */
6887 setlocale(LC_CTYPE, myLocale);
6888 operantLocale = mb_malloc(strlen(myLocale)+1);
6889 strcpy(operantLocale, myLocale);
6892 if (mb_lang != cString)
6895 mb_free(&mb_charset);
6896 _DtLcxCloseDb(&myDb);
6900 /* a routine to do all the things we want to do before actually
6901 * parsing the SDL document.
6906 m_errfile = FopenFile(errFileName, O_WRONLY|O_APPEND, xxx);
6914 inFile = FopenFile(tempFileName, O_RDONLY, xxx);
6916 unlink(tempFileName);
6918 outFile = FopenFile(vstructFileName, O_WRONLY, xxx);
6922 /* a routine to do all those things we want to do after parsing the
6923 * document such as doing the fixups in the vstruct
6925 void CloseDocument()
6927 FcloseFile(outFile, tempFileName, xxx);
6930 IncorporateVstructElements();