home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / modules / xml / glue / xmlglue.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  5.4 KB  |  181 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #ifndef    _RDF_XMLGLUE_H_
  20. #define    _RDF_XMLGLUE_H_
  21.  
  22. #include "xmlparse.h"
  23.  
  24. #ifdef XP_UNIX
  25. #include <sys/fcntl.h>
  26. #elif defined(XP_MAC)
  27. #include <fcntl.h>
  28. #endif
  29.  
  30.  
  31.  
  32. /* xmlglue.c data structures and defines */
  33.  
  34. #define XML_LINE_SIZE 500
  35.  
  36.  
  37. #include <stdlib.h>
  38. #include <string.h>
  39. #include "nspr.h"
  40. #include "plhash.h"
  41. #include "ntypes.h"
  42. #include "net.h"
  43. #include "xp.h"
  44. #include "xp_str.h"
  45. #include "utils.h"
  46. #include "xmlparse.h"
  47.  
  48. #define getMem(x) PR_Calloc(1,(x))
  49. #define freeMem(x) PR_Free((x))
  50.  
  51. #define copyString(source) XP_STRDUP(source)
  52. #define stringEquals(x, y) (strcasecomp(x, y) ==0)
  53.  
  54.  
  55.  
  56. #ifndef true
  57. #define true PR_TRUE
  58. #endif
  59. #ifndef false
  60. #define false PR_FALSE
  61. #endif
  62. #define null NULL
  63. #define nullp(x) (((void*)x) == ((void*)0))
  64.  
  65.  
  66.  
  67. /* xmlparse.c data structures and defines */
  68.  
  69. #define MAX_TAG_SIZE 100
  70. #define MAX_ATTRIBUTES 10
  71. #define XML_BUF_SIZE 4096
  72. #define wsc(c) ((c == ' ') || (c == '\r') || (c == '\n') || (c == '\t'))
  73. typedef struct _XMLFileStruct {
  74.   int32   status;
  75.   struct _StyleSheetStruct* ss;
  76.   struct _XMLElementStruct*  top;
  77.   struct _XMLElementStruct*  current;
  78.   void*   stream;
  79.   int8    numOpenStreams;
  80.   void*   urls;
  81.   void*   mwcontext;
  82.   char*   address;
  83.   XML_Parser parser;
  84. } XMLFileStruct;
  85.  
  86. typedef XMLFileStruct* XMLFile;
  87.  
  88. typedef struct _StyleSheetStruct {
  89.   XMLFile xmlFile;
  90.   struct _StyleElementStruct* el;
  91.   struct _StyleSheetStruct* next;
  92.   void*  urls;
  93.   char* holdOver;
  94.   int32   lineSize;
  95.   char* line;
  96.   char* address;
  97. } StyleSheetStruct;
  98.  
  99. typedef StyleSheetStruct* StyleSheet;
  100.  
  101. typedef struct _StyleElementStruct {
  102.   char** tagStack;
  103.   char*   style;
  104.   struct _StyleElementStruct* next;
  105. } StyleElementStruct;
  106.  
  107. typedef StyleElementStruct* StyleElement;
  108.  
  109.  
  110. typedef struct _XMLElementStruct {
  111.   char*  tag;
  112.   char** attributes;
  113.   char* content;
  114.   struct _XMLElementStruct* parent;
  115.   struct _XMLElementStruct* child;
  116.   struct _XMLElementStruct* next;
  117. } XMLElementStruct;
  118.  
  119. typedef XMLElementStruct* XMLElement;
  120.  
  121. typedef struct _XMLHTMLInclusionStruct {
  122.   char** content;
  123.   XMLFile xml;
  124.   int32 n;
  125. } XMLHTMLInclusionStruct;
  126.  
  127. typedef  XMLHTMLInclusionStruct *XMLHTMLInclusion;
  128.  
  129.  
  130.  
  131. /* xmlparse.c function prototypes */
  132.  
  133. XP_BEGIN_PROTOS
  134.  
  135. int        parseNextXMLBlob (NET_StreamClass *stream, char* blob, int32 size);
  136. void        processNextXMLContent (XMLFile f, char* content);
  137. char **        copyCharStarList (char** list);
  138. char *        makeAbsoluteURL (char* p1, char* p2);
  139. void        processNextXMLElement (XMLFile f, char* attr);
  140. void        addStyleSheet(XMLFile f, StyleSheet ss);
  141. void        addChild (XMLElement parent, XMLElement child);
  142. char *        getTagHTMLEquiv (XMLFile f, XMLElement el);
  143. void        outputAttributes(XMLFile f, char** attlist);
  144. void        outputAsHTML (XMLFile f, XMLElement el);
  145. void        convertToHTML (XMLFile xf);
  146. void        outputStyleSpan (XMLFile f, XMLElement el, PRBool endp);
  147. char *        getAttributeValue (const char** attlist, char* elName);
  148. void        tokenizeXMLElement (char* attr, char** attlist);
  149. void            readCSS(StyleSheet ss);
  150. void            outputToStream(XMLFile f, char* s);
  151.  
  152.  
  153. void XMLDOM_CharHandler (XMLFile f, const char* content, int len) ;
  154. void XMLDOM_EndHandler (XMLFile f, const char* elementName) ;
  155. void XMLDOM_StartHandler (XMLFile f, const char* elementName, const char** attlist) ;
  156. void XMLDOM_PIHandler (XMLFile f, const char *elementName, const char *attlist) ;
  157.  
  158. unsigned int            xml_write_ready(NET_StreamClass *stream);
  159. void                xml_abort(NET_StreamClass *stream, int status);
  160. void                xml_complete (NET_StreamClass *stream);
  161. unsigned int            xmlcss_write_ready(NET_StreamClass *stream);
  162. void                xmlcss_abort(NET_StreamClass *stream, int status);
  163. void                xmlcss_complete (NET_StreamClass *stream);
  164. void                outputToStream (XMLFile f, char* s);
  165. void                xmlcss_GetUrlExitFunc (URL_Struct *urls, int status, MWContext *cx);
  166. void                readCSS (StyleSheet ss);
  167. int                xmlhtml_write(NET_StreamClass *stream, const char *str, int32 len);
  168. unsigned int            xmlhtml_write_ready(NET_StreamClass *stream);
  169. void                xmlhtml_abort(NET_StreamClass *stream, int status);
  170. void                xmlhtml_complete  (NET_StreamClass *stream);
  171. void                xmlhtml_GetUrlExitFunc (URL_Struct *urls, int status, MWContext *cx);
  172. void                readHTML (char* url, XMLHTMLInclusion ss);
  173.  
  174. PUBLIC NET_StreamClass *    XML_XMLConverter(FO_Present_Types  format_out, void *data_object, URL_Struct *URL_s, MWContext  *window_id);
  175. PUBLIC NET_StreamClass *    XML_CSSConverter(FO_Present_Types  format_out, void *data_object, URL_Struct *URL_s, MWContext  *window_id);
  176. PUBLIC NET_StreamClass *    XML_HTMLConverter(FO_Present_Types  format_out, void *data_object, URL_Struct *URL_s, MWContext  *window_id);
  177.  
  178. XP_END_PROTOS
  179.  
  180. #endif
  181.