Compare commits

...

56 Commits

Author SHA1 Message Date
morse%netscape.com
c713379ead updates for single signon
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@14858 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-18 04:35:47 +00:00
sar%netscape.com
149c102fa1 this ifdef NO_SECURITY snuck in during a merge. replacing it with ifdef MOZ_SECURITY and turning the logic around to match
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@14643 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-14 01:11:40 +00:00
cls%seawood.org
a131892fd9 Changes to make parallel builds play nice.
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@14389 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-11 01:50:01 +00:00
cls%seawood.org
09dd57061b Added -Iunix to INCLUDES
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@13599 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-28 05:36:57 +00:00
cls%seawood.org
aa9a419e45 New autoconf files for nglayout
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@13594 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-28 03:53:57 +00:00
(no author)
2d156df69c This commit was manufactured by cvs2svn to create branch 'XPCOM_BRANCH'.
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@13234 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-21 02:13:57 +00:00
warren%netscape.com
804b01a422 Renamed NSRepository to nsRepository.
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@8924 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-01 00:53:04 +00:00
kostello%netscape.com
a5f68e93ee Fix Mac build
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@8878 18797224-902f-48f8-a5cc-f745e15eee43
1998-08-31 19:13:38 +00:00
kostello%netscape.com
415e570976 Fix mac build
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@8877 18797224-902f-48f8-a5cc-f745e15eee43
1998-08-31 19:10:30 +00:00
pierre%netscape.com
2369a73396 renamed NSGetFactory and NSCanUnload to build on Mac
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@7339 18797224-902f-48f8-a5cc-f745e15eee43
1998-08-05 08:16:26 +00:00
pierre%netscape.com
89b19e4a3d fix build errors with Raptor
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@7333 18797224-902f-48f8-a5cc-f745e15eee43
1998-08-05 08:02:20 +00:00
pierre%netscape.com
64e905d880 fix Raptor Mac build: added some ifdefs around include files
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@6615 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-28 04:17:34 +00:00
pierre%netscape.com
8fd75aa605 updated to Windows make file
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@6609 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-28 04:08:33 +00:00
dcone%netscape.com
d62955e1cc Updated the MANIFEST
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@6075 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-21 17:47:58 +00:00
kostello%netscape.com
0f9724f018 First checkin -- real work to be done by Don Cone
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@6074 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-21 17:46:08 +00:00
scullin
5b297144f8 Make interface public, minor changes.
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@5434 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-13 23:36:09 +00:00
scullin
b37c81c8ec Restore XP_Bool in pointer arguments for correctness on UNIX and mac.
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@4541 18797224-902f-48f8-a5cc-f745e15eee43
1998-06-25 23:16:52 +00:00
(no author)
d5fb34b8e4 This commit was manufactured by cvs2svn to create branch 'XPCOM_BRANCH'.
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@3269 18797224-902f-48f8-a5cc-f745e15eee43
1998-06-04 22:51:08 +00:00
hardts
96d5374145 link in XPCOM libs
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@2206 18797224-902f-48f8-a5cc-f745e15eee43
1998-05-22 19:38:03 +00:00
cyeh
ce9f6618ef add files to projects. approved steve hardt
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@2156 18797224-902f-48f8-a5cc-f745e15eee43
1998-05-22 00:48:16 +00:00
cyeh
f0b79bc8b7 fix string definitons and protoypes for Mac.
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@2153 18797224-902f-48f8-a5cc-f745e15eee43
1998-05-22 00:31:55 +00:00
peterl
ce32841cce added enumerate methods
added small initial buffer to avoid memory allocations


git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@2043 18797224-902f-48f8-a5cc-f745e15eee43
1998-05-20 20:31:36 +00:00
peterl
54504544d8 added implementation of new and delete to make gcc happy
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@1837 18797224-902f-48f8-a5cc-f745e15eee43
1998-05-18 21:02:09 +00:00
peterl
0427aa89dc added count method
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@1836 18797224-902f-48f8-a5cc-f745e15eee43
1998-05-18 21:01:50 +00:00
rpotts
21a9aae486 Added nsAgg.h to the export list...
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@1734 18797224-902f-48f8-a5cc-f745e15eee43
1998-05-15 10:11:04 +00:00
scullin
cca9d870b0 G++ warning fix submitted by Brian Grunkemeyer.
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@1241 18797224-902f-48f8-a5cc-f745e15eee43
1998-05-07 20:50:59 +00:00
hardts
f6191d3e3c build libreg in export phase so will be available for xpcom
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@1039 18797224-902f-48f8-a5cc-f745e15eee43
1998-05-01 23:04:25 +00:00
rpotts
e899b2fa24 Added include of stdlib.h for exit() since windows.h used to pull it in.
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@864 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-29 19:34:36 +00:00
rpotts
2bcd076e39 added include of windows.h since NSPR no longer pulls it in...
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@863 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-29 19:30:50 +00:00
rpotts
1ee5c9d910 fixed build bustage since NSPR no longer includes windows.h for windows...
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@857 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-29 18:14:10 +00:00
scullin
fdebfadaa4 Fix windows breakage resulting from nspr not including windows.h by default.
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@856 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-29 18:11:05 +00:00
scullin
108846d00d nsresults instead of int return values.
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@718 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-27 21:31:21 +00:00
sar
3e715bea36 making the switch ns->mozilla for dir name
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@704 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-27 19:21:40 +00:00
kipp
cbb3003865 Added IsNull and IsNotNull methods to iptr macros
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@673 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-26 02:56:53 +00:00
kipp
5d46b3856c Added pre-condition in release impl code
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@667 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-25 18:49:26 +00:00
scullin
03b27c99b4 Remove dependency on Motif
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@575 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-24 00:16:20 +00:00
scullin
9a436480ab Linux build fixes. Disables UNIX admin kit.
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@554 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-23 19:01:24 +00:00
kipp
a3a2bdd1d7 define win32_lean_and_mean
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@546 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-23 16:47:42 +00:00
scullin
b45913f1e9 De-NSPR20-ified
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@544 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-23 04:28:16 +00:00
kipp
39317cc438 Added TestID
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@521 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-22 21:12:58 +00:00
kipp
6ee540cdcb new
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@520 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-22 21:12:46 +00:00
kipp
a642c1efa5 Use nspr i/o routines to maximize portability; allow Parse to be slightly more flexible on it's input
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@519 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-22 21:12:27 +00:00
kipp
f69d0b4d33 Export Parse and ToString from the DLL
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@518 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-22 21:12:01 +00:00
peterl
f93a5c4453 added nsIPtr.h
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@503 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-22 07:18:05 +00:00
peterl
d83687718f added nsIPtr.h
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@492 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-22 06:29:09 +00:00
peterl
c204869940 Made nsHashKey have virtual destructor, also exported class
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@491 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-22 06:28:23 +00:00
scullin
e7dc830b9d NSPR related changes submitted by wtc.
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@481 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-22 00:05:08 +00:00
scullin
4d8f551d43 Added missing semi-colon.
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@255 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-14 19:53:24 +00:00
scullin
a4400dcf90 Initial documentation.
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@254 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-14 19:52:12 +00:00
scullin
45ab7bb0f7 IRIX build fixes.
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@224 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-14 01:58:11 +00:00
scullin
8ba251d902 IRIX build fixes
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@223 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-14 01:55:01 +00:00
kipp
b9ed9501a4 Build library during libs phase
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@169 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-13 20:56:02 +00:00
scullin
b48ff903ec XPCOM-ified prefs.
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@149 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-10 22:32:28 +00:00
scullin
61b9cc3630 Fix typo.
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@148 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-10 21:47:38 +00:00
scullin
9436bc4620 Latest xpcom stuff from raptor work.
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@121 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-09 00:38:54 +00:00
(no author)
7df6e8cb7b This commit was manufactured by cvs2svn to create branch 'XPCOM_BRANCH'.
git-svn-id: svn://10.0.0.236/branches/XPCOM_BRANCH@101 18797224-902f-48f8-a5cc-f745e15eee43
1998-04-08 05:34:53 +00:00
94 changed files with 47132 additions and 1245 deletions

View File

@@ -1,248 +0,0 @@
# Three different line formats are valid:
# key -a aliases...
# key [options] directory
# key [options] directory files...
#
# Where "options" are composed of:
# -i prog Run "prog" on "cvs commit" from top-level of module.
# -o prog Run "prog" on "cvs checkout" of module.
# -e prog Run "prog" on "cvs export" of module.
# -t prog Run "prog" on "cvs rtag" of module.
# -u prog Run "prog" on "cvs update" of module.
# -d dir Place module in directory "dir" instead of module name.
# -l Top-level directory only -- do not recurse.
#
# NOTE: If you change any of the "Run" options above, you'll have to
# release and re-checkout any working directories of these modules.
#
# And "directory" is a path to a directory relative to $CVSROOT.
#
# The "-a" option specifies an alias. An alias is interpreted as if
# everything on the right of the "-a" had been typed on the command line.
#
# You can encode a module within a module by using the special '&'
# character to interpose another module into the current module. This
# can be useful for creating a module that consists of many directories
# spread out over the entire source repository.
ClientSourceProduct -a \
ClientSourceProductWin \
ClientSourceProductMac \
ClientSourceProductUnix \
ClientSourceProductWin -a MozillaCommon MozillaWinOnly
ClientSourceProductMac -a MozillaCommon MozillaMacOnly
ClientSourceProductUnix -a MozillaCommon MozillaUnixOnly
MozillaCommon -a \
ns/LEGAL \
ns/LICENSE \
ns/build \
ns/include \
ns/jpeg \
ns/js \
ns/lib/htmldlgs \
ns/lib/layout \
ns/lib/libcnv \
ns/lib/libi18n \
ns/lib/liblayer \
ns/lib/libmisc \
ns/lib/libmime \
ns/lib/libmocha \
ns/lib/libnet \
ns/lib/libparse \
ns/lib/libpics \
ns/lib/libpwcac \
ns/lib/libstyle \
ns/lib/plugin \
ns/lib/xlate \
ns/lib/xp \
ns/modules/edtplug/classes \
ns/modules/edtplug/src \
ns/modules/edtplug/include \
ns/modules/libfont/classes \
ns/modules/libfont/public \
ns/modules/libfont/src \
ns/modules/libhook \
ns/modules/libimg \
ns/modules/libpref \
ns/modules/libreg \
ns/modules/libutil \
ns/modules/progress/src \
ns/modules/rdf \
ns/modules/schedulr \
ns/modules/security/freenav \
ns/modules/xml \
ns/modules/zlib/src \
ns/nav-java/stubs \
ns/nsprpub \
ns/xpcom \
ns/l10n \
ns/nsprpub \
ns/dbm \
ns/modules/schedulr
MozillaWinOnly -a \
ns/client.mak \
ns/cmd/makefile.win \
ns/cmd/wincom \
ns/cmd/winfe \
ns/config \
ns/lib/makefile.win \
ns/modules/coreincl \
ns/modules/edtplug/makefile.win \
ns/makefile.win \
ns/modules/libfont/jmcgen \
ns/modules/libfont/makefile.win \
ns/modules/libfont/producers/makefile.win \
ns/modules/libfont/producers/win \
ns/modules/libfont/producers/win/classes \
ns/modules/libfont/producers/win/classes/netscape \
ns/modules/libfont/producers/win/classes/netscape/fonts \
ns/modules/libfont/producers/win/src \
ns/modules/makefile.win \
ns/modules/progress/makefile.win \
ns/modules/progress/public \
ns/modules/security/makefile.win \
ns/modules/zlib/makefile.win \
ns/nav-java/makefile.win \
JavaStubWin
MozillaUnixOnly -a \
ns/cmd/Makefile \
ns/cmd/stubfe \
ns/cmd/xfe \
ns/config/.cvsignore \
ns/config/AIX.mk \
ns/config/BSD_OS.mk \
ns/config/bsdecho.c \
ns/config/bsdecho.c \
ns/config/clobber_miss.pl \
ns/config/clobber_miss.pl \
ns/config/common.mk \
ns/config/common.mk \
ns/config/config.guess \
ns/config/config.mk \
ns/config/coreconf.mk \
ns/config/coreconf.mk \
ns/config/cvsco.pl \
ns/config/cvsco.pl \
ns/config/fastcwd.pl \
ns/config/fastcwd.pl \
ns/config/FreeBSD.mk \
ns/config/gtscc.c \
ns/config/HP-UX.mk \
ns/config/IRIX.mk \
ns/config/Linux.mk \
ns/config/makecopy.c \
ns/config/makecopy.c \
ns/config/Makefile \
ns/config/Makefile \
ns/config/mangle.c \
ns/config/mangle.c \
ns/config/mantomak.c \
ns/config/mantomak.c \
ns/config/mkdepend \
ns/config/NCR.mk \
ns/config/NEC.mk \
ns/config/NEWS-OS.mk \
ns/config/NEXTSTEP.mk \
ns/config/nfspwd.pl \
ns/config/nfspwd.pl \
ns/config/nodl.pl \
ns/config/nodl.pl \
ns/config/nsinstall.c \
ns/config/nsinstall.c \
ns/config/OSF1.mk \
ns/config/outofdate.pl \
ns/config/outofdate.pl \
ns/config/pathsub.c \
ns/config/pathsub.c \
ns/config/pathsub.h \
ns/config/pathsub.h \
ns/config/pkg2dpth.pl \
ns/config/pkg2dpth.pl \
ns/config/ports \
ns/config/revdepth.pl \
ns/config/revdepth.pl \
ns/config/Rhapsody.mk \
ns/config/rules.mk \
ns/config/SCOOS.mk \
ns/config/SINIX.mk \
ns/config/sj.pl \
ns/config/sj.pl \
ns/config/SunOS.mk \
ns/config/SunOS4.mk \
ns/config/SunOS5.mk \
ns/config/UNIXWARE.mk \
ns/config/xmversion.sh \
ns/lib/Makefile \
ns/Makefile \
ns/modules/edtplug/Makefile \
ns/modules/libfont/jmcgen \
ns/modules/libfont/Makefile \
ns/modules/libfont/producers/Makefile \
ns/modules/Makefile \
ns/modules/progress/Makefile \
ns/modules/progress/public \
ns/modules/security/Makefile \
ns/modules/zlib/Makefile \
ns/nav-java/Makefile \
ns/lib/mariner \
JavaStubUnix
MozillaMacOnly -a \
ns/cmd/macfe \
ns/lib/mac/AutoAdmin \
ns/lib/mac/Includes \
ns/lib/mac/MacMemoryAllocator \
ns/lib/mac/Misc \
ns/lib/mac/MoreFiles \
ns/lib/mac/NSRuntime \
ns/lib/mac/NSStdLib \
ns/lib/mac/patches \
ns/lib/mac/PowerPlant \
ns/lib/mac/UserInterface \
ns/modules/coreincl \
ns/modules/edtplug/macbuild \
ns/modules/libfont/jmcgen/include \
ns/modules/libfont/jmcgen/src \
ns/modules/libfont/macbuild \
ns/modules/progress/macbuild \
ns/modules/progress/public \
ns/modules/zlib/macbuild \
ns/lib/mariner \
JavaStubMac
JavaStubAll -a \
JavaStubWin \
JavaStubMac \
JavaStubUnix
JavaStubCore -a \
ns/sun-java/stubs/include \
ns/sun-java/stubs/src
JavaStubMac -a \
JavaStubCore \
ns/sun-java/stubs/macbuild \
ns/sun-java/stubs/macjri
JavaStubUnix -a \
JavaStubCore \
ns/sun-java/Makefile \
ns/sun-java/stubs/jri \
ns/sun-java/stubs/Makefile
JavaStubWin -a \
JavaStubCore \
ns/sun-java/makefile.win \
ns/sun-java/stubs/jri \
ns/sun-java/stubs/makefile.win

View File

@@ -0,0 +1,50 @@
/* -*- 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.
*/
// CSecureAttachment.cp
#pragma once
#include "CSecureAttachment.h"
#include "xp_core.h"
#include "secnav.h"
#include "secrng.h"
CSecureAttachment::CSecureAttachment()
: LAttachment(msg_Event)
{
mTickCounter = 0;
}
void CSecureAttachment::ExecuteSelf(
MessageT inMessage,
void *ioParam)
{
if (mTickCounter < 500)
{
EventRecord* theEvent = (EventRecord*)ioParam;
RNG_RandomUpdate(theEvent, sizeof(EventRecord));
long ticks = ::TickCount();
RNG_RandomUpdate(&ticks, sizeof(long));
mTickCounter++;
}
else
delete this;
}

File diff suppressed because it is too large Load Diff

3875
mozilla/cmd/winfe/fegui.cpp Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -318,7 +318,7 @@ BINREL_DIST=$(XPDIST)\WIN954.0_OPT.OBJ
BINREL_DIST=$(XPDIST)\WIN954.0_DBG.OBJD
!endif
!endif
LINK_LIBS= \
!if "$(MOZ_BITS)"=="32"
!ifndef NSPR20
@@ -1533,7 +1533,7 @@ $(GENDIR)\tdlogo.rc: $(MOZ_SRC)\ns\lib\xp\tdlogo.gif
AboutImages: $(GENDIR) \
$(GENDIR)\flamer.rc
$(GENDIR)\flamer.rc: $(MOZ_SRC)\ns\lib\xp\flamer.gif
$(BIN2RC) $(MOZ_SRC)\ns\lib\xp\flamer.gif image/gif > $(GENDIR)\flamer.rc
!endif
@@ -1547,7 +1547,7 @@ prebuild: $(GENDIR) $(GENDIR)\initpref.rc $(GENDIR)\allpref.rc \
$(GENDIR)\allpref2.rc $(GENDIR)\allpref3.rc $(GENDIR)\allpref4.rc\
$(GENDIR)\winpref.rc $(GENDIR)\config.rc NavCenterImages \
AboutImages
$(GENDIR)\initpref.rc: $(MOZ_SRC)\ns\modules\libpref\src\initpref.js
$(TXT2RC) init_prefs $(MOZ_SRC)\ns\modules\libpref\src\initpref.js \
$(GENDIR)\initpref.rc
@@ -1658,6 +1658,9 @@ install: \
!IF EXIST($(DIST)\bin\sched32.dll)
$(OUTDIR)\sched32.dll \
!ENDIF
!IF EXIST($(DIST)\bin\libreg32.dll)
$(OUTDIR)\libreg32.dll \
!ENDIF
!IF EXIST($(DIST)\bin\jrt32$(VERSION_NUMBER).dll)
$(OUTDIR)\jrt32$(VERSION_NUMBER).dll \
!ENDIF
@@ -1665,7 +1668,7 @@ install: \
$(OUTDIR)\uni3200.dll \
!ENDIF
!IF EXIST($(DIST)\bin\awt32$(VERSION_NUMBER).dll)
$(OUTDIR)\java\bin\awt32$(VERSION_NUMBER).dll \
$(OUTDIR)\java\bin\awt32$(VERSION_NUMBER).dll \
!ENDIF
!if defined(MOZ_TRACKGDI)
!IF EXIST($(DIST)\bin\trackgdi.dll)
@@ -1763,6 +1766,9 @@ install: \
!IF EXIST($(DIST)\bin\sched16.dll)
$(OUTDIR)\sched16.dll \
!ENDIF
!IF EXIST($(DIST)\bin\libreg16.dll)
$(OUTDIR)\libreg16.dll \
!ENDIF
!IF EXIST($(DIST)\bin\nsinit.exe)
$(OUTDIR)\nsinit.exe \
!ENDIF
@@ -1914,6 +1920,9 @@ $(OUTDIR)\xppref32.dll: $(DIST)\bin\xppref32.dll
$(OUTDIR)\sched32.dll: $(DIST)\bin\sched32.dll
@IF EXIST $(DIST)\bin\sched32.dll copy $(DIST)\bin\sched32.dll $(OUTDIR)\sched32.dll
$(OUTDIR)\libreg32.dll: $(DIST)\bin\libreg32.dll
@IF EXIST $(DIST)\bin\libreg32.dll copy $(DIST)\bin\libreg32.dll $(OUTDIR)\libreg32.dll
$(OUTDIR)\uni3200.dll: $(DIST)\bin\uni3200.dll
@IF EXIST $(DIST)\bin\uni3200.dll copy $(DIST)\bin\uni3200.dll $(OUTDIR)\uni3200.dll
@@ -1989,6 +1998,9 @@ $(OUTDIR)\xppref16.dll: $(DIST)\bin\xppref16.dll
$(OUTDIR)\sched16.dll: $(DIST)\bin\sched16.dll
@IF EXIST $(DIST)\bin\sched16.dll copy $(DIST)\bin\sched16.dll $(OUTDIR)\sched16.dll
$(OUTDIR)\libreg16.dll: $(DIST)\bin\libreg16.dll
@IF EXIST $(DIST)\bin\libreg16.dll copy $(DIST)\bin\libreg16.dll $(OUTDIR)\libreg16.dll
$(OUTDIR)\uni1600.dll: $(DIST)\bin\uni1600.dll
@IF EXIST $(DIST)\bin\uni1600.dll copy $(DIST)\bin\uni1600.dll $(OUTDIR)\uni1600.dll
@@ -2288,7 +2300,8 @@ BUILD_SOURCE: $(OBJ_FILES)
$(DIST)\lib\htmldg16.lib +
$(DIST)\lib\hook.lib +
$(DIST)\lib\png.lib +
$(DIST)\lib\sched16.lib +
$(DIST)\lib\sched16.lib +
$(DIST)\lib\libreg16.lib +
$(DIST)\lib\rdf16.lib +
$(DIST)\lib\xpstrdll.lib +
!ifdef MOZ_MAIL_NEWS
@@ -2662,7 +2675,7 @@ symbols:
@echo "MOZ_USERNAME = $(MOZ_USERNAME)"
@echo "MOZ_USERDEBUG = $(MOZ_USERDEBUG)"
!endif
ns.zip:
cd $(OUTDIR)
@@ -2703,6 +2716,7 @@ ns.zip:
edpref32.dll \
editor32.dll \
xppref32.dll \
sched32.dll \
sched32.dll \
libreg32.dll \
netscape.cfg \
moz40p3

2031
mozilla/cmd/winfe/nsapp.cpp Normal file

File diff suppressed because it is too large Load Diff

123
mozilla/cmd/winfe/stdafx.h Normal file
View File

@@ -0,0 +1,123 @@
/* -*- 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.
*/
#ifndef STDAFX_PCH
#define STDAFX_PCH
#define OEMRESOURCE
#if defined(DEBUG_blythe)
// Set up a flag specific to WFE developers in the client
#define DEBUG_WFE
#endif
/* Very windows specific includes.
*/
/* MFC, KFC, RUN DMC, whatever */
#include <afxwin.h>
#include <afxext.h>
#include <afxpriv.h>
#include <afxole.h>
#include <afxdisp.h>
#include <afxodlgs.h>
#ifdef _WIN32
#include <afxcmn.h>
#endif
/* More XP than anything */
#include "xp.h"
#include "fe_proto.h"
#include "fe_rgn.h"
#include "libi18n.h"
#include "xlate.h"
#include "ntypes.h"
#ifdef EDITOR
#include "edttypes.h"
#endif
#include "xpassert.h"
#include "lo_ele.h"
#include "layers.h"
/* Standard C includes */
#ifndef _WIN32
#include <dos.h>
#endif
#include <malloc.h>
#include <direct.h>
#include <stdarg.h>
#include <time.h>
#include <io.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#ifdef DEBUG
#include <assert.h>
#endif
/* Very windows specific includes.
*/
/* WFE needs a layout file */
extern "C" {
#include "layout.h"
}
/* Some common defines. */
#ifndef _AFXDLL
#define new DEBUG_NEW
#endif
/* All front end forward declarations needed to compile. */
#include "forward.h"
/* Front end Casting macros. */
#include "cast.h"
/* General purpose utilities. */
#include "feutil.h"
/* afxData/sysInfo */
#include "sysinfo.h"
/* Some defines we like everywhere. */
#include "resource.h"
#include "defaults.h"
/* The application include and
* Commonly used, rarely changed headers */
#include "ncapiurl.h"
#include "genedit.h"
#include "genframe.h"
#include "genview.h"
#include "gendoc.h"
#include "intlwin.h"
#include "mozilla.h"
#include "cxwin.h"
#include "winproto.h"
#ifdef DEBUG
#ifdef assert
#undef assert
#endif
#define assert(x) ASSERT(x)
#endif
#endif /* STDAFX_PCH */

View File

@@ -21,16 +21,19 @@
# There are N dimensions to a full complement of binaries:
#
# - target architecture
# - debug vs optimized
# - normal vs "lite"
# - normal vs purified
# - debug vs optimized
# - normal vs "lite"
# - normal vs purified
# - dynamic vs statically linked
#
# A directory is needed for each of the first two dimensions (target
# and debug), but executables for all of the others will then be built
# in the same directory from the same .o files. The files have names
# as follows:
#
# mozilla-export
# moz-export (Dynamically linked with libs in
# ../../dist/<objdir>/bin)
# mozilla-export (Statically linked)
# mozilla-nis-export (SunOS 4 only)
# mozilla-export.pure (SunOS 4 and Solaris only)
# ...etc...
@@ -70,9 +73,10 @@ DIRS = \
Microline3.0/XmL \
$(NULL)
REQUIRES = \
XfeWidgets \
Microline \
REQUIRES =\
XfeWidgets \
XfeBm \
Microline \
addr \
applet \
img \
@@ -192,9 +196,9 @@ GARBAGE += e_kit_resources.h cxxlink-filter
ICONS_LIB = $(DIST)/lib/lib$(LITE_PREFIX)xfeicons.a
DTWIDGETS_LIB = $(DIST)/lib/libDtWidgets.a
XFE_WIDGETS_LIB = $(DIST)/lib/libXfeWidgets.a
COMBOBOX_LIB = $(DIST)/lib/libComboBox.a
DTWIDGETS_LIB = $(DIST)/lib/libDtWidgets.a
XFE_WIDGETS_LIB = $(DIST)/lib/libXfeWidgets.a
XFE_WIDGETS_BM_LIB = $(DIST)/lib/libXfeBm.a
ifeq ($(OS_ARCH),AIX)
NSPR_LIB =
@@ -222,9 +226,24 @@ BASIC_LIBS = \
$(MICROLINE_LIB) \
$(ICONS_LIB) \
$(DTWIDGETS_LIB) \
$(XFE_WIDGETS_BM_LIB) \
$(XFE_WIDGETS_LIB) \
$(DIST)/lib/libxlate.a \
$(DIST)/lib/lib$(LITE_PREFIX)net.a \
$(DIST)/lib/libnetcache.a \
$(DIST)/lib/libnetcnvts.a \
$(DIST)/lib/libnetwork.a \
$(DIST)/lib/libnetcnvts.a \
$(DIST)/lib/libcnetinit.a \
$(DIST)/lib/libabouturl.a \
$(DIST)/lib/libdataurl.a \
$(DIST)/lib/libfileurl.a \
$(DIST)/lib/libftpurl.a \
$(DIST)/lib/libgophurl.a \
$(DIST)/lib/libhttpurl.a \
$(DIST)/lib/libjsurl.a \
$(DIST)/lib/libmarimurl.a \
$(DIST)/lib/libremoturl.a \
$(DIST)/lib/libnetwork.a \
$(DIST)/lib/lib$(LITE_PREFIX)rdf.a \
$(DIST)/lib/lib$(LITE_PREFIX)xml.a \
$(DIST)/lib/lib$(LITE_PREFIX)lay.a \
@@ -254,7 +273,10 @@ BASIC_LIBS += \
$(DIST)/lib/libreg.a \
$(NULL)
BASIC_LIBS_2 = $(DIST)/lib/lib$(LITE_PREFIX)xp.a $(DIST)/lib/libdbm.a
BASIC_LIBS_2 = \
$(DIST)/lib/lib$(LITE_PREFIX)xp.a \
$(DIST)/lib/libdbm.a \
$(NULL)
ifdef MOZ_MAIL_NEWS
BASIC_LIBS += \
@@ -358,6 +380,8 @@ ifdef MOZ_LDAP
BASIC_LIBS += $(DIST)/lib/libldap.a $(DIST)/lib/liblber.a
endif
BASIC_LIBS += $(DIST)/lib/libxpcom.a
LOCALES = $(LOCALE_MAP) $(MAIL_IM_HACK) $(NEWS_IM_HACK)
ALL_EXPORT_LIBS = $(BASIC_LIBS) $(EXPORT_LIB) $(BASIC_LIBS_2) $(NSPR_LIB)
@@ -575,11 +599,19 @@ endif
# Linux
ifeq ($(OS_ARCH),Linux)
# Some linux platforms (there's so many of them) need special defines
# for different versions of motif. Right now the only significant
# define is NS_MOTIF2_XP_LD_FLAGS (-lXp needed for motif 2.x)
# If the motif.mk file exists, it might define extra flags needed for
# specific versions of motif.
#
# Currently there is only 2 flags:
#
# MOZILLA_XM_2_1_PRINT_SHELL_FLAGS: X Print Shell Extension available
# starting with X11R6.3 and needed by motif 2.1.
#
# MOZILLA_XM_2_1_BROKEN_LOCALE_FLAGS: Needed because of currently
# broken locale support in motif 2.1 when linked with gnu libc2.
#
# Please direct questions about motif and linux to ramiro@netscape.com.
#
# The file motif.mk holds such defines.
-include $(DEPTH)/config/motif.mk
XTOOLLIB = -L/usr/X11R6/lib -lXt -lSM -lICE
@@ -593,22 +625,30 @@ else
MOTIFLIB =\
$(MOTIFPATCH_LIB) \
/usr/X11R6/lib/libXm.a \
$(NS_MOTIF2_XP_LD_FLAGS)
$(MOZILLA_XM_2_1_BROKEN_LOCALE_FLAGS) \
-L/usr/X11R6/lib -lXm \
$(MOZILLA_XM_2_1_PRINT_SHELL_FLAGS)
endif
else
MOTIFLIB = /usr/X11R6/lib/libXm.a
endif
OTHER_LIBS = $(MOTIFLIB) $(XTOOLLIB) $(XMULIB) $(EXTENSIONLIB) $(XLIB) /usr/lib/libm.a -ldl
OTHER_LIBS = $(MOTIFLIB) $(XTOOLLIB) $(XMULIB) $(EXTENSIONLIB) $(XLIB) -lm -ldl
#
# This assumes there is a libXm.so on the system. If there isn't, you'll
# get two identical binaries.
#
ifeq ($(OS_RELEASE)$(CPU_ARCH),2.0x86)
DYN_MOTIFLIB = $(MOTIFPATCH_LIB) -lXm $(NS_MOTIF2_XP_LD_FLAGS)
DYN_MOTIFLIB =\
$(MOTIFPATCH_LIB) \
$(MOZILLA_XM_2_1_BROKEN_LOCALE_FLAGS) \
-lXm \
$(MOZILLA_XM_2_1_PRINT_SHELL_FLAGS)
EXTRA_EXPORT_OBJS = $(OBJDIR)/$(XFE_PROGNAME)-motif-export
EXTRA_EXPORT_BINARY = $(EXTRA_EXPORT_OBJS)
@@ -768,15 +808,15 @@ $(MICROLINE_LIB):
$(ICONS_LIB):
cd icons; $(MAKE)
$(COMBOBOX_LIB):
cd combobox; $(MAKE)
$(DTWIDGETS_LIB):
cd DtWidgets; $(MAKE)
$(XFE_WIDGETS_LIB):
cd XfeWidgets/Xfe; $(MAKE)
$(XFE_WIDGETS_BM_LIB):
cd XfeWidgets/XfeBm; $(MAKE)
$(XFE2_LIB):
cd src; $(MAKE)
@@ -909,7 +949,7 @@ ifeq ($(OS_ARCH)$(OS_RELEASE)$(CPU_ARCH),Linux2.0x86)
$(OBJDIR)/$(XFE_PROGNAME)-motif-export: $(OBJS) $(EXPORT_OBJS) $(EXPORT_DEPLIBS)
@$(MAKE_OBJDIR)
rm -f $@
$(CCLD) -o $@ $(LDFLAGS) $(OBJS) $(EXPORT_OBJS) $(BASIC_LIBS) $(EXPORT_LIB) $(BASIC_LIBS_2) -L/usr/X11R6/lib $(DYN_MOTIFLIB) -lXt -lSM -lICE $(XMULIB) $(EXTENSIONLIB) $(XLIB) /usr/lib/libm.a -ldl $(NSPR_LIB) $(DNS_LIB) -lc
$(CCLD) -o $@ $(LDFLAGS) $(OBJS) $(EXPORT_OBJS) $(BASIC_LIBS) $(EXPORT_LIB) $(BASIC_LIBS_2) -L/usr/X11R6/lib $(DYN_MOTIFLIB) -lXt -lSM -lICE $(XMULIB) $(EXTENSIONLIB) $(XLIB) -lm -ldl $(NSPR_LIB) $(DNS_LIB) -lc
@$(EXTRA_POST_LINK_CMD) $@
endif

3284
mozilla/cmd/xfe/icons.c Normal file

File diff suppressed because it is too large Load Diff

5212
mozilla/cmd/xfe/mozilla.c Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,874 @@
/* -*- Mode: C; tab-width: 8; 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.
*/
/*
dialogs.c --- Preference dialogs.
Created: Spence Murray <spence@netscape.com>, 30-Sep-95.
*/
#define PREFS_NET
#define PREFS_SOCKS
#define PREFS_DISK_CACHE
#define PREFS_VERIFY
#define PREFS_CLEAR_CACHE_BUTTONS
#define PREFS_SIG
#define PREFS_NEWS_MAX
#define PREFS_8BIT
/* #define PREFS_EMPTY_TRASH */
/* #define PREFS_QUEUED_DELIVERY */
#include <stdio.h>
#include "mozilla.h"
#include "xlate.h"
#include "xfe.h"
#include "felocale.h"
#include "nslocks.h"
#include "secnav.h"
#include "cert.h"
#include "mozjava.h"
#include "prnetdb.h"
#include "e_kit.h"
#include "pref_helpers.h"
#include "libmocha.h"
#include <Xm/Label.h>
#include <Xm/CascadeBG.h>
#include <Xm/PanedW.h>
#include <Xm/PushB.h>
#include <Xm/ToggleB.h>
#include <Xm/ArrowBG.h>
#ifndef _STDC_
#define _STDC_ 1
#define HACKED_STDC 1
#endif
#include <XmL/Folder.h>
#ifdef HACKED_STDC
#undef HACKED_STDC
#undef _STDC_
#endif
#include "msgcom.h"
#include "libimg.h" /* Image Library public API. */
/* For sys_errlist and sys_nerr */
#include <sys/errno.h>
#if !defined(__FreeBSD__) && !defined(LINUX_GLIBC_2)
extern char *sys_errlist[];
extern int sys_nerr;
#endif
#include "prprf.h"
#include "libi18n.h"
#include "fonts.h"
/* for XP_GetString() */
#include <xpgetstr.h>
extern int XFE_UNKNOWN_ERROR;
extern int XFE_FILE_DOES_NOT_EXIST;
extern int XFE_FTP_PROXY_HOST;
#ifdef MOZ_MAIL_NEWS
extern int XFE_GLOBAL_MAILCAP_FILE;
extern int XFE_GLOBAL_MIME_FILE;
#endif
extern int XFE_GOPHER_PROXY_HOST;
extern int XFE_HOST_IS_UNKNOWN;
extern int XFE_HTTPS_PROXY_HOST;
extern int XFE_HTTP_PROXY_HOST;
extern int XFE_NO_PORT_NUMBER;
#ifdef MOZ_MAIL_NEWS
extern int XFE_MAIL_HOST;
extern int XFE_NEWS_HOST;
extern int XFE_NEWS_RC_DIRECTORY;
extern int XFE_PRIVATE_MAILCAP_FILE;
extern int XFE_PRIVATE_MIME_FILE;
#endif
extern int XFE_SOCKS_HOST;
extern int XFE_TEMP_DIRECTORY;
extern int XFE_WAIS_PROXY_HOST;
extern int XFE_WARNING;
extern int XFE_ERROR_SAVING_OPTIONS;
extern int XFE_GENERAL;
extern int XFE_PASSWORDS;
extern int XFE_PERSONAL_CERTIFICATES;
extern int XFE_SITE_CERTIFICATES;
extern int XFE_APPEARANCE;
extern int XFE_BOOKMARKS;
extern int XFE_COLORS;
extern int XFE_FONTS;
extern int XFE_APPLICATIONS;
extern int XFE_HELPERS;
extern int XFE_IMAGES;
extern int XFE_LANGUAGES;
extern int XFE_CACHE;
extern int XFE_CONNECTIONS;
extern int XFE_PROXIES;
extern int XFE_PROTOCOLS;
extern int XFE_LANG;
extern int XFE_APPEARANCE;
extern int XFE_COMPOSE_DLG;
extern int XFE_SERVERS;
extern int XFE_IDENTITY;
extern int XFE_ORGANIZATION;
extern int XFE_CHANGE_PASSWORD;
extern int XFE_SET_PASSWORD;
#ifdef MOZ_MAIL_NEWS
extern int XFE_PRIVATE_MIMETYPE_RELOAD;
extern int XFE_PRIVATE_MAILCAP_RELOAD;
extern int XFE_PRIVATE_RELOADED_MIMETYPE;
extern int XFE_PRIVATE_RELOADED_MAILCAP;
#endif
extern void fe_installGeneralAppearance(void);
extern void fe_installGeneralFonts(void);
extern void fe_installGeneralColors(void);
extern void fe_installGeneralAdvanced(void);
extern void fe_installGeneralPasswd(void);
extern void fe_installGeneralCache(void);
extern void fe_installGeneralProxies(void);
extern void fe_installBrowser(void);
extern void fe_installBrowserAppl(void);
#ifdef MOZ_MAIL_NEWS
extern void fe_installMailNews(void);
extern void fe_installMailNewsIdentity(void);
extern void fe_installMailNewsComposition(void);
extern void fe_installMailNewsMserver(void);
extern void fe_installMailNewsNserver(void);
extern void fe_installMailNewsAddrBook(void);
extern void fe_installOfflineNews(void);
extern void fe_installMserverMore(void);
#endif
extern void fe_installProxiesView(void);
extern void fe_installDiskMore(void);
extern void fe_installSslConfig(void);
extern void fe_installOffline(void);
extern void fe_installDiskSpace(void);
/* Preferences
*/
struct fe_prefs_data
{
MWContext *context;
Widget shell, form;
Widget promptDialog;
/*=== General prefs folder ===*/
Widget general_form;
/* Appearance page */
Widget styles1_selector, styles1_page;
Widget icons_p, text_p, both_p, tips_p;
Widget browser_p, mail_p, news_p;
Widget blank_p, home_p, home_text;
Widget underline_p;
Widget expire_days_p, expire_days_text, never_expire_p;
/* Applications page */
Widget apps_selector, apps_page;
Widget tmp_text;
Widget telnet_text, tn3270_text, rlogin_text, rlogin_user_text;
#if 0
/* Bookmarks page */
Widget bookmarks_selector, bookmarks_page;
Widget book_text;
#endif
/* Colors page */
Widget colors_selector, colors_page;
/* Fonts page */
Widget fonts_selector, fonts_page;
Widget prop_family_pulldown, fixed_family_pulldown;
Widget prop_family_option, fixed_family_option;
Widget prop_size_pulldown, fixed_size_pulldown;
Widget prop_size_option, fixed_size_option;
Widget prop_size_field, fixed_size_field;
Widget prop_size_toggle, fixed_size_toggle;
int fonts_changed;
/* Helpers page */
Widget helpers_selector, helpers_page;
int helpers_changed;
struct fe_prefs_helpers_data *helpers;
/* Images page */
Widget images_selector, images_page;
Widget auto_p, dither_p, closest_p;
Widget while_loading_p, after_loading_p;
/* Languages page */
Widget languages_selector, languages_page;
Widget lang_reg_avail, lang_reg_pref, lang_reg_text;
Widget tmpDefaultButton;
/*=== Mail/News prefs folder ===*/
Widget mailnews_form;
/* Appearance page */
Widget appearance_selector, appearance_page;
Widget fixed_message_font_p, var_message_font_p;
Widget cite_plain_p, cite_bold_p, cite_italic_p, cite_bold_italic_p;
Widget cite_normal_p, cite_bigger_p, cite_smaller_p;
Widget cite_color_text;
Widget mail_horiz_p, mail_vert_p, mail_stack_p;
Widget news_horiz_p, news_vert_p, news_stack_p;
Widget msgwin_use_mailwin_p, msgwin_use_new_p, msgwin_use_existing_p;
/* Compose page */
Widget compose_selector, compose_page;
Widget eightbit_toggle, qp_toggle;
Widget deliverAuto_toggle, deliverQ_toggle;
Widget mMailOutSelf_toggle, mMailOutOther_text;
Widget nMailOutSelf_toggle, nMailOutOther_text;
Widget mCopyOut_text;
Widget nCopyOut_text;
Widget autoquote_toggle;
/* Servers page */
Widget dirs_selector, dirs_page;
Widget srvr_text, user_text;
Widget pop_toggle;
Widget movemail_text;
Widget external_toggle, builtin_toggle;
Widget no_limit, msg_limit, limit_text;
Widget msg_remove, msg_leave;
Widget check_every, check_never, check_text;
Widget smtp_text, maildir_text;
Widget newshost_text, newsrc_text, newsmax_text;
/* Identity page */
Widget identity_selector, identity_page;
Widget user_name_text, user_mail_text, user_org_text, user_sig_text;
/* Organization page */
Widget organization_selector, organization_page;
Widget emptyTrash_toggle, rememberPswd_toggle;
Widget threadmail_toggle, threadnews_toggle;
Widget mdate_toggle, mnum_toggle, msubject_toggle, msender_toggle;
Widget ndate_toggle, nnum_toggle, nsubject_toggle, nsender_toggle;
/*=== Network prefs folder ===*/
Widget network_form;
/* Cache page */
Widget cache_selector, cache_page;
Widget memory_text, memory_clear;
Widget disk_text, disk_dir, disk_clear;
Widget verify_label, once_p, every_p, expired_p;
Widget cache_ssl_p;
/* Nework page */
Widget network_selector, network_page;
Widget buf_label, buf_text;
Widget conn_label, conn_text;
/* Proxies page */
Widget proxies_selector, proxies_page;
Widget no_proxies_p, manual_p, manual_browse;
Widget auto_proxies_p, proxy_label, proxy_text;
Widget proxy_reload;
Widget ftp_text, ftp_port;
Widget gopher_text, gopher_port;
Widget http_text, http_port;
Widget https_text, https_port;
Widget wais_text, wais_port;
Widget no_text;
Widget socks_text, socks_port;
/* Protocols page */
Widget protocols_selector, protocols_page;
Widget cookie_p; /* Show alert before accepting a cookie */
Widget anon_ftp_p; /* Use email address for anon ftp */
Widget email_form_p; /* Show alert before submiting a form by email */
/* Languages page */
Widget lang_selector, lang_page;
#ifdef JAVA
Widget java_toggle;
#endif
Widget javascript_toggle;
/*=== Security prefs folder ===*/
Widget security_form;
/* General Security page */
Widget sec_general_selector, sec_general_page;
Widget enter_toggle, leave_toggle, mixed_toggle, submit_toggle;
Widget ssl2_toggle, ssl3_toggle;
/* Security Passwords page */
Widget sec_passwords_selector, sec_passwords_page;
Widget once_toggle, every_toggle, periodic_toggle;
Widget periodic_text, change_password;
#ifdef FORTEZZA
Widget fortezza_toggle, fortezza_timeout;
#endif
/* Personal Certificates page */
Widget personal_selector, personal_page;
Widget pers_list, pers_info, pers_delete_cert, pers_new_cert;
Widget site_default, pers_label;
Widget pers_cert_menu;
char *deleted_user_cert;
/* Site Certificates page */
Widget site_selector, site_page;
Widget all_list, all_edit_cert, all_delete_cert;
Widget all_label;
char *deleted_site_cert;
};
void
FE_SetPasswordAskPrefs(MWContext *context, int askPW, int timeout)
{
}
void
FE_SetPasswordEnabled(MWContext *context, PRBool usePW)
{
}
void
fe_MarkHelpersModified(MWContext *context)
{
/* Mark that the helpers have been modified. We need this
* to detect if we need to save/reload all these helpers.
* For doing this, the condition we adopt is
* (1) User clicked on 'OK' button for the Edit Helpers Dialog
* This also covers the "New" case as the same Dialog
* is shown for the "New" and "Edit".
* (2) User deleted a mime/type and confirmed it.
*/
if (context && CONTEXT_DATA(context)->fep)
CONTEXT_DATA(context)->fep->helpers_changed = TRUE;
}
const char *multiline_continuator = "\t\t\n";
/*
* This belongs in a utility module
*
* Convert an array of strings
* to multiline string (embedded new-lines)
*
* returns a string built up from the array
*
* The caller must free the array
*/
char *
array_to_multiline_str(char **array, int cnt)
{
char *mstring, *p;
int i, str_len;
/*
* Handle an empty array
*/
if (cnt == 0) {
/* always allocate an array so the caller can free it */
mstring = strdup("\n");
return mstring;
}
/*
* Get the length of the multiline string
*/
str_len = 0;
for (i=0; i<cnt; i++) {
if (i != 0)
str_len += strlen(multiline_continuator);
str_len += strlen(array[i]);
}
str_len += 2; /* space for new-line and terminator */
mstring = (char *)XP_ALLOC(str_len);
for (p=mstring, i=0; i<cnt; i++) {
if (i != 0) {
strcpy(p, multiline_continuator);
p += strlen(multiline_continuator);
}
strcpy(p, array[i]);
p += strlen(array[i]);
}
/*
* Note: don't add a final line-feed for multiline
* as the prefs_write_string() function handles it funny
*/
return mstring;
}
/*
* This belongs in a utility module
*
* Convert an array of strings
* to multiline preference (embedded new-lines)
*
* returns a preference value string built up from the array
*
* The caller must free the array
*/
char *
array_to_multiline_pref(char **array, int cnt)
{
char *string;
string = array_to_multiline_str(array, cnt);
return string;
}
/*
* This belongs in a utility module
*
* Convert a multiline string (embedded new-lines)
* to an array of strings
* create the array
* copies the lines into the array
* returns length of the array
*
* To free the array:
* for (i=0; i<cnt; i++)
* XP_FREE(array[i]);
* XP_FREE(array);
*/
int
multiline_str_to_array(const char *string, char ***array_p)
{
char *p, *q, **array;
int i, cnt, len;
Boolean at_start_of_line;
/* handle null string */
if (string == NULL) {
/* always allocate an array so the caller can free it */
array = (char **)XP_ALLOC(sizeof(char *));
array[0] = NULL;
*array_p = array;
return 0;
}
/*
* count the number of lines
* (count beginnings so we will count any last line without a '\n')
* This supports multibyte text only because '\n' is less than 0x40
*/
cnt = 0;
at_start_of_line = True;
for (p=(char *)string; *p; p++) {
if (at_start_of_line) {
cnt += 1;
at_start_of_line = False;
}
if (*p == '\n') {
at_start_of_line = True;
}
}
/* copy lines into the array */
array = (char **)XP_ALLOC((cnt+1) * sizeof(char *));
i = 0;
len = 0;
for (p=q=(char *)string; *p; p++) {
if (*p == '\n') {
array[i] = (char *)XP_ALLOC(len+1);
strncpy(array[i], q, len);
/* add a string terminator */
array[i][len] = '\0';
i += 1;
len = 0;
q = p + 1;
}
else
len += 1;
}
if (len) { /* include ending chars with no newline */
array[i] = (char *)XP_ALLOC(len+1);
strncpy(array[i], q, len);
/* add a string terminator */
array[i][len] = '\0';
}
*array_p = array;
return cnt;
}
/*
* This belongs in a utility module
*
* Convert a multiline preference (embedded new-lines)
* to an array of strings
* create the array
* copies the lines into the array
* remove leading/trailing white space
* remove blank lines
* returns length of the array
*
* To free the array:
* for (i=0; i<cnt; i++)
* XP_FREE(array[i]);
* XP_FREE(array);
*/
int
multiline_pref_to_array(const char *string, char ***array_p)
{
int i, j, cnt;
char **array;
/*
* Convert the multiline string to an array
* (with leading/trailing white space and blank lines)
*/
cnt = multiline_str_to_array(string, array_p);
/*
* trim any leading/training white space
*/
array = *array_p;
for (i=0; i<cnt; i++) {
char *tmp;
tmp = XP_StripLine(array[i]);
/* we can't lose the malloc address else free will fail */
/* so if there was white space at the beginning we make a copy */
if (tmp != array[i]) {
char *tmp2 = array[i];
array[i] = strdup(tmp);
XP_FREE(tmp2);
}
}
/*
* remove any blank lines
*/
for (i=0; i<cnt; i++) {
if (array[i][0] == '\0') {
XP_FREE(array[i]);
for (j=i+1; j<cnt; j++)
array[j-1] = array[j];
cnt -= 1;
}
}
return cnt;
}
IL_DitherMode
fe_pref_string_to_dither_mode (char *s)
{
if (!XP_STRCASECMP(s, "True") || !XP_STRCASECMP(s, "Dither"))
return IL_Dither;
else if (!XP_STRCASECMP(s, "False") || !XP_STRCASECMP(s, "ClosestColor"))
return IL_ClosestColor;
/* In the absence of a reasonable value, dithering is auto-selected */
return IL_Auto;
}
#ifdef MOZ_MAIL_NEWS
void
fe_SetMailNewsSortBehavior(MWContext* context, XP_Bool thread, int sortcode)
{
XP_ASSERT(context->type == MWContextMail || context->type == MWContextNews);
if (context->type == MWContextMail || context->type == MWContextNews) {
if (thread) {
MSG_SetToggleStatus(ACTIVE_MAILTAB(context)->threadpane, MSG_SortByThread, NULL, 0,
thread ? MSG_Checked : MSG_Unchecked);
} else {
switch (sortcode) {
case 0:
MSG_Command(ACTIVE_MAILTAB(context)->threadpane, MSG_SortByDate, NULL, 0);
break;
case 1:
MSG_Command(ACTIVE_MAILTAB(context)->threadpane, MSG_SortByMessageNumber, NULL, 0);
break;
case 2:
MSG_Command(ACTIVE_MAILTAB(context)->threadpane, MSG_SortBySubject, NULL, 0);
break;
case 3:
MSG_Command(ACTIVE_MAILTAB(context)->threadpane, MSG_SortBySender, NULL, 0);
break;
}
}
}
}
#endif
void
fe_InstallPreferences (MWContext *context)
{
/* This function is called from main() */
fe_installGeneralAppearance();
fe_installGeneralFonts();
fe_installGeneralColors();
fe_installGeneralAdvanced();
fe_installGeneralPasswd();
fe_installGeneralCache();
fe_installGeneralProxies();
fe_installDiskSpace();
fe_installBrowser();
fe_installBrowserAppl();
#ifdef MOZ_MAIL_NEWS
fe_installMailNews();
fe_installMailNewsIdentity();
fe_installMailNewsComposition();
fe_installMailNewsMserver();
fe_installMailNewsNserver();
fe_installMailNewsAddrBook();
#endif
fe_installOffline();
#ifdef MOZ_MAIL_NEWS
fe_installOfflineNews();
fe_installMserverMore();
#endif
fe_installProxiesView();
fe_installSslConfig();
fe_installDiskMore();
/* CACHE
*/
/* spider begin */
FE_SARCacheDir = fe_globalPrefs.sar_cache_dir ;
/* spider end */
NET_DontDiskCacheSSL(!fe_globalPrefs.cache_ssl_p);
/* bookmark_file
*/
FE_GlobalHist = fe_globalPrefs.history_file;
/* NETWORK
*/
NET_ChangeMaxNumberOfConnections (50);
NET_ChangeMaxNumberOfConnectionsPerContext (fe_globalPrefs.max_connections);
/* The unit for tcp buffer size is changed from kbyes to btyes */
NET_ChangeSocketBufferSize (fe_globalPrefs.network_buffer_size);
/* NEWS
*/
#ifdef MOZ_MAIL_NEWS
NET_SetNumberOfNewsArticlesInListing (fe_globalPrefs.news_max_articles);
NET_SetCacheXOVER (fe_globalPrefs.news_cache_xover);
#endif
/* PROTOCOLS
*/
#ifdef MOZ_MAIL_NEWS
NET_WarnOnMailtoPost(fe_globalPrefs.email_submit);
#endif
#ifdef FORTEZZA
if (fe_globalPrefs.fortezza_toggle) {
int timeout = fe_globalPrefs.fortezza_timeout;
/* '0' minute timeout because 1 minute... still pretty darn fast */
FortezzaSetTimeout(timeout ? timeout : 1);
} else {
FortezzaSetTimeout(0);
}
#endif
}
void
fe_GeneralPrefsDialog (MWContext *context)
{
}
void
fe_MailNewsPrefsDialog (MWContext *context)
{
}
void
fe_NetworkPrefsDialog (MWContext *context)
{
}
void
fe_SecurityPrefsDialog (MWContext *context)
{
}
/* spider begin */
void
fe_VerifyDiskCache (MWContext *context)
{
#ifdef PREFS_DISK_CACHE
static Boolean done = False;
if (done) return;
done = True;
if (fe_globalPrefs.disk_cache_size <= 0)
return;
fe_VerifyDiskCacheExistence(context, fe_globalPrefs.cache_dir) ;
#endif /* PREFS_DISK_CACHE */
#ifdef PREFS_OLD_WAY
#ifdef PREFS_DISK_CACHE
struct stat st;
char file [1024];
char message [4000];
static Boolean done = False;
if (done) return;
done = True;
if (fe_globalPrefs.disk_cache_size <= 0)
return;
strcpy (file, fe_globalPrefs.cache_dir);
if (file [strlen (file) - 1] == '/')
file [strlen (file) - 1] = 0;
if (stat (file, &st))
{
/* Doesn't exist - try to create it. */
if (mkdir (file, 0700))
{
/* Failed. */
char *error = ((errno >= 0 && errno < sys_nerr)
? sys_errlist [errno]
: XP_GetString( XFE_UNKNOWN_ERROR));
PR_snprintf (message, sizeof (message),
fe_globalData.create_cache_dir_message,
file, error);
}
else
{
/* Suceeded. */
PR_snprintf (message, sizeof (message),
fe_globalData.created_cache_dir_message, file);
}
}
else if (! (st.st_mode & S_IFDIR))
{
/* Exists but isn't a directory. */
PR_snprintf (message, sizeof (message),
fe_globalData.cache_not_dir_message, file);
}
else
{
/* The disk cache is ok! */
*message = 0;
}
if (*message)
{
PR_snprintf(message + strlen (message), sizeof (message),
fe_globalData.cache_suffix_message,
fe_globalPrefs.disk_cache_size, fe_progclass);
FE_Alert (context, message);
}
#endif /* PREFS_DISK_CACHE */
#endif /* PREFS_OLD_WAY */
}
void
fe_VerifySARDiskCache (MWContext *context)
{
#ifdef PREFS_DISK_CACHE
fe_VerifyDiskCacheExistence(context, fe_globalPrefs.sar_cache_dir) ;
#endif /* PREFS_DISK_CACHE */
}
void
fe_VerifyDiskCacheExistence (MWContext *context, char * cache_directory)
{
#ifdef PREFS_DISK_CACHE
struct stat st;
char file [1024];
char message [4000];
if (!cache_directory)
return ;
strcpy (file, cache_directory);
if (file [strlen (file) - 1] == '/')
file [strlen (file) - 1] = 0;
if (stat (file, &st))
{
/* Doesn't exist - try to create it. */
if (mkdir (file, 0700))
{
/* Failed. */
char *error = ((errno >= 0 && errno < sys_nerr)
? sys_errlist [errno]
: XP_GetString( XFE_UNKNOWN_ERROR));
PR_snprintf (message, sizeof (message),
fe_globalData.create_cache_dir_message,
file, error);
}
else
{
/* Suceeded. */
PR_snprintf (message, sizeof (message),
fe_globalData.created_cache_dir_message, file);
}
}
else if (! (st.st_mode & S_IFDIR))
{
/* Exists but isn't a directory. */
PR_snprintf (message, sizeof (message),
fe_globalData.cache_not_dir_message, file);
}
else
{
/* The disk cache is ok! */
*message = 0;
}
if (*message)
{
PR_snprintf(message + strlen (message), sizeof (message),
fe_globalData.cache_suffix_message,
fe_globalPrefs.disk_cache_size, fe_progclass);
FE_Alert (context, message);
}
#endif /* PREFS_DISK_CACHE */
}
/* spider end */

2104
mozilla/include/net.h Normal file

File diff suppressed because it is too large Load Diff

129
mozilla/include/shistele.h Normal file
View File

@@ -0,0 +1,129 @@
/* -*- 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.
*/
#ifndef SHISTELE_H
#define SHISTELE_H
#include "xp_list.h"
/*
** This structure holds pointer so all saved data in the history. It is
** also used by URL_Structs and is ultimately fed to layout.
**
** Warning: Don't change the names of the fields because they're used by
** macros.
*/
typedef struct SHIST_SavedData {
void* FormList; /* layout data to recreate forms */
void* EmbedList; /* layout data to recreate embeds and applets */
void* Grid; /* layout data to recreate grids */
#ifdef MOCHA
void* Window; /* window object for grid being resized */
/* XXX none of this would be necessary if frameset docs were reparsed */
void* OnLoad; /* JavaScript onload event handler source */
void* OnUnload; /* JavaScript onunload event handler source */
void* OnFocus; /* JavaScript onfocus event handler source */
void* OnBlur; /* JavaScript onblur event handler source */
void* OnHelp; /* JavaScript onhelp event handler source */
void* OnMouseOver; /* JavaScript onmouseover event handler source */
void* OnMouseOut; /* JavaScript onmouseout event handler source */
void* OnDragDrop; /* JavaScript ondragdrop event handler source */
void* OnMove; /* JavaScript onmove event handler source */
void* OnResize; /* JavaScript onresize event handler source */
void* style_stack; /* JSSS style stack info */
#endif
} SHIST_SavedData;
/*
This structure encapsulates all of the information needed for the
session history. It should contain stuff like a list of all of the
documents in the current history and a pointer to where the currently
viewed document sits in the chain.
WARNING!! Some slots of this structure are shared with URL_Struct and
net_CacheObject. If you add a slot, decide whether it needs to be
shared as well.
*/
struct _History_entry {
char * title; /* title for this entry */
char * address; /* URL address string */
char * content_name; /* Server-provided "real name", used for
default file name when saving. */
int method; /* method of acessing URL */
char * referer; /* What document points to this url */
char * post_data; /* post data */
int32 post_data_size; /* post data size */
Bool post_data_is_file; /* is the post data a filename? */
char * post_headers; /* content type for posted data */
int32 position_tag; /* layout specific data for determining
* where in the document the user was
*/
time_t last_modified; /* time of last modification */
time_t last_access; /* time of last access */
int history_num; /* special hack to add navigation */
SHIST_SavedData savedData; /* layout data */
PRPackedBool
is_binary, /* is this a binary object pretending
* to be HTML?
*/
is_active, /* is it an active stream? */
is_netsite, /* did it come from netsite? */
replace; /* did it come from netsite? */
int transport_method; /* network, disk cache, memory cache */
uint32 refresh; /* refresh interval */
char *refresh_url; /* URL to refresh */
char *wysiwyg_url; /* URL for WYSIWYG printing/saving */
/* Security information */
int security_on; /* is security on? */
/* Security info on a connection is opaque */
unsigned char *sec_info;
/* Unique identifier */
int32 unique_id;
int32 ref_count;
/* Page services*/
char *page_services_url; /* If it supports services, what link is used */
/* HTTP_11 support*/
char *etag; /* Unique entity tag */
char *origin_url; /* original referrer of javascript: URL */
};
#define SHIST_CAME_FROM_NETWORK 0
#define SHIST_CAME_FROM_DISK_CACHE 1
#define SHIST_CAME_FROM_MEMORY_CACHE 2
struct History_ {
XP_List * list_ptr; /* pointer to linked list */
int cur_doc; /* an index into the list that points to the current document */
History_entry *cur_doc_ptr; /* a ptr to the current doc entry */
int32 num_entries; /* size of the history list */
int32 max_entries; /* maximum size of list; -1 == no limit */
};
#endif /* SHISTELE_H */

1107
mozilla/lib/libmisc/shist.c Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,880 @@
/* -*- 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.
*/
/* Please leave outside of ifdef for window precompiled headers */
#include "mkutils.h"
#ifdef MOZILLA_CLIENT
/* Publicly released Netscape cache access routines.
*
* These routines are shared between the netscape executable
* and the programs released as a cache developers kit.
*
* Created: Lou Montulli <montulli@netscape.com>, July-95.
* Modifications/Addition: Gagan Saksena, 97
*/
#ifndef EXT_DB_ROUTINES
#include "secnav.h"
#include "sechash.h"
#endif
#include "extcache.h" /* include this for everything */
#ifdef EXT_DB_ROUTINES
#include <fcntl.h>
#include <sys/stat.h>
#include <assert.h>
typedef struct {
int32 len;
char *data;
} SECItem;
#ifdef _sgi
#include <sys/endian.h>
#endif /* _sgi */
/* URL methods
*/
#define URL_GET_METHOD 0
#define URL_POST_METHOD 1
#define URL_HEAD_METHOD 2
#endif /* DB_STORE */
MODULE_PRIVATE DBT *
net_CacheDBTDup(DBT *obj)
{
DBT * rv = XP_NEW(DBT);
if(!rv)
return(NULL);
rv->size = obj->size;
rv->data = XP_ALLOC(rv->size);
if(!rv->data)
{
FREE(rv);
return(NULL);
}
XP_MEMCPY(rv->data, obj->data, rv->size);
return(rv);
}
/* free the cache object
*/
MODULE_PRIVATE void net_freeCacheObj (net_CacheObject * cache_obj)
{
FREEIF(cache_obj->address);
FREEIF(cache_obj->post_data);
FREEIF(cache_obj->post_headers);
FREEIF(cache_obj->content_type);
FREEIF(cache_obj->charset);
FREEIF(cache_obj->content_encoding);
FREEIF(cache_obj->page_services_url);
FREEIF(cache_obj->filename);
#ifndef EXT_DB_ROUTINES
FREEIF(cache_obj->sec_info);
#endif
FREE(cache_obj);
}
/* returns true if this DBT looks like a valid
* entry. It looks at the checksum and the
* version number to see if it's valid
*/
#define MAX_VALID_DBT_SIZE 10000
MODULE_PRIVATE Bool
net_IsValidCacheDBT(DBT *obj)
{
char *cur_ptr, *max_ptr;
uint32 len;
if(!obj || obj->size < 9 || obj->size > MAX_VALID_DBT_SIZE)
return(FALSE);
cur_ptr = (char *)obj->data;
max_ptr = cur_ptr+obj->size;
/* get the total size of the struct out of
* the first field to check it
*/
COPY_INT32(&len, cur_ptr);
cur_ptr += sizeof(int32);
if(len != obj->size)
{
TRACEMSG(("Size going in is not the same as size coming out"));
return(FALSE);
}
/* get the version number of the written structure
*/
if(cur_ptr > max_ptr)
return(FALSE);
COPY_INT32(&len, cur_ptr);
cur_ptr += sizeof(int32);
if(len != CACHE_FORMAT_VERSION)
{
TRACEMSG(("Version of cache structure is wrong!: %d", len));
return(FALSE);
}
/* looks good to me... */
return(TRUE);
}
/* takes a cache object and returns a malloc'd
* (void *) suitible for passing in as a database
* data storage object
*/
MODULE_PRIVATE DBT *
net_CacheStructToDBData(net_CacheObject * old_obj)
{
int32 len;
char *cur_ptr;
void *new_obj;
int32 total_size;
DBT *rv;
rv = XP_NEW(DBT);
if(!rv)
return(NULL);
total_size = sizeof(net_CacheObject);
#define ADD_STRING_SIZE(string) \
total_size += old_obj->string ? XP_STRLEN(old_obj->string)+1 : 0
ADD_STRING_SIZE(address);
total_size += old_obj->post_data_size+1;
ADD_STRING_SIZE(post_headers);
ADD_STRING_SIZE(content_type);
ADD_STRING_SIZE(content_encoding);
ADD_STRING_SIZE(charset);
ADD_STRING_SIZE(filename);
total_size += sizeof(uint32); /* size of secinfo */
total_size += SECNAV_SSLSocketStatusLength(old_obj->sec_info);
ADD_STRING_SIZE(page_services_url);
#undef ADD_STRING_SIZE
new_obj = XP_ALLOC(total_size * sizeof(char));
if(!new_obj)
{
FREE(rv);
return NULL;
}
XP_MEMSET(new_obj, 0, total_size * sizeof(char));
/*
* order is:
* int32 size of the entire structure;
*
* int32 version of the structure format (CACHE_FORMAT_VERSION)
*
* time_t last_modified;
* time_t last_accessed;
* time_t expires;
* uint32 content_length;
* Bool is_netsite;
*
* time_t lock_date;
*
* char * filename;
* int32 filename_len;
*
* int32 security_on;
* unsigned char * sec_info;
*
* int32 method;
*
* # don't store address, or post_data stuff
* # char * address;
* # uint32 post_data_size;
* # char * post_data;
*
* char * post_headers;
* char * content_type;
* char * content_encoding;
* char * charset;
*
* Bool incomplete_file;
* uint32 total_content_length;
*
* char * page_services_url;
*
* string lengths all include null terminators
* all integer constants are stored as 4 bytes
* all booleans are stored as one byte
*/
/* VERY VERY IMPORTANT. Whenever the
* format of the record structure changes
* you must verify that the byte positions
* in extcache.h are updated
*/
#define STUFF_STRING(string) \
{ \
len = (old_obj->string ? XP_STRLEN(old_obj->string)+1 : 0); \
COPY_INT32((void *)cur_ptr, &len); \
cur_ptr = cur_ptr + sizeof(int32); \
if(len) \
XP_MEMCPY((void *)cur_ptr, old_obj->string, len); \
cur_ptr += len; \
}
#define STUFF_NUMBER(number) \
{ \
COPY_INT32((void *)cur_ptr, &old_obj->number); \
cur_ptr = cur_ptr + sizeof(int32); \
}
#define STUFF_TIMET(number) \
{ \
COPY_INT32((void *)cur_ptr, &old_obj->number); \
cur_ptr = cur_ptr + sizeof(time_t); \
}
#define STUFF_BOOL(bool_val) \
{ \
if(old_obj->bool_val) \
((char *)(cur_ptr))[0] = 1; \
else \
((char *)(cur_ptr))[0] = 0; \
cur_ptr = cur_ptr + sizeof(char); \
}
cur_ptr = (char *)new_obj;
/* put the total size of the struct into
* the first field so that we have
* a cross check against corruption
*/
COPY_INT32((void *)cur_ptr, &total_size);
cur_ptr = cur_ptr + sizeof(int32);
/* put the version number of the structure
* format that we are using
* By using a version string when writting
* we can support backwards compatibility
* in our reading code
* (use "len" as a temp variable)
*/
len = CACHE_FORMAT_VERSION;
COPY_INT32((void *)cur_ptr, &len);
cur_ptr = cur_ptr + sizeof(int32);
STUFF_TIMET(last_modified);
STUFF_TIMET(last_accessed);
STUFF_TIMET(expires);
STUFF_NUMBER(content_length);
STUFF_BOOL(is_netsite);
STUFF_TIMET(lock_date);
STUFF_STRING(filename);
STUFF_NUMBER(filename_len);
STUFF_BOOL(is_relative_path);
STUFF_NUMBER(security_on);
#ifndef EXT_DB_ROUTINES
/* save the security info */
if ( old_obj->sec_info ) {
len = SECNAV_SSLSocketStatusLength(old_obj->sec_info);
COPY_INT32((void *)cur_ptr, &len);
cur_ptr = cur_ptr + sizeof(int32);
XP_MEMCPY((void *)cur_ptr, old_obj->sec_info, len);
cur_ptr += len;
} else
#endif
{
len = 0;
COPY_INT32((void *)cur_ptr, &len);
cur_ptr = cur_ptr + sizeof(int32);
}
STUFF_NUMBER(method);
#ifdef STORE_ADDRESS_AND_POST_DATA
STUFF_STRING(address);
STUFF_NUMBER(post_data_size);
/* post_data
* this is special since it not necessarily a string
*/
if(old_obj->post_data_size)
{
XP_MEMCPY(cur_ptr, old_obj->post_data, old_obj->post_data_size+1);
cur_ptr += old_obj->post_data_size+1;
}
#endif /* STORE_ADDRESS_AND_POST_DATA */
STUFF_STRING(post_headers);
STUFF_STRING(content_type);
STUFF_STRING(content_encoding);
STUFF_STRING(charset);
STUFF_BOOL(incomplete_file);
STUFF_NUMBER(real_content_length);
STUFF_STRING(page_services_url);
#undef STUFF_STRING
#undef STUFF_NUMBER
#undef STUFF_BOOL
rv->data = new_obj;
rv->size = total_size;
return(rv);
}
/* takes a database storage object and returns a malloc'd
* cache data object. The cache object needs all of
* it's parts free'd.
*
* returns NULL on parse error
*/
MODULE_PRIVATE net_CacheObject *
net_DBDataToCacheStruct(DBT * db_obj)
{
net_CacheObject * rv = XP_NEW(net_CacheObject);
char * cur_ptr;
char * max_ptr;
uint32 len;
int32 version;
if(!rv)
return NULL;
XP_MEMSET(rv, 0, sizeof(net_CacheObject));
/* if any strings are larger than this then
* there was a serious database error
*/
#define MAX_HUGE_STRING_SIZE 10000
#define RETRIEVE_STRING(string) \
{ \
if(cur_ptr > max_ptr) \
{ \
net_freeCacheObj(rv); \
return(NULL); \
} \
COPY_INT32(&len, cur_ptr); \
cur_ptr += sizeof(int32); \
if(len) \
{ \
if(len > MAX_HUGE_STRING_SIZE) \
{ \
net_freeCacheObj(rv); \
return(NULL); \
} \
rv->string = (char*)XP_ALLOC(len); \
if(!rv->string) \
{ \
net_freeCacheObj(rv); \
return(NULL); \
} \
XP_MEMCPY(rv->string, cur_ptr, len); \
cur_ptr += len; \
} \
}
#define RETRIEVE_NUMBER(number) \
{ \
if(cur_ptr > max_ptr) \
return(rv); \
COPY_INT32(&rv->number, cur_ptr); \
cur_ptr += sizeof(int32); \
}
#define RETRIEVE_TIMET(number) \
{ \
if(cur_ptr > max_ptr) \
return(rv); \
COPY_INT32(&rv->number, cur_ptr); \
cur_ptr += sizeof(time_t); \
}
#define RETRIEVE_BOOL(bool) \
{ \
if(cur_ptr > max_ptr) \
return(rv); \
if(((char *)(cur_ptr))[0]) \
rv->bool = TRUE; \
else \
rv->bool = FALSE; \
cur_ptr += sizeof(char); \
}
cur_ptr = (char *)db_obj->data;
max_ptr = cur_ptr+db_obj->size;
/* get the total size of the struct out of
* the first field to check it
*/
COPY_INT32(&len, cur_ptr);
cur_ptr += sizeof(int32);
if(len != db_obj->size)
{
TRACEMSG(("Size going in is not the same as size coming out"));
FREE(rv);
return(NULL);
}
/* get the version number of the written structure
*/
if(cur_ptr > max_ptr)
return(rv);
COPY_INT32(&version, cur_ptr);
cur_ptr += sizeof(int32);
if(version != CACHE_FORMAT_VERSION)
{
TRACEMSG(("Version of cache structure is wrong!: %d", version));
FREE(rv);
return(NULL);
}
RETRIEVE_TIMET(last_modified);
RETRIEVE_TIMET(last_accessed);
RETRIEVE_TIMET(expires);
RETRIEVE_NUMBER(content_length);
RETRIEVE_BOOL(is_netsite);
RETRIEVE_TIMET(lock_date);
RETRIEVE_STRING(filename);
RETRIEVE_NUMBER(filename_len);
RETRIEVE_BOOL(is_relative_path);
RETRIEVE_NUMBER(security_on);
/* security info */
if(cur_ptr > max_ptr)
return(rv);
COPY_INT32(&len, cur_ptr);
cur_ptr += sizeof(int32);
if ( len == 0 ) {
rv->sec_info = NULL;
} else {
rv->sec_info = XP_ALLOC(len);
if ( rv->sec_info == NULL ) {
return(rv);
}
XP_MEMCPY(rv->sec_info, cur_ptr, len);
cur_ptr += len;
}
RETRIEVE_NUMBER(method);
#ifdef STORE_ADDRESS_AND_POST_DATA
RETRIEVE_STRING(address);
RETRIEVE_NUMBER(post_data_size);
/* post_data
* this is special since it not necessarily a string
*/
if(rv->post_data_size)
{
rv->post_data = XP_ALLOC(rv->post_data_size+1);
if(rv->post_data)
XP_MEMCPY(rv->post_data, cur_ptr, rv->post_data_size+1);
cur_ptr += rv->post_data_size+1;
}
#endif /* STORE_ADDRESS_AND_POST_DATA */
RETRIEVE_STRING(post_headers);
RETRIEVE_STRING(content_type);
RETRIEVE_STRING(content_encoding);
RETRIEVE_STRING(charset);
RETRIEVE_BOOL(incomplete_file);
RETRIEVE_NUMBER(real_content_length);
RETRIEVE_STRING(page_services_url);
#undef RETRIEVE_STRING
#undef RETRIEVE_NUMBER
#undef RETRIEVE_BOOL
return(rv);
}
#if defined(DEBUG) && defined(UNIX)
int
cache_test_me()
{
net_CacheObject test;
net_CacheObject *rv;
int32 total_size;
DBT *db_obj;
XP_MEMSET(&test, 0, sizeof(net_CacheObject));
StrAllocCopy(test.address, "test1");
db_obj = net_CacheStructToDBData(&test);
rv = net_DBDataToCacheStruct(db_obj);
printf("test1: %s\n", rv->address);
XP_MEMSET(&test, 0, sizeof(net_CacheObject));
StrAllocCopy(test.address, "test2");
StrAllocCopy(test.charset, "test2");
db_obj = net_CacheStructToDBData(&test);
rv = net_DBDataToCacheStruct(db_obj);
printf("test2: %s %s\n", rv->address, rv->charset);
XP_MEMSET(&test, 0, sizeof(net_CacheObject));
StrAllocCopy(test.address, "test3");
StrAllocCopy(test.charset, "test3");
test.content_length = 3 ;
test.method = 3 ;
test.is_netsite = 3 ;
db_obj = net_CacheStructToDBData(&test);
rv = net_DBDataToCacheStruct(db_obj);
printf("test3: %s %s %d %d %s\n",
rv->address, rv->charset,
rv->content_length, rv->method,
(rv->is_netsite == 3 ? "TRUE" : "FALSE"));
}
#endif
/* generates a key for use in the cache database
* from a CacheObject struct
*
* Key is based on the address and the post_data
*
* looks like:
* size checksum | size of address | ADDRESS | size of post data | POST DATA
*/
MODULE_PRIVATE DBT *
net_GenCacheDBKey(char *address, char *post_data, int32 post_data_size)
{
DBT *rv = XP_NEW(DBT);
char *hash;
char *data_ptr;
int32 str_len;
int32 size;
#define MD5_HASH_SIZE 16 /* always 16 due to md5 hash type */
if(!rv)
return(NULL);
if(!address)
{
XP_ASSERT(0);
rv->size = 0;
return(rv);
}
hash = XP_STRCHR(address, '#');
/* don't include '#' in a key */
if(hash)
*hash = '\0';
str_len = XP_STRLEN(address)+1;
size = sizeof(int32); /* for check sum */
size += sizeof(int32); /* for size of address */
size += str_len; /* for address string */
size += sizeof(int32); /* for size of post_data */
if(post_data_size)
size += MD5_HASH_SIZE;
rv->size = size;
rv->data = XP_ALLOC(size);
if(!rv->data)
{
FREE(rv);
return NULL;
}
data_ptr = (char *) rv->data;
/* put in the checksum size */
COPY_INT32(data_ptr, &size);
data_ptr = data_ptr + sizeof(int32);
/* put in the size of the address string */
COPY_INT32(data_ptr, &str_len);
data_ptr = data_ptr + sizeof(int32);
/* put in the address string data */
XP_MEMCPY(data_ptr, address, str_len);
data_ptr = data_ptr + str_len;
/* set the address back to it's original form */
if(hash)
*hash = '#';
/* put in the size of the post data */
if(post_data_size)
{
int32 size_of_md5 = MD5_HASH_SIZE;
unsigned char post_data_hash[MD5_HASH_SIZE];
MD5_HashBuf(post_data_hash, (unsigned char*)post_data, post_data_size);
COPY_INT32(data_ptr, &size_of_md5);
data_ptr = data_ptr + sizeof(int32);
/* put in the post data if there is any */
XP_MEMCPY(data_ptr, post_data_hash, sizeof(post_data_hash));
}
else
{
COPY_INT32(data_ptr, &post_data_size);
data_ptr = data_ptr + sizeof(int32);
}
return(rv);
}
/* returns a static string that contains the
* URL->address of the key
*
* returns NULL on error
*/
MODULE_PRIVATE char *
net_GetAddressFromCacheKey(DBT *key)
{
uint32 size;
char *data;
/* check for minimum size */
if(key->size < 10)
return(NULL);
/* validate size checksum */
data = (char *)key->data;
COPY_INT32(&size, data);
data += sizeof(int32);
if(size != key->size)
return(NULL);
/* get size of address string */
COPY_INT32(&size, data);
data += sizeof(int32);
/* make sure it's a valid c string */
if(data[size] != '\0')
return(NULL);
/* it's valid return it */
return(data);
}
/* checks a date within a DBT struct so
* that we don't have to convert it into a CacheObject
*
* This works because of the fixed length record format
* of the first part of the specific DBT format I'm
* using
*
* returns 0 on error
*/
MODULE_PRIVATE time_t
net_GetTimeInCacheDBT(DBT *data, int byte_position)
{
time_t date;
char *ptr = (char *)data->data;
if(data->size < byte_position+sizeof(time_t))
return(0);
if(!net_IsValidCacheDBT(data))
return(0);
COPY_INT32(&date, ptr+byte_position);
/* TRACEMSG(("Got date from cache DBT: %d", date)); */
return(date);
}
/* Sets a date within a DBT struct so
* that we don't have to convert it into a CacheObject
*
* This works because of the fixed length record format
* of the first part of the specific DBT format I'm
* using
*
* returns 0 on error
*/
MODULE_PRIVATE void
net_SetTimeInCacheDBT(DBT *data, int byte_position, time_t date)
{
char *ptr = (char *)data->data;
if(data->size < byte_position+sizeof(time_t))
return;
if(!net_IsValidCacheDBT(data))
return;
COPY_INT32(ptr+byte_position, &date);
return;
}
/* Gets the filename within a cache DBT struct so
* that we don't have to convert it into a CacheObject
*
* This works because of the fixed length record format
* of the first part of the specific DBT format I'm
* using
*
* returns NULL on error
*/
#define MAX_FILE_SIZE 2048
MODULE_PRIVATE char *
net_GetFilenameInCacheDBT(DBT *data)
{
int32 size;
char *rv;
char *ptr = (char*)data->data;
if(data->size < FILENAME_BYTE_POSITION)
return(NULL);
if(!net_IsValidCacheDBT(data))
return(0);
COPY_INT32(&size, ptr+FILENAME_SIZE_BYTE_POSITION);
if(data->size < FILENAME_BYTE_POSITION+size
|| size > MAX_FILE_SIZE)
return(NULL);
rv = (char *)XP_ALLOC(size);
if(!rv)
return(NULL);
XP_MEMCPY(rv, ptr+FILENAME_BYTE_POSITION, size);
TRACEMSG(("Got filename: %s from DBT", rv));
return(rv);
}
/* Gets a int32 within a DBT struct so
* that we don't have to convert it into a CacheObject
*
* This works because of the fixed length record format
* of the first part of the specific DBT format I'm
* using
*
* returns 0 on error
*/
MODULE_PRIVATE time_t
net_GetInt32InCacheDBT(DBT *data, int byte_position)
{
int32 num;
char *ptr = (char *)data->data;
if(!net_IsValidCacheDBT(data))
return(0);
if(data->size < byte_position+sizeof(time_t))
return(0);
COPY_INT32(&num, ptr+byte_position);
/* TRACEMSG(("Got int32 from cache DBT: %d", num)); */
return(num);
}
MODULE_PRIVATE void
net_FreeCacheDBTdata(DBT *stuff)
{
if(stuff)
{
FREE(stuff->data);
FREE(stuff);
}
}
/* takes a database storage object and returns an un-malloc'd
* cache data object. The structure returned has pointers
* directly into the database memory and are only valid
* until the next call to any database function
*
* do not free anything returned by this structure
*/
MODULE_PRIVATE net_CacheObject *
net_Fast_DBDataToCacheStruct(DBT *obj)
{
static net_CacheObject *rv=0;
/* free any previous one */
if(rv)
net_freeCacheObj(rv);
rv = net_DBDataToCacheStruct(obj);
return(rv);
}
#endif /* MOZILLA_CLIENT */

View File

@@ -0,0 +1,273 @@
/* -*- 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.
*/
#ifndef EXT_CACHE_H
#define EXT_CACHE_H
#ifndef EXT_DB_ROUTINES
#include "mcom_db.h"
#endif
#ifdef EXT_DB_ROUTINES
#define Bool char
#define uint32 unsigned int
#define int32 int
#define XP_NEW(structure) ((structure *) malloc(sizeof(structure)))
#define XP_ALLOC (void *) malloc
#define XP_MEMCPY memcpy
#define XP_MEMSET memset
#define TRACEMSG(x) printf x
#define FREEIF(x) do { if(x) free(x); } while(0)
#define FREE free
#define XP_STRLEN strlen
#define XP_STRCHR strchr
#define XP_STRCMP strcmp
#define XP_ASSERT assert
#define MODULE_PRIVATE
#define PRIVATE static
#define TRUE !0
#define FALSE 0
#include <stdio.h>
#include <string.h>
#include <db.h>
#endif
#ifndef EXT_DB_ROUTINES
#include "mkutils.h"
#ifndef NSPR20
#include "prosdep.h" /* for IS_LITTLE_ENDIAN / IS_BIG_ENDIAN */
#else
#include "prtypes.h"
#endif
#endif /* EXT_DB_ROUTINES */
#if !defined(IS_LITTLE_ENDIAN) && !defined(IS_BIG_ENDIAN)
ERROR! Must have a byte order
#endif
#ifdef IS_LITTLE_ENDIAN
#define COPY_INT32(_a,_b) XP_MEMCPY(_a, _b, sizeof(int32));
#else
#define COPY_INT32(_a,_b) /* swap */ \
do { \
((char *)(_a))[0] = ((char *)(_b))[3]; \
((char *)(_a))[1] = ((char *)(_b))[2]; \
((char *)(_a))[2] = ((char *)(_b))[1]; \
((char *)(_a))[3] = ((char *)(_b))[0]; \
} while(0)
#endif
#define EXT_CACHE_NAME_STRING "INT_ExternalCacheNameString"
/* Internal WARNING!! Some slots of this structure
* are shared with URL_Struct and
* History_entry. If you add a slot, decide whether it needs to be shared
* as well.
*/
typedef struct _net_CacheObject {
time_t last_modified;
time_t last_accessed;
time_t expires;
Bool is_netsite;
uint32 content_length;
char * filename; /* cache file name */
int32 filename_len; /* optimization */
Bool is_relative_path; /* is the path relative? */
/* Security information */
int32 security_on; /* is security on? */
unsigned char *sec_info;
time_t lock_date; /* the file is locked if this
* is non-zero. The date
* represents the time the
* lock was put in place.
* Locks are only valid for
* one session
*/
int32 method;
char * address;
uint32 post_data_size;
char * post_data;
char * post_headers;
char * content_type;
char * content_encoding;
char * charset;
Bool incomplete_file; /* means that the whole
* file is not there.
* This can only be true
* if the server supports byteranges
*/
uint32 real_content_length; /* the whole content length
* i.e. the server size of a truncated
* client file
*/
char * page_services_url;
char * etag; /* HTTP/1.1 Etag */
} net_CacheObject;
/* this is the version number of the cache database entry.
* It should be incremented in integer ingrements up
* to MAXINT32
*/
#define CACHE_FORMAT_VERSION 5
/* these defines specify the exact byte position
* of the first 4 elements in the DBT data struct
* Change these if you change the order of entry into
* the DBT
*/
#define LAST_MODIFIED_BYTE_POSITION \
sizeof(int32)+sizeof(int32)
#define LAST_ACCESSED_BYTE_POSITION \
sizeof(int32)+sizeof(int32)+sizeof(time_t)
#define EXPIRES_BYTE_POSITION \
sizeof(int32)+sizeof(int32)+sizeof(time_t)+sizeof(time_t)
#define CONTENT_LENGTH_BYTE_POSITION \
sizeof(int32)+sizeof(int32)+sizeof(time_t)+sizeof(time_t) \
+sizeof(time_t)
#define IS_NETSITE_BYTE_POSITION \
sizeof(int32)+sizeof(int32)+sizeof(time_t)+sizeof(time_t) \
+sizeof(time_t)+sizeof(int32)
#define LOCK_DATE_BYTE_POSITION \
sizeof(int32)+sizeof(int32)+sizeof(time_t)+sizeof(time_t) \
+sizeof(time_t)+sizeof(int32)+sizeof(char)
#define FILENAME_SIZE_BYTE_POSITION \
sizeof(int32)+sizeof(int32)+sizeof(time_t)+sizeof(time_t) \
+sizeof(time_t)+sizeof(uint32)+sizeof(char)+sizeof(time_t)
#define FILENAME_BYTE_POSITION \
sizeof(int32)+sizeof(int32)+sizeof(time_t)+sizeof(time_t) \
+sizeof(time_t)+sizeof(uint32)+sizeof(char)+sizeof(time_t) \
+sizeof(int32)
/* generates a key for use in the cache database
* from a CacheObject struct
*
* Key is based on the address and the post_data
*/
extern DBT *
net_GenCacheDBKey(char *address, char *post_data, int32 post_data_size);
/* returns a static string that contains the
* URL->address of the key
*
* returns NULL on error
*/
extern char *
net_GetAddressFromCacheKey(DBT *key);
/* allocs and copies a new DBT from an existing DBT
*/
extern DBT * net_CacheDBTDup(DBT *obj);
/* free the cache object
*/
extern void net_freeCacheObj (net_CacheObject * cache_obj);
/* takes a cache object and returns a malloc'd
* (void *) suitible for passing in as a database
* data storage object
*/
extern DBT * net_CacheStructToDBData(net_CacheObject * old_obj);
/* takes a database storage object and returns a malloc'd
* cache data object. The cache object needs all of
* it's parts free'd.
*
* returns NULL on parse error
*/
extern net_CacheObject * net_DBDataToCacheStruct(DBT * db_obj);
/* checks a date within a DBT struct so
* that we don't have to convert it into a CacheObject
*
* This works because of the fixed length record format
* of the first part of the specific DBT format I'm
* using
*
* returns 0 on error
*/
extern time_t net_GetTimeInCacheDBT(DBT *data, int byte_position);
/* Sets a date within a DBT struct so
* that we don't have to convert it into a CacheObject
*
* This works because of the fixed length record format
* of the first part of the specific DBT format I'm
* using
*
* returns 0 on error
*/
extern void net_SetTimeInCacheDBT(DBT *data, int byte_position, time_t date);
/* Gets the filename within a cache DBT struct so
* that we don't have to convert it into a CacheObject
*
* This works because of the fixed length record format
* of the first part of the specific DBT format I'm
* using
*
* returns NULL on error
*/
extern char * net_GetFilenameInCacheDBT(DBT *data);
/* Gets a int32 within a DBT struct so
* that we don't have to convert it into a CacheObject
*
* This works because of the fixed length record format
* of the first part of the specific DBT format I'm
* using
*
* returns 0 on error
*/
extern time_t net_GetInt32InCacheDBT(DBT *data, int byte_position);
/* free's a DBT struct
*/
extern void net_FreeCacheDBTdata(DBT *stuff);
/* stores a cache object in the DBM database
*/
extern void net_ExtCacheStore(DB *database, net_CacheObject * obj);
/* takes a database storage object and returns an un-malloc'd
* cache data object. The structure returned has pointers
* directly into the database memory and are only valid
* until the next call to any database function
*
* do not free anything returned by this structure
*/
extern net_CacheObject * net_Fast_DBDataToCacheStruct(DBT *obj);
/* returns true if this DBT looks like a valid
* entry. It looks at the checksum and the
* version number to see if it's valid
*/
extern Bool net_IsValidCacheDBT(DBT *obj);
#endif /* EXT_CACHE_H */

3430
mozilla/lib/libnet/mkcache.c Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -61,7 +61,6 @@
#endif
#include "mktcp.h" /* for NET_InGetHostByName semaphore */
#include "cert.h"
#ifdef MOZILLA_CLIENT
#include "secnav.h"
#ifdef MOCHA
@@ -76,7 +75,6 @@
#include "il_strm.h" /* Image Lib public API. */
#include "libi18n.h"
#include "xp_sec.h"
#include "mkmocha.h"
#include "htmldlgs.h"
@@ -4215,16 +4213,8 @@ NET_FreeURLStruct (URL_Struct * URL_s)
FREEIF(URL_s->wysiwyg_url);
FREEIF(URL_s->error_msg);
FREEIF(URL_s->key_cipher);
FREEIF(URL_s->key_issuer);
FREEIF(URL_s->key_subject);
if ( URL_s->certificate ) {
CERT_DestroyCertificate(URL_s->certificate);
}
if ( URL_s->redirecting_cert ) {
CERT_DestroyCertificate(URL_s->redirecting_cert);
}
FREEIF(URL_s->sec_info);
FREEIF(URL_s->redirect_sec_info);
/* Free all memory associated with header information */
net_FreeURLAllHeaders(URL_s);
@@ -4460,10 +4450,8 @@ net_OutputURLDocInfo(MWContext *ctxt, char *which, char **data, int32 *length)
}
if(URL_s->cache_file || URL_s->memory_copy)
sec_msg = XP_PrettySecurityStatus(URL_s->security_on,
URL_s->key_cipher,
URL_s->key_size,
URL_s->key_secret_size);
sec_msg = SECNAV_PrettySecurityStatus(URL_s->security_on,
URL_s->sec_info);
else
sec_msg = XP_STRDUP(XP_GetString(XP_STATUS_UNKNOWN));
@@ -4473,20 +4461,10 @@ net_OutputURLDocInfo(MWContext *ctxt, char *which, char **data, int32 *length)
FREE(sec_msg);
}
if(URL_s->certificate)
sec_msg = CERT_HTMLCertInfo(URL_s->certificate, PR_TRUE,
PR_TRUE);
else
sec_msg = 0;
sec_msg = SECNAV_SSLSocketCertString(URL_s->sec_info);
if(sec_msg)
{
char *extstring;
extstring = SECNAV_MakeCertButtonString(URL_s->certificate);
if ( extstring ) {
StrAllocCat(sec_msg, extstring);
XP_FREE(extstring);
}
ADD_CELL(XP_GetString(XP_CERTIFICATE_), sec_msg);
FREE(sec_msg);
}
@@ -4653,6 +4631,11 @@ PRIVATE int net_output_about_url(ActiveEntry * cur_entry)
NET_DisplayMemCacheInfoAsHTML(cur_entry);
return(-1);
}
else if(!strcasecomp(which, "logout"))
{
NET_RemoveAllAuthorizations();
return(-1);
}
else if(!strcasecomp(which, "image-cache"))
{
IL_DisplayMemCacheInfoAsHTML(cur_entry->format_out, cur_entry->URL_s,

3772
mozilla/lib/libnet/mkhttp.c Normal file

File diff suppressed because it is too large Load Diff

5326
mozilla/lib/libnet/mknews.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -108,7 +108,7 @@ nsPluginManager::MemFlush(PRUint32 size)
static NS_DEFINE_IID(kPluginManagerIID, NP_IPLUGINMANAGER_IID);
//static NS_DEFINE_IID(kNPIJVMPluginManagerIID, NP_IJVMPLUGINMANAGER_IID);
NS_METHOD
NS_IMETHODIMP
nsPluginManager::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr)
{
if (NULL == aInstancePtr) {
@@ -184,7 +184,7 @@ NS_IMPL_AGGREGATED(nsPluginInstancePeer);
static NS_DEFINE_IID(kLiveConnectPluginInstancePeerIID, NP_ILIVECONNECTPLUGININSTANCEPEER_IID);
static NS_DEFINE_IID(kPluginInstancePeerIID, NP_IPLUGININSTANCEPEER_IID);
NS_METHOD
NS_IMETHODIMP
nsPluginInstancePeer::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr)
{
if (NULL == aInstancePtr) {

90
mozilla/lib/xp/Makefile Normal file
View File

@@ -0,0 +1,90 @@
#!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 = ../..
MODULE = xp
LIBRARY_NAME = xp
CSRCS = xp_alloc.c \
xp_cntxt.c \
xp_core.c \
xp_error.c \
xp_file.c \
xp_hash.c \
xp_list.c \
xp_ncent.c \
xp_reg.c \
xp_rgb.c \
xp_qsort.c \
xp_str.c \
xp_thrmo.c \
xp_time.c \
xp_trace.c \
xp_wrap.c \
xpassert.c \
xplocale.c \
$(NULL)
REQUIRES = js nspr dbm security img util jtools layer java lay style pref rdf
CSRCS += allxpstr.c xp_intl.c
ifeq ($(STAND_ALONE_JAVA),1)
CSRCS = xp_qsort.c
endif
include $(DEPTH)/config/rules.mk
EMACS = lemacs
AUDIO_FILES = $(wildcard *.au)
GIF_FILES = $(wildcard *.gif)
JPEG_FILES = $(wildcard *.jpg)
GEN_OUT = $(AUDIO_FILES:.au=.h) $(GIF_FILES:.gif=.h) $(JPEG_FILES:.jpg=.h)
#
# Uncomment these to (re)generate the headers.
#
#GARBAGE += $(GEN_OUT) $(wildcard *~)
#
#all:: $(GEN_OUT)
$(LIBRARY): $(OBJS)
#
# Generate c header's for various binary files
#
.SUFFIXES: .au .gif .jpg
.au.h:
@echo generating $*.h from $<...; \
CNAME=`echo $*_au`; \
$(EMACS) -batch -q -l bin-to-c.el -f batch-bin-to-c $$CNAME $< $*.h
.gif.h:
@echo generating $*.h from $<...; \
CNAME=`echo $*_gif`; \
$(EMACS) -batch -q -l bin-to-c.el -f batch-bin-to-c $$CNAME $< $*.h
.jpg.h:
@echo generating $*.h from $<...; \
CNAME=`echo $*_jpg`; \
$(EMACS) -batch -q -l bin-to-c.el -f batch-bin-to-c $$CNAME $< $*.h

View File

@@ -1,4 +1,3 @@
#!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,8 +13,15 @@
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#
DEPTH = ../..
DIRS = classes src include
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/rules.mk
include $(DEPTH)/config/autoconf.mk
DIRS = public admin src
include $(topsrcdir)/config/rules.mk

View File

@@ -0,0 +1,55 @@
#
# 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
ifdef POLARIS
SHARED_LIBRARY = $(OBJDIR)/libAutoAdmin.so
endif
XFEDIR = $(DEPTH)/cmd/xfe
CSRCS = prefldap.c icondata.c
REQUIRES = dbm ldap js pref
include $(topsrcdir)/config/rules.mk
INCLUDES += -I$(topsrcdir)/cmd/xfe/icons -I$(DEPTH)/cmd/xfe/icons/$(OBJDIR)
DEFINES += -DPOLARIS
GARBAGE += icondata.c
ifeq ($(OS_ARCH),AIX)
MKSHLIB = svld -berok $(DSO_LDOPTS)
endif
ifeq ($(OS_ARCH),OSF1)
MKSHLIB = $(LD) $(DSO_LDOPTS)
endif
polaris: $(SHARED_LIBRARY)
$(INSTALL) -m 555 $(SHARED_LIBRARY) $(DIST)/bin
icondata.c:
@rm -f icondata.c $(NOSUCHFILE)
@cd $(XFEDIR)/icons; $(MAKE)
@ln -s $(XFEDIR)/icons/$(OBJDIR)/icondata.c $@

View File

@@ -0,0 +1,39 @@
#
# 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
REQUIRES = security
include $(topsrcdir)/config/rules.mk
LIBS = -L$(DIST)/lib -lhash
all:: other-stuff $(OBJDIR)/resources $(OBJDIR)/un-obscure
other-stuff:
cd $(DEPTH)/config; $(MAKE)
cd $(DEPTH)/security/lib/util; $(MAKE) export
cd $(DEPTH)/security/lib/hash; $(MAKE)
$(OBJDIR)/resources: $(OBJDIR)/resources.o
$(CC) -o $@ $< $(LIBS)

View File

@@ -0,0 +1,7 @@
#
# This is a list of local files which get copied to the mozilla:dist directory
#
prefapi.h
prefldap.h
nsIPref.h

View File

@@ -19,6 +19,6 @@ DEPTH = ../../..
MODULE = pref
EXPORTS = prefapi.h prefldap.h
EXPORTS = prefapi.h prefldap.h nsIPref.h
include $(DEPTH)/config/rules.mk

View File

@@ -0,0 +1,30 @@
#
# 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
MODULE = pref
EXPORTS = prefapi.h prefldap.h nsIPref.h
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
include $(topsrcdir)/config/rules.mk

View File

@@ -20,6 +20,6 @@ IGNORE_MANIFEST=1
MODULE=pref
DEPTH=..\..\..
EXPORTS=prefapi.h prefldap.h
EXPORTS=prefapi.h prefldap.h nsIPref.h
include <$(MOZ_SRC)\ns\config\rules.mak>
include <$(DEPTH)\config\rules.mak>

View File

@@ -0,0 +1,146 @@
/* -*- 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.
*/
#ifndef nsIPref_h__
#define nsIPref_h__
#include "xp_core.h"
#include "jsapi.h"
#include "nsISupports.h"
typedef int (*PrefChangedFunc) (const char *, void *);
// {A22AD7B0-CA86-11d1-A9A4-00805F8A7AC4}
NS_DECLARE_ID(kIPrefIID,
0xa22ad7b0, 0xca86, 0x11d1, 0xa9, 0xa4, 0x0, 0x80, 0x5f, 0x8a, 0x7a, 0xc4);
// {DC26E0E0-CA94-11d1-A9A4-00805F8A7AC4}
NS_DECLARE_ID(kPrefCID,
0xdc26e0e0, 0xca94, 0x11d1, 0xa9, 0xa4, 0x0, 0x80, 0x5f, 0x8a, 0x7a, 0xc4);
/*
* Return values
*/
#define NS_PREF_VALUE_CHANGED 1
class nsIPref: public nsISupports {
public:
// Initialize/shutdown
NS_IMETHOD Startup(char *filename) = 0;
NS_IMETHOD Shutdown() = 0;
// Config file input
NS_IMETHOD ReadUserJSFile(char *filename) = 0;
NS_IMETHOD ReadLIJSFile(char *filename) = 0;
// JS stuff
NS_IMETHOD GetConfigContext(JSContext **js_context) = 0;
NS_IMETHOD GetGlobalConfigObject(JSObject **js_object) = 0;
NS_IMETHOD GetPrefConfigObject(JSObject **js_object) = 0;
NS_IMETHOD EvaluateConfigScript(const char * js_buffer, size_t length,
const char* filename,
PRBool bGlobalContext,
PRBool bCallbacks) = 0;
// Getters
NS_IMETHOD GetCharPref(const char *pref,
char * return_buf, int * buf_length) = 0;
NS_IMETHOD GetIntPref(const char *pref, int32 * return_int) = 0;
NS_IMETHOD GetBoolPref(const char *pref, XP_Bool *return_val) = 0;
NS_IMETHOD GetBinaryPref(const char *pref,
void * return_val, int * buf_length) = 0;
NS_IMETHOD GetColorPref(const char *pref_name,
uint8 *red, uint8 *green, uint8 *blue) = 0;
NS_IMETHOD GetColorPrefDWord(const char *pref_name, uint32 *colorref) = 0;
NS_IMETHOD GetRectPref(const char *pref_name,
int16 *left, int16 *top,
int16 *right, int16 *bottom) = 0;
// Setters
NS_IMETHOD SetCharPref(const char *pref,const char* value) = 0;
NS_IMETHOD SetIntPref(const char *pref,int32 value) = 0;
NS_IMETHOD SetBoolPref(const char *pref,PRBool value) = 0;
NS_IMETHOD SetBinaryPref(const char *pref,void * value, long size) = 0;
NS_IMETHOD SetColorPref(const char *pref_name,
uint8 red, uint8 green, uint8 blue) = 0;
NS_IMETHOD SetColorPrefDWord(const char *pref_name, uint32 colorref) = 0;
NS_IMETHOD SetRectPref(const char *pref_name,
int16 left, int16 top, int16 right, int16 bottom) = 0;
// Get Defaults
NS_IMETHOD GetDefaultCharPref(const char *pref,
char * return_buf, int * buf_length) = 0;
NS_IMETHOD GetDefaultIntPref(const char *pref, int32 * return_int) = 0;
NS_IMETHOD GetDefaultBoolPref(const char *pref, XP_Bool *return_val) = 0;
NS_IMETHOD GetDefaultBinaryPref(const char *pref,
void * return_val, int * buf_length) = 0;
NS_IMETHOD GetDefaultColorPref(const char *pref_name,
uint8 *red, uint8 *green, uint8 *blue) = 0;
NS_IMETHOD GetDefaultColorPrefDWord(const char *pref_name,
uint32 *colorref) = 0;
NS_IMETHOD GetDefaultRectPref(const char *pref_name,
int16 *left, int16 *top,
int16 *right, int16 *bottom) = 0;
// Set defaults
NS_IMETHOD SetDefaultCharPref(const char *pref,const char* value) = 0;
NS_IMETHOD SetDefaultIntPref(const char *pref,int32 value) = 0;
NS_IMETHOD SetDefaultBoolPref(const char *pref,PRBool value) = 0;
NS_IMETHOD SetDefaultBinaryPref(const char *pref,
void * value, long size) = 0;
NS_IMETHOD SetDefaultColorPref(const char *pref_name,
uint8 red, uint8 green, uint8 blue) = 0;
NS_IMETHOD SetDefaultRectPref(const char *pref_name,
int16 left, int16 top,
int16 right, int16 bottom) = 0;
// Copy prefs
NS_IMETHOD CopyCharPref(const char *pref, char ** return_buf) = 0;
NS_IMETHOD CopyBinaryPref(const char *pref_name,
void ** return_value, int *size) = 0;
NS_IMETHOD CopyDefaultCharPref( const char
*pref_name, char ** return_buffer ) = 0;
NS_IMETHOD CopyDefaultBinaryPref(const char *pref,
void ** return_val, int * size) = 0;
// Path prefs
NS_IMETHOD CopyPathPref(const char *pref, char ** return_buf) = 0;
NS_IMETHOD SetPathPref(const char *pref_name,
const char *path, PRBool set_default) = 0;
// Pref info
NS_IMETHOD PrefIsLocked(const char *pref_name, XP_Bool *res) = 0;
// Save pref files
NS_IMETHOD SavePrefFile(void) = 0;
NS_IMETHOD SavePrefFileAs(const char *filename) = 0;
NS_IMETHOD SaveLIPrefFile(const char *filename) = 0;
// Callbacks
NS_IMETHOD RegisterCallback( const char* domain,
PrefChangedFunc callback,
void* instance_data ) = 0;
NS_IMETHOD UnregisterCallback( const char* domain,
PrefChangedFunc callback,
void* instance_data ) = 0;
};
#endif /* nsIPref_h__ */

View File

@@ -22,24 +22,18 @@
#ifndef PREFAPI_H
#define PREFAPI_H
#include "prtypes.h"
#if defined(XP_UNIX) || defined(XP_MAC) || defined(XP_OS2)
#include "xp_core.h"
#endif
#include "prtypes.h"
#include "jscompat.h"
#include "jspubtd.h"
#ifdef XP_WIN
#ifndef NSPR20
#include "prhash.h"
#else
#include "plhash.h"
#endif
#endif
NSPR_BEGIN_EXTERN_C
#if defined(XP_WIN) || defined(XP_OS2)
#ifdef XP_PC
// horrible pre-declaration...so kill me.
int pref_InitInitialObjects(JSContext *js_context,JSObject *js_object);
PR_EXTERN(int) pref_savePref(PRHashEntry *he, int i, void *arg);
@@ -141,7 +135,7 @@ PREF_QuietEvaluateJSBufferWithGlobalScope(const char * js_buffer, size_t length)
*/
PR_EXTERN(JSBool)
PREF_EvaluateConfigScript(const char * js_buffer, size_t length,
const char* filename, XP_Bool bGlobalContext, XP_Bool bCallbacks);
const char* filename, PRBool bGlobalContext, PRBool bCallbacks);
/*
@@ -173,7 +167,7 @@ enum {
*/
PR_EXTERN(int) PREF_SetCharPref(const char *pref,const char* value);
PR_EXTERN(int) PREF_SetIntPref(const char *pref,int32 value);
PR_EXTERN(int) PREF_SetBoolPref(const char *pref,XP_Bool value);
PR_EXTERN(int) PREF_SetBoolPref(const char *pref,PRBool value);
PR_EXTERN(int) PREF_SetBinaryPref(const char *pref,void * value, long size);
PR_EXTERN(int) PREF_SetColorPref(const char *pref_name, uint8 red, uint8 green, uint8 blue);
PR_EXTERN(int) PREF_SetColorPrefDWord(const char *pref_name, uint32 colorref);
@@ -190,7 +184,7 @@ PR_EXTERN(int) PREF_SetRectPref(const char *pref_name, int16 left, int16 top, in
*/
PR_EXTERN(int) PREF_SetDefaultCharPref(const char *pref,const char* value);
PR_EXTERN(int) PREF_SetDefaultIntPref(const char *pref,int32 value);
PR_EXTERN(int) PREF_SetDefaultBoolPref(const char *pref,XP_Bool value);
PR_EXTERN(int) PREF_SetDefaultBoolPref(const char *pref,PRBool value);
PR_EXTERN(int) PREF_SetDefaultBinaryPref(const char *pref,void * value, long size);
PR_EXTERN(int) PREF_SetDefaultColorPref(const char *pref_name, uint8 red, uint8 green, uint8 blue);
PR_EXTERN(int) PREF_SetDefaultRectPref(const char *pref_name, int16 left, int16 top, int16 right, int16 bottom);
@@ -244,7 +238,7 @@ PR_EXTERN(int) PREF_CopyDefaultBinaryPref(const char *pref, void ** return_val,
// </font>
*/
PR_EXTERN(int) PREF_CopyPathPref(const char *pref, char ** return_buf);
PR_EXTERN(int) PREF_SetPathPref(const char *pref_name, const char *path, XP_Bool set_default);
PR_EXTERN(int) PREF_SetPathPref(const char *pref_name, const char *path, PRBool set_default);
/*
// <font color=blue>
@@ -287,11 +281,11 @@ PR_EXTERN(int) PREF_GetConfigBool(const char *obj_name, XP_Bool *return_bool);
/*
// <font color=blue>
// XP_Bool funtion that returns whether or not the preference is locked and therefore
// PRBool funtion that returns whether or not the preference is locked and therefore
// cannot be changed.
// </font>
*/
PR_EXTERN(XP_Bool) PREF_PrefIsLocked(const char *pref_name);
PR_EXTERN(PRBool) PREF_PrefIsLocked(const char *pref_name);
PR_EXTERN(int) PREF_GetPrefType(const char *pref_name);
@@ -366,15 +360,15 @@ PR_EXTERN(int) PREF_UnregisterCallback( const char* domain,
/*
// Front ends implement to determine whether AutoAdmin library is installed.
*/
PR_EXTERN(XP_Bool) PREF_IsAutoAdminEnabled();
PR_EXTERN(PRBool) PREF_IsAutoAdminEnabled(void);
#ifdef XP_UNIX
struct fe_icon_data;
typedef void* XmStringPtr;
typedef void* KeySymPtr;
PR_EXTERN(void) PREF_AlterSplashIcon(struct fe_icon_data*);
PR_EXTERN(XP_Bool) PREF_GetLabelAndMnemonic(char*, char**, XmStringPtr xmstring, KeySymPtr keysym);
PR_EXTERN(XP_Bool) PREF_GetUrl(char*, char**);
PR_EXTERN(PRBool) PREF_GetLabelAndMnemonic(char*, char**, XmStringPtr xmstring, KeySymPtr keysym);
PR_EXTERN(PRBool) PREF_GetUrl(char*, char**);
#endif
NSPR_END_EXTERN_C

View File

@@ -20,7 +20,7 @@ DEPTH = ../../..
MODULE = pref
LIBRARY_NAME = pref
REQUIRES = libxp js pref nspr dbm security ldap java img layer util
REQUIRES = js pref nspr dbm security ldap img layer xpcom util
ifneq ($(subst /,_,$(shell uname -s)),OS2)
CSRCS = unix/unixpref.c
@@ -39,10 +39,14 @@ endif
CSRCS += prefapi.c
CPPSRCS += nsPref.cpp
include $(DEPTH)/config/rules.mk
INCLUDES += -I$(DEPTH)/cmd/xfe/icons -Iunix
DEFINES += -DB1M
GARBAGE += unix/jsbuffer.h
CONFIG_FILES = initpref.js \

View File

@@ -0,0 +1,108 @@
#
# 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
MODULE = pref
LIBRARY_NAME = pref
REQUIRES = js pref dbm security ldap img layer xpcom util
ifneq ($(subst /,_,$(shell uname -s)),OS2)
CSRCS = unix/unixpref.c
else
CSRCS = prefldap.c
LIBRARY = xppref32.$(LIB_SUFFIX)
EXPORTS = initpref.js init/all.js init/config.js win/winpref.js os2/os2pref.js
OS2_IMPLIB = 1
DEF_FILE = xpOS2.def
EXTRA_LIBS = $(DIST)/lib/js$(MOZ_BITS)$(VERSION_NUMBER).lib \
$(LIBNSPR) \
$(DIST)/lib/libldap.lib $(DIST)/lib/liblber.lib \
$(DIST)/lib/libldap.lib $(DIST)/lib/libhash.lib \
$(NULL)
endif
CSRCS += prefapi.c
CPPSRCS += nsPref.cpp
include $(topsrcdir)/config/rules.mk
INCLUDES += -I$(topsrcdir)/cmd/xfe/icons -I$(srcdir)/unix -Iunix
DEFINES += -DB1M
GARBAGE += unix/jsbuffer.h
CONFIG_FILES = initpref.js \
init/all.js \
$(NULL)
ifdef MOZ_MAIL_NEWS
CONFIG_FILES += \
init/mailnews.js \
$(NULL)
endif
ifdef MOZ_SECURITY
CONFIG_FILES += \
init/security.js \
$(NULL)
endif
ifdef MOZ_EDITOR
CONFIG_FILES += \
init/editor.js \
$(NULL)
endif
ifndef MOZ_MAIL_NEWS
CONFIG_FILES += \
init/configr.js \
$(NULL)
else
CONFIG_FILES += \
init/config.js \
$(NULL)
endif
CONFIG_FILES += \
unix/unix.js \
$(NULL)
CONFIG_FILES := $(addprefix $(srcdir)/, $(CONFIG_FILES))
$(LIBRARY): $(OBJS)
unix/unixpref.c: unix/jsbuffer.h
@if test ! -d unix; then rm -f unix && mkdir -p unix; fi
@if test ! -f $@; then $(INSTALL) $(srcdir)/unix/unixpref.c unix/; fi
unix/jsbuffer.h: Makefile $(CONFIG_FILES)
@if test ! -d unix; then rm -f unix && mkdir -p unix; fi
@(echo "/* This is an automatically generated file */" > $@; \
echo >> $@; \
echo "static char* pref_init_buffer = " >> $@; \
cat $(CONFIG_FILES) | sed 's/\\/\\\\/g' | sed 's/\\r/\\n/' | sed 's/\"/\\\"/g' | sed 's/^M//g' | sed 's/^/"/' | sed 's/$$/\\n"/' >> $@; \
echo \; >> $@; \
)

View File

@@ -185,6 +185,7 @@ pref("network.accept_cookies", 0); // 0 = Always, 1 = warn, 2 =
pref("network.foreign_cookies", 0); // 0 = Accept, 1 = Don't accept
pref("network.cookie.cookieBehavior", 0); // 0-Accept, 1-dontAcceptForeign, 2-dontUse
pref("network.cookie.warnAboutCookies", false);
pref("network.signon.rememberSignons", true);
pref("network.sendRefererHeader", true);
pref("network.enablePad", false); // Allow client to do proxy autodiscovery
pref("network.padPacURL", "http://supernova:8080"); // The proxy autodiscovery url

View File

@@ -22,6 +22,7 @@
#include "prlink.h"
#include "ufilemgr.h"
#include "uprefd.h"
#include "LString.h"
#include <Types.h>
#include <Resources.h>
@@ -116,7 +117,7 @@ PREF_CopyPathPref(const char *pref_name, char ** return_buffer)
}
PR_IMPLEMENT(int)
PREF_SetPathPref(const char *pref_name, const char *path, XP_Bool set_default)
PREF_SetPathPref(const char *pref_name, const char *path, PRBool set_default)
{
FSSpec fileSpec;
AliasHandle aliasH;
@@ -154,10 +155,9 @@ pref_FindAutoAdminLib(FSSpec& spec)
return CFileMgr::FileExists(spec);
}
PR_IMPLEMENT(XP_Bool)
PR_IMPLEMENT(PRBool)
PREF_IsAutoAdminEnabled()
{
FSSpec spec;
return (XP_Bool) pref_FindAutoAdminLib(spec);
}

View File

@@ -47,6 +47,7 @@ LINCS = -I$(PUBLIC)/js \
-I$(PUBLIC)/ldap \
-I$(PUBLIC)/dbm \
-I$(PUBLIC)/security \
-I$(PUBLIC)/xpcom \
-I$(DEPTH)\include \
LCFLAGS = -DMOZILLA_CLIENT
@@ -67,16 +68,19 @@ BINREL_DIST=$(XPDIST)\WIN954.0_DBG.OBJD
!endif
!endif
!ifdef NO_SECURITY
HASHLIBS=$(DIST)\lib\secfreenav32.lib
!else
!ifdef MOZ_SECURITY
HASHLIBS=$(BINREL_DIST)\lib\hash.lib $(BINREL_DIST)\lib\secutil.lib
!else
HASHLIBS=$(DIST)\lib\secfreenav32.lib
!endif
!if ("$(MOZ_BITS)" == "16" )
LLIBS = $(LIBNSPR) $(DIST)\lib\js$(MOZ_BITS)$(VERSION_NUMBER).lib \
$(HASHLIBS) \
$(BINREL_DIST)\lib\watcomfx.lib
LLIBS = \
$(LIBNSPR) $(DIST)\lib\plc21.lib \
$(DIST)\lib\js$(MOZ_BITS)$(VERSION_NUMBER).lib \
$(HASHLIBS) \
$(DIST)\lib\xpcom16.lib \
$(BINREL_DIST)\lib\watcomfx.lib
!ifdef NSPR20
DEFFILE = $(DLL1NAME).def
@@ -84,8 +88,12 @@ DEFFILE = $(DLL1NAME).def
DEFFILE = $(DLLNAME).def
!endif
!else
LLIBS = $(LIBNSPR) $(DIST)\lib\js$(MOZ_BITS)$(VERSION_NUMBER).lib \
$(HASHLIBS)
LLIBS = \
$(DIST)\lib\libplc21.lib \
$(LIBNSPR) \
$(DIST)\lib\js$(MOZ_BITS)$(VERSION_NUMBER).lib \
$(DIST)\lib\xpcom32.lib \
$(HASHLIBS)
!endif
@@ -96,6 +104,7 @@ $(HASHLIBS)
#//------------------------------------------------------------------------
OBJS = \
.\$(OBJDIR)\prefapi.obj \
.\$(OBJDIR)\nsPref.obj \
$(NULL)
#//------------------------------------------------------------------------

View File

@@ -0,0 +1,629 @@
/* -*- 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 "pratom.h"
#include "prefapi.h"
#define NS_IMPL_IDS
#include "nsIFactory.h"
#include "nsRepository.h"
#include "nsIPref.h"
#ifdef XP_MAC
#include "nsINetSupport.h"
#include "nsIStreamListener.h"
#endif
class nsPref: public nsIPref {
NS_DECL_ISUPPORTS
private:
nsPref();
~nsPref();
static nsPref *mInstance;
public:
static nsPref *GetInstance();
// Initialize/shutdown
NS_IMETHOD Startup(char *filename);
NS_IMETHOD Shutdown();
// Config file input
NS_IMETHOD ReadUserJSFile(char *filename);
NS_IMETHOD ReadLIJSFile(char *filename);
// JS stuff
NS_IMETHOD GetConfigContext(JSContext **js_context);
NS_IMETHOD GetGlobalConfigObject(JSObject **js_object);
NS_IMETHOD GetPrefConfigObject(JSObject **js_object);
NS_IMETHOD EvaluateConfigScript(const char * js_buffer, size_t length,
const char* filename,
PRBool bGlobalContext,
PRBool bCallbacks);
// Getters
NS_IMETHOD GetCharPref(const char *pref,
char * return_buf, int * buf_length);
NS_IMETHOD GetIntPref(const char *pref, int32 * return_int);
NS_IMETHOD GetBoolPref(const char *pref, XP_Bool * return_val);
NS_IMETHOD GetBinaryPref(const char *pref,
void * return_val, int * buf_length);
NS_IMETHOD GetColorPref(const char *pref,
uint8 *red, uint8 *green, uint8 *blue);
NS_IMETHOD GetColorPrefDWord(const char *pref, uint32 *colorref);
NS_IMETHOD GetRectPref(const char *pref,
int16 *left, int16 *top,
int16 *right, int16 *bottom);
// Setters
NS_IMETHOD SetCharPref(const char *pref,const char* value);
NS_IMETHOD SetIntPref(const char *pref,int32 value);
NS_IMETHOD SetBoolPref(const char *pref,PRBool value);
NS_IMETHOD SetBinaryPref(const char *pref,void * value, long size);
NS_IMETHOD SetColorPref(const char *pref,
uint8 red, uint8 green, uint8 blue);
NS_IMETHOD SetColorPrefDWord(const char *pref, uint32 colorref);
NS_IMETHOD SetRectPref(const char *pref,
int16 left, int16 top, int16 right, int16 bottom);
// Get Defaults
NS_IMETHOD GetDefaultCharPref(const char *pref,
char * return_buf, int * buf_length);
NS_IMETHOD GetDefaultIntPref(const char *pref, int32 * return_int);
NS_IMETHOD GetDefaultBoolPref(const char *pref, XP_Bool * return_val);
NS_IMETHOD GetDefaultBinaryPref(const char *pref,
void * return_val, int * buf_length);
NS_IMETHOD GetDefaultColorPref(const char *pref,
uint8 *red, uint8 *green, uint8 *blue);
NS_IMETHOD GetDefaultColorPrefDWord(const char *pref,
uint32 *colorref);
NS_IMETHOD GetDefaultRectPref(const char *pref,
int16 *left, int16 *top,
int16 *right, int16 *bottom);
// Set defaults
NS_IMETHOD SetDefaultCharPref(const char *pref,const char* value);
NS_IMETHOD SetDefaultIntPref(const char *pref,int32 value);
NS_IMETHOD SetDefaultBoolPref(const char *pref,PRBool value);
NS_IMETHOD SetDefaultBinaryPref(const char *pref,
void * value, long size);
NS_IMETHOD SetDefaultColorPref(const char *pref,
uint8 red, uint8 green, uint8 blue);
NS_IMETHOD SetDefaultRectPref(const char *pref,
int16 left, int16 top,
int16 right, int16 bottom);
// Copy prefs
NS_IMETHOD CopyCharPref(const char *pref, char ** return_buf);
NS_IMETHOD CopyBinaryPref(const char *pref,
void ** return_value, int *size);
NS_IMETHOD CopyDefaultCharPref( const char
*pref, char ** return_buffer );
NS_IMETHOD CopyDefaultBinaryPref(const char *pref,
void ** return_val, int * size);
// Path prefs
NS_IMETHOD CopyPathPref(const char *pref, char ** return_buf);
NS_IMETHOD SetPathPref(const char *pref,
const char *path, PRBool set_default);
// Pref info
NS_IMETHOD PrefIsLocked(const char *pref, XP_Bool *res);
// Save pref files
NS_IMETHOD SavePrefFile(void);
NS_IMETHOD SavePrefFileAs(const char *filename);
NS_IMETHOD SaveLIPrefFile(const char *filename);
// Callbacks
NS_IMETHOD RegisterCallback( const char* domain,
PrefChangedFunc callback,
void* instance_data );
NS_IMETHOD UnregisterCallback( const char* domain,
PrefChangedFunc callback,
void* instance_data );
};
nsPref* nsPref::mInstance = NULL;
static PRInt32 g_InstanceCount = 0;
static PRInt32 g_LockCount = 0;
static nsresult _convertRes(int res)
{
nsresult nsres = NS_OK;
switch (res) {
case PREF_OUT_OF_MEMORY:
nsres = NS_ERROR_OUT_OF_MEMORY;
break;
case PREF_NOT_INITIALIZED:
nsres = NS_ERROR_NOT_INITIALIZED;
break;
case PREF_TYPE_CHANGE_ERR:
case PREF_ERROR:
case PREF_BAD_LOCKFILE:
nsres = NS_ERROR_UNEXPECTED;
break;
case PREF_VALUECHANGED:
nsres = NS_PREF_VALUE_CHANGED;
break;
};
return nsres;
}
/*
* Constructor/Destructor
*/
nsPref::nsPref() {
PR_AtomicIncrement(&g_InstanceCount);
NS_INIT_REFCNT();
}
nsPref::~nsPref() {
PR_AtomicDecrement(&g_InstanceCount);
mInstance = NULL;
}
nsPref *nsPref::GetInstance()
{
if (mInstance == NULL) {
mInstance = new nsPref();
}
return mInstance;
}
/*
* nsISupports Implementation
*/
NS_IMPL_ISUPPORTS(nsPref, kIPrefIID);
/*
* nsIPref Implementation
*/
NS_IMETHODIMP nsPref::Startup(char *filename)
{
return _convertRes(PREF_Init(filename));
}
NS_IMETHODIMP nsPref::Shutdown()
{
PREF_Cleanup();
return NS_OK;
}
/*
* Config file input
*/
NS_IMETHODIMP nsPref::ReadUserJSFile(char *filename)
{
return _convertRes(PREF_ReadUserJSFile(filename));
}
NS_IMETHODIMP nsPref::ReadLIJSFile(char *filename)
{
return _convertRes(PREF_ReadLIJSFile(filename));
}
/*
* JS stuff
*/
NS_IMETHODIMP nsPref::GetConfigContext(JSContext **js_context)
{
return _convertRes(PREF_GetConfigContext(js_context));
}
NS_IMETHODIMP nsPref::GetGlobalConfigObject(JSObject **js_object)
{
return _convertRes(PREF_GetGlobalConfigObject(js_object));
}
NS_IMETHODIMP nsPref::GetPrefConfigObject(JSObject **js_object)
{
return _convertRes(PREF_GetPrefConfigObject(js_object));
}
NS_IMETHODIMP nsPref::EvaluateConfigScript(const char * js_buffer,
size_t length,
const char* filename,
PRBool bGlobalContext,
PRBool bCallbacks)
{
return _convertRes(PREF_EvaluateConfigScript(js_buffer,
length,
filename,
bGlobalContext,
bCallbacks));
}
/*
* Getters
*/
NS_IMETHODIMP nsPref::GetCharPref(const char *pref,
char * return_buf, int * buf_length)
{
return _convertRes(PREF_GetCharPref(pref, return_buf, buf_length));
}
NS_IMETHODIMP nsPref::GetIntPref(const char *pref, int32 * return_int)
{
return _convertRes(PREF_GetIntPref(pref, return_int));
}
NS_IMETHODIMP nsPref::GetBoolPref(const char *pref, XP_Bool * return_val)
{
return _convertRes(PREF_GetBoolPref(pref, return_val));
}
NS_IMETHODIMP nsPref::GetBinaryPref(const char *pref,
void * return_val, int * buf_length)
{
return _convertRes(PREF_GetBinaryPref(pref, return_val, buf_length));
}
NS_IMETHODIMP nsPref::GetColorPref(const char *pref,
uint8 *red, uint8 *green, uint8 *blue)
{
return _convertRes(PREF_GetColorPref(pref, red, green, blue));
}
NS_IMETHODIMP nsPref::GetColorPrefDWord(const char *pref,
uint32 *colorref)
{
return _convertRes(PREF_GetColorPrefDWord(pref, colorref));
}
NS_IMETHODIMP nsPref::GetRectPref(const char *pref,
int16 *left, int16 *top,
int16 *right, int16 *bottom)
{
return _convertRes(PREF_GetRectPref(pref, left, top, right, bottom));
}
/*
* Setters
*/
NS_IMETHODIMP nsPref::SetCharPref(const char *pref,const char* value)
{
return _convertRes(PREF_SetCharPref(pref, value));
}
NS_IMETHODIMP nsPref::SetIntPref(const char *pref,int32 value)
{
return _convertRes(PREF_SetIntPref(pref, value));
}
NS_IMETHODIMP nsPref::SetBoolPref(const char *pref,PRBool value)
{
return _convertRes(PREF_SetBoolPref(pref, value));
}
NS_IMETHODIMP nsPref::SetBinaryPref(const char *pref,void * value, long size)
{
return _convertRes(PREF_SetBinaryPref(pref, value, size));
}
NS_IMETHODIMP nsPref::SetColorPref(const char *pref,
uint8 red, uint8 green, uint8 blue)
{
return _convertRes(PREF_SetColorPref(pref, red, green, blue));
}
NS_IMETHODIMP nsPref::SetColorPrefDWord(const char *pref,
uint32 value)
{
return _convertRes(PREF_SetColorPrefDWord(pref, value));
}
NS_IMETHODIMP nsPref::SetRectPref(const char *pref,
int16 left, int16 top,
int16 right, int16 bottom)
{
return _convertRes(PREF_SetRectPref(pref, left, top, right, bottom));
}
/*
* Get Defaults
*/
NS_IMETHODIMP nsPref::GetDefaultCharPref(const char *pref,
char * return_buf,
int * buf_length)
{
return _convertRes(PREF_GetDefaultCharPref(pref, return_buf, buf_length));
}
NS_IMETHODIMP nsPref::GetDefaultIntPref(const char *pref,
int32 * return_int)
{
return _convertRes(PREF_GetDefaultIntPref(pref, return_int));
}
NS_IMETHODIMP nsPref::GetDefaultBoolPref(const char *pref,
XP_Bool * return_val)
{
return _convertRes(PREF_GetDefaultBoolPref(pref, return_val));
}
NS_IMETHODIMP nsPref::GetDefaultBinaryPref(const char *pref,
void * return_val,
int * buf_length)
{
return _convertRes(PREF_GetDefaultBinaryPref(pref, return_val, buf_length));
}
NS_IMETHODIMP nsPref::GetDefaultColorPref(const char *pref,
uint8 *red, uint8 *green,
uint8 *blue)
{
return _convertRes(PREF_GetDefaultColorPref(pref, red, green, blue));
}
NS_IMETHODIMP nsPref::GetDefaultColorPrefDWord(const char *pref,
uint32 *colorref)
{
return _convertRes(PREF_GetDefaultColorPrefDWord(pref, colorref));
}
NS_IMETHODIMP nsPref::GetDefaultRectPref(const char *pref,
int16 *left, int16 *top,
int16 *right, int16 *bottom)
{
return _convertRes(PREF_GetDefaultRectPref(pref,
left, top, right, bottom));
}
/*
* Set defaults
*/
NS_IMETHODIMP nsPref::SetDefaultCharPref(const char *pref,const char* value)
{
return _convertRes(PREF_SetDefaultCharPref(pref, value));
}
NS_IMETHODIMP nsPref::SetDefaultIntPref(const char *pref,int32 value)
{
return _convertRes(PREF_SetDefaultIntPref(pref, value));
}
NS_IMETHODIMP nsPref::SetDefaultBoolPref(const char *pref, PRBool value)
{
return _convertRes(PREF_SetDefaultBoolPref(pref, value));
}
NS_IMETHODIMP nsPref::SetDefaultBinaryPref(const char *pref,
void * value, long size)
{
return _convertRes(PREF_SetDefaultBinaryPref(pref, value, size));
}
NS_IMETHODIMP nsPref::SetDefaultColorPref(const char *pref,
uint8 red, uint8 green, uint8 blue)
{
return _convertRes(PREF_SetDefaultColorPref(pref, red, green, blue));
}
NS_IMETHODIMP nsPref::SetDefaultRectPref(const char *pref,
int16 left, int16 top,
int16 right, int16 bottom)
{
return _convertRes(PREF_SetDefaultRectPref(pref, left, top, right, bottom));
}
/*
* Copy prefs
*/
NS_IMETHODIMP nsPref::CopyCharPref(const char *pref, char ** return_buf)
{
return _convertRes(PREF_CopyCharPref(pref, return_buf));
}
NS_IMETHODIMP nsPref::CopyBinaryPref(const char *pref,
void ** return_value, int *size)
{
return _convertRes(PREF_CopyBinaryPref(pref, return_value, size));
}
NS_IMETHODIMP nsPref::CopyDefaultCharPref( const char *pref,
char ** return_buffer )
{
return _convertRes(PREF_CopyDefaultCharPref(pref, return_buffer));
}
NS_IMETHODIMP nsPref::CopyDefaultBinaryPref(const char *pref,
void ** return_val, int * size)
{
return _convertRes(PREF_CopyDefaultBinaryPref(pref, return_val, size));
}
/*
* Path prefs
*/
NS_IMETHODIMP nsPref::CopyPathPref(const char *pref, char ** return_buf)
{
#ifndef XP_MAC
return _convertRes(PREF_CopyPathPref(pref, return_buf));
#endif
}
NS_IMETHODIMP nsPref::SetPathPref(const char *pref,
const char *path, PRBool set_default)
{
#ifndef XP_MAC
return _convertRes(PREF_SetPathPref(pref, path, set_default));
#endif
}
/*
* Pref info
*/
NS_IMETHODIMP nsPref::PrefIsLocked(const char *pref, XP_Bool *res)
{
if (res == NULL) {
return NS_ERROR_INVALID_POINTER;
}
*res = PREF_PrefIsLocked(pref);
return NS_OK;
}
/*
* Save pref files
*/
NS_IMETHODIMP nsPref::SavePrefFile(void)
{
return _convertRes(PREF_SavePrefFile());
}
NS_IMETHODIMP nsPref::SavePrefFileAs(const char *filename)
{
return _convertRes(PREF_SavePrefFileAs(filename));
}
NS_IMETHODIMP nsPref::SaveLIPrefFile(const char *filename)
{
return _convertRes(PREF_SaveLIPrefFile(filename));
}
/*
* Callbacks
*/
NS_IMETHODIMP nsPref::RegisterCallback( const char* domain,
PrefChangedFunc callback,
void* instance_data )
{
PREF_RegisterCallback(domain, callback, instance_data);
return NS_OK;
}
NS_IMETHODIMP nsPref::UnregisterCallback( const char* domain,
PrefChangedFunc callback,
void* instance_data )
{
return _convertRes(PREF_UnregisterCallback(domain, callback, instance_data));
}
class nsPrefFactory: public nsIFactory {
NS_DECL_ISUPPORTS
nsPrefFactory() {
NS_INIT_REFCNT();
PR_AtomicIncrement(&g_InstanceCount);
}
~nsPrefFactory() {
PR_AtomicDecrement(&g_InstanceCount);
}
NS_IMETHOD CreateInstance(nsISupports *aDelegate,
const nsIID &aIID,
void **aResult);
NS_IMETHOD LockFactory(PRBool aLock) {
if (aLock) {
PR_AtomicIncrement(&g_LockCount);
} else {
PR_AtomicDecrement(&g_LockCount);
}
return NS_OK;
};
};
NS_DEFINE_IID(kFactoryIID, NS_IFACTORY_IID);
NS_IMPL_ISUPPORTS(nsPrefFactory, kFactoryIID);
nsresult nsPrefFactory::CreateInstance(nsISupports *aDelegate,
const nsIID &aIID,
void **aResult)
{
if (aDelegate != NULL) {
return NS_ERROR_NO_AGGREGATION;
}
nsPref *t = nsPref::GetInstance();
if (t == NULL) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsresult res = t->QueryInterface(aIID, aResult);
if (NS_FAILED(res)) {
*aResult = NULL;
}
return res;
}
#ifdef XP_MAC
extern "C" NS_EXPORT nsresult NSGetFactory_PREF_DLL(const nsCID &aCID, nsIFactory **aFactory)
#else
extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, nsIFactory **aFactory)
#endif
{
if (aFactory == NULL) {
return NS_ERROR_NULL_POINTER;
}
if (aCID.Equals(kPrefCID)) {
nsPrefFactory *factory = new nsPrefFactory();
nsresult res = factory->QueryInterface(kFactoryIID, (void **) aFactory);
if (NS_FAILED(res)) {
*aFactory = NULL;
delete factory;
}
return res;
}
return NS_NOINTERFACE;
}
#ifdef XP_MAC
extern "C" NS_EXPORT PRBool NSCanUnload_PREF_DLL()
#else
extern "C" NS_EXPORT PRBool NSCanUnload()
#endif
{
return PRBool(g_InstanceCount == 0 && g_LockCount == 0);
}
extern "C" NS_EXPORT nsresult NSRegisterSelf(const char *path)
{
return nsRepository::RegisterFactory(kPrefCID, path,
PR_TRUE, PR_TRUE);
}
extern "C" NS_EXPORT nsresult NSUnregisterSelf(const char *path)
{
return nsRepository::UnregisterFactory(kPrefCID, path);
}

View File

@@ -17,30 +17,39 @@
*/
#include "jsapi.h"
#include "xp_core.h"
#include "xp_mcom.h"
#include "xp_qsort.h"
#if defined(XP_MAC)
#include <stat.h>
#else
#include <sys/stat.h>
#endif
#include <errno.h>
#ifdef _WIN32
#include "windows.h"
#endif
#ifdef MOZ_ADMIN_LIB
#include "prefldap.h"
#endif
#include "prefapi.h"
#if defined(XP_MAC) || defined(XP_UNIX)
#include "fe_proto.h"
#endif
#if defined(XP_WIN) || defined(XP_OS2)
#include "npapi.h"
#include "assert.h"
#define NOT_NULL(X) X
#define XP_ASSERT(X) assert(X)
#if defined(XP_PC) || defined(XP_OS2)
#define LINEBREAK "\n"
#endif
#ifndef NO_SECURITY
#include "sechash.h"
#ifndef NSPR20
#include "prhash.h"
#else
#include "plhash.h"
#endif
#include "plstr.h"
#include "plhash.h"
#include "plbase64.h"
#include "prlog.h"
#include "prmem.h"
#include "prprf.h"
/* WHS TEMPORARY */
#define XP_QSORT qsort
#if defined(XP_MAC) && defined (__MWERKS__)
/* Can't get the xp people to fix warnings... */
@@ -55,9 +64,9 @@ JSObject * m_GlobalConfigObject = NULL;
static char * m_filename = NULL;
static char * m_lifilename = NULL;
static struct CallbackNode* m_Callbacks = NULL;
static XP_Bool m_ErrorOpeningUserPrefs = FALSE;
static XP_Bool m_CallbacksEnabled = FALSE;
static XP_Bool m_IsAnyPrefLocked = FALSE;
static PRBool m_ErrorOpeningUserPrefs = FALSE;
static PRBool m_CallbacksEnabled = FALSE;
static PRBool m_IsAnyPrefLocked = FALSE;
static PRHashTable* m_HashTable = NULL;
/* LI_STUFF - PREF_LILOCAL here to flag prefs as transferable or not */
@@ -77,7 +86,7 @@ typedef union
{
char* stringVal;
int32 intVal;
XP_Bool boolVal;
PRBool boolVal;
} PrefValue;
typedef struct
@@ -114,15 +123,15 @@ pref_FreeEntry(void *pool, PRHashEntry *he, uint flag)
PrefNode *pref = (PrefNode *) he->value;
if (pref) {
if (pref->flags & PREF_STRING) {
XP_FREEIF(pref->defaultPref.stringVal);
XP_FREEIF(pref->userPref.stringVal);
PR_FREEIF(pref->defaultPref.stringVal);
PR_FREEIF(pref->userPref.stringVal);
}
XP_FREE(he->value);
PR_Free(he->value);
}
if (flag == HT_FREE_ENTRY) {
XP_FREEIF((void *)he->key);
XP_FREE(he);
PR_FREEIF((void *)he->key);
PR_Free(he);
}
}
@@ -145,13 +154,13 @@ struct CallbackNode {
/* -- Prototypes */
int pref_DoCallback(const char* changed_pref);
int pref_OpenFile(const char* filename, XP_Bool is_error_fatal, XP_Bool verifyHash, XP_Bool bGlobalContext);
XP_Bool pref_VerifyLockFile(char* buf, long buflen);
int pref_OpenFile(const char* filename, PRBool is_error_fatal, PRBool verifyHash, PRBool bGlobalContext);
PRBool pref_VerifyLockFile(char* buf, long buflen);
int pref_GetCharPref(const char *pref_name, char * return_buffer, int * length, XP_Bool get_default);
int pref_CopyCharPref(const char *pref_name, char ** return_buffer, XP_Bool get_default);
int pref_GetIntPref(const char *pref_name,int32 * return_int, XP_Bool get_default);
int pref_GetBoolPref(const char *pref_name, XP_Bool * return_value, XP_Bool get_default);
int pref_GetCharPref(const char *pref_name, char * return_buffer, int * length, PRBool get_default);
int pref_CopyCharPref(const char *pref_name, char ** return_buffer, PRBool get_default);
int pref_GetIntPref(const char *pref_name,int32 * return_int, PRBool get_default);
int pref_GetBoolPref(const char *pref_name, XP_Bool * return_value, PRBool get_default);
JSBool PR_CALLBACK pref_BranchCallback(JSContext *cx, JSScript *script);
void pref_ErrorReporter(JSContext *cx, const char *message,JSErrorReport *report);
@@ -163,7 +172,7 @@ int pref_HashPref(const char *key, PrefValue value, PrefType type, PrefAction ac
extern JSBool pref_InitInitialObjects(void);
#endif
PRIVATE JSClass global_class = {
static JSClass global_class = {
"global", 0,
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
@@ -184,7 +193,7 @@ JSBool PR_CALLBACK pref_NativeLIDefPref(JSContext *cx, JSObject *obj, unsigned i
/* LI_STUFF added localPref pref_NativeLILocalPref, 1 */
PRIVATE JSFunctionSpec autoconf_methods[] = {
static JSFunctionSpec autoconf_methods[] = {
{ "pref", pref_NativeDefaultPref, 2 },
{ "defaultPref", pref_NativeDefaultPref, 2 },
{ "user_pref", pref_NativeUserPref, 2 },
@@ -199,21 +208,21 @@ PRIVATE JSFunctionSpec autoconf_methods[] = {
{ NULL, NULL, 0 }
};
PRIVATE JSPropertySpec autoconf_props[] = {
static JSPropertySpec autoconf_props[] = {
{0}
};
PRIVATE JSClass autoconf_class = {
static JSClass autoconf_class = {
"PrefConfig", 0,
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
};
int pref_OpenFile(const char* filename, XP_Bool is_error_fatal, XP_Bool verifyHash, XP_Bool bGlobalContext)
int pref_OpenFile(const char* filename, PRBool is_error_fatal, PRBool verifyHash, PRBool bGlobalContext)
{
int ok = PREF_ERROR;
XP_File fp;
XP_StatStruct stats;
FILE *fp;
struct stat stats;
long fileLength;
stats.st_size = 0;
@@ -228,7 +237,7 @@ int pref_OpenFile(const char* filename, XP_Bool is_error_fatal, XP_Bool verifyHa
if (fp) {
char* readBuf = (char *) malloc(fileLength * sizeof(char));
if (readBuf) {
fileLength = XP_FileRead(readBuf, fileLength, fp);
fileLength = fread(readBuf, sizeof(char), fileLength, fp);
if ( verifyHash && pref_VerifyLockFile(readBuf, fileLength) == FALSE )
{
@@ -241,13 +250,13 @@ int pref_OpenFile(const char* filename, XP_Bool is_error_fatal, XP_Bool verifyHa
}
free(readBuf);
}
XP_FileClose(fp);
fclose(fp);
/* If the user prefs file exists but generates an error,
don't clobber the file when we try to save it. */
if ((!readBuf || ok != PREF_NOERROR) && is_error_fatal)
m_ErrorOpeningUserPrefs = TRUE;
#ifdef XP_WIN
#ifdef XP_PC
if (m_ErrorOpeningUserPrefs && is_error_fatal)
MessageBox(NULL,"Error in preference file (prefs.js). Default preferences will be used.","Netscape - Warning", MB_OK);
#endif
@@ -260,9 +269,10 @@ int pref_OpenFile(const char* filename, XP_Bool is_error_fatal, XP_Bool verifyHa
and verifies the first line of the buffer expresses the correct hash in the form:
// xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx
where each 'xx' is a hex value. */
XP_Bool pref_VerifyLockFile(char* buf, long buflen)
PRBool pref_VerifyLockFile(char* buf, long buflen)
{
XP_Bool success = FALSE;
#ifndef NO_SECURITY
PRBool success = FALSE;
const int obscure_value = 7;
const long hash_length = 51; /* len = 48 chars of MD5 + // + EOL */
unsigned char digest[16];
@@ -291,20 +301,22 @@ XP_Bool pref_VerifyLockFile(char* buf, long buflen)
MD5_DestroyContext(md5_cxt, PR_TRUE);
XP_SPRINTF(szHash, "%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x",
PR_snprintf(szHash, 64, "%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x",
(int)digest[0],(int)digest[1],(int)digest[2],(int)digest[3],
(int)digest[4],(int)digest[5],(int)digest[6],(int)digest[7],
(int)digest[8],(int)digest[9],(int)digest[10],(int)digest[11],
(int)digest[12],(int)digest[13],(int)digest[14],(int)digest[15]);
success = ( strncmp((const char*) buf + 3, szHash, hash_length - 4) == 0 );
success = ( PL_strncmp((const char*) buf + 3, szHash, hash_length - 4) == 0 );
}
return success;
#else
/*
* Should return 'success', but since the MD5 code is stubbed out,
* just return 'TRUE' until we have a replacement.
*/
return TRUE;
#endif
}
PR_IMPLEMENT(int)
@@ -383,7 +395,7 @@ PREF_Init(char *filename)
}
#if !defined(XP_WIN) && !defined(XP_OS2)
#if !defined(XP_PC) && !defined(XP_OS2) && !defined(XP_MAC)
ok = pref_InitInitialObjects();
#endif
}
@@ -442,8 +454,8 @@ PREF_Cleanup()
while (node) {
next_node = node->next;
XP_FREE(node->domain);
XP_FREE(node);
PR_Free(node->domain);
PR_Free(node);
node = next_node;
}
if (m_mochaContext) JS_DestroyContext(m_mochaContext);
@@ -472,7 +484,7 @@ PREF_ReadLockFile(const char *filename)
/* This is more recent than the below 3 routines which should be obsoleted */
PR_IMPLEMENT(JSBool)
PREF_EvaluateConfigScript(const char * js_buffer, size_t length,
const char* filename, XP_Bool bGlobalContext, XP_Bool bCallbacks)
const char* filename, PRBool bGlobalContext, PRBool bCallbacks)
{
JSBool ok;
jsval result;
@@ -592,7 +604,7 @@ PREF_SetIntPref(const char *pref_name, int32 value)
}
PR_IMPLEMENT(int)
PREF_SetBoolPref(const char *pref_name, XP_Bool value)
PREF_SetBoolPref(const char *pref_name, PRBool value)
{
PrefValue pref;
pref.boolVal = value;
@@ -600,26 +612,10 @@ PREF_SetBoolPref(const char *pref_name, XP_Bool value)
return pref_HashPref(pref_name, pref, PREF_BOOL, PREF_SETUSER);
}
#if !defined(XP_WIN) && !defined(XP_OS2)
extern char *EncodeBase64Buffer(char *subject, long size);
extern char *DecodeBase64Buffer(char *subject);
#else
/* temporary to make windows into a DLL...add a assert if used */
char *EncodeBase64Buffer(char *subject, long size)
{
assert(0);
}
char *DecodeBase64Buffer(char *subject)
{
assert(0);
}
#endif
PR_IMPLEMENT(int)
PREF_SetBinaryPref(const char *pref_name, void * value, long size)
{
char* buf = EncodeBase64Buffer(value, size);
char* buf = PL_Base64Encode(value, size, NULL);
if (buf) {
PrefValue pref;
@@ -635,7 +631,7 @@ PREF_SetColorPref(const char *pref_name, uint8 red, uint8 green, uint8 blue)
{
char colstr[63];
PrefValue pref;
XP_SPRINTF( colstr, "#%02X%02X%02X", red, green, blue);
PR_snprintf( colstr, 63, "#%02X%02X%02X", red, green, blue);
pref.stringVal = colstr;
return pref_HashPref(pref_name, pref, PREF_STRING, PREF_SETUSER);
@@ -655,7 +651,7 @@ PREF_SetColorPrefDWord(const char *pref_name, uint32 colorref)
red = MYGetRValue(colorref);
green = MYGetGValue(colorref);
blue = MYGetboolVal(colorref);
XP_SPRINTF( colstr, "#%02X%02X%02X", red, green, blue);
PR_snprintf( colstr, 63, "#%02X%02X%02X", red, green, blue);
pref.stringVal = colstr;
return pref_HashPref(pref_name, pref, PREF_STRING, PREF_SETUSER);
@@ -666,7 +662,7 @@ PREF_SetRectPref(const char *pref_name, int16 left, int16 top, int16 right, int1
{
char rectstr[63];
PrefValue pref;
XP_SPRINTF( rectstr, "%d,%d,%d,%d", left, top, right, bottom);
PR_snprintf( rectstr, 63, "%d,%d,%d,%d", left, top, right, bottom);
pref.stringVal = rectstr;
return pref_HashPref(pref_name, pref, PREF_STRING, PREF_SETUSER);
@@ -695,7 +691,7 @@ PREF_SetDefaultIntPref(const char *pref_name,int32 value)
}
PR_IMPLEMENT(int)
PREF_SetDefaultBoolPref(const char *pref_name,XP_Bool value)
PREF_SetDefaultBoolPref(const char *pref_name,PRBool value)
{
PrefValue pref;
pref.boolVal = value;
@@ -706,7 +702,7 @@ PREF_SetDefaultBoolPref(const char *pref_name,XP_Bool value)
PR_IMPLEMENT(int)
PREF_SetDefaultBinaryPref(const char *pref_name,void * value,long size)
{
char* buf = EncodeBase64Buffer(value, size);
char* buf = PL_Base64Encode(value, size, NULL);
if (buf) {
PrefValue pref;
pref.stringVal = buf;
@@ -720,7 +716,7 @@ PR_IMPLEMENT(int)
PREF_SetDefaultColorPref(const char *pref_name, uint8 red, uint8 green, uint8 blue)
{
char colstr[63];
XP_SPRINTF( colstr, "#%02X%02X%02X", red, green, blue);
PR_snprintf( colstr, 63, "#%02X%02X%02X", red, green, blue);
return PREF_SetDefaultCharPref(pref_name, colstr);
}
@@ -729,7 +725,7 @@ PR_IMPLEMENT(int)
PREF_SetDefaultRectPref(const char *pref_name, int16 left, int16 top, int16 right, int16 bottom)
{
char rectstr[63];
XP_SPRINTF( rectstr, "%d,%d,%d,%d", left, top, right, bottom);
PR_snprintf( rectstr, 63, "%d,%d,%d,%d", left, top, right, bottom);
return PREF_SetDefaultCharPref(pref_name, rectstr);
}
@@ -749,7 +745,7 @@ pref_saveLIPref(PRHashEntry *he, int i, void *arg)
if (tmp_str) {
PR_snprintf(buf, 2048, "user_pref(\"%s\", \"%s\");" LINEBREAK,
(char*) he->key, tmp_str);
XP_FREE(tmp_str);
PR_Free(tmp_str);
}
}
else if (pref->flags & PREF_INT) {
@@ -761,7 +757,7 @@ pref_saveLIPref(PRHashEntry *he, int i, void *arg)
(pref->userPref.boolVal) ? "true" : "false");
}
prefArray[i] = XP_STRDUP(buf);
prefArray[i] = PL_strdup(buf);
} else if (pref && PREF_IS_LOCKED(pref) && !PREF_HAS_LI_VALUE(pref)) {
char buf[2048];
@@ -770,7 +766,7 @@ pref_saveLIPref(PRHashEntry *he, int i, void *arg)
if (tmp_str) {
PR_snprintf(buf, 2048, "user_pref(\"%s\", \"%s\");" LINEBREAK,
(char*) he->key, tmp_str);
XP_FREE(tmp_str);
PR_Free(tmp_str);
}
}
else if (pref->flags & PREF_INT) {
@@ -782,7 +778,7 @@ pref_saveLIPref(PRHashEntry *he, int i, void *arg)
(pref->defaultPref.boolVal) ? "true" : "false");
}
prefArray[i] = XP_STRDUP(buf);
prefArray[i] = PL_strdup(buf);
}
return 0;
}
@@ -802,7 +798,7 @@ pref_savePref(PRHashEntry *he, int i, void *arg)
if (tmp_str) {
PR_snprintf(buf, 2048, "user_pref(\"%s\", \"%s\");" LINEBREAK,
(char*) he->key, tmp_str);
XP_FREE(tmp_str);
PR_Free(tmp_str);
}
}
else if (pref->flags & PREF_INT) {
@@ -814,7 +810,7 @@ pref_savePref(PRHashEntry *he, int i, void *arg)
(pref->userPref.boolVal) ? "true" : "false");
}
prefArray[i] = XP_STRDUP(buf);
prefArray[i] = PL_strdup(buf);
} else if (pref && PREF_IS_LOCKED(pref)) {
char buf[2048];
@@ -823,7 +819,7 @@ pref_savePref(PRHashEntry *he, int i, void *arg)
if (tmp_str) {
PR_snprintf(buf, 2048, "user_pref(\"%s\", \"%s\");" LINEBREAK,
(char*) he->key, tmp_str);
XP_FREE(tmp_str);
PR_Free(tmp_str);
}
}
else if (pref->flags & PREF_INT) {
@@ -835,7 +831,7 @@ pref_savePref(PRHashEntry *he, int i, void *arg)
(pref->defaultPref.boolVal) ? "true" : "false");
}
prefArray[i] = XP_STRDUP(buf);
prefArray[i] = PL_strdup(buf);
}
/* LI_STUFF?? may need to write out the lilocal stuff here if it applies - probably won't support in
the prefs.js file. We won't need to worry about the user.js since it is read only.
@@ -867,6 +863,10 @@ this is new. clients should use the old PREF_SavePrefFile or new PREF_SaveLIPre
This is called by them and does the right thing.
?? make this private to this file.
*/
#define PREF_FILE_BANNER "// Netscape User Preferences" LINEBREAK \
"// This is a generated file! Do not edit." LINEBREAK LINEBREAK
PR_IMPLEMENT(int)
PREF_SavePrefFileWith(const char *filename, PRHashEnumerator heSaveProc) {
int success = PREF_ERROR;
@@ -878,22 +878,20 @@ PREF_SavePrefFileWith(const char *filename, PRHashEnumerator heSaveProc) {
return PREF_NOT_INITIALIZED;
/* ?! Don't save (blank) user prefs if there was an error reading them */
#if defined(XP_WIN) || defined(XP_OS2)
#if defined(XP_PC) || defined(XP_OS2)
if (!filename)
#else
if (!filename || m_ErrorOpeningUserPrefs)
#endif
return PREF_NOERROR;
valueArray = (char**) XP_CALLOC(sizeof(char*), m_HashTable->nentries);
valueArray = (char**) PR_Calloc(sizeof(char*), m_HashTable->nentries);
if (!valueArray)
return PREF_OUT_OF_MEMORY;
fp = fopen(filename, "w");
if (fp) {
XP_FileWrite("// Netscape User Preferences" LINEBREAK
"// This is a generated file! Do not edit." LINEBREAK LINEBREAK,
-1, fp);
fwrite(PREF_FILE_BANNER, sizeof(char), PL_strlen(PREF_FILE_BANNER), fp);
/* LI_STUFF here we pass in the heSaveProc proc used so that li can do its own thing */
PR_HashTableEnumerateEntries(m_HashTable, heSaveProc, valueArray);
@@ -904,18 +902,19 @@ PREF_SavePrefFileWith(const char *filename, PRHashEnumerator heSaveProc) {
{
if (valueArray[valueIdx])
{
XP_FileWrite(valueArray[valueIdx], -1, fp);
XP_FREE(valueArray[valueIdx]);
fwrite(valueArray[valueIdx], sizeof(char),
PL_strlen(valueArray[valueIdx]), fp);
PR_Free(valueArray[valueIdx]);
}
}
XP_FileClose(fp);
fclose(fp);
success = PREF_NOERROR;
}
else
success = errno;
XP_FREE(valueArray);
PR_Free(valueArray);
return success;
}
@@ -945,7 +944,7 @@ PREF_SavePrefFileAs(const char *filename) {
return PREF_SavePrefFileWith(filename, pref_savePref);
}
int pref_GetCharPref(const char *pref_name, char * return_buffer, int * length, XP_Bool get_default)
int pref_GetCharPref(const char *pref_name, char * return_buffer, int * length, PRBool get_default)
{
int result = PREF_ERROR;
char* stringVal;
@@ -968,7 +967,7 @@ int pref_GetCharPref(const char *pref_name, char * return_buffer, int * length,
*length = strlen(stringVal) + 1;
}
else {
strncpy(return_buffer, stringVal, PR_MIN(*length - 1, strlen(stringVal) + 1));
PL_strncpy(return_buffer, stringVal, PR_MIN(*length - 1, strlen(stringVal) + 1));
return_buffer[*length - 1] = '\0';
}
result = PREF_OK;
@@ -977,7 +976,7 @@ int pref_GetCharPref(const char *pref_name, char * return_buffer, int * length,
return result;
}
int pref_CopyCharPref(const char *pref_name, char ** return_buffer, XP_Bool get_default)
int pref_CopyCharPref(const char *pref_name, char ** return_buffer, PRBool get_default)
{
int result = PREF_ERROR;
char* stringVal;
@@ -995,14 +994,14 @@ int pref_CopyCharPref(const char *pref_name, char ** return_buffer, XP_Bool get_
stringVal = pref->userPref.stringVal;
if (stringVal) {
*return_buffer = XP_STRDUP(stringVal);
*return_buffer = PL_strdup(stringVal);
result = PREF_OK;
}
}
return result;
}
int pref_GetIntPref(const char *pref_name,int32 * return_int, XP_Bool get_default)
int pref_GetIntPref(const char *pref_name,int32 * return_int, PRBool get_default)
{
int result = PREF_ERROR;
PrefNode* pref;
@@ -1021,7 +1020,7 @@ int pref_GetIntPref(const char *pref_name,int32 * return_int, XP_Bool get_defaul
return result;
}
int pref_GetBoolPref(const char *pref_name, XP_Bool * return_value, XP_Bool get_default)
int pref_GetBoolPref(const char *pref_name, XP_Bool * return_value, PRBool get_default)
{
int result = PREF_ERROR;
PrefNode* pref;
@@ -1133,17 +1132,14 @@ PREF_GetBinaryPref(const char *pref_name, void * return_value, int *size)
result = PREF_CopyCharPref(pref_name, &buf);
if (result == PREF_NOERROR) {
char* debuf;
if (strlen(buf) == 0) { /* don't decode empty string ? */
XP_FREE(buf);
PR_Free(buf);
return -1;
}
debuf = DecodeBase64Buffer(buf);
XP_MEMCPY(return_value, debuf, *size);
PL_Base64Decode(buf, *size, return_value);
XP_FREE(buf);
XP_FREE(debuf);
PR_Free(buf);
}
return result;
}
@@ -1164,14 +1160,14 @@ ReadCharPrefUsing(const char *pref_name, void** return_value, int *size, CharPre
if (result == PREF_NOERROR) {
if (strlen(buf) == 0) { /* do not decode empty string? */
XP_FREE(buf);
PR_Free(buf);
return -1;
}
*return_value = DecodeBase64Buffer(buf);
*return_value = PL_Base64Decode(buf, 0, NULL);
*size = strlen(buf);
XP_FREE(buf);
PR_Free(buf);
}
return result;
}
@@ -1196,7 +1192,7 @@ PREF_CopyPathPref(const char *pref_name, char ** return_buffer)
}
PR_IMPLEMENT(int)
PREF_SetPathPref(const char *pref_name, const char *path, XP_Bool set_default)
PREF_SetPathPref(const char *pref_name, const char *path, PRBool set_default)
{
PrefAction action = set_default ? PREF_SETDEFAULT : PREF_SETUSER;
PrefValue pref;
@@ -1234,11 +1230,7 @@ PREF_GetDefaultBoolPref(const char *pref_name, XP_Bool * return_value)
PR_IMPLEMENT(int)
PREF_GetDefaultBinaryPref(const char *pref_name, void * return_value, int * length)
{
#ifdef XP_WIN
assert( FALSE );
#else
XP_ASSERT( FALSE );
#endif
PR_ASSERT( FALSE );
return TRUE;
}
@@ -1303,8 +1295,8 @@ pref_DeleteItem(PRHashEntry *he, int i, void *arg)
/* note if we're deleting "ldap" then we want to delete "ldap.xxx"
and "ldap" (if such a leaf node exists) but not "ldap_1.xxx" */
if (to_delete && (XP_STRNCMP(he->key, to_delete, len) == 0 ||
(len-1 == strlen(he->key) && XP_STRNCMP(he->key, to_delete, len-1) == 0)))
if (to_delete && (PL_strncmp(he->key, to_delete, len) == 0 ||
(len-1 == strlen(he->key) && PL_strncmp(he->key, to_delete, len-1) == 0)))
return HT_ENUMERATE_REMOVE;
else
return HT_ENUMERATE_NEXT;
@@ -1319,7 +1311,7 @@ PREF_DeleteBranch(const char *branch_name)
PR_HashTableEnumerateEntries(m_HashTable, pref_DeleteItem, (void*) branch_dot);
XP_FREE(branch_dot);
PR_Free(branch_dot);
return 0;
}
@@ -1361,11 +1353,7 @@ PR_IMPLEMENT(int)
PREF_GetConfigString(const char *obj_name, char * return_buffer, int size,
int index, const char *field)
{
#ifdef XP_WIN
assert( FALSE );
#else
XP_ASSERT( FALSE );
#endif
PR_ASSERT( FALSE );
return -1;
}
@@ -1380,7 +1368,7 @@ PREF_CopyConfigString(const char *obj_name, char **return_buffer)
if (pref && pref->flags & PREF_STRING) {
if (return_buffer)
*return_buffer = XP_STRDUP(pref->defaultPref.stringVal);
*return_buffer = PL_strdup(pref->defaultPref.stringVal);
success = PREF_NOERROR;
}
return success;
@@ -1398,10 +1386,10 @@ PREF_CopyIndexConfigString(const char *obj_name,
if (pref && pref->flags & PREF_STRING) {
if (return_buffer)
*return_buffer = XP_STRDUP(pref->defaultPref.stringVal);
*return_buffer = PL_strdup(pref->defaultPref.stringVal);
success = PREF_NOERROR;
}
XP_FREEIF(setup_buf);
PR_FREEIF(setup_buf);
return success;
}
@@ -1438,9 +1426,9 @@ PREF_GetConfigBool(const char *obj_name, XP_Bool *return_bool)
/*
* Hash table functions
*/
static XP_Bool pref_ValueChanged(PrefValue oldValue, PrefValue newValue, PrefType type)
static PRBool pref_ValueChanged(PrefValue oldValue, PrefValue newValue, PrefType type)
{
XP_Bool changed = TRUE;
PRBool changed = TRUE;
switch (type) {
case PREF_STRING:
if (oldValue.stringVal && newValue.stringVal)
@@ -1462,9 +1450,9 @@ static void pref_SetValue(PrefValue* oldValue, PrefValue newValue, PrefType type
{
switch (type) {
case PREF_STRING:
XP_ASSERT(newValue.stringVal);
XP_FREEIF(oldValue->stringVal);
oldValue->stringVal = newValue.stringVal ? XP_STRDUP(newValue.stringVal) : NULL;
PR_ASSERT(newValue.stringVal);
PR_FREEIF(oldValue->stringVal);
oldValue->stringVal = newValue.stringVal ? PL_strdup(newValue.stringVal) : NULL;
break;
default:
@@ -1487,15 +1475,15 @@ int pref_HashPref(const char *key, PrefValue value, PrefType type, PrefAction ac
return PREF_OUT_OF_MEMORY;
pref->flags = type;
if (pref->flags & PREF_BOOL)
pref->defaultPref.boolVal = (XP_Bool) -2;
pref->defaultPref.boolVal = (PRBool) -2;
/* ugly hack -- define it to a default that no pref will ever default to
this should really get fixed right by some out of band data */
if (pref->flags & PREF_INT)
pref->defaultPref.intVal = (int32) -5632;
PR_HashTableAdd(m_HashTable, XP_STRDUP(key), pref);
PR_HashTableAdd(m_HashTable, PL_strdup(key), pref);
}
else if (!(pref->flags & type)) {
XP_ASSERT(0); /* this shouldn't happen */
PR_ASSERT(0); /* this shouldn't happen */
return PREF_TYPE_CHANGE_ERR;
}
@@ -1657,7 +1645,7 @@ JSBool PR_CALLBACK pref_NativeGetPref
{
void* value = NULL;
PrefNode* pref;
XP_Bool prefExists = TRUE;
PRBool prefExists = TRUE;
if (argc >= 1 && JSVAL_IS_STRING(argv[0]))
{
@@ -1665,7 +1653,7 @@ JSBool PR_CALLBACK pref_NativeGetPref
pref = (PrefNode*) PR_HashTableLookup(m_HashTable, key);
if (pref) {
XP_Bool use_default = (PREF_IS_LOCKED(pref) || !PREF_HAS_USER_VALUE(pref));
PRBool use_default = (PREF_IS_LOCKED(pref) || !PREF_HAS_USER_VALUE(pref));
if (pref->flags & PREF_STRING) {
char* str = use_default ? pref->defaultPref.stringVal : pref->userPref.stringVal;
@@ -1684,10 +1672,10 @@ JSBool PR_CALLBACK pref_NativeGetPref
}
/* -- */
PR_IMPLEMENT(XP_Bool)
PR_IMPLEMENT(PRBool)
PREF_PrefIsLocked(const char *pref_name)
{
XP_Bool result = FALSE;
PRBool result = FALSE;
if (m_IsAnyPrefLocked) {
PrefNode* pref = (PrefNode*) PR_HashTableLookup(m_HashTable, pref_name);
if (pref && PREF_IS_LOCKED(pref))
@@ -1716,16 +1704,16 @@ PR_IMPLEMENT(int)
pref_addChild(PRHashEntry *he, int i, void *arg)
{
PrefChildIter* pcs = (PrefChildIter*) arg;
if ( XP_STRNCMP(he->key, pcs->parent, strlen(pcs->parent)) == 0 ) {
if ( PL_strncmp(he->key, pcs->parent, strlen(pcs->parent)) == 0 ) {
char buf[512];
char* nextdelim;
int parentlen = strlen(pcs->parent);
char* substring;
XP_Bool substringBordersSeparator = FALSE;
PRBool substringBordersSeparator = FALSE;
strncpy(buf, he->key, PR_MIN(512, strlen(he->key) + 1));
nextdelim = buf + parentlen;
if (parentlen < strlen(buf)) {
if (parentlen < PL_strlen(buf)) {
/* Find the next delimiter if any and truncate the string there */
nextdelim = strstr(nextdelim, ".");
if (nextdelim) {
@@ -1737,7 +1725,7 @@ pref_addChild(PRHashEntry *he, int i, void *arg)
if (substring)
{
int buflen = strlen(buf);
XP_ASSERT(substring[buflen] > 0);
PR_ASSERT(substring[buflen] > 0);
substringBordersSeparator = (substring[buflen] == '\0' || substring[buflen] == ';');
}
@@ -1753,8 +1741,8 @@ pref_addChild(PRHashEntry *he, int i, void *arg)
return HT_ENUMERATE_STOP;
}
#endif
XP_STRCAT(pcs->childList, buf);
XP_STRCAT(pcs->childList, ";");
PL_strcat(pcs->childList, buf);
PL_strcat(pcs->childList, ";");
}
}
return 0;
@@ -1779,7 +1767,7 @@ PREF_CreateChildList(const char* parent_node, char **child_list)
PR_HashTableEnumerateEntries(m_HashTable, pref_addChild, &pcs);
*child_list = pcs.childList;
XP_FREE(pcs.parent);
PR_Free(pcs.parent);
return (pcs.childList == NULL) ? PREF_OUT_OF_MEMORY : PREF_OK;
}
@@ -1801,7 +1789,7 @@ PREF_RegisterCallback(const char *pref_node,
{
struct CallbackNode* node = (struct CallbackNode*) malloc(sizeof(struct CallbackNode));
if (node) {
node->domain = XP_STRDUP(pref_node);
node->domain = PL_strdup(pref_node);
node->func = callback;
node->data = instance_data;
node->next = m_Callbacks;
@@ -1831,8 +1819,8 @@ PREF_UnregisterCallback(const char *pref_node,
prev_node->next = next_node;
else
m_Callbacks = next_node;
XP_FREE(node->domain);
XP_FREE(node);
PR_Free(node->domain);
PR_Free(node);
node = next_node;
result = PREF_NOERROR;
}
@@ -1850,7 +1838,7 @@ int pref_DoCallback(const char* changed_pref)
struct CallbackNode* node;
for (node = m_Callbacks; node != NULL; node = node->next)
{
if ( XP_STRNCMP(changed_pref, node->domain, strlen(node->domain)) == 0 ) {
if ( PL_strncmp(changed_pref, node->domain, strlen(node->domain)) == 0 ) {
int result2 = (*node->func) (changed_pref, node->data);
if (result2 != PREF_OK)
result = result2;
@@ -1861,7 +1849,7 @@ int pref_DoCallback(const char* changed_pref)
/* !! Front ends need to implement */
#ifndef XP_MAC
PR_IMPLEMENT(XP_Bool)
PR_IMPLEMENT(PRBool)
PREF_IsAutoAdminEnabled()
{
if (m_AutoAdminLib == NULL)
@@ -1879,22 +1867,13 @@ JSBool PR_CALLBACK pref_NativeGetLDAPAttr
{
#ifdef MOZ_ADMIN_LIB
ldap_func get_ldap_attributes = NULL;
#if (defined (XP_MAC) && defined(powerc)) || defined (XP_WIN) || defined(XP_UNIX)
#if (defined (XP_MAC) && defined(powerc)) || defined (XP_PC) || defined(XP_UNIX)
if (m_AutoAdminLib == NULL) {
m_AutoAdminLib = pref_LoadAutoAdminLib();
}
if (m_AutoAdminLib) {
get_ldap_attributes = (ldap_func)
#ifndef NSPR20
PR_FindSymbol(
#ifndef XP_WIN16
"pref_get_ldap_attributes"
#else
MAKEINTRESOURCE(1)
#endif
, m_AutoAdminLib);
#else /* NSPR20 */
PR_FindSymbol(
m_AutoAdminLib,
#ifndef XP_WIN16
@@ -1903,7 +1882,6 @@ JSBool PR_CALLBACK pref_NativeGetLDAPAttr
MAKEINTRESOURCE(1)
#endif
);
#endif /* NSPR20 */
}
if (get_ldap_attributes == NULL) {
/* This indicates the AutoAdmin dll was not found. */
@@ -1928,7 +1906,7 @@ JSBool PR_CALLBACK pref_NativeGetLDAPAttr
if (value) {
JSString* str = JS_NewStringCopyZ(cx, value);
XP_FREE(value);
PR_Free(value);
if (str) {
*rval = STRING_TO_JSVAL(str);
return JS_TRUE;
@@ -1976,15 +1954,15 @@ pref_printDebugInfo(PRHashEntry *he, int i, void *arg)
buf2 = PR_smprintf("%s %s</font><br>", buf1, val.boolVal ? "true" : "false");
}
if ((strlen(buf2) + strlen(pcs->childList) + 1) > pcs->bufsize) {
if ((PL_strlen(buf2) + PL_strlen(pcs->childList) + 1) > pcs->bufsize) {
pcs->bufsize *= 3;
pcs->childList = (char*) realloc(pcs->childList, sizeof(char) * pcs->bufsize);
if (!pcs->childList)
return HT_ENUMERATE_STOP;
}
XP_STRCAT(pcs->childList, buf2);
XP_FREE(buf1);
XP_FREE(buf2);
PL_strcat(pcs->childList, buf2);
PR_Free(buf1);
PR_Free(buf2);
return 0;
}
@@ -1995,7 +1973,7 @@ PREF_AboutConfig()
pcs.bufsize = 8192;
pcs.childList = (char*) malloc(sizeof(char) * pcs.bufsize);
pcs.childList[0] = '\0';
XP_STRCAT(pcs.childList, "<HTML>");
PL_strcat(pcs.childList, "<HTML>");
PR_HashTableEnumerateEntries(m_HashTable, pref_printDebugInfo, &pcs);
@@ -2028,7 +2006,7 @@ pref_BranchCallback(JSContext *cx, JSScript *script)
lm_language_name);
if (message) {
ok = FE_Confirm(decoder->window_context, message);
XP_FREE(message);
PR_Free(message);
}
}
#endif
@@ -2073,7 +2051,7 @@ pref_ErrorReporter(JSContext *cx, const char *message,
if (last) {
pref_Alert(last);
XP_FREE(last);
PR_Free(last);
}
}
@@ -2086,7 +2064,7 @@ void pref_Alert(char* msg)
#endif
FE_Alert(NULL, msg);
#endif
#if defined (XP_WIN)
#if defined (XP_PC)
MessageBox (NULL, msg, "Netscape -- JS Preference Warning", MB_OK);
#endif
}
@@ -2094,7 +2072,7 @@ void pref_Alert(char* msg)
#ifdef XP_WIN16
#define ADMNLIBNAME "adm1640.dll"
#elif defined XP_WIN32 || defined XP_OS2
#elif defined XP_PC || defined XP_OS2
#define ADMNLIBNAME "adm3240.dll"
#elif defined XP_UNIX
#define ADMNLIBNAME "libAutoAdmin.so"
@@ -2114,7 +2092,7 @@ pref_LoadAutoAdminLib()
PR_SetLibraryPath( "/usr/local/netscape/" );
#endif
#ifdef XP_UNIX
#if defined(XP_UNIX) && !defined(B1M)
{
char aalib[MAXPATHLEN];
@@ -2143,11 +2121,7 @@ pref_LoadAutoAdminLib()
}
/* Make sure it's really libAutoAdmin.so */
#ifndef NSPR20
if ( lib && PR_FindSymbol("_POLARIS_SplashPro", lib) == NULL ) return NULL;
#else
if ( lib && PR_FindSymbol(lib, "_POLARIS_SplashPro") == NULL ) return NULL;
#endif
#else
lib = PR_LoadLibrary( ADMNLIBNAME );
#endif
@@ -2175,7 +2149,7 @@ static JSBool pref_HashJSPref(unsigned int argc, jsval *argv, PrefAction action)
/* this is somehow fixing an internal compiler error for win16 */
PrefValue value;
const char *key;
XP_Bool bIsBool, bIsInt, bIsString;
PRBool bIsBool, bIsInt, bIsString;
;
if (argc < 2)

View File

@@ -17,30 +17,39 @@
*/
#include "jsapi.h"
#include "xp_core.h"
#include "xp_mcom.h"
#include "xp_qsort.h"
#if defined(XP_MAC)
#include <stat.h>
#else
#include <sys/stat.h>
#endif
#include <errno.h>
#ifdef _WIN32
#include "windows.h"
#endif
#ifdef MOZ_ADMIN_LIB
#include "prefldap.h"
#endif
#include "prefapi.h"
#if defined(XP_MAC) || defined(XP_UNIX)
#include "fe_proto.h"
#endif
#if defined(XP_WIN) || defined(XP_OS2)
#include "npapi.h"
#include "assert.h"
#define NOT_NULL(X) X
#define XP_ASSERT(X) assert(X)
#if defined(XP_PC) || defined(XP_OS2)
#define LINEBREAK "\n"
#endif
#ifndef NO_SECURITY
#include "sechash.h"
#ifndef NSPR20
#include "prhash.h"
#else
#include "plhash.h"
#endif
#include "plstr.h"
#include "plhash.h"
#include "plbase64.h"
#include "prlog.h"
#include "prmem.h"
#include "prprf.h"
/* WHS TEMPORARY */
#define XP_QSORT qsort
#if defined(XP_MAC) && defined (__MWERKS__)
/* Can't get the xp people to fix warnings... */
@@ -55,9 +64,9 @@ JSObject * m_GlobalConfigObject = NULL;
static char * m_filename = NULL;
static char * m_lifilename = NULL;
static struct CallbackNode* m_Callbacks = NULL;
static XP_Bool m_ErrorOpeningUserPrefs = FALSE;
static XP_Bool m_CallbacksEnabled = FALSE;
static XP_Bool m_IsAnyPrefLocked = FALSE;
static PRBool m_ErrorOpeningUserPrefs = FALSE;
static PRBool m_CallbacksEnabled = FALSE;
static PRBool m_IsAnyPrefLocked = FALSE;
static PRHashTable* m_HashTable = NULL;
/* LI_STUFF - PREF_LILOCAL here to flag prefs as transferable or not */
@@ -77,7 +86,7 @@ typedef union
{
char* stringVal;
int32 intVal;
XP_Bool boolVal;
PRBool boolVal;
} PrefValue;
typedef struct
@@ -114,15 +123,15 @@ pref_FreeEntry(void *pool, PRHashEntry *he, uint flag)
PrefNode *pref = (PrefNode *) he->value;
if (pref) {
if (pref->flags & PREF_STRING) {
XP_FREEIF(pref->defaultPref.stringVal);
XP_FREEIF(pref->userPref.stringVal);
PR_FREEIF(pref->defaultPref.stringVal);
PR_FREEIF(pref->userPref.stringVal);
}
XP_FREE(he->value);
PR_Free(he->value);
}
if (flag == HT_FREE_ENTRY) {
XP_FREEIF((void *)he->key);
XP_FREE(he);
PR_FREEIF((void *)he->key);
PR_Free(he);
}
}
@@ -145,13 +154,13 @@ struct CallbackNode {
/* -- Prototypes */
int pref_DoCallback(const char* changed_pref);
int pref_OpenFile(const char* filename, XP_Bool is_error_fatal, XP_Bool verifyHash, XP_Bool bGlobalContext);
XP_Bool pref_VerifyLockFile(char* buf, long buflen);
int pref_OpenFile(const char* filename, PRBool is_error_fatal, PRBool verifyHash, PRBool bGlobalContext);
PRBool pref_VerifyLockFile(char* buf, long buflen);
int pref_GetCharPref(const char *pref_name, char * return_buffer, int * length, XP_Bool get_default);
int pref_CopyCharPref(const char *pref_name, char ** return_buffer, XP_Bool get_default);
int pref_GetIntPref(const char *pref_name,int32 * return_int, XP_Bool get_default);
int pref_GetBoolPref(const char *pref_name, XP_Bool * return_value, XP_Bool get_default);
int pref_GetCharPref(const char *pref_name, char * return_buffer, int * length, PRBool get_default);
int pref_CopyCharPref(const char *pref_name, char ** return_buffer, PRBool get_default);
int pref_GetIntPref(const char *pref_name,int32 * return_int, PRBool get_default);
int pref_GetBoolPref(const char *pref_name, XP_Bool * return_value, PRBool get_default);
JSBool PR_CALLBACK pref_BranchCallback(JSContext *cx, JSScript *script);
void pref_ErrorReporter(JSContext *cx, const char *message,JSErrorReport *report);
@@ -163,7 +172,7 @@ int pref_HashPref(const char *key, PrefValue value, PrefType type, PrefAction ac
extern JSBool pref_InitInitialObjects(void);
#endif
PRIVATE JSClass global_class = {
static JSClass global_class = {
"global", 0,
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
@@ -184,7 +193,7 @@ JSBool PR_CALLBACK pref_NativeLIDefPref(JSContext *cx, JSObject *obj, unsigned i
/* LI_STUFF added localPref pref_NativeLILocalPref, 1 */
PRIVATE JSFunctionSpec autoconf_methods[] = {
static JSFunctionSpec autoconf_methods[] = {
{ "pref", pref_NativeDefaultPref, 2 },
{ "defaultPref", pref_NativeDefaultPref, 2 },
{ "user_pref", pref_NativeUserPref, 2 },
@@ -199,21 +208,21 @@ PRIVATE JSFunctionSpec autoconf_methods[] = {
{ NULL, NULL, 0 }
};
PRIVATE JSPropertySpec autoconf_props[] = {
static JSPropertySpec autoconf_props[] = {
{0}
};
PRIVATE JSClass autoconf_class = {
static JSClass autoconf_class = {
"PrefConfig", 0,
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
};
int pref_OpenFile(const char* filename, XP_Bool is_error_fatal, XP_Bool verifyHash, XP_Bool bGlobalContext)
int pref_OpenFile(const char* filename, PRBool is_error_fatal, PRBool verifyHash, PRBool bGlobalContext)
{
int ok = PREF_ERROR;
XP_File fp;
XP_StatStruct stats;
FILE *fp;
struct stat stats;
long fileLength;
stats.st_size = 0;
@@ -228,7 +237,7 @@ int pref_OpenFile(const char* filename, XP_Bool is_error_fatal, XP_Bool verifyHa
if (fp) {
char* readBuf = (char *) malloc(fileLength * sizeof(char));
if (readBuf) {
fileLength = XP_FileRead(readBuf, fileLength, fp);
fileLength = fread(readBuf, sizeof(char), fileLength, fp);
if ( verifyHash && pref_VerifyLockFile(readBuf, fileLength) == FALSE )
{
@@ -241,13 +250,13 @@ int pref_OpenFile(const char* filename, XP_Bool is_error_fatal, XP_Bool verifyHa
}
free(readBuf);
}
XP_FileClose(fp);
fclose(fp);
/* If the user prefs file exists but generates an error,
don't clobber the file when we try to save it. */
if ((!readBuf || ok != PREF_NOERROR) && is_error_fatal)
m_ErrorOpeningUserPrefs = TRUE;
#ifdef XP_WIN
#ifdef XP_PC
if (m_ErrorOpeningUserPrefs && is_error_fatal)
MessageBox(NULL,"Error in preference file (prefs.js). Default preferences will be used.","Netscape - Warning", MB_OK);
#endif
@@ -260,9 +269,10 @@ int pref_OpenFile(const char* filename, XP_Bool is_error_fatal, XP_Bool verifyHa
and verifies the first line of the buffer expresses the correct hash in the form:
// xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx
where each 'xx' is a hex value. */
XP_Bool pref_VerifyLockFile(char* buf, long buflen)
PRBool pref_VerifyLockFile(char* buf, long buflen)
{
XP_Bool success = FALSE;
#ifndef NO_SECURITY
PRBool success = FALSE;
const int obscure_value = 7;
const long hash_length = 51; /* len = 48 chars of MD5 + // + EOL */
unsigned char digest[16];
@@ -291,20 +301,22 @@ XP_Bool pref_VerifyLockFile(char* buf, long buflen)
MD5_DestroyContext(md5_cxt, PR_TRUE);
XP_SPRINTF(szHash, "%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x",
PR_snprintf(szHash, 64, "%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x",
(int)digest[0],(int)digest[1],(int)digest[2],(int)digest[3],
(int)digest[4],(int)digest[5],(int)digest[6],(int)digest[7],
(int)digest[8],(int)digest[9],(int)digest[10],(int)digest[11],
(int)digest[12],(int)digest[13],(int)digest[14],(int)digest[15]);
success = ( strncmp((const char*) buf + 3, szHash, hash_length - 4) == 0 );
success = ( PL_strncmp((const char*) buf + 3, szHash, hash_length - 4) == 0 );
}
return success;
#else
/*
* Should return 'success', but since the MD5 code is stubbed out,
* just return 'TRUE' until we have a replacement.
*/
return TRUE;
#endif
}
PR_IMPLEMENT(int)
@@ -383,7 +395,7 @@ PREF_Init(char *filename)
}
#if !defined(XP_WIN) && !defined(XP_OS2)
#if !defined(XP_PC) && !defined(XP_OS2) && !defined(XP_MAC)
ok = pref_InitInitialObjects();
#endif
}
@@ -442,8 +454,8 @@ PREF_Cleanup()
while (node) {
next_node = node->next;
XP_FREE(node->domain);
XP_FREE(node);
PR_Free(node->domain);
PR_Free(node);
node = next_node;
}
if (m_mochaContext) JS_DestroyContext(m_mochaContext);
@@ -472,7 +484,7 @@ PREF_ReadLockFile(const char *filename)
/* This is more recent than the below 3 routines which should be obsoleted */
PR_IMPLEMENT(JSBool)
PREF_EvaluateConfigScript(const char * js_buffer, size_t length,
const char* filename, XP_Bool bGlobalContext, XP_Bool bCallbacks)
const char* filename, PRBool bGlobalContext, PRBool bCallbacks)
{
JSBool ok;
jsval result;
@@ -592,7 +604,7 @@ PREF_SetIntPref(const char *pref_name, int32 value)
}
PR_IMPLEMENT(int)
PREF_SetBoolPref(const char *pref_name, XP_Bool value)
PREF_SetBoolPref(const char *pref_name, PRBool value)
{
PrefValue pref;
pref.boolVal = value;
@@ -600,26 +612,10 @@ PREF_SetBoolPref(const char *pref_name, XP_Bool value)
return pref_HashPref(pref_name, pref, PREF_BOOL, PREF_SETUSER);
}
#if !defined(XP_WIN) && !defined(XP_OS2)
extern char *EncodeBase64Buffer(char *subject, long size);
extern char *DecodeBase64Buffer(char *subject);
#else
/* temporary to make windows into a DLL...add a assert if used */
char *EncodeBase64Buffer(char *subject, long size)
{
assert(0);
}
char *DecodeBase64Buffer(char *subject)
{
assert(0);
}
#endif
PR_IMPLEMENT(int)
PREF_SetBinaryPref(const char *pref_name, void * value, long size)
{
char* buf = EncodeBase64Buffer(value, size);
char* buf = PL_Base64Encode(value, size, NULL);
if (buf) {
PrefValue pref;
@@ -635,7 +631,7 @@ PREF_SetColorPref(const char *pref_name, uint8 red, uint8 green, uint8 blue)
{
char colstr[63];
PrefValue pref;
XP_SPRINTF( colstr, "#%02X%02X%02X", red, green, blue);
PR_snprintf( colstr, 63, "#%02X%02X%02X", red, green, blue);
pref.stringVal = colstr;
return pref_HashPref(pref_name, pref, PREF_STRING, PREF_SETUSER);
@@ -655,7 +651,7 @@ PREF_SetColorPrefDWord(const char *pref_name, uint32 colorref)
red = MYGetRValue(colorref);
green = MYGetGValue(colorref);
blue = MYGetboolVal(colorref);
XP_SPRINTF( colstr, "#%02X%02X%02X", red, green, blue);
PR_snprintf( colstr, 63, "#%02X%02X%02X", red, green, blue);
pref.stringVal = colstr;
return pref_HashPref(pref_name, pref, PREF_STRING, PREF_SETUSER);
@@ -666,7 +662,7 @@ PREF_SetRectPref(const char *pref_name, int16 left, int16 top, int16 right, int1
{
char rectstr[63];
PrefValue pref;
XP_SPRINTF( rectstr, "%d,%d,%d,%d", left, top, right, bottom);
PR_snprintf( rectstr, 63, "%d,%d,%d,%d", left, top, right, bottom);
pref.stringVal = rectstr;
return pref_HashPref(pref_name, pref, PREF_STRING, PREF_SETUSER);
@@ -695,7 +691,7 @@ PREF_SetDefaultIntPref(const char *pref_name,int32 value)
}
PR_IMPLEMENT(int)
PREF_SetDefaultBoolPref(const char *pref_name,XP_Bool value)
PREF_SetDefaultBoolPref(const char *pref_name,PRBool value)
{
PrefValue pref;
pref.boolVal = value;
@@ -706,7 +702,7 @@ PREF_SetDefaultBoolPref(const char *pref_name,XP_Bool value)
PR_IMPLEMENT(int)
PREF_SetDefaultBinaryPref(const char *pref_name,void * value,long size)
{
char* buf = EncodeBase64Buffer(value, size);
char* buf = PL_Base64Encode(value, size, NULL);
if (buf) {
PrefValue pref;
pref.stringVal = buf;
@@ -720,7 +716,7 @@ PR_IMPLEMENT(int)
PREF_SetDefaultColorPref(const char *pref_name, uint8 red, uint8 green, uint8 blue)
{
char colstr[63];
XP_SPRINTF( colstr, "#%02X%02X%02X", red, green, blue);
PR_snprintf( colstr, 63, "#%02X%02X%02X", red, green, blue);
return PREF_SetDefaultCharPref(pref_name, colstr);
}
@@ -729,7 +725,7 @@ PR_IMPLEMENT(int)
PREF_SetDefaultRectPref(const char *pref_name, int16 left, int16 top, int16 right, int16 bottom)
{
char rectstr[63];
XP_SPRINTF( rectstr, "%d,%d,%d,%d", left, top, right, bottom);
PR_snprintf( rectstr, 63, "%d,%d,%d,%d", left, top, right, bottom);
return PREF_SetDefaultCharPref(pref_name, rectstr);
}
@@ -749,7 +745,7 @@ pref_saveLIPref(PRHashEntry *he, int i, void *arg)
if (tmp_str) {
PR_snprintf(buf, 2048, "user_pref(\"%s\", \"%s\");" LINEBREAK,
(char*) he->key, tmp_str);
XP_FREE(tmp_str);
PR_Free(tmp_str);
}
}
else if (pref->flags & PREF_INT) {
@@ -761,7 +757,7 @@ pref_saveLIPref(PRHashEntry *he, int i, void *arg)
(pref->userPref.boolVal) ? "true" : "false");
}
prefArray[i] = XP_STRDUP(buf);
prefArray[i] = PL_strdup(buf);
} else if (pref && PREF_IS_LOCKED(pref) && !PREF_HAS_LI_VALUE(pref)) {
char buf[2048];
@@ -770,7 +766,7 @@ pref_saveLIPref(PRHashEntry *he, int i, void *arg)
if (tmp_str) {
PR_snprintf(buf, 2048, "user_pref(\"%s\", \"%s\");" LINEBREAK,
(char*) he->key, tmp_str);
XP_FREE(tmp_str);
PR_Free(tmp_str);
}
}
else if (pref->flags & PREF_INT) {
@@ -782,7 +778,7 @@ pref_saveLIPref(PRHashEntry *he, int i, void *arg)
(pref->defaultPref.boolVal) ? "true" : "false");
}
prefArray[i] = XP_STRDUP(buf);
prefArray[i] = PL_strdup(buf);
}
return 0;
}
@@ -802,7 +798,7 @@ pref_savePref(PRHashEntry *he, int i, void *arg)
if (tmp_str) {
PR_snprintf(buf, 2048, "user_pref(\"%s\", \"%s\");" LINEBREAK,
(char*) he->key, tmp_str);
XP_FREE(tmp_str);
PR_Free(tmp_str);
}
}
else if (pref->flags & PREF_INT) {
@@ -814,7 +810,7 @@ pref_savePref(PRHashEntry *he, int i, void *arg)
(pref->userPref.boolVal) ? "true" : "false");
}
prefArray[i] = XP_STRDUP(buf);
prefArray[i] = PL_strdup(buf);
} else if (pref && PREF_IS_LOCKED(pref)) {
char buf[2048];
@@ -823,7 +819,7 @@ pref_savePref(PRHashEntry *he, int i, void *arg)
if (tmp_str) {
PR_snprintf(buf, 2048, "user_pref(\"%s\", \"%s\");" LINEBREAK,
(char*) he->key, tmp_str);
XP_FREE(tmp_str);
PR_Free(tmp_str);
}
}
else if (pref->flags & PREF_INT) {
@@ -835,7 +831,7 @@ pref_savePref(PRHashEntry *he, int i, void *arg)
(pref->defaultPref.boolVal) ? "true" : "false");
}
prefArray[i] = XP_STRDUP(buf);
prefArray[i] = PL_strdup(buf);
}
/* LI_STUFF?? may need to write out the lilocal stuff here if it applies - probably won't support in
the prefs.js file. We won't need to worry about the user.js since it is read only.
@@ -867,6 +863,10 @@ this is new. clients should use the old PREF_SavePrefFile or new PREF_SaveLIPre
This is called by them and does the right thing.
?? make this private to this file.
*/
#define PREF_FILE_BANNER "// Netscape User Preferences" LINEBREAK \
"// This is a generated file! Do not edit." LINEBREAK LINEBREAK
PR_IMPLEMENT(int)
PREF_SavePrefFileWith(const char *filename, PRHashEnumerator heSaveProc) {
int success = PREF_ERROR;
@@ -878,22 +878,20 @@ PREF_SavePrefFileWith(const char *filename, PRHashEnumerator heSaveProc) {
return PREF_NOT_INITIALIZED;
/* ?! Don't save (blank) user prefs if there was an error reading them */
#if defined(XP_WIN) || defined(XP_OS2)
#if defined(XP_PC) || defined(XP_OS2)
if (!filename)
#else
if (!filename || m_ErrorOpeningUserPrefs)
#endif
return PREF_NOERROR;
valueArray = (char**) XP_CALLOC(sizeof(char*), m_HashTable->nentries);
valueArray = (char**) PR_Calloc(sizeof(char*), m_HashTable->nentries);
if (!valueArray)
return PREF_OUT_OF_MEMORY;
fp = fopen(filename, "w");
if (fp) {
XP_FileWrite("// Netscape User Preferences" LINEBREAK
"// This is a generated file! Do not edit." LINEBREAK LINEBREAK,
-1, fp);
fwrite(PREF_FILE_BANNER, sizeof(char), PL_strlen(PREF_FILE_BANNER), fp);
/* LI_STUFF here we pass in the heSaveProc proc used so that li can do its own thing */
PR_HashTableEnumerateEntries(m_HashTable, heSaveProc, valueArray);
@@ -904,18 +902,19 @@ PREF_SavePrefFileWith(const char *filename, PRHashEnumerator heSaveProc) {
{
if (valueArray[valueIdx])
{
XP_FileWrite(valueArray[valueIdx], -1, fp);
XP_FREE(valueArray[valueIdx]);
fwrite(valueArray[valueIdx], sizeof(char),
PL_strlen(valueArray[valueIdx]), fp);
PR_Free(valueArray[valueIdx]);
}
}
XP_FileClose(fp);
fclose(fp);
success = PREF_NOERROR;
}
else
success = errno;
XP_FREE(valueArray);
PR_Free(valueArray);
return success;
}
@@ -945,7 +944,7 @@ PREF_SavePrefFileAs(const char *filename) {
return PREF_SavePrefFileWith(filename, pref_savePref);
}
int pref_GetCharPref(const char *pref_name, char * return_buffer, int * length, XP_Bool get_default)
int pref_GetCharPref(const char *pref_name, char * return_buffer, int * length, PRBool get_default)
{
int result = PREF_ERROR;
char* stringVal;
@@ -968,7 +967,7 @@ int pref_GetCharPref(const char *pref_name, char * return_buffer, int * length,
*length = strlen(stringVal) + 1;
}
else {
strncpy(return_buffer, stringVal, PR_MIN(*length - 1, strlen(stringVal) + 1));
PL_strncpy(return_buffer, stringVal, PR_MIN(*length - 1, strlen(stringVal) + 1));
return_buffer[*length - 1] = '\0';
}
result = PREF_OK;
@@ -977,7 +976,7 @@ int pref_GetCharPref(const char *pref_name, char * return_buffer, int * length,
return result;
}
int pref_CopyCharPref(const char *pref_name, char ** return_buffer, XP_Bool get_default)
int pref_CopyCharPref(const char *pref_name, char ** return_buffer, PRBool get_default)
{
int result = PREF_ERROR;
char* stringVal;
@@ -995,14 +994,14 @@ int pref_CopyCharPref(const char *pref_name, char ** return_buffer, XP_Bool get_
stringVal = pref->userPref.stringVal;
if (stringVal) {
*return_buffer = XP_STRDUP(stringVal);
*return_buffer = PL_strdup(stringVal);
result = PREF_OK;
}
}
return result;
}
int pref_GetIntPref(const char *pref_name,int32 * return_int, XP_Bool get_default)
int pref_GetIntPref(const char *pref_name,int32 * return_int, PRBool get_default)
{
int result = PREF_ERROR;
PrefNode* pref;
@@ -1021,7 +1020,7 @@ int pref_GetIntPref(const char *pref_name,int32 * return_int, XP_Bool get_defaul
return result;
}
int pref_GetBoolPref(const char *pref_name, XP_Bool * return_value, XP_Bool get_default)
int pref_GetBoolPref(const char *pref_name, XP_Bool * return_value, PRBool get_default)
{
int result = PREF_ERROR;
PrefNode* pref;
@@ -1133,17 +1132,14 @@ PREF_GetBinaryPref(const char *pref_name, void * return_value, int *size)
result = PREF_CopyCharPref(pref_name, &buf);
if (result == PREF_NOERROR) {
char* debuf;
if (strlen(buf) == 0) { /* don't decode empty string ? */
XP_FREE(buf);
PR_Free(buf);
return -1;
}
debuf = DecodeBase64Buffer(buf);
XP_MEMCPY(return_value, debuf, *size);
PL_Base64Decode(buf, *size, return_value);
XP_FREE(buf);
XP_FREE(debuf);
PR_Free(buf);
}
return result;
}
@@ -1164,14 +1160,14 @@ ReadCharPrefUsing(const char *pref_name, void** return_value, int *size, CharPre
if (result == PREF_NOERROR) {
if (strlen(buf) == 0) { /* do not decode empty string? */
XP_FREE(buf);
PR_Free(buf);
return -1;
}
*return_value = DecodeBase64Buffer(buf);
*return_value = PL_Base64Decode(buf, 0, NULL);
*size = strlen(buf);
XP_FREE(buf);
PR_Free(buf);
}
return result;
}
@@ -1196,7 +1192,7 @@ PREF_CopyPathPref(const char *pref_name, char ** return_buffer)
}
PR_IMPLEMENT(int)
PREF_SetPathPref(const char *pref_name, const char *path, XP_Bool set_default)
PREF_SetPathPref(const char *pref_name, const char *path, PRBool set_default)
{
PrefAction action = set_default ? PREF_SETDEFAULT : PREF_SETUSER;
PrefValue pref;
@@ -1234,11 +1230,7 @@ PREF_GetDefaultBoolPref(const char *pref_name, XP_Bool * return_value)
PR_IMPLEMENT(int)
PREF_GetDefaultBinaryPref(const char *pref_name, void * return_value, int * length)
{
#ifdef XP_WIN
assert( FALSE );
#else
XP_ASSERT( FALSE );
#endif
PR_ASSERT( FALSE );
return TRUE;
}
@@ -1303,8 +1295,8 @@ pref_DeleteItem(PRHashEntry *he, int i, void *arg)
/* note if we're deleting "ldap" then we want to delete "ldap.xxx"
and "ldap" (if such a leaf node exists) but not "ldap_1.xxx" */
if (to_delete && (XP_STRNCMP(he->key, to_delete, len) == 0 ||
(len-1 == strlen(he->key) && XP_STRNCMP(he->key, to_delete, len-1) == 0)))
if (to_delete && (PL_strncmp(he->key, to_delete, len) == 0 ||
(len-1 == strlen(he->key) && PL_strncmp(he->key, to_delete, len-1) == 0)))
return HT_ENUMERATE_REMOVE;
else
return HT_ENUMERATE_NEXT;
@@ -1319,7 +1311,7 @@ PREF_DeleteBranch(const char *branch_name)
PR_HashTableEnumerateEntries(m_HashTable, pref_DeleteItem, (void*) branch_dot);
XP_FREE(branch_dot);
PR_Free(branch_dot);
return 0;
}
@@ -1361,11 +1353,7 @@ PR_IMPLEMENT(int)
PREF_GetConfigString(const char *obj_name, char * return_buffer, int size,
int index, const char *field)
{
#ifdef XP_WIN
assert( FALSE );
#else
XP_ASSERT( FALSE );
#endif
PR_ASSERT( FALSE );
return -1;
}
@@ -1380,7 +1368,7 @@ PREF_CopyConfigString(const char *obj_name, char **return_buffer)
if (pref && pref->flags & PREF_STRING) {
if (return_buffer)
*return_buffer = XP_STRDUP(pref->defaultPref.stringVal);
*return_buffer = PL_strdup(pref->defaultPref.stringVal);
success = PREF_NOERROR;
}
return success;
@@ -1398,10 +1386,10 @@ PREF_CopyIndexConfigString(const char *obj_name,
if (pref && pref->flags & PREF_STRING) {
if (return_buffer)
*return_buffer = XP_STRDUP(pref->defaultPref.stringVal);
*return_buffer = PL_strdup(pref->defaultPref.stringVal);
success = PREF_NOERROR;
}
XP_FREEIF(setup_buf);
PR_FREEIF(setup_buf);
return success;
}
@@ -1438,9 +1426,9 @@ PREF_GetConfigBool(const char *obj_name, XP_Bool *return_bool)
/*
* Hash table functions
*/
static XP_Bool pref_ValueChanged(PrefValue oldValue, PrefValue newValue, PrefType type)
static PRBool pref_ValueChanged(PrefValue oldValue, PrefValue newValue, PrefType type)
{
XP_Bool changed = TRUE;
PRBool changed = TRUE;
switch (type) {
case PREF_STRING:
if (oldValue.stringVal && newValue.stringVal)
@@ -1462,9 +1450,9 @@ static void pref_SetValue(PrefValue* oldValue, PrefValue newValue, PrefType type
{
switch (type) {
case PREF_STRING:
XP_ASSERT(newValue.stringVal);
XP_FREEIF(oldValue->stringVal);
oldValue->stringVal = newValue.stringVal ? XP_STRDUP(newValue.stringVal) : NULL;
PR_ASSERT(newValue.stringVal);
PR_FREEIF(oldValue->stringVal);
oldValue->stringVal = newValue.stringVal ? PL_strdup(newValue.stringVal) : NULL;
break;
default:
@@ -1487,15 +1475,15 @@ int pref_HashPref(const char *key, PrefValue value, PrefType type, PrefAction ac
return PREF_OUT_OF_MEMORY;
pref->flags = type;
if (pref->flags & PREF_BOOL)
pref->defaultPref.boolVal = (XP_Bool) -2;
pref->defaultPref.boolVal = (PRBool) -2;
/* ugly hack -- define it to a default that no pref will ever default to
this should really get fixed right by some out of band data */
if (pref->flags & PREF_INT)
pref->defaultPref.intVal = (int32) -5632;
PR_HashTableAdd(m_HashTable, XP_STRDUP(key), pref);
PR_HashTableAdd(m_HashTable, PL_strdup(key), pref);
}
else if (!(pref->flags & type)) {
XP_ASSERT(0); /* this shouldn't happen */
PR_ASSERT(0); /* this shouldn't happen */
return PREF_TYPE_CHANGE_ERR;
}
@@ -1657,7 +1645,7 @@ JSBool PR_CALLBACK pref_NativeGetPref
{
void* value = NULL;
PrefNode* pref;
XP_Bool prefExists = TRUE;
PRBool prefExists = TRUE;
if (argc >= 1 && JSVAL_IS_STRING(argv[0]))
{
@@ -1665,7 +1653,7 @@ JSBool PR_CALLBACK pref_NativeGetPref
pref = (PrefNode*) PR_HashTableLookup(m_HashTable, key);
if (pref) {
XP_Bool use_default = (PREF_IS_LOCKED(pref) || !PREF_HAS_USER_VALUE(pref));
PRBool use_default = (PREF_IS_LOCKED(pref) || !PREF_HAS_USER_VALUE(pref));
if (pref->flags & PREF_STRING) {
char* str = use_default ? pref->defaultPref.stringVal : pref->userPref.stringVal;
@@ -1684,10 +1672,10 @@ JSBool PR_CALLBACK pref_NativeGetPref
}
/* -- */
PR_IMPLEMENT(XP_Bool)
PR_IMPLEMENT(PRBool)
PREF_PrefIsLocked(const char *pref_name)
{
XP_Bool result = FALSE;
PRBool result = FALSE;
if (m_IsAnyPrefLocked) {
PrefNode* pref = (PrefNode*) PR_HashTableLookup(m_HashTable, pref_name);
if (pref && PREF_IS_LOCKED(pref))
@@ -1716,16 +1704,16 @@ PR_IMPLEMENT(int)
pref_addChild(PRHashEntry *he, int i, void *arg)
{
PrefChildIter* pcs = (PrefChildIter*) arg;
if ( XP_STRNCMP(he->key, pcs->parent, strlen(pcs->parent)) == 0 ) {
if ( PL_strncmp(he->key, pcs->parent, strlen(pcs->parent)) == 0 ) {
char buf[512];
char* nextdelim;
int parentlen = strlen(pcs->parent);
char* substring;
XP_Bool substringBordersSeparator = FALSE;
PRBool substringBordersSeparator = FALSE;
strncpy(buf, he->key, PR_MIN(512, strlen(he->key) + 1));
nextdelim = buf + parentlen;
if (parentlen < strlen(buf)) {
if (parentlen < PL_strlen(buf)) {
/* Find the next delimiter if any and truncate the string there */
nextdelim = strstr(nextdelim, ".");
if (nextdelim) {
@@ -1737,7 +1725,7 @@ pref_addChild(PRHashEntry *he, int i, void *arg)
if (substring)
{
int buflen = strlen(buf);
XP_ASSERT(substring[buflen] > 0);
PR_ASSERT(substring[buflen] > 0);
substringBordersSeparator = (substring[buflen] == '\0' || substring[buflen] == ';');
}
@@ -1753,8 +1741,8 @@ pref_addChild(PRHashEntry *he, int i, void *arg)
return HT_ENUMERATE_STOP;
}
#endif
XP_STRCAT(pcs->childList, buf);
XP_STRCAT(pcs->childList, ";");
PL_strcat(pcs->childList, buf);
PL_strcat(pcs->childList, ";");
}
}
return 0;
@@ -1779,7 +1767,7 @@ PREF_CreateChildList(const char* parent_node, char **child_list)
PR_HashTableEnumerateEntries(m_HashTable, pref_addChild, &pcs);
*child_list = pcs.childList;
XP_FREE(pcs.parent);
PR_Free(pcs.parent);
return (pcs.childList == NULL) ? PREF_OUT_OF_MEMORY : PREF_OK;
}
@@ -1801,7 +1789,7 @@ PREF_RegisterCallback(const char *pref_node,
{
struct CallbackNode* node = (struct CallbackNode*) malloc(sizeof(struct CallbackNode));
if (node) {
node->domain = XP_STRDUP(pref_node);
node->domain = PL_strdup(pref_node);
node->func = callback;
node->data = instance_data;
node->next = m_Callbacks;
@@ -1831,8 +1819,8 @@ PREF_UnregisterCallback(const char *pref_node,
prev_node->next = next_node;
else
m_Callbacks = next_node;
XP_FREE(node->domain);
XP_FREE(node);
PR_Free(node->domain);
PR_Free(node);
node = next_node;
result = PREF_NOERROR;
}
@@ -1850,7 +1838,7 @@ int pref_DoCallback(const char* changed_pref)
struct CallbackNode* node;
for (node = m_Callbacks; node != NULL; node = node->next)
{
if ( XP_STRNCMP(changed_pref, node->domain, strlen(node->domain)) == 0 ) {
if ( PL_strncmp(changed_pref, node->domain, strlen(node->domain)) == 0 ) {
int result2 = (*node->func) (changed_pref, node->data);
if (result2 != PREF_OK)
result = result2;
@@ -1861,7 +1849,7 @@ int pref_DoCallback(const char* changed_pref)
/* !! Front ends need to implement */
#ifndef XP_MAC
PR_IMPLEMENT(XP_Bool)
PR_IMPLEMENT(PRBool)
PREF_IsAutoAdminEnabled()
{
if (m_AutoAdminLib == NULL)
@@ -1879,22 +1867,13 @@ JSBool PR_CALLBACK pref_NativeGetLDAPAttr
{
#ifdef MOZ_ADMIN_LIB
ldap_func get_ldap_attributes = NULL;
#if (defined (XP_MAC) && defined(powerc)) || defined (XP_WIN) || defined(XP_UNIX)
#if (defined (XP_MAC) && defined(powerc)) || defined (XP_PC) || defined(XP_UNIX)
if (m_AutoAdminLib == NULL) {
m_AutoAdminLib = pref_LoadAutoAdminLib();
}
if (m_AutoAdminLib) {
get_ldap_attributes = (ldap_func)
#ifndef NSPR20
PR_FindSymbol(
#ifndef XP_WIN16
"pref_get_ldap_attributes"
#else
MAKEINTRESOURCE(1)
#endif
, m_AutoAdminLib);
#else /* NSPR20 */
PR_FindSymbol(
m_AutoAdminLib,
#ifndef XP_WIN16
@@ -1903,7 +1882,6 @@ JSBool PR_CALLBACK pref_NativeGetLDAPAttr
MAKEINTRESOURCE(1)
#endif
);
#endif /* NSPR20 */
}
if (get_ldap_attributes == NULL) {
/* This indicates the AutoAdmin dll was not found. */
@@ -1928,7 +1906,7 @@ JSBool PR_CALLBACK pref_NativeGetLDAPAttr
if (value) {
JSString* str = JS_NewStringCopyZ(cx, value);
XP_FREE(value);
PR_Free(value);
if (str) {
*rval = STRING_TO_JSVAL(str);
return JS_TRUE;
@@ -1976,15 +1954,15 @@ pref_printDebugInfo(PRHashEntry *he, int i, void *arg)
buf2 = PR_smprintf("%s %s</font><br>", buf1, val.boolVal ? "true" : "false");
}
if ((strlen(buf2) + strlen(pcs->childList) + 1) > pcs->bufsize) {
if ((PL_strlen(buf2) + PL_strlen(pcs->childList) + 1) > pcs->bufsize) {
pcs->bufsize *= 3;
pcs->childList = (char*) realloc(pcs->childList, sizeof(char) * pcs->bufsize);
if (!pcs->childList)
return HT_ENUMERATE_STOP;
}
XP_STRCAT(pcs->childList, buf2);
XP_FREE(buf1);
XP_FREE(buf2);
PL_strcat(pcs->childList, buf2);
PR_Free(buf1);
PR_Free(buf2);
return 0;
}
@@ -1995,7 +1973,7 @@ PREF_AboutConfig()
pcs.bufsize = 8192;
pcs.childList = (char*) malloc(sizeof(char) * pcs.bufsize);
pcs.childList[0] = '\0';
XP_STRCAT(pcs.childList, "<HTML>");
PL_strcat(pcs.childList, "<HTML>");
PR_HashTableEnumerateEntries(m_HashTable, pref_printDebugInfo, &pcs);
@@ -2028,7 +2006,7 @@ pref_BranchCallback(JSContext *cx, JSScript *script)
lm_language_name);
if (message) {
ok = FE_Confirm(decoder->window_context, message);
XP_FREE(message);
PR_Free(message);
}
}
#endif
@@ -2073,7 +2051,7 @@ pref_ErrorReporter(JSContext *cx, const char *message,
if (last) {
pref_Alert(last);
XP_FREE(last);
PR_Free(last);
}
}
@@ -2086,7 +2064,7 @@ void pref_Alert(char* msg)
#endif
FE_Alert(NULL, msg);
#endif
#if defined (XP_WIN)
#if defined (XP_PC)
MessageBox (NULL, msg, "Netscape -- JS Preference Warning", MB_OK);
#endif
}
@@ -2094,7 +2072,7 @@ void pref_Alert(char* msg)
#ifdef XP_WIN16
#define ADMNLIBNAME "adm1640.dll"
#elif defined XP_WIN32 || defined XP_OS2
#elif defined XP_PC || defined XP_OS2
#define ADMNLIBNAME "adm3240.dll"
#elif defined XP_UNIX
#define ADMNLIBNAME "libAutoAdmin.so"
@@ -2114,7 +2092,7 @@ pref_LoadAutoAdminLib()
PR_SetLibraryPath( "/usr/local/netscape/" );
#endif
#ifdef XP_UNIX
#if defined(XP_UNIX) && !defined(B1M)
{
char aalib[MAXPATHLEN];
@@ -2143,11 +2121,7 @@ pref_LoadAutoAdminLib()
}
/* Make sure it's really libAutoAdmin.so */
#ifndef NSPR20
if ( lib && PR_FindSymbol("_POLARIS_SplashPro", lib) == NULL ) return NULL;
#else
if ( lib && PR_FindSymbol(lib, "_POLARIS_SplashPro") == NULL ) return NULL;
#endif
#else
lib = PR_LoadLibrary( ADMNLIBNAME );
#endif
@@ -2175,7 +2149,7 @@ static JSBool pref_HashJSPref(unsigned int argc, jsval *argv, PrefAction action)
/* this is somehow fixing an internal compiler error for win16 */
PrefValue value;
const char *key;
XP_Bool bIsBool, bIsInt, bIsString;
PRBool bIsBool, bIsInt, bIsString;
;
if (argc < 2)

View File

@@ -19,7 +19,6 @@
/* LDAP functions callable from JavaScript */
#include "ldap.h"
#include "xp_mcom.h"
#include "prefldap.h"
/*

View File

@@ -20,13 +20,17 @@
unixpref.c
**********************************************************************/
#include <stdio.h>
#include <assert.h>
#include "prefapi.h"
#include "prlink.h"
#include "prlog.h"
#include "jsapi.h"
#include "jsbuffer.h"
#include "xpassert.h"
#ifndef B1M
#include <Xm/Xm.h>
#endif
extern PRLibrary* pref_LoadAutoAdminLib(void);
extern PRLibrary* m_AutoAdminLib;
@@ -46,7 +50,7 @@ pref_InitInitialObjects(void)
{
JSBool status;
XP_ASSERT(pref_init_buffer);
PR_ASSERT(pref_init_buffer);
status = PREF_EvaluateJSBuffer(pref_init_buffer, strlen(pref_init_buffer));
@@ -69,21 +73,16 @@ PREF_AlterSplashIcon(struct fe_icon_data* icon)
if ( PREF_IsAutoAdminEnabled() &&
icon &&
(splash_screen = (struct fe_icon_type*)
#ifndef NSPR20
PR_FindSymbol("_POLARIS_SplashPro", m_AutoAdminLib)) != NULL ) {
#else
PR_FindSymbol(m_AutoAdminLib, "_POLARIS_SplashPro")) != NULL ) {
#endif
memcpy(icon, splash_screen, sizeof(*icon));
}
}
#ifndef B1M
/*
* PREF_GetLabelAndMnemonic
*/
XP_Bool
PRBool
PREF_GetLabelAndMnemonic(char* name, char** str, void* v_xm_str, void* v_mnemonic)
{
XmString *xm_str = (XmString*)v_xm_str;
@@ -93,11 +92,11 @@ PREF_GetLabelAndMnemonic(char* name, char** str, void* v_xm_str, void* v_mnemoni
char* p1;
char* p2;
XP_ASSERT(name);
XP_ASSERT(str);
XP_ASSERT(xm_str);
PR_ASSERT(name);
PR_ASSERT(str);
PR_ASSERT(xm_str);
if ( name == NULL || str == NULL || xm_str == NULL ) return FALSE;
if ( name == NULL || str == NULL || xm_str == NULL ) return PR_FALSE;
_str = NULL;
*str = NULL;
@@ -109,7 +108,7 @@ PREF_GetLabelAndMnemonic(char* name, char** str, void* v_xm_str, void* v_mnemoni
PREF_CopyConfigString(buf, &_str);
if ( _str == NULL || *_str == '\0' ) return FALSE;
if ( _str == NULL || *_str == '\0' ) return PR_FALSE;
/* Strip out ampersands */
if ( strchr(_str, '&') != NULL ) {
@@ -124,19 +123,19 @@ PREF_GetLabelAndMnemonic(char* name, char** str, void* v_xm_str, void* v_mnemoni
return ( *xm_str != NULL );
}
#endif
/*
* PREF_GetUrl
*/
XP_Bool
PRBool
PREF_GetUrl(char* name, char** url)
{
char buf[256];
XP_ASSERT(name);
PR_ASSERT(name);
if ( name == NULL || url == NULL ) return FALSE;
if ( name == NULL || url == NULL ) return PR_FALSE;
strncpy(buf, name, 200);
strcat(buf, ".url");

View File

@@ -18,6 +18,6 @@
DEPTH = ../..
DIRS = include src
DIRS = include src
include $(DEPTH)/config/rules.mk

View File

@@ -81,17 +81,17 @@ typedef struct _reginfo
#define UNIX_GLOBAL_FLAG "MOZILLA_SHARED_REGISTRY"
/* Platform-dependent declspec for library interface */
#if defined(STANDALONE_REGISTRY) && defined(XP_PC)
#if defined(WIN32)
#define VR_INTERFACE(type) __declspec(dllexport) type __stdcall
#elif defined(XP_OS2)
#define VR_INTERFACE(type) type _Optlink
#else
#define VR_INTERFACE(type) type _far _pascal _export
#endif
#if defined(XP_PC)
#if defined(WIN32)
#define VR_INTERFACE(type) __declspec(dllexport) type __stdcall
#elif defined(XP_OS2)
#define VR_INTERFACE(type) type _Optlink
#else
#define VR_INTERFACE(type) type _far _pascal _export
#endif
#else
#define VR_INTERFACE(type) type
#endif /* STANDALONE_REGISTRY and XP_PC */
#define VR_INTERFACE(type) type
#endif
XP_BEGIN_PROTOS
@@ -113,6 +113,10 @@ VR_INTERFACE(REGERR) NR_RegPack(
HREG hReg /* handle of open registry to pack */
);
VR_INTERFACE(REGERR) NR_RegSetUsername(
const char *name /* name of current user */
);
/* ---------------------------------------------------------------------
* Registry API -- Key Management functions
* ---------------------------------------------------------------------
@@ -207,8 +211,8 @@ VR_INTERFACE(REGERR) NR_RegEnumEntries(
);
#ifndef STANDALONE_REGISTRY
void NR_ShutdownRegistry(void);
void NR_StartupRegistry(void);
VR_INTERFACE(void) NR_ShutdownRegistry(void);
VR_INTERFACE(void) NR_StartupRegistry(void);
#endif /* STANDALONE_REGISTRY */
XP_END_PROTOS

View File

@@ -54,14 +54,10 @@ VR_INTERFACE(REGERR) VR_InRegistry(char *path);
VR_INTERFACE(REGERR) VR_ValidateComponent(char *path);
VR_INTERFACE(REGERR) VR_Enum(REGENUM *state, char *buffer, uint32 buflen);
#ifndef STANDALONE_REGISTRY
VR_INTERFACE(void) VR_Initialize(void* env);
#endif
VR_INTERFACE(REGERR) VR_SetRegDirectory(const char *path);
XP_END_PROTOS
#endif /* _VERREG_H_ */
/* EOF: VerReg.h */

View File

@@ -37,6 +37,7 @@ DEPTH=..\..
#// DIRS - There are subdirectories to process
#//
#//------------------------------------------------------------------------
DIRS=include src
#//------------------------------------------------------------------------

View File

@@ -22,7 +22,7 @@ LIBRARY_NAME = reg
REQUIRES = libreg nspr dbm pref js
CSRCS = reg.c VerReg.c
CSRCS = reg.c VerReg.c vr_stubs.c
BIN_SRCS = VerReg.c reg.c vr_stubs.c
BIN_OBJS = $(addprefix $(OBJDIR)/R_,$(BIN_SRCS:.c=.o))
@@ -42,9 +42,9 @@ PROGRAM = $(OBJDIR)/vreg$(BIN_SUFFIX)
$(PROGRAM): $(BIN_OBJS)
@$(MAKE_OBJDIR)
ifeq ($(OS_ARCH), OS2)
$(LINK_EXE) -OUT:$@ $(BIN_OBJS) $(LDFLAGS) $(OS_LIBS) $(DIST)/lib/libxp.$(LIB_SUFFIX)
$(LINK_EXE) -OUT:$@ $(BIN_OBJS) $(LDFLAGS) $(OS_LIBS)
else
$(CCF) -o $@ $(BIN_OBJS) $(LDFLAGS) $(DIST)/lib/lib$(LITE_PREFIX)xp.$(LIB_SUFFIX)
$(CCF) -o $@ $(BIN_OBJS) $(LDFLAGS)
endif
$(OBJDIR)/R_VerReg.o: VerReg.c

View File

@@ -37,36 +37,10 @@
#include <io.h>
#endif
#ifndef STANDALONE_REGISTRY
#include "xp_mcom.h"
#include "xp_core.h"
#ifndef NSPR20
#include "prosdep.h"
#else
#ifdef XP_MAC
#include <Folders.h>
#include "prosdep.h"
#else
#include "md/prosdep.h"
#endif
#endif
#include "prmon.h"
#ifdef BROKEN
#include "su_folderspec.h"
#endif
#else
#ifdef XP_MAC
#include <types.h>
#include <stat.h>
#else
#include <sys/types.h>
#include <sys/stat.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#endif
#include "reg.h"
#include "NSReg.h"
@@ -115,6 +89,7 @@ XP_Bool bGlobalRegistry = FALSE;
PRMonitor *vr_monitor = NULL;
#endif
static char *app_dir = NULL;
/* ---------------------------------------------------------------------
* local functions
@@ -160,14 +135,14 @@ static REGERR vr_Init(void)
if (!isInited)
{
#ifndef STANDALONE_REGISTRY
#ifdef BROKEN
curPath = FE_GetDirectoryPath(eCommunicatorFolder);
#else
/* can't use Version Registry interface until "BROKEN" works */
err = REGERR_FAIL;
goto done;
#endif
#if !defined(STANDALONE_REGISTRY)
curPath = app_dir;
if (curPath == NULL) {
/* can't use Version Registry interface until "BROKEN" works */
err = REGERR_FAIL;
goto done;
}
#ifdef XP_UNIX
if (curPath != NULL) {
regbuf = (char*)XP_ALLOC( 10 + XP_STRLEN(curPath) );
@@ -259,7 +234,6 @@ static REGERR vr_Init(void)
done:
#ifndef STANDALONE_REGISTRY
PR_ExitMonitor(vr_monitor);
XP_FREEIF(curPath);
#ifdef XP_UNIX
XP_FREEIF(regbuf);
#endif
@@ -1101,7 +1075,7 @@ VR_INTERFACE(REGERR) VR_ValidateComponent(char *component_path)
}
urlPath = path;
#ifndef STANDALONE_REGISTRY
#ifdef BROKEN
url = XP_PlatformFileToURL(path);
if ( url == NULL )
return REGERR_MEMORY;
@@ -1144,4 +1118,17 @@ VR_INTERFACE(REGERR) VR_ValidateComponent(char *component_path)
#pragma export reset
#endif
VR_INTERFACE(REGERR) VR_SetRegDirectory(const char *path)
{
char *tmp = XP_STRDUP(path);
if (NULL == tmp) {
return REGERR_MEMORY;
}
XP_FREEIF(app_dir);
app_dir = tmp;
return REGERR_OK;
}
/* EOF: VerReg.c */

View File

@@ -31,7 +31,7 @@ IGNORE_MANIFEST=1
DEPTH= ..\..\..
!ifndef MAKE_OBJ_TYPE
MAKE_OBJ_TYPE=EXE
MAKE_OBJ_TYPE=DLL
!endif
#//------------------------------------------------------------------------
@@ -39,8 +39,6 @@ MAKE_OBJ_TYPE=EXE
#// Define any Public Make Variables here: (ie. PDFFILE, MAPFILE, ...)
#//
#//------------------------------------------------------------------------
LIBNAME=libreg$(MOZ_BITS)
PDBFILE=$(LIBNAME).pdb
#//------------------------------------------------------------------------
#//
@@ -51,6 +49,7 @@ PDBFILE=$(LIBNAME).pdb
OBJS= \
.\$(OBJDIR)\reg.obj \
.\$(OBJDIR)\VerReg.obj \
.\$(OBJDIR)\vr_stubs.obj \
$(NULL)
#//------------------------------------------------------------------------
@@ -60,6 +59,8 @@ OBJS= \
#//
#//------------------------------------------------------------------------
LIBNAME=libreg$(MOZ_BITS)
DLL=$(OBJDIR)\$(LIBNAME).dll
LIBRARY= .\$(OBJDIR)\$(LIBNAME).lib
#//------------------------------------------------------------------------
@@ -69,15 +70,14 @@ LIBRARY= .\$(OBJDIR)\$(LIBNAME).lib
#//
#//------------------------------------------------------------------------
LCFLAGS = $(LCFLAGS)
LLIBS = $(LLIBS) $(LIBNSPR)
#//
#// Win16 places ALL public header files in $(PUBLIC)/win16
#//
!if "$(MOZ_BITS)" != "16"
LINCS= $(LINCS) -I$(PUBLIC)/libreg \
-I$(PUBLIC)/nspr \
-I$(PUBLIC)/dbm \
-I$(PUBLIC)/pref \
-I$(PUBLIC)/js \
$(NULL)
!endif
@@ -88,6 +88,11 @@ LINCS= $(LINCS) -I$(PUBLIC)/libreg \
#//------------------------------------------------------------------------
include <$(DEPTH)/config/rules.mak>
install:: $(LIBRARY)
export:: $(DLL)
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
$(MAKE_INSTALL) $(DLL) $(DIST)\bin
clobber::
$(RM) $(DIST)\bin\$(DLL)
$(RM) $(DIST)\lib\$(LIBRARY)

View File

@@ -33,13 +33,10 @@
#define VERIFY_READ 1
#endif
#ifndef STANDALONE_REGISTRY
#include "xp_mcom.h"
#include "xp_error.h"
#include "prmon.h"
#include "prefapi.h"
#else
#ifdef XP_MAC
#include <size_t.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -49,7 +46,6 @@
#ifdef SUNOS4
#include <unistd.h> /* for SEEK_SET */
#endif /* SUNOS4 */
#endif /* STANDALONE_REGISTRY */
#include "reg.h"
#include "NSReg.h"
@@ -97,7 +93,7 @@ static XP_Bool bRegStarted = FALSE;
#if !defined(STANDALONE_REGISTRY)
static PRMonitor *reglist_monitor;
#endif
static char *user_name = NULL;
/* --------------------------------------------------------------------
@@ -1513,6 +1509,8 @@ static void nr_InitStdRkeys( REGFILE *reg );
static Bool nr_ProtectedNode( REGFILE *reg, REGOFF key );
static REGERR nr_RegAddKey( REGFILE *reg, RKEY key, char *path, RKEY *newKey );
static void nr_Upgrade_1_1( REGFILE *reg );
static char* nr_GetUsername();
/* --------------------------------------------------------------------- */
@@ -1549,9 +1547,8 @@ static REGOFF nr_TranslateKey( REGFILE *reg, RKEY key )
REGERR err;
char* profName;
err = PREF_CopyDefaultCharPref( "profile.name", &profName );
if (err == PREF_NOERROR ) {
profName = nr_GetUsername();
if ( NULL != profName ) {
/* Don't assign a slot for missing or magic profile */
if ( '\0' == *profName ||
0 == XP_STRCMP(ASW_MAGIC_PROFILE_NAME, profName))
@@ -1790,12 +1787,42 @@ static void nr_Upgrade_1_1(REGFILE *reg)
}
static char *nr_GetUsername()
{
if (NULL == user_name) {
return "default";
} else {
return user_name;
}
}
/* ---------------------------------------------------------------------
* Public API
* --------------------------------------------------------------------- */
/* ---------------------------------------------------------------------
* NR_RegSetUsername - Set the current username
*
* Parameters:
* name - name of the current user
*
* Output:
* ---------------------------------------------------------------------
*/
VR_INTERFACE(REGERR) NR_RegSetUsername(const char *name)
{
char *tmp = XP_STRDUP(name);
if (NULL == tmp) {
return REGERR_MEMORY;
}
XP_FREEIF(user_name);
user_name = tmp;
return REGERR_OK;
}
/* ---------------------------------------------------------------------
* NReg_Open - Open a netscape XP registry
*
@@ -2845,19 +2872,13 @@ VR_INTERFACE(REGERR) NR_RegEnumEntries( HREG hReg, RKEY key, REGENUM *state,
#ifndef STANDALONE_REGISTRY
#include "VerReg.h"
#ifdef WIN32
extern BOOL WFE_IsMoveFileExBroken();
#endif
/* ---------------------------------------------------------------------
* ---------------------------------------------------------------------
* Registry initialization and shut-down
* ---------------------------------------------------------------------
* ---------------------------------------------------------------------
*/
#ifdef BROKEN
extern void SU_InitMonitor(void);
extern void SU_DestroyMonitor(void);
#endif
extern PRMonitor *vr_monitor;
#ifdef XP_UNIX
extern XP_Bool bGlobalRegistry;
@@ -2867,14 +2888,12 @@ extern XP_Bool bGlobalRegistry;
#pragma export on
#endif
void NR_StartupRegistry(void)
VR_INTERFACE(void) NR_StartupRegistry(void)
{
HREG reg;
RKEY key;
REGERR err;
REGENUM state;
XP_Bool removeFromList;
XP_StatStruct stat;
if (bRegStarted)
return;
vr_monitor = PR_NewMonitor();
XP_ASSERT( vr_monitor != NULL );
@@ -2884,110 +2903,10 @@ void NR_StartupRegistry(void)
bGlobalRegistry = ( getenv(UNIX_GLOBAL_FLAG) != NULL );
#endif
#ifdef BROKEN
SU_InitMonitor();
#endif
bRegStarted = TRUE;
/* need to register a PREF callback for "profile.name" */
/* check to see that we have a valid registry */
if (REGERR_OK == NR_RegOpen("", &reg))
{
#ifdef XP_PC
/* perform scheduled file deletions and replacements (PC only) */
if (REGERR_OK == NR_RegGetKey(reg, ROOTKEY_PRIVATE,
REG_DELETE_LIST_KEY,&key))
{
char *urlFile;
char *pFile;
char buf[MAXREGNAMELEN];
state = 0;
while (REGERR_OK == NR_RegEnumEntries(reg, key, &state,
buf, sizeof(buf), NULL ))
{
urlFile = XP_PlatformFileToURL(buf);
if ( urlFile == NULL)
continue;
pFile = urlFile+7;
removeFromList = FALSE;
if (0 == XP_FileRemove(pFile, xpURL)) {
/* file was successfully deleted */
removeFromList = TRUE;
}
else if (XP_Stat(pFile, &stat, xpURL) != 0) {
/* file doesn't appear to exist */
removeFromList = TRUE;
}
if (removeFromList) {
err = NR_RegDeleteEntry( reg, key, buf );
/* must reset state or enum will stop on deleted entry */
if ( err == REGERR_OK )
state = 0;
}
XP_FREEIF(urlFile);
}
/* delete list node if empty */
state = 0;
if (REGERR_NOMORE == NR_RegEnumEntries( reg, key, &state, buf,
sizeof(buf), NULL ))
{
NR_RegDeleteKey(reg, ROOTKEY_PRIVATE, REG_DELETE_LIST_KEY);
}
}
/* replace files if any listed */
if (REGERR_OK == NR_RegGetKey(reg, ROOTKEY_PRIVATE,
REG_REPLACE_LIST_KEY, &key))
{
char tmpfile[MAXREGNAMELEN];
char target[MAXREGNAMELEN];
state = 0;
while (REGERR_OK == NR_RegEnumEntries(reg, key, &state,
tmpfile, sizeof(tmpfile), NULL ))
{
removeFromList = FALSE;
if (XP_Stat(tmpfile, &stat, xpURL) != 0)
{
/* new file is gone! */
removeFromList = TRUE;
}
else if ( REGERR_OK != NR_RegGetEntryString( reg, key,
tmpfile, target, sizeof(target) ) )
{
/* can't read target filename, corruption? */
removeFromList = TRUE;
}
else {
if (XP_Stat(target, &stat, xpURL) == 0) {
/* need to delete old file first */
XP_FileRemove( target, xpURL );
}
if (0 == XP_FileRename(tmpfile, xpURL, target, xpURL)) {
removeFromList = TRUE;
}
}
if (removeFromList) {
err = NR_RegDeleteEntry( reg, key, tmpfile );
/* must reset state or enum will stop on deleted entry */
if ( err == REGERR_OK )
state = 0;
}
}
/* delete list node if empty */
state = 0;
if (REGERR_NOMORE == NR_RegEnumEntries(reg, key, &state, tmpfile,
sizeof(tmpfile), NULL ))
{
NR_RegDeleteKey(reg, ROOTKEY_PRIVATE, REG_REPLACE_LIST_KEY);
}
}
#endif /* XP_PC */
if (REGERR_OK == NR_RegOpen("", &reg)) {
NR_RegClose(reg);
}
else {
@@ -2996,9 +2915,10 @@ void NR_StartupRegistry(void)
VR_InRegistry("/Netscape");
VR_Close();
}
}
void NR_ShutdownRegistry(void)
VR_INTERFACE(void) NR_ShutdownRegistry(void)
{
REGFILE* pReg;
@@ -3022,9 +2942,10 @@ void NR_ShutdownRegistry(void)
PR_DestroyMonitor( reglist_monitor );
reglist_monitor = NULL;
}
#ifdef BROKEN
SU_DestroyMonitor();
#endif
XP_FREEIF(user_name);
bRegStarted = FALSE;
}
#ifdef XP_MAC

View File

@@ -22,9 +22,9 @@
#ifndef _REG_H_
#define _REG_H_
#ifdef STANDALONE_REGISTRY
#include "vr_stubs.h"
#else
#ifndef STANDALONE_REGISTRY
#include "prmon.h"
#endif

View File

@@ -19,10 +19,12 @@
/* this file contains stubs needed to build the registry routines
* into a stand-alone library for use with our installers
*/
#ifdef STANDALONE_REGISTRY
#include <stdio.h>
#include <string.h>
#ifndef STANDALONE_REGISTRY
#include "prtypes.h"
#endif
#include "vr_stubs.h"
#ifdef XP_MAC
@@ -176,6 +178,7 @@ char *strdup(const char *source)
return newAllocation;
}
int strcasecmp(const char *str1, const char *str2)
{
char currentChar1, currentChar2;
@@ -255,32 +258,63 @@ int strncasecmp(const char *str1, const char *str2, int length)
#include "NSReg.h"
#include "VerReg.h"
char *TheRegistry;
char *TheRegistry = "registry";
char *Flist;
/* WARNING: build hackery */
#ifdef STANDALONE_REGISTRY
long BUILDNUM =
#include "../../../build/build_number"
;
#endif
REGERR vr_ParseVersion(char *verstr, VERSION *result);
int main(int argc, char *argv[]);
#ifdef XP_UNIX
XP_File VR_StubOpen (const char * mode)
#define DEF_REG "/.netscape/registry"
XP_File VR_StubOpen (const char *name, const char * mode)
{
XP_File fh;
struct stat st;
if ( stat( TheRegistry, &st ) == 0 )
fh = fopen( TheRegistry, XP_FILE_UPDATE_BIN );
else
fh = fopen( TheRegistry, XP_FILE_WRITE_BIN );
return fh;
}
#ifndef STANDALONE_REGISTRY
char *def = NULL;
if (name == NULL || *name == '\0') {
char *home = getenv("HOME");
if (home != NULL) {
def = (char *) XP_ALLOC(XP_STRLEN(home) + XP_STRLEN(DEF_REG));
if (def != NULL) {
XP_STRCPY(def, home);
XP_STRCAT(def, DEF_REG);
}
}
if (def != NULL) {
name = def;
} else {
name = TheRegistry;
}
}
#else
name = TheRegistry;
#endif
if ( stat( name, &st ) == 0 )
fh = fopen( name, XP_FILE_UPDATE_BIN );
else
fh = fopen( name, XP_FILE_WRITE_BIN );
#ifndef STANDALONE_REGISTRY
XP_FREEIF(def);
#endif
return fh;
}
#endif
#ifdef STANDALONE_REGISTRY
int main(int argc, char *argv[])
{
XP_File fh;
@@ -361,6 +395,7 @@ int main(int argc, char *argv[])
fclose( fh );
return 0;
}
#endif /* XP_UNIX || XP_OS2 */
#endif /* STANDALONE_REGISTRY */
#endif /* XP_UNIX || XP_OS2 */

View File

@@ -69,12 +69,17 @@
#define XP_FileFlush(file) fflush(file)
#define XP_FileClose(file) fclose(file)
#ifdef XP_UNIX
#define XP_FileOpen(name,type,mode) VR_StubOpen((name), (mode))
#else
#define XP_FileOpen(name,type,mode) VR_StubOpen((mode))
#endif
#define XP_BEGIN_PROTOS
#define XP_END_PROTOS
#define XP_ASSERT(x) ((void)0)
#define XP_STRCAT(a,b) strcat((a),(b))
#define XP_STRCPY(a,b) strcpy((a),(b))
#define XP_STRLEN(x) strlen(x)
#define XP_SPRINTF sprintf
@@ -88,34 +93,25 @@
#define XP_MEMSET(d, c, l) memset((d), (c), (l))
#ifdef XP_PC
#define XP_STRCASECMP(x,y) strcmpi((x),(y))
#ifdef XP_OS2
#define XP_STRCASECMP(x,y) stricmp((x),(y))
#define XP_STRNCASECMP(x,y,n) strnicmp((x),(y),(n))
#else
#define XP_STRNCASECMP(x,y,n) strncmpi((x),(y),(n))
#endif
#endif
#ifdef XP_MAC
#define XP_STRCASECMP(x,y) strcasecmp((x),(y))
#define XP_STRNCASECMP(x,y,n) strncasecmp((x),(y),(n))
extern int strcasecmp(const char *str1, const char *str2);
extern int strncasecmp(const char *str1, const char *str2, int length);
#endif
#ifdef XP_UNIX
#define XP_STRCASECMP strcasecomp /* from libxp.a */
#endif
typedef FILE * XP_File;
#ifdef STANDALONE_REGISTRY /* included from prmon.h otherwise */
typedef long int32;
typedef unsigned long uint32;
typedef short int16;
typedef unsigned short uint16;
typedef unsigned char uint8;
#endif
typedef char Bool;
typedef int XP_Bool;
@@ -128,7 +124,16 @@ typedef int XP_Bool;
#define XP_Stat(file,data,type) stat((file),(data))
#endif
#ifdef XP_UNIX
extern XP_File VR_StubOpen (const char *name, const char * mode);
#else
extern XP_File VR_StubOpen (const char * mode);
#endif
#ifdef XP_MAC
extern int strcasecmp(const char *str1, const char *str2);
extern int strncasecmp(const char *str1, const char *str2, int length);
extern char * strdup(const char *str);
#endif
#endif /* _VR_STUBS_H_ */

View File

@@ -0,0 +1,663 @@
/*
* 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 "secnav.h"
#include "libmocha.h"
#include "prlink.h"
#include "prinrval.h"
int
SSL_SetSockPeerID(PRFileDesc *fd, char *peerID)
{
return(0);
}
void
SECNAV_Posting(PRFileDesc *fd)
{
return;
}
void
SECNAV_HTTPHead(PRFileDesc *fd)
{
return;
}
void
SECNAV_RegisterNetlibMimeConverters()
{
return;
}
char *
SECNAV_MungeString(const char *unmunged_string)
{
return(NULL);
}
char *
SECNAV_UnMungeString(const char *munged_string)
{
return(NULL);
}
PRBool
SECNAV_GenKeyFromChoice(void *proto_win, LO_Element *form,
char *choiceString, char *challenge,
char *typeString, char *pqgString,
char **pValue, PRBool *pDone)
{
return(PR_FALSE);
}
char **
SECNAV_GetKeyChoiceList(char *type, char *pqgString)
{
return(NULL);
}
PRBool
SECNAV_SecurityDialog(MWContext *context, int state)
{
return (state == SD_INSECURE_POST_FROM_INSECURE_DOC);
}
JSObject *
lm_DefinePkcs11(MochaDecoder *decoder)
{
return((JSObject *)1);
}
JSObject *
lm_DefineCrypto(MochaDecoder *decoder)
{
return((JSObject *)1);
}
void
NET_InitCertLdapProtocol(void)
{
}
CERTCertificate *
CERT_DupCertificate(CERTCertificate *cert)
{
return(NULL);
}
void
CERT_DestroyCertificate(CERTCertificate *cert)
{
return;
}
CERTCertificate *
CERT_NewTempCertificate (CERTCertDBHandle *handle, SECItem *derCert,
char *nickname, PRBool isperm, PRBool copyDER)
{
return(NULL);
}
CERTCertDBHandle *
CERT_GetDefaultCertDB(void)
{
return(NULL);
}
CERTCertificate *
CERT_DecodeCertFromPackage(char *certbuf, int certlen)
{
return(NULL);
}
char *
CERT_HTMLCertInfo(CERTCertificate *cert, PRBool showImages, PRBool showIssuer)
{
return(NULL);
}
PRBool
CERT_CompareCertsForRedirection(CERTCertificate *c1, CERTCertificate *c2)
{
return(PR_FALSE);
}
const char *
SECNAV_GetPolicyNameString(void)
{
return(NULL);
}
int
SECNAV_InitConfigObject(void)
{
return(0);
}
int
SECNAV_RunInitialSecConfig(void)
{
return(0);
}
void
SECNAV_EarlyInit(void)
{
return;
}
void
SECNAV_Init(void)
{
return;
}
void
SECNAV_Shutdown(void)
{
return;
}
void
SECNAV_SecurityAdvisor(void *proto_win, URL_Struct *url)
{
return;
}
char *
SECNAV_MakeCertButtonString(CERTCertificate *cert)
{
return(NULL);
}
int
SECNAV_SecURLData(char *which, NET_StreamClass *stream, MWContext *cx)
{
return(-1);
}
char *
SECNAV_SecURLContentType(char *which)
{
return(NULL);
}
int
SECNAV_SecHandleSecurityAdvisorURL(MWContext *cx, const char *which)
{
return(-1);
}
void
SECNAV_HandleInternalSecURL(URL_Struct *url, MWContext *cx)
{
return;
}
PRBool
SSL_IsDomestic(void)
{
return(PR_FALSE);
}
SECStatus
SECNAV_ComputeFortezzaProxyChallengeResponse(MWContext *context,
char *asciiChallenge,
char **signature_out,
char **clientRan_out,
char **certChain_out)
{
return(SECFailure);
}
char *
SECNAV_PrettySecurityStatus(int level, unsigned char *status)
{
return(NULL);
}
char *
SECNAV_SecurityVersion(PRBool longForm)
{
return("N");
}
char *
SECNAV_SSLCapabilities(void)
{
return(NULL);
}
unsigned char *
SECNAV_SSLSocketStatus(PRFileDesc *fd, int *return_security_level)
{
return(NULL);
}
unsigned char *
SECNAV_CopySSLSocketStatus(unsigned char *status)
{
return(NULL);
}
unsigned int
SECNAV_SSLSocketStatusLength(unsigned char *status)
{
return(0);
}
char *
SECNAV_SSLSocketCertString(unsigned char *status)
{
return(NULL);
}
PRBool
SECNAV_CompareCertsForRedirection(unsigned char *status1,
unsigned char *status2)
{
return(PR_FALSE);
}
CERTCertificate *
SECNAV_CertFromSSLSocketStatus(unsigned char *status)
{
return(NULL);
}
SECStatus
RNG_RNGInit(void)
{
return(SECSuccess);
}
/*
* probably need to provide something here
*/
SECStatus
RNG_GenerateGlobalRandomBytes(void *dest, size_t len)
{
/* This is a temporary implementation to avoid */
/* the cache filename horkage. This needs to have a more */
/* secure/free implementation here - Gagan */
char* output=dest;
size_t i;
srand((unsigned int) PR_IntervalToMilliseconds(PR_IntervalNow()));
for (i=0;i<len; i++)
{
int t = rand();
*output = (char) (t % 256);
output++;
}
return(SECSuccess);
}
/*
** Get the "noisiest" information available on the system.
*/
size_t
RNG_GetNoise(void *buf, size_t maxbytes)
{
return(0);
}
/*
** RNG_SystemInfoForRNG should be called before any use of SSL. It
** gathers up the system specific information to help seed the
** state of the global random number generator.
*/
void
RNG_SystemInfoForRNG(void)
{
return;
}
/*
** Use the contents (and stat) of a file to help seed the
** global random number generator.
*/
void RNG_FileForRNG(char *filename)
{
return;
}
/*
** Update the global random number generator with more seeding
** material
*/
SECStatus
RNG_RandomUpdate(void *data, size_t bytes)
{
return(SECFailure);
}
PRStaticLinkTable jsl_nodl_tab[1];
void
_java_jsl_init(void)
{
}
DIGESTS *PR_CALLBACK
SOB_calculate_digest(void XP_HUGE *data, long length)
{
return(NULL);
}
int PR_CALLBACK
SOB_verify_digest(ZIG *siglist, const char *name, DIGESTS *dig)
{
return(-1);
}
void PR_CALLBACK
SOB_destroy (ZIG *zig)
{
return;
}
char *
SOB_get_error (int status)
{
return(NULL);
}
ZIG_Context *
SOB_find(ZIG *zig, char *pattern, int type)
{
return(NULL);
}
int
SOB_find_next(ZIG_Context *ctx, SOBITEM **it)
{
return(-1);
}
void
SOB_find_end(ZIG_Context *ctx)
{
return;
}
char *
SOB_get_url (ZIG *zig)
{
return(NULL);
}
ZIG *
SOB_new (void)
{
return(NULL);
}
int
SOB_set_callback (int type, ZIG *zig,
int (*fn) (int status, ZIG *zig,
const char *metafile,
char *pathname, char *errortext))
{
return(-1);
}
int PR_CALLBACK
SOB_cert_attribute(int attrib, ZIG *zig, long keylen, void *key,
void **result, unsigned long *length)
{
return(-1);
}
int PR_CALLBACK
SOB_stash_cert(ZIG *zig, long keylen, void *key)
{
return(-1);
}
int SOB_parse_manifest(char XP_HUGE *raw_manifest, long length,
const char *path, const char *url, ZIG *zig)
{
return(-1);
}
void
SECNAV_signedAppletPrivileges(void *proto_win, char *javaPrin,
char *javaTarget, char *risk, int isCert)
{
return;
}
char *
SOB_JAR_list_certs (void)
{
return(NULL);
}
int
SOB_JAR_validate_archive (char *filename)
{
return(-1);
}
void *
SOB_JAR_new_hash (int alg)
{
return(NULL);
}
void *
SOB_JAR_hash (int alg, void *cookie, int length, void *data)
{
return(NULL);
}
void *
SOB_JAR_end_hash (int alg, void *cookie)
{
return(NULL);
}
int
SOB_JAR_sign_archive (char *nickname, char *password, char *sf, char *outsig)
{
return(-1);
}
int
SOB_set_context (ZIG *zig, MWContext *mw)
{
return(-1);
}
int
SOB_pass_archive(int format, char *filename, const char *url, ZIG *zig)
{
return(-1);
}
int
SOB_get_metainfo(ZIG *zig, char *name, char *header, void **info,
unsigned long *length)
{
return(-1);
}
int
SOB_verified_extract(ZIG *zig, char *path, char *outpath)
{
return(-1);
}
/*
** Hash a non-null terminated string "src" into "dest" using MD5
*/
SECStatus
MD5_HashBuf(unsigned char *dest, const unsigned char *src,
uint32 src_length)
{
return(SECFailure);
}
/*
** Create a new MD5 context
*/
MD5Context *
MD5_NewContext(void)
{
return(NULL);
}
/*
** Destroy an MD5 secure hash context.
** "cx" the context
** "freeit" if PR_TRUE then free the object as well as its sub-objects
*/
void
MD5_DestroyContext(MD5Context *cx, PRBool freeit)
{
return;
}
/*
** Reset an MD5 context, preparing it for a fresh round of hashing
*/
void
MD5_Begin(MD5Context *cx)
{
return;
}
/*
** Update the MD5 hash function with more data.
** "cx" the context
** "input" the data to hash
** "inputLen" the amount of data to hash
*/
void
MD5_Update(MD5Context *cx, const unsigned char *input, unsigned int inputLen)
{
return;
}
/*
** Finish the MD5 hash function. Produce the digested results in "digest"
** "cx" the context
** "digest" where the 16 bytes of digest data are stored
** "digestLen" where the digest length (16) is stored
** "maxDigestLen" the maximum amount of data that can ever be
** stored in "digest"
*/
void
MD5_End(MD5Context *cx, unsigned char *digest,
unsigned int *digestLen, unsigned int maxDigestLen)
{
return;
}
/*
** Hash a non-null terminated string "src" into "dest" using SHA-1
*/
SECStatus
SHA1_HashBuf(unsigned char *dest, const unsigned char *src, uint32 src_length)
{
return(SECFailure);
}
/*
** Create a new SHA-1 context
*/
SHA1Context *
SHA1_NewContext(void)
{
return(NULL);
}
/*
** Destroy a SHA-1 secure hash context.
** "cx" the context
** "freeit" if PR_TRUE then free the object as well as its sub-objects
*/
void
SHA1_DestroyContext(SHA1Context *cx, PRBool freeit)
{
return;
}
/*
** Reset a SHA-1 context, preparing it for a fresh round of hashing
*/
void
SHA1_Begin(SHA1Context *cx)
{
return;
}
/*
** Update the SHA-1 hash function with more data.
** "cx" the context
** "input" the data to hash
** "inputLen" the amount of data to hash
*/
void
SHA1_Update(SHA1Context *cx, const unsigned char *input, unsigned int inputLen)
{
return;
}
/*
** Finish the SHA-1 hash function. Produce the digested results in "digest"
** "cx" the context
** "digest" where the 16 bytes of digest data are stored
** "digestLen" where the digest length (20) is stored
** "maxDigestLen" the maximum amount of data that can ever be
** stored in "digest"
*/
void
SHA1_End(SHA1Context *cx, unsigned char *digest,
unsigned int *digestLen, unsigned int maxDigestLen)
{
return;
}
/*
** Return a malloc'd ascii string which is the base64 encoded
** version of the input string.
*/
char *
BTOA_DataToAscii(const unsigned char *data, unsigned int len)
{
return(NULL);
}
/*
** Return a malloc'd string which is the base64 decoded version
** of the input string; set *lenp to the length of the returned data.
*/
unsigned char *
ATOB_AsciiToData(const char *string, unsigned int *lenp)
{
return(NULL);
}

View File

@@ -0,0 +1,236 @@
/*
* 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 _SECSTUBN_H_
#define _SECSTUBN_H_
#include "xp.h"
#include "ntypes.h"
#include "net.h"
typedef struct _digests DIGESTS;
typedef struct _zig ZIG;
typedef struct _zigcontext ZIG_Context;
typedef struct _peheader PEHeader;
typedef struct SOBITEM_ {
char *pathname;
int type;
size_t size;
void *data;
} SOBITEM;
typedef struct FINGERZIG_ {
size_t length;
void *key;
CERTCertificate *cert;
} FINGERZIG;
#define ZIG_CB_SIGNAL 1
#define ZIG_SIGN 10
#define ZIG_F_GUESS 0
#define ZIG_MF 2
#define ZIG_ERR_PNF 12
SEC_BEGIN_PROTOS
void
SECNAV_Posting(PRFileDesc *fd);
void
SECNAV_HTTPHead(PRFileDesc *fd);
void
SECNAV_RegisterNetlibMimeConverters();
char *
SECNAV_MungeString(const char *unmunged_string);
char *
SECNAV_UnMungeString(const char *munged_string);
PRBool
SECNAV_GenKeyFromChoice(void *proto_win, LO_Element *form,
char *choiceString, char *challenge,
char *typeString, char *pqgString,
char **pValue, PRBool *pDone);
char **
SECNAV_GetKeyChoiceList(char *type, char *pqgString);
PRBool
SECNAV_SecurityDialog(MWContext *context, int state);
void
NET_InitCertLdapProtocol(void);
const char *
SECNAV_GetPolicyNameString(void);
int
SECNAV_InitConfigObject(void);
int
SECNAV_RunInitialSecConfig(void);
void
SECNAV_EarlyInit(void);
void
SECNAV_Init(void);
void
SECNAV_Shutdown(void);
void
SECNAV_SecurityAdvisor(void *proto_win, URL_Struct *url);
char *
SECNAV_MakeCertButtonString(CERTCertificate *cert);
int
SECNAV_SecURLData(char *which, NET_StreamClass *stream, MWContext *cx);
char *
SECNAV_SecURLContentType(char *which);
int
SECNAV_SecHandleSecurityAdvisorURL(MWContext *cx, const char *which);
void
SECNAV_HandleInternalSecURL(URL_Struct *url, MWContext *cx);
SECStatus
SECNAV_ComputeFortezzaProxyChallengeResponse(MWContext *context,
char *asciiChallenge,
char **signature_out,
char **clientRan_out,
char **certChain_out);
char *
SECNAV_PrettySecurityStatus(int level, unsigned char *status);
char *
SECNAV_SecurityVersion(PRBool longForm);
char *
SECNAV_SSLCapabilities(void);
unsigned char *
SECNAV_SSLSocketStatus(PRFileDesc *fd, int *return_security_level);
unsigned char *
SECNAV_CopySSLSocketStatus(unsigned char *status);
unsigned int
SECNAV_SSLSocketStatusLength(unsigned char *status);
char *
SECNAV_SSLSocketCertString(unsigned char *status);
PRBool
SECNAV_CompareCertsForRedirection(unsigned char *status1,
unsigned char *status2);
CERTCertificate *
SECNAV_CertFromSSLSocketStatus(unsigned char *status);
DIGESTS *PR_CALLBACK
SOB_calculate_digest(void XP_HUGE *data, long length);
int PR_CALLBACK
SOB_verify_digest(ZIG *siglist, const char *name, DIGESTS *dig);
void PR_CALLBACK
SOB_destroy (ZIG *zig);
char *
SOB_get_error (int status);
ZIG_Context *
SOB_find(ZIG *zig, char *pattern, int type);
int
SOB_find_next(ZIG_Context *ctx, SOBITEM **it);
void
SOB_find_end(ZIG_Context *ctx);
char *
SOB_get_url (ZIG *zig);
ZIG *
SOB_new (void);
int
SOB_set_callback (int type, ZIG *zig,
int (*fn) (int status, ZIG *zig,
const char *metafile,
char *pathname, char *errortext));
int PR_CALLBACK
SOB_cert_attribute(int attrib, ZIG *zig, long keylen, void *key,
void **result, unsigned long *length);
int PR_CALLBACK
SOB_stash_cert(ZIG *zig, long keylen, void *key);
int SOB_parse_manifest(char XP_HUGE *raw_manifest, long length,
const char *path, const char *url, ZIG *zig);
void
SECNAV_signedAppletPrivileges(void *proto_win, char *javaPrin,
char *javaTarget, char *risk, int isCert);
char *
SOB_JAR_list_certs (void);
int
SOB_JAR_validate_archive (char *filename);
void *
SOB_JAR_new_hash (int alg);
void *
SOB_JAR_hash (int alg, void *cookie, int length, void *data);
void *
SOB_JAR_end_hash (int alg, void *cookie);
int
SOB_JAR_sign_archive (char *nickname, char *password, char *sf, char *outsig);
int
SOB_set_context (ZIG *zig, MWContext *mw);
int
SOB_pass_archive(int format, char *filename, const char *url, ZIG *zig);
int
SOB_get_metainfo(ZIG *zig, char *name, char *header, void **info,
unsigned long *length);
int
SOB_verified_extract(ZIG *zig, char *path, char *outpath);
NET_StreamClass *
SECNAV_MakePreencryptedWriteStream(FO_Present_Types format_out, void *data,
URL_Struct *url, MWContext *window_id);
SEC_END_PROTOS
#endif /* _SECSTUBN_H_ */

View File

@@ -15,6 +15,6 @@
# Reserved.
DEPTH = ..
DIRS = src
DIRS = src tests
include $(DEPTH)/config/rules.mk

View File

@@ -19,6 +19,10 @@
#include "nsDebug.h"
#include "prlog.h"
#if defined(_WIN32)
#include <windows.h>
#endif
/**
* Implementation of the nsDebug methods. Note that this code is
* always compiled in, in case some other module that uses it is
@@ -47,6 +51,20 @@ NS_COM void nsDebug::Abort(const char* aFile, PRIntn aLine)
#endif
}
NS_COM void nsDebug::Break(const char* aFile, PRIntn aLine)
{
InitLog();
PR_LOG(gDebugLog, PR_LOG_ERROR,
("Break: at file %s, line %d", aFile, aLine));
PR_LogFlush();
//XXX this works on win32 only for now. For all the other platforms call Abort
#if defined(_WIN32)
::DebugBreak();
#else
Abort(aFile, aLine);
#endif
}
NS_COM void nsDebug::PreCondition(const char* aStr, const char* aExpr,
const char* aFile, PRIntn aLine)
{
@@ -54,7 +72,7 @@ NS_COM void nsDebug::PreCondition(const char* aStr, const char* aExpr,
PR_LOG(gDebugLog, PR_LOG_ERROR,
("PreCondition: \"%s\" (%s) at file %s, line %d", aStr, aExpr,
aFile, aLine));
Abort(aFile, aLine);
Break(aFile, aLine);
}
NS_COM void nsDebug::PostCondition(const char* aStr, const char* aExpr,
@@ -64,7 +82,7 @@ NS_COM void nsDebug::PostCondition(const char* aStr, const char* aExpr,
PR_LOG(gDebugLog, PR_LOG_ERROR,
("PostCondition: \"%s\" (%s) at file %s, line %d", aStr, aExpr,
aFile, aLine));
Abort(aFile, aLine);
Break(aFile, aLine);
}
NS_COM void nsDebug::Assertion(const char* aStr, const char* aExpr,
@@ -74,7 +92,7 @@ NS_COM void nsDebug::Assertion(const char* aStr, const char* aExpr,
PR_LOG(gDebugLog, PR_LOG_ERROR,
("Assertion: \"%s\" (%s) at file %s, line %d", aStr, aExpr,
aFile, aLine));
Abort(aFile, aLine);
Break(aFile, aLine);
}
NS_COM void nsDebug::NotYetImplemented(const char* aMessage,
@@ -84,7 +102,7 @@ NS_COM void nsDebug::NotYetImplemented(const char* aMessage,
PR_LOG(gDebugLog, PR_LOG_ERROR,
("NotYetImplemented: \"%s\" at file %s, line %d", aMessage,
aFile, aLine));
Abort(aFile, aLine);
Break(aFile, aLine);
}
NS_COM void nsDebug::NotReached(const char* aMessage,
@@ -93,7 +111,7 @@ NS_COM void nsDebug::NotReached(const char* aMessage,
InitLog();
PR_LOG(gDebugLog, PR_LOG_ERROR,
("NotReached: \"%s\" at file %s, line %d", aMessage, aFile, aLine));
Abort(aFile, aLine);
Break(aFile, aLine);
}
NS_COM void nsDebug::Error(const char* aMessage,
@@ -102,7 +120,7 @@ NS_COM void nsDebug::Error(const char* aMessage,
InitLog();
PR_LOG(gDebugLog, PR_LOG_ERROR,
("Error: \"%s\" at file %s, line %d", aMessage, aFile, aLine));
Abort(aFile, aLine);
Break(aFile, aLine);
}
NS_COM void nsDebug::Warning(const char* aMessage,

View File

@@ -15,34 +15,40 @@
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include <stdio.h>
#include "nsID.h"
#include "prprf.h"
const static char gIDFormat[] =
"{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}";
static const char gIDFormat[] =
"{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}";
static const char gIDFormat2[] =
"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x";
/*
* Turns a {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} string into
* an nsID
*/
PRBool nsID::Parse(char *aIDStr) {
int count, n1, n2, n3[8];
long int n0;
NS_COM PRBool nsID::Parse(char *aIDStr)
{
PRInt32 count = 0;
PRInt32 n1, n2, n3[8];
PRInt32 n0;
count = sscanf(aIDStr, gIDFormat,
&n0, &n1, &n2,
&n3[0],&n3[1],&n3[2],&n3[3],
&n3[4],&n3[5],&n3[6],&n3[7]);
if (NULL != aIDStr) {
count = PR_sscanf(aIDStr,
(aIDStr[0] == '{') ? gIDFormat : gIDFormat2,
&n0, &n1, &n2,
&n3[0],&n3[1],&n3[2],&n3[3],
&n3[4],&n3[5],&n3[6],&n3[7]);
m0 = (PRInt32) n0;
m1 = (PRInt16) n1;
m2 = (PRInt16) n2;
for (int i = 0; i < 8; i++) {
m3[i] = (PRInt8) n3[i];
m0 = (PRInt32) n0;
m1 = (PRInt16) n1;
m2 = (PRInt16) n2;
for (int i = 0; i < 8; i++) {
m3[i] = (PRInt8) n3[i];
}
}
return (PRBool) (count == 11);
}
@@ -51,15 +57,16 @@ PRBool nsID::Parse(char *aIDStr) {
* format. Caller should delete [] the string.
*/
char *nsID::ToString() const
NS_COM char *nsID::ToString() const
{
char *res = new char[39];
if (res != NULL) {
sprintf(res, gIDFormat,
(long int) m0, (int) m1, (int) m2,
(int) m3[0], (int) m3[1], (int) m3[2], (int) m3[3],
(int) m3[4], (int) m3[5], (int) m3[6], (int) m3[7]);
PR_snprintf(res, 39, gIDFormat,
m0, (PRUint32) m1, (PRUint32) m2,
(PRUint32) m3[0], (PRUint32) m3[1], (PRUint32) m3[2],
(PRUint32) m3[3], (PRUint32) m3[4], (PRUint32) m3[5],
(PRUint32) m3[6], (PRUint32) m3[7]);
}
return res;
}

View File

@@ -18,11 +18,13 @@
#include <stdlib.h>
#include <iostream.h>
#ifdef _WIN32
#include <windows.h>
#endif
#include "plstr.h"
#include "prlink.h"
#include "nsRepository.h"
#ifdef USE_NSREG
#define STANDALONE_REGISTRY
#define XP_BEGIN_PROTOS extern "C" {
#define XP_END_PROTOS };
#include "NSReg.h"
@@ -31,7 +33,6 @@
nsHashtable *NSRepository::factories = NULL;
PRMonitor *NSRepository::monitor = NULL;
static NS_DEFINE_IID(kFactoryIID, NS_IFACTORY_IID);
static NS_DEFINE_IID(kFactory2IID, NS_IFACTORY2_IID);
class FactoryEntry {
@@ -74,15 +75,15 @@ public:
id = aID;
}
PRUint32 HashValue() {
PRUint32 HashValue(void) const {
return id.m0;
}
PRBool Equals(nsHashKey *aKey) {
return (id.Equals(((IDKey *) aKey)->id));
PRBool Equals(const nsHashKey *aKey) const {
return (id.Equals(((const IDKey *) aKey)->id));
}
nsHashKey *Clone() {
nsHashKey *Clone(void) const {
return new IDKey(id);
}
};
@@ -97,15 +98,16 @@ static nsresult platformRegister(const nsCID &aCID, const char *aLibrary)
if (err == REGERR_OK) {
RKEY key;
err = NR_RegAddKey(hreg, ROOTKEY_COMMON,
"SOFTWARE\\Netscape\\CID", &key);
"Classes", &key);
if (err == REGERR_OK) {
char *cidString = aCID.ToString();
NR_RegSetEntryString(hreg, key, cidString, (char *) aLibrary);
err = NR_RegSetEntryString(hreg, key, cidString, (char *) aLibrary);
delete [] cidString;
}
NR_RegClose(hreg);
}
return NS_OK;
return err;
}
static nsresult platformUnregister(const nsCID &aCID, const char *aLibrary)
@@ -115,15 +117,15 @@ static nsresult platformUnregister(const nsCID &aCID, const char *aLibrary)
if (err == REGERR_OK) {
RKEY key;
err = NR_RegAddKey(hreg, ROOTKEY_COMMON,
"SOFTWARE\\Netscape\\CID", &key);
"Classes", &key);
if (err == REGERR_OK) {
char *cidString = aCID.ToString();
NR_RegDeleteEntry(hreg, key, cidString);
err = NR_RegDeleteEntry(hreg, key, cidString);
delete [] cidString;
}
NR_RegClose(hreg);
}
return NS_OK;
return err;
}
static FactoryEntry *platformFind(const nsCID &aCID)
@@ -134,11 +136,11 @@ static FactoryEntry *platformFind(const nsCID &aCID)
if (err == REGERR_OK) {
RKEY key;
err = NR_RegGetKey(hreg, ROOTKEY_COMMON,
"SOFTWARE\\Netscape\\CID", &key);
"Classes", &key);
if (err == REGERR_OK) {
char *cidString = aCID.ToString();
char library[_MAX_PATH];
uint32 len = _MAX_PATH;
char library[256];
uint32 len = 256;
err = NR_RegGetEntryString(hreg, key, cidString, library, len);
delete [] cidString;
@@ -153,7 +155,7 @@ static FactoryEntry *platformFind(const nsCID &aCID)
#else // USE_NSREG
#ifdef XP_PC
#ifdef _WIN32
#define USE_REGISTRY
static nsresult platformRegister(const nsCID &aCID, const char *aLibrary)
@@ -205,7 +207,7 @@ static FactoryEntry *platformFind(const nsCID &aCID)
return NULL;
}
#endif // XP_PC
#endif // _WIN32
#endif // USE_NSREG
@@ -291,6 +293,9 @@ nsresult NSRepository::Initialize()
monitor = PR_NewMonitor();
}
#ifdef USE_NSREG
NR_StartupRegistry();
#endif
return NS_OK;
}

View File

@@ -25,11 +25,11 @@
static PR_CALLBACK PLHashNumber _hashValue(const void *key)
{
return ((nsHashKey *) key)->HashValue();
return ((const nsHashKey *) key)->HashValue();
}
static PR_CALLBACK PRIntn _hashKeyCompare(const void *key1, const void *key2) {
return ((nsHashKey *) key1)->Equals((nsHashKey *) key2);
return ((const nsHashKey *) key1)->Equals((const nsHashKey *) key2);
}
static PR_CALLBACK PRIntn _hashValueCompare(const void *value1,
@@ -78,6 +78,17 @@ static PR_CALLBACK PRIntn _hashEnumerate(PLHashEntry *he, PRIntn i, void *arg)
HT_ENUMERATE_STOP;
}
//
// HashKey
//
nsHashKey::nsHashKey(void)
{
}
nsHashKey::~nsHashKey(void)
{
}
nsHashtable::nsHashtable(PRUint32 aInitSize) {
hashtable = PL_NewHashTable(aInitSize,
_hashValue,

View File

@@ -0,0 +1,341 @@
/* -*- 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 "nsISupportsArray.h"
static NS_DEFINE_IID(kISupportsArrayIID, NS_ISUPPORTSARRAY_IID);
static const PRInt32 kGrowArrayBy = 8;
static const PRInt32 kAutoArraySize = 4;
class SupportsArrayImpl : public nsISupportsArray {
public:
SupportsArrayImpl(void);
~SupportsArrayImpl(void);
NS_DECL_ISUPPORTS
NS_IMETHOD_(nsISupportsArray&) operator=(const nsISupportsArray& aOther);
NS_IMETHOD_(PRBool) operator==(const nsISupportsArray& aOther) const { return Equals(&aOther); }
NS_IMETHOD_(PRBool) Equals(const nsISupportsArray* aOther) const;
NS_IMETHOD_(PRInt32) Count(void) const { return mCount; }
NS_IMETHOD_(nsISupports*) ElementAt(PRInt32 aIndex) const;
NS_IMETHOD_(nsISupports*) operator[](PRInt32 aIndex) const { return ElementAt(aIndex); }
NS_IMETHOD_(PRInt32) IndexOf(const nsISupports* aPossibleElement, PRInt32 aStartIndex = 0) const;
NS_IMETHOD_(PRInt32) LastIndexOf(const nsISupports* aPossibleElement) const;
NS_IMETHOD_(PRBool) InsertElementAt(nsISupports* aElement, PRInt32 aIndex);
NS_IMETHOD_(PRBool) ReplaceElementAt(nsISupports* aElement, PRInt32 aIndex);
NS_IMETHOD_(PRBool) AppendElement(nsISupports* aElement) {
return InsertElementAt(aElement, mCount);
}
NS_IMETHOD_(PRBool) RemoveElementAt(PRInt32 aIndex);
NS_IMETHOD_(PRBool) RemoveElement(const nsISupports* aElement, PRInt32 aStartIndex = 0);
NS_IMETHOD_(PRBool) RemoveLastElement(const nsISupports* aElement);
NS_IMETHOD_(void) Clear(void);
NS_IMETHOD_(void) Compact(void);
NS_IMETHOD_(PRBool) EnumerateForwards(nsISupportsArrayEnumFunc aFunc, void* aData);
NS_IMETHOD_(PRBool) EnumerateBackwards(nsISupportsArrayEnumFunc aFunc, void* aData);
protected:
void DeleteArray(void);
nsISupports** mArray;
PRInt32 mArraySize;
PRInt32 mCount;
nsISupports* mAutoArray[kAutoArraySize];
private:
// Copy constructors are not allowed
SupportsArrayImpl(const nsISupportsArray& other);
};
SupportsArrayImpl::SupportsArrayImpl()
{
NS_INIT_REFCNT();
mArray = &(mAutoArray[0]);
mArraySize = kAutoArraySize;
mCount = 0;
}
SupportsArrayImpl::~SupportsArrayImpl()
{
DeleteArray();
}
NS_IMPL_ISUPPORTS(SupportsArrayImpl, kISupportsArrayIID);
void SupportsArrayImpl::DeleteArray(void)
{
Clear();
if (mArray != &(mAutoArray[0])) {
delete[] mArray;
mArray = &(mAutoArray[0]);
mArraySize = kAutoArraySize;
}
}
nsISupportsArray& SupportsArrayImpl::operator=(const nsISupportsArray& aOther)
{
PRInt32 otherCount = aOther.Count();
if (otherCount > mArraySize) {
DeleteArray();
mArraySize = otherCount;
mArray = new nsISupports*[mArraySize];
}
else {
Clear();
}
mCount = otherCount;
while (0 <= --otherCount) {
mArray[otherCount] = aOther.ElementAt(otherCount);
}
return *this;
}
PRBool SupportsArrayImpl::Equals(const nsISupportsArray* aOther) const
{
if (0 != aOther) {
const SupportsArrayImpl* other = (const SupportsArrayImpl*)aOther;
if (mCount == other->mCount) {
PRInt32 index = mCount;
while (0 <= --index) {
if (mArray[index] != other->mArray[index]) {
return PR_FALSE;
}
}
return PR_TRUE;
}
}
return PR_FALSE;
}
nsISupports* SupportsArrayImpl::ElementAt(PRInt32 aIndex) const
{
if ((0 <= aIndex) && (aIndex < mCount)) {
nsISupports* element = mArray[aIndex];
NS_ADDREF(element);
return element;
}
return 0;
}
PRInt32 SupportsArrayImpl::IndexOf(const nsISupports* aPossibleElement, PRInt32 aStartIndex) const
{
if ((0 <= aStartIndex) && (aStartIndex < mCount)) {
const nsISupports** start = (const nsISupports**)mArray; // work around goofy compiler behavior
const nsISupports** ep = (start + aStartIndex);
const nsISupports** end = (start + mCount);
while (ep < end) {
if (aPossibleElement == *ep) {
return (ep - start);
}
ep++;
}
}
return -1;
}
PRInt32 SupportsArrayImpl::LastIndexOf(const nsISupports* aPossibleElement) const
{
if (0 < mCount) {
const nsISupports** start = (const nsISupports**)mArray; // work around goofy compiler behavior
const nsISupports** ep = (start + mCount);
while (start <= --ep) {
if (aPossibleElement == *ep) {
return (ep - start);
}
}
}
return -1;
}
PRBool SupportsArrayImpl::InsertElementAt(nsISupports* aElement, PRInt32 aIndex)
{
if ((0 <= aIndex) && (aIndex <= mCount)) {
if (mArraySize < (mCount + 1)) { // need to grow the array
mArraySize += kGrowArrayBy;
nsISupports** oldArray = mArray;
mArray = new nsISupports*[mArraySize];
if (0 == mArray) { // ran out of memory
mArray = oldArray;
mArraySize -= kGrowArrayBy;
return PR_FALSE;
}
if (0 != oldArray) { // need to move old data
if (0 < aIndex) {
::memcpy(mArray, oldArray, aIndex * sizeof(nsISupports*));
}
PRInt32 slide = (mCount - aIndex);
if (0 < slide) {
::memcpy(mArray + aIndex + 1, oldArray + aIndex, slide * sizeof(nsISupports*));
}
if (oldArray != &(mAutoArray[0])) {
delete[] oldArray;
}
}
}
else {
PRInt32 slide = (mCount - aIndex);
if (0 < slide) {
::memmove(mArray + aIndex + 1, mArray + aIndex, slide * sizeof(nsISupports*));
}
}
mArray[aIndex] = aElement;
NS_ADDREF(aElement);
mCount++;
return PR_TRUE;
}
return PR_FALSE;
}
PRBool SupportsArrayImpl::ReplaceElementAt(nsISupports* aElement, PRInt32 aIndex)
{
if ((0 <= aIndex) && (aIndex < mCount)) {
NS_ADDREF(aElement); // addref first in case it's the same object!
NS_RELEASE(mArray[aIndex]);
mArray[aIndex] = aElement;
return PR_TRUE;
}
return PR_FALSE;
}
PRBool SupportsArrayImpl::RemoveElementAt(PRInt32 aIndex)
{
if ((0 <= aIndex) && (aIndex < mCount)) {
NS_RELEASE(mArray[aIndex]);
mCount--;
PRInt32 slide = (mCount - aIndex);
if (0 < slide) {
::memmove(mArray + aIndex, mArray + aIndex + 1,
slide * sizeof(nsISupports*));
}
return PR_TRUE;
}
return PR_FALSE;
}
PRBool SupportsArrayImpl::RemoveElement(const nsISupports* aElement, PRInt32 aStartIndex)
{
if ((0 <= aStartIndex) && (aStartIndex < mCount)) {
nsISupports** ep = mArray;
nsISupports** end = ep + mCount;
while (ep < end) {
if (*ep == aElement) {
return RemoveElementAt(PRInt32(ep - mArray));
}
ep++;
}
}
return PR_FALSE;
}
PRBool SupportsArrayImpl::RemoveLastElement(const nsISupports* aElement)
{
if (0 < mCount) {
nsISupports** ep = (mArray + mCount);
while (mArray <= --ep) {
if (*ep == aElement) {
return RemoveElementAt(PRInt32(ep - mArray));
}
}
}
return PR_FALSE;
}
void SupportsArrayImpl::Clear(void)
{
while (0 <= --mCount) {
NS_RELEASE(mArray[mCount]);
}
mCount = 0;
}
void SupportsArrayImpl::Compact(void)
{
if ((mArraySize != mCount) && (kAutoArraySize < mArraySize)) {
nsISupports** oldArray = mArray;
PRInt32 oldArraySize = mArraySize;
if (mCount <= kAutoArraySize) {
mArray = &(mAutoArray[0]);
mArraySize = kAutoArraySize;
}
else {
mArray = new nsISupports*[mCount];
mArraySize = mCount;
}
if (0 == mArray) {
mArray = oldArray;
mArraySize = oldArraySize;
return;
}
::memcpy(mArray, oldArray, mCount * sizeof(nsISupports*));
delete[] oldArray;
}
}
PRBool SupportsArrayImpl::EnumerateForwards(nsISupportsArrayEnumFunc aFunc, void* aData)
{
PRInt32 index = -1;
PRBool running = PR_TRUE;
while (running && (++index < mCount)) {
running = (*aFunc)(mArray[index], aData);
}
return running;
}
PRBool SupportsArrayImpl::EnumerateBackwards(nsISupportsArrayEnumFunc aFunc, void* aData)
{
PRInt32 index = mCount;
PRBool running = PR_TRUE;
while (running && (0 <= --index)) {
running = (*aFunc)(mArray[index], aData);
}
return running;
}
NS_COM nsresult
NS_NewISupportsArray(nsISupportsArray** aInstancePtrResult)
{
if (aInstancePtrResult == 0) {
return NS_ERROR_NULL_POINTER;
}
SupportsArrayImpl *it = new SupportsArrayImpl();
if (0 == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return it->QueryInterface(kISupportsArrayIID, (void **) aInstancePtrResult);
}

View File

@@ -19,6 +19,10 @@
#include "nsDebug.h"
#include "prlog.h"
#if defined(_WIN32)
#include <windows.h>
#endif
/**
* Implementation of the nsDebug methods. Note that this code is
* always compiled in, in case some other module that uses it is
@@ -47,6 +51,20 @@ NS_COM void nsDebug::Abort(const char* aFile, PRIntn aLine)
#endif
}
NS_COM void nsDebug::Break(const char* aFile, PRIntn aLine)
{
InitLog();
PR_LOG(gDebugLog, PR_LOG_ERROR,
("Break: at file %s, line %d", aFile, aLine));
PR_LogFlush();
//XXX this works on win32 only for now. For all the other platforms call Abort
#if defined(_WIN32)
::DebugBreak();
#else
Abort(aFile, aLine);
#endif
}
NS_COM void nsDebug::PreCondition(const char* aStr, const char* aExpr,
const char* aFile, PRIntn aLine)
{
@@ -54,7 +72,7 @@ NS_COM void nsDebug::PreCondition(const char* aStr, const char* aExpr,
PR_LOG(gDebugLog, PR_LOG_ERROR,
("PreCondition: \"%s\" (%s) at file %s, line %d", aStr, aExpr,
aFile, aLine));
Abort(aFile, aLine);
Break(aFile, aLine);
}
NS_COM void nsDebug::PostCondition(const char* aStr, const char* aExpr,
@@ -64,7 +82,7 @@ NS_COM void nsDebug::PostCondition(const char* aStr, const char* aExpr,
PR_LOG(gDebugLog, PR_LOG_ERROR,
("PostCondition: \"%s\" (%s) at file %s, line %d", aStr, aExpr,
aFile, aLine));
Abort(aFile, aLine);
Break(aFile, aLine);
}
NS_COM void nsDebug::Assertion(const char* aStr, const char* aExpr,
@@ -74,7 +92,7 @@ NS_COM void nsDebug::Assertion(const char* aStr, const char* aExpr,
PR_LOG(gDebugLog, PR_LOG_ERROR,
("Assertion: \"%s\" (%s) at file %s, line %d", aStr, aExpr,
aFile, aLine));
Abort(aFile, aLine);
Break(aFile, aLine);
}
NS_COM void nsDebug::NotYetImplemented(const char* aMessage,
@@ -84,7 +102,7 @@ NS_COM void nsDebug::NotYetImplemented(const char* aMessage,
PR_LOG(gDebugLog, PR_LOG_ERROR,
("NotYetImplemented: \"%s\" at file %s, line %d", aMessage,
aFile, aLine));
Abort(aFile, aLine);
Break(aFile, aLine);
}
NS_COM void nsDebug::NotReached(const char* aMessage,
@@ -93,7 +111,7 @@ NS_COM void nsDebug::NotReached(const char* aMessage,
InitLog();
PR_LOG(gDebugLog, PR_LOG_ERROR,
("NotReached: \"%s\" at file %s, line %d", aMessage, aFile, aLine));
Abort(aFile, aLine);
Break(aFile, aLine);
}
NS_COM void nsDebug::Error(const char* aMessage,
@@ -102,7 +120,7 @@ NS_COM void nsDebug::Error(const char* aMessage,
InitLog();
PR_LOG(gDebugLog, PR_LOG_ERROR,
("Error: \"%s\" at file %s, line %d", aMessage, aFile, aLine));
Abort(aFile, aLine);
Break(aFile, aLine);
}
NS_COM void nsDebug::Warning(const char* aMessage,

View File

@@ -1,66 +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 <stdio.h>
#include "nsID.h"
const static char gIDFormat[] =
"{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}";
/*
* Turns a {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} string into
* an nsID
*/
PRBool nsID::Parse(char *aIDStr) {
int count, n1, n2, n3[8];
long int n0;
count = sscanf(aIDStr, gIDFormat,
&n0, &n1, &n2,
&n3[0],&n3[1],&n3[2],&n3[3],
&n3[4],&n3[5],&n3[6],&n3[7]);
m0 = (PRInt32) n0;
m1 = (PRInt16) n1;
m2 = (PRInt16) n2;
for (int i = 0; i < 8; i++) {
m3[i] = (PRInt8) n3[i];
}
return (PRBool) (count == 11);
}
/*
* Returns an allocated string in {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
* format. Caller should delete [] the string.
*/
char *nsID::ToString() const
{
char *res = new char[39];
if (res != NULL) {
sprintf(res, gIDFormat,
(long int) m0, (int) m1, (int) m2,
(int) m3[0], (int) m3[1], (int) m3[2], (int) m3[3],
(int) m3[4], (int) m3[5], (int) m3[6], (int) m3[7]);
}
return res;
}

Binary file not shown.

View File

@@ -20,6 +20,6 @@ IGNORE_MANIFEST=1
#
DEPTH=..
DIRS=src
DIRS=src tests
include <$(DEPTH)\config\rules.mak>

View File

@@ -22,20 +22,26 @@ LIBRARY_NAME = xpcom
CPPSRCS = nsDebug.cpp \
nsHashtable.cpp \
nsID.cpp \
nsSupportsArray.cpp \
nsRepository.cpp \
$(NULL)
EXPORTS = nsAgg.h \
nsCom.h \
EXPORTS = nsCom.h \
nsAgg.h \
nsDebug.h \
nsError.h \
nsHashtable.h \
nsID.h \
nsIFactory.h \
nsISupports.h \
nsIPtr.h \
nsISupportsArray.h \
nsRepository.h \
nsIEnumerator.h \
$(NULL)
DEFINES = -D_IMPL_NS_COM
LCFLAGS = -D_IMPL_NS_COM -DUSE_NSREG
REQUIRES = libreg
include $(DEPTH)/config/rules.mk

View File

@@ -21,38 +21,46 @@ MAKE_OBJ_TYPE = DLL
DEPTH=..\..
LINCS = \
-I$(PUBLIC)\libreg \
$(NULL)
LLIBS = \
$(LIBNSPR) \
$(DIST)\lib\libplc21.lib \
$(DIST)\lib\libreg32.lib \
$(NULL)
LIBNAME = .\$(OBJDIR)\xpcom$(MOZ_BITS)
DLL = $(LIBNAME).dll
LCFLAGS = -D_IMPL_NS_COM
REQUIRES =
LCFLAGS = -D_IMPL_NS_COM -DUSE_NSREG -DWIN32_LEAN_AND_MEAN
CPPSRCS = \
nsDebug.cpp \
nsHashtable.cpp \
nsID.cpp \
nsRepository.cpp \
nsSupportsArray.cpp \
CPP_OBJS = \
.\$(OBJDIR)\nsDebug.obj \
.\$(OBJDIR)\nsHashtable.obj \
.\$(OBJDIR)\nsID.obj \
.\$(OBJDIR)\nsSupportsArray.obj \
.\$(OBJDIR)\nsRepository.obj \
EXPORTS = \
nsAgg.h \
nsCom.h \
nsDebug.h \
nsError.h \
nsHashtable.h \
nsID.h \
nsIFactory.h \
nsISupports.h \
nsIPtr.h \
nsISupportsArray.h \
nsRepository.h \
nsIEnumerator.h \
$(NULL)
@@ -61,7 +69,8 @@ MODULE = xpcom
include <$(DEPTH)\config\rules.mak>
install:: $(DLL)
$(MAKE_INSTALL) $(LIBNAME).$(DLL_SUFFIX) $(DIST)\bin
$(MAKE_INSTALL) $(LIBNAME).$(LIB_SUFFIX) $(DIST)\lib
libs:: $(DLL)
$(MAKE_INSTALL) $(LIBNAME).$(DLL_SUFFIX) $(DIST)\bin
$(MAKE_INSTALL) $(LIBNAME).$(LIB_SUFFIX) $(DIST)\lib

View File

@@ -29,8 +29,8 @@ protected: \
\
/* You must implement this operation instead of the nsISupports */ \
/* methods if you inherit from nsAggregated. */ \
NS_IMETHOD AggregatedQueryInterface(const nsIID& aIID, \
void** aInstancePtr); \
NS_IMETHOD \
AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr); \
\
class Internal : public nsISupports { \
public: \
@@ -38,7 +38,7 @@ protected: \
Internal() {} \
\
NS_IMETHOD QueryInterface(const nsIID& aIID, \
void** aInstancePtr); \
void** aInstancePtr); \
NS_IMETHOD_(nsrefcnt) AddRef(void); \
NS_IMETHOD_(nsrefcnt) Release(void); \
\
@@ -60,7 +60,7 @@ public: \
// Put this in your class's implementation file:
#define NS_IMPL_AGGREGATED(_class) \
NS_METHOD \
NS_IMETHODIMP \
_class::QueryInterface(const nsIID& aIID, void** aInstancePtr) \
{ \
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); \
@@ -74,7 +74,7 @@ _class::QueryInterface(const nsIID& aIID, void** aInstancePtr) \
return AggregatedQueryInterface(aIID, aInstancePtr); \
} \
\
NS_METHOD_(nsrefcnt) \
NS_IMETHODIMP_(nsrefcnt) \
_class::AddRef(void) \
{ \
if (fOuter) \
@@ -83,7 +83,7 @@ _class::AddRef(void) \
return ++mRefCnt; \
} \
\
NS_METHOD_(nsrefcnt) \
NS_IMETHODIMP_(nsrefcnt) \
_class::Release(void) \
{ \
if (fOuter) \
@@ -97,21 +97,21 @@ _class::Release(void) \
} \
} \
\
NS_METHOD \
NS_IMETHODIMP \
_class::Internal::QueryInterface(const nsIID& aIID, void** aInstancePtr) \
{ \
_class* agg = (_class*)((char*)(this) - offsetof(_class, fAggregated)); \
return agg->AggregatedQueryInterface(aIID, aInstancePtr); \
} \
\
NS_METHOD \
NS_IMETHODIMP_(nsrefcnt) \
_class::Internal::AddRef(void) \
{ \
_class* agg = (_class*)((char*)(this) - offsetof(_class, fAggregated)); \
return ++agg->mRefCnt; \
} \
\
NS_METHOD \
NS_IMETHODIMP_(nsrefcnt) \
_class::Internal::Release(void) \
{ \
_class* agg = (_class*)((char*)(this) - offsetof(_class, fAggregated)); \

View File

@@ -24,41 +24,50 @@
*/
#ifdef _IMPL_NS_COM
# ifdef XP_PC
# define NS_COM _declspec(dllexport)
# else // !XP_PC
# define NS_COM
# endif // !XP_PC
#ifdef XP_PC
#define NS_COM _declspec(dllexport)
#else // !XP_PC
#define NS_COM
#endif // !XP_PC
#else // !_IMPL_NS_COM
# ifdef XP_PC
# define NS_COM _declspec(dllimport)
# else // !XP_PC
# define NS_COM
# endif // !XP_PC
#ifdef XP_PC
#define NS_COM _declspec(dllimport)
#else // !XP_PC
#define NS_COM
#endif // !XP_PC
#endif // !_IMPL_NS_COM
/*
* DLL Export macro
*/
#ifndef NS_EXPORT
# ifdef XP_PC
# define NS_EXPORT _declspec(dllexport)
# else // !XP_PC
# define NS_EXPORT
# endif // !XP_PC
#endif // !NS_EXPORT
#ifdef XP_PC
# define NS_METHOD_(Type) Type __stdcall
# define NS_METHOD nsresult __stdcall
#else // !XP_PC
# define NS_METHOD_(Type) Type
# define NS_METHOD nsresult
#endif // !XP_PC
#define NS_IMETHOD_(Type) virtual NS_METHOD_(Type)
#define NS_IMETHOD virtual NS_METHOD
#define NS_EXPORT _declspec(dllexport)
#define NS_EXPORT_(type) _declspec(dllexport) type __stdcall
#define NS_IMETHOD_(type) virtual type __stdcall
#define NS_IMETHOD virtual nsresult __stdcall
#define NS_IMETHODIMP_(type) type __stdcall
#define NS_IMETHODIMP nsresult __stdcall
#define NS_METHOD_(type) type __stdcall
#define NS_METHOD nsresult __stdcall
#else // !XP_PC
#define NS_EXPORT
#define NS_EXPORT_(type) type
#define NS_IMETHOD_(type) virtual type
#define NS_IMETHOD virtual nsresult
#define NS_IMETHODIMP_(type) type
#define NS_IMETHODIMP nsresult
#define NS_METHOD_(type) type
#define NS_METHOD nsresult
#endif // !XP_PC
#endif

View File

@@ -19,6 +19,10 @@
#include "nsDebug.h"
#include "prlog.h"
#if defined(_WIN32)
#include <windows.h>
#endif
/**
* Implementation of the nsDebug methods. Note that this code is
* always compiled in, in case some other module that uses it is
@@ -47,6 +51,20 @@ NS_COM void nsDebug::Abort(const char* aFile, PRIntn aLine)
#endif
}
NS_COM void nsDebug::Break(const char* aFile, PRIntn aLine)
{
InitLog();
PR_LOG(gDebugLog, PR_LOG_ERROR,
("Break: at file %s, line %d", aFile, aLine));
PR_LogFlush();
//XXX this works on win32 only for now. For all the other platforms call Abort
#if defined(_WIN32)
::DebugBreak();
#else
Abort(aFile, aLine);
#endif
}
NS_COM void nsDebug::PreCondition(const char* aStr, const char* aExpr,
const char* aFile, PRIntn aLine)
{
@@ -54,7 +72,7 @@ NS_COM void nsDebug::PreCondition(const char* aStr, const char* aExpr,
PR_LOG(gDebugLog, PR_LOG_ERROR,
("PreCondition: \"%s\" (%s) at file %s, line %d", aStr, aExpr,
aFile, aLine));
Abort(aFile, aLine);
Break(aFile, aLine);
}
NS_COM void nsDebug::PostCondition(const char* aStr, const char* aExpr,
@@ -64,7 +82,7 @@ NS_COM void nsDebug::PostCondition(const char* aStr, const char* aExpr,
PR_LOG(gDebugLog, PR_LOG_ERROR,
("PostCondition: \"%s\" (%s) at file %s, line %d", aStr, aExpr,
aFile, aLine));
Abort(aFile, aLine);
Break(aFile, aLine);
}
NS_COM void nsDebug::Assertion(const char* aStr, const char* aExpr,
@@ -74,7 +92,7 @@ NS_COM void nsDebug::Assertion(const char* aStr, const char* aExpr,
PR_LOG(gDebugLog, PR_LOG_ERROR,
("Assertion: \"%s\" (%s) at file %s, line %d", aStr, aExpr,
aFile, aLine));
Abort(aFile, aLine);
Break(aFile, aLine);
}
NS_COM void nsDebug::NotYetImplemented(const char* aMessage,
@@ -84,7 +102,7 @@ NS_COM void nsDebug::NotYetImplemented(const char* aMessage,
PR_LOG(gDebugLog, PR_LOG_ERROR,
("NotYetImplemented: \"%s\" at file %s, line %d", aMessage,
aFile, aLine));
Abort(aFile, aLine);
Break(aFile, aLine);
}
NS_COM void nsDebug::NotReached(const char* aMessage,
@@ -93,7 +111,7 @@ NS_COM void nsDebug::NotReached(const char* aMessage,
InitLog();
PR_LOG(gDebugLog, PR_LOG_ERROR,
("NotReached: \"%s\" at file %s, line %d", aMessage, aFile, aLine));
Abort(aFile, aLine);
Break(aFile, aLine);
}
NS_COM void nsDebug::Error(const char* aMessage,
@@ -102,7 +120,7 @@ NS_COM void nsDebug::Error(const char* aMessage,
InitLog();
PR_LOG(gDebugLog, PR_LOG_ERROR,
("Error: \"%s\" at file %s, line %d", aMessage, aFile, aLine));
Abort(aFile, aLine);
Break(aFile, aLine);
}
NS_COM void nsDebug::Warning(const char* aMessage,

View File

@@ -41,6 +41,11 @@ public:
*/
static NS_COM void Abort(const char* aFile, PRIntn aLine);
/**
* Break the executing program into the debugger.
*/
static NS_COM void Break(const char* aFile, PRIntn aLine);
/**
* Log a pre-condition message to the debug log
*/
@@ -101,6 +106,15 @@ if (!(expr)) \
if (!(expr)) \
nsDebug::Assertion(str, #expr, __FILE__, __LINE__)
/**
* Test an assertion for truth. If the expression is not true then
* trigger a program failure. The expression will still be
* executed in release mode.
*/
#define NS_VERIFY(expr,str) \
if (!(expr)) \
nsDebug::Assertion(str, #expr, __FILE__, __LINE__)
/**
* Test a post-condition for truth. If the expression is not true then
* trigger a program failure.
@@ -141,16 +155,24 @@ if (!(expr)) \
#define NS_ABORT() \
nsDebug::Abort(__FILE__, __LINE__)
/**
* Cause a break
*/
#define NS_BREAK() \
nsDebug::Break(__FILE__, __LINE__)
#else /* NS_DEBUG */
#define NS_PRECONDITION(expr,str) {}
#define NS_ASSERTION(expr,str) {}
#define NS_VERIFY(expr,str) expr
#define NS_POSTCONDITION(expr,str) {}
#define NS_NOTYETIMPLEMENTED(str) {}
#define NS_NOTREACHED(str) {}
#define NS_ERROR(str) {}
#define NS_WARNING(str) {}
#define NS_ABORT() {}
#define NS_BREAK() {}
#endif /* ! NS_DEBUG */

View File

@@ -0,0 +1,88 @@
/* -*- 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.
*/
#ifndef nsError_h
#define nsError_h
#define NS_FAILED(_nsresult) ((_nsresult) & 0x80000000)
#define NS_SUCCEEDED(_nsresult) (!((_nsresult) & 0x80000000))
/**
* @name Standard return values
*/
//@{
/// Standard "it worked" return value
#define NS_OK 0
#define NS_ERROR_BASE ((nsresult) 0xC1F30000)
/// Returned when an instance is not initialized
#define NS_ERROR_NOT_INITIALIZED (NS_ERROR_BASE + 1)
/// Returned when an instance is already initialized
#define NS_ERROR_ALREADY_INITIALIZED (NS_ERROR_BASE + 2)
/// Returned by a not implemented function
#define NS_ERROR_NOT_IMPLEMENTED ((nsresult) 0x80004001L)
/// Returned when a given interface is not supported.
#define NS_NOINTERFACE ((nsresult) 0x80004002L)
#define NS_ERROR_NO_INTERFACE NS_NOINTERFACE
#define NS_ERROR_INVALID_POINTER ((nsresult) 0x80004003L)
#define NS_ERROR_NULL_POINTER NS_ERROR_INVALID_POINTER
/// Returned when a function aborts
#define NS_ERROR_ABORT ((nsresult) 0x80004004L)
/// Returned when a function fails
#define NS_ERROR_FAILURE ((nsresult) 0x80004005L)
/// Returned when an unexpected error occurs
#define NS_ERROR_UNEXPECTED ((nsresult) 0x8000ffffL)
/// Returned when a memory allocation failes
#define NS_ERROR_OUT_OF_MEMORY ((nsresult) 0x8007000eL)
/// Returned when an illegal value is passed
#define NS_ERROR_ILLEGAL_VALUE ((nsresult) 0x80070057L)
/// Returned when a class doesn't allow aggregation
#define NS_ERROR_NO_AGGREGATION ((nsresult) 0x80040110L)
/// Returned when a class doesn't allow aggregation
#define NS_ERROR_NOT_AVAILABLE ((nsresult) 0x80040111L)
/// Returned when a class is not registered
#define NS_ERROR_FACTORY_NOT_REGISTERED ((nsresult) 0x80040154L)
/// Returned when a dynamically loaded factory couldn't be found
#define NS_ERROR_FACTORY_NOT_LOADED ((nsresult) 0x800401f8L)
/// Returned when a factory doesn't support signatures
#define NS_ERROR_FACTORY_NO_SIGNATURE_SUPPORT \
(NS_ERROR_BASE + 0x101)
/// Returned when a factory already is registered
#define NS_ERROR_FACTORY_EXISTS (NS_ERROR_BASE + 0x100)
//@}
#endif

View File

@@ -25,11 +25,11 @@
static PR_CALLBACK PLHashNumber _hashValue(const void *key)
{
return ((nsHashKey *) key)->HashValue();
return ((const nsHashKey *) key)->HashValue();
}
static PR_CALLBACK PRIntn _hashKeyCompare(const void *key1, const void *key2) {
return ((nsHashKey *) key1)->Equals((nsHashKey *) key2);
return ((const nsHashKey *) key1)->Equals((const nsHashKey *) key2);
}
static PR_CALLBACK PRIntn _hashValueCompare(const void *value1,
@@ -78,6 +78,17 @@ static PR_CALLBACK PRIntn _hashEnumerate(PLHashEntry *he, PRIntn i, void *arg)
HT_ENUMERATE_STOP;
}
//
// HashKey
//
nsHashKey::nsHashKey(void)
{
}
nsHashKey::~nsHashKey(void)
{
}
nsHashtable::nsHashtable(PRUint32 aInitSize) {
hashtable = PL_NewHashTable(aInitSize,
_hashValue,

View File

@@ -20,19 +20,23 @@
#define nsHashtable_h__
#include "plhash.h"
#include "nsCom.h"
class nsHashKey {
class NS_COM nsHashKey {
protected:
nsHashKey(void);
public:
virtual PRUint32 HashValue() = 0;
virtual PRBool Equals(nsHashKey *aKey) = 0;
virtual nsHashKey *Clone() = 0;
virtual ~nsHashKey(void);
virtual PRUint32 HashValue(void) const = 0;
virtual PRBool Equals(const nsHashKey *aKey) const = 0;
virtual nsHashKey *Clone(void) const = 0;
};
// Enumerator callback function. Use
typedef PRBool (*nsHashtableEnumFunc)(nsHashKey *aKey, void *aData);
class nsHashtable {
class NS_COM nsHashtable {
private:
// members
PLHashTable *hashtable;
@@ -41,6 +45,7 @@ public:
nsHashtable(PRUint32 aSize = 256);
~nsHashtable();
PRInt32 Count(void) { return hashtable->nentries; }
void *Put(nsHashKey *aKey, void *aData);
void *Get(nsHashKey *aKey);
void *Remove(nsHashKey *aKey);

View File

@@ -15,34 +15,40 @@
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include <stdio.h>
#include "nsID.h"
#include "prprf.h"
const static char gIDFormat[] =
"{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}";
static const char gIDFormat[] =
"{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}";
static const char gIDFormat2[] =
"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x";
/*
* Turns a {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} string into
* an nsID
*/
PRBool nsID::Parse(char *aIDStr) {
int count, n1, n2, n3[8];
long int n0;
NS_COM PRBool nsID::Parse(char *aIDStr)
{
PRInt32 count = 0;
PRInt32 n1, n2, n3[8];
PRInt32 n0;
count = sscanf(aIDStr, gIDFormat,
&n0, &n1, &n2,
&n3[0],&n3[1],&n3[2],&n3[3],
&n3[4],&n3[5],&n3[6],&n3[7]);
if (NULL != aIDStr) {
count = PR_sscanf(aIDStr,
(aIDStr[0] == '{') ? gIDFormat : gIDFormat2,
&n0, &n1, &n2,
&n3[0],&n3[1],&n3[2],&n3[3],
&n3[4],&n3[5],&n3[6],&n3[7]);
m0 = (PRInt32) n0;
m1 = (PRInt16) n1;
m2 = (PRInt16) n2;
for (int i = 0; i < 8; i++) {
m3[i] = (PRInt8) n3[i];
m0 = (PRInt32) n0;
m1 = (PRInt16) n1;
m2 = (PRInt16) n2;
for (int i = 0; i < 8; i++) {
m3[i] = (PRInt8) n3[i];
}
}
return (PRBool) (count == 11);
}
@@ -51,15 +57,16 @@ PRBool nsID::Parse(char *aIDStr) {
* format. Caller should delete [] the string.
*/
char *nsID::ToString() const
NS_COM char *nsID::ToString() const
{
char *res = new char[39];
if (res != NULL) {
sprintf(res, gIDFormat,
(long int) m0, (int) m1, (int) m2,
(int) m3[0], (int) m3[1], (int) m3[2], (int) m3[3],
(int) m3[4], (int) m3[5], (int) m3[6], (int) m3[7]);
PR_snprintf(res, 39, gIDFormat,
m0, (PRUint32) m1, (PRUint32) m2,
(PRUint32) m3[0], (PRUint32) m3[1], (PRUint32) m3[2],
(PRUint32) m3[3], (PRUint32) m3[4], (PRUint32) m3[5],
(PRUint32) m3[6], (PRUint32) m3[7]);
}
return res;
}

View File

@@ -21,15 +21,34 @@
#include "prtypes.h"
#include "string.h"
#include "nsCom.h"
/**
* A "unique identifier". This is modeled after OSF DCE UUIDs.
*/
struct nsID {
/**
* @name Indentifier values
*/
//@{
PRUint32 m0;
PRUint16 m1, m2;
PRUint16 m1;
PRUint16 m2;
PRUint8 m3[8];
//@}
/**
* @name Methods
*/
//@{
/**
* Equivalency method. Compares this nsID with another.
* @return <b>PR_TRUE</b> if they are the same, <b>PR_FALSE</b> if not.
*/
inline PRBool Equals(const nsID& other) const {
return (PRBool)
((((PRUint32*) &m0)[0] == ((PRUint32*) &other.m0)[0]) &&
@@ -38,14 +57,33 @@ struct nsID {
(((PRUint32*) &m0)[3] == ((PRUint32*) &other.m0)[3]));
}
// Turns a {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} string into
// an nsID
PRBool Parse(char *aIDStr);
/**
* nsID Parsing method. Turns a {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
* string into an nsID
*/
NS_COM PRBool Parse(char *aIDStr);
// Returns an allocated string in {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
// format. Caller should free string.
char* ToString() const;
/**
* nsID string encoder. Returns an allocated string in
* {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} format. Caller should free string.
*/
NS_COM char* ToString() const;
//@}
};
/**
* Declare an ID. If NS_IMPL_IDS is set, a variable <i>_name</i> is declared
* with the given values, otherwise <i>_name</i> is declared as an
* <tt>extern</tt> variable.
*/
#ifdef NS_IMPL_IDS
#define NS_DECLARE_ID(_name,m0,m1,m2,m30,m31,m32,m33,m34,m35,m36,m37) \
extern "C" const nsID _name = {m0,m1,m2,{m30,m31,m32,m33,m34,m35,m36,m37}}
#else
#define NS_DECLARE_ID(_name,m0,m1,m2,m30,m31,m32,m33,m34,m35,m36,m37) \
extern "C" const nsID _name
#endif
#endif

View File

@@ -46,10 +46,10 @@ typedef nsID nsCID;
class nsIFactory: public nsISupports {
public:
NS_IMETHOD CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
REFNSIID aIID,
void **aResult) = 0;
NS_IMETHOD_(void) LockFactory(PRBool aLock) = 0;
NS_IMETHOD LockFactory(PRBool aLock) = 0;
};
/**
@@ -65,7 +65,7 @@ public:
class nsIFactory2: public nsIFactory {
public:
NS_IMETHOD CreateInstance2(nsISupports *aOuter,
const nsIID &aIID,
REFNSIID aIID,
void *aSignature,
void **aResult) = 0;
};

142
mozilla/xpcom/src/nsIPtr.h Normal file
View File

@@ -0,0 +1,142 @@
/* -*- 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.
*/
#ifndef nsIPtr_h___
#define nsIPtr_h___
#include "nsISupports.h"
/*
* nsIPtr is an "auto-release pointer" class for nsISupports based interfaces
*
* It's intent is to be a "set and forget" pointer to help with managing
* active references to nsISupports bases objects.
*
* The pointer object ensures that the underlying pointer is always
* released whenever the value is changed or when the object leaves scope.
*
* Proper care needs to be taken when assigning pointers to a nsIPtr.
* When asigning from a C pointer (nsISupports*), the pointer presumes
* an active reference and subsumes it. When assigning from another nsIPtr,
* a new reference is established.
*
* There are 3 ways to assign a value to a nsIPtr.
* 1) Direct construction or assignment from a C pointer.
* 2) Direct construction or assignment form another nsIPtr.
* 3) Usage of an "out parameter" method.
* a) AssignRef() releases the underlying pointer and returns a reference to it.
* Useful for pointer reference out paramaters.
* b) AssignPtr() releases the underlying pointer and returns a pointer to it.
* c) Query() releases the underlying pointer and returns a (void**) pointer to it.
* Useful for calls to QueryInterface()
* 4) The SetAddRef() method. This is equivalent to an assignment followed by an AddRef().
*
* examples:
*
* class It {
* void NS_NewFoo(nsIFoo** aFoo);
* nsIFoo* GetFoo(void);
* void GetBar(nsIBar*& aBar);
* };
*
* nsIFooPtr foo = it->GetFoo();
* nsIBarPtr bar;
*
* it->NS_NewFoo(foo.AssignPtr());
* it->GetBar(bar.AssignRef());
* it->QueryInterface(kIFooIID, foo.Query());
* bar.SetAddRef(new Bar());
*
* Advantages:
* Set and forget. Once a pointer is assigned to a nsIPtr, it is impossible
* to forget to release it.
* Always pre-initialized. You can't forget to initialize the pointer.
*
* Disadvantages:
* Usage of this class doesn't eliminate the need to think about ref counts
* and assign values properly, AddRef'ing as needed.
* The nsIPtr doesn't typecast exactly like a C pointer. In order to achieve
* typecasting, it may be necessary to first cast to a C pointer of the
* underlying type.
*
*/
#define NS_DEF_PTR(cls) \
class cls##Ptr { \
public: \
cls##Ptr(void) : mPtr(0) {} \
cls##Ptr(const cls##Ptr& aCopy) : mPtr(aCopy.mPtr) \
{ if(0 != mPtr) mPtr->AddRef(); } \
cls##Ptr(cls* aInterface) : mPtr(aInterface) {} \
~cls##Ptr(void) { if(0 != mPtr) mPtr->Release(); } \
cls##Ptr& operator=(const cls##Ptr& aCopy) \
{ if(mPtr == aCopy.mPtr) return *this; \
if(0 != aCopy.mPtr) aCopy.mPtr->AddRef(); \
if(0 != mPtr) mPtr->Release(); \
mPtr = aCopy.mPtr; return *this; } \
cls##Ptr& operator=(cls* aInterface) \
{ if(mPtr == aInterface) return *this; \
if(0 != mPtr) mPtr->Release(); mPtr = aInterface; \
return *this; } \
cls##Ptr& operator=(PRInt32 aInt) \
{ if(0 != mPtr) mPtr->Release(); mPtr = 0; \
return *this; } \
void SetAddRef(cls* aInterface) \
{ if(aInterface == mPtr) return; \
if(0 != aInterface) aInterface->AddRef(); \
if(0 != mPtr) mPtr->Release(); mPtr = aInterface; } \
cls* AddRef(void) { mPtr->AddRef(); return mPtr; } \
cls* IfAddRef(void) \
{ if(0 != mPtr) mPtr->AddRef(); return mPtr; } \
cls*& AssignRef(void) \
{ if(0 != mPtr) mPtr->Release(); mPtr = 0; return mPtr; } \
cls** AssignPtr(void) \
{ if(0 != mPtr) mPtr->Release(); mPtr = 0; return &mPtr; } \
void** Query(void) \
{ if(0 != mPtr) mPtr->Release(); mPtr = 0; return (void**)&mPtr; } \
PRBool IsNull() const \
{ return PRBool(0 == mPtr); } \
PRBool IsNotNull() const \
{ return PRBool(0 != mPtr); } \
PRBool operator==(const cls##Ptr& aCopy) const \
{ return PRBool(mPtr == aCopy.mPtr); } \
PRBool operator==(cls* aInterface) const \
{ return PRBool(mPtr == aInterface); } \
PRBool operator!=(const cls##Ptr& aCopy) const \
{ return PRBool(mPtr != aCopy.mPtr); } \
PRBool operator!=(cls* aInterface) const \
{ return PRBool(mPtr != aInterface); } \
cls* operator->(void) { return mPtr; } \
cls& operator*(void) { return *mPtr; } \
operator cls*(void) { return mPtr; } \
const cls* operator->(void) const { return mPtr; } \
const cls& operator*(void) const { return *mPtr; } \
operator const cls*(void) const { return mPtr; } \
private: \
void* operator new(size_t size) { return 0; } \
void operator delete(void* aPtr) {} \
cls* mPtr; \
public: \
friend inline PRBool operator==(const cls* aInterface, const cls##Ptr& aPtr) \
{ return PRBool(aInterface == aPtr.mPtr); } \
friend inline PRBool operator!=(const cls* aInterface, const cls##Ptr& aPtr) \
{ return PRBool(aInterface != aPtr.mPtr); } \
}
#endif // nsIPtr_h___

View File

@@ -21,73 +21,110 @@
#include "nsDebug.h"
#include "nsID.h"
#include "nsError.h"
// An "interface id" which can be used to uniquely identify a given
// interface. Primarily used as an argument to nsISupports.QueryInterface
// method.
/*@{*/
/**
* An "interface id" which can be used to uniquely identify a given
* interface.
*/
typedef nsID nsIID;
// Define an IID
/**
* A macro shorthand for <tt>const nsIID&<tt>
*/
#define REFNSIID const nsIID&
/**
* Define an IID (obsolete)
*/
#define NS_DEFINE_IID(_name, _iidspec) \
const nsIID _name = _iidspec
//----------------------------------------------------------------------
// IID for the nsISupports interface
// {00000000-0000-0000-c000-000000000046}
/**
* IID for the nsISupports interface
* {00000000-0000-0000-c000-000000000046}
*/
#define NS_ISUPPORTS_IID \
{ 0x00000000, 0x0000, 0x0000, \
{0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} }
#define NS_FAILED(_nsresult) ((_nsresult) & 0x80000000)
#define NS_SUCCEEDED(_nsresult) (!((_nsresult) & 0x80000000))
/**
* Generic result data type
*/
// Standard "it worked" return value
#define NS_OK 0
#define NS_ERROR_BASE ((nsresult) 0xC1F30000)
// Some standard error codes we use
#define NS_ERROR_OUT_OF_MEMORY (NS_ERROR_BASE + 0)
#define NS_ERROR_NO_AGGREGATION (NS_ERROR_BASE + 1)
#define NS_ERROR_NULL_POINTER (NS_ERROR_BASE + 2)
#define NS_ERROR_ILLEGAL_VALUE (NS_ERROR_BASE + 3)
#define NS_ERROR_NOT_INITIALIZED (NS_ERROR_BASE + 4)
#define NS_ERROR_ALREADY_INITIALIZED (NS_ERROR_BASE + 5)
#define NS_ERROR_NOT_IMPLEMENTED (NS_ERROR_BASE + 6)
// Generic result data type
typedef PRUint32 nsresult;
// This is returned by QueryInterface when a given interface is not
// supported.
#define NS_NOINTERFACE ((nsresult) 0x80004002L)
// Reference count values
/**
* Reference count values
*/
typedef PRUint32 nsrefcnt;
// Basic component object model interface. Objects which implement
// this interface support runtime interface discovery (QueryInterface)
// and a reference counted memory model (AddRef/Release). This is
// modelled after the win32 IUnknown API.
/**
* Basic component object model interface. Objects which implement
* this interface support runtime interface discovery (QueryInterface)
* and a reference counted memory model (AddRef/Release). This is
* modelled after the win32 IUnknown API.
*/
class nsISupports {
public:
NS_IMETHOD QueryInterface(const nsIID& aIID,
/**
* @name Methods
*/
//@{
/**
* A run time mechanism for interface discovery.
* @param aIID [in] A requested interface IID
* @param aInstancePtr [out] A pointer to an interface pointer to
* receive the result.
* @return <b>NS_OK</b> if the interface is supported by the associated
* instance, <b>NS_NOINTERFACE</b> if it is not.
* <b>NS_ERROR_INVALID_POINTER</b> if <i>aInstancePtr</i> is <b>NULL</b>.
*/
NS_IMETHOD QueryInterface(REFNSIID aIID,
void** aInstancePtr) = 0;
/**
* Increases the reference count for this interface.
* The associated instance will not be deleted unless
* the reference count is returned to zero.
*
* @return The resulting reference count.
*/
NS_IMETHOD_(nsrefcnt) AddRef(void) = 0;
/**
* Decreases the reference count for this interface.
* Generally, if the reference count returns to zero,
* the associated instance is deleted.
*
* @return The resulting reference count.
*/
NS_IMETHOD_(nsrefcnt) Release(void) = 0;
//@}
};
//----------------------------------------------------------------------
// Some convenience macros for implementing AddRef and Release
/**
* Some convenience macros for implementing AddRef and Release
*/
// Declare the reference count variable and the implementations of the
// AddRef and QueryInterface methods.
/**
* Declare the reference count variable and the implementations of the
* AddRef and QueryInterface methods.
*/
#define NS_DECL_ISUPPORTS \
public: \
NS_IMETHOD QueryInterface(const nsIID& aIID, \
NS_IMETHOD QueryInterface(REFNSIID aIID, \
void** aInstancePtr); \
NS_IMETHOD_(nsrefcnt) AddRef(void); \
NS_IMETHOD_(nsrefcnt) Release(void); \
@@ -95,35 +132,60 @@ protected: \
nsrefcnt mRefCnt; \
public:
// Initialize the reference count variable. Add this to each and every
// constructor you implement.
/**
* Initialize the reference count variable. Add this to each and every
* constructor you implement.
*/
#define NS_INIT_REFCNT() mRefCnt = 0
// Use this macro to implement the AddRef method for a given _class
/**
* Use this macro to implement the AddRef method for a given <i>_class</i>
* @param _class The name of the class implementing the method
*/
#define NS_IMPL_ADDREF(_class) \
nsrefcnt _class::AddRef(void) \
{ \
return ++mRefCnt; \
}
/**
* Macro for adding a reference to an interface.
* @param _ptr The interface pointer.
*/
#define NS_ADDREF(_ptr) \
(_ptr)->AddRef()
/**
* Macro for adding a reference to an interface that checks for NULL.
* @param _ptr The interface pointer.
*/
#define NS_IF_ADDREF(_ptr) \
((0 != (_ptr)) ? (_ptr)->AddRef() : 0);
/**
* Macro for releasing a reference to an interface.
* @param _ptr The interface pointer.
*/
#define NS_RELEASE(_ptr) \
(_ptr)->Release(); \
(_ptr) = NULL
/**
* Macro for releasing a reference to an interface that checks for NULL;
* @param _ptr The interface pointer.
*/
#define NS_IF_RELEASE(_ptr) \
((0 != (_ptr)) ? (_ptr)->Release() : 0); \
(_ptr) = NULL
// Use this macro to implement the Release method for a given _class
/**
* Use this macro to implement the Release method for a given <i>_class</i>
* @param _class The name of the class implementing the method
*/
#define NS_IMPL_RELEASE(_class) \
nsrefcnt _class::Release(void) \
{ \
NS_PRECONDITION(0 != mRefCnt, "dup release"); \
if (--mRefCnt == 0) { \
delete this; \
return 0; \
@@ -133,18 +195,23 @@ nsrefcnt _class::Release(void) \
//----------------------------------------------------------------------
// Some convenience macros for implementing QueryInterface
/*
* Some convenience macros for implementing QueryInterface
*/
/**
* This implements query interface with two assumptions: First, the
* class in question implements nsISupports and it's own interface and
* nothing else. Second, the implementation of the class's primary
* inheritance chain leads to it's own interface.
*
* @param _class The name of the class implementing the method
* @param _classiiddef The name of the #define symbol that defines the IID
* for the class (e.g. NS_ISUPPORTS_IID)
*/
// This implements query interface with two assumptions: First, the
// class in question implements nsISupports and it's own interface and
// nothing else. Second, the implementation of the class's primary
// inheritance chain leads to it's own interface.
//
// _class is the name of the class implementing the method
// _classiiddef is the name of the #define symbol that defines the IID
// for the class (e.g. NS_ISUPPORTS_IID)
#define NS_IMPL_QUERY_INTERFACE(_class,_classiiddef) \
nsresult _class::QueryInterface(const nsIID& aIID, void** aInstancePtr) \
nsresult _class::QueryInterface(REFNSIID aIID, void** aInstancePtr) \
{ \
if (NULL == aInstancePtr) { \
return NS_ERROR_NULL_POINTER; \
@@ -164,9 +231,19 @@ nsresult _class::QueryInterface(const nsIID& aIID, void** aInstancePtr) \
return NS_NOINTERFACE; \
}
/**
* Convenience macro for implementing all nsISupports methods for
* a simple class.
* @param _class The name of the class implementing the method
* @param _classiiddef The name of the #define symbol that defines the IID
* for the class (e.g. NS_ISUPPORTS_IID)
*/
#define NS_IMPL_ISUPPORTS(_class,_classiiddef) \
NS_IMPL_ADDREF(_class) \
NS_IMPL_RELEASE(_class) \
NS_IMPL_QUERY_INTERFACE(_class,_classiiddef)
/*@}*/
#endif /* nsISupports_h___ */

View File

@@ -0,0 +1,72 @@
/* -*- 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.
*/
#ifndef nsISupportsArray_h___
#define nsISupportsArray_h___
#include "nsCom.h"
#include "nsISupports.h"
// {791eafa0-b9e6-11d1-8031-006008159b5a}
#define NS_ISUPPORTSARRAY_IID \
{0x791eafa0, 0xb9e6, 0x11d1, \
{0x80, 0x31, 0x00, 0x60, 0x08, 0x15, 0x9b, 0x5a}}
// Enumerator callback function. Return PR_FALSE to stop
typedef PRBool (*nsISupportsArrayEnumFunc)(nsISupports* aElement, void *aData);
class nsISupportsArray : public nsISupports {
public:
NS_IMETHOD_(nsISupportsArray&) operator=(const nsISupportsArray& other) = 0;
NS_IMETHOD_(PRBool) operator==(const nsISupportsArray& other) const = 0;
NS_IMETHOD_(PRBool) Equals(const nsISupportsArray* other) const = 0;
NS_IMETHOD_(PRInt32) Count(void) const = 0;
NS_IMETHOD_(nsISupports*) ElementAt(PRInt32 aIndex) const = 0;
NS_IMETHOD_(nsISupports*) operator[](PRInt32 aIndex) const = 0;
NS_IMETHOD_(PRInt32) IndexOf(const nsISupports* aPossibleElement, PRInt32 aStartIndex = 0) const = 0;
NS_IMETHOD_(PRInt32) LastIndexOf(const nsISupports* aPossibleElement) const = 0;
NS_IMETHOD_(PRBool) InsertElementAt(nsISupports* aElement, PRInt32 aIndex) = 0;
NS_IMETHOD_(PRBool) ReplaceElementAt(nsISupports* aElement, PRInt32 aIndex) = 0;
NS_IMETHOD_(PRBool) AppendElement(nsISupports* aElement) = 0;
NS_IMETHOD_(PRBool) RemoveElementAt(PRInt32 aIndex) = 0;
NS_IMETHOD_(PRBool) RemoveElement(const nsISupports* aElement, PRInt32 aStartIndex = 0) = 0;
NS_IMETHOD_(PRBool) RemoveLastElement(const nsISupports* aElement) = 0;
NS_IMETHOD_(void) Clear(void) = 0;
NS_IMETHOD_(void) Compact(void) = 0;
NS_IMETHOD_(PRBool) EnumerateForwards(nsISupportsArrayEnumFunc aFunc, void* aData) = 0;
NS_IMETHOD_(PRBool) EnumerateBackwards(nsISupportsArrayEnumFunc aFunc, void* aData) = 0;
private:
// Copy constructors are not allowed
// XXX test wether this has to be here nsISupportsArray(const nsISupportsArray& other);
};
extern NS_COM nsresult
NS_NewISupportsArray(nsISupportsArray** aInstancePtrResult);
#endif // nsISupportsArray_h___

View File

@@ -18,11 +18,13 @@
#include <stdlib.h>
#include <iostream.h>
#ifdef _WIN32
#include <windows.h>
#endif
#include "plstr.h"
#include "prlink.h"
#include "nsRepository.h"
#ifdef USE_NSREG
#define STANDALONE_REGISTRY
#define XP_BEGIN_PROTOS extern "C" {
#define XP_END_PROTOS };
#include "NSReg.h"
@@ -31,7 +33,6 @@
nsHashtable *NSRepository::factories = NULL;
PRMonitor *NSRepository::monitor = NULL;
static NS_DEFINE_IID(kFactoryIID, NS_IFACTORY_IID);
static NS_DEFINE_IID(kFactory2IID, NS_IFACTORY2_IID);
class FactoryEntry {
@@ -74,15 +75,15 @@ public:
id = aID;
}
PRUint32 HashValue() {
PRUint32 HashValue(void) const {
return id.m0;
}
PRBool Equals(nsHashKey *aKey) {
return (id.Equals(((IDKey *) aKey)->id));
PRBool Equals(const nsHashKey *aKey) const {
return (id.Equals(((const IDKey *) aKey)->id));
}
nsHashKey *Clone() {
nsHashKey *Clone(void) const {
return new IDKey(id);
}
};
@@ -97,15 +98,16 @@ static nsresult platformRegister(const nsCID &aCID, const char *aLibrary)
if (err == REGERR_OK) {
RKEY key;
err = NR_RegAddKey(hreg, ROOTKEY_COMMON,
"SOFTWARE\\Netscape\\CID", &key);
"Classes", &key);
if (err == REGERR_OK) {
char *cidString = aCID.ToString();
NR_RegSetEntryString(hreg, key, cidString, (char *) aLibrary);
err = NR_RegSetEntryString(hreg, key, cidString, (char *) aLibrary);
delete [] cidString;
}
NR_RegClose(hreg);
}
return NS_OK;
return err;
}
static nsresult platformUnregister(const nsCID &aCID, const char *aLibrary)
@@ -115,15 +117,15 @@ static nsresult platformUnregister(const nsCID &aCID, const char *aLibrary)
if (err == REGERR_OK) {
RKEY key;
err = NR_RegAddKey(hreg, ROOTKEY_COMMON,
"SOFTWARE\\Netscape\\CID", &key);
"Classes", &key);
if (err == REGERR_OK) {
char *cidString = aCID.ToString();
NR_RegDeleteEntry(hreg, key, cidString);
err = NR_RegDeleteEntry(hreg, key, cidString);
delete [] cidString;
}
NR_RegClose(hreg);
}
return NS_OK;
return err;
}
static FactoryEntry *platformFind(const nsCID &aCID)
@@ -134,11 +136,11 @@ static FactoryEntry *platformFind(const nsCID &aCID)
if (err == REGERR_OK) {
RKEY key;
err = NR_RegGetKey(hreg, ROOTKEY_COMMON,
"SOFTWARE\\Netscape\\CID", &key);
"Classes", &key);
if (err == REGERR_OK) {
char *cidString = aCID.ToString();
char library[_MAX_PATH];
uint32 len = _MAX_PATH;
char library[256];
uint32 len = 256;
err = NR_RegGetEntryString(hreg, key, cidString, library, len);
delete [] cidString;
@@ -153,7 +155,7 @@ static FactoryEntry *platformFind(const nsCID &aCID)
#else // USE_NSREG
#ifdef XP_PC
#ifdef _WIN32
#define USE_REGISTRY
static nsresult platformRegister(const nsCID &aCID, const char *aLibrary)
@@ -205,7 +207,7 @@ static FactoryEntry *platformFind(const nsCID &aCID)
return NULL;
}
#endif // XP_PC
#endif // _WIN32
#endif // USE_NSREG
@@ -291,6 +293,9 @@ nsresult NSRepository::Initialize()
monitor = PR_NewMonitor();
}
#ifdef USE_NSREG
NR_StartupRegistry();
#endif
return NS_OK;
}

View File

@@ -23,28 +23,34 @@
#include "prmon.h"
#include "nsCom.h"
#include "nsID.h"
#include "nsError.h"
#include "nsISupports.h"
#include "nsIFactory.h"
#include "nsHashtable.h"
/*
* NSIRepository class
* Prototypes for dynamic library export functions
*/
// Errors
#define NS_ERROR_FACTORY_EXISTS (NS_ERROR_BASE + 0x100)
#define NS_ERROR_FACTORY_NOT_REGISTERED (NS_ERROR_BASE + 0x101)
#define NS_ERROR_FACTORY_NOT_LOADED (NS_ERROR_BASE + 0x102)
#define NS_ERROR_FACTORY_NO_SIGNATURE_SUPPORT (NS_ERROR_BASE + 0x103)
#define NS_ERROR_FACTORY_NOT_UNREGISTERED (NS_ERROR_BASE + 0x104)
extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass,
nsIFactory **aFactory);
extern "C" NS_EXPORT PRBool NSCanUnload(void);
extern "C" NS_EXPORT nsresult NSRegisterSelf(const char *path);
extern "C" NS_EXPORT nsresult NSUnregisterSelf(const char *path);
/*
* Dynamic library export function types
*/
typedef nsresult (*nsFactoryProc)(const nsCID &aCLass,
nsIFactory **aFactory);
typedef PRBool (*nsCanUnloadProc)();
typedef PRBool (*nsCanUnloadProc)(void);
typedef nsresult (*nsRegisterProc)(const char *path);
typedef nsresult (*nsUnregisterProc)(const char *path);
class FactoryEntry;
/*
* NSRepository class
*/
class NS_COM NSRepository {
private:

View File

@@ -0,0 +1,341 @@
/* -*- 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 "nsISupportsArray.h"
static NS_DEFINE_IID(kISupportsArrayIID, NS_ISUPPORTSARRAY_IID);
static const PRInt32 kGrowArrayBy = 8;
static const PRInt32 kAutoArraySize = 4;
class SupportsArrayImpl : public nsISupportsArray {
public:
SupportsArrayImpl(void);
~SupportsArrayImpl(void);
NS_DECL_ISUPPORTS
NS_IMETHOD_(nsISupportsArray&) operator=(const nsISupportsArray& aOther);
NS_IMETHOD_(PRBool) operator==(const nsISupportsArray& aOther) const { return Equals(&aOther); }
NS_IMETHOD_(PRBool) Equals(const nsISupportsArray* aOther) const;
NS_IMETHOD_(PRInt32) Count(void) const { return mCount; }
NS_IMETHOD_(nsISupports*) ElementAt(PRInt32 aIndex) const;
NS_IMETHOD_(nsISupports*) operator[](PRInt32 aIndex) const { return ElementAt(aIndex); }
NS_IMETHOD_(PRInt32) IndexOf(const nsISupports* aPossibleElement, PRInt32 aStartIndex = 0) const;
NS_IMETHOD_(PRInt32) LastIndexOf(const nsISupports* aPossibleElement) const;
NS_IMETHOD_(PRBool) InsertElementAt(nsISupports* aElement, PRInt32 aIndex);
NS_IMETHOD_(PRBool) ReplaceElementAt(nsISupports* aElement, PRInt32 aIndex);
NS_IMETHOD_(PRBool) AppendElement(nsISupports* aElement) {
return InsertElementAt(aElement, mCount);
}
NS_IMETHOD_(PRBool) RemoveElementAt(PRInt32 aIndex);
NS_IMETHOD_(PRBool) RemoveElement(const nsISupports* aElement, PRInt32 aStartIndex = 0);
NS_IMETHOD_(PRBool) RemoveLastElement(const nsISupports* aElement);
NS_IMETHOD_(void) Clear(void);
NS_IMETHOD_(void) Compact(void);
NS_IMETHOD_(PRBool) EnumerateForwards(nsISupportsArrayEnumFunc aFunc, void* aData);
NS_IMETHOD_(PRBool) EnumerateBackwards(nsISupportsArrayEnumFunc aFunc, void* aData);
protected:
void DeleteArray(void);
nsISupports** mArray;
PRInt32 mArraySize;
PRInt32 mCount;
nsISupports* mAutoArray[kAutoArraySize];
private:
// Copy constructors are not allowed
SupportsArrayImpl(const nsISupportsArray& other);
};
SupportsArrayImpl::SupportsArrayImpl()
{
NS_INIT_REFCNT();
mArray = &(mAutoArray[0]);
mArraySize = kAutoArraySize;
mCount = 0;
}
SupportsArrayImpl::~SupportsArrayImpl()
{
DeleteArray();
}
NS_IMPL_ISUPPORTS(SupportsArrayImpl, kISupportsArrayIID);
void SupportsArrayImpl::DeleteArray(void)
{
Clear();
if (mArray != &(mAutoArray[0])) {
delete[] mArray;
mArray = &(mAutoArray[0]);
mArraySize = kAutoArraySize;
}
}
nsISupportsArray& SupportsArrayImpl::operator=(const nsISupportsArray& aOther)
{
PRInt32 otherCount = aOther.Count();
if (otherCount > mArraySize) {
DeleteArray();
mArraySize = otherCount;
mArray = new nsISupports*[mArraySize];
}
else {
Clear();
}
mCount = otherCount;
while (0 <= --otherCount) {
mArray[otherCount] = aOther.ElementAt(otherCount);
}
return *this;
}
PRBool SupportsArrayImpl::Equals(const nsISupportsArray* aOther) const
{
if (0 != aOther) {
const SupportsArrayImpl* other = (const SupportsArrayImpl*)aOther;
if (mCount == other->mCount) {
PRInt32 index = mCount;
while (0 <= --index) {
if (mArray[index] != other->mArray[index]) {
return PR_FALSE;
}
}
return PR_TRUE;
}
}
return PR_FALSE;
}
nsISupports* SupportsArrayImpl::ElementAt(PRInt32 aIndex) const
{
if ((0 <= aIndex) && (aIndex < mCount)) {
nsISupports* element = mArray[aIndex];
NS_ADDREF(element);
return element;
}
return 0;
}
PRInt32 SupportsArrayImpl::IndexOf(const nsISupports* aPossibleElement, PRInt32 aStartIndex) const
{
if ((0 <= aStartIndex) && (aStartIndex < mCount)) {
const nsISupports** start = (const nsISupports**)mArray; // work around goofy compiler behavior
const nsISupports** ep = (start + aStartIndex);
const nsISupports** end = (start + mCount);
while (ep < end) {
if (aPossibleElement == *ep) {
return (ep - start);
}
ep++;
}
}
return -1;
}
PRInt32 SupportsArrayImpl::LastIndexOf(const nsISupports* aPossibleElement) const
{
if (0 < mCount) {
const nsISupports** start = (const nsISupports**)mArray; // work around goofy compiler behavior
const nsISupports** ep = (start + mCount);
while (start <= --ep) {
if (aPossibleElement == *ep) {
return (ep - start);
}
}
}
return -1;
}
PRBool SupportsArrayImpl::InsertElementAt(nsISupports* aElement, PRInt32 aIndex)
{
if ((0 <= aIndex) && (aIndex <= mCount)) {
if (mArraySize < (mCount + 1)) { // need to grow the array
mArraySize += kGrowArrayBy;
nsISupports** oldArray = mArray;
mArray = new nsISupports*[mArraySize];
if (0 == mArray) { // ran out of memory
mArray = oldArray;
mArraySize -= kGrowArrayBy;
return PR_FALSE;
}
if (0 != oldArray) { // need to move old data
if (0 < aIndex) {
::memcpy(mArray, oldArray, aIndex * sizeof(nsISupports*));
}
PRInt32 slide = (mCount - aIndex);
if (0 < slide) {
::memcpy(mArray + aIndex + 1, oldArray + aIndex, slide * sizeof(nsISupports*));
}
if (oldArray != &(mAutoArray[0])) {
delete[] oldArray;
}
}
}
else {
PRInt32 slide = (mCount - aIndex);
if (0 < slide) {
::memmove(mArray + aIndex + 1, mArray + aIndex, slide * sizeof(nsISupports*));
}
}
mArray[aIndex] = aElement;
NS_ADDREF(aElement);
mCount++;
return PR_TRUE;
}
return PR_FALSE;
}
PRBool SupportsArrayImpl::ReplaceElementAt(nsISupports* aElement, PRInt32 aIndex)
{
if ((0 <= aIndex) && (aIndex < mCount)) {
NS_ADDREF(aElement); // addref first in case it's the same object!
NS_RELEASE(mArray[aIndex]);
mArray[aIndex] = aElement;
return PR_TRUE;
}
return PR_FALSE;
}
PRBool SupportsArrayImpl::RemoveElementAt(PRInt32 aIndex)
{
if ((0 <= aIndex) && (aIndex < mCount)) {
NS_RELEASE(mArray[aIndex]);
mCount--;
PRInt32 slide = (mCount - aIndex);
if (0 < slide) {
::memmove(mArray + aIndex, mArray + aIndex + 1,
slide * sizeof(nsISupports*));
}
return PR_TRUE;
}
return PR_FALSE;
}
PRBool SupportsArrayImpl::RemoveElement(const nsISupports* aElement, PRInt32 aStartIndex)
{
if ((0 <= aStartIndex) && (aStartIndex < mCount)) {
nsISupports** ep = mArray;
nsISupports** end = ep + mCount;
while (ep < end) {
if (*ep == aElement) {
return RemoveElementAt(PRInt32(ep - mArray));
}
ep++;
}
}
return PR_FALSE;
}
PRBool SupportsArrayImpl::RemoveLastElement(const nsISupports* aElement)
{
if (0 < mCount) {
nsISupports** ep = (mArray + mCount);
while (mArray <= --ep) {
if (*ep == aElement) {
return RemoveElementAt(PRInt32(ep - mArray));
}
}
}
return PR_FALSE;
}
void SupportsArrayImpl::Clear(void)
{
while (0 <= --mCount) {
NS_RELEASE(mArray[mCount]);
}
mCount = 0;
}
void SupportsArrayImpl::Compact(void)
{
if ((mArraySize != mCount) && (kAutoArraySize < mArraySize)) {
nsISupports** oldArray = mArray;
PRInt32 oldArraySize = mArraySize;
if (mCount <= kAutoArraySize) {
mArray = &(mAutoArray[0]);
mArraySize = kAutoArraySize;
}
else {
mArray = new nsISupports*[mCount];
mArraySize = mCount;
}
if (0 == mArray) {
mArray = oldArray;
mArraySize = oldArraySize;
return;
}
::memcpy(mArray, oldArray, mCount * sizeof(nsISupports*));
delete[] oldArray;
}
}
PRBool SupportsArrayImpl::EnumerateForwards(nsISupportsArrayEnumFunc aFunc, void* aData)
{
PRInt32 index = -1;
PRBool running = PR_TRUE;
while (running && (++index < mCount)) {
running = (*aFunc)(mArray[index], aData);
}
return running;
}
PRBool SupportsArrayImpl::EnumerateBackwards(nsISupportsArrayEnumFunc aFunc, void* aData)
{
PRInt32 index = mCount;
PRBool running = PR_TRUE;
while (running && (0 <= --index)) {
running = (*aFunc)(mArray[index], aData);
}
return running;
}
NS_COM nsresult
NS_NewISupportsArray(nsISupportsArray** aInstancePtrResult)
{
if (aInstancePtrResult == 0) {
return NS_ERROR_NULL_POINTER;
}
SupportsArrayImpl *it = new SupportsArrayImpl();
if (0 == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return it->QueryInterface(kISupportsArrayIID, (void **) aInstancePtrResult);
}

View File

@@ -20,17 +20,19 @@ DEPTH=../..
include $(DEPTH)/config/config.mk
CPPSRCS = \
RegFactory.cpp \
TestFactory.cpp \
$(NULL)
INCLUDES=-I../src
INCLUDES=-I../src -I$(DIST)/include
DIRS = dynamic
OBJS = $(CPPSRCS:.cpp=.o)
EX_LIBS = \
$(DIST)/lib/libxpcom.a \
$(DIST)/bin/libreg.so \
$(DIST)/bin/libxpcom.so \
$(DIST)/lib/libplc21.a \
$(DIST)/lib/libplds21.a \
$(DIST)/lib/libnspr21.a \
@@ -45,7 +47,7 @@ include $(DEPTH)/config/rules.mk
$(OBJDIR)/%.o: %.cpp
@$(MAKE_OBJDIR)
$(CCC) -o $@ $(CFLAGS) -c $*.cpp
$(CCC) -o $@ $(CFLAGS) -DUSE_NSREG -c $*.cpp
$(PROGS):$(OBJDIR)/%: $(OBJDIR)/%.o $(EX_LIBS)
@$(MAKE_OBJDIR)
@@ -53,6 +55,6 @@ $(PROGS):$(OBJDIR)/%: $(OBJDIR)/%.o $(EX_LIBS)
export::
instal:: $(TARGETS)
$(INSTALL) NON_DIRS $(DIST)/bin
install:: $(PROGS)
$(INSTALL) $(PROGS) $(DIST)/bin

View File

@@ -23,13 +23,32 @@
static PRBool gUnreg = PR_FALSE;
void print_err(nsresult err)
{
switch (err) {
case NS_ERROR_FACTORY_NOT_LOADED:
cerr << "Factory not loaded";
break;
case NS_NOINTERFACE:
cerr << "No Interface";
break;
case NS_ERROR_NULL_POINTER:
cerr << "Null pointer";
break;
case NS_ERROR_OUT_OF_MEMORY:
cerr << "Out of memory";
break;
default:
cerr << hex << err << dec;
}
}
PRLibrary *GetLib(const char *path) {
return PR_LoadLibrary(path);
}
int Register(const char *path)
nsresult Register(const char *path)
{
int res = NS_OK;
nsresult res = NS_OK;
PRLibrary *instance = GetLib(path);
if (instance != NULL) {
nsRegisterProc proc = (nsRegisterProc) PR_FindSymbol(instance,
@@ -45,9 +64,9 @@ int Register(const char *path)
return res;
}
int Unregister(const char *path)
nsresult Unregister(const char *path)
{
int res = NS_OK;
nsresult res = NS_OK;
PRLibrary *instance = GetLib(path);
if (instance != NULL) {
nsUnregisterProc proc = (nsUnregisterProc) PR_FindSymbol(instance,
@@ -87,14 +106,18 @@ int ProcessArgs(int argc, char *argv[])
if (NS_SUCCEEDED(res)) {
cout << "Successfully unregistered: " << argv[i] << "\n";
} else {
cerr << "Unregister failed (" << res << "): " << argv[i] << "\n";
cerr << "Unregister failed (";
print_err(res);
cerr << "): " << argv[i] << "\n";
}
} else {
res = Register(argv[i]);
if (NS_SUCCEEDED(res)) {
cout << "Successfully registered: " << argv[i] << "\n";
} else {
cerr << "Register failed (" << res << "): " << argv[i] << "\n";
cerr << "Register failed (";
print_err(res);
cerr << "): " << argv[i] << "\n";
}
}
i++;

View File

@@ -0,0 +1,197 @@
/* -*- 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 <stdio.h>
#include <stdlib.h>
#include "nsISupportsArray.h"
// {9e70a320-be02-11d1-8031-006008159b5a}
#define NS_IFOO_IID \
{0x9e70a320, 0xbe02, 0x11d1, \
{0x80, 0x31, 0x00, 0x60, 0x08, 0x15, 0x9b, 0x5a}}
static const PRBool kExitOnError = PR_TRUE;
static NS_DEFINE_IID(kIFooIID, NS_IFOO_IID);
class IFoo : public nsISupports {
public:
IFoo(PRInt32 aID);
~IFoo();
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
PRInt32 mRefCnt;
PRInt32 mID;
static PRInt32 gCount;
};
PRInt32 IFoo::gCount;
IFoo::IFoo(PRInt32 aID)
{
NS_INIT_REFCNT();
mID = aID;
gCount++;
fprintf(stdout, "init: %d (%x), %d total)\n", mID, this, gCount);
}
IFoo::~IFoo()
{
gCount--;
fprintf(stdout, "destruct: %d (%x), %d remain)\n", mID, this, gCount);
}
NS_IMPL_ISUPPORTS(IFoo, NS_IFOO_IID);
const char* AssertEqual(PRInt32 aValue1, PRInt32 aValue2)
{
if (aValue1 == aValue2) {
return "OK";
}
if (kExitOnError) {
exit(1);
}
return "ERROR";
}
void DumpArray(nsISupportsArray* aArray, PRInt32 aExpectedCount, PRInt32 aElementIDs[], PRInt32 aExpectedTotal)
{
PRInt32 count = aArray->Count();
PRInt32 index;
fprintf(stdout, "object count %d = %d %s\n", IFoo::gCount, aExpectedTotal,
AssertEqual(IFoo::gCount, aExpectedTotal));
fprintf(stdout, "array count %d = %d %s\n", count, aExpectedCount,
AssertEqual(count, aExpectedCount));
for (index = 0; (index < count) && (index < aExpectedCount); index++) {
IFoo* foo = (IFoo*)(aArray->ElementAt(index));
fprintf(stdout, "%2d: %d=%d (%x) c: %d %s\n",
index, aElementIDs[index], foo->mID, foo, foo->mRefCnt - 1,
AssertEqual(foo->mID, aElementIDs[index]));
foo->Release();
}
}
void FillArray(nsISupportsArray* aArray, PRInt32 aCount)
{
PRInt32 index;
for (index = 0; index < aCount; index++) {
IFoo* foo = new IFoo(index);
foo->AddRef();
aArray->AppendElement(foo);
foo->Release();
}
}
int main(int argc, char *argv[])
{
nsISupportsArray* array;
nsresult rv;
if (NS_OK == (rv = NS_NewISupportsArray(&array))) {
FillArray(array, 10);
fprintf(stdout, "Array created:\n");
PRInt32 fillResult[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
DumpArray(array, 10, fillResult, 10);
// test insert
IFoo* foo = (IFoo*)array->ElementAt(3);
foo->Release(); // pre-release to fix ref count for dumps
array->InsertElementAt(foo, 5);
fprintf(stdout, "insert 3 at 5:\n");
PRInt32 insertResult[11] = {0, 1, 2, 3, 4, 3, 5, 6, 7, 8, 9};
DumpArray(array, 11, insertResult, 10);
fprintf(stdout, "insert 3 at 0:\n");
array->InsertElementAt(foo, 0);
PRInt32 insertResult2[12] = {3, 0, 1, 2, 3, 4, 3, 5, 6, 7, 8, 9};
DumpArray(array, 12, insertResult2, 10);
fprintf(stdout, "append 3:\n");
array->AppendElement(foo);
PRInt32 appendResult[13] = {3, 0, 1, 2, 3, 4, 3, 5, 6, 7, 8, 9, 3};
DumpArray(array, 13, appendResult, 10);
// test IndexOf && LastIndexOf
PRInt32 expectedIndex[5] = {0, 4, 6, 12, -1};
PRInt32 count = 0;
PRInt32 index = array->IndexOf(foo);
fprintf(stdout, "IndexOf(foo): %d=%d %s\n", index, expectedIndex[count],
AssertEqual(index, expectedIndex[count]));
while (-1 != index) {
count++;
index = array->IndexOf(foo, index + 1);
if (-1 != index)
fprintf(stdout, "IndexOf(foo): %d=%d %s\n", index, expectedIndex[count],
AssertEqual(index, expectedIndex[count]));
}
index = array->LastIndexOf(foo);
count--;
fprintf(stdout, "LastIndexOf(foo): %d=%d %s\n", index, expectedIndex[count],
AssertEqual(index, expectedIndex[count]));
// test ReplaceElementAt
fprintf(stdout, "ReplaceElementAt(8):\n");
array->ReplaceElementAt(foo, 8);
PRInt32 replaceResult[13] = {3, 0, 1, 2, 3, 4, 3, 5, 3, 7, 8, 9, 3};
DumpArray(array, 13, replaceResult, 9);
// test RemoveElementAt, RemoveElement RemoveLastElement
fprintf(stdout, "RemoveElementAt(0):\n");
array->RemoveElementAt(0);
PRInt32 removeResult[12] = {0, 1, 2, 3, 4, 3, 5, 3, 7, 8, 9, 3};
DumpArray(array, 12, removeResult, 9);
fprintf(stdout, "RemoveElementAt(7):\n");
array->RemoveElementAt(7);
PRInt32 removeResult2[11] = {0, 1, 2, 3, 4, 3, 5, 7, 8, 9, 3};
DumpArray(array, 11, removeResult2, 9);
fprintf(stdout, "RemoveElement(foo):\n");
array->RemoveElement(foo);
PRInt32 removeResult3[10] = {0, 1, 2, 4, 3, 5, 7, 8, 9, 3};
DumpArray(array, 10, removeResult3, 9);
fprintf(stdout, "RemoveLastElement(foo):\n");
array->RemoveLastElement(foo);
PRInt32 removeResult4[9] = {0, 1, 2, 4, 3, 5, 7, 8, 9};
DumpArray(array, 9, removeResult4, 9);
// test clear
fprintf(stdout, "clear array:\n");
array->Clear();
DumpArray(array, 0, 0, 0);
fprintf(stdout, "add 4 new:\n");
FillArray(array, 4);
DumpArray(array, 4, fillResult, 4);
// test compact
fprintf(stdout, "compact array:\n");
array->Compact();
DumpArray(array, 4, fillResult, 4);
// test delete
fprintf(stdout, "release array:\n");
NS_RELEASE(array);
}
else {
fprintf(stdout, "error can't create array: %x\n", rv);
}
return 0;
}

View File

@@ -97,7 +97,7 @@ public:
const nsIID &aIID,
void **aResult);
NS_IMETHOD_(void) LockFactory(PRBool aLock) {};
NS_IMETHOD LockFactory(PRBool aLock) { return NS_OK; }
};
NS_IMPL_ISUPPORTS(TestFactory, kFactoryIID);
@@ -134,7 +134,7 @@ extern "C" void RegisterTestFactories() {
PR_FALSE);
// Windows can use persistant registry
#ifndef XP_PC
#ifndef USE_NSREG
NSRepository::RegisterFactory(kTestLoadedFactoryCID,
"libtestdynamic.so",
PR_FALSE,

View File

@@ -0,0 +1,56 @@
/* -*- 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 <stdio.h>
#include "plstr.h"
#include "nsID.h"
static char* ids[] = {
"5C347B10-D55C-11D1-89B7-006008911B81",
"{5C347B10-D55C-11D1-89B7-006008911B81}",
"5c347b10-d55c-11d1-89b7-006008911b81",
"{5c347b10-d55c-11d1-89b7-006008911b81}",
"FC347B10-D55C-F1D1-F9B7-006008911B81",
"{FC347B10-D55C-F1D1-F9B7-006008911B81}",
"fc347b10-d55c-f1d1-f9b7-006008911b81",
"{fc347b10-d55c-f1d1-f9b7-006008911b81}",
};
#define NUM_IDS (sizeof(ids) / sizeof(ids[0]))
int main(int argc, char** argv)
{
nsID id;
for (int i = 0; i < NUM_IDS; i++) {
char* idstr = ids[i];
if (!id.Parse(idstr)) {
fprintf(stderr, "TestID: Parse failed on test #%d\n", i);
return -1;
}
char* cp = id.ToString();
if (NULL == cp) {
fprintf(stderr, "TestID: ToString failed on test #%d\n", i);
return -1;
}
if (0 != PL_strcmp(cp, ids[4*(i/4) + 3])) {
fprintf(stderr, "TestID: compare of ToString failed on test #%d\n", i);
return -1;
}
}
return 0;
}

View File

@@ -27,9 +27,6 @@ NS_DEFINE_IID(kFactoryIID, NS_IFACTORY_IID);
NS_DEFINE_CID(kTestLoadedFactoryCID, NS_TESTLOADEDFACTORY_CID);
NS_DEFINE_IID(kTestClassIID, NS_ITESTCLASS_IID);
static PRInt32 g_InstanceCount = 0;
static PRInt32 g_LockCount = 0;
/**
* ITestClass implementation
*/
@@ -39,13 +36,7 @@ class TestDynamicClassImpl: public ITestClass {
TestDynamicClassImpl() {
NS_INIT_REFCNT();
PR_AtomicIncrement(&g_InstanceCount);
}
~TestDynamicClassImpl() {
PR_AtomicDecrement(&g_InstanceCount);
}
void Test();
};
@@ -59,28 +50,32 @@ void TestDynamicClassImpl::Test() {
* TestFactory implementation
*/
static PRInt32 g_FactoryCount = 0;
static PRInt32 g_LockCount = 0;
class TestDynamicFactory: public nsIFactory {
NS_DECL_ISUPPORTS
TestDynamicFactory() {
NS_INIT_REFCNT();
PR_AtomicIncrement(&g_InstanceCount);
PR_AtomicIncrement(&g_FactoryCount);
}
~TestDynamicFactory() {
PR_AtomicDecrement(&g_InstanceCount);
PR_AtomicDecrement(&g_FactoryCount);
}
NS_IMETHOD CreateInstance(nsISupports *aDelegate,
const nsIID &aIID,
void **aResult);
NS_IMETHOD_(void) LockFactory(PRBool aLock) {
NS_IMETHOD LockFactory(PRBool aLock) {
if (aLock) {
PR_AtomicIncrement(&g_LockCount);
} else {
PR_AtomicDecrement(&g_LockCount);
}
return NS_OK;
};
};
@@ -128,7 +123,7 @@ extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID,
}
extern "C" NS_EXPORT PRBool NSCanUnload() {
return PRBool(g_InstanceCount == 0 && g_LockCount == 0);
return PRBool(g_FactoryCount == 0 && g_LockCount == 0);
}
extern "C" NS_EXPORT nsresult NSRegisterSelf(const char *path)

View File

@@ -24,7 +24,13 @@ DIRS = dynamic windows
MAKE_OBJ_TYPE = EXE
PROG1 = .\$(OBJDIR)\TestFactory.exe
PROG2 = .\$(OBJDIR)\RegFactory.exe
PROGRAMS = $(PROG1) $(PROG2)
PROG3 = .\$(OBJDIR)\TestArray.exe
PROG4 = .\$(OBJDIR)\TestID.exe
PROGRAMS = $(PROG1) $(PROG2) $(PROG3) $(PROG4)
LCFLAGS=-DUSE_NSREG
REQUIRES=libreg
LINCS=-I..\src
@@ -59,4 +65,6 @@ clobber::
$(PROG1): $(OBJDIR) TestFactory.cpp
$(PROG2): $(OBJDIR) RegFactory.cpp
$(PROG3): $(OBJDIR) TestArray.cpp
$(PROG3): $(OBJDIR) TestID.cpp

View File

@@ -16,6 +16,7 @@
* Reserved.
*/
#include <windows.h>
#include <iostream.h>
#include "nsISupports.h"
#include "nsIFactory.h"
@@ -86,10 +87,11 @@ public:
const nsIID &aIID,
void **aResult);
NS_IMETHOD_(void) LockFactory(PRBool aLock) {
NS_IMETHOD LockFactory(PRBool aLock) {
cout << "nsTestComFactory: ";
cout << (aLock == PR_TRUE ? "Locking server" : "Unlocking server");
cout << "\n";
return S_OK;
}
};