Compare commits
20 Commits
N2
...
RemoveOldD
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
17dcbf17c7 | ||
|
|
64a29e6ece | ||
|
|
b7dbce42e5 | ||
|
|
76167b406b | ||
|
|
8d5b67a606 | ||
|
|
9560b95ab2 | ||
|
|
70d536c270 | ||
|
|
d7df8af487 | ||
|
|
84e5e238ec | ||
|
|
5e7723cbc7 | ||
|
|
4ec116f593 | ||
|
|
89879caa76 | ||
|
|
5914824c25 | ||
|
|
7af8e81039 | ||
|
|
4aab81ccb1 | ||
|
|
3612e06ea4 | ||
|
|
d6807032b7 | ||
|
|
30ef067ea1 | ||
|
|
6f153ff858 | ||
|
|
791d05abe7 |
85
mozilla/Makefile
Normal file
85
mozilla/Makefile
Normal file
@@ -0,0 +1,85 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
DEPTH = .
|
||||
|
||||
NSPRDIR = nsprpub
|
||||
NSPR20 = 1
|
||||
MOZILLA_CLIENT = 1
|
||||
|
||||
ifndef NO_MOCHA
|
||||
DIRS_JS = js
|
||||
endif
|
||||
|
||||
DIRS = config coreconf $(NSPRDIR) jpeg dbm xpcom base network caps
|
||||
|
||||
ifdef MOZ_NETCAST
|
||||
DIRS += netcast
|
||||
endif
|
||||
|
||||
ifdef MOZ_JAVA
|
||||
DIRS += sun-java ldap ifc $(DIRS_JS) nav-java ifc/tools js/jsd
|
||||
else
|
||||
DIRS += sun-java nav-java $(DIRS_JS)
|
||||
endif
|
||||
|
||||
ifndef NO_SECURITY
|
||||
DIRS += security
|
||||
endif
|
||||
|
||||
DIRS += privacy
|
||||
|
||||
DIRS += modules lib l10n cmd
|
||||
|
||||
ifeq ($(STAND_ALONE_JAVA),1)
|
||||
DIRS = config lib/xp $(NSPRDIR) jpeg modules/zlib sun-java ifc js ifc/tools sun-java/java
|
||||
endif
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
export:: envirocheck $(OBJS)
|
||||
|
||||
# Running this rule assembles all the SDK source pieces into dist/sdk.
|
||||
# You'll need to run this rule on every platform to get all the
|
||||
# binaries (e.g. javah) copied there. You'll also have to do special
|
||||
# magic on a Mac.
|
||||
sdk-src::
|
||||
$(SDKINSTALL) include/npapi.h $(SDK)/include/
|
||||
$(SDKINSTALL) include/jri_md.h $(SDK)/include/
|
||||
$(SDKINSTALL) include/jritypes.h $(SDK)/include/
|
||||
$(SDKINSTALL) include/jri.h $(SDK)/include/
|
||||
$(SDKINSTALL) lib/plugin/npupp.h $(SDK)/include/
|
||||
$(SDKINSTALL) sdk/common/*.c* $(SDK)/common/
|
||||
$(SDKINSTALL) sun-java/classsrc/$(ZIP_NAME).x $(SDK)/classes/$(ZIP_NAME)
|
||||
$(SDKINSTALL) sdk/examples/simple/Source/*.c $(SDK)/examples/simple/Source/
|
||||
$(SDKINSTALL) sdk/examples/simple/Source/*.java $(SDK)/examples/simple/Source/
|
||||
$(SDKINSTALL) sdk/examples/simple/Source/*.class $(SDK)/examples/simple/Source/
|
||||
$(SDKINSTALL) sdk/examples/simple/Source/_gen/*.h $(SDK)/examples/simple/Source/_gen/
|
||||
$(SDKINSTALL) sdk/examples/simple/Source/_stubs/*.c $(SDK)/examples/simple/Source/_stubs/
|
||||
$(SDKINSTALL) sdk/examples/simple/Unix/makefile.* $(SDK)/examples/simple/Unix/
|
||||
$(SDKINSTALL) sdk/examples/simple/Testing/SimpleExample.html $(SDK)/examples/simple/Testing/
|
||||
$(SDKINSTALL) sdk/examples/simple/readme.html $(SDK)/examples/simple/
|
||||
$(SDKINSTALL) sdk/examples/UnixTemplate/Source/*.c $(SDK)/examples/UnixTemplate/Source/
|
||||
$(SDKINSTALL) sdk/examples/UnixTemplate/Testing/Test.html $(SDK)/examples/UnixTemplate/Testing/
|
||||
$(SDKINSTALL) sdk/examples/UnixTemplate/Unix/makefile.* $(SDK)/examples/UnixTemplate/Unix/
|
||||
$(SDKINSTALL) sdk/examples/UnixTemplate/readme.html $(SDK)/examples/UnixTemplate/
|
||||
|
||||
sdk-bin::
|
||||
cd sdk; $(MAKE); cd ..
|
||||
$(SDKINSTALL) $(DIST)/bin/javah$(BIN_SUFFIX) $(SDK)/bin/$(OS_CONFIG)/
|
||||
$(SDKINSTALL) sdk/examples/simple/Source/$(OBJDIR)/npsimple.$(DLL_SUFFIX) $(SDK)/bin/$(OS_CONFIG)/
|
||||
$(SDKINSTALL) sdk/examples/UnixTemplate/Source/$(OBJDIR)/nptemplate.$(DLL_SUFFIX) $(SDK)/bin/$(OS_CONFIG)/
|
||||
@@ -22,75 +22,106 @@ VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
# The list of directories that need to be built to build the standalone
|
||||
# nglayout test program. The order is important.
|
||||
DIRS = \
|
||||
config \
|
||||
dbm \
|
||||
nsprpub \
|
||||
$(NULL)
|
||||
NSPRDIR = $(topsrcdir)/nsprpub
|
||||
NSPRDIR_AC = nsprpub
|
||||
NSPR20 = 1
|
||||
NSPR_MAKE_ARGS = -C $(NSPRDIR) DIST=`pwd`/dist CC=$(CC) CCC=$(CXX) MOZILLA_CLIENT=$(MOZILLA_CLIENT) MOZ_DEBUG=$(MOZ_DEBUG) USE_PTHREADS=$(USE_PTHREADS) BUILD_OPT=$(BUILD_OPT) NO_MDUPDATE=$(NO_MDUPDATE) $@
|
||||
|
||||
ifndef NO_MOCHA
|
||||
DIRS_JS = js
|
||||
endif
|
||||
|
||||
DIRS = config coreconf
|
||||
ifdef NSPR_AUTOCONF
|
||||
DIRS += $(NSPRDIR_AC)
|
||||
endif
|
||||
DIRS += dbm xpcom base network caps
|
||||
|
||||
ifndef MOZ_NATIVE_JPEG
|
||||
DIRS += \
|
||||
jpeg \
|
||||
$(NULL)
|
||||
DIRS += jpeg
|
||||
endif
|
||||
|
||||
DIRS += \
|
||||
modules/libreg \
|
||||
xpcom \
|
||||
$(NULL)
|
||||
ifdef MOZ_NETCAST
|
||||
DIRS += netcast
|
||||
endif
|
||||
|
||||
ifdef MOZ_JAVA
|
||||
DIRS += sun-java ldap ifc $(DIRS_JS) nav-java ifc/tools js/jsd
|
||||
else
|
||||
DIRS += sun-java nav-java $(DIRS_JS)
|
||||
endif
|
||||
|
||||
ifndef NO_SECURITY
|
||||
DIRS += security
|
||||
endif
|
||||
|
||||
DIRS += privacy
|
||||
|
||||
DIRS += modules lib l10n cmd
|
||||
|
||||
ifeq ($(STAND_ALONE_JAVA),1)
|
||||
DIRS = config lib/xp sun-java ifc js ifc/tools sun-java/java
|
||||
ifndef MOZ_NATIVE_JPEG
|
||||
DIRS += jpeg
|
||||
endif
|
||||
ifndef MOZ_NATIVE_ZLIB
|
||||
DIRS += \
|
||||
modules/zlib \
|
||||
$(NULL)
|
||||
DIRS += modules/zlib
|
||||
endif
|
||||
endif
|
||||
|
||||
DIRS += \
|
||||
modules/libutil \
|
||||
intl \
|
||||
sun-java \
|
||||
nav-java \
|
||||
js \
|
||||
modules/security/freenav \
|
||||
modules/libpref \
|
||||
modules/libimg \
|
||||
modules/oji \
|
||||
modules/plugin \
|
||||
base \
|
||||
caps \
|
||||
lib/xp \
|
||||
lib/libpwcac \
|
||||
network \
|
||||
lib/liblayer/include \
|
||||
htmlparser \
|
||||
gfx \
|
||||
dom \
|
||||
view \
|
||||
widget \
|
||||
layout \
|
||||
rdf \
|
||||
webshell \
|
||||
editor \
|
||||
silentdl
|
||||
ifndef NSPR_AUTOCONF
|
||||
export:: envirocheck $(OBJS)
|
||||
$(MAKE) $(NSPR_MAKE_ARGS)
|
||||
|
||||
libs::
|
||||
$(MAKE) $(NSPR_MAKE_ARGS)
|
||||
|
||||
install::
|
||||
$(MAKE) $(NSPR_MAKE_ARGS)
|
||||
|
||||
clean::
|
||||
$(MAKE) $(NSPR_MAKE_ARGS)
|
||||
|
||||
realclean::
|
||||
$(MAKE) $(NSPR_MAKE_ARGS)
|
||||
|
||||
DIRS += xpfe
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
clobber::
|
||||
$(MAKE) $(NSPR_MAKE_ARGS)
|
||||
|
||||
clobber_all::
|
||||
$(MAKE) $(NSPR_MAKE_ARGS)
|
||||
|
||||
endif # !NSPR_AUTOCONF
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
real_all: all
|
||||
|
||||
real_export: export
|
||||
|
||||
real_libs: libs
|
||||
|
||||
real_install: install
|
||||
|
||||
real_clobber: clobber
|
||||
|
||||
real_depend: depend
|
||||
# Running this rule assembles all the SDK source pieces into dist/sdk.
|
||||
# You'll need to run this rule on every platform to get all the
|
||||
# binaries (e.g. javah) copied there. You'll also have to do special
|
||||
# magic on a Mac.
|
||||
sdk-src::
|
||||
$(SDKINSTALL) include/npapi.h $(SDK)/include/
|
||||
$(SDKINSTALL) include/jri_md.h $(SDK)/include/
|
||||
$(SDKINSTALL) include/jritypes.h $(SDK)/include/
|
||||
$(SDKINSTALL) include/jri.h $(SDK)/include/
|
||||
$(SDKINSTALL) lib/plugin/npupp.h $(SDK)/include/
|
||||
$(SDKINSTALL) sdk/common/*.c* $(SDK)/common/
|
||||
$(SDKINSTALL) sun-java/classsrc/$(ZIP_NAME).x $(SDK)/classes/$(ZIP_NAME)
|
||||
$(SDKINSTALL) sdk/examples/simple/Source/*.c $(SDK)/examples/simple/Source/
|
||||
$(SDKINSTALL) sdk/examples/simple/Source/*.java $(SDK)/examples/simple/Source/
|
||||
$(SDKINSTALL) sdk/examples/simple/Source/*.class $(SDK)/examples/simple/Source/
|
||||
$(SDKINSTALL) sdk/examples/simple/Source/_gen/*.h $(SDK)/examples/simple/Source/_gen/
|
||||
$(SDKINSTALL) sdk/examples/simple/Source/_stubs/*.c $(SDK)/examples/simple/Source/_stubs/
|
||||
$(SDKINSTALL) sdk/examples/simple/Unix/makefile.* $(SDK)/examples/simple/Unix/
|
||||
$(SDKINSTALL) sdk/examples/simple/Testing/SimpleExample.html $(SDK)/examples/simple/Testing/
|
||||
$(SDKINSTALL) sdk/examples/simple/readme.html $(SDK)/examples/simple/
|
||||
$(SDKINSTALL) sdk/examples/UnixTemplate/Source/*.c $(SDK)/examples/UnixTemplate/Source/
|
||||
$(SDKINSTALL) sdk/examples/UnixTemplate/Testing/Test.html $(SDK)/examples/UnixTemplate/Testing/
|
||||
$(SDKINSTALL) sdk/examples/UnixTemplate/Unix/makefile.* $(SDK)/examples/UnixTemplate/Unix/
|
||||
$(SDKINSTALL) sdk/examples/UnixTemplate/readme.html $(SDK)/examples/UnixTemplate/
|
||||
|
||||
sdk-bin::
|
||||
cd sdk; $(MAKE); cd ..
|
||||
$(SDKINSTALL) $(DIST)/bin/javah$(BIN_SUFFIX) $(SDK)/bin/$(OS_CONFIG)/
|
||||
$(SDKINSTALL) sdk/examples/simple/Source/$(OBJDIR)/npsimple.$(DLL_SUFFIX) $(SDK)/bin/$(OS_CONFIG)/
|
||||
$(SDKINSTALL) sdk/examples/UnixTemplate/Source/$(OBJDIR)/nptemplate.$(DLL_SUFFIX) $(SDK)/bin/$(OS_CONFIG)/
|
||||
|
||||
@@ -1,443 +0,0 @@
|
||||
|
||||
<HEAD>
|
||||
<TITLE>Building Mozilla on the Macintosh PPC platform</TITLE>
|
||||
</HEAD>
|
||||
<BODY BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B">
|
||||
<P>
|
||||
|
||||
<HR>
|
||||
|
||||
</P>
|
||||
|
||||
<H1>Building Mozilla on the Macintosh PPC platform</H1>
|
||||
|
||||
<H2>Daniel Nunes, <A HREF="mailto:leaf@netscape.com"><TT>leaf@netscape.com</TT></A></H2>
|
||||
|
||||
<P>v 1.1, 1998-9-29<BR>
|
||||
updated for the Pro4 IDE</P>
|
||||
|
||||
<P>
|
||||
|
||||
<HR>
|
||||
|
||||
<I>How to build Mozilla on a Macintosh PPC System.</I>
|
||||
|
||||
<HR>
|
||||
|
||||
</P>
|
||||
|
||||
<H2>1. <A HREF="#s1">Introduction</A></H2>
|
||||
|
||||
<H2>2. <A HREF="#s2">Building Mozilla</A></H2>
|
||||
|
||||
<UL>
|
||||
<LI><A HREF="#ss2.1">2.1 Get the Code </A></LI>
|
||||
|
||||
<LI><A HREF="#ss2.2">2.2 Requirements</A></LI>
|
||||
|
||||
<LI><A HREF="#ss2.3">2.3 Set up the Build Environment</A></LI>
|
||||
|
||||
<LI><A HREF="#ss2.4">2.4 Build the Lizard </A></LI>
|
||||
</UL>
|
||||
|
||||
<H2>3. <A HREF="#s3"> Common Problems </A></H2>
|
||||
|
||||
<H2>4. <A HREF="#s4"> Credits </A></H2>
|
||||
|
||||
<P>
|
||||
|
||||
<HR>
|
||||
|
||||
</P>
|
||||
|
||||
<H2><A NAME=s1></A>1. Introduction</H2>
|
||||
|
||||
<P>What this document is: A guide to building the Mozilla
|
||||
application. This includes:</P>
|
||||
|
||||
<OL>
|
||||
<LI>A listing of the development tools you will need to build
|
||||
Mozilla.</LI>
|
||||
|
||||
<LI>A list of environment variables you will need to set before
|
||||
building.</LI>
|
||||
</OL>
|
||||
|
||||
<P>If you're looking for documentation on developing features or
|
||||
fixing bugs, the Mozilla <A HREF="http://www.mozilla.org/docs/tplist/tplist.html">Technical
|
||||
Documents </A> or <A HREF="http://www.mozilla.org/library.html">
|
||||
Library </A> are probably what you're looking for.</P>
|
||||
|
||||
<P>
|
||||
|
||||
<HR>
|
||||
|
||||
</P>
|
||||
|
||||
<H2><A NAME=s2></A>2. Building Mozilla</H2>
|
||||
|
||||
<P> </P>
|
||||
|
||||
<UL>
|
||||
<LI>Each of the following subsections describes, or gives
|
||||
references to descriptions of, the steps necessary to build
|
||||
Mozilla.
|
||||
|
||||
<H2><A NAME="ss2.1"></A>2.1 Get the Code</H2>
|
||||
|
||||
<P> </P>
|
||||
|
||||
<UL>
|
||||
<LI>There are two principal ways of getting the code, <A HREF="http://www.mozilla.org/download.html">
|
||||
ftp</A> and <A HREF="http://www.mozilla.org/cvs.html"> CVS</A>.
|
||||
CVS will provide the most current code for building, but is
|
||||
slower than ftp. Ftp drops are generally produced once per
|
||||
month, and are known to compile.</LI>
|
||||
</UL>
|
||||
|
||||
<P> </P>
|
||||
|
||||
<H2><A NAME="ss2.2"></A>2.2 Requirements</H2>
|
||||
|
||||
<P>The following need to be installed:</P>
|
||||
|
||||
<UL>
|
||||
<LI>CodeWarrior (CW) Pro4 - obtainable from <A HREF="http://www.metrowerks.com">Metrowerks</A>.
|
||||
See <A HREF="#s3">Common Sticking Points</A> if you have a
|
||||
different version. Mozilla will no longer build with anything
|
||||
earlier.</LI>
|
||||
|
||||
<LI>PowerPlant - obtainable from the CodeWarrior CD.</LI>
|
||||
|
||||
<LI>MSL - the Metrowerks Standard Library, obtainable from the
|
||||
CodeWarrior CD</LI>
|
||||
|
||||
<LI><A HREF="ftp://ftp.boingo.com//dan/WASTE/waste-13.hqx">WASTE
|
||||
1.3</A></LI>
|
||||
|
||||
<LI><A HREF="http://www.bact.wisc.edu/CWASTEEdit/CWASTEEdit.sit.hqx">CWASTE
|
||||
1.6.2</A></LI>
|
||||
|
||||
<LI><A HREF="ftp://ftp.scripting.com/userland/menuSharingToolkit4.1.sit.hqx">Menu
|
||||
Sharing Toolkit</A> (from UserLand)</LI>
|
||||
|
||||
<LI><A HREF="ftp://ftp.share.com/pub/internet-configuration/ICProgKit1.4.sit">Internet
|
||||
Config 1.4 SDK</A></LI>
|
||||
|
||||
<LI><A HREF="http://www.mooseyard.com/Jens/Software/">AEGizmos
|
||||
1.4.2</A></LI>
|
||||
|
||||
<LI><A HREF="ftp://sunsite.cnlab-switch.ch/software/platform/macos/perl/Mac_Perl_520r4_tool.bin">MacPerl
|
||||
5 MPW Tool</A></LI>
|
||||
|
||||
<LI><A HREF="ftp://sunsite.cnlab-switch.ch/software/platform/macos/perl/Mac_Perl_520r4_appl.bin">MacPerl
|
||||
5 Application</A></LI>
|
||||
|
||||
<LI>The module Mac:AppleEvents:Simple, which should be stored
|
||||
in your Perl library folder under :Mac:AppleEvents:Simple.pm,
|
||||
may be downloaded <A HREF="http://www.perl.com/CPAN-local/modules/by-module/Mac/Mac-AppleEvents-Simple-0.10.tgz">here</A>.</LI>
|
||||
|
||||
<LI>The module Mac:Apps:Launch, which should be stored in your
|
||||
Perl library folder under :Mac:Apps:Launch.pm, may be
|
||||
downloaded <A HREF="http://www.perl.com/CPAN-local/modules/by-module/Mac/Mac-Apps-Launch-1.30.tar.gz">here</A>.</LI>
|
||||
|
||||
<LI>MakeStub - MPW (installed with CodeWarrior Heaven option).
|
||||
If you choose not to install MPW, it is located on the MacOS
|
||||
Tools CD in "CW Pro 4 Tools:CodeWarrior MPW:MPW:Tools"</LI>
|
||||
|
||||
<LI>RunTSScript - in Mozilla source distribution
|
||||
(mozilla:build:mac:RunTSScript), needs to be installed by
|
||||
hand</LI>
|
||||
|
||||
<LI><A HREF="ftp://dev.apple.com/devworld/Tool_Chest/Core_Mac_OS_Tools/MPW_etc./MPW-GM/MPW/ToolServer.sit.hqx">ToolServer</A>
|
||||
- or in the CW distribution (CW Pro 4 Tools:Apple Development
|
||||
Tools:ToolServer 3.4.1.sit). <B>We recommend pulling it off the
|
||||
CD</B> because it comes with configuration files for
|
||||
CodeWarrior which you would have to create manually were you to
|
||||
pull it off the net.</LI>
|
||||
|
||||
<LI><A HREF="http://sunsite.cnlab-switch.ch/ftp/software/platform/macos/src/HTML/MPW_C.html">patch
|
||||
2.1</A></LI>
|
||||
</UL>
|
||||
|
||||
<P>Hardware/OS</P>
|
||||
|
||||
<UL>
|
||||
<LI>To build Navigator, you need a fast PPC Mac. The faster the
|
||||
better.</LI>
|
||||
|
||||
<LI>You will need about 96 MB of physical RAM to "fast link"
|
||||
the app. You can still fast link if you give your machine 96 MB
|
||||
of virtual memory, but then the VM hit is large enough to
|
||||
counteract any improvement. One of our beta testers had a
|
||||
machine with only 64MB of physical RAM (VM was off) and it ran
|
||||
out of memory trying to link. Turning VM on got it to link, but
|
||||
build time increased greatly.</LI>
|
||||
|
||||
<LI>Reports from the net indicate that the optimized version
|
||||
(MozillaPPC) take much less RAM to build than the 96MB we
|
||||
suggest. If you are running out of memory, try building that
|
||||
instead of the debug version (the debug symbols require a lot
|
||||
of RAM come link time).</LI>
|
||||
|
||||
<LI>You should be ok with a 400MB disk partition, even when
|
||||
fully built. This does not include tools like the IDE, just
|
||||
source.</LI>
|
||||
|
||||
<LI>On an HFS+ volume, a full build takes about 110MB. HFS+ is
|
||||
good, but utilities are sparse.</LI>
|
||||
</UL>
|
||||
|
||||
<P> </P>
|
||||
|
||||
<H2><A NAME="ss2.3"></A>2.3 Setup the Build Environment</H2>
|
||||
|
||||
<P> </P>
|
||||
|
||||
<OL>
|
||||
<LI>Install CodeWarrior from the CD. While it is large,
|
||||
installing the "CodeWarrior Heaven" option will guarantee that
|
||||
you have everything you need. This will give you PowerPlant,
|
||||
MSL, and MPW. If you choose to install less, proceed at your
|
||||
own risk.</LI>
|
||||
|
||||
<LI>In the Finder, increase the memory partition of the IDE to
|
||||
15MB (you can get by with 12, if need be).</LI>
|
||||
|
||||
<LI>Uncompress the StuffIt Archive for ToolServer. The goal is
|
||||
to let ToolServer and MPW share the same Tools directory so you
|
||||
don't need to have multiple versions of tools. Do the
|
||||
following:
|
||||
|
||||
<OL>
|
||||
<LI>Open ToolServer's Tools folder. There is one file called
|
||||
"RMetrowerks".</LI>
|
||||
|
||||
<LI>Move RMetrowerks to Tools folder of MPW. MPW folder must
|
||||
be at "Metrowerks:Codewarrior MPW:MPW" if you installed
|
||||
Codewarrior Heaven.</LI>
|
||||
|
||||
<LI>Remove ToolServer's Tools folder.</LI>
|
||||
|
||||
<LI>Now create an alias of Tools folder in "CodeWarrior MPW"
|
||||
and move it to your ToolServer folder. Rename the alias
|
||||
(probably called "Tools alias") to "Tools"</LI>
|
||||
|
||||
<LI><FONT COLOR="#FF0000"><B>IMPORTANT</B></FONT>: Make sure
|
||||
you only have one instance of ToolServer on your machine. If
|
||||
the build script finds the wrong one, the correct tools will
|
||||
not be found and strange things will happen.</LI>
|
||||
</OL>
|
||||
</LI>
|
||||
|
||||
<LI>After installing the MacPerl MPW Tool distribution (run the
|
||||
InstallerVISE application), in the "MacPerl ƒ" folder,
|
||||
there will be an MPW tool named "perl". Install this in MPW's
|
||||
tools folder.</LI>
|
||||
|
||||
<LI>Install the MacPerl Application (run the InstallerVISE
|
||||
application). You can install this anywhere, but it is
|
||||
recommended that you install it inside of your CodeWarrior
|
||||
folder for easy reference. After installation, you will need to
|
||||
set a preference to enable double-click launch of the perl
|
||||
scripts. This preference is set by going under the Edit Menu to
|
||||
Preferences. Click on the "Script" button and hit the radio
|
||||
button "Run Scripts opened from Finder"</LI>
|
||||
|
||||
<LI>Install the "patch" and "MakeStub" Tools in the tools
|
||||
folder. Note that "MakeStub" is automatically installed by the
|
||||
"CodeWarrior Heaven" install option.</LI>
|
||||
|
||||
<LI>Install RunTSScript (found in the Mozilla source
|
||||
distribution) in the compilers folder in your build environment
|
||||
("Metrowerks:Metrowerks Codewarrior:Codewarrior
|
||||
Plugins:Compilers")</LI>
|
||||
|
||||
<LI>Next, after downloading all the 3rd party software
|
||||
components, drag WASTE, CWASTE, Menu Sharing, Internet Config,
|
||||
and the AEGizmo folders (just as they are) into the "MacOS
|
||||
Support" folder in your build environment.</LI>
|
||||
|
||||
<LI>Create a folder inside the PowerPlant folder
|
||||
(Metrowerks:Metrowerks CodeWarrior:MacOS Support:PowerPlant)
|
||||
called "_Will Be Obsolete" Make sure you include the leading
|
||||
underscore.</LI>
|
||||
|
||||
<LI>Unstuff the obsolete LGA classes (located on the Reference
|
||||
CD in "CodeWarrior Examples:MacOS Examples:PowerPlant
|
||||
Examples:Obsolete PP Items:Old GA Classes.sit) and place the
|
||||
resulting folder into the "_Will Be Obsolete" folder you
|
||||
created in the previous step.</LI>
|
||||
|
||||
<LI>Start ToolServer from within CodeWarrior (or use MPW if you
|
||||
are brave enough). We're about to patch some files. Make sure
|
||||
the ToolServer menu is in the CodeWarrior menu bar by turning
|
||||
on the <A HREF="IDEPrefs.gif">preference</A> under the "Extras"
|
||||
panel in the IDE Preferences (not the project preferences!).
|
||||
The menu bar should look like this:
|
||||
|
||||
<P><IMG SRC="IDEMenuBar.gif" WIDTH=359 HEIGHT=20 X-CLARIS-USEIMAGEWIDTH X-CLARIS-USEIMAGEHEIGHT ALIGN=bottom></P>
|
||||
|
||||
<P>Choose "Start ToolServer" from the ToolServer menu (this is
|
||||
the icon menu between "Window" and "Help" in the menubar
|
||||
above). You will now see a window with no close box. This is
|
||||
your ToolServer Worksheet where you will type (or cut &
|
||||
paste) the commands for the following steps.</P>
|
||||
|
||||
<P>In case you have never used MPW/ToolServer before, the
|
||||
following is <B>very important</B>. Pressing "return" does not
|
||||
execute commands like you might think. It just inserts a
|
||||
newline into the worksheet like a normal text editor. <B>To
|
||||
actually get ToolServer to execute the command, you must press
|
||||
"Enter" (lower right of numeric keypad).</B> This executes the
|
||||
line that the cursor is on, and only that line. If you want to
|
||||
execute multiple lines at once, select them all and hit
|
||||
Enter.</P></LI>
|
||||
|
||||
<LI>Set the shell variables {IDE} and {Source} to the correct
|
||||
paths for your build environment. {IDE} is where your
|
||||
CodeWarrior IDE is located. {Source} is the folder containing
|
||||
the toplevel "ns" folder of the Mozilla source. Mine look like
|
||||
this (don't forget to keep the quotes if your path includes
|
||||
spaces), yours will almost certainly be different
|
||||
(<FONT COLOR="#FF0000">to punctuate this, the things you need
|
||||
to change are in red</FONT>).
|
||||
|
||||
<PRE>Set IDE "<FONT COLOR="#FF0000">Develop:CW Pro 4:Metrowerks CodeWarrior:</FONT>"
|
||||
Set Source "<FONT COLOR="#FF0000">Source:FreeSource:</FONT>"</PRE></LI>
|
||||
|
||||
<LI>Execute the following lines to patch menusharing.c to allow
|
||||
it to compile with the new Universal Headers. It references an
|
||||
obsolete header file (GestaltEqu.h).
|
||||
|
||||
<PRE>directory "{IDE}MacOS Support:Menu Sharing Toolkit 4.1:"
|
||||
patch menusharing.c "{Source}mozilla:lib:mac:patches:menusharing.patch"</PRE></LI>
|
||||
|
||||
<LI>You need to patch stat.mac.h to fix a problem in MSL where
|
||||
lines were omitted.
|
||||
|
||||
<PRE>directory "{IDE}Metrowerks Standard Library:MSL C:MSL Mac:Public Includes"
|
||||
patch stat.mac.h "{Source}mozilla:lib:mac:patches:stat.mac.h.patch"</PRE></LI>
|
||||
|
||||
<LI>Congratulations! Now you are ready to build. Once these
|
||||
steps are done, you don't have to repeat these setups the next
|
||||
time!</LI>
|
||||
</OL>
|
||||
|
||||
<P> </P>
|
||||
|
||||
<H2><A NAME="ss2.4"></A>2.4 Run the build</H2>
|
||||
|
||||
<UL>
|
||||
<LI>In the folder mozilla:build:mac:, there are several Perl
|
||||
scripts with names of the form BuildMozillaXXX.pl, where XXX is
|
||||
"Optimized", "Debug", "Tinderbox", et al. Each script builds
|
||||
the corresponding version of Mozilla. If you configured the
|
||||
MacPerl application to execute scripts that are opened from the
|
||||
finder, all you have to do is double click on the appropriate
|
||||
one; otherwise, launch MacPerl, and run the appropriate script
|
||||
from the "Run Script..." menu item.
|
||||
|
||||
<P>These `configured build' scripts are simple, and you might
|
||||
want to make your own to force your build to StopForErrors(),
|
||||
or alternatively DontStopForErrors(), et al. You can set up
|
||||
certain build-script variables and (soon) compile-time flags.
|
||||
Compare the supplied scripts to figure out what you might want.
|
||||
Note that CodeWarriorLib, Moz.pm, and BuildList.pm, are
|
||||
AppleScript libraries and Perl modules meant to be used by a
|
||||
`configured build'. Use your favorite POD viewer (Shuck comes
|
||||
with MacPerl) to view the documentation in the Perl
|
||||
scripts.</P>
|
||||
|
||||
<P>If there were any errors in any of the projects along the
|
||||
way, the script will stop at that point and the IDE will tell
|
||||
you the errors. You can fix them and make sure they current
|
||||
project builds, but to continue the automation, you have to
|
||||
start from the beginning by double-clicking the script again.
|
||||
This isn't quite as bad as it sounds because the previous
|
||||
projects are already built (unless you changed some major
|
||||
header file). Please note that stopping the script once it has
|
||||
started is difficult. We are working to address this issue.</P>
|
||||
|
||||
<P>After the build is complete, you can find aliases to the
|
||||
built libraries and the final Mozilla application. Debug builds
|
||||
are built to Mozilla:dist:client_debug, while optimized builds
|
||||
are built to Mozilla:dist:client.</P>
|
||||
|
||||
<P>Don't worry too much about the numerous warnings generated
|
||||
during the build. We try our best to get the XP teams to use
|
||||
real compilers, but alas, they continue to write warning-laden
|
||||
code. There is also some generated code (Java is one example)
|
||||
that has a lot of warnings that we can't help either. If you
|
||||
write any new code, please help us in our quest to get zero
|
||||
warnings.</P></LI>
|
||||
</UL>
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
|
||||
<HR>
|
||||
|
||||
</P>
|
||||
|
||||
<H2><A NAME=s3></A>3. Common Sticking Points</H2>
|
||||
|
||||
<UL>
|
||||
<LI><B>I only have CodeWarrior Pro3 or Pro2. How do i build with
|
||||
it?</B>
|
||||
|
||||
<UL>
|
||||
<LI>Currently, the answer is, "You don't." We make use of
|
||||
several classes in PowerPlant which recently appeared in Pro4.
|
||||
Time to upgrade, I'm afraid. Don't even try opening the
|
||||
projects with Pro2 because you will get data loss and have to
|
||||
throw the project away (it won't even prompt you!)</LI>
|
||||
</UL>
|
||||
</LI>
|
||||
|
||||
<LI><B>I'm having problems building. MacPerl tells me it can't
|
||||
fine MemAllocatorStubs</B>
|
||||
|
||||
<UL>
|
||||
<LI>It sounds like your ToolServer environment is not setup
|
||||
correctly. Make sure you follow the directions to the letter.
|
||||
You could also be seeing this if you have multiple versions of
|
||||
ToolServer on your computer and the Finder lauches the wrong
|
||||
one. This is very common, as the <I>Carbon Dater</I> app from
|
||||
Apple DTS contains a copy of ToolServer. Either remove all the
|
||||
other versions of ToolServer or make sure you launch the
|
||||
appropriate version before you start building.</LI>
|
||||
</UL>
|
||||
</LI>
|
||||
|
||||
<LI><B>The IDE runs out of memory building jsinterp.c. What do I
|
||||
do?</B>
|
||||
|
||||
<UL>
|
||||
<LI>We have seen this every now and then, and it only appears
|
||||
to show up when building optimized (non-debug) builds. You can
|
||||
normally get around this by building that file by itself
|
||||
(select it and choose "Compile") and then continuing the make.
|
||||
We're not sure why this is happening, so if you have any
|
||||
answers or solutions, please let us know!</LI>
|
||||
</UL>
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
|
||||
<HR>
|
||||
|
||||
</P>
|
||||
|
||||
<H2><A NAME=s4></A>4. Credits</H2>
|
||||
|
||||
<UL>
|
||||
<LI>The majority of this document is taken from the build document
|
||||
included in the Mozilla source distribution at
|
||||
README:mozilla:macbuild.htm written by Mike Pinkerton, <A HREF="mailto:pinkerton@netscape.com">
|
||||
pinkerton@netscape.com</A>.</LI>
|
||||
</UL>
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,158 +0,0 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Building Mozilla on unix platforms</TITLE>
|
||||
</HEAD>
|
||||
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000EE" VLINK="#551A8B"
|
||||
ALINK="#FF0000">
|
||||
<HR>
|
||||
<H1>
|
||||
Building Mozilla on Unix platforms</H1>
|
||||
|
||||
<H2>
|
||||
Daniel Nunes, <TT><A HREF="mailto:leaf@netscape.com">leaf@netscape.com</A></TT></H2>
|
||||
v 1.1, June 1998
|
||||
|
||||
<P>
|
||||
<HR><I>How to build Mozilla on a Unix System.</I>
|
||||
<HR>
|
||||
<H2>1. <A HREF="#s1">Introduction</A></H2>
|
||||
|
||||
<H2>2. <A HREF="#s2">Building Mozilla</A></H2>
|
||||
|
||||
<UL>
|
||||
<LI>
|
||||
<A HREF="#ss2.1">2.1 Get the Code </A></LI>
|
||||
|
||||
<LI>
|
||||
<A HREF="#ss2.2">2.2 Requirements</A></LI>
|
||||
|
||||
<LI>
|
||||
<A HREF="#ss2.3">2.3 Set up the Build Environment</A></LI>
|
||||
|
||||
<LI>
|
||||
<A HREF="#ss2.4">2.4 Build the Lizard </A></LI>
|
||||
|
||||
<LI>
|
||||
<A HREF="#ss2.5">2.5 Run the Lizard </A></LI>
|
||||
</UL>
|
||||
|
||||
<H2>3. <A HREF="#s3"> Common Problems </A></H2>
|
||||
|
||||
<HR>
|
||||
<H2><A NAME="s1">1. Introduction</A></H2>
|
||||
|
||||
<P>
|
||||
What this document is: A guide to building the Mozilla application.
|
||||
<BR>
|
||||
This includes:
|
||||
<OL>
|
||||
<LI> A listing of the development tools you will need to build Mozilla. </LI>
|
||||
<LI> A list of environment variables you will need to set before building. </LI>
|
||||
</OL>
|
||||
<P>
|
||||
If you're looking for documentation on developing features or fixing bugs,
|
||||
the Mozilla
|
||||
<A HREF="http://www.mozilla.org/docs/tplist/tplist.html">Technical Documents
|
||||
</A> or <A HREF="http://www.mozilla.org/library.html"> Library </A>
|
||||
are probably what you're looking for.
|
||||
<P>
|
||||
<HR>
|
||||
<H2><A NAME="s2">2. Building Mozilla </A></H2>
|
||||
<P>
|
||||
<UL>Each of the following subsections describes, or gives references to
|
||||
descriptions of, the steps necessary to build Mozilla.
|
||||
</UL>
|
||||
<H2><A NAME="ss2.1">2.1 Get the Code</A></H2>
|
||||
<P>
|
||||
<UL>
|
||||
There are two principal ways of getting the code,
|
||||
<A HREF="http://www.mozilla.org/download.html"> ftp</A> and
|
||||
<A HREF="http://www.mozilla.org/cvs.html"> CVS</A>.
|
||||
CVS will provide the most current code for building, but is
|
||||
slower than ftp. Ftp drops are generally produced once per month,
|
||||
and are known to compile.
|
||||
</UL>
|
||||
<P>
|
||||
<H2><A NAME="ss2.2">2.2 Requirements</A></H2>
|
||||
<UL>
|
||||
The following should be installed:
|
||||
<UL>
|
||||
<LI>Motif 1.2
|
||||
<LI>The native C/C++ compiler (or GNU C/C++ compiler 2.7.2 in lieu of the
|
||||
native compiler)
|
||||
<LI>GNU make 3.74 or better
|
||||
<LI>Perl (or, if you have no Perl, then set <CODE>PERL=/bin/echo</CODE>)
|
||||
</UL>
|
||||
<P>
|
||||
Your hardware should be equal to, or better than:
|
||||
<UL>
|
||||
32 MB RAM, 128 MB swap (64 MB RAM recommended)
|
||||
</UL>
|
||||
</UL>
|
||||
<P>
|
||||
<H2><A NAME="ss2.3">2.3 Setup the Build Environment</A></H2>
|
||||
<P>
|
||||
<UL>
|
||||
The following environment variables need to be set:
|
||||
<CODE>
|
||||
<PRE>
|
||||
MOZILLA_CLIENT=1
|
||||
MOZ_MEDIUM=1
|
||||
NO_MDUPDATE=1
|
||||
</PRE>
|
||||
</CODE>
|
||||
Optionally, you can set <CODE>BUILD_OPT=1</CODE> if you don't want a debug
|
||||
build.
|
||||
<P>
|
||||
If your Motif libraries are installed in a non-standard place, you can tell
|
||||
the Mozilla makefiles where to look by setting
|
||||
<CODE>MOZILLA_MOTIF_SEARCH_PATH</CODE> to point to the directory in which
|
||||
your Motif installation resides.
|
||||
<P>
|
||||
Environment variables are set by the shell, and there are two common ways
|
||||
of setting them. <BR>
|
||||
Type <CODE>setenv VARIABLE value</CODE> or <CODE>export VARIABLE=value</CODE>.
|
||||
<P>
|
||||
</UL>
|
||||
|
||||
<H2><A NAME="ss2.4">2.4 Run the build </A></H2>
|
||||
<UL>
|
||||
Change to the directory you copied the source into (for example,
|
||||
<CODE>cd /builds</CODE>). If this directory was empty before you
|
||||
installed the source, there should be two directories here:
|
||||
<CODE>README</CODE> and <CODE>mozilla</CODE>.
|
||||
<CODE>
|
||||
<PRE>
|
||||
cd mozilla
|
||||
gmake
|
||||
</PRE>
|
||||
</CODE>
|
||||
</UL>
|
||||
<H2><A NAME="ss2.5">2.5 After the build </A></H2>
|
||||
<UL>
|
||||
You may notice that if you try running mozilla-export right after the build,
|
||||
you'll run into a problem. You need to set <CODE>LD_LIBRARY_PATH</CODE> to
|
||||
<CODE>
|
||||
${LD_LIBRARY_PATH}:/PATH_TO_SOURCE/mozilla/dist/Linux2.0.32_x86_OPT.OBJ/bin
|
||||
</CODE> (where <CODE>PATH_TO_SOURCE</CODE> is the full path to your source
|
||||
tree) before the dynamically linked binary will run. <BR><BR>
|
||||
This varies by platform:<br>
|
||||
<UL>
|
||||
<LI>On HP-UX, the equivalent environment variable is <CODE>SHLIB_PATH</CODE>.
|
||||
<LI>On AIX, the equivalent environment variable is <CODE>LIBPATH</CODE>.
|
||||
</UL>
|
||||
</UL>
|
||||
|
||||
<HR>
|
||||
<H2><A NAME="s3">3. Common Sticking Points</A></H2>
|
||||
<LI>My linker dies with this error: undefined reference to `_Xsetlocale'
|
||||
<UL>If this error occurs, you might have to recompile libX11.so
|
||||
with the -DX_LOCALE flag (thanks to Scott Lampert,
|
||||
<A HREF="mailto:fortunato@heavymetal.org">fortunato@heavymetal.org</A>).
|
||||
|
||||
</UL>
|
||||
<HR>
|
||||
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,217 +0,0 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Building Mozilla on Microsoft Windows 32-bit platforms</TITLE>
|
||||
</HEAD>
|
||||
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000EE" VLINK="#551A8B"
|
||||
ALINK="#FF0000">
|
||||
<HR>
|
||||
<H1>
|
||||
Building Mozilla on Microsoft Windows 32-bit platforms</H1>
|
||||
|
||||
<H2>
|
||||
Daniel Nunes, <TT><A HREF="mailto:leaf@netscape.com">leaf@netscape.com</A></TT>
|
||||
</H2>
|
||||
v 1.0, June 1998
|
||||
|
||||
<P>
|
||||
<HR><I>How to build Mozilla on a Microsoft Windows 32-bit System.</I>
|
||||
<HR>
|
||||
<H2>1. <A HREF="#s1">Introduction</A></H2>
|
||||
|
||||
<H2>2. <A HREF="#s2">Building Mozilla</A></H2>
|
||||
|
||||
<UL>
|
||||
<LI>
|
||||
<A HREF="#ss2.1">2.1 Get the Code </A></LI>
|
||||
|
||||
<LI>
|
||||
<A HREF="#ss2.2">2.2 Requirements</A></LI>
|
||||
|
||||
<LI>
|
||||
<A HREF="#ss2.3">2.3 Set up the Build Environment</A></LI>
|
||||
|
||||
<LI>
|
||||
<A HREF="#ss2.4">2.4 Build the Lizard </A></LI>
|
||||
</UL>
|
||||
|
||||
<H2>3. <A HREF="#s3"> Common Problems </A></H2>
|
||||
|
||||
<HR>
|
||||
<H2><A NAME="s1">1. Introduction</A></H2>
|
||||
|
||||
<P>
|
||||
What this document is: A guide to building the Mozilla application.
|
||||
<BR>
|
||||
This includes:
|
||||
<OL>
|
||||
<LI> A listing of the development tools you will need to build Mozilla. </LI>
|
||||
<LI> A list of environment variables you will need to set before building. </LI>
|
||||
</OL>
|
||||
<P>
|
||||
If you're looking for documentation on developing features or fixing bugs,
|
||||
the Mozilla
|
||||
<A HREF="http://www.mozilla.org/docs/tplist/tplist.html">Technical Documents
|
||||
</A> or <A HREF="http://www.mozilla.org/library.html"> Library </A>
|
||||
are probably what you're looking for.
|
||||
<P>
|
||||
<HR>
|
||||
<H2><A NAME="s2">2. Building Mozilla </A></H2>
|
||||
<P>
|
||||
<UL>Each of the following subsections describes, or gives references to
|
||||
descriptions of, the steps necessary to build Mozilla.
|
||||
<H2><A NAME="ss2.1">2.1 Get the Code</A></H2>
|
||||
<P>
|
||||
<UL>
|
||||
There are two principal ways of getting the code,
|
||||
<A HREF="http://www.mozilla.org/download.html"> ftp</A> and
|
||||
<A HREF="http://www.mozilla.org/cvs.html"> CVS</A>.
|
||||
CVS will provide the most current code for building, but is
|
||||
slower than ftp. Ftp drops are generally produced once per month,
|
||||
and are known to compile.
|
||||
|
||||
</UL>
|
||||
<P>
|
||||
<H2><A NAME="ss2.2">2.2 Requirements</A></H2>
|
||||
<UL>
|
||||
The following need to be installed:
|
||||
<UL>
|
||||
<LI>Microsoft Visual C++ version 4.2 or later
|
||||
<LI>GNU Tools for Microsoft Windows, located:
|
||||
<UL>
|
||||
<LI><A HREF="http://www.cygnus.com/misc/gnu-win32">Cygnus</A></LI>
|
||||
<LI><A HREF="http://www.gnu.org/order/ftp.html">GNU home page</A></LI>
|
||||
<LI><A HREF="ftp://prep.ai.mit.edu/pub/gnu">MIT</A></LI>
|
||||
</UL>
|
||||
Specifically, you'll need:
|
||||
<UL><CODE>
|
||||
cp.exe<BR>
|
||||
rm.exe<BR>
|
||||
uname.exe<BR>
|
||||
</CODE>
|
||||
</UL>
|
||||
Netscape has internally modified version of gmake, shmsdos and win32gnu
|
||||
that we use to get around some problems we were having keeping in sync
|
||||
with the Unix version of gmake. This version of gmake can be found in the
|
||||
Windows Build Tools package, which can be ftp'd from
|
||||
<A HREF="http://www.mozilla.org/download-mozilla.html"> the Mozilla
|
||||
Download page</A>.
|
||||
The three files you will need are:
|
||||
<UL><CODE>
|
||||
gmake.exe<BR>
|
||||
shmsdos.exe<BR>
|
||||
uname.exe<BR>
|
||||
</CODE>
|
||||
</UL>
|
||||
|
||||
</UL>
|
||||
<P>
|
||||
Hardware/OS
|
||||
<UL>
|
||||
<LI>Pentium 133 MHz or better</LI>
|
||||
<LI>64 MB RAM, 128 MB recommended</LI>
|
||||
<LI>250 MB NTFS or 500 MB FAT disk space</LI>
|
||||
<LI>NT 4.0 is preferred; NT 3.51 will also work.
|
||||
</LI>
|
||||
</UL>
|
||||
</UL>
|
||||
<P>
|
||||
<H2><A NAME="ss2.3">2.3 Setup the Build Environment</A></H2>
|
||||
<P>
|
||||
<UL>
|
||||
The following environment variables need to be set:
|
||||
<UL>
|
||||
<CODE>
|
||||
set MOZ_BITS=32
|
||||
<BR>
|
||||
set MOZ_DEBUG=1 (set this only if you want to build a debug build)
|
||||
<BR>
|
||||
set MOZ_MEDIUM=1
|
||||
<BR>
|
||||
set MOZ_NT=351 (if running NT3.51)
|
||||
<BR>
|
||||
set MOZ_OUT=(optional: specifies location of resultant executable)
|
||||
<BR>
|
||||
set MOZ_SRC=(top of your tree, for example: set MOZ_SRC=d:\mozilla_source
|
||||
if this is the directory where you checked or unzipped the source into)
|
||||
<BR>
|
||||
set MOZ_TOOLS=(the parent directory of the GNU tools 'bin' directory. The build
|
||||
looks for MOZ_TOOLS\bin\gmake.exe, so make sure that the gmake.exe from
|
||||
the Windows Build Tools package resides there.)
|
||||
<BR>
|
||||
set NSPR20=1
|
||||
<BR>
|
||||
set _MSC_VER=1100 (if you are running VC++ 5.0) or 1200
|
||||
(if you are running VC++ 6.0)
|
||||
<BR>
|
||||
</CODE>
|
||||
</UL>
|
||||
<BR>
|
||||
<P>
|
||||
</UL>
|
||||
|
||||
<H2><A NAME="ss2.4">2.4 Run the build </A></H2>
|
||||
<UL>
|
||||
Change to the directory you copied the source into (for example,
|
||||
<CODE>cd d:\mozilla_source</CODE>). If this directory was empty before you
|
||||
installed the source, there should be two directories here:
|
||||
<CODE>README</CODE> and <CODE>mozilla</CODE>.
|
||||
<CODE>
|
||||
<PRE>
|
||||
cd mozilla\config
|
||||
nmake /f makefile.win
|
||||
cd ..
|
||||
nmake /f client.mak
|
||||
</PRE>
|
||||
</CODE>
|
||||
</UL>
|
||||
</UL>
|
||||
|
||||
<HR>
|
||||
<H2><A NAME="s3">3. Common Sticking Points</A></H2>
|
||||
<UL>
|
||||
<LI><B>nmake has a 'fatal error', listing one of the GNU commands and a
|
||||
hexadecimal return code.</B>
|
||||
<UL>
|
||||
This will happen as a result of not having the GNU tools and Windows Build
|
||||
tools in your path. Add the directories with the appropriate binaries to your
|
||||
path.
|
||||
</UL>
|
||||
</LI>
|
||||
<LI>
|
||||
<B>It fails with the message "'.\WIN32' unexpected": </B>
|
||||
<UL>
|
||||
You didn't properly
|
||||
set the environment variables -- you must not include a space at the end
|
||||
of the set statements (be careful if you are cut'n'pasting).
|
||||
</UL>
|
||||
</LI>
|
||||
<LI>
|
||||
<B>It fails to build, with directory-related errors: </B>
|
||||
<UL>
|
||||
The full path
|
||||
to the source must not include any spaces. Additionally, the source must
|
||||
be extracted with an intact directory structure by a utility that understands
|
||||
long filenames. If in doubt, grab Info-Zip at
|
||||
<A HREF="ftp://ftp.cdrom.com/pub/infozip">ftp://ftp.cdrom.com/pub/infozip</A>
|
||||
</UL>
|
||||
</LI>
|
||||
<LI>
|
||||
<B>It fails immediately with the message "Cannot find specified directory":
|
||||
</B>
|
||||
<UL>
|
||||
You didn't properly set the environment variable MOZ_TOOLS;
|
||||
this needs to be set to the path up to, but not including, the final \bin
|
||||
directory in the path to the gnu tools. So, the path to the tool executables
|
||||
is '%MOZ_TOOLS%\bin\<executable>'.
|
||||
</UL>
|
||||
</LI>
|
||||
<LI>
|
||||
<B>I'm not running a 32-bit windows system, how do i build?</B>
|
||||
<UL>
|
||||
Currently, the build process depends on a 32-bit operating system.
|
||||
Windows NT 4.0 is the recommended windows operating system.
|
||||
</UL>
|
||||
</UL>
|
||||
<HR>
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,15 +1,16 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Building the Mozilla client on unix platforms</TITLE>
|
||||
<TITLE>Building Mozilla on unix platforms</TITLE>
|
||||
</HEAD>
|
||||
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000EE" VLINK="#551A8B"
|
||||
ALINK="#FF0000">
|
||||
<HR>
|
||||
<H1>Building the Mozilla client on Unix platforms</H1>
|
||||
<H1>
|
||||
Building Mozilla on Unix platforms</H1>
|
||||
|
||||
<H2>
|
||||
Daniel Nunes, <TT><A HREF="mailto:leaf@mozilla.org">leaf@mozilla.org</A></TT></H2>
|
||||
v 1.2, 1998-11-02
|
||||
Daniel Nunes, <TT><A HREF="mailto:leaf@netscape.com">leaf@netscape.com</A></TT></H2>
|
||||
v 1.0, June 1998
|
||||
|
||||
<P>
|
||||
<HR><I>How to build Mozilla on a Unix System.</I>
|
||||
@@ -26,10 +27,10 @@ v 1.2, 1998-11-02
|
||||
<A HREF="#ss2.2">2.2 Requirements</A></LI>
|
||||
|
||||
<LI>
|
||||
<A HREF="#ss2.3">2.3 Build the Lizard</A></LI>
|
||||
<A HREF="#ss2.3">2.3 Set up the Build Environment</A></LI>
|
||||
|
||||
<LI>
|
||||
<A HREF="#ss2.4">2.4 After the Build</A></LI>
|
||||
<A HREF="#ss2.4">2.4 Build the Lizard </A></LI>
|
||||
</UL>
|
||||
|
||||
<H2>3. <A HREF="#s3"> Common Problems </A></H2>
|
||||
@@ -37,28 +38,19 @@ v 1.2, 1998-11-02
|
||||
<HR>
|
||||
<H2><A NAME="s1">1. Introduction</A></H2>
|
||||
|
||||
<P>
|
||||
Perhaps you are interested in building classic Mozilla, before the
|
||||
fall of the old layout engine, and the rise of the new. If so, the
|
||||
<B><A HREF="classic-unix.html">Classic Mozilla Build document</A></B>
|
||||
is what you're looking for.
|
||||
|
||||
<P>
|
||||
|
||||
<P>
|
||||
What this document is: A guide to building the Mozilla application.
|
||||
<BR>
|
||||
This includes:
|
||||
<OL>
|
||||
<LI> A listing of the development tools you will need to build Mozilla. </LI>
|
||||
<LI> A sample set of commands to build Mozilla using the Autoconf
|
||||
build system. </LI>
|
||||
<LI> A list of environment variables you will need to set before building. </LI>
|
||||
</OL>
|
||||
<P>
|
||||
If you're looking for documentation on developing features or fixing bugs,
|
||||
the Mozilla
|
||||
<A HREF="../tplist.html">Technical Documents</A> or
|
||||
<A HREF="../../../library.html"> Library </A>
|
||||
<A HREF="http://www.mozilla.org/docs/tplist/tplist.html">Technical Documents
|
||||
</A> or <A HREF="http://www.mozilla.org/library.html"> Library </A>
|
||||
are probably what you're looking for.
|
||||
<P>
|
||||
<HR>
|
||||
@@ -67,56 +59,24 @@ are probably what you're looking for.
|
||||
<UL>Each of the following subsections describes, or gives references to
|
||||
descriptions of, the steps necessary to build Mozilla.
|
||||
</UL>
|
||||
<UL>
|
||||
<H2><A NAME="ss2.1">2.1 Get the Code</A></H2>
|
||||
<P>
|
||||
<UL>
|
||||
|
||||
Eventually, there will be two principal ways of getting the code,
|
||||
<A HREF="../../../download.html"> ftp</A> and
|
||||
<A HREF="../../../cvs.html"> CVS</A>.
|
||||
CVS will provide the most current code for building, but is
|
||||
slower than ftp. Ftp drops are generally produced once per month,
|
||||
and are known to compile on some machine, somewhere.
|
||||
|
||||
<B>For now</B>, however, you must do the following to obtain the newest
|
||||
browser source:
|
||||
<BR>
|
||||
<CODE>
|
||||
cvs co mozilla/nglayout.mk<BR>
|
||||
cd mozilla<BR>
|
||||
gmake -f nglayout.mk pull_all<BR>
|
||||
</CODE>
|
||||
<BR>
|
||||
This should pull all the right source.
|
||||
There are two principal ways of getting the code,
|
||||
<A HREF="http://www.mozilla.org/download.html"> ftp</A> and
|
||||
<A HREF="http://www.mozilla.org/cvs.html"> CVS</A>.
|
||||
CVS will provide the least outdated code for building, but is
|
||||
slower than ftp.
|
||||
</UL>
|
||||
<P>
|
||||
<H2><A NAME="ss2.2">2.2 Requirements</A></H2>
|
||||
<UL>
|
||||
The following should be installed:
|
||||
The following need to be installed:
|
||||
<UL>
|
||||
<LI>Motif 1.2
|
||||
<LI>The native C/C++ compiler (or GNU C/C++ compiler 2.7.2 in lieu of the
|
||||
native compiler)
|
||||
<LI>Motif 1.2 (2.1 recommended for RedHat Linux)
|
||||
<LI>GNU C/C++ compiler 2.7.2
|
||||
<LI>GNU make 3.74 or better
|
||||
<LI>Perl5
|
||||
<LI><A HREF="../../../projects/autoconf/">Autconf</A> requirements,
|
||||
including NSPR.
|
||||
<LI><CODE>LD_LIBRARY_PATH</CODE> must include the path to the NSPR
|
||||
shared objects.<BR>
|
||||
For most people, this means adding <CODE>/usr/local/nspr/lib</CODE>
|
||||
to <CODE>LD_LIBRARY_PATH</CODE>
|
||||
(either:
|
||||
<BR>
|
||||
<CODE>setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/usr/local/nspr/lib</CODE>
|
||||
<BR>
|
||||
or
|
||||
<BR>
|
||||
<CODE>export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/nspr/lib</CODE>
|
||||
.<BR>
|
||||
If you get an error like "No such variable" then omit the
|
||||
<CODE>${LD_LIBRARY_PATH}:</CODE> part
|
||||
)
|
||||
<LI>Perl (or, if you have no Perl, then set <CODE>PERL=/bin/echo</CODE>)
|
||||
</UL>
|
||||
<P>
|
||||
Your hardware should be equal to, or better than:
|
||||
@@ -125,37 +85,51 @@ Your hardware should be equal to, or better than:
|
||||
</UL>
|
||||
</UL>
|
||||
<P>
|
||||
<H2><A NAME="ss2.3">2.3 Build the Lizard</A></H2>
|
||||
<H2><A NAME="ss2.3">2.3 Setup the Build Environment</A></H2>
|
||||
<P>
|
||||
<UL>
|
||||
The following environment variables need to be set:
|
||||
<CODE>
|
||||
autoconf<BR>
|
||||
mkdir obj-`./build/autoconf/config.guess`<BR>
|
||||
cd obj-`./build/autoconf/config.guess`<BR>
|
||||
../configure --with-nspr=/usr/local/nspr --enable-toolkit=motif<BR>
|
||||
gmake depend<BR>
|
||||
gmake<BR>
|
||||
<PRE>
|
||||
MOZILLA_CLIENT=1
|
||||
MOZ_MEDIUM=1
|
||||
NO_SECURITY=1
|
||||
NO_MDUPDATE=1
|
||||
</PRE>
|
||||
</CODE>
|
||||
Optionally, you can set <CODE>BUILD_OPT=1</CODE> if you don't want a debug
|
||||
build.
|
||||
<BR>
|
||||
Environment variables are set by the shell, and each shell may or may not have
|
||||
its own way of setting them. Type <CODE>man setenv</CODE> to find out how your
|
||||
shell sets variables, if you don't know already.
|
||||
<P>
|
||||
</UL>
|
||||
<H2><A NAME="ss2.4">2.4 After the build </A></H2>
|
||||
|
||||
<H2><A NAME="ss2.4">2.4 Run the build </A></H2>
|
||||
<UL>
|
||||
|
||||
<LI> <CODE>cd dist/bin</CODE> and you should see links to the objects you
|
||||
need to run <CODE>main</CODE>.
|
||||
|
||||
<LI>On most unixen LD_LIBRARY_PATH must be set to wherever the necessary
|
||||
libraries are.
|
||||
|
||||
<UL>
|
||||
<LI>On HP-UX, the equivalent environment variable is <CODE>SHLIB_PATH</CODE>.
|
||||
<LI>On AIX, the equivalent environment variable is <CODE>LIBPATH</CODE>.
|
||||
</UL>
|
||||
</UL>
|
||||
Change to the directory you copied the source into (for example,
|
||||
<CODE>cd /builds</CODE>). If this directory was empty before you
|
||||
installed the source, there should be two directories here:
|
||||
<CODE>README</CODE> and <CODE>mozilla</CODE>.
|
||||
<CODE>
|
||||
<PRE>
|
||||
cd mozilla
|
||||
gmake
|
||||
</PRE>
|
||||
</CODE>
|
||||
</UL>
|
||||
<HR>
|
||||
<H2><A NAME="s3">3. Common Sticking Points</A></H2>
|
||||
<LI>I'm sure there are bound to be some. Send
|
||||
<A HREF="mailto:leaf@mozilla.org"> me</A> mail.
|
||||
<LI>My linker dies with this error: undefined reference to `_Xsetlocale'
|
||||
<UL>If this error occurs, you might have to recompile libX11.so
|
||||
with the -DX_LOCALE flag (thanks to Scott Lampert,
|
||||
<A HREF="mailto:fortunato@heavymetal.org">fortunato@heavymetal.org</A>).
|
||||
This problem stems from use of an older version of RedHat Motif.
|
||||
Moving to Motif 2.1 should resolve this. There are probably other problems
|
||||
with using the older versions of Motif, but i haven't encountered them.
|
||||
|
||||
</UL>
|
||||
<HR>
|
||||
|
||||
|
||||
|
||||
7
mozilla/aclocal.m4
vendored
7
mozilla/aclocal.m4
vendored
@@ -1,7 +0,0 @@
|
||||
dnl
|
||||
dnl Local autoconf macros used with mozilla
|
||||
dnl The contents of this file are under the Public Domain.
|
||||
dnl
|
||||
|
||||
builtin(include, gtk.m4)dnl
|
||||
|
||||
24
mozilla/base/Makefile
Normal file
24
mozilla/base/Makefile
Normal file
@@ -0,0 +1,24 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ..
|
||||
|
||||
DIRS = public src tests
|
||||
|
||||
include $(DEPTH)/config/config.mk
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
@@ -24,7 +24,9 @@ include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public src
|
||||
|
||||
ifdef ENABLE_TESTS
|
||||
DIRS += tests
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,17 +0,0 @@
|
||||
# target: baseDebug.shlb
|
||||
mozilla/base/src/mac/nsTimerMac.cpp
|
||||
mozilla/base/src/nsArena.cpp
|
||||
mozilla/base/src/nsAtomTable.cpp
|
||||
mozilla/base/src/nsBTree.cpp
|
||||
mozilla/base/src/nsByteBuffer.cpp
|
||||
mozilla/base/src/nsCRT.cpp
|
||||
mozilla/base/src/nsDeque.cpp
|
||||
mozilla/base/src/nsEscape.cpp
|
||||
mozilla/base/src/nsFileSpec.cpp
|
||||
mozilla/base/src/nsFileStream.cpp
|
||||
mozilla/base/src/nsRBTree.cpp
|
||||
mozilla/base/src/nsSizeOfHandler.cpp
|
||||
mozilla/base/src/nsString.cpp
|
||||
mozilla/base/src/nsUnicharBuffer.cpp
|
||||
mozilla/base/src/nsUnicharInputStream.cpp
|
||||
mozilla/base/src/nsVoidArray.cpp
|
||||
@@ -1,19 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "MacPrefix_debug.h"
|
||||
@@ -2,7 +2,4 @@
|
||||
# This is a list of local files which get copied to the mozilla:dist:base directory
|
||||
#
|
||||
|
||||
nsISizeOfHandler.h
|
||||
nsFileStream.h
|
||||
nsFileSpec.h
|
||||
nsRepeater.h
|
||||
nsISizeOfHandler.h
|
||||
30
mozilla/base/public/Makefile
Normal file
30
mozilla/base/public/Makefile
Normal file
@@ -0,0 +1,30 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=../..
|
||||
|
||||
DEFINES = -D_IMPL_NS_BASE
|
||||
|
||||
EXPORTS = \
|
||||
nsISizeOfHandler.h \
|
||||
$(NULL)
|
||||
|
||||
MODULE = raptor
|
||||
|
||||
include $(DEPTH)/config/config.mk
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
@@ -22,18 +22,15 @@ VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DEFINES += -D_IMPL_NS_BASE
|
||||
DEFINES = -D_IMPL_NS_BASE
|
||||
|
||||
EXPORTS = \
|
||||
nsISizeOfHandler.h \
|
||||
nsEscape.h \
|
||||
nsFileSpec.h \
|
||||
nsFileStream.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
MODULE=base
|
||||
MODULE = raptor
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
|
||||
@@ -21,10 +21,7 @@ IGNORE_MANIFEST=1
|
||||
DEFINES = -D_IMPL_NS_BASE
|
||||
|
||||
EXPORTS = \
|
||||
nsIProperties.h \
|
||||
nsISizeOfHandler.h \
|
||||
nsFileSpec.h \
|
||||
nsFileStream.h \
|
||||
$(NULL)
|
||||
|
||||
MODULE = raptor
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/* First checked in on 98/12/03 by John R. McMullen, derived from net.h/mkparse.c. */
|
||||
|
||||
#ifndef _ESCAPE_H_
|
||||
#define _ESCAPE_H_
|
||||
|
||||
#include "prtypes.h"
|
||||
|
||||
/* valid mask values for NET_Escape() and NET_EscapedSize(). */
|
||||
typedef enum {
|
||||
url_XAlphas = (1<<0)
|
||||
, url_XPAlphas = (1<<1)
|
||||
, url_Path = (1<<2)
|
||||
} nsEscapeMask;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
char * nsEscape(const char * str, nsEscapeMask mask);
|
||||
/* Caller must use delete [] on the result */
|
||||
char * nsUnescape(char * str);
|
||||
/* decode % escaped hex codes into character values,
|
||||
* modifies the parameter, returns the same buffer
|
||||
*/
|
||||
|
||||
char * nsEscapeCount(const char * str, PRInt32 len, nsEscapeMask mask, PRInt32* out_len);
|
||||
/* Like nsEscape, but if out_len is non-null, return result string length
|
||||
* in *out_len, and uses len instead of NUL termination.
|
||||
* Caller must use delete [] on the result.
|
||||
*/
|
||||
PRInt32 nsUnescapeCount (char * str);
|
||||
/* decode % escaped hex codes into character values,
|
||||
* modifies the parameter buffer, returns the length of the result
|
||||
* (result may contain \0's).
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif // _ESCAPE_H_
|
||||
@@ -1,408 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
// First checked in on 98/11/20 by John R. McMullen in the wrong directory.
|
||||
// Checked in again 98/12/04.
|
||||
// Polished version 98/12/08.
|
||||
|
||||
//========================================================================================
|
||||
//
|
||||
// Classes defined:
|
||||
//
|
||||
// nsFilePath, nsFileURL, nsNativeFileSpec.
|
||||
//
|
||||
// This suite provides the following services:
|
||||
//
|
||||
// 1. Encapsulates all platform-specific file details, so that files can be
|
||||
// described correctly without any platform #ifdefs
|
||||
//
|
||||
// 2. Type safety. This will fix the problems that used to occur because people
|
||||
// confused file paths. They used to use const char*, which could mean three
|
||||
// or four different things. Bugs were introduced as people coded, right up
|
||||
// to the moment Communicator 4.5 shipped.
|
||||
//
|
||||
// 3. Used in conjunction with nsFileStream.h (q.v.), this supports all the power
|
||||
// and readability of the ansi stream syntax.
|
||||
//
|
||||
// Basic example:
|
||||
//
|
||||
// nsFilePath myPath("/Development/iotest.txt");
|
||||
//
|
||||
// nsOutputFileStream testStream(myPath);
|
||||
// testStream << "Hello World" << nsEndl;
|
||||
//
|
||||
// 4. Handy methods for manipulating file specifiers safely, e.g. MakeUnique(),
|
||||
// SetLeafName(), Exists().
|
||||
//
|
||||
// 5. Easy cross-conversion.
|
||||
//
|
||||
// Examples:
|
||||
//
|
||||
// Initialize a URL from a string without suffix
|
||||
//
|
||||
// nsFileURL fileURL("file:///Development/MPW/MPW%20Shell");
|
||||
//
|
||||
// Initialize a Unix path from a URL
|
||||
//
|
||||
// nsFilePath filePath(fileURL);
|
||||
//
|
||||
// Initialize a native file spec from a URL
|
||||
//
|
||||
// nsNativeFileSpec fileSpec(fileURL);
|
||||
//
|
||||
// Make the spec unique (this one has no suffix).
|
||||
//
|
||||
// fileSpec.MakeUnique();
|
||||
//
|
||||
// Assign the spec to a URL
|
||||
//
|
||||
// fileURL = fileSpec;
|
||||
//
|
||||
// Assign a unix path using a string with a suffix.
|
||||
//
|
||||
// filePath = "/Development/MPW/SysErrs.err";
|
||||
//
|
||||
// Assign to a file spec using a unix path.
|
||||
//
|
||||
// fileSpec = filePath;
|
||||
//
|
||||
// Make this unique (this one has a suffix).
|
||||
//
|
||||
// fileSpec.MakeUnique();
|
||||
//
|
||||
// 6. Fixes a bug that have been there for a long time, and
|
||||
// is inevitable if you use NSPR alone, where files are described as paths.
|
||||
//
|
||||
// The problem affects platforms (Macintosh) in which a path does not fully
|
||||
// specify a file, because two volumes can have the same name. This
|
||||
// is solved by holding a "private" native file spec inside the
|
||||
// nsFilePath and nsFileURL classes, which is used when appropriate.
|
||||
//
|
||||
// Not yet done:
|
||||
//
|
||||
// Equality operators... much more.
|
||||
//
|
||||
//========================================================================================
|
||||
|
||||
#ifndef _FILESPEC_H_
|
||||
#define _FILESPEC_H_
|
||||
|
||||
#include "nscore.h"
|
||||
|
||||
//========================================================================================
|
||||
// Compiler-specific macros, as needed
|
||||
//========================================================================================
|
||||
#if !defined(NS_USING_NAMESPACE) && (defined(__MWERKS__) || defined(XP_PC))
|
||||
#define NS_USING_NAMESPACE
|
||||
#endif
|
||||
|
||||
#ifdef NS_USING_NAMESPACE
|
||||
|
||||
#define NS_NAMESPACE_PROTOTYPE
|
||||
#define NS_NAMESPACE namespace
|
||||
#define NS_NAMESPACE_END
|
||||
#else
|
||||
|
||||
#define NS_NAMESPACE_PROTOTYPE static
|
||||
#define NS_NAMESPACE struct
|
||||
#define NS_NAMESPACE_END ;
|
||||
|
||||
#endif
|
||||
//=========================== End Compiler-specific macros ===============================
|
||||
|
||||
#ifdef XP_MAC
|
||||
#include <Files.h>
|
||||
#elif defined(XP_UNIX) || defined (XP_OS2)
|
||||
#include <dirent.h>
|
||||
#elif XP_PC
|
||||
#include "prio.h"
|
||||
#endif
|
||||
|
||||
//========================================================================================
|
||||
// Here are the allowable ways to describe a file.
|
||||
//========================================================================================
|
||||
|
||||
class nsFilePath; // This can be passed to NSPR file I/O routines.
|
||||
class nsFileURL;
|
||||
class nsNativeFileSpec;
|
||||
|
||||
#define kFileURLPrefix "file://"
|
||||
#define kFileURLPrefixLength (7)
|
||||
|
||||
class nsBasicOutStream;
|
||||
|
||||
//========================================================================================
|
||||
class NS_BASE nsNativeFileSpec
|
||||
// This is whatever each platform really prefers to describe files as. Declared first
|
||||
// because the other two types have an embeded nsNativeFileSpec object.
|
||||
//========================================================================================
|
||||
{
|
||||
public:
|
||||
nsNativeFileSpec();
|
||||
explicit nsNativeFileSpec(const char* inString, bool inCreateDirs = false);
|
||||
explicit nsNativeFileSpec(const nsFilePath& inPath);
|
||||
explicit nsNativeFileSpec(const nsFileURL& inURL);
|
||||
nsNativeFileSpec(const nsNativeFileSpec& inPath);
|
||||
virtual ~nsNativeFileSpec();
|
||||
|
||||
void operator = (const char* inPath);
|
||||
void operator = (const nsFilePath& inPath);
|
||||
void operator = (const nsFileURL& inURL);
|
||||
void operator = (const nsNativeFileSpec& inOther);
|
||||
|
||||
#ifndef XP_MAC
|
||||
operator const char* () const { return mPath; }
|
||||
// This is the only automatic conversion to const char*
|
||||
// that is provided, and it allows the
|
||||
// path to be "passed" to NSPR file routines.
|
||||
#endif
|
||||
|
||||
#ifdef XP_MAC
|
||||
// For Macintosh people, this is meant to be useful in its own right as a C++ version
|
||||
// of the FSSpec struct.
|
||||
nsNativeFileSpec(
|
||||
short vRefNum,
|
||||
long parID,
|
||||
ConstStr255Param name);
|
||||
nsNativeFileSpec(const FSSpec& inSpec)
|
||||
: mSpec(inSpec), mError(noErr) {}
|
||||
|
||||
operator FSSpec* () { return &mSpec; }
|
||||
operator const FSSpec* const () { return &mSpec; }
|
||||
operator FSSpec& () { return mSpec; }
|
||||
operator const FSSpec& () const { return mSpec; }
|
||||
OSErr Error() const { return mError; }
|
||||
void MakeAliasSafe();
|
||||
// Called for the spec of an alias. Copies the alias to
|
||||
// a secret temp directory and modifies the spec to point
|
||||
// to it. Sets mError.
|
||||
void ResolveAlias(bool& wasAliased);
|
||||
// Called for the spec of an alias. Modifies the spec to
|
||||
// point to the original. Sets mError.
|
||||
void MakeUnique(ConstStr255Param inSuggestedLeafName);
|
||||
StringPtr GetLeafPName() { return mSpec.name; }
|
||||
ConstStr255Param GetLeafPName() const { return mSpec.name; }
|
||||
#endif // end of Macintosh utility methods.
|
||||
|
||||
#ifdef XP_MAC
|
||||
bool Valid() const { return mError == noErr; }
|
||||
#else
|
||||
bool Valid() const { return true; } // Fixme.
|
||||
#endif // XP_MAC
|
||||
|
||||
friend NS_BASE nsBasicOutStream& operator << (
|
||||
nsBasicOutStream& s,
|
||||
const nsNativeFileSpec& spec);
|
||||
|
||||
//--------------------------------------------------
|
||||
// Queries and path algebra. These do not modify the disk.
|
||||
//--------------------------------------------------
|
||||
|
||||
char* GetLeafName() const; // Allocated. Use delete [].
|
||||
void SetLeafName(const char* inLeafName);
|
||||
// inLeafName can be a relative path, so this allows
|
||||
// one kind of concatenation of "paths".
|
||||
|
||||
void GetParent(nsNativeFileSpec& outSpec) const;
|
||||
// Return the filespec of the parent directory. Used
|
||||
// in conjunction with GetLeafName(), this lets you
|
||||
// parse a path into a list of node names. Beware,
|
||||
// however, that the top node is still not a name,
|
||||
// but a spec. Volumes on Macintosh can have identical
|
||||
// names. Perhaps could be used for an operator --() ?
|
||||
|
||||
nsNativeFileSpec operator + (const char* inRelativePath) const;
|
||||
void operator += (const char* inRelativePath);
|
||||
// Concatenate the relative path to this directory.
|
||||
// Used for constructing the filespec of a descendant.
|
||||
// This must be a directory for this to work. This differs
|
||||
// from SetLeafName(), since the latter will work
|
||||
// starting with a sibling of the directory and throws
|
||||
// away its leaf information, whereas this one assumes
|
||||
// this is a directory, and the relative path starts
|
||||
// "below" this.
|
||||
|
||||
void MakeUnique();
|
||||
void MakeUnique(const char* inSuggestedLeafName);
|
||||
|
||||
bool IsDirectory() const;
|
||||
// More stringent than Exists()
|
||||
bool IsFile() const;
|
||||
// More stringent than Exists()
|
||||
bool Exists() const;
|
||||
|
||||
//--------------------------------------------------
|
||||
// Creation and deletion of objects. These can modify the disk.
|
||||
//--------------------------------------------------
|
||||
|
||||
void CreateDirectory(int mode = 0700 /* for unix */);
|
||||
void Delete(bool inRecursive);
|
||||
|
||||
//--------------------------------------------------
|
||||
// Data
|
||||
//--------------------------------------------------
|
||||
|
||||
private:
|
||||
friend class nsFilePath;
|
||||
#ifdef XP_MAC
|
||||
FSSpec mSpec;
|
||||
OSErr mError;
|
||||
#else
|
||||
char* mPath;
|
||||
#endif
|
||||
}; // class nsNativeFileSpec
|
||||
|
||||
//========================================================================================
|
||||
class NS_BASE nsFileURL
|
||||
// This is an escaped string that looks like "file:///foo/bar/mumble%20fish". Since URLs
|
||||
// are the standard way of doing things in mozilla, this allows a string constructor,
|
||||
// which just stashes the string with no conversion.
|
||||
//========================================================================================
|
||||
{
|
||||
public:
|
||||
nsFileURL(const nsFileURL& inURL);
|
||||
explicit nsFileURL(const char* inString, bool inCreateDirs = false);
|
||||
explicit nsFileURL(const nsFilePath& inPath);
|
||||
explicit nsFileURL(const nsNativeFileSpec& inPath);
|
||||
virtual ~nsFileURL();
|
||||
|
||||
// nsString GetString() const { return mPath; }
|
||||
// may be needed for implementation reasons,
|
||||
// but should not provide a conversion constructor.
|
||||
|
||||
void operator = (const nsFileURL& inURL);
|
||||
void operator = (const char* inString);
|
||||
void operator = (const nsFilePath& inOther);
|
||||
void operator = (const nsNativeFileSpec& inOther);
|
||||
|
||||
friend NS_BASE nsBasicOutStream& operator << (
|
||||
nsBasicOutStream& s, const nsFileURL& spec);
|
||||
|
||||
#ifdef XP_MAC
|
||||
// Accessor to allow quick assignment to a mNativeFileSpec
|
||||
const nsNativeFileSpec& GetNativeSpec() const { return mNativeFileSpec; }
|
||||
#endif
|
||||
private:
|
||||
// Should not be defined (only nsFilePath is to be treated as strings.
|
||||
operator char* ();
|
||||
operator const char* const ();
|
||||
private:
|
||||
friend class nsFilePath; // to allow construction of nsFilePath
|
||||
char* mURL;
|
||||
#ifdef XP_MAC
|
||||
// Since the path on the macintosh does not uniquely specify a file (volumes
|
||||
// can have the same name), stash the secret nsNativeFileSpec, too.
|
||||
nsNativeFileSpec mNativeFileSpec;
|
||||
#endif
|
||||
}; // class nsFileURL
|
||||
|
||||
//========================================================================================
|
||||
class NS_BASE nsFilePath
|
||||
// This is a string that looks like "/foo/bar/mumble%20fish". Same as nsFileURL, but
|
||||
// without the "file:// prefix".
|
||||
//========================================================================================
|
||||
{
|
||||
public:
|
||||
nsFilePath(const nsFilePath& inPath);
|
||||
explicit nsFilePath(const char* inString, bool inCreateDirs = false);
|
||||
explicit nsFilePath(const nsFileURL& inURL);
|
||||
explicit nsFilePath(const nsNativeFileSpec& inPath);
|
||||
virtual ~nsFilePath();
|
||||
|
||||
|
||||
operator const char* () const { return mPath; }
|
||||
// This is the only automatic conversion to const char*
|
||||
// that is provided, and it allows the
|
||||
// path to be "passed" to NSPR file routines.
|
||||
operator char* () { return mPath; }
|
||||
// This is the only automatic conversion to string
|
||||
// that is provided, because a naked string should
|
||||
// only mean a standard file path.
|
||||
|
||||
void operator = (const nsFilePath& inPath);
|
||||
void operator = (const char* inString);
|
||||
void operator = (const nsFileURL& inURL);
|
||||
void operator = (const nsNativeFileSpec& inOther);
|
||||
|
||||
#ifdef XP_MAC
|
||||
public:
|
||||
// Accessor to allow quick assignment to a mNativeFileSpec
|
||||
const nsNativeFileSpec& GetNativeSpec() const { return mNativeFileSpec; }
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
char* mPath;
|
||||
#ifdef XP_MAC
|
||||
// Since the path on the macintosh does not uniquely specify a file (volumes
|
||||
// can have the same name), stash the secret nsNativeFileSpec, too.
|
||||
nsNativeFileSpec mNativeFileSpec;
|
||||
#endif
|
||||
}; // class nsFilePath
|
||||
|
||||
//========================================================================================
|
||||
class NS_BASE nsDirectoryIterator
|
||||
// Example:
|
||||
//
|
||||
// nsNativeFileSpec parentDir(...); // directory over whose children we shall iterate
|
||||
// for (nsDirectoryIterator i(parentDir); i; i++)
|
||||
// {
|
||||
// // do something with (const nsNativeFileSpec&)i
|
||||
// }
|
||||
//
|
||||
// or:
|
||||
//
|
||||
// for (nsDirectoryIterator i(parentDir, false); i; i--)
|
||||
// {
|
||||
// // do something with (const nsNativeFileSpec&)i
|
||||
// }
|
||||
//
|
||||
// Currently, the only platform on which backwards iteration actually goes backwards
|
||||
// is Macintosh. On other platforms, both styles will work, but will go forwards.
|
||||
//========================================================================================
|
||||
{
|
||||
public:
|
||||
nsDirectoryIterator(
|
||||
const nsNativeFileSpec& parent,
|
||||
int iterateDirection = +1);
|
||||
#ifndef XP_MAC
|
||||
// Macintosh currently doesn't allocate, so needn't clean up.
|
||||
virtual ~nsDirectoryIterator();
|
||||
#endif
|
||||
operator bool() const { return mExists; }
|
||||
nsDirectoryIterator& operator ++(); // moves to the next item, if any.
|
||||
nsDirectoryIterator& operator ++(int) { return ++(*this); } // post-increment.
|
||||
nsDirectoryIterator& operator --(); // moves to the previous item, if any.
|
||||
nsDirectoryIterator& operator --(int) { return --(*this); } // post-decrement.
|
||||
operator nsNativeFileSpec&() { return mCurrent; }
|
||||
private:
|
||||
nsNativeFileSpec mCurrent;
|
||||
bool mExists;
|
||||
|
||||
#if defined(XP_UNIX)
|
||||
DIR* mDir;
|
||||
#elif defined(XP_PC)
|
||||
PRDir* mDir; // XXX why not use PRDir for Unix & Mac, too?
|
||||
#elif defined(XP_MAC)
|
||||
OSErr SetToIndex();
|
||||
short mIndex;
|
||||
short mMaxIndex;
|
||||
#endif
|
||||
}; // class nsDirectoryIterator
|
||||
|
||||
#endif // _FILESPEC_H_
|
||||
@@ -1,332 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0(the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright(C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
// First checked in on 98/11/20 by John R. McMullen in the wrong directory.
|
||||
// Checked in again 98/12/04.
|
||||
// Polished version 98/12/08.
|
||||
|
||||
//========================================================================================
|
||||
//
|
||||
// Classes defined:
|
||||
//
|
||||
// single-byte char:
|
||||
//
|
||||
// nsInputFileStream, nsOutputFileStream
|
||||
//
|
||||
// This suite provide the following services:
|
||||
//
|
||||
// 1. Encapsulates all platform-specific file details, so that file i/o
|
||||
// can be done correctly without any platform #ifdefs
|
||||
//
|
||||
// 2. Uses NSPR file services (NOT ansi file I/O), in order to get best
|
||||
// native performance. This performance difference is especially large on
|
||||
// macintosh.
|
||||
//
|
||||
// 3. Allows all the power of the ansi stream syntax.
|
||||
//
|
||||
// Basic example:
|
||||
//
|
||||
// nsFilePath myPath("/Development/iotest.txt");
|
||||
//
|
||||
// nsOutputFileStream testStream(myPath);
|
||||
// testStream << "Hello World" << nsEndl;
|
||||
//
|
||||
// 4. Requires streams to be constructed using typesafe nsFilePath specifier
|
||||
// (not the notorious and bug prone const char*), namely nsFilePath. See
|
||||
// nsFileSpec.h for more details.
|
||||
//
|
||||
// 5. Fixes a bug that have been there for a long time, and
|
||||
// is inevitable if you use NSPR alone:
|
||||
//
|
||||
// The problem on platforms (Macintosh) in which a path does not fully
|
||||
// specify a file, because two volumes can have the same name.
|
||||
//
|
||||
// Not yet provided:
|
||||
//
|
||||
// Endian-awareness for reading and writing crossplatform binary files. At this
|
||||
// time there seems to be no demand for this.
|
||||
//
|
||||
//========================================================================================
|
||||
|
||||
#ifndef _FILESTREAM_H_
|
||||
#define _FILESTREAM_H_
|
||||
|
||||
#include "nscore.h"
|
||||
|
||||
#ifdef XP_MAC
|
||||
#include "pprio.h" // To get PR_ImportFile
|
||||
#else
|
||||
#include "prio.h"
|
||||
#endif
|
||||
#include "nsFileSpec.h"
|
||||
|
||||
//========================================================================================
|
||||
// Compiler-specific macros, as needed
|
||||
//========================================================================================
|
||||
#if !defined(NS_USING_NAMESPACE) && (defined(__MWERKS__) || defined(XP_PC))
|
||||
#define NS_USING_NAMESPACE
|
||||
#endif
|
||||
|
||||
#if !defined(NS_USING_STL) && (defined(__MWERKS__) || defined(XP_PC))
|
||||
#define NS_USING_STL
|
||||
#endif
|
||||
|
||||
#ifdef NS_USING_NAMESPACE
|
||||
|
||||
#define NS_NAMESPACE_PROTOTYPE
|
||||
#define NS_NAMESPACE namespace
|
||||
#define NS_NAMESPACE_END
|
||||
|
||||
#else
|
||||
|
||||
#define NS_NAMESPACE_PROTOTYPE static
|
||||
#define NS_NAMESPACE struct
|
||||
#define NS_NAMESPACE_END ;
|
||||
|
||||
#endif // NS_USING_NAMESPACE
|
||||
|
||||
#ifndef XP_MAC
|
||||
// PR_STDOUT and PR_STDIN are fatal on Macintosh. So for console i/o, we must use the std
|
||||
// stream stuff instead. However, we have to require that cout and cin are passed in
|
||||
// to the constructor because in the current build, there is a copy in the base.shlb,
|
||||
// and another in the caller's file. Passing it in as a parameter ensures that the
|
||||
// caller and this library are using the same global object. Groan.
|
||||
//
|
||||
// Unix currently does not support iostreams at all. Their compilers do not support
|
||||
// ANSI C++, or even ARM C++.
|
||||
//
|
||||
// Windows supports them, but only if you turn on the -GX compile flag, to support
|
||||
// exceptions.
|
||||
|
||||
// Catch 22.
|
||||
#define NS_USE_PR_STDIO
|
||||
#endif
|
||||
|
||||
#ifdef NS_USE_PR_STDIO
|
||||
class istream;
|
||||
class ostream;
|
||||
#define CONSOLE_IN 0
|
||||
#define CONSOLE_OUT 0
|
||||
#else
|
||||
#include <iostream>
|
||||
using std::istream;
|
||||
using std::ostream;
|
||||
#define CONSOLE_IN &std::cin
|
||||
#define CONSOLE_OUT &std::cout
|
||||
#endif
|
||||
|
||||
//=========================== End Compiler-specific macros ===============================
|
||||
|
||||
//========================================================================================
|
||||
class NS_BASE nsBasicFileStream
|
||||
//========================================================================================
|
||||
{
|
||||
public:
|
||||
nsBasicFileStream();
|
||||
nsBasicFileStream(PRFileDesc* desc, int nsprMode);
|
||||
nsBasicFileStream(
|
||||
const nsFilePath& inFile,
|
||||
int nsprMode,
|
||||
PRIntn accessMode);
|
||||
virtual ~nsBasicFileStream();
|
||||
|
||||
|
||||
inline PRBool is_open() const { return mFileDesc != 0; }
|
||||
void open(
|
||||
const nsFilePath& inFile,
|
||||
int nsprMode,
|
||||
PRIntn accessMode);
|
||||
void close();
|
||||
PRIntn tell() const;
|
||||
void seek(PRInt32 offset) { seek(PR_SEEK_SET, offset); }
|
||||
void seek(PRSeekWhence whence, PRInt32 offset);
|
||||
PRBool eof() const { return mEOF; }
|
||||
PRBool failed() const { return mFailed; }
|
||||
// call PR_GetError() for details
|
||||
protected:
|
||||
|
||||
PRFileDesc* GetFileDescriptor() const { return mFileDesc; }
|
||||
|
||||
protected:
|
||||
|
||||
friend class nsBasicInStream;
|
||||
friend class nsBasicOutStream;
|
||||
|
||||
PRFileDesc* mFileDesc;
|
||||
int mNSPRMode;
|
||||
PRBool mFailed;
|
||||
PRBool mEOF;
|
||||
}; // class nsBasicFileStream
|
||||
|
||||
//========================================================================================
|
||||
class NS_BASE nsBasicInStream
|
||||
//========================================================================================
|
||||
{
|
||||
protected:
|
||||
nsBasicInStream(nsBasicFileStream& inStream, istream* stream);
|
||||
|
||||
public:
|
||||
|
||||
nsBasicInStream& operator >> (nsBasicInStream& (*pf)(nsBasicInStream&))
|
||||
{
|
||||
return pf(*this);
|
||||
}
|
||||
void get(char& c);
|
||||
PRInt32 read(void* s, PRInt32 n);
|
||||
PRBool readline(char* s, PRInt32 n);
|
||||
// Result always null-terminated
|
||||
// false result indicates line was truncated
|
||||
// to fit buffer, or an error occurred.
|
||||
|
||||
// Input streamers. Add more as needed
|
||||
nsBasicInStream& operator >> (char& ch);
|
||||
|
||||
istream* GetStandardStream() const { return mStdStream; }
|
||||
|
||||
protected:
|
||||
|
||||
nsBasicFileStream& mBase;
|
||||
istream* mStdStream;
|
||||
}; // class nsBasicInStream
|
||||
|
||||
//========================================================================================
|
||||
class NS_BASE nsBasicOutStream
|
||||
//========================================================================================
|
||||
{
|
||||
protected:
|
||||
|
||||
nsBasicOutStream(nsBasicFileStream& inStream, ostream* stream);
|
||||
|
||||
public:
|
||||
|
||||
nsBasicOutStream& operator << (nsBasicOutStream& (*pf)(nsBasicOutStream&))
|
||||
{
|
||||
return pf(*this);
|
||||
}
|
||||
void put(char c);
|
||||
PRInt32 write(const void* s, PRInt32 n);
|
||||
void flush();
|
||||
|
||||
// Output streamers. Add more as needed
|
||||
nsBasicOutStream& operator << (const char* buf);
|
||||
nsBasicOutStream& operator << (char ch);
|
||||
nsBasicOutStream& operator << (short val);
|
||||
nsBasicOutStream& operator << (unsigned short val);
|
||||
nsBasicOutStream& operator << (long val);
|
||||
nsBasicOutStream& operator << (unsigned long val);
|
||||
|
||||
ostream* GetStandardStream() const { return mStdStream; }
|
||||
|
||||
protected:
|
||||
|
||||
nsBasicFileStream& mBase;
|
||||
ostream* mStdStream;
|
||||
}; // class nsBasicOutStream
|
||||
|
||||
//========================================================================================
|
||||
class NS_BASE nsInputFileStream
|
||||
//========================================================================================
|
||||
: public nsBasicFileStream
|
||||
, public nsBasicInStream
|
||||
{
|
||||
public:
|
||||
enum { kDefaultMode = PR_RDONLY };
|
||||
nsInputFileStream(istream* stream = CONSOLE_IN);
|
||||
nsInputFileStream(
|
||||
const nsFilePath& inFile,
|
||||
int nsprMode = kDefaultMode,
|
||||
PRIntn accessMode = 00700) // <- OCTAL
|
||||
: nsBasicFileStream(inFile, nsprMode, accessMode)
|
||||
, nsBasicInStream(*this, 0)
|
||||
{}
|
||||
|
||||
void open(
|
||||
const nsFilePath& inFile,
|
||||
int nsprMode = kDefaultMode,
|
||||
PRIntn accessMode = 00700) // <- OCTAL
|
||||
{
|
||||
nsBasicFileStream::open(inFile, nsprMode, accessMode);
|
||||
}
|
||||
private:
|
||||
|
||||
nsInputFileStream& operator >> (char* buf); // TOO DANGEROUS. DON'T DEFINE.
|
||||
|
||||
}; // class nsInputFileStream
|
||||
|
||||
//========================================================================================
|
||||
class NS_BASE nsOutputFileStream
|
||||
//========================================================================================
|
||||
: public nsBasicFileStream
|
||||
, public nsBasicOutStream
|
||||
{
|
||||
public:
|
||||
enum { kDefaultMode = (PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE) };
|
||||
|
||||
nsOutputFileStream(ostream* stream = CONSOLE_OUT);
|
||||
nsOutputFileStream(
|
||||
const nsFilePath& inFile,
|
||||
int nsprMode = kDefaultMode,
|
||||
PRIntn accessMode = 00700) // <- OCTAL
|
||||
: nsBasicFileStream(inFile, nsprMode, accessMode)
|
||||
, nsBasicOutStream(*this, 0)
|
||||
{}
|
||||
|
||||
inline void open(
|
||||
const nsFilePath& inFile,
|
||||
int nsprMode = kDefaultMode,
|
||||
PRIntn accessMode = 00700) // <- OCTAL
|
||||
{
|
||||
nsBasicFileStream::open(inFile, nsprMode, accessMode);
|
||||
}
|
||||
}; // class nsOutputFileStream
|
||||
|
||||
//========================================================================================
|
||||
class NS_BASE nsIOFileStream
|
||||
//========================================================================================
|
||||
: public nsBasicFileStream
|
||||
, public nsBasicOutStream
|
||||
, public nsBasicInStream
|
||||
{
|
||||
public:
|
||||
enum { kDefaultMode = (PR_RDWR | PR_CREATE_FILE) };
|
||||
|
||||
nsIOFileStream(
|
||||
const nsFilePath& inFile,
|
||||
int nsprMode = kDefaultMode,
|
||||
PRIntn accessMode = 00700) // <- OCTAL
|
||||
: nsBasicFileStream(inFile, nsprMode, accessMode)
|
||||
, nsBasicInStream(*this, 0)
|
||||
, nsBasicOutStream(*this, 0)
|
||||
{}
|
||||
|
||||
inline void open(
|
||||
const nsFilePath& inFile,
|
||||
int nsprMode = kDefaultMode,
|
||||
PRIntn accessMode = 00700) // <- OCTAL
|
||||
{
|
||||
nsBasicFileStream::open(inFile, nsprMode, accessMode);
|
||||
}
|
||||
}; // class nsIOFileStream
|
||||
|
||||
//========================================================================================
|
||||
// Manipulators
|
||||
//========================================================================================
|
||||
NS_BASE nsBasicOutStream& nsEndl(nsBasicOutStream& os);
|
||||
|
||||
|
||||
#endif /* _FILESTREAM_H_ */
|
||||
@@ -1,48 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsIProperties_h___
|
||||
#define nsIProperties_h___
|
||||
|
||||
#include "nsID.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
|
||||
// {1A180F60-93B2-11d2-9B8B-00805F8A16D9}
|
||||
#define NS_IPROPERTIES_IID \
|
||||
{ 0x1a180f60, 0x93b2, 0x11d2, \
|
||||
{ 0x9b, 0x8b, 0x0, 0x80, 0x5f, 0x8a, 0x16, 0xd9 } }
|
||||
|
||||
// {2245E573-9464-11d2-9B8B-00805F8A16D9}
|
||||
NS_DECLARE_ID(kPropertiesCID,
|
||||
0x2245e573, 0x9464, 0x11d2, 0x9b, 0x8b, 0x0, 0x80, 0x5f, 0x8a, 0x16, 0xd9);
|
||||
|
||||
class nsIProperties : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_IMETHOD Load(nsIInputStream* aIn) = 0;
|
||||
NS_IMETHOD GetProperty(const nsString& aKey, nsString& aValue) = 0;
|
||||
NS_IMETHOD SetProperty(const nsString& aKey, nsString& aNewValue,
|
||||
nsString& aOldValue) = 0;
|
||||
NS_IMETHOD Save(nsIOutputStream* aOut, const nsString& aHeader) = 0;
|
||||
NS_IMETHOD Subclass(nsIProperties* aSubclass) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIProperties_h___ */
|
||||
@@ -1,58 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsRepeater_h___
|
||||
#define nsRepeater_h___
|
||||
|
||||
class EventRecord;
|
||||
|
||||
class Repeater {
|
||||
public:
|
||||
|
||||
Repeater();
|
||||
virtual ~Repeater();
|
||||
|
||||
virtual void RepeatAction(const EventRecord &aMacEvent) = 0;
|
||||
|
||||
void StartRepeating();
|
||||
void StopRepeating();
|
||||
void StartIdling();
|
||||
void StopIdling();
|
||||
|
||||
static void DoRepeaters(const EventRecord &aMacEvent);
|
||||
static void DoIdlers(const EventRecord &aMacEvent);
|
||||
|
||||
protected:
|
||||
|
||||
void AddToRepeatList();
|
||||
void RemoveFromRepeatList();
|
||||
void AddToIdleList();
|
||||
void RemoveFromIdleList();
|
||||
|
||||
static Repeater* sRepeaters;
|
||||
static Repeater* sIdlers;
|
||||
|
||||
bool mRepeating;
|
||||
bool mIdling;
|
||||
Repeater* mPrevRptr;
|
||||
Repeater* mNextRptr;
|
||||
Repeater* mPrevIdlr;
|
||||
Repeater* mNextIdlr;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,939 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0(the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright(C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#error "Do not use this file. The unix compilers do not support standard C++. Use nsFileStream"
|
||||
|
||||
// First checked in on 98/11/20 by John R. McMullen in the wrong directory.
|
||||
// Checked in again 98/12/04.
|
||||
// Polished version 98/12/08.
|
||||
|
||||
//========================================================================================
|
||||
//
|
||||
// Classes defined:
|
||||
//
|
||||
// single-byte char:
|
||||
//
|
||||
// nsInputFileStream, nsOutputFileStream, nsIOFileStream
|
||||
//
|
||||
// wide char:
|
||||
//
|
||||
// nsWideInputFileStream, nsWideOutputFileStream, nsWideIOFileStream
|
||||
//
|
||||
// This suite provide the following services:
|
||||
//
|
||||
// 1. Encapsulates all platform-specific file details, so that file i/o
|
||||
// can be done correctly without any platform #ifdefs
|
||||
//
|
||||
// 2. Uses NSPR file services (NOT ansi file I/O), in order to get best
|
||||
// native performance. This performance difference is especially large on
|
||||
// macintosh.
|
||||
//
|
||||
// 3. Allows all the power of the ansi stream syntax: these streams
|
||||
// ARE derived classes of ostream, istream, and iostream. ALL METHODS OF
|
||||
// istream, ostream, AND iostream ARE AVAILABLE!
|
||||
//
|
||||
// Basic example:
|
||||
//
|
||||
// nsFilePath myPath("/Development/iotest.txt");
|
||||
//
|
||||
// nsOutputFileStream testStream(myPath);
|
||||
// testStream << "Hello World" << endl;
|
||||
//
|
||||
// 4. Requires streams to be constructed using typesafe nsFilePath specifier
|
||||
// (not the notorious and bug prone const char*), namely nsFilePath. See
|
||||
// nsFileSpec.h for more details.
|
||||
//
|
||||
// 5. Fixes a bug that have been there for a long time, and
|
||||
// is inevitable if you use NSPR alone:
|
||||
//
|
||||
// The problem on platforms (Macintosh) in which a path does not fully
|
||||
// specify a file, because two volumes can have the same name.
|
||||
//
|
||||
// Not yet provided:
|
||||
//
|
||||
// Endian-awareness for reading and writing crossplatform binary files. At this
|
||||
// time there seems to be no demand for this.
|
||||
//
|
||||
//========================================================================================
|
||||
|
||||
#ifndef _FILESTREAM_H_
|
||||
#define _FILESTREAM_H_
|
||||
|
||||
#include "nscore.h"
|
||||
|
||||
#ifdef XP_MAC
|
||||
#include "pprio.h" // To get PR_ImportFile
|
||||
#else
|
||||
#include "prio.h"
|
||||
#endif
|
||||
#include "nsFileSpec.h"
|
||||
|
||||
//========================================================================================
|
||||
// Compiler-specific macros, as needed
|
||||
//========================================================================================
|
||||
#if !defined(NS_USING_NAMESPACE) && (defined(__MWERKS__) || defined(XP_PC))
|
||||
#define NS_USING_NAMESPACE
|
||||
#endif
|
||||
|
||||
#if !defined(NS_USING_STL) && (defined(__MWERKS__) || defined(XP_PC))
|
||||
#define NS_USING_STL
|
||||
#endif
|
||||
|
||||
#ifdef NS_USING_NAMESPACE
|
||||
|
||||
#define NS_NAMESPACE_PROTOTYPE
|
||||
#define NS_NAMESPACE namespace
|
||||
#define NS_NAMESPACE_END
|
||||
|
||||
#else
|
||||
|
||||
#define NS_NAMESPACE_PROTOTYPE static
|
||||
#define NS_NAMESPACE struct
|
||||
#define NS_NAMESPACE_END ;
|
||||
|
||||
#endif // NS_USING_NAMESPACE
|
||||
|
||||
#ifdef NS_USING_STL
|
||||
|
||||
// Macintosh and Windows use this section.
|
||||
//
|
||||
// Here's where the party is. When Unix wants to join in (by supporting
|
||||
// a build system with STL headers), what fun we'll have! Meanwhile, I've used
|
||||
// macros to make this build on all our platforms. Unix doesn't have support for
|
||||
// STL, and therefore we could not use the template forms of these classes on Unix.
|
||||
// (it's a long story). Therefore, Unix supports no stream char types except 1-byte
|
||||
// characters, and therefore nobody else does now either, until Unix catches up.
|
||||
|
||||
|
||||
#define DEFINING_FILE_STREAM // templateers define this when this file is included.
|
||||
#define IOS_BASE ios_base
|
||||
#include <istream>
|
||||
using std::ios_base;
|
||||
using std::basic_streambuf;
|
||||
using std::codecvt_base;
|
||||
using std::codecvt;
|
||||
using std::streamsize;
|
||||
using std::locale;
|
||||
using std::basic_istream;
|
||||
using std::basic_ostream;
|
||||
using std::basic_iostream;
|
||||
using std::char_traits;
|
||||
#define TEMPLATE_DEF template<class charT, class traits>
|
||||
#define FILE_BUFFER_TYPE nsFileBufferT<charT, traits>
|
||||
#define INPUT_FILE_STREAM nsInputFileStreamT<charT, traits>
|
||||
#define OUTPUT_FILE_STREAM nsOutputFileStreamT<charT, traits>
|
||||
#define IO_FILE_STREAM nsIOFileStreamT<charT, traits>
|
||||
#define BASIC_STREAMBUF basic_streambuf<charT, traits>
|
||||
#define BASIC_ISTREAM basic_istream<charT, traits>
|
||||
#define BASIC_OSTREAM basic_ostream<charT, traits>
|
||||
#define BASIC_IOSTREAM basic_iostream<charT, traits>
|
||||
#define INT_TYPE FILE_BUFFER_TYPE::int_type
|
||||
#define POS_TYPE FILE_BUFFER_TYPE::pos_type
|
||||
#define OFF_TYPE FILE_BUFFER_TYPE::off_type
|
||||
#define SEEK_DIR IOS_BASE::seekdir
|
||||
#define EOF_VALUE traits::eof()
|
||||
|
||||
#else
|
||||
|
||||
// Unix uses this section until it supports STL. This means no locales, no traits,
|
||||
// no wide chars, etc. Also, the stream classes are the original ARM-style ones,
|
||||
// and are not templatized.
|
||||
|
||||
#define IOS_BASE ios
|
||||
#include <istream.h>
|
||||
#define TEMPLATE_DEF
|
||||
#define FILE_BUFFER_TYPE nsFileBufferT
|
||||
#define INPUT_FILE_STREAM nsInputFileStreamT
|
||||
#define OUTPUT_FILE_STREAM nsOutputFileStreamT
|
||||
#define IO_FILE_STREAM nsIOFileStreamT
|
||||
#define BASIC_STREAMBUF streambuf
|
||||
#define BASIC_ISTREAM istream
|
||||
#define BASIC_OSTREAM ostream
|
||||
#define BASIC_IOSTREAM iostream
|
||||
#define INT_TYPE int
|
||||
#define POS_TYPE long
|
||||
#define OFF_TYPE long
|
||||
#define SEEK_DIR ios::seek_dir
|
||||
#define int_type int
|
||||
#define pos_type long
|
||||
#define off_type long
|
||||
#define char_type char
|
||||
#define EOF_VALUE EOF
|
||||
|
||||
#endif // NS_USING_STL
|
||||
|
||||
#ifdef __MWERKS__
|
||||
|
||||
#ifdef MSIPL_WCHART
|
||||
#define NS_USING_WIDE_CHAR
|
||||
#endif
|
||||
#ifdef MSIPL_EXPLICIT_FUNC_TEMPLATE_ARG
|
||||
#define NS_EXPLICIT_FUNC_TEMPLATE_ARG
|
||||
#endif
|
||||
#define NS_READ_LOCK(mut) READ_LOCK(mut)
|
||||
#define NS_WRITE_LOCK(mut) WRITE_LOCK(mut)
|
||||
|
||||
#else
|
||||
|
||||
// Fix me, if necessary, for thread-safety.
|
||||
#define NS_READ_LOCK(mut)
|
||||
#define NS_WRITE_LOCK(mut)
|
||||
|
||||
#endif // __MWERKS__
|
||||
|
||||
//=========================== End Compiler-specific macros ===============================
|
||||
|
||||
//========================================================================================
|
||||
NS_NAMESPACE nsFileStreamHelpers
|
||||
// Prototypes for common (non-template) implementations in the .cpp file which do not
|
||||
// need the template args (charT, traits).
|
||||
//========================================================================================
|
||||
{
|
||||
NS_NAMESPACE_PROTOTYPE NS_BASE PRFileDesc* open(
|
||||
const nsFilePath& inFile,
|
||||
IOS_BASE::openmode mode,
|
||||
PRIntn accessMode);
|
||||
} NS_NAMESPACE_END // nsFileStreamHelpers
|
||||
|
||||
//========================================================================================
|
||||
// Template declarations
|
||||
//========================================================================================
|
||||
|
||||
//========================================================================================
|
||||
TEMPLATE_DEF
|
||||
class nsFileBufferT
|
||||
//========================================================================================
|
||||
: public BASIC_STREAMBUF
|
||||
{
|
||||
#ifdef NS_USING_STL
|
||||
typedef codecvt_base::result result;
|
||||
|
||||
public:
|
||||
typedef charT char_type;
|
||||
typedef typename traits::pos_type pos_type;
|
||||
typedef typename traits::off_type off_type;
|
||||
typedef typename traits::int_type int_type;
|
||||
typedef traits traits_type;
|
||||
typedef typename traits::state_type state_type;
|
||||
|
||||
typedef codecvt<charT, char, state_type> ofacet_type;
|
||||
typedef codecvt<char, charT, state_type> ifacet_type;
|
||||
#endif
|
||||
|
||||
public:
|
||||
nsFileBufferT();
|
||||
nsFileBufferT(PRFileDesc* pfile_arg);
|
||||
virtual ~nsFileBufferT();
|
||||
bool is_open() const;
|
||||
FILE_BUFFER_TYPE* open(
|
||||
const nsFilePath& inFile,
|
||||
IOS_BASE::openmode mode,
|
||||
PRIntn accessMode);
|
||||
FILE_BUFFER_TYPE* close();
|
||||
|
||||
protected:
|
||||
virtual int_type overflow(int_type c=EOF_VALUE);
|
||||
virtual int_type pbackfail(int_type c=EOF_VALUE);
|
||||
virtual int_type underflow();
|
||||
virtual pos_type seekoff(
|
||||
off_type off, SEEK_DIR way,
|
||||
IOS_BASE::openmode which=IOS_BASE::in|IOS_BASE::out);
|
||||
virtual pos_type seekpos(pos_type sp,
|
||||
IOS_BASE::openmode which=IOS_BASE::in|IOS_BASE::out);
|
||||
virtual BASIC_STREAMBUF* setbuf(char_type* s, streamsize n);
|
||||
virtual int sync();
|
||||
virtual int_type uflow();
|
||||
#ifdef NS_USING_STL
|
||||
virtual void imbue(const locale& loc);
|
||||
#endif
|
||||
virtual streamsize showmanyc();
|
||||
virtual streamsize xsgetn(char_type* s, streamsize n);
|
||||
virtual streamsize xsputn(const char_type* s, streamsize n);
|
||||
|
||||
private:
|
||||
PRFileDesc* mFileDesc;
|
||||
IOS_BASE::openmode mode_;
|
||||
}; // class nsFileBufferT
|
||||
|
||||
//========================================================================================
|
||||
TEMPLATE_DEF
|
||||
class nsInputFileStreamT
|
||||
//========================================================================================
|
||||
: public BASIC_ISTREAM
|
||||
{
|
||||
#ifdef NS_USING_STL
|
||||
public:
|
||||
typedef charT char_type;
|
||||
typedef typename traits::pos_type pos_type;
|
||||
typedef typename traits::off_type off_type;
|
||||
typedef typename traits::int_type int_type;
|
||||
typedef traits traits_type;
|
||||
#endif
|
||||
|
||||
public:
|
||||
nsInputFileStreamT();
|
||||
explicit nsInputFileStreamT(
|
||||
const nsFilePath& inFile,
|
||||
IOS_BASE::openmode mode=IOS_BASE::in,
|
||||
PRIntn accessMode = 0x00400);
|
||||
|
||||
virtual ~nsInputFileStreamT();
|
||||
|
||||
FILE_BUFFER_TYPE* rdbuf() const;
|
||||
inline bool is_open();
|
||||
inline void open(
|
||||
const nsFilePath& inFile,
|
||||
IOS_BASE::openmode mode=IOS_BASE::in,
|
||||
PRIntn accessMode = 0x00400);
|
||||
inline void close();
|
||||
|
||||
private:
|
||||
FILE_BUFFER_TYPE mBuffer;
|
||||
}; // class nsInputFileStreamT
|
||||
|
||||
//========================================================================================
|
||||
TEMPLATE_DEF
|
||||
class nsOutputFileStreamT
|
||||
//========================================================================================
|
||||
: public BASIC_OSTREAM
|
||||
{
|
||||
#ifdef NS_USING_STL
|
||||
public:
|
||||
typedef charT char_type;
|
||||
typedef typename traits::pos_type pos_type;
|
||||
typedef typename traits::off_type off_type;
|
||||
typedef typename traits::int_type int_type;
|
||||
typedef traits traits_type;
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
nsOutputFileStreamT();
|
||||
explicit nsOutputFileStreamT(
|
||||
const nsFilePath& inFile,
|
||||
IOS_BASE::openmode mode = IOS_BASE::out|IOS_BASE::trunc,
|
||||
PRIntn accessMode = 0x00200);
|
||||
|
||||
virtual ~nsOutputFileStreamT();
|
||||
|
||||
FILE_BUFFER_TYPE* rdbuf() const;
|
||||
inline bool is_open();
|
||||
inline void open(
|
||||
const nsFilePath& inFile,
|
||||
IOS_BASE::openmode mode = IOS_BASE::out|IOS_BASE::trunc,
|
||||
PRIntn accessMode = 0x00200);
|
||||
inline void close();
|
||||
|
||||
private:
|
||||
FILE_BUFFER_TYPE mBuffer;
|
||||
}; // class nsOutputFileStreamT
|
||||
|
||||
//========================================================================================
|
||||
// Implementation of nsFileBufferT
|
||||
//========================================================================================
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline FILE_BUFFER_TYPE::nsFileBufferT()
|
||||
: BASIC_STREAMBUF(), mFileDesc(NULL)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline FILE_BUFFER_TYPE::nsFileBufferT(PRFileDesc* pfarg)
|
||||
: BASIC_STREAMBUF(), mFileDesc(pfarg)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline FILE_BUFFER_TYPE* FILE_BUFFER_TYPE::close()
|
||||
// Must precede the destructor because both are inline.
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (mFileDesc==PR_STDIN || mFileDesc==PR_STDOUT || mFileDesc==PR_STDERR)
|
||||
return this;
|
||||
NS_WRITE_LOCK(_mutex);
|
||||
return (mFileDesc && PR_Close(mFileDesc) == PR_SUCCESS) ? mFileDesc = 0, this : 0;
|
||||
}
|
||||
|
||||
#if defined(DEFINING_FILE_STREAM)
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
FILE_BUFFER_TYPE::~nsFileBufferT()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
close();
|
||||
}
|
||||
#endif // #if defined(DEFINING_FILE_STREAM)
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline bool
|
||||
FILE_BUFFER_TYPE::is_open() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
NS_READ_LOCK(_mutex);
|
||||
return bool(mFileDesc); // in case it is typedefed to int
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline FILE_BUFFER_TYPE* FILE_BUFFER_TYPE::open(
|
||||
const nsFilePath& inFile,
|
||||
IOS_BASE::openmode mode,
|
||||
PRIntn accessMode)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (mFileDesc)
|
||||
return 0;
|
||||
NS_WRITE_LOCK(_mutex);
|
||||
mFileDesc = nsFileStreamHelpers::open(inFile, mode, accessMode);
|
||||
if (!mFileDesc)
|
||||
return 0;
|
||||
mode_ = mode;
|
||||
return this;
|
||||
} // FILE_BUFFER_TYPE::open
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline int FILE_BUFFER_TYPE:: sync()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return (mFileDesc ? (int)PR_Sync(mFileDesc) : 0);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline BASIC_STREAMBUF* FILE_BUFFER_TYPE::setbuf(char_type*, streamsize)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return (!mFileDesc) ? 0 : this;
|
||||
}
|
||||
|
||||
#if defined(DEFINING_FILE_STREAM)
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
INT_TYPE FILE_BUFFER_TYPE::overflow(int_type c)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
#ifndef NS_USING_STL
|
||||
char ch = c;
|
||||
PRInt32 bytesWrit1 = PR_Write(mFileDesc, &ch, sizeof(ch));
|
||||
return bytesWrit1 < sizeof(ch) ? EOF_VALUE : c;
|
||||
#else
|
||||
#ifdef NS_EXPLICIT_FUNC_TEMPLATE_ARG
|
||||
const ofacet_type& ft=use_facet<ofacet_type>(getloc());
|
||||
#elif defined(XP_PC)
|
||||
const ofacet_type& ft=use_facet(getloc(), (ofacet_type*)0, false);
|
||||
#else
|
||||
const ofacet_type& ft=use_facet(getloc(), (ofacet_type*)0);
|
||||
#endif
|
||||
char_type ch = traits_type::to_char_type(c);
|
||||
if (!mFileDesc)
|
||||
return EOF_VALUE;
|
||||
if (traits_type::eq_int_type(c, EOF_VALUE))
|
||||
return traits_type::not_eof(c);
|
||||
if (ft.always_noconv())
|
||||
{
|
||||
PRInt32 bytesWrit1 = PR_Write(mFileDesc, &ch, sizeof(ch));
|
||||
return bytesWrit1 < sizeof(ch) ? EOF_VALUE : c;
|
||||
}
|
||||
{ // <- sic!
|
||||
state_type fst;
|
||||
const char_type* end;
|
||||
char buf[4];
|
||||
char* ebuf;
|
||||
result conv;
|
||||
if ((conv=ft.out(fst, &ch, &ch+1, end, buf, buf+3, ebuf))==
|
||||
codecvt_base::noconv)
|
||||
{
|
||||
PRInt32 bytesWrit2 = PR_Write(mFileDesc, &ch, sizeof(ch));
|
||||
return bytesWrit2 < sizeof(ch) ? EOF_VALUE : c;
|
||||
}
|
||||
if ((conv==codecvt_base::partial)||(conv==codecvt_base::error))
|
||||
return EOF_VALUE;
|
||||
*ebuf=0;
|
||||
PRInt32 bytesWrit3 = strlen(buf);
|
||||
return PR_Write(mFileDesc, buf, bytesWrit3) < bytesWrit3 ? EOF_VALUE : c;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif // #if defined(DEFINING_FILE_STREAM)
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline INT_TYPE FILE_BUFFER_TYPE::underflow()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!mFileDesc)
|
||||
return EOF_VALUE;
|
||||
char_type s;
|
||||
PRInt32 request = 1;
|
||||
if (1 != PR_Read(mFileDesc, &s, request))
|
||||
return EOF_VALUE;
|
||||
PR_Seek(mFileDesc, -1, PR_SEEK_CUR);
|
||||
return (int_type)s;
|
||||
}
|
||||
|
||||
#if defined(DEFINING_FILE_STREAM)
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
streamsize FILE_BUFFER_TYPE::xsputn(const char_type* s, streamsize n)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
#ifndef NS_USING_STL
|
||||
PRInt32 bytesWrit1 = PR_Write(mFileDesc, s, sizeof(char) * size_t(n));
|
||||
return bytesWrit1 < 0 ? 0 : (streamsize)bytesWrit1;
|
||||
#else
|
||||
#ifdef NS_EXPLICIT_FUNC_TEMPLATE_ARG
|
||||
const ofacet_type& ft=use_facet<ofacet_type>(loc);
|
||||
#elif defined(XP_PC)
|
||||
const ofacet_type& ft=use_facet(getloc(), (ofacet_type*)0, false);
|
||||
#else
|
||||
const ofacet_type& ft=use_facet(getloc(), (ofacet_type*)0);
|
||||
#endif
|
||||
if (!mFileDesc || !n)
|
||||
return 0;
|
||||
if (ft.always_noconv())
|
||||
{
|
||||
PRInt32 bytesWrit1 = PR_Write(mFileDesc, s, sizeof(char) * size_t(n));
|
||||
return bytesWrit1 < 0 ? 0 : (streamsize)bytesWrit1;
|
||||
}
|
||||
{ // <- sic!
|
||||
state_type fst;
|
||||
const char_type* end;
|
||||
char buf[8];
|
||||
char* ebuf;
|
||||
result conv;
|
||||
#ifdef NS_EXPLICIT_FUNC_TEMPLATE_ARG
|
||||
if ((conv=use_facet<ofacet_type>(getloc()).
|
||||
#elif defined(XP_PC)
|
||||
if ((conv=use_facet(getloc(), (ofacet_type*)0, false).
|
||||
#else
|
||||
if ((conv=use_facet(getloc(), (ofacet_type*)0).
|
||||
#endif
|
||||
out(fst, s, s+n, end, buf, buf+7, ebuf))==codecvt_base::noconv)
|
||||
return (streamsize)PR_Write(mFileDesc, s, sizeof(char) * size_t(n));
|
||||
if ((conv==codecvt_base::partial) ||(conv==codecvt_base::error))
|
||||
return 0;
|
||||
*ebuf=0;
|
||||
PRInt32 bytesWrit2 = strlen(buf);
|
||||
bytesWrit2 = PR_Write(mFileDesc, buf, bytesWrit2);
|
||||
return bytesWrit2 < 0 ? 0 : streamsize(bytesWrit2 / sizeof(char_type));
|
||||
}
|
||||
#endif
|
||||
} // FILE_BUFFER_TYPE::xsputn
|
||||
#endif // #if defined(DEFINING_FILE_STREAM)
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline INT_TYPE FILE_BUFFER_TYPE::pbackfail(int_type c)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!mFileDesc)
|
||||
return EOF_VALUE;
|
||||
if (PR_Seek(mFileDesc, -1, PR_SEEK_CUR) < 0)
|
||||
return EOF_VALUE;
|
||||
#ifdef NS_USING_STL
|
||||
return (traits::eq_int_type(c, EOF_VALUE)) ? traits::not_eof(c) : c;
|
||||
#else
|
||||
return c;
|
||||
#endif
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline INT_TYPE FILE_BUFFER_TYPE::uflow()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!mFileDesc)
|
||||
return EOF_VALUE;
|
||||
char_type s;
|
||||
if (1 != PR_Read(mFileDesc, &s, 1)) // attempt to read 1 byte, confirm 1 byte
|
||||
return EOF_VALUE;
|
||||
return (int_type)s;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline streamsize FILE_BUFFER_TYPE::xsgetn(char_type* s, streamsize n)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return mFileDesc ? (streamsize)PR_Read(mFileDesc, s, sizeof(char) * size_t(n)) : 0;
|
||||
}
|
||||
|
||||
#ifdef NS_USING_STL
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline void FILE_BUFFER_TYPE::imbue(const locale& loc_arg)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
#ifdef XP_MAC
|
||||
loc = loc_arg;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline streamsize FILE_BUFFER_TYPE::showmanyc()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return (streamsize)PR_Available(mFileDesc);
|
||||
}
|
||||
|
||||
#if defined(DEFINING_FILE_STREAM)
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
POS_TYPE FILE_BUFFER_TYPE::seekoff(
|
||||
OFF_TYPE off,
|
||||
SEEK_DIR way,
|
||||
IOS_BASE::openmode /* which */)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!mFileDesc ||
|
||||
#ifdef NS_USING_STL
|
||||
((way&IOS_BASE::beg) && off<0) || ((way&IOS_BASE::end) && off > 0)
|
||||
#else
|
||||
((way == IOS_BASE::beg) && off<0) || ((way == IOS_BASE::end) && off > 0)
|
||||
#endif
|
||||
)
|
||||
return pos_type(-1);
|
||||
PRSeekWhence poseek = PR_SEEK_CUR;
|
||||
switch (way)
|
||||
{
|
||||
case IOS_BASE::beg : poseek= PR_SEEK_SET;
|
||||
break;
|
||||
case IOS_BASE::end : poseek= PR_SEEK_END;
|
||||
break;
|
||||
}
|
||||
PRInt32 position = PR_Seek(mFileDesc, off, poseek);
|
||||
if (position < 0)
|
||||
return pos_type(-1);
|
||||
return pos_type(position);
|
||||
}
|
||||
#endif // #if defined(DEFINING_FILE_STREAM)
|
||||
|
||||
#if defined(DEFINING_FILE_STREAM)
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
POS_TYPE FILE_BUFFER_TYPE::seekpos(pos_type sp, IOS_BASE::openmode)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!mFileDesc || sp==pos_type(-1))
|
||||
return -1;
|
||||
#if defined(XP_PC) || defined(XP_UNIX)
|
||||
PRInt32 position = sp;
|
||||
#else
|
||||
PRInt32 position = sp.offset();
|
||||
#endif
|
||||
position = PR_Seek(mFileDesc, position, PR_SEEK_SET);
|
||||
if (position < 0)
|
||||
return pos_type(-1);
|
||||
return position;
|
||||
}
|
||||
#endif // #if defined(DEFINING_FILE_STREAM)
|
||||
|
||||
//========================================================================================
|
||||
// Implementation of nsInputFileStreamT
|
||||
//========================================================================================
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline INPUT_FILE_STREAM::nsInputFileStreamT()
|
||||
: BASIC_ISTREAM(&mBuffer)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// already inited
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline INPUT_FILE_STREAM::nsInputFileStreamT(
|
||||
const nsFilePath& inFile,
|
||||
IOS_BASE::openmode mode,
|
||||
PRIntn accessMode)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: BASIC_ISTREAM(&mBuffer)
|
||||
{
|
||||
// already inited
|
||||
if (!mBuffer.open(inFile, openmode(mode|in), accessMode))
|
||||
setstate(failbit);
|
||||
}
|
||||
|
||||
#if defined(DEFINING_FILE_STREAM)
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
INPUT_FILE_STREAM::~nsInputFileStreamT()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
}
|
||||
#endif // #if defined(DEFINING_FILE_STREAM)
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline FILE_BUFFER_TYPE* INPUT_FILE_STREAM::rdbuf() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return (FILE_BUFFER_TYPE*)&mBuffer;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline bool INPUT_FILE_STREAM:: is_open()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return mBuffer.is_open();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline void INPUT_FILE_STREAM::open(
|
||||
const nsFilePath& inFile,
|
||||
IOS_BASE::openmode mode,
|
||||
PRIntn accessMode)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!mBuffer.open(inFile, openmode(mode|in), accessMode))
|
||||
setstate(failbit);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline void INPUT_FILE_STREAM::close()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!mBuffer.close())
|
||||
setstate(failbit);
|
||||
}
|
||||
|
||||
//========================================================================================
|
||||
// Implementation of nsOutputFileStreamT
|
||||
//========================================================================================
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline OUTPUT_FILE_STREAM::nsOutputFileStreamT()
|
||||
: BASIC_OSTREAM(&mBuffer)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// already inited
|
||||
}
|
||||
|
||||
#if defined(DEFINING_FILE_STREAM)
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
OUTPUT_FILE_STREAM::nsOutputFileStreamT(
|
||||
const nsFilePath& inFile,
|
||||
IOS_BASE::openmode mode,
|
||||
PRIntn accessMode)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: BASIC_OSTREAM(&mBuffer)
|
||||
{
|
||||
// already inited
|
||||
if (!mBuffer.open(inFile, openmode(mode|out), accessMode))
|
||||
setstate(failbit);
|
||||
}
|
||||
#endif // #if defined(DEFINING_FILE_STREAM)
|
||||
|
||||
#if defined(DEFINING_FILE_STREAM)
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline OUTPUT_FILE_STREAM::~nsOutputFileStreamT()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
}
|
||||
#endif // #if defined(DEFINING_FILE_STREAM)
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline FILE_BUFFER_TYPE*
|
||||
OUTPUT_FILE_STREAM::rdbuf() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return (FILE_BUFFER_TYPE*)&mBuffer;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline bool OUTPUT_FILE_STREAM:: is_open()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return mBuffer.is_open();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline void OUTPUT_FILE_STREAM::open(
|
||||
const nsFilePath& inFile,
|
||||
IOS_BASE::openmode mode,
|
||||
PRIntn accessMode)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!mBuffer.open(inFile, openmode(mode | out), accessMode))
|
||||
setstate(failbit);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline void OUTPUT_FILE_STREAM:: close()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!mBuffer.close())
|
||||
setstate(failbit);
|
||||
}
|
||||
|
||||
//========================================================================================
|
||||
TEMPLATE_DEF
|
||||
class nsIOFileStreamT : public BASIC_IOSTREAM
|
||||
//========================================================================================
|
||||
{
|
||||
#ifdef NS_USING_STL
|
||||
public:
|
||||
typedef charT char_type;
|
||||
typedef typename traits::pos_type pos_type;
|
||||
typedef typename traits::off_type off_type;
|
||||
typedef typename traits::int_type int_type;
|
||||
typedef traits traits_type;
|
||||
#endif
|
||||
|
||||
public:
|
||||
nsIOFileStreamT();
|
||||
explicit nsIOFileStreamT(
|
||||
const nsFilePath& inFile,
|
||||
IOS_BASE::openmode mode = IOS_BASE::in|IOS_BASE::out,
|
||||
PRIntn accessMode = 0x00600);
|
||||
|
||||
virtual ~nsIOFileStreamT();
|
||||
|
||||
FILE_BUFFER_TYPE* rdbuf() const;
|
||||
inline bool is_open();
|
||||
inline void open(
|
||||
const nsFilePath& inFile,
|
||||
IOS_BASE::openmode mode = IOS_BASE::in|IOS_BASE::out,
|
||||
PRIntn accessMode = 0x00600);
|
||||
inline void close();
|
||||
|
||||
private:
|
||||
FILE_BUFFER_TYPE mBuffer;
|
||||
}; // class nsIOFileStreamT
|
||||
|
||||
//========================================================================================
|
||||
// Implementation of nsIOFileStream
|
||||
//========================================================================================
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline IO_FILE_STREAM::nsIOFileStreamT()
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mBuffer(), BASIC_IOSTREAM(&mBuffer)
|
||||
{
|
||||
// already inited
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline IO_FILE_STREAM::nsIOFileStreamT(
|
||||
const nsFilePath& inFile,
|
||||
IOS_BASE::openmode mode,
|
||||
PRIntn accessMode)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mBuffer(), BASIC_IOSTREAM(&mBuffer)
|
||||
{
|
||||
// already inited
|
||||
if (!mBuffer.open(inFile, mode, accessMode))
|
||||
setstate(failbit);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline IO_FILE_STREAM::~nsIOFileStreamT()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline FILE_BUFFER_TYPE*
|
||||
IO_FILE_STREAM::rdbuf() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return (FILE_BUFFER_TYPE*)&mBuffer;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline bool IO_FILE_STREAM::is_open()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return mBuffer.is_open();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline void IO_FILE_STREAM::open(
|
||||
const nsFilePath& inFile,
|
||||
IOS_BASE::openmode mode,
|
||||
PRIntn accessMode)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!mBuffer.open(inFile, mode, accessMode))
|
||||
setstate(failbit);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TEMPLATE_DEF
|
||||
inline void IO_FILE_STREAM::close()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!mBuffer.close())
|
||||
setstate(failbit);
|
||||
}
|
||||
|
||||
//========================================================================================
|
||||
// Specializations of the stream templates
|
||||
//========================================================================================
|
||||
|
||||
#ifdef NS_USING_STL
|
||||
typedef nsFileBufferT<char, char_traits<char> > nsFileBuffer;
|
||||
typedef nsInputFileStreamT<char, char_traits<char> > nsInputFileStream;
|
||||
typedef nsOutputFileStreamT<char, char_traits<char> > nsOutputFileStream;
|
||||
typedef nsIOFileStreamT<char, char_traits<char> > nsIOFileStream;
|
||||
|
||||
#ifdef NS_USING_WIDE_CHAR
|
||||
typedef nsFileBufferT<wchar_t, char_traits<wchar_t> > nsWideFileBuffer;
|
||||
typedef nsInputFileStreamT<wchar_t, char_traits<wchar_t> > nsWideInputFileStream;
|
||||
typedef nsOutputFileStreamT<wchar_t, char_traits<wchar_t> > nsWideOutputFileStream;
|
||||
typedef nsIOFileStreamT<wchar_t, char_traits<wchar_t> > nsWideIOFileStream;
|
||||
#endif // NS_USING_WIDE_CHAR
|
||||
|
||||
#else
|
||||
|
||||
typedef nsFileBufferT nsFileBuffer;
|
||||
typedef nsInputFileStreamT nsInputFileStream;
|
||||
typedef nsOutputFileStreamT nsOutputFileStream;
|
||||
typedef nsIOFileStreamT nsIOFileStream;
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _FILESTREAM_H_ */
|
||||
|
||||
72
mozilla/base/src/Makefile
Normal file
72
mozilla/base/src/Makefile
Normal file
@@ -0,0 +1,72 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=../..
|
||||
|
||||
DEFINES =-D_IMPL_NS_BASE
|
||||
|
||||
DIRS = unix
|
||||
|
||||
LIBRARY_NAME = raptorbase
|
||||
|
||||
CPPSRCS = \
|
||||
nsArena.cpp \
|
||||
nsAtomTable.cpp \
|
||||
nsBTree.cpp \
|
||||
nsByteBuffer.cpp \
|
||||
nsCRT.cpp \
|
||||
nsDeque.cpp \
|
||||
nsRBTree.cpp \
|
||||
nsSizeOfHandler.cpp \
|
||||
nsString.cpp \
|
||||
nsUnicharBuffer.cpp \
|
||||
nsUnicharInputStream.cpp \
|
||||
nsVoidArray.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
nscore.h \
|
||||
nsBTree.h \
|
||||
nsCRT.h \
|
||||
nsDeque.h \
|
||||
nsIArena.h \
|
||||
nsIAtom.h \
|
||||
nsIByteBuffer.h \
|
||||
nsIBaseStream.h \
|
||||
nsIInputStream.h \
|
||||
nsIOutputStream.h \
|
||||
nsITimer.h \
|
||||
nsITimerCallback.h \
|
||||
nsIUnicharBuffer.h \
|
||||
nsIUnicharInputStream.h \
|
||||
nsInt64.h \
|
||||
nsRBTree.h \
|
||||
nsString.h \
|
||||
nsTime.h \
|
||||
nsVoidArray.h \
|
||||
nsUnitConversion.h \
|
||||
$(NULL)
|
||||
|
||||
MODULE = raptor
|
||||
|
||||
REQUIRES = xpcom netlib raptor
|
||||
|
||||
include $(DEPTH)/config/config.mk
|
||||
|
||||
TARGET = $(LIBARY)
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
@@ -17,14 +17,14 @@
|
||||
|
||||
DEPTH=../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DEFINES +=-D_IMPL_NS_BASE
|
||||
DEFINES =-D_IMPL_NS_BASE
|
||||
|
||||
DIRS = $(MOZ_TOOLKIT)
|
||||
DIRS = unix
|
||||
|
||||
LIBRARY_NAME = raptorbase
|
||||
|
||||
@@ -35,11 +35,8 @@ CPPSRCS = \
|
||||
nsByteBuffer.cpp \
|
||||
nsCRT.cpp \
|
||||
nsDeque.cpp \
|
||||
nsEscape.cpp \
|
||||
nsFileSpec.cpp \
|
||||
nsFileStream.cpp \
|
||||
nsRBTree.cpp \
|
||||
nsSizeOfHandler.cpp \
|
||||
nsSizeOfHandler.cpp \
|
||||
nsString.cpp \
|
||||
nsUnicharBuffer.cpp \
|
||||
nsUnicharInputStream.cpp \
|
||||
@@ -69,9 +66,9 @@ EXPORTS = \
|
||||
nsUnitConversion.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
MODULE=base
|
||||
MODULE = raptor
|
||||
|
||||
REQUIRES = xpcom netlib raptor
|
||||
|
||||
@@ -80,6 +77,3 @@ include $(topsrcdir)/config/config.mk
|
||||
TARGET = $(LIBARY)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
test:
|
||||
@echo OS_ARCH = $(OS_ARCH)
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
LIBRARY_NAME = gmbasegtk
|
||||
|
||||
MODULE=base
|
||||
|
||||
REQUIRES = xpcom raptor
|
||||
|
||||
DEFINES += -D_IMPL_NS_WIDGET
|
||||
|
||||
CPPSRCS = nsTimer.cpp
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
CFLAGS += $(TK_CFLAGS)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
@@ -1,190 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#include "nsITimer.h"
|
||||
#include "nsITimerCallback.h"
|
||||
#include "nsCRT.h"
|
||||
#include "prlog.h"
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static NS_DEFINE_IID(kITimerIID, NS_ITIMER_IID);
|
||||
|
||||
extern "C" gint nsTimerExpired(gpointer aCallData);
|
||||
|
||||
/*
|
||||
* Implementation of timers using Gtk timer facility
|
||||
*/
|
||||
class TimerImpl : public nsITimer {
|
||||
public:
|
||||
|
||||
public:
|
||||
TimerImpl();
|
||||
virtual ~TimerImpl();
|
||||
|
||||
virtual nsresult Init(nsTimerCallbackFunc aFunc,
|
||||
void *aClosure,
|
||||
// PRBool aRepeat,
|
||||
PRUint32 aDelay);
|
||||
|
||||
virtual nsresult Init(nsITimerCallback *aCallback,
|
||||
// PRBool aRepeat,
|
||||
PRUint32 aDelay);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
virtual void Cancel();
|
||||
virtual PRUint32 GetDelay() { return mDelay; }
|
||||
virtual void SetDelay(PRUint32 aDelay) { mDelay=aDelay; };
|
||||
virtual void* GetClosure() { return mClosure; }
|
||||
|
||||
void FireTimeout();
|
||||
|
||||
private:
|
||||
nsresult Init(PRUint32 aDelay);
|
||||
|
||||
PRUint32 mDelay;
|
||||
nsTimerCallbackFunc mFunc;
|
||||
void *mClosure;
|
||||
nsITimerCallback *mCallback;
|
||||
// PRBool mRepeat;
|
||||
TimerImpl *mNext;
|
||||
guint mTimerId;
|
||||
};
|
||||
|
||||
void TimerImpl::FireTimeout()
|
||||
{
|
||||
if (mFunc != NULL) {
|
||||
(*mFunc)(this, mClosure);
|
||||
}
|
||||
else if (mCallback != NULL) {
|
||||
mCallback->Notify(this); // Fire the timer
|
||||
}
|
||||
|
||||
// Always repeating here
|
||||
|
||||
// if (mRepeat)
|
||||
// mTimerId = gtk_timeout_add(aDelay, nsTimerExpired, this);
|
||||
}
|
||||
|
||||
|
||||
TimerImpl::TimerImpl()
|
||||
{
|
||||
// printf("TimerImple::TimerImpl called for %p\n", this);
|
||||
NS_INIT_REFCNT();
|
||||
mFunc = NULL;
|
||||
mCallback = NULL;
|
||||
mNext = NULL;
|
||||
mTimerId = 0;
|
||||
mDelay = 0;
|
||||
mClosure = NULL;
|
||||
}
|
||||
|
||||
TimerImpl::~TimerImpl()
|
||||
{
|
||||
//printf("TimerImpl::~TimerImpl called for %p\n", this);
|
||||
Cancel();
|
||||
NS_IF_RELEASE(mCallback);
|
||||
}
|
||||
|
||||
nsresult
|
||||
TimerImpl::Init(nsTimerCallbackFunc aFunc,
|
||||
void *aClosure,
|
||||
// PRBool aRepeat,
|
||||
PRUint32 aDelay)
|
||||
{
|
||||
//printf("TimerImpl::Init called with func + closure for %p\n", this);
|
||||
mFunc = aFunc;
|
||||
mClosure = aClosure;
|
||||
// mRepeat = aRepeat;
|
||||
|
||||
if ((aDelay > 10000) || (aDelay < 0)) {
|
||||
printf("Timer::Init() called with bogus value \"%d\"! Not enabling timer.\n",
|
||||
aDelay);
|
||||
return Init(aDelay);
|
||||
}
|
||||
|
||||
mTimerId = gtk_timeout_add(aDelay, nsTimerExpired, this);
|
||||
|
||||
return Init(aDelay);
|
||||
}
|
||||
|
||||
nsresult
|
||||
TimerImpl::Init(nsITimerCallback *aCallback,
|
||||
// PRBool aRepeat,
|
||||
PRUint32 aDelay)
|
||||
{
|
||||
//printf("TimerImpl::Init called with callback only for %p\n", this);
|
||||
mCallback = aCallback;
|
||||
// mRepeat = aRepeat;
|
||||
if ((aDelay > 10000) || (aDelay < 0)) {
|
||||
printf("Timer::Init() called with bogus value \"%d\"! Not enabling timer.\n",
|
||||
aDelay);
|
||||
return Init(aDelay);
|
||||
}
|
||||
|
||||
mTimerId = gtk_timeout_add(aDelay, nsTimerExpired, this);
|
||||
|
||||
return Init(aDelay);
|
||||
}
|
||||
|
||||
nsresult
|
||||
TimerImpl::Init(PRUint32 aDelay)
|
||||
{
|
||||
//printf("TimerImpl::Init called with delay %d only for %p\n", aDelay, this);
|
||||
|
||||
mDelay = aDelay;
|
||||
NS_ADDREF(this);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(TimerImpl, kITimerIID)
|
||||
|
||||
|
||||
void
|
||||
TimerImpl::Cancel()
|
||||
{
|
||||
//printf("TimerImpl::Cancel called for %p\n", this);
|
||||
TimerImpl *me = this;
|
||||
if (mTimerId)
|
||||
gtk_timeout_remove(mTimerId);
|
||||
}
|
||||
|
||||
NS_BASE nsresult NS_NewTimer(nsITimer** aInstancePtrResult)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
TimerImpl *timer = new TimerImpl();
|
||||
if (nsnull == timer) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return timer->QueryInterface(kITimerIID, (void **) aInstancePtrResult);
|
||||
}
|
||||
|
||||
gint nsTimerExpired(gpointer aCallData)
|
||||
{
|
||||
//printf("nsTimerExpired for %p\n", aCallData);
|
||||
TimerImpl* timer = (TimerImpl *)aCallData;
|
||||
timer->FireTimeout();
|
||||
return 0;
|
||||
}
|
||||
@@ -1,851 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
// This file is included by nsFile.cp, and includes the Macintosh-specific
|
||||
// implementations.
|
||||
|
||||
#include "FullPath.h"
|
||||
#include "FileCopy.h"
|
||||
#include "MoreFilesExtras.h"
|
||||
#include "nsEscape.h"
|
||||
|
||||
#include <Aliases.h>
|
||||
#include <Folders.h>
|
||||
#include <Errors.h>
|
||||
#include <TextUtils.h>
|
||||
|
||||
const unsigned char* kAliasHavenFolderName = "\pnsAliasHaven";
|
||||
|
||||
//========================================================================================
|
||||
namespace MacFileHelpers
|
||||
//========================================================================================
|
||||
{
|
||||
inline void PLstrcpy(Str255 dst, ConstStr255Param src)
|
||||
{
|
||||
memcpy(dst, src, 1 + src[0]);
|
||||
}
|
||||
|
||||
void PLstrcpy(Str255 dst, const char* src, int inMaxLen=255);
|
||||
void PLstrncpy(Str255 dst, const char* src, int inMaxLen);
|
||||
|
||||
void SwapSlashColon(char * s);
|
||||
OSErr FSSpecFromFullUnixPath(
|
||||
const char * unixPath,
|
||||
FSSpec& outSpec,
|
||||
Boolean resolveAlias,
|
||||
Boolean allowPartial = false,
|
||||
Boolean createDirs = false);
|
||||
char* MacPathFromUnixPath(const char* unixPath);
|
||||
char* EncodeMacPath(
|
||||
char* inPath, // NOT const - gets clobbered
|
||||
Boolean prependSlash,
|
||||
Boolean doEscape );
|
||||
OSErr FSSpecFromPathname(
|
||||
const char* inPathNamePtr,
|
||||
FSSpec& outSpec,
|
||||
Boolean inCreateDirs);
|
||||
char* PathNameFromFSSpec(
|
||||
const FSSpec& inSpec,
|
||||
Boolean wantLeafName );
|
||||
OSErr CreateFolderInFolder(
|
||||
short refNum, // Parent directory/volume
|
||||
long dirID,
|
||||
ConstStr255Param folderName, // Name of the new folder
|
||||
short& outRefNum, // Volume of the created folder
|
||||
long& outDirID); //
|
||||
|
||||
// Some routines to support an "alias haven" directory. Aliases in this directory
|
||||
// are never resolved. There is a ResolveAlias here that respects that. This is
|
||||
// to support attaching of aliases in mail.
|
||||
void EnsureAliasHaven();
|
||||
void SetNoResolve(Boolean inResolve);
|
||||
bool IsAliasSafe(const FSSpec& inSpec);
|
||||
OSErr MakeAliasSafe(FSSpec& inOutSpec);
|
||||
OSErr ResolveAliasFile(FSSpec& inOutSpec, Boolean& wasAliased);
|
||||
|
||||
Boolean sNoResolve = false;
|
||||
long sAliasHavenDirID = 0;
|
||||
short sAliasHavenVRefNum = 0;
|
||||
} // namespace MacFileHelpers
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MacFileHelpers::PLstrcpy(Str255 dst, const char* src, int inMax)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
int srcLength = strlen(src);
|
||||
NS_ASSERTION(srcLength <= inMax, "Oops, string is too long!");
|
||||
if (srcLength > inMax)
|
||||
srcLength = inMax;
|
||||
dst[0] = srcLength;
|
||||
memcpy(&dst[1], src, srcLength);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MacFileHelpers::PLstrncpy(Str255 dst, const char* src, int inMax)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
int srcLength = strlen(src);
|
||||
if (srcLength > inMax)
|
||||
srcLength = inMax;
|
||||
dst[0] = srcLength;
|
||||
memcpy(&dst[1], src, srcLength);
|
||||
}
|
||||
|
||||
//-----------------------------------
|
||||
void MacFileHelpers::SwapSlashColon(char * s)
|
||||
//-----------------------------------
|
||||
|
||||
{
|
||||
while ( *s != 0)
|
||||
{
|
||||
if (*s == '/')
|
||||
*s++ = ':';
|
||||
else if (*s == ':')
|
||||
*s++ = '/';
|
||||
else
|
||||
*s++;
|
||||
}
|
||||
} // MacFileHelpers::SwapSlashColon
|
||||
|
||||
//-----------------------------------
|
||||
char* MacFileHelpers::EncodeMacPath(
|
||||
char* inPath, // NOT const, gets clobbered
|
||||
Boolean prependSlash,
|
||||
Boolean doEscape )
|
||||
// Transforms Macintosh style path into Unix one
|
||||
// Method: Swap ':' and '/', hex escape the result
|
||||
//-----------------------------------
|
||||
{
|
||||
if (inPath == NULL)
|
||||
return NULL;
|
||||
int pathSize = strlen(inPath);
|
||||
|
||||
// XP code sometimes chokes if there's a final slash in the unix path.
|
||||
// Since correct mac paths to folders and volumes will end in ':', strip this
|
||||
// first.
|
||||
char* c = inPath + pathSize - 1;
|
||||
if (*c == ':')
|
||||
{
|
||||
*c = 0;
|
||||
pathSize--;
|
||||
}
|
||||
|
||||
char * newPath = NULL;
|
||||
char * finalPath = NULL;
|
||||
|
||||
if (prependSlash)
|
||||
{
|
||||
newPath = new char[pathSize + 2];
|
||||
newPath[0] = ':'; // It will be converted to '/'
|
||||
memcpy(&newPath[1], inPath, pathSize + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
newPath = new char[pathSize + 1];
|
||||
strcpy(newPath, inPath);
|
||||
}
|
||||
if (newPath)
|
||||
{
|
||||
SwapSlashColon( newPath );
|
||||
if (doEscape)
|
||||
{
|
||||
finalPath = nsEscape(newPath, url_Path);
|
||||
delete [] newPath;
|
||||
}
|
||||
else
|
||||
finalPath = newPath;
|
||||
}
|
||||
delete [] inPath;
|
||||
return finalPath;
|
||||
} // MacFileHelpers::EncodeMacPath
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
inline void MacFileHelpers::SetNoResolve(Boolean inResolve)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
sNoResolve = inResolve;
|
||||
} // MacFileHelpers::SetNoResolve
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
OSErr MacFileHelpers::MakeAliasSafe(FSSpec& inOutSpec)
|
||||
// Pass in the spec of an alias. This copies the file to the safe haven folder, and
|
||||
// returns the spec of the copy to the caller
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
EnsureAliasHaven();
|
||||
nsNativeFileSpec dstDirSpec(sAliasHavenVRefNum, sAliasHavenDirID, "\p");
|
||||
|
||||
// Make sure its name is unique
|
||||
nsNativeFileSpec havenSpec(sAliasHavenVRefNum, sAliasHavenDirID, "\pG'day");
|
||||
if (havenSpec.Valid())
|
||||
havenSpec.MakeUnique(inOutSpec.name);
|
||||
// Copy the file into the haven directory
|
||||
if (havenSpec.Valid())
|
||||
{
|
||||
OSErr err = ::FSpFileCopy(
|
||||
&inOutSpec,
|
||||
dstDirSpec,
|
||||
havenSpec.GetLeafPName(),
|
||||
nil, 0, true);
|
||||
// Return the spec of the copy to the caller.
|
||||
if (err != noErr)
|
||||
return err;
|
||||
inOutSpec = havenSpec;
|
||||
}
|
||||
return noErr;
|
||||
} // MacFileHelpers::MakeAliasSafe
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
char* MacFileHelpers::MacPathFromUnixPath(const char* unixPath)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// Relying on the fact that the unix path is always longer than the mac path:
|
||||
size_t len = strlen(unixPath);
|
||||
char* result = new char[len + 2]; // ... but allow for the initial colon in a partial name
|
||||
if (result)
|
||||
{
|
||||
char* dst = result;
|
||||
const char* src = unixPath;
|
||||
if (*src == '/') // ¥ full path
|
||||
src++;
|
||||
else if (strchr(src, '/')) // ¥ partial path, and not just a leaf name
|
||||
*dst++ = ':';
|
||||
strcpy(dst, src);
|
||||
nsUnescape(dst); // Hex Decode
|
||||
MacFileHelpers::SwapSlashColon(dst);
|
||||
}
|
||||
return result;
|
||||
} // MacFileHelpers::MacPathFromUnixPath
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
OSErr MacFileHelpers::FSSpecFromPathname(
|
||||
const char* inPathNamePtr,
|
||||
FSSpec& outSpec,
|
||||
Boolean inCreateDirs)
|
||||
// FSSpecFromPathname reverses PathNameFromFSSpec.
|
||||
// It returns a FSSpec given a c string which is a mac pathname.
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
OSErr err;
|
||||
// Simplify this routine to use FSMakeFSSpec if length < 255. Otherwise use the MoreFiles
|
||||
// routine FSpLocationFromFullPath, which allocates memory, to handle longer pathnames.
|
||||
|
||||
size_t inLength = strlen(inPathNamePtr);
|
||||
if (inLength < 255)
|
||||
{
|
||||
Str255 ppath;
|
||||
MacFileHelpers::PLstrcpy(ppath, inPathNamePtr);
|
||||
err = ::FSMakeFSSpec(0, 0, ppath, &outSpec);
|
||||
}
|
||||
else
|
||||
err = FSpLocationFromFullPath(inLength, inPathNamePtr, &outSpec);
|
||||
|
||||
if (err == dirNFErr && inCreateDirs)
|
||||
{
|
||||
const char* path = inPathNamePtr;
|
||||
outSpec.vRefNum = 0;
|
||||
outSpec.parID = 0;
|
||||
do {
|
||||
// Locate the colon that terminates the node.
|
||||
// But if we've a partial path (starting with a colon), find the second one.
|
||||
const char* nextColon = strchr(path + (*path == ':'), ':');
|
||||
// Well, if there are no more colons, point to the end of the string.
|
||||
if (!nextColon)
|
||||
nextColon = path + strlen(path);
|
||||
|
||||
// Make a pascal string out of this node. Include initial
|
||||
// and final colon, if any!
|
||||
Str255 ppath;
|
||||
MacFileHelpers::PLstrncpy(ppath, path, nextColon - path + 1);
|
||||
|
||||
// Use this string as a relative path using the directory created
|
||||
// on the previous round (or directory 0,0 on the first round).
|
||||
err = ::FSMakeFSSpec(outSpec.vRefNum, outSpec.parID, ppath, &outSpec);
|
||||
|
||||
// If this was the leaf node, then we are done.
|
||||
if (!*nextColon)
|
||||
break;
|
||||
|
||||
// If we got "file not found", then
|
||||
// we need to create a directory.
|
||||
if (err == fnfErr && *nextColon)
|
||||
err = FSpDirCreate(&outSpec, smCurrentScript, &outSpec.parID);
|
||||
// For some reason, this usually returns fnfErr, even though it works.
|
||||
if (err != noErr && err != fnfErr)
|
||||
return err;
|
||||
path = nextColon; // next round
|
||||
} while (1);
|
||||
}
|
||||
return err;
|
||||
} // MacFileHelpers::FSSpecFromPathname
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
OSErr MacFileHelpers::CreateFolderInFolder(
|
||||
short refNum, // Parent directory/volume
|
||||
long dirID,
|
||||
ConstStr255Param folderName, // Name of the new folder
|
||||
short& outRefNum, // Volume of the created folder
|
||||
long& outDirID) //
|
||||
// Creates a folder named 'folderName' inside a folder.
|
||||
// The errors returned are same as PBDirCreate
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
HFileParam hpb;
|
||||
hpb.ioVRefNum = refNum;
|
||||
hpb.ioDirID = dirID;
|
||||
hpb.ioNamePtr = (StringPtr)&folderName;
|
||||
|
||||
OSErr err = PBDirCreateSync((HParmBlkPtr)&hpb);
|
||||
if (err == noErr)
|
||||
{
|
||||
outRefNum = hpb.ioVRefNum;
|
||||
outDirID = hpb.ioDirID;
|
||||
}
|
||||
else
|
||||
{
|
||||
outRefNum = 0;
|
||||
outDirID = 0;
|
||||
}
|
||||
return err;
|
||||
} // MacFileHelpers::CreateFolderInFolder
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void MacFileHelpers::EnsureAliasHaven()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// Alias Haven is a directory in which we never resolve aliases.
|
||||
if (sAliasHavenVRefNum != 0)
|
||||
return;
|
||||
|
||||
|
||||
FSSpec temp;
|
||||
if (FindFolder(0, kTemporaryFolderType, true, & temp.vRefNum, &temp.parID) == noErr)
|
||||
{
|
||||
CreateFolderInFolder(
|
||||
temp.vRefNum, // Parent directory/volume
|
||||
temp.parID,
|
||||
kAliasHavenFolderName, // Name of the new folder
|
||||
sAliasHavenVRefNum, // Volume of the created folder
|
||||
sAliasHavenDirID);
|
||||
}
|
||||
} // MacFileHelpers::EnsureAliasHaven
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
bool MacFileHelpers::IsAliasSafe(const FSSpec& inSpec)
|
||||
// Returns true if the alias is in the alias haven directory, or if alias resolution
|
||||
// has been turned off.
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return sNoResolve
|
||||
|| (inSpec.parID == sAliasHavenDirID && inSpec.vRefNum == sAliasHavenVRefNum);
|
||||
} // MacFileHelpers::IsAliasSafe
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
OSErr MacFileHelpers::ResolveAliasFile(FSSpec& inOutSpec, Boolean& wasAliased)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
wasAliased = false;
|
||||
if (IsAliasSafe(inOutSpec))
|
||||
return noErr;
|
||||
Boolean dummy;
|
||||
return ::ResolveAliasFile(&inOutSpec, TRUE, &dummy, &wasAliased);
|
||||
} // MacFileHelpers::ResolveAliasFile
|
||||
|
||||
//-----------------------------------
|
||||
OSErr MacFileHelpers::FSSpecFromFullUnixPath(
|
||||
const char * unixPath,
|
||||
FSSpec& outSpec,
|
||||
Boolean resolveAlias,
|
||||
Boolean allowPartial,
|
||||
Boolean createDirs)
|
||||
// File spec from URL. Reverses GetURLFromFileSpec
|
||||
// Its input is only the <path> part of the URL
|
||||
// JRM 97/01/08 changed this so that if it's a partial path (doesn't start with '/'),
|
||||
// then it is combined with inOutSpec's vRefNum and parID to form a new spec.
|
||||
//-----------------------------------
|
||||
{
|
||||
if (unixPath == NULL)
|
||||
return badFidErr;
|
||||
char* macPath = MacPathFromUnixPath(unixPath);
|
||||
if (!macPath)
|
||||
return memFullErr;
|
||||
|
||||
OSErr err = noErr;
|
||||
if (!allowPartial)
|
||||
{
|
||||
NS_ASSERTION(*unixPath == '/' /*full path*/, "Not a full Unix path!");
|
||||
}
|
||||
err = FSSpecFromPathname(macPath, outSpec, createDirs);
|
||||
if (err == fnfErr)
|
||||
err = noErr;
|
||||
Boolean dummy;
|
||||
if (err == noErr && resolveAlias) // Added
|
||||
err = MacFileHelpers::ResolveAliasFile(outSpec, dummy);
|
||||
delete [] macPath;
|
||||
NS_ASSERTION(err==noErr||err==fnfErr||err==dirNFErr||err==nsvErr, "Not a path!");
|
||||
return err;
|
||||
} // MacFileHelpers::FSSpecFromLocalUnixPath
|
||||
|
||||
//-----------------------------------
|
||||
char* MacFileHelpers::PathNameFromFSSpec( const FSSpec& inSpec, Boolean wantLeafName )
|
||||
// Returns a full pathname to the given file
|
||||
// Returned value is allocated with new [], and must be freed with delete []
|
||||
// This is taken from FSpGetFullPath in MoreFiles, except that we need to tolerate
|
||||
// fnfErr.
|
||||
//-----------------------------------
|
||||
{
|
||||
char* result = nil;
|
||||
OSErr err = noErr;
|
||||
|
||||
short fullPathLength = 0;
|
||||
Handle fullPath = NULL;
|
||||
|
||||
FSSpec tempSpec = inSpec;
|
||||
if ( tempSpec.parID == fsRtParID )
|
||||
{
|
||||
/* The object is a volume */
|
||||
|
||||
/* Add a colon to make it a full pathname */
|
||||
tempSpec.name[++tempSpec.name[0]] = ':';
|
||||
|
||||
/* We're done */
|
||||
err = PtrToHand(&tempSpec.name[1], &fullPath, tempSpec.name[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The object isn't a volume */
|
||||
|
||||
CInfoPBRec pb = { 0 };
|
||||
Str63 dummyFileName;
|
||||
MacFileHelpers::PLstrcpy(dummyFileName, "\pG'day!");
|
||||
|
||||
/* Is the object a file or a directory? */
|
||||
pb.dirInfo.ioNamePtr = (! tempSpec.name[0]) ? (StringPtr)dummyFileName : tempSpec.name;
|
||||
pb.dirInfo.ioVRefNum = tempSpec.vRefNum;
|
||||
pb.dirInfo.ioDrDirID = tempSpec.parID;
|
||||
pb.dirInfo.ioFDirIndex = 0;
|
||||
err = PBGetCatInfoSync(&pb);
|
||||
if ( err == noErr || err == fnfErr)
|
||||
{
|
||||
// if the object is a directory, append a colon so full pathname ends with colon
|
||||
// Beware of the "illegal spec" case that Netscape uses (empty name string). In
|
||||
// this case, we don't want the colon.
|
||||
if ( err == noErr && tempSpec.name[0] && (pb.hFileInfo.ioFlAttrib & ioDirMask) != 0 )
|
||||
{
|
||||
++tempSpec.name[0];
|
||||
tempSpec.name[tempSpec.name[0]] = ':';
|
||||
}
|
||||
|
||||
/* Put the object name in first */
|
||||
err = PtrToHand(&tempSpec.name[1], &fullPath, tempSpec.name[0]);
|
||||
if ( err == noErr )
|
||||
{
|
||||
/* Get the ancestor directory names */
|
||||
pb.dirInfo.ioNamePtr = tempSpec.name;
|
||||
pb.dirInfo.ioVRefNum = tempSpec.vRefNum;
|
||||
pb.dirInfo.ioDrParID = tempSpec.parID;
|
||||
do /* loop until we have an error or find the root directory */
|
||||
{
|
||||
pb.dirInfo.ioFDirIndex = -1;
|
||||
pb.dirInfo.ioDrDirID = pb.dirInfo.ioDrParID;
|
||||
err = PBGetCatInfoSync(&pb);
|
||||
if ( err == noErr )
|
||||
{
|
||||
/* Append colon to directory name */
|
||||
++tempSpec.name[0];
|
||||
tempSpec.name[tempSpec.name[0]] = ':';
|
||||
|
||||
/* Add directory name to beginning of fullPath */
|
||||
(void) Munger(fullPath, 0, NULL, 0, &tempSpec.name[1], tempSpec.name[0]);
|
||||
err = MemError();
|
||||
}
|
||||
} while ( err == noErr && pb.dirInfo.ioDrDirID != fsRtDirID );
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( err != noErr && err != fnfErr)
|
||||
goto Clean;
|
||||
|
||||
fullPathLength = GetHandleSize(fullPath);
|
||||
err = noErr;
|
||||
int allocSize = 1 + fullPathLength;
|
||||
// We only want the leaf name if it's the root directory or wantLeafName is true.
|
||||
if (inSpec.parID != fsRtParID && !wantLeafName)
|
||||
allocSize -= inSpec.name[0];
|
||||
result = new char[allocSize];
|
||||
if (!result)
|
||||
goto Clean;
|
||||
memcpy(result, *fullPath, allocSize - 1);
|
||||
result[ allocSize - 1 ] = 0;
|
||||
Clean:
|
||||
if (fullPath)
|
||||
DisposeHandle(fullPath);
|
||||
NS_ASSERTION(result, "Out of memory"); // OOPS! very bad.
|
||||
return result;
|
||||
} // MacFileHelpers::PathNameFromFSSpec
|
||||
|
||||
//========================================================================================
|
||||
// Macintosh nsNativeFileSpec implementation
|
||||
//========================================================================================
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsNativeFileSpec::nsNativeFileSpec()
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mError(noErr)
|
||||
{
|
||||
mSpec.name[0] = '\0';
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsNativeFileSpec::nsNativeFileSpec(const nsNativeFileSpec& inSpec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mSpec(inSpec.mSpec)
|
||||
, mError(inSpec.Error())
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsNativeFileSpec::nsNativeFileSpec(const char* inString, bool inCreateDirs)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mError = MacFileHelpers::FSSpecFromFullUnixPath(
|
||||
inString, mSpec, true, true, inCreateDirs);
|
||||
// allow a partial path, create as necessary
|
||||
if (mError == fnfErr)
|
||||
mError = noErr;
|
||||
} // nsNativeFileSpec::nsNativeFileSpec
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsNativeFileSpec::nsNativeFileSpec(
|
||||
short vRefNum,
|
||||
long parID,
|
||||
ConstStr255Param name)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mError = ::FSMakeFSSpec(vRefNum, parID, name, &mSpec);
|
||||
if (mError == fnfErr)
|
||||
mError = noErr;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsNativeFileSpec::nsNativeFileSpec(const nsFilePath& inPath)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
*this = inPath.GetNativeSpec();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsBasicOutStream& operator << (nsBasicOutStream& s, const nsNativeFileSpec& spec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
s << spec.mSpec.vRefNum << ", " << spec.mSpec.parID << ", \"";
|
||||
s.write((const char*)&spec.mSpec.name[1], spec.mSpec.name[0]);
|
||||
return s << "\"";
|
||||
} // nsOutputFileStream& operator << (nsOutputFileStream&, const nsNativeFileSpec&)
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsNativeFileSpec::operator = (const char* inString)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mError = MacFileHelpers::FSSpecFromFullUnixPath(inString, mSpec, true);
|
||||
} // nsNativeFileSpec::operator =
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsNativeFileSpec::operator = (const nsNativeFileSpec& inSpec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mSpec = inSpec.mSpec;
|
||||
mError = inSpec.Error();
|
||||
} // nsNativeFileSpec::operator =
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsNativeFileSpec::operator = (const nsFilePath& inPath)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
*this = inPath.GetNativeSpec();
|
||||
} // nsNativeFileSpec::operator =
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
bool nsNativeFileSpec::Exists() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
FSSpec temp;
|
||||
return ::FSMakeFSSpec(mSpec.vRefNum, mSpec.parID, mSpec.name, &temp) == noErr;
|
||||
} // nsNativeFileSpec::operator =
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsNativeFileSpec::SetLeafName(const char* inLeafName)
|
||||
// In leaf name can actually be a partial path...
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// what about long relative paths? Hmm?
|
||||
Str255 partialPath;
|
||||
MacFileHelpers::PLstrcpy(partialPath, inLeafName);
|
||||
mError = FSMakeFSSpec(mSpec.vRefNum, mSpec.parID, partialPath, &mSpec);
|
||||
} // nsNativeFileSpec::SetLeafName
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
char* nsNativeFileSpec::GetLeafName() const
|
||||
// Result needs to be delete[]ed.
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
char leaf[64];
|
||||
memcpy(leaf, &mSpec.name[1], mSpec.name[0]);
|
||||
leaf[mSpec.name[0]] = '\0';
|
||||
return nsFileSpecHelpers::StringDup(leaf);
|
||||
} // nsNativeFileSpec::GetLeafName
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsNativeFileSpec::MakeAliasSafe()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mError = MacFileHelpers::MakeAliasSafe(mSpec);
|
||||
} // nsNativeFileSpec::MakeAliasSafe
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsNativeFileSpec::MakeUnique(ConstStr255Param inSuggestedLeafName)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (inSuggestedLeafName[0] > 0)
|
||||
MacFileHelpers::PLstrcpy(mSpec.name, inSuggestedLeafName);
|
||||
|
||||
MakeUnique();
|
||||
} // nsNativeFileSpec::MakeUnique
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsNativeFileSpec::ResolveAlias(bool& wasAliased)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
Boolean wasAliased2;
|
||||
mError = MacFileHelpers::ResolveAliasFile(mSpec, wasAliased2);
|
||||
wasAliased = (wasAliased2 != false);
|
||||
} // nsNativeFileSpec::ResolveAlias
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
bool nsNativeFileSpec::IsFile() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
long dirID;
|
||||
Boolean isDirectory;
|
||||
return (noErr == FSpGetDirectoryID(&mSpec, &dirID, &isDirectory) && !isDirectory);
|
||||
} // nsNativeFileSpec::IsFile
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
bool nsNativeFileSpec::IsDirectory() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
long dirID;
|
||||
Boolean isDirectory;
|
||||
return (noErr == FSpGetDirectoryID(&mSpec, &dirID, &isDirectory) && isDirectory);
|
||||
} // nsNativeFileSpec::IsDirectory
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsNativeFileSpec::GetParent(nsNativeFileSpec& outSpec) const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (mError == noErr)
|
||||
outSpec.mError = FSMakeFSSpec(mSpec.vRefNum, mSpec.parID, NULL, outSpec);
|
||||
} // nsNativeFileSpec::GetParent
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsNativeFileSpec::operator += (const char* inRelativePath)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
long dirID;
|
||||
Boolean isDirectory;
|
||||
mError = FSpGetDirectoryID(&mSpec, &dirID, &isDirectory);
|
||||
if (mError == noErr && isDirectory)
|
||||
{
|
||||
mError = FSMakeFSSpec(mSpec.vRefNum, dirID, "\pG'day", *this);
|
||||
if (mError == noErr)
|
||||
SetLeafName(inRelativePath);
|
||||
}
|
||||
} // nsNativeFileSpec::operator +=
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsNativeFileSpec::CreateDirectory(int /* unix mode */)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
long ignoredDirID;
|
||||
FSpDirCreate(&mSpec, smCurrentScript, &ignoredDirID);
|
||||
} // nsNativeFileSpec::CreateDirectory
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsNativeFileSpec::Delete(bool inRecursive)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (inRecursive)
|
||||
{
|
||||
// MoreFilesExtras
|
||||
mError = DeleteDirectory(
|
||||
mSpec.vRefNum,
|
||||
mSpec.parID,
|
||||
const_cast<unsigned char*>(mSpec.name));
|
||||
}
|
||||
else
|
||||
mError = FSpDelete(&mSpec);
|
||||
} // nsNativeFileSpec::Delete
|
||||
|
||||
|
||||
//========================================================================================
|
||||
// Macintosh nsFilePath implementation
|
||||
//========================================================================================
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFilePath::nsFilePath(const char* inString, bool inCreateDirs)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mPath(nsnull)
|
||||
, mNativeFileSpec(inString, inCreateDirs)
|
||||
{
|
||||
// Make canonical and absolute.
|
||||
char * path = MacFileHelpers::PathNameFromFSSpec( mNativeFileSpec, TRUE );
|
||||
mPath = MacFileHelpers::EncodeMacPath(path, true, true);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFilePath::nsFilePath(const nsNativeFileSpec& inSpec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mNativeFileSpec(inSpec)
|
||||
{
|
||||
char * path = MacFileHelpers::PathNameFromFSSpec( inSpec.mSpec, TRUE );
|
||||
mPath = MacFileHelpers::EncodeMacPath(path, true, true);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFilePath::operator = (const nsNativeFileSpec& inSpec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
delete [] mPath;
|
||||
char * path = MacFileHelpers::PathNameFromFSSpec( inSpec.mSpec, TRUE );
|
||||
mPath = MacFileHelpers::EncodeMacPath(path, true, true);
|
||||
mNativeFileSpec = inSpec;
|
||||
} // nsFilePath::operator =
|
||||
|
||||
//========================================================================================
|
||||
// nsFileURL implementation
|
||||
//========================================================================================
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileURL::nsFileURL(const char* inString, bool inCreateDirs)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mURL(nsnull)
|
||||
, mNativeFileSpec(inString + kFileURLPrefixLength, inCreateDirs)
|
||||
{
|
||||
NS_ASSERTION(strstr(inString, kFileURLPrefix) == inString, "Not a URL!");
|
||||
// Make canonical and absolute.
|
||||
char* path = MacFileHelpers::PathNameFromFSSpec( mNativeFileSpec, TRUE );
|
||||
char* escapedPath = MacFileHelpers::EncodeMacPath(path, true, true);
|
||||
mURL = nsFileSpecHelpers::StringDup(kFileURLPrefix, kFileURLPrefixLength + strlen(escapedPath));
|
||||
strcat(mURL, escapedPath);
|
||||
delete [] escapedPath;
|
||||
} // nsFileURL::nsFileURL
|
||||
|
||||
//========================================================================================
|
||||
// nsDirectoryIterator
|
||||
//========================================================================================
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsDirectoryIterator::nsDirectoryIterator(
|
||||
const nsNativeFileSpec& inDirectory
|
||||
, int inIterateDirection)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mCurrent(inDirectory)
|
||||
, mExists(false)
|
||||
, mIndex(-1)
|
||||
{
|
||||
CInfoPBRec pb;
|
||||
DirInfo* dipb = (DirInfo*)&pb;
|
||||
// Sorry about this, there seems to be a bug in CWPro 4:
|
||||
const FSSpec& inSpec = inDirectory.nsNativeFileSpec::operator const FSSpec&();
|
||||
Str255 outName;
|
||||
MacFileHelpers::PLstrcpy(outName, inSpec.name);
|
||||
pb.hFileInfo.ioNamePtr = outName;
|
||||
pb.hFileInfo.ioVRefNum = inSpec.vRefNum;
|
||||
pb.hFileInfo.ioDirID = inSpec.parID;
|
||||
pb.hFileInfo.ioFDirIndex = 0; // use ioNamePtr and ioDirID
|
||||
|
||||
OSErr err = PBGetCatInfoSync( &pb );
|
||||
|
||||
// test that we have got a directory back, not a file
|
||||
if ( (err != noErr ) || !( dipb->ioFlAttrib & 0x0010 ) )
|
||||
return;
|
||||
// Sorry about this, there seems to be a bug in CWPro 4:
|
||||
FSSpec& currentSpec = mCurrent.nsNativeFileSpec::operator FSSpec&();
|
||||
currentSpec.vRefNum = inSpec.vRefNum;
|
||||
currentSpec.parID = dipb->ioDrDirID;
|
||||
mMaxIndex = pb.dirInfo.ioDrNmFls;
|
||||
if (inIterateDirection > 0)
|
||||
{
|
||||
mIndex = 0; // ready to increment
|
||||
++(*this); // the pre-increment operator
|
||||
}
|
||||
else
|
||||
{
|
||||
mIndex = mMaxIndex + 1; // ready to decrement
|
||||
--(*this); // the pre-decrement operator
|
||||
}
|
||||
} // nsDirectoryIterator::nsDirectoryIterator
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
OSErr nsDirectoryIterator::SetToIndex()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
CInfoPBRec cipb;
|
||||
DirInfo *dipb=(DirInfo *)&cipb;
|
||||
Str255 objectName;
|
||||
dipb->ioCompletion = NULL;
|
||||
dipb->ioFDirIndex = mIndex;
|
||||
// Sorry about this, there seems to be a bug in CWPro 4:
|
||||
FSSpec& currentSpec = mCurrent.nsNativeFileSpec::operator FSSpec&();
|
||||
dipb->ioVRefNum = currentSpec.vRefNum; /* Might need to use vRefNum, not sure*/
|
||||
dipb->ioDrDirID = currentSpec.parID;
|
||||
dipb->ioNamePtr = objectName;
|
||||
OSErr err = PBGetCatInfoSync(&cipb);
|
||||
if (err == noErr)
|
||||
err = FSMakeFSSpec(currentSpec.vRefNum, currentSpec.parID, objectName, ¤tSpec);
|
||||
mExists = err == noErr;
|
||||
return err;
|
||||
} // nsDirectoryIterator::SetToIndex()
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsDirectoryIterator& nsDirectoryIterator::operator -- ()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mExists = false;
|
||||
while (--mIndex > 0)
|
||||
{
|
||||
OSErr err = SetToIndex();
|
||||
if (err == noErr)
|
||||
break;
|
||||
}
|
||||
return *this;
|
||||
} // nsDirectoryIterator::operator --
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsDirectoryIterator& nsDirectoryIterator::operator ++ ()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mExists = false;
|
||||
if (mIndex >= 0) // probably trying to use a file as a directory!
|
||||
while (++mIndex <= mMaxIndex)
|
||||
{
|
||||
OSErr err = SetToIndex();
|
||||
if (err == noErr)
|
||||
break;
|
||||
}
|
||||
return *this;
|
||||
} // nsDirectoryIterator::operator ++
|
||||
@@ -1,147 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsRepeater.h"
|
||||
|
||||
Repeater* Repeater::sRepeaters = 0;
|
||||
Repeater* Repeater::sIdlers = 0;
|
||||
|
||||
Repeater::Repeater()
|
||||
{
|
||||
mRepeating = false;
|
||||
mIdling = false;
|
||||
mPrevRptr = 0;
|
||||
mNextRptr = 0;
|
||||
mPrevIdlr = 0;
|
||||
mNextIdlr = 0;
|
||||
}
|
||||
|
||||
Repeater::~Repeater()
|
||||
{
|
||||
if (mRepeating) RemoveFromRepeatList();
|
||||
if (mIdling) RemoveFromIdleList();
|
||||
}
|
||||
|
||||
// protected helper functs
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void Repeater::AddToRepeatList()
|
||||
{
|
||||
if (sRepeaters)
|
||||
{
|
||||
sRepeaters->mPrevRptr = this;
|
||||
mNextRptr = sRepeaters;
|
||||
}
|
||||
sRepeaters = this;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void Repeater::RemoveFromRepeatList()
|
||||
{
|
||||
if (sRepeaters == this) sRepeaters = mNextRptr;
|
||||
if (mPrevRptr) mPrevRptr->mNextRptr = mNextRptr;
|
||||
if (mNextRptr) mNextRptr->mPrevRptr = mPrevRptr;
|
||||
mPrevRptr = 0;
|
||||
mNextRptr = 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void Repeater::AddToIdleList()
|
||||
{
|
||||
if (sIdlers)
|
||||
{
|
||||
sIdlers->mPrevIdlr = this;
|
||||
mNextIdlr = sIdlers;
|
||||
}
|
||||
sIdlers = this;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void Repeater::RemoveFromIdleList()
|
||||
{
|
||||
if (sIdlers == this) sIdlers = mNextIdlr;
|
||||
if (mPrevIdlr) mPrevIdlr->mNextIdlr = mNextIdlr;
|
||||
if (mNextIdlr) mNextIdlr->mPrevIdlr = mPrevIdlr;
|
||||
mPrevIdlr = 0;
|
||||
mNextIdlr = 0;
|
||||
}
|
||||
|
||||
// repeater methods
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
void Repeater::StartRepeating()
|
||||
{
|
||||
if (!mRepeating)
|
||||
{
|
||||
AddToRepeatList();
|
||||
mRepeating = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Repeater::StopRepeating()
|
||||
{
|
||||
if (mRepeating)
|
||||
{
|
||||
RemoveFromRepeatList();
|
||||
mRepeating = false;
|
||||
}
|
||||
}
|
||||
|
||||
void Repeater::DoRepeaters(const EventRecord &aMacEvent)
|
||||
{
|
||||
Repeater* theRepeater = sRepeaters;
|
||||
while (theRepeater)
|
||||
{
|
||||
theRepeater->RepeatAction(aMacEvent);
|
||||
theRepeater = theRepeater->mNextRptr;
|
||||
}
|
||||
}
|
||||
|
||||
// idler methods
|
||||
|
||||
void Repeater::StartIdling()
|
||||
{
|
||||
if (!mIdling)
|
||||
{
|
||||
AddToIdleList();
|
||||
mIdling = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Repeater::StopIdling()
|
||||
{
|
||||
if (mIdling)
|
||||
{
|
||||
RemoveFromIdleList();
|
||||
mIdling = false;
|
||||
}
|
||||
}
|
||||
|
||||
void Repeater::DoIdlers(const EventRecord &aMacEvent)
|
||||
{
|
||||
Repeater* theIdler = sIdlers;
|
||||
while (theIdler)
|
||||
{
|
||||
theIdler->RepeatAction(aMacEvent);
|
||||
theIdler = theIdler->mNextIdlr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -20,297 +20,263 @@
|
||||
// Mac implementation of the nsITimer interface
|
||||
//
|
||||
|
||||
// nsMacTimerPeriodical idles,
|
||||
|
||||
|
||||
#include "nsITimer.h"
|
||||
#include "nsITimerCallback.h"
|
||||
#include "prlog.h"
|
||||
#include "nsRepeater.h"
|
||||
|
||||
#include <list.h>
|
||||
#include <Events.h>
|
||||
|
||||
|
||||
#include <LPeriodical.h>
|
||||
#include <LArray.h>
|
||||
#include <LArrayIterator.h>
|
||||
#include <LComparator.h>
|
||||
|
||||
#pragma mark class TimerImpl
|
||||
|
||||
//========================================================================================
|
||||
class TimerImpl : public nsITimer
|
||||
//
|
||||
// TimerImpl implements nsITimer API
|
||||
//========================================================================================
|
||||
//
|
||||
class TimerImpl : public nsITimer
|
||||
{
|
||||
private:
|
||||
nsTimerCallbackFunc mCallbackFunc;
|
||||
nsITimerCallback * mCallbackObject;
|
||||
void * mClosure;
|
||||
PRUint32 mDelay;
|
||||
PRUint32 mFireTime; // Timer should fire when TickCount >= this number
|
||||
|
||||
public:
|
||||
private:
|
||||
nsTimerCallbackFunc mCallbackFunc;
|
||||
nsITimerCallback * mCallbackObject;
|
||||
void * mClosure;
|
||||
PRUint32 mDelay;
|
||||
UInt32 mFireTime; // Timer should fire when TickCount >= this number
|
||||
|
||||
public:
|
||||
|
||||
// constructors
|
||||
// constructors
|
||||
|
||||
TimerImpl();
|
||||
TimerImpl();
|
||||
|
||||
virtual ~TimerImpl();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
virtual ~TimerImpl(){};
|
||||
|
||||
PRUint32 GetFireTime() const { return mFireTime; }
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
void Fire();
|
||||
UInt32 GetFireTime() { return mFireTime; }
|
||||
|
||||
// nsITimer overrides
|
||||
void Fire();
|
||||
|
||||
virtual nsresult Init(nsTimerCallbackFunc aFunc,
|
||||
void *aClosure,
|
||||
PRUint32 aDelay);
|
||||
// nsITimer overrides
|
||||
|
||||
virtual nsresult Init(nsITimerCallback *aCallback,
|
||||
PRUint32 aDelay);
|
||||
virtual nsresult Init(nsTimerCallbackFunc aFunc,
|
||||
void *aClosure,
|
||||
PRUint32 aDelay);
|
||||
|
||||
virtual void Cancel();
|
||||
virtual nsresult Init(nsITimerCallback *aCallback,
|
||||
PRUint32 aDelay);
|
||||
|
||||
virtual PRUint32 GetDelay();
|
||||
virtual void Cancel();
|
||||
|
||||
virtual void SetDelay(PRUint32 aDelay);
|
||||
virtual PRUint32 GetDelay();
|
||||
|
||||
virtual void SetDelay(PRUint32 aDelay);
|
||||
|
||||
virtual void* GetClosure();
|
||||
|
||||
#if DEBUG
|
||||
enum {
|
||||
eGoodTimerSignature = 'Barf',
|
||||
eDeletedTimerSignature = 'oops'
|
||||
};
|
||||
|
||||
Boolean IsGoodTimer() const { return (mSignature == eGoodTimerSignature); }
|
||||
#endif
|
||||
|
||||
private:
|
||||
// Calculates mFireTime too
|
||||
void SetDelaySelf( PRUint32 aDelay );
|
||||
|
||||
#if DEBUG
|
||||
UInt32 mSignature;
|
||||
#endif
|
||||
|
||||
private:
|
||||
// Calculates mFireTime too
|
||||
void SetDelaySelf( PRUint32 aDelay );
|
||||
};
|
||||
|
||||
#pragma mark class TimerPeriodical
|
||||
//
|
||||
// TimerPeriodical is a singleton LPeriodical subclass that fires
|
||||
// off TimerImpl. The firing is done on idle
|
||||
//
|
||||
class TimerPeriodical : public LPeriodical
|
||||
{
|
||||
static TimerPeriodical * gPeriodical;
|
||||
|
||||
LArray mTimers; // List of TimerImpl *
|
||||
|
||||
public:
|
||||
// Returns the singleton instance
|
||||
static TimerPeriodical * GetPeriodical();
|
||||
|
||||
//========================================================================================
|
||||
class TimerPeriodical : public Repeater
|
||||
// TimerPeriodical is a singleton Repeater subclass that fires
|
||||
// off TimerImpl. The firing is done on idle.
|
||||
//========================================================================================
|
||||
{
|
||||
static TimerPeriodical * gPeriodical;
|
||||
|
||||
list<TimerImpl*> mTimers;
|
||||
|
||||
public:
|
||||
// Returns the singleton instance
|
||||
static TimerPeriodical * GetPeriodical();
|
||||
TimerPeriodical();
|
||||
|
||||
TimerPeriodical();
|
||||
virtual ~TimerPeriodical();
|
||||
|
||||
nsresult AddTimer( TimerImpl * aTimer);
|
||||
|
||||
nsresult RemoveTimer( TimerImpl * aTimer);
|
||||
|
||||
virtual ~TimerPeriodical();
|
||||
|
||||
virtual void RepeatAction( const EventRecord &inMacEvent);
|
||||
|
||||
nsresult AddTimer( TimerImpl * aTimer);
|
||||
|
||||
nsresult RemoveTimer( TimerImpl * aTimer);
|
||||
virtual void SpendTime( const EventRecord &inMacEvent);
|
||||
};
|
||||
|
||||
#pragma mark class TimerImplComparator
|
||||
//
|
||||
// TimerImplComparator compares two TimerImpl
|
||||
//
|
||||
class TimerImplComparator : public LComparator
|
||||
{
|
||||
virtual Int32 Compare(
|
||||
const void* inItemOne,
|
||||
const void* inItemTwo,
|
||||
Uint32 inSizeOne,
|
||||
Uint32 inSizeTwo) const;
|
||||
};
|
||||
|
||||
|
||||
//========================================================================================
|
||||
//
|
||||
// TimerImpl implementation
|
||||
//========================================================================================
|
||||
//
|
||||
|
||||
static NS_DEFINE_IID(kITimerIID, NS_ITIMER_IID);
|
||||
NS_IMPL_ISUPPORTS(TimerImpl, kITimerIID)
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TimerImpl::TimerImpl()
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mCallbackFunc(nsnull)
|
||||
, mCallbackObject(nsnull)
|
||||
, mClosure(nsnull)
|
||||
, mDelay(0)
|
||||
, mFireTime(0)
|
||||
#if DEBUG
|
||||
, mSignature(eGoodTimerSignature)
|
||||
#endif
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
NS_INIT_REFCNT();
|
||||
mCallbackFunc = NULL;
|
||||
mCallbackObject = NULL;
|
||||
mClosure = NULL;
|
||||
mDelay = 0;
|
||||
mFireTime = 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
TimerImpl::~TimerImpl()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
Cancel();
|
||||
NS_IF_RELEASE(mCallbackObject);
|
||||
#if DEBUG
|
||||
mSignature = eDeletedTimerSignature;
|
||||
#endif
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsresult TimerImpl::Init(nsTimerCallbackFunc aFunc,
|
||||
void *aClosure,
|
||||
PRUint32 aDelay)
|
||||
//----------------------------------------------------------------------------------------
|
||||
void *aClosure,
|
||||
PRUint32 aDelay)
|
||||
{
|
||||
mCallbackFunc = aFunc;
|
||||
mClosure = aClosure;
|
||||
SetDelaySelf(aDelay);
|
||||
return TimerPeriodical::GetPeriodical()->AddTimer(this);
|
||||
mCallbackFunc = aFunc;
|
||||
mClosure = aClosure;
|
||||
SetDelaySelf(aDelay);
|
||||
return TimerPeriodical::GetPeriodical()->AddTimer(this);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsresult TimerImpl::Init(nsITimerCallback *aCallback,
|
||||
PRUint32 aDelay)
|
||||
//----------------------------------------------------------------------------------------
|
||||
PRUint32 aDelay)
|
||||
{
|
||||
NS_ADDREF(aCallback);
|
||||
mCallbackObject = aCallback;
|
||||
SetDelaySelf(aDelay);
|
||||
return TimerPeriodical::GetPeriodical()->AddTimer(this);
|
||||
mCallbackObject = aCallback;
|
||||
SetDelaySelf(aDelay);
|
||||
return TimerPeriodical::GetPeriodical()->AddTimer(this);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void TimerImpl::Cancel()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
|
||||
TimerPeriodical::GetPeriodical()->RemoveTimer(this);
|
||||
TimerPeriodical::GetPeriodical()->RemoveTimer(this);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
PRUint32 TimerImpl::GetDelay()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return mDelay;
|
||||
return mDelay;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void TimerImpl::SetDelay(PRUint32 aDelay)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
SetDelaySelf(aDelay);
|
||||
SetDelaySelf(aDelay);
|
||||
// Make sure that timer was sorted
|
||||
NS_ADDREF(this);
|
||||
TimerPeriodical::GetPeriodical()->RemoveTimer(this);
|
||||
TimerPeriodical::GetPeriodical()->AddTimer(this);
|
||||
NS_RELEASE(this);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void* TimerImpl::GetClosure()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return mClosure;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void TimerImpl::Fire()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
NS_PRECONDITION(mRefCnt > 0, "Firing a disposed Timer!");
|
||||
if (mCallbackFunc != NULL)
|
||||
{
|
||||
(*mCallbackFunc)(this, mClosure);
|
||||
if (mCallbackFunc != NULL) {
|
||||
(*mCallbackFunc)(this, mClosure);
|
||||
}
|
||||
else if (mCallbackObject != NULL)
|
||||
{
|
||||
nsITimerCallback* object = mCallbackObject;
|
||||
mCallbackObject = nsnull;
|
||||
// because the Notify call will release it.
|
||||
// We will release again it in the destructor if
|
||||
// it is not null when we go away!
|
||||
object->Notify(this); // Fire the timer
|
||||
else if (mCallbackObject != NULL) {
|
||||
mCallbackObject->Notify(this); // Fire the timer
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void TimerImpl::SetDelaySelf( PRUint32 aDelay )
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
|
||||
mDelay = aDelay;
|
||||
mFireTime = TickCount() + (mDelay * 3) / 50; // We need mFireTime in ticks (1/60th)
|
||||
// but aDelay is in 1000th (60/1000 = 3/50)
|
||||
mDelay = aDelay;
|
||||
mFireTime = TickCount() + (mDelay * 3) / 50; // We need mFireTime in ticks (1/60th)
|
||||
// but aDelay is in 1000th (60/1000 = 3/50)
|
||||
}
|
||||
|
||||
TimerPeriodical * TimerPeriodical::gPeriodical = nsnull;
|
||||
TimerPeriodical * TimerPeriodical::gPeriodical = NULL;
|
||||
|
||||
TimerPeriodical * TimerPeriodical::GetPeriodical()
|
||||
{
|
||||
if (gPeriodical == NULL)
|
||||
gPeriodical = new TimerPeriodical();
|
||||
return gPeriodical;
|
||||
if (gPeriodical == NULL)
|
||||
gPeriodical = new TimerPeriodical();
|
||||
return gPeriodical;
|
||||
}
|
||||
|
||||
TimerPeriodical::TimerPeriodical()
|
||||
{
|
||||
mTimers.SetComparator( new TimerImplComparator() );
|
||||
mTimers.SetKeepSorted( true );
|
||||
}
|
||||
|
||||
TimerPeriodical::~TimerPeriodical()
|
||||
{
|
||||
PR_ASSERT(mTimers.size() == 0);
|
||||
PR_ASSERT(mTimers.GetCount() == 0);
|
||||
}
|
||||
|
||||
nsresult TimerPeriodical::AddTimer( TimerImpl * aTimer)
|
||||
{
|
||||
// make sure it's not already there
|
||||
mTimers.remove(aTimer);
|
||||
mTimers.push_back(aTimer);
|
||||
StartRepeating();
|
||||
return NS_OK;
|
||||
try
|
||||
{
|
||||
NS_ADDREF(aTimer);
|
||||
mTimers.AddItem( &aTimer );
|
||||
StartRepeating();
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult TimerPeriodical::RemoveTimer( TimerImpl * aTimer)
|
||||
{
|
||||
mTimers.remove(aTimer);
|
||||
if ( mTimers.size() == 0 )
|
||||
StopRepeating();
|
||||
return NS_OK;
|
||||
mTimers.SetComparator(LLongComparator::GetComparator(), false);
|
||||
mTimers.Remove(&aTimer);
|
||||
mTimers.SetComparator(new TimerImplComparator());
|
||||
|
||||
NS_RELEASE( aTimer );
|
||||
if ( mTimers.GetCount() == 0 )
|
||||
StopRepeating();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Called through every event loop
|
||||
// Loops through the list of available timers, and
|
||||
// fires off the appropriate ones
|
||||
void TimerPeriodical::RepeatAction( const EventRecord &inMacEvent)
|
||||
// fires off the available ones
|
||||
void TimerPeriodical::SpendTime( const EventRecord &inMacEvent)
|
||||
{
|
||||
list<TimerImpl*>::iterator iter = mTimers.begin();
|
||||
list<TimerImpl*> fireList;
|
||||
|
||||
while (iter != mTimers.end())
|
||||
{
|
||||
TimerImpl* timer = *iter;
|
||||
|
||||
NS_ASSERTION(timer->IsGoodTimer(), "Bad timer!");
|
||||
|
||||
if (timer->GetFireTime() <= inMacEvent.when)
|
||||
{
|
||||
mTimers.erase(iter++);
|
||||
NS_ADDREF(timer);
|
||||
fireList.push_back(timer);
|
||||
}
|
||||
else
|
||||
{
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
if ( mTimers.size() == 0 )
|
||||
StopRepeating();
|
||||
|
||||
for (iter=fireList.begin(); iter!=fireList.end(); iter++)
|
||||
{
|
||||
(*iter)->Fire();
|
||||
NS_RELEASE(*iter);
|
||||
}
|
||||
LArrayIterator iter(mTimers);
|
||||
TimerImpl * timer;
|
||||
while (iter.Next(&timer))
|
||||
{
|
||||
if (timer->GetFireTime() <= inMacEvent.when)
|
||||
{
|
||||
//NS_ADDREF(timer);
|
||||
RemoveTimer(timer);
|
||||
timer->Fire();
|
||||
//NS_RELEASE(timer);
|
||||
}
|
||||
else
|
||||
break; // Items are sorted, so we do not need to iterate until the end
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// class TimerImplComparator implementation
|
||||
//
|
||||
Int32 TimerImplComparator::Compare(
|
||||
const void* inItemOne,
|
||||
const void* inItemTwo,
|
||||
Uint32 inSizeOne,
|
||||
Uint32 inSizeTwo) const
|
||||
{
|
||||
return (( TimerImpl *) inItemOne)->GetFireTime() - (( TimerImpl *) inItemTwo)->GetFireTime();
|
||||
}
|
||||
|
||||
NS_BASE nsresult NS_NewTimer(nsITimer** aInstancePtrResult)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
|
||||
@@ -26,39 +26,31 @@ LIBRARY_NAME=raptorbase
|
||||
CPPSRCS = \
|
||||
nsArena.cpp \
|
||||
nsAtomTable.cpp \
|
||||
nsBaseDLL.cpp \
|
||||
nsBTree.cpp \
|
||||
nsByteBuffer.cpp \
|
||||
nsCRT.cpp \
|
||||
nsDeque.cpp \
|
||||
nsProperties.cpp \
|
||||
nsRBTree.cpp \
|
||||
nsSizeOfHandler.cpp \
|
||||
nsString.cpp \
|
||||
nsUnicharBuffer.cpp \
|
||||
nsUnicharInputStream.cpp \
|
||||
nsVoidArray.cpp \
|
||||
nsFileSpec.cpp \
|
||||
nsFileStream.cpp \
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS = \
|
||||
.\$(OBJDIR)\nsArena.obj \
|
||||
.\$(OBJDIR)\nsAtomTable.obj \
|
||||
.\$(OBJDIR)\nsBaseDLL.obj \
|
||||
.\$(OBJDIR)\nsBTree.obj \
|
||||
.\$(OBJDIR)\nsByteBuffer.obj \
|
||||
.\$(OBJDIR)\nsCRT.obj \
|
||||
.\$(OBJDIR)\nsDeque.obj \
|
||||
.\$(OBJDIR)\nsProperties.obj \
|
||||
.\$(OBJDIR)\nsRBTree.obj \
|
||||
.\$(OBJDIR)\nsSizeOfHandler.obj \
|
||||
.\$(OBJDIR)\nsString.obj \
|
||||
.\$(OBJDIR)\nsUnicharBuffer.obj \
|
||||
.\$(OBJDIR)\nsUnicharInputStream.obj \
|
||||
.\$(OBJDIR)\nsVoidArray.obj \
|
||||
.\$(OBJDIR)\nsFileSpec.obj \
|
||||
.\$(OBJDIR)\nsFileStream.obj \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS=nscore.h nsIArena.h nsIAtom.h nsIByteBuffer.h \
|
||||
@@ -74,7 +66,7 @@ MODULE=raptor
|
||||
REQUIRES=xpcom netlib raptor
|
||||
|
||||
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\netlib \
|
||||
-I$(PUBLIC)\raptor
|
||||
-I$(PUBLIC)\raptor
|
||||
|
||||
MAKE_OBJ_TYPE = DLL
|
||||
DLLNAME = raptorbase
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
LIBRARY_NAME = gmbasemotif
|
||||
|
||||
MODULE=base
|
||||
|
||||
REQUIRES = xpcom raptor
|
||||
|
||||
DEFINES += -D_IMPL_NS_WIDGET
|
||||
|
||||
CPPSRCS = nsTimer.cpp
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsBaseDLL.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIProperties.h"
|
||||
#include "nsProperties.h"
|
||||
#include "nsRepository.h"
|
||||
|
||||
extern "C" PRInt32 gLockCount = 0;
|
||||
|
||||
NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
|
||||
extern "C" NS_EXPORT nsresult
|
||||
NSRegisterSelf(const char* path)
|
||||
{
|
||||
nsresult ret;
|
||||
|
||||
ret = nsRepository::RegisterFactory(kPropertiesCID, path, PR_TRUE,
|
||||
PR_TRUE);
|
||||
if (NS_FAILED(ret)) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult
|
||||
NSUnregisterSelf(const char* path)
|
||||
{
|
||||
nsresult ret;
|
||||
|
||||
ret = nsRepository::UnregisterFactory(kPropertiesCID, path);
|
||||
if (NS_FAILED(ret)) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult
|
||||
NSGetFactory(const nsCID& aClass, nsISupports* aServMgr, nsIFactory** aFactory)
|
||||
{
|
||||
nsresult res;
|
||||
|
||||
if (!aFactory) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
if (aClass.Equals(kPropertiesCID)) {
|
||||
nsPropertiesFactory *propsFactory = new nsPropertiesFactory();
|
||||
if (!propsFactory) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
res = propsFactory->QueryInterface(kIFactoryIID, (void**) aFactory);
|
||||
if (NS_FAILED(res)) {
|
||||
*aFactory = nsnull;
|
||||
delete propsFactory;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsBaseDLL_h___
|
||||
#define nsBaseDLL_h___
|
||||
|
||||
#include "prtypes.h"
|
||||
|
||||
extern "C" PRInt32 gLockCount;
|
||||
|
||||
#endif /* nsBaseDLL_h___ */
|
||||
@@ -23,25 +23,25 @@
|
||||
|
||||
class ByteBufferImpl : public nsIByteBuffer {
|
||||
public:
|
||||
ByteBufferImpl(PRUint32 aBufferSize);
|
||||
ByteBufferImpl(PRInt32 aBufferSize);
|
||||
~ByteBufferImpl();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
virtual PRUint32 GetLength(void) const;
|
||||
virtual PRUint32 GetBufferSize(void) const;
|
||||
virtual PRInt32 GetLength() const;
|
||||
virtual PRInt32 GetBufferSize() const;
|
||||
virtual char* GetBuffer() const;
|
||||
virtual PRBool Grow(PRUint32 aNewSize);
|
||||
virtual PRBool Grow(PRInt32 aNewSize);
|
||||
virtual PRInt32 Fill(nsresult* aErrorCode, nsIInputStream* aStream,
|
||||
PRUint32 aKeep);
|
||||
PRInt32 aKeep);
|
||||
|
||||
char* mBuffer;
|
||||
PRUint32 mSpace;
|
||||
PRUint32 mLength;
|
||||
PRInt32 mSpace;
|
||||
PRInt32 mLength;
|
||||
};
|
||||
|
||||
ByteBufferImpl::ByteBufferImpl(PRUint32 aBufferSize)
|
||||
ByteBufferImpl::ByteBufferImpl(PRInt32 aBufferSize)
|
||||
{
|
||||
if (aBufferSize < MIN_BUFFER_SIZE) {
|
||||
if (PRUint32(aBufferSize) < MIN_BUFFER_SIZE) {
|
||||
aBufferSize = MIN_BUFFER_SIZE;
|
||||
}
|
||||
mSpace = aBufferSize;
|
||||
@@ -62,24 +62,24 @@ ByteBufferImpl::~ByteBufferImpl()
|
||||
mLength = 0;
|
||||
}
|
||||
|
||||
PRUint32 ByteBufferImpl::GetLength(void) const
|
||||
PRInt32 ByteBufferImpl::GetLength() const
|
||||
{
|
||||
return mLength;
|
||||
}
|
||||
|
||||
PRUint32 ByteBufferImpl::GetBufferSize(void) const
|
||||
PRInt32 ByteBufferImpl::GetBufferSize() const
|
||||
{
|
||||
return mSpace;
|
||||
}
|
||||
|
||||
char* ByteBufferImpl::GetBuffer(void) const
|
||||
char* ByteBufferImpl::GetBuffer() const
|
||||
{
|
||||
return mBuffer;
|
||||
}
|
||||
|
||||
PRBool ByteBufferImpl::Grow(PRUint32 aNewSize)
|
||||
PRBool ByteBufferImpl::Grow(PRInt32 aNewSize)
|
||||
{
|
||||
if (aNewSize < MIN_BUFFER_SIZE) {
|
||||
if (PRUint32(aNewSize) < MIN_BUFFER_SIZE) {
|
||||
aNewSize = MIN_BUFFER_SIZE;
|
||||
}
|
||||
char* newbuf = new char[aNewSize];
|
||||
@@ -95,10 +95,10 @@ PRBool ByteBufferImpl::Grow(PRUint32 aNewSize)
|
||||
}
|
||||
|
||||
PRInt32 ByteBufferImpl::Fill(nsresult* aErrorCode, nsIInputStream* aStream,
|
||||
PRUint32 aKeep)
|
||||
PRInt32 aKeep)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aStream, "null stream");
|
||||
NS_PRECONDITION(aKeep <= mLength, "illegal keep count");
|
||||
NS_PRECONDITION(PRUint32(aKeep) <= PRUint32(mLength), "illegal keep count");
|
||||
if ((nsnull == aStream) || (PRUint32(aKeep) > PRUint32(mLength))) {
|
||||
// whoops
|
||||
*aErrorCode = NS_BASE_STREAM_ILLEGAL_ARGS;
|
||||
@@ -112,8 +112,8 @@ PRInt32 ByteBufferImpl::Fill(nsresult* aErrorCode, nsIInputStream* aStream,
|
||||
|
||||
// Read in some new data
|
||||
mLength = aKeep;
|
||||
PRUint32 amount = mSpace - aKeep;
|
||||
PRUint32 nb;
|
||||
PRInt32 amount = mSpace - aKeep;
|
||||
PRInt32 nb;
|
||||
*aErrorCode = aStream->Read(mBuffer, aKeep, amount, &nb);
|
||||
if (NS_SUCCEEDED(*aErrorCode)) {
|
||||
mLength += nb;
|
||||
@@ -125,7 +125,7 @@ PRInt32 ByteBufferImpl::Fill(nsresult* aErrorCode, nsIInputStream* aStream,
|
||||
|
||||
NS_BASE nsresult NS_NewByteBuffer(nsIByteBuffer** aInstancePtrResult,
|
||||
nsISupports* aOuter,
|
||||
PRUint32 aBufferSize)
|
||||
PRInt32 aBufferSize)
|
||||
{
|
||||
if (nsnull != aOuter) {
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
@@ -86,7 +86,6 @@ static const unsigned char kLower2Upper[256] = {
|
||||
240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
|
||||
};
|
||||
|
||||
// XXX bug: this doesn't map 0x80 to 0x9f properly
|
||||
static const PRUnichar kIsoLatin1ToUCS2[256] = {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
||||
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
|
||||
@@ -194,6 +193,7 @@ PRInt32 nsCRT::strncmp(const PRUnichar* s1, const PRUnichar* s2, PRInt32 n)
|
||||
if ((0==c1) || (0==c2)) break;
|
||||
}
|
||||
}
|
||||
else return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -251,7 +251,7 @@ PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const PRUnichar* s2, PRInt32 n)
|
||||
}
|
||||
if ((0==c1) || (0==c2)) break;
|
||||
}
|
||||
}
|
||||
} else return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -303,7 +303,7 @@ PRInt32 nsCRT::strncmp(const PRUnichar* s1, const char* s2, PRInt32 n)
|
||||
}
|
||||
if ((0==c1) || (0==c2)) break;
|
||||
}
|
||||
}
|
||||
} else return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -361,20 +361,11 @@ PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const char* s2, PRInt32 n)
|
||||
}
|
||||
if (c1 == 0) break;
|
||||
}
|
||||
}
|
||||
} else return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
PRUnichar* nsCRT::strdup(const PRUnichar* str)
|
||||
{
|
||||
PRInt32 len = nsCRT::strlen(str) + 1; // add one for null
|
||||
PRUnichar* rslt = new PRUnichar[len];
|
||||
if (rslt == NULL) return NULL;
|
||||
nsCRT::memcpy(rslt, str, len * sizeof(PRUnichar));
|
||||
return rslt;
|
||||
}
|
||||
|
||||
PRUint32 nsCRT::HashValue(const PRUnichar* us)
|
||||
{
|
||||
PRUint32 rv = 0;
|
||||
|
||||
@@ -71,10 +71,6 @@ public:
|
||||
return PRInt32(PL_strncasecmp(s1, s2, aMaxLen));
|
||||
}
|
||||
|
||||
static char* strdup(const char* str) {
|
||||
return PL_strdup(str);
|
||||
}
|
||||
|
||||
/// Like strlen except for ucs2 strings
|
||||
static PRInt32 strlen(const PRUnichar* s);
|
||||
|
||||
@@ -102,10 +98,6 @@ public:
|
||||
static PRInt32 strncasecmp(const PRUnichar* s1, const char* s2,
|
||||
PRInt32 aMaxLen);
|
||||
|
||||
// Note: uses new[] to allocate memory, so you must use delete[] to
|
||||
// free the memory
|
||||
static PRUnichar* strdup(const PRUnichar* str);
|
||||
|
||||
/// Compute a hashcode for a ucs2 string
|
||||
static PRUint32 HashValue(const PRUnichar* s1);
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "nsDeque.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
@@ -86,12 +86,12 @@ nsDeque& nsDeque::Erase() {
|
||||
|
||||
|
||||
/**
|
||||
* This method adds an item to the end of the deque.
|
||||
* This method adds an item to the end of the queue.
|
||||
* This operation has the potential to cause the
|
||||
* underlying buffer to resize.
|
||||
*
|
||||
* @update gess4/18/98
|
||||
* @param anItem: new item to be added to deque
|
||||
* @param anItem: new item to be added to queue
|
||||
* @return nada
|
||||
*/
|
||||
nsDeque& nsDeque::Push(void* anItem) {
|
||||
@@ -122,50 +122,6 @@ nsDeque& nsDeque::Push(void* anItem) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method adds an item to the front of the deque.
|
||||
* This operation has the potential to cause the
|
||||
* underlying buffer to resize.
|
||||
*
|
||||
* @update gess4/18/98
|
||||
* @param anItem: new item to be added to deque
|
||||
* @return nada
|
||||
*/
|
||||
nsDeque& nsDeque::PushFront(void* anItem) {
|
||||
if(mOrigin>0) {
|
||||
mOrigin-=1;
|
||||
mData[mOrigin]=anItem;
|
||||
mSize++;
|
||||
}
|
||||
else {
|
||||
Push(anItem);
|
||||
mOrigin=mSize-1;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove and return the last item in the container.
|
||||
*
|
||||
* @update gess4/18/98
|
||||
* @param none
|
||||
* @return ptr to last item in container
|
||||
*/
|
||||
void* nsDeque::Pop(void) {
|
||||
void* result=0;
|
||||
if(mSize>0) {
|
||||
int offset=mOrigin+mSize-1;
|
||||
if(offset>=mCapacity)
|
||||
offset-=mCapacity;
|
||||
result=mData[offset];
|
||||
mData[offset]=0;
|
||||
mSize--;
|
||||
if(0==mSize)
|
||||
mOrigin=0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets called you want to remove and return
|
||||
* the first member in the container.
|
||||
@@ -174,7 +130,7 @@ void* nsDeque::Pop(void) {
|
||||
* @param nada
|
||||
* @return last item in container
|
||||
*/
|
||||
void* nsDeque::PopFront() {
|
||||
void* nsDeque::Pop() {
|
||||
void* result=0;
|
||||
if(mSize>0) {
|
||||
result=mData[mOrigin];
|
||||
@@ -205,6 +161,28 @@ void* nsDeque::Peek() {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove and return the last item in the container.
|
||||
*
|
||||
* @update gess4/18/98
|
||||
* @param none
|
||||
* @return ptr to last item in container
|
||||
*/
|
||||
void* nsDeque::PopBack(void) {
|
||||
void* result=0;
|
||||
if(mSize>0) {
|
||||
int offset=mOrigin+mSize;
|
||||
if(offset>=mCapacity)
|
||||
offset-=mCapacity;
|
||||
result=mData[offset-1];
|
||||
mData[offset-1]=0;
|
||||
mSize--;
|
||||
if(0==mSize)
|
||||
mOrigin=0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this to retrieve the ith element from this container.
|
||||
* Keep in mind that accessing the underlying elements is
|
||||
|
||||
@@ -93,15 +93,6 @@ friend class nsDequeIterator;
|
||||
* @return *this
|
||||
*/
|
||||
nsDeque& Push(void* anItem);
|
||||
|
||||
/**
|
||||
* Pushes new member onto the front of the deque
|
||||
*
|
||||
* @update gess4/18/98
|
||||
* @param ptr to object to store
|
||||
* @return *this
|
||||
*/
|
||||
nsDeque& PushFront(void* anItem);
|
||||
|
||||
/**
|
||||
* Remove and return the first item in the container.
|
||||
@@ -112,16 +103,6 @@ friend class nsDequeIterator;
|
||||
*/
|
||||
void* Pop(void);
|
||||
|
||||
/**
|
||||
* Remove and return the first item in the container.
|
||||
*
|
||||
* @update gess4/18/98
|
||||
* @param none
|
||||
* @return ptr to first item in container
|
||||
*/
|
||||
void* PopFront(void);
|
||||
|
||||
|
||||
/**
|
||||
* Return topmost item without removing it.
|
||||
*
|
||||
@@ -132,16 +113,14 @@ friend class nsDequeIterator;
|
||||
void* Peek(void);
|
||||
|
||||
/**
|
||||
* method used to retrieve ptr to
|
||||
* ith member in container. DOesn't remove
|
||||
* that item.
|
||||
*
|
||||
* Remove and return the last item in the container.
|
||||
*
|
||||
* @update gess4/18/98
|
||||
* @param index of desired item
|
||||
* @return ptr to ith element in list
|
||||
* @param none
|
||||
* @return ptr to first item in container
|
||||
*/
|
||||
void* ObjectAt(int anIndex) const;
|
||||
|
||||
void* PopBack(void);
|
||||
|
||||
/**
|
||||
* Remove all items from container without destroying them
|
||||
*
|
||||
@@ -250,6 +229,17 @@ private:
|
||||
*/
|
||||
nsDeque& operator=(const nsDeque& anOther);
|
||||
|
||||
/**
|
||||
* PRIVATE method used to retrieve ptr to
|
||||
* ith member in container. DOesn't remove
|
||||
* that item.
|
||||
*
|
||||
* @update gess4/18/98
|
||||
* @param index of desired item
|
||||
* @return ptr to ith element in list
|
||||
*/
|
||||
void* ObjectAt(int anIndex) const;
|
||||
|
||||
};
|
||||
|
||||
/******************************************************
|
||||
|
||||
@@ -1,152 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
// First checked in on 98/12/03 by John R. McMullen, derived from net.h/mkparse.c.
|
||||
|
||||
#include "nsEscape.h"
|
||||
|
||||
#include "plstr.h"
|
||||
|
||||
const int netCharType[256] =
|
||||
/* Bit 0 xalpha -- the alphas
|
||||
** Bit 1 xpalpha -- as xalpha but
|
||||
** converts spaces to plus and plus to %20
|
||||
** Bit 3 ... path -- as xalphas but doesn't escape '/'
|
||||
*/
|
||||
/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
|
||||
{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x */
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 1x */
|
||||
0,0,0,0,0,0,0,0,0,0,7,4,0,7,7,4, /* 2x !"#$%&'()*+,-./ */
|
||||
7,7,7,7,7,7,7,7,7,7,0,0,0,0,0,0, /* 3x 0123456789:;<=>? */
|
||||
0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, /* 4x @ABCDEFGHIJKLMNO */
|
||||
/* bits for '@' changed from 7 to 0 so '@' can be escaped */
|
||||
/* in usernames and passwords in publishing. */
|
||||
7,7,7,7,7,7,7,7,7,7,7,0,0,0,0,7, /* 5X PQRSTUVWXYZ[\]^_ */
|
||||
0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, /* 6x `abcdefghijklmno */
|
||||
7,7,7,7,7,7,7,7,7,7,7,0,0,0,0,0, /* 7X pqrstuvwxyz{\}~ DEL */
|
||||
0, };
|
||||
|
||||
/* decode % escaped hex codes into character values
|
||||
*/
|
||||
#define UNHEX(C) \
|
||||
((C >= '0' && C <= '9') ? C - '0' : \
|
||||
((C >= 'A' && C <= 'F') ? C - 'A' + 10 : \
|
||||
((C >= 'a' && C <= 'f') ? C - 'a' + 10 : 0)))
|
||||
|
||||
|
||||
#define IS_OK(C) (netCharType[((unsigned int) (C))] & (mask))
|
||||
#define HEX_ESCAPE '%'
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
char* nsEscape(const char * str, nsEscapeMask mask)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if(!str)
|
||||
return NULL;
|
||||
return nsEscapeCount(str, (PRInt32)PL_strlen(str), mask, NULL);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
char* nsEscapeCount(const char * str, PRInt32 len, nsEscapeMask mask, PRInt32 * out_len)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
int32 i, extra = 0;
|
||||
char *hexChars = "0123456789ABCDEF";
|
||||
|
||||
if(!str)
|
||||
return(0);
|
||||
|
||||
register const unsigned char* src = (unsigned char *) str;
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
if (!IS_OK(src[i]))
|
||||
extra+=2; /* the escape, plus an extra byte for each nibble */
|
||||
}
|
||||
|
||||
char* result = new char[len + extra + 1];
|
||||
if (!result)
|
||||
return(0);
|
||||
|
||||
register unsigned char* dst = (unsigned char *) result;
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
unsigned char c = src[i];
|
||||
if (IS_OK(c))
|
||||
{
|
||||
*dst++ = c;
|
||||
}
|
||||
else if (mask == url_XPAlphas && c == ' ')
|
||||
{
|
||||
*dst++ = '+'; /* convert spaces to pluses */
|
||||
}
|
||||
else
|
||||
{
|
||||
*dst++ = HEX_ESCAPE;
|
||||
*dst++ = hexChars[c >> 4]; /* high nibble */
|
||||
*dst++ = hexChars[c & 0x0f]; /* low nibble */
|
||||
}
|
||||
}
|
||||
|
||||
*dst = '\0'; /* tack on eos */
|
||||
if(out_len)
|
||||
*out_len = dst - (unsigned char *) result;
|
||||
return result;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
char* nsUnescape(char * str)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsUnescapeCount(str);
|
||||
return str;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
PRInt32 nsUnescapeCount(char * str)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
register char *src = str;
|
||||
register char *dst = str;
|
||||
|
||||
while (*src)
|
||||
if (*src != HEX_ESCAPE)
|
||||
{
|
||||
*dst++ = *src++;
|
||||
}
|
||||
else
|
||||
{
|
||||
src++; /* walk over escape */
|
||||
if (*src)
|
||||
{
|
||||
*dst = UNHEX(*src) << 4;
|
||||
src++;
|
||||
}
|
||||
if (*src)
|
||||
{
|
||||
*dst = (*dst + UNHEX(*src));
|
||||
src++;
|
||||
}
|
||||
dst++;
|
||||
}
|
||||
|
||||
*dst = 0;
|
||||
|
||||
return (int)(dst - str);
|
||||
|
||||
} /* NET_UnEscapeCnt */
|
||||
|
||||
@@ -1,579 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsFileSpec.h"
|
||||
|
||||
#include "nsFileStream.h"
|
||||
#include "nsDebug.h"
|
||||
|
||||
#include "prtypes.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
//========================================================================================
|
||||
NS_NAMESPACE nsFileSpecHelpers
|
||||
//========================================================================================
|
||||
{
|
||||
enum
|
||||
{ kMaxFilenameLength = 31 // should work on Macintosh, Unix, and Win32.
|
||||
, kMaxAltDigitLength = 5
|
||||
, kMaxCoreLeafNameLength = (kMaxFilenameLength - (kMaxAltDigitLength + 1))
|
||||
};
|
||||
NS_NAMESPACE_PROTOTYPE void LeafReplace(
|
||||
char*& ioPath,
|
||||
char inSeparator,
|
||||
const char* inLeafName);
|
||||
#ifndef XP_MAC
|
||||
NS_NAMESPACE_PROTOTYPE void Canonify(char*& ioPath, bool inMakeDirs);
|
||||
NS_NAMESPACE_PROTOTYPE void MakeAllDirectories(const char* inPath, int mode);
|
||||
#endif
|
||||
NS_NAMESPACE_PROTOTYPE char* GetLeaf(const char* inPath, char inSeparator); // allocated
|
||||
NS_NAMESPACE_PROTOTYPE char* StringDup(const char* inString, int allocLength = 0);
|
||||
NS_NAMESPACE_PROTOTYPE char* AllocCat(const char* inString1, const char* inString2);
|
||||
NS_NAMESPACE_PROTOTYPE char* StringAssign(char*& ioString, const char* inOther);
|
||||
NS_NAMESPACE_PROTOTYPE char* ReallocCat(char*& ioString, const char* inString1);
|
||||
#ifdef XP_PC
|
||||
NS_NAMESPACE_PROTOTYPE void NativeToUnix(char*& ioPath);
|
||||
NS_NAMESPACE_PROTOTYPE void UnixToNative(char*& ioPath);
|
||||
#endif
|
||||
} NS_NAMESPACE_END
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
char* nsFileSpecHelpers::StringDup(
|
||||
const char* inString,
|
||||
int allocLength)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!allocLength && inString)
|
||||
allocLength = strlen(inString);
|
||||
char* newPath = inString || allocLength ? new char[allocLength + 1] : nsnull;
|
||||
if (!newPath)
|
||||
return NULL;
|
||||
strcpy(newPath, inString);
|
||||
return newPath;
|
||||
} // nsFileSpecHelpers::StringDup
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
char* nsFileSpecHelpers::AllocCat(
|
||||
const char* inString1,
|
||||
const char* inString2)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!inString1)
|
||||
return inString2 ? StringDup(inString2) : (char*)NULL;
|
||||
if (!inString2)
|
||||
return StringDup(inString1);
|
||||
char* outString = StringDup(inString1, strlen(inString1) + strlen(inString2));
|
||||
if (outString)
|
||||
strcat(outString, inString2);
|
||||
return outString;
|
||||
} // nsFileSpecHelpers::StringDup
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
char* nsFileSpecHelpers::StringAssign(
|
||||
char*& ioString,
|
||||
const char* inString2)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!inString2)
|
||||
{
|
||||
delete [] ioString;
|
||||
ioString = (char*)NULL;
|
||||
return ioString;
|
||||
}
|
||||
if (!ioString || (strlen(inString2) > strlen(ioString)))
|
||||
{
|
||||
delete [] ioString;
|
||||
ioString = StringDup(inString2);
|
||||
return ioString;
|
||||
}
|
||||
strcpy(ioString, inString2);
|
||||
return ioString;
|
||||
} // nsFileSpecHelpers::StringAssign
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileSpecHelpers::LeafReplace(
|
||||
char*& ioPath,
|
||||
char inSeparator,
|
||||
const char* inLeafName)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// Find the existing leaf name
|
||||
if (!ioPath)
|
||||
return;
|
||||
if (!inLeafName)
|
||||
{
|
||||
*ioPath = '\0';
|
||||
return;
|
||||
}
|
||||
char* lastSeparator = strrchr(ioPath, inSeparator);
|
||||
int oldLength = strlen(ioPath);
|
||||
*(++lastSeparator) = '\0'; // strip the current leaf name
|
||||
int newLength = lastSeparator - ioPath + strlen(inLeafName);
|
||||
if (newLength > oldLength)
|
||||
{
|
||||
char* newPath = StringDup(ioPath, newLength + 1);
|
||||
delete [] ioPath;
|
||||
ioPath = newPath;
|
||||
}
|
||||
strcat(ioPath, inLeafName);
|
||||
} // nsNativeFileSpec::LeafReplace
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
char* nsFileSpecHelpers::GetLeaf(const char* inPath, char inSeparator)
|
||||
// Returns a pointer to an allocated string representing the leaf.
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!inPath)
|
||||
return NULL;
|
||||
char* lastSeparator = strrchr(inPath, inSeparator);
|
||||
if (lastSeparator)
|
||||
return StringDup(++lastSeparator);
|
||||
return StringDup(inPath);
|
||||
} // nsNativeFileSpec::GetLeaf
|
||||
|
||||
#if defined(XP_UNIX) || defined(XP_PC)
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileSpecHelpers::MakeAllDirectories(const char* inPath, int mode)
|
||||
// Make the path a valid one by creating all the intermediate directories. Does NOT
|
||||
// make the leaf into a directory. This should be a unix path.
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!inPath)
|
||||
return;
|
||||
|
||||
char* pathCopy = nsFileSpecHelpers::StringDup( inPath );
|
||||
if (!pathCopy)
|
||||
return;
|
||||
|
||||
const char kSeparator = '/'; // I repeat: this should be a unix-style path.
|
||||
const int kSkipFirst = 1;
|
||||
|
||||
#ifdef XP_PC
|
||||
// Either this is a relative path, or we ensure that it has
|
||||
// a drive letter specifier.
|
||||
NS_ASSERTION( pathCopy[0] != '/' || pathCopy[2] == '|', "No drive letter!" );
|
||||
#endif
|
||||
char* currentStart = pathCopy;
|
||||
char* currentEnd = strchr(currentStart + kSkipFirst, kSeparator);
|
||||
if (currentEnd)
|
||||
{
|
||||
*currentEnd = '\0';
|
||||
nsNativeFileSpec spec(nsFilePath(pathCopy, false));
|
||||
do
|
||||
{
|
||||
// If the node doesn't exist, and it is not the initial node in a full path,
|
||||
// then make a directory (We cannot make the initial (volume) node).
|
||||
if (!spec.Exists() && *currentStart != kSeparator)
|
||||
spec.CreateDirectory(mode);
|
||||
if (!spec.Exists())
|
||||
{
|
||||
NS_ASSERTION(spec.Exists(), "Could not create the directory?");
|
||||
break;
|
||||
}
|
||||
currentStart = ++currentEnd;
|
||||
currentEnd = strchr(currentStart, kSeparator);
|
||||
if (!currentEnd)
|
||||
break;
|
||||
spec += currentStart; // "lengthen" the path, adding the next node.
|
||||
} while (currentEnd);
|
||||
}
|
||||
delete [] pathCopy;
|
||||
} // nsFileSpecHelpers::MakeAllDirectories
|
||||
|
||||
#endif // XP_PC || XP_UNIX
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
char* nsFileSpecHelpers::ReallocCat(char*& ioString, const char* inString1)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
char* newString = AllocCat(ioString, inString1);
|
||||
delete [] ioString;
|
||||
ioString = newString;
|
||||
return ioString;
|
||||
} // nsNativeFileSpec::ReallocCat
|
||||
|
||||
#if defined(XP_PC)
|
||||
#include "windows/nsFileSpecWin.cpp" // Windows-specific implementations
|
||||
#elif defined(XP_MAC)
|
||||
#include "nsFileSpecMac.cpp" // Macintosh-specific implementations
|
||||
#elif defined(XP_UNIX)
|
||||
#include "unix/nsFileSpecUnix.cpp" // Unix-specific implementations
|
||||
#endif
|
||||
|
||||
//========================================================================================
|
||||
// nsFileURL implementation
|
||||
//========================================================================================
|
||||
|
||||
#ifndef XP_MAC
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileURL::nsFileURL(const char* inString, bool inCreateDirs)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mURL(nsnull)
|
||||
{
|
||||
if (!inString)
|
||||
return;
|
||||
NS_ASSERTION(strstr(inString, kFileURLPrefix) == inString, "Not a URL!");
|
||||
// Make canonical and absolute.
|
||||
nsFilePath path(inString + kFileURLPrefixLength, inCreateDirs);
|
||||
*this = path;
|
||||
} // nsFileURL::nsFileURL
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileURL::nsFileURL(const nsFileURL& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mURL(nsFileSpecHelpers::StringDup(inOther.mURL))
|
||||
#ifdef XP_MAC
|
||||
, mNativeFileSpec(inOther.GetNativeSpec())
|
||||
#endif
|
||||
{
|
||||
} // nsFileURL::nsFileURL
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileURL::nsFileURL(const nsFilePath& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mURL(nsFileSpecHelpers::AllocCat(kFileURLPrefix, (const char*)inOther))
|
||||
#ifdef XP_MAC
|
||||
, mNativeFileSpec(inOther.GetNativeSpec())
|
||||
#endif
|
||||
{
|
||||
} // nsFileURL::nsFileURL
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileURL::nsFileURL(const nsNativeFileSpec& inOther)
|
||||
: mURL(nsFileSpecHelpers::AllocCat(kFileURLPrefix, (const char*)nsFilePath(inOther)))
|
||||
#ifdef XP_MAC
|
||||
, mNativeFileSpec(inOther)
|
||||
#endif
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
} // nsFileURL::nsFileURL
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFileURL::~nsFileURL()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
delete [] mURL;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileURL::operator = (const char* inString)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsFileSpecHelpers::StringAssign(mURL, inString);
|
||||
NS_ASSERTION(strstr(inString, kFileURLPrefix) == inString, "Not a URL!");
|
||||
#ifdef XP_MAC
|
||||
mNativeFileSpec = inString + kFileURLPrefixLength;
|
||||
#endif
|
||||
} // nsFileURL::operator =
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileURL::operator = (const nsFileURL& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mURL = nsFileSpecHelpers::StringAssign(mURL, inOther.mURL);
|
||||
#ifdef XP_MAC
|
||||
mNativeFileSpec = inOther.GetNativeSpec();
|
||||
#endif
|
||||
} // nsFileURL::operator =
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileURL::operator = (const nsFilePath& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
delete [] mURL;
|
||||
mURL = nsFileSpecHelpers::AllocCat(kFileURLPrefix, (const char*)inOther);
|
||||
#ifdef XP_MAC
|
||||
mNativeFileSpec = inOther.GetNativeSpec();
|
||||
#endif
|
||||
} // nsFileURL::operator =
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileURL::operator = (const nsNativeFileSpec& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
delete [] mURL;
|
||||
mURL = nsFileSpecHelpers::AllocCat(kFileURLPrefix, (const char*)nsFilePath(inOther));
|
||||
#ifdef XP_MAC
|
||||
mNativeFileSpec = inOther;
|
||||
#endif
|
||||
} // nsFileURL::operator =
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsBasicOutStream& operator << (nsBasicOutStream& s, const nsFileURL& url)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return (s << url.mURL);
|
||||
}
|
||||
|
||||
//========================================================================================
|
||||
// nsFilePath implementation
|
||||
//========================================================================================
|
||||
|
||||
#ifndef XP_MAC
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFilePath::nsFilePath(const char* inString, bool inCreateDirs)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mPath(nsFileSpecHelpers::StringDup(inString))
|
||||
{
|
||||
NS_ASSERTION(strstr(inString, kFileURLPrefix) != inString, "URL passed as path");
|
||||
|
||||
#ifdef XP_PC
|
||||
nsFileSpecHelpers::UnixToNative(mPath);
|
||||
#endif
|
||||
// Make canonical and absolute.
|
||||
nsFileSpecHelpers::Canonify(mPath, inCreateDirs);
|
||||
#ifdef XP_PC
|
||||
NS_ASSERTION( mPath[1] == ':', "unexpected canonical path" );
|
||||
nsFileSpecHelpers::NativeToUnix(mPath);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFilePath::nsFilePath(const nsFileURL& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mPath(nsFileSpecHelpers::StringDup(inOther.mURL + kFileURLPrefixLength))
|
||||
#ifdef XP_MAC
|
||||
, mNativeFileSpec(inOther.GetNativeSpec())
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef XP_UNIX
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFilePath::nsFilePath(const nsNativeFileSpec& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mPath(nsFileSpecHelpers::StringDup(inOther.mPath))
|
||||
{
|
||||
}
|
||||
#endif // XP_UNIX
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFilePath::~nsFilePath()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
delete [] mPath;
|
||||
}
|
||||
|
||||
#ifdef XP_UNIX
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFilePath::operator = (const nsNativeFileSpec& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mPath = nsFileSpecHelpers::StringAssign(mPath, inOther.mPath);
|
||||
}
|
||||
#endif // XP_UNIX
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFilePath::operator = (const char* inString)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
NS_ASSERTION(strstr(inString, kFileURLPrefix) != inString, "URL passed as path");
|
||||
#ifdef XP_MAC
|
||||
mNativeFileSpec = inString;
|
||||
nsFileSpecHelpers::StringAssign(mPath, (const char*)nsFilePath(mNativeFileSpec));
|
||||
#else
|
||||
#ifdef XP_PC
|
||||
nsFileSpecHelpers::UnixToNative(mPath);
|
||||
#endif
|
||||
// Make canonical and absolute.
|
||||
nsFileSpecHelpers::Canonify(mPath, false /* XXX? */);
|
||||
#ifdef XP_PC
|
||||
nsFileSpecHelpers::NativeToUnix(mPath);
|
||||
#endif
|
||||
#endif // XP_MAC
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFilePath::operator = (const nsFileURL& inOther)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsFileSpecHelpers::StringAssign(mPath, (const char*)nsFilePath(inOther));
|
||||
#ifdef XP_MAC
|
||||
mNativeFileSpec = inOther.GetNativeSpec();
|
||||
#endif
|
||||
}
|
||||
|
||||
//========================================================================================
|
||||
// nsNativeFileSpec implementation
|
||||
//========================================================================================
|
||||
|
||||
#ifndef XP_MAC
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsNativeFileSpec::nsNativeFileSpec()
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mPath(NULL)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsNativeFileSpec::nsNativeFileSpec(const nsFileURL& inURL)
|
||||
//----------------------------------------------------------------------------------------
|
||||
#ifndef XP_MAC
|
||||
: mPath(NULL)
|
||||
#endif
|
||||
{
|
||||
*this = nsFilePath(inURL); // convert to unix path first
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsNativeFileSpec::MakeUnique(const char* inSuggestedLeafName)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (inSuggestedLeafName && *inSuggestedLeafName)
|
||||
SetLeafName(inSuggestedLeafName);
|
||||
|
||||
MakeUnique();
|
||||
} // nsNativeFileSpec::MakeUnique
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsNativeFileSpec::MakeUnique()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!Exists())
|
||||
return;
|
||||
|
||||
char* leafName = GetLeafName();
|
||||
if (!leafName)
|
||||
return;
|
||||
|
||||
char* lastDot = strrchr(leafName, '.');
|
||||
char* suffix = "";
|
||||
if (lastDot)
|
||||
{
|
||||
suffix = nsFileSpecHelpers::StringDup(lastDot); // include '.'
|
||||
*lastDot = '\0'; // strip suffix and dot.
|
||||
}
|
||||
const int kMaxRootLength
|
||||
= nsFileSpecHelpers::kMaxCoreLeafNameLength - strlen(suffix) - 1;
|
||||
if (strlen(leafName) > kMaxRootLength)
|
||||
leafName[kMaxRootLength] = '\0';
|
||||
for (short index = 1; index < 1000 && Exists(); index++)
|
||||
{
|
||||
// start with "Picture-1.jpg" after "Picture.jpg" exists
|
||||
char newName[nsFileSpecHelpers::kMaxFilenameLength + 1];
|
||||
sprintf(newName, "%s-%d%s", leafName, index, suffix);
|
||||
SetLeafName(newName);
|
||||
}
|
||||
if (*suffix)
|
||||
delete [] suffix;
|
||||
delete [] leafName;
|
||||
} // nsNativeFileSpec::MakeUnique
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsNativeFileSpec::operator = (const nsFileURL& inURL)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
*this = nsFilePath(inURL); // convert to unix path first
|
||||
}
|
||||
|
||||
//========================================================================================
|
||||
// UNIX & WIN nsNativeFileSpec implementation
|
||||
//========================================================================================
|
||||
|
||||
#ifdef XP_UNIX
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsNativeFileSpec::nsNativeFileSpec(const nsFilePath& inPath)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mPath(nsFileSpecHelpers::StringDup((const char*)inPath))
|
||||
{
|
||||
}
|
||||
#endif // XP_UNIX
|
||||
|
||||
#ifdef XP_UNIX
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsNativeFileSpec::operator = (const nsFilePath& inPath)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsFileSpecHelpers::StringAssign(mPath, (const char*)inPath);
|
||||
}
|
||||
#endif //XP_UNIX
|
||||
|
||||
#if defined(XP_UNIX) || defined(XP_PC)
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsNativeFileSpec::nsNativeFileSpec(const nsNativeFileSpec& inSpec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mPath(nsFileSpecHelpers::StringDup(inSpec.mPath))
|
||||
{
|
||||
}
|
||||
#endif //XP_UNIX
|
||||
|
||||
#if defined(XP_UNIX) || defined(XP_PC)
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsNativeFileSpec::nsNativeFileSpec(const char* inString, bool inCreateDirs)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mPath(nsFileSpecHelpers::StringDup(inString))
|
||||
{
|
||||
// Make canonical and absolute.
|
||||
nsFileSpecHelpers::Canonify(mPath, inCreateDirs);
|
||||
}
|
||||
#endif //XP_UNIX,PC
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsNativeFileSpec::~nsNativeFileSpec()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
#ifndef XP_MAC
|
||||
delete [] mPath;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(XP_UNIX) || defined(XP_PC)
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsNativeFileSpec::operator = (const nsNativeFileSpec& inSpec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mPath = nsFileSpecHelpers::StringAssign(mPath, inSpec.mPath);
|
||||
}
|
||||
#endif //XP_UNIX
|
||||
|
||||
|
||||
#if defined(XP_UNIX) || defined(XP_PC)
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsNativeFileSpec::operator = (const char* inString)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mPath = nsFileSpecHelpers::StringAssign(mPath, inString);
|
||||
// Make canonical and absolute.
|
||||
nsFileSpecHelpers::Canonify(mPath, true /* XXX? */);
|
||||
}
|
||||
#endif //XP_UNIX
|
||||
|
||||
#if (defined(XP_UNIX) || defined(XP_PC))
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsBasicOutStream& operator << (nsBasicOutStream& s, const nsNativeFileSpec& spec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return (s << (const char*)spec.mPath);
|
||||
}
|
||||
#endif // DEBUG && XP_UNIX
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsNativeFileSpec nsNativeFileSpec::operator + (const char* inRelativePath) const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsNativeFileSpec result = *this;
|
||||
result += inRelativePath;
|
||||
return result;
|
||||
} // nsNativeFileSpec::operator +
|
||||
@@ -1,460 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
// First checked in on 98/12/08 by John R. McMullen.
|
||||
// Since nsFileStream.h is entirely templates, common code (such as open())
|
||||
// which does not actually depend on the charT, can be placed here.
|
||||
|
||||
#include "nsFileStream.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef XP_MAC
|
||||
#include <Errors.h>
|
||||
#endif
|
||||
|
||||
//========================================================================================
|
||||
// nsBasicFileStream
|
||||
//========================================================================================
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsBasicFileStream::nsBasicFileStream()
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mFileDesc(0)
|
||||
, mNSPRMode(0)
|
||||
, mFailed(false)
|
||||
, mEOF(false)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsBasicFileStream::nsBasicFileStream(
|
||||
const nsFilePath& inFile,
|
||||
int nsprMode,
|
||||
PRIntn accessMode)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mFileDesc(0)
|
||||
, mNSPRMode(0)
|
||||
, mFailed(false)
|
||||
, mEOF(false)
|
||||
{
|
||||
open(inFile, nsprMode, accessMode);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsBasicFileStream::nsBasicFileStream(PRFileDesc* desc, int nsprMode)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mFileDesc(desc)
|
||||
, mNSPRMode(nsprMode)
|
||||
, mFailed(false)
|
||||
, mEOF(false)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsBasicFileStream::~nsBasicFileStream()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsBasicFileStream::open(
|
||||
const nsFilePath& inFile,
|
||||
int nsprMode,
|
||||
PRIntn accessMode)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (mFileDesc)
|
||||
return;
|
||||
|
||||
const int nspr_modes[]={
|
||||
PR_WRONLY | PR_CREATE_FILE,
|
||||
PR_WRONLY | PR_CREATE_FILE | PR_APPEND,
|
||||
PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE,
|
||||
PR_RDONLY,
|
||||
PR_RDONLY | PR_APPEND,
|
||||
PR_RDWR | PR_CREATE_FILE,
|
||||
PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE,
|
||||
// "wb",
|
||||
// "ab",
|
||||
// "wb",
|
||||
// "rb",
|
||||
// "r+b",
|
||||
// "w+b",
|
||||
0 };
|
||||
const int* currentLegalMode = nspr_modes;
|
||||
while (*currentLegalMode && nsprMode != *currentLegalMode)
|
||||
++currentLegalMode;
|
||||
if (!*currentLegalMode)
|
||||
return;
|
||||
|
||||
#ifdef XP_MAC
|
||||
// Use the file spec to open the file, because one path can be common to
|
||||
// several files on the Macintosh (you can have several volumes with the
|
||||
// same name, see).
|
||||
mFileDesc = 0;
|
||||
if (inFile.GetNativeSpec().Error() != noErr)
|
||||
return;
|
||||
OSErr err = noErr;
|
||||
#if DEBUG
|
||||
const OSType kCreator = 'CWIE';
|
||||
#else
|
||||
const OSType kCreator = 'MOSS';
|
||||
#endif
|
||||
nsNativeFileSpec nativeSpec = inFile.GetNativeSpec();
|
||||
FSSpec* spec = (FSSpec*)nativeSpec;
|
||||
if (nsprMode & PR_CREATE_FILE)
|
||||
err = FSpCreate(spec, kCreator, 'TEXT', 0);
|
||||
if (err == dupFNErr)
|
||||
err = noErr;
|
||||
if (err != noErr)
|
||||
return;
|
||||
|
||||
SInt8 perm;
|
||||
if (nsprMode & PR_RDWR)
|
||||
perm = fsRdWrPerm;
|
||||
else if (nsprMode & PR_WRONLY)
|
||||
perm = fsWrPerm;
|
||||
else
|
||||
perm = fsRdPerm;
|
||||
|
||||
short refnum;
|
||||
err = FSpOpenDF(spec, perm, &refnum);
|
||||
|
||||
if (err == noErr && (nsprMode & PR_TRUNCATE))
|
||||
err = SetEOF(refnum, 0);
|
||||
if (err == noErr && (nsprMode & PR_APPEND))
|
||||
err = SetFPos(refnum, fsFromLEOF, 0);
|
||||
if (err != noErr)
|
||||
return;
|
||||
|
||||
if ((mFileDesc = PR_ImportFile(refnum)) == 0)
|
||||
return;
|
||||
#else
|
||||
// Platforms other than Macintosh...
|
||||
// Another bug in NSPR: Mac PR_Open assumes a unix style path, but Win PR_Open assumes
|
||||
// a windows path.
|
||||
if ((mFileDesc = PR_Open((const char*)nsNativeFileSpec(inFile), nsprMode, accessMode)) == 0)
|
||||
return;
|
||||
#endif
|
||||
mNSPRMode = nsprMode;
|
||||
} // nsFileStreamHelpers::open
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsBasicFileStream::close()
|
||||
// Must precede the destructor because both are inline.
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (mFileDesc==PR_STDIN || mFileDesc==PR_STDOUT || mFileDesc==PR_STDERR || mFileDesc == 0)
|
||||
return;
|
||||
if (PR_Close(mFileDesc) == PR_SUCCESS)
|
||||
mFileDesc = 0;
|
||||
} // nsBasicFileStream::close
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsBasicFileStream::seek(PRSeekWhence whence, PRInt32 offset)
|
||||
// Must precede the destructor because both are inline.
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (mFileDesc==PR_STDIN || mFileDesc==PR_STDOUT || mFileDesc==PR_STDERR || mFileDesc == 0)
|
||||
return;
|
||||
mFailed = false; // reset on a seek.
|
||||
mEOF = false; // reset on a seek.
|
||||
PRInt32 position = PR_Seek(mFileDesc, 0, PR_SEEK_CUR);
|
||||
PRInt32 available = PR_Available(mFileDesc);
|
||||
PRInt32 fileSize = position + available;
|
||||
PRInt32 newPosition;
|
||||
switch (whence)
|
||||
{
|
||||
case PR_SEEK_CUR: newPosition = position + offset; break;
|
||||
case PR_SEEK_SET: newPosition = offset; break;
|
||||
case PR_SEEK_END: newPosition = fileSize + offset; break;
|
||||
}
|
||||
if (newPosition < 0)
|
||||
{
|
||||
newPosition = 0;
|
||||
mFailed = true;
|
||||
}
|
||||
else if (newPosition >= fileSize)
|
||||
{
|
||||
newPosition = fileSize;
|
||||
mEOF = true;
|
||||
}
|
||||
if (PR_Seek(mFileDesc, newPosition, PR_SEEK_SET) < 0)
|
||||
mFailed = true;
|
||||
} // nsBasicFileStream::seek
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
PRIntn nsBasicFileStream::tell() const
|
||||
// Must precede the destructor because both are inline.
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (mFileDesc==PR_STDIN || mFileDesc==PR_STDOUT || mFileDesc==PR_STDERR || mFileDesc == 0)
|
||||
return -1;
|
||||
return PR_Seek(mFileDesc, 0, PR_SEEK_CUR);
|
||||
} // nsBasicFileStream::tell
|
||||
|
||||
//========================================================================================
|
||||
// nsBasicInStream
|
||||
//========================================================================================
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsBasicInStream::nsBasicInStream(nsBasicFileStream& inBasicStream, istream* inStream)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mBase(inBasicStream)
|
||||
, mStdStream(inStream)
|
||||
{
|
||||
}
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsBasicInStream::get(char& c)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
read(&c, sizeof(char));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
PRBool nsBasicInStream::readline(char* s, PRInt32 n)
|
||||
// This will truncate if the buffer is too small. Result will always be null-terminated.
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
PRBool bufferLargeEnough = true; // result
|
||||
if (!s || !n)
|
||||
return true;
|
||||
PRIntn position = mBase.tell();
|
||||
if (position < 0)
|
||||
return false;
|
||||
PRInt32 bytesRead = read(s, n - 1);
|
||||
if (mBase.failed())
|
||||
return false;
|
||||
s[bytesRead] = '\0'; // always terminate at the end of the buffer
|
||||
char* tp = strpbrk(s, "\n\r");
|
||||
if (tp)
|
||||
{
|
||||
char ch = *tp;
|
||||
*tp++ = '\0'; // terminate at the newline, then skip past it
|
||||
if ((ch == '\n' && *tp == '\r') || (ch == '\r' && *tp == '\n'))
|
||||
tp++; // possibly a pair.
|
||||
bytesRead = (tp - s);
|
||||
}
|
||||
else if (!mBase.eof())
|
||||
bufferLargeEnough = false;
|
||||
position += bytesRead;
|
||||
mBase.seek(position);
|
||||
return bufferLargeEnough;
|
||||
} // nsBasicInStream::getline
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
PRInt32 nsBasicInStream::read(void* s, PRInt32 n)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
#ifndef NS_USE_PR_STDIO
|
||||
// Calling PR_Read on stdin is sure suicide on Macintosh.
|
||||
if (GetStandardStream())
|
||||
{
|
||||
GetStandardStream()->read((char*)s, n);
|
||||
return n;
|
||||
}
|
||||
#endif
|
||||
if (!mBase.is_open() || mBase.failed())
|
||||
return -1;
|
||||
PRInt32 bytesRead = PR_Read(mBase.GetFileDescriptor(), s, n);
|
||||
if (bytesRead < 0)
|
||||
mBase.mFailed = true;
|
||||
else if (bytesRead < n)
|
||||
mBase.mEOF = true;
|
||||
return bytesRead;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsBasicInStream& nsBasicInStream::operator >> (char& c)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
get(c);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//========================================================================================
|
||||
// nsInputFileStream
|
||||
//========================================================================================
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsInputFileStream::nsInputFileStream(istream* stream)
|
||||
//----------------------------------------------------------------------------------------
|
||||
#ifndef NS_USE_PR_STDIO
|
||||
: nsBasicFileStream(0, kDefaultMode)
|
||||
, nsBasicInStream(*this, stream)
|
||||
#else
|
||||
: nsBasicFileStream(PR_STDIN, kDefaultMode)
|
||||
, nsBasicInStream(*this, 0)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
//========================================================================================
|
||||
// nsBasicOutStream
|
||||
//========================================================================================
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsBasicOutStream::nsBasicOutStream(nsBasicFileStream& inBase, ostream* stream)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mBase(inBase)
|
||||
, mStdStream(stream)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsBasicOutStream::put(char c)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
write(&c, sizeof(c));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
PRInt32 nsBasicOutStream::write(const void* s, PRInt32 n)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
#ifndef NS_USE_PR_STDIO
|
||||
// Calling PR_Write on stdout is sure suicide.
|
||||
if (mStdStream)
|
||||
{
|
||||
mStdStream->write((const char*)s, n);
|
||||
return n;
|
||||
}
|
||||
#endif
|
||||
if (!mBase.mFileDesc || mBase.failed())
|
||||
return -1;
|
||||
PRInt32 bytesWrit = PR_Write(mBase.mFileDesc, s, n);
|
||||
if (bytesWrit != n)
|
||||
mBase.mFailed = true;
|
||||
return bytesWrit;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsBasicOutStream& nsBasicOutStream::operator << (char c)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
put(c);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsBasicOutStream& nsBasicOutStream::operator << (const char* s)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
write(s, strlen(s));
|
||||
return *this;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsBasicOutStream& nsBasicOutStream::operator << (short val)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
char buf[30];
|
||||
sprintf(buf, "%d", val);
|
||||
return *this << buf;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsBasicOutStream& nsBasicOutStream::operator << (unsigned short val)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
char buf[30];
|
||||
sprintf(buf, "%ud", val);
|
||||
return *this << buf;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsBasicOutStream& nsBasicOutStream::operator << (long val)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
char buf[30];
|
||||
sprintf(buf, "%ld", val);
|
||||
return *this << buf;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsBasicOutStream& nsBasicOutStream::operator << (unsigned long val)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
char buf[30];
|
||||
sprintf(buf, "%uld", val);
|
||||
return *this << buf;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsBasicOutStream::flush()
|
||||
// Must precede the destructor because both are inline.
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
#ifndef NS_USE_PR_STDIO
|
||||
if (mStdStream)
|
||||
{
|
||||
mStdStream->flush();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (mBase.mFileDesc == 0)
|
||||
return;
|
||||
PRBool itFailed = PR_Sync(mBase.mFileDesc) != PR_SUCCESS;
|
||||
#ifdef XP_MAC
|
||||
// On unix, it seems to fail always.
|
||||
if (itFailed)
|
||||
mBase.mFailed = true;
|
||||
#endif
|
||||
} // nsBasicOutStream::flush
|
||||
|
||||
//========================================================================================
|
||||
// nsOutputFileStream
|
||||
//========================================================================================
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsOutputFileStream::nsOutputFileStream(ostream* stream)
|
||||
//----------------------------------------------------------------------------------------
|
||||
#ifndef NS_USE_PR_STDIO
|
||||
: nsBasicFileStream(0, kDefaultMode)
|
||||
, nsBasicOutStream(*this, stream)
|
||||
#else
|
||||
: nsBasicFileStream(PR_STDOUT, kDefaultMode)
|
||||
, nsBasicOutStream(*this, 0)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
//========================================================================================
|
||||
// Manipulators
|
||||
//========================================================================================
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsBasicOutStream& nsEndl(nsBasicOutStream& os)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
#ifndef NS_USE_PR_STDIO
|
||||
// Calling PR_Write on stdout is sure suicide on Macintosh.
|
||||
ostream* stream = os.GetStandardStream();
|
||||
if (stream)
|
||||
{
|
||||
*stream << std::endl;
|
||||
return os;
|
||||
}
|
||||
#endif
|
||||
os.put('\n');
|
||||
os.flush();
|
||||
return os;
|
||||
}
|
||||
@@ -38,18 +38,19 @@ public:
|
||||
|
||||
/** Error codes */
|
||||
//@{
|
||||
// XXX fix up the values so they are not total hacks... MMP
|
||||
/// End of file
|
||||
#define NS_BASE_STREAM_EOF NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 1)
|
||||
#define NS_BASE_STREAM_EOF 0x80001001
|
||||
/// Stream closed
|
||||
#define NS_BASE_STREAM_CLOSED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 2)
|
||||
#define NS_BASE_STREAM_CLOSED 0x80001002
|
||||
/// Error from the operating system
|
||||
#define NS_BASE_STREAM_OSERROR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 3)
|
||||
#define NS_BASE_STREAM_OSERROR 0x80001003
|
||||
/// Illegal arguments
|
||||
#define NS_BASE_STREAM_ILLEGAL_ARGS NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 4)
|
||||
#define NS_BASE_STREAM_ILLEGAL_ARGS 0x80001004
|
||||
/// For unichar streams
|
||||
#define NS_BASE_STREAM_NO_CONVERTER NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 5)
|
||||
#define NS_BASE_STREAM_NO_CONVERTER 0x80001005
|
||||
/// For unichar streams
|
||||
#define NS_BASE_STREAM_BAD_CONVERSION NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 6)
|
||||
#define NS_BASE_STREAM_BAD_CONVERSION 0x80001006
|
||||
//@}
|
||||
|
||||
|
||||
|
||||
@@ -31,27 +31,26 @@ class nsIInputStream;
|
||||
class nsIByteBuffer : public nsISupports {
|
||||
public:
|
||||
/** @return length of buffer, i.e. how many bytes are currently in it. */
|
||||
virtual PRUint32 GetLength(void) const = 0;
|
||||
virtual PRInt32 GetLength() const = 0;
|
||||
|
||||
/** @return number of bytes allocated in the buffer */
|
||||
virtual PRUint32 GetBufferSize(void) const = 0;
|
||||
virtual PRInt32 GetBufferSize() const = 0;
|
||||
|
||||
/** @return the buffer */
|
||||
virtual char* GetBuffer(void) const = 0;
|
||||
virtual char* GetBuffer() const = 0;
|
||||
|
||||
/** Grow buffer to aNewSize bytes. */
|
||||
virtual PRBool Grow(PRUint32 aNewSize) = 0;
|
||||
virtual PRBool Grow(PRInt32 aNewSize) = 0;
|
||||
|
||||
/** Fill the buffer with data from aStream. Don't grow the buffer, only
|
||||
* read until length of buffer equals buffer size. */
|
||||
virtual PRInt32 Fill(nsresult* aErrorCode, nsIInputStream* aStream,
|
||||
PRUint32 aKeep) = 0;
|
||||
PRInt32 aKeep) = 0;
|
||||
};
|
||||
|
||||
/** Create a new byte buffer using the given buffer size. */
|
||||
extern NS_BASE nsresult NS_NewByteBuffer(nsIByteBuffer** aInstancePtrResult,
|
||||
nsISupports* aOuter,
|
||||
PRUint32 aBufferSize = 0);
|
||||
PRInt32 aBufferSize = 0);
|
||||
|
||||
#endif /* nsIByteBuffer_h___ */
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD
|
||||
GetLength(PRUint32 *aLength) = 0;
|
||||
GetLength(PRInt32 *aLength) = 0;
|
||||
|
||||
/** Read data from the stream.
|
||||
* @param aErrorCode the error code if an error occurs
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD
|
||||
Read(char* aBuf, PRUint32 aOffset, PRUint32 aCount, PRUint32 *aReadCount) = 0;
|
||||
Read(char* aBuf, PRInt32 aOffset, PRInt32 aCount, PRInt32 *aReadCount) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsInputStream_h___ */
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD
|
||||
Write(const char* aBuf, PRUint32 aOffset, PRUint32 aCount, PRUint32 *aWriteCount) = 0;
|
||||
Write(const char* aBuf, PRInt32 aOffset, PRInt32 aCount, PRInt32 *aWriteCount) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -41,6 +41,6 @@ public:
|
||||
extern NS_BASE nsresult
|
||||
NS_NewUnicharBuffer(nsIUnicharBuffer** aInstancePtrResult,
|
||||
nsISupports* aOuter,
|
||||
PRUint32 aBufferSize = 0);
|
||||
PRInt32 aBufferSize = 0);
|
||||
|
||||
#endif /* nsIUnicharBuffer_h___ */
|
||||
|
||||
@@ -29,6 +29,13 @@ class nsString;
|
||||
{ 0x35e40290, 0x93b5, 0x11d1, \
|
||||
{0x89, 0x5b, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} }
|
||||
|
||||
/// Enumeration of character set ids.
|
||||
enum nsCharSetID {
|
||||
eCharSetID_IsoLatin1 = 0,
|
||||
eCharSetID_UTF8,
|
||||
eCharSetID_ShiftJis
|
||||
// XXX more i'm sure...
|
||||
};
|
||||
|
||||
/** Abstract unicode character input stream
|
||||
* @see nsIInputStream
|
||||
@@ -36,9 +43,9 @@ class nsString;
|
||||
class nsIUnicharInputStream : public nsISupports {
|
||||
public:
|
||||
NS_IMETHOD Read(PRUnichar* aBuf,
|
||||
PRUint32 aOffset,
|
||||
PRUint32 aCount,
|
||||
PRUint32 *aReadCount) = 0;
|
||||
PRInt32 aOffset,
|
||||
PRInt32 aCount,
|
||||
PRInt32 *aReadCount) = 0;
|
||||
NS_IMETHOD Close() = 0;
|
||||
};
|
||||
|
||||
@@ -59,12 +66,12 @@ public:
|
||||
* aDst; aSrcLen is updated to indicate how much data was used in
|
||||
* the source buffer.
|
||||
*/
|
||||
NS_IMETHOD Convert(PRUnichar* aDst,
|
||||
PRUint32 aDstOffset,
|
||||
PRUint32& aDstLen,
|
||||
const char* aSrc,
|
||||
PRUint32 aSrcOffset,
|
||||
PRUint32& aSrcLen) = 0;
|
||||
virtual PRInt32 Convert(PRUnichar* aDst,
|
||||
PRInt32 aDstOffset,
|
||||
PRInt32& aDstLen,
|
||||
const char* aSrc,
|
||||
PRInt32 aSrcOffset,
|
||||
PRInt32& aSrcLen) = 0;
|
||||
};
|
||||
|
||||
/** Create a new nsUnicharInputStream that provides a converter for the
|
||||
@@ -77,7 +84,7 @@ extern NS_BASE nsresult
|
||||
nsISupports* aOuter,
|
||||
nsIInputStream* aStreamToWrap,
|
||||
PRInt32 aBufferSize = 0,
|
||||
nsString* aCharSet = nsnull);
|
||||
nsCharSetID aCharSet = eCharSetID_IsoLatin1);
|
||||
|
||||
/** Create a new nsB2UConverter for the given character set. When given
|
||||
* nsnull, the converter for iso-latin1 to unicode is provided. If no
|
||||
@@ -86,6 +93,6 @@ extern NS_BASE nsresult
|
||||
extern NS_BASE nsresult
|
||||
NS_NewB2UConverter(nsIB2UConverter** aInstancePtrResult,
|
||||
nsISupports* aOuter,
|
||||
nsString* aCharSet = nsnull);
|
||||
nsCharSetID aCharSet = eCharSetID_IsoLatin1);
|
||||
|
||||
#endif /* nsUnicharInputStream_h___ */
|
||||
|
||||
@@ -26,17 +26,12 @@
|
||||
* This class encapsulates full 64-bit integer functionality and
|
||||
* provides simple arithmetic and conversion operations.
|
||||
*/
|
||||
|
||||
// If you ever decide that you need to add a non-inline method to this
|
||||
// class, be sure to change the class declaration to "class NS_BASE
|
||||
// nsInt64".
|
||||
|
||||
class nsInt64
|
||||
class NS_BASE nsInt64
|
||||
{
|
||||
private:
|
||||
private:
|
||||
PRInt64 mValue;
|
||||
|
||||
public:
|
||||
public:
|
||||
/**
|
||||
* Construct a new 64-bit integer.
|
||||
*/
|
||||
@@ -227,7 +222,7 @@ public:
|
||||
/**
|
||||
* Add two 64-bit integers.
|
||||
*/
|
||||
inline const nsInt64
|
||||
const nsInt64
|
||||
operator +(const nsInt64& aObject1, const nsInt64& aObject2) {
|
||||
return nsInt64(aObject1) += aObject2;
|
||||
}
|
||||
|
||||
@@ -1,288 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#define NS_IMPL_IDS
|
||||
#include "nsID.h"
|
||||
|
||||
#include "nsBaseDLL.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIProperties.h"
|
||||
#include "nsIUnicharInputStream.h"
|
||||
#include "nsProperties.h"
|
||||
#include "plhash.h"
|
||||
#include "pratom.h"
|
||||
|
||||
class nsProperties : public nsIProperties
|
||||
{
|
||||
public:
|
||||
nsProperties();
|
||||
~nsProperties();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Load(nsIInputStream* aIn);
|
||||
NS_IMETHOD GetProperty(const nsString& aKey, nsString& aValue);
|
||||
NS_IMETHOD SetProperty(const nsString& aKey, nsString& aNewValue,
|
||||
nsString& aOldValue);
|
||||
NS_IMETHOD Save(nsIOutputStream* aOut, const nsString& aHeader);
|
||||
NS_IMETHOD Subclass(nsIProperties* aSubclass);
|
||||
|
||||
PRInt32 Read();
|
||||
PRInt32 SkipLine(PRInt32 c);
|
||||
PRInt32 SkipWhiteSpace(PRInt32 c);
|
||||
|
||||
nsIUnicharInputStream* mIn;
|
||||
nsIProperties* mSubclass;
|
||||
struct PLHashTable* mTable;
|
||||
};
|
||||
|
||||
nsProperties::nsProperties()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
mIn = nsnull;
|
||||
mSubclass = NS_STATIC_CAST(nsIProperties*, this);
|
||||
mTable = nsnull;
|
||||
}
|
||||
|
||||
nsProperties::~nsProperties()
|
||||
{
|
||||
if (mTable) {
|
||||
PL_HashTableDestroy(mTable);
|
||||
mTable = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
NS_DEFINE_IID(kIPropertiesIID, NS_IPROPERTIES_IID);
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsProperties, kIPropertiesIID)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsProperties::Load(nsIInputStream *aIn)
|
||||
{
|
||||
PRInt32 c;
|
||||
nsresult ret;
|
||||
|
||||
ret = NS_NewConverterStream(&mIn, nsnull, aIn);
|
||||
if (ret != NS_OK) {
|
||||
cout << "NS_NewConverterStream failed" << endl;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
c = Read();
|
||||
while (1) {
|
||||
c = SkipWhiteSpace(c);
|
||||
if (c < 0) {
|
||||
break;
|
||||
}
|
||||
else if ((c == '#') || (c == '!')) {
|
||||
c = SkipLine(c);
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
nsAutoString key("");
|
||||
while ((c >= 0) && (c != '=') && (c != ':')) {
|
||||
key.Append((PRUnichar) c);
|
||||
c = Read();
|
||||
}
|
||||
if (c < 0) {
|
||||
break;
|
||||
}
|
||||
char *trimThese = " \t";
|
||||
key.Trim(trimThese, PR_FALSE, PR_TRUE);
|
||||
c = Read();
|
||||
nsAutoString value("");
|
||||
while ((c >= 0) && (c != '\r') && (c != '\n')) {
|
||||
if (c == '\\') {
|
||||
c = Read();
|
||||
if ((c == '\r') || (c == '\n')) {
|
||||
c = SkipWhiteSpace(c);
|
||||
}
|
||||
else {
|
||||
value.Append('\\');
|
||||
}
|
||||
}
|
||||
value.Append((PRUnichar) c);
|
||||
c = Read();
|
||||
}
|
||||
value.Trim(trimThese, PR_TRUE, PR_TRUE);
|
||||
nsAutoString oldValue("");
|
||||
mSubclass->SetProperty(key, value, oldValue);
|
||||
}
|
||||
}
|
||||
mIn->Close();
|
||||
mIn = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static PLHashNumber
|
||||
HashKey(const PRUnichar *aString)
|
||||
{
|
||||
return (PLHashNumber) nsCRT::HashValue(aString);
|
||||
}
|
||||
|
||||
static PRIntn
|
||||
CompareKeys(const PRUnichar *aStr1, const PRUnichar *aStr2)
|
||||
{
|
||||
return nsCRT::strcmp(aStr1, aStr2) == 0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsProperties::SetProperty(const nsString& aKey, nsString& aNewValue,
|
||||
nsString& aOldValue)
|
||||
{
|
||||
cout << "will add " << aKey.ToNewCString() << "=" << aNewValue.ToNewCString() << endl;
|
||||
if (!mTable) {
|
||||
mTable = PL_NewHashTable(8, (PLHashFunction) HashKey,
|
||||
(PLHashComparator) CompareKeys,
|
||||
(PLHashComparator) nsnull, nsnull, nsnull);
|
||||
if (!mTable) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
PRUnichar *key = aKey.ToNewUnicode();
|
||||
PRInt32 len;
|
||||
PRUint32 hashValue = nsCRT::HashValue(key, &len);
|
||||
PLHashEntry **hep = PL_HashTableRawLookup(mTable, hashValue, key);
|
||||
PLHashEntry *he = *hep;
|
||||
if (he && aOldValue) {
|
||||
// XXX fix me
|
||||
}
|
||||
PL_HashTableRawAdd(mTable, hep, hashValue, key,
|
||||
new nsString(aNewValue.ToNewUnicode()));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsProperties::Save(nsIOutputStream* aOut, const nsString& aHeader)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsProperties::Subclass(nsIProperties* aSubclass)
|
||||
{
|
||||
if (aSubclass) {
|
||||
mSubclass = aSubclass;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsProperties::GetProperty(const nsString& aKey, nsString& aValue)
|
||||
{
|
||||
PRUnichar *key = aKey;
|
||||
PRInt32 len;
|
||||
PRUint32 hashValue = nsCRT::HashValue(key, &len);
|
||||
PLHashEntry **hep = PL_HashTableRawLookup(mTable, hashValue, key);
|
||||
PLHashEntry *he = *hep;
|
||||
if (he) {
|
||||
((nsString *) he->value)->Copy(aValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsProperties::Read()
|
||||
{
|
||||
PRUnichar c;
|
||||
PRUint32 nRead;
|
||||
nsresult ret;
|
||||
|
||||
ret = mIn->Read(&c, 0, 1, &nRead);
|
||||
if (ret == NS_OK) {
|
||||
return c;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
#define IS_WHITE_SPACE(c) \
|
||||
(((c) == ' ') || ((c) == '\t') || ((c) == '\r') || ((c) == '\n'))
|
||||
|
||||
PRInt32
|
||||
nsProperties::SkipWhiteSpace(PRInt32 c)
|
||||
{
|
||||
while ((c >= 0) && IS_WHITE_SPACE(c)) {
|
||||
c = Read();
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsProperties::SkipLine(PRInt32 c)
|
||||
{
|
||||
while ((c >= 0) && (c != '\r') && (c != '\n')) {
|
||||
c = Read();
|
||||
}
|
||||
if (c == '\r') {
|
||||
c = Read();
|
||||
}
|
||||
if (c == '\n') {
|
||||
c = Read();
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsPropertiesFactory, kIFactoryIID);
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPropertiesFactory::CreateInstance(nsISupports* aOuter, REFNSIID aIID,
|
||||
void** aResult)
|
||||
{
|
||||
if (aOuter) {
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*aResult = nsnull;
|
||||
nsProperties* props = new nsProperties();
|
||||
if (!props) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult ret = props->QueryInterface(aIID, aResult);
|
||||
if (NS_FAILED(ret)) {
|
||||
delete props;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPropertiesFactory::LockFactory(PRBool aLock)
|
||||
{
|
||||
if (aLock) {
|
||||
PR_AtomicIncrement(&gLockCount);
|
||||
}
|
||||
else {
|
||||
PR_AtomicDecrement(&gLockCount);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsProperties_h___
|
||||
#define nsProperties_h___
|
||||
|
||||
#include "nsIFactory.h"
|
||||
|
||||
class nsPropertiesFactory : nsIFactory
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CreateInstance(nsISupports* aOuter, REFNSIID aIID,
|
||||
void** aResult);
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
};
|
||||
|
||||
#endif /* nsProperties_h___ */
|
||||
@@ -1,133 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
// First checked in on 98/12/08 by John R. McMullen.
|
||||
// Since nsFileStream.h is entirely templates, common code (such as open())
|
||||
// which does not actually depend on the charT, can be placed here.
|
||||
|
||||
#ifdef XP_UNIX
|
||||
// Compile the un-inlined functions in this file only.
|
||||
#define DEFINING_FILE_STREAM
|
||||
#endif
|
||||
|
||||
#include "nsStdFileStream.h"
|
||||
|
||||
#ifdef XP_MAC
|
||||
#include <Errors.h>
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
PRFileDesc* nsFileStreamHelpers::open(
|
||||
const nsFilePath& inFile,
|
||||
IOS_BASE::openmode mode,
|
||||
PRIntn accessMode)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
PRFileDesc* descriptor = 0;
|
||||
const IOS_BASE::openmode valid_modes[]=
|
||||
{
|
||||
IOS_BASE::out,
|
||||
IOS_BASE::out | IOS_BASE::app,
|
||||
IOS_BASE::out | IOS_BASE::trunc,
|
||||
IOS_BASE::in,
|
||||
IOS_BASE::in | IOS_BASE::out,
|
||||
IOS_BASE::in | IOS_BASE::out | IOS_BASE::trunc,
|
||||
// IOS_BASE::out | IOS_BASE::binary,
|
||||
// IOS_BASE::out | IOS_BASE::app | IOS_BASE::binary,
|
||||
// IOS_BASE::out | IOS_BASE::trunc | IOS_BASE::binary,
|
||||
// IOS_BASE::in | IOS_BASE::binary,
|
||||
// IOS_BASE::in | IOS_BASE::out | IOS_BASE::binary,
|
||||
// IOS_BASE::in | IOS_BASE::out | IOS_BASE::trunc | IOS_BASE::binary,
|
||||
0
|
||||
};
|
||||
|
||||
const int nspr_modes[]={
|
||||
PR_WRONLY | PR_CREATE_FILE,
|
||||
PR_WRONLY | PR_CREATE_FILE | PR_APPEND,
|
||||
PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE,
|
||||
PR_RDONLY,
|
||||
PR_RDONLY | PR_APPEND,
|
||||
PR_RDWR | PR_CREATE_FILE,
|
||||
PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE,
|
||||
// "wb",
|
||||
// "ab",
|
||||
// "wb",
|
||||
// "rb",
|
||||
// "r+b",
|
||||
// "w+b",
|
||||
0 };
|
||||
int ind=0;
|
||||
while (valid_modes[ind] && valid_modes[ind] != (mode&~IOS_BASE::ate))
|
||||
++ind;
|
||||
if (!nspr_modes[ind])
|
||||
return 0;
|
||||
|
||||
#ifdef XP_MAC
|
||||
// Use the file spec to open the file, because one path can be common to
|
||||
// several files on the Macintosh (you can have several volumes with the
|
||||
// same name, see).
|
||||
descriptor = 0;
|
||||
if (inFile.GetNativeSpec().Error() != noErr)
|
||||
return 0;
|
||||
OSErr err = noErr;
|
||||
#if DEBUG
|
||||
const OSType kCreator = 'CWIE';
|
||||
#else
|
||||
const OSType kCreator = 'MOSS';
|
||||
#endif
|
||||
nsNativeFileSpec nativeSpec = inFile.GetNativeSpec();
|
||||
FSSpec* spec = (FSSpec*)nativeSpec;
|
||||
if (nspr_modes[ind] & PR_CREATE_FILE)
|
||||
err = FSpCreate(spec, kCreator, 'TEXT', 0);
|
||||
if (err == dupFNErr)
|
||||
err = noErr;
|
||||
if (err != noErr)
|
||||
return 0;
|
||||
|
||||
SInt8 perm;
|
||||
if (nspr_modes[ind] & PR_RDWR)
|
||||
perm = fsRdWrPerm;
|
||||
else if (nspr_modes[ind] & PR_WRONLY)
|
||||
perm = fsWrPerm;
|
||||
else
|
||||
perm = fsRdPerm;
|
||||
|
||||
short refnum;
|
||||
err = FSpOpenDF(spec, perm, &refnum);
|
||||
|
||||
if (err == noErr && (nspr_modes[ind] & PR_TRUNCATE))
|
||||
err = SetEOF(refnum, 0);
|
||||
if (err == noErr && (nspr_modes[ind] & PR_APPEND))
|
||||
err = SetFPos(refnum, fsFromLEOF, 0);
|
||||
if (err != noErr)
|
||||
return 0;
|
||||
|
||||
if ((descriptor = PR_ImportFile(refnum)) == 0)
|
||||
return 0;
|
||||
#else
|
||||
// Platforms other than Macintosh...
|
||||
if ((descriptor = PR_Open(inFile, nspr_modes[ind], accessMode)) != 0)
|
||||
#endif
|
||||
if (mode&IOS_BASE::ate && PR_Seek(descriptor, 0, PR_SEEK_END) >= 0)
|
||||
{
|
||||
PR_Close(descriptor);
|
||||
descriptor = 0;
|
||||
return 0;
|
||||
}
|
||||
return descriptor;
|
||||
} // nsFileStreamHelpers::open
|
||||
@@ -39,63 +39,6 @@ PRUnichar kCommonEmptyBuffer[100]; //shared by all strings; NEVER WRITE HERE!!
|
||||
PRBool nsString::mSelfTested = PR_FALSE;
|
||||
|
||||
|
||||
|
||||
#define NOT_USED 0xfffd
|
||||
|
||||
static PRUint16 PA_HackTable[] = {
|
||||
NOT_USED,
|
||||
NOT_USED,
|
||||
0x201a, /* SINGLE LOW-9 QUOTATION MARK */
|
||||
0x0192, /* LATIN SMALL LETTER F WITH HOOK */
|
||||
0x201e, /* DOUBLE LOW-9 QUOTATION MARK */
|
||||
0x2026, /* HORIZONTAL ELLIPSIS */
|
||||
0x2020, /* DAGGER */
|
||||
0x2021, /* DOUBLE DAGGER */
|
||||
0x02c6, /* MODIFIER LETTER CIRCUMFLEX ACCENT */
|
||||
0x2030, /* PER MILLE SIGN */
|
||||
0x0160, /* LATIN CAPITAL LETTER S WITH CARON */
|
||||
0x2039, /* SINGLE LEFT-POINTING ANGLE QUOTATION MARK */
|
||||
0x0152, /* LATIN CAPITAL LIGATURE OE */
|
||||
NOT_USED,
|
||||
NOT_USED,
|
||||
NOT_USED,
|
||||
|
||||
NOT_USED,
|
||||
0x2018, /* LEFT SINGLE QUOTATION MARK */
|
||||
0x2019, /* RIGHT SINGLE QUOTATION MARK */
|
||||
0x201c, /* LEFT DOUBLE QUOTATION MARK */
|
||||
0x201d, /* RIGHT DOUBLE QUOTATION MARK */
|
||||
0x2022, /* BULLET */
|
||||
0x2013, /* EN DASH */
|
||||
0x2014, /* EM DASH */
|
||||
0x02dc, /* SMALL TILDE */
|
||||
0x2122, /* TRADE MARK SIGN */
|
||||
0x0161, /* LATIN SMALL LETTER S WITH CARON */
|
||||
0x203a, /* SINGLE RIGHT-POINTING ANGLE QUOTATION MARK */
|
||||
0x0153, /* LATIN SMALL LIGATURE OE */
|
||||
NOT_USED,
|
||||
NOT_USED,
|
||||
0x0178 /* LATIN CAPITAL LETTER Y WITH DIAERESIS */
|
||||
};
|
||||
|
||||
static PRUnichar gToUCS2[256];
|
||||
|
||||
class CTableConstructor {
|
||||
public:
|
||||
CTableConstructor(){
|
||||
PRUnichar* cp = gToUCS2;
|
||||
PRInt32 i;
|
||||
for (i = 0; i < 256; i++) {
|
||||
*cp++ = PRUnichar(i);
|
||||
}
|
||||
cp = gToUCS2;
|
||||
for (i = 0; i < 32; i++) {
|
||||
cp[0x80 + i] = PA_HackTable[i];
|
||||
}
|
||||
}
|
||||
};
|
||||
static CTableConstructor gTableConstructor;
|
||||
|
||||
/***********************************************************************
|
||||
IMPLEMENTATION NOTES:
|
||||
|
||||
@@ -126,15 +69,15 @@ nsString::nsString() {
|
||||
/**
|
||||
* This constructor accepts an isolatin string
|
||||
* @update gess7/30/98
|
||||
* @param aCString is a ptr to a 1-byte cstr
|
||||
* @param anISOLatin1 is a ptr to a 1-byte cstr
|
||||
*/
|
||||
nsString::nsString(const char* aCString) {
|
||||
nsString::nsString(const char* anISOLatin1) {
|
||||
mLength=mCapacity=0;
|
||||
mStr = kCommonEmptyBuffer;
|
||||
if(aCString) {
|
||||
PRInt32 len=strlen(aCString);
|
||||
if(anISOLatin1) {
|
||||
PRInt32 len=strlen(anISOLatin1);
|
||||
EnsureCapacityFor(len);
|
||||
this->SetString(aCString,len);
|
||||
this->SetString(anISOLatin1,len);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +159,7 @@ PRBool nsString::IsOrdered(void) const {
|
||||
if(mLength>1) {
|
||||
PRInt32 theIndex;
|
||||
for(theIndex=1;theIndex<mLength;theIndex++) {
|
||||
if(mStr[theIndex-1]>mStr[theIndex]) {
|
||||
if(mStr[theIndex-1]>=mStr[theIndex]) {
|
||||
result=PR_FALSE;
|
||||
break;
|
||||
}
|
||||
@@ -376,12 +319,12 @@ nsString nsString::operator+(const nsString& aString){
|
||||
/**
|
||||
* create a new string by adding this to the given buffer.
|
||||
* @update gess 7/27/98
|
||||
* @param aCString is a ptr to cstring to be added to this
|
||||
* @param anISOLatin1 is a ptr to cstring to be added to this
|
||||
* @return newly created string
|
||||
*/
|
||||
nsString nsString::operator+(const char* aCString) {
|
||||
nsString nsString::operator+(const char* anISOLatin1) {
|
||||
nsString temp(*this);
|
||||
temp.Append(aCString);
|
||||
temp.Append(anISOLatin1);
|
||||
return temp;
|
||||
}
|
||||
|
||||
@@ -459,23 +402,6 @@ void nsString::ToUpperCase()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts all chars in given string to UCS2
|
||||
*/
|
||||
void nsString::ToUCS2(PRInt32 aStartOffset){
|
||||
if(aStartOffset<mLength){
|
||||
chartype* cp = &mStr[aStartOffset];
|
||||
chartype* end = cp + mLength;
|
||||
while (cp < end) {
|
||||
unsigned char ch = (unsigned char)*cp;
|
||||
*cp=gToUCS2[ch];
|
||||
cp++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Converts chars in this to lowercase, and
|
||||
* stores them in aOut
|
||||
@@ -532,10 +458,9 @@ nsString* nsString::ToNewString() const {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an aCString clone of this string
|
||||
* NOTE: Call delete[] when you're done with this copy. NOT free!
|
||||
* Creates an ISOLatin1 clone of this string
|
||||
* @update gess 7/27/98
|
||||
* @return ptr to new aCString string
|
||||
* @return ptr to new isolatin1 string
|
||||
*/
|
||||
char* nsString::ToNewCString() const
|
||||
{
|
||||
@@ -615,77 +540,60 @@ float nsString::ToFloat(PRInt32* aErrorCode) const
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform numeric string to int conversion with given radix.
|
||||
* @update gess 10/01/98
|
||||
* Perform string to int conversion.
|
||||
* @update gess 7/27/98
|
||||
* @param aErrorCode will contain error if one occurs
|
||||
* @param aRadix tells us what base to expect the string in.
|
||||
* @return int rep of string value; aErrorCode gets set too: NS_OK, NS_ERROR_ILLEGAL_VALUE
|
||||
* @return int rep of string value
|
||||
*/
|
||||
PRInt32 nsString::ToInteger(PRInt32* aErrorCode,PRInt32 aRadix) const {
|
||||
PRInt32 result = 0;
|
||||
PRInt32 decPt=Find(PRUnichar('.'),0);
|
||||
PRUnichar* cp = (-1==decPt) ? mStr + mLength-1 : mStr+decPt-1;
|
||||
char digit=0;
|
||||
PRUnichar theChar;
|
||||
PRInt32 theShift=0;
|
||||
PRInt32 theMult=1;
|
||||
PRInt32 nsString::ToInteger(PRInt32* aErrorCode) const {
|
||||
PRInt32 rv = 0;
|
||||
PRUnichar* cp = mStr;
|
||||
PRUnichar* end = mStr + mLength;
|
||||
|
||||
*aErrorCode = (0<mLength) ? NS_OK : NS_ERROR_ILLEGAL_VALUE;
|
||||
|
||||
|
||||
// Skip trailing non-numeric...
|
||||
while (cp >= mStr) {
|
||||
theChar = *cp;
|
||||
if((theChar>='0') && (theChar<='9')){
|
||||
// Skip leading whitespace
|
||||
while (cp < end) {
|
||||
PRUnichar ch = *cp;
|
||||
if (!IsSpace(ch)) {
|
||||
break;
|
||||
}
|
||||
else if((theChar>='a') && (theChar<='f')) {
|
||||
break;
|
||||
}
|
||||
else if((theChar>='A') && (theChar<='F')) {
|
||||
break;
|
||||
}
|
||||
cp--;
|
||||
cp++;
|
||||
}
|
||||
if (cp == end) {
|
||||
*aErrorCode = (PRInt32) NS_ERROR_ILLEGAL_VALUE;
|
||||
return rv;
|
||||
}
|
||||
|
||||
//now iterate the numeric chars and build our result
|
||||
while(cp>=mStr) {
|
||||
theChar=*cp--;
|
||||
if((theChar>='0') && (theChar<='9')){
|
||||
digit=theChar-'0';
|
||||
}
|
||||
else if((theChar>='a') && (theChar<='f')) {
|
||||
digit=(theChar-'a')+10;
|
||||
}
|
||||
else if((theChar>='A') && (theChar<='F')) {
|
||||
digit=(theChar-'A')+10;
|
||||
}
|
||||
else if('-'==theChar) {
|
||||
result=-result;
|
||||
break;
|
||||
}
|
||||
else if('+'==theChar) { //stop in a good state if you see this...
|
||||
break;
|
||||
}
|
||||
else if(' '==theChar){ //stop in a good state if you see this...
|
||||
break;
|
||||
}
|
||||
else{
|
||||
*aErrorCode=NS_ERROR_ILLEGAL_VALUE;
|
||||
result=0;
|
||||
break;
|
||||
}
|
||||
result+=digit*theMult;
|
||||
theMult*=aRadix;
|
||||
// Check for sign
|
||||
PRUnichar sign = '+';
|
||||
if ((*cp == '+') || (*cp == '-')) {
|
||||
sign = *cp++;
|
||||
}
|
||||
|
||||
return result;
|
||||
if (cp == end) {
|
||||
*aErrorCode = (PRInt32) NS_ERROR_ILLEGAL_VALUE;
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Convert the number
|
||||
while (cp < end) {
|
||||
PRUnichar ch = *cp++;
|
||||
if ((ch < '0') || (ch > '9')) {
|
||||
*aErrorCode = (PRInt32) NS_ERROR_ILLEGAL_VALUE;
|
||||
break;
|
||||
}
|
||||
rv = rv * 10 + (ch - '0');
|
||||
}
|
||||
|
||||
if (sign == '-') {
|
||||
rv = -rv;
|
||||
}
|
||||
*aErrorCode = NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* assign given PRUnichar* to this string
|
||||
* @update gess 7/27/98
|
||||
* @param PRUnichar: buffer to be assigned to this
|
||||
* @param anISOLatin1: buffer to be assigned to this
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::SetString(const PRUnichar* aStr,PRInt32 aLength) {
|
||||
@@ -711,19 +619,16 @@ nsString& nsString::SetString(const PRUnichar* aStr,PRInt32 aLength) {
|
||||
/**
|
||||
* assign given char* to this string
|
||||
* @update gess 7/27/98
|
||||
* @param aCString: buffer to be assigned to this
|
||||
* @param anISOLatin1: buffer to be assigned to this
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::SetString(const char* aCString,PRInt32 aLength) {
|
||||
if(aCString!=0) {
|
||||
PRInt32 len=(aLength<0) ? nsCRT::strlen(aCString) : aLength;
|
||||
nsString& nsString::SetString(const char* anISOLatin1,PRInt32 aLength) {
|
||||
if(anISOLatin1!=0) {
|
||||
PRInt32 len=(aLength<0) ? nsCRT::strlen(anISOLatin1) : aLength;
|
||||
if(mCapacity<=len)
|
||||
EnsureCapacityFor(len);
|
||||
const unsigned char* from = (const unsigned char*) aCString;
|
||||
const unsigned char* end = from + len;
|
||||
PRUnichar* dst = mStr;
|
||||
while (from < end) {
|
||||
*dst++ = PRUnichar(*from++);
|
||||
for(int i=0;i<len;i++) {
|
||||
mStr[i]=chartype(anISOLatin1[i]);
|
||||
}
|
||||
mLength=len;
|
||||
mStr[mLength]=0;
|
||||
@@ -738,7 +643,7 @@ nsString& nsString::SetString(const char* aCString,PRInt32 aLength) {
|
||||
/**
|
||||
* assign given char* to this string
|
||||
* @update gess 7/27/98
|
||||
* @param PRUnichar: buffer to be assigned to this
|
||||
* @param anISOLatin1: buffer to be assigned to this
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::operator=(const PRUnichar* aStr) {
|
||||
@@ -759,11 +664,11 @@ nsString& nsString::operator=(const nsString& aString) {
|
||||
/**
|
||||
* assign given char* to this string
|
||||
* @update gess 7/27/98
|
||||
* @param aCString: buffer to be assigned to this
|
||||
* @param anISOLatin1: buffer to be assigned to this
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::operator=(const char* aCString) {
|
||||
return SetString(aCString);
|
||||
nsString& nsString::operator=(const char* anISOLatin1) {
|
||||
return SetString(anISOLatin1);
|
||||
}
|
||||
|
||||
|
||||
@@ -808,17 +713,14 @@ nsString& nsString::Append(const nsString& aString,PRInt32 aLength) {
|
||||
* @param aString : string to be appended to this
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Append(const char* aCString,PRInt32 aLength) {
|
||||
if(aCString!=0) {
|
||||
PRInt32 len=(aLength<0) ? strlen(aCString) : aLength;
|
||||
nsString& nsString::Append(const char* anISOLatin1,PRInt32 aLength) {
|
||||
if(anISOLatin1!=0) {
|
||||
PRInt32 len=(aLength<0) ? strlen(anISOLatin1) : aLength;
|
||||
if(mLength+len >= mCapacity) {
|
||||
EnsureCapacityFor(mLength+len);
|
||||
}
|
||||
const unsigned char* from = (const unsigned char*) aCString;
|
||||
const unsigned char* end = from + len;
|
||||
PRUnichar* to = mStr + mLength;
|
||||
while (from < end) {
|
||||
*to++ = PRUnichar(*from++);
|
||||
for(int i=0;i<len;i++) {
|
||||
mStr[mLength+i]=chartype(anISOLatin1[i]);
|
||||
}
|
||||
mLength+=len;
|
||||
mStr[mLength]=0;
|
||||
@@ -891,11 +793,11 @@ nsString& nsString::operator+=(const nsString &aString) {
|
||||
/**
|
||||
* append given buffer to this string
|
||||
* @update gess 7/27/98
|
||||
* @param aCString: buffer to be appended to this
|
||||
* @param anISOLatin1: buffer to be appended to this
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::operator+=(const char* aCString) {
|
||||
return Append(aCString);
|
||||
nsString& nsString::operator+=(const char* anISOLatin1) {
|
||||
return Append(anISOLatin1);
|
||||
}
|
||||
|
||||
|
||||
@@ -965,7 +867,7 @@ nsString& nsString::Append(float aFloat){
|
||||
* @param aCount -- number of chars to copy
|
||||
* @return number of chars copied
|
||||
*/
|
||||
PRInt32 nsString::Left(nsString& aCopy,PRInt32 aCount) const {
|
||||
PRInt32 nsString::Left(nsString& aCopy,PRInt32 aCount) {
|
||||
return Mid(aCopy,0,aCount);
|
||||
}
|
||||
|
||||
@@ -980,7 +882,7 @@ PRInt32 nsString::Left(nsString& aCopy,PRInt32 aCount) const {
|
||||
* @param anOffset -- position where copying begins
|
||||
* @return number of chars copied
|
||||
*/
|
||||
PRInt32 nsString::Mid(nsString& aCopy,PRInt32 anOffset,PRInt32 aCount) const {
|
||||
PRInt32 nsString::Mid(nsString& aCopy,PRInt32 anOffset,PRInt32 aCount) {
|
||||
if(anOffset<mLength) {
|
||||
aCount=(anOffset+aCount<=mLength) ? aCount : mLength-anOffset;
|
||||
|
||||
@@ -1007,7 +909,7 @@ PRInt32 nsString::Mid(nsString& aCopy,PRInt32 anOffset,PRInt32 aCount) const {
|
||||
* @param aCount -- number of chars to copy
|
||||
* @return number of chars copied
|
||||
*/
|
||||
PRInt32 nsString::Right(nsString& aCopy,PRInt32 aCount) const {
|
||||
PRInt32 nsString::Right(nsString& aCopy,PRInt32 aCount) {
|
||||
PRInt32 offset=(mLength-aCount<0) ? 0 : mLength-aCount;
|
||||
return Mid(aCopy,offset,aCount);
|
||||
}
|
||||
@@ -1023,9 +925,8 @@ PRInt32 nsString::Right(nsString& aCopy,PRInt32 aCount) const {
|
||||
* @param aCount -- number of chars to be copied from aCopy
|
||||
* @return number of chars inserted into this.
|
||||
*/
|
||||
PRInt32 nsString::Insert(const nsString& aCopy,PRInt32 anOffset,PRInt32 aCount) {
|
||||
PRInt32 nsString::Insert(nsString& aCopy,PRInt32 anOffset,PRInt32 aCount) {
|
||||
aCount=(aCount>aCopy.mLength) ? aCopy.mLength : aCount; //don't try to copy more than you are given
|
||||
if (aCount < 0) aCount = aCopy.mLength;
|
||||
if(0<=anOffset) {
|
||||
if(aCount>0) {
|
||||
|
||||
@@ -1206,8 +1107,8 @@ PRBool nsString::IsSpace(PRUnichar aChar) {
|
||||
* @return this
|
||||
*/
|
||||
nsString& nsString::Trim(const char* aTrimSet,
|
||||
PRBool aEliminateLeading,
|
||||
PRBool aEliminateTrailing)
|
||||
PRBool aEliminateLeading,
|
||||
PRBool aEliminateTrailing)
|
||||
{
|
||||
PRUnichar* from = mStr;
|
||||
PRUnichar* end = mStr + mLength-1;
|
||||
@@ -1334,18 +1235,18 @@ PRInt32 nsString::BinarySearch(PRUnichar aChar) const {
|
||||
* Search for given buffer within this string
|
||||
*
|
||||
* @update gess 3/25/98
|
||||
* @param aCStringBuf - charstr to be found
|
||||
* @param anISOLatin1Buf - charstr to be found
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 nsString::Find(const char* aCStringBuf) const{
|
||||
NS_ASSERTION(0!=aCStringBuf,kNullPointerError);
|
||||
PRInt32 nsString::Find(const char* anISOLatin1Buf) const{
|
||||
NS_ASSERTION(0!=anISOLatin1Buf,kNullPointerError);
|
||||
PRInt32 result=kNotFound;
|
||||
if(aCStringBuf) {
|
||||
PRInt32 len=strlen(aCStringBuf);
|
||||
if(anISOLatin1Buf) {
|
||||
PRInt32 len=strlen(anISOLatin1Buf);
|
||||
if((0<len) && (len<=mLength)) { //only enter if abuffer length is <= mStr length.
|
||||
PRInt32 max=mLength-len;
|
||||
for(PRInt32 offset=0;offset<=max;offset++)
|
||||
if(0==nsCRT::strncmp(&mStr[offset],aCStringBuf,len))
|
||||
if(0==nsCRT::strncmp(&mStr[offset],anISOLatin1Buf,len))
|
||||
return offset; //in this case, 0 means they match
|
||||
}
|
||||
}
|
||||
@@ -1422,11 +1323,11 @@ PRInt32 nsString::Find(PRUnichar aChar, PRInt32 anOffset) const{
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
PRInt32 nsString::FindCharInSet(const char* anAsciiSet,PRInt32 anOffset) const{
|
||||
NS_ASSERTION(0!=anAsciiSet,kNullPointerError);
|
||||
if(anAsciiSet && (strlen(anAsciiSet))) {
|
||||
PRInt32 nsString::FindCharInSet(const char* anISOLatin1Set,PRInt32 anOffset) const{
|
||||
NS_ASSERTION(0!=anISOLatin1Set,kNullPointerError);
|
||||
if(anISOLatin1Set && (strlen(anISOLatin1Set))) {
|
||||
for(PRInt32 i=anOffset;i<mLength;i++){
|
||||
char* pos=strchr(anAsciiSet,char(mStr[i]));
|
||||
char* pos=strchr(anISOLatin1Set,char(mStr[i]));
|
||||
if(pos)
|
||||
return i;
|
||||
}
|
||||
@@ -1459,11 +1360,11 @@ PRInt32 nsString::FindCharInSet(nsString& aSet,PRInt32 anOffset) const{
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
PRInt32 nsString::RFindCharInSet(const char* anAsciiSet,PRInt32 anOffset) const{
|
||||
NS_ASSERTION(0!=anAsciiSet,kNullPointerError);
|
||||
if(anAsciiSet && strlen(anAsciiSet)) {
|
||||
PRInt32 nsString::RFindCharInSet(const char* anISOLatin1Set,PRInt32 anOffset) const{
|
||||
NS_ASSERTION(0!=anISOLatin1Set,kNullPointerError);
|
||||
if(anISOLatin1Set && strlen(anISOLatin1Set)) {
|
||||
for(PRInt32 i=mLength-1;i>0;i--){
|
||||
char* pos=strchr(anAsciiSet,char(mStr[i]));
|
||||
char* pos=strchr(anISOLatin1Set,char(mStr[i]));
|
||||
if(pos)
|
||||
return i;
|
||||
}
|
||||
@@ -1544,17 +1445,17 @@ PRInt32 nsString::RFind(const nsString& aString,PRBool aIgnoreCase) const{
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
PRInt32 nsString::RFind(const char* anAsciiSet,PRBool aIgnoreCase) const{
|
||||
NS_ASSERTION(0!=anAsciiSet,kNullPointerError);
|
||||
PRInt32 nsString::RFind(const char* anISOLatin1Set,PRBool aIgnoreCase) const{
|
||||
NS_ASSERTION(0!=anISOLatin1Set,kNullPointerError);
|
||||
|
||||
if(anAsciiSet) {
|
||||
PRInt32 len=strlen(anAsciiSet);
|
||||
if(anISOLatin1Set) {
|
||||
PRInt32 len=strlen(anISOLatin1Set);
|
||||
if((len) && (len<=mLength)) { //only enter if abuffer length is <= mStr length.
|
||||
for(PRInt32 offset=mLength-len;offset>=0;offset--) {
|
||||
PRInt32 result=0;
|
||||
if(aIgnoreCase)
|
||||
result=nsCRT::strncasecmp(&mStr[offset],anAsciiSet,len);
|
||||
else result=nsCRT::strncmp(&mStr[offset],anAsciiSet,len);
|
||||
result=nsCRT::strncasecmp(&mStr[offset],anISOLatin1Set,len);
|
||||
else result=nsCRT::strncmp(&mStr[offset],anISOLatin1Set,len);
|
||||
if(0==result)
|
||||
return offset; //in this case, 0 means they match
|
||||
}
|
||||
@@ -1592,12 +1493,12 @@ PRInt32 nsString::RFind(PRUnichar aChar,PRBool aIgnoreCase) const{
|
||||
/**
|
||||
* Compares given cstring to this string.
|
||||
* @update gess 7/27/98
|
||||
* @param aCString pts to a cstring
|
||||
* @param anISOLatin1 pts to a cstring
|
||||
* @param aIgnoreCase tells us how to treat case
|
||||
* @return -1,0,1
|
||||
*/
|
||||
PRInt32 nsString::Compare(const char *aCString,PRBool aIgnoreCase,PRInt32 aLength) const {
|
||||
NS_ASSERTION(0!=aCString,kNullPointerError);
|
||||
PRInt32 nsString::Compare(const char *anISOLatin1,PRBool aIgnoreCase,PRInt32 aLength) const {
|
||||
NS_ASSERTION(0!=anISOLatin1,kNullPointerError);
|
||||
|
||||
if(-1!=aLength) {
|
||||
|
||||
@@ -1605,23 +1506,16 @@ PRInt32 nsString::Compare(const char *aCString,PRBool aIgnoreCase,PRInt32 aLengt
|
||||
//In some cases, this can speed up the string comparison.
|
||||
|
||||
int maxlen=(aLength<mLength) ? aLength : mLength;
|
||||
if (maxlen == 0) {
|
||||
if ((mLength == 0) && (aLength == 0))
|
||||
return 0;
|
||||
if (mLength == 0)
|
||||
return -1;
|
||||
return 1;
|
||||
}
|
||||
if (aIgnoreCase) {
|
||||
return nsCRT::strncasecmp(mStr,aCString,maxlen);
|
||||
return nsCRT::strncasecmp(mStr,anISOLatin1,maxlen);
|
||||
}
|
||||
return nsCRT::strncmp(mStr,aCString,maxlen);
|
||||
return nsCRT::strncmp(mStr,anISOLatin1,maxlen);
|
||||
}
|
||||
|
||||
if (aIgnoreCase) {
|
||||
return nsCRT::strcasecmp(mStr,aCString);
|
||||
return nsCRT::strcasecmp(mStr,anISOLatin1);
|
||||
}
|
||||
return nsCRT::strcmp(mStr,aCString);
|
||||
return nsCRT::strcmp(mStr,anISOLatin1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1632,17 +1526,10 @@ PRInt32 nsString::Compare(const char *aCString,PRBool aIgnoreCase,PRInt32 aLengt
|
||||
*/
|
||||
PRInt32 nsString::Compare(const nsString &S,PRBool aIgnoreCase) const {
|
||||
int maxlen=(S.mLength<mLength) ? S.mLength : mLength;
|
||||
if (maxlen == 0) {
|
||||
if ((mLength == 0) && (S.mLength == 0))
|
||||
return 0;
|
||||
if (mLength == 0)
|
||||
return -1;
|
||||
return 1;
|
||||
}
|
||||
if (aIgnoreCase) {
|
||||
return nsCRT::strcasecmp(mStr,S.mStr);
|
||||
return nsCRT::strncasecmp(mStr,S.mStr,maxlen);
|
||||
}
|
||||
return nsCRT::strcmp(mStr,S.mStr);
|
||||
return nsCRT::strncmp(mStr,S.mStr,maxlen);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1659,13 +1546,6 @@ PRInt32 nsString::Compare(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aL
|
||||
//In some cases, this can speed up the string comparison.
|
||||
|
||||
int maxlen=(aLength<mLength) ? aLength : mLength;
|
||||
if (maxlen == 0) {
|
||||
if ((mLength == 0) && (aLength == 0))
|
||||
return 0;
|
||||
if (mLength == 0)
|
||||
return -1;
|
||||
return 1;
|
||||
}
|
||||
if (aIgnoreCase) {
|
||||
return nsCRT::strncasecmp(mStr,aString,maxlen);
|
||||
}
|
||||
@@ -1896,11 +1776,11 @@ nsAutoString::nsAutoString()
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsAutoString::nsAutoString(const char* aCString)
|
||||
nsAutoString::nsAutoString(const char* isolatin1)
|
||||
: nsString()
|
||||
{
|
||||
INIT_AUTO_STRING();
|
||||
SetString(aCString);
|
||||
SetString(isolatin1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2065,17 +1945,6 @@ NS_BASE int fputs(const nsString& aString, FILE* out)
|
||||
* @return
|
||||
*/
|
||||
void nsString::SelfTest(void) {
|
||||
|
||||
nsAutoString a("foobar");
|
||||
nsAutoString b("foo");
|
||||
nsAutoString c(".5111");
|
||||
nsAutoString d(" 5");
|
||||
PRInt32 result=a.Compare(b);
|
||||
PRInt32 result2=result;
|
||||
result=c.ToInteger(&result2);
|
||||
result=d.ToInteger(&result2);
|
||||
result2=result;
|
||||
|
||||
#if 0
|
||||
|
||||
static const char* kConstructorError = kConstructorError;
|
||||
|
||||
@@ -54,9 +54,9 @@ nsString();
|
||||
|
||||
/**
|
||||
* This constructor accepts an isolatin string
|
||||
* @param an ascii is a ptr to a 1-byte cstr
|
||||
* @param anISOLatin1 is a ptr to a 1-byte cstr
|
||||
*/
|
||||
nsString(const char* aCString);
|
||||
nsString(const char* anISOLatin1);
|
||||
|
||||
/**
|
||||
* This is our copy constructor
|
||||
@@ -184,10 +184,10 @@ nsString operator+(const nsString& aString);
|
||||
|
||||
/**
|
||||
* create a new string by adding this to the given buffer.
|
||||
* @param aCString is a ptr to cstring to be added to this
|
||||
* @param anISOLatin1 is a ptr to cstring to be added to this
|
||||
* @return newly created string
|
||||
*/
|
||||
nsString operator+(const char* aCString);
|
||||
nsString operator+(const char* anISOLatin1);
|
||||
|
||||
/**
|
||||
* create a new string by adding this to the given char.
|
||||
@@ -225,12 +225,6 @@ void ToLowerCase(nsString& aString) const;
|
||||
*/
|
||||
void ToUpperCase();
|
||||
|
||||
/**
|
||||
* Converts all chars in given string to UCS2
|
||||
* which ensure that the lower 256 chars are correct.
|
||||
*/
|
||||
void ToUCS2(PRInt32 aStartOffset);
|
||||
|
||||
/**
|
||||
* Converts all chars in internal string to upper
|
||||
*/
|
||||
@@ -243,9 +237,8 @@ void ToUpperCase(nsString& aString) const;
|
||||
nsString* ToNewString() const;
|
||||
|
||||
/**
|
||||
* Creates an ascii clone of this string
|
||||
* NOTE: This string is allocated with new; YOU MUST deallocate with delete[]!
|
||||
* @return ptr to new c-String string
|
||||
* Creates an ISOLatin1 clone of this string
|
||||
* @return ptr to new isolatin1 string
|
||||
*/
|
||||
char* ToNewCString() const;
|
||||
|
||||
@@ -282,7 +275,7 @@ float ToFloat(PRInt32* aErrorCode) const;
|
||||
* @param aErrorCode will contain error if one occurs
|
||||
* @return int rep of string value
|
||||
*/
|
||||
PRInt32 ToInteger(PRInt32* aErrorCode,PRInt32 aRadix=10) const;
|
||||
PRInt32 ToInteger(PRInt32* aErrorCode) const;
|
||||
|
||||
/**********************************************************************
|
||||
String manipulation methods...
|
||||
@@ -290,7 +283,7 @@ PRInt32 ToInteger(PRInt32* aErrorCode,PRInt32 aRadix=10) const;
|
||||
|
||||
/**
|
||||
* assign given PRUnichar* to this string
|
||||
* @param aStr: buffer to be assigned to this
|
||||
* @param anISOLatin1: buffer to be assigned to this
|
||||
* @param alength is the length of the given str (or -1)
|
||||
if you want me to determine its length
|
||||
* @return this
|
||||
@@ -299,12 +292,12 @@ nsString& SetString(const PRUnichar* aStr,PRInt32 aLength=-1);
|
||||
|
||||
/**
|
||||
* assign given char* to this string
|
||||
* @param aCString: buffer to be assigned to this
|
||||
* @param anISOLatin1: buffer to be assigned to this
|
||||
* @param alength is the length of the given str (or -1)
|
||||
if you want me to determine its length
|
||||
* @return this
|
||||
*/
|
||||
nsString& SetString(const char* aCString,PRInt32 aLength=-1);
|
||||
nsString& SetString(const char* anISOLatin1,PRInt32 aLength=-1);
|
||||
|
||||
/**
|
||||
* assign given string to this one
|
||||
@@ -315,10 +308,10 @@ nsString& operator=(const nsString& aString);
|
||||
|
||||
/**
|
||||
* assign given char* to this string
|
||||
* @param aCString: buffer to be assigned to this
|
||||
* @param anISOLatin1: buffer to be assigned to this
|
||||
* @return this
|
||||
*/
|
||||
nsString& operator=(const char* aCString);
|
||||
nsString& operator=(const char* anISOLatin1);
|
||||
|
||||
/**
|
||||
* assign given char to this string
|
||||
@@ -350,10 +343,10 @@ nsString& operator+=(const nsString& aString);
|
||||
|
||||
/**
|
||||
* append given buffer to this string
|
||||
* @param aCString: buffer to be appended to this
|
||||
* @param anISOLatin1: buffer to be appended to this
|
||||
* @return this
|
||||
*/
|
||||
nsString& operator+=(const char* aCString);
|
||||
nsString& operator+=(const char* anISOLatin1);
|
||||
|
||||
/**
|
||||
* append given buffer to this string
|
||||
@@ -385,7 +378,7 @@ nsString& Append(const nsString& aString,PRInt32 aLength=-1);
|
||||
if you want me to determine its length
|
||||
* @return this
|
||||
*/
|
||||
nsString& Append(const char* aCString,PRInt32 aLength=-1);
|
||||
nsString& Append(const char* anISOLatin1,PRInt32 aLength=-1);
|
||||
|
||||
/**
|
||||
* append given string to this string
|
||||
@@ -434,7 +427,7 @@ nsString& Append(float aFloat);
|
||||
* @param aCount -- number of chars to copy
|
||||
* @return number of chars copied
|
||||
*/
|
||||
PRInt32 Left(nsString& aCopy,PRInt32 aCount) const;
|
||||
PRInt32 Left(nsString& aCopy,PRInt32 aCount);
|
||||
|
||||
/*
|
||||
* Copies n characters from this string to given string,
|
||||
@@ -446,7 +439,7 @@ PRInt32 Left(nsString& aCopy,PRInt32 aCount) const;
|
||||
* @param anOffset -- position where copying begins
|
||||
* @return number of chars copied
|
||||
*/
|
||||
PRInt32 Mid(nsString& aCopy,PRInt32 anOffset,PRInt32 aCount) const;
|
||||
PRInt32 Mid(nsString& aCopy,PRInt32 anOffset,PRInt32 aCount);
|
||||
|
||||
/*
|
||||
* Copies n characters from this string to given string,
|
||||
@@ -457,7 +450,7 @@ PRInt32 Mid(nsString& aCopy,PRInt32 anOffset,PRInt32 aCount) const;
|
||||
* @param aCount -- number of chars to copy
|
||||
* @return number of chars copied
|
||||
*/
|
||||
PRInt32 Right(nsString& aCopy,PRInt32 aCount) const;
|
||||
PRInt32 Right(nsString& aCopy,PRInt32 aCount);
|
||||
|
||||
/*
|
||||
* This method inserts n chars from given string into this
|
||||
@@ -468,7 +461,7 @@ PRInt32 Right(nsString& aCopy,PRInt32 aCount) const;
|
||||
* @param aCount -- number of chars to be copied from aCopy
|
||||
* @return number of chars inserted into this.
|
||||
*/
|
||||
PRInt32 Insert(const nsString& aCopy,PRInt32 anOffset,PRInt32 aCount=-1);
|
||||
PRInt32 Insert(nsString& aCopy,PRInt32 anOffset,PRInt32 aCount=-1);
|
||||
|
||||
/**
|
||||
* Insert a single unicode char into this string at
|
||||
@@ -613,7 +606,7 @@ PRInt32 RFindCharInSet(nsString& aString,PRInt32 anOffset=0) const;
|
||||
* @param aIgnoreCase tells us whether or not to do caseless compare
|
||||
* @return offset in string, or -1 (kNotFound)
|
||||
*/
|
||||
PRInt32 RFind(const char* aCString,PRBool aIgnoreCase=PR_FALSE) const;
|
||||
PRInt32 RFind(const char* anISOLatin1,PRBool aIgnoreCase=PR_FALSE) const;
|
||||
PRInt32 RFind(const PRUnichar* aString,PRBool aIgnoreCase=PR_FALSE) const;
|
||||
PRInt32 RFind(const nsString& aString,PRBool aIgnoreCase=PR_FALSE) const;
|
||||
|
||||
@@ -673,7 +666,7 @@ PRBool operator<(const PRUnichar* aString) const;
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
PRBool operator>(const nsString &S) const;
|
||||
PRBool operator>(const char *aCString) const;
|
||||
PRBool operator>(const char *anISOLatin1) const;
|
||||
PRBool operator>(const PRUnichar* aString) const;
|
||||
|
||||
/**
|
||||
@@ -682,7 +675,7 @@ PRBool operator>(const PRUnichar* aString) const;
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
PRBool operator<=(const nsString &S) const;
|
||||
PRBool operator<=(const char *aCString) const;
|
||||
PRBool operator<=(const char *anISOLatin1) const;
|
||||
PRBool operator<=(const PRUnichar* aString) const;
|
||||
|
||||
/**
|
||||
@@ -691,7 +684,7 @@ PRBool operator<=(const PRUnichar* aString) const;
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
PRBool operator>=(const nsString &S) const;
|
||||
PRBool operator>=(const char* aCString) const;
|
||||
PRBool operator>=(const char *anISOLatin1) const;
|
||||
PRBool operator>=(const PRUnichar* aString) const;
|
||||
|
||||
/**
|
||||
@@ -771,12 +764,12 @@ public:
|
||||
nsAutoString(const nsString& other);
|
||||
nsAutoString(const nsAutoString& other);
|
||||
nsAutoString(PRUnichar aChar);
|
||||
nsAutoString(const char* aCString);
|
||||
nsAutoString(const char* isolatin1);
|
||||
nsAutoString(const PRUnichar* us, PRInt32 uslen = -1);
|
||||
virtual ~nsAutoString();
|
||||
|
||||
nsAutoString& operator=(const nsString& aString) {nsString::operator=(aString); return *this;}
|
||||
nsAutoString& operator=(const char* aCString) {nsString::operator=(aCString); return *this;}
|
||||
nsAutoString& operator=(const char* anISOLatin1) {nsString::operator=(anISOLatin1); return *this;}
|
||||
nsAutoString& operator=(char aChar) {nsString::operator=(aChar); return *this;}
|
||||
nsAutoString& operator=(const PRUnichar* aBuffer) {nsString::operator=(aBuffer); return *this;}
|
||||
nsAutoString& operator=(PRUnichar aChar) {nsString::operator=(aChar); return *this;}
|
||||
|
||||
@@ -27,12 +27,7 @@
|
||||
* This class encapsulates full 64-bit time functionality and
|
||||
* provides simple arithmetic and conversion operations.
|
||||
*/
|
||||
|
||||
// If you ever decide that you need to add a non-inline method to this
|
||||
// class, be sure to change the class declaration to "class NS_BASE
|
||||
// nsTime".
|
||||
|
||||
class nsTime
|
||||
class NS_BASE nsTime
|
||||
{
|
||||
private:
|
||||
nsInt64 mValue;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
class UnicharBufferImpl : public nsIUnicharBuffer {
|
||||
public:
|
||||
UnicharBufferImpl(PRUint32 aBufferSize);
|
||||
UnicharBufferImpl(PRInt32 aBufferSize);
|
||||
~UnicharBufferImpl();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
@@ -35,13 +35,13 @@ public:
|
||||
PRInt32 aKeep);
|
||||
|
||||
PRUnichar* mBuffer;
|
||||
PRUint32 mSpace;
|
||||
PRUint32 mLength;
|
||||
PRInt32 mSpace;
|
||||
PRInt32 mLength;
|
||||
};
|
||||
|
||||
UnicharBufferImpl::UnicharBufferImpl(PRUint32 aBufferSize)
|
||||
UnicharBufferImpl::UnicharBufferImpl(PRInt32 aBufferSize)
|
||||
{
|
||||
if (aBufferSize < MIN_BUFFER_SIZE) {
|
||||
if (PRUint32(aBufferSize) < MIN_BUFFER_SIZE) {
|
||||
aBufferSize = MIN_BUFFER_SIZE;
|
||||
}
|
||||
mSpace = aBufferSize;
|
||||
@@ -115,10 +115,8 @@ PRInt32 UnicharBufferImpl::Fill(nsresult* aErrorCode,
|
||||
// Read in some new data
|
||||
mLength = aKeep;
|
||||
PRInt32 amount = mSpace - aKeep;
|
||||
PRUint32 nb;
|
||||
NS_ASSERTION(aKeep >= 0, "unsigned madness");
|
||||
NS_ASSERTION(amount >= 0, "unsigned madness");
|
||||
*aErrorCode = aStream->Read(mBuffer, (PRUint32)aKeep, (PRUint32)amount, &nb);
|
||||
PRInt32 nb;
|
||||
*aErrorCode = aStream->Read(mBuffer, aKeep, amount, &nb);
|
||||
if (NS_SUCCEEDED(*aErrorCode)) {
|
||||
mLength += nb;
|
||||
}
|
||||
@@ -129,7 +127,7 @@ PRInt32 UnicharBufferImpl::Fill(nsresult* aErrorCode,
|
||||
|
||||
NS_BASE nsresult NS_NewUnicharBuffer(nsIUnicharBuffer** aInstancePtrResult,
|
||||
nsISupports* aOuter,
|
||||
PRUint32 aBufferSize)
|
||||
PRInt32 aBufferSize)
|
||||
{
|
||||
if (nsnull != aOuter) {
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
@@ -37,14 +37,14 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Read(PRUnichar* aBuf,
|
||||
PRUint32 aOffset,
|
||||
PRUint32 aCount,
|
||||
PRUint32 *aReadCount);
|
||||
PRInt32 aOffset,
|
||||
PRInt32 aCount,
|
||||
PRInt32 *aReadCount);
|
||||
NS_IMETHOD Close();
|
||||
|
||||
nsString* mString;
|
||||
PRUint32 mPos;
|
||||
PRUint32 mLen;
|
||||
PRInt32 mPos;
|
||||
PRInt32 mLen;
|
||||
};
|
||||
|
||||
StringUnicharInputStream::StringUnicharInputStream(nsString* aString)
|
||||
@@ -63,17 +63,16 @@ StringUnicharInputStream::~StringUnicharInputStream()
|
||||
}
|
||||
|
||||
nsresult StringUnicharInputStream::Read(PRUnichar* aBuf,
|
||||
PRUint32 aOffset,
|
||||
PRUint32 aCount,
|
||||
PRUint32 *aReadCount)
|
||||
PRInt32 aOffset,
|
||||
PRInt32 aCount,
|
||||
PRInt32 *aReadCount)
|
||||
{
|
||||
if (mPos >= mLen) {
|
||||
*aReadCount = 0;
|
||||
return (nsresult)-1;
|
||||
}
|
||||
const PRUnichar* us = mString->GetUnicode();
|
||||
NS_ASSERTION(mLen >= mPos, "unsigned madness");
|
||||
PRUint32 amount = mLen - mPos;
|
||||
PRInt32 amount = mLen - mPos;
|
||||
if (amount > aCount) {
|
||||
amount = aCount;
|
||||
}
|
||||
@@ -120,12 +119,12 @@ public:
|
||||
IsoLatin1Converter();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_IMETHOD Convert(PRUnichar* aDst,
|
||||
PRUint32 aDstOffset,
|
||||
PRUint32& aDstLen,
|
||||
const char* aSrc,
|
||||
PRUint32 aSrcOffset,
|
||||
PRUint32& aSrcLen);
|
||||
virtual PRInt32 Convert(PRUnichar* aDst,
|
||||
PRInt32 aDstOffset,
|
||||
PRInt32& aDstLen,
|
||||
const char* aSrc,
|
||||
PRInt32 aSrcOffset,
|
||||
PRInt32& aSrcLen);
|
||||
};
|
||||
|
||||
IsoLatin1Converter::IsoLatin1Converter()
|
||||
@@ -136,14 +135,14 @@ IsoLatin1Converter::IsoLatin1Converter()
|
||||
NS_DEFINE_IID(kIB2UConverterIID, NS_IB2UCONVERTER_IID);
|
||||
NS_IMPL_ISUPPORTS(IsoLatin1Converter,kIB2UConverterIID);
|
||||
|
||||
nsresult IsoLatin1Converter::Convert(PRUnichar* aDst,
|
||||
PRUint32 aDstOffset,
|
||||
PRUint32& aDstLen,
|
||||
PRInt32 IsoLatin1Converter::Convert(PRUnichar* aDst,
|
||||
PRInt32 aDstOffset,
|
||||
PRInt32& aDstLen,
|
||||
const char* aSrc,
|
||||
PRUint32 aSrcOffset,
|
||||
PRUint32& aSrcLen)
|
||||
PRInt32 aSrcOffset,
|
||||
PRInt32& aSrcLen)
|
||||
{
|
||||
PRUint32 amount = aSrcLen;
|
||||
PRInt32 amount = aSrcLen;
|
||||
if (aSrcLen > aDstLen) {
|
||||
amount = aDstLen;
|
||||
}
|
||||
@@ -161,14 +160,13 @@ nsresult IsoLatin1Converter::Convert(PRUnichar* aDst,
|
||||
NS_BASE nsresult
|
||||
NS_NewB2UConverter(nsIB2UConverter** aInstancePtrResult,
|
||||
nsISupports* aOuter,
|
||||
nsString* aCharSet)
|
||||
nsCharSetID aCharSet)
|
||||
{
|
||||
if (nsnull != aOuter) {
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
// We cannot use enum to pass charset id
|
||||
if ((nsnull != aCharSet) && (! aCharSet->EqualsIgnoreCase( "iso-8859-1" ))){
|
||||
return NS_BASE_STREAM_NO_CONVERTER;
|
||||
if (eCharSetID_IsoLatin1 != aCharSet) {
|
||||
return NS_BASE_STREAM_NO_CONVERTER;
|
||||
}
|
||||
IsoLatin1Converter* it = new IsoLatin1Converter();
|
||||
if (nsnull == it) {
|
||||
@@ -183,14 +181,14 @@ class ConverterInputStream : public nsIUnicharInputStream {
|
||||
public:
|
||||
ConverterInputStream(nsIInputStream* aStream,
|
||||
nsIB2UConverter* aConverter,
|
||||
PRUint32 aBufSize);
|
||||
PRInt32 aBufSize);
|
||||
~ConverterInputStream();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_IMETHOD Read(PRUnichar* aBuf,
|
||||
PRUint32 aOffset,
|
||||
PRUint32 aCount,
|
||||
PRUint32 *aReadCount);
|
||||
PRInt32 aOffset,
|
||||
PRInt32 aCount,
|
||||
PRInt32 *aReadCount);
|
||||
NS_IMETHOD Close();
|
||||
|
||||
protected:
|
||||
@@ -199,15 +197,15 @@ protected:
|
||||
nsIInputStream* mInput;
|
||||
nsIB2UConverter* mConverter;
|
||||
nsIByteBuffer* mByteData;
|
||||
PRUint32 mByteDataOffset;
|
||||
PRInt32 mByteDataOffset;
|
||||
nsIUnicharBuffer* mUnicharData;
|
||||
PRUint32 mUnicharDataOffset;
|
||||
PRUint32 mUnicharDataLength;
|
||||
PRInt32 mUnicharDataOffset;
|
||||
PRInt32 mUnicharDataLength;
|
||||
};
|
||||
|
||||
ConverterInputStream::ConverterInputStream(nsIInputStream* aStream,
|
||||
nsIB2UConverter* aConverter,
|
||||
PRUint32 aBufferSize)
|
||||
PRInt32 aBufferSize)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mInput = aStream; aStream->AddRef();
|
||||
@@ -252,12 +250,11 @@ nsresult ConverterInputStream::Close()
|
||||
}
|
||||
|
||||
nsresult ConverterInputStream::Read(PRUnichar* aBuf,
|
||||
PRUint32 aOffset,
|
||||
PRUint32 aCount,
|
||||
PRUint32 *aReadCount)
|
||||
PRInt32 aOffset,
|
||||
PRInt32 aCount,
|
||||
PRInt32 *aReadCount)
|
||||
{
|
||||
NS_ASSERTION(mUnicharDataLength >= mUnicharDataOffset, "unsigned madness");
|
||||
PRUint32 rv = mUnicharDataLength - mUnicharDataOffset;
|
||||
PRInt32 rv = mUnicharDataLength - mUnicharDataOffset;
|
||||
nsresult errorCode;
|
||||
if (0 == rv) {
|
||||
// Fill the unichar buffer
|
||||
@@ -285,8 +282,7 @@ PRInt32 ConverterInputStream::Fill(nsresult * aErrorCode)
|
||||
return -1;
|
||||
}
|
||||
|
||||
NS_ASSERTION(mByteData->GetLength() >= mByteDataOffset, "unsigned madness");
|
||||
PRUint32 remainder = mByteData->GetLength() - mByteDataOffset;
|
||||
PRInt32 remainder = mByteData->GetLength() - mByteDataOffset;
|
||||
mByteDataOffset = remainder;
|
||||
PRInt32 nb = mByteData->Fill(aErrorCode, mInput, remainder);
|
||||
if (nb <= 0) {
|
||||
@@ -300,8 +296,8 @@ PRInt32 ConverterInputStream::Fill(nsresult * aErrorCode)
|
||||
NS_ASSERTION(remainder + nb == mByteData->GetLength(), "bad nb");
|
||||
|
||||
// Now convert as much of the byte buffer to unicode as possible
|
||||
PRUint32 dstLen = mUnicharData->GetBufferSize();
|
||||
PRUint32 srcLen = remainder + nb;
|
||||
PRInt32 dstLen = mUnicharData->GetBufferSize();
|
||||
PRInt32 srcLen = remainder + nb;
|
||||
*aErrorCode = mConverter->Convert(mUnicharData->GetBuffer(), 0, dstLen,
|
||||
mByteData->GetBuffer(), 0, srcLen);
|
||||
mUnicharDataOffset = 0;
|
||||
@@ -316,7 +312,7 @@ NS_NewConverterStream(nsIUnicharInputStream** aInstancePtrResult,
|
||||
nsISupports* aOuter,
|
||||
nsIInputStream* aStreamToWrap,
|
||||
PRInt32 aBufferSize,
|
||||
nsString* aCharSet)
|
||||
nsCharSetID aCharSet)
|
||||
{
|
||||
if (nsnull != aOuter) {
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsISizeOfHandler.h"
|
||||
#include "nsString.h"
|
||||
|
||||
static PRInt32 kGrowArrayBy = 8;
|
||||
|
||||
@@ -226,186 +225,3 @@ PRBool nsVoidArray::EnumerateBackwards(nsVoidArrayEnumFunc aFunc, void* aData)
|
||||
return running;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// nsStringArray
|
||||
|
||||
nsStringArray::nsStringArray(void)
|
||||
: nsVoidArray()
|
||||
{
|
||||
}
|
||||
|
||||
nsStringArray::~nsStringArray(void)
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
nsStringArray&
|
||||
nsStringArray::operator=(const nsStringArray& other)
|
||||
{
|
||||
if (nsnull != mArray) {
|
||||
delete mArray;
|
||||
}
|
||||
PRInt32 otherCount = other.mCount;
|
||||
mArraySize = otherCount;
|
||||
mCount = otherCount;
|
||||
if (0 < otherCount) {
|
||||
mArray = new void*[otherCount];
|
||||
while (0 <= --otherCount) {
|
||||
nsString* otherString = (nsString*)(other.mArray[otherCount]);
|
||||
mArray[otherCount] = new nsString(*otherString);
|
||||
}
|
||||
} else {
|
||||
mArray = nsnull;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void
|
||||
nsStringArray::SizeOf(nsISizeOfHandler* aHandler) const
|
||||
{
|
||||
nsVoidArray::SizeOf(aHandler);
|
||||
PRInt32 index = mCount;
|
||||
while (0 <= --index) {
|
||||
nsString* string = (nsString*)mArray[index];
|
||||
string->SizeOf(aHandler);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsStringArray::StringAt(PRInt32 aIndex, nsString& aString) const
|
||||
{
|
||||
nsString* string = (nsString*)nsVoidArray::ElementAt(aIndex);
|
||||
if (nsnull != string) {
|
||||
aString = *string;
|
||||
}
|
||||
else {
|
||||
aString.Truncate();
|
||||
}
|
||||
}
|
||||
|
||||
nsString*
|
||||
nsStringArray::StringAt(PRInt32 aIndex) const
|
||||
{
|
||||
return (nsString*)nsVoidArray::ElementAt(aIndex);
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsStringArray::IndexOf(const nsString& aPossibleString) const
|
||||
{
|
||||
void** ap = mArray;
|
||||
void** end = ap + mCount;
|
||||
while (ap < end) {
|
||||
nsString* string = (nsString*)*ap;
|
||||
if (string->Equals(aPossibleString)) {
|
||||
return ap - mArray;
|
||||
}
|
||||
ap++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsStringArray::IndexOfIgnoreCase(const nsString& aPossibleString) const
|
||||
{
|
||||
void** ap = mArray;
|
||||
void** end = ap + mCount;
|
||||
while (ap < end) {
|
||||
nsString* string = (nsString*)*ap;
|
||||
if (string->EqualsIgnoreCase(aPossibleString)) {
|
||||
return ap - mArray;
|
||||
}
|
||||
ap++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsStringArray::InsertStringAt(const nsString& aString, PRInt32 aIndex)
|
||||
{
|
||||
nsString* string = new nsString(aString);
|
||||
if (nsVoidArray::InsertElementAt(string, aIndex)) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
delete string;
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsStringArray::ReplaceStringAt(const nsString& aString, PRInt32 aIndex)
|
||||
{
|
||||
nsString* string = (nsString*)nsVoidArray::ElementAt(aIndex);
|
||||
if (nsnull != string) {
|
||||
*string = aString;
|
||||
return PR_TRUE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsStringArray::RemoveString(const nsString& aString)
|
||||
{
|
||||
PRInt32 index = IndexOf(aString);
|
||||
if (-1 < index) {
|
||||
return RemoveStringAt(index);
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsStringArray::RemoveStringIgnoreCase(const nsString& aString)
|
||||
{
|
||||
PRInt32 index = IndexOfIgnoreCase(aString);
|
||||
if (-1 < index) {
|
||||
return RemoveStringAt(index);
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool nsStringArray::RemoveStringAt(PRInt32 aIndex)
|
||||
{
|
||||
nsString* string = StringAt(aIndex);
|
||||
if (nsnull != string) {
|
||||
nsVoidArray::RemoveElementAt(aIndex);
|
||||
delete string;
|
||||
return PR_TRUE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
nsStringArray::Clear(void)
|
||||
{
|
||||
PRInt32 index = mCount;
|
||||
while (0 <= --index) {
|
||||
nsString* string = (nsString*)mArray[index];
|
||||
delete string;
|
||||
}
|
||||
nsVoidArray::Clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
nsStringArray::EnumerateForwards(nsStringArrayEnumFunc aFunc, void* aData)
|
||||
{
|
||||
PRInt32 index = -1;
|
||||
PRBool running = PR_TRUE;
|
||||
|
||||
while (running && (++index < mCount)) {
|
||||
running = (*aFunc)(*((nsString*)mArray[index]), aData);
|
||||
}
|
||||
return running;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsStringArray::EnumerateBackwards(nsStringArrayEnumFunc aFunc, void* aData)
|
||||
{
|
||||
PRInt32 index = mCount;
|
||||
PRBool running = PR_TRUE;
|
||||
|
||||
while (running && (0 <= --index)) {
|
||||
running = (*aFunc)(*((nsString*)mArray[index]), aData);
|
||||
}
|
||||
return running;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,55 +71,4 @@ private:
|
||||
nsVoidArray(const nsVoidArray& other);
|
||||
};
|
||||
|
||||
|
||||
class nsString;
|
||||
|
||||
typedef PRBool (*nsStringArrayEnumFunc)(nsString& aElement, void *aData);
|
||||
|
||||
class NS_BASE nsStringArray: protected nsVoidArray
|
||||
{
|
||||
public:
|
||||
nsStringArray(void);
|
||||
~nsStringArray(void);
|
||||
|
||||
nsStringArray& operator=(const nsStringArray& other);
|
||||
|
||||
void SizeOf(nsISizeOfHandler* aHandler) const;
|
||||
|
||||
PRInt32 Count(void) const {
|
||||
return mCount;
|
||||
}
|
||||
|
||||
void StringAt(PRInt32 aIndex, nsString& aString) const;
|
||||
nsString* StringAt(PRInt32 aIndex) const;
|
||||
nsString* operator[](PRInt32 aIndex) const { return StringAt(aIndex); }
|
||||
|
||||
PRInt32 IndexOf(const nsString& aPossibleString) const;
|
||||
PRInt32 IndexOfIgnoreCase(const nsString& aPossibleString) const;
|
||||
|
||||
PRBool InsertStringAt(const nsString& aString, PRInt32 aIndex);
|
||||
|
||||
PRBool ReplaceStringAt(const nsString& aString, PRInt32 aIndex);
|
||||
|
||||
PRBool AppendString(const nsString& aString) {
|
||||
return InsertStringAt(aString, mCount);
|
||||
}
|
||||
|
||||
PRBool RemoveString(const nsString& aString);
|
||||
PRBool RemoveStringIgnoreCase(const nsString& aString);
|
||||
PRBool RemoveStringAt(PRInt32 aIndex);
|
||||
void Clear(void);
|
||||
|
||||
void Compact(void) {
|
||||
nsVoidArray::Compact();
|
||||
}
|
||||
|
||||
PRBool EnumerateForwards(nsStringArrayEnumFunc aFunc, void* aData);
|
||||
PRBool EnumerateBackwards(nsStringArrayEnumFunc aFunc, void* aData);
|
||||
|
||||
private:
|
||||
/// Copy constructors are not allowed
|
||||
nsStringArray(const nsStringArray& other);
|
||||
};
|
||||
|
||||
#endif /* nsVoidArray_h___ */
|
||||
|
||||
@@ -64,18 +64,6 @@ typedef PRUcs2 PRUnichar;
|
||||
// is placed. It needs to be done this way to make the 4.x compiler happy...
|
||||
#undef NS_EXPORT_
|
||||
#define NS_EXPORT_(type) type _declspec(dllexport) __stdcall
|
||||
#elif defined(XP_MAC)
|
||||
|
||||
#define NS_IMPORT
|
||||
#define NS_IMPORT_(type) type
|
||||
|
||||
// XXX NS_EXPORT_ defined in nsCom.h actually does an export. Here it's just sugar.
|
||||
#undef NS_EXPORT
|
||||
#undef NS_EXPORT_
|
||||
|
||||
#define NS_EXPORT __declspec(export)
|
||||
#define NS_EXPORT_(type) type __declspec(export)
|
||||
|
||||
#else
|
||||
/* XXX do something useful? */
|
||||
#define NS_IMPORT
|
||||
@@ -136,33 +124,4 @@ typedef PRUcs2 PRUnichar;
|
||||
#define NS_PLUGIN NS_IMPORT
|
||||
#endif
|
||||
|
||||
#ifdef _IMPL_NS_APPSHELL
|
||||
#define NS_APPSHELL NS_EXPORT
|
||||
#else
|
||||
#define NS_APPSHELL NS_IMPORT
|
||||
#endif
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
// Casting macros for hiding C++ features from older compilers
|
||||
|
||||
#define HAS_C_PLUS_PLUS_CASTS // we'll be optimistic.
|
||||
#if defined(__sgi) && !defined(__GNUC__)
|
||||
#undef HAS_C_PLUS_PLUS_CASTS
|
||||
#endif
|
||||
|
||||
#if defined(HAS_C_PLUS_PLUS_CASTS)
|
||||
#define NS_STATIC_CAST(__type, __ptr) static_cast<__type>(__ptr)
|
||||
#define NS_CONST_CAST(__type, __ptr) const_cast<__type>(__ptr)
|
||||
#define NS_REINTERPRET_CAST(__type, __ptr) reinterpret_cast<__type>(__ptr)
|
||||
#else
|
||||
#define NS_STATIC_CAST(__type, __ptr) ((__type)(__ptr))
|
||||
#define NS_CONST_CAST(__type, __ptr) ((__type)(__ptr))
|
||||
#define NS_REINTERPRET_CAST(__type, __ptr) ((__type)(__ptr))
|
||||
#endif
|
||||
|
||||
// No sense in making an NS_DYNAMIC_CAST() macro: you can't duplicate
|
||||
// the semantics. So if you want to dynamic_cast, then just use it
|
||||
// "straight", no macro.
|
||||
|
||||
#endif /* nscore_h___ */
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
LIBRARY_NAME = gmbaseunix
|
||||
|
||||
MODULE=base
|
||||
|
||||
REQUIRES=xpcom raptor
|
||||
|
||||
DEFINES += -D_IMPL_NS_WIDGET
|
||||
|
||||
CPPSRCS= \
|
||||
nsTimer.cpp
|
||||
|
||||
CPP_OBJS= \
|
||||
./$(OBJDIR)/nsTimer.o \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
TARGETS = $(LIBRARY)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
||||
@@ -1,200 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#include "nsITimer.h"
|
||||
#include "nsITimerCallback.h"
|
||||
#include "nsCRT.h"
|
||||
#include "prlog.h"
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
|
||||
//
|
||||
// Copied from the unix version, Rhapsody needs to
|
||||
// make this work. Stubs to compile things for now.
|
||||
//
|
||||
|
||||
#if 0
|
||||
Michael Hanni <mhanni@sprintmail.com> suggests:
|
||||
|
||||
I understand that nsTimer.cpp in base/rhapsody/ needs to be completed,
|
||||
yes? Wouldn't this code just use some NSTimers in the NSRunLoop?
|
||||
|
||||
Timer = [NSTimer timerWithTimeInterval:0.02 //seconds
|
||||
target:self
|
||||
selector:@selector(doThis:)
|
||||
userInfo:nil
|
||||
repeats:YES];
|
||||
[[NSRunLoop currentRunLoop] addTimer:Timer
|
||||
forMode:NSDefaultRunLoopMode];
|
||||
|
||||
I only looked at nsTimer.cpp briefly, but could something like this work
|
||||
if imbedded in all that c++? ;-)
|
||||
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_IID(kITimerIID, NS_ITIMER_IID);
|
||||
|
||||
extern void nsTimerExpired(void *aCallData);
|
||||
|
||||
class TimerImpl : public nsITimer {
|
||||
public:
|
||||
|
||||
public:
|
||||
TimerImpl();
|
||||
virtual ~TimerImpl();
|
||||
|
||||
virtual nsresult Init(nsTimerCallbackFunc aFunc,
|
||||
void *aClosure,
|
||||
// PRBool aRepeat,
|
||||
PRUint32 aDelay);
|
||||
|
||||
virtual nsresult Init(nsITimerCallback *aCallback,
|
||||
// PRBool aRepeat,
|
||||
PRUint32 aDelay);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
virtual void Cancel();
|
||||
virtual PRUint32 GetDelay() { return mDelay; }
|
||||
virtual void SetDelay(PRUint32 aDelay) { mDelay=aDelay; };
|
||||
virtual void* GetClosure() { return mClosure; }
|
||||
|
||||
void FireTimeout();
|
||||
|
||||
private:
|
||||
nsresult Init(PRUint32 aDelay);
|
||||
|
||||
PRUint32 mDelay;
|
||||
nsTimerCallbackFunc mFunc;
|
||||
void *mClosure;
|
||||
nsITimerCallback *mCallback;
|
||||
// PRBool mRepeat;
|
||||
TimerImpl *mNext;
|
||||
int mTimerId;
|
||||
};
|
||||
|
||||
void TimerImpl::FireTimeout()
|
||||
{
|
||||
if (mFunc != NULL) {
|
||||
(*mFunc)(this, mClosure);
|
||||
}
|
||||
else if (mCallback != NULL) {
|
||||
mCallback->Notify(this); // Fire the timer
|
||||
}
|
||||
|
||||
// Always repeating here
|
||||
|
||||
// if (mRepeat)
|
||||
// mTimerId = XtAppAddTimeOut(gAppContext, GetDelay(),(XtTimerCallbackProc)nsTimerExpired, this);
|
||||
}
|
||||
|
||||
|
||||
TimerImpl::TimerImpl()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mFunc = NULL;
|
||||
mCallback = NULL;
|
||||
mNext = NULL;
|
||||
mTimerId = 0;
|
||||
mDelay = 0;
|
||||
mClosure = NULL;
|
||||
}
|
||||
|
||||
TimerImpl::~TimerImpl()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult
|
||||
TimerImpl::Init(nsTimerCallbackFunc aFunc,
|
||||
void *aClosure,
|
||||
// PRBool aRepeat,
|
||||
PRUint32 aDelay)
|
||||
{
|
||||
mFunc = aFunc;
|
||||
mClosure = aClosure;
|
||||
// mRepeat = aRepeat;
|
||||
|
||||
printf("TimerImpl::Init() not implemented\n");
|
||||
|
||||
#ifdef RHAPSODY_NEEDS_TO_IMPLEMENT_THIS
|
||||
mTimerId = XtAppAddTimeOut(gAppContext, aDelay,(XtTimerCallbackProc)nsTimerExpired, this);
|
||||
#endif
|
||||
|
||||
return Init(aDelay);
|
||||
}
|
||||
|
||||
nsresult
|
||||
TimerImpl::Init(nsITimerCallback *aCallback,
|
||||
// PRBool aRepeat,
|
||||
PRUint32 aDelay)
|
||||
{
|
||||
mCallback = aCallback;
|
||||
// mRepeat = aRepeat;
|
||||
|
||||
printf("TimerImpl::Init() not implmented.\n");
|
||||
|
||||
#ifdef RHAPSODY_NEEDS_TO_IMPLEMENT_THIS
|
||||
mTimerId = XtAppAddTimeOut(gAppContext, aDelay, (XtTimerCallbackProc)nsTimerExpired, this);
|
||||
#endif
|
||||
|
||||
return Init(aDelay);
|
||||
}
|
||||
|
||||
nsresult
|
||||
TimerImpl::Init(PRUint32 aDelay)
|
||||
{
|
||||
mDelay = aDelay;
|
||||
NS_ADDREF(this);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(TimerImpl, kITimerIID)
|
||||
|
||||
|
||||
void
|
||||
TimerImpl::Cancel()
|
||||
{
|
||||
|
||||
printf("TimerImpl::Cancel() not implemented.\n");
|
||||
|
||||
#ifdef RHAPSODY_NEEDS_TO_IMPLEMENT_THIS
|
||||
XtRemoveTimeOut(mTimerId);
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_BASE nsresult NS_NewTimer(nsITimer** aInstancePtrResult)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
TimerImpl *timer = new TimerImpl();
|
||||
if (nsnull == timer) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return timer->QueryInterface(kITimerIID, (void **) aInstancePtrResult);
|
||||
}
|
||||
|
||||
|
||||
void nsTimerExpired(void *aCallData)
|
||||
{
|
||||
TimerImpl* timer = (TimerImpl *)aCallData;
|
||||
timer->FireTimeout();
|
||||
}
|
||||
43
mozilla/base/src/unix/Makefile
Normal file
43
mozilla/base/src/unix/Makefile
Normal file
@@ -0,0 +1,43 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
|
||||
DEPTH = ../../..
|
||||
|
||||
|
||||
LIBRARY_NAME = gmbaseunix
|
||||
|
||||
MODULE=raptor
|
||||
|
||||
REQUIRES=xpcom raptor
|
||||
|
||||
DEFINES = -D_IMPL_NS_WIDGET
|
||||
|
||||
CPPSRCS= \
|
||||
nsTimer.cpp
|
||||
|
||||
CPP_OBJS= \
|
||||
./$(OBJDIR)/nsTimer.o \
|
||||
$(NULL)
|
||||
|
||||
include $(DEPTH)/config/config.mk
|
||||
|
||||
TARGETS = $(LIBRARY)
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
|
||||
47
mozilla/base/src/unix/Makefile.in
Normal file
47
mozilla/base/src/unix/Makefile.in
Normal file
@@ -0,0 +1,47 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
LIBRARY_NAME = gmbaseunix
|
||||
|
||||
MODULE=raptor
|
||||
|
||||
REQUIRES=xpcom raptor
|
||||
|
||||
DEFINES = -D_IMPL_NS_WIDGET
|
||||
|
||||
CPPSRCS= \
|
||||
nsTimer.cpp
|
||||
|
||||
CPP_OBJS= \
|
||||
./$(OBJDIR)/nsTimer.o \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
TARGETS = $(LIBRARY)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
This directory is obsolete.
|
||||
|
||||
The nsTimer files that used to live here have been moved to ../motif
|
||||
in order to allow for multiple unix toolkits.
|
||||
|
||||
ramiro@netscape.com 11-02-1998
|
||||
@@ -1,220 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
// This file is included by nsFileSpec.cpp, and includes the Unix-specific
|
||||
// implementations.
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/param.h>
|
||||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileSpecHelpers::Canonify(char*& ioPath, bool inMakeDirs)
|
||||
// Canonify, make absolute, and check whether directories exist
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!ioPath)
|
||||
return;
|
||||
if (inMakeDirs)
|
||||
{
|
||||
const mode_t mode = 0700;
|
||||
nsFileSpecHelpers::MakeAllDirectories(ioPath, mode);
|
||||
}
|
||||
char buffer[MAXPATHLEN];
|
||||
errno = 0;
|
||||
*buffer = '\0';
|
||||
char* canonicalPath = realpath(ioPath, buffer);
|
||||
if (!canonicalPath)
|
||||
{
|
||||
// Linux's realpath() is pathetically buggy. If the reason for the nil
|
||||
// result is just that the leaf does not exist, strip the leaf off,
|
||||
// process that, and then add the leaf back.
|
||||
char* allButLeaf = nsFileSpecHelpers::StringDup(ioPath);
|
||||
if (!allButLeaf)
|
||||
return;
|
||||
char* lastSeparator = strrchr(allButLeaf, '/');
|
||||
if (lastSeparator)
|
||||
{
|
||||
*lastSeparator = '\0';
|
||||
canonicalPath = realpath(allButLeaf, buffer);
|
||||
strcat(buffer, "/");
|
||||
// Add back the leaf
|
||||
strcat(buffer, ++lastSeparator);
|
||||
}
|
||||
delete [] allButLeaf;
|
||||
}
|
||||
if (!canonicalPath && *ioPath != '/' && !inMakeDirs)
|
||||
{
|
||||
// Well, if it's a relative path, hack it ourselves.
|
||||
canonicalPath = realpath(".", buffer);
|
||||
if (canonicalPath)
|
||||
{
|
||||
strcat(canonicalPath, "/");
|
||||
strcat(canonicalPath, ioPath);
|
||||
}
|
||||
}
|
||||
if (canonicalPath)
|
||||
nsFileSpecHelpers::StringAssign(ioPath, canonicalPath);
|
||||
} // nsFileSpecHelpers::Canonify
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsNativeFileSpec::SetLeafName(const char* inLeafName)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsFileSpecHelpers::LeafReplace(mPath, '/', inLeafName);
|
||||
} // nsNativeFileSpec::SetLeafName
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
char* nsNativeFileSpec::GetLeafName() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return nsFileSpecHelpers::GetLeaf(mPath, '/');
|
||||
} // nsNativeFileSpec::GetLeafName
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
bool nsNativeFileSpec::Exists() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
struct stat st;
|
||||
return 0 == stat(mPath, &st);
|
||||
} // nsNativeFileSpec::Exists
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
bool nsNativeFileSpec::IsFile() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
struct stat st;
|
||||
return 0 == stat(mPath, &st) && S_ISREG(st.st_mode);
|
||||
} // nsNativeFileSpec::IsFile
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
bool nsNativeFileSpec::IsDirectory() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
struct stat st;
|
||||
return 0 == stat(mPath, &st) && S_ISDIR(st.st_mode);
|
||||
} // nsNativeFileSpec::IsDirectory
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsNativeFileSpec::GetParent(nsNativeFileSpec& outSpec) const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsFileSpecHelpers::StringAssign(outSpec.mPath, mPath);
|
||||
char* cp = strrchr(outSpec.mPath, '/');
|
||||
if (cp)
|
||||
*cp = '\0';
|
||||
} // nsNativeFileSpec::GetParent
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsNativeFileSpec::operator += (const char* inRelativePath)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!inRelativePath || !mPath)
|
||||
return;
|
||||
|
||||
if (mPath[strlen(mPath) - 1] != '/')
|
||||
char* newPath = nsFileSpecHelpers::ReallocCat(mPath, "/");
|
||||
SetLeafName(inRelativePath);
|
||||
} // nsNativeFileSpec::operator +=
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsNativeFileSpec::CreateDirectory(int mode)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// Note that mPath is canonical!
|
||||
mkdir(mPath, mode);
|
||||
} // nsNativeFileSpec::CreateDirectory
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsNativeFileSpec::Delete(bool inRecursive)
|
||||
// To check if this worked, call Exists() afterwards, see?
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (IsDirectory())
|
||||
{
|
||||
if (inRecursive)
|
||||
{
|
||||
for (nsDirectoryIterator i(*this); i; i++)
|
||||
{
|
||||
nsNativeFileSpec& child = (nsNativeFileSpec&)i;
|
||||
child.Delete(inRecursive);
|
||||
}
|
||||
}
|
||||
rmdir(mPath);
|
||||
}
|
||||
else
|
||||
remove(mPath);
|
||||
} // nsNativeFileSpec::Delete
|
||||
|
||||
//========================================================================================
|
||||
// nsDirectoryIterator
|
||||
//========================================================================================
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsDirectoryIterator::nsDirectoryIterator(
|
||||
const nsNativeFileSpec& inDirectory
|
||||
, int inIterateDirection)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mCurrent(inDirectory)
|
||||
, mDir(nsnull)
|
||||
, mExists(false)
|
||||
{
|
||||
mCurrent += "sysygy"; // prepare the path for SetLeafName
|
||||
mDir = opendir((const char*)nsFilePath(inDirectory));
|
||||
++(*this);
|
||||
} // nsDirectoryIterator::nsDirectoryIterator
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsDirectoryIterator::~nsDirectoryIterator()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (mDir)
|
||||
closedir(mDir);
|
||||
} // nsDirectoryIterator::nsDirectoryIterator
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsDirectoryIterator& nsDirectoryIterator::operator ++ ()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mExists = false;
|
||||
if (!mDir)
|
||||
return *this;
|
||||
char* dot = ".";
|
||||
char* dotdot = "..";
|
||||
struct dirent* entry = readdir(mDir);
|
||||
if (entry && strcmp(entry->d_name, dot) == 0)
|
||||
entry = readdir(mDir);
|
||||
if (entry && strcmp(entry->d_name, dotdot) == 0)
|
||||
entry = readdir(mDir);
|
||||
if (entry)
|
||||
{
|
||||
mExists = true;
|
||||
mCurrent.SetLeafName(entry->d_name);
|
||||
}
|
||||
return *this;
|
||||
} // nsDirectoryIterator::operator ++
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsDirectoryIterator& nsDirectoryIterator::operator -- ()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return ++(*this); // can't do it backwards.
|
||||
} // nsDirectoryIterator::operator --
|
||||
@@ -1,297 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
// This file is included by nsFileSpec.cp, and includes the Windows-specific
|
||||
// implementations.
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <direct.h>
|
||||
#include <stdlib.h>
|
||||
#include "prio.h"
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileSpecHelpers::Canonify(char*& ioPath, bool inMakeDirs)
|
||||
// Canonify, make absolute, and check whether directories exist. This
|
||||
// takes a (possibly relative) native path and converts it into a
|
||||
// fully qualified native path.
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!ioPath)
|
||||
return;
|
||||
if (inMakeDirs) {
|
||||
const int mode = 0700;
|
||||
char* unixStylePath = nsFileSpecHelpers::StringDup(ioPath);
|
||||
nsFileSpecHelpers::NativeToUnix(unixStylePath);
|
||||
nsFileSpecHelpers::MakeAllDirectories(unixStylePath, mode);
|
||||
delete[] unixStylePath;
|
||||
}
|
||||
char buffer[_MAX_PATH];
|
||||
errno = 0;
|
||||
*buffer = '\0';
|
||||
char* canonicalPath = _fullpath(buffer, ioPath, _MAX_PATH);
|
||||
|
||||
NS_ASSERTION( canonicalPath[0] != '\0', "Uh oh...couldn't convert" );
|
||||
if (canonicalPath[0] == '\0')
|
||||
return;
|
||||
|
||||
nsFileSpecHelpers::StringAssign(ioPath, canonicalPath);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileSpecHelpers::UnixToNative(char*& ioPath)
|
||||
// This just does string manipulation. It doesn't check reality, or canonify, or
|
||||
// anything
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// Allow for relative or absolute. We can do this in place, because the
|
||||
// native path is never longer.
|
||||
|
||||
if (!ioPath || !*ioPath)
|
||||
return;
|
||||
|
||||
char* src = ioPath;
|
||||
if (*ioPath == '/')
|
||||
{
|
||||
// Strip initial slash for an absolute path
|
||||
src++;
|
||||
}
|
||||
|
||||
// Convert the vertical slash to a colon
|
||||
char* cp = src + 1;
|
||||
|
||||
// If it was an absolute path, check for the drive letter
|
||||
if (*ioPath == '/' && strstr(cp, "|/") == cp)
|
||||
*cp = ':';
|
||||
|
||||
// Convert '/' to '\'.
|
||||
while (*++cp)
|
||||
{
|
||||
if (*cp == '/')
|
||||
*cp = '\\';
|
||||
}
|
||||
|
||||
if (*ioPath == '/') {
|
||||
for (cp = ioPath; *cp; ++cp)
|
||||
*cp = *(cp + 1);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFileSpecHelpers::NativeToUnix(char*& ioPath)
|
||||
// This just does string manipulation. It doesn't check reality, or canonify, or
|
||||
// anything. The unix path is longer, so we can't do it in place.
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!ioPath || !*ioPath)
|
||||
return;
|
||||
|
||||
// Convert the drive-letter separator, if present
|
||||
char* temp = nsFileSpecHelpers::StringDup("/", 1 + strlen(ioPath));
|
||||
|
||||
char* cp = ioPath + 1;
|
||||
if (strstr(cp, ":\\") == cp) {
|
||||
*cp = '|'; // absolute path
|
||||
}
|
||||
else {
|
||||
*temp = '\0'; // relative path
|
||||
}
|
||||
|
||||
// Convert '\' to '/'
|
||||
for (; *cp; cp++)
|
||||
{
|
||||
if (*cp == '\\')
|
||||
*cp = '/';
|
||||
}
|
||||
|
||||
// Add the slash in front.
|
||||
strcat(temp, ioPath);
|
||||
StringAssign(ioPath, temp);
|
||||
delete [] temp;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsNativeFileSpec::nsNativeFileSpec(const nsFilePath& inPath)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mPath(NULL)
|
||||
{
|
||||
*this = inPath;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsNativeFileSpec::operator = (const nsFilePath& inPath)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsFileSpecHelpers::StringAssign(mPath, (const char*)inPath);
|
||||
nsFileSpecHelpers::UnixToNative(mPath);
|
||||
} // nsNativeFileSpec::operator =
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsFilePath::nsFilePath(const nsNativeFileSpec& inSpec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mPath(NULL)
|
||||
{
|
||||
*this = inSpec;
|
||||
} // nsFilePath::nsFilePath
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsFilePath::operator = (const nsNativeFileSpec& inSpec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsFileSpecHelpers::StringAssign(mPath, inSpec.mPath);
|
||||
nsFileSpecHelpers::NativeToUnix(mPath);
|
||||
} // nsFilePath::operator =
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsNativeFileSpec::SetLeafName(const char* inLeafName)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsFileSpecHelpers::LeafReplace(mPath, '\\', inLeafName);
|
||||
} // nsNativeFileSpec::SetLeafName
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
char* nsNativeFileSpec::GetLeafName() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return nsFileSpecHelpers::GetLeaf(mPath, '\\');
|
||||
} // nsNativeFileSpec::GetLeafName
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
bool nsNativeFileSpec::Exists() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
struct stat st;
|
||||
return 0 == stat(mPath, &st);
|
||||
} // nsNativeFileSpec::Exists
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
bool nsNativeFileSpec::IsFile() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
struct stat st;
|
||||
return 0 == stat(mPath, &st) && (_S_IFREG & st.st_mode);
|
||||
} // nsNativeFileSpec::IsFile
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
bool nsNativeFileSpec::IsDirectory() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
struct stat st;
|
||||
return 0 == stat(mPath, &st) && (_S_IFDIR & st.st_mode);
|
||||
} // nsNativeFileSpec::IsDirectory
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsNativeFileSpec::GetParent(nsNativeFileSpec& outSpec) const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsFileSpecHelpers::StringAssign(outSpec.mPath, mPath);
|
||||
char* cp = strrchr(outSpec.mPath, '\\');
|
||||
if (cp)
|
||||
*cp = '\0';
|
||||
} // nsNativeFileSpec::GetParent
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsNativeFileSpec::operator += (const char* inRelativePath)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (!inRelativePath || !mPath)
|
||||
return;
|
||||
|
||||
if (mPath[strlen(mPath) - 1] != '\\')
|
||||
char* newPath = nsFileSpecHelpers::ReallocCat(mPath, "\\");
|
||||
SetLeafName(inRelativePath);
|
||||
} // nsNativeFileSpec::operator +=
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsNativeFileSpec::CreateDirectory(int /*mode*/)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// Note that mPath is canonical!
|
||||
mkdir(mPath);
|
||||
} // nsNativeFileSpec::CreateDirectory
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsNativeFileSpec::Delete(bool inRecursive)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (IsDirectory())
|
||||
{
|
||||
if (inRecursive)
|
||||
{
|
||||
for (nsDirectoryIterator i(*this); i; i++)
|
||||
{
|
||||
nsNativeFileSpec& child = (nsNativeFileSpec&)i;
|
||||
child.Delete(inRecursive);
|
||||
}
|
||||
}
|
||||
rmdir(mPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
remove(mPath);
|
||||
}
|
||||
} // nsNativeFileSpec::Delete
|
||||
|
||||
//========================================================================================
|
||||
// nsDirectoryIterator
|
||||
//========================================================================================
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsDirectoryIterator::nsDirectoryIterator(
|
||||
const nsNativeFileSpec& inDirectory
|
||||
, int inIterateDirection)
|
||||
//----------------------------------------------------------------------------------------
|
||||
: mCurrent(inDirectory)
|
||||
, mDir(nsnull)
|
||||
, mExists(false)
|
||||
{
|
||||
mDir = PR_OpenDir(inDirectory);
|
||||
mCurrent += "dummy";
|
||||
++(*this);
|
||||
} // nsDirectoryIterator::nsDirectoryIterator
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsDirectoryIterator::~nsDirectoryIterator()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (mDir)
|
||||
PR_CloseDir(mDir);
|
||||
} // nsDirectoryIterator::nsDirectoryIterator
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsDirectoryIterator& nsDirectoryIterator::operator ++ ()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mExists = false;
|
||||
if (!mDir)
|
||||
return *this;
|
||||
PRDirEntry* entry = PR_ReadDir(mDir, PR_SKIP_BOTH); // Ignore '.' && '..'
|
||||
if (entry)
|
||||
{
|
||||
mExists = true;
|
||||
mCurrent.SetLeafName(entry->name);
|
||||
}
|
||||
return *this;
|
||||
} // nsDirectoryIterator::operator ++
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsDirectoryIterator& nsDirectoryIterator::operator -- ()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
return ++(*this); // can't do it backwards.
|
||||
} // nsDirectoryIterator::operator --
|
||||
|
||||
@@ -23,9 +23,12 @@
|
||||
#include "prprf.h"
|
||||
#include "prtime.h"
|
||||
|
||||
static nsString* ConvertCharacterSetName(const char* aName)
|
||||
static nsCharSetID ConvertCharacterSetName(const char* aName)
|
||||
{
|
||||
return new nsString(aName);
|
||||
if (nsCRT::strcasecmp(aName, "iso-latin-1") == 0) {
|
||||
return eCharSetID_IsoLatin1;
|
||||
}
|
||||
return (nsCharSetID) -1;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
@@ -36,7 +39,7 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
char* characterSetName = argv[2];
|
||||
nsString* cset = ConvertCharacterSetName(characterSetName);
|
||||
nsCharSetID cset = ConvertCharacterSetName(characterSetName);
|
||||
if (PRInt32(cset) < 0) {
|
||||
printf("illegal character set name: '%s'\n", characterSetName);
|
||||
return -1;
|
||||
@@ -52,9 +55,8 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
// Get an input stream from the url
|
||||
nsresult ec;
|
||||
nsIInputStream* in;
|
||||
ec = NS_OpenURL(url, &in);
|
||||
PRInt32 ec;
|
||||
nsIInputStream* in = url->Open(&ec);
|
||||
if (nsnull == in) {
|
||||
printf("open of url('%s') failed: error=%x\n", urlName, ec);
|
||||
return -1;
|
||||
@@ -73,7 +75,7 @@ int main(int argc, char** argv)
|
||||
PRInt32 count = 0;
|
||||
for (;;) {
|
||||
PRUnichar buf[1000];
|
||||
PRUint32 nb;
|
||||
PRInt32 nb;
|
||||
ec = uin->Read(buf, 0, 1000, &nb);
|
||||
if (ec < 0) {
|
||||
if (ec != NS_BASE_STREAM_EOF) {
|
||||
|
||||
@@ -1,401 +0,0 @@
|
||||
#include "string.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsFileStream.h"
|
||||
|
||||
struct FilesTest
|
||||
{
|
||||
FilesTest() : mConsole() {}
|
||||
|
||||
int RunAllTests();
|
||||
|
||||
void WriteStuff(nsOutputFileStream& s);
|
||||
int InputStream(const char* relativePath);
|
||||
int OutputStream(const char* relativePath);
|
||||
int IOStream(const char* relativePath);
|
||||
int Parent(const char* relativePath, nsNativeFileSpec& outParent);
|
||||
int Delete(nsNativeFileSpec& victim);
|
||||
int CreateDirectory(nsNativeFileSpec& victim);
|
||||
int IterateDirectoryChildren(nsNativeFileSpec& startChild);
|
||||
int CanonicalPath(const char* relativePath);
|
||||
|
||||
void Banner(const char* bannerString);
|
||||
void Passed();
|
||||
void Failed();
|
||||
void Inspect();
|
||||
|
||||
nsOutputFileStream mConsole;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void FilesTest::Banner(const char* bannerString)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mConsole
|
||||
<< nsEndl
|
||||
<< "---------------------------" << nsEndl
|
||||
<< bannerString << " Test" << nsEndl
|
||||
<< "---------------------------" << nsEndl;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void FilesTest::Passed()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mConsole << "Test passed." << nsEndl;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void FilesTest::Failed()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mConsole << "ERROR: Test failed." << nsEndl;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void FilesTest::Inspect()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mConsole << nsEndl << "^^^^^^^^^^ PLEASE INSPECT OUTPUT FOR ERRORS" << nsEndl;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void FilesTest::WriteStuff(nsOutputFileStream& s)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// Initialize a URL from a string without suffix. Change the path to suit your machine.
|
||||
nsFileURL fileURL("file:///Development/MPW/MPW%20Shell", false);
|
||||
s << "File URL initialized to: \"" << fileURL << "\""<< nsEndl;
|
||||
|
||||
// Initialize a Unix path from a URL
|
||||
nsFilePath filePath(fileURL);
|
||||
s << "As a unix path: \"" << (const char*)filePath << "\""<< nsEndl;
|
||||
|
||||
// Initialize a native file spec from a URL
|
||||
nsNativeFileSpec fileSpec(fileURL);
|
||||
s << "As a file spec: " << fileSpec << nsEndl;
|
||||
|
||||
// Make the spec unique (this one has no suffix).
|
||||
fileSpec.MakeUnique();
|
||||
s << "Unique file spec: " << fileSpec << nsEndl;
|
||||
|
||||
// Assign the spec to a URL
|
||||
fileURL = fileSpec;
|
||||
s << "File URL assigned from spec: \"" << fileURL << "\""<< nsEndl;
|
||||
|
||||
// Assign a unix path using a string with a suffix.
|
||||
filePath = "/Development/MPW/SysErrs.err";
|
||||
s << "File path reassigned to: \"" << (const char*)filePath << "\""<< nsEndl;
|
||||
|
||||
// Assign to a file spec using a unix path.
|
||||
fileSpec = filePath;
|
||||
s << "File spec reassigned to: " << fileSpec << nsEndl;
|
||||
|
||||
// Make this unique (this one has a suffix).
|
||||
fileSpec.MakeUnique();
|
||||
s << "File spec made unique: " << fileSpec << nsEndl;
|
||||
} // WriteStuff
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
int FilesTest::OutputStream(const char* relativePath)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsFilePath myTextFilePath(relativePath, true); // relative path.
|
||||
const char* pathAsString = (const char*)myTextFilePath;
|
||||
nsNativeFileSpec mySpec(myTextFilePath);
|
||||
{
|
||||
mConsole << "WRITING IDENTICAL OUTPUT TO " << pathAsString << nsEndl << nsEndl;
|
||||
nsOutputFileStream testStream(myTextFilePath);
|
||||
if (!testStream.is_open())
|
||||
{
|
||||
mConsole
|
||||
<< "ERROR: File "
|
||||
<< pathAsString
|
||||
<< " could not be opened for output"
|
||||
<< nsEndl;
|
||||
return -1;
|
||||
}
|
||||
FilesTest::WriteStuff(testStream);
|
||||
} // <-- Scope closes the stream (and the file).
|
||||
|
||||
if (!mySpec.Exists() || mySpec.IsDirectory() || !mySpec.IsFile())
|
||||
{
|
||||
mConsole
|
||||
<< "ERROR: File "
|
||||
<< pathAsString
|
||||
<< " is not a file (cela n'est pas un pipe)"
|
||||
<< nsEndl;
|
||||
return -1;
|
||||
}
|
||||
Passed();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
int FilesTest::IOStream(const char* relativePath)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsFilePath myTextFilePath(relativePath, true); // relative path.
|
||||
const char* pathAsString = (const char*)myTextFilePath;
|
||||
mConsole
|
||||
<< "Replacing \"path\" by \"ZUUL\" in " << pathAsString << nsEndl << nsEndl;
|
||||
nsIOFileStream testStream(myTextFilePath);
|
||||
if (!testStream.is_open())
|
||||
{
|
||||
mConsole
|
||||
<< "ERROR: File "
|
||||
<< pathAsString
|
||||
<< " could not be opened for input+output"
|
||||
<< nsEndl;
|
||||
return -1;
|
||||
}
|
||||
char line[1000];
|
||||
testStream.seek(0); // check that the seek compiles
|
||||
while (!testStream.eof())
|
||||
{
|
||||
PRInt32 pos = testStream.tell();
|
||||
testStream.readline(line, sizeof(line));
|
||||
char* replacementSubstring = strstr(line, "path");
|
||||
if (replacementSubstring)
|
||||
{
|
||||
testStream.seek(pos + (replacementSubstring - line));
|
||||
testStream << "ZUUL";
|
||||
testStream.seek(pos); // back to the start of the line
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
int FilesTest::InputStream(const char* relativePath)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsFilePath myTextFilePath(relativePath, true);
|
||||
const char* pathAsString = (const char*)myTextFilePath;
|
||||
mConsole << "READING BACK DATA FROM " << pathAsString << nsEndl << nsEndl;
|
||||
nsInputFileStream testStream2(myTextFilePath);
|
||||
if (!testStream2.is_open())
|
||||
{
|
||||
mConsole
|
||||
<< "ERROR: File "
|
||||
<< pathAsString
|
||||
<< " could not be opened for input"
|
||||
<< nsEndl;
|
||||
return -1;
|
||||
}
|
||||
char line[1000];
|
||||
|
||||
testStream2.seek(0); // check that the seek compiles
|
||||
while (!testStream2.eof())
|
||||
{
|
||||
testStream2.readline(line, sizeof(line));
|
||||
mConsole << line << nsEndl;
|
||||
}
|
||||
Inspect();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
int FilesTest::Parent(
|
||||
const char* relativePath,
|
||||
nsNativeFileSpec& outParent)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsFilePath myTextFilePath(relativePath, true);
|
||||
const char* pathAsString = (const char*)myTextFilePath;
|
||||
nsNativeFileSpec mySpec(myTextFilePath);
|
||||
|
||||
mySpec.GetParent(outParent);
|
||||
nsFilePath parentPath(outParent);
|
||||
mConsole
|
||||
<< "GetParent() on "
|
||||
<< "\n\t" << pathAsString
|
||||
<< "\n yields "
|
||||
<< "\n\t" << (const char*)parentPath
|
||||
<< nsEndl;
|
||||
Inspect();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
int FilesTest::Delete(nsNativeFileSpec& victim)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// - Test of non-recursive delete
|
||||
|
||||
nsFilePath victimPath(victim);
|
||||
mConsole
|
||||
<< "Attempting to delete "
|
||||
<< "\n\t" << (const char*)victimPath
|
||||
<< "\n without recursive option (should fail)"
|
||||
<< nsEndl;
|
||||
victim.Delete(false);
|
||||
if (victim.Exists())
|
||||
Passed();
|
||||
else
|
||||
{
|
||||
mConsole
|
||||
<< "ERROR: File "
|
||||
<< "\n\t" << (const char*)victimPath
|
||||
<< "\n has been deleted without the recursion option,"
|
||||
<< "\n and is a nonempty directory!"
|
||||
<< nsEndl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// - Test of recursive delete
|
||||
|
||||
mConsole
|
||||
<< nsEndl
|
||||
<< "Deleting "
|
||||
<< "\n\t" << (const char*)victimPath
|
||||
<< "\n with recursive option"
|
||||
<< nsEndl;
|
||||
victim.Delete(true);
|
||||
if (victim.Exists())
|
||||
{
|
||||
mConsole
|
||||
<< "ERROR: Directory "
|
||||
<< "\n\t" << (const char*)victimPath
|
||||
<< "\n has NOT been deleted despite the recursion option!"
|
||||
<< nsEndl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
Passed();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
int FilesTest::CreateDirectory(nsNativeFileSpec& dirSpec)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsFilePath dirPath(dirSpec);
|
||||
mConsole
|
||||
<< "Testing CreateDirectory() using"
|
||||
<< "\n\t" << (const char*)dirPath
|
||||
<< nsEndl;
|
||||
|
||||
dirSpec.CreateDirectory();
|
||||
if (dirSpec.Exists())
|
||||
Passed();
|
||||
else
|
||||
{
|
||||
Failed();
|
||||
return -1;
|
||||
}
|
||||
dirSpec.Delete(true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
int FilesTest::IterateDirectoryChildren(nsNativeFileSpec& startChild)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// - Test of directory iterator
|
||||
|
||||
nsNativeFileSpec grandparent;
|
||||
startChild.GetParent(grandparent); // should be the original default directory.
|
||||
nsFilePath grandparentPath(grandparent);
|
||||
|
||||
mConsole << "Forwards listing of " << (const char*)grandparentPath << ":" << nsEndl;
|
||||
for (nsDirectoryIterator i(grandparent, +1); i; i++)
|
||||
{
|
||||
char* itemName = ((nsNativeFileSpec&)i).GetLeafName();
|
||||
mConsole << '\t' << itemName << nsEndl;
|
||||
delete [] itemName;
|
||||
}
|
||||
|
||||
mConsole << "Backwards listing of " << (const char*)grandparentPath << ":" << nsEndl;
|
||||
for (nsDirectoryIterator j(grandparent, -1); j; j--)
|
||||
{
|
||||
char* itemName = ((nsNativeFileSpec&)j).GetLeafName();
|
||||
mConsole << '\t' << itemName << nsEndl;
|
||||
delete [] itemName;
|
||||
}
|
||||
Inspect();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
int FilesTest::CanonicalPath(
|
||||
const char* relativePath)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsFilePath myTextFilePath(relativePath, true);
|
||||
const char* pathAsString = (const char*)myTextFilePath;
|
||||
if (*pathAsString != '/')
|
||||
{
|
||||
mConsole
|
||||
<< "ERROR: after initializing the path object with a relative path,"
|
||||
<< "\n the path consisted of the string "
|
||||
<< "\n\t" << pathAsString
|
||||
<< "\n which is not a canonical full path!"
|
||||
<< nsEndl;
|
||||
return -1;
|
||||
}
|
||||
Passed();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
int FilesTest::RunAllTests()
|
||||
// For use with DEBUG defined.
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// Test of mConsole output
|
||||
|
||||
mConsole << "WRITING TEST OUTPUT TO CONSOLE" << nsEndl << nsEndl;
|
||||
|
||||
// Test of nsFileSpec
|
||||
|
||||
Banner("Interconversion");
|
||||
WriteStuff(mConsole);
|
||||
Inspect();
|
||||
|
||||
Banner("Canonical Path");
|
||||
if (CanonicalPath("mumble/iotest.txt") != 0)
|
||||
return -1;
|
||||
|
||||
Banner("OutputStream");
|
||||
if (OutputStream("mumble/iotest.txt") != 0)
|
||||
return -1;
|
||||
|
||||
Banner("InputStream");
|
||||
if (InputStream("mumble/iotest.txt") != 0)
|
||||
return -1;
|
||||
|
||||
Banner("IOStream");
|
||||
if (IOStream("mumble/iotest.txt") != 0)
|
||||
return -1;
|
||||
if (InputStream("mumble/iotest.txt") != 0)
|
||||
return -1;
|
||||
|
||||
Banner("Parent");
|
||||
nsNativeFileSpec parent;
|
||||
if (Parent("mumble/iotest.txt", parent) != 0)
|
||||
return -1;
|
||||
|
||||
Banner("Delete");
|
||||
if (Delete(parent) != 0)
|
||||
return -1;
|
||||
|
||||
Banner("CreateDirectory");
|
||||
if (CreateDirectory(parent) != 0)
|
||||
return -1;
|
||||
|
||||
Banner("IterateDirectoryChildren");
|
||||
if (IterateDirectoryChildren(parent) != 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
int main()
|
||||
// For use with DEBUG defined.
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
|
||||
FilesTest tester;
|
||||
return tester.RunAllTests();
|
||||
} // main
|
||||
62
mozilla/base/tests/Makefile
Normal file
62
mozilla/base/tests/Makefile
Normal file
@@ -0,0 +1,62 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=../..
|
||||
|
||||
REQUIRES=xpcom netlib
|
||||
|
||||
include $(DEPTH)/config/config.mk
|
||||
|
||||
CPPSRCS = \
|
||||
TestAtoms.cpp \
|
||||
TestCRT.cpp \
|
||||
$(NULL)
|
||||
|
||||
INCLUDES+=-I../src
|
||||
|
||||
OBJS = $(CPPSRCS:.cpp=.o)
|
||||
|
||||
EX_LIBS = \
|
||||
$(DIST)/lib/libraptorbase.a \
|
||||
$(DIST)/lib/libxpcom.a \
|
||||
$(DIST)/lib/libplc21.a \
|
||||
$(DIST)/lib/libplds21.a \
|
||||
$(DIST)/lib/libnspr21.a \
|
||||
$(NULL)
|
||||
|
||||
PROGS = $(addprefix $(OBJDIR)/, $(CPPSRCS:.cpp=))
|
||||
|
||||
TARGETS = $(PROGS)
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
# needed for mac linux
|
||||
ifeq (linux,$(ARCH))
|
||||
OS_LIBS += /usr/lib/libdl.so
|
||||
endif
|
||||
|
||||
$(OBJDIR)/%.o: %.cpp
|
||||
@$(MAKE_OBJDIR)
|
||||
$(CCC) -o $@ $(CFLAGS) -c $*.cpp
|
||||
|
||||
$(PROGS):$(OBJDIR)/%: $(OBJDIR)/%.o $(EX_LIBS)
|
||||
@$(MAKE_OBJDIR)
|
||||
$(CCC) -o $@ $@.o $(LDFLAGS) $(EX_LIBS) $(OS_LIBS)
|
||||
|
||||
install:: $(TARGETS)
|
||||
$(INSTALL) $(PROGS) $(DIST)/bin
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
@@ -14,33 +15,53 @@
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../..
|
||||
DEPTH=../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
REQUIRES = xpcom netlib
|
||||
REQUIRES=xpcom netlib
|
||||
|
||||
CPPSRCS = TestAtoms.cpp TestCRT.cpp FilesTest.cpp
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
LIBS = \
|
||||
-lraptorbase \
|
||||
-lxpcom \
|
||||
$(NSPR_LIBS) \
|
||||
CPPSRCS = \
|
||||
TestAtoms.cpp \
|
||||
TestCRT.cpp \
|
||||
$(NULL)
|
||||
|
||||
SIMPLE_PROGRAMS = $(CPPSRCS:.cpp=)
|
||||
INCLUDES+=-I$(srcdir)/../src
|
||||
|
||||
OBJS = $(CPPSRCS:.cpp=.o)
|
||||
|
||||
EX_LIBS = \
|
||||
$(DIST)/lib/libraptorbase.a \
|
||||
$(DIST)/lib/libxpcom.a \
|
||||
$(DIST)/lib/libplc21.a \
|
||||
$(DIST)/lib/libplds21.a \
|
||||
$(DIST)/lib/libnspr21.a \
|
||||
$(NULL)
|
||||
|
||||
PROGS = $(addprefix $(OBJDIR)/, $(CPPSRCS:.cpp=))
|
||||
|
||||
TARGETS = $(PROGS)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
INCLUDES += -I$(srcdir)/../src
|
||||
|
||||
# needed for mac linux
|
||||
ifeq ($(OS_ARCH),Linux)
|
||||
ifneq ($(OS_RELEASE),1.2)
|
||||
OS_LIBS += /usr/lib/libdl.so
|
||||
endif
|
||||
ifeq (linux,$(ARCH))
|
||||
OS_LIBS += /usr/lib/libdl.so
|
||||
endif
|
||||
|
||||
$(OBJDIR)/%.o: %.cpp
|
||||
@$(MAKE_OBJDIR)
|
||||
$(CCC) -o $@ $(CFLAGS) -c $<
|
||||
|
||||
$(PROGS):$(OBJDIR)/%: $(OBJDIR)/%.o $(EX_LIBS)
|
||||
@$(MAKE_OBJDIR)
|
||||
$(CCC) -o $@ $@.o $(LDFLAGS) $(EX_LIBS) $(OS_LIBS)
|
||||
|
||||
install:: $(TARGETS)
|
||||
$(INSTALL) $(PROGS) $(DIST)/bin
|
||||
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#define NS_IMPL_IDS
|
||||
|
||||
#include "nsXPComCIID.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsINetService.h"
|
||||
#include "nsIProperties.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsRepository.h"
|
||||
#ifdef XP_PC
|
||||
#include "plevent.h"
|
||||
#endif
|
||||
|
||||
#define TEST_URL "resource:/res/test.properties"
|
||||
|
||||
#define NETLIB_DLL "netlib.dll"
|
||||
#define RAPTORBASE_DLL "raptorbase.dll"
|
||||
#define XPCOM_DLL "xpcom32.dll"
|
||||
|
||||
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
|
||||
static NS_DEFINE_IID(kINetServiceIID, NS_INETSERVICE_IID);
|
||||
static NS_DEFINE_IID(kIPropertiesIID, NS_IPROPERTIES_IID);
|
||||
static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID);
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
nsRepository::RegisterFactory(kNetServiceCID, NETLIB_DLL, PR_FALSE,
|
||||
PR_FALSE);
|
||||
nsRepository::RegisterFactory(kEventQueueServiceCID, XPCOM_DLL,
|
||||
PR_FALSE, PR_FALSE);
|
||||
nsresult ret;
|
||||
nsIEventQueueService* pEventQueueService = nsnull;
|
||||
ret = nsServiceManager::GetService(kEventQueueServiceCID,
|
||||
kIEventQueueServiceIID, (nsISupports**) &pEventQueueService);
|
||||
if (NS_FAILED(ret)) {
|
||||
printf("cannot get event queue service\n");
|
||||
return 1;
|
||||
}
|
||||
ret = pEventQueueService->CreateThreadEventQueue();
|
||||
if (NS_FAILED(ret)) {
|
||||
printf("CreateThreadEventQueue failed\n");
|
||||
return 1;
|
||||
}
|
||||
nsINetService* pNetService = nsnull;
|
||||
ret = nsServiceManager::GetService(kNetServiceCID, kINetServiceIID,
|
||||
(nsISupports**) &pNetService);
|
||||
if (NS_FAILED(ret)) {
|
||||
printf("cannot get net service\n");
|
||||
return 1;
|
||||
}
|
||||
nsIURL *url = nsnull;
|
||||
ret = pNetService->CreateURL(&url, nsString(TEST_URL), nsnull, nsnull,
|
||||
nsnull);
|
||||
if (NS_FAILED(ret)) {
|
||||
printf("cannot create URL\n");
|
||||
return 1;
|
||||
}
|
||||
nsIInputStream *in = nsnull;
|
||||
ret = pNetService->OpenBlockingStream(url, nsnull, &in);
|
||||
if (NS_FAILED(ret)) {
|
||||
printf("cannot open stream\n");
|
||||
return 1;
|
||||
}
|
||||
nsIProperties *props = nsnull;
|
||||
ret = nsRepository::CreateInstance(kPropertiesCID, NULL,
|
||||
kIPropertiesIID, (void**) &props);
|
||||
if (NS_FAILED(ret)) {
|
||||
printf("create nsIProperties failed\n");
|
||||
return 1;
|
||||
}
|
||||
props->Load(in);
|
||||
int i = 1;
|
||||
while (1) {
|
||||
char name[16];
|
||||
sprintf(name, "%d", i);
|
||||
nsAutoString v("");
|
||||
props->GetProperty(name, v);
|
||||
if (!v.Length()) {
|
||||
break;
|
||||
}
|
||||
char *value = v.ToNewCString();
|
||||
cout << "\"" << i << "\"=\"" << value << "\"" << endl;
|
||||
i++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -22,19 +22,15 @@ PROG0 = .\$(OBJDIR)\TimerTest.exe
|
||||
PROG1 = .\$(OBJDIR)\TestAtoms.exe
|
||||
PROG2 = .\$(OBJDIR)\CvtURL.exe
|
||||
PROG3 = .\$(OBJDIR)\TestCRT.exe
|
||||
PROG4 = .\$(OBJDIR)\FilesTest.exe
|
||||
PROG5 = .\$(OBJDIR)\PropertiesTest.exe
|
||||
RESFILE = timer.res
|
||||
PROGRAMS = $(PROG0) $(PROG1) \
|
||||
!ifdef MODULAR_NETLIB
|
||||
$(PROG2) \
|
||||
$(PROG3) \
|
||||
$(PROG5) \
|
||||
!endif
|
||||
$(PROG4) \
|
||||
$(NULL)
|
||||
$(NULL)
|
||||
|
||||
LINCS=-I..\src -I$(PUBLIC)\xpcom -I$(PUBLIC)\netlib -I$(PUBLIC)\raptor
|
||||
LINCS=-I..\src -I$(PUBLIC)\xpcom -I$(PUBLIC)\netlib
|
||||
|
||||
LLIBS= \
|
||||
$(DIST)\lib\xpcom32.lib \
|
||||
@@ -57,10 +53,7 @@ install:: $(PROGRAMS)
|
||||
!ifdef MODULAR_NETLIB
|
||||
$(MAKE_INSTALL) $(PROG2) $(DIST)\bin
|
||||
$(MAKE_INSTALL) $(PROG3) $(DIST)\bin
|
||||
$(MAKE_INSTALL) $(PROG5) $(DIST)\bin
|
||||
$(MAKE_INSTALL) test.properties $(DIST)\bin\res
|
||||
!endif
|
||||
$(MAKE_INSTALL) $(PROG4) $(DIST)\bin
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\bin\TimerTest.exe
|
||||
@@ -68,10 +61,7 @@ clobber::
|
||||
!ifdef MODULAR_NETLIB
|
||||
rm -f $(DIST)\bin\CvtURL.exe
|
||||
rm -f $(DIST)\bin\TestCRT.exe
|
||||
rm -f $(DIST)\bin\PropertiesTest.exe
|
||||
rm -f $(DIST)\bin\res\test.properties
|
||||
!endif
|
||||
rm -f $(DIST)\bin\FilesTest.exe
|
||||
|
||||
# Move this into config/obj.inc when it's allowed
|
||||
.cpp{.\$(OBJDIR)\}.exe:
|
||||
@@ -93,12 +83,8 @@ $(PROG0): $(OBJDIR) TimerTest.cpp $(RESFILE)
|
||||
|
||||
$(PROG1): $(OBJDIR) TestAtoms.cpp
|
||||
|
||||
$(PROG4): $(OBJDIR) FilesTest.cpp
|
||||
|
||||
!ifdef MODULAR_NETLIB
|
||||
$(PROG2): $(OBJDIR) CvtURL.cpp
|
||||
|
||||
$(PROG3): $(OBJDIR) TestCRT.cpp
|
||||
|
||||
$(PROG5): $(OBJDIR) PropertiesTest.cpp
|
||||
!endif
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
1=1
|
||||
2=2
|
||||
3 =3
|
||||
4 =4
|
||||
5=5
|
||||
6= 6
|
||||
7=7
|
||||
8= 8
|
||||
# this is a comment
|
||||
9=this is the first part of a continued line \
|
||||
and here is the 2nd part
|
||||
272
mozilla/build/autoconf/config.guess
vendored
272
mozilla/build/autoconf/config.guess
vendored
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
# Attempt to guess a canonical system name.
|
||||
# Copyright (C) 1992, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1992, 93, 94, 95, 1996 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
@@ -52,53 +52,11 @@ trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15
|
||||
|
||||
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
alpha:OSF1:*:*)
|
||||
if test $UNAME_RELEASE = "V4.0"; then
|
||||
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
|
||||
fi
|
||||
# A Vn.n version is a released version.
|
||||
# A Tn.n version is a released field test version.
|
||||
# A Xn.n version is an unreleased experimental baselevel.
|
||||
# 1.2 uses "1.2" for uname -r.
|
||||
cat <<EOF >dummy.s
|
||||
.globl main
|
||||
.ent main
|
||||
main:
|
||||
.frame \$30,0,\$26,0
|
||||
.prologue 0
|
||||
.long 0x47e03d80 # implver $0
|
||||
lda \$2,259
|
||||
.long 0x47e20c21 # amask $2,$1
|
||||
srl \$1,8,\$2
|
||||
sll \$2,2,\$2
|
||||
sll \$0,3,\$0
|
||||
addl \$1,\$0,\$0
|
||||
addl \$2,\$0,\$0
|
||||
ret \$31,(\$26),1
|
||||
.end main
|
||||
EOF
|
||||
${CC-cc} dummy.s -o dummy 2>/dev/null
|
||||
if test "$?" = 0 ; then
|
||||
./dummy
|
||||
case "$?" in
|
||||
7)
|
||||
UNAME_MACHINE="alpha"
|
||||
;;
|
||||
15)
|
||||
UNAME_MACHINE="alphaev5"
|
||||
;;
|
||||
14)
|
||||
UNAME_MACHINE="alphaev56"
|
||||
;;
|
||||
10)
|
||||
UNAME_MACHINE="alphapca56"
|
||||
;;
|
||||
16)
|
||||
UNAME_MACHINE="alphaev6"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
rm -f dummy.s dummy
|
||||
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr [[A-Z]] [[a-z]]`
|
||||
echo alpha-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//'`
|
||||
exit 0 ;;
|
||||
21064:Windows_NT:50:3)
|
||||
echo alpha-dec-winnt3.5
|
||||
@@ -110,35 +68,11 @@ EOF
|
||||
echo m68k-cbm-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
amiga:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
arc64:OpenBSD:*:*)
|
||||
echo mips64el-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
arc:OpenBSD:*:*)
|
||||
echo mipsel-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
hkmips:OpenBSD:*:*)
|
||||
echo mips-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
pmax:OpenBSD:*:*)
|
||||
echo mipsel-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
sgi:OpenBSD:*:*)
|
||||
echo mips-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
wgrisc:OpenBSD:*:*)
|
||||
echo mipsel-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
echo m68k-cbm-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
|
||||
echo arm-acorn-riscix${UNAME_RELEASE}
|
||||
exit 0;;
|
||||
arm32:NetBSD:*:*)
|
||||
echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
|
||||
exit 0 ;;
|
||||
SR2?01:HI-UX/MPP:*:*)
|
||||
echo hppa1.1-hitachi-hiuxmpp
|
||||
exit 0;;
|
||||
Pyramid*:OSx*:*:*|MIS*:OSx*:*:*)
|
||||
# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
|
||||
if test "`(/bin/universe) 2>/dev/null`" = att ; then
|
||||
@@ -174,18 +108,6 @@ EOF
|
||||
sun3*:SunOS:*:*)
|
||||
echo m68k-sun-sunos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
sun*:*:4.2BSD:*)
|
||||
UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
|
||||
test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
|
||||
case "`/bin/arch`" in
|
||||
sun3)
|
||||
echo m68k-sun-sunos${UNAME_RELEASE}
|
||||
;;
|
||||
sun4)
|
||||
echo sparc-sun-sunos${UNAME_RELEASE}
|
||||
;;
|
||||
esac
|
||||
exit 0 ;;
|
||||
aushp:SunOS:*:*)
|
||||
echo sparc-auspex-sunos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
@@ -193,25 +115,19 @@ EOF
|
||||
echo m68k-atari-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
atari*:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
echo m68k-atari-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
sun3*:NetBSD:*:*)
|
||||
echo m68k-sun-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
sun3*:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
echo m68k-sun-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mac68k:NetBSD:*:*)
|
||||
echo m68k-apple-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mac68k:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mvme68k:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mvme88k:OpenBSD:*:*)
|
||||
echo m88k-unknown-openbsd${UNAME_RELEASE}
|
||||
echo m68k-apple-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
powerpc:machten:*:*)
|
||||
echo powerpc-apple-machten${UNAME_RELEASE}
|
||||
@@ -462,8 +378,8 @@ EOF
|
||||
hp3[0-9][05]:NetBSD:*:*)
|
||||
echo m68k-hp-netbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
hp300:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
hp3[0-9][05]:OpenBSD:*:*)
|
||||
echo m68k-hp-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
i?86:BSD/386:*:* | *:BSD/OS:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
|
||||
@@ -478,10 +394,7 @@ EOF
|
||||
echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
|
||||
exit 0 ;;
|
||||
i*:CYGWIN*:*)
|
||||
echo ${UNAME_MACHINE}-pc-cygwin32
|
||||
exit 0 ;;
|
||||
i*:MINGW*:*)
|
||||
echo ${UNAME_MACHINE}-pc-mingw32
|
||||
echo i386-pc-cygwin32
|
||||
exit 0 ;;
|
||||
p*:CYGWIN*:*)
|
||||
echo powerpcle-unknown-cygwin32
|
||||
@@ -490,134 +403,43 @@ EOF
|
||||
echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit 0 ;;
|
||||
*:GNU:*:*)
|
||||
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
|
||||
echo `echo ${UNAME_MACHINE}|sed -e 's,/.*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
|
||||
exit 0 ;;
|
||||
*:Linux:*:*)
|
||||
# uname on the ARM produces all sorts of strangeness, and we need to
|
||||
# filter it out.
|
||||
case "$UNAME_MACHINE" in
|
||||
arm* | sa110*) UNAME_MACHINE="arm" ;;
|
||||
esac
|
||||
|
||||
# The BFD linker knows what the default object file format is, so
|
||||
# first see if it will tell us.
|
||||
ld_help_string=`ld --help 2>&1`
|
||||
ld_supported_emulations=`echo $ld_help_string \
|
||||
| sed -ne '/supported emulations:/!d
|
||||
s/[ ][ ]*/ /g
|
||||
s/.*supported emulations: *//
|
||||
s/ .*//
|
||||
p'`
|
||||
case "$ld_supported_emulations" in
|
||||
i?86linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0 ;;
|
||||
i?86coff) echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0 ;;
|
||||
sparclinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
|
||||
armlinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
|
||||
m68klinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
|
||||
elf32ppc) echo "powerpc-unknown-linux-gnu" ; exit 0 ;;
|
||||
esac
|
||||
|
||||
if test "${UNAME_MACHINE}" = "alpha" ; then
|
||||
sed 's/^ //' <<EOF >dummy.s
|
||||
.globl main
|
||||
.ent main
|
||||
main:
|
||||
.frame \$30,0,\$26,0
|
||||
.prologue 0
|
||||
.long 0x47e03d80 # implver $0
|
||||
lda \$2,259
|
||||
.long 0x47e20c21 # amask $2,$1
|
||||
srl \$1,8,\$2
|
||||
sll \$2,2,\$2
|
||||
sll \$0,3,\$0
|
||||
addl \$1,\$0,\$0
|
||||
addl \$2,\$0,\$0
|
||||
ret \$31,(\$26),1
|
||||
.end main
|
||||
EOF
|
||||
LIBC=""
|
||||
${CC-cc} dummy.s -o dummy 2>/dev/null
|
||||
if test "$?" = 0 ; then
|
||||
./dummy
|
||||
case "$?" in
|
||||
7)
|
||||
UNAME_MACHINE="alpha"
|
||||
;;
|
||||
15)
|
||||
UNAME_MACHINE="alphaev5"
|
||||
;;
|
||||
14)
|
||||
UNAME_MACHINE="alphaev56"
|
||||
;;
|
||||
10)
|
||||
UNAME_MACHINE="alphapca56"
|
||||
;;
|
||||
16)
|
||||
UNAME_MACHINE="alphaev6"
|
||||
;;
|
||||
esac
|
||||
|
||||
objdump --private-headers dummy | \
|
||||
grep ld.so.1 > /dev/null
|
||||
if test "$?" = 0 ; then
|
||||
LIBC="libc1"
|
||||
fi
|
||||
fi
|
||||
rm -f dummy.s dummy
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0
|
||||
elif test "${UNAME_MACHINE}" = "mips" ; then
|
||||
cat >dummy.c <<EOF
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
#ifdef __MIPSEB__
|
||||
printf ("%s-unknown-linux-gnu\n", argv[1]);
|
||||
#endif
|
||||
#ifdef __MIPSEL__
|
||||
printf ("%sel-unknown-linux-gnu\n", argv[1]);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
|
||||
rm -f dummy.c dummy
|
||||
if echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: elf_i.86"; then
|
||||
echo "${UNAME_MACHINE}-pc-linux" ; exit 0
|
||||
elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: i.86linux"; then
|
||||
echo "${UNAME_MACHINE}-pc-linuxaout" ; exit 0
|
||||
elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: i.86coff"; then
|
||||
echo "${UNAME_MACHINE}-pc-linuxcoff" ; exit 0
|
||||
elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: m68kelf"; then
|
||||
echo "${UNAME_MACHINE}-unknown-linux" ; exit 0
|
||||
elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: m68klinux"; then
|
||||
echo "${UNAME_MACHINE}-unknown-linuxaout" ; exit 0
|
||||
elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: elf32ppc"; then
|
||||
echo "powerpc-unknown-linux" ; exit 0
|
||||
elif test "${UNAME_MACHINE}" = "alpha" ; then
|
||||
echo alpha-unknown-linux ; exit 0
|
||||
elif test "${UNAME_MACHINE}" = "sparc" ; then
|
||||
echo sparc-unknown-linux ; exit 0
|
||||
else
|
||||
# Either a pre-BFD a.out linker (linux-gnuoldld)
|
||||
# or one that does not give us useful --help.
|
||||
# GCC wants to distinguish between linux-gnuoldld and linux-gnuaout.
|
||||
# If ld does not provide *any* "supported emulations:"
|
||||
# that means it is gnuoldld.
|
||||
echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:"
|
||||
test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
|
||||
|
||||
case "${UNAME_MACHINE}" in
|
||||
i?86)
|
||||
VENDOR=pc;
|
||||
;;
|
||||
*)
|
||||
VENDOR=unknown;
|
||||
;;
|
||||
esac
|
||||
# Either a pre-BFD a.out linker (linuxoldld) or one that does not give us
|
||||
# useful --help. Gcc wants to distinguish between linuxoldld and linuxaout.
|
||||
test ! -d /usr/lib/ldscripts/. \
|
||||
&& echo "${UNAME_MACHINE}-pc-linuxoldld" && exit 0
|
||||
# Determine whether the default compiler is a.out or elf
|
||||
cat >dummy.c <<EOF
|
||||
#include <features.h>
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
#ifdef __ELF__
|
||||
# ifdef __GLIBC__
|
||||
# if __GLIBC__ >= 2
|
||||
printf ("%s-${VENDOR}-linux-gnu\n", argv[1]);
|
||||
# else
|
||||
printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
|
||||
# endif
|
||||
# else
|
||||
printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
|
||||
# endif
|
||||
printf ("%s-pc-linux\n", argv[1]);
|
||||
#else
|
||||
printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]);
|
||||
printf ("%s-pc-linuxaout\n", argv[1]);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@@ -630,14 +452,6 @@ EOF
|
||||
i?86:DYNIX/ptx:4*:*)
|
||||
echo i386-sequent-sysv4
|
||||
exit 0 ;;
|
||||
i?86:UNIX_SV:4.2MP:2.*)
|
||||
# Unixware is an offshoot of SVR4, but it has its own version
|
||||
# number series starting with 2...
|
||||
# I am not positive that other SVR4 systems won't match this,
|
||||
# I just have to hope. -- rms.
|
||||
# Use sysv4.2uw... so that sysv4* matches it.
|
||||
echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
|
||||
exit 0 ;;
|
||||
i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
|
||||
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
|
||||
echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE}
|
||||
@@ -659,11 +473,6 @@ EOF
|
||||
echo ${UNAME_MACHINE}-pc-sysv32
|
||||
fi
|
||||
exit 0 ;;
|
||||
pc:*:*:*)
|
||||
# uname -m prints for DJGPP always 'pc', but it prints nothing about
|
||||
# the processor, so we play safe by assuming i386.
|
||||
echo i386-pc-msdosdjgpp
|
||||
exit 0 ;;
|
||||
Intel:Mach:3*:*)
|
||||
echo i386-pc-mach3
|
||||
exit 0 ;;
|
||||
@@ -723,10 +532,6 @@ EOF
|
||||
echo ns32k-sni-sysv
|
||||
fi
|
||||
exit 0 ;;
|
||||
PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
|
||||
# says <Richard.M.Bartel@ccMail.Census.GOV>
|
||||
echo i586-unisys-sysv4
|
||||
exit 0 ;;
|
||||
*:UNIX_System_V:4*:FTX*)
|
||||
# From Gerald Hewes <hewes@openmarket.com>.
|
||||
# How about differentiating between stratus architectures? -djm
|
||||
@@ -739,9 +544,6 @@ EOF
|
||||
mc68*:A/UX:*:*)
|
||||
echo m68k-apple-aux${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
news*:NEWS-OS:*:6*)
|
||||
echo mips-sony-newsos6
|
||||
exit 0 ;;
|
||||
R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:*)
|
||||
if [ -d /usr/nec ]; then
|
||||
echo mips-nec-sysv${UNAME_RELEASE}
|
||||
@@ -749,6 +551,10 @@ EOF
|
||||
echo mips-unknown-sysv${UNAME_RELEASE}
|
||||
fi
|
||||
exit 0 ;;
|
||||
PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
|
||||
# says <Richard.M.Bartel@ccMail.Census.GOV>
|
||||
echo i586-unisys-sysv4
|
||||
exit 0 ;;
|
||||
esac
|
||||
|
||||
#echo '(No uname command or uname output not recognized.)' 1>&2
|
||||
|
||||
106
mozilla/build/autoconf/config.sub
vendored
106
mozilla/build/autoconf/config.sub
vendored
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
# Configuration validation subroutine script, version 1.1.
|
||||
# Copyright (C) 1991, 92-97, 1998 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1991, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
|
||||
# This file is (in principle) common to ALL GNU software.
|
||||
# The presence of a machine in this file suggests that SOME GNU software
|
||||
# can handle that machine. It does not imply ALL GNU software can.
|
||||
@@ -69,7 +69,7 @@ esac
|
||||
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
|
||||
case $maybe_os in
|
||||
linux-gnu*)
|
||||
os=-$maybe_os
|
||||
os=`echo $maybe_os | sed -e 's|linux-gnu|linux|'`
|
||||
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
|
||||
;;
|
||||
*)
|
||||
@@ -149,20 +149,19 @@ esac
|
||||
case $basic_machine in
|
||||
# Recognize the basic CPU types without company name.
|
||||
# Some are omitted here because they have special meanings below.
|
||||
tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \
|
||||
| arme[lb] | pyramid | mn10200 | mn10300 \
|
||||
tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arm \
|
||||
| arme[lb] | pyramid | mn10300 \
|
||||
| tron | a29k | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 \
|
||||
| alpha | alphaev5 | alphaev56 | we32k | ns16k | clipper \
|
||||
| i370 | sh | powerpc | powerpcle | 1750a | dsp16xx | pdp11 \
|
||||
| mips64 | mipsel | mips64el | mips64orion | mips64orionel \
|
||||
| mipstx39 | mipstx39el \
|
||||
| sparc | sparclet | sparclite | sparc64 | v850)
|
||||
| alpha | we32k | ns16k | clipper | i370 | sh \
|
||||
| powerpc | powerpcle | 1750a | dsp16xx | mips64 | mipsel \
|
||||
| pdp11 | mips64el | mips64orion | mips64orionel \
|
||||
| sparc | sparclet | sparclite | sparc64)
|
||||
basic_machine=$basic_machine-unknown
|
||||
;;
|
||||
# We use `pc' rather than `unknown'
|
||||
# because (1) that's what they normally are, and
|
||||
# (2) the word "unknown" tends to confuse beginning users.
|
||||
i[34567]86)
|
||||
i[3456]86)
|
||||
basic_machine=$basic_machine-pc
|
||||
;;
|
||||
# Object if more than one company name word.
|
||||
@@ -171,18 +170,14 @@ case $basic_machine in
|
||||
exit 1
|
||||
;;
|
||||
# Recognize the basic CPU types with company name.
|
||||
vax-* | tahoe-* | i[34567]86-* | i860-* | m32r-* | m68k-* | m68000-* \
|
||||
| m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \
|
||||
| mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
|
||||
| power-* | none-* | 580-* | cray2-* | h8300-* | i960-* \
|
||||
| xmp-* | ymp-* | hppa-* | hppa1.0-* | hppa1.1-* \
|
||||
| alpha-* | alphaev5-* | alphaev56-* | we32k-* | cydra-* \
|
||||
| ns16k-* | pn-* | np1-* | xps100-* | clipper-* | orion-* \
|
||||
| sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
|
||||
| sparc64-* | mips64-* | mipsel-* \
|
||||
| mips64el-* | mips64orion-* | mips64orionel-* \
|
||||
| mipstx39-* | mipstx39el-* \
|
||||
| f301-*)
|
||||
vax-* | tahoe-* | i[3456]86-* | i860-* | m32r-* | m68k-* | m68000-* \
|
||||
| m88k-* | sparc-* | ns32k-* | fx80-* | arm-* | c[123]* \
|
||||
| mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* | power-* \
|
||||
| none-* | 580-* | cray2-* | h8300-* | i960-* | xmp-* | ymp-* \
|
||||
| hppa-* | hppa1.0-* | hppa1.1-* | alpha-* | we32k-* | cydra-* | ns16k-* \
|
||||
| pn-* | np1-* | xps100-* | clipper-* | orion-* | sparclite-* \
|
||||
| pdp11-* | sh-* | powerpc-* | powerpcle-* | sparc64-* | mips64-* | mipsel-* \
|
||||
| mips64el-* | mips64orion-* | mips64orionel-* | f301-*)
|
||||
;;
|
||||
# Recognize the various machine names and aliases which stand
|
||||
# for a CPU type and a company and sometimes even an OS.
|
||||
@@ -209,9 +204,9 @@ case $basic_machine in
|
||||
amiga | amiga-*)
|
||||
basic_machine=m68k-cbm
|
||||
;;
|
||||
amigaos | amigados)
|
||||
amigados)
|
||||
basic_machine=m68k-cbm
|
||||
os=-amigaos
|
||||
os=-amigados
|
||||
;;
|
||||
amigaunix | amix)
|
||||
basic_machine=m68k-cbm
|
||||
@@ -350,19 +345,19 @@ case $basic_machine in
|
||||
os=-mvs
|
||||
;;
|
||||
# I'm not sure what "Sysv32" means. Should this be sysv3.2?
|
||||
i[34567]86v32)
|
||||
i[3456]86v32)
|
||||
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
|
||||
os=-sysv32
|
||||
;;
|
||||
i[34567]86v4*)
|
||||
i[3456]86v4*)
|
||||
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
|
||||
os=-sysv4
|
||||
;;
|
||||
i[34567]86v)
|
||||
i[3456]86v)
|
||||
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
|
||||
os=-sysv
|
||||
;;
|
||||
i[34567]86sol2)
|
||||
i[3456]86sol2)
|
||||
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
|
||||
os=-solaris2
|
||||
;;
|
||||
@@ -396,11 +391,11 @@ case $basic_machine in
|
||||
;;
|
||||
mipsel*-linux*)
|
||||
basic_machine=mipsel-unknown
|
||||
os=-linux-gnu
|
||||
os=-linux
|
||||
;;
|
||||
mips*-linux*)
|
||||
basic_machine=mips-unknown
|
||||
os=-linux-gnu
|
||||
os=-linux
|
||||
;;
|
||||
mips3*-*)
|
||||
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
|
||||
@@ -469,23 +464,25 @@ case $basic_machine in
|
||||
pc532 | pc532-*)
|
||||
basic_machine=ns32k-pc532
|
||||
;;
|
||||
pentium | p5 | k5 | nexen)
|
||||
basic_machine=i586-pc
|
||||
pentium | p5)
|
||||
basic_machine=i586-intel
|
||||
;;
|
||||
pentiumpro | p6 | k6 | 6x86)
|
||||
basic_machine=i686-pc
|
||||
pentiumpro | p6)
|
||||
basic_machine=i686-intel
|
||||
;;
|
||||
pentiumii | pentium2)
|
||||
basic_machine=i786-pc
|
||||
;;
|
||||
pentium-* | p5-* | k5-* | nexen-*)
|
||||
pentium-* | p5-*)
|
||||
basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
pentiumpro-* | p6-* | k6-* | 6x86-*)
|
||||
pentiumpro-* | p6-*)
|
||||
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
pentiumii-* | pentium2-*)
|
||||
basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
k5)
|
||||
# We don't have specific support for AMD's K5 yet, so just call it a Pentium
|
||||
basic_machine=i586-amd
|
||||
;;
|
||||
nexen)
|
||||
# We don't have specific support for Nexgen yet, so just call it a Pentium
|
||||
basic_machine=i586-nexgen
|
||||
;;
|
||||
pn)
|
||||
basic_machine=pn-gould
|
||||
@@ -569,12 +566,6 @@ case $basic_machine in
|
||||
basic_machine=i386-sequent
|
||||
os=-dynix
|
||||
;;
|
||||
tx39)
|
||||
basic_machine=mipstx39-unknown
|
||||
;;
|
||||
tx39el)
|
||||
basic_machine=mipstx39el-unknown
|
||||
;;
|
||||
tower | tower-32)
|
||||
basic_machine=m68k-ncr
|
||||
;;
|
||||
@@ -594,7 +585,7 @@ case $basic_machine in
|
||||
basic_machine=vax-dec
|
||||
os=-vms
|
||||
;;
|
||||
vpp*|vx|vx-*)
|
||||
vpp*|vx|vx-*)
|
||||
basic_machine=f301-fujitsu
|
||||
;;
|
||||
vxworks960)
|
||||
@@ -624,7 +615,7 @@ case $basic_machine in
|
||||
# Here we handle the default manufacturer of certain CPU types. It is in
|
||||
# some cases the only manufacturer, in others, it is the most popular.
|
||||
mips)
|
||||
if [ x$os = x-linux-gnu ]; then
|
||||
if [ x$os = x-linux ]; then
|
||||
basic_machine=mips-unknown
|
||||
else
|
||||
basic_machine=mips-mips
|
||||
@@ -689,14 +680,11 @@ case $os in
|
||||
-solaris)
|
||||
os=-solaris2
|
||||
;;
|
||||
-svr4*)
|
||||
-unixware* | svr4*)
|
||||
os=-sysv4
|
||||
;;
|
||||
-unixware*)
|
||||
os=-sysv4.2uw
|
||||
;;
|
||||
-gnu/linux*)
|
||||
os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
|
||||
os=`echo $os | sed -e 's|gnu/linux|linux|'`
|
||||
;;
|
||||
# First accept the basic system types.
|
||||
# The portable systems comes first.
|
||||
@@ -705,8 +693,7 @@ case $os in
|
||||
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
|
||||
| -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
|
||||
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
|
||||
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
|
||||
| -aos* \
|
||||
| -amigados* | -msdos* | -newsos* | -unicos* | -aof* | -aos* \
|
||||
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
|
||||
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
|
||||
| -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
|
||||
@@ -714,12 +701,9 @@ case $os in
|
||||
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
|
||||
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
|
||||
| -cygwin32* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
|
||||
| -mingw32* | -linux-gnu* | -uxpv*)
|
||||
| -linux* | -uxpv*)
|
||||
# Remember, each alternative MUST END IN *, to match a version number.
|
||||
;;
|
||||
-linux*)
|
||||
os=`echo $os | sed -e 's|linux|linux-gnu|'`
|
||||
;;
|
||||
-sunos5*)
|
||||
os=`echo $os | sed -e 's|sunos5|solaris2|'`
|
||||
;;
|
||||
@@ -840,7 +824,7 @@ case $basic_machine in
|
||||
os=-sysv
|
||||
;;
|
||||
*-cbm)
|
||||
os=-amigaos
|
||||
os=-amigados
|
||||
;;
|
||||
*-dg)
|
||||
os=-dgux
|
||||
|
||||
@@ -1,186 +0,0 @@
|
||||
# Configure paths for GTK+
|
||||
# Owen Taylor 97-11-3
|
||||
# (copy of gtk.m4 (public domain))
|
||||
|
||||
dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
|
||||
dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS
|
||||
dnl
|
||||
AC_DEFUN(AM_PATH_GTK,
|
||||
[dnl
|
||||
dnl Get the cflags and libraries from the gtk-config script
|
||||
dnl
|
||||
AC_ARG_WITH(gtk-prefix,[ --with-gtk-prefix=PFX Prefix where GTK is installed (optional)],
|
||||
gtk_config_prefix="$withval", gtk_config_prefix="")
|
||||
AC_ARG_WITH(gtk-exec-prefix,[ --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)],
|
||||
gtk_config_exec_prefix="$withval", gtk_config_exec_prefix="")
|
||||
AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
|
||||
, enable_gtktest=yes)
|
||||
|
||||
if test x$gtk_config_exec_prefix != x ; then
|
||||
gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix"
|
||||
if test x${GTK_CONFIG+set} != xset ; then
|
||||
GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config
|
||||
fi
|
||||
fi
|
||||
if test x$gtk_config_prefix != x ; then
|
||||
gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix"
|
||||
if test x${GTK_CONFIG+set} != xset ; then
|
||||
GTK_CONFIG=$gtk_config_prefix/bin/gtk-config
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_PATH_PROG(GTK_CONFIG, gtk-config, no)
|
||||
min_gtk_version=ifelse([$1], ,0.99.7,$1)
|
||||
AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
|
||||
no_gtk=""
|
||||
if test "$GTK_CONFIG" = "no" ; then
|
||||
no_gtk=yes
|
||||
else
|
||||
GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags`
|
||||
GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs`
|
||||
gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
|
||||
gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
|
||||
gtk_config_micro_version=`$GTK_CONFIG $gtk_config_args --version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
|
||||
if test "x$enable_gtktest" = "xyes" ; then
|
||||
ac_save_CFLAGS="$CFLAGS"
|
||||
ac_save_LIBS="$LIBS"
|
||||
CFLAGS="$CFLAGS $GTK_CFLAGS"
|
||||
LIBS="$LIBS $GTK_LIBS"
|
||||
dnl
|
||||
dnl Now check if the installed GTK is sufficiently new. (Also sanity
|
||||
dnl checks the results of gtk-config to some extent
|
||||
dnl
|
||||
rm -f conf.gtktest
|
||||
AC_TRY_RUN([
|
||||
#include <gtk/gtk.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
int major, minor, micro;
|
||||
char *tmp_version;
|
||||
|
||||
system ("touch conf.gtktest");
|
||||
|
||||
/* HP/UX 9 (%@#!) writes to sscanf strings */
|
||||
tmp_version = g_strdup("$min_gtk_version");
|
||||
if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
|
||||
printf("%s, bad version string\n", "$min_gtk_version");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ((gtk_major_version != $gtk_config_major_version) ||
|
||||
(gtk_minor_version != $gtk_config_minor_version) ||
|
||||
(gtk_micro_version != $gtk_config_micro_version))
|
||||
{
|
||||
printf("\n*** 'gtk-config --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n",
|
||||
$gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
|
||||
gtk_major_version, gtk_minor_version, gtk_micro_version);
|
||||
printf ("*** was found! If gtk-config was correct, then it is best\n");
|
||||
printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
|
||||
printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
|
||||
printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
|
||||
printf("*** required on your system.\n");
|
||||
printf("*** If gtk-config was wrong, set the environment variable GTK_CONFIG\n");
|
||||
printf("*** to point to the correct copy of gtk-config, and remove the file config.cache\n");
|
||||
printf("*** before re-running configure\n");
|
||||
}
|
||||
#if defined (GTK_MAJOR_VERSION) && defined (GTK_MINOR_VERSION) && defined (GTK_MICRO_VERSION)
|
||||
else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
|
||||
(gtk_minor_version != GTK_MINOR_VERSION) ||
|
||||
(gtk_micro_version != GTK_MICRO_VERSION))
|
||||
{
|
||||
printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
|
||||
GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
|
||||
printf("*** library (version %d.%d.%d)\n",
|
||||
gtk_major_version, gtk_minor_version, gtk_micro_version);
|
||||
}
|
||||
#endif /* defined (GTK_MAJOR_VERSION) ... */
|
||||
else
|
||||
{
|
||||
if ((gtk_major_version > major) ||
|
||||
((gtk_major_version == major) && (gtk_minor_version > minor)) ||
|
||||
((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
|
||||
gtk_major_version, gtk_minor_version, gtk_micro_version);
|
||||
printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
|
||||
major, minor, micro);
|
||||
printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
|
||||
printf("***\n");
|
||||
printf("*** If you have already installed a sufficiently new version, this error\n");
|
||||
printf("*** probably means that the wrong copy of the gtk-config shell script is\n");
|
||||
printf("*** being found. The easiest way to fix this is to remove the old version\n");
|
||||
printf("*** of GTK+, but you can also set the GTK_CONFIG environment to point to the\n");
|
||||
printf("*** correct copy of gtk-config. (In this case, you will have to\n");
|
||||
printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
|
||||
printf("*** so that the correct libraries are found at run-time))\n");
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
|
||||
CFLAGS="$ac_save_CFLAGS"
|
||||
LIBS="$ac_save_LIBS"
|
||||
fi
|
||||
fi
|
||||
if test "x$no_gtk" = x ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
ifelse([$2], , :, [$2])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
if test "$GTK_CONFIG" = "no" ; then
|
||||
echo "*** The gtk-config script installed by GTK could not be found"
|
||||
echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in"
|
||||
echo "*** your path, or set the GTK_CONFIG environment variable to the"
|
||||
echo "*** full path to gtk-config."
|
||||
else
|
||||
if test -f conf.gtktest ; then
|
||||
:
|
||||
else
|
||||
echo "*** Could not run GTK test program, checking why..."
|
||||
CFLAGS="$CFLAGS $GTK_CFLAGS"
|
||||
LIBS="$LIBS $GTK_LIBS"
|
||||
AC_TRY_LINK([
|
||||
#include <gtk/gtk.h>
|
||||
#include <stdio.h>
|
||||
], [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
|
||||
[ echo "*** The test program compiled, but did not run. This usually means"
|
||||
echo "*** that the run-time linker is not finding GTK or finding the wrong"
|
||||
echo "*** version of GTK. If it is not finding GTK, you'll need to set your"
|
||||
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
|
||||
echo "*** to the installed location Also, make sure you have run ldconfig if that"
|
||||
echo "*** is required on your system"
|
||||
echo "***"
|
||||
echo "*** If you have an old version installed, it is best to remove it, although"
|
||||
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
|
||||
echo "***"
|
||||
echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
|
||||
echo "*** came with the system with the command"
|
||||
echo "***"
|
||||
echo "*** rpm --erase --nodeps gtk gtk-devel" ],
|
||||
[ echo "*** The test program failed to compile or link. See the file config.log for the"
|
||||
echo "*** exact error that occured. This usually means GTK was incorrectly installed"
|
||||
echo "*** or that you have moved GTK since it was installed. In the latter case, you"
|
||||
echo "*** may want to edit the gtk-config script: $GTK_CONFIG" ])
|
||||
CFLAGS="$ac_save_CFLAGS"
|
||||
LIBS="$ac_save_LIBS"
|
||||
fi
|
||||
fi
|
||||
GTK_CFLAGS=""
|
||||
GTK_LIBS=""
|
||||
ifelse([$3], , :, [$3])
|
||||
fi
|
||||
AC_SUBST(GTK_CFLAGS)
|
||||
AC_SUBST(GTK_LIBS)
|
||||
rm -f conf.gtktest
|
||||
])
|
||||
@@ -1,83 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
#
|
||||
# This script will generate a single Makefile from a Makefile.in using
|
||||
# the config.status script.
|
||||
#
|
||||
# The config.status script is generated the first time you run
|
||||
# ./configure.
|
||||
#
|
||||
#
|
||||
# Usage: update-makefile.sh
|
||||
#
|
||||
# Send comments, improvements, bugs to ramiro@netscape.com
|
||||
#
|
||||
|
||||
# Make sure a Makefile.in exists
|
||||
if [ ! -f Makefile.in ]
|
||||
then
|
||||
echo
|
||||
echo "There ain't no 'Makefile.in' over here: $pwd"
|
||||
echo
|
||||
|
||||
exit
|
||||
fi
|
||||
|
||||
# Use DEPTH in the Makefile.in to determine the depth
|
||||
depth=`grep -w DEPTH Makefile.in | grep -e "\.\." | awk -F"=" '{ print $2; }'`
|
||||
|
||||
# Determine the depth count
|
||||
n=`echo $depth | tr '/' ' ' | wc -w`
|
||||
|
||||
# Determine the path (strip anything before the mozilla/ root)
|
||||
path=`pwd | awk -v count=$n -F"/" '\
|
||||
{ for(i=NF-count+1; i <= NF ; i++) \
|
||||
{ \
|
||||
if (i!=NF) \
|
||||
{ printf "%s/", $i } \
|
||||
else \
|
||||
{ printf "%s", $i } \
|
||||
} \
|
||||
}'`
|
||||
|
||||
dir=$path
|
||||
|
||||
# Add a slash only to dirs where depth >= mozilla_root
|
||||
if [ $n -gt 0 ]
|
||||
then
|
||||
dir=${dir}"/"
|
||||
fi
|
||||
|
||||
back=`pwd`
|
||||
|
||||
makefile=${dir}"Makefile"
|
||||
|
||||
cd $depth
|
||||
|
||||
# Make sure config.status exists
|
||||
if [ -f config.status ]
|
||||
then
|
||||
CONFIG_FILES=$makefile ./config.status
|
||||
else
|
||||
echo
|
||||
echo "There ain't no 'config.status' over here: $pwd"
|
||||
echo
|
||||
fi
|
||||
|
||||
cd $back
|
||||
@@ -19,73 +19,27 @@
|
||||
#
|
||||
# Fix brain-damaged compilers that don't understand -o and -c together
|
||||
#
|
||||
CC=`echo $1 | sed -e "s|'||g" -e 's|"||g'`
|
||||
shift
|
||||
DASH_C=0
|
||||
DASH_O=0
|
||||
DUMMY="XxxXxxX"
|
||||
GET_OBJECT=0
|
||||
OBJ="${DUMMY}"
|
||||
OBJECT="${DUMMY}"
|
||||
|
||||
for i in $*
|
||||
do
|
||||
[ "${CHECK_O}" = yes ] && {
|
||||
case $i in
|
||||
./*/*.o) OBJECT="$i"
|
||||
OPTS="${OPTS} -o"
|
||||
DASH_O=1
|
||||
;;
|
||||
./*.o) OBJECT="`basename $i`"
|
||||
i=""
|
||||
DASH_O=1
|
||||
;;
|
||||
*.o) if [ $i = `basename $i` ]
|
||||
then
|
||||
OBJECT="$i"
|
||||
i=""
|
||||
else
|
||||
OPTS="${OPTS} -o"
|
||||
fi
|
||||
DASH_O=1
|
||||
;;
|
||||
*) OPTS="${OPTS} -o $i"
|
||||
DASH_O=1
|
||||
i=""
|
||||
;;
|
||||
esac
|
||||
CHECK_O=no
|
||||
}
|
||||
case $i in
|
||||
-c) DASH_C=1
|
||||
OPTS="${OPTS} -c"
|
||||
;;
|
||||
-o) CHECK_O=yes
|
||||
;;
|
||||
*.c) C_SRC=$i
|
||||
OPTS="${OPTS} $i"
|
||||
# cc always creates the .o from the .c name
|
||||
OBJ=`basename $C_SRC .c`.o
|
||||
;;
|
||||
*.s) S_SRC=$i
|
||||
OPTS="${OPTS} $i"
|
||||
# or the .o from the .s name
|
||||
OBJ=`basename $S_SRC .s`.o
|
||||
;;
|
||||
*.o) OBJECT=$i
|
||||
OPTS="${OPTS} $i"
|
||||
;;
|
||||
*) OPTS="${OPTS} $i"
|
||||
;;
|
||||
-c) DASH_C=1;;
|
||||
-o) DASH_O=1;;
|
||||
*.c) C_SRC=$i;;
|
||||
*.s) S_SRC=$i;;
|
||||
*.o) OBJECT=$i;;
|
||||
esac
|
||||
done
|
||||
|
||||
${CC} ${OPTS} || exit $?
|
||||
cc $* || exit $?
|
||||
|
||||
# if there was no -c and -o we're done
|
||||
[ $DASH_C = 1 -a $DASH_O = 1 ] || exit 0
|
||||
|
||||
# if $OBJ and $OBJECT are the same we're done
|
||||
[ $OBJ = $OBJECT ] && exit 0
|
||||
# cc always creates the .o from the .c name
|
||||
[ $C_SRC ] && OBJ=`basename $C_SRC .c`.o
|
||||
# or the .o from the .s name
|
||||
[ $S_SRC ] && OBJ=`basename $S_SRC .s`.o
|
||||
|
||||
[ -f $OBJ ] && mv -f $OBJ $OBJECT
|
||||
[ -f $OBJECT ] || [ -f $OBJ ] && mv -f $OBJ $OBJECT
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
#
|
||||
# Wrapper for brain-damaged compilers that don't understand -o and -c together.
|
||||
#
|
||||
CXX=`echo $1 | sed -e "s|'||g" -e 's|"||g'`
|
||||
shift
|
||||
|
||||
DUMMY="XxxXxxX"
|
||||
DASH_C=0
|
||||
DASH_O=0
|
||||
@@ -33,75 +32,36 @@ OBJECT="${DUMMY}"
|
||||
|
||||
for i in $*
|
||||
do
|
||||
[ ${GET_OBJECT} -eq 1 ] && {
|
||||
case $i in
|
||||
./*/*.o) OBJECT="$i"
|
||||
OPTS="${OPTS} -o"
|
||||
DASH_O=1
|
||||
;;
|
||||
./*.o) OBJECT="`basename $i`"
|
||||
i=""
|
||||
DASH_O=1
|
||||
;;
|
||||
*.o) if [ $i = `basename $i` ]
|
||||
then
|
||||
i=""
|
||||
else
|
||||
OPTS="${OPTS} -o"
|
||||
DASH_O=1
|
||||
fi
|
||||
;;
|
||||
*) OPTS="${OPTS} -o $i"
|
||||
DASH_O=1
|
||||
i=""
|
||||
;;
|
||||
esac
|
||||
GET_OBJECT=0
|
||||
}
|
||||
if [ ${GET_OBJECT} -eq 1 ]; then
|
||||
OBJECT="$i"
|
||||
GET_OBJECT=0
|
||||
fi
|
||||
case $i in
|
||||
-c)
|
||||
DASH_C=1
|
||||
OPTS="${OPTS} -c"
|
||||
;;
|
||||
-o)
|
||||
DASH_O=1
|
||||
GET_OBJECT=1
|
||||
;;
|
||||
*.c)
|
||||
C_SRC="$i"
|
||||
OPTS="${OPTS} $i"
|
||||
# cc always creates the .o from the .c name
|
||||
OBJ=`basename ${C_SRC} .c`.o
|
||||
;;
|
||||
+.*)
|
||||
OPTS="${OPTS} $i"
|
||||
;;
|
||||
*.cpp)
|
||||
CPP_SRC="$i"
|
||||
OPTS="${OPTS} $i"
|
||||
# cc always creates the .o from the .cpp name
|
||||
OBJ=`basename ${CPP_SRC} .cpp`.o
|
||||
;;
|
||||
*.cc)
|
||||
CC_SRC="$i"
|
||||
OPTS="${OPTS} $i"
|
||||
# cc always creates the .o from the .cc name
|
||||
OBJ=`basename ${CC_SRC} .cc`.o
|
||||
;;
|
||||
*.s)
|
||||
S_SRC="$i"
|
||||
OPTS="${OPTS} $i"
|
||||
# cc always creates the .o from the .s name
|
||||
OBJ=`basename ${S_SRC} .s`.o
|
||||
;;
|
||||
*.o) OBJECT=$i
|
||||
OPTS="${OPTS} $i"
|
||||
;;
|
||||
*) OPTS="${OPTS} $i"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
${CXX} ${OPTS} || exit $?
|
||||
CC $* || exit $?
|
||||
|
||||
# LAME!!!
|
||||
if [ -f -O ]; then
|
||||
@@ -111,8 +71,16 @@ fi
|
||||
# if there was no -c and -o we're done
|
||||
[ ${DASH_C} -eq 1 -a ${DASH_O} -eq 1 ] || exit 0
|
||||
|
||||
# if $OBJ and $OBJECT are the same we're done
|
||||
[ $OBJ = $OBJECT ] && exit 0
|
||||
|
||||
[ -f $OBJ ] && mv -f $OBJ $OBJECT
|
||||
# cc always creates the .o from the .c name
|
||||
if [ "${C_SRC}" != "${DUMMY}" ]; then
|
||||
OBJ=`basename ${C_SRC} .c`.o
|
||||
elif [ "${CPP_SRC}" != "${DUMMY}" ]; then
|
||||
OBJ=`basename ${CPP_SRC} .cpp`.o
|
||||
elif [ "${CC_SRC}" != "${DUMMY}" ]; then
|
||||
OBJ=`basename ${CC_SRC} .cc`.o
|
||||
# or the .o from the .s name
|
||||
elif [ "${S_SRC}" != "${DUMMY}" ]; then
|
||||
OBJ=`basename ${S_SRC} .s`.o
|
||||
fi
|
||||
|
||||
[ -f ${OBJECT} ] || [ -f ${OBJ} ] && mv -f ${OBJ} ${OBJECT}
|
||||
|
||||
@@ -56,16 +56,7 @@ sub BuildMozilla()
|
||||
BuildProjectClean(":mozilla:lib:mac:NSStdLib:NSStdLib.mcp", "Stubs");
|
||||
BuildProjectClean(":mozilla:lib:mac:NSRuntime:NSRuntime.mcp", "Stubs");
|
||||
BuildProjectClean(":mozilla:lib:mac:MacMemoryAllocator:MemAllocator.mcp", "Stubs");
|
||||
# BuildProjectClean(":mozilla:cmd:macfe:projects:client:Client.mcp", "Stubs");
|
||||
|
||||
if ( $main::CARBON )
|
||||
{
|
||||
BuildProject(":mozilla:cmd:macfe:projects:interfaceLib:Interface.mcp", "Carbon Interfaces");
|
||||
}
|
||||
else
|
||||
{
|
||||
BuildProject(":mozilla:cmd:macfe:projects:interfaceLib:Interface.mcp", "MacOS Interfaces");
|
||||
}
|
||||
BuildProjectClean(":mozilla:cmd:macfe:projects:client:NavigatorStubs.mcp", "Stubs");
|
||||
|
||||
BuildProject(":mozilla:lib:mac:NSRuntime:NSRuntime.mcp", "NSRuntime$D.shlb");
|
||||
MakeAlias(":mozilla:lib:mac:NSRuntime:NSRuntime$D.shlb", "$dist_dir");
|
||||
@@ -179,7 +170,7 @@ sub BuildMozilla()
|
||||
}
|
||||
}
|
||||
|
||||
# BuildProject(":mozilla:cmd:macfe:projects:client:Client.mcp", "Client$D");
|
||||
BuildProject(":mozilla:cmd:macfe:projects:client:Client.mcp", "Client$D");
|
||||
}
|
||||
|
||||
|
||||
@@ -222,7 +213,7 @@ sub DistMozilla()
|
||||
InstallFromManifest(":mozilla:modules:security:freenav:MANIFEST", ":mozilla:dist:security:");
|
||||
|
||||
#XPCOM
|
||||
InstallFromManifest(":mozilla:xpcom:public:MANIFEST", ":mozilla:dist:xpcom:");
|
||||
InstallFromManifest(":mozilla:xpcom:src:MANIFEST", ":mozilla:dist:xpcom:");
|
||||
|
||||
#ZLIB
|
||||
InstallFromManifest(":mozilla:modules:zlib:src:MANIFEST", ":mozilla:dist:zlib:");
|
||||
@@ -290,7 +281,6 @@ sub DistMozilla()
|
||||
InstallFromManifest(":mozilla:network:protocol:pop3:MANIFEST", ":mozilla:dist:network:");
|
||||
InstallFromManifest(":mozilla:network:protocol:remote:MANIFEST", ":mozilla:dist:network:");
|
||||
InstallFromManifest(":mozilla:network:protocol:smtp:MANIFEST", ":mozilla:dist:network:");
|
||||
InstallFromManifest(":mozilla:network:protocol:sockstub:MANIFEST", ":mozilla:dist:network:");
|
||||
|
||||
#HTML_DIALOGS
|
||||
InstallFromManifest(":mozilla:lib:htmldlgs:MANIFEST", ":mozilla:dist:htmldlgs:");
|
||||
@@ -343,7 +333,6 @@ sub DistMozilla()
|
||||
|
||||
#CAPS
|
||||
InstallFromManifest(":mozilla:caps:include:MANIFEST", ":mozilla:dist:caps:");
|
||||
InstallFromManifest(":mozilla:caps:public:MANIFEST", ":mozilla:dist:caps:");
|
||||
|
||||
#BASE
|
||||
InstallFromManifest(":mozilla:base:public:MANIFEST", ":mozilla:dist:base:");
|
||||
|
||||
143
mozilla/build/mac/BuildListObsolete.pm
Normal file
143
mozilla/build/mac/BuildListObsolete.pm
Normal file
@@ -0,0 +1,143 @@
|
||||
#!perl
|
||||
|
||||
package BuildListObsolete;
|
||||
require Exporter;
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(BuildMozilla);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
BuildList - build the [ordered] set of projects needed to construct Mozilla
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
...
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
The contents of this file are subject to the Netscape Public License
|
||||
Version 1.0 (the "NPL"); you may not use this file except in
|
||||
compliance with the NPL. You may obtain a copy of the NPL at
|
||||
http://www.mozilla.org/NPL/
|
||||
|
||||
Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
for the specific language governing rights and limitations under the
|
||||
NPL.
|
||||
|
||||
The Initial Developer of this code under the NPL is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
Reserved.
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
sub BuildMozilla()
|
||||
{
|
||||
use Moz;
|
||||
|
||||
chdir(":::"); # assuming this script is in "...:mozilla:build:mac:", change dir to just inside "mozilla"
|
||||
|
||||
|
||||
if ( $main::DEBUG )
|
||||
{
|
||||
$D = " (Debug)";
|
||||
$LibD = "Debug";
|
||||
$dist_dir = ":dist:client_debug:";
|
||||
}
|
||||
else
|
||||
{
|
||||
$D = "";
|
||||
$LibD = "";
|
||||
$dist_dir = ":dist:client:";
|
||||
}
|
||||
|
||||
#
|
||||
# Build the appropriate target of each project
|
||||
#
|
||||
|
||||
BuildProjectClean(":lib:mac:NSStdLib:NSStdLib.mcp", "Stub Library");
|
||||
BuildProjectClean(":lib:mac:MacMemoryAllocator:MemAllocator.mcp", "Stub Library");
|
||||
BuildProjectClean(":cmd:macfe:projects:client:Navigator.mcp", "Stub Library");
|
||||
|
||||
BuildProject(":lib:mac:NSRuntime:NSRuntime.mcp");
|
||||
MakeAlias(":lib:mac:NSRuntime:NSRuntimePPCLib", "$dist_dir");
|
||||
|
||||
BuildProject(":cmd:macfe:restext:NavStringLibPPC.mcp");
|
||||
MakeAlias(":cmd:macfe:restext:StringsPPCLib", "$dist_dir");
|
||||
|
||||
BuildProject(":lib:mac:MoreFiles:build:MoreFilesPPC.prj");
|
||||
MakeAlias(":lib:mac:MoreFiles:build:MoreFilesPPC.lib", "$dist_dir");
|
||||
|
||||
BuildProject(":nsprpub:macbuild:NSPR20PPC".$LibD.".mcp");
|
||||
MakeAlias(":nsprpub:macbuild:NSPR20PPC".$LibD."Lib", "$dist_dir");
|
||||
|
||||
BuildProject(":dbm:macbuild:DBMPPC".$LibD.".mcp");
|
||||
MakeAlias(":dbm:macbuild:DBMPPC".$LibD."Lib", "${dist_dir}");
|
||||
|
||||
BuildProject(":lib:mac:MacMemoryAllocator:MemAllocator.mcp", "PPC Shared Library$D");
|
||||
MakeAlias(":lib:mac:MacMemoryAllocator:MemAllocatorPPC".$LibD."Lib", "$dist_dir");
|
||||
|
||||
BuildProject(":lib:mac:NSStdLib:NSStdLib.mcp", "PPC Shared Library");
|
||||
MakeAlias(":lib:mac:NSStdLib:NSStdLibPPCLib", "$dist_dir");
|
||||
|
||||
BuildProject(":modules:security:freenav:macbuild:NoSecurity.mcp", "PPC Shared Library$D");
|
||||
MakeAlias(":modules:security:freenav:macbuild:NoSecurity".$LibD."Lib", "$dist_dir");
|
||||
|
||||
BuildProject(":xpcom:macbuild:xpcomPPC".$LibD.".mcp");
|
||||
MakeAlias(":xpcom:macbuild:xpcomPPC".$LibD."Lib", "$dist_dir");
|
||||
|
||||
BuildProject(":lib:mac:PowerPlant:PowerPlant.mcp");
|
||||
MakeAlias(":lib:mac:PowerPlant:PowerPlantPPC".$LibD."Lib", "$dist_dir");
|
||||
|
||||
BuildProject(":modules:zlib:macbuild:zlib.mcp", "PPC Shared Library$D");
|
||||
MakeAlias(":modules:zlib:macbuild:zlibPPC".$LibD."Lib", "$dist_dir");
|
||||
|
||||
BuildProject(":jpeg:macbuild:JPEG.mcp", "PPC Shared Library$D");
|
||||
MakeAlias(":jpeg:macbuild:JPEGPPC".$LibD."Lib", "$dist_dir");
|
||||
|
||||
BuildProject(":sun-java:stubs:macbuild:JavaStubs.mcp", "PPC Shared Library$D");
|
||||
MakeAlias(":sun-java:stubs:macbuild:JavaRuntimePPC".$LibD."Lib", "$dist_dir");
|
||||
|
||||
BuildProject(":js:jsj:macbuild:JSJ_PPC".$LibD.".mcp");
|
||||
|
||||
BuildProject(":js:macbuild:JavaScriptPPC".$LibD.".mcp");
|
||||
MakeAlias(":js:macbuild:JavaScriptPPC".$LibD."Lib", "$dist_dir");
|
||||
|
||||
BuildProject(":nav-java:stubs:macbuild:NavJavaStubs.mcp", "PPC Shared Library$D");
|
||||
MakeAlias(":nav-java:stubs:macbuild:NavJavaPPC".$LibD."Lib", "$dist_dir");
|
||||
|
||||
if ( $main::DEBUG )
|
||||
{
|
||||
BuildProject(":modules:rdf:macbuild:RDF.mcp", "PPC Shared Library +D -LDAP");
|
||||
MakeAlias(":modules:rdf:macbuild:RDFPPCDebugLib", "${dist_dir}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Moz::BuildProject(":modules:rdf:macbuild:RDF.mcp", "PPC Shared Library -LDAP");
|
||||
MakeAlias(":modules:rdf:macbuild:RDFPPCLib", "${dist_dir}");
|
||||
}
|
||||
|
||||
BuildProject(":modules:xml:macbuild:XML.mcp", "PPC Shared Library$D");
|
||||
MakeAlias(":modules:xml:macbuild:XMLPPC".$LibD."Lib", "$dist_dir");
|
||||
|
||||
BuildProject(":modules:libfont:macbuild:FontBroker.mcp", "PPC Library$D");
|
||||
|
||||
BuildProject(":modules:schedulr:macbuild:Schedulr.mcp", "PPC Shared Library$D");
|
||||
MakeAlias(":modules:schedulr:macbuild:Schedulr".$LibD."PPCLib", "$dist_dir");
|
||||
|
||||
BuildProject(":network:macbuild:network.mcp", "PPC Library (Debug Moz)");
|
||||
|
||||
if ( $main::MOZ_LITE == 0 )
|
||||
{
|
||||
BuildProject(":cmd:macfe:Composer:build:Composer.mcp", "PPC Library$D");
|
||||
}
|
||||
|
||||
BuildProject(":cmd:macfe:projects:client:Navigator.mcp", "Moz PPC App$D");
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
124
mozilla/build/mac/BuildMozilla.pm
Normal file
124
mozilla/build/mac/BuildMozilla.pm
Normal file
@@ -0,0 +1,124 @@
|
||||
#!perl
|
||||
|
||||
package BuildMozilla;
|
||||
require Exporter;
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(BuildMozilla);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
BuildMozilla - build the [ordered] set of projects needed to construct Mozilla
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
The contents of this file are subject to the Netscape Public License
|
||||
Version 1.0 (the "NPL"); you may not use this file except in
|
||||
compliance with the NPL. You may obtain a copy of the NPL at
|
||||
http://www.mozilla.org/NPL/
|
||||
|
||||
Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
for the specific language governing rights and limitations under the
|
||||
NPL.
|
||||
|
||||
The Initial Developer of this code under the NPL is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
Reserved.
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
sub BuildMozilla()
|
||||
{
|
||||
use Moz;
|
||||
|
||||
chdir("::::"); # assuming this script is in "...:mozilla:build:mac:", change dir to just above "mozilla"
|
||||
|
||||
|
||||
# Ideally, we would set the target name like so:
|
||||
# $target = $main::DEBUG ? "debug" : "optimized";
|
||||
# ...and all projects would have corresponding targets
|
||||
|
||||
|
||||
$D = $main::DEBUG ? " (Debug)" : ""; # $D becomes a suffix to target names for selecting either the debug or non-debug target of a project
|
||||
|
||||
|
||||
#
|
||||
# Build the appropriate target of each project
|
||||
#
|
||||
|
||||
Moz::BuildProject(":mozilla:lib:mac:NSStdLib:NSStdLib.mcp", "Stub Library");
|
||||
Moz::BuildProject(":mozilla:lib:mac:MacMemoryAllocator:MemAllocator.mcp", "Stub Library");
|
||||
Moz::BuildProject(":mozilla:cmd:macfe:projects:client:Navigator.mcp", "Stub Library");
|
||||
|
||||
Moz::BuildProject(":mozilla:lib:mac:NSRuntime:NSRuntime.mcp");
|
||||
Moz::BuildProject(":mozilla:cmd:macfe:restext:NavStringLibPPC.mcp");
|
||||
Moz::BuildProject(":mozilla:lib:mac:MoreFiles:build:MoreFilesPPC.prj");
|
||||
|
||||
if ( $main::DEBUG )
|
||||
{
|
||||
Moz::BuildProject(":mozilla:nsprpub:macbuild:NSPR20PPCDebug.mcp");
|
||||
Moz::BuildProject(":mozilla:dbm:macbuild:DBMPPCDebug.mcp");
|
||||
}
|
||||
else
|
||||
{
|
||||
Moz::BuildProject(":mozilla:nsprpub:macbuild:NSPR20PPC.mcp");
|
||||
Moz::BuildProject(":mozilla:dbm:macbuild:DBMPPC.mcp");
|
||||
}
|
||||
|
||||
Moz::BuildProject(":mozilla:lib:mac:MacMemoryAllocator:MemAllocator.mcp", "PPC Shared Library$D");
|
||||
Moz::BuildProject(":mozilla:lib:mac:NSStdLib:NSStdLib.mcp", "PPC Shared Library");
|
||||
Moz::BuildProject(":mozilla:modules:security:freenav:macbuild:NoSecurity.mcp", "PPC Shared Library$D");
|
||||
|
||||
if ( $main::DEBUG )
|
||||
{
|
||||
Moz::BuildProject(":mozilla:xpcom:macbuild:xpcomPPCDebug.mcp");
|
||||
}
|
||||
else
|
||||
{
|
||||
Moz::BuildProject(":mozilla:xpcom:macbuild:xpcomPPC.mcp");
|
||||
}
|
||||
|
||||
Moz::BuildProject(":mozilla:lib:mac:PowerPlant:PowerPlant.mcp");
|
||||
Moz::BuildProject(":mozilla:modules:zlib:macbuild:zlib.mcp", "PPC Shared Library$D");
|
||||
Moz::BuildProject(":mozilla:jpeg:macbuild:JPEG.mcp", "PPC Shared Library$D");
|
||||
Moz::BuildProject(":mozilla:sun-java:stubs:macbuild:JavaStubs.mcp", "PPC Shared Library$D");
|
||||
|
||||
if ( $main::DEBUG )
|
||||
{
|
||||
Moz::BuildProject(":mozilla:js:jsj:macbuild:JSJ_PPCDebug.mcp");
|
||||
Moz::BuildProject(":mozilla:js:macbuild:JavaScriptPPCDebug.mcp");
|
||||
}
|
||||
else
|
||||
{
|
||||
Moz::BuildProject(":mozilla:js:jsj:macbuild:JSJ_PPC.mcp");
|
||||
Moz::BuildProject(":mozilla:js:macbuild:JavaScriptPPC.mcp");
|
||||
}
|
||||
|
||||
Moz::BuildProject(":mozilla:nav-java:stubs:macbuild:NavJavaStubs.mcp", "PPC Shared Library$D");
|
||||
|
||||
|
||||
# the following `if' can be fixed when we either rename the debug target of the RDF project, or of all the other projects
|
||||
|
||||
if ( $main::DEBUG )
|
||||
{
|
||||
Moz::BuildProject(":mozilla:modules:rdf:macbuild:RDF.mcp", "PPC Shared Library +D -LDAP");
|
||||
}
|
||||
else
|
||||
{
|
||||
Moz::BuildProject(":mozilla:modules:rdf:macbuild:RDF.mcp", "PPC Shared Library -LDAP");
|
||||
}
|
||||
|
||||
Moz::BuildProject(":mozilla:modules:xml:macbuild:XML.mcp", "PPC Shared Library$D");
|
||||
Moz::BuildProject(":mozilla:modules:libfont:macbuild:FontBroker.mcp", "PPC Library$D");
|
||||
Moz::BuildProject(":mozilla:modules:schedulr:macbuild:Schedulr.mcp", "PPC Shared Library$D");
|
||||
Moz::BuildProject(":mozilla:network:macbuild:network.mcp", "PPC Library (Debug Moz)");
|
||||
Moz::BuildProject(":mozilla:cmd:macfe:Composer:build:Composer.mcp", "PPC Library$D");
|
||||
Moz::BuildProject(":mozilla:cmd:macfe:projects:client:Navigator.mcp", "Moz PPC App$D");
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
@@ -33,19 +33,16 @@ Moz::StopForErrors();
|
||||
|
||||
chdir("::::");
|
||||
|
||||
SetBuildNumber();
|
||||
|
||||
SetTimeBomb(0, 30);
|
||||
|
||||
# Make and popuplate the dist directory
|
||||
DistMozilla();
|
||||
|
||||
Delay(10);
|
||||
|
||||
# Set the build number in about-all.html. Commented out for now
|
||||
# until ckid/mcvs resource problem is resolved.
|
||||
SetBuildNumber();
|
||||
|
||||
# SetAgentString();
|
||||
|
||||
SetTimeBomb(0, 30);
|
||||
|
||||
# Now build the projects
|
||||
BuildMozilla();
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
#!perl
|
||||
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
#
|
||||
# nglayout build script (debug)
|
||||
#
|
||||
use Mac::Processes;
|
||||
use NGLayoutBuildList;
|
||||
use Cwd;
|
||||
use Moz;
|
||||
|
||||
# configuration variables
|
||||
$DEBUG = 0;
|
||||
$ALIAS_SYM_FILES = $DEBUG;
|
||||
$CLOBBER_LIBS = 0;
|
||||
$MOZ_FULLCIRCLE = 0;
|
||||
|
||||
$pull{all} = 0;
|
||||
$pull{lizard} = 0;
|
||||
$pull{xpcom} = 0;
|
||||
$pull{imglib} = 0;
|
||||
$pull{netlib} = 0;
|
||||
$pull{nglayout} = 0;
|
||||
$pull{mac} = 0;
|
||||
|
||||
$build{all} = 1; # turn off to do individual builds
|
||||
$build{dist} = 0;
|
||||
$build{stubs} = 0;
|
||||
$build{common} = 0;
|
||||
$build{nglayout} = 0;
|
||||
$build{resources} = 0;
|
||||
$build{editor} = 0;
|
||||
$build{viewer} = 0;
|
||||
$build{xpapp} = 0;
|
||||
|
||||
if ($pull{all})
|
||||
{
|
||||
foreach $k (keys(%pull))
|
||||
{
|
||||
$pull{$k} = 1;
|
||||
}
|
||||
}
|
||||
if ($build{all})
|
||||
{
|
||||
foreach $k (keys(%build))
|
||||
{
|
||||
$build{$k} = 1;
|
||||
}
|
||||
}
|
||||
|
||||
# do the work
|
||||
# you should not have to edit anything bellow
|
||||
|
||||
chdir("::::");
|
||||
$MOZ_SRC = cwd();
|
||||
|
||||
if ($MOZ_FULLCIRCLE)
|
||||
{
|
||||
#// Get the Build Number for the Master.ini(Full Circle) n'stuff
|
||||
$buildnum = Moz::SetBuildNumber();
|
||||
}
|
||||
|
||||
OpenErrorLog("NGLayoutBuildLog");
|
||||
#OpenErrorLog("Mozilla.BuildLog"); # Tinderbox requires that name
|
||||
|
||||
Moz::StopForErrors();
|
||||
#Moz::DontStopForErrors();
|
||||
|
||||
if ($pull{all}) {
|
||||
Checkout();
|
||||
}
|
||||
|
||||
chdir($MOZ_SRC);
|
||||
BuildDist();
|
||||
|
||||
chdir($MOZ_SRC);
|
||||
BuildProjects();
|
||||
|
||||
print "Build layout complete\n";
|
||||
@@ -20,18 +20,12 @@
|
||||
#
|
||||
# nglayout build script (debug)
|
||||
#
|
||||
use Mac::Processes;
|
||||
use NGLayoutBuildList;
|
||||
use Cwd;
|
||||
use Moz;
|
||||
|
||||
# configuration variables
|
||||
$DEBUG = 1;
|
||||
$ALIAS_SYM_FILES = $DEBUG;
|
||||
$CLOBBER_LIBS = 1; # turn on to clobber existing libs and .xSYM files before
|
||||
# building each project
|
||||
$MOZ_FULLCIRCLE = 0;
|
||||
|
||||
$pull{all} = 0;
|
||||
$pull{lizard} = 0;
|
||||
$pull{xpcom} = 0;
|
||||
@@ -40,15 +34,68 @@ $pull{netlib} = 0;
|
||||
$pull{nglayout} = 0;
|
||||
$pull{mac} = 0;
|
||||
|
||||
$build{all} = 1; # turn off to do individual builds
|
||||
$build{all} = 0;
|
||||
$build{dist} = 0;
|
||||
$build{stubs} = 0;
|
||||
$build{common} = 0;
|
||||
$build{nglayout} = 0;
|
||||
$build{resources} = 0;
|
||||
$build{editor} = 0;
|
||||
$build{viewer} = 0;
|
||||
$build{xpapp} = 0;
|
||||
$build{common}= 0;
|
||||
$build{nglayout}= 0;
|
||||
|
||||
|
||||
#
|
||||
# UI
|
||||
#
|
||||
|
||||
@choices = ("pull_and_build_all",
|
||||
"pull_all",
|
||||
"build_all",
|
||||
"pull_nglayout",
|
||||
"build_dist",
|
||||
"build_projects");
|
||||
#damn, this does not work on
|
||||
if (0)
|
||||
{
|
||||
while (GetFrontProcess () != GetCurrentProcess())
|
||||
{
|
||||
SetFrontProcess( GetCurrentProcess() );
|
||||
}
|
||||
@pick = MacPerl::Pick("What would you like to do?", @choices);
|
||||
$pull{all} = 0;
|
||||
$build{all} = 1;
|
||||
foreach $i (@pick)
|
||||
{
|
||||
if ($i eq "pull_and_build_all")
|
||||
{
|
||||
$pull{all} = 1;
|
||||
$build{all} = 1;
|
||||
}
|
||||
elsif ($i eq "pull_all")
|
||||
{
|
||||
$pull{all} = 1;
|
||||
}
|
||||
elsif ($i eq "build_all")
|
||||
{
|
||||
$build{all} = 1;
|
||||
}
|
||||
elsif ($i eq "build_dist")
|
||||
{
|
||||
$build{dist} = 1;
|
||||
}
|
||||
elsif ($i eq "build_projects")
|
||||
{
|
||||
$build{projects} = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$pull{all} = 1;
|
||||
$build{all} = 1;
|
||||
# $pull{netlib} = 1;
|
||||
# $pull{nglayout} = 1;
|
||||
# $build{common} = 1;
|
||||
# $build{nglayout} = 1;
|
||||
# $build{dist} = 1;
|
||||
# $pull{nglayout} = 1;
|
||||
}
|
||||
|
||||
if ($pull{all})
|
||||
{
|
||||
@@ -71,21 +118,12 @@ if ($build{all})
|
||||
chdir("::::");
|
||||
$MOZ_SRC = cwd();
|
||||
|
||||
if ($MOZ_FULLCIRCLE)
|
||||
{
|
||||
#// Get the Build Number for the Master.ini(Full Circle) n'stuff
|
||||
$buildnum = Moz::SetBuildNumber();
|
||||
}
|
||||
|
||||
OpenErrorLog("NGLayoutDebugBuildLog");
|
||||
#OpenErrorLog("Mozilla.BuildLog"); # Tinderbox requires that name
|
||||
|
||||
Moz::StopForErrors();
|
||||
#Moz::DontStopForErrors();
|
||||
|
||||
if ($pull{all}) {
|
||||
Checkout();
|
||||
}
|
||||
#OpenErrorLog("::NGLayoutBuildLog");
|
||||
OpenErrorLog(":::Mozilla.BuildLog"); # Tinderbox requires that name
|
||||
Checkout();
|
||||
|
||||
chdir($MOZ_SRC);
|
||||
BuildDist();
|
||||
|
||||
BIN
mozilla/build/mac/CodeWarriorLib
Normal file
BIN
mozilla/build/mac/CodeWarriorLib
Normal file
Binary file not shown.
@@ -33,7 +33,7 @@ use Mac::Types;
|
||||
use File::Basename;
|
||||
|
||||
use vars qw($VERSION);
|
||||
$VERSION = '1.02';
|
||||
$VERSION = '1.01';
|
||||
|
||||
my($app) = 'CWIE';
|
||||
|
||||
@@ -109,10 +109,7 @@ sub build_project ($;$$$) {
|
||||
while (1) {
|
||||
$p = _get_project($full_path);
|
||||
if (!$p) {
|
||||
if ($project_was_closed) {
|
||||
print "### Error - request for project document failed after opening\n";
|
||||
die "### possibly CW Pro 4 bug: be sure to close your Find window\n";
|
||||
}
|
||||
return if ($project_was_closed);
|
||||
$project_was_closed = 1;
|
||||
_open_file($full_path);
|
||||
} else {
|
||||
@@ -166,9 +163,8 @@ sub activate () {
|
||||
foreach $psi (values(%Process)) {
|
||||
if ($psi->processSignature() eq $app) {
|
||||
$appath = $psi->processAppSpec(), "\n";
|
||||
_save_appath($filepath, $appath);
|
||||
last;
|
||||
}
|
||||
_save_appath($filepath, $appath);
|
||||
}
|
||||
|
||||
if ((!$appath || ! -x $appath) && open(F, $filepath)) {
|
||||
@@ -190,9 +186,9 @@ sub activate () {
|
||||
local(*D);
|
||||
my $cwd = `pwd`;
|
||||
$appath = _get_folder(
|
||||
'Where is the CW IDE folder?',
|
||||
'Where is the folder containing CodeWarrior IDE?',
|
||||
dirname($Application{$app})
|
||||
);
|
||||
) . ':';
|
||||
die "CodeWarrior IDE not found.\n" if !$appath;
|
||||
opendir(D, $appath) or die $!;
|
||||
chdir($appath);
|
||||
@@ -215,10 +211,7 @@ sub activate () {
|
||||
launchAppSpec => $appath,
|
||||
launchControlFlags => launchContinue() + launchNoFileFlags()
|
||||
);
|
||||
unless (LaunchApplication($lp)) {
|
||||
unlink($filepath);
|
||||
die $^E;
|
||||
}
|
||||
LaunchApplication($lp) or die $^E;
|
||||
}
|
||||
|
||||
sub _build ($;$) {
|
||||
@@ -339,10 +332,6 @@ sub _test ($) {
|
||||
|
||||
=over 4
|
||||
|
||||
=item v1.02, September 23, 1998
|
||||
|
||||
Made fixes in finding and saving location of CodeWarrior IDE.
|
||||
|
||||
=item v1.01, June 1, 1998
|
||||
|
||||
Made fixes to C<chdir()> in C<activate()>, made C<activate()> more robust
|
||||
|
||||
78
mozilla/build/mac/CopyExports.script
Normal file
78
mozilla/build/mac/CopyExports.script
Normal file
@@ -0,0 +1,78 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
if {#} != 1
|
||||
echo "CopyExports requires 1 parameters:"
|
||||
echo "Parameter 1: path relative to {SourceRootDir} of the file which contains"
|
||||
echo " the list of files to be copied, one per line. This path"
|
||||
echo " may not begin with a colon"
|
||||
echo
|
||||
Exit 1
|
||||
end if
|
||||
|
||||
|
||||
Set SourceList "{SourceRootDir}{1}"
|
||||
|
||||
Set ScriptsDir "{SourceRootDir}mozilla:build:mac:"
|
||||
|
||||
#set sourceList "{SourceRootDir}mozilla:{1}"
|
||||
|
||||
if {verbose}
|
||||
echo "Source list is in file ¶"{SourceList}¶""
|
||||
echo "Scripts directory is ¶"{ScriptsDir}¶""
|
||||
end if
|
||||
|
||||
# for each line in the source file, remove it if it starts with #, otherwise quote it
|
||||
|
||||
for curLine in `streamedit "{sourceList}" -e '/¥#Å/ Delete; /¥/ Replace /(Å)¨1/ "¶""¨1"¶""'`
|
||||
|
||||
echo "{curLine}"
|
||||
|
||||
# ignore empty lines
|
||||
if `evaluate "{{curLine}}" != ""`
|
||||
|
||||
echo "{curLine}"
|
||||
|
||||
# strip out trailing comments
|
||||
if `evaluate "{curLine}" =~ /(Å)¨1[ ¶t]+(#Å)¨2/`
|
||||
set sourceLine "{¨1}"
|
||||
# echo "Discarding comment {¨2}"
|
||||
else
|
||||
set sourceLine "{curLine}"
|
||||
end if
|
||||
|
||||
if `evaluate "{sourceLine}" =~ /([Â ¶t]+)¨1[ ¶t]+[:]*(Å)¨2/`
|
||||
|
||||
if {verbose}
|
||||
echo "Cur line is {sourceLine}"
|
||||
end if
|
||||
|
||||
set exportFile "{¨1}"
|
||||
set theTarget "{¨2}"
|
||||
|
||||
if {verbose}
|
||||
echo "Export file name is {exportFile}"
|
||||
echo "Target directory is {theTarget}"
|
||||
end if
|
||||
|
||||
"{ScriptsDir}CopyList.script" "{exportFile}" "{theTarget}"
|
||||
|
||||
end if
|
||||
|
||||
end if
|
||||
|
||||
end for
|
||||
81
mozilla/build/mac/CopyHeaders.script
Normal file
81
mozilla/build/mac/CopyHeaders.script
Normal file
@@ -0,0 +1,81 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
|
||||
# This is the controlling script for a set of scripts that copy public
|
||||
# header files in one or more source trees into a single, "dist" directory.
|
||||
#
|
||||
# It relies on the two accompanying scripts, ÒCopyList.scriptÓ and
|
||||
# ÒCopyExports.scriptÓ, which must be in the same directory.
|
||||
#
|
||||
# To execute this script, select everything from "# Get the..." to
|
||||
# " the end" and hit the Enter key.
|
||||
#
|
||||
# Known bugs:
|
||||
# Header files are always copied if the export.mac file contains
|
||||
# non-local paths.
|
||||
# Spurious output is produced even when verbose is off.
|
||||
#
|
||||
|
||||
# Uncomment this to get some progress information
|
||||
# set -e verbose 1
|
||||
|
||||
# Get the root of everything
|
||||
|
||||
set magicfilepath "{systempfolder}filepath" # Temporary items folder, "filepath"
|
||||
if !`Exists "{{magicFilePath}}"`
|
||||
Echo "No file path file seems to have been created in the temporary items folder."
|
||||
Echo "Was this script executed from the perl script? That's the way it was designed."
|
||||
Exit 1
|
||||
end if
|
||||
|
||||
set myDirectory "`catenate "{{magicFilePath}}"`"
|
||||
delete -i "{{magicFilePath}}"
|
||||
|
||||
Set SourceList "{myDirectory}{1}"
|
||||
(Evaluate "{myDirectory}" =~ /(Å:)¨1[Â:]+:[Â:]+:[Â:]+/) #·· dev:null
|
||||
Set -e mozillaDir "{¨1}"
|
||||
|
||||
if !`Exists "{{mozillaDir}}"`
|
||||
Echo "A file path was passed, but it doesn't seem to be the mozilla directory."
|
||||
Exit 1
|
||||
end if
|
||||
echo "Mozilla directory found at {mozillaDir}"
|
||||
|
||||
#Calculate the root directory by stripping off the leaf name.
|
||||
(Evaluate "{mozillaDir}" =~ /(Å:)¨1([Â:]+)¨2/) #·· dev:null
|
||||
Set -e SourceRootDir "{¨1}"
|
||||
Set -e DestRootDir "{mozillaDir}dist:"
|
||||
|
||||
# Ensure the build and stubs folders exist
|
||||
|
||||
if !`exists -d "{mozillaDir}dist"`
|
||||
newfolder "{mozillaDir}dist"
|
||||
end if
|
||||
if !`exists -d "{mozillaDir}dist:client"`
|
||||
newfolder "{mozillaDir}dist:client"
|
||||
end if
|
||||
if !`exists -d "{mozillaDir}dist:client_debug"`
|
||||
newfolder "{mozillaDir}dist:client_debug"
|
||||
end if
|
||||
if !`exists -d "{mozillaDir}dist:client_stubs"`
|
||||
newfolder "{mozillaDir}dist:client_stubs"
|
||||
end if
|
||||
|
||||
"{SourceRootDir}mozilla:build:mac:CopyExports.script" "mozilla:build:mac:MacExportListPublic"
|
||||
|
||||
# the end
|
||||
97
mozilla/build/mac/CopyList.script
Normal file
97
mozilla/build/mac/CopyList.script
Normal file
@@ -0,0 +1,97 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
if {#} != 2
|
||||
echo "CopyList requires 2 parameters:"
|
||||
echo "Parameter 1: path relative to {SourceRootDir} of the file which contains"
|
||||
echo " the list of files to be copied, one per line. This path"
|
||||
echo " may not begin with a colon"
|
||||
echo
|
||||
echo "Parameter 2: path relative to {DestRootDir} of the directory where all the"
|
||||
echo " files are to be copied. No initial colons!"
|
||||
echo
|
||||
Exit 1
|
||||
end if
|
||||
|
||||
set debugEcho "" # This setting will actually duplicate the files
|
||||
#set debugEcho "echo" # This setting will merely print the "duplicate" commands.
|
||||
|
||||
set sourceList "{SourceRootDir}{1}"
|
||||
set targetDir "{DestRootDir}{2}"
|
||||
|
||||
# targetDir may not end in a colon for this script to work.
|
||||
if `Evaluate "{targetDir}" =~ /(Å)¨1:/`
|
||||
#echo "Removed a colon"
|
||||
set targetDir "{¨1}"
|
||||
end if
|
||||
|
||||
#Ensure the target hierarchy exists
|
||||
# Volume name
|
||||
(Evaluate "{TargetDir}" =~ /([Â:]+)¨1:Å/) ·· dev:null
|
||||
Set PartialPath "{¨1}"
|
||||
Loop
|
||||
(Evaluate "{TargetDir}" =~ /("{PartialPath}":[Â:]+)¨1([:]*)¨2Å/) ·· dev:null
|
||||
Set PartialPath "{¨1}"
|
||||
Set Exit 0
|
||||
(NewFolder "{PartialPath}") ·· dev:null
|
||||
Set Exit 1
|
||||
break if "{¨2}" == ""
|
||||
End Loop
|
||||
|
||||
#Calculate the source directory by stripping off the leaf name.
|
||||
(Evaluate "{SourceList}" =~ /(Å:)¨1([Â:]+)¨2/) #·· dev:null
|
||||
Set SourceDir "{¨1}"
|
||||
|
||||
if {verbose}
|
||||
echo "Source list is in file ¶"{sourceList}¶""
|
||||
echo "Source directory is ¶"{SourceDir}¶""
|
||||
echo "Target directory is ¶"{targetDir}¶""
|
||||
end if
|
||||
|
||||
# Strip all comment lines, pipe the stripped lines into the "for" loop.
|
||||
# We quote each whole line here so that we deal with a line at a time in the
|
||||
# for loop. Don't ya just love MPW quoting rulesÉ
|
||||
|
||||
for f in `streamedit "{sourceList}" -e '/¥#Å/ Delete; /¥/ Replace /(Å)¨1/ "¶""¨1"¶""'`
|
||||
|
||||
if `evaluate "{{f}}" != ""`
|
||||
|
||||
# strip out trailing comments (in fact, anything following whitespace)
|
||||
if `evaluate "{f}" =~ /([Â ¶t]+)¨1[ ¶t]+([#]*Å)¨2/`
|
||||
set sourceFile "{¨1}"
|
||||
# echo "Discarding comment {¨2}"
|
||||
else
|
||||
set sourceFile "{f}"
|
||||
end if
|
||||
|
||||
# sourceFile can be a relative path, so need to get the file name for date comparisons
|
||||
if `evaluate "{sourceFile}" =~ /Å:([Â:]+)¨1/`
|
||||
set filename "{¨1}"
|
||||
else
|
||||
set filename "{sourceFile}"
|
||||
end if
|
||||
|
||||
# now copy the file if newer
|
||||
if "`Newer "{sourceDir}{sourceFile}" "{targetDir}:{filename}"`" #|| !`Exists "{targetDir}:{filename}"`
|
||||
if {verbose} ; echo "{sourceDir}{sourceFile} is newer than {targetDir}:{filename}" ; end if
|
||||
#{debugEcho} duplicate -y "{sourceDir}{sourceFile}" "{targetDir}"
|
||||
{debugEcho} newalias "{sourceDir}{sourceFile}" "{targetDir}:{filename}"
|
||||
end if
|
||||
|
||||
end if
|
||||
|
||||
end for
|
||||
Binary file not shown.
69
mozilla/build/mac/DoCopyHeaders
Normal file
69
mozilla/build/mac/DoCopyHeaders
Normal file
@@ -0,0 +1,69 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
#
|
||||
|
||||
|
||||
# This is the controlling script for a set of scripts that copy public
|
||||
# header files in one or more source trees into a single, "dist" directory.
|
||||
#
|
||||
# It relies on the two accompanying scripts, ÒCopyList.scriptÓ and
|
||||
# ÒCopyExports.scriptÓ, which must be in the same directory.
|
||||
#
|
||||
# To execute this script, select everything from "# Get the..." to
|
||||
# " the end" and hit the Enter key.
|
||||
#
|
||||
# Known bugs:
|
||||
# Spurious output is produced even when verbose is off.
|
||||
#
|
||||
|
||||
# Uncomment this to get some progress information
|
||||
# set -e verbose 1
|
||||
|
||||
# Get the root of everything
|
||||
|
||||
set moz ""
|
||||
loop
|
||||
set mozillaDir `GetFileName -d -m "Please select the ÒmozillaÓ directory"`
|
||||
#set SourceRootDir
|
||||
(Evaluate "{mozillaDir}" =~ /(Å:)¨1([Â:]+)¨2:/) #·· dev:null
|
||||
set moz "{¨2}"
|
||||
break if "{moz}" == "mozilla"
|
||||
Alert "Sorry, this only works if you select the folder called ÒmozillaÓ."
|
||||
end loop
|
||||
|
||||
#Calculate the root directory by stripping off the leaf name.
|
||||
(Evaluate "{mozillaDir}" =~ /(Å:)¨1([Â:]+)¨2/) #·· dev:null
|
||||
Set -e SourceRootDir "{¨1}"
|
||||
Set -e DestRootDir "{mozillaDir}dist:"
|
||||
|
||||
# Ensure the build and stubs folders exist
|
||||
|
||||
if !`exists -d "{mozillaDir}dist"`
|
||||
newfolder "{mozillaDir}dist"
|
||||
end if
|
||||
if !`exists -d "{mozillaDir}dist:client"`
|
||||
newfolder "{mozillaDir}dist:client"
|
||||
end if
|
||||
if !`exists -d "{mozillaDir}dist:client_debug"`
|
||||
newfolder "{mozillaDir}dist:client_debug"
|
||||
end if
|
||||
if !`exists -d "{mozillaDir}dist:client_stubs"`
|
||||
newfolder "{mozillaDir}dist:client_stubs"
|
||||
end if
|
||||
|
||||
"{SourceRootDir}mozilla:build:mac:CopyExports.script" "mozilla:build:mac:MacExportListPublic"
|
||||
|
||||
# the end
|
||||
Binary file not shown.
@@ -1,260 +0,0 @@
|
||||
(*
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*)
|
||||
|
||||
(*
|
||||
GenToc - Generates a .toc file from the current contents of a project.
|
||||
|
||||
by Patrick C. Beard <beard@netscape.com>
|
||||
*)
|
||||
|
||||
on swapDelimiters(newDelimiters)
|
||||
set oldDelimiters to get AppleScript's text item delimiters
|
||||
set AppleScript's text item delimiters to newDelimiters
|
||||
return oldDelimiters
|
||||
end swapDelimiters
|
||||
|
||||
on setDelimiters(newDelimiters)
|
||||
set AppleScript's text item delimiters to newDelimiters
|
||||
end setDelimiters
|
||||
|
||||
on setExtension(fileName, newExtension)
|
||||
set oldDelimiters to swapDelimiters(".")
|
||||
set newFileName to (text item 1 of fileName) & newExtension
|
||||
setDelimiters(oldDelimiters)
|
||||
return newFileName
|
||||
end setExtension
|
||||
|
||||
on folderFromPath(filePath)
|
||||
set folderPath to ((filePath's text items 1 thru ((count of filePath's text items) - 1)) as string) & ":"
|
||||
return folderPath
|
||||
end folderFromPath
|
||||
|
||||
on fileFromPath(filePath)
|
||||
return last text item of filePath
|
||||
end fileFromPath
|
||||
|
||||
on openProject(aProjectFile)
|
||||
tell application "CodeWarrior IDE 3.3"
|
||||
open aProjectFile
|
||||
end tell
|
||||
end openProject
|
||||
|
||||
on selectProject(aProjectFile)
|
||||
set projectName to fileFromPath(aProjectFile as text)
|
||||
tell application "CodeWarrior IDE 3.3"
|
||||
if (name of window 1 is not projectName) then
|
||||
select window projectName
|
||||
end if
|
||||
end tell
|
||||
end selectProject
|
||||
|
||||
on getTargets()
|
||||
set targetList to {}
|
||||
set nameList to {}
|
||||
tell application "CodeWarrior IDE 3.3"
|
||||
set currentProject to project document 1
|
||||
repeat with targetIndex from 1 to (count of targets of currentProject)
|
||||
set currentTarget to (target targetIndex of currentProject)
|
||||
set targetList to targetList & {currentTarget}
|
||||
set nameList to nameList & {name of currentTarget}
|
||||
end repeat
|
||||
return {target:targetList, names:nameList}
|
||||
end tell
|
||||
end getTargets
|
||||
|
||||
(* uses "sort" scripting addition to sort a list of strings. *)
|
||||
on sortList(aList)
|
||||
if (aList {}) then
|
||||
return sort aList
|
||||
else
|
||||
return {}
|
||||
end if
|
||||
end sortList
|
||||
|
||||
(* uses "info for" scripting addition, to return the file type of a path. *)
|
||||
on getFileType(aFilePath)
|
||||
return file type of (info for alias aFilePath)
|
||||
end getFileType
|
||||
|
||||
(* returns all "TEXT" files of the named target. *)
|
||||
on getTargetFiles(targetKey)
|
||||
set targetFiles to {}
|
||||
tell application "CodeWarrior IDE 3.3"
|
||||
set currentProject to project document 1
|
||||
set currentTarget to (target targetKey of currentProject)
|
||||
try
|
||||
-- workaround for CW IDE 3.X bug, loop until error encountered.
|
||||
set fileIndex to 1
|
||||
repeat until false
|
||||
set targetFile to (target file fileIndex of currentTarget)
|
||||
-- only consider text files, since other platforms won't be managing binaries.
|
||||
-- also, only consider if target file is directly linked.
|
||||
if (linked of targetFile) then
|
||||
set targetFilePath to (Access Paths of targetFile)
|
||||
tell me
|
||||
if (getFileType(targetFilePath) = "TEXT") then
|
||||
set targetFiles to targetFiles & {targetFilePath}
|
||||
end if
|
||||
end tell
|
||||
end if
|
||||
set fileIndex to (fileIndex + 1)
|
||||
end repeat
|
||||
on error msg
|
||||
-- display dialog msg & " file count = " & fileIndex
|
||||
end try
|
||||
end tell
|
||||
return sortList(targetFiles)
|
||||
end getTargetFiles
|
||||
|
||||
on addTargetFile(targetFile, targetName)
|
||||
tell application "CodeWarrior IDE 3.3"
|
||||
add (project document 1) new target file with data {targetFile} to targets {targetName}
|
||||
end tell
|
||||
end addTargetFile
|
||||
|
||||
on setCurrentTarget(currentTargetName)
|
||||
tell application "CodeWarrior IDE 3.3"
|
||||
Set Current Target currentTargetName
|
||||
end tell
|
||||
end setCurrentTarget
|
||||
|
||||
on removeTargetFile(targetFile)
|
||||
tell application "CodeWarrior IDE 3.3"
|
||||
Remove Files {targetFile}
|
||||
end tell
|
||||
end removeTargetFile
|
||||
|
||||
on quote(aString)
|
||||
return "'" & aString & "'"
|
||||
end quote
|
||||
|
||||
on listContains(aList, anItem)
|
||||
repeat with listItem in aList
|
||||
if (listItem contains anItem) then
|
||||
return true
|
||||
end if
|
||||
end repeat
|
||||
return false
|
||||
end listContains
|
||||
|
||||
on showList(listToShow)
|
||||
choose from list listToShow with prompt "List:" with empty selection allowed
|
||||
end showList
|
||||
|
||||
on replace(aString, oldChar, newChar)
|
||||
set newString to ""
|
||||
repeat with aChar in (every character of aString)
|
||||
if (contents of aChar = oldChar) then
|
||||
set newString to newString & newChar
|
||||
else
|
||||
set newString to newString & aChar
|
||||
end if
|
||||
end repeat
|
||||
return newString
|
||||
end replace
|
||||
|
||||
on substring(aString, anOffset)
|
||||
set aSubString to ""
|
||||
repeat with charIndex from anOffset to (count aString)
|
||||
set aSubString to aSubString & (character charIndex of aString)
|
||||
end repeat
|
||||
return aSubString
|
||||
end substring
|
||||
|
||||
on setFileInfo(aFile, aCreator, aType)
|
||||
tell application "Finder"
|
||||
set creator type of aFile to aCreator
|
||||
set file type of aFile to aType
|
||||
end tell
|
||||
end setFileInfo
|
||||
|
||||
on closeFile(fileRef)
|
||||
try
|
||||
-- make sure it's not currently open.
|
||||
close access fileRef
|
||||
on error
|
||||
-- ignore error closing.
|
||||
end try
|
||||
end closeFile
|
||||
|
||||
on mroFile(aFile)
|
||||
try
|
||||
-- make sure it's modifiable.
|
||||
mro aFile
|
||||
on error
|
||||
-- ignore error MROing.
|
||||
end try
|
||||
end mroFile
|
||||
|
||||
on run
|
||||
-- so we can easily strip off file names from paths.
|
||||
set oldDelimiters to swapDelimiters(":")
|
||||
|
||||
set theProjectFile to (choose file with prompt "Choose a CW Project file." of type {"MMPr"})
|
||||
set theManifestFile to (new file with prompt "Create MANIFEST where?" default name setExtension(fileFromPath(theProjectFile as text), ".toc"))
|
||||
|
||||
set manifestRef to false
|
||||
|
||||
try
|
||||
-- make sure the file is closed & is modifiable.
|
||||
closeFile(theManifestFile)
|
||||
mroFile(theManifestFile)
|
||||
|
||||
-- open the new MANIFEST file.
|
||||
set manifestRef to (open for access theManifestFile with write permission)
|
||||
set eof manifestRef to 0
|
||||
|
||||
-- give it CodeWarrior look and feel.
|
||||
setFileInfo(theManifestFile, "CWIE", "TEXT")
|
||||
|
||||
openProject(theProjectFile)
|
||||
selectProject(theProjectFile)
|
||||
|
||||
set targetsList to getTargets()
|
||||
set targetNames to names of targetsList
|
||||
set targetCount to count items of targetNames
|
||||
|
||||
set mozillaTreePathOffset to (offset of "mozilla" in (theManifestFile as text))
|
||||
|
||||
-- dump all targets into the new MANIFEST file.
|
||||
repeat with targetName in targetNames
|
||||
write ("# target: " & targetName & return) to manifestRef
|
||||
setCurrentTarget(targetName)
|
||||
set targetFiles to getTargetFiles(contents of targetName)
|
||||
repeat with targetFile in targetFiles
|
||||
-- only store the path name relative to the source tree itself.
|
||||
set targetFilePath to substring(contents of targetFile, mozillaTreePathOffset)
|
||||
write (replace(targetFilePath, ":", "/") & return) to manifestRef
|
||||
end repeat
|
||||
end repeat
|
||||
on error msg
|
||||
display dialog msg
|
||||
end try
|
||||
if (manifestRef is not false) then
|
||||
closeFile(manifestRef)
|
||||
end if
|
||||
|
||||
-- shut the project down, and display the result.
|
||||
tell application "CodeWarrior IDE 3.3"
|
||||
activate
|
||||
Close Project
|
||||
open theManifestFile
|
||||
end tell
|
||||
|
||||
setDelimiters(oldDelimiters)
|
||||
end run
|
||||
@@ -41,7 +41,6 @@
|
||||
#pragma unsigned_char off
|
||||
#pragma exceptions on
|
||||
#pragma bool on
|
||||
#pragma RTTI on
|
||||
|
||||
|
||||
/* Save as much space as possible with strings... */
|
||||
|
||||
@@ -1,217 +0,0 @@
|
||||
#!perl -w
|
||||
package MANIFESTO;
|
||||
|
||||
require 5.004;
|
||||
require Exporter;
|
||||
|
||||
#use strict;
|
||||
|
||||
use vars qw($VERSION @ISA @EXPORT $MANIFESTOLib);
|
||||
use Mac::StandardFile;
|
||||
use Moz;
|
||||
use Cwd;
|
||||
use Exporter;
|
||||
use File::Basename;
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(ReconcileProject);
|
||||
$VERSION = "1.00";
|
||||
|
||||
=head1 NAME
|
||||
|
||||
MANIFESTO - drives the Mac Project Reconciliation tool.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
You want to use this script. It will make your life easier.
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
The contents of this file are subject to the Netscape Public License
|
||||
Version 1.0 (the "NPL"); you may not use this file except in
|
||||
compliance with the NPL. You may obtain a copy of the NPL at
|
||||
http://www.mozilla.org/NPL/
|
||||
|
||||
Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
for the specific language governing rights and limitations under the
|
||||
NPL.
|
||||
|
||||
The Initial Developer of this code under the NPL is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
Reserved.
|
||||
|
||||
=cut
|
||||
|
||||
#
|
||||
# globals
|
||||
# $MANIFESTOLib - location of MANIFESTO applescript library
|
||||
#
|
||||
|
||||
#
|
||||
# utility routines
|
||||
#
|
||||
|
||||
sub current_directory()
|
||||
{
|
||||
my $current_directory = cwd();
|
||||
chop($current_directory) if ( $current_directory =~ m/:$/ );
|
||||
return $current_directory;
|
||||
}
|
||||
|
||||
# Uses the "compile script" extension to compile a script.
|
||||
sub compile_script($;$) {
|
||||
my($scriptPath, $outputPath) = @_;
|
||||
|
||||
#// generate a script to compile a script file.
|
||||
my $script = <<END_OF_APPLESCRIPT;
|
||||
store script (compile script (alias "$scriptPath")) in (file "$outputPath") replacing yes
|
||||
END_OF_APPLESCRIPT
|
||||
|
||||
#// run the script.
|
||||
MacPerl::DoAppleScript($script);
|
||||
}
|
||||
|
||||
# _useMANIFESTOLib()
|
||||
# returns 1 on success
|
||||
# Search the include path for the file called MANIFESTOLib
|
||||
sub _useMANIFESTOLib()
|
||||
{
|
||||
unless ( defined($MANIFESTOLib) )
|
||||
{
|
||||
my($scriptName) = "MANIFESTOLib.script";
|
||||
my($libName) = "MANIFESTOLib";
|
||||
# try the directory we were run from
|
||||
my($scriptPath) = dirname($0) . ":" . $scriptName;
|
||||
my($libPath) = dirname($0) . ":" . $libName;
|
||||
# make sure that the compiled script is up to date with the textual script.
|
||||
unless (-e $libPath && getModificationDate($libPath) >= getModificationDate($scriptPath)) {
|
||||
print "# Recompiling MANIFESTOLib.script.\n";
|
||||
compile_script($scriptPath, $libPath);
|
||||
}
|
||||
if ( -e $libPath) {
|
||||
$MANIFESTOLib = $libPath;
|
||||
} else {
|
||||
# now search the include directories
|
||||
foreach (@INC)
|
||||
{
|
||||
unless ( m/^Dev:Pseudo/ ) # This is some bizarre MacPerl special-case directory
|
||||
{
|
||||
$libPath = $_ . $libName;
|
||||
if (-e $libPath)
|
||||
{
|
||||
$MANIFESTOLib = $libPath;
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (! (-e $MANIFESTOLib)) {
|
||||
print STDERR "MANIFESTOLib lib could not be found! $MANIFESTOLib";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub getModificationDate($) {
|
||||
my($filePath)=@_;
|
||||
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
|
||||
$atime,$mtime,$ctime,$blksize,$blocks) = stat($filePath);
|
||||
return $mtime;
|
||||
}
|
||||
|
||||
sub setExtension($;$;$) {
|
||||
my($filePath, $oldExtension, $newExtension)=@_;
|
||||
my($name, $dir, $type) = fileparse($filePath, $oldExtension);
|
||||
return "$dir$name$newExtension";
|
||||
}
|
||||
|
||||
#
|
||||
# ReconcileProject(projectPath, manifestoPath)
|
||||
#
|
||||
# Uses MANIFESTOLib AppleScript to reconcile the contents (toc?) of a
|
||||
# CodeWarrior project with an external MANIFEST file.
|
||||
#
|
||||
|
||||
sub ReconcileProject($;$) {
|
||||
#// turn this feature on by removing the following line.
|
||||
return 1;
|
||||
|
||||
my($projectPath, $manifestoPath) = @_;
|
||||
my($sourceTree) = current_directory();
|
||||
my($logPath) = setExtension($manifestoPath, ".toc", ".log");
|
||||
|
||||
print STDERR "# Reconciling Project: $projectPath with $manifestoPath\n";
|
||||
|
||||
#// compare the modification dates of the .toc and .log files. If .log is newer, do nothing.
|
||||
if (-e $logPath && getModificationDate($logPath) >= getModificationDate($manifestoPath)) {
|
||||
print "# Project is up to date.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
_useMANIFESTOLib() || die "Could not load MANIFESTOLib\n";
|
||||
|
||||
my $script = <<END_OF_APPLESCRIPT;
|
||||
tell (load script file "$MANIFESTOLib") to ReconcileProject("$sourceTree:", "$sourceTree$projectPath", "$sourceTree$manifestoPath")
|
||||
END_OF_APPLESCRIPT
|
||||
|
||||
#// run the script, and store the results in a file called "$manifestoPath.log"
|
||||
my $asresult = substr(MacPerl::DoAppleScript($script), 1, -1); #// chops off leading, trailing quotes.
|
||||
|
||||
#// print out to STDOUT to show progress.
|
||||
print $asresult;
|
||||
|
||||
#// store the results in "$manifestoPath.log", which will act as a cache for later checks.
|
||||
open(OUTPUT, ">$logPath") || die "can't open log file $logPath.";
|
||||
print OUTPUT $asresult;
|
||||
close(OUTPUT);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
1;
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
MANIFESTO - Scripts to process source .toc files.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use MANIFESTO;
|
||||
ReconcileProject(<path to Mac project file>, <path to table of contents file>) || die "cannot reconcile project";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This is a PERL interface for talking to MANIFESTOLib AppleScripts.
|
||||
|
||||
=item ReconcileProject
|
||||
ReconcileProject(<path to Mac project file>, <path to table of contents file>);
|
||||
|
||||
Reconciles the contents of a project with an external .toc file.
|
||||
|
||||
=cut
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
=over
|
||||
|
||||
=item MacCVS Home Page
|
||||
|
||||
http://www.maccvs.org/
|
||||
|
||||
=back
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
Patrick Beard beard@netscape.com
|
||||
|
||||
based on work by
|
||||
|
||||
Aleks Totic atotic@netscape.com
|
||||
|
||||
=cut
|
||||
|
||||
__END__
|
||||
Binary file not shown.
@@ -1,372 +0,0 @@
|
||||
(*
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*)
|
||||
|
||||
(*
|
||||
MANIFESTOLib - Reconciles a CW Project file with an external table of contents file.
|
||||
|
||||
Uses merge sort, one pass per target.
|
||||
|
||||
by Patrick C. Beard <beard@netscape.com>
|
||||
*)
|
||||
|
||||
(* Global Configuration Properties *)
|
||||
|
||||
property pShowReport : true
|
||||
-- property pSourceTree : "Homeward:Work:Raptor:src:"
|
||||
property pSourceTree : "Morbeus:Projects:Raptor:src:"
|
||||
|
||||
on swapDelimiters(newDelimiters)
|
||||
set oldDelimiters to get AppleScript's text item delimiters
|
||||
set AppleScript's text item delimiters to newDelimiters
|
||||
return oldDelimiters
|
||||
end swapDelimiters
|
||||
|
||||
on setDelimiters(newDelimiters)
|
||||
set AppleScript's text item delimiters to newDelimiters
|
||||
end setDelimiters
|
||||
|
||||
-- replaces oldChar with newChar in a string.
|
||||
on replace(aString, oldChar, newChar)
|
||||
set newString to ""
|
||||
repeat with aChar in (every character of aString)
|
||||
if (contents of aChar = oldChar) then
|
||||
set newString to newString & newChar
|
||||
else
|
||||
set newString to newString & aChar
|
||||
end if
|
||||
end repeat
|
||||
return newString
|
||||
end replace
|
||||
|
||||
(* uses "sort" scripting addition to sort a list of strings. *)
|
||||
on sortList(aList)
|
||||
if (aList {}) then
|
||||
return sort aList
|
||||
else
|
||||
return {}
|
||||
end if
|
||||
end sortList
|
||||
|
||||
-- reads .toc file into a list.
|
||||
on readManifestFile(sourceTree, manifestFile)
|
||||
set oldDelimiters to swapDelimiters(return)
|
||||
set fileRef to false
|
||||
set fileLines to {}
|
||||
try
|
||||
set fileRef to (open for access manifestFile without write permission)
|
||||
-- read entire file into memory, use text items to delimit lines.
|
||||
set fileContents to (read fileRef)
|
||||
repeat with lineRef in (every text item of fileContents)
|
||||
-- ignore lines that start with "#" or are empty.
|
||||
set fileLine to (contents of lineRef)
|
||||
if (fileLine "") and not (fileLine starts with "#") then
|
||||
set fileLines to fileLines & (sourceTree & replace(fileLine, "/", ":"))
|
||||
end if
|
||||
end repeat
|
||||
on error
|
||||
-- ignore errors.
|
||||
end try
|
||||
if (fileRef is not false) then close access fileRef
|
||||
setDelimiters(oldDelimiters)
|
||||
return sortList(fileLines)
|
||||
end readManifestFile
|
||||
|
||||
(* both of the following depend on ":" as the delimiter character. *)
|
||||
|
||||
on folderFromPath(filePath)
|
||||
return ((filePath's text items 1 thru ((count of filePath's text items) - 1)) as string) & ":"
|
||||
end folderFromPath
|
||||
|
||||
on fileFromPath(filePath)
|
||||
return last text item of filePath
|
||||
end fileFromPath
|
||||
|
||||
(* CW Pro IDE Interface Handlers. *)
|
||||
|
||||
on openProject(aProjectFile)
|
||||
tell application "CodeWarrior IDE 3.3"
|
||||
-- activate
|
||||
open aProjectFile
|
||||
end tell
|
||||
end openProject
|
||||
|
||||
(* forces the named project file to be the front window. *)
|
||||
on selectProject(aProjectFile)
|
||||
set projectName to fileFromPath(aProjectFile as text)
|
||||
tell application "CodeWarrior IDE 3.3"
|
||||
if (name of window 1 is not projectName) then
|
||||
select window projectName
|
||||
end if
|
||||
end tell
|
||||
end selectProject
|
||||
|
||||
on closeProject(aProjectFile)
|
||||
tell application "CodeWarrior IDE 3.3"
|
||||
Close Project
|
||||
end tell
|
||||
end closeProject
|
||||
|
||||
on getTargets()
|
||||
set targetList to {}
|
||||
set nameList to {}
|
||||
tell application "CodeWarrior IDE 3.3"
|
||||
set currentProject to project document 1
|
||||
repeat with targetIndex from 1 to (count of targets of currentProject)
|
||||
set currentTarget to (target targetIndex of currentProject)
|
||||
set targetList to targetList & {currentTarget}
|
||||
set nameList to nameList & {name of currentTarget}
|
||||
end repeat
|
||||
return {target:targetList, names:nameList}
|
||||
end tell
|
||||
end getTargets
|
||||
|
||||
(* uses "info for" scripting addition, to return the file type of a path. *)
|
||||
on getFileType(aFilePath)
|
||||
return file type of (info for alias aFilePath)
|
||||
end getFileType
|
||||
|
||||
(* returns all "TEXT" files of the named target. *)
|
||||
on getTargetFiles(targetKey)
|
||||
set targetFiles to {}
|
||||
tell application "CodeWarrior IDE 3.3"
|
||||
set currentProject to project document 1
|
||||
set currentTarget to (target targetKey of currentProject)
|
||||
try
|
||||
-- workaround for CW IDE 3.X bug, loop until error encountered.
|
||||
set fileIndex to 1
|
||||
repeat until false
|
||||
set targetFile to (target file fileIndex of currentTarget)
|
||||
-- only consider text files, since other platforms won't be managing binaries.
|
||||
-- also, only consider if target file is directly linked.
|
||||
if (linked of targetFile) then
|
||||
set targetFilePath to (Access Paths of targetFile)
|
||||
tell me
|
||||
if (getFileType(targetFilePath) = "TEXT") then
|
||||
set targetFiles to targetFiles & {targetFilePath}
|
||||
end if
|
||||
end tell
|
||||
end if
|
||||
set fileIndex to (fileIndex + 1)
|
||||
end repeat
|
||||
on error msg
|
||||
-- display dialog msg & " file count = " & fileIndex
|
||||
end try
|
||||
end tell
|
||||
return sortList(targetFiles)
|
||||
end getTargetFiles
|
||||
|
||||
on addTargetFile(targetFile, targetList)
|
||||
tell application "CodeWarrior IDE 3.3"
|
||||
add (project document 1) new target file with data {targetFile} to targets targetList
|
||||
end tell
|
||||
end addTargetFile
|
||||
|
||||
global gCurrentTarget
|
||||
|
||||
on setCurrentTarget(currentTargetName)
|
||||
if (gCurrentTarget currentTargetName) then
|
||||
set gCurrentTarget to currentTargetName
|
||||
tell application "CodeWarrior IDE 3.3"
|
||||
Set Current Target currentTargetName
|
||||
end tell
|
||||
end if
|
||||
end setCurrentTarget
|
||||
|
||||
on removeTargetFile(targetFile)
|
||||
tell application "CodeWarrior IDE 3.3"
|
||||
Remove Files {targetFile}
|
||||
end tell
|
||||
end removeTargetFile
|
||||
|
||||
on quote(aString)
|
||||
return "'" & aString & "'"
|
||||
end quote
|
||||
|
||||
on listContains(aList, anItem)
|
||||
repeat with listItem in aList
|
||||
if (contents of listItem = anItem) then
|
||||
return true
|
||||
end if
|
||||
end repeat
|
||||
return false
|
||||
end listContains
|
||||
|
||||
on showList(aList)
|
||||
choose from list aList with prompt "List:" with empty selection allowed
|
||||
end showList
|
||||
|
||||
global gProjectModified
|
||||
|
||||
on ModifyReadOnly(aProjectFile)
|
||||
if (not gProjectModified) then
|
||||
set gProjectModified to true
|
||||
-- so CodeWarrior will notice, must close the file before MROing it.
|
||||
closeProject(aProjectFile)
|
||||
mro aProjectFile
|
||||
openProject(aProjectFile)
|
||||
selectProject(aProjectFile)
|
||||
end if
|
||||
end ModifyReadOnly
|
||||
|
||||
on makeStream(itemList)
|
||||
return {streamList:itemList, streamCount:count itemList, streamIndex:0}
|
||||
end makeStream
|
||||
|
||||
(* true is used as the end of stream value. *)
|
||||
property pEOS : true
|
||||
|
||||
on advanceStream(stream)
|
||||
set itemCount to (streamCount of stream)
|
||||
set itemIndex to (streamIndex of stream)
|
||||
if (itemIndex < itemCount) then
|
||||
set itemIndex to (itemIndex + 1)
|
||||
set (streamIndex of stream) to itemIndex
|
||||
return (item itemIndex of streamList of stream)
|
||||
else
|
||||
return pEOS
|
||||
end if
|
||||
end advanceStream
|
||||
|
||||
-- returns true if str2 is INFINITELY great, or str1 is less than str2.
|
||||
on precedes(str1, str2)
|
||||
return (str2 = pEOS) or ((str1 pEOS) and (str1 < str2))
|
||||
end precedes
|
||||
|
||||
on get_current_application()
|
||||
return last text item of ((path to current application) as text)
|
||||
end get_current_application
|
||||
|
||||
on get_frontmost_application()
|
||||
return last text item of ((path to frontmost application) as text)
|
||||
end get_frontmost_application
|
||||
|
||||
on activate_application(applicationName)
|
||||
tell application "Finder"
|
||||
set applicationProcess to (application process applicationName)
|
||||
set frontmost of applicationProcess to true
|
||||
end tell
|
||||
end activate_application
|
||||
|
||||
on ReconcileProject(sourceTree, projectPath, manifestoPath)
|
||||
-- so we can easily strip off file names from paths.
|
||||
set oldDelimiters to swapDelimiters(":")
|
||||
|
||||
-- initialize globals.
|
||||
set gCurrentTarget to ""
|
||||
set gProjectModified to false
|
||||
|
||||
-- convert paths to aliases.
|
||||
set projectFile to alias projectPath
|
||||
set manifestFile to alias manifestoPath
|
||||
|
||||
-- read the MANIFESTO file into a list of paths.
|
||||
set manifestContents to readManifestFile(sourceTree, manifestFile)
|
||||
-- return manifestContents
|
||||
|
||||
-- now, start processing the file items, ensuring that the project contains all items.
|
||||
openProject(projectFile)
|
||||
selectProject(projectFile)
|
||||
set targetsList to getTargets()
|
||||
set targetNames to names of targetsList
|
||||
|
||||
if (pShowReport) then
|
||||
set theReport to ""
|
||||
set addedFiles to ""
|
||||
set removedFiles to ""
|
||||
end if
|
||||
|
||||
-- push current application to front for speed.
|
||||
-- set frontmostApplication to get_frontmost_application()
|
||||
-- set currentApplication to get_current_application()
|
||||
-- activate_application(currentApplication)
|
||||
|
||||
-- reconcile all targets with the MANIFEST file.
|
||||
-- this loop should be recoded in PERL for speed.
|
||||
-- IDEA: with sorted lists, can scan both lists, like a merge sort, and make one pass per target.
|
||||
repeat with targetNameRef in targetNames
|
||||
-- switch targets because getTargetFiles now checks to see if file is linked in current target.
|
||||
set targetName to (contents of targetNameRef)
|
||||
set targetFiles to getTargetFiles(targetName)
|
||||
-- hopefully, this list test is fast.
|
||||
if (targetFiles manifestContents) then
|
||||
-- return {count targetFiles, count manifestContents, targetFiles, manifestContents}
|
||||
-- make sure the project file is modifiable.
|
||||
ModifyReadOnly(projectFile)
|
||||
setCurrentTarget(targetName)
|
||||
set targetStream to makeStream(targetFiles)
|
||||
set targetItem to advanceStream(targetStream)
|
||||
set manifestStream to makeStream(manifestContents)
|
||||
set manifestItem to advanceStream(manifestStream)
|
||||
repeat until (manifestItem is pEOS) and (targetItem is pEOS)
|
||||
-- display dialog "m: " & manifestItem & ", t: " & targetFileItem
|
||||
if (manifestItem = targetItem) then
|
||||
-- items match, advance both.
|
||||
set manifestItem to advanceStream(manifestStream)
|
||||
set targetItem to advanceStream(targetStream)
|
||||
else
|
||||
-- return {manifestItem, targetItem}
|
||||
if (precedes(manifestItem, targetItem)) then
|
||||
-- we have an item in manifest, not in project, so we have to add it to the targets.
|
||||
-- display dialog "adding " & manifestItem
|
||||
addTargetFile(manifestItem, targetNames)
|
||||
if pShowReport then
|
||||
set addedFiles to addedFiles & ("# " & (last text item of manifestItem) & return)
|
||||
end if
|
||||
set manifestItem to advanceStream(manifestStream)
|
||||
else
|
||||
-- we have an item not in manifest, but in project, so it must be removed from this target.
|
||||
-- display dialog "removing " & targetItem
|
||||
removeTargetFile(targetItem)
|
||||
if pShowReport then
|
||||
set removedFiles to removedFiles & ("# " & targetName & " - " & (last text item of targetItem) & return)
|
||||
end if
|
||||
set targetItem to advanceStream(targetStream)
|
||||
end if
|
||||
end if
|
||||
end repeat
|
||||
end if
|
||||
end repeat
|
||||
|
||||
-- activate_application(frontmostApplication)
|
||||
|
||||
-- commit the project changes, and optionally display a report.
|
||||
tell application "CodeWarrior IDE 3.3"
|
||||
-- leave project open for compilation phase?
|
||||
Close Project
|
||||
if pShowReport then
|
||||
if addedFiles is not "" then set theReport to ("# Added files: " & return & addedFiles)
|
||||
if removedFiles is not "" then set theReport to theReport & ("# Removed files: " & return & removedFiles)
|
||||
if (theReport is "") then set theReport to (" # Project is up to date." & return)
|
||||
-- display dialog theReport buttons {"OK"} default button "OK"
|
||||
end if
|
||||
end tell
|
||||
|
||||
-- restore AppleScript's delimiters.
|
||||
setDelimiters(oldDelimiters)
|
||||
|
||||
-- return 0 to indicate no error.
|
||||
return theReport
|
||||
end ReconcileProject
|
||||
|
||||
on run
|
||||
-- when run interactively,
|
||||
-- ask user which project/MANIFEST files to use.
|
||||
set projectPath to (choose file with prompt "Choose a CW Project file." of type {"MMPr"}) as text
|
||||
set manifestPath to (choose file with prompt "Choose a TOC file to process." of type {"TEXT"}) as text
|
||||
ReconcileProject(pSourceTree, projectPath, manifestPath)
|
||||
end run
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user