1998-04-08 08:04:58 +04:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
1998-04-08 08:04:58 +04:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
1998-04-08 08:04:58 +04:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1998-04-08 08:04:58 +04:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 06:43:54 +03:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1998-04-08 08:04:58 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _RDF_XMLGLUE_H_
|
|
|
|
#define _RDF_XMLGLUE_H_
|
|
|
|
|
1998-04-29 14:13:27 +04:00
|
|
|
/* Make sure @#$%^&* LAYERS is defined for the Mac */
|
|
|
|
#ifndef LAYERS
|
|
|
|
#define LAYERS
|
|
|
|
#endif
|
|
|
|
|
1998-04-08 08:04:58 +04:00
|
|
|
#include "xmlparse.h"
|
1998-05-29 00:10:18 +04:00
|
|
|
|
|
|
|
#ifndef XP_MAC
|
1998-05-24 05:13:55 +04:00
|
|
|
#define MOZILLA_CLIENT 1
|
|
|
|
#endif
|
1998-04-08 08:04:58 +04:00
|
|
|
|
1998-05-24 04:27:54 +04:00
|
|
|
#ifdef MOZILLA_CLIENT
|
1998-04-29 14:13:27 +04:00
|
|
|
#include "jscompat.h"
|
|
|
|
#include "lo_ele.h"
|
|
|
|
#include "libevent.h"
|
|
|
|
#include "libmocha.h"
|
1998-05-24 04:27:54 +04:00
|
|
|
#include "net.h"
|
|
|
|
#include "xp.h"
|
|
|
|
#include "xp_str.h"
|
|
|
|
#endif
|
1998-04-29 14:13:27 +04:00
|
|
|
|
1998-04-08 08:04:58 +04:00
|
|
|
#ifdef XP_UNIX
|
|
|
|
#include <sys/fcntl.h>
|
|
|
|
#elif defined(XP_MAC)
|
|
|
|
#include <fcntl.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* xmlglue.c data structures and defines */
|
|
|
|
|
1998-05-17 22:22:29 +04:00
|
|
|
#define XML_LINE_SIZE 4096
|
1998-04-08 08:04:58 +04:00
|
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "nspr.h"
|
|
|
|
#include "plhash.h"
|
|
|
|
#include "ntypes.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "xmlparse.h"
|
|
|
|
|
|
|
|
#define getMem(x) PR_Calloc(1,(x))
|
|
|
|
#define freeMem(x) PR_Free((x))
|
|
|
|
|
|
|
|
#define copyString(source) XP_STRDUP(source)
|
|
|
|
#define stringEquals(x, y) (strcasecomp(x, y) ==0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef true
|
|
|
|
#define true PR_TRUE
|
|
|
|
#endif
|
|
|
|
#ifndef false
|
|
|
|
#define false PR_FALSE
|
|
|
|
#endif
|
|
|
|
#define null NULL
|
|
|
|
#define nullp(x) (((void*)x) == ((void*)0))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* xmlparse.c data structures and defines */
|
|
|
|
|
|
|
|
#define MAX_TAG_SIZE 100
|
|
|
|
#define MAX_ATTRIBUTES 10
|
|
|
|
#define XML_BUF_SIZE 4096
|
|
|
|
#define wsc(c) ((c == ' ') || (c == '\r') || (c == '\n') || (c == '\t'))
|
|
|
|
typedef struct _XMLFileStruct {
|
|
|
|
int32 status;
|
|
|
|
struct _StyleSheetStruct* ss;
|
|
|
|
struct _XMLElementStruct* top;
|
|
|
|
struct _XMLElementStruct* current;
|
|
|
|
void* stream;
|
|
|
|
int8 numOpenStreams;
|
|
|
|
void* urls;
|
1998-05-24 04:27:54 +04:00
|
|
|
#ifdef MOZILLA_CLIENT
|
1998-04-29 14:13:27 +04:00
|
|
|
MWContext* mwcontext;
|
1998-05-24 04:27:54 +04:00
|
|
|
#endif
|
1998-04-08 08:04:58 +04:00
|
|
|
char* address;
|
1998-04-29 14:13:27 +04:00
|
|
|
char* outputBuffer;
|
1998-04-08 08:04:58 +04:00
|
|
|
XML_Parser parser;
|
1998-04-29 14:13:27 +04:00
|
|
|
int32 numTransclusions;
|
|
|
|
struct _XMLElementStruct** transclusions;
|
1998-04-08 08:04:58 +04:00
|
|
|
} XMLFileStruct;
|
|
|
|
|
|
|
|
typedef XMLFileStruct* XMLFile;
|
|
|
|
|
|
|
|
typedef struct _StyleSheetStruct {
|
|
|
|
XMLFile xmlFile;
|
|
|
|
struct _StyleElementStruct* el;
|
|
|
|
struct _StyleSheetStruct* next;
|
|
|
|
void* urls;
|
|
|
|
char* holdOver;
|
|
|
|
int32 lineSize;
|
|
|
|
char* line;
|
|
|
|
char* address;
|
|
|
|
} StyleSheetStruct;
|
|
|
|
|
|
|
|
typedef StyleSheetStruct* StyleSheet;
|
|
|
|
|
|
|
|
typedef struct _StyleElementStruct {
|
|
|
|
char** tagStack;
|
|
|
|
char* style;
|
|
|
|
struct _StyleElementStruct* next;
|
1998-04-29 14:13:27 +04:00
|
|
|
int id; /* Unique identifier among all style elements in all style sheets */
|
1998-04-08 08:04:58 +04:00
|
|
|
} StyleElementStruct;
|
|
|
|
|
|
|
|
typedef StyleElementStruct* StyleElement;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct _XMLElementStruct {
|
|
|
|
char* tag;
|
|
|
|
char** attributes;
|
|
|
|
char* content;
|
1998-05-24 04:27:54 +04:00
|
|
|
#ifdef MOZILLA_CLIENT
|
1998-04-29 14:13:27 +04:00
|
|
|
JSObject *mocha_object;
|
1998-05-24 04:27:54 +04:00
|
|
|
#endif
|
1998-04-08 08:04:58 +04:00
|
|
|
struct _XMLElementStruct* parent;
|
|
|
|
struct _XMLElementStruct* child;
|
|
|
|
struct _XMLElementStruct* next;
|
|
|
|
} XMLElementStruct;
|
|
|
|
|
|
|
|
typedef XMLElementStruct* XMLElement;
|
|
|
|
|
|
|
|
typedef struct _XMLHTMLInclusionStruct {
|
|
|
|
char** content;
|
|
|
|
XMLFile xml;
|
|
|
|
int32 n;
|
|
|
|
} XMLHTMLInclusionStruct;
|
|
|
|
|
|
|
|
typedef XMLHTMLInclusionStruct *XMLHTMLInclusion;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* xmlparse.c function prototypes */
|
|
|
|
|
|
|
|
XP_BEGIN_PROTOS
|
|
|
|
|
|
|
|
int parseNextXMLBlob (NET_StreamClass *stream, char* blob, int32 size);
|
|
|
|
void processNextXMLContent (XMLFile f, char* content);
|
|
|
|
char ** copyCharStarList (char** list);
|
|
|
|
char * makeAbsoluteURL (char* p1, char* p2);
|
|
|
|
void processNextXMLElement (XMLFile f, char* attr);
|
|
|
|
void addStyleSheet(XMLFile f, StyleSheet ss);
|
|
|
|
void addChild (XMLElement parent, XMLElement child);
|
|
|
|
char * getTagHTMLEquiv (XMLFile f, XMLElement el);
|
|
|
|
void outputAttributes(XMLFile f, char** attlist);
|
|
|
|
void outputAsHTML (XMLFile f, XMLElement el);
|
|
|
|
void convertToHTML (XMLFile xf);
|
|
|
|
void outputStyleSpan (XMLFile f, XMLElement el, PRBool endp);
|
|
|
|
char * getAttributeValue (const char** attlist, char* elName);
|
|
|
|
void tokenizeXMLElement (char* attr, char** attlist);
|
|
|
|
void readCSS(StyleSheet ss);
|
|
|
|
void outputToStream(XMLFile f, char* s);
|
|
|
|
|
|
|
|
|
|
|
|
void XMLDOM_CharHandler (XMLFile f, const char* content, int len) ;
|
|
|
|
void XMLDOM_EndHandler (XMLFile f, const char* elementName) ;
|
|
|
|
void XMLDOM_StartHandler (XMLFile f, const char* elementName, const char** attlist) ;
|
|
|
|
void XMLDOM_PIHandler (XMLFile f, const char *elementName, const char *attlist) ;
|
|
|
|
|
|
|
|
unsigned int xml_write_ready(NET_StreamClass *stream);
|
|
|
|
void xml_abort(NET_StreamClass *stream, int status);
|
|
|
|
void xml_complete (NET_StreamClass *stream);
|
|
|
|
unsigned int xmlcss_write_ready(NET_StreamClass *stream);
|
|
|
|
void xmlcss_abort(NET_StreamClass *stream, int status);
|
|
|
|
void xmlcss_complete (NET_StreamClass *stream);
|
|
|
|
void outputToStream (XMLFile f, char* s);
|
|
|
|
void xmlcss_GetUrlExitFunc (URL_Struct *urls, int status, MWContext *cx);
|
|
|
|
void readCSS (StyleSheet ss);
|
|
|
|
int xmlhtml_write(NET_StreamClass *stream, const char *str, int32 len);
|
|
|
|
unsigned int xmlhtml_write_ready(NET_StreamClass *stream);
|
|
|
|
void xmlhtml_abort(NET_StreamClass *stream, int status);
|
|
|
|
void xmlhtml_complete (NET_StreamClass *stream);
|
1998-04-29 14:13:27 +04:00
|
|
|
void xmlhtml_complete_int (XMLFile xml);
|
1998-04-08 08:04:58 +04:00
|
|
|
void xmlhtml_GetUrlExitFunc (URL_Struct *urls, int status, MWContext *cx);
|
|
|
|
void readHTML (char* url, XMLHTMLInclusion ss);
|
|
|
|
|
|
|
|
PUBLIC NET_StreamClass * XML_XMLConverter(FO_Present_Types format_out, void *data_object, URL_Struct *URL_s, MWContext *window_id);
|
|
|
|
PUBLIC NET_StreamClass * XML_CSSConverter(FO_Present_Types format_out, void *data_object, URL_Struct *URL_s, MWContext *window_id);
|
|
|
|
PUBLIC NET_StreamClass * XML_HTMLConverter(FO_Present_Types format_out, void *data_object, URL_Struct *URL_s, MWContext *window_id);
|
|
|
|
|
|
|
|
XP_END_PROTOS
|
|
|
|
|
|
|
|
#endif
|