Compare commits

..

27 Commits

Author SHA1 Message Date
gagan%netscape.com
3eeb8561a1 Added the memstream file.
git-svn-id: svn://10.0.0.236/branches/NuCache_BRANCH@9000 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-01 19:35:57 +00:00
gagan%netscape.com
280a09abc4 Added streams based changes.
git-svn-id: svn://10.0.0.236/branches/NuCache_BRANCH@8724 18797224-902f-48f8-a5cc-f745e15eee43
1998-08-28 20:24:48 +00:00
gagan%netscape.com
d1401c09ab Test
git-svn-id: svn://10.0.0.236/branches/NuCache_BRANCH@8507 18797224-902f-48f8-a5cc-f745e15eee43
1998-08-26 18:26:31 +00:00
gagan%netscape.com
4a9ef1b8cb Misc. changes
git-svn-id: svn://10.0.0.236/branches/NuCache_BRANCH@8506 18797224-902f-48f8-a5cc-f745e15eee43
1998-08-26 18:25:43 +00:00
gagan%netscape.com
a7537cf1dc Removed unneccessary dependencies on xp stuff.
git-svn-id: svn://10.0.0.236/branches/NuCache_BRANCH@8097 18797224-902f-48f8-a5cc-f745e15eee43
1998-08-17 18:52:40 +00:00
gagan%netscape.com
c54efd75e9 Replaced #include <> with #include "", since Mac doesn't like <>.
git-svn-id: svn://10.0.0.236/branches/NuCache_BRANCH@8096 18797224-902f-48f8-a5cc-f745e15eee43
1998-08-17 18:38:46 +00:00
gagan%netscape.com
5a30b4e55a Added nsMonitorable class to do the basic functionality of Enter/Exit Monitors. Made corresponding changes in nsCacheManager, nsCacheModule, nsDiskModule, and nsMemModule.
git-svn-id: svn://10.0.0.236/branches/NuCache_BRANCH@8079 18797224-902f-48f8-a5cc-f745e15eee43
1998-08-15 20:45:50 +00:00
gagan%netscape.com
3b59088a0b Added missing files.
git-svn-id: svn://10.0.0.236/branches/NuCache_BRANCH@8077 18797224-902f-48f8-a5cc-f745e15eee43
1998-08-15 18:19:37 +00:00
(no author)
bf5c968c5a This commit was manufactured by cvs2svn to create branch 'NuCache_BRANCH'.
git-svn-id: svn://10.0.0.236/branches/NuCache_BRANCH@8052 18797224-902f-48f8-a5cc-f745e15eee43
1998-08-14 23:48:06 +00:00
gagan%netscape.com
18216e82d4 Replaced cache_object instead of memory_copy.
git-svn-id: svn://10.0.0.236/branches/NuCache_BRANCH@7926 18797224-902f-48f8-a5cc-f745e15eee43
1998-08-13 08:09:39 +00:00
gagan%netscape.com
9cd35b92eb Added PR_ASSERT(0) for stuff that shouldn't be getting called.
git-svn-id: svn://10.0.0.236/branches/NuCache_BRANCH@7925 18797224-902f-48f8-a5cc-f745e15eee43
1998-08-13 08:08:31 +00:00
gagan%netscape.com
e22a85b2a0 Post Data, Page Services URLs added.
git-svn-id: svn://10.0.0.236/branches/NuCache_BRANCH@7899 18797224-902f-48f8-a5cc-f745e15eee43
1998-08-13 04:17:41 +00:00
gagan%netscape.com
48053e6550 Added nucacheproto.c for NU_CACHE.
git-svn-id: svn://10.0.0.236/branches/NuCache_BRANCH@7876 18797224-902f-48f8-a5cc-f745e15eee43
1998-08-12 21:35:43 +00:00
gagan%netscape.com
d125038cb3 Writes ok now.
git-svn-id: svn://10.0.0.236/branches/NuCache_BRANCH@7738 18797224-902f-48f8-a5cc-f745e15eee43
1998-08-11 09:25:54 +00:00
gagan%netscape.com
acf204eec6 misc. changes and reverting back to just the basics...
git-svn-id: svn://10.0.0.236/branches/NuCache_BRANCH@7735 18797224-902f-48f8-a5cc-f745e15eee43
1998-08-11 06:27:25 +00:00
gagan%netscape.com
a0197ad679 Added mozilla\network\cache\nu to build.
git-svn-id: svn://10.0.0.236/branches/NuCache_BRANCH@7700 18797224-902f-48f8-a5cc-f745e15eee43
1998-08-10 22:41:00 +00:00
gagan%netscape.com
2022f54469 Added these missing files.
git-svn-id: svn://10.0.0.236/branches/NuCache_BRANCH@7536 18797224-902f-48f8-a5cc-f745e15eee43
1998-08-07 05:24:16 +00:00
gagan%netscape.com
60e4ff2b8f Content length and type + misc.
git-svn-id: svn://10.0.0.236/branches/NuCache_BRANCH@7535 18797224-902f-48f8-a5cc-f745e15eee43
1998-08-07 05:23:11 +00:00
gagan%netscape.com
9655d5b93d update
git-svn-id: svn://10.0.0.236/branches/NuCache_BRANCH@6850 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-30 05:35:41 +00:00
gagan%netscape.com
993ba757db aaaahpdate.
git-svn-id: svn://10.0.0.236/branches/NuCache_BRANCH@6849 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-30 05:35:05 +00:00
gagan%netscape.com
f30b2b6d08 Todo list
git-svn-id: svn://10.0.0.236/branches/NuCache_BRANCH@6382 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-24 06:02:59 +00:00
gagan%netscape.com
248e293e2a update
git-svn-id: svn://10.0.0.236/branches/NuCache_BRANCH@6142 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-22 03:33:07 +00:00
gagan%netscape.com
cce44aa1b0 temp checkin
git-svn-id: svn://10.0.0.236/branches/NuCache_BRANCH@6052 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-21 03:27:44 +00:00
gagan%netscape.com
d8c5fa6511 Define NU_CACHE if env is available.
git-svn-id: svn://10.0.0.236/branches/NuCache_BRANCH@6045 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-21 02:37:54 +00:00
gagan%netscape.com
3a14fa3dda Updates for Cachestubs.
git-svn-id: svn://10.0.0.236/branches/NuCache_BRANCH@6033 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-21 01:03:51 +00:00
gagan%netscape.com
f4d254645c Added cachelib for NuCache.
git-svn-id: svn://10.0.0.236/branches/NuCache_BRANCH@6031 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-21 00:54:39 +00:00
(no author)
4bce2b926e This commit was manufactured by cvs2svn to create branch 'NuCache_BRANCH'.
git-svn-id: svn://10.0.0.236/branches/NuCache_BRANCH@5718 18797224-902f-48f8-a5cc-f745e15eee43
1998-07-16 18:22:24 +00:00
633 changed files with 127921 additions and 100623 deletions

File diff suppressed because it is too large Load Diff

408
mozilla/config/config.mak Normal file
View File

@@ -0,0 +1,408 @@
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
!if !defined(CONFIG_CONFIG_MAK)
CONFIG_CONFIG_MAK=1
#//------------------------------------------------------------------------
#//
#// Define public make variables:
#//
#// OBJDIR - Specifies the location of intermediate files (ie. objs...)
#// Currently, the names are WINxx_O.OBJ or WINxx_D.OBJ for
#// optimized and debug builds respectively.
#//
#// DIST - Specifies the location of the distribution directory where
#// all targets are delivered.
#//
#// CFGFILE - Specifies the name of the temporary configuration file
#// containing the arguments to the current command.
#//
#// INCS - Default include paths.
#//
#// CFLAGS - Default compiler options.
#//
#// LFLAGS - Default linker options.
#//
#//------------------------------------------------------------------------
!if [$(MOZ_TOOLS)\bin\uname > osuname.inc]
!endif
WINOS=\
!include "osuname.inc"
WINOS=$(WINOS: =)^
!if [del osuname.inc]
!endif
## Include support for MOZ_LITE/MOZ_MEDIUM
include <$(DEPTH)/config/liteness.mak>
!if "$(MOZ_BITS)" == "16"
!if "$(MAKE_OBJ_TYPE)" == "DLL"
OBJTYPE=D
!else
OBJTYPE=E
!endif
!else
OBJTYPE=
!endif
XPDIST=$(DEPTH)\dist
PUBLIC=$(XPDIST)\public
#//-----------------------------------------------------------------------
#// OBJDIR is NOT the same as DIST for Win16. The Win16 dist stuff can
#// be built with EXE or DLL compiler flags, but the DIST directory
#// has the same name no matter what
#//-----------------------------------------------------------------------
!ifdef NGLAYOUT_BUILD_PREFIX
DIST_PREFIX=NGL
!else
!ifdef MOZ_NAV_BUILD_PREFIX
DIST_PREFIX=NAV
!else
DIST_PREFIX=WIN
!endif
!endif
!ifndef MOZ_DEBUG
OBJDIR=$(DIST_PREFIX)$(MOZ_BITS)$(OBJTYPE)_O.OBJ
JAVA_OPTIMIZER = -O
!ifdef NO_CAFE
JAVAC_OPTIMIZER =
!else
#JAVAC_OPTIMIZER= -O -noinline
JAVAC_OPTIMIZER =
!endif
!else
OBJDIR=$(DIST_PREFIX)$(MOZ_BITS)$(OBJTYPE)_D.OBJ
JAVA_OPTIMIZER = -g
JAVAC_OPTIMIZER = -g
!endif
#//
#// DIST DEFINES SHOULD NEVER BE COMPONENT SPECIFIC.
#//
!ifndef MOZ_DEBUG
DIST=$(XPDIST)\$(DIST_PREFIX)$(MOZ_BITS)_O.OBJ
!else
DIST=$(XPDIST)\$(DIST_PREFIX)$(MOZ_BITS)_D.OBJ
!endif
# This will always give the location of NGLayout's dist, even if "NGLAYOUT_BUILD_PREFIX" is not defined.
!if defined(MOZ_NGLAYOUT)
!ifndef MOZ_DEBUG
NGLAYOUT_DIST=$(XPDIST)\NGL$(MOZ_BITS)_O.OBJ
!else
NGLAYOUT_DIST=$(XPDIST)\NGL$(MOZ_BITS)_D.OBJ
!endif
!endif
CFGFILE=$(OBJDIR)\cmd.cfg
!if "$(MOZ_BITS)" == "16"
INCS=-I$(XPDIST)\public\win16 $(INCS) -I$(DEPTH)\include -I$(DIST)\include -I..\include
!else
INCS=$(INCS) -I$(DEPTH)\include -I$(DIST)\include \
-I$(XPDIST)\public\img -I$(XPDIST)\public\util \
-I$(XPDIST)\public\coreincl
!endif # 16
!ifndef NO_LAYERS
INCS=$(INCS) -I$(DEPTH)\lib\liblayer\include
!endif
!if "$(STAND_ALONE_JAVA)" == "1"
LCFLAGS=$(LCFLAGS) -DSTAND_ALONE_JAVA
!endif
!if defined(MOZ_JAVA)
MOZ_JAVA_FLAG=-DJAVA
!if defined(MOZ_OJI)
!error You can't define both MOZ_JAVA and MOZ_OJI anymore.
!endif
JAVA_OR_OJI=1
!endif
!if defined(MOZ_OJI)
LCFLAGS=$(LCFLAGS) -DOJI
JAVA_OR_OJI=1
!endif
# Perhaps we should add MOZ_LITENESS_FLAGS to 16 bit build
!if "$(MOZ_BITS)" == "16"
CFLAGS=$(MOZ_JAVA_FLAG) -DMOCHA -DLAYERS -DEDITOR $(OS_CFLAGS) $(MOZ_CFLAGS)
!else
CFLAGS=$(MOZ_JAVA_FLAG) -DMOCHA -DLAYERS $(OS_CFLAGS) $(MOZ_CFLAGS) $(MOZ_LITENESS_FLAGS)
!endif
LFLAGS=$(OS_LFLAGS) $(LLFLAGS) $(MOZ_LFLAGS)
!ifdef NO_SECURITY
CFLAGS = $(CFLAGS) -DNO_SECURITY
!endif
# This compiles in heap dumping utilities and other good stuff
# for developers -- maybe we only want it in for a special SDK
# nspr/java runtime(?):
!if "$(MOZ_BITS)"=="32" || defined(MOZ_DEBUG)
CFLAGS = $(CFLAGS) -DDEVELOPER_DEBUG
!endif
!ifdef STANDALONE_IMAGE_LIB
CFLAGS=$(CFLAGS) -DSTANDALONE_IMAGE_LIB
!endif
!ifdef MODULAR_NETLIB
CFLAGS=$(CFLAGS) -DMODULAR_NETLIB
!else
# Defines for new cookie management...
CFLAGS=$(CFLAGS) -DCookieManagement -DSingleSignon
!endif
# TODO Remove later - Gagan
!ifdef NU_CACHE
CFLAGS=$(CFLAGS) -DNU_CACHE
!endif
# always need these:
CFLAGS = $(CFLAGS) -DNETSCAPE
# Specify that we are building a client.
# This will instruct the cross platform libraries to
# include all the client specific cruft.
!if defined(SERVER_BUILD)
CFLAGS = $(CFLAGS) -DSERVER_BUILD
!elseif defined(LIVEWIRE)
CFLAGS = $(CFLAGS) -DLIVEWIRE
!else
CFLAGS = $(CFLAGS) -DMOZILLA_CLIENT
!endif
PERL= $(MOZ_TOOLS)\perl5\perl.exe
MASM = $(MOZ_TOOLS)\bin\ml.exe
!if "$(WINOS)" == "WIN95"
MKDIR = $(DEPTH)\config\w95mkdir
QUIET =
!else
MKDIR = mkdir
QUIET=@
!endif
#//------------------------------------------------------------------------
#//
#// Include the OS dependent configuration information
#//
#//------------------------------------------------------------------------
include <$(DEPTH)/config/WIN$(MOZ_BITS)>
!ifdef MOZ_DEBUG
!ifdef USERNAME
CFLAGS = $(CFLAGS) -DDEBUG_$(USERNAME)
!endif
!if defined(GLOWCODE) && defined(GLOWPROF) && "$(MOZ_BITS)"=="32"
CFLAGS = $(CFLAGS) -Gh
!endif
!endif
#//------------------------------------------------------------------------
#//
#// Define the global make commands.
#//
#// MAKE_INSTALL - Copy a target to the distribution directory.
#//
#// MAKE_OBJDIRS - Create an object directory (if necessary).
#//
#// MAKE_MANGLE - Convert all long filenames into 8.3 names
#//
#// MAKE_UNMANGLE - Restore all long filenames
#//
#//------------------------------------------------------------------------
!if !defined(MOZ_SRC)
#enable builds on any drive if defined.
MOZ_SRC=y:
!endif
MAKE_INSTALL=$(QUIET)$(DEPTH)\config\makecopy.exe
MAKE_MANGLE=$(DEPTH)\config\mangle.exe
MAKE_UNMANGLE=if exist unmangle.bat call unmangle.bat
#//------------------------------------------------------------------------
#//
#// Common Libraries
#//
#//------------------------------------------------------------------------
!ifdef NSPR20
!if "$(MOZ_BITS)" == "16"
LIBNSPR=$(DIST)\lib\nspr21.lib
LIBNSPR=$(LIBNSPR) $(DIST)\lib\plds21.lib
LIBNSPR=$(LIBNSPR) $(DIST)\lib\msgc21.lib
!else
LIBNSPR=$(DIST)\lib\libnspr21.lib
LIBNSPR=$(LIBNSPR) $(DIST)\lib\libplds21.lib
LIBNSPR=$(LIBNSPR) $(DIST)\lib\libmsgc21.lib
!endif
!else
LIBNSPR=$(DIST)\lib\pr$(MOZ_BITS)$(VERSION_NUMBER).lib
!endif
!ifdef NSPR20
NSPRDIR = nsprpub
CFLAGS = $(CFLAGS) -DNSPR20
!else
NSPRDIR = nspr
!endif
LIBJPEG=$(DIST)\lib\jpeg$(MOZ_BITS)$(VERSION_NUMBER).lib
######################################################################
### Windows-Specific Java Stuff
PATH_SEPARATOR = ;
# where the bytecode will go
!if "$(AWT_11)" == "1"
JAVA_DESTPATH = $(DEPTH)\dist\classes11
!else
JAVA_DESTPATH = $(DEPTH)\dist\classes
!endif
# where the source are
DEFAULT_JAVA_SOURCEPATH = $(DEPTH)\sun-java\classsrc
!ifndef JAVA_SOURCEPATH
!if "$(AWT_11)" == "1"
JAVA_SOURCEPATH = $(DEPTH)\sun-java\classsrc11;$(DEFAULT_JAVA_SOURCEPATH)
!else
JAVA_SOURCEPATH = $(DEFAULT_JAVA_SOURCEPATH)
!endif
!endif
JAVA_PROG=$(MOZ_TOOLS)\bin\java.exe
#JAVA_PROG=$(DIST)\bin\java
JAVAC_ZIP=$(MOZ_TOOLS)/lib/javac.zip
ZIP_PROG = $(MOZ_TOOLS)\bin\zip
UNZIP_PROG = $(MOZ_TOOLS)\bin\unzip
ZIP_FLAGS = -0 -r -q
CFLAGS = $(CFLAGS) -DOS_HAS_DLL
DLL_SUFFIX = dll
LIB_SUFFIX = lib
!if "$(STAND_ALONE_JAVA)" == "1"
STAND_ALONE_JAVA_DLL_SUFFIX=s
!else
STAND_ALONE_JAVA_DLL_SUFFIX=
!endif
MOD_JRT=jrt$(MOZ_BITS)$(VERSION_NUMBER)
MOD_MM =mm$(MOZ_BITS)$(VERSION_NUMBER)
MOD_AWT=awt$(MOZ_BITS)$(VERSION_NUMBER)
MOD_AWTS=awt$(MOZ_BITS)$(VERSION_NUMBER)$(STAND_ALONE_JAVA_DLL_SUFFIX)
MOD_JIT=jit$(MOZ_BITS)$(VERSION_NUMBER)
MOD_JSJ=jsj$(MOZ_BITS)$(VERSION_NUMBER)
MOD_NET=net$(MOZ_BITS)$(VERSION_NUMBER)
MOD_JBN=jbn$(MOZ_BITS)$(VERSION_NUMBER)
MOD_NSC=nsc$(MOZ_BITS)$(VERSION_NUMBER)
MOD_JPW=jpw$(MOZ_BITS)$(VERSION_NUMBER)
MOD_JDB=jdb$(MOZ_BITS)$(VERSION_NUMBER)
MOD_ZIP=zip$(MOZ_BITS)$(VERSION_NUMBER)
MOD_ZPW=zpw$(MOZ_BITS)$(VERSION_NUMBER)
MOD_CON=con$(MOZ_BITS)$(VERSION_NUMBER)
MOD_NPJ=npj$(MOZ_BITS)$(VERSION_NUMBER)
JRTDLL=$(MOD_JRT).$(DLL_SUFFIX)
MMDLL =$(MOD_MM).$(DLL_SUFFIX)
AWTDLL=$(MOD_AWT).$(DLL_SUFFIX)
AWTSDLL=$(MOD_AWT)$(STAND_ALONE_JAVA_DLL_SUFFIX).$(DLL_SUFFIX)
JITDLL=$(MOD_JIT).$(DLL_SUFFIX)
JSJDLL=$(MOD_JSJ).$(DLL_SUFFIX)
NETDLL=$(MOD_NET).$(DLL_SUFFIX)
JBNDLL=$(MOD_JBN).$(DLL_SUFFIX)
NSCDLL=$(MOD_NSC).$(DLL_SUFFIX)
JPWDLL=$(MOD_JPW).$(DLL_SUFFIX)
JDBDLL=$(MOD_JDB).$(DLL_SUFFIX)
ZIPDLL=$(MOD_ZIP).$(DLL_SUFFIX)
ZPWDLL=$(MOD_ZPW).$(DLL_SUFFIX)
CONDLL=$(MOD_CON).$(DLL_SUFFIX)
NPJDLL=$(MOD_NPJ).$(DLL_SUFFIX)
ZIPLIB=$(DIST)\lib\$(MOD_ZIP).$(LIB_SUFFIX)
AWTLIB=$(DIST)\lib\$(MOD_AWT).$(LIB_SUFFIX)
######################################################################
include <$(DEPTH)/config/common.mk>
JAVA_DEFINES = \
-DJAR_NAME=\"$(JAR_NAME)\" \
-DJRTDLL=\"$(JRTDLL)\" \
-DMMDLL=\"$(MMDLL)\" \
-DAWTDLL=\"$(AWTDLL)\" \
-DAWTSDLL=\"$(AWTSDLL)\" \
-DJSJDLL=\"$(JSJDLL)\" \
-DJITDLL=\"$(JITDLL)\" \
-DNETDLL=\"$(NETDLL)\" \
-DJBNDLL=\"$(JBNDLL)\" \
-DNSCDLL=\"$(NSCDLL)\" \
-DJDBDLL=\"$(JDBDLL)\" \
-DJPWDLL=\"$(JPWDLL)\" \
-DZPWDLL=\"$(ZPWDLL)\" \
-DCONDLL=\"$(CONDLL)\"
!if "$(MOZ_BITS)" == "16"
# Override JAVA_DEFINES to make command line short for win16.
# Put any new defines into javadefs.h in ns/sun-java/include.
# This is to shorten the command line in order not to break Win16.
JAVA_DEFINES = -DJAR_NAME=\"$(JAR_NAME)\" -DMOZ_BITS=\"$(MOZ_BITS)\" -DVERSION_NUMBER=\"$(VERSION_NUMBER)\" -DDLL_SUFFIX=\".$(DLL_SUFFIX)\"
!endif
!if "$(AWT_11)" == "1"
JAVA_DEFINES = $(JAVA_DEFINES) -DAWT_11
!else
JAVA_DEFINES = $(JAVA_DEFINES) -DAWT_102
!endif
#JAVA_CLASSPATH = $(JAVA_CLASSPATH:/=\)
JMCSRCDIR = $(JMCSRCDIR:/=\)
JAVA_BOOT_CLASSPATH = $(JAVA_BOOT_CLASSPATH:/=\)
NMAKE=nmake -nologo -$(MAKEFLAGS)
########
# Get the cwd to prepend to all compiled source
# files. Will allow debugger to automatically find sources
# instead of asking for the path info.
# Win16 will break if enabled, guess we continue to live in pain
# therein.
########
!if "$(MOZ_BITS)" == "32"
CURDIR=$(MAKEDIR)^\
!endif
!endif # CONFIG_CONFIG_MAK

632
mozilla/config/config.mk Normal file
View File

@@ -0,0 +1,632 @@
#
# 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.
#
#
# config.mk
#
# Determines the platform and builds the macros needed to load the
# appropriate platform-specific .mk file, then defines all (most?)
# of the generic macros.
#
# This wastes time.
include $(DEPTH)/config/common.mk
#
# Important internal static macros
#
OS_ARCH := $(subst /,_,$(shell uname -s))
OS_RELEASE := $(shell uname -r)
OS_TEST := $(shell uname -m)
#
# Tweak the default OS_ARCH and OS_RELEASE macros as needed.
#
ifeq ($(OS_ARCH),AIX)
OS_RELEASE := $(shell uname -v).$(shell uname -r)
endif
ifeq ($(OS_ARCH),BSD_386)
OS_ARCH := BSD_OS
endif
ifeq ($(OS_ARCH),IRIX64)
OS_ARCH := IRIX
endif
ifeq ($(OS_ARCH),UNIX_SV)
ifneq ($(findstring NCR,$(shell grep NCR /etc/bcheckrc | head -1 )),)
OS_ARCH := NCR
else
OS_ARCH := UNIXWARE
OS_RELEASE := $(shell uname -v)
endif
endif
ifeq ($(OS_ARCH),ncr)
OS_ARCH := NCR
endif
# This is the only way to correctly determine the actual OS version on NCR boxes.
ifeq ($(OS_ARCH),NCR)
OS_RELEASE := $(shell awk '{print $$3}' /etc/.relid | sed 's/^\([0-9]\)\(.\)\(..\)\(.*\)$$/\2.\3/')
endif
ifeq ($(OS_ARCH),UNIX_System_V)
OS_ARCH := NEC
endif
ifeq ($(OS_ARCH),QNX)
OS_RELEASE := $(shell uname -v | sed 's/^\([0-9]\)\([0-9]*\)$$/\1.\2/')
endif
ifeq ($(OS_ARCH),SCO_SV)
OS_ARCH := SCOOS
OS_RELEASE := 5.0
endif
ifneq (,$(filter SINIX-N SINIX-Y SINIX-Z ReliantUNIX-M,$(OS_ARCH)))
OS_ARCH := SINIX
OS_TEST := $(shell uname -p)
endif
ifeq ($(OS_ARCH),UnixWare)
OS_ARCH := UNIXWARE
endif
#
# Strip off the excessively long version numbers on these platforms,
# but save the version to allow multiple versions of the same base
# platform to be built in the same tree.
#
ifneq (,$(filter FreeBSD HP-UX IRIX Linux NetBSD OSF1 SunOS,$(OS_ARCH)))
OS_VERS := $(suffix $(OS_RELEASE))
OS_RELEASE := $(basename $(OS_RELEASE))
OS_VERSION := $(shell echo $(OS_VERS) | sed 's/-.*//')
endif
OS_CONFIG := $(OS_ARCH)$(OS_RELEASE)
#
# Personal makefile customizations go in these optional make include files.
#
MY_CONFIG := $(DEPTH)/config/myconfig.mk
MY_RULES := $(DEPTH)/config/myrules.mk
#
# Relative pathname from top-of-tree to current source directory
#
ifneq (,$(filter-out OS2 WINNT,$(OS_ARCH)))
REVDEPTH := $(DEPTH)/config/revdepth
SRCDIR = $(shell $(PERL) $(REVDEPTH).pl $(DEPTH))
endif
#
# Define an include-at-most-once flag
#
NS_CONFIG_MK = 1
#
# Provide the means to easily override our tool directory locations.
#
ifdef NETSCAPE_HIERARCHY
NETSCAPE_BUILD = 1 # Defines XFEPRIVDIR, below.
CONTRIB_BIN := /tools/contrib/bin/
JAVA_BIN := /usr/local/java/bin/
LOCAL_BIN := /usr/local/bin/
LOCAL_SUN4 := /usr/local/sun4/bin/
NS_BIN := /tools/ns/bin/
NS_LIB := /tools/ns/lib
JAVA_LIB := /usr/local/netscape/java/lib
else
NS_LIB := .
JAVA_LIB := .
endif
# Allow NETSCAPE_BUILD to include XFEPRIVDIR w/o NETSCAPE_HIERARCHY
ifdef NETSCAPE_BUILD
XFEPRIVDIR := $(DEPTH)/../ns/cmd/xfe/
endif
#
# Default command macros; can be overridden in <arch>.mk.
#
AS = $(CC)
ASFLAGS = $(CFLAGS)
BSDECHO = echo
CC = gcc
CCC = g++
CCF = $(CC) $(CFLAGS)
LINK_EXE = $(LINK) $(OS_LFLAGS) $(LFLAGS)
LINK_DLL = $(LINK) $(OS_DLLFLAGS) $(DLLFLAGS)
NFSPWD = $(DEPTH)/config/nfspwd
PURIFY = purify $(PURIFYOPTIONS)
QUANTIFY = quantify $(QUANTIFYOPTIONS)
RANLIB = /bin/true
SDKINSTALL = $(NSINSTALL) -t
UNZIP_PROG = $(LOCAL_BIN)/unzip
ZIP_PROG = $(LOCAL_BIN)/zip
ZIP_FLAGS = -0rq
ifeq ($(OS_ARCH),OS2)
EMPTY :=
SLASH := /$(EMPTY)
BSLASH := \$(EMPTY)
SEMICOLON := ;$(EMPTY)
SPACE := $(EMPTY) $(EMPTY)
PATH_SEPARATOR := \;
RC = flipper rc$(BIN_SUFFIX)
XP_DEFINE = -DXP_PC
LIB_SUFFIX = lib
DLL_SUFFIX = dll
MAP_SUFFIX = map
BIN_SUFFIX = .exe
AR = flipper ILibo //noignorecase //nologo $@
IMPLIB = flipper ILibo //noignorecase //nologo $@
DLLFLAGS = -DLL -OUT:$@ $(XLFLAGS) -MAP:$(@:.dll=.map)
LFLAGS = $(OBJS) -OUT:$@ $(XLFLAGS) $(DEPLIBS) $(EXTRA_LIBS) -MAP:$(@:.dll=.map) $(DEF_FILE)
NSINSTALL = nsinstall
INSTALL = $(NSINSTALL)
JAVA_PROG = flipper java -norestart
JAVAC_ZIP = $(subst $(BSLASH),$(SLASH),$(JAVA_HOME))/lib/classes.zip
else
ifeq ($(OS_ARCH),WINNT)
PATH_SEPARATOR := :
RC = rc$(BIN_SUFFIX)
XP_DEFINE = -DXP_PC
LIB_SUFFIX = lib
DLL_SUFFIX = dll
BIN_SUFFIX = .exe
AR = lib -NOLOGO -OUT:"$@"
DLLFLAGS = $(XLFLAGS) -OUT:"$@"
LFLAGS = $(OBJS) $(DEPLIBS) $(EXTRA_LIBS) -OUT:"$@"
NSINSTALL = nsinstall
INSTALL = $(NSINSTALL)
JAVA_PROG = java
else
PATH_SEPARATOR := :
XP_DEFINE = -DXP_UNIX
AR = ar cr $@
DLL_SUFFIX = so
LIB_SUFFIX = a
ifeq ($(AWT_11),1)
JAVA_PROG = $(NS_BIN)java
JAVAC_ZIP = $(NS_LIB)/classes.zip
else
JAVA_PROG = $(LOCAL_BIN)java
JAVAC_ZIP = $(JAVA_LIB)/javac.zip
endif
PERL = $(NS_BIN)perl
TAR = tar
EMACS = xemacs
WHOAMI = /usr/bin/whoami
endif
endif
#
# Debug by default.
#
OBJDIR_TAG = _DBG
OPTIMIZER = -g
JAVA_OPTIMIZER = -g
XBCFLAGS = -FR$*
XCFLAGS = $(LCFLAGS)
XLFLAGS = $(LLFLAGS)
ifeq ($(OS_ARCH),OS2)
OPTIMIZER = -Ti+
XLFLAGS += -DEBUG
ifdef BUILD_PROFILE
OPTIMIZER += -Gh+
OBJDIR_TAG = _PRF
else
OPTIMIZER += -DDEBUG
ifdef BUILD_MEMDBG
OPTIMIZER += -Tm+ -DXP_OS2_MEMDEBUG=1
OBJDIR_TAG = _MEM
endif
endif
else
ifeq ($(OS_ARCH),WINNT)
OPTIMIZER = -Od -Z7
JAVA_OPTIMIZER = $(OPTIMIZER)
XLFLAGS += -DEBUG
else
DEFINES = -DDEBUG -UNDEBUG -DDEBUG_$(shell $(WHOAMI)) -DTRACING
endif
endif
ifdef BUILD_OPT
OBJDIR_TAG = _OPT
XBCFLAGS =
ifeq ($(OS_ARCH),OS2)
OPTIMIZER = -O+ -Oi -DNDEBUG
else
ifeq ($(OS_ARCH),WINNT)
OPTIMIZER = -O2
else
OPTIMIZER = -O
DEFINES = -UDEBUG -DNDEBUG -DTRIMMED
endif
endif
endif
#
# XXX For now, we're including $(DEPTH)/include directly instead of
# getting this stuff from dist. This stuff is old and will eventually
# be put in the library directories where it belongs so that it can
# get exported to dist properly.
#
INCLUDES = $(LOCAL_PREINCLUDES) $(MODULE_PREINCLUDES) -I$(DEPTH)/include $(LOCAL_INCLUDES) $(OS_INCLUDES)
LIBNT = $(DIST)/lib/libnt.$(LIB_SUFFIX)
LIBAWT = $(DIST)/lib/libawt.$(LIB_SUFFIX)
LIBMMEDIA = $(DIST)/lib/libmmedia.$(LIB_SUFFIX)
#
# NSPR 2.0 is now the default, "setenv NSPR10 1" to go back to 1.0
#
ifndef NSPR10
NSPR20 = 1
NSPRDIR = nsprpub
DEFINES += -DNSPR20
INCLUDES += -I$(DIST)/include
LIBNSPR = $(DIST)/lib/libplds21.$(LIB_SUFFIX) \
$(DIST)/lib/libmsgc21.$(LIB_SUFFIX) \
$(DIST)/lib/libnspr21.$(LIB_SUFFIX)
PURELIBNSPR = $(DIST)/lib/purelibplds21.$(LIB_SUFFIX) \
$(DIST)/lib/purelibmsgc21.$(LIB_SUFFIX) \
$(DIST)/lib/purelibnspr21.$(LIB_SUFFIX)
else
NSPRDIR = nspr
LIBNSPR = $(DIST)/lib/libnspr.$(LIB_SUFFIX)
PURELIBNSPR = $(DIST)/lib/libpurenspr.$(LIB_SUFFIX)
endif
ifdef DBMALLOC
LIBNSPR += $(DIST)/lib/libdbmalloc.$(LIB_SUFFIX)
endif
ifeq ($(OS_ARCH),OS2)
LIBNSJAVA = $(DIST)/lib/jrt$(MOZ_BITS)$(VERSION_NUMBER).$(LIB_SUFFIX)
LIBMD = $(DIST)/lib/libjmd.$(LIB_SUFFIX)
LIBJAVA = $(DIST)/lib/libjrt.$(LIB_SUFFIX)
LIBNSPR = $(DIST)/lib/pr$(MOZ_BITS)$(VERSION_NUMBER).$(LIB_SUFFIX)
LIBXP = $(DIST)/lib/libxp.$(LIB_SUFFIX)
else
ifeq ($(OS_ARCH),WINNT)
LIBNSJAVA = $(DIST)/lib/jrt3221.$(LIB_SUFFIX)
else
LIBNSJAVA = $(DIST)/lib/nsjava32.$(LIB_SUFFIX)
endif
endif
CFLAGS = $(XP_DEFINE) $(OPTIMIZER) $(OS_CFLAGS) $(MDUPDATE_FLAGS) $(DEFINES) $(INCLUDES) $(XCFLAGS) $(PROF_FLAGS)
NOMD_CFLAGS = $(XP_DEFINE) $(OPTIMIZER) $(OS_CFLAGS) $(DEFINES) $(INCLUDES) $(XCFLAGS)
#
# Include the binary distrib stuff, if necessary.
#
ifdef NS_BUILD_CORE
include $(DEPTH)/config/coreconf.mk
endif
#
# Now include the platform-specific stuff.
#
include $(DEPTH)/config/$(OS_ARCH).mk
#
# Some platforms (Solaris) might require builds using either
# (or both) compiler(s).
#
ifdef SHOW_CC_TYPE
COMPILER = _$(notdir $(CC))
endif
#
# Name of the binary code directories
#
ifeq ($(OS_ARCH)_$(PROCESSOR_ARCHITECTURE),WINNT_x86)
OBJDIR_NAME = $(OS_CONFIG)$(OS_VERSION)$(OBJDIR_TAG).OBJ
else
OBJDIR_NAME = $(OS_CONFIG)$(OS_VERSION)$(PROCESSOR_ARCHITECTURE)$(COMPILER)$(IMPL_STRATEGY)$(OBJDIR_TAG).OBJ
endif
# Figure out where the binary code lives. It either lives in the src
# tree (NSBUILDROOT is undefined) or somewhere else.
ifdef NSBUILDROOT
BUILD = $(NSBUILDROOT)/$(OBJDIR_NAME)/build
OBJDIR = $(BUILD)/$(SRCDIR)
XPDIST = $(NSBUILDROOT)
DIST = $(NSBUILDROOT)/$(OBJDIR_NAME)/dist
else
BUILD = $(OBJDIR_NAME)
OBJDIR = $(OBJDIR_NAME)
XPDIST = $(DEPTH)/dist
DIST = $(DEPTH)/dist/$(OBJDIR_NAME)
endif
# all public include files go in subdirectories of PUBLIC:
PUBLIC = $(XPDIST)/public
VPATH = $(OBJDIR)
DEPENDENCIES = $(OBJDIR)/.md
ifneq ($(OS_ARCH),WINNT)
MKDEPEND_DIR = $(DEPTH)/config/mkdepend
MKDEPEND = $(MKDEPEND_DIR)/$(OBJDIR_NAME)/mkdepend
MKDEPENDENCIES = $(OBJDIR)/depend.mk
endif
#
# Include any personal overrides the user might think are needed.
#
-include $(MY_CONFIG)
######################################################################
# Now test variables that might have been set or overridden by $(MY_CONFIG).
DEFINES += -DNETSCAPE -DOSTYPE=\"$(OS_CONFIG)\"
# Specify that we are building a client.
# This will instruct the cross platform libraries to
# include all the client specific cruft.
ifdef SERVER_BUILD
DEFINES += -DSERVER_BUILD
ifdef LIVEWIRE
DEFINES += -DLIVEWIRE
endif
STATIC_JAVA = yes
else
MOZILLA_CLIENT = 1
DEFINES += -DMOZILLA_CLIENT
endif
ifdef MOZ_SINGLESIGNON
DEFINES += -DSingleSignon
endif
ifdef MOZ_COOKIEMANAGE
DEFINES += -DCookieManagement
endif
ifdef MOZ_LITE
NO_EDITOR = 1
NO_UNIX_LDAP = 1
MOZ_JSD = 1
MOZ_NAV_BUILD_PREFIX = 1
endif
ifdef MOZ_MEDIUM
DEFINES += -DEDITOR -DMOZ_COMMUNICATOR_IIDS
EDITOR = 1
MOZ_JSD = 1
MOZ_COMMUNICATOR_IIDS = 1
MOZ_COMMUNICATOR_CONFIG_JS = 1
MOZ_COPY_ALL_JARS = 1
ifndef MOZ_SECURITY
NO_SECURITY = 1
endif
endif
ifdef MOZ_DARK
DEFINES += -DEDITOR -DMOZ_COMMUNICATOR_IIDS -DMOZ_MAIL_NEWS -DMOZ_OFFLINE \
-DMOZ_TASKBAR -DMOZ_LDAP -DMOZ_NEO
#-DMOZ_CALENDAR
EDITOR = 1
MOZ_JSD = 1
MOZ_COMMUNICATOR_IIDS = 1
MOZ_COMMUNICATOR_CONFIG_JS = 1
MOZ_COPY_ALL_JARS = 1
MOZ_OFFLINE=1
MOZ_TASKBAR=1
MOZ_LDAP=1
MOZ_MAIL_NEWS=1
#MOZ_CALENDAR=1
MOZ_NEO=1
endif
ifdef MOZ_GOLD
DEFINES += -DGOLD
BUILD_GOLD = 1
endif
ifdef NO_SECURITY
DEFINES += -DNO_SECURITY
endif
# Crash-reporting system
ifdef MOZ_FULLCIRCLE
DEFINES += -DMOZ_FULLCIRCLE
endif
ifdef EDITOR
DEFINES += -DEDITOR -DEDITOR_UI
BUILD_EDITOR = 1
BUILD_EDITOR_UI = 1
BUILD_EDT = 1
endif
# Build layers by default
ifndef NO_LAYERS
DEFINES += -DLAYERS
endif
ifdef BUILD_DEBUG_GC
DEFINES += -DDEBUG_GC
endif
ifdef BUILD_UNIX_PLUGINS
# UNIX_EMBED Should not be needed. For now these two defines go
# together until I talk with jg. --dp
DEFINES += -DUNIX_EMBED -DX_PLUGINS
endif
ifndef NO_UNIX_LDAP
DEFINES += -DUNIX_LDAP
endif
#
# Platform dependent switching off of NSPR, JAVA and MOCHA
#
ifndef NO_NSPR
DEFINES += -DNSPR
endif
ifdef MOZ_JAVA
DEFINES += -DJAVA
ifdef MOZ_OJI
error You can't define both MOZ_JAVA and MOZ_OJI anymore.
endif
JAVA_OR_OJI = 1
endif
ifdef MOZ_OJI
DEFINES += -DOJI
JAVA_OR_OJI = 1
endif
ifdef JAVA_OR_OJI
MOZ_SMARTUPDATE = 1
endif
ifndef NO_MOCHA
DEFINES += -DMOCHA
endif
ifdef FORTEZZA
DEFINES += -DFORTEZZA
endif
ifdef UNIX_SKIP_ASSERTS
DEFINES += -DUNIX_SKIP_ASSERTS
endif
ifdef SHACK
DEFINES += -DSHACK
endif
ifndef NO_UNIX_ASYNC_DNS
DEFINES += -DUNIX_ASYNC_DNS
endif
# For profiling
ifdef MOZILLA_GPROF
# Don't want profiling on build tools..
ifneq ($(SRCDIR),config)
PROF_FLAGS = $(OS_GPROF_FLAGS) -DMOZILLA_GPROF
endif
endif
# This compiles in heap dumping utilities and other good stuff
# for developers -- maybe we only want it in for a special SDK
# nspr/java runtime(?):
DEFINES += -DDEVELOPER_DEBUG
#
# For the standalone image lib
#
ifdef STANDALONE_IMAGE_LIB
DEFINES += -DSTANDALONE_IMAGE_LIB
endif
ifdef MODULAR_NETLIB
DEFINES += -DMODULAR_NETLIB
endif
######################################################################
GARBAGE = $(DEPENDENCIES) core $(wildcard core.[0-9]*)
ifndef SDK
SDK = $(DEPTH)/dist/sdk
endif
ifneq ($(OS_ARCH),WINNT)
NSINSTALL = $(DEPTH)/config/$(OBJDIR_NAME)/nsinstall
ifeq ($(NSDISTMODE),copy)
# copy files, but preserve source mtime
INSTALL = $(NSINSTALL) -t
else
ifeq ($(NSDISTMODE),absolute_symlink)
# install using absolute symbolic links
INSTALL = $(NSINSTALL) -L `$(NFSPWD)`
else
# install using relative symbolic links
INSTALL = $(NSINSTALL) -R
endif
endif
endif
######################################################################
### Java Stuff - see common.mk
######################################################################
# where the bytecode will go
JAVA_DESTPATH = $(XPDIST)/classes
# where the sources for the module you are compiling are
# default is sun-java/classsrc, override for other modules
ifndef JAVA_SOURCEPATH
JAVA_SOURCEPATH = $(DEPTH)/sun-java/classsrc
endif
ifndef JAVAH_IN_JAVA
ifeq ($(OS_ARCH),OS2)
JAVAH_PROG = flipper $(DIST)/bin/javah
else
JAVAH_PROG = $(DIST)/bin/javah
endif
else
JAVAH_PROG = $(JAVA) netscape.tools.jric.Main
endif
ifeq ($(STAND_ALONE_JAVA),1)
STAND_ALONE_JAVA_DLL_SUFFIX = s
endif
ifeq ($(OS_ARCH),OS2)
AWTDLL = awt$(MOZ_BITS)$(VERSION_NUMBER).$(DLL_SUFFIX)
AWTSDLL = awt$(MOZ_BITS)$(VERSION_NUMBER)$(STAND_ALONE_JAVA_DLL_SUFFIX).$(DLL_SUFFIX)
CONDLL = con.$(MOZ_BITS)$(VERSION_NUMBER)(DLL_SUFFIX)
JBNDLL = jbn.$(MOZ_BITS)$(VERSION_NUMBER)(DLL_SUFFIX)
JDBCDLL = jdb.$(MOZ_BITS)$(VERSION_NUMBER)(DLL_SUFFIX)
JITDLL = jit.$(MOZ_BITS)$(VERSION_NUMBER)(DLL_SUFFIX)
JPWDLL = jpw.$(MOZ_BITS)$(VERSION_NUMBER)(DLL_SUFFIX)
JRTDLL = jrt$(MOZ_BITS)$(VERSION_NUMBER).$(DLL_SUFFIX)
JSJDLL = jsj.$(MOZ_BITS)$(VERSION_NUMBER)(DLL_SUFFIX)
MMDLL = mm$(MOZ_BITS)$(VERSION_NUMBER).$(DLL_SUFFIX)
NETDLL = net.$(MOZ_BITS)$(VERSION_NUMBER)(DLL_SUFFIX)
NSCDLL = nsc.$(MOZ_BITS)$(VERSION_NUMBER)(DLL_SUFFIX)
ZIPDLL = zip.$(MOZ_BITS)$(VERSION_NUMBER)(DLL_SUFFIX)
ZPWDLL = zpw.$(MOZ_BITS)$(VERSION_NUMBER)(DLL_SUFFIX)
else
AWTDLL = libawt.$(DLL_SUFFIX)
AWTSDLL = libawt$(STAND_ALONE_JAVA_DLL_SUFFIX).$(DLL_SUFFIX)
CONDLL = libcon.$(DLL_SUFFIX)
JBNDLL = libjbn.$(DLL_SUFFIX)
JDBCDLL = libjdb.$(DLL_SUFFIX)
JITDLL = libjit.$(DLL_SUFFIX)
JPWDLL = libjpw.$(DLL_SUFFIX)
JRTDLL = libjrt.$(DLL_SUFFIX)
JSJDLL = libjsj.$(DLL_SUFFIX)
MMDLL = libmm.$(DLL_SUFFIX)
NETDLL = libnet.$(DLL_SUFFIX)
NSCDLL = libnsc.$(DLL_SUFFIX)
ZIPDLL = libzip.$(DLL_SUFFIX)
ZPWDLL = libzpw.$(DLL_SUFFIX)
endif
JAVA_DEFINES += -DAWTSDLL=\"$(AWTSDLL)\" -DCONDLL=\"$(CONDLL)\" -DJBNDLL=\"$(JBNDLL)\" -DJDBDLL=\"$(JDBDLL)\" \
-DJSJDLL=\"$(JSJDLL)\" -DNETDLL=\"$(NETDLL)\" -DNSCDLL=\"$(NSCDLL)\" -DZPWDLL=\"$(ZPWDLL)\" \
-DJAR_NAME=\"$(JAR_NAME)\"
ifeq ($(AWT_11),1)
JAVA_DEFINES += -DAWT_11
else
JAVA_DEFINES += -DAWT_102
endif

2199
mozilla/include/net.h Normal file

File diff suppressed because it is too large Load Diff

39
mozilla/network/Makefile Normal file
View File

@@ -0,0 +1,39 @@
#! gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#
#
DEPTH = ..
DIRS = \
cache \
client \
cnvts \
mimetype \
main \
protocol \
util
ifdef MODULAR_NETLIB
DIRS += module
endif
include $(DEPTH)/config/rules.mk
INCLUDE += $(PUBLIC)\ldap $(PUBLIC)\security

6
mozilla/network/cache/MANIFEST vendored Normal file
View File

@@ -0,0 +1,6 @@
#
# This is a list of local files which get copied to the mozilla:dist directory
#
extcache.h
netcache.h

42
mozilla/network/cache/Makefile vendored Normal file
View File

@@ -0,0 +1,42 @@
#!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 = netcache
LIBRARY_NAME = netcache
CSRCS = \
cachedump.c \
extcache.c \
mkcache.c \
mkextcac.c \
mkmemcac.c \
$(NULL)
ifdef NU_CACHE
CSRCS += \
nucacheproto.c \
$(NULL)
endif
EXPORTS= netcache.h mkcache.h mkmemcac.h extcache.h
REQUIRES = network nspr2 dbm util pref js java fileurl security layer img jtools cachelib
include $(DEPTH)/config/rules.mk

139
mozilla/network/cache/cachedump.c vendored Normal file
View File

@@ -0,0 +1,139 @@
/* -*- 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.
*/
/* this little program will sequentially dump out
* every record in the database
*/
#include "mkcache.h"
#include "extcache.h"
#include "plstr.h"
#include <fcntl.h>
#include <sys/stat.h>
#include <assert.h>
#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
static DB *
net_OpenExtCacheFatDB(char *filename)
{
DB *rv;
HASHINFO hash_info = {
16*1024, /* bucket size */
0, /* fill factor */
0, /* number of elements */
0, /* bytes to cache */
0, /* hash function */
0}; /* byte order */
rv = dbopen(filename,
O_RDWR | O_CREAT,
0644,
DB_HASH,
&hash_info);
if(!rv)
{
printf("Could not open cache database: %s\n", filename);
exit(1);
}
return(rv);
}
int main(int argc, char **argv)
{
char url[4028];
struct stat stat_s;
net_CacheObject * cache_obj;
DB * ext_cache_database=0;
DBT key;
DBT data;
int len;
char *end;
memset(&cache_obj, 0, sizeof(net_CacheObject));
if(argc != 2)
{
printf("Usage:\n"
"%s database\n"
"\n"
"database: path and name of the database\n", argv[0]);
exit(1);
}
/* open the cache database */
ext_cache_database = net_OpenExtCacheFatDB(argv[1]);
if(!ext_cache_database)
{
perror("Could not open cache database");
exit(1);
}
while(!(ext_cache_database->seq)(ext_cache_database, &key, &data, 0))
{
if(key.size == PL_strlen(EXT_CACHE_NAME_STRING)
&& !PL_strcmp(key.data, EXT_CACHE_NAME_STRING))
{
/* make sure it's a terminated string */
if(((char *)data.data)[data.size-1] == '\0')
printf("\n\nDatabase Name: %s\n", (char*)data.data);
else
printf("\n\nDatabase Name is corrupted!\n");
printf("\n--------------------------------------\n");
continue;
}
/* try and convert the db struct to a cache struct */
cache_obj = net_DBDataToCacheStruct(&data);
if(!cache_obj)
{
printf("Malformed database entry:\n");
printf("key: ");
fwrite(key.data, 1, key.size, stdout);
printf("\ndata: ");
fwrite(data.data, 1, data.size, stdout);
printf("\n");
printf("--------------------------------------\n");
continue;
}
/* the URL is 8 bytes into the key struct
*/
printf("URL: %s\n",(char*)key.data+8);
printf("file: %s\n", cache_obj->filename);
printf("is_relative_path: %s\n", cache_obj->is_relative_path ? "TRUE" : "FALSE");
printf("content_type: %s\n", cache_obj->content_type);
printf("content_length: %d\n", cache_obj->content_length);
printf("last_modified: %s\n", ctime(&cache_obj->last_modified));
printf("--------------------------------------\n");
}
}

21
mozilla/network/cache/cacheutils.h vendored Normal file
View File

@@ -0,0 +1,21 @@
#ifndef CACHEUTILS_H
#define CACHEUTILS_H
/* Find an actively-loading cache file for URL_s in context, and copy the first
* nbytes of it to a new cache file. Return a cache converter stream by which
* the caller can append to the cloned cache file.
*/
extern NET_VoidStreamClass *
NET_CloneWysiwygCacheFile(MWContext *context, URL_Struct *URL_s,
uint32 nbytes, const char * wysiwyg_url,
const char * base_href);
/* Create a wysiwyg cache converter to a copy of the current entry for URL_s.
*/
extern NET_VoidStreamClass *
net_CloneWysiwygMemCacheEntry(MWContext *window_id, URL_Struct *URL_s,
uint32 nbytes, const char * wysiwyg_url,
const char * base_href);
#endif /* CACHEUTILS_H */

6
mozilla/network/cache/export.mac vendored Normal file
View File

@@ -0,0 +1,6 @@
#
# This is a list of local files which get copied to the mozilla:dist directory
#
extcache.h
netcache.h

857
mozilla/network/cache/extcache.c vendored Normal file
View File

@@ -0,0 +1,857 @@
/* -*- 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 "mkcache.h"
#ifdef MOZILLA_CLIENT
#include "mktrace.h"
#include "prmem.h"
#include "plstr.h"
/* 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
*/
#include "rosetta.h"
#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 = PR_NEW(DBT);
if(!rv)
return(NULL);
rv->size = obj->size;
rv->data = PR_Malloc(rv->size);
if(!rv->data)
{
PR_Free(rv);
return(NULL);
}
memcpy(rv->data, obj->data, rv->size);
return(rv);
}
/* free the cache object
*/
MODULE_PRIVATE void net_freeCacheObj (net_CacheObject * cache_obj)
{
PR_FREEIF(cache_obj->address);
PR_FREEIF(cache_obj->post_data);
PR_FREEIF(cache_obj->post_headers);
PR_FREEIF(cache_obj->content_type);
PR_FREEIF(cache_obj->charset);
PR_FREEIF(cache_obj->content_encoding);
PR_FREEIF(cache_obj->page_services_url);
PR_FREEIF(cache_obj->filename);
#ifndef EXT_DB_ROUTINES
PR_FREEIF(cache_obj->sec_info);
#endif
PR_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 PRBool
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 = PR_NEW(DBT);
if(!rv)
return(NULL);
total_size = sizeof(net_CacheObject);
#define ADD_STRING_SIZE(string) \
total_size += old_obj->string ? PL_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 += HG73653(old_obj->sec_info);
ADD_STRING_SIZE(page_services_url);
#undef ADD_STRING_SIZE
new_obj = PR_Malloc(total_size * sizeof(char));
if(!new_obj)
{
PR_Free(rv);
return NULL;
}
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;
* XP_Bool is_netsite;
*
* time_t lock_date;
*
* char * filename;
* int32 filename_len;
*
* int32 HG52242;
* unsigned char * HG42320;
*
* 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;
*
* XP_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 ? PL_strlen(old_obj->string)+1 : 0); \
COPY_INT32((void *)cur_ptr, &len); \
cur_ptr = cur_ptr + sizeof(int32); \
if(len) \
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);
HG73209
/* 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
HG42539
/* save the security info */
if ( old_obj->sec_info ) {
len = HG65293(old_obj->sec_info);
COPY_INT32((void *)cur_ptr, &len);
cur_ptr = cur_ptr + sizeof(int32);
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)
{
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 = PR_NEW(net_CacheObject);
char * cur_ptr;
char * max_ptr;
uint32 len;
int32 version;
if(!rv)
return NULL;
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*)PR_Malloc(len); \
if(!rv->string) \
{ \
net_freeCacheObj(rv); \
return(NULL); \
} \
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"));
PR_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));
PR_Free(rv);
return(NULL);
}
HG32839
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);
HG72761
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 = PR_Malloc(rv->post_data_size+1);
if(rv->post_data)
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;
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);
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);
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 = PR_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)
{
PR_ASSERT(0);
rv->size = 0;
return(rv);
}
hash = PL_strchr(address, '#');
/* don't include '#' in a key */
if(hash)
*hash = '\0';
str_len = PL_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 */
HG42490
rv->size = size;
rv->data = PR_Malloc(size);
if(!rv->data)
{
PR_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);
HG83777
/* 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 */
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 */
HG73699
{
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);
HG72873
/* 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 *)PR_Malloc(size);
if(!rv)
return(NULL);
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)
{
PR_Free(stuff->data);
PR_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 */

272
mozilla/network/cache/extcache.h vendored Normal file
View File

@@ -0,0 +1,272 @@
/* -*- 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 PRBool char
#define uint32 unsigned int
#define int32 int
#define PR_NEW(structure) ((structure *) malloc(sizeof(structure)))
#define PR_Malloc (void *) malloc
#define memcpy memcpy
#define memset memset
#define TRACEMSG(x) printf x
#define FREEIF(x) do { if(x) free(x); } while(0)
#define FREE free
#define PL_strlen strlen
#define PL_strchr strchr
#define PL_strcmp strcmp
#define PR_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
#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) 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;
PRBool is_netsite;
uint32 content_length;
char * filename; /* cache file name */
int32 filename_len; /* optimization */
PRBool 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;
PRBool 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 PRBool net_IsValidCacheDBT(DBT *obj);
#endif /* EXT_CACHE_H */

105
mozilla/network/cache/makefile.win vendored Normal file
View File

@@ -0,0 +1,105 @@
#!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.
IGNORE_MANIFEST=1
#
#------------------------------------------------------------------------
#
# Makefile to build the cache LIB
#
#------------------------------------------------------------------------
#!ifdef MOZ_JAVA
#LOCAL_JMC_SUBDIR = .
#!endif
#
# Make sure we have MOZILLA_CLIENT defined so we get the
# proper JS includes
#
LCFLAGS = $(LCFLAGS) -DMOZILLA_CLIENT
!ifdef BUILD_DEBUG_GC
LCFLAGS = $(LCFLAGS) -DDEBUG_GC
!endif
LLIBS= \
$(NULL)
MISCDEP=$(LLIBS)
OBJS= \
.\$(OBJDIR)\extcache.obj \
.\$(OBJDIR)\mkcache.obj \
.\$(OBJDIR)\mkextcac.obj \
.\$(OBJDIR)\mkmemcac.obj \
!ifdef NU_CACHE
.\$(OBJDIR)\nucacheproto.obj \
!endif
$(NULL)
CSRCS = \
cachedump.c \
extcache.c \
mkcache.c \
mkextcac.c \
mkmemcac.c \
!ifdef NU_CACHE
nucacheproto.c \
!endif
$(NULL)
LIBRARY_NAME=netcache
MODULE=netcache
DEPTH=..\..
EXTRA_LIBS=
REQUIRES= network nspr2 cachelib
EXPORTS= netcache.h
C_OBJS = \
$(NULL)
# use LINCS on win32 for now since REQUIRES seems to be broken
#!if "$(MOZ_BITS)" != "16"
LINCS= \
-I$(XPDIST)\public\nspr2 \
-I$(XPDIST)\public\dbm \
-I$(XPDIST)\public\util \
-I$(XPDIST)\public\pref \
-I$(XPDIST)\public\network \
-I$(XPDIST)\public\js \
-I$(XPDIST)\public\java \
-I$(XPDIST)\public\fileurl \
-I$(XPDIST)\public\security \
-I$(XPDIST)\public\cache \
-I$(XPDIST)\public\jtools
#!endif
include <$(DEPTH)\config\rules.mak>
libs:: $(LIBRARY)
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
symbols::
@echo "LIBRARY_NAME is $(LIBRARY_NAME)"
@echo "LIBRARY is $(LIBRARY)"

3835
mozilla/network/cache/mkcache.c vendored Normal file

File diff suppressed because it is too large Load Diff

40
mozilla/network/cache/mkcache.h vendored Normal file
View File

@@ -0,0 +1,40 @@
/* -*- 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 MKCACHE_H
#define MKCACHE_H
#include "xp.h"
#ifndef EXT_CACHE_H
#include "extcache.h"
#endif
#ifndef NU_CACHE
/* trace variable for cache testing */
extern PRBool NET_CacheTraceOn;
#endif /* This is handled by CacheTrace_Enable() and CacheTrace_IsEnabled() in the NU world */
PR_BEGIN_EXTERN_C
#ifndef NU_CACHE
/* public accessor function for netcaster */
extern PRBool NET_CacheStore(net_CacheObject *cacheObject, URL_Struct *url_s, PRBool accept_partial_files);
#endif
PR_END_EXTERN_C
#endif /* MKCACHE_H */

1554
mozilla/network/cache/mkextcac.c vendored Normal file

File diff suppressed because it is too large Load Diff

22
mozilla/network/cache/mkextcac.h vendored Normal file
View File

@@ -0,0 +1,22 @@
/* -*- 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 MKEXTCACHE_H
#define MKEXTCACHE_H
#endif /* MKEXTCACHE_H */

2141
mozilla/network/cache/mkmemcac.c vendored Normal file

File diff suppressed because it is too large Load Diff

61
mozilla/network/cache/mkmemcac.h vendored Normal file
View File

@@ -0,0 +1,61 @@
/* -*- 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 MK_MEMORY_CACHE_H
#include "mkgeturl.h"
/* A pointer to this struct is passed as the converter_obj argument to
* NET_MemCacheConverter.
*/
typedef struct net_MemCacheConverterObject {
NET_StreamClass *next_stream;
PRBool dont_hold_URL_s;
} net_MemCacheConverterObject;
extern NET_StreamClass *
NET_MemCacheConverter (FO_Present_Types format_out,
void *converter_obj,
URL_Struct *URL_s,
MWContext *window_id);
/* remove a URL from the memory cache
*/
extern void
NET_RemoveURLFromMemCache(URL_Struct *URL_s);
/* set or unset a lock on a memory cache object
*/
extern void
NET_ChangeMemCacheLock(URL_Struct *URL_s, PRBool set);
/* Create a wysiwyg cache converter to a copy of the current entry for URL_s.
*/
extern NET_StreamClass *
net_CloneWysiwygMemCacheEntry(MWContext *window_id, URL_Struct *URL_s,
uint32 nbytes, const char * wysiwyg_url,
const char * base_href);
/* return the first cache object in memory */
extern net_CacheObject *
NET_FirstMemCacheObject(XP_List* list_ptr);
/* return the next cache object in memory */
extern net_CacheObject *
NET_NextMemCacheObject(XP_List* list_ptr);
#endif /* MK_MEMORY_CACHE_H */

79
mozilla/network/cache/netcache.h vendored Normal file
View File

@@ -0,0 +1,79 @@
/* -*- 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 NETCACHE_H
#define NETCACHE_H
#include "mkgeturl.h"
PR_BEGIN_EXTERN_C
/* Initialization */
extern void NET_CacheInit(void);
/* Shutdown */
extern void NET_CleanupCache(void);
/* create an HTML stream and push a bunch of HTML about
* the cache
*/
extern void NET_DisplayCacheInfoAsHTML(ActiveEntry * cur_entry);
/* create an HTML stream and push a bunch of HTML about
* the memory cache - TODO consolidate these two into one function! - Gagan
*/
extern void NET_DisplayMemCacheInfoAsHTML(ActiveEntry * cur_entry);
extern int NET_FindURLInCache(URL_Struct * URL_s, MWContext *ctxt);
#ifdef NU_CACHE
extern void NET_InitNuCacheProtocol(void);
#else
extern void NET_InitMemCacProtocol(void);
#endif
/* Will go away later */
extern PRBool NET_IsCacheTraceOn(void);
/* return TRUE if the URL is in the cache and
* is a partial cache file - TODO- only used in HTTP- cleanup - Gagan
*/
extern PRBool NET_IsPartialCacheFile(URL_Struct *URL_s);
/* Update cache entry on a 304 return*/
extern void NET_RefreshCacheFileExpiration(URL_Struct * URL_s);
/* remove a URL from the cache */
extern void NET_RemoveURLFromCache(URL_Struct *URL_s);
/* Removed in NU_Cache, SAR should go through new api. - Gagan */
#ifndef NU_CACHE
extern void NET_OpenExtCacheFAT(MWContext *ctxt, char * cache_name, char * instructions);
extern void CACHE_CloseAllOpenSARCache();
extern void CACHE_OpenAllSARCache();
extern int NET_FindURLInMemCache(URL_Struct * URL_s, MWContext *ctxt);
/* lookup routine
*
* builds a key and looks for it in the database. Returns an access
* method and sets a filename in the URL struct if found
*/
extern int NET_FindURLInExtCache(URL_Struct * URL_s, MWContext *ctxt);
#endif
PR_END_EXTERN_C
#endif /* NETCACHE_H */

26
mozilla/network/cache/nu/Makefile vendored Normal file
View File

@@ -0,0 +1,26 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../../..
DIRS = public src
include $(DEPTH)/config/config.mk
include $(DEPTH)/config/rules.mk

View File

@@ -0,0 +1,24 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../../../..
MODULE = cache
include $(DEPTH)/config/rules.mk

View File

@@ -0,0 +1,18 @@
#!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.
!include $(MOZ_SRC)\ns\config\rules.mak

View File

@@ -0,0 +1,65 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _nsCacheTrace_H_
#define _nsCacheTrace_H_
/*
* nsCacheTrace
*
* Gagan Saksena
* 02/02/98
*
*/
#ifndef CRLF
# define CRLF "\r\n"
#endif
#include "prtypes.h"
#include "prlog.h"
class nsCacheTrace
{
public:
nsCacheTrace(void);
static void Enable(PRBool bEnable);
static PRBool IsEnabled(void);
static void Trace(const char* msg);
static void Traceln(const char* msg);
static void Use(char* buffer);
static char* m_TraceBuffer;
private:
PRBool m_bEnabled;
};
inline void nsCacheTrace::Trace(const char* msg)
{
PR_ASSERT(msg);
//Do log stuff here TODO
}
inline void nsCacheTrace::Traceln(const char* msg)
{
Trace(msg);
Trace(CRLF);
}
inline void nsCacheTrace::Use(char* buffer)
{
m_TraceBuffer = buffer;
}
#endif

View File

@@ -0,0 +1,132 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsFFEntry_h__
#define nsFFEntry_h__
#include "nsFFObject.h"
//#include "nsISupports.h"
/** An FFEntry consists of several objects, all io takes place
* through the FFEntry's read and write functions */
class nsFFEntry//: public nsISupports
{
public:
nsFFEntry();
nsFFEntry(const PRUint32 i_ID);
//Single block entries can use this constructor
nsFFEntry(const PRUint32 i_ID, const PRUint32 i_offset, const PRUint32 i_size);
virtual ~nsFFEntry();
/*
NS_IMETHOD QueryInterface(const nsIID& aIID,
void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
*/
PRBool AddObject(const nsFFObject* i_object);
//Appends an entry to the list
PRBool AddEntry(const nsFFEntry* i_pEntry);
nsFFObject* FirstObject(void) const;
void FirstObject(const nsFFObject* i_object);
PRUint32 ID(void) const;
void ID(const PRUint32 i_ID);
nsFFEntry* NextEntry(void) const;
void NextEntry(const nsFFEntry* i_pEntry);
//Returns the number of objects in this entry.
PRUint32 Objects(void) const;
PRBool Remove(void);
PRUint32 Size(void) const;
protected:
private:
nsFFEntry(const nsFFEntry& o);
nsFFEntry& operator=(const nsFFEntry& o);
nsFFObject* m_pFirstObject;
nsFFEntry* m_pNextEntry;
PRUint32 m_ID;
PRUint32 m_Objects;
};
inline
PRBool nsFFEntry::AddEntry(const nsFFEntry* i_Entry)
{
if (!i_Entry)
return PR_FALSE;
if (m_pNextEntry)
return m_pNextEntry->AddEntry(i_Entry);
m_pNextEntry = (nsFFEntry*) i_Entry;
return PR_TRUE;
}
inline
nsFFObject* nsFFEntry::FirstObject(void) const
{
return m_pFirstObject;
}
inline
PRUint32 nsFFEntry::ID(void) const
{
return m_ID;
}
inline
void nsFFEntry::ID(const PRUint32 i_id)
{
m_ID = i_id;
}
inline
nsFFEntry* nsFFEntry::NextEntry(void) const
{
return m_pNextEntry;
}
inline
void nsFFEntry::NextEntry(const nsFFEntry* i_pEntry)
{
m_pNextEntry = (nsFFEntry*) i_pEntry;
}
inline
PRUint32 nsFFEntry::Objects(void) const
{
return m_Objects;
}
inline
PRUint32 nsFFEntry::Size(void) const
{
return m_pFirstObject ? m_pFirstObject->TotalSize() : 0; // Assumption that there is no zero length files //TODO
}
#endif // nsFFEntry_h__

View File

@@ -0,0 +1,125 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsFFObject_h__
#define nsFFObject_h__
#include "prtypes.h"
class nsFFObject
{
public:
nsFFObject(
PRUint32 i_ID,
PRUint32 i_Offset,
PRUint32 i_Size = 0);
virtual ~nsFFObject();
PRBool Add(const nsFFObject* i_object);
PRUint32 ID(void) const;
void ID(const PRUint32 i_ID);
nsFFObject* Next(void) const;
void Next(nsFFObject* io_pNext);
PRUint32 Offset(void) const;
void Offset(const PRUint32 i_offset);
PRUint32 Size(void) const;
void Size(const PRUint32 i_Size);
PRUint32 TotalSize(void) const;
protected:
private:
nsFFObject(const nsFFObject& o);
nsFFObject& operator=(const nsFFObject& o);
PRUint32 m_ID;
PRUint32 m_Offset;
PRUint32 m_Size;
nsFFObject* m_pNext;
};
inline
PRUint32 nsFFObject::ID(void) const
{
return m_ID;
}
inline
void nsFFObject::ID(const PRUint32 i_ID)
{
m_ID = i_ID;
}
inline
nsFFObject* nsFFObject::Next(void) const
{
return m_pNext;
}
inline
void nsFFObject::Next(nsFFObject* io_pNext)
{
if (io_pNext)
io_pNext->ID(m_ID);
m_pNext = io_pNext;
// Overlap check! //TODO
//PR_ASSERT(io_pNext->Offset() > m_Offset + m_Size) ||
// (io_pNext->Offset() + io_pNext->Size() < m_Offset)
}
inline
PRUint32 nsFFObject::Offset(void) const
{
return m_Offset;
}
inline
void nsFFObject::Offset(const PRUint32 i_Offset)
{
m_Offset = i_Offset;
//TODO - overlap check.
}
inline
PRUint32 nsFFObject::Size(void) const
{
return m_Size;
}
inline
void nsFFObject::Size(const PRUint32 i_Size)
{
m_Size = i_Size;
//TODO - Overlap check.
}
inline
PRUint32 nsFFObject::TotalSize(void) const
{
return m_Size + (m_pNext ? m_pNext->TotalSize() : 0);
}
#endif // nsFFObject_h__

View File

@@ -0,0 +1,107 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsFlatFile_h__
#define nsFlatFile_h__
#include "prtypes.h"
#include "prio.h"
//#include "nsISupports.h"
#ifdef IS_LITTLE_ENDIAN
#ifndef COPY_INT32
#define COPY_INT32(_a,_b) 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
#endif
/** A class to handle flat file storage mechanism */
static const PRUint32 kPAGE_SIZE =4096;
class nsFlatFile //: public nsISupports
{
public:
nsFlatFile(const char* i_pFilename,
const PRUint32 i_FileSize= 5242880); // 5 meg
// TODO think if we want to substract the toc size from this?
virtual ~nsFlatFile();
const char* Filename(void) const;
PRUint32 HeaderSize(void) const;
void Init(void);
PRBool IsValid(void) const;
PRUint32 Size(void) const;
/*
NS_IMETHOD QueryInterface(const nsIID& aIID,
void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
*/
protected:
private:
nsFlatFile(const nsFlatFile& o);
nsFlatFile& operator=(const nsFlatFile& o);
PRBool m_bIsValid;
char* m_pFilename;
PRUint32 m_Size;
PRFileDesc* m_pFD;
PRUint32 m_HeaderSize;
};
inline
const char* nsFlatFile::Filename(void) const
{
return m_pFilename;
}
inline
PRUint32 nsFlatFile::HeaderSize(void) const
{
return m_HeaderSize;
}
inline
PRBool nsFlatFile::IsValid(void) const
{
return m_bIsValid;
}
inline
PRUint32 nsFlatFile::Size(void) const
{
return m_Size;
}
#endif // nsFlatFile_h__

108
mozilla/network/cache/nu/include/nsTOC.h vendored Normal file
View File

@@ -0,0 +1,108 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsTOC_h__
#define nsTOC_h__
//#include "nsISupports.h"
#include "nsFlatFile.h"
#include "nsFFEntry.h"
class nsTOC//: public nsISupports
{
public:
nsTOC(const char* i_pFilename, nsFlatFile* i_pFlatFile);
virtual ~nsTOC();
/*
NS_IMETHOD QueryInterface(const nsIID& aIID,
void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
*/
nsFFEntry* AddEntry(PRUint32 i_size = kPAGE_SIZE);
PRUint32 Entries(void) const;
const char* Filename(void) const;
nsFFEntry* FirstDataEntry(void) const;
nsFFEntry* FreeEntry(void) const;
void Init(void);
PRBool IsValid(void) const;
protected:
PRUint32 NextID(void) const;
PRBool Serialize(nsFFEntry* io_Entry, PRBool bRead = PR_FALSE);
private:
nsTOC(const nsTOC& o);
nsTOC& operator=(const nsTOC& o);
nsFFEntry* m_pContents; // The first entry is reserved for free space list
PRUint32 m_Entries;
char* m_pFilename;
nsFlatFile* m_pFlatFile;
PRFileDesc* m_pFD;
PRBool m_bIsValid;
};
inline
PRUint32 nsTOC::Entries(void) const
{
return m_Entries;
}
inline
const char* nsTOC::Filename(void) const
{
return m_pFilename;
}
inline
nsFFEntry* nsTOC::FirstDataEntry(void) const
{
return m_pContents ? m_pContents->NextEntry() : 0;
}
inline
nsFFEntry* nsTOC::FreeEntry(void) const
{
return m_pContents;
}
inline
PRBool nsTOC::IsValid(void) const
{
return m_bIsValid;
}
inline
PRUint32 nsTOC::NextID(void) const
{
return m_Entries + 1;
}
#endif // nsTOC_h__

View File

@@ -0,0 +1,25 @@
/* A class to time excursion events */
/* declare an object of this class within the scope to be timed. */
#include "prtypes.h"
#include "prinrval.h"
class nsTimeIt
{
public:
nsTimeIt(PRUint32& tmp);
~nsTimeIt();
private:
PRIntervalTime t;
PRUint32& dest;
};
inline
nsTimeIt::nsTimeIt(PRUint32& tmp):t(PR_IntervalNow()), dest(tmp)
{
}
inline
nsTimeIt::~nsTimeIt()
{
dest = PR_IntervalToMicroseconds(PR_IntervalNow()-t);
}

View File

@@ -0,0 +1,27 @@
/* -*- 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.
*/
//
// nuCache.Prefix
//
// Global prefix file for the nuCache project.
//
//
#include "MacPrefix_debug.h"
#include "nuCacheConfig.h"

Binary file not shown.

View File

@@ -0,0 +1,18 @@
/* -*- 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.
*/
#define CGLUESUPPORTED 0 // turn off C glue support to avoid conflict on create() in RDF

View File

@@ -0,0 +1,27 @@
/* -*- 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.
*/
//
// RDFDebug.Prefix
//
// Global prefix file for the nuCache project.
//
//
#include "MacPrefix_debug.h"
#include "nuCacheConfig.h"

22
mozilla/network/cache/nu/makefile.win vendored Normal file
View File

@@ -0,0 +1,22 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH=..\..\..
DIRS=public src
include <$(DEPTH)\config\rules.mak>

50
mozilla/network/cache/nu/nsGeneric.cpp vendored Normal file
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 "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#include "nsGeneric.h"
nsGeneric::nsGeneric()
{
}
nsGeneric::~nsGeneric()
{
}
nsrefcnt nsGeneric::AddRef(void)
{
return ++m_RefCnt;
}
nsrefcnt nsGeneric::Release(void)
{
if (--m_RefCnt == 0)
{
delete this;
return 0;
}
return m_RefCnt;
}
nsresult nsGeneric::QueryInterface(const nsIID& aIID,
void** aInstancePtrResult)
{
return NS_OK;
}
nsGeneric::

45
mozilla/network/cache/nu/nsGeneric.h vendored Normal file
View File

@@ -0,0 +1,45 @@
/* -*- 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 "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#ifndef nsGeneric_h__
#define nsGeneric_h__
#include "nsISupports.h"
class nsGeneric: public nsISupports
{
public:
nsGeneric();
virtual ~nsGeneric();
NS_IMETHOD QueryInterface(const nsIID& aIID,
void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
protected:
private:
nsGeneric(const nsGeneric& o);
nsGeneric& operator=(const nsGeneric& o);
};
#endif // nsGeneric_h__

View File

@@ -0,0 +1,130 @@
/* -*- 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 "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
/* Design and original implementation by Gagan Saksena '98 */
/* Ideally we should be using the C++ api directly, but since the core of
Netlib is still in C, this file uses the stub functions that call the C++
API internally, allowing C programs to use the new cache architecture.
If you are accessing the cache, see if you can directly use the C++ api. */
#ifndef CacheStubs_h__
#define CacheStubs_h__
#include "prtypes.h"
#include "prinrval.h"
#define MEM_MODULE_ID 0
#define DISK_MODULE_ID 1
PR_BEGIN_EXTERN_C
/* General mapped functions which resolve to a bunch of internal calls. */
extern void Cache_Init(void);
extern void Cache_Shutdown(void);
/* Cache Manager stub functions
Does not include some functions not required in the current
design like AddModule etc... If you need to these functions, try
accessing them directly thru the C++ api or let me know.
Check nsCacheManager.h for details on these functions.*/
extern PRBool CacheManager_Contains(const char* i_url);
extern PRInt16 CacheManager_Entries(void);
extern void* CacheManager_GetObject(const char* i_url);
extern PRBool CacheManager_IsOffline(void);
extern void CacheManager_Offline(PRBool bSet);
extern PRBool CacheManager_Remove(const char* i_url);
extern PRUint32 CacheManager_WorstCaseTime(void);
/* Cache Object- check nsCacheObject.h for details on these functions */
extern void* CacheObject_Create(const char* i_url);
extern void CacheObject_Destroy(void* pThis);
extern const char* CacheObject_GetAddress(const void* pThis);
extern const char* CacheObject_GetCharset(void* pThis);
extern const char* CacheObject_GetContentEncoding(void* pThis);
extern PRUint32 CacheObject_GetContentLength(void* pThis);
extern const char* CacheObject_GetContentType(void* pThis);
extern const char* CacheObject_GetEtag(const void* pThis);
extern PRIntervalTime CacheObject_GetExpires(const void* pThis);
extern const char* CacheObject_GetFilename(const void* pThis);
extern PRIntervalTime CacheObject_GetLastAccessed(const void* pThis);
extern PRIntervalTime CacheObject_GetLastModified(const void* pThis);
extern PRInt16 CacheObject_GetModule(const void* pThis);
extern const char* CacheObject_GetPageServicesURL(void* pThis);
extern const char* CacheObject_GetPostData(const void* pThis);
extern PRUint32 CacheObject_GetPostDataLen(const void* pThis);
extern PRUint32 CacheObject_GetSize(const void* pThis);
extern PRUint32 CacheObject_Hits(const void* pThis);
extern PRBool CacheObject_IsExpired(const void* pThis);
extern PRBool CacheObject_IsPartial(const void* pThis);
extern PRUint32 CacheObject_Read(const void* pThis, char* o_Destination, PRUint32 i_Len);
extern void CacheObject_SetAddress(void* pThis, const char* i_Address);
extern void CacheObject_SetCharset(void* pThis, const char* i_CharSet);
extern void CacheObject_SetContentEncoding(void* pThis, const char* i_Encoding);
extern void CacheObject_SetContentLength(void* pThis, PRUint32 i_Len);
extern void CacheObject_SetContentType(void* pThis, const char* i_Type);
extern void CacheObject_SetEtag(void* pThis, const char* i_Etag);
extern void CacheObject_SetExpires(void *pThis, const PRIntervalTime i_Time);
extern void CacheObject_SetFilename(void *pThis, const char* i_Filename);
extern void CacheObject_SetLastModified(void* pThis, const PRIntervalTime i_Time);
extern void CacheObject_SetModule(void* pThis, const PRInt16 i_Module);
extern void CacheObject_SetPageServicesURL(void* pThis, const char* i_Url);
extern void CacheObject_SetPostData(void* pThis, const char* i_PostData, const PRUint32 i_Len);
extern void CacheObject_SetSize(void* pThis, const PRUint32 i_Size);
extern PRBool CacheObject_Synch(void* pThis);
extern PRUint32 CacheObject_Write(void* pThis, const char* i_buffer, const PRUint32 i_length);
/* Cache Prefs- check nsCachePref.h for details on these functions */
extern PRUint32 CachePref_GetDiskCacheSize(void);
extern PRBool CachePref_GetDiskCacheSSL(void);
extern PRUint32 CachePref_GetMemCacheSize(void);
extern void CachePref_SetDiskCacheSize(const PRUint32 i_Size);
extern void CachePref_SetDiskCacheSSL(PRBool bSet);
extern void CachePref_SetMemCacheSize(const PRUint32 i_Size);
/* Cache Trace- Check nsCacheTrace.h for details on these functions */
extern void CacheTrace_Enable(PRBool bEnable);
extern PRBool CacheTrace_IsEnabled(void);
/* Disk Module- Check nsDiskModule.h for details on these functions */
extern PRBool DiskModule_AddObject(void* pCacheObject);
extern PRBool DiskModule_Contains(const char* i_url);
extern PRUint32 DiskModule_Entries(void);
extern PRUint32 DiskModule_GetSize(void); /* Should be the same as CachePref_DiskCacheSize */
extern PRUint32 DiskModule_GetSizeInUse(void);
extern PRBool DiskModule_IsEnabled(void);
extern PRBool DiskModule_Remove(const char* i_url);
extern PRBool DiskModule_RemoveAll(void);
extern void DiskModule_SetSize(PRUint32 i_Size);
/* Mem Module- Check nsMemModule.h for details on these functions */
extern PRBool MemModule_AddObject(void* pCacheObject);
extern PRBool MemModule_Contains(const char* i_url);
extern PRUint32 MemModule_Entries(void);
extern PRUint32 MemModule_GetSize(void); /* Should be the same as CachePref_MemCacheSize */
extern PRUint32 MemModule_GetSizeInUse(void);
extern PRBool MemModule_IsEnabled(void);
extern PRBool MemModule_Remove(const char* i_url);
extern PRBool MemModule_RemoveAll(void);
extern void MemModule_SetSize(PRUint32 i_Size);
PR_END_EXTERN_C
#endif // CacheStubs_h__

View File

@@ -0,0 +1,35 @@
#!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=../../../..
EXPORTS = \
nsMonitorable.h \
nsMemModule.h \
nsCacheManager.h \
nsDiskModule.h \
nsCacheModule.h \
nsMemCacheObject.h \
nsCacheObject.h \
nsCachePref.h \
$(NULL)
MODULE = cache
include $(DEPTH)/config/config.mk
include $(DEPTH)/config/rules.mk

View File

@@ -0,0 +1,32 @@
#!nmake
#
# 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=..\..\..\..
IGNORE_MANIFEST=1
MODULE=cache
EXPORTS=nsCacheObject.h nsMemModule.h nsCacheManager.h \
nsDiskModule.h nsCacheModule.h nsMemCacheObject.h \
nsCachePref.h nsCacheBkgThd.h nsBkgThread.h \
CacheStubs.h nsCacheIterator.h nsIterator.h \
nsMonitorable.h nsStream.h nsFileStream.h \
nsMemStream.h \
$(NULL)
include <$(DEPTH)\config\rules.mak>

View File

@@ -0,0 +1,64 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsBkgThread_h__
#define nsBkgThread_h__
//#include "nsISupports.h"
#include "prthread.h"
#include "prinrval.h"
/*
Creates a background thread that maintains odd
tasks like updating, expiration, validation and
garbage collection.
Note that this is a noop active when the cache
manager is offline.
In PRThread terms, this is a PR_USER_THREAD with
local scope.
*/
class nsBkgThread//: public nsISupports
{
public:
nsBkgThread(PRIntervalTime iSleepTime, PRBool bStart=PR_TRUE);
virtual ~nsBkgThread();
/*
NS_IMETHOD QueryInterface(const nsIID& aIID,
void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
*/
void Process(void);
virtual void Run(void) = 0;
void Stop(void);
protected:
PRThread* m_pThread;
PRBool m_bContinue;
PRIntervalTime m_SleepTime;
private:
nsBkgThread(const nsBkgThread& o);
nsBkgThread& operator=(const nsBkgThread& o);
};
#endif // nsBkgThread_h__

View File

@@ -0,0 +1,46 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsCacheBkgThd_h__
#define nsCacheBkgThd_h__
#include "nsBkgThread.h"
class nsCacheBkgThd: public nsBkgThread
{
public:
nsCacheBkgThd(PRIntervalTime iSleepTime);
virtual ~nsCacheBkgThd();
/*
NS_IMETHOD QueryInterface(const nsIID& aIID,
void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
*/
void Run(void);
protected:
private:
nsCacheBkgThd(const nsCacheBkgThd& o);
nsCacheBkgThd& operator=(const nsCacheBkgThd& o);
};
#endif // nsCacheBkgThd_h__

View File

@@ -0,0 +1,74 @@
/* -*- 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 "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#ifndef nsCacheIterator_h__
#define nsCacheIterator_h__
#include "nsIterator.h"
#include "prtypes.h"
#include "nsCacheModule.h"
class nsCacheIterator: public nsIterator
{
public:
nsCacheIterator(nsCacheModule* i_pModule);
virtual ~nsCacheIterator();
virtual PRBool IsDone(void) const;
virtual nsCacheObject* Current(void) const;
private:
nsCacheIterator(const nsCacheIterator& o);
nsCacheIterator& operator=(const nsCacheIterator& o);
nsCacheModule* m_pModule;
};
inline
nsCacheIterator::nsCacheIterator(nsCacheModule* i_pModule): m_pModule(i_pModule)
{
}
inline
nsCacheIterator::~nsCacheIterator()
{
}
inline
PRBool nsCacheIterator::IsDone(void) const
{
if (m_pModule)
{
return m_pModule->Entries() <= m_Index;
}
else
return PR_FALSE;
}
inline
nsCacheObject* nsCacheIterator::Current(void) const
{
if (m_pModule)
{
return m_pModule->GetObject(m_Index);
}
return 0;
}
#endif // nsCacheIterator_h__

View File

@@ -0,0 +1,168 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _CacheManager_H_
#define _CacheManager_H_
/*
* nsCacheManager
* Design and original implementation
* by Gagan Saksena 02/02/98
*
*/
#if 0
# include "nsISupports.h"
#endif
#include "prlog.h"
#include "nsMonitorable.h"
#include "nsCacheModule.h"
#include "nsCacheObject.h"
class nsMemModule;
class nsDiskModule;
class nsCachePref;
class nsCacheBkgThd;
class nsCacheManager : public nsMonitorable //: public nsISupports
{
public:
//Reserved modules
enum modules
{
MEM =0,
DISK=1
};
nsCacheManager();
~nsCacheManager();
PRInt32 AddModule(nsCacheModule* i_cacheModule);
// InsertModule
PRBool Contains(const char* i_url) const;
/* Number of modules in the cache manager */
PRInt16 Entries() const;
/* Singleton */
static nsCacheManager* GetInstance();
nsCacheObject* GetObj(const char* i_url) const;
nsCacheModule* GetModule(PRInt16 i_index) const;
nsMemModule* GetMemModule() const;
nsDiskModule* GetDiskModule() const;
PRBool IsOffline(void) const;
void Offline(PRBool bSet);
PRBool Remove(const char* i_url);
const char* Trace() const;
/* Performance measure- microseconds */
PRUint32 WorstCaseTime(void) const;
protected:
PRBool ContainsExactly(const char* i_url) const;
void Init();
nsCacheModule* LastModule() const;
//PRBool Lock(void);
//void Unlock(void);
/*
class MgrMonitor
{
public:
MgrMonitor() { nsCacheManager::GetInstance()->Lock();}
~MgrMonitor() { nsCacheManager::GetInstance()->Unlock();}
};
friend MgrMonitor;
*/
private:
nsCacheModule* m_pFirstModule;
PRMonitor* m_pMonitor;
nsCacheManager(const nsCacheManager& cm);
nsCacheManager& operator=(const nsCacheManager& cm);
nsCacheBkgThd* m_pBkgThd;
PRBool m_bOffline;
};
inline
nsDiskModule* nsCacheManager::GetDiskModule() const
{
PR_ASSERT(m_pFirstModule && m_pFirstModule->NextModule());
return (m_pFirstModule) ? (nsDiskModule*) m_pFirstModule->NextModule() : NULL;
}
inline
nsMemModule* nsCacheManager::GetMemModule() const
{
PR_ASSERT(m_pFirstModule);
return (nsMemModule*) m_pFirstModule;
}
inline
PRBool nsCacheManager::IsOffline(void) const
{
return m_bOffline;
}
/*
inline
PRBool nsCacheManager::Lock(void)
{
if (!m_pMonitor)
{
m_pMonitor = PR_NewMonitor();
if (!m_pMonitor)
return PR_FALSE;
}
PR_EnterMonitor(m_pMonitor);
return PR_TRUE;
}
*/
inline
void nsCacheManager::Offline(PRBool i_bSet)
{
m_bOffline = i_bSet;
}
/*
inline
void nsCacheManager::Unlock(void)
{
PR_ASSERT(m_pMonitor);
if (m_pMonitor)
PR_ExitMonitor(m_pMonitor);
}
*/
#endif

View File

@@ -0,0 +1,194 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsCacheModule_h__
#define nsCacheModule_h__
/*
* nsCacheModule
*
* Gagan Saksena 02/03/98
*
*/
//#include <nsISupports.h>
#include "nsCacheObject.h"
#include "nsEnumeration.h"
#include "nsMonitorable.h"
/* Why in the world is forward decl. not working? */
//class nsCacheObject;
/*
// {5D51B24F-E6C2-11d1-AFE5-006097BFC036}
static const NS_CACHEMODULE_ID =
{ 0x5d51b24f, 0xe6c2, 0x11d1, { 0xaf, 0xe5, 0x0, 0x60, 0x97, 0xbf, 0xc0, 0x36 } };
*/
class nsCacheIterator;
class nsCacheModule : public nsMonitorable /*: public nsISupports */
{
public:
nsCacheModule(const PRUint32 i_size /*= DEFAULT_SIZE */);
virtual
~nsCacheModule();
virtual
PRBool AddObject(nsCacheObject* i_pObject)=0;
virtual
PRBool Contains(const char* i_url) const=0;
virtual
PRBool Contains(nsCacheObject* i_pObject) const=0;
void Enable(PRBool i_Enable);
const PRUint32 Entries(void) const;
nsEnumeration* Enumeration(void) const;
/* Enumerations wiht a function pointer - TODO */
//TODO move to own interface for both Garbage Collection and Revalidation
virtual
void GarbageCollect(void);
virtual
nsCacheObject* GetObject(const char* i_url) const=0;
virtual
nsCacheObject* GetObject(const PRUint32 i_index) const =0;
virtual
nsStream* GetStreamFor(const nsCacheObject* i_pObject)=0;
PRBool IsEnabled(void) const;
/* Cant do additions, deletions, validations, expirations */
PRBool IsReadOnly(void) const;
nsCacheModule* NextModule(void) const;
void NextModule(nsCacheModule*);
virtual
PRBool Remove(const char* i_url) = 0;
virtual
PRBool Remove(const PRUint32 i_index) = 0;
virtual
PRBool RemoveAll(void);
virtual
PRBool Revalidate(void) = 0;
const PRUint32 Size(void) const;
virtual
void SetSize(const PRUint32 i_size);
PRUint32 SizeInUse(void) const;
const char* Trace(void) const;
protected:
virtual
PRBool ReduceSizeTo(const PRUint32 i_NewSize);
PRUint32 m_Entries;
PRUint32 m_Size;
PRUint32 m_SizeInUse;
PRBool m_Enabled;
nsEnumeration* m_pEnumeration;
nsCacheIterator* m_pIterator;
nsCacheModule* m_pNext;
private:
nsCacheModule(const nsCacheModule& cm);
nsCacheModule& operator=(const nsCacheModule& cm);
};
inline void nsCacheModule::Enable(PRBool i_Enable)
{
m_Enabled = i_Enable;
}
inline const PRUint32 nsCacheModule::Entries() const
{
return m_Entries;
}
inline
nsEnumeration* nsCacheModule::Enumeration(void) const
{
MonitorLocker ml((nsMonitorable*)this);
if (!m_pEnumeration)
{
PR_ASSERT(m_pIterator);
((nsCacheModule*)this)->m_pEnumeration = new nsEnumeration((nsIterator*)m_pIterator);
}
else
((nsCacheModule*)this)->m_pEnumeration->Reset();
return m_pEnumeration;
}
inline PRBool nsCacheModule::IsEnabled(void) const
{
return m_Enabled;
}
inline PRBool nsCacheModule::IsReadOnly(void) const
{
return PR_FALSE;
}
inline nsCacheModule* nsCacheModule::NextModule(void) const
{
return m_pNext;
}
inline void nsCacheModule::NextModule(nsCacheModule* pNext)
{
/* No overwriting */
PR_ASSERT(m_pNext == 0);
if (m_pNext)
{
/* ERROR */
delete m_pNext; //Worst case.
}
m_pNext = pNext;
}
inline const PRUint32 nsCacheModule::Size() const
{
return m_Size;
}
inline void nsCacheModule::SetSize(const PRUint32 size)
{
m_Size = size;
}
inline PRUint32 nsCacheModule::SizeInUse(void) const
{
return m_SizeInUse;
}
#endif // nsCacheModule_h__

View File

@@ -0,0 +1,288 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsCacheObject_h__
#define nsCacheObject_h__
#if 0
#include "nsISupports.h"
#endif
#include "prtypes.h"
#include "prinrval.h"
static const PRUint32 kCACHE_VERSION = 5;
class nsStream;
class nsCacheObject //: public nsISupports
{
public:
enum state_flags
{
INIT=0x000000,
PARTIAL=0x000001
};
nsCacheObject();
nsCacheObject(const nsCacheObject& another);
nsCacheObject(const char* i_url);
virtual ~nsCacheObject();
/*
NS_IMETHOD QueryInterface(const nsIID& aIID,
void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
*/
void Address(const char* i_url);
const char* Address(void) const;
void Charset(const char* i_Charset);
const char* Charset(void) const;
void ContentEncoding(const char* i_Encoding);
const char* ContentEncoding(void) const;
void ContentLength(PRUint32 i_len);
PRUint32 ContentLength(void) const;
void ContentType(const char* i_Type);
const char* ContentType(void) const;
void Etag(const char* i_etag);
const char* Etag(void) const;
void Expires(PRIntervalTime i_Expires);
PRIntervalTime Expires(void) const;
void Filename(const char* i_Filename);
const char* Filename(void) const;
PRUint16 Hits(void) const;
/* Read and write info about this cache object */
void* Info(void) const;
PRBool Info(void* /*, PRUint32 len */);
PRUint32 InfoSize(void) const;
PRBool IsExpired(void) const;
PRBool IsPartial(void) const;
PRIntervalTime LastAccessed(void) const;
PRIntervalTime LastModified(void) const;
void LastModified(const PRIntervalTime i_lastModified);
PRInt16 Module(void) const;
void Module(PRUint16 i_m);
void PageServicesURL(const char* i_Url);
const char* PageServicesURL(void) const;
const char* PostData(void) const;
void PostData(const char* i_data, const PRUint32 i_Len);
PRUint32 PostDataLen(void) const;
PRUint32 Read(char* o_Buffer, PRUint32 len);
PRUint32 Size(void) const;
void Size(PRUint32 i_Size);
const char* Trace() const;
PRUint32 Write(const char* i_Buffer, const PRUint32 len);
protected:
void Init();
char* m_Charset;
char* m_ContentEncoding;
PRUint32 m_ContentLength;
char* m_ContentType;
char* m_Etag;
PRIntervalTime m_Expires;
int m_Flags;
char* m_Filename;
PRUint16 m_Hits;
PRUint32 m_info_size;
PRIntervalTime m_LastAccessed, m_LastModified;
void* m_pInfo;
char* m_PageServicesURL;
char* m_PostData;
PRUint32 m_PostDataLen;
PRInt16 m_Module;
PRUint32 m_Size;
nsStream* m_pStream;
char* m_URL;
private:
nsCacheObject& operator=(const nsCacheObject& x);
};
inline
const char* nsCacheObject::Address(void) const
{
return m_URL;
};
inline
const char* nsCacheObject::Charset(void) const
{
return m_Charset;
}
inline
const char* nsCacheObject::ContentEncoding(void) const
{
return m_ContentEncoding;
}
inline
PRUint32 nsCacheObject::ContentLength(void) const
{
return m_ContentLength;
};
inline
void nsCacheObject::ContentLength(PRUint32 i_Size)
{
m_ContentLength = i_Size;
};
inline
const char* nsCacheObject::ContentType(void) const
{
return m_ContentType;
};
inline
const char* nsCacheObject::Etag(void) const
{
return m_Etag;
};
inline
PRIntervalTime nsCacheObject::Expires(void) const
{
return m_Expires;
};
inline
void nsCacheObject::Expires(PRIntervalTime i_Expires)
{
m_Expires = i_Expires;
};
inline
const char* nsCacheObject::Filename(void) const
{
return m_Filename;
}
inline
PRUint16 nsCacheObject::Hits(void) const
{
return m_Hits;
};
inline
PRBool nsCacheObject::IsExpired(void) const
{
PRIntervalTime now = PR_IntervalNow();
return (m_Expires <= now);
};
inline
PRBool nsCacheObject::IsPartial(void) const
{
return (m_Flags & nsCacheObject::PARTIAL);
};
inline
PRIntervalTime nsCacheObject::LastAccessed(void) const
{
return m_LastAccessed;
};
inline
PRIntervalTime nsCacheObject::LastModified(void) const
{
return m_LastModified;
};
inline
void nsCacheObject::LastModified(const PRIntervalTime i_LastModified)
{
m_LastModified = i_LastModified;
};
inline
PRInt16 nsCacheObject::Module(void) const
{
return m_Module;
};
inline
void nsCacheObject::Module(PRUint16 i_Module)
{
m_Module = i_Module;
};
inline
const char* nsCacheObject::PageServicesURL(void) const
{
return m_PageServicesURL;
}
inline
const char* nsCacheObject::PostData(void) const
{
return m_PostData;
}
inline
PRUint32 nsCacheObject::PostDataLen(void) const
{
return m_PostDataLen;
}
inline
PRUint32 nsCacheObject::Size(void) const
{
return m_Size;
};
inline
void nsCacheObject::Size(PRUint32 i_Size)
{
m_Size = i_Size;
};
#endif // nsCacheObject_h__

View File

@@ -0,0 +1,84 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsCachePref_h__
#define nsCachePref_h__
//#include "nsISupports.h"
#include "prtypes.h"
class nsCachePref //: public nsISupports
{
public:
static nsCachePref* GetInstance(void);
nsCachePref(void);
~nsCachePref();
enum Refresh
{
NEVER,
ONCE,
ALWAYS
} r;
const PRUint32 BkgSleepTime(void);
const char* DiskCacheDBFilename(void); /* like Fat.db */
const char* DiskCacheFolder(void); /* Cache dir */
PRBool DiskCacheSSL(void);
void DiskCacheSSL(PRBool bSet);
PRUint32 DiskCacheSize(void);
void DiskCacheSize(const PRUint32 i_Size);
PRUint32 MemCacheSize(void);
void MemCacheSize(const PRUint32 i_Size);
nsCachePref::Refresh
Frequency(void);
/* Revalidating in background, makes IMS calls in the bkg thread to
update cache entries. TODO, this should be at a bigger time period
than the cache cleanup routine */
PRBool RevalidateInBkg(void);
/*
NS_IMETHOD QueryInterface(const nsIID& aIID,
void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
*/
private:
nsCachePref(const nsCachePref& o);
nsCachePref& operator=(const nsCachePref& o);
PRBool m_bRevalidateInBkg;
PRBool m_bDiskCacheSSL;
nsCachePref::Refresh m_RefreshFreq;
PRUint32 m_MemCacheSize;
PRUint32 m_DiskCacheSize;
char* m_DiskCacheDBFilename;
char* m_DiskCacheFolder;
PRUint32 m_BkgSleepTime;
};
#endif // nsCachePref_h__

View File

@@ -0,0 +1,77 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _nsDiskModule_H_
#define _nsDiskModule_H_
/*
* nsDiskModule
*
* Gagan Saksena 02/03/98
*
*/
#include "nsCacheModule.h"
#include "nsCachePref.h"
#include "mcom_db.h"
class nsDiskModule : public nsCacheModule
{
public:
nsDiskModule(const PRUint32 size = nsCachePref::GetInstance()->DiskCacheSize());
~nsDiskModule();
// Cache module interface
PRBool AddObject(nsCacheObject* io_pObject);
PRBool Contains(nsCacheObject* io_pObject) const;
PRBool Contains(const char* i_url) const;
void GarbageCollect(void);
nsCacheObject* GetObject(const PRUint32 i_index) const;
nsCacheObject* GetObject(const char* i_url) const;
nsStream* GetStreamFor(const nsCacheObject* i_pObject)=0;
PRBool ReduceSizeTo(const PRUint32 i_NewSize);
PRBool Remove(const char* i_url);
PRBool Remove(const PRUint32 i_index);
// To do cleanup set size to zero. Else initialize disk cache
void SetSize(const PRUint32 i_size);
PRBool Revalidate(void);
private:
enum sync_frequency
{
EVERYTIME,
IDLE,
NEVER
} m_Sync;
PRBool InitDB(void);
nsDiskModule(const nsDiskModule& dm);
nsDiskModule& operator=(const nsDiskModule& dm);
DB* m_pDB;
};
#endif

View File

@@ -0,0 +1,93 @@
/* -*- 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 "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#ifndef nsEnumeration_h__
#define nsEnumeration_h__
//#include "nsISupports.h"
#include "nsIterator.h"
#include "prlog.h"
class nsEnumeration //: public nsISupports
{
public:
nsEnumeration(nsIterator* iter);
virtual ~nsEnumeration();
PRBool HasMoreElements(void);
void* NextElement(void);
void Reset(void);
/*
NS_IMETHOD QueryInterface(const nsIID& aIID,
void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
*/
protected:
nsIterator* m_pIter;
private:
nsEnumeration(const nsEnumeration& o);
nsEnumeration& operator=(const nsEnumeration& o);
};
inline
nsEnumeration::nsEnumeration(nsIterator* iter):m_pIter(iter)
{
PR_ASSERT(iter);
if (m_pIter)
m_pIter->First();
}
inline
nsEnumeration::~nsEnumeration()
{
}
inline
PRBool nsEnumeration::HasMoreElements(void)
{
if (m_pIter) //remove this check for optimization?
return m_pIter->IsDone() ? PR_FALSE : PR_TRUE;
return PR_FALSE;
}
inline
void* nsEnumeration::NextElement(void)
{
if (m_pIter)
{
void* pTemp = m_pIter->CurrentItem();
m_pIter->Next();
return pTemp;
}
return 0;
}
inline
void nsEnumeration::Reset(void)
{
if (m_pIter)
{
m_pIter->First();
}
}
#endif // nsEnumeration_h__

View File

@@ -0,0 +1,52 @@
/* -*- 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 "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#ifndef nsFileStream_h__
#define nsFileStream_h__
//#include "nsISupports.h"
#include "nsStream.h"
#include "xp.h" // Reqd. for xp_file.h
#include "xp_file.h" // Cuz we don't have a better choice, as yet
class nsFileStream: public nsStream
{
public:
nsFileStream(XP_File* i_pFile);
virtual ~nsFileStream();
/*
NS_IMETHOD QueryInterface(const nsIID& aIID,
void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
*/
PRInt32 Read(void* o_Buffer, PRUint32 i_Len);
PRInt32 Write(const void* i_Buffer, PRUint32 i_Len);
protected:
private:
nsFileStream(const nsFileStream& o);
nsFileStream& operator=(const nsFileStream& o);
XP_File* m_pFile;
};
#endif // nsFileStream_h__

View File

@@ -0,0 +1,53 @@
/* -*- 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 nsHash_h__
#define nsHash_h__
#include "plhash.h"
class nsHashKey {
protected:
nsHashKey(void);
public:
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 (*nsHashEnumFunc)(nsHashKey *aKey, void *aData);
class nsHash {
private:
// members
PLHashTable *hashtable;
public:
nsHash(PRUint32 aSize = 256);
~nsHash();
void *Put(nsHashKey *aKey, void *aData);
void *Get(nsHashKey *aKey);
void *Remove(nsHashKey *aKey);
void Enumerate(nsHashEnumFunc aEnumFunc);
};
#endif

View File

@@ -0,0 +1,67 @@
/* -*- 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 "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#ifndef nsIterator_h__
#define nsIterator_h__
//#include "nsISupports.h"
#include "prtypes.h"
class nsIterator //:public nsISupports
{
public:
virtual void First(void);
virtual PRBool IsDone(void) const = 0;
virtual void Next(void);
virtual void* CurrentItem(void) const;
/*
NS_IMETHOD QueryInterface(const nsIID& aIID,
void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
*/
protected:
nsIterator() {m_Index = 0;};
PRUint32 m_Index;
};
inline
void nsIterator::First(void)
{
m_Index = 0;
}
inline
void nsIterator::Next(void)
{
++m_Index;
}
inline
void* nsIterator::CurrentItem(void) const
{
return 0;
}
#endif // nsIterator_h__

View File

@@ -0,0 +1,101 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _nsMemCacheObject_h_
#define _nsMemCacheObject_h_
#include "prtypes.h"
#include "nsCacheObject.h"
class nsMemCacheObject
{
public:
nsMemCacheObject(void);
nsMemCacheObject(nsCacheObject* io_pObject);
nsMemCacheObject(const char* i_url);
~nsMemCacheObject();
void* Data(void) const;
void Next(nsMemCacheObject* pObject);
void Next(nsCacheObject* io_pObject);
nsMemCacheObject* Next(void) const;
nsCacheObject* ThisObject(void) const;
private:
nsMemCacheObject* m_pNextObject;
nsCacheObject* m_pObject;
void* m_pData;
nsMemCacheObject& operator=(const nsMemCacheObject& mco);
nsMemCacheObject(const nsMemCacheObject&);
};
inline nsMemCacheObject::nsMemCacheObject(void):
m_pObject(new nsCacheObject()),
m_pNextObject(0),
m_pData(0)
{
}
inline nsMemCacheObject::nsMemCacheObject(nsCacheObject* io_pObject):
m_pObject(io_pObject),
m_pNextObject(0),
m_pData(0)
{
}
inline nsMemCacheObject::nsMemCacheObject(const char* i_url):
m_pObject(new nsCacheObject(i_url)),
m_pNextObject(0),
m_pData(0)
{
}
inline void* nsMemCacheObject::Data(void) const
{
// PR_ASSERT(m_pData);
return m_pData;
}
inline nsMemCacheObject* nsMemCacheObject::Next(void) const
{
return m_pNextObject;
}
inline void nsMemCacheObject::Next(nsMemCacheObject* pObject)
{
m_pNextObject = pObject;
}
inline void nsMemCacheObject::Next(nsCacheObject* pObject)
{
m_pNextObject = new nsMemCacheObject(pObject);
}
inline nsCacheObject* nsMemCacheObject::ThisObject(void) const
{
return m_pObject;
}
#endif //_nsMemCacheObject_h_

View File

@@ -0,0 +1,112 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _nsMemModule_H_
#define _nsMemModule_H_
/*
* nsMemModule
*
* Gagan Saksena
* 02/03/98
*
*/
#include "nsCacheModule.h"
#include "nsMemCacheObject.h"
#include "nsCachePref.h"
//#include "nsHash.h" // TODO - replace with nsHashtable when the XPCOM_BRANCH merges
//#include "nsHashtable.h"
/*
// {5D51B250-E6C2-11d1-AFE5-006097BFC036}
static const NS_MEMMODULE_IID =
{ 0x5d51b250, 0xe6c2, 0x11d1, { 0xaf, 0xe5, 0x0, 0x60, 0x97, 0xbf, 0xc0, 0x36 } };
*/
class nsMemModule : public nsCacheModule
{
public:
nsMemModule(const PRUint32 size=nsCachePref::GetInstance()->MemCacheSize());
~nsMemModule();
/*
NS_IMETHOD QueryInterface(const nsIID& aIID,
void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
*/
PRBool AddObject(nsCacheObject* io_pObject);
PRBool Contains(nsCacheObject* io_pObject) const;
PRBool Contains(const char* i_url) const;
void GarbageCollect(void);
nsCacheObject* GetObject(const PRUint32 i_index) const;
nsCacheObject* GetObject(const char* i_url) const;
nsStream* GetStreamFor(const nsCacheObject* i_pObject);
PRBool ReduceSizeTo(const PRUint32 i_NewSize);
PRBool Remove(const char* i_url);
PRBool Remove(const PRUint32 i_index);
// PRBool RemoveAll(void);
PRBool Revalidate(void);
// Start of nsMemModule specific stuff...
// Here is a sample implementation using linked list
protected:
nsMemCacheObject* LastObject(void) const;
private:
nsMemCacheObject* m_pFirstObject;
//nsHash m_ht; //TODO replace with nsHashtable
//Optimization
nsMemCacheObject* m_pLastObject;
nsMemModule(const nsMemModule& mm);
nsMemModule& operator=(const nsMemModule& mm);
/*
class nsMemKey : public nsHashKey
{
public:
nsMemKey();
~nsMemKey();
PRUint32 HashValue();
PRBool Equals(nsHashKey *aKey);
nsHashKey* Clone();
};
*/
};
inline
PRBool nsMemModule::Revalidate(void)
{
/* Mem module elements are never revalidated */
return PR_FALSE;
}
#endif

View File

@@ -0,0 +1,52 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this Mem are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this Mem except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#ifndef nsMemStream_h__
#define nsMemStream_h__
//#include "nsISupports.h"
#include "nsStream.h"
class nsMemStream: public nsStream
{
public:
nsMemStream();
virtual ~nsMemStream();
/*
NS_IMETHOD QueryInterface(const nsIID& aIID,
void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
*/
PRInt32 Read(void* o_Buffer, PRUint32 i_Len);
PRInt32 Write(const void* i_Buffer, PRUint32 i_Len);
protected:
private:
nsMemStream(const nsMemStream& o);
nsMemStream& operator=(const nsMemStream& o);
void* m_pCurrent;
void* m_pStart;
PRUint32 m_Size;
};
#endif // nsMemStream_h__

View File

@@ -0,0 +1,106 @@
/* -*- 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 "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#ifndef nsMonitorable_h__
#define nsMonitorable_h__
//#include "nsISupports.h"
#include "prmon.h"
class nsMonitorable//: public nsISupports
{
public:
nsMonitorable();
virtual ~nsMonitorable();
/*
NS_IMETHOD QueryInterface(const nsIID& aIID,
void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
*/
PRBool Lock(void);
void Unlock(void);
protected:
class MonitorLocker
{
public:
MonitorLocker(nsMonitorable* i_pThis):
m_pMonitorable(i_pThis)
{
if (m_pMonitorable) m_pMonitorable->Lock();
}
~MonitorLocker()
{
if (m_pMonitorable) m_pMonitorable->Unlock();
}
private:
nsMonitorable* m_pMonitorable;
};
PRMonitor* m_pMonitor;
private:
nsMonitorable(const nsMonitorable& o);
nsMonitorable& operator=(const nsMonitorable& o);
};
inline
nsMonitorable::nsMonitorable(void):m_pMonitor(PR_NewMonitor())
{
}
inline
nsMonitorable::~nsMonitorable()
{
if (m_pMonitor)
{
PR_DestroyMonitor(m_pMonitor);
m_pMonitor = 0;
}
}
inline
PRBool nsMonitorable::Lock(void)
{
if (!m_pMonitor)
{
m_pMonitor = PR_NewMonitor();
if (!m_pMonitor)
return PR_FALSE;
}
PR_EnterMonitor(m_pMonitor);
return PR_TRUE;
}
inline
void nsMonitorable::Unlock(void)
{
PR_ASSERT(m_pMonitor);
if (m_pMonitor)
PR_ExitMonitor(m_pMonitor);
}
#endif // nsMonitorable_h__

View File

@@ -0,0 +1,51 @@
/* -*- 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 "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#ifndef nsStream_h__
#define nsStream_h__
//#include "nsISupports.h"
#include "prtypes.h"
class nsStream//: public nsISupports
{
public:
nsStream();
virtual ~nsStream();
/*
NS_IMETHOD QueryInterface(const nsIID& aIID,
void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
*/
virtual
PRInt32 Read(void* o_Buffer, PRUint32 i_Len) = 0;
virtual
PRInt32 Write(const void* i_Buffer, PRUint32 i_Len) = 0;
protected:
private:
nsStream(const nsStream& o);
nsStream& operator=(const nsStream& o);
};
#endif // nsStream_h__

View File

@@ -0,0 +1,493 @@
/* -*- 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 "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
/* Design and original implementation by Gagan Saksena '98 */
#include "CacheStubs.h"
#include "nsCacheManager.h"
#include "nsDiskModule.h"
#include "nsMemModule.h"
#include "nsCacheTrace.h"
#include "prlog.h"
#define CACHEMGR nsCacheManager::GetInstance()
void
Cache_Init(void)
{
/* Most of the initilization gets done in the constructor for the
* nsCacheManager class. */
}
void
Cache_Shutdown(void)
{
/* todo- Should the destructor for nsCacheManager object be forced here?*/
}
/* CacheManager functions */
PRBool
CacheManager_Contains(const char* i_url)
{
return CACHEMGR->Contains(i_url);
}
PRInt16
CacheManager_Entries()
{
return CACHEMGR->Entries();
}
void*
CacheManager_GetObject(const char* i_url)
{
return CACHEMGR->GetObj(i_url);
}
PRBool
CacheManager_IsOffline(void)
{
return CACHEMGR->IsOffline();
}
void
CacheManager_Offline(PRBool bSet)
{
CACHEMGR->Offline(bSet);
}
PRBool
CacheManager_Remove(const char* i_url)
{
return CACHEMGR->Remove(i_url);
}
PRUint32
CacheManager_WorstCaseTime(void)
{
return CACHEMGR->WorstCaseTime();
}
/* CacheObject functions */
void*
CacheObject_Create(const char* i_url)
{
return new nsCacheObject(i_url);
}
const char*
CacheObject_GetAddress(const void* pThis)
{
return pThis ? ((nsCacheObject*)pThis)->Address() : 0;
}
const char*
CacheObject_GetCharset(const void* pThis)
{
return pThis ? ((nsCacheObject*)pThis)->Charset() : 0;
}
const char*
CacheObject_GetContentEncoding(const void* pThis)
{
return pThis ? ((nsCacheObject*)pThis)->ContentEncoding() : 0;
}
PRUint32
CacheObject_GetContentLength(const void* pThis)
{
return pThis ? ((nsCacheObject*)pThis)->ContentLength() : 0;
}
const char*
CacheObject_GetContentType(const void* pThis)
{
return pThis ? ((nsCacheObject*)pThis)->ContentType() : 0;
}
const char*
CacheObject_GetEtag(const void* pThis)
{
return pThis ? ((nsCacheObject*)pThis)->Etag() : 0;
}
PRIntervalTime
CacheObject_GetExpires(const void* pThis)
{
return pThis ? ((nsCacheObject*)pThis)->Expires() : 0;
}
const char*
CacheObject_GetFilename(const void* pThis)
{
return pThis ? ((nsCacheObject*)pThis)->Filename() : 0;
}
PRIntervalTime
CacheObject_GetLastAccessed(const void* pThis)
{
return pThis ? ((nsCacheObject*)pThis)->LastAccessed() : 0;
}
PRIntervalTime
CacheObject_GetLastModified(const void* pThis)
{
return pThis ? ((nsCacheObject*)pThis)->LastModified() : 0;
}
PRInt16
CacheObject_GetModule(const void* pThis)
{
return pThis ? ((nsCacheObject*)pThis)->Module() : -1;
}
const char*
CacheObject_GetPageServicesURL(const void* pThis)
{
return pThis ? ((nsCacheObject*)pThis)->PageServicesURL() : 0;
}
const char*
CacheObject_GetPostData(const void* pThis)
{
return pThis ? ((nsCacheObject*)pThis)->PostData() : 0;
}
PRUint32
CacheObject_GetPostDataLen(const void* pThis)
{
return pThis ? ((nsCacheObject*)pThis)->PostDataLen() : 0;
}
PRUint32
CacheObject_GetSize(const void* pThis)
{
return pThis ? ((nsCacheObject*)pThis)->Size() : 0;
}
PRUint32
CacheObject_Hits(const void* pThis)
{
return pThis ? ((nsCacheObject*)pThis)->Hits() : 0;
}
PRBool
CacheObject_IsExpired(const void* pThis)
{
return pThis ? ((nsCacheObject*)pThis)->IsExpired() : PR_FALSE;
}
PRBool
CacheObject_IsPartial(const void* pThis)
{
return pThis ? ((nsCacheObject*)pThis)->IsPartial() : PR_FALSE;
}
PRUint32
CacheObject_Read(const void* pThis, char* o_Buffer, PRUint32 i_Len)
{
return pThis ? ((nsCacheObject*)pThis)->Read(o_Buffer, i_Len) : 0;
}
void
CacheObject_SetAddress(void* pThis, const char* i_Address)
{
if (pThis)
((nsCacheObject*)pThis)->Address(i_Address);
}
void
CacheObject_SetCharset(void* pThis, const char* i_Charset)
{
if (pThis)
((nsCacheObject*)pThis)->Charset(i_Charset);
}
void
CacheObject_SetContentEncoding(void* pThis, const char* i_Encoding)
{
if (pThis)
((nsCacheObject*)pThis)->ContentEncoding(i_Encoding);
}
void
CacheObject_SetContentLength(void* pThis, PRUint32 i_ContentLen)
{
if (pThis)
((nsCacheObject*)pThis)->ContentLength(i_ContentLen);
}
void
CacheObject_SetContentType(void* pThis, const char* i_ContentType)
{
if (pThis)
((nsCacheObject*)pThis)->ContentType(i_ContentType);
}
void
CacheObject_SetEtag(void* pThis, const char* i_Etag)
{
if (pThis)
((nsCacheObject*)pThis)->Etag(i_Etag);
}
void
CacheObject_SetExpires(void *pThis, const PRIntervalTime i_Time)
{
if (pThis)
((nsCacheObject*)pThis)->Expires(i_Time);
}
void
CacheObject_SetFilename(void* pThis, const char* i_Filename)
{
if (pThis)
((nsCacheObject*)pThis)->Filename(i_Filename);
}
void
CacheObject_SetLastModified(void* pThis, const PRIntervalTime i_Time)
{
if (pThis)
((nsCacheObject*)pThis)->LastModified(i_Time);
}
void
CacheObject_SetModule(void* pThis, const PRInt16 i_Module)
{
if (pThis)
((nsCacheObject*)pThis)->Module(i_Module);
}
void
CacheObject_SetPageServicesURL(void* pThis, const char* i_Url)
{
if (pThis)
((nsCacheObject*)pThis)->PageServicesURL(i_Url);
}
void
CacheObject_SetPostData(void* pThis, const char* i_PostData, const PRUint32 i_Len)
{
if (pThis)
((nsCacheObject*)pThis)->PostData(i_PostData, i_Len);
}
void
CacheObject_SetSize(void* pThis, const PRUint32 i_Size)
{
if (pThis)
((nsCacheObject*)pThis)->Size(i_Size);
}
PRBool
CacheObject_Synch(void* pThis)
{
if (pThis)
{
nsCacheObject* pObj = (nsCacheObject*) pThis;
PRBool bStatus = CACHEMGR->GetModule(pObj->Module())->AddObject(pObj);
return bStatus;
}
return PR_FALSE;
}
PRUint32
CacheObject_Write(void* pThis, const char* i_buffer, const PRUint32 i_length)
{
return i_length;
}
void
CacheObject_Destroy(void* pThis)
{
if (pThis)
{
((nsCacheObject*)pThis)->~nsCacheObject();
pThis = 0;
}
}
/* CachePref functions */
PRUint32
CachePref_GetDiskCacheSize(void)
{
return nsCachePref::GetInstance()->DiskCacheSize();
}
PRBool
CachePref_GetDiskCacheSSL(void)
{
return nsCachePref::GetInstance()->DiskCacheSSL();
}
PRUint32
CachePref_GetMemCacheSize(void)
{
return nsCachePref::GetInstance()->MemCacheSize();
}
void
CachePref_SetDiskCacheSize(const PRUint32 i_Size)
{
nsCachePref::GetInstance()->DiskCacheSize(i_Size);
}
void
CachePref_SetDiskCacheSSL(PRBool bSet)
{
nsCachePref::GetInstance()->DiskCacheSSL(bSet);
}
void
CachePref_SetMemCacheSize(const PRUint32 i_Size)
{
nsCachePref::GetInstance()->MemCacheSize(i_Size);
}
/* CacheTrace functions */
void
CacheTrace_Enable(PRBool bEnable)
{
nsCacheTrace::Enable(bEnable);
}
PRBool
CacheTrace_IsEnabled(void)
{
return nsCacheTrace::IsEnabled();
}
/* DiskModule functions */
#define DISKMOD nsCacheManager::GetInstance()->GetDiskModule()
PRBool
DiskModule_AddObject(void* pObject)
{
return DISKMOD->AddObject((nsCacheObject*)pObject);
}
PRBool
DiskModule_Contains(const char* i_url)
{
return DISKMOD->Contains(i_url);
}
PRUint32
DiskModule_Entries(void)
{
return DISKMOD->Entries();
}
PRUint32
DiskModule_GetSize(void)
{
return DISKMOD->Size();
}
PRUint32
DiskModule_GetSizeInUse(void)
{
return DISKMOD->SizeInUse();
}
PRBool
DiskModule_IsEnabled(void)
{
return DISKMOD->IsEnabled();
}
PRBool
DiskModule_Remove(const char* i_url)
{
return DISKMOD->Remove(i_url);
}
PRBool
DiskModule_RemoveAll(void)
{
return DISKMOD->RemoveAll();
}
void
DiskModule_SetSize(PRUint32 i_Size)
{
DISKMOD->SetSize(i_Size);
}
/* MemModule functions */
#define MEMMOD nsCacheManager::GetInstance()->GetMemModule()
PRBool
MemModule_AddObject(void* pObject)
{
return MEMMOD->AddObject((nsCacheObject*)pObject);
}
PRBool
MemModule_Contains(const char* i_url)
{
return MEMMOD->Contains(i_url);
}
PRUint32
MemModule_Entries(void)
{
return MEMMOD->Entries();
}
PRUint32
MemModule_GetSize(void)
{
return MEMMOD->Size();
}
PRUint32
MemModule_GetSizeInUse(void)
{
return MEMMOD->SizeInUse() ;
}
PRBool
MemModule_IsEnabled(void)
{
return MEMMOD->IsEnabled();
}
PRBool
MemModule_Remove(const char* i_url)
{
return MEMMOD->Remove(i_url);
}
PRBool
MemModule_RemoveAll(void)
{
return MEMMOD->RemoveAll();
}
void
MemModule_SetSize(PRUint32 i_Size)
{
MEMMOD->SetSize(i_Size);
}
#undef MEMMOD
#undef DISKMOD
#undef CACHEMGR

62
mozilla/network/cache/nu/src/Makefile vendored Normal file
View File

@@ -0,0 +1,62 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH=../../../..
TARGET = $(LIBRARY)
LIBRARY_NAME=cachelib
MISCDEP = \
$(LIBNSPR) \
$(DIST)/lib/dbm32.lib \
$(DIST)/lib/libplc21.lib \
$(DIST)/lib/xpcom32.lib \
$(NULL)
MODULE = cache
CPPSRCS = nsCacheObject.cpp \
nsCacheModule.cpp \
nsCacheManager.cpp \
nsMemModule.cpp \
nsDiskModule.cpp \
nsCacheTrace.cpp \
nsCachePref.cpp \
nsMemCacheObject.cpp \
nsBkgThread.cpp \
nsCacheBkgThd.cpp \
CacheStubs.cpp \
nsFileStream.cpp \
nsMemStream.cpp \
$(NULL)
REQUIRES = dbm nspr pref xpcom
LLIBS = \
$(DIST)/lib/dbm32.lib \
$(DIST)/lib/libplc21.lib \
$(DIST)/lib/xpcom32.lib \
$(LIBNSPR) \
$(NULL)
include $(DEPTH)/config/rules.mk
INCLUDES += -I../include \
-I../public \
$(NULL)

View File

@@ -0,0 +1,81 @@
#!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.
IGNORE_MANIFEST = 1
DEPTH=..\..\..\..
MAKE_OBJ_TYPE = EXE
DLLNAME = cachelib
#DLL = .\$(OBJDIR)\$(DLLNAME).dll
LIBRARY_NAME=cachelib
#
# Remember to change libplc21 to $whatever it is...
#
LLIBS = \
$(LIBNSPR) \
$(DIST)\lib\libplc21.lib \
$(DIST)\lib\dbm32.lib \
$(DIST)\lib\xpcom32.lib \
$(NULL)
MISCDEP = $(LLIBS)
MODULE = cache
OBJS = \
.\$(OBJDIR)\nsCacheObject.obj \
.\$(OBJDIR)\nsCacheModule.obj \
.\$(OBJDIR)\nsMemModule.obj \
.\$(OBJDIR)\nsDiskModule.obj \
.\$(OBJDIR)\nsCacheTrace.obj \
.\$(OBJDIR)\nsCacheManager.obj \
.\$(OBJDIR)\nsCachePref.obj \
.\$(OBJDIR)\nsMemCacheObject.obj \
.\$(OBJDIR)\nsBkgThread.obj \
.\$(OBJDIR)\nsCacheBkgThd.obj \
.\$(OBJDIR)\CacheStubs.obj \
.\$(OBJDIR)\nsFileStream.obj \
.\$(OBJDIR)\nsMemStream.obj \
$(NULL)
# .\$(OBJDIR)\nsHash.obj \
LINCS = \
-I$(PUBLIC)\xpcom \
-I$(PUBLIC)\dbm \
-I$(PUBLIC)\pref \
-I..\public \
-I..\include \
$(NULL)
LCFLAGS = \
$(LCFLAGS) \
$(NULL)
#-DNS_DLLNAME=$(DLLNAME).dll \
include <$(DEPTH)\config\rules.mak>
install:: $(EXE)
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).$(LIB_SUFFIX) $(DIST)\lib
# $(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).$(DLL_SUFFIX) $(DIST)\bin
clobber::
rm -f $(DIST)\lib\$(DLLNAME).$(LIB_SUFFIX)

View File

@@ -0,0 +1,92 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsBkgThread.h"
#include "prlog.h"
static void PR_CALLBACK RunFunction(void* arg);
static void PR_CALLBACK RunFunction(void* arg)
{
nsBkgThread* pBT = (nsBkgThread*) arg;
if (pBT)
{
pBT->Process();
}
}
nsBkgThread::nsBkgThread(PRIntervalTime iSleepTime, PRBool bStart /* =PR_TRUE */)
{
m_SleepTime = iSleepTime;
m_bContinue = bStart;
m_pThread = PR_CreateThread(
PR_USER_THREAD,
RunFunction,
this,
PR_PRIORITY_NORMAL,
PR_LOCAL_THREAD,
PR_JOINABLE_THREAD,
0);
PR_ASSERT(NULL != m_pThread);
}
nsBkgThread::~nsBkgThread()
{
m_bContinue = PR_FALSE;
if (m_pThread != NULL)
{
Stop();
}
}
/*
nsrefcnt nsBkgThread::AddRef(void)
{
return ++m_RefCnt;
}
nsrefcnt nsBkgThread::Release(void)
{
if (--m_RefCnt == 0)
{
delete this;
return 0;
}
return m_RefCnt;
}
nsresult nsBkgThread::QueryInterface(const nsIID& aIID,
void** aInstancePtrResult)
{
return NS_OK;
}
*/
void nsBkgThread::Process(void)
{
while (m_bContinue)
{
PR_Sleep(m_SleepTime);
Run();
}
}
void nsBkgThread::Stop(void)
{
m_bContinue = PR_FALSE;
PRStatus status = PR_Interrupt(m_pThread);
PR_ASSERT(PR_SUCCESS == status);
}

View File

@@ -0,0 +1,78 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "prlog.h"
#include "nsCacheBkgThd.h"
#include "nsCacheManager.h"
#include "nsCacheModule.h"
#include "nsCachePref.h"
nsCacheBkgThd::nsCacheBkgThd(PRIntervalTime iSleepTime):
nsBkgThread(iSleepTime)
{
}
nsCacheBkgThd::~nsCacheBkgThd()
{
}
/*
nsrefcnt nsCacheBkgThd::AddRef(void)
{
return ++m_RefCnt;
}
nsrefcnt nsCacheBkgThd::Release(void)
{
if (--m_RefCnt == 0)
{
delete this;
return 0;
}
return m_RefCnt;
}
nsresult nsCacheBkgThd::QueryInterface(const nsIID& aIID,
void** aInstancePtrResult)
{
return NS_OK;
}
*/
void nsCacheBkgThd::Run(void)
{
/* Step thru all the modules and call cleanup on each */
nsCacheManager* pCM = nsCacheManager::GetInstance();
PR_ASSERT(pCM);
if (pCM->IsOffline())
return; /* Dont update entries if offline */
PRInt16 i = pCM->Entries();
while (i>0)
{
nsCacheModule* pModule = pCM->GetModule(--i);
PR_ASSERT(pModule);
/* TODO change this based on if it supports garbage cleaning */
if (!pModule->IsReadOnly())
{
pModule->GarbageCollect();
if (nsCachePref::GetInstance()->RevalidateInBkg())
{
pModule->Revalidate();
}
}
}
}

View File

@@ -0,0 +1,249 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
* Gagan Saksena 02/02/98
*
*/
#include "prtypes.h"
#include "prinrval.h"
#include "nsCacheManager.h"
#include "nsCacheTrace.h"
#include "nsCachePref.h"
#include "nsCacheModule.h"
#include "nsMemModule.h"
#include "nsDiskModule.h"
#include "nsCacheBkgThd.h"
/* TODO move this to InitNetLib */
static nsCacheManager TheManager;
nsCacheManager::nsCacheManager(): m_pFirstModule(0), m_bOffline(PR_FALSE)
{
Init();
}
nsCacheManager::~nsCacheManager()
{
if (m_pBkgThd)
{
m_pBkgThd->Stop();
delete m_pBkgThd;
m_pBkgThd = 0;
}
if (m_pFirstModule)
{
delete m_pFirstModule;
m_pFirstModule = 0;
}
}
nsCacheManager*
nsCacheManager::GetInstance()
{
return &TheManager;
}
#if 0
/* Caller must free returned char* */
const char*
nsCacheManager::Trace() const
{
char linebuffer[128];
char* total;
sprintf(linebuffer, "nsCacheManager: Modules = %d\n", Entries());
total = new char[strlen(linebuffer) + 1];
strcpy(total, linebuffer);
return total;
}
#endif
PRInt32
nsCacheManager::AddModule(nsCacheModule* pModule)
{
MonitorLocker ml(this);
if (pModule)
{
if (m_pFirstModule)
LastModule()->NextModule(pModule);
else
m_pFirstModule = pModule;
return Entries()-1;
}
else
return -1;
}
PRBool
nsCacheManager::Contains(const char* i_url) const
{
MonitorLocker ml((nsMonitorable*)this);
// Add logic to check for IMAP type URLs, byteranges, and search with / appended as well...
// TODO
PRBool bStatus = ContainsExactly(i_url);
if (!bStatus)
{
// try alternate stuff
/*
char* extraBytes;
char extraBytesSeparator;
*/
}
return bStatus;
}
PRBool
nsCacheManager::ContainsExactly(const char* i_url) const
{
if (m_pFirstModule)
{
nsCacheModule* pModule = m_pFirstModule;
while (pModule)
{
if (pModule->Contains(i_url))
{
return PR_TRUE;
}
pModule = pModule->NextModule();
}
}
return PR_FALSE;
}
nsCacheObject*
nsCacheManager::GetObj(const char* i_url) const
{
MonitorLocker ml((nsMonitorable*)this);
if (m_pFirstModule)
{
nsCacheModule* pModule = m_pFirstModule;
nsCacheObject* obj = 0;
while (pModule)
{
obj = pModule->GetObject(i_url);
if (obj)
return obj;
pModule = pModule->NextModule();
}
}
return 0;
}
PRInt16
nsCacheManager::Entries() const
{
MonitorLocker ml((nsMonitorable*)this);
if (m_pFirstModule)
{
PRInt16 count=1;
nsCacheModule* pModule = m_pFirstModule;
while (pModule = pModule->NextModule())
{
count++;
}
return count;
}
return 0;
}
nsCacheModule*
nsCacheManager::GetModule(PRInt16 i_index) const
{
MonitorLocker ml((nsMonitorable*)this);
if ((i_index < 0) || (i_index >= Entries()))
return 0;
nsCacheModule* pModule = m_pFirstModule;
PR_ASSERT(pModule);
for (PRInt16 i=0; i<i_index; pModule = pModule->NextModule())
{
i++;
PR_ASSERT(pModule);
}
return pModule;
}
void
nsCacheManager::Init()
{
MonitorLocker ml(this);
if (m_pFirstModule)
delete m_pFirstModule;
m_pFirstModule = new nsMemModule(nsCachePref::GetInstance()->MemCacheSize());
PR_ASSERT(m_pFirstModule);
if (m_pFirstModule)
{
nsDiskModule* pTemp = new nsDiskModule(nsCachePref::GetInstance()->DiskCacheSize());
PR_ASSERT(pTemp);
m_pFirstModule->NextModule(pTemp);
m_pBkgThd = new nsCacheBkgThd(PR_SecondsToInterval(nsCachePref::GetInstance()->BkgSleepTime()));
PR_ASSERT(m_pBkgThd);
}
}
nsCacheModule*
nsCacheManager::LastModule() const
{
MonitorLocker ml((nsMonitorable*)this);
if (m_pFirstModule)
{
nsCacheModule* pModule = m_pFirstModule;
while(pModule->NextModule()) {
pModule = pModule->NextModule();
}
return pModule;
}
return 0;
}
PRBool
nsCacheManager::Remove(const char* i_url)
{
MonitorLocker ml(this);
PRBool bStatus = PR_FALSE;
if (m_pFirstModule)
{
nsCacheModule* pModule = m_pFirstModule;
bStatus |= pModule->Remove(i_url);
if (bStatus)
return bStatus;
while(pModule->NextModule()) {
pModule = pModule->NextModule();
if (bStatus)
return bStatus;
}
}
return bStatus;
}
PRUint32
nsCacheManager::WorstCaseTime(void) const
{
PRIntervalTime start = PR_IntervalNow();
if (this->Contains("a vague string that should not be in any of the modules"))
{
PR_ASSERT(0);
}
return PR_IntervalToMicroseconds(PR_IntervalNow() - start);
}

View File

@@ -0,0 +1,97 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsCacheModule.h"
#include "nsCacheTrace.h"
#include "nsCacheIterator.h"
/*
* nsCacheModule
*
* Gagan Saksena 02/02/98
*
*/
#define DEFAULT_SIZE 10*0x100000L
nsCacheModule::nsCacheModule(const PRUint32 i_size=DEFAULT_SIZE):
m_Size(i_size),
m_pEnumeration(0),
m_pNext(0),
m_Entries(0)
{
m_pIterator = new nsCacheIterator(this);
}
nsCacheModule::~nsCacheModule()
{
if (m_pNext)
{
delete m_pNext;
m_pNext = 0;
}
if (m_pIterator)
{
delete m_pIterator;
m_pIterator = 0;
}
if (m_pEnumeration)
{
delete m_pEnumeration;
m_pEnumeration = 0;
}
}
void nsCacheModule::GarbageCollect(void)
{
}
PRBool nsCacheModule::ReduceSizeTo(const PRUint32 i_NewSize)
{
MonitorLocker ml(this);
//TODO
return PR_TRUE;
}
PRBool nsCacheModule::RemoveAll(void)
{
MonitorLocker ml(this);
PRBool status = PR_TRUE;
while (m_Entries > 0)
{
status &= Remove(--m_Entries);
}
return status;
}
#if 0
// Caller must free this
const char* nsCacheModule::Trace() const
{
char linebuffer[128];
char* total;
PR_sprintf(linebuffer, "nsCacheModule: Objects = %d\n", Entries());
total = new char[PR_strlen(linebuffer) + 1];
strcpy(total, linebuffer);
return total;
}
#endif

View File

@@ -0,0 +1,580 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include <memory.h>
#include "prmem.h"
#include "prprf.h"
#include "plstr.h"
#include "nsCacheObject.h"
#include "nsCacheTrace.h"
#include "nsCacheModule.h"
#include "nsCacheManager.h"
#include "nsStream.h"
/*
* nsCacheObject
*
* Gagan Saksena 02/02/98
*
*/
static const PRIntervalTime DEFAULT_EXPIRES = PR_SecondsToInterval(86400);
#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) 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
/* Convenient macros used in stuffing and reading back cache object to a void * */
/* TODO: Change these to file scope functions */
#define STUFF_STRING(string) \
{ \
len = (string ? PL_strlen(string)+1 : 0); \
COPY_INT32((void *)cur_ptr, &len); \
cur_ptr = cur_ptr + sizeof(int32); \
if(len) \
memcpy((void *)cur_ptr, string, len); \
cur_ptr += len; \
}
#define STUFF_NUMBER(number) \
{ \
COPY_INT32((void *)cur_ptr, &number); \
cur_ptr = cur_ptr + sizeof(PRUint32); \
}
#define STUFF_TIME(number) \
{ \
COPY_INT32((void *)cur_ptr, &number); \
cur_ptr = cur_ptr + sizeof(PRIntervalTime); \
}
#define STUFF_BOOL(bool_val) \
{ \
if(bool_val) \
((char *)(cur_ptr))[0] = 1; \
else \
((char *)(cur_ptr))[0] = 0; \
cur_ptr = cur_ptr + sizeof(char); \
}
/* 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) \
{ \
return PR_TRUE; \
} \
COPY_INT32(&len, cur_ptr); \
cur_ptr += sizeof(int32); \
if(len) \
{ \
if(len > MAX_HUGE_STRING_SIZE) \
{ \
return PR_FALSE; \
} \
string = new char[len]; \
if(!string) \
{ \
return PR_FALSE; \
} \
memcpy(string, cur_ptr, len); \
cur_ptr += len; \
} \
}
#define RETRIEVE_NUMBER(number) \
{ \
if(cur_ptr > max_ptr) \
return PR_TRUE; \
COPY_INT32(&number, cur_ptr); \
cur_ptr += sizeof(int32); \
}
#define RETRIEVE_TIME(number) \
{ \
if(cur_ptr > max_ptr) \
return PR_TRUE; \
COPY_INT32(&number, cur_ptr); \
cur_ptr += sizeof(PRIntervalTime); \
}
#define RETRIEVE_BOOL(bool) \
{ \
if(cur_ptr > max_ptr) \
return PR_TRUE; \
if(((char *)(cur_ptr))[0]) \
bool = TRUE; \
else \
bool = FALSE; \
cur_ptr += sizeof(char); \
}
/* TODO- Further optimization, initialize these to null,
but that will add more work on copy constructor which is ok */
nsCacheObject::nsCacheObject():
m_Charset(new char[1]),
m_ContentEncoding(new char[1]),
m_ContentType(new char[1]),
m_Etag(new char[1]),
m_Filename(new char[1]),
m_Flags(INIT),
m_Module(-1),
m_pInfo(0),
m_PageServicesURL(new char[1]),
m_PostData(new char[1]),
m_PostDataLen(0),
m_pStream(0),
m_URL(new char[1])
{
Init();
*m_Charset = '\0';
*m_ContentEncoding = '\0';
*m_ContentType = '\0';
*m_Etag = '\0';
*m_Filename = '\0';
*m_PageServicesURL = '\0';
*m_PostData = '\0';
*m_URL = '\0';
}
nsCacheObject::~nsCacheObject()
{
if (m_Charset)
delete[] m_Charset;
if (m_ContentEncoding)
delete[] m_ContentEncoding;
if (m_ContentType)
delete[] m_ContentType;
if (m_Etag)
delete[] m_Etag;
if (m_Filename)
delete[] m_Filename;
if (m_PageServicesURL)
delete[] m_PageServicesURL;
if (m_PostData)
delete[] m_PostData;
if (m_URL)
delete[] m_URL;
if (m_pStream)
delete m_pStream;
}
nsCacheObject::nsCacheObject(const nsCacheObject& another):
m_Charset(new char[PL_strlen(another.m_Charset)+1]),
m_ContentEncoding(new char[PL_strlen(another.m_ContentEncoding)+1]),
m_ContentType(new char[PL_strlen(another.m_ContentType)+1]),
m_Etag(new char[PL_strlen(another.m_Etag)+1]),
m_Filename(new char[PL_strlen(another.m_Filename)+1]),
m_Flags(another.m_Flags),
m_PageServicesURL(new char[PL_strlen(another.m_PageServicesURL)+1]),
m_PostDataLen(another.m_PostDataLen),
m_PostData(new char[another.m_PostDataLen+1]),
m_URL(new char[PL_strlen(another.m_URL)+1]),
m_pStream(0),
m_pInfo(0) /* Should this be copied as well? */
{
PL_strncpy(m_Charset, another.m_Charset, PL_strlen(another.m_Charset));
PL_strncpy(m_ContentEncoding, another.m_ContentEncoding, PL_strlen(another.m_ContentEncoding));
PL_strncpy(m_ContentType, another.m_ContentType, PL_strlen(another.m_ContentType));
PL_strncpy(m_Etag, another.m_Etag, PL_strlen(another.m_Etag));
PL_strncpy(m_Filename, another.m_Filename, PL_strlen(another.m_Filename));
PL_strncpy(m_PageServicesURL, another.m_PageServicesURL, PL_strlen(another.m_PageServicesURL));
PL_strncpy(m_PostData, another.m_PostData, another.m_PostDataLen);
PL_strncpy(m_URL, another.m_URL, PL_strlen(another.m_URL));
m_Hits = another.m_Hits;
m_LastAccessed = another.m_LastAccessed;
m_LastModified = another.m_LastModified;
m_Size = another.m_Size;
m_Module = another.m_Module;
}
nsCacheObject::nsCacheObject(const char* i_url):
m_Charset(new char[1]),
m_ContentEncoding(new char[1]),
m_ContentType(new char[1]),
m_Etag(new char[1]),
m_Filename(new char[1]),
m_Flags(INIT),
m_PageServicesURL(new char[1]),
m_PostData(new char[1]),
m_PostDataLen(0),
m_URL(new char[PL_strlen(i_url)+1]),
m_Module(-1),
m_pStream(0),
m_pInfo(0)
{
Init();
PR_ASSERT(i_url);
PL_strncpy(m_URL, i_url, PL_strlen(i_url));
*m_Charset = '\0';
*m_ContentEncoding = '\0';
*m_ContentType = '\0';
*m_Etag = '\0';
*m_Filename = '\0';
*m_PageServicesURL = '\0';
*m_PostData = '\0';
}
void nsCacheObject::Address(const char* i_url)
{
PR_ASSERT(i_url && *i_url);
if (!i_url)
return;
if (m_URL)
delete[] m_URL;
m_URL = new char[PL_strlen(i_url) + 1];
PL_strncpy(m_URL, i_url, PL_strlen(i_url));
}
void nsCacheObject::Charset(const char* i_Charset)
{
// PR_ASSERT(i_Charset && *i_Charset);
if (!i_Charset)
return;
if (m_Charset)
delete[] m_Charset;
m_URL = new char[PL_strlen(i_Charset) + 1];
PL_strncpy(m_Charset, i_Charset, PL_strlen(i_Charset));
}
void nsCacheObject::ContentEncoding(const char* i_Encoding)
{
// PR_ASSERT(i_Encoding && *i_Encoding);
if (!i_Encoding)
return;
if (m_ContentEncoding)
delete[] m_ContentEncoding;
m_ContentEncoding = new char[PL_strlen(i_Encoding) + 1];
PL_strncpy(m_ContentEncoding, i_Encoding, PL_strlen(i_Encoding));
}
void nsCacheObject::ContentType(const char* i_Type)
{
// PR_ASSERT(i_Type && *i_Type);
if (!i_Type)
{
/* Reset to empty */ // TODO ??
return;
}
if (m_ContentType)
delete[] m_ContentType;
m_ContentType = new char[PL_strlen(i_Type) + 1];
PL_strncpy(m_ContentType, i_Type, PL_strlen(i_Type));
}
void nsCacheObject::Etag(const char* i_etag)
{
// PR_ASSERT(i_etag && *i_etag);
if (!i_etag)
return;
if (m_Etag)
delete[] m_Etag;
m_Etag = new char[PL_strlen(i_etag) + 1];
PL_strncpy(m_Etag, i_etag, PL_strlen(i_etag));
}
void nsCacheObject::Filename(const char* i_Filename)
{
// PR_ASSERT(i_Filename && *i_Filename);
if (!i_Filename)
return;
if (m_Filename)
delete[] m_Filename;
m_Filename = new char[PL_strlen(i_Filename) +1];
PL_strncpy(m_Filename, i_Filename, PL_strlen(i_Filename));
}
void* nsCacheObject::Info(void) const
{
if (m_pInfo)
return m_pInfo;
nsCacheObject* pThis = (nsCacheObject*) this;
if (m_URL){
pThis->m_info_size = sizeof(nsCacheObject);
pThis->m_info_size -= sizeof(void*); // m_info itself is not being serialized
pThis->m_info_size -= sizeof(char*); // And neither is PostData
//Add the strings sizes
pThis->m_info_size += PL_strlen(m_Charset)+1;
pThis->m_info_size += PL_strlen(m_ContentEncoding)+1;
pThis->m_info_size += PL_strlen(m_ContentType)+1;
pThis->m_info_size += PL_strlen(m_Etag)+1;
pThis->m_info_size += PL_strlen(m_Filename)+1;
pThis->m_info_size += PL_strlen(m_PageServicesURL)+1;
pThis->m_info_size += PL_strlen(m_URL)+1;
//Add the Postdata len
pThis->m_info_size += m_PostDataLen+1;
void* new_obj = PR_Calloc(1, m_info_size * sizeof(char));
if (!new_obj)
{
PR_Free(new_obj);
return 0;
}
PRUint32 len;
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, &m_info_size);
cur_ptr += sizeof(PRUint32);
/* 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
*/
COPY_INT32((void *)cur_ptr, &kCACHE_VERSION);
cur_ptr += sizeof(PRUint32);
STUFF_STRING(m_Charset);
STUFF_STRING(m_ContentEncoding);
STUFF_NUMBER(m_ContentLength);
STUFF_STRING(m_ContentType);
STUFF_STRING(m_Etag);
STUFF_TIME(m_Expires);
STUFF_STRING(m_Filename);
STUFF_NUMBER(m_Flags);
STUFF_NUMBER(m_Hits);
STUFF_TIME(m_LastAccessed);
STUFF_TIME(m_LastModified);
STUFF_NUMBER(m_Module);
STUFF_STRING(m_PageServicesURL);
STUFF_NUMBER(m_PostDataLen);
/* There is a possibility of it not being a string! */
if (m_PostData)
{
memcpy(cur_ptr, m_PostData, m_PostDataLen+1);
cur_ptr += m_PostDataLen+1;
}
STUFF_NUMBER(m_Size);
STUFF_STRING(m_URL);
// Important Assertion. Dont remove!
// If this fails then you or somebody has added a variable to the
// nsCacheObject class and a decision on its "cacheability" has
// not yet been made.
PR_ASSERT(cur_ptr == (char*) new_obj + m_info_size);
pThis->m_pInfo = new_obj;
}
return m_pInfo;
}
PRBool nsCacheObject::Info(void* i_data)
{
if (!i_data)
return PR_FALSE;
char* cur_ptr = (char*) i_data;
//Reset the m_pInfo;
PR_FREEIF(m_pInfo);
//Reset all strings
if (m_Charset)
delete[] m_Charset;
if (m_ContentEncoding)
delete[] m_ContentEncoding;
if (m_ContentType)
delete[] m_ContentType;
if (m_Etag)
delete[] m_Etag;
if (m_Filename)
delete[] m_Filename;
if (m_PageServicesURL)
delete[] m_PageServicesURL;
if (m_URL)
delete[] m_URL;
if (m_PostData)
delete[] m_PostData;
m_PostDataLen = 0;
COPY_INT32(&m_info_size, cur_ptr);
char* max_ptr = cur_ptr + m_info_size;
cur_ptr += sizeof(PRUint32);
PRUint32 version;
COPY_INT32(&version, cur_ptr);
cur_ptr += sizeof(PRUint32);
PR_ASSERT(version == kCACHE_VERSION);
if (version != kCACHE_VERSION)
{
//TODO Bad cache version
return PR_FALSE;
}
PRUint32 len;
RETRIEVE_STRING(m_Charset);
RETRIEVE_STRING(m_ContentEncoding);
RETRIEVE_NUMBER(m_ContentLength);
RETRIEVE_STRING(m_ContentType);
RETRIEVE_STRING(m_Etag);
RETRIEVE_TIME(m_Expires);
RETRIEVE_STRING(m_Filename);
RETRIEVE_NUMBER(m_Flags);
RETRIEVE_NUMBER(m_Hits);
RETRIEVE_TIME(m_LastAccessed);
RETRIEVE_TIME(m_LastModified);
RETRIEVE_NUMBER(m_Module);
RETRIEVE_STRING(m_PageServicesURL);
RETRIEVE_NUMBER(m_PostDataLen);
// Special case-
m_PostData = new char[m_PostDataLen + 1];
if (m_PostData)
{
memcpy(m_PostData, cur_ptr, m_PostDataLen+1);
}
cur_ptr += m_PostDataLen +1;
RETRIEVE_NUMBER(m_Size);
RETRIEVE_STRING(m_URL);
// Most important assertion! Don't ever remove!
PR_ASSERT(cur_ptr == max_ptr);
return PR_TRUE;
}
PRUint32 nsCacheObject::InfoSize(void) const
{
if (!m_pInfo)
{
((nsCacheObject*) this)->Info();
}
return m_info_size;
}
void nsCacheObject::Init()
{
m_Expires = PR_IntervalNow() + DEFAULT_EXPIRES;
m_Hits = 0;
}
void nsCacheObject::PageServicesURL(const char* i_Url)
{
// PR_ASSERT(i_Url && *i_Url);
if (!i_Url)
return;
if (m_PageServicesURL)
delete[] m_PageServicesURL;
m_PageServicesURL = new char[PL_strlen(i_Url) + 1];
PL_strncpy(m_PageServicesURL, i_Url, PL_strlen(i_Url));
}
void nsCacheObject::PostData(const char* i_data, const PRUint32 i_Len)
{
if (!i_data || (0 ==i_Len))
return;
if (m_PostData)
delete[] m_PostData;
m_PostData = new char[i_Len+1];
PL_strncpy(m_PostData, i_data, i_Len);
m_PostDataLen = i_Len;
}
PRUint32 nsCacheObject::Read(char* o_Buffer, PRUint32 len)
{
if (!m_pStream)
{
PR_ASSERT(m_Module >=0);
if (0 <= m_Module)
{
nsCacheModule* pModule = nsCacheManager::GetInstance()->GetModule(m_Module);
if (pModule)
{
m_pStream = pModule->GetStreamFor(this);
if (m_pStream)
return m_pStream->Read(o_Buffer, len);
}
}
return 0;
}
return m_pStream->Read(o_Buffer, len);
}
#if 0
/* Caller must free returned string */
// TODO change to use PR_stuff...
const char* nsCacheObject::Trace() const
{
char linebuffer[256];
char* total;
PR_Sprintf(linebuffer, "nsCacheObject:URL=%s,SIZE=%d,ET=%s,\n\tLM=%d,LA=%d,EXP=%d,HITS=%d\n",
m_URL,
m_Size,
m_Etag,
m_LastModified,
m_LastAccessed,
m_Expires,
m_Hits);
total = new char[PL_strlen(linebuffer) +1];
PL_strcpy(total, linebuffer);
return total;
}
#endif
PRUint32 nsCacheObject::Write(const char* i_Buffer, const PRUint32 len)
{
if (!m_pStream)
{
PR_ASSERT(m_Module >=0);
if (0 <= m_Module)
{
nsCacheModule* pModule = nsCacheManager::GetInstance()->GetModule(m_Module);
if (pModule)
{
m_pStream = pModule->GetStreamFor(this);
if (m_pStream)
return m_pStream->Write(i_Buffer, len);
}
}
return 0;
}
return m_pStream->Write(i_Buffer, len);
}

View File

@@ -0,0 +1,128 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsCachePref.h"
//#include "prefapi.h"
static const PRUint32 MEM_CACHE_SIZE_DEFAULT = 1024*1024;
static const PRUint32 DISK_CACHE_SIZE_DEFAULT = 5*MEM_CACHE_SIZE_DEFAULT;
static const PRUint32 BKG_THREAD_SLEEP = 15*60; /*in seconds, 15 minutes */
static const PRUint16 BUGS_FOUND_SO_FAR = 0;
/* Find a bug in NU_CACHE, get these many chocolates */
static const PRUint16 CHOCOLATES_PER_BUG_FOUND = 2^BUGS_FOUND_SO_FAR;
/* TODO move this to InitNetLib */
static nsCachePref ThePrefs;
nsCachePref::nsCachePref(void):
m_BkgSleepTime(BKG_THREAD_SLEEP),
m_DiskCacheDBFilename(new char[6+1]),
m_DiskCacheFolder(0),
m_DiskCacheSize(DISK_CACHE_SIZE_DEFAULT),
m_MemCacheSize(MEM_CACHE_SIZE_DEFAULT),
m_RefreshFreq(ONCE)
{
//Read all the stuff from pref here.
//If this changes to nsPref, here is all that needs to be changed.
//PRUint32 nTemp;
//PREF_GetIntPref("browser.cache.memory_cache_size",&nTemp);
//*1024
}
nsCachePref::~nsCachePref()
{
}
const PRUint32
nsCachePref::BkgSleepTime(void)
{
return BKG_THREAD_SLEEP;
}
PRUint32 nsCachePref::DiskCacheSize()
{
return m_DiskCacheSize;
}
void nsCachePref::DiskCacheSize(const PRUint32 i_Size)
{
m_DiskCacheSize = i_Size;
}
PRBool nsCachePref::DiskCacheSSL(void)
{
return m_bDiskCacheSSL;
}
void nsCachePref::DiskCacheSSL(PRBool bSet)
{
m_bDiskCacheSSL = bSet;
}
const char* nsCachePref::DiskCacheDBFilename(void)
{
return "fat.db";
}
const char* nsCachePref::DiskCacheFolder(void)
{
return 0;
}
nsCachePref* nsCachePref::GetInstance()
{
return &ThePrefs;
}
PRUint32 nsCachePref::MemCacheSize()
{
return m_MemCacheSize;
}
void nsCachePref::MemCacheSize(const PRUint32 i_Size)
{
m_MemCacheSize = i_Size;
}
PRBool nsCachePref::RevalidateInBkg(void)
{
return m_bRevalidateInBkg;
}
/*
nsrefcnt nsCachePref::AddRef(void)
{
return ++m_RefCnt;
}
nsrefcnt nsCachePref::Release(void)
{
if (--m_RefCnt == 0)
{
delete this;
return 0;
}
return m_RefCnt;
}
nsresult nsCachePref::QueryInterface(const nsIID& aIID,
void** aInstancePtrResult)
{
return NS_OK;
}
*/

View File

@@ -0,0 +1,44 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
* nsCacheTrace
*
* Gagan Saksena 02/02/98
*
*/
#include "nsCacheTrace.h"
static nsCacheTrace TheTrace;
nsCacheTrace::nsCacheTrace():m_bEnabled(PR_FALSE)
{
}
void nsCacheTrace::Enable(PRBool bEnable)
{
TheTrace.m_bEnabled = bEnable;
}
PRBool nsCacheTrace::IsEnabled(void)
{
return TheTrace.m_bEnabled;
}

View File

@@ -0,0 +1,271 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
* nsDiskModule
*
* Gagan Saksena 02/02/98
*
*/
#include "prtypes.h"
#include "prmem.h"
#include "plstr.h"
#include "prlog.h"
#include "nsDiskModule.h"
#include "nsCacheObject.h"
#include "nsCacheManager.h"
#include "mcom_db.h"
#define ENSURE_INIT \
if (!m_pDB) \
{ \
nsDiskModule* pThis = (nsDiskModule*) this; \
PRBool res = pThis->InitDB(); \
PR_ASSERT(res); \
}
//
// Constructor: nsDiskModule
//
nsDiskModule::nsDiskModule(const PRUint32 size):
nsCacheModule(size),
m_pDB(0)
{
}
nsDiskModule::~nsDiskModule()
{
if (m_pDB)
{
(*m_pDB->sync)(m_pDB, 0);
(*m_pDB->close)(m_pDB);
m_pDB = 0;
}
}
PRBool nsDiskModule::AddObject(nsCacheObject* io_pObject)
{
ENSURE_INIT;
if (!m_pDB || !io_pObject)
{
// Set some error state TODO
return PR_FALSE;
}
if (io_pObject->Address())
{
MonitorLocker ml(this);
// TODO optimize these further- make static - Gagan
DBT* key = PR_NEW(DBT);
DBT* data = PR_NEW(DBT);
io_pObject->Module(nsCacheManager::DISK);
key->data = (void*)io_pObject->Address();
/* Later on change this to include post data- io_pObject->KeyData() */
key->size = PL_strlen(io_pObject->Address());
data->data = io_pObject->Info();
data->size = io_pObject->InfoSize();
int status = (*m_pDB->put)(m_pDB, key, data, 0);
if (status == 0)
{
// if (m_Sync == EVERYTIME)
status = (*m_pDB->sync)(m_pDB, 0);
}
PR_Free(key);
PR_Free(data);
return (status == 0);
}
return PR_FALSE;
}
PRBool nsDiskModule::Contains(nsCacheObject* io_pObject) const
{
//return Contains(io_oObject->Address());
ENSURE_INIT;
if (!m_pDB || !io_pObject)
return PR_FALSE;
nsCacheObject* pTemp = GetObject(io_pObject->Address());
if (pTemp)
{
io_pObject = pTemp; /*bug */
return PR_TRUE;
}
return PR_FALSE;
}
PRBool nsDiskModule::Contains(const char* i_url) const
{
ENSURE_INIT;
if (!m_pDB || !i_url || !*i_url)
return PR_FALSE;
DBT key, data;
key.data = (void*) i_url;
key.size = PL_strlen(i_url);
int status = (*m_pDB->get)(m_pDB, &key, &data, 0);
return (status == 0);
}
void nsDiskModule::GarbageCollect(void)
{
MonitorLocker ml(this);
}
nsCacheObject* nsDiskModule::GetObject(const PRUint32 i_index) const
{
ENSURE_INIT;
if (!m_pDB)
return 0;
//todo
return 0;
}
nsCacheObject* nsDiskModule::GetObject(const char* i_url) const
{
ENSURE_INIT;
if (!m_pDB || !i_url || !*i_url)
return 0;
DBT key, data;
key.data = (void*) i_url;
key.size = PL_strlen(i_url);
if (0 == (*m_pDB->get)(m_pDB, &key, &data, 0))
{
nsCacheObject* pTemp = new nsCacheObject();
pTemp->Info(data.data);
return pTemp;
}
return 0;
}
nsStream* nsDiskModule::GetStreamFor(const nsCacheObject* i_pObject)
{
ENSURE_INIT;
return 0;
}
PRBool nsDiskModule::InitDB(void)
{
MonitorLocker ml(this);
if (m_pDB)
return PR_TRUE;
HASHINFO hash_info = {
16*1024, /* bucket size */
0, /* fill factor */
0, /* number of elements */
0, /* bytes to cache */
0, /* hash function */
0}; /* byte order */
m_pDB = dbopen(
nsCachePref::GetInstance()->DiskCacheDBFilename(),
O_RDWR | O_CREAT,
0600,
DB_HASH,
&hash_info);
if (!m_pDB)
return PR_FALSE;
/* Open and read in the number of existing entries */
m_Entries = 0;
int status;
DBT key, data;
if(!(status = (*m_pDB->seq)(m_pDB, &key, &data, R_FIRST)))
{
while(!(status = (*m_pDB->seq) (m_pDB, &key, &data, R_NEXT)))
{
/* Also validate the corresponding file here */
//TODO
m_Entries++;
}
}
if (status < 0)
return PR_FALSE;
return PR_TRUE;
}
PRBool nsDiskModule::ReduceSizeTo(const PRUint32 i_NewSize)
{
//TODO
return PR_TRUE;
}
PRBool nsDiskModule::Remove(const char* i_url)
{
ENSURE_INIT;
//TODO
// Also remove the file corresponding to this item.
return PR_FALSE;
}
PRBool nsDiskModule::Remove(const PRUint32 i_index)
{
ENSURE_INIT;
//TODO
// Also remove the file corresponding to this item.
return PR_FALSE;
}
PRBool nsDiskModule::Revalidate(void)
{
ENSURE_INIT;
//TODO - This will add a dependency on HTTP lib
return PR_FALSE;
}
void nsDiskModule::SetSize(const PRUint32 i_Size)
{
MonitorLocker ml(this);
m_Size = i_Size;
if (m_Size >0)
{
ReduceSizeTo(m_Size);
}
else
{
RemoveAll();
}
}
#undef ENSURE_INIT

View File

@@ -0,0 +1,91 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsFFEntry.h"
#include "prmem.h"
#include "prlog.h"
nsFFEntry::nsFFEntry():
m_ID(0),
m_pFirstObject(0),
m_pNextEntry(0),
m_Objects(0)
{
}
nsFFEntry::nsFFEntry(const PRUint32 i_ID):
m_ID(i_ID),
m_pFirstObject(0),
m_pNextEntry(0),
m_Objects(0)
{
}
nsFFEntry::nsFFEntry(const PRUint32 i_ID, const PRUint32 i_offset, const PRUint32 i_size):
m_ID(i_ID),
m_pFirstObject(new nsFFObject(i_ID, i_offset, i_size)),
m_pNextEntry(0),
m_Objects(1)
{
//PR_ASSERT(i_offset > nsFlatFile::HeaderSize());
}
nsFFEntry::~nsFFEntry()
{
PR_FREEIF(m_pFirstObject);
PR_FREEIF(m_pNextEntry);
}
/*
nsrefcnt nsFFEntry::AddRef(void)
{
return ++m_RefCnt;
}
nsrefcnt nsFFEntry::Release(void)
{
if (--m_RefCnt == 0)
{
delete this;
return 0;
}
return m_RefCnt;
}
nsresult nsFFEntry::QueryInterface(const nsIID& aIID,
void** aInstancePtrResult)
{
return NS_OK;
}
nsFFEntry::
*/
PRBool nsFFEntry::AddObject(const nsFFObject* i_object)
{
PR_ASSERT(i_object);
if (!i_object)
return PR_FALSE;
if (!m_pFirstObject)
{
m_pFirstObject = (nsFFObject*) i_object;
m_Objects++;
}
return m_pFirstObject->Add(i_object);
return PR_FALSE;
}

View File

@@ -0,0 +1,44 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsFFObject.h"
#include "prlog.h"
nsFFObject::nsFFObject(PRUint32 i_ID, PRUint32 i_Offset, PRUint32 i_Size):
m_ID(i_ID),
m_Offset(i_Offset),
m_Size(i_Size),
m_pNext(0)
{
}
nsFFObject::~nsFFObject()
{
}
PRBool nsFFObject::Add(const nsFFObject* i_object)
{
PR_ASSERT(i_object);
if (!i_object)
return PR_FALSE;
if (m_pNext)
return m_pNext->Add(i_object);
m_pNext = (nsFFObject*) i_object;
return PR_TRUE;
}

View File

@@ -0,0 +1,71 @@
/* -*- 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 "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#include "nsFileStream.h"
nsFileStream::nsFileStream(XP_File* i_pFile):m_pFile(i_pFile)
{
PR_ASSERT(m_pFile);
}
nsFileStream::~nsFileStream()
{
}
/*
nsrefcnt nsFileStream::AddRef(void)
{
return ++m_RefCnt;
}
nsrefcnt nsFileStream::Release(void)
{
if (--m_RefCnt == 0)
{
delete this;
return 0;
}
return m_RefCnt;
}
nsresult nsFileStream::QueryInterface(const nsIID& aIID,
void** aInstancePtrResult)
{
return NS_OK;
}
*/
PRInt32 nsFileStream::Read(void* o_Buffer, PRUint32 i_Len)
{
if (m_pFile)
{
int status = XP_FileRead(o_Buffer, i_Len, *m_pFile);
return status;
}
return 0;
}
PRInt32 nsFileStream::Write(const void* i_Buffer, PRUint32 i_Len)
{
if (m_pFile)
{
int status = XP_FileWrite(i_Buffer, i_Len, *m_pFile);
return status;
}
return 0;
}

View File

@@ -0,0 +1,153 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsFlatFile.h"
#include "plstr.h"
#include "prmem.h"
#include "memory.h"
static const PRUint32 kFLAT_FILE_VERSION = 1;
static const PRUint32 kMAGIC_NUMBER = 3739142906; // Facede de //TODO
static const char kFILL_CHAR = 'G';
nsFlatFile::nsFlatFile(const char* i_pFilename, const PRUint32 i_Size):
m_bIsValid(PR_FALSE),
m_pFD(0),
m_Size(i_Size),
m_HeaderSize(2*sizeof(PRUint32)),
m_pFilename(new char[PL_strlen(i_pFilename) + 1])
{
PL_strcpy(m_pFilename, i_pFilename);
Init();
}
nsFlatFile::~nsFlatFile()
{
delete[] m_pFilename;
if (m_pFD)
{
PR_Close(m_pFD);
m_pFD = 0;
}
}
void nsFlatFile::Init(void)
{
if (m_pFilename)
{
m_pFD = PR_Open(m_pFilename, PR_CREATE_FILE | PR_RDWR, 0600);
if (!m_pFD)
{
return;
}
PRFileInfo info;
// if the file is just being created then write magic number
// and flat file version, else verify
if (PR_SUCCESS == PR_GetOpenFileInfo(m_pFD, &info))
{
PRInt32 status;
if (info.size > 0)
{
char* buf = new char[m_HeaderSize];
//verify
status = PR_Read(m_pFD, buf, m_HeaderSize);
if (status > 0)
{
char* cur_ptr = buf;
PRUint32 test;
COPY_INT32(&test, cur_ptr);
if (test != kMAGIC_NUMBER)
{
PR_Close(m_pFD);
m_pFD = 0;
//PR_ASSERT(!"Bad flat file!");
return;
}
cur_ptr += sizeof(PRUint32);
COPY_INT32(&test, cur_ptr);
if (test != kFLAT_FILE_VERSION)
{
PR_Close(m_pFD);
m_pFD = 0;
//PR_ASSERT(!"Bad version of flat file format!");
return;
}
//Everything was as expected so
m_bIsValid = PR_TRUE;
}
delete[] buf;
}
else
{
//write out
char* buf = new char[m_HeaderSize];
PRUint32 test = m_HeaderSize;
char* cur_ptr = buf;
COPY_INT32((void*) cur_ptr, &kMAGIC_NUMBER);
cur_ptr += sizeof(PRUint32);
COPY_INT32((void*) cur_ptr, &kFLAT_FILE_VERSION);
status = PR_Write(m_pFD, buf, m_HeaderSize);
delete[] buf;
PRBool bFillChar = PR_FALSE;
if (bFillChar)
{
buf = new char[kPAGE_SIZE];
for (int i = 0; i< kPAGE_SIZE; ++i)
buf[i] = kFILL_CHAR;
int j = (int)((m_Size - m_HeaderSize) / kPAGE_SIZE);
int k;
for (k = j; k > 0; --k)
{
status = PR_Write(m_pFD, (void*) buf, kPAGE_SIZE);
}
delete[] buf;
int remaining = (m_Size-m_HeaderSize) % kPAGE_SIZE;
for (k = remaining; k>0; --k)
{
status = PR_Write(m_pFD, (void*) &kFILL_CHAR, 1);
}
}
}
}
}
}
/*
nsrefcnt nsFlatFile::AddRef(void)
{
return ++m_RefCnt;
}
nsrefcnt nsFlatFile::Release(void)
{
if (--m_RefCnt == 0)
{
delete this;
return 0;
}
return m_RefCnt;
}
nsresult nsFlatFile::QueryInterface(const nsIID& aIID,
void** aInstancePtrResult)
{
return NS_OK;
}
*/

142
mozilla/network/cache/nu/src/nsHash.cpp vendored 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.
*/
#include "prmem.h"
#include "nsHash.h"
//
// Key operations
//
static PR_CALLBACK PLHashNumber _hashValue(const void *key)
{
return ((const nsHashKey *) key)->HashValue();
}
static PR_CALLBACK PRIntn _hashKeyCompare(const void *key1, const void *key2) {
return ((const nsHashKey *) key1)->Equals((const nsHashKey *) key2);
}
static PR_CALLBACK PRIntn _hashValueCompare(const void *value1,
const void *value2) {
// We're not going to make any assumptions about value equality
return 0;
}
//
// Memory callbacks
//
static PR_CALLBACK void *_hashAllocTable(void *pool, PRSize size) {
return PR_MALLOC(size);
}
static PR_CALLBACK void _hashFreeTable(void *pool, void *item) {
PR_DELETE(item);
}
static PR_CALLBACK PLHashEntry *_hashAllocEntry(void *pool, const void *key) {
return PR_NEW(PLHashEntry);
}
static PR_CALLBACK void _hashFreeEntry(void *pool, PLHashEntry *entry,
PRUintn flag) {
if (flag == HT_FREE_ENTRY) {
delete (nsHashKey *) (entry->key);
PR_DELETE(entry);
}
}
static PLHashAllocOps _hashAllocOps = {
_hashAllocTable, _hashFreeTable,
_hashAllocEntry, _hashFreeEntry
};
//
// Enumerator callback
//
static PR_CALLBACK PRIntn _hashEnumerate(PLHashEntry *he, PRIntn i, void *arg)
{
return ((nsHashEnumFunc) arg)((nsHashKey *) he->key, he->value) ?
HT_ENUMERATE_NEXT :
HT_ENUMERATE_STOP;
}
//
// HashKey
//
nsHashKey::nsHashKey(void)
{
}
nsHashKey::~nsHashKey(void)
{
}
nsHash::nsHash(PRUint32 aInitSize) {
hashtable = PL_NewHashTable(aInitSize,
_hashValue,
_hashKeyCompare,
_hashValueCompare,
&_hashAllocOps,
NULL);
}
nsHash::~nsHash() {
PL_HashTableDestroy(hashtable);
}
void *nsHash::Put(nsHashKey *aKey, void *aData) {
void *res = NULL;
PLHashNumber hash = aKey->HashValue();
PLHashEntry *he;
PLHashEntry **hep = PL_HashTableRawLookup(hashtable, hash, (void *) aKey);
if ((he = *hep) != NULL) {
res = he->value;
he->value = aData;
} else {
PL_HashTableRawAdd(hashtable, hep, hash,
(void *) aKey->Clone(), aData);
}
return res;
}
void *nsHash::Get(nsHashKey *aKey) {
return PL_HashTableLookup(hashtable, (void *) aKey);
}
void *nsHash::Remove(nsHashKey *aKey) {
PLHashNumber hash = aKey->HashValue();
PLHashEntry *he;
PLHashEntry **hep = PL_HashTableRawLookup(hashtable, hash, (void *) aKey);
void *res = NULL;
if ((he = *hep) != NULL) {
res = he->value;
PL_HashTableRawRemove(hashtable, hep, he);
}
return res;
}
void nsHash::Enumerate(nsHashEnumFunc aEnumFunc) {
PL_HashTableEnumerateEntries(hashtable, _hashEnumerate, aEnumFunc);
}

View File

@@ -0,0 +1,44 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
* nsMemCacheObject
*
* Gagan Saksena 04/22/98
*
*/
#include "prtypes.h"
#include "nsMemCacheObject.h"
nsMemCacheObject::~nsMemCacheObject()
{
if (m_pNextObject)
{
delete m_pNextObject;
m_pNextObject = 0;
}
if (m_pObject)
{
delete m_pObject;
m_pObject = 0;
}
// Free the void* if allocated - TODO
}

View File

@@ -0,0 +1,241 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "prtypes.h"
#include "plstr.h"
#include "prlog.h"
#include "nsMemModule.h"
#include "nsMemCacheObject.h"
#include "nsCacheManager.h"
/*
* nsMemModule
*
* Gagan Saksena 02/02/98
*
*/
//NS_DEFINE_IID(kMemModuleIID, NS_MEMMODULE_IID);
nsMemModule::nsMemModule(const PRUint32 size):
m_pFirstObject(0),
nsCacheModule(size)
{
SetSize(size);
}
nsMemModule::~nsMemModule()
{
if (m_pFirstObject) {
delete m_pFirstObject;
m_pFirstObject = 0;
}
}
PRBool nsMemModule::AddObject(nsCacheObject* io_pObject)
{
#if 0
if (io_pObject)
{
m_ht.Put(io_pObject->Address(), io_pObject);
}
return PR_FALSE;
#endif
if (io_pObject)
{
MonitorLocker ml(this);
if (m_pFirstObject)
{
LastObject()->Next(new nsMemCacheObject(io_pObject));
}
else
{
m_pFirstObject = new nsMemCacheObject(io_pObject);
}
m_Entries++;
io_pObject->Module(nsCacheManager::MEM);
return PR_TRUE;
}
return PR_FALSE;
}
PRBool nsMemModule::Contains(const char* i_url) const
{
MonitorLocker ml((nsMonitorable*)this);
if (m_pFirstObject && i_url && *i_url)
{
nsMemCacheObject* pObj = m_pFirstObject;
PRUint32 inlen = PL_strlen(i_url);
do
{
if (0 == PL_strncasecmp(pObj->ThisObject()->Address(), i_url, inlen))
return PR_TRUE;
pObj = pObj->Next();
}
while (pObj);
}
return PR_FALSE;
}
PRBool nsMemModule::Contains(nsCacheObject* i_pObject) const
{
MonitorLocker ml((nsMonitorable*)this);
if (i_pObject && *i_pObject->Address())
{
return this->Contains(i_pObject->Address());
}
return 0;
}
void nsMemModule::GarbageCollect(void)
{
MonitorLocker ml(this);
if (m_Entries > 0)
{
nsEnumeration* pEnum = Enumeration();
PRUint32 index = 0;
while (pEnum->HasMoreElements())
{
nsCacheObject* pObj = (nsCacheObject*) pEnum->NextElement();
PR_ASSERT(pObj);
if (pObj->IsExpired())
{
PRBool status = Remove(index);
PR_ASSERT(status == PR_TRUE);
}
++index;
}
}
}
nsCacheObject* nsMemModule::GetObject(const PRUint32 i_index) const
{
MonitorLocker ml((nsMonitorable*)this);
nsMemCacheObject* pNth = 0;
if (m_pFirstObject)
{
PRUint32 index = 0;
pNth = m_pFirstObject;
while (pNth->Next() && (index++ != i_index ))
{
pNth = pNth->Next();
}
}
return pNth->ThisObject();
}
nsCacheObject* nsMemModule::GetObject(const char* i_url) const
{
MonitorLocker ml((nsMonitorable*)this);
if (m_pFirstObject && i_url && *i_url)
{
nsMemCacheObject* pObj = m_pFirstObject;
int inlen = PL_strlen(i_url);
do
{
if (0 == PL_strncasecmp(pObj->ThisObject()->Address(), i_url, inlen))
return pObj->ThisObject();
pObj = pObj->Next();
}
while (pObj);
}
return 0;
}
nsStream* nsMemModule::GetStreamFor(const nsCacheObject* i_pObject)
{
MonitorLocker ml(this);
return 0;
}
nsMemCacheObject* nsMemModule::LastObject(void) const
{
MonitorLocker ml((nsMonitorable*)this);
nsMemCacheObject* pLast = 0;
if (m_pFirstObject)
{
pLast = m_pFirstObject;
while (pLast->Next())
pLast = pLast->Next();
}
return pLast;
}
PRBool nsMemModule::ReduceSizeTo(const PRUint32 i_NewSize)
{
//TODO
return PR_TRUE;
}
PRBool nsMemModule::Remove(const char* i_url)
{
//TODO
return PR_FALSE;
}
PRBool nsMemModule::Remove(const PRUint32 i_index)
{
//TODO
return PR_FALSE;
}
/*
NS_IMETHOD nsMemModule::QueryInterface(const nsIID& aIID, void** aInstancePtr)
{
}
NS_IMETHOD_(nsrefcnt) nsMemModule::AddRef(void)
{
}
NS_IMETHOD_(nsrefcnt) nsMemModule::Release(void)
{
}
*/
/*
PRUint32 nsMemModule::nsMemKey::HashValue()
{
return 0;
}
PRBool nsMemModule::nsMemKey::Equals(nsHashKey *aKey)
{
return PR_FALSE;
}
nsHashKey* nsMemModule::nsMemKey::Clone()
{
return new nsMemModule::nsMemKey();
}
nsMemModule::nsMemKey::neMemKey()
{
}
*/

View File

@@ -0,0 +1,59 @@
/* -*- 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 "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#include "nsMemStream.h"
nsMemStream::nsMemStream()
{
}
nsMemStream::~nsMemStream()
{
}
/*
nsrefcnt nsMemStream::AddRef(void)
{
return ++m_RefCnt;
}
nsrefcnt nsMemStream::Release(void)
{
if (--m_RefCnt == 0)
{
delete this;
return 0;
}
return m_RefCnt;
}
nsresult nsMemStream::QueryInterface(const nsIID& aIID,
void** aInstancePtrResult)
{
return NS_OK;
}
*/
PRInt32 nsMemStream::Read(void* o_Buffer, PRUint32 i_Len)
{
return 0;
}
PRInt32 nsMemStream::Write(const void* i_Buffer, PRUint32 i_Len)
{
return 0;
}

262
mozilla/network/cache/nu/src/nsTOC.cpp vendored Normal file
View File

@@ -0,0 +1,262 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsTOC.h"
#include "plstr.h"
#include "memory.h"
#include "prlog.h"
static const PRUint32 kTOC_FLAT_FILE_VERSION = 1;
static const PRUint32 kTOC_MAGIC_NUMBER = 19712809;
static const PRUint32 kTOC_HEADER_SIZE = 2* sizeof(PRUint32);
//TODO change this to a memory mapped file!
nsTOC::nsTOC(const char* i_pFilename, nsFlatFile* i_pFlatFile):
m_pFilename( new char[PL_strlen(i_pFilename) + 1]),
m_pFD(0),
m_bIsValid(PR_FALSE),
m_pFlatFile(i_pFlatFile),
m_Entries(1)
{
PL_strcpy(m_pFilename, i_pFilename);
Init();
}
nsTOC::~nsTOC()
{
delete[] m_pFilename;
if (m_pFD)
{
PR_Close(m_pFD);
m_pFD = 0;
}
}
/*
nsrefcnt nsTOC::AddRef(void)
{
return ++m_RefCnt;
}
nsrefcnt nsTOC::Release(void)
{
if (--m_RefCnt == 0)
{
delete this;
return 0;
}
return m_RefCnt;
}
nsresult nsTOC::QueryInterface(const nsIID& aIID,
void** aInstancePtrResult)
{
return NS_OK;
}
*/
void nsTOC::Init(void)
{
if (m_pFilename)
{
m_pFD = PR_Open(m_pFilename, PR_CREATE_FILE | PR_RDWR, 0600);
if (!m_pFD)
{
return;
}
PRFileInfo info;
// if the file is just being created then write magic number
// and flat file version, else verify
if (PR_SUCCESS == PR_GetOpenFileInfo(m_pFD, &info))
{
PRInt32 status;
if (info.size > 0)
{
char buf[kTOC_HEADER_SIZE];
//verify
status = PR_Read(m_pFD, &buf, kTOC_HEADER_SIZE);
if (status > 0)
{
char* cur_ptr = &buf[0];
PRUint32 test;
COPY_INT32(&test, cur_ptr);
if (test != kTOC_MAGIC_NUMBER)
{
PR_Close(m_pFD);
m_pFD = 0;
//PR_ASSERT(!"Bad TOC file!");
return;
}
cur_ptr += sizeof(PRUint32);
COPY_INT32(&test, cur_ptr);
if (test != kTOC_FLAT_FILE_VERSION)
{
PR_Close(m_pFD);
m_pFD = 0;
//PR_ASSERT(!"Bad version of TOC file!");
return;
}
// Number of entries in the TOC
status = PR_Read(m_pFD, &buf, sizeof(PRUint32));
if (status > 0)
{
cur_ptr = &buf[0];
COPY_INT32(&m_Entries, cur_ptr);
}
//Read in the list of entries
nsFFEntry* pCurrent;
Serialize(pCurrent, PR_TRUE);
//There has got to be a free entry.
PR_ASSERT(pCurrent /*&& pCurrent->IsValid() TODO*/);
m_pContents = pCurrent;
PRUint32 count = 1; //Definitely one!
Serialize(pCurrent, PR_TRUE);
while (pCurrent)
{
count++;
m_pContents->AddEntry(pCurrent);
Serialize(pCurrent, PR_TRUE);
}
PR_ASSERT(count == m_Entries);
//Everything was as expected so
m_bIsValid = PR_TRUE;
}
}
else
{
//write out
char* buf = new char[kTOC_HEADER_SIZE];
char* cur_ptr = buf;
COPY_INT32((void*) cur_ptr, &kTOC_MAGIC_NUMBER);
cur_ptr += sizeof(PRUint32);
COPY_INT32((void*) cur_ptr, &kTOC_FLAT_FILE_VERSION);
status = PR_Write(m_pFD, buf, kTOC_HEADER_SIZE);
// Number of entries in the TOC
COPY_INT32((void*)buf, &m_Entries);
status = PR_Write(m_pFD, buf, sizeof(PRUint32));
delete[] buf;
//Since the TOC is being created afresh, reset the flat file with everything marked as
//free.
m_pContents = new nsFFEntry(
0,
m_pFlatFile->HeaderSize(),
m_pFlatFile->Size()-m_pFlatFile->HeaderSize());
//Serialize the only entry-
Serialize(m_pContents);
m_bIsValid = PR_TRUE;
}
}
}
}
nsFFEntry* nsTOC::AddEntry(PRUint32 i_Size)
{
if (i_Size > FreeEntry()->Size())
{
//Garbage collect
}
nsFFEntry* pEntry = new nsFFEntry(
NextID(),
FreeEntry()->FirstObject()->Offset(),
i_Size);
return pEntry;
}
PRBool nsTOC::Serialize(nsFFEntry* io_Entry, PRBool bRead )
{
PR_ASSERT(m_pFD);
if (bRead)
{
io_Entry = new nsFFEntry();
if (!io_Entry)
return PR_FALSE;
char* buf = new char[sizeof(PRUint32)];
PRUint32 temp, objects, size;
//Read ID
PR_Read(m_pFD, buf, sizeof(PRUint32));
COPY_INT32(&temp, buf);
io_Entry->ID(temp);
//Read number of objects
PR_Read(m_pFD, buf, sizeof(PRUint32));
COPY_INT32(&objects, buf);
//Read objects
for (int i= objects; i>0; --i)
{
PR_Read(m_pFD, buf, sizeof(PRUint32));
COPY_INT32(&temp, buf);
PR_Read(m_pFD, buf, sizeof(PRUint32));
COPY_INT32(&size, buf);
io_Entry->AddObject(new nsFFObject(io_Entry->ID(), temp, size));
}
delete[] buf;
PR_ASSERT(io_Entry->Objects() == objects);
if (io_Entry->Objects() != objects)
return PR_FALSE;
return PR_TRUE;
}
else
{
PR_ASSERT(io_Entry);
if (!io_Entry)
return PR_FALSE;
//TODO speed this up by increasing the buffer size to write out
//more than one int at a time!
char* buf = new char[sizeof(PRUint32)];
PRUint32 temp;
//Write ID
temp = io_Entry->ID();
COPY_INT32((void*) buf, &temp);
PR_Write(m_pFD, buf, sizeof(PRUint32));
//Write number of Objects
temp = io_Entry->Objects();
COPY_INT32((void*) buf, &temp);
PR_Write(m_pFD, buf, sizeof(PRUint32));
//Write Objects
if (temp > 0)
{
nsFFObject* current = io_Entry->FirstObject();
while (current)
{
PR_ASSERT(current->ID() == io_Entry->ID());
//Offset
temp = current->Offset();
COPY_INT32((void*) buf, &temp);
PR_Write(m_pFD, buf, sizeof(PRUint32));
//size
temp = current->Size();
COPY_INT32((void*) buf, &temp);
PR_Write(m_pFD, buf, sizeof(PRUint32));
current = current->Next();
}
}
delete[] buf;
return PR_TRUE;
}
return PR_FALSE;
}

View File

@@ -0,0 +1,104 @@
// CacheTreeView.cpp : implementation file
//
#include "stdafx.h"
#include "cb.h"
#include "CacheTreeView.h"
#include "cbdoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCacheTreeView
IMPLEMENT_DYNCREATE(CCacheTreeView, CTreeView)
CCacheTreeView::CCacheTreeView()
{
m_pImgList = new CImageList();
}
CCacheTreeView::~CCacheTreeView()
{
delete m_pImgList;
}
BEGIN_MESSAGE_MAP(CCacheTreeView, CTreeView)
//{{AFX_MSG_MAP(CCacheTreeView)
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
int CCacheTreeView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
lpCreateStruct->style = TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT;
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
GetDocument()->m_pTreeView = this;
// Create the Image List
m_pImgList->Create(IDB_CACHEICONS,16,0,RGB(255,0,255));
m_pImgList->SetBkColor(GetSysColor(COLOR_WINDOW));
// Attach image list to Tree
GetTreeCtrl().SetImageList(m_pImgList, TVSIL_NORMAL);
GetTreeCtrl().SetIndent(10);
return 0;
}
void CCacheTreeView::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
}
#ifdef _DEBUG
void CCacheTreeView::AssertValid() const
{
CTreeView::AssertValid();
}
void CCacheTreeView::Dump(CDumpContext& dc) const
{
CTreeView::Dump(dc);
}
CCbDoc* CCacheTreeView::GetDocument()
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCbDoc)));
return (CCbDoc*)m_pDocument;
}
#endif //_DEBUG
void CCacheTreeView::Populate() {
AssertValid();
GetTreeCtrl().DeleteAllItems();
TV_INSERTSTRUCT insertStruct;
TV_ITEM itemStruct;
insertStruct.hParent = TVI_ROOT;
insertStruct.hInsertAfter = TVI_FIRST;
insertStruct.item = itemStruct;
HTREEITEM hti = GetTreeCtrl().InsertItem(&insertStruct);
GetTreeCtrl().SetItemText(hti, "Your Cache");
insertStruct.hParent = hti;
insertStruct.hInsertAfter = hti;
insertStruct.item = itemStruct;
HTREEITEM htiDisk = GetTreeCtrl().InsertItem(&insertStruct);
GetTreeCtrl().SetItemText(htiDisk, "Disk");
HTREEITEM htiMem = GetTreeCtrl().InsertItem(&insertStruct);
GetTreeCtrl().SetItemText(htiMem, "Memory");
}

View File

@@ -0,0 +1,54 @@
// CacheTreeView.h : header file
//
#ifndef _CacheTreeView_h_
#define _CacheTreeView_h_
#include <afxcview.h>
class CImageList;
class CCbDoc;
class CCacheTreeView : public CTreeView
{
protected:
CCacheTreeView(); // protected constructor used by dynamic creation
DECLARE_DYNCREATE(CCacheTreeView)
// Attributes
public:
CCbDoc* GetDocument();
void Populate();
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCacheTreeView)
protected:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
//}}AFX_VIRTUAL
protected:
virtual ~CCacheTreeView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// Generated message map functions
protected:
//{{AFX_MSG(CCacheTreeView)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
CImageList* m_pImgList;
};
#ifndef _DEBUG // debug version in AnimalView.cpp
inline CCbDoc* CCacheTreeView::GetDocument()
{ return (CCbDoc*)m_pDocument; }
#endif
#endif

View File

@@ -0,0 +1,128 @@
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "cb.h"
#include "MainFrm.h"
#include "CacheTreeView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
}
CMainFrame::~CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.Create(this) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
return 0;
}
BOOL CMainFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
CCreateContext* pContext)
{
// create a splitter with 1 row, 2 columns
if (!m_wndSplitter.CreateStatic(this, 1, 2))
{
TRACE0("Failed to CreateStaticSplitter\n");
return FALSE;
}
// add the first splitter pane - the default view in column 0
if (!m_wndSplitter.CreateView(0, 0,
RUNTIME_CLASS(CCacheTreeView), CSize(250, 50), pContext))
{
TRACE0("Failed to create first pane\n");
return FALSE;
}
// add the second splitter pane - an input view in column 1
if (!m_wndSplitter.CreateView(0, 1, pContext->m_pNewViewClass, CSize(0, 0), pContext))
{
TRACE0("Failed to create second pane\n");
return FALSE;
}
// activate the tree view
SetActiveView((CView*)m_wndSplitter.GetPane(0,1));
return TRUE;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
return CFrameWnd::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers

View File

@@ -0,0 +1,48 @@
// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////
class CMainFrame : public CFrameWnd
{
protected: // create from serialization only
CMainFrame();
DECLARE_DYNCREATE(CMainFrame)
// Attributes
protected:
CSplitterWnd m_wndSplitter;
public:
void Status(const char* mesg);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
public:
virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected: // control bar embedded members
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;
// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
inline void CMainFrame::Status(const char* mesg) {
m_wndStatusBar.SetPaneText(0, mesg);
}
/////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,6 @@
// stdafx.cpp : source file that includes just the standard includes
// cb.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

View File

@@ -0,0 +1,16 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT

140
mozilla/network/cache/nu/tests/cb/cb.cpp vendored Normal file
View File

@@ -0,0 +1,140 @@
// cb.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "cb.h"
#include "MainFrm.h"
#include "cbDoc.h"
#include "cbView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCbApp
BEGIN_MESSAGE_MAP(CCbApp, CWinApp)
//{{AFX_MSG_MAP(CCbApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCbApp construction
CCbApp::CCbApp()
{
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CCbApp object
CCbApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CCbApp initialization
BOOL CCbApp::InitInstance()
{
// Standard initialization
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
LoadStdProfileSettings(0); // Load standard INI file options (including MRU)
// Register document templates
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CCbDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CCbView));
AddDocTemplate(pDocTemplate);
// Enable DDE Execute open
EnableShellOpen();
RegisterShellFileTypes(TRUE);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// Enable drag/drop open
m_pMainWnd->DragAcceptFiles();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CCbApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CCbApp commands

36
mozilla/network/cache/nu/tests/cb/cb.h vendored Normal file
View File

@@ -0,0 +1,36 @@
// cb.h : main header file for the CB application
//
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
/////////////////////////////////////////////////////////////////////////////
// CCbApp:
// See cb.cpp for the implementation of this class
//
class CCbApp : public CWinApp
{
public:
CCbApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCbApp)
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CCbApp)
afx_msg void OnAppAbout();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////

524
mozilla/network/cache/nu/tests/cb/cb.mak vendored Normal file
View File

@@ -0,0 +1,524 @@
# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
!IF "$(CFG)" == ""
CFG=cb - Win32 Debug
!MESSAGE No configuration specified. Defaulting to cb - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "cb - Win32 Release" && "$(CFG)" != "cb - Win32 Debug"
!MESSAGE Invalid configuration "$(CFG)" specified.
!MESSAGE You can specify a configuration when running NMAKE on this makefile
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "cb.mak" CFG="cb - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "cb - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "cb - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE
!ERROR An invalid configuration is specified.
!ENDIF
!IF "$(OS)" == "Windows_NT"
NULL=
!ELSE
NULL=nul
!ENDIF
################################################################################
# Begin Project
# PROP Target_Last_Scanned "cb - Win32 Debug"
CPP=cl.exe
RSC=rc.exe
MTL=mktyplib.exe
!IF "$(CFG)" == "cb - Win32 Release"
# PROP BASE Use_MFC 6
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 6
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
OUTDIR=.\Release
INTDIR=.\Release
ALL : "$(OUTDIR)\cb.exe"
CLEAN :
-@erase "$(INTDIR)\CacheTreeView.obj"
-@erase "$(INTDIR)\cb.obj"
-@erase "$(INTDIR)\cb.pch"
-@erase "$(INTDIR)\cb.res"
-@erase "$(INTDIR)\cbDoc.obj"
-@erase "$(INTDIR)\cbView.obj"
-@erase "$(INTDIR)\MainFrm.obj"
-@erase "$(INTDIR)\StdAfx.obj"
-@erase "$(OUTDIR)\cb.exe"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\..\..\..\dist\public\cache" /I "..\..\..\..\..\dist\win32_d.obj\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c
CPP_PROJ=/nologo /MD /W3 /GX /O2 /I "..\..\..\..\..\dist\public\cache" /I\
"..\..\..\..\..\dist\win32_d.obj\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS"\
/D "_AFXDLL" /D "_MBCS" /Fp"$(INTDIR)/cb.pch" /Yu"stdafx.h" /Fo"$(INTDIR)/" /c
CPP_OBJS=.\Release/
CPP_SBRS=.\.
# ADD BASE MTL /nologo /D "NDEBUG" /win32
# ADD MTL /nologo /D "NDEBUG" /win32
MTL_PROJ=/nologo /D "NDEBUG" /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
RSC_PROJ=/l 0x409 /fo"$(INTDIR)/cb.res" /d "NDEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
BSC32_FLAGS=/nologo /o"$(OUTDIR)/cb.bsc"
BSC32_SBRS= \
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
# ADD LINK32 /nologo /subsystem:windows /machine:I386
LINK32_FLAGS=/nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)/cb.pdb"\
/machine:I386 /out:"$(OUTDIR)/cb.exe"
LINK32_OBJS= \
"$(INTDIR)\CacheTreeView.obj" \
"$(INTDIR)\cb.obj" \
"$(INTDIR)\cb.res" \
"$(INTDIR)\cbDoc.obj" \
"$(INTDIR)\cbView.obj" \
"$(INTDIR)\MainFrm.obj" \
"$(INTDIR)\StdAfx.obj" \
"..\..\..\..\..\dist\WIN32_D.OBJ\lib\cachelib.lib"
"$(OUTDIR)\cb.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "cb - Win32 Debug"
# PROP BASE Use_MFC 6
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 6
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
OUTDIR=.\Debug
INTDIR=.\Debug
ALL : "$(OUTDIR)\cb.exe" "$(OUTDIR)\cb.bsc"
CLEAN :
-@erase "$(INTDIR)\CacheTreeView.obj"
-@erase "$(INTDIR)\CacheTreeView.sbr"
-@erase "$(INTDIR)\cb.obj"
-@erase "$(INTDIR)\cb.pch"
-@erase "$(INTDIR)\cb.res"
-@erase "$(INTDIR)\cb.sbr"
-@erase "$(INTDIR)\cbDoc.obj"
-@erase "$(INTDIR)\cbDoc.sbr"
-@erase "$(INTDIR)\cbView.obj"
-@erase "$(INTDIR)\cbView.sbr"
-@erase "$(INTDIR)\MainFrm.obj"
-@erase "$(INTDIR)\MainFrm.sbr"
-@erase "$(INTDIR)\StdAfx.obj"
-@erase "$(INTDIR)\StdAfx.sbr"
-@erase "$(INTDIR)\vc40.idb"
-@erase "$(INTDIR)\vc40.pdb"
-@erase "$(OUTDIR)\cb.bsc"
-@erase "$(OUTDIR)\cb.exe"
-@erase "$(OUTDIR)\cb.ilk"
-@erase "$(OUTDIR)\cb.pdb"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\..\..\dist\public\cache" /I "..\..\..\..\..\dist\win32_d.obj\include" /I "..\..\..\..\..\dist\public\dbm" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /Yu"stdafx.h" /V"ERBOSE:lib" /c
CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\..\..\dist\public\cache"\
/I "..\..\..\..\..\dist\win32_d.obj\include" /I\
"..\..\..\..\..\dist\public\dbm" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D\
"_AFXDLL" /D "_MBCS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/cb.pch" /Yu"stdafx.h"\
/Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /V"ERBOSE:lib" /c
CPP_OBJS=.\Debug/
CPP_SBRS=.\Debug/
# ADD BASE MTL /nologo /D "_DEBUG" /win32
# ADD MTL /nologo /D "_DEBUG" /win32
MTL_PROJ=/nologo /D "_DEBUG" /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
# ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
RSC_PROJ=/l 0x409 /fo"$(INTDIR)/cb.res" /d "_DEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
BSC32_FLAGS=/nologo /o"$(OUTDIR)/cb.bsc"
BSC32_SBRS= \
"$(INTDIR)\CacheTreeView.sbr" \
"$(INTDIR)\cb.sbr" \
"$(INTDIR)\cbDoc.sbr" \
"$(INTDIR)\cbView.sbr" \
"$(INTDIR)\MainFrm.sbr" \
"$(INTDIR)\StdAfx.sbr"
"$(OUTDIR)\cb.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
$(BSC32) @<<
$(BSC32_FLAGS) $(BSC32_SBRS)
<<
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386
# ADD LINK32 ..\..\..\..\..\dist\win32_d.obj\lib\libnspr21.lib ..\..\..\..\..\dist\win32_d.obj\lib\libplc21.lib ..\..\..\..\..\dist\win32_d.obj\lib\dbm32.lib ..\..\..\..\..\dist\win32_d.obj\lib\cachelib.lib /nologo /subsystem:windows /debug /machine:I386
# SUBTRACT LINK32 /nodefaultlib
LINK32_FLAGS=..\..\..\..\..\dist\win32_d.obj\lib\libnspr21.lib\
..\..\..\..\..\dist\win32_d.obj\lib\libplc21.lib\
..\..\..\..\..\dist\win32_d.obj\lib\dbm32.lib\
..\..\..\..\..\dist\win32_d.obj\lib\cachelib.lib /nologo /subsystem:windows\
/incremental:yes /pdb:"$(OUTDIR)/cb.pdb" /debug /machine:I386\
/out:"$(OUTDIR)/cb.exe"
LINK32_OBJS= \
"$(INTDIR)\CacheTreeView.obj" \
"$(INTDIR)\cb.obj" \
"$(INTDIR)\cb.res" \
"$(INTDIR)\cbDoc.obj" \
"$(INTDIR)\cbView.obj" \
"$(INTDIR)\MainFrm.obj" \
"$(INTDIR)\StdAfx.obj" \
"..\..\..\..\..\dist\WIN32_D.OBJ\lib\cachelib.lib"
"$(OUTDIR)\cb.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
.c{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cpp{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cxx{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.c{$(CPP_SBRS)}.sbr:
$(CPP) $(CPP_PROJ) $<
.cpp{$(CPP_SBRS)}.sbr:
$(CPP) $(CPP_PROJ) $<
.cxx{$(CPP_SBRS)}.sbr:
$(CPP) $(CPP_PROJ) $<
################################################################################
# Begin Target
# Name "cb - Win32 Release"
# Name "cb - Win32 Debug"
!IF "$(CFG)" == "cb - Win32 Release"
!ELSEIF "$(CFG)" == "cb - Win32 Debug"
!ENDIF
################################################################################
# Begin Source File
SOURCE=.\cb.cpp
DEP_CPP_CB_CP=\
".\cb.h"\
".\cbDoc.h"\
".\cbView.h"\
".\MainFrm.h"\
".\StdAfx.h"\
!IF "$(CFG)" == "cb - Win32 Release"
"$(INTDIR)\cb.obj" : $(SOURCE) $(DEP_CPP_CB_CP) "$(INTDIR)" "$(INTDIR)\cb.pch"
!ELSEIF "$(CFG)" == "cb - Win32 Debug"
"$(INTDIR)\cb.obj" : $(SOURCE) $(DEP_CPP_CB_CP) "$(INTDIR)" "$(INTDIR)\cb.pch"
"$(INTDIR)\cb.sbr" : $(SOURCE) $(DEP_CPP_CB_CP) "$(INTDIR)" "$(INTDIR)\cb.pch"
!ENDIF
# End Source File
################################################################################
# Begin Source File
SOURCE=.\StdAfx.cpp
DEP_CPP_STDAF=\
".\StdAfx.h"\
!IF "$(CFG)" == "cb - Win32 Release"
# ADD CPP /Yc"stdafx.h"
BuildCmds= \
$(CPP) /nologo /MD /W3 /GX /O2 /I "..\..\..\..\..\dist\public\cache" /I\
"..\..\..\..\..\dist\win32_d.obj\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS"\
/D "_AFXDLL" /D "_MBCS" /Fp"$(INTDIR)/cb.pch" /Yc"stdafx.h" /Fo"$(INTDIR)/" /c\
$(SOURCE) \
"$(INTDIR)\StdAfx.obj" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
$(BuildCmds)
"$(INTDIR)\cb.pch" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
$(BuildCmds)
!ELSEIF "$(CFG)" == "cb - Win32 Debug"
# ADD CPP /Yc"stdafx.h"
BuildCmds= \
$(CPP) /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\..\..\dist\public\cache"\
/I "..\..\..\..\..\dist\win32_d.obj\include" /I\
"..\..\..\..\..\dist\public\dbm" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D\
"_AFXDLL" /D "_MBCS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/cb.pch" /Yc"stdafx.h"\
/Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /V"ERBOSE:lib" /c $(SOURCE) \
"$(INTDIR)\StdAfx.obj" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
$(BuildCmds)
"$(INTDIR)\StdAfx.sbr" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
$(BuildCmds)
"$(INTDIR)\cb.pch" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
$(BuildCmds)
!ENDIF
# End Source File
################################################################################
# Begin Source File
SOURCE=.\MainFrm.cpp
DEP_CPP_MAINF=\
".\CacheTreeView.h"\
".\cb.h"\
".\MainFrm.h"\
".\StdAfx.h"\
!IF "$(CFG)" == "cb - Win32 Release"
"$(INTDIR)\MainFrm.obj" : $(SOURCE) $(DEP_CPP_MAINF) "$(INTDIR)"\
"$(INTDIR)\cb.pch"
!ELSEIF "$(CFG)" == "cb - Win32 Debug"
"$(INTDIR)\MainFrm.obj" : $(SOURCE) $(DEP_CPP_MAINF) "$(INTDIR)"\
"$(INTDIR)\cb.pch"
"$(INTDIR)\MainFrm.sbr" : $(SOURCE) $(DEP_CPP_MAINF) "$(INTDIR)"\
"$(INTDIR)\cb.pch"
!ENDIF
# End Source File
################################################################################
# Begin Source File
SOURCE=.\cbDoc.cpp
DEP_CPP_CBDOC=\
".\CacheTreeView.h"\
".\cb.h"\
".\cbDoc.h"\
".\StdAfx.h"\
!IF "$(CFG)" == "cb - Win32 Release"
"$(INTDIR)\cbDoc.obj" : $(SOURCE) $(DEP_CPP_CBDOC) "$(INTDIR)"\
"$(INTDIR)\cb.pch"
!ELSEIF "$(CFG)" == "cb - Win32 Debug"
"$(INTDIR)\cbDoc.obj" : $(SOURCE) $(DEP_CPP_CBDOC) "$(INTDIR)"\
"$(INTDIR)\cb.pch"
"$(INTDIR)\cbDoc.sbr" : $(SOURCE) $(DEP_CPP_CBDOC) "$(INTDIR)"\
"$(INTDIR)\cb.pch"
!ENDIF
# End Source File
################################################################################
# Begin Source File
SOURCE=.\cbView.cpp
!IF "$(CFG)" == "cb - Win32 Release"
DEP_CPP_CBVIE=\
"..\..\..\..\..\dist\public\cache\nsBkgThread.h"\
"..\..\..\..\..\dist\public\cache\nsCacheBkgThd.h"\
"..\..\..\..\..\dist\public\cache\nsCacheManager.h"\
"..\..\..\..\..\dist\public\cache\nsCacheModule.h"\
"..\..\..\..\..\dist\public\cache\nsCacheObject.h"\
"..\..\..\..\..\dist\public\cache\nsCachePref.h"\
"..\..\..\..\..\dist\public\cache\nsDiskModule.h"\
"..\..\..\..\..\dist\public\cache\nsMemCacheObject.h"\
"..\..\..\..\..\dist\public\cache\nsMemModule.h"\
"..\..\..\..\..\dist\win32_d.obj\include\obsolete\protypes.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prcpucfg.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prinrval.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prlog.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prthread.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prtypes.h"\
".\cb.h"\
".\cbDoc.h"\
".\cbView.h"\
".\MainFrm.h"\
".\nsTimeIt.h"\
".\StdAfx.h"\
NODEP_CPP_CBVIE=\
"..\..\..\..\..\dist\public\cache\mcom_db.h"\
"..\..\..\..\..\dist\public\cache\nsISupports.h"\
"..\..\..\..\..\dist\win32_d.obj\include\protypes.h"\
"$(INTDIR)\cbView.obj" : $(SOURCE) $(DEP_CPP_CBVIE) "$(INTDIR)"\
"$(INTDIR)\cb.pch"
!ELSEIF "$(CFG)" == "cb - Win32 Debug"
DEP_CPP_CBVIE=\
"..\..\..\..\..\dist\public\cache\nsBkgThread.h"\
"..\..\..\..\..\dist\public\cache\nsCacheBkgThd.h"\
"..\..\..\..\..\dist\public\cache\nsCacheManager.h"\
"..\..\..\..\..\dist\public\cache\nsCacheModule.h"\
"..\..\..\..\..\dist\public\cache\nsCacheObject.h"\
"..\..\..\..\..\dist\public\cache\nsCachePref.h"\
"..\..\..\..\..\dist\public\cache\nsDiskModule.h"\
"..\..\..\..\..\dist\public\cache\nsMemCacheObject.h"\
"..\..\..\..\..\dist\public\cache\nsMemModule.h"\
"..\..\..\..\..\dist\public\dbm\cdefs.h"\
"..\..\..\..\..\dist\public\dbm\mcom_db.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prinrval.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prlog.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prthread.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prtypes.h"\
".\cb.h"\
".\cbDoc.h"\
".\cbView.h"\
".\MainFrm.h"\
".\nsTimeIt.h"\
".\StdAfx.h"\
{$(INCLUDE)}"\sys\STAT.H"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_CBVIE=\
"..\..\..\..\..\dist\public\cache\nsISupports.h"\
"..\..\..\..\..\dist\public\dbm\prmacos.h"\
"..\..\..\..\..\dist\public\dbm\xp_mcom.h"\
"$(INTDIR)\cbView.obj" : $(SOURCE) $(DEP_CPP_CBVIE) "$(INTDIR)"\
"$(INTDIR)\cb.pch"
"$(INTDIR)\cbView.sbr" : $(SOURCE) $(DEP_CPP_CBVIE) "$(INTDIR)"\
"$(INTDIR)\cb.pch"
!ENDIF
# End Source File
################################################################################
# Begin Source File
SOURCE=.\cb.rc
DEP_RSC_CB_RC=\
".\res\cacheico.bmp"\
".\res\cb.ico"\
".\res\cb.rc2"\
".\res\cbDoc.ico"\
".\res\Toolbar.bmp"\
"$(INTDIR)\cb.res" : $(SOURCE) $(DEP_RSC_CB_RC) "$(INTDIR)"
$(RSC) $(RSC_PROJ) $(SOURCE)
# End Source File
################################################################################
# Begin Source File
SOURCE=.\CacheTreeView.cpp
DEP_CPP_CACHE=\
".\CacheTreeView.h"\
".\cb.h"\
".\cbDoc.h"\
".\StdAfx.h"\
!IF "$(CFG)" == "cb - Win32 Release"
"$(INTDIR)\CacheTreeView.obj" : $(SOURCE) $(DEP_CPP_CACHE) "$(INTDIR)"\
"$(INTDIR)\cb.pch"
!ELSEIF "$(CFG)" == "cb - Win32 Debug"
"$(INTDIR)\CacheTreeView.obj" : $(SOURCE) $(DEP_CPP_CACHE) "$(INTDIR)"\
"$(INTDIR)\cb.pch"
"$(INTDIR)\CacheTreeView.sbr" : $(SOURCE) $(DEP_CPP_CACHE) "$(INTDIR)"\
"$(INTDIR)\cb.pch"
!ENDIF
# End Source File
################################################################################
# Begin Source File
SOURCE=\work\mozilla\dist\WIN32_D.OBJ\lib\cachelib.lib
!IF "$(CFG)" == "cb - Win32 Release"
!ELSEIF "$(CFG)" == "cb - Win32 Debug"
!ENDIF
# End Source File
# End Target
# End Project
################################################################################

BIN
mozilla/network/cache/nu/tests/cb/cb.mdp vendored Normal file

Binary file not shown.

387
mozilla/network/cache/nu/tests/cb/cb.rc vendored Normal file
View File

@@ -0,0 +1,387 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"#define _AFX_NO_OLE_RESOURCES\r\n"
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
"\r\n"
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
"#ifdef _WIN32\r\n"
"LANGUAGE 9, 1\r\n"
"#pragma code_page(1252)\r\n"
"#endif\r\n"
"#include ""res\\cb.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
"#include ""afxres.rc"" // Standard components\r\n"
"#include ""afxprint.rc"" // printing/print preview resources\r\n"
"#endif\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON DISCARDABLE "res\\cb.ico"
IDR_DBTYPE ICON DISCARDABLE "res\\cbDoc.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\Toolbar.bmp"
IDB_CACHEICONS BITMAP DISCARDABLE "res\\cacheico.bmp"
/////////////////////////////////////////////////////////////////////////////
//
// Toolbar
//
IDR_MAINFRAME TOOLBAR DISCARDABLE 16, 15
BEGIN
BUTTON ID_FILE_NEW
BUTTON ID_FILE_OPEN
BUTTON ID_FILE_SAVE
SEPARATOR
BUTTON ID_EDIT_CUT
BUTTON ID_EDIT_COPY
BUTTON ID_EDIT_PASTE
SEPARATOR
BUTTON ID_FILE_PRINT
BUTTON ID_APP_ABOUT
END
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDR_MAINFRAME MENU PRELOAD DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&New\tCtrl+N", ID_FILE_NEW
MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN
MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE
MENUITEM "Save &As...", ID_FILE_SAVE_AS
MENUITEM SEPARATOR
MENUITEM "&Print...\tCtrl+P", ID_FILE_PRINT
MENUITEM "Print Pre&view", ID_FILE_PRINT_PREVIEW
MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP
MENUITEM SEPARATOR
MENUITEM "E&xit", ID_APP_EXIT
END
POPUP "&Edit"
BEGIN
MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO
MENUITEM SEPARATOR
MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT
MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY
MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE
END
POPUP "&View"
BEGIN
MENUITEM "&Toolbar", ID_VIEW_TOOLBAR
MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR
MENUITEM "S&plit", ID_WINDOW_SPLIT
END
POPUP "&Help"
BEGIN
MENUITEM "&About cb...", ID_APP_ABOUT
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE
BEGIN
"N", ID_FILE_NEW, VIRTKEY, CONTROL
"O", ID_FILE_OPEN, VIRTKEY, CONTROL
"S", ID_FILE_SAVE, VIRTKEY, CONTROL
"P", ID_FILE_PRINT, VIRTKEY, CONTROL
"Z", ID_EDIT_UNDO, VIRTKEY, CONTROL
"X", ID_EDIT_CUT, VIRTKEY, CONTROL
"C", ID_EDIT_COPY, VIRTKEY, CONTROL
"V", ID_EDIT_PASTE, VIRTKEY, CONTROL
VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT
VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT
VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL
VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT
VK_F6, ID_NEXT_PANE, VIRTKEY
VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT
END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 217, 55
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About cb"
FONT 8, "MS Sans Serif"
BEGIN
ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20
LTEXT "cb Version 1.0",IDC_STATIC,40,10,119,8,SS_NOPREFIX
LTEXT "Copyright © 1998",IDC_STATIC,40,25,119,8
DEFPUSHBUTTON "OK",IDOK,178,7,32,14,WS_GROUP
END
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904B0"
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "CB MFC Application\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "CB\0"
VALUE "LegalCopyright", "Copyright © 1998\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "CB.EXE\0"
VALUE "ProductName", "CB Application\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#endif // !_MAC
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_ABOUTBOX, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 210
TOPMARGIN, 7
BOTTOMMARGIN, 48
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE PRELOAD DISCARDABLE
BEGIN
IDR_MAINFRAME "Cache Browser\n\nDB\n\n.DB\nCb.Document\nDB Document"
END
STRINGTABLE PRELOAD DISCARDABLE
BEGIN
AFX_IDS_APP_TITLE "cb"
AFX_IDS_IDLEMESSAGE "Ready"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_INDICATOR_EXT "EXT"
ID_INDICATOR_CAPS "CAP"
ID_INDICATOR_NUM "NUM"
ID_INDICATOR_SCRL "SCRL"
ID_INDICATOR_OVR "OVR"
ID_INDICATOR_REC "REC"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_FILE_NEW "Create a new document\nNew"
ID_FILE_OPEN "Open an existing document\nOpen"
ID_FILE_CLOSE "Close the active document\nClose"
ID_FILE_SAVE "Save the active document\nSave"
ID_FILE_SAVE_AS "Save the active document with a new name\nSave As"
ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup"
ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup"
ID_FILE_PRINT "Print the active document\nPrint"
ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_APP_ABOUT "Display program information, version number and copyright\nAbout"
ID_APP_EXIT "Quit the application; prompts to save documents\nExit"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_FILE_MRU_FILE1 "Open this document"
ID_FILE_MRU_FILE2 "Open this document"
ID_FILE_MRU_FILE3 "Open this document"
ID_FILE_MRU_FILE4 "Open this document"
ID_FILE_MRU_FILE5 "Open this document"
ID_FILE_MRU_FILE6 "Open this document"
ID_FILE_MRU_FILE7 "Open this document"
ID_FILE_MRU_FILE8 "Open this document"
ID_FILE_MRU_FILE9 "Open this document"
ID_FILE_MRU_FILE10 "Open this document"
ID_FILE_MRU_FILE11 "Open this document"
ID_FILE_MRU_FILE12 "Open this document"
ID_FILE_MRU_FILE13 "Open this document"
ID_FILE_MRU_FILE14 "Open this document"
ID_FILE_MRU_FILE15 "Open this document"
ID_FILE_MRU_FILE16 "Open this document"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_NEXT_PANE "Switch to the next window pane\nNext Pane"
ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_WINDOW_SPLIT "Split the active window into panes\nSplit"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_EDIT_CLEAR "Erase the selection\nErase"
ID_EDIT_CLEAR_ALL "Erase everything\nErase All"
ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy"
ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut"
ID_EDIT_FIND "Find the specified text\nFind"
ID_EDIT_PASTE "Insert Clipboard contents\nPaste"
ID_EDIT_REPEAT "Repeat the last action\nRepeat"
ID_EDIT_REPLACE "Replace specific text with different text\nReplace"
ID_EDIT_SELECT_ALL "Select the entire document\nSelect All"
ID_EDIT_UNDO "Undo the last action\nUndo"
ID_EDIT_REDO "Redo the previously undone action\nRedo"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar"
ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar"
END
STRINGTABLE DISCARDABLE
BEGIN
AFX_IDS_SCSIZE "Change the window size"
AFX_IDS_SCMOVE "Change the window position"
AFX_IDS_SCMINIMIZE "Reduce the window to an icon"
AFX_IDS_SCMAXIMIZE "Enlarge the window to full size"
AFX_IDS_SCNEXTWINDOW "Switch to the next document window"
AFX_IDS_SCPREVWINDOW "Switch to the previous document window"
AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents"
END
STRINGTABLE DISCARDABLE
BEGIN
AFX_IDS_SCRESTORE "Restore the window to normal size"
AFX_IDS_SCTASKLIST "Activate Task List"
END
STRINGTABLE DISCARDABLE
BEGIN
AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview"
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE 9, 1
#pragma code_page(1252)
#endif
#include "res\cb.rc2" // non-Microsoft Visual C++ edited resources
#include "afxres.rc" // Standard components
#include "afxprint.rc" // printing/print preview resources
#endif
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -0,0 +1,75 @@
// cbDoc.cpp : implementation of the CCbDoc class
//
#include "stdafx.h"
#include "cb.h"
#include "cbDoc.h"
#include "CacheTreeView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCbDoc
IMPLEMENT_DYNCREATE(CCbDoc, CDocument)
BEGIN_MESSAGE_MAP(CCbDoc, CDocument)
//{{AFX_MSG_MAP(CCbDoc)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCbDoc construction/destruction
CCbDoc::CCbDoc()
{
}
CCbDoc::~CCbDoc()
{
}
BOOL CCbDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
if (m_pTreeView)
m_pTreeView->Populate();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CCbDoc serialization
void CCbDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
}
else
{
}
}
/////////////////////////////////////////////////////////////////////////////
// CCbDoc diagnostics
#ifdef _DEBUG
void CCbDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CCbDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCbDoc commands

View File

@@ -0,0 +1,43 @@
// cbDoc.h : interface of the CCbDoc class
//
/////////////////////////////////////////////////////////////////////////////
class CCacheTreeView;
class CCbDoc : public CDocument
{
protected: // create from serialization only
CCbDoc();
DECLARE_DYNCREATE(CCbDoc)
// Attributes
public:
CCacheTreeView* m_pTreeView;
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCbDoc)
public:
virtual BOOL OnNewDocument();
virtual void Serialize(CArchive& ar);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CCbDoc();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CCbDoc)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,178 @@
// cbView.cpp : implementation of the CCbView class
//
#include "stdafx.h"
#include "cb.h"
#include "cbDoc.h"
#include "cbView.h"
#include <afxcmn.h>
#include "MainFrm.h"
#include "nsCacheManager.h"
#include "nsMemModule.h"
#include "nsDiskModule.h"
#include "nsCacheObject.h"
#include "nsTimeIt.h"
#include "nsCacheBkgThd.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define ID_TREECTRL (WM_USER +1)
#define STATUS(s) ((CMainFrame*)GetParentFrame())->Status(s)
IMPLEMENT_DYNCREATE(CCbView, CView)
BEGIN_MESSAGE_MAP(CCbView, CView)
//{{AFX_MSG_MAP(CCbView)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCbView construction/destruction
CCbView::CCbView()
{
}
CCbView::~CCbView()
{
}
BOOL CCbView::PreCreateWindow(CREATESTRUCT& cs)
{
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CCbView drawing
void CCbView::OnDraw(CDC* pDC)
{
CRect rect;
GetClientRect(&rect);
pDC->SetBkColor(RGB(192,192,192));
pDC->FillSolidRect(rect, RGB(192,192,192));
rect.DeflateRect(10,10);
pDC->DrawText(m_Mesg.GetBuffer(m_Mesg.GetLength()), -1, rect, DT_WORDBREAK | DT_EXPANDTABS);
}
/////////////////////////////////////////////////////////////////////////////
// CCbView printing
BOOL CCbView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CCbView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
}
void CCbView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
}
/////////////////////////////////////////////////////////////////////////////
// CCbView diagnostics
#ifdef _DEBUG
void CCbView::AssertValid() const
{
CView::AssertValid();
}
void CCbView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CCbDoc* CCbView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCbDoc)));
return (CCbDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCbView message handlers
void CCbView::OnInitialUpdate()
{
//STATUS("Loading lib...");
nsCacheManager* pCM = nsCacheManager::GetInstance();
nsMemModule* pMM = pCM->GetMemModule();
nsDiskModule* pDM = new nsDiskModule();
pCM->AddModule(pDM);
nsCacheObject* pCO = new nsCacheObject("http://www.netscape.com/");
pCO->Etag("Etag-testing");
pCO->Size(2250);
pCO->LastModified(time(0));
pDM->AddObject(pCO);
// if (!pDM->Contains("http://www.netscape.com/"))
// pDM->AddObject(pCO);
// else
{
nsCacheObject* pTemp = new nsCacheObject("http://www.netscape.com/");
if (pDM->Contains(pTemp))
{
m_Mesg += pTemp->Trace();
}
}
int j = 1000;
char tmpBuff[10];
while (j--)
{
pCO = new nsCacheObject(itoa(j,tmpBuff,10));
VERIFY(pDM->AddObject(pCO));
}
m_Mesg += itoa(pDM->Entries(), tmpBuff, 10);
m_Mesg += " nsCacheObject(s) added.\n";
char* traceBuff =(char*) pCM->Trace();
m_Mesg += "-----------------\n";
m_Mesg += traceBuff;
delete[] traceBuff;
traceBuff = (char*) pMM->Trace();
m_Mesg += traceBuff;
delete[] traceBuff;
m_Mesg += "-----------------\n";
char buffer[10];
m_Mesg += "Worst case time= ";
m_Mesg += itoa(pCM->WorstCaseTime(), buffer, 10);
m_Mesg += " microsec.\n";
PRUint32 t;
{
nsTimeIt tmp(t);
if (pCM->Contains("999"))
m_Mesg += "!";
}
m_Mesg += "-----------------\n";
m_Mesg += "An item found in ";
m_Mesg += itoa(t, buffer, 10);
m_Mesg += " microsec.\n";
CView::OnInitialUpdate();
}

View File

@@ -0,0 +1,54 @@
// cbView.h : interface of the CCbView class
//
/////////////////////////////////////////////////////////////////////////////
class CCbView : public CView
{
protected: // create from serialization only
CCbView();
DECLARE_DYNCREATE(CCbView)
// Attributes
public:
CCbDoc* GetDocument();
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCbView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual void OnInitialUpdate();
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CCbView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CCbView)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
CString m_Mesg;
};
#ifndef _DEBUG // debug version in cbView.cpp
inline CCbDoc* CCbView::GetDocument()
{ return (CCbDoc*)m_pDocument; }
#endif
/////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,26 @@
/* TODO put NPL here */
/* A class to time excursion events */
/* declare an object of this class within the scope to be timed. */
#include <prtypes.h>
#include <prinrval.h>
class nsTimeIt
{
public:
nsTimeIt(PRUint32& tmp);
~nsTimeIt();
private:
PRIntervalTime t;
PRUint32& dest;
};
inline
nsTimeIt::nsTimeIt(PRUint32& tmp):t(PR_IntervalNow()), dest(tmp)
{
}
inline
nsTimeIt::~nsTimeIt()
{
dest = PR_IntervalToMicroseconds(PR_IntervalNow()-t);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 502 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,13 @@
//
// CB.RC2 - resources Microsoft Visual C++ does not edit directly
//
#ifdef APSTUDIO_INVOKED
#error this file is not editable by Microsoft Visual C++
#endif //APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
// Add manually edited resources here...
/////////////////////////////////////////////////////////////////////////////

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,20 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by cb.rc
//
#define IDD_ABOUTBOX 100
#define IDR_MAINFRAME 128
#define IDR_DBTYPE 129
#define IDB_CACHEICONS 130
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 131
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@@ -0,0 +1,42 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include <prtypes.h>
#include <prio.h>
#include <plstr.h>
#include "nsFlatFile.h"
#include "nsTOC.h"
int main()
{
PRFileDesc* pfd = PR_GetSpecialFD(PR_StandardOutput);
nsFlatFile tf("CACHE.DAT");
nsTOC toc("Cache.TOC", &tf);
if (tf.IsValid() && toc.IsValid())
{
PR_Write(pfd, tf.Filename(), PL_strlen(tf.Filename()));
PR_Write(pfd, " ", 2);
PR_Write(pfd, toc.Filename(), PL_strlen(toc.Filename()));
}
return 1;
}

View File

@@ -0,0 +1,329 @@
# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
!IF "$(CFG)" == ""
CFG=fftest - Win32 Debug
!MESSAGE No configuration specified. Defaulting to fftest - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "fftest - Win32 Release" && "$(CFG)" != "fftest - Win32 Debug"
!MESSAGE Invalid configuration "$(CFG)" specified.
!MESSAGE You can specify a configuration when running NMAKE on this makefile
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "fftest.mak" CFG="fftest - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "fftest - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "fftest - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
!ERROR An invalid configuration is specified.
!ENDIF
!IF "$(OS)" == "Windows_NT"
NULL=
!ELSE
NULL=nul
!ENDIF
################################################################################
# Begin Project
# PROP Target_Last_Scanned "fftest - Win32 Debug"
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "fftest - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
OUTDIR=.\Release
INTDIR=.\Release
ALL : "$(OUTDIR)\fftest.exe"
CLEAN :
-@erase "$(INTDIR)\FlatFileTest.obj"
-@erase "$(INTDIR)\nsFFEntry.obj"
-@erase "$(INTDIR)\nsFFObject.obj"
-@erase "$(INTDIR)\nsFlatFile.obj"
-@erase "$(INTDIR)\nsTOC.obj"
-@erase "$(OUTDIR)\fftest.exe"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
# ADD CPP /nologo /W4 /GX /O2 /I "..\..\..\..\..\dist\win32_d.obj\include" /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
CPP_PROJ=/nologo /ML /W4 /GX /O2 /I "..\..\..\..\..\dist\win32_d.obj\include"\
/I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\
/Fp"$(INTDIR)/fftest.pch" /YX /Fo"$(INTDIR)/" /c
CPP_OBJS=.\Release/
CPP_SBRS=.\.
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
BSC32_FLAGS=/nologo /o"$(OUTDIR)/fftest.bsc"
BSC32_SBRS= \
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 ..\..\..\..\..\dist\win32_d.obj\lib\libnspr21.lib ..\..\..\..\..\dist\win32_d.obj\lib\libplc21.lib /nologo /subsystem:console /machine:I386
LINK32_FLAGS=..\..\..\..\..\dist\win32_d.obj\lib\libnspr21.lib\
..\..\..\..\..\dist\win32_d.obj\lib\libplc21.lib /nologo /subsystem:console\
/incremental:no /pdb:"$(OUTDIR)/fftest.pdb" /machine:I386\
/out:"$(OUTDIR)/fftest.exe"
LINK32_OBJS= \
"$(INTDIR)\FlatFileTest.obj" \
"$(INTDIR)\nsFFEntry.obj" \
"$(INTDIR)\nsFFObject.obj" \
"$(INTDIR)\nsFlatFile.obj" \
"$(INTDIR)\nsTOC.obj"
"$(OUTDIR)\fftest.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "fftest - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
OUTDIR=.\Debug
INTDIR=.\Debug
ALL : "$(OUTDIR)\fftest.exe"
CLEAN :
-@erase "$(INTDIR)\FlatFileTest.obj"
-@erase "$(INTDIR)\nsFFEntry.obj"
-@erase "$(INTDIR)\nsFFObject.obj"
-@erase "$(INTDIR)\nsFlatFile.obj"
-@erase "$(INTDIR)\nsTOC.obj"
-@erase "$(INTDIR)\vc40.idb"
-@erase "$(INTDIR)\vc40.pdb"
-@erase "$(OUTDIR)\fftest.exe"
-@erase "$(OUTDIR)\fftest.ilk"
-@erase "$(OUTDIR)\fftest.pdb"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
# ADD CPP /nologo /W4 /Gm /GX /Zi /Od /I "..\..\..\..\..\dist\win32_d.obj\include" /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
CPP_PROJ=/nologo /MLd /W4 /Gm /GX /Zi /Od /I\
"..\..\..\..\..\dist\win32_d.obj\include" /I "..\..\include" /D "WIN32" /D\
"_DEBUG" /D "_CONSOLE" /Fp"$(INTDIR)/fftest.pch" /YX /Fo"$(INTDIR)/"\
/Fd"$(INTDIR)/" /c
CPP_OBJS=.\Debug/
CPP_SBRS=.\.
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
BSC32_FLAGS=/nologo /o"$(OUTDIR)/fftest.bsc"
BSC32_SBRS= \
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
# ADD LINK32 ..\..\..\..\..\dist\win32_d.obj\lib\libnspr21.lib ..\..\..\..\..\dist\win32_d.obj\lib\libplc21.lib /nologo /subsystem:console /debug /machine:I386
LINK32_FLAGS=..\..\..\..\..\dist\win32_d.obj\lib\libnspr21.lib\
..\..\..\..\..\dist\win32_d.obj\lib\libplc21.lib /nologo /subsystem:console\
/incremental:yes /pdb:"$(OUTDIR)/fftest.pdb" /debug /machine:I386\
/out:"$(OUTDIR)/fftest.exe"
LINK32_OBJS= \
"$(INTDIR)\FlatFileTest.obj" \
"$(INTDIR)\nsFFEntry.obj" \
"$(INTDIR)\nsFFObject.obj" \
"$(INTDIR)\nsFlatFile.obj" \
"$(INTDIR)\nsTOC.obj"
"$(OUTDIR)\fftest.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
.c{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cpp{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cxx{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.c{$(CPP_SBRS)}.sbr:
$(CPP) $(CPP_PROJ) $<
.cpp{$(CPP_SBRS)}.sbr:
$(CPP) $(CPP_PROJ) $<
.cxx{$(CPP_SBRS)}.sbr:
$(CPP) $(CPP_PROJ) $<
################################################################################
# Begin Target
# Name "fftest - Win32 Release"
# Name "fftest - Win32 Debug"
!IF "$(CFG)" == "fftest - Win32 Release"
!ELSEIF "$(CFG)" == "fftest - Win32 Debug"
!ENDIF
################################################################################
# Begin Source File
SOURCE=.\FlatFileTest.cpp
DEP_CPP_FLATF=\
"..\..\..\..\..\dist\win32_d.obj\include\obsolete\protypes.h"\
"..\..\..\..\..\dist\win32_d.obj\include\plstr.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prcpucfg.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prinet.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prinrval.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prio.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prlong.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prtime.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prtypes.h"\
"..\..\include\nsFFEntry.h"\
"..\..\include\nsFFObject.h"\
"..\..\include\nsFlatFile.h"\
"..\..\include\nsTOC.h"\
{$(INCLUDE)}"\sys\types.h"\
NODEP_CPP_FLATF=\
"..\..\..\..\..\dist\win32_d.obj\include\macsocket.h"\
"..\..\..\..\..\dist\win32_d.obj\include\protypes.h"\
"$(INTDIR)\FlatFileTest.obj" : $(SOURCE) $(DEP_CPP_FLATF) "$(INTDIR)"
# End Source File
################################################################################
# Begin Source File
SOURCE=\work\mozilla\network\cache\nu\src\nsFlatFile.cpp
DEP_CPP_NSFLA=\
"..\..\..\..\..\dist\win32_d.obj\include\obsolete\protypes.h"\
"..\..\..\..\..\dist\win32_d.obj\include\plstr.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prcpucfg.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prinet.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prinrval.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prio.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prlong.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prmem.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prtime.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prtypes.h"\
"..\..\include\nsFlatFile.h"\
{$(INCLUDE)}"\sys\types.h"\
NODEP_CPP_NSFLA=\
"..\..\..\..\..\dist\win32_d.obj\include\macsocket.h"\
"..\..\..\..\..\dist\win32_d.obj\include\protypes.h"\
"$(INTDIR)\nsFlatFile.obj" : $(SOURCE) $(DEP_CPP_NSFLA) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
# End Source File
################################################################################
# Begin Source File
SOURCE=\work\mozilla\network\cache\nu\src\nsFFObject.cpp
DEP_CPP_NSFFO=\
"..\..\..\..\..\dist\win32_d.obj\include\obsolete\protypes.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prcpucfg.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prtypes.h"\
"..\..\include\nsFFObject.h"\
NODEP_CPP_NSFFO=\
"..\..\..\..\..\dist\win32_d.obj\include\protypes.h"\
"$(INTDIR)\nsFFObject.obj" : $(SOURCE) $(DEP_CPP_NSFFO) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
# End Source File
################################################################################
# Begin Source File
SOURCE=\work\mozilla\network\cache\nu\src\nsTOC.cpp
DEP_CPP_NSTOC=\
"..\..\..\..\..\dist\win32_d.obj\include\obsolete\protypes.h"\
"..\..\..\..\..\dist\win32_d.obj\include\plstr.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prcpucfg.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prinet.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prinrval.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prio.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prlog.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prlong.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prtime.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prtypes.h"\
"..\..\include\nsFFEntry.h"\
"..\..\include\nsFFObject.h"\
"..\..\include\nsFlatFile.h"\
"..\..\include\nsTOC.h"\
{$(INCLUDE)}"\sys\types.h"\
NODEP_CPP_NSTOC=\
"..\..\..\..\..\dist\win32_d.obj\include\macsocket.h"\
"..\..\..\..\..\dist\win32_d.obj\include\protypes.h"\
"$(INTDIR)\nsTOC.obj" : $(SOURCE) $(DEP_CPP_NSTOC) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
# End Source File
################################################################################
# Begin Source File
SOURCE=\work\mozilla\network\cache\nu\src\nsFFEntry.cpp
DEP_CPP_NSFFE=\
"..\..\..\..\..\dist\win32_d.obj\include\obsolete\protypes.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prcpucfg.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prlog.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prmem.h"\
"..\..\..\..\..\dist\win32_d.obj\include\prtypes.h"\
"..\..\include\nsFFEntry.h"\
"..\..\include\nsFFObject.h"\
NODEP_CPP_NSFFE=\
"..\..\..\..\..\dist\win32_d.obj\include\protypes.h"\
"$(INTDIR)\nsFFEntry.obj" : $(SOURCE) $(DEP_CPP_NSFFE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
# End Source File
# End Target
# End Project
################################################################################

Some files were not shown because too many files have changed in this diff Show More