зеркало из https://github.com/mozilla/gecko-dev.git
Fix for bug 88623 (Cleanup Transformiix code). r=Pike, sr=jst.
This commit is contained in:
Родитель
e53a1781f1
Коммит
2265ea47a2
|
@ -57,7 +57,6 @@ CPPSRCS = XSLTProcessorModule.cpp
|
|||
LOBJS =../source/base/ArrayList.$(OBJ_SUFFIX) \
|
||||
../source/base/Double.$(OBJ_SUFFIX) \
|
||||
../source/base/List.$(OBJ_SUFFIX) \
|
||||
../source/base/TxObjectWrapper.$(OBJ_SUFFIX) \
|
||||
../source/base/Map.$(OBJ_SUFFIX) \
|
||||
../source/base/NamedMap.$(OBJ_SUFFIX) \
|
||||
../source/base/SimpleErrorObserver.$(OBJ_SUFFIX) \
|
||||
|
@ -67,7 +66,7 @@ LOBJS =../source/base/ArrayList.$(OBJ_SUFFIX) \
|
|||
../source/base/txAtoms.$(OBJ_SUFFIX) \
|
||||
../source/base/txExpandedNameMap.$(OBJ_SUFFIX) \
|
||||
../source/base/MozillaString.$(OBJ_SUFFIX) \
|
||||
../source/net/URIUtils.$(OBJ_SUFFIX) \
|
||||
../source/base/txURIUtils.$(OBJ_SUFFIX) \
|
||||
../source/xml/dom/mozImpl/MozillaObjectWrapper.$(OBJ_SUFFIX) \
|
||||
../source/xml/dom/mozImpl/MozillaAttr.$(OBJ_SUFFIX) \
|
||||
../source/xml/dom/mozImpl/MozillaCDATASection.$(OBJ_SUFFIX) \
|
||||
|
@ -161,7 +160,6 @@ EXTRA_DSO_LDOPTS += \
|
|||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
INCLUDES += -I$(srcdir)/../source/xslt -I$(srcdir)/../source/base \
|
||||
-I$(srcdir)/../source/net \
|
||||
-I$(srcdir)/../source/xml -I$(srcdir)/../source/xml/dom \
|
||||
-I$(srcdir)/../source/xml/parser -I$(srcdir)/../source/xpath \
|
||||
-I$(srcdir)/../source/xslt/util -I$(srcdir)/../source/xslt/functions
|
||||
|
|
|
@ -42,7 +42,6 @@ CPP_OBJS= \
|
|||
..\source\base\$(OBJDIR)\ArrayList.obj \
|
||||
..\source\base\$(OBJDIR)\Double.obj \
|
||||
..\source\base\$(OBJDIR)\List.obj \
|
||||
..\source\base\$(OBJDIR)\TxObjectWrapper.obj \
|
||||
..\source\base\$(OBJDIR)\Map.obj \
|
||||
..\source\base\$(OBJDIR)\NamedMap.obj \
|
||||
..\source\base\$(OBJDIR)\SimpleErrorObserver.obj \
|
||||
|
@ -52,7 +51,7 @@ CPP_OBJS= \
|
|||
..\source\base\$(OBJDIR)\txAtoms.obj \
|
||||
..\source\base\$(OBJDIR)\txExpandedNameMap.obj \
|
||||
..\source\base\$(OBJDIR)\MozillaString.obj \
|
||||
..\source\net\$(OBJDIR)\URIUtils.obj \
|
||||
..\source\base\$(OBJDIR)\txURIUtils.obj \
|
||||
..\source\xml\dom\mozImpl\$(OBJDIR)\MozillaObjectWrapper.obj \
|
||||
..\source\xml\dom\mozImpl\$(OBJDIR)\MozillaAttr.obj \
|
||||
..\source\xml\dom\mozImpl\$(OBJDIR)\MozillaCDATASection.obj \
|
||||
|
|
|
@ -1137,7 +1137,7 @@
|
|||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>URIUtils.cpp</PATH>
|
||||
<PATH>txURIUtils.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS></FILEFLAGS>
|
||||
|
@ -1797,7 +1797,7 @@
|
|||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>URIUtils.cpp</PATH>
|
||||
<PATH>txURIUtils.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
|
@ -3235,7 +3235,7 @@
|
|||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>URIUtils.cpp</PATH>
|
||||
<PATH>txURIUtils.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS></FILEFLAGS>
|
||||
|
@ -3911,7 +3911,7 @@
|
|||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>URIUtils.cpp</PATH>
|
||||
<PATH>txURIUtils.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
|
@ -4443,12 +4443,10 @@
|
|||
<PATH>txExpandedNameMap.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
</GROUP>
|
||||
<GROUP><NAME>net</NAME>
|
||||
<FILEREF>
|
||||
<TARGETNAME>transformiixDebug.shlb</TARGETNAME>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>URIUtils.cpp</PATH>
|
||||
<PATH>txURIUtils.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
</GROUP>
|
||||
|
|
|
@ -26,7 +26,7 @@ VPATH = @srcdir@
|
|||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = base net xml xpath xslt
|
||||
DIRS = base xml xpath xslt
|
||||
|
||||
ifdef TX_EXE
|
||||
DIRS += main
|
||||
|
|
|
@ -41,14 +41,14 @@ CPPSRCS = ArrayList.cpp \
|
|||
Double.cpp \
|
||||
List.cpp \
|
||||
Map.cpp \
|
||||
TxObjectWrapper.cpp \
|
||||
NamedMap.cpp \
|
||||
SimpleErrorObserver.cpp \
|
||||
Stack.cpp \
|
||||
StringList.cpp \
|
||||
Tokenizer.cpp \
|
||||
txAtoms.cpp \
|
||||
txExpandedNameMap.cpp
|
||||
txExpandedNameMap.cpp \
|
||||
txURIUtils.cpp
|
||||
|
||||
ifdef TX_EXE
|
||||
CPPSRCS += CommandLineUtils.cpp \
|
||||
|
|
|
@ -58,14 +58,4 @@ class TxObject {
|
|||
} //-- equals
|
||||
};
|
||||
|
||||
/**
|
||||
* A Simple TxObject wrapper class
|
||||
**/
|
||||
class TxObjectWrapper : public TxObject {
|
||||
public:
|
||||
TxObjectWrapper();
|
||||
virtual ~TxObjectWrapper();
|
||||
void* object;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The Original Code is TransforMiiX XSLT processor.
|
||||
*
|
||||
* The Initial Developer of the Original Code is The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Keith Visco as a Non MITRE employee,
|
||||
* (C) 1999 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
*/
|
||||
|
||||
#include "TxObject.h"
|
||||
|
||||
//--------------------------------------/
|
||||
//- A Simple TxObject wrapper class -/
|
||||
//--------------------------------------/
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
**/
|
||||
TxObjectWrapper::TxObjectWrapper() {
|
||||
this->object = 0;
|
||||
} //-- TxObjectWrapper
|
||||
|
||||
/**
|
||||
* Default destructor
|
||||
**/
|
||||
TxObjectWrapper::~TxObjectWrapper() {
|
||||
this->object = 0;
|
||||
} //-- ~TxObjectWrapper
|
||||
|
|
@ -39,7 +39,6 @@ CPP_OBJS= \
|
|||
.\$(OBJDIR)\ArrayList.obj \
|
||||
.\$(OBJDIR)\Double.obj \
|
||||
.\$(OBJDIR)\List.obj \
|
||||
.\$(OBJDIR)\TxObjectWrapper.obj \
|
||||
.\$(OBJDIR)\NamedMap.obj \
|
||||
.\$(OBJDIR)\SimpleErrorObserver.obj \
|
||||
.\$(OBJDIR)\Stack.obj \
|
||||
|
@ -47,7 +46,8 @@ CPP_OBJS= \
|
|||
.\$(OBJDIR)\StringList.obj \
|
||||
.\$(OBJDIR)\Tokenizer.obj \
|
||||
.\$(OBJDIR)\txAtoms.obj \
|
||||
.\$(OBJDIR)\txExpandedNameMap.obj
|
||||
.\$(OBJDIR)\txExpandedNameMap.obj \
|
||||
.\$(OBJDIR)\txURIUtils.obj
|
||||
|
||||
!ifndef TX_EXE
|
||||
CPP_OBJS = $(CPP_OBJS) \
|
||||
|
|
|
@ -32,7 +32,6 @@ OBJS =../base/ArrayList.$(OBJ_SUFFIX) \
|
|||
../base/CommandLineUtils.$(OBJ_SUFFIX) \
|
||||
../base/Double.$(OBJ_SUFFIX) \
|
||||
../base/List.$(OBJ_SUFFIX) \
|
||||
../base/TxObjectWrapper.$(OBJ_SUFFIX) \
|
||||
../base/Map.$(OBJ_SUFFIX) \
|
||||
../base/NamedMap.$(OBJ_SUFFIX) \
|
||||
../base/SimpleErrorObserver.$(OBJ_SUFFIX) \
|
||||
|
@ -42,7 +41,7 @@ OBJS =../base/ArrayList.$(OBJ_SUFFIX) \
|
|||
../base/txAtoms.$(OBJ_SUFFIX) \
|
||||
../base/txExpandedNameMap.$(OBJ_SUFFIX) \
|
||||
../base/TxString.$(OBJ_SUFFIX) \
|
||||
../net/URIUtils.$(OBJ_SUFFIX) \
|
||||
../base/txURIUtils.$(OBJ_SUFFIX) \
|
||||
../xml/dom/standalone/Attr.$(OBJ_SUFFIX) \
|
||||
../xml/dom/standalone/CDATASection.$(OBJ_SUFFIX) \
|
||||
../xml/dom/standalone/DocumentType.$(OBJ_SUFFIX) \
|
||||
|
|
|
@ -30,7 +30,6 @@ CPP_OBJS= \
|
|||
../base/$(OBJDIR)/CommandLineUtils.obj \
|
||||
../base/$(OBJDIR)/Double.obj \
|
||||
../base/$(OBJDIR)/List.obj \
|
||||
../base/$(OBJDIR)/TxObjectWrapper.obj \
|
||||
../base/$(OBJDIR)/Map.obj \
|
||||
../base/$(OBJDIR)/NamedMap.obj \
|
||||
../base/$(OBJDIR)/SimpleErrorObserver.obj \
|
||||
|
@ -40,7 +39,7 @@ CPP_OBJS= \
|
|||
../base/$(OBJDIR)/txAtoms.obj \
|
||||
../base/$(OBJDIR)/txExpandedNameMap.obj \
|
||||
../base/$(OBJDIR)/TxString.obj \
|
||||
../net/$(OBJDIR)/URIUtils.obj \
|
||||
../base/$(OBJDIR)/txURIUtils.obj \
|
||||
../xml/dom/standalone/$(OBJDIR)/Attr.obj \
|
||||
../xml/dom/standalone/$(OBJDIR)/CDATASection.obj \
|
||||
../xml/dom/standalone/$(OBJDIR)/DocumentType.obj \
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
DEPTH=..\..\..
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
|
||||
DIRS=base net xml xpath xslt
|
||||
DIRS=base xml xpath xslt
|
||||
|
||||
!ifdef TX_EXE
|
||||
DIRS = $(DIRS) main
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Makefile
|
|
@ -1,43 +0,0 @@
|
|||
#
|
||||
# The contents of this file are subject to the Mozilla 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/MPL/
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# The Original Code is Transformiix XSLT Processor.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Axel Hecht.
|
||||
# Portions created by Axel Hecht are Copyright (C) Axel Hecht.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Axel Hecht <axel@pike.org>
|
||||
#
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
ifndef TX_EXE
|
||||
MODULE = transformiix
|
||||
REQUIRES = string \
|
||||
xpcom \
|
||||
necko \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
CPPSRCS = URIUtils.cpp
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
INCLUDES += -I$(srcdir)/../base
|
||||
|
||||
libs:: $(OBJS)
|
|
@ -1,314 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The Original Code is TransforMiiX XSLT processor.
|
||||
*
|
||||
* The Initial Developer of the Original Code is The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Keith Visco as a Non MITRE employee,
|
||||
* (C) 1999 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
* Larry Fitzpatrick, OpenText, lef@opentext.com
|
||||
* -- 19990806
|
||||
* -- moved initialization of constant shorts and chars from
|
||||
* URIUtils.cpp to here
|
||||
*
|
||||
* Peter Van der Beken
|
||||
*
|
||||
*/
|
||||
|
||||
#include "URIUtils.h"
|
||||
|
||||
#ifndef TX_EXE
|
||||
#include "nsNetUtil.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* URIUtils
|
||||
* A set of utilities for handling URIs
|
||||
**/
|
||||
|
||||
#ifdef TX_EXE
|
||||
//- Constants -/
|
||||
|
||||
const String URIUtils::HTTP_PROTOCOL = "http";
|
||||
const String URIUtils::FILE_PROTOCOL = "file";
|
||||
const char URIUtils::HREF_PATH_SEP = '/';
|
||||
const char URIUtils::DEVICE_SEP = '|';
|
||||
const char URIUtils::PORT_SEP = ':';
|
||||
const char URIUtils::PROTOCOL_SEP = ':';
|
||||
const short URIUtils::PROTOCOL_MODE = 1;
|
||||
const short URIUtils::HOST_MODE = 2;
|
||||
const short URIUtils::PORT_MODE = 3;
|
||||
const short URIUtils::PATH_MODE = 4;
|
||||
|
||||
|
||||
/**
|
||||
* Returns an InputStream for the file represented by the href
|
||||
* argument
|
||||
* @param href the href of the file to get the input stream for.
|
||||
* @return an InputStream to the desired resource
|
||||
* @exception java.io.FileNotFoundException when the file could not be
|
||||
* found
|
||||
**/
|
||||
istream* URIUtils::getInputStream
|
||||
(const String& href, String& errMsg)
|
||||
{
|
||||
|
||||
istream* inStream = 0;
|
||||
|
||||
ParsedURI* uri = parseURI(href);
|
||||
if ( !uri->isMalformed ) {
|
||||
inStream = openStream(uri);
|
||||
}
|
||||
else {
|
||||
// Try local files
|
||||
char* fchars = new char[href.length()+1];
|
||||
inStream = new ifstream(href.toCharArray(fchars), ios::in);
|
||||
delete fchars;
|
||||
}
|
||||
delete uri;
|
||||
|
||||
return inStream;
|
||||
|
||||
} //-- getInputStream
|
||||
|
||||
/**
|
||||
* Returns the document base of the href argument
|
||||
* @return the document base of the given href
|
||||
**/
|
||||
void URIUtils::getDocumentBase(const String& href, String& dest) {
|
||||
//-- use temp str so the subString method doesn't destroy dest
|
||||
String docBase("");
|
||||
|
||||
if (!href.isEmpty()) {
|
||||
|
||||
int idx = -1;
|
||||
//-- check for URL
|
||||
ParsedURI* uri = parseURI(href);
|
||||
if ( !uri->isMalformed ) {
|
||||
idx = href.lastIndexOf(HREF_PATH_SEP);
|
||||
}
|
||||
else {
|
||||
//-- The following contains a fix from Shane Hathaway
|
||||
//-- to handle the case when both "\" and "/" appear in filename
|
||||
int idx2 = href.lastIndexOf(HREF_PATH_SEP);
|
||||
//idx = href.lastIndexOf(File.separator);
|
||||
idx = -1; //-- hack change later
|
||||
if (idx2 > idx) idx = idx2;
|
||||
}
|
||||
if (idx >= 0) href.subString(0,idx, docBase);
|
||||
delete uri;
|
||||
}
|
||||
dest.append(docBase);
|
||||
} //-- getDocumentBase
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Resolves the given href argument, using the given documentBase
|
||||
* if necessary.
|
||||
* The new resolved href will be appended to the given dest String
|
||||
**/
|
||||
void URIUtils::resolveHref(const String& href, const String& base,
|
||||
String& dest) {
|
||||
if (base.isEmpty()) {
|
||||
dest.append(href);
|
||||
return;
|
||||
}
|
||||
if (href.isEmpty()) {
|
||||
dest.append(base);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef TX_EXE
|
||||
nsCOMPtr<nsIURI> pURL;
|
||||
String resultHref;
|
||||
nsresult result = NS_NewURI(getter_AddRefs(pURL), base.getConstNSString());
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
NS_MakeAbsoluteURI(resultHref.getNSString(), href.getConstNSString(), pURL);
|
||||
dest.append(resultHref);
|
||||
}
|
||||
#else
|
||||
String documentBase;
|
||||
getDocumentBase(base, documentBase);
|
||||
|
||||
//-- check for URL
|
||||
ParsedURI* uri = parseURI(href);
|
||||
if ( !uri->isMalformed ) {
|
||||
dest.append(href);
|
||||
delete uri;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//-- join document base + href
|
||||
String xHref;
|
||||
if (!documentBase.isEmpty()) {
|
||||
xHref.append(documentBase);
|
||||
if (documentBase.charAt(documentBase.length()-1) != HREF_PATH_SEP)
|
||||
xHref.append(HREF_PATH_SEP);
|
||||
}
|
||||
xHref.append(href);
|
||||
|
||||
//-- check new href
|
||||
ParsedURI* newUri = parseURI(xHref);
|
||||
if ( !newUri->isMalformed ) {
|
||||
dest.append(xHref);
|
||||
}
|
||||
else {
|
||||
// Try local files
|
||||
char* xHrefChars = new char[xHref.length()+1];
|
||||
ifstream inFile(xHref.toCharArray(xHrefChars), ios::in);
|
||||
if ( inFile ) dest.append(xHref);
|
||||
else dest.append(href);
|
||||
inFile.close();
|
||||
delete xHrefChars;
|
||||
}
|
||||
delete uri;
|
||||
delete newUri;
|
||||
//cout << "\n---\nhref='" << href << "', base='" << base << "'\ndocumentBase='" << documentBase << "', dest='" << dest << "'\n---\n";
|
||||
#endif
|
||||
} //-- resolveHref
|
||||
|
||||
void URIUtils::getFragmentIdentifier(const String& href, String& frag) {
|
||||
PRInt32 pos;
|
||||
pos = href.lastIndexOf('#');
|
||||
if(pos != NOT_FOUND)
|
||||
href.subString(pos+1, frag);
|
||||
else
|
||||
frag.clear();
|
||||
} //-- getFragmentIdentifier
|
||||
|
||||
void URIUtils::getDocumentURI(const String& href, String& docUri) {
|
||||
PRInt32 pos;
|
||||
pos = href.lastIndexOf('#');
|
||||
if(pos != NOT_FOUND)
|
||||
href.subString(0,pos,docUri);
|
||||
else
|
||||
docUri = href;
|
||||
} //-- getDocumentURI
|
||||
|
||||
#ifdef TX_EXE
|
||||
istream* URIUtils::openStream(ParsedURI* uri) {
|
||||
if ( !uri ) return 0;
|
||||
// check protocol
|
||||
|
||||
istream* inStream = 0;
|
||||
if ( FILE_PROTOCOL.isEqual(uri->protocol) ) {
|
||||
char* fchars = new char[uri->path.length()+1];
|
||||
ifstream* inFile = new ifstream(uri->path.toCharArray(fchars), ios::in);
|
||||
delete fchars;
|
||||
inStream = inFile;
|
||||
}
|
||||
|
||||
return inStream;
|
||||
} //-- openStream
|
||||
|
||||
URIUtils::ParsedURI* URIUtils::parseURI(const String& uri) {
|
||||
|
||||
ParsedURI* uriTokens = new ParsedURI;
|
||||
if (!uriTokens)
|
||||
return NULL;
|
||||
uriTokens->isMalformed = MB_FALSE;
|
||||
|
||||
short mode = PROTOCOL_MODE;
|
||||
|
||||
// look for protocol
|
||||
int totalCount = uri.length();
|
||||
int charCount = 0;
|
||||
UNICODE_CHAR prevCh = '\0';
|
||||
int fslash = 0;
|
||||
String buffer(uri.length());
|
||||
while ( charCount < totalCount ) {
|
||||
UNICODE_CHAR ch = uri.charAt(charCount++);
|
||||
switch(ch) {
|
||||
case '.' :
|
||||
if ( mode == PROTOCOL_MODE ) {
|
||||
uriTokens->isMalformed = MB_TRUE;
|
||||
mode = HOST_MODE;
|
||||
}
|
||||
buffer.append(ch);
|
||||
break;
|
||||
case ':' :
|
||||
{
|
||||
switch ( mode ) {
|
||||
case PROTOCOL_MODE :
|
||||
uriTokens->protocol = buffer;
|
||||
buffer.clear();
|
||||
mode = HOST_MODE;
|
||||
break;
|
||||
case HOST_MODE :
|
||||
uriTokens->host = buffer;
|
||||
buffer.clear();
|
||||
mode = PORT_MODE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '/' :
|
||||
switch ( mode ) {
|
||||
case HOST_MODE :
|
||||
if (!buffer.isEmpty()) {
|
||||
mode = PATH_MODE;
|
||||
buffer.append(ch);
|
||||
}
|
||||
else if ( fslash == 2 ) mode = PATH_MODE;
|
||||
else ++fslash;
|
||||
break;
|
||||
case PORT_MODE :
|
||||
mode = PATH_MODE;
|
||||
uriTokens->port.append(buffer);
|
||||
buffer.clear();
|
||||
break;
|
||||
default:
|
||||
buffer.append(ch);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
buffer.append(ch);
|
||||
}
|
||||
prevCh = ch;
|
||||
}
|
||||
|
||||
if ( mode == PROTOCOL_MODE ) {
|
||||
uriTokens->isMalformed = MB_TRUE;
|
||||
}
|
||||
//-- finish remaining mode
|
||||
if (!buffer.isEmpty()) {
|
||||
switch ( mode ) {
|
||||
case PROTOCOL_MODE :
|
||||
uriTokens->protocol.append(buffer);
|
||||
break;
|
||||
case HOST_MODE :
|
||||
uriTokens->host.append(buffer);
|
||||
break;
|
||||
case PORT_MODE :
|
||||
uriTokens->port.append(buffer);
|
||||
break;
|
||||
case PATH_MODE :
|
||||
uriTokens->path.append(buffer);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return uriTokens;
|
||||
} //-- parseURI
|
||||
|
||||
#endif
|
|
@ -1,135 +0,0 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Mozilla 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/MPL/
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The Original Code is TransforMiiX XSLT processor.
|
||||
*
|
||||
* The Initial Developer of the Original Code is The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Keith Visco as a Non MITRE employee,
|
||||
* (C) 1999 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
*
|
||||
* Larry Fitzpatrick, OpenText, lef@opentext.com
|
||||
* -- 19990806
|
||||
* -- moved initialization of constant shorts and chars to
|
||||
* URIUtils.cpp
|
||||
*
|
||||
* Peter Van der Beken
|
||||
* -- 20000326
|
||||
* -- added Mozilla integration code
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TRANSFRMX_URIUTILS_H
|
||||
#define TRANSFRMX_URIUTILS_H
|
||||
|
||||
#include "TxString.h"
|
||||
#include "baseutils.h"
|
||||
#ifdef TX_EXE
|
||||
#include <fstream.h>
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* A utility class for URI handling
|
||||
* Not yet finished, only handles file URI at this point
|
||||
**/
|
||||
|
||||
class URIUtils {
|
||||
|
||||
|
||||
public:
|
||||
|
||||
#ifdef TX_EXE
|
||||
static const String HTTP_PROTOCOL;
|
||||
static const String FILE_PROTOCOL;
|
||||
|
||||
/**
|
||||
* the path separator for an URI
|
||||
**/
|
||||
static const char HREF_PATH_SEP;
|
||||
|
||||
/**
|
||||
* The Device separator for an URI
|
||||
**/
|
||||
static const char DEVICE_SEP;
|
||||
|
||||
/**
|
||||
* The Port separator for an URI
|
||||
**/
|
||||
static const char PORT_SEP;
|
||||
|
||||
/**
|
||||
* The Protocal separator for an URI
|
||||
**/
|
||||
static const char PROTOCOL_SEP;
|
||||
|
||||
|
||||
static istream* getInputStream
|
||||
(const String& href, String& errMsg);
|
||||
|
||||
/**
|
||||
* Returns the document base of the href argument
|
||||
* The document base will be appended to the given dest String
|
||||
**/
|
||||
static void getDocumentBase(const String& href, String& dest);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Resolves the given href argument, using the given documentBase
|
||||
* if necessary.
|
||||
* The new resolved href will be appended to the given dest String
|
||||
**/
|
||||
static void resolveHref(const String& href, const String& base, String& dest);
|
||||
|
||||
/**
|
||||
* Returns the fragment identifier of the given URI, or "" if none exists
|
||||
* frag is cleared before the idetifier is appended
|
||||
**/
|
||||
static void getFragmentIdentifier(const String& href, String& frag);
|
||||
|
||||
/**
|
||||
* Returns the document location of given the URI (ie everything except
|
||||
* fragment). docUri is cleared before the URI is appended
|
||||
**/
|
||||
static void getDocumentURI(const String& href, String& docUri);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
#ifdef TX_EXE
|
||||
static const short PROTOCOL_MODE;
|
||||
static const short HOST_MODE;
|
||||
static const short PORT_MODE;
|
||||
static const short PATH_MODE;
|
||||
|
||||
struct ParsedURI {
|
||||
MBool isMalformed;
|
||||
String fragmentIdentifier;
|
||||
String host;
|
||||
String protocol;
|
||||
String port;
|
||||
String path;
|
||||
};
|
||||
|
||||
static istream* openStream(ParsedURI* uri);
|
||||
static ParsedURI* parseURI(const String& uri);
|
||||
#endif
|
||||
|
||||
}; //-- URIUtils
|
||||
|
||||
/* */
|
||||
#endif
|
|
@ -1,49 +0,0 @@
|
|||
#!nmake
|
||||
#
|
||||
# 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/
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
REQUIRES = string \
|
||||
xpcom \
|
||||
necko \
|
||||
$(NULL)
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
|
||||
!if defined(TX_EXE)
|
||||
DEFINES= $(DEFINES) -DTX_EXE
|
||||
!endif
|
||||
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\URIUtils.obj \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
LINCS=-I$(PUBLIC)\xpcom -I..\base
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
$(DEFINES) \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
libs:: $(OBJDIR) $(CPP_OBJS)
|
|
@ -57,7 +57,7 @@ CPPSRCS = MozillaAttr.cpp \
|
|||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
INCLUDES += -I$(srcdir)/../../../base -I$(srcdir)/../../ -I$(srcdir)/../../../net \
|
||||
INCLUDES += -I$(srcdir)/../../../base -I$(srcdir)/../../ \
|
||||
-I$(srcdir)/../../../xpath -I$(srcdir)/../../../xslt
|
||||
|
||||
libs:: $(OBJS)
|
||||
|
|
|
@ -55,7 +55,7 @@ CPP_OBJS= \
|
|||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
LINCS= -I..\..\..\base -I..\..\dom -I..\.. -I..\..\..\net \
|
||||
LINCS= -I..\..\..\base -I..\..\dom -I..\.. \
|
||||
-I..\..\..\xpath -I..\..\..\xslt
|
||||
|
||||
LCFLAGS = \
|
||||
|
|
|
@ -46,8 +46,7 @@ CPPSRCS = Attr.cpp \
|
|||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
INCLUDES += -I$(srcdir) -I$(srcdir)/../.. \
|
||||
-I$(srcdir)/../../../base -I$(srcdir)/../../../net \
|
||||
INCLUDES += -I$(srcdir) -I$(srcdir)/../.. -I$(srcdir)/../../../base \
|
||||
-I$(srcdir)/../../../xpath -I$(srcdir)/../../../xslt
|
||||
|
||||
libs:: $(OBJS)
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
#include "dom.h"
|
||||
#include "ArrayList.h"
|
||||
#include "URIUtils.h"
|
||||
#include "txURIUtils.h"
|
||||
#include "txAtoms.h"
|
||||
#include <string.h>
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ CPP_OBJS= \
|
|||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
LINCS=-I..\.. -I..\..\..\base -I..\..\..\net \
|
||||
LINCS=-I..\.. -I..\..\..\base \
|
||||
-I..\..\..\xpath -I..\..\..\xslt
|
||||
|
||||
LCFLAGS = \
|
||||
|
|
|
@ -50,7 +50,7 @@ endif
|
|||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
INCLUDES += -I$(srcdir)/../../base -I$(srcdir)/../../net -I$(srcdir)/../dom
|
||||
INCLUDES += -I$(srcdir)/../../base -I$(srcdir)/../dom
|
||||
ifdef TX_EXE
|
||||
INCLUDES += -I$(srcdir)/xmlparse -I$(srcdir)/xmltok
|
||||
COMPILE_CFLAGS += -DXML_UNICODE
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include "XMLParser.h"
|
||||
#include "URIUtils.h"
|
||||
#include "txURIUtils.h"
|
||||
#ifndef TX_EXE
|
||||
#include "nsSyncLoader.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
|
|
@ -51,7 +51,7 @@ CPP_OBJS= \
|
|||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
LINCS=-I..\..\base -I..\dom -I..\..\net
|
||||
LINCS=-I..\..\base -I..\dom
|
||||
!ifndef TX_EXE
|
||||
LINCS=$(LINCS) -I$(PUBLIC)\expat
|
||||
!else
|
||||
|
|
|
@ -69,10 +69,9 @@ endif
|
|||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
INCLUDES += -I$(srcdir) -I$(srcdir)/../base -I$(srcdir)/../net \
|
||||
INCLUDES += -I$(srcdir) -I$(srcdir)/../base \
|
||||
-I$(srcdir)/../xml -I$(srcdir)/../xml/dom \
|
||||
-I$(srcdir)/../xml/parser -I$(srcdir)/../xml/parser/xmlparse \
|
||||
-I$(srcdir)/../xml/printer -I$(srcdir)/../xpath -I$(srcdir)/../xslt/util \
|
||||
-I$(srcdir)/../xslt/functions
|
||||
-I$(srcdir)/../xpath -I$(srcdir)/util -I$(srcdir)/functions
|
||||
|
||||
libs:: $(OBJS)
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include "ProcessorState.h"
|
||||
#include "XSLTFunctions.h"
|
||||
#include "FunctionLib.h"
|
||||
#include "URIUtils.h"
|
||||
#include "txURIUtils.h"
|
||||
#include "XMLUtils.h"
|
||||
#include "XMLDOMUtils.h"
|
||||
#include "Tokenizer.h"
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
#include "txNodeSorter.h"
|
||||
#include "Numbering.h"
|
||||
#include "Tokenizer.h"
|
||||
#include "URIUtils.h"
|
||||
#include "txURIUtils.h"
|
||||
#include "txAtoms.h"
|
||||
#include "TxLog.h"
|
||||
#include "txRtfHandler.h"
|
||||
|
|
|
@ -48,10 +48,8 @@ CPPSRCS = CurrentFunctionCall.cpp \
|
|||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
INCLUDES += -I$(srcdir)/../../base -I$(srcdir)/../../net \
|
||||
-I$(srcdir)/../../xpath -I$(srcdir)/../../xml \
|
||||
-I$(srcdir)/../../xml/parser -I$(srcdir)/../../xml/parser/xmlparse \
|
||||
-I$(srcdir)/../../xml/dom \
|
||||
-I$(srcdir)/.. -I$(srcdir)/../util
|
||||
INCLUDES += -I$(srcdir)/../../base -I$(srcdir)/../../xpath \
|
||||
-I$(srcdir)/../../xml/dom -I$(srcdir)/../../xml \
|
||||
-I$(srcdir)/../../xml/parser -I$(srcdir)/.. -I$(srcdir)/../util
|
||||
|
||||
libs:: $(OBJS)
|
||||
|
|
|
@ -49,7 +49,7 @@ EXPORTS = \
|
|||
|
||||
LINCS= $(LINCS) -I$(PUBLIC)\xpcom -I..\..\base \
|
||||
-I..\..\xml\dom -I..\..\xpath -I..\..\xml -I.. \
|
||||
-I..\..\net -I$(DEPTH)\expat -I..\..\xml\parser -I..\util
|
||||
-I$(DEPTH)\expat -I..\..\xml\parser -I..\util
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
|
|
|
@ -72,11 +72,11 @@ EXPORTS = \
|
|||
$(NULL)
|
||||
|
||||
!ifdef TX_EXE
|
||||
LINCS=-I. -I..\base -I..\net -I..\xml -I..\xml\dom -I..\xml\parser \
|
||||
-I..\xml\parser\xmlparse -I..\xml\printer -I..\xpath -Iutil -Ifunctions
|
||||
LINCS=-I. -I..\base -I..\xml -I..\xml\dom -I..\xml\parser \
|
||||
-I..\xml\parser\xmlparse -I..\xpath -I.\util -I.\functions
|
||||
!else
|
||||
LINCS=-I$(PUBLIC)\xpcom -I..\xpath -I..\xml\dom -I..\xml\dom\mozImpl \
|
||||
-I..\base -I ..\xml -I .\util -I ..\net -I..\xml\parser -I.\functions
|
||||
-I..\base -I ..\xml -I .\util -I..\xml\parser -I.\functions
|
||||
!endif
|
||||
|
||||
LCFLAGS = \
|
||||
|
|
Загрузка…
Ссылка в новой задаче