home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / modules / rdf / src / xmlparse.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.7 KB  |  142 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_XMLPARSE_H_
  20. #define    _RDF_XMLPARSE_H_
  21.  
  22.  
  23. /* This is a "stop-gap" xml parser that is being shipped with the free
  24.    source. A real xml parser from James Clark will replace this 
  25.    within the next few weeks */
  26.  
  27.  
  28. #include <stdlib.h>
  29. #include <string.h>
  30. #include "nspr.h"
  31. #include "plhash.h"
  32. #include "ntypes.h"
  33. #include "net.h"
  34. #include "xp.h"
  35. #include "xp_str.h"
  36. #include "utils.h"
  37. #include "rdf-int.h"
  38.  
  39.  
  40.  
  41. #ifndef true
  42. #define true PR_TRUE
  43. #endif
  44. #ifndef false
  45. #define false PR_FALSE
  46. #endif
  47. #define null NULL
  48. #define nullp(x) (((void*)x) == ((void*)0))
  49.  
  50.  
  51.  
  52. /* xmlparse.c data structures and defines */
  53.  
  54. #define MAX_TAG_SIZE 100
  55. #define MAX_ATTRIBUTES 10
  56. #define XML_BUF_SIZE 4096
  57. #define wsc(c) ((c == ' ') || (c == '\r') || (c == '\n') || (c == '\t'))
  58. typedef struct _XMLFileStruct {
  59.   struct _StyleSheetStruct* ss;
  60.   struct _XMLElementStruct*  top;
  61.   struct _XMLElementStruct*  current;
  62.   uint32  status;
  63.   void*   stream;
  64.   int8  numOpenStreams;
  65.   void*  urls;
  66.   void* mwcontext;
  67.   char* holdOver;
  68.   int32   lineSize;
  69.   char* line;
  70.   char*  address;
  71. } XMLFileStruct;
  72.  
  73. typedef XMLFileStruct* XMLFile;
  74.  
  75. typedef struct _StyleSheetStruct {
  76.   XMLFile xmlFile;
  77.   struct _StyleElementStruct* el;
  78.   struct _StyleSheetStruct* next;
  79.   void*  urls;
  80.   char* holdOver;
  81.   int32   lineSize;
  82.   char* line;
  83.   char* address;
  84. } StyleSheetStruct;
  85.  
  86. typedef StyleSheetStruct* StyleSheet;
  87.  
  88. typedef struct _StyleElementStruct {
  89.   char** tagStack;
  90.   char*   style;
  91.   struct _StyleElementStruct* next;
  92. } StyleElementStruct;
  93.  
  94. typedef StyleElementStruct* StyleElement;
  95.  
  96.  
  97. typedef struct _XMLElementStruct {
  98.   char*  tag;
  99.   char** attributes;
  100.   char* content;
  101.   struct _XMLElementStruct* parent;
  102.   struct _XMLElementStruct* child;
  103.   struct _XMLElementStruct* next;
  104. } XMLElementStruct;
  105.  
  106. typedef XMLElementStruct* XMLElement;
  107.  
  108. typedef struct _XMLHTMLInclusionStruct {
  109.   char** content;
  110.   XMLFile xml;
  111.   int32 n;
  112. } XMLHTMLInclusionStruct;
  113.  
  114. typedef  XMLHTMLInclusionStruct *XMLHTMLInclusion;
  115.  
  116.  
  117.  
  118. /* xmlparse.c function prototypes */
  119.  
  120. XP_BEGIN_PROTOS
  121.  
  122. int        parseNextXMLBlob (NET_StreamClass *stream, char* blob, int32 size);
  123. void        processNextXMLContent (XMLFile f, char* content);
  124. char **        copyCharStarList (char** list);
  125. char *        makeAbsoluteURL (char* p1, char* p2);
  126. void        processNextXMLElement (XMLFile f, char* attr);
  127. void        addStyleSheet(XMLFile f, StyleSheet ss);
  128. void        addChild (XMLElement parent, XMLElement child);
  129. char *        getTagHTMLEquiv (XMLFile f, XMLElement el);
  130. void        outputAttributes(XMLFile f, char** attlist);
  131. void        outputAsHTML (XMLFile f, XMLElement el);
  132. void        convertToHTML (XMLFile xf);
  133. void        outputStyleSpan (XMLFile f, XMLElement el, PRBool endp);
  134. char *        getAttributeValue (char** attlist, char* elName);
  135. void        tokenizeXMLElement (char* attr, char** attlist, char** elementName);
  136. void            readCSS(StyleSheet ss);
  137. void            outputToStream(XMLFile f, char* s);
  138.  
  139. XP_END_PROTOS
  140.  
  141. #endif
  142.