HTML.c
上传用户:zlh9724
上传日期:2007-01-04
资源大小:1991k
文件大小:25k
- /* HTML.c
- ** STRUCTURED STREAM TO RICH HYPERTEXT CONVERTER
- **
- ** (c) COPYRIGHT MIT 1995.
- ** Please first read the full copyright statement in the file COPYRIGH.
- **
- ** This generates of a hypertext object. It converts from the
- ** structured stream interface fro HTMl events into the style-
- ** oriented iunterface of the HText interface. This module is
- ** only used in clients and shouldnot be linked into servers.
- **
- ** Override this module if making a new GUI browser.
- **
- ** HISTORY:
- ** 8 Jul 94 FM Insulate free() from _free structure element.
- **
- */
- /* Library include files */
- #include "tcp.h"
- #include "HTUtils.h"
- #include "HTString.h"
- #include "HTAtom.h"
- #include "HTChunk.h"
- #include "HText.h"
- #include "HTStyle.h"
- #include "HTAlert.h"
- #include "HTMLGen.h"
- #include "HTParse.h"
- #include "HTML.h"
- extern HTStyleSheet * styleSheet; /* Application-wide */
- /* Module-wide style cache
- */
- PRIVATE int got_styles = 0;
- PRIVATE HTStyle *styles[HTMLP_ELEMENTS];
- PRIVATE HTStyle *default_style;
- /* HTML Object
- ** -----------
- */
- #define MAX_NESTING 20 /* Should be checked by parser */
- typedef struct _stack_element {
- HTStyle * style;
- int tag_number;
- } stack_element;
- struct _HTStructured {
- CONST HTStructuredClass * isa;
- HTRequest * request;
- HTParentAnchor * node_anchor;
- HText * text;
- HTStream* target; /* Output stream */
- HTStreamClass targetClass; /* Output routines */
- HTChunk * title; /* Grow by 128 */
-
- char * comment_start; /* for literate programming */
- char * comment_end;
-
- CONST SGML_dtd* dtd;
-
- HTTag * current_tag;
- BOOL style_change;
- HTStyle * new_style;
- HTStyle * old_style;
- BOOL in_word; /* Have just had a non-white char */
- stack_element stack[MAX_NESTING];
- stack_element *sp; /* Style stack pointer */
- int overflow; /* Keep track of overflow nesting */
- };
- struct _HTStream {
- CONST HTStreamClass * isa;
- /* .... */
- };
- /* Forward declarations of routines
- */
- PRIVATE void get_styles (void);
- PRIVATE void actually_set_style (HTStructured * me);
- PRIVATE void change_paragraph_style (HTStructured * me, HTStyle * style);
- /* Style buffering avoids dummy paragraph begin/ends.
- */
- #define UPDATE_STYLE if (me->style_change) { actually_set_style(me); }
- #ifdef OLD_CODE
- /* The following accented characters are from peter Flynn, curia project */
- /* these ifdefs don't solve the problem of a simple terminal emulator
- ** with a different character set to the client machine. But nothing does,
- ** except looking at the TERM setting */
- { "ocus" , "&" }, /* for CURIA */
- #ifdef IBMPC
- { "aacute" , "240" }, /* For PC display */
- { "eacute" , "202" },
- { "iacute" , "241" },
- { "oacute" , "242" },
- { "uacute" , "243" },
- { "Aacute" , "101" },
- { "Eacute" , "220" },
- { "Iacute" , "111" },
- { "Oacute" , "117" },
- { "Uacute" , "125" },
- #else
- { "aacute" , "341" }, /* Works for openwindows -- Peter Flynn */
- { "eacute" , "351" },
- { "iacute" , "355" },
- { "oacute" , "363" },
- { "uacute" , "372" },
- { "Aacute" , "301" },
- { "Eacute" , "310" },
- { "Iacute" , "315" },
- { "Oacute" , "323" },
- { "Uacute" , "332" },
- #endif
- { 0, 0 } /* Terminate list */
- };
- #endif
- /* Entity values -- for ISO Latin 1 local representation
- **
- ** This MUST match exactly the table referred to in the DTD!
- */
- static char * ISO_Latin1[] = {
- "306", /* capital AE diphthong (ligature) */
- "301", /* capital A, acute accent */
- "302", /* capital A, circumflex accent */
- "300", /* capital A, grave accent */
- "305", /* capital A, ring */
- "303", /* capital A, tilde */
- "304", /* capital A, dieresis or umlaut mark */
- "307", /* capital C, cedilla */
- "320", /* capital Eth, Icelandic */
- "311", /* capital E, acute accent */
- "312", /* capital E, circumflex accent */
- "310", /* capital E, grave accent */
- "313", /* capital E, dieresis or umlaut mark */
- "315", /* capital I, acute accent */
- "316", /* capital I, circumflex accent */
- "314", /* capital I, grave accent */
- "317", /* capital I, dieresis or umlaut mark */
- "321", /* capital N, tilde */
- "323", /* capital O, acute accent */
- "324", /* capital O, circumflex accent */
- "322", /* capital O, grave accent */
- "330", /* capital O, slash */
- "325", /* capital O, tilde */
- "326", /* capital O, dieresis or umlaut mark */
- "336", /* capital THORN, Icelandic */
- "332", /* capital U, acute accent */
- "333", /* capital U, circumflex accent */
- "331", /* capital U, grave accent */
- "334", /* capital U, dieresis or umlaut mark */
- "335", /* capital Y, acute accent */
- "341", /* small a, acute accent */
- "342", /* small a, circumflex accent */
- "346", /* small ae diphthong (ligature) */
- "340", /* small a, grave accent */
- "