home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / INTERNET / WWW / LYNX / SOURCE / SRC0_8A.ZIP / DOSLYNX / SRC / HTML.C < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-18  |  33.5 KB  |  1,279 lines

  1. /*        Structured stream to Rich hypertext converter
  2. **        ============================================
  3. **
  4. **    This generates of a hypertext object.  It converts from the
  5. **    structured stream interface fro HTMl events into the style-
  6. **    oriented iunterface of the HText.h interface.  This module is
  7. **    only used in clients and shouldnot be linked into servers.
  8. **
  9. **    Override this module if making a new GUI browser.
  10. **
  11. */
  12. #include"capalloc.h"
  13. #include "HTML.h"
  14. #include"globals.h"
  15.  
  16. /* #define CAREFUL         Check nesting here notreally necessary */
  17.  
  18. #include <ctype.h>
  19. #include <stdio.h>
  20. #include"capstdio.h"
  21.  
  22. #include "HTAtom.h"
  23. #include "HTChunk.h"
  24. #include "HText.h"
  25. #include "HTStyle.h"
  26.  
  27. #include "HTAlert.h"
  28. #include "HTMLGen.h"
  29. #include "HTParse.h"
  30.  
  31. #include "SGML.h"
  32.  
  33. extern HTStyleSheet * styleSheet;    /* Application-wide */
  34.  
  35. /*    Module-wide style cache
  36. */
  37. PRIVATE int         got_styles = 0;
  38. PRIVATE HTStyle *styles[HTML_ELEMENTS];
  39. PRIVATE HTStyle *default_style;
  40.  
  41.  
  42. /*        HTML Object
  43. **        -----------
  44. */
  45. #define MAX_NESTING 200        /* Should be checked by parser */
  46.  
  47. typedef struct _stack_element {
  48.         HTStyle *    style;
  49.     int        tag_number;
  50. } stack_element;
  51.  
  52. struct _HTStructured {
  53.     CONST HTStructuredClass *     isa;
  54.     HTParentAnchor *         node_anchor;
  55.     HText *             text;
  56.  
  57.     HTStream*            target;            /* Output stream */
  58.     HTStreamClass        targetClass;        /* Output routines */
  59.  
  60.     HTChunk             title;        /* Grow by 128 */
  61.     
  62.     char *            comment_start;    /* for literate programming */
  63.     char *            comment_end;
  64.  
  65.     HTTag *            current_tag;
  66.     BOOL            style_change;
  67.     HTStyle *            new_style;
  68.     HTStyle *            old_style;
  69.     BOOL            in_word;  /* Have just had a non-white char */
  70.     stack_element     stack[MAX_NESTING];
  71.     stack_element     *sp;        /* Style stack pointer */
  72. };
  73.  
  74. struct _HTStream {
  75.     CONST HTStreamClass *    isa;
  76.     /* .... */
  77. };
  78.  
  79. /*        Forward declarations of routines
  80. */
  81. PRIVATE void get_styles NOPARAMS;
  82.  
  83.  
  84. PRIVATE void actually_set_style PARAMS((HTStructured * me));
  85. PRIVATE void change_paragraph_style PARAMS((HTStructured * me, HTStyle * style));
  86.  
  87. /*    Style buffering avoids dummy paragraph begin/ends.
  88. */
  89. #define UPDATE_STYLE if (me->style_change) { actually_set_style(me); }
  90.  
  91.  
  92. #ifdef OLD_CODE
  93. /* The following accented characters are from peter Flynn, curia project */
  94.  
  95. /* these ifdefs don't solve the problem of a simple terminal emulator
  96. ** with a different character set to the client machine. But nothing does,
  97. ** except looking at the TERM setting */
  98.  
  99.  
  100.         { "ocus" , "&" },       /* for CURIA */
  101. #ifdef IBMPC
  102.         { "aacute" , "\240" },    /* For PC display */
  103.         { "eacute" , "\202" },
  104.         { "iacute" , "\241" },
  105.         { "oacute" , "\242" },
  106.         { "uacute" , "\243" },
  107.         { "Aacute" , "\101" },
  108.         { "Eacute" , "\220" },
  109.         { "Iacute" , "\111" },
  110.         { "Oacute" , "\117" },
  111.         { "Uacute" , "\125" },
  112. #else
  113.     { "aacute" , "\341" },    /* Works for openwindows -- Peter Flynn */
  114.     { "eacute" , "\351" },
  115.     { "iacute" , "\355" },
  116.     { "oacute" , "\363" },
  117.     { "uacute" , "\372" },
  118.     { "Aacute" , "\301" },
  119.     { "Eacute" , "\310" },
  120.     { "Iacute" , "\315" },
  121.     { "Oacute" , "\323" },
  122.     { "Uacute" , "\332" },
  123. #endif
  124.     { 0,    0 }  /* Terminate list */
  125. };
  126. #endif
  127.  
  128.  
  129. /*     Entity values -- for ISO Latin 1 local representation
  130. **
  131. **    This MUST match exactly the table referred to in the DTD!
  132. */
  133. #ifndef MSDOS
  134. static char * ISO_Latin1[] = {
  135.     "\306",    /* capital AE diphthong (ligature) */
  136.     "\301",    /* capital A, acute accent */
  137.     "\302",    /* capital A, circumflex accent */
  138.     "\300",    /* capital A, grave accent */
  139.     "\305",    /* capital A, ring */
  140.     "\303",    /* capital A, tilde */
  141.     "\304",    /* capital A, dieresis or umlaut mark */
  142.     "\307",    /* capital C, cedilla */
  143.     "\320",    /* capital Eth, Icelandic */
  144.     "\311",    /* capital E, acute accent */
  145.     "\312",    /* capital E, circumflex accent */
  146.     "\310",    /* capital E, grave accent */
  147.     "\313",    /* capital E, dieresis or umlaut mark */
  148.     "\315",    /* capital I, acute accent */
  149.     "\316",    /* capital I, circumflex accent */
  150.     "\314",    /* capital I, grave accent */
  151.     "\317",    /* capital I, dieresis or umlaut mark */
  152.     "\321",    /* capital N, tilde */
  153.     "\323",    /* capital O, acute accent */
  154.       "\324",    /* capital O, circumflex accent */ 
  155.       "\322",    /* capital O, grave accent */ 
  156.       "\330",    /* capital O, slash */ 
  157.     "\325",    /* capital O, tilde */
  158.       "\326",    /* capital O, dieresis or umlaut mark */ 
  159.       "\336",    /* capital THORN, Icelandic */ 
  160.       "\332",    /* capital U, acute accent */ 
  161.       "\333",    /* capital U, circumflex accent */ 
  162.     "\331",    /* capital U, grave accent */
  163.       "\334",    /* capital U, dieresis or umlaut mark */ 
  164.       "\335",    /* capital Y, acute accent */ 
  165.       "\341",    /* small a, acute accent */ 
  166.       "\342",    /* small a, circumflex accent */ 
  167.       "\346",    /* small ae diphthong (ligature) */ 
  168.       "\340",    /* small a, grave accent */ 
  169.     "\046",    /* ampersand */
  170.     "\345",    /* small a, ring */
  171.       "\343",    /* small a, tilde */ 
  172.       "\344",    /* small a, dieresis or umlaut mark */ 
  173.       "\347",    /* small c, cedilla */ 
  174.       "\351",    /* small e, acute accent */ 
  175.       "\352",    /* small e, circumflex accent */ 
  176.       "\350",    /* small e, grave accent */ 
  177.       "\360",    /* small eth, Icelandic */ 
  178.       "\353",    /* small e, dieresis or umlaut mark */ 
  179.       "\076",    /* greater than */ 
  180.     "\355",    /* small i, acute accent */
  181.       "\356",    /* small i, circumflex accent */ 
  182.     "\354",    /* small i, grave accent */
  183.       "\357",    /* small i, dieresis or umlaut mark */ 
  184.       "\074",    /* less than */ 
  185.       "\361",    /* small n, tilde */ 
  186.       "\363",    /* small o, acute accent */ 
  187.       "\364",    /* small o, circumflex accent */ 
  188.       "\362",    /* small o, grave accent */ 
  189.       "\370",    /* small o, slash */ 
  190.       "\365",    /* small o, tilde */ 
  191.       "\366",    /* small o, dieresis or umlaut mark */ 
  192.       "\337",    /* small sharp s, German (sz ligature) */ 
  193.       "\376",    /* small thorn, Icelandic */ 
  194.       "\372",    /* small u, acute accent */ 
  195.       "\373",    /* small u, circumflex accent */ 
  196.       "\371",    /* small u, grave accent */ 
  197.     "\374",    /* small u, dieresis or umlaut mark */
  198.     "\375",    /* small y, acute accent */
  199.       "\377",    /* small y, dieresis or umlaut mark */ 
  200. };
  201. #else
  202. static char * ISO_Latin1[] = {
  203.     "\222",    /* capital AE diphthong (ligature) */
  204.     "\265",    /* capital A, acute accent */
  205.     "\266",    /* capital A, circumflex accent */
  206.     "\267",    /* capital A, grave accent */
  207.     "\217",    /* capital A, ring */
  208.     "\307",    /* capital A, tilde */
  209.     "\216",    /* capital A, dieresis or umlaut mark */
  210.     "\200",    /* capital C, cedilla */
  211.     "\321",    /* capital Eth, Icelandic */
  212.     "\220",    /* capital E, acute accent */
  213.     "\322",    /* capital E, circumflex accent */
  214.     "\324",    /* capital E, grave accent */
  215.     "\323",    /* capital E, dieresis or umlaut mark */
  216.     "\326",    /* capital I, acute accent */
  217.     "\327",    /* capital I, circumflex accent */
  218.     "\336",    /* capital I, grave accent */
  219.     "\330",    /* capital I, dieresis or umlaut mark */
  220.     "\245",    /* capital N, tilde */
  221.     "\340",    /* capital O, acute accent */
  222.     "\342",    /* capital O, circumflex accent */
  223.     "\343",    /* capital O, grave accent */
  224.     "\235",    /* capital O, slash */
  225.     "\345",    /* capital O, tilde */
  226.     "\231",    /* capital O, dieresis or umlaut mark */
  227.     "\350",    /* capital THORN, Icelandic */
  228.     "\351",    /* capital U, acute accent */
  229.     "\352",    /* capital U, circumflex accent */
  230.     "\353",    /* capital U, grave accent */
  231.     "\232",    /* capital U, dieresis or umlaut mark */
  232.     "\355",    /* capital Y, acute accent */
  233.     "\240",    /* small a, acute accent */
  234.     "\203",    /* small a, circumflex accent */
  235.     "\221",    /* small ae diphthong (ligature) */
  236.     "\205",    /* small a, grave accent */
  237.     "\046",    /* ampersand */
  238.     "\206",    /* small a, ring */
  239.     "\306",    /* small a, tilde */
  240.     "\204",    /* small a, dieresis or umlaut mark */
  241.     "\207",    /* small c, cedilla */
  242.     "\202",    /* small e, acute accent */
  243.     "\210",    /* small e, circumflex accent */
  244.     "\212",    /* small e, grave accent */
  245.     "\320",    /* small eth, Icelandic */
  246.     "\211",    /* small e, dieresis or umlaut mark */
  247.     "\076",    /* greater than */
  248.     "\241",    /* small i, acute accent */
  249.     "\214",    /* small i, circumflex accent */
  250.     "\215",    /* small i, grave accent */
  251.     "\213",    /* small i, dieresis or umlaut mark */
  252.     "\074",    /* less than */
  253.     "\244",    /* small n, tilde */
  254.     "\242",    /* small o, acute accent */
  255.     "\223",    /* small o, circumflex accent */
  256.     "\225",    /* small o, grave accent */
  257.     "\233",    /* small o, slash */
  258.     "\344",    /* small o, tilde */
  259.     "\224",    /* small o, dieresis or umlaut mark */
  260.     "\341",    /* small sharp s, German (sz ligature) */
  261.     "\347",    /* small thorn, Icelandic */
  262.     "\243",    /* small u, acute accent */
  263.     "\226",    /* small u, circumflex accent */
  264.     "\227",    /* small u, grave accent */
  265.     "\201",    /* small u, dieresis or umlaut mark */
  266.     "\354",    /* small y, acute accent */
  267.     "\230",    /* small y, dieresis or umlaut mark */
  268. };
  269. #endif /* MSDOS */
  270.  
  271. /*     Entity values -- for NeXT local representation
  272. **
  273. **    This MUST match exactly the table referred to in the DTD!
  274. **
  275. */
  276. static char * NeXTCharacters[] = {
  277.     "\341",    /* capital AE diphthong (ligature)     */
  278.     "\202",    /* capital A, acute accent        */
  279.     "\203",    /* capital A, circumflex accent     */
  280.     "\201",    /* capital A, grave accent         */
  281.     "\206",    /* capital A, ring             */
  282.     "\204",    /* capital A, tilde             */
  283.     "\205",    /* capital A, dieresis or umlaut mark    */
  284.     "\207",    /* capital C, cedilla             */
  285.     "\220",    /* capital Eth, Icelandic         */
  286.     "\211",    /* capital E, acute accent                 */
  287.     "\212",    /* capital E, circumflex accent             */
  288.     "\210",    /* capital E, grave accent                 */
  289.     "\213",    /* capital E, dieresis or umlaut mark             */
  290.     "\215",    /* capital I, acute accent                 */
  291.     "\216",    /* capital I, circumflex accent     these are    */
  292.     "\214",    /* capital I, grave accent        ISO -100 hex    */
  293.     "\217",    /* capital I, dieresis or umlaut mark            */
  294.     "\221",    /* capital N, tilde                     */
  295.     "\223",    /* capital O, acute accent                 */
  296.     "\224",    /* capital O, circumflex accent             */
  297.     "\222",    /* capital O, grave accent                 */
  298.     "\351",    /* capital O, slash         'cept this */
  299.     "\225",    /* capital O, tilde                     */
  300.     "\226",    /* capital O, dieresis or umlaut mark            */
  301.     "\234",    /* capital THORN, Icelandic */
  302.     "\230",    /* capital U, acute accent */
  303.     "\231",    /* capital U, circumflex accent */
  304.     "\227",    /* capital U, grave accent */
  305.     "\232",    /* capital U, dieresis or umlaut mark */
  306.     "\233",    /* capital Y, acute accent */
  307.     "\326",    /* small a, acute accent */
  308.     "\327",    /* small a, circumflex accent */
  309.     "\361",    /* small ae diphthong (ligature) */
  310.     "\325",    /* small a, grave accent */
  311.     "\046",    /* ampersand */
  312.       "\332",    /* small a, ring */ 
  313.       "\330",    /* small a, tilde */ 
  314.       "\331",    /* small a, dieresis or umlaut mark */ 
  315.       "\333",    /* small c, cedilla */ 
  316.       "\335",    /* small e, acute accent */ 
  317.       "\336",    /* small e, circumflex accent */ 
  318.       "\334",    /* small e, grave accent */ 
  319.       "\346",    /* small eth, Icelandic     */ 
  320.       "\337",    /* small e, dieresis or umlaut mark */ 
  321.       "\076",    /* greater than */ 
  322.       "\342",    /* small i, acute accent */ 
  323.       "\344",    /* small i, circumflex accent */ 
  324.       "\340",    /* small i, grave accent */ 
  325.       "\345",    /* small i, dieresis or umlaut mark */ 
  326.     "\074",    /* less than */
  327.     "\347",    /* small n, tilde */
  328.       "\355",    /* small o, acute accent */ 
  329.       "\356",    /* small o, circumflex accent */ 
  330.       "\354",    /* small o, grave accent */ 
  331.       "\371",    /* small o, slash */ 
  332.       "\357",    /* small o, tilde */ 
  333.       "\360",    /* small o, dieresis or umlaut mark */ 
  334.       "\373",    /* small sharp s, German (sz ligature) */ 
  335.     "\374",    /* small thorn, Icelandic */
  336.       "\363",    /* small u, acute accent */ 
  337.       "\364",    /* small u, circumflex accent */ 
  338.     "\362",    /* small u, grave accent */
  339.       "\366",    /* small u, dieresis or umlaut mark */ 
  340.     "\367",    /* small y, acute accent */
  341.       "\375",    /* small y, dieresis or umlaut mark */ 
  342. };
  343.  
  344. /*     Entity values -- for IBM/PC Code Page 850 (International)
  345. **
  346. **    This MUST match exactly the table referred to in the DTD!
  347. **
  348. */
  349. /* @@@@@@@@@@@@@@@@@ TBD */
  350.  
  351.  
  352.  
  353. /*        Set character set
  354. **        ----------------
  355. */
  356.  
  357. PRIVATE char** p_entity_values = ISO_Latin1;    /* Pointer to translation */
  358.  
  359. PUBLIC void HTMLUseCharacterSet ARGS1(HTMLCharacterSet, i)
  360. {
  361.     p_entity_values = (i == HTML_NEXT_CHARS) ? NeXTCharacters
  362.                              : ISO_Latin1;
  363. }
  364.  
  365.  
  366. /*        Flattening the style structure
  367. **        ------------------------------
  368. **
  369. On the NeXT, and on any read-only browser, it is simpler for the text to have
  370. a sequence of styles, rather than a nested tree of styles. In this
  371. case we have to flatten the structure as it arrives from SGML tags into
  372. a sequence of styles.
  373. */
  374.  
  375. /*        If style really needs to be set, call this
  376. */
  377. PRIVATE void actually_set_style ARGS1(HTStructured *, me)
  378. {
  379.     if (!me->text) {            /* First time through */
  380.         me->text = HText_new2(me->node_anchor, me->target);
  381.         HText_beginAppend(me->text);
  382.         HText_setStyle(me->text, me->new_style);
  383.         me->in_word = NO;
  384.     } else {
  385.         HText_setStyle(me->text, me->new_style);
  386.     }
  387.     me->old_style = me->new_style;
  388.     me->style_change = NO;
  389. }
  390.  
  391. /*      If you THINK you need to change style, call this
  392. */
  393.  
  394. PRIVATE void change_paragraph_style ARGS2(HTStructured *, me, HTStyle *,style)
  395. {
  396.     if (me->new_style!=style) {
  397.         me->style_change = YES;
  398.     me->new_style = style;
  399.     }
  400.     me->in_word = NO;
  401. }
  402.  
  403. /*_________________________________________________________________________
  404. **
  405. **            A C T I O N     R O U T I N E S
  406. */
  407.  
  408. /*    Character handling
  409. **    ------------------
  410. */
  411.  
  412. PRIVATE void HTML_put_character ARGS2(HTStructured *, me, char, c)
  413. {
  414.  
  415.     switch (me->sp[0].tag_number) {
  416.     case HTML_COMMENT:
  417.     break;                    /* Do Nothing */
  418.  
  419.     case HTML_TITLE:
  420.     HTChunkPutc(&me->title, c);
  421.     break;
  422.  
  423.  
  424.     case HTML_LISTING:                /* Litteral text */
  425.     case HTML_XMP:
  426.     case HTML_PLAINTEXT:
  427.     case HTML_PRE:
  428. /*    We guarrantee that the style is up-to-date in begin_litteral
  429. */
  430.     HText_appendCharacter(me->text, c);
  431.     break;
  432.     
  433.     default:                    /* Free format text */
  434.     if (me->style_change) {
  435.         if ((c=='\n') || (c==' ')) return;    /* Ignore it */
  436.         UPDATE_STYLE;
  437.     }
  438.     if (c=='\n') {
  439.         if (me->in_word) {
  440.         HText_appendCharacter(me->text, ' ');
  441.         me->in_word = NO;
  442.         }
  443.     } else {
  444.         HText_appendCharacter(me->text, c);
  445.         me->in_word = YES;
  446.     }
  447.     } /* end switch */
  448. }
  449.  
  450.  
  451.  
  452. /*    String handling
  453. **    ---------------
  454. **
  455. **    This is written separately from put_character becuase the loop can
  456. **    in some cases be promoted to a higher function call level for speed.
  457. */
  458. PRIVATE void HTML_put_string ARGS2(HTStructured *, me, CONST char*, s)
  459. {
  460.  
  461.     switch (me->sp[0].tag_number) {
  462.     case HTML_COMMENT:
  463.         break;                    /* Do Nothing */
  464.     
  465.     case HTML_TITLE:    
  466.         HTChunkPuts(&me->title, s);
  467.     break;
  468.  
  469.     
  470.     case HTML_LISTING:                /* Litteral text */
  471.     case HTML_XMP:
  472.     case HTML_PLAINTEXT:
  473.     case HTML_PRE:
  474.  
  475. /*    We guarrantee that the style is up-to-date in begin_litteral
  476. */
  477.     HText_appendText(me->text, s);
  478.     break;
  479.  
  480.     default:                    /* Free format text */
  481.     {
  482.         CONST char *p = s;
  483.         if (me->style_change) {
  484.         for (; *p && ((*p=='\n') || (*p==' ')); p++)  ;  /* Ignore leaders */
  485.         if (!*p) return;
  486.         UPDATE_STYLE;
  487.         }
  488.         for(; *p; p++) {
  489.         if (me->style_change) {
  490.             if ((*p=='\n') || (*p==' ')) continue;  /* Ignore it */
  491.             UPDATE_STYLE;
  492.         }
  493.         if (*p=='\n') {
  494.             if (me->in_word) {
  495.             HText_appendCharacter(me->text, ' ');
  496.             me->in_word = NO;
  497.             }
  498.         } else {
  499.             HText_appendCharacter(me->text, *p);
  500.             me->in_word = YES;
  501.         }
  502.         } /* for */
  503.     }
  504.     } /* end switch */
  505. }
  506.  
  507.  
  508. /*    Buffer write
  509. **    ------------
  510. */
  511. PRIVATE void HTML_write ARGS3(HTStructured *, me, CONST char*, s, int, l)
  512. {
  513.     CONST char* p;
  514.     CONST char* e = s+l;
  515.     for (p=s; s<e; p++) HTML_put_character(me, *p);
  516. }
  517.  
  518.  
  519. /*    Start Element
  520. **    -------------
  521. */
  522. PRIVATE void HTML_start_element ARGS4(
  523.     HTStructured *,     me,
  524.     int,        element_number,
  525.     CONST BOOL*,         present,
  526.     CONST char **,    value)
  527. {
  528. #ifdef MSDOSMEM
  529.     {
  530.         extern void *vp_msdosmem;
  531.         extern void **vpp_msdosmem;
  532.         present = (BOOL *)vp_msdosmem;
  533.         value = (char **)vpp_msdosmem;
  534.     }
  535. #endif /* MSDOSMEM */
  536.  
  537.     switch (element_number) {
  538.  
  539.     /*
  540.      *    Forms stuff.
  541.      */
  542.     case HTML_FORM:    {
  543.         /*    Start up a new form.
  544.          */
  545.         auto char *cp_action = NULL;
  546.         auto char *cp_enctype = NULL;
  547.         auto char *cp_method = NULL;
  548.  
  549.         /*     Determine the form's action URL.
  550.          *    If there is none, assume the current document's URL
  551.          *        will be the action URL.
  552.          */
  553.         if(present[HTML_FORM_ACTION])    {
  554.             if(value[HTML_FORM_ACTION] != NULL)    {
  555.                 if(*value[HTML_FORM_ACTION] != '\0')    {
  556.                     StrAllocCopy(cp_action, (char *)
  557.                         value[HTML_FORM_ACTION]);
  558.                 }
  559.             }
  560.         }
  561.  
  562.         /*     Determine the form's encoding type.
  563.          */
  564.         if(present[HTML_FORM_ENCTYPE])    {
  565.             if(value[HTML_FORM_ENCTYPE] != NULL)    {
  566.                 if(*value[HTML_FORM_ENCTYPE] != '\0')    {
  567.                     StrAllocCopy(cp_enctype, (char *)
  568.                         value[HTML_FORM_ENCTYPE]);
  569.                 }
  570.             }
  571.         }
  572.         /*     Determine the form's method for submission.
  573.          *    If there is none, assume the method of GET.
  574.          */
  575.         if(present[HTML_FORM_METHOD])    {
  576.             if(value[HTML_FORM_METHOD] != NULL)    {
  577.                 if(*value[HTML_FORM_METHOD] != '\0')    {
  578.                     StrAllocCopy(cp_method,
  579.                         value[HTML_FORM_METHOD]);
  580.                 }
  581.             }
  582.         }
  583.  
  584.         if(cp_action == NULL)    {
  585.             StrAllocCopy(cp_action, me->node_anchor->address);
  586.         }
  587.         if(cp_method == NULL)    {
  588.             StrAllocCopy(cp_method, "GET");
  589.         }
  590.  
  591.         /*    Have gridtext do the client specifics.
  592.          */
  593.         HText_beginForm(me->text, cp_action, cp_enctype, cp_method);
  594.  
  595.         /*    Free off the allocated memory.
  596.          */
  597.         if(cp_action != NULL)    {
  598.             free(cp_action);
  599.         }
  600.         if(cp_enctype != NULL)    {
  601.             free(cp_enctype);
  602.         }
  603.         if(cp_method != NULL)    {
  604.             free(cp_method);
  605.         }
  606.         break;
  607.     }
  608.     case HTML_INPUT:    {
  609.         break;
  610.     }
  611.     case HTML_OPTION:    {
  612.         break;
  613.     }
  614.     case HTML_SELECT:    {
  615.         break;
  616.     }
  617.     case HTML_TEXTAREA:    {
  618.         UPDATE_STYLE;
  619.         break;
  620.     }
  621.  
  622.     case HTML_A:
  623.         /*
  624.          *    First, we will not start any new anchors if we
  625.          *    are really low on memory.  Check.
  626.          */
  627.         if(really_safe_pool[Stop_Anchors] == NULL)    {
  628.             usi_skipped++;
  629.             break;
  630.         }
  631.         else    {
  632.             HTChildAnchor * source;
  633.             char * href = NULL;
  634.  
  635.             /*
  636.              *    set to know that we started an anchor, is OK
  637.              *    to end the anchor.
  638.              *    Anchor nesting allowed.
  639.              */
  640.             c_DidStartAnchor++;
  641.  
  642.             if(present[HTML_A_HREF])    {
  643.                 StrAllocCopy(href, value[HTML_A_HREF]);
  644.                 HTSimplify(href);
  645.             }
  646.  
  647.             source = HTAnchor_findChildAndLink(me->node_anchor,
  648.                 present[HTML_A_NAME] ? value[HTML_A_NAME] : 0,
  649.                 present[HTML_A_HREF] ? href : 0, present[
  650.                 HTML_A_TYPE] && value[HTML_A_TYPE] ?
  651.                 (HTLinkType*)HTAtom_for(value[HTML_A_TYPE]) :
  652.                 0);
  653.             free(href);
  654.  
  655.             if(present[HTML_A_TITLE] && value[HTML_A_TITLE])
  656.             {
  657.                 HTParentAnchor *dest = HTAnchor_parent(
  658.                     HTAnchor_followMainLink((HTAnchor*)
  659.                     source));
  660.  
  661.                 if (!HTAnchor_title(dest))
  662.                     HTAnchor_setTitle(dest, value[
  663.                         HTML_A_TITLE]);
  664.             }
  665.             UPDATE_STYLE;
  666.             HText_beginAnchor(me->text, source);
  667.         }
  668.     break;
  669.  
  670.     case HTML_TITLE:
  671.     HTChunkClear(&me->title);
  672.     break;
  673.  
  674.     case HTML_NEXTID:
  675.     /* if (present[NEXTID_N] && value[NEXTID_N])
  676.         HText_setNextId(me->text, atoi(value[NEXTID_N])); */
  677.     break;
  678.  
  679.     case HTML_ISINDEX:
  680.     if(present != NULL && present[HTML_ISINDEX_ACTION] != NO)    {
  681. #ifndef RELEASE
  682.         if(TRACE)    {
  683.             fprintf(stderr, "HTML:  1 HTAnchor_setIndex(%p, %s)\n",
  684.                 (void *)(me->node_anchor), (char *)(value[
  685.                 HTML_ISINDEX_ACTION]));
  686.         }
  687. #endif /* RELEASE */
  688.         HTAnchor_setIndex(me->node_anchor, value[HTML_ISINDEX_ACTION]);
  689.     }
  690.     else    {
  691. #ifndef RELEASE
  692.         if(TRACE)    {
  693.             fprintf(stderr, "HTML:  2 HTAnchor_setIndex(%p, %s)\n",
  694.                 (void *)(me->node_anchor), me->node_anchor->
  695.                 address);
  696.         }
  697. #endif /* RELEASE */
  698.         HTAnchor_setIndex(me->node_anchor, me->node_anchor->address);
  699.     }
  700.     break;
  701.  
  702.     case HTML_BR:
  703.     UPDATE_STYLE;
  704.     HText_appendCharacter(me->text, '\n');
  705.     me->in_word = NO;
  706.     break;
  707.  
  708.     case HTML_HR:
  709.     UPDATE_STYLE;
  710.     HText_appendCharacter(me->text, '\n');
  711.     {
  712.         unsigned short int usi_count;
  713.         for(usi_count = 0; usi_count < 35; usi_count++)
  714.             HText_appendCharacter(me->text, '-');
  715.     }
  716.     HText_appendCharacter(me->text, '\n');
  717.     me->in_word = NO;
  718.     break;
  719.  
  720.     case HTML_P:
  721.     UPDATE_STYLE;
  722.     HText_appendParagraph(me->text);
  723.     me->in_word = NO;
  724.     break;
  725.  
  726.     case HTML_DL:
  727.     change_paragraph_style(me, present && present[DL_COMPACT]
  728.         ? styles[HTML_DLC]
  729.         : styles[HTML_DL]);
  730.     break;
  731.  
  732.     case HTML_DT:
  733.     if (!me->style_change) {
  734.         HText_appendParagraph(me->text);
  735.         me->in_word = NO;
  736.     }
  737.     break;
  738.  
  739.     case HTML_DD:
  740.     UPDATE_STYLE;
  741. /*    HTML_put_character(me, '\t');    Just tab, format: doesn't work well */
  742.     HText_appendCharacter(me->text, '\t');
  743.     me->in_word = NO;
  744.     break;
  745.  
  746.     case HTML_UL:
  747.     case HTML_OL:
  748.     case HTML_MENU:
  749.     case HTML_DIR:
  750.     change_paragraph_style(me, styles[element_number]);
  751.     break;
  752.  
  753.     case HTML_LI:
  754.     UPDATE_STYLE;
  755.     HText_appendParagraph(me->text);
  756.     me->in_word = NO;
  757.     break;
  758.  
  759.     case HTML_LISTING:                /* Litteral text */
  760.     case HTML_XMP:
  761.     case HTML_PLAINTEXT:
  762.     case HTML_PRE:
  763.     change_paragraph_style(me, styles[element_number]);
  764.     UPDATE_STYLE;
  765.     if (me->comment_end)
  766.         HText_appendText(me->text, me->comment_end);
  767.     break;
  768.  
  769.     case HTML_IMG:    {        /* Images -- display text */
  770.  
  771.     BOOL B_anchor = FALSE;
  772.  
  773.     /*
  774.      *    First off, are we inside of an anchor so that the ALT text
  775.      *        will be used for the anchor and not the inline image.
  776.      */
  777.     if(c_DidStartAnchor != 0)    {
  778.         /*
  779.          *     Track that we were in an anchor.
  780.          */
  781.         B_anchor = TRUE;
  782.  
  783.         /*
  784.          *    Also, make sure that if we have ALT text, that it
  785.          *    is for the anchor, and not the image.
  786.          *    If no alt text, output [ANCHOR].
  787.          */
  788.         if(present[HTML_IMG_ALT])    {
  789.             if(value[HTML_IMG_ALT] != NULL)    {
  790.                 if(*(value[HTML_IMG_ALT]) != '\0')    {
  791.                     HTML_put_character(me, ' ');
  792.                     HTML_put_string(me,
  793.                         value[HTML_IMG_ALT]);
  794.                     HTML_put_character(me, ' ');
  795.                 }
  796.                 else    {
  797.                     HTML_put_string(me, " [ANCHOR] ");
  798.                 }
  799.             }
  800.             else    {
  801.                 HTML_put_string(me, " [ANCHOR] ");
  802.             }
  803.         }
  804.         else    {
  805.             HTML_put_string(me, " [ANCHOR] ");
  806.         }
  807.     }
  808.  
  809.     /*
  810.      *     Now then, construct the [IMAGE] anchor, href is src.
  811.      */
  812.  
  813.     /*
  814.      *    First, we will not start any new anchors if we
  815.      *    are really low on memory.  Check.
  816.      */
  817.     if(really_safe_pool[Stop_Anchors] == NULL)    {
  818.         if(B_anchor == TRUE)    {
  819.             HTML_put_string(me, " [IMAGE] ");
  820.         }
  821.         else    {
  822.             if(present[HTML_IMG_ALT])    {
  823.                 if(value[HTML_IMG_ALT] != NULL)    {
  824.                     if(*(value[HTML_IMG_ALT]) != '\0')
  825.                     {
  826.                         /*
  827.                          *     Use the ALT text.
  828.                          */
  829.                         HTML_put_string(me, " ");
  830.                         HTML_put_string(me, value[
  831.                             HTML_IMG_ALT]);
  832.                         HTML_put_string(me, " ");
  833.                     }
  834.                     else    {
  835.                         HTML_put_string(me,
  836.                             " [IMAGE] ");
  837.                     }
  838.                 }
  839.                 else    {
  840.                     HTML_put_string(me, " [IMAGE] ");
  841.                 }
  842.             }
  843.             else    {
  844.                 HTML_put_string(me, " [IMAGE] ");
  845.             }
  846.         }
  847.         break;
  848.     }
  849.     else    {
  850.         HTChildAnchor * source;
  851.         char * href = NULL;
  852.  
  853.         if(present[HTML_IMG_SRC])    {
  854.             StrAllocCopy(href, value[HTML_IMG_SRC]);
  855.             HTSimplify(href);
  856.         }
  857.  
  858.         source = HTAnchor_findChildAndLink(me->node_anchor,
  859.             0, present[HTML_IMG_SRC] ? href : 0, 0);
  860.         free(href);
  861.  
  862.         UPDATE_STYLE;
  863.         HText_beginAnchor(me->text, source);
  864.  
  865.         /*
  866.          *     Decide how to name the anchor.
  867.          */
  868.         if(B_anchor == TRUE)    {
  869.             HTML_put_string(me, " [IMAGE] ");
  870.         }
  871.         else    {
  872.             if(present[HTML_IMG_ALT])    {
  873.                 if(value[HTML_IMG_ALT] != NULL)    {
  874.                     if(*(value[HTML_IMG_ALT]) != '\0')
  875.                     {
  876.                         /*
  877.                          *     Use the ALT text.
  878.                          */
  879.                         HTML_put_string(me, " ");
  880.                         HTML_put_string(me, value[
  881.                             HTML_IMG_ALT]);
  882.                         HTML_put_string(me, " ");
  883.                     }
  884.                     else    {
  885.                         HTML_put_string(me,
  886.                             " [IMAGE] ");
  887.                     }
  888.                 }
  889.                 else    {
  890.                     HTML_put_string(me, " [IMAGE] ");
  891.                 }
  892.             }
  893.             else    {
  894.                 HTML_put_string(me, " [IMAGE] ");
  895.             }
  896.         }
  897.  
  898.         HText_endAnchor(me->text);
  899.     }
  900.     break;
  901.     }
  902.  
  903.     case HTML_HTML:            /* Ignore these altogether */
  904.     case HTML_HEAD:
  905.     case HTML_BODY:
  906.  
  907.  
  908.     case HTML_TT:            /* Physical character highlighting */
  909.     case HTML_B:            /* Currently ignored */
  910.     case HTML_I:
  911.     case HTML_U:
  912.  
  913.     case HTML_EM:            /* Logical character highlighting */
  914.     case HTML_STRONG:            /* Currently ignored */
  915.     case HTML_CODE:
  916.     case HTML_SAMP:
  917.     case HTML_KBD:
  918.     case HTML_VAR:
  919.     case HTML_DFN:
  920.     case HTML_CITE:
  921.     break;
  922.  
  923.     case HTML_H1:            /* paragraph styles */
  924.     case HTML_H2:
  925.     case HTML_H3:
  926.     case HTML_H4:
  927.     case HTML_H5:
  928.     case HTML_H6:
  929.     case HTML_H7:
  930.     case HTML_ADDRESS:
  931.     case HTML_BLOCKQUOTE:
  932.     change_paragraph_style(me, styles[element_number]);    /* May be postponed */
  933.     break;
  934.  
  935.     } /* end switch */
  936.  
  937.     if (HTML_dtd.tags[element_number].contents!= SGML_EMPTY) {
  938.     if (me->sp == me->stack) {
  939.         fprintf(stderr, "HTML: ****** Maximum nesting of %d exceded!\n",
  940.         MAX_NESTING);
  941.         return;
  942.     }
  943.     --(me->sp);
  944.     me->sp[0].style = me->new_style;    /* Stack new style */
  945.     me->sp[0].tag_number = element_number;
  946.     }
  947. }
  948.  
  949.  
  950. /*        End Element
  951. **        -----------
  952. **
  953. */
  954. /*    When we end an element, the style must be returned to that
  955. **    in effect before that element.  Note that anchors (etc?)
  956. **    don't have an associated style, so that we must scan down the
  957. **    stack for an element with a defined style. (In fact, the styles
  958. **    should be linked to the whole stack not just the top one.)
  959. **    TBL 921119
  960. **
  961. **    We don't turn on "CAREFUL" check because the parser produces
  962. **    (internal code errors apart) good nesting. The parser checks
  963. **    incoming code errors, not this module.
  964. */
  965. PRIVATE void HTML_end_element ARGS2(HTStructured *, me, int , element_number)
  966. {
  967. #ifdef CAREFUL            /* parser assumed to produce good nesting */
  968.     if (element_number != me->sp[0].tag_number) {
  969.     fprintf(stderr, "HTMLText: end of element %s when expecting end of %s\n",
  970.         HTML_dtd.tags[element_number].name,
  971.         HTML_dtd.tags[me->sp->tag_number].name);
  972.         /* panic */
  973.     }
  974. #endif
  975.  
  976.     me->sp++;                /* Pop state off stack */
  977.  
  978.     switch(element_number) {
  979.  
  980.     /*
  981.      *    Forms stuff.
  982.      */
  983.     case HTML_FORM:    {
  984.         HText_endForm(me->text);
  985.         break;
  986.     }
  987.     case HTML_SELECT:    {
  988.         break;
  989.     }
  990.     case HTML_TEXTAREA:    {
  991.         UPDATE_STYLE;
  992.         break;
  993.     }
  994.  
  995.     case HTML_A:
  996.     /*
  997.      *    First, check to see if low on memory.  If so, do not allow
  998.      *    any more anchors.  Be sure to wrap up the final anchor created
  999.      *    though.
  1000.      */
  1001.     if(really_safe_pool[Stop_Anchors] == NULL && c_DidStartAnchor == 0)
  1002.     {
  1003.         break;
  1004.     }
  1005.     /*
  1006.      *    Mark for start of allowing no more of ending anchors if low
  1007.      *    on memory.
  1008.      */
  1009.     c_DidStartAnchor--;
  1010.     UPDATE_STYLE;
  1011.     HText_endAnchor(me->text);
  1012.     break;
  1013.  
  1014.     case HTML_TITLE:
  1015.     HTChunkTerminate(&me->title);
  1016.     HTAnchor_setTitle(me->node_anchor, me->title.data);
  1017.     break;
  1018.  
  1019.     case HTML_LISTING:                /* Litteral text */
  1020.     case HTML_XMP:
  1021.     case HTML_PLAINTEXT:
  1022.     case HTML_PRE:
  1023.     if (me->comment_start)
  1024.         HText_appendText(me->text, me->comment_start);
  1025.     /* Fall through */
  1026.  
  1027.     default:
  1028.  
  1029.     change_paragraph_style(me, me->sp->style);    /* Often won't really change */
  1030.     break;
  1031.  
  1032.     } /* switch */
  1033. }
  1034.  
  1035.  
  1036. /*        Expanding entities
  1037. **        ------------------
  1038. */
  1039. /*    (In fact, they all shrink!)
  1040. */
  1041.  
  1042. PRIVATE void HTML_put_entity ARGS2(HTStructured *, me, int, entity_number)
  1043. {
  1044.     HTML_put_string(me, ISO_Latin1[entity_number]);    /* @@ Other representations */
  1045. }
  1046.  
  1047.  
  1048. /*    Free an HTML object
  1049. **    -------------------
  1050. **
  1051. ** If the document is empty, the text object will not yet exist.
  1052.    So we could in fact abandon creating the document and return
  1053.    an error code.  In fact an empty document is an important type
  1054.    of document, so we don't.
  1055. **
  1056. **    If non-interactive, everything is freed off.   No: crashes -listrefs
  1057. **    Otherwise, the interactive object is left.    
  1058. */
  1059. PUBLIC void HTML_free ARGS1(HTStructured *, me)
  1060. {
  1061.     UPDATE_STYLE;        /* Creates empty document here! */
  1062.     if (me->comment_end)
  1063.         HTML_put_string(me,me->comment_end);
  1064.     HText_endAppend(me->text);
  1065.  
  1066.     if (me->target) {
  1067.         (*me->targetClass.free)(me->target);
  1068.     }
  1069.     free(me);
  1070. }
  1071.  
  1072.  
  1073. PRIVATE void HTML_abort ARGS2(HTStructured *, me, HTError, e)
  1074.  
  1075. {
  1076.     if (me->target) {
  1077.         (*me->targetClass.abort)(me->target, e);
  1078.     }
  1079.     free(me);
  1080.  
  1081. }
  1082.  
  1083.  
  1084. /*    Get Styles from style sheet
  1085. **    ---------------------------
  1086. */
  1087. PRIVATE void get_styles NOARGS
  1088. {
  1089.     got_styles = YES;
  1090.  
  1091.     default_style =        HTStyleNamed(styleSheet, "Normal");
  1092.  
  1093.     styles[HTML_H1] =        HTStyleNamed(styleSheet, "Heading1");
  1094.     styles[HTML_H2] =        HTStyleNamed(styleSheet, "Heading2");
  1095.     styles[HTML_H3] =        HTStyleNamed(styleSheet, "Heading3");
  1096.     styles[HTML_H4] =        HTStyleNamed(styleSheet, "Heading4");
  1097.     styles[HTML_H5] =        HTStyleNamed(styleSheet, "Heading5");
  1098.     styles[HTML_H6] =        HTStyleNamed(styleSheet, "Heading6");
  1099.     styles[HTML_H7] =        HTStyleNamed(styleSheet, "Heading7");
  1100.  
  1101.     styles[HTML_DL] =        HTStyleNamed(styleSheet, "Glossary");
  1102.     styles[HTML_UL] =
  1103.     styles[HTML_OL] =        HTStyleNamed(styleSheet, "List");
  1104.     styles[HTML_MENU] =        HTStyleNamed(styleSheet, "Menu");
  1105.     styles[HTML_DIR] =        HTStyleNamed(styleSheet, "Dir");    
  1106.     styles[HTML_DLC] =        HTStyleNamed(styleSheet, "GlossaryCompact");
  1107.     styles[HTML_ADDRESS]=    HTStyleNamed(styleSheet, "Address");
  1108.     styles[HTML_BLOCKQUOTE]=    HTStyleNamed(styleSheet, "Blockquote");
  1109.     styles[HTML_PLAINTEXT] =
  1110.     styles[HTML_XMP] =        HTStyleNamed(styleSheet, "Example");
  1111.     styles[HTML_PRE] =        HTStyleNamed(styleSheet, "Preformatted");
  1112.     styles[HTML_LISTING] =    HTStyleNamed(styleSheet, "Listing");
  1113.  
  1114.     /*     For forms, we don't want to analize some stuff....
  1115.      */
  1116.     styles[HTML_TEXTAREA] =    HTStyleNamed(styleSheet, "Example");
  1117. }
  1118. /*                P U B L I C
  1119. */
  1120.  
  1121. /*    Structured Object Class
  1122. **    -----------------------
  1123. */
  1124. PUBLIC CONST HTStructuredClass HTMLPresentation = /* As opposed to print etc */
  1125. {        
  1126.     "text/html",
  1127.     HTML_free,
  1128.     HTML_abort,
  1129.     HTML_put_character,     HTML_put_string,  HTML_write,
  1130.     HTML_start_element,     HTML_end_element,
  1131.     HTML_put_entity
  1132. }; 
  1133.  
  1134.  
  1135. /*        New Structured Text object
  1136. **        --------------------------
  1137. **
  1138. **    The strutcured stream can generate either presentation,
  1139. **    or plain text, or HTML.
  1140. */
  1141. PUBLIC HTStructured* HTML_new ARGS3(
  1142.     HTParentAnchor *,     anchor,
  1143.     HTFormat,        format_out,
  1144.     HTStream*,        stream)
  1145. {
  1146.  
  1147.     HTStructured * me;
  1148.     
  1149.     if (format_out != WWW_PLAINTEXT && format_out != WWW_PRESENT) {
  1150.         HTStream * intermediate = HTStreamStack(WWW_HTML, format_out,
  1151.         stream, anchor);
  1152.     if (intermediate) return HTMLGenerator(intermediate);
  1153.         fprintf(stderr, "** Internal error: can't parse HTML to %s\n",
  1154.         HTAtom_name(format_out));
  1155. #ifndef MSDOS
  1156.     exit (-99);
  1157. #else
  1158.     fprintf(stderr, "WWW html.c exit(-99); denied by doslynx.\n");
  1159.     fprintf(stderr, "Consider leaving the application.\n");
  1160. #endif /* MSDOS */
  1161.     }
  1162.  
  1163.     me = (HTStructured*) malloc(sizeof(*me));
  1164.     if (me == NULL) outofmem(__FILE__, "HTML_new");
  1165.  
  1166.     if (!got_styles) get_styles();
  1167.  
  1168.     me->isa = &HTMLPresentation;
  1169.     me->node_anchor =  anchor;
  1170.     me->title.size = 0;
  1171.     me->title.growby = 128;
  1172.     me->title.allocated = 0;
  1173.     me->title.data = 0;
  1174.     me->text = 0;
  1175.     me->style_change = YES; /* Force check leading to text creation */
  1176.     me->new_style = default_style;
  1177.     me->old_style = 0;
  1178.     me->sp = me->stack + MAX_NESTING - 1;
  1179.     me->sp->tag_number = -1;                /* INVALID */
  1180.     me->sp->style = default_style;            /* INVALID */
  1181.     
  1182.     me->comment_start = NULL;
  1183.     me->comment_end = NULL;
  1184.     me->target = stream;
  1185.     if (stream) me->targetClass = *stream->isa;    /* Copy pointers */
  1186.  
  1187.     return (HTStructured*) me;
  1188. }
  1189.  
  1190.  
  1191. /*    HTConverter for HTML to plain text
  1192. **    ----------------------------------
  1193. **
  1194. **    This will convert from HTML to presentation or plain text.
  1195. */
  1196. PUBLIC HTStream* HTMLToPlain ARGS3(
  1197.     HTPresentation *,    pres,
  1198.     HTParentAnchor *,    anchor,    
  1199.     HTStream *,        sink)
  1200. {
  1201.     return(SGML_new(&HTML_dtd, HTML_new(anchor, pres->rep_out, sink)));
  1202. }
  1203.  
  1204.  
  1205. /*    HTConverter for HTML to C code
  1206. **    ------------------------------
  1207. **
  1208. **    C copde is like plain text but all non-preformatted code
  1209. **    is commented out.
  1210. **    This will convert from HTML to presentation or plain text.
  1211. */
  1212. PUBLIC HTStream* HTMLToC ARGS3(
  1213.     HTPresentation *,    pres,
  1214.     HTParentAnchor *,    anchor,    
  1215.     HTStream *,        sink)
  1216. {
  1217.     
  1218.     HTStructured * html;
  1219.     
  1220.     (*sink->isa->put_string)(sink, "/* ");    /* Before even title */
  1221.     html = HTML_new(anchor, WWW_PLAINTEXT, sink);
  1222.     html->comment_start = "/* ";
  1223.     html->comment_end = " */\n";    /* Must start in col 1 for cpp */
  1224. /*    HTML_put_string(html,html->comment_start); */
  1225.  
  1226.     return(SGML_new(&HTML_dtd, html));
  1227. }
  1228.  
  1229.  
  1230. /*    Presenter for HTML
  1231. **    ------------------
  1232. **
  1233. **    This will convert from HTML to presentation or plain text.
  1234. **
  1235. **    Override this if you have a windows version
  1236. */
  1237. #ifndef GUI
  1238. PUBLIC HTStream* HTMLPresent ARGS3(
  1239.     HTPresentation *,    pres,
  1240.     HTParentAnchor *,    anchor,    
  1241.     HTStream *,        sink)
  1242. {
  1243.     /*
  1244.      *     Save the context to do some HTML hacking.
  1245.      */
  1246.     return(SGML_new(&HTML_dtd, HTML_new(anchor, WWW_PRESENT, sink)));
  1247. }
  1248. #endif
  1249.  
  1250.  
  1251. /*    Record error message as a hypertext object
  1252. **    ------------------------------------------
  1253. **
  1254. **    The error message should be marked as an error so that
  1255. **    it can be reloaded later.
  1256. **    This implementation just throws up an error message
  1257. **    and leaves the document unloaded.
  1258. **    A smarter implementation would load an error document,
  1259. **    marking at such so that it is retried on reload.
  1260. **
  1261. ** On entry,
  1262. **    sink     is a stream to the output device if any
  1263. **    number    is the HTTP error number
  1264. **    message    is the human readable message.
  1265. **
  1266. ** On exit,
  1267. **    returns    a negative number to indicate lack of success in the load.
  1268. */
  1269.  
  1270. PUBLIC int HTLoadError ARGS3(
  1271.     HTStream *,     sink,
  1272.     int,        number,
  1273.     CONST char *,    message)
  1274. {
  1275.     HTAlert(message);        /* @@@@@@@@@@@@@@@@@@@ */
  1276.     return -number;
  1277. }
  1278.  
  1279.