Sfoglia il codice sorgente

Moving NSCP Directory Server from DirectoryBranch to TRUNK, initial drop. (foxworth)

cvsadm 21 anni fa
commit
b2093e3016
100 ha cambiato i file con 13028 aggiunte e 0 eliminazioni
  1. 268 0
      Makefile
  2. 3 0
      bchecker.ini
  3. 49 0
      buildnum.pl
  4. 198 0
      component_versions.mk
  5. 978 0
      components.mk
  6. 5 0
      config/.cvsignore
  7. 58 0
      config/Linux2.4.mk
  8. 58 0
      config/Linux2.6.mk
  9. 38 0
      config/Makefile
  10. 14 0
      config/SunOS5.8.mk
  11. 14 0
      config/SunOS5.8_i86pc.mk
  12. 14 0
      config/SunOS5.9.mk
  13. 14 0
      config/UNIX.mk
  14. 56 0
      config/WINNT5.0.mk
  15. 120 0
      config/common.mn
  16. 520 0
      config/config.mk
  17. 21 0
      config/nfspwd.pl
  18. 305 0
      config/nsinstall.c
  19. 206 0
      config/pathsub.c
  20. 46 0
      config/pathsub.h
  21. 19 0
      config/revdepth-nt.pl
  22. 22 0
      config/revdepth.pl
  23. 707 0
      config/rules.mk
  24. 24 0
      config/webint.mk
  25. 125 0
      dirver.pl
  26. 500 0
      httpd/autobuild
  27. 229 0
      httpd/src/Makefile
  28. 383 0
      httpd/src/ntnsapi.c
  29. 38 0
      httpd/src/unixso.exp
  30. 246 0
      httpd/src/unixso.mk
  31. 85 0
      include/Makefile
  32. 40 0
      include/base/Makefile
  33. 209 0
      include/base/crit.h
  34. 217 0
      include/base/dbtbase.h
  35. 76 0
      include/base/ereport.h
  36. 73 0
      include/base/eventhandler.h
  37. 34 0
      include/base/eventlog.h
  38. 121 0
      include/base/file.h
  39. 94 0
      include/base/fsmutex.h
  40. 89 0
      include/base/lexer.h
  41. 21 0
      include/base/nterr.h
  42. 67 0
      include/base/nterrors.h
  43. 61 0
      include/base/plist.h
  44. 103 0
      include/base/pool.h
  45. 54 0
      include/base/rwlock.h
  46. 114 0
      include/base/shexp.h
  47. 565 0
      include/base/systems.h
  48. 91 0
      include/base/systhr.h
  49. 210 0
      include/base/util.h
  50. 6 0
      include/copyrght.h
  51. 245 0
      include/i18n.h
  52. 27 0
      include/ldaputil/cert.h
  53. 124 0
      include/ldaputil/certmap.h
  54. 91 0
      include/ldaputil/dbconf.h
  55. 29 0
      include/ldaputil/encode.h
  56. 108 0
      include/ldaputil/errors.h
  57. 634 0
      include/ldaputil/extcmap.h
  58. 23 0
      include/ldaputil/init.h
  59. 94 0
      include/ldaputil/ldapauth.h
  60. 100 0
      include/ldaputil/ldapdb.h
  61. 132 0
      include/ldaputil/ldaputil.h
  62. 41 0
      include/libaccess/acl.h
  63. 79 0
      include/libaccess/acladmin.h
  64. 56 0
      include/libaccess/aclbuild.h
  65. 307 0
      include/libaccess/aclerror.h
  66. 37 0
      include/libaccess/acleval.h
  67. 52 0
      include/libaccess/aclglobal.h
  68. 112 0
      include/libaccess/aclparse.h
  69. 156 0
      include/libaccess/aclproto.h
  70. 264 0
      include/libaccess/aclstruct.h
  71. 157 0
      include/libaccess/attrec.h
  72. 24 0
      include/libaccess/authdb.h
  73. 40 0
      include/libaccess/ava.h
  74. 15 0
      include/libaccess/avadb.h
  75. 59 0
      include/libaccess/avapfile.h
  76. 161 0
      include/libaccess/dbtlibaccess.h
  77. 51 0
      include/libaccess/dnfstruct.h
  78. 81 0
      include/libaccess/ipfstruct.h
  79. 184 0
      include/libaccess/las.h
  80. 62 0
      include/libaccess/ldapacl.h
  81. 87 0
      include/libaccess/nsadb.h
  82. 122 0
      include/libaccess/nsamgmt.h
  83. 288 0
      include/libaccess/nsauth.h
  84. 97 0
      include/libaccess/nsautherr.h
  85. 102 0
      include/libaccess/nscert.h
  86. 182 0
      include/libaccess/nsdb.h
  87. 92 0
      include/libaccess/nsdberr.h
  88. 52 0
      include/libaccess/nsdbmgmt.h
  89. 47 0
      include/libaccess/nserror.h
  90. 35 0
      include/libaccess/nsgmgmt.h
  91. 73 0
      include/libaccess/nsgroup.h
  92. 74 0
      include/libaccess/nslock.h
  93. 36 0
      include/libaccess/nsumgmt.h
  94. 70 0
      include/libaccess/nsuser.h
  95. 215 0
      include/libaccess/register.h
  96. 6 0
      include/libaccess/stubs.h
  97. 99 0
      include/libaccess/symbols.h
  98. 13 0
      include/libaccess/userauth.h
  99. 81 0
      include/libaccess/usi.h
  100. 104 0
      include/libaccess/usrcache.h

+ 268 - 0
Makefile

@@ -0,0 +1,268 @@
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright 2001 Sun Microsystems, Inc.
+# Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+# 
+# Top-level gmake Makefile for Directory Server builds.
+#
+# Execute the command:
+#
+#       gmake help
+#
+# to see a list of available targets.
+
+# Relative path to the top of the build tree (i.e., where the DS source tree is checked out)
+MCOM_ROOT=..
+
+# define COMPONENT_DEPS here so that components are pulled in this makefile
+COMPONENT_DEPS := 1
+
+include nsdefs.mk
+include nsconfig.mk
+include ns_usedb.mk
+
+# first (default) rule: build and create a DS package
+all:	buildAndPkgDirectory
+
+help:
+	@echo
+	@echo The following are build targets that you can choose from:
+	@echo
+	@echo "   gmake buildAndPkgDirectory"
+	@echo "   gmake buildDirectory"
+	@echo "   gmake pkgDirectory"
+	@echo "   gmake pkgDirectoryl10n"
+	@echo "   gmake pkgDirectoryPseudoL10n"
+
+###### Implementation notes:
+#
+# We use ../../reltools/ftp_puller_new.pl to pull and maintain dependencies
+# for the components (binary and header files) we use for the build.  The
+# dependencies are maintained in the file ../components.OS, where OS is
+# the operating system.  These files do not exist in CVS; they are created
+# as needed.  We could probably make the system smarter to know the
+# difference between debug/optimized and export/domestic, but for now it
+# does not. 
+#
+# The file ./component_versions.mk contains the component version
+# information.  If you want to change the version of a component used
+# to build or package, this is the place to look.
+#
+#
+# The file ./components.mk contains the information about what files and
+# directories are used by the component.  It also contains the
+# information about how to pull the component.  Each component defines a
+# XXX_DEP macro which is the name of a file to be used for dependency
+# checking.
+#
+#
+# By default, NT uses FTP and Unix uses SYMLINK as their pull methods.
+# This is controlled by the COMPONENT_PULL_METHOD macro.  For example,
+# on Unix, you can use
+#
+#     gmake COMPONENT_PULL_METHOD=FTP buildDirectory 
+#
+# To force use of ftp to pull all components.  In addition, each component
+# can have a XXX_PULL_METHOD macro.  If this macro is defined, it overrides
+# the default.  For example, on Unix, you can use
+#
+#     gmake NSPR_PULL_METHOD=FTP buildDirectory
+#
+# if you want to get NSPR via ftp and the other components via symlink.
+#
+#
+# By default, the components are only pulled from the top level if you do
+# a gmake buildDirectory.  There is a macro called COMPONENT_DEPS.  If
+# this is defined on the command line of the gmake command e.g.
+#
+#     gmake COMPONENT_DEPS=1 ... 
+#
+# this will force component checking and pulling.  This will have the
+# effect of slowing down the build.
+#
+###### End of implementation notes.
+
+components: $(ADMINUTIL_DEP) $(NSPR_DEP) $(ARLIB_DEP) $(DBM_DEP) $(SECURITY_DEP) $(SVRCORE_DEP) \
+	$(ICU_DEP) $(SETUPSDK_DEP) $(LDAPSDK_DEP) $(DB_LIB_DEP) $(SASL_DEP) $(PEER_DEP) \
+	$(DSRK_DEP) $(AXIS_DEP) $(DSMLJAR_DEP)
+	-@echo "The components are up to date"
+
+ifeq ($(BUILD_JAVA_CODE),1)
+DS_CONSOLE_COMPONENT_DEP  = $(LDAPJDK_DEP) $(SWING_DEP) $(MCC_DEP)
+DS_CONSOLE_COMPONENT_DEP += $(JAVASSL_DEP) $(JSS_DEP) $(CRIMSONJAR_DEP)
+java_platform_check:
+
+else
+
+DS_CONSOLE_COMPONENT_DEP  =
+java_platform_check:
+	-@echo "Note: Java code is not built on this platform ($(ARCH))."
+	-@echo "      Use 'gmake BUILD_JAVA_CODE=1 ...' to override."
+endif
+
+consoleComponents: $(DS_CONSOLE_COMPONENT_DEP)
+
+pumpkin:
+	@echo NSOS_RELEASE is: $(NSOS_RELEASE)
+	$(PERL) pumpkin.pl $(PUMPKIN_AGE) pumpkin.dat
+
+buildnum:
+	if test ! -d $(BUILD_ARCH); then mkdir $(BUILD_ARCH); fi;
+	$(PERL) buildnum.pl -p $(BUILD_ARCH)
+
+nsCommon:
+	cd config;		$(MAKE) export $(NSDEFS)
+# XXXsspitzer:  for UNIXWARE and UnixWare
+ifeq ($(subst nix,NIX,$(subst are,ARE,$(ARCH))), UNIXWARE)
+	- mkdir built/$(NS_BUILD_FLAVOR)/obj
+	cd built/$(NS_BUILD_FLAVOR)/obj && ar xv ../../../$(LIBNSPR) uxwrap.o
+endif
+ifeq ($(ARCH), WINNT)
+	cd lib/libnt;	$(MAKE) $(MFLAGS) export $(NSDEFS)
+	cd lib/libnt;	$(MAKE) $(MFLAGS) libs $(NSDEFS)
+endif
+
+#
+# Notice that BUILD_MODULE is not supplied directly on this target.
+# It either inherits from the calling target or from the default in
+# nsdefs.mk.  Therefore if you need to perform 'gmake httpdlib', be sure
+# that BUILD_MODULE is set to whatever target release that you need.
+#
+httpdLib:
+	@echo 
+	@echo 
+	@echo 
+	@echo ==== Starting Server LIBS for: $(BUILD_MODULE) ==========
+	@echo
+	cd lib/base; 		$(MAKE) $(MFLAGS)
+	cd lib/ldaputil;	$(MAKE) $(MFLAGS)
+	cd lib/frame; 		$(MAKE) $(MFLAGS)
+	cd lib/libaccess; 	$(MAKE) $(MFLAGS)
+	cd lib/libadmin; 	$(MAKE) $(MFLAGS)
+	cd lib/safs; 		$(MAKE) $(MFLAGS)
+	cd lib/libcrypt; 	$(MAKE) $(MFLAGS)
+	cd lib/libmsgdisp; 	$(MAKE) $(MFLAGS)
+	cd lib/libsi18n; 	$(MAKE) $(MFLAGS)
+ifeq ($(ARCH), WINNT)
+	cd lib/httpdaemon;	$(MAKE) $(MFLAGS)
+endif
+	@echo ==== Finished Server LIBS for: $(BUILD_MODULE) ==========
+	@echo 
+
+buildAndPkgDirectory:	buildDirectory pkgDirectory
+
+buildDirectory: buildnum pumpkin $(OBJDIR) $(DIRVER_H) $(SDKVER_H) components
+	@echo 
+	@echo 
+	@echo 
+	@echo ==== Starting Netscape Directory Server ==========
+	@echo
+	$(MAKE) $(MFLAGS) nsCommon
+	cd config;           $(MAKE) $(MFLAGS) install $(NSDEFS)
+	$(MAKE) $(MFLAGS) BUILD_MODULE=DIRECTORY LDAP_NO_LIBLCACHE=1 httpdLib
+ifeq ($(ARCH), WINNT)
+	$(PERL) ntversion.pl $(MCOM_ROOT) $(MAJOR_VERSION) $(MINOR_VERSION)
+endif
+	cd httpd; $(MAKE) $(MFLAGS) LDAP_NO_LIBLCACHE=1 BUILD_MODULE=DIRECTORY httpd-bin
+	cd ldap; $(MAKE) $(MFLAGS) LDAP_NO_LIBLCACHE=1 BUILD_MODULE=DIRECTORY all
+	@echo ==== Finished Netscape Directory Server ==========
+	@echo
+	@echo ==== Starting Netscape Directory Server Console ==========
+	@echo
+	$(MAKE) $(MFLAGS) buildDirectoryConsole
+	@echo
+	@echo ==== Finished Netscape Directory Server Console ==========
+	@echo
+	@echo ==== Starting Netscape Directory Clients ==========
+	@echo
+	$(MAKE) $(MFLAGS) buildDirectoryClients
+	@echo
+	@echo ==== Finished Netscape Directory Clients ==========
+	@echo
+
+cleanDirectory:
+	@echo
+	@echo
+	@echo ==== Cleaning Netscape Directory Server on $(ARCH) ====
+	@echo
+	rm -rf $(ARCH)
+	rm -rf built/$(NS_BUILD_FLAVOR)
+	rm -rf built/release/slapd/$(NS_BUILD_FLAVOR)
+	rm -rf ../dist/$(NSOBJDIR_NAME)
+	rm -rf ../dist/full
+	rm -rf $(CLASS_DEST)	# ../dist/classes
+	@echo
+	@echo ==== All done ===
+	@echo
+
+buildDirectoryConsole: consoleComponents java_platform_check
+ifeq ($(BUILD_JAVA_CODE),1)
+	cd ldap/admin/src/java/com/netscape/admin/dirserv; $(MAKE) $(MFLAGS) package
+	cd ldap/admin/src/java/com/netscape/xmltools; $(MAKE) $(MFLAGS) package
+endif
+
+buildDirectoryClients: $(ANT_DEP) java_platform_check
+ifeq ($(BUILD_JAVA_CODE),1)
+	cd ldap/clients; $(MAKE) $(MFLAGS)
+endif
+	cd ldap/clients/dsgw; $(MAKE) $(MFLAGS)
+
+$(OBJDIR):
+	if test ! -d $(OBJDIR); then mkdir $(OBJDIR); fi;
+
+$(SDKVER_H):
+	if test ! -d $(DIRVERDIR); then mkdir $(DIRVERDIR); fi;
+	$(PERL) dirver.pl -v "$(DIRSDK_VERSION)" -o $@
+
+$(DIRVER_H):
+	if test ! -d $(DIRVERDIR); then mkdir $(DIRVERDIR); fi;
+	$(PERL) dirver.pl -v "$(DIR_VERSION)" -o $@
+
+pkgLdapSDK: setupLdapSDK
+	@echo
+	@echo =========== Finished - LDAP SDK  Package Build ============
+
+setupLdapSDK:
+	@echo =========== Starting - LDAP SDK  Package Build ============
+	@echo	
+	cd ldap/cm; $(MAKE) $(MAKEFLAGS) releaseLdapSDK 
+	cd ldap/cm; $(MAKE) $(MAKEFLAGS) packageLdapSDK 
+
+
+pkgDirectory:	setupDirectory
+	@echo
+	@echo =========== Finished - Directory Server Package Build ============
+
+Acceptance:
+	cd ldap/cm; $(MAKE) Acceptance $(MFLAGS)
+
+Longduration:
+	cd ldap/cm; $(MAKE) Longduration $(MFLAGS)
+
+setupDirectory:
+	cd ldap/cm; $(MAKE) $(MFLAGS) releaseDirectory;
+	cd ldap/cm; $(MAKE) $(MFLAGS) packageDirectory;
+
+pkgDirectoryJars:
+	cd ldap/cm; $(MAKE) $(MFLAGS) packageJars 
+
+pkgDirectoryl10n:
+	@echo =========== Starting - Directory Server International Package Build ============
+	cd ldap/cm; $(MAKE) $(MFLAGS) l10nRePackage
+	@echo =========== Finished - Directory Server International Package Build ============
+
+pkgDirectoryPseudoL10n:
+	@echo =========== Starting - Directory Server L10N Package Build ============
+ifeq ($(BUILD_SECURITY),export)
+ifeq ($(BUILD_DEBUG),optimize)
+	cd i18npkg/apollo; $(MAKE) $(MFLAGS)
+else
+	@echo skipping pkgDirectoryPseudoL10n
+endif
+else
+	@echo skipping pkgDirectoryPseudoL10n
+endif
+	@echo =========== Finished - Directory Server L10N Package Build ============
+

+ 3 - 0
bchecker.ini

@@ -0,0 +1,3 @@
+checking_level full
+checking_uninit_compile on
+compiler_fault_recovery on

+ 49 - 0
buildnum.pl

@@ -0,0 +1,49 @@
+#!/usr/bin/perl
+#--------------------------------------------
+# buildnum.pl
+#
+# Generates a dated build number and writes
+# out a buildnum.dat file in a user specified
+# subdirectory.
+#
+# Usage: buildnum.pl -p <platform dir>
+#--------------------------------------------
+
+use Getopt::Std;
+use FileHandle;
+                                                                                             
+autoflush STDERR 1;
+                                                                                             
+getopts('p:H');
+                                                                                             
+if ($opt_H) {exitHelp();}
+
+# Load arguments
+$platdir = $opt_p || exitHelp();
+$buildnum_file = "./$platdir/buildnum.dat";
+
+# Get current time
+@now = gmtime;
+
+# Format buildnum as YYYY.DDD.HHMM
+$year = $now[5] + 1900;
+$doy = $now[7] + 1;
+if ($doy < 100) { $doy = 0 . $doy; }
+$tod = $now[2] . $now[1];
+$buildnum = "$year.$doy.$tod";
+
+# Write buildnum.dat
+open(BUILDNUM,">$buildnum_file") || die "Error: Can't create $buildnum_file: $!\n";
+print BUILDNUM "\\\"$buildnum\\\"";
+close(BUILDNUM);
+
+#---------- exitHelp subroutine ----------
+sub exitHelp {
+    print(STDERR "$0: Generates a dated build number.
+
+    \tUsage: $0 -p <platform>
+
+    \t-p <platform>             Platform subdirectory.
+    \t-H                        Print this help message\n");
+    exit(0);
+}

+ 198 - 0
component_versions.mk

@@ -0,0 +1,198 @@
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright 2001 Sun Microsystems, Inc.
+# Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+# This file contains the version definitions for all components used in the build.  It
+# should be COMPLETELY AND TOTALLY SELF CONTAINED e.g. no references to macros defined
+# outside of this file.
+
+# The XXX_DIR OR XXX_VERSDIR or XXX_COMP or XXX_COMP_DIR macros are the name of the
+# base directory for the component under the main components directory
+# for example, the LDAP SDK component directory is
+# $(COMPONENTS_DIR)/$(LDAPCOMP_DIR) == /share/builds/components/ldapsdk31
+
+# the XXX_RELDATE or XXX_VERSION macros are the name of the subdirectory under
+# the component directory where the specific version can be found.  This is
+# usually in the form of YYYYMMDD, although NSPR et. al use a different
+# naming scheme.
+# NSPR
+ifndef NSPR_RELDATE
+  NSPR_RELDATE = DS7.0
+endif
+
+# SECURITY (NSS) LIBRARY
+ifndef SECURITY_RELDATE
+  SECURITY_RELDATE = DS7.0
+endif
+
+# LIBDB
+DBDEFS:=
+ifndef DB_MAJOR_MINOR
+DB_MAJOR_MINOR:=db42
+endif
+ifndef DB_VERSION
+  DB_VERSION:=DS7.0
+endif
+
+# DBM Library
+ifndef DBM_RELDATE
+  DBM_RELDATE = DS7.0
+endif
+
+# SMARTHEAP
+ifndef SH_VERSION
+  SH_VERSION:=v6.01
+endif
+
+# LDAP SDK
+ifndef LDAP_RELDATE
+  LDAP_RELDATE = DS7.0
+endif
+ifndef LDAPCOMP_DIR
+  LDAPCOMP_DIR=ldapsdk50
+endif
+
+# DSRK
+ifndef DSRK_RELDATE
+  DSRK_RELDATE = 20041029
+endif
+ifndef DSRKCOMP_DIR
+  DSRKCOMP_DIR=dsrk70
+endif
+
+# CRIMSONJAR 
+ifndef CRIMSONJAR_VERSION
+  CRIMSONJAR_VERSION = 1.1.3
+endif
+ifndef CRIMSONJAR_COMP
+  CRIMSONJAR_COMP = crimson
+endif
+
+# ANT 
+ifndef ANT_VERSION
+  ANT_VERSION = 1.4.1
+endif
+ifndef ANT_COMP
+  ANT_COMP = ant
+endif
+
+# Servlet SDK
+ifndef SERVLET_VERSION
+  SERVLET_VERSION = 2.3
+endif
+ifndef SERVLET_COMP
+  SERVLET_COMP = javax/servlet
+endif
+
+# LDAP JDK
+ifndef LDAPJDK_RELDATE
+  LDAPJDK_RELDATE = v4.17
+endif
+ifndef LDAPJDK_COMP
+  LDAPJDK_COMP = ldapjdk41
+endif
+
+# admin server
+
+ifndef ADM_RELDATE
+  ADM_RELDATE = 20041117
+endif
+ifndef ADM_VERSDIR
+  ADM_VERSDIR = admserv62
+endif
+
+# peer
+ifndef PEER_RELDATE
+  PEER_RELDATE = DS7.0
+endif
+
+# setup sdk
+ifndef SETUP_SDK_RELDATE
+  SETUP_SDK_RELDATE = DS7.0
+endif
+ifndef SETUPSDK_VERSDIR
+  SETUPSDK_VERSDIR = v6.2
+endif
+
+# infozip utilities
+ifndef INFOZIP_RELDATE
+  INFOZIP_RELDATE = CMSTOOLS_7_x
+endif
+
+# server core
+ifndef SVRCORE_RELDATE
+  SVRCORE_RELDATE = DS7.0
+endif
+
+# admin utility library
+ifndef ADMINUTIL_VER
+  ADMINUTIL_VER=62
+endif
+ifndef ADMINUTIL_RELDATE
+  ADMINUTIL_RELDATE=20041117
+endif
+
+ifndef ADMINUTIL_VERSDIR
+  ADMINUTIL_VERSDIR=adminsdk$(ADMINUTIL_VER)
+endif
+
+# MCC (Console JDK)
+ifndef MCC_REL
+  MCC_REL=62
+endif
+ifndef MCC_COMP
+  MCC_COMP = consolesdk$(MCC_REL)
+endif
+ifndef MCC_RELDATE
+  MCC_RELDATE=20041117
+endif
+
+ifndef PERLDAP_VERSION
+  PERLDAP_VERSION=20041116
+endif
+
+ifndef JSS_COMP
+  JSS_COMP=jss
+endif
+
+ifndef JSS_VERSION
+  JSS_VERSION=DS7.0
+endif
+
+ifndef JSS_JAR_VERSION
+  JSS_JAR_VERSION=3
+endif
+
+ifndef SASL_VERSDIR
+  SASL_VERSDIR=sasl_1_0
+endif
+ifndef SASL_RELDATE
+  SASL_RELDATE=20041130
+endif
+
+# jakarta/axis for DSMLGW
+ifndef TOMCAT_VERSION
+  TOMCAT_VERSION=5.0.27
+endif
+ifndef AXIS_VERSION
+  AXIS_VERSION=1_2beta
+endif
+
+# JSP compiler jasper
+ifndef JSPC_VERSION
+  JSPC_VERSION = 4.0.3
+endif
+ifndef JSPC_COMP
+  JSPC_COMP = javax/jasper
+endif
+
+# ICU
+ifndef ICU_VERSDIR
+  ICU_VERSDIR=libicu_2_4
+endif
+ifndef ICU_RELDATE
+  ICU_RELDATE=DS7.0
+endif

+ 978 - 0
components.mk

@@ -0,0 +1,978 @@
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright 2001 Sun Microsystems, Inc.
+# Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+# this file contains definitions for component macros used during the build
+# process.  Things like the component location in the build tree, etc.
+# this file should be included by nsconfig.mk after it figures out all
+# of the OS, architecture, security, and other platform and build related
+# macros.  This file also contains the instructions for making the component
+# up to date e.g. copying the files from their repository to an area where
+# the build process has access to it.  For some components and OS's, this may
+# be as simple as creating a symbolic link to the repository
+
+# Each component should define a COMPONENT_DEP macro which can be used in
+# other makefiles for dependency checking e.g.
+# target: $(COMPONENT1_DEP) $(COMPONENT2_DEP) ...
+# This macro should evaluate to the name of a single file which must be
+# present for the package to be complete e.g. some library or include
+# file name
+# Each component then should define a target for that dependency which will
+# bring the component up to date if that target does not exist e.g.
+# $(COMPONENT1_DEP):
+#	use ftp or symlinks or ??? to get the necessary files to the build
+#	area
+
+# Each component should define a COMPONENT_LINK macro which can be used to
+# link the component's libraries with the target.  For NT, this will typically
+# be something like
+# /LIBPATH:path_to_library lib1 lib2 lib3 /LIBPATH:more_libs lib4 lib5 ...
+# On Unix, this will be something like
+# -Lpath_to_library -l1 -l2 -l3 -Lmore_libs -l4 -l5 ...
+
+# Each component should define a COMPONENT_INCLUDE macro which can be used
+# to compile using the component's header files e.g.
+# -Ipath_to_include_files -Ipath_to_more_include_files
+
+# Once this file is working, I will DELETE compvers.sh and ns_ftp.sh
+# from the tree, so help me god.
+
+# this macro contains a list of source files and directories to copy to
+# the directory where DLLs/SOs go at runtime; each component will add the files/dirs to
+# this macro that it needs to package; not all components will have
+# files which need packaging
+# if you need some other behavior, see PACKAGE_SRC_DEST below
+LIBS_TO_PKG =
+
+# this macro contains a list of source files and directories to copy to
+# the directory where DLLs/SOs go at runtime; each component will add the files/dirs to
+# this macro that it needs to package; this is for DLLs/SOs for the shared/bin
+# directory where the ldap c sdk command line tools, some security tools, and
+# the i18n conversion tools live
+LIBS_TO_PKG_SHARED = 
+
+# this macro contains a list of source files and directories to copy to
+# the shared tools directory - things like the ldap c sdk command line
+# tools, shared security tools, etc.
+BINS_TO_PKG_SHARED =
+
+# this macro contains a list of shared libraries/dlls needed during
+# setup to run the setup pre-install program on unix (ns-config) or
+# the slapd plugin on NT (DSINST_PreInstall)
+PACKAGE_SETUP_LIBS =
+
+# this macro contains a list of libraries/dlls to copy to the clients
+# library directory
+LIBS_TO_PKG_CLIENTS =
+
+# this macro contains a list of source files and directories to copy to
+# the release/java directory; usually a list of jar files
+PACKAGE_UNDER_JAVA =
+
+# this macro contains a list of pairs of source and dest files and directories
+# the source is where to find the item in the build tree, and the dest is
+# the place in the release to put the item, relative to the server root e.g.
+# nls locale files are in libnls31/locale, but for packaging they need to
+# go into lib/nls, not just lib; the destination should be a directory name;
+# separate the src from the dest with a single space
+COMMA := ,
+NULLSTRING :=
+SPACE := $(NULLSTRING) # the space is between the ) and the #
+PACKAGE_SRC_DEST =
+
+ifeq ($(ARCH), WINNT)
+EXE_SUFFIX = .exe
+else # unix - windows has no lib name prefix, except for nspr
+LIB_PREFIX = lib
+endif
+
+# ADMINUTIL library #######################################
+ADMINUTIL_VERSION=$(ADMINUTIL_RELDATE)$(SEC_SUFFIX)
+ADMINUTIL_BASE=$(ADMINUTIL_VERSDIR)/${ADMINUTIL_VERSION}
+ADMSDKOBJDIR = $(FULL_RTL_OBJDIR)
+ADMINUTIL_IMPORT=$(COMPONENTS_DIR)/${ADMINUTIL_BASE}/$(NSOBJDIR_NAME)
+# this is the base directory under which the component's files will be found
+# during the build process
+ADMINUTIL_BUILD_DIR=$(NSCP_DISTDIR_FULL_RTL)/adminutil
+ADMINUTIL_LIBPATH=$(ADMINUTIL_BUILD_DIR)/lib
+ADMINUTIL_INCPATH=$(ADMINUTIL_BUILD_DIR)/include
+
+PACKAGE_SRC_DEST += $(ADMINUTIL_LIBPATH)/property bin/slapd/lib
+LIBS_TO_PKG += $(wildcard $(ADMINUTIL_LIBPATH)/*.$(DLL_SUFFIX))
+LIBS_TO_PKG_CLIENTS += $(wildcard $(ADMINUTIL_LIBPATH)/*.$(DLL_SUFFIX))
+
+#
+# Libadminutil
+#
+ADMINUTIL_DEP = $(ADMINUTIL_LIBPATH)/libadminutil$(ADMINUTIL_VER).$(LIB_SUFFIX)
+ifeq ($(ARCH), WINNT)
+ADMINUTIL_LINK = /LIBPATH:$(ADMINUTIL_LIBPATH) libadminutil$(ADMINUTIL_VER).$(LIB_SUFFIX)
+ADMINUTIL_S_LINK = /LIBPATH:$(ADMINUTIL_LIBPATH) libadminutil_s$(ADMINUTIL_VER).$(LIB_SUFFIX)
+LIBADMINUTILDLL_NAMES = $(ADMINUTIL_LIBPATH)/libadminutil$(ADMINUTIL_VER).$(DLL_SUFFIX)
+else
+ADMINUTIL_LINK=-L$(ADMINUTIL_LIBPATH) -ladminutil$(ADMINUTIL_VER)
+endif
+ADMINUTIL_INCLUDE=-I$(ADMINUTIL_INCPATH) \
+	-I$(ADMINUTIL_INCPATH)/libadminutil \
+	-I$(ADMINUTIL_INCPATH)/libadmsslutil
+
+ifndef ADMINUTIL_PULL_METHOD
+ADMINUTIL_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(ADMINUTIL_DEP): ${NSCP_DISTDIR_FULL_RTL}
+ifdef COMPONENT_DEPS
+	$(FTP_PULL) -method $(ADMINUTIL_PULL_METHOD) \
+		-objdir $(ADMINUTIL_BUILD_DIR) \
+		-componentdir $(ADMINUTIL_IMPORT) \
+		-files include,lib
+endif
+	-@if [ ! -f $@ ] ; \
+	then echo "Error: could not get component adminutil file $@" ; \
+	fi
+###########################################################
+# Peer
+
+PEER_BUILD_DIR = $(NSCP_DISTDIR)/peer
+ifeq ($(ARCH), WINNT)
+# PEER_RELEASE = $(COMPONENTS_DIR)/peer/$(PEER_RELDATE)
+# PEER_FILES = include
+else
+PEER_RELEASE = $(COMPONENTS_DIR)/peer/$(PEER_RELDATE)/$(NSOBJDIR_NAME)
+PEER_FILES = obj
+PEER_DEP = $(PEER_OBJPATH)/ns-ldapagt
+endif
+# PEER_MGMTPATH = $(PEER_BUILD_DIR)/dev
+# PEER_INCDIR = $(PEER_BUILD_DIR)/include
+# PEER_BINPATH = $(PEER_BUILD_DIR)/dev
+PEER_OBJPATH = $(PEER_BUILD_DIR)/obj
+# PEER_INCLUDE = -I$(PEER_INCDIR)
+
+ifndef PEER_PULL_METHOD
+PEER_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(PEER_DEP): $(NSCP_DISTDIR)
+ifdef COMPONENT_DEPS
+	$(FTP_PULL) -method $(PEER_PULL_METHOD) \
+		-objdir $(PEER_BUILD_DIR) -componentdir $(PEER_RELEASE) \
+		-files $(PEER_FILES)
+	-@if [ ! -f $@ ] ; \
+	then echo "Error: could not get component PEER file $@" ; \
+	fi
+endif
+
+###########################################################
+
+# NSPR20 Library
+NSPR_LIBNAMES = plc4 plds4
+ifeq ($(ARCH), SOLARIS)
+  ifeq ($(NSPR_RELDATE), v4.2.2)
+# no need after v4.4.1
+NSPR_LIBNAMES += ultrasparc4 
+# just need ultrasparc for now
+LIBS_TO_PKG += $(addsuffix .$(DLL_SUFFIX),$(addprefix $(NSPR_LIBPATH)/lib,ultrasparc4))
+  endif
+endif
+NSPR_LIBNAMES += nspr4
+NSPR_BUILD_DIR = $(NSCP_DISTDIR_FULL_RTL)/nspr
+NSPR_ABS_BUILD_DIR = $(NSCP_ABS_DISTDIR_FULL_RTL)/nspr
+NSPR_LIBPATH = $(NSPR_BUILD_DIR)/lib
+NSPR_INCLUDE = -I$(NSPR_BUILD_DIR)/include
+NSPR_IMPORT = $(COMPONENTS_DIR)/nspr20/$(NSPR_RELDATE)/$(FULL_RTL_OBJDIR)
+NSPR_LIBS_TO_PKG = $(addsuffix .$(DLL_SUFFIX),$(addprefix $(NSPR_LIBPATH)/lib,$(NSPR_LIBNAMES)))
+
+LIBS_TO_PKG += $(NSPR_LIBS_TO_PKG)
+LIBS_TO_PKG_SHARED += $(NSPR_LIBS_TO_PKG) # needed for cmd line tools
+PACKAGE_SETUP_LIBS += $(NSPR_LIBS_TO_PKG)
+LIBS_TO_PKG_CLIENTS += $(NSPR_LIBS_TO_PKG) # for dsgw
+
+NSPR_DEP = $(NSPR_LIBPATH)/libnspr4.$(LIB_SUFFIX)
+ifeq ($(ARCH), WINNT)
+  NSPRDLL_NAME = $(addprefix lib, $(NSPR_LIBNAMES))
+  NSPROBJNAME = $(addsuffix .lib, $(NSPRDLL_NAME))
+  NSPRLINK = /LIBPATH:$(NSPR_LIBPATH) $(NSPROBJNAME)
+  LIBNSPRDLL_NAMES = $(addsuffix .dll, $(addprefix $(NSPR_LIBPATH)/, \
+	$(addprefix lib, $(NSPR_LIBNAMES))))
+else
+  NSPR_SOLIBS = $(addsuffix .$(DLL_SUFFIX),  $(addprefix $(LIB_PREFIX), $(NSPR_LIBNAMES)))
+  NSPROBJNAME = $(addsuffix .a, $(addprefix $(LIB_PREFIX), $(NSPR_LIBNAMES))
+  LIBNSPR = $(addprefix $(NSPR_LIBPATH)/, $(NSPR_SOLIBS))
+  NSPRLINK = -L$(NSPR_LIBPATH) $(addprefix -l, $(NSPR_LIBNAMES))
+endif
+
+ifndef NSPR_PULL_METHOD
+NSPR_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(NSPR_DEP): $(NSCP_DISTDIR_FULL_RTL)
+ifdef COMPONENT_DEPS
+	$(FTP_PULL) -method $(NSPR_PULL_METHOD) \
+		-objdir $(NSPR_BUILD_DIR) -componentdir $(NSPR_IMPORT) \
+		-files lib,include
+endif
+	-@if [ ! -f $@ ] ; \
+	then echo "Error: could not get component NSPR file $@" ; \
+	fi
+
+### DBM #############################
+
+DBM_BUILD_DIR = $(NSCP_DISTDIR_FULL_RTL)/dbm
+DBM_LIBPATH = $(DBM_BUILD_DIR)/lib
+DBM_INCDIR = $(DBM_BUILD_DIR)/include
+DBM_DEP = $(DBM_LIBPATH)/libdbm.$(LIB_SUFFIX)
+DBM_IMPORT = $(COMPONENTS_DIR)/dbm/$(DBM_RELDATE)/$(NSOBJDIR_NAME)
+DBM_INCLUDE = -I$(DBM_INCDIR)
+DBM_LIBNAMES = dbm
+
+ifeq ($(ARCH), WINNT)
+  DBMOBJNAME = $(addsuffix .lib, $(DBM_LIBNAMES))
+  LIBDBM = $(addprefix $(DBM_LIBPATH)/, $(DBMOBJNAME))
+  DBMLINK = /LIBPATH:$(DBM_LIBPATH) $(DBMOBJNAME)
+  DBM_DEP = $(DBM_LIBPATH)/dbm.$(LIB_SUFFIX)
+else
+  DBM_SOLIBS = $(addsuffix .$(DLL_SUFFIX),  $(addprefix $(LIB_PREFIX), $(DBM_LIBNAMES)))
+  DBMROBJNAME = $(addsuffix .a, $(addprefix $(LIB_PREFIX), $(DBM_LIBNAMES)))
+  LIBDBM = $(addprefix $(DBM_LIBPATH)/, $(DBMROBJNAME))
+  DBMLINK = -L$(DBM_LIBPATH) $(addprefix -l, $(DBM_LIBNAMES))
+  DBM_DEP = $(DBM_LIBPATH)/libdbm.$(LIB_SUFFIX)
+endif
+
+ifndef DBM_PULL_METHOD
+DBM_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(DBM_DEP): $(NSCP_DISTDIR_FULL_RTL)
+ifdef COMPONENT_DEPS
+	$(FTP_PULL) -method $(DBM_PULL_METHOD) \
+		-objdir $(DBM_BUILD_DIR) -componentdir $(DBM_IMPORT)/.. \
+		-files xpheader.jar -unzip $(DBM_INCDIR)
+	$(FTP_PULL) -method $(DBM_PULL_METHOD) \
+		-objdir $(DBM_BUILD_DIR) -componentdir $(DBM_IMPORT) \
+		-files mdbinary.jar -unzip $(DBM_BUILD_DIR)
+endif
+	-@if [ ! -f $@ ] ; \
+	then echo "Error: could not get component DBM file $@" ; \
+	fi
+
+### DBM END #############################
+
+### SECURITY #############################
+SECURITY_BUILD_DIR = $(NSCP_DISTDIR_FULL_RTL)/nss
+SECURITY_LIBPATH = $(SECURITY_BUILD_DIR)/lib
+SECURITY_BINPATH = $(SECURITY_BUILD_DIR)/bin
+SECURITY_INCDIR = $(SECURITY_BUILD_DIR)/include
+SECURITY_INCLUDE = -I$(SECURITY_INCDIR)
+# add crlutil and ocspclnt when we support CRL and OCSP cert checking in DS
+ifeq ($(SECURITY_RELDATE), NSS_3_7_9_RTM)
+SECURITY_BINNAMES = certutil derdump pp pk12util ssltap modutil
+else
+SECURITY_BINNAMES = certutil derdump pp pk12util ssltap modutil shlibsign
+endif
+SECURITY_LIBNAMES = ssl3 nss3 softokn3
+SECURITY_IMPORT = $(COMPONENTS_DIR)/nss/$(SECURITY_RELDATE)/$(FULL_RTL_OBJDIR)
+
+SECURITY_LIBNAMES.pkg = $(SECURITY_LIBNAMES)
+SECURITY_LIBNAMES.pkg += smime3
+ifeq ($(ARCH), SOLARIS)
+SECURITY_LIBNAMES.pkg += freebl_hybrid_3 freebl_pure32_3 fort swft
+endif
+ifeq ($(ARCH), HPUX)
+SECURITY_LIBNAMES.pkg += freebl_hybrid_3 freebl_pure32_3 fort swft
+endif
+ifeq ($(ARCH), AIX)
+SECURITY_LIBNAMES.pkg += fort swft
+endif
+ifeq ($(ARCH), OSF1)
+SECURITY_LIBNAMES.pkg += fort swft
+endif
+ifeq ($(ARCH), WINNT)
+SECURITY_LIBNAMES.pkg += fort32 swft32
+endif
+
+SECURITY_TOOLS = $(addsuffix $(EXE_SUFFIX),$(SECURITY_BINNAMES))
+SECURITY_TOOLS_FULLPATH = $(addprefix $(SECURITY_BINPATH)/, $(SECURITY_TOOLS))
+
+SECURITY_LIBS_TO_PKG = $(addsuffix .$(DLL_SUFFIX),$(addprefix $(SECURITY_LIBPATH)/$(LIB_PREFIX),$(SECURITY_LIBNAMES.pkg)))
+ifneq ($(SECURITY_RELDATE), NSS_3_7_9_RTM)
+SECURITY_LIBS_TO_PKG += $(addsuffix .chk,$(addprefix $(SECURITY_LIBPATH)/$(LIB_PREFIX),$(SECURITY_LIBNAMES.pkg)))
+endif
+LIBS_TO_PKG += $(SECURITY_LIBS_TO_PKG)
+LIBS_TO_PKG_SHARED += $(SECURITY_LIBS_TO_PKG) # for cmd line tools
+PACKAGE_SETUP_LIBS += $(SECURITY_LIBS_TO_PKG)
+LIBS_TO_PKG_CLIENTS += $(SECURITY_LIBS_TO_PKG) # for dsgw
+
+ifeq ($(ARCH), WINNT)
+  SECURITYOBJNAME = $(addsuffix .$(LIB_SUFFIX), $(SECURITY_LIBNAMES))
+  LIBSECURITY = $(addprefix $(SECURITY_LIBPATH)/, $(SECURITYOBJNAME))
+  SECURITYLINK = /LIBPATH:$(SECURITY_LIBPATH) $(SECURITYOBJNAME)
+  SECURITY_DEP = $(SECURITY_LIBPATH)/ssl3.$(DLL_SUFFIX)
+else
+  SECURITYOBJNAME = $(addsuffix .$(DLL_SUFFIX), $(addprefix $(LIB_PREFIX), $(SECURITY_LIBNAMES)))
+  LIBSECURITY = $(addprefix $(SECURITY_LIBPATH)/, $(SECURITYOBJNAME))
+  SECURITYLINK = -L$(SECURITY_LIBPATH) $(addprefix -l, $(SECURITY_LIBNAMES))
+  SECURITY_DEP = $(SECURITY_LIBPATH)/libssl3.$(DLL_SUFFIX)
+endif
+
+# we need to package the root cert file in the alias directory
+PACKAGE_SRC_DEST += $(SECURITY_LIBPATH)/$(LIB_PREFIX)nssckbi.$(DLL_SUFFIX) alias
+
+# need to package the sec tools in shared/bin
+BINS_TO_PKG_SHARED += $(SECURITY_TOOLS_FULLPATH)
+
+#ifeq ($(ARCH), OSF1)
+#OSF1SECURITYHACKOBJ = $(OBJDIR)/osf1securityhack.o
+
+#$(OSF1SECURITYHACKOBJ): $(MCOM_ROOT)/ldapserver/osf1securityhack.c
+#	$(CC) -c $(CFLAGS) $(MCC_INCLUDE) $< -o $@
+
+#  SECURITYLINK += $(OSF1SECURITYHACKOBJ)
+#endif
+
+SECURITY_FILES=lib,include,bin/$(subst $(SPACE),$(COMMA)bin/,$(SECURITY_TOOLS))
+
+ifndef SECURITY_PULL_METHOD
+SECURITY_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(SECURITY_DEP): $(NSCP_DISTDIR_FULL_RTL) $(OSF1SECURITYHACKOBJ)
+ifdef COMPONENT_DEPS
+	mkdir -p $(SECURITY_BINPATH)
+	$(FTP_PULL) -method $(SECURITY_PULL_METHOD) \
+		-objdir $(SECURITY_BUILD_DIR) -componentdir $(SECURITY_IMPORT) \
+		-files $(SECURITY_FILES)
+endif
+	-@if [ ! -f $@ ] ; \
+	then echo "Error: could not get component NSS file $@" ; \
+	fi
+
+### SECURITY END #############################
+
+### SVRCORE #############################
+SVRCORE_BUILD_DIR = $(NSCP_DISTDIR)/svrcore
+SVRCORE_LIBPATH = $(SVRCORE_BUILD_DIR)/lib
+SVRCORE_INCDIR = $(SVRCORE_BUILD_DIR)/include
+SVRCORE_INCLUDE = -I$(SVRCORE_INCDIR)
+#SVRCORE_LIBNAMES = svrplcy svrcore
+SVRCORE_LIBNAMES = svrcore
+SVRCORE_IMPORT = $(COMPONENTS_DIR)/svrcore/$(SVRCORE_RELDATE)/$(NSOBJDIR_NAME)
+
+ifeq ($(ARCH), WINNT)
+  SVRCOREOBJNAME = $(addsuffix .lib, $(SVRCORE_LIBNAMES))
+  LIBSVRCORE = $(addprefix $(SVRCORE_LIBPATH)/, $(SVRCOREOBJNAME))
+  SVRCORELINK = /LIBPATH:$(SVRCORE_LIBPATH) $(SVRCOREOBJNAME)
+  SVRCORE_DEP = $(SVRCORE_LIBPATH)/svrcore.$(LIB_SUFFIX)
+else
+  SVRCOREOBJNAME = $(addsuffix .a, $(addprefix $(LIB_PREFIX), $(SVRCORE_LIBNAMES)))
+  LIBSVRCORE = $(addprefix $(SVRCORE_LIBPATH)/, $(SVRCOREOBJNAME))
+ifeq ($(ARCH), OSF1)
+# the -all flag is used by default.  This flag causes _all_ objects in lib.a files to
+# be processed and linked.  This causes problems with svrcore because there are
+# several undefined symbols (notably, the JSS_xxx functions)
+  SVRCORELINK = -L$(SVRCORE_LIBPATH) -none $(addprefix -l, $(SVRCORE_LIBNAMES)) -all
+else
+  SVRCORELINK = -L$(SVRCORE_LIBPATH) $(addprefix -l, $(SVRCORE_LIBNAMES))
+endif
+  SVRCORE_DEP = $(SVRCORE_LIBPATH)/libsvrcore.$(LIB_SUFFIX)
+endif
+
+ifndef SVRCORE_PULL_METHOD
+SVRCORE_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(SVRCORE_DEP): $(NSCP_DISTDIR)
+ifdef COMPONENT_DEPS
+	$(FTP_PULL) -method $(SVRCORE_PULL_METHOD) \
+		-objdir $(SVRCORE_BUILD_DIR) -componentdir $(SVRCORE_IMPORT)/.. \
+		-files xpheader.jar -unzip $(SVRCORE_INCDIR)
+	$(FTP_PULL) -method $(SVRCORE_PULL_METHOD) \
+		-objdir $(SVRCORE_BUILD_DIR) -componentdir $(SVRCORE_IMPORT) \
+		-files mdbinary.jar -unzip $(SVRCORE_BUILD_DIR)
+endif
+	-@if [ ! -f $@ ] ; \
+	then echo "Error: could not get component SVRCORE file $@" ; \
+	fi
+
+### SVRCORE END #############################
+
+### SETUPSDK #############################
+# this is where the build looks for setupsdk components
+SETUP_SDK_BUILD_DIR = $(NSCP_DISTDIR)/setupsdk
+SETUPSDK_VERSION = $(SETUP_SDK_RELDATE)$(SEC_SUFFIX)
+SETUPSDK_RELEASE = $(COMPONENTS_DIR)/setupsdk/$(SETUPSDK_VERSDIR)/$(SETUPSDK_VERSION)/$(NSOBJDIR_NAME)
+SETUPSDK_LIBPATH = $(SETUP_SDK_BUILD_DIR)/lib
+SETUPSDK_INCDIR = $(SETUP_SDK_BUILD_DIR)/include
+SETUPSDK_BINPATH = $(SETUP_SDK_BUILD_DIR)/bin
+SETUPSDK_INCLUDE = -I$(SETUPSDK_INCDIR)
+
+ifeq ($(ARCH), WINNT)
+SETUP_SDK_FILES = setupsdk.tar.gz -unzip $(NSCP_DISTDIR)/setupsdk
+SETUPSDK_DEP = $(SETUPSDK_LIBPATH)/nssetup32.$(LIB_SUFFIX)
+SETUPSDKLINK = /LIBPATH:$(SETUPSDK_LIBPATH) nssetup32.$(LIB_SUFFIX)
+SETUPSDK_S_LINK = /LIBPATH:$(SETUPSDK_LIBPATH) nssetup32_s.$(LIB_SUFFIX)
+else
+SETUP_SDK_FILES = bin,lib,include
+SETUPSDK_DEP = $(SETUPSDK_LIBPATH)/libinstall.$(LIB_SUFFIX)
+SETUPSDKLINK = -L$(SETUPSDK_LIBPATH) -linstall
+SETUPSDK_S_LINK = $(SETUPSDKLINK)
+endif
+
+ifndef SETUPSDK_PULL_METHOD
+SETUPSDK_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(SETUPSDK_DEP): $(NSCP_DISTDIR)
+ifdef COMPONENT_DEPS
+	$(FTP_PULL) -method $(SETUPSDK_PULL_METHOD) \
+		-objdir $(SETUP_SDK_BUILD_DIR) -componentdir $(SETUPSDK_RELEASE) \
+		-files $(SETUP_SDK_FILES)
+endif
+	-@if [ ! -f $@ ] ; \
+	then echo "Error: could not get component SETUPSDK file $@" ; \
+	fi
+
+####################################################
+# LDAP SDK
+###################################################
+ifndef LDAP_VERSION
+  LDAP_VERSION = $(LDAP_RELDATE)$(SEC_SUFFIX)
+endif
+
+LDAP_ROOT = $(NSCP_DISTDIR_FULL_RTL)/ldapsdk
+LDAPSDK_LIBPATH = $(LDAP_ROOT)/lib
+LDAPSDK_INCDIR = $(LDAP_ROOT)/include
+LDAPSDK_INCLUDE = -I$(LDAPSDK_INCDIR)
+ifndef LDAP_SBC
+# LDAP_SBC = $(COMPONENTS_DIR_DEV)
+LDAP_SBC = $(COMPONENTS_DIR)
+endif
+
+# package the command line programs
+LDAPSDK_TOOLS = $(wildcard $(LDAP_ROOT)/tools/*$(EXE_SUFFIX))
+BINS_TO_PKG_SHARED += $(LDAPSDK_TOOLS)
+# package the include files - needed for the plugin API
+LDAPSDK_INCLUDE_FILES = $(wildcard $(LDAPSDK_INCDIR)/*.h)
+PACKAGE_SRC_DEST += $(subst $(SPACE),$(SPACE)plugins/slapd/slapi/include$(SPACE),$(LDAPSDK_INCLUDE_FILES))
+PACKAGE_SRC_DEST += plugins/slapd/slapi/include
+
+LDAPOBJDIR = $(FULL_RTL_OBJDIR)
+ifeq ($(ARCH), WINNT)
+  ifeq ($(PROCESSOR), ALPHA)
+	ifeq ($(DEBUG), full)
+	  LDAPOBJDIR = WINNTALPHA3.51_DBG.OBJ
+	else
+	  LDAPOBJDIR = WINNTALPHA3.51_OPT.OBJ
+	endif
+  endif
+
+  LDAP_RELEASE = $(LDAP_SBC)/$(LDAPCOMP_DIR)/$(LDAP_VERSION)/$(LDAPOBJDIR)
+  LDAP_LIBNAMES = ldapssl32v$(LDAP_SUF) ldap32v$(LDAP_SUF) ldappr32v$(LDAP_SUF)
+  LDAPDLL_NAME = $(addprefix ns, $(LDAP_LIBNAMES))
+  LDAPOBJNAME = $(addsuffix .$(LIB_SUFFIX), $(LDAPDLL_NAME))
+  LDAPLINK = /LIBPATH:$(LDAPSDK_LIBPATH) $(LDAPOBJNAME)
+  LIBLDAPDLL_NAMES = $(addsuffix .dll, $(addprefix $(LDAP_LIBPATH)/, $(LDAPDLL_NAME)))
+  LDAPSDK_DEP = $(LDAPSDK_LIBPATH)/nsldap32v$(LDAP_SUF).$(DLL_SUFFIX)
+  LDAPSDK_PULL_LIBS = lib/nsldapssl32v$(LDAP_SUF).$(LIB_SUFFIX),lib/nsldapssl32v$(LDAP_SUF).$(LDAP_DLL_SUFFIX),lib/nsldap32v$(LDAP_SUF).$(LIB_SUFFIX),lib/nsldap32v$(LDAP_SUF).$(LDAP_DLL_SUFFIX),lib/nsldappr32v$(LDAP_SUF).$(LIB_SUFFIX),lib/nsldappr32v$(LDAP_SUF).$(LDAP_DLL_SUFFIX)
+
+  LIBS_TO_PKG += $(addsuffix .$(DLL_SUFFIX),$(addprefix $(LDAPSDK_LIBPATH)/,$(LDAPDLL_NAME)))
+  PACKAGE_SETUP_LIBS += $(addsuffix .$(DLL_SUFFIX),$(addprefix $(LDAPSDK_LIBPATH)/,$(LDAPDLL_NAME)))
+  LIBS_TO_PKG_SHARED += $(addsuffix .$(DLL_SUFFIX),$(addprefix $(LDAPSDK_LIBPATH)/,$(LDAPDLL_NAME)))
+  LIBS_TO_PKG_CLIENTS += $(addsuffix .$(DLL_SUFFIX),$(addprefix $(LDAPSDK_LIBPATH)/,$(LDAPDLL_NAME)))
+endif
+
+# override LDAP version in OS specific section
+ifneq ($(ARCH), WINNT)
+# LDAP Does not has PTH version, so here is the hack which treat non PTH
+# version as PTH version
+  ifeq ($(USE_PTHREADS), 1)
+	LDAP_RELEASE = $(LDAP_SBC)/$(LDAPCOMP_DIR)/$(LDAP_VERSION)/$(NSOBJDIR_NAME1)
+  else
+	LDAP_RELEASE = $(LDAP_SBC)/$(LDAPCOMP_DIR)/$(LDAP_VERSION)/$(LDAPOBJDIR)
+  endif
+  LDAP_SOLIB_NAMES = ssldap$(LDAP_SUF)$(LDAP_DLL_PRESUF) ldap$(LDAP_SUF)$(LDAP_DLL_PRESUF) prldap$(LDAP_SUF)$(LDAP_DLL_PRESUF)
+  ifndef LDAP_NO_LIBLCACHE
+	LDAP_SOLIB_NAMES += lcache30$(LDAP_DLL_PRESUF)
+  endif
+  LDAP_DOTALIB_NAMES =
+  LDAP_LIBNAMES = $(LDAP_DOTALIB_NAMES) $(LDAP_SOLIB_NAMES)
+  LDAP_SOLIBS = $(addsuffix .$(LDAP_DLL_SUFFIX), $(addprefix $(LIB_PREFIX), $(LDAP_SOLIB_NAMES)))
+  LDAPOBJNAME = $(addsuffix .$(LIB_SUFFIX), $(addprefix $(LIB_PREFIX), $(LDAP_DOTALIB_NAMES))) \
+		$(LDAP_SOLIBS)
+  LDAPSDK_DEP = $(LDAPSDK_LIBPATH)/libldap$(LDAP_SUF).$(DLL_SUFFIX)
+  LDAPLINK = -L$(LDAPSDK_LIBPATH) $(addprefix -l,$(LDAP_SOLIB_NAMES))
+  LDAP_NOSSL_LINK = -L$(LDAPSDK_LIBPATH) -lldap$(LDAP_SUF)$(LDAP_DLL_PRESUF)
+  LDAPSDK_PULL_LIBS = lib/libssldap$(LDAP_SUF)$(LDAP_DLL_PRESUF).$(LDAP_DLL_SUFFIX),lib/libldap$(LDAP_SUF)$(LDAP_DLL_PRESUF).$(LDAP_DLL_SUFFIX),lib/libprldap$(LDAP_SUF)$(LDAP_DLL_PRESUF).$(LDAP_DLL_SUFFIX)
+
+  LIBS_TO_PKG += $(addprefix $(LDAPSDK_LIBPATH)/,$(LDAP_SOLIBS))
+  PACKAGE_SETUP_LIBS += $(addprefix $(LDAPSDK_LIBPATH)/,$(LDAP_SOLIBS))
+  LIBS_TO_PKG_SHARED += $(addprefix $(LDAPSDK_LIBPATH)/,$(LDAP_SOLIBS))
+  LIBS_TO_PKG_CLIENTS += $(addprefix $(LDAPSDK_LIBPATH)/,$(LDAP_SOLIBS))
+endif
+
+LDAP_LIBPATH = $(LDAP_ROOT)/lib
+LDAP_INCLUDE = $(LDAP_ROOT)/include
+LDAP_TOOLDIR = $(LDAP_ROOT)/tools
+LIBLDAP = $(addprefix $(LDAP_LIBPATH)/, $(LDAPOBJNAME))
+LDAPSDK_FILES = include,$(LDAPSDK_PULL_LIBS),tools
+
+ifndef LDAPSDK_PULL_METHOD
+LDAPSDK_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(LDAPSDK_DEP): $(NSCP_DISTDIR_FULL_RTL)
+ifdef COMPONENT_DEPS
+	mkdir -p $(LDAP_LIBPATH)
+	$(FTP_PULL) -method $(LDAPSDK_PULL_METHOD) \
+		-objdir $(LDAP_ROOT) -componentdir $(LDAP_RELEASE) \
+		-files $(LDAPSDK_FILES)
+endif
+	-@if [ ! -f $@ ] ; \
+	then echo "Error: could not get component LDAPSDK file $@" ; \
+	fi
+
+####################################################
+# DSRK
+####################################################
+ifndef DSRK_VERSION
+ DSRK_VERSION = $(DSRK_RELDATE)$(SEC_SUFFIX)
+endif
+ifndef DSRK_SBC
+# DSRK_SBC = $(COMPONENTS_DIR_DEV)
+DSRK_SBC = $(COMPONENTS_DIR)
+endif
+
+DSRK_RELEASE = $(DSRK_SBC)/dsrk/$(DSRKCOMP_DIR)/$(DSRK_VERSION)/$(NSOBJDIR_NAME)
+DSRK_FILES = bin,perl
+DSRK_BUILD_DIR = $(NSCP_DISTDIR)/dsrk
+DSRK_DEP = $(DSRK_BUILD_DIR)/bin/n$(DSRKCOMP_DIR)
+
+ifndef DSRK_PULL_METHOD
+DSRK_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(DSRK_DEP): $(NSCP_DISTDIR_FULL_RTL)
+ifdef COMPONENT_DEPS
+	$(FTP_PULL) -method $(DSRK_PULL_METHOD) \
+		-objdir $(DSRK_BUILD_DIR) -componentdir $(DSRK_RELEASE) \
+		-files $(DSRK_FILES)
+endif
+	-@if [ ! -d $@ ] ; \
+	then echo "Error: could not get component DSRK file $@" ; \
+	fi
+
+# apache-axis java classes #######################################
+AXIS = axis-bin-$(AXIS_VERSION).zip
+AXIS_FILES = $(AXIS)
+#AXIS_RELEASE = $(COMPONENTS_DIR)
+AXIS_RELEASE = $(COMPONENTS_DIR_DEV)/ds/ds70-bozeman
+#AXISJAR_DIR = $(AXISJAR_RELEASE)/$(AXISJAR_COMP)/$(AXISJAR_VERSION)
+AXIS_DIR = $(AXIS_RELEASE)/axis
+AXIS_FILE = $(CLASS_DEST)/$(AXIS)
+AXIS_DEP = $(AXIS_FILE) 
+AXIS_REL_DIR=$(subst -bin,,$(subst .zip,,$(AXIS)))
+
+
+# This is java, so there is only one real platform subdirectory
+
+#PACKAGE_UNDER_JAVA += $(AXIS_FILE)
+
+ifndef AXIS_PULL_METHOD
+AXIS_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(AXIS_DEP): $(CLASS_DEST) 
+ifdef COMPONENT_DEPS
+	echo "Inside ftppull"
+	$(FTP_PULL) -method $(COMPONENT_PULL_METHOD) \
+		-objdir $(CLASS_DEST) -componentdir $(AXIS_DIR) \
+		-files $(AXIS_FILES) -unzip $(CLASS_DEST)
+endif
+	-@if [ ! -f $@ ] ; \
+	then echo "Error: could not get component AXIS files $@" ; \
+	fi
+
+###########################################################
+
+
+# other dsml java classes #######################################
+DSMLJAR = activation.jar,jaxrpc-api.jar,jaxrpc.jar,saaj.jar,xercesImpl.jar,xml-apis.jar
+DSMLJAR_FILES = $(DSMLJAR)
+DSMLJAR_RELEASE = $(COMPONENTS_DIR_DEV)/ds/ds70-bozeman
+#DSMLJARJAR_DIR = $(DSMLJARJAR_RELEASE)/$(DSMLJARJAR_COMP)/$(DSMLJARJAR_VERSION)
+DSMLJAR_DIR = $(DSMLJAR_RELEASE)/dsmljars
+DSMLJAR_FILE = $(CLASS_DEST)
+DSMLJAR_DEP = $(CLASS_DEST)/activation.jar $(CLASS_DEST)/jaxrpc-api.jar $(CLASS_DEST)/jaxrpc.jar $(CLASS_DEST)/saaj.jar $(CLASS_DEST)/xercesImpl.jar $(CLASS_DEST)/xml-apis.jar
+
+ifndef DSMLJAR_PULL_METHOD
+DSMLJAR_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(DSMLJAR_DEP): $(CLASS_DEST) 
+ifdef COMPONENT_DEPS
+	echo "Inside ftppull"
+	$(FTP_PULL) -method $(COMPONENT_PULL_METHOD) \
+		-objdir $(CLASS_DEST) -componentdir $(DSMLJAR_DIR) \
+		-files $(DSMLJAR_FILES)
+
+endif
+	-@if [ ! -f $@ ] ; \
+	then echo "Error: could not get component DSMLJAR files $@" ; \
+	fi
+
+###########################################################
+
+# XMLTOOLS java classes #######################################
+CRIMSONJAR = crimson.jar
+CRIMSON_LICENSE = LICENSE.crimson
+CRIMSONJAR_FILES = $(CRIMSONJAR),$(CRIMSON_LICENSE)
+CRIMSONJAR_RELEASE = $(COMPONENTS_DIR)
+CRIMSONJAR_DIR = $(CRIMSONJAR_RELEASE)/$(CRIMSONJAR_COMP)/$(CRIMSONJAR_VERSION)
+CRIMSONJAR_FILE = $(CLASS_DEST)/$(CRIMSONJAR)
+CRIMSONJAR_DEP = $(CRIMSONJAR_FILE) $(CLASS_DEST)/$(CRIMSON_LICENSE)
+
+
+# This is java, so there is only one real platform subdirectory
+
+PACKAGE_UNDER_JAVA += $(CRIMSONJAR_FILE)
+
+ifndef CRIMSONJAR_PULL_METHOD
+CRIMSONJAR_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(CRIMSONJAR_DEP): $(CLASS_DEST)
+ifdef COMPONENT_DEPS
+	echo "Inside ftppull"
+	$(FTP_PULL) -method $(COMPONENT_PULL_METHOD) \
+		-objdir $(CLASS_DEST) -componentdir $(CRIMSONJAR_DIR) \
+		-files $(CRIMSONJAR_FILES)
+endif
+	-@if [ ! -f $@ ] ; \
+	then echo "Error: could not get component CRIMSONJAR files $@" ; \
+	fi
+
+###########################################################
+
+# ANT java classes #######################################
+ifeq ($(BUILD_JAVA_CODE),1)
+#  (we use ant for building some Java code)
+ANTJAR = ant.jar
+JAXPJAR = jaxp.jar
+ANT_FILES = $(ANTJAR) $(JAXPJAR)
+ANT_RELEASE = $(COMPONENTS_DIR)
+ANT_HOME = $(ANT_RELEASE)/$(ANT_COMP)/$(ANT_VERSION)
+ANT_DIR = $(ANT_HOME)/lib
+ANT_DEP = $(addprefix $(CLASS_DEST)/, $(ANT_FILES))
+ANT_CP = $(subst $(SPACE),$(PATH_SEP),$(ANT_DEP))
+ANT_PULL = $(subst $(SPACE),$(COMMA),$(ANT_FILES))
+
+ifndef ANT_PULL_METHOD
+ANT_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(ANT_DEP): $(CLASS_DEST) $(CRIMSONJAR_DEP)
+ifdef COMPONENT_DEPS
+	echo "Inside ftppull"
+	$(FTP_PULL) -method $(COMPONENT_PULL_METHOD) \
+		-objdir $(CLASS_DEST) -componentdir $(ANT_DIR) \
+		-files $(ANT_PULL)
+endif
+	-@if [ ! -f $@ ] ; \
+	then echo "Error: could not get component ant files $@" ; \
+	fi
+endif
+###########################################################
+
+# Servlet SDK classes #######################################
+SERVLETJAR = servlet.jar
+SERVLET_FILES = $(SERVLETJAR)
+SERVLET_RELEASE = $(COMPONENTS_DIR)
+SERVLET_DIR = $(SERVLET_RELEASE)/$(SERVLET_COMP)/$(SERVLET_VERSION)
+SERVLET_DEP = $(addprefix $(CLASS_DEST)/, $(SERVLET_FILES))
+SERVLET_CP = $(subst $(SPACE),$(PATH_SEP),$(SERVLET_DEP))
+SERVLET_PULL = $(subst $(SPACE),$(COMMA),$(SERVLET_FILES))
+
+ifndef SERVLET_PULL_METHOD
+SERVLET_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(SERVLET_DEP): $(CLASS_DEST)
+ifdef COMPONENT_DEPS
+	echo "Inside ftppull"
+	$(FTP_PULL) -method $(COMPONENT_PULL_METHOD) \
+		-objdir $(CLASS_DEST) -componentdir $(SERVLET_DIR) \
+		-files $(SERVLET_PULL)
+endif
+	-@if [ ! -f $@ ] ; \
+	then echo "Error: could not get component servlet SDK files $@" ; \
+	fi
+
+###########################################################
+
+# LDAP java classes #######################################
+LDAPJDK = ldapjdk.jar
+LDAPJDK_VERSION = $(LDAPJDK_RELDATE)
+LDAPJDK_RELEASE = $(COMPONENTS_DIR)
+LDAPJDK_DIR = $(LDAPJDK_RELEASE)
+LDAPJDK_IMPORT = $(LDAPJDK_RELEASE)/$(LDAPJDK_COMP)/$(LDAPJDK_VERSION)/$(NSOBJDIR_NAME)
+# This is java, so there is only one real platform subdirectory
+LDAPJARFILE=$(CLASS_DEST)/ldapjdk.jar
+LDAPJDK_DEP=$(LDAPJARFILE)
+
+#PACKAGE_UNDER_JAVA += $(LDAPJARFILE)
+
+ifndef LDAPJDK_PULL_METHOD
+LDAPJDK_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(LDAPJDK_DEP): $(CLASS_DEST)
+ifdef COMPONENT_DEPS
+	$(FTP_PULL) -method $(LDAPJDK_PULL_METHOD) \
+		-objdir $(CLASS_DEST) -componentdir $(LDAPJDK_IMPORT) \
+		-files $(LDAPJDK)
+endif
+	-@if [ ! -f $@ ] ; \
+	then echo "Error: could not get component LDAPJDK file $@" ; \
+	fi
+
+###########################################################
+
+# MCC java classes - the Mission Control Console #########
+MCC_VERSION=$(MCC_RELDATE)$(SEC_SUFFIX)
+#
+MCCJAR = mcc$(MCC_REL).jar
+MCCJAR_EN = mcc$(MCC_REL)_en.jar
+NMCLFJAR = nmclf$(MCC_REL).jar
+NMCLFJAR_EN = nmclf$(MCC_REL)_en.jar
+BASEJAR = base.jar
+#MCC_RELEASE=$(COMPONENTS_DIR_DEV)
+MCC_RELEASE=$(COMPONENTS_DIR)
+MCC_JARDIR = $(MCC_RELEASE)/$(MCC_COMP)/$(MCC_VERSION)/jars
+MCCJARFILE=$(CLASS_DEST)/$(MCCJAR)
+NMCLFJARFILE=$(CLASS_DEST)/$(NMCLFJAR)
+BASEJARFILE=$(CLASS_DEST)/$(BASEJAR)
+
+MCC_DEP = $(BASEJARFILE)
+MCC_FILES=$(MCCJAR),$(MCCJAR_EN),$(NMCLFJAR),$(NMCLFJAR_EN),$(BASEJAR)
+
+#PACKAGE_UNDER_JAVA += $(addprefix $(CLASS_DEST)/,$(subst $(COMMA),$(SPACE),$(MCC_FILES)))
+
+ifndef MCC_PULL_METHOD
+MCC_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(MCC_DEP): $(CLASS_DEST)
+ifdef COMPONENT_DEPS
+	$(FTP_PULL) -method $(MCC_PULL_METHOD) \
+		-objdir $(CLASS_DEST) -componentdir $(MCC_JARDIR) \
+		-files $(MCC_FILES)
+endif
+	-@if [ ! -f $@ ] ; \
+	then echo "Error: could not get component MCC file $@" ; \
+	fi
+
+###########################################################
+
+###########################################################
+### Perldap package #######################################
+
+PERLDAP_COMPONENT_DIR = $(COMPONENTS_DIR)/perldap/$(PERLDAP_VERSION)/$(NSOBJDIR_NAME_32)
+PERLDAP_ZIP_FILE = perldap14.zip
+
+###########################################################
+
+# JSS classes - for the Mission Control Console ######
+JSSJAR = jss$(JSS_JAR_VERSION).jar
+JSSJARFILE = $(CLASS_DEST)/$(JSSJAR)
+JSS_RELEASE = $(COMPONENTS_DIR)/$(JSS_COMP)/$(JSS_VERSION)
+JSS_DEP = $(JSSJARFILE)
+
+#PACKAGE_UNDER_JAVA += $(JSSJARFILE)
+
+ifndef JSS_PULL_METHOD
+JSS_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(JSS_DEP): $(CLASS_DEST)
+ifdef COMPONENT_DEPS
+	$(FTP_PULL) -method $(JSS_PULL_METHOD) \
+		-objdir $(CLASS_DEST) -componentdir $(JSS_RELEASE) \
+		-files $(JSSJAR)
+endif
+	-@if [ ! -f $@ ] ; \
+	then echo "Error: could not get component JSS file $@" ; \
+	fi
+
+###########################################################
+
+###########################################################
+### Admin Server package ##################################
+
+ADMIN_REL = $(ADM_VERSDIR)
+ADMIN_REL_DATE = $(ADM_VERSION)
+ADMIN_FILE = admserv.tar.gz
+ADMIN_FILE_TAR = admserv.tar
+ADMSDKOBJDIR = $(NSCONFIG)$(NSOBJDIR_TAG).OBJ
+IMPORTADMINSRV_BASE=$(COMPONENTS_DIR)/$(ADMIN_REL)/$(ADMIN_REL_DATE)
+IMPORTADMINSRV = $(IMPORTADMINSRV_BASE)/$(NSOBJDIR_NAME_32)
+ADMSERV_DIR=$(ABS_ROOT)/dist/$(NSOBJDIR_NAME)/admserv
+ADMSERV_DEP = $(ADMSERV_DIR)/setup$(EXE_SUFFIX)
+
+ifdef FORTEZZA
+  ADM_VERSION = $(ADM_RELDATE)F
+else
+  ifeq ($(SECURITY), domestic)
+    ADM_VERSION = $(ADM_RELDATE)D
+  else
+    ifneq ($(ARCH), IRIX)
+        ADM_VERSION = $(ADM_RELDATE)E
+    else
+        ADM_VERSION = $(ADM_RELDATE)D
+    endif
+  endif
+endif
+
+ADM_VERSION = $(ADM_RELDATE)$(SEC_SUFFIX)
+ADM_RELEASE = $(COMPONENTS_DIR)/$(ADM_VERSDIR)/$(ADM_VERSION)/$(NSOBJDIR_NAME)
+
+ifndef ADMSERV_PULL_METHOD
+ADMSERV_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+ifndef ADMSERV_DEPS
+ADMSERV_DEPS = $(COMPONENT_DEPS)
+endif
+#IMPORTADMINSRV = /share/builds/sbsrel1/admsvr/admsvr62/ships/20030702.2/spd04_Solaris8/SunOS5.8-domestic-optimize-normal
+#ADM_RELEASE = /share/builds/sbsrel1/admsvr/admsvr62/ships/20030702.2/spd04_Solaris8/SunOS5.8-domestic-optimize-normal
+$(ADMSERV_DEP): $(ABS_ROOT)/dist/$(NSOBJDIR_NAME)
+ifdef ADMSERV_DEPS
+	$(FTP_PULL) -method $(ADMSERV_PULL_METHOD) \
+		-objdir $(ADMSERV_DIR) -componentdir $(IMPORTADMINSRV) \
+		-files $(ADMIN_FILE) -unzip $(ADMSERV_DIR)
+endif
+	@if [ ! -f $@ ] ; \
+	then echo "Error: could not get component ADMINSERV file $@" ; \
+	exit 1 ; \
+	fi
+### Admin Server END ######################################
+
+
+
+### SASL package ##########################################
+
+SASL_BUILD_DIR = $(NSCP_DISTDIR_FULL_RTL)/sasl
+SASL_RELEASE = $(COMPONENTS_DIR)/sasl/$(SASL_VERSDIR)/$(SASL_RELDATE)/$(NSOBJDIR_NAME)
+SASL_LIBPATH = $(SASL_BUILD_DIR)/lib
+SASL_BINPATH = $(SASL_BUILD_DIR)/bin
+SASL_INCLUDE = $(SASL_BUILD_DIR)/include
+SASL_DEP = $(SASL_INCLUDE)/sasl.h
+ifeq ($(ARCH), WINNT)
+SASL_LINK = /LIBPATH:$(SASL_LIBPATH) sasl.lib
+else
+ifeq ($(ARCH), SOLARIS)
+GSSAPI_LIBS=-lgss
+endif
+#ifeq ($(ARCH), HPUX)
+GSSAPI_LIBS=-lgss
+#endif
+ifeq ($(ARCH), Linux)
+GSSAPI_LIBS=-L/usr/kerberos/lib -lgssapi_krb5
+endif
+SASL_LINK = -L$(SASL_LIBPATH) -lsasl $(GSSAPI_LIBS)
+#SASL_LINK = -L$(SASL_LIBPATH) -lsasl
+endif
+
+ifndef SASL_PULL_METHOD
+SASL_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(SASL_DEP): $(NSCP_DISTDIR_FULL_RTL)
+ifdef COMPONENT_DEPS
+	$(FTP_PULL) -method $(SASL_PULL_METHOD) \
+		-objdir $(SASL_BUILD_DIR) -componentdir $(SASL_RELEASE) \
+		-files lib,include
+endif
+	-@if [ ! -f $@ ] ; \
+	then echo "Error: could not get component SASL file $@" ; \
+	fi
+
+###########################################################
+
+### JSP compiler package ##################################
+
+JSPC_REL = $(JSPC_VERSDIR)
+JSPC_REL_DATE = $(JSPC_VERSION)
+JSPC_FILES = jasper-compiler.jar jasper-runtime.jar
+JSPC_RELEASE = $(COMPONENTS_DIR)
+JSPC_DIR = $(JSPC_RELEASE)/$(JSPC_COMP)/$(JSPC_VERSION)
+JSPC_DEP = $(addprefix $(CLASS_DEST)/, $(JSPC_FILES))
+JSPC_CP = $(subst $(SPACE),$(PATH_SEP),$(JSPC_DEP))
+JSPC_PULL = $(subst $(SPACE),$(COMMA),$(JSPC_FILES))
+
+ifndef JSPC_PULL_METHOD
+JSPC_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(JSPC_DEP): $(CLASS_DEST)
+ifdef COMPONENT_DEPS
+	echo "Inside ftppull"
+	$(FTP_PULL) -method $(COMPONENT_PULL_METHOD) \
+		-objdir $(CLASS_DEST) -componentdir $(JSPC_DIR) \
+		-files $(JSPC_PULL)
+endif
+	-@if [ ! -f $@ ] ; \
+	then echo "Error: could not get component jspc files $@" ; \
+	fi
+
+###########################################################
+
+### ICU package ##########################################
+
+ICU_LIB_VERSION = 24
+ICU_BUILD_DIR = $(NSCP_DISTDIR_FULL_RTL)/libicu
+ICU_RELEASE = $(COMPONENTS_DIR)/libicu/$(ICU_VERSDIR)/$(ICU_RELDATE)/$(NSOBJDIR_NAME)
+ICU_LIBPATH = $(ICU_BUILD_DIR)/lib
+ICU_BINPATH = $(ICU_BUILD_DIR)/bin
+ICU_INCPATH = $(ICU_BUILD_DIR)/include
+ICU_DEP = $(ICU_INCPATH)/unicode/unicode.h
+ICU_INCLUDE = -I$(ICU_INCPATH)
+ifeq ($(ARCH), WINNT)
+ifeq ($(BUILD_DEBUG), optimize)
+ICU_LIB_SUF=
+else
+ICU_LIB_SUF=d
+endif
+ICU_LIBNAMES = icuin$(ICU_LIB_SUF) icuuc$(ICU_LIB_SUF) icudata
+ICU_DLLNAMES = icuin$(ICU_LIB_VERSION)$(ICU_LIB_SUF) icuuc$(ICU_LIB_VERSION)$(ICU_LIB_SUF) icudt$(ICU_LIB_VERSION)l
+ICULINK = /LIBPATH:$(ICU_LIBPATH) $(addsuffix .$(LIB_SUFFIX),$(ICU_LIBNAMES))
+LIBS_TO_PKG += $(addsuffix .$(DLL_SUFFIX),$(addprefix $(ICU_BINPATH)/,$(ICU_DLLNAMES)))
+LIBS_TO_PKG_SHARED += $(addsuffix .$(DLL_SUFFIX),$(addprefix $(ICU_BINPATH)/,$(ICU_DLLNAMES)))
+LIBS_TO_PKG_CLIENTS += $(addsuffix .$(DLL_SUFFIX),$(addprefix $(ICU_BINPATH)/,$(ICU_DLLNAMES)))
+else
+ICU_LIBNAMES = icui18n icuuc icudata
+ICULINK = -L$(ICU_LIBPATH) $(addprefix -l, $(ICU_LIBNAMES))
+LIBS_TO_PKG += $(addsuffix .$(ICU_LIB_VERSION),$(addsuffix .$(DLL_SUFFIX),$(addprefix $(ICU_LIBPATH)/,$(addprefix lib,$(ICU_LIBNAMES)))))
+LIBS_TO_PKG_SHARED += $(addsuffix .$(ICU_LIB_VERSION),$(addsuffix .$(DLL_SUFFIX),$(addprefix $(ICU_LIBPATH)/,$(addprefix lib,$(ICU_LIBNAMES)))))
+LIBS_TO_PKG_CLIENTS += $(addsuffix .$(ICU_LIB_VERSION),$(addsuffix .$(DLL_SUFFIX),$(addprefix $(ICU_LIBPATH)/,$(addprefix lib,$(ICU_LIBNAMES)))))
+#LIBS_TO_PKG = $(addsuffix $(addprefix lib,$(ICU_LIBNAMES))
+endif
+
+BINS_TO_PKG_SHARED += $(ICU_BINPATH)/uconv$(EXE_SUFFIX)
+
+ifndef ICU_PULL_METHOD
+ICU_PULL_METHOD = $(COMPONENT_PULL_METHOD)
+endif
+
+$(ICU_DEP): $(NSCP_DISTDIR_FULL_RTL)
+ifdef COMPONENT_DEPS
+	$(FTP_PULL) -method $(ICU_PULL_METHOD) \
+		-objdir $(ICU_BUILD_DIR) -componentdir $(ICU_RELEASE) \
+		-files lib,include,bin
+endif
+	-@if [ ! -f $@ ] ; \
+	then echo "Error: could not get component ICU file $@" ; \
+	fi
+
+###########################################################

+ 5 - 0
config/.cvsignore

@@ -0,0 +1,5 @@
+nfspwd
+nsinstall
+revdepth
+myconfig.mk
+myrules.mk

+ 58 - 0
config/Linux2.4.mk

@@ -0,0 +1,58 @@
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright 2001 Sun Microsystems, Inc.
+# Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+#
+# Config stuff for Linux2.4
+#
+
+#include $(NSPRDEPTH)/config/UNIX.mk
+
+CC 		= gcc
+CCC 		= g++
+
+CPU_ARCH	= x86
+GFX_ARCH	= x
+
+RANLIB 		= ranlib
+
+ifdef SERVER_BUILD
+# see sun-java/config/config.mk
+STATIC_JAVA = yes
+endif
+
+NEED_XMOS = 1
+
+# fixme OS_CFLAGS = -m486 -ansi -Wall -pipe -MDupdate $(DEPENDENCIES)
+OS_CFLAGS = -m486 -ansi -Wall -pipe
+
+OS_CFLAGS += -DLINUX -DLINUX2_4 -D_POSIX_SOURCE -D_BSD_SOURCE -DHAVE_STRERROR -D_REENTRANT
+OS_LIBS = -L /lib -lc -ldl -lpthread
+
+ARCH = linux
+
+EN_LOCALE = C
+DE_LOCALE = de_DE.ISO8859-1
+FR_LOCALE = fr_FR.ISO8859-1
+JP_LOCALE = ja
+SJIS_LOCALE = ja_JP.SJIS
+KR_LOCALE = ko_KR.EUC
+CN_LOCALE = zh
+TW_LOCALE = zh
+I2_LOCALE = i2
+
+BUILD_UNIX_PLUGINS = 1
+
+ifeq ($(OS_RELEASE),2.4)
+OS_REL_CFLAGS         += -DLINUX2_4
+MKSHLIB			= $(LD) -shared
+endif
+
+XINC = /usr/X11R6/include
+INCLUDES += -I$(XINC)
+
+BSDECHO	= echo
+

+ 58 - 0
config/Linux2.6.mk

@@ -0,0 +1,58 @@
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright 2001 Sun Microsystems, Inc.
+# Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+#
+# Config stuff for Linux2.4
+#
+
+#include $(NSPRDEPTH)/config/UNIX.mk
+
+CC 		= gcc
+CCC 		= g++
+
+CPU_ARCH	= x86
+GFX_ARCH	= x
+
+RANLIB 		= ranlib
+
+ifdef SERVER_BUILD
+# see sun-java/config/config.mk
+STATIC_JAVA = yes
+endif
+
+NEED_XMOS = 1
+
+# fixme OS_CFLAGS = -m486 -ansi -Wall -pipe -MDupdate $(DEPENDENCIES)
+OS_CFLAGS = -m486 -ansi -Wall -pipe
+
+OS_CFLAGS += -DLINUX -DLINUX2_4 -D_POSIX_SOURCE -D_BSD_SOURCE -DHAVE_STRERROR -D_REENTRANT
+OS_LIBS = -L /lib -lc -ldl -lpthread
+
+ARCH = linux
+
+EN_LOCALE = C
+DE_LOCALE = de_DE.ISO8859-1
+FR_LOCALE = fr_FR.ISO8859-1
+JP_LOCALE = ja
+SJIS_LOCALE = ja_JP.SJIS
+KR_LOCALE = ko_KR.EUC
+CN_LOCALE = zh
+TW_LOCALE = zh
+I2_LOCALE = i2
+
+BUILD_UNIX_PLUGINS = 1
+
+ifeq ($(OS_RELEASE),2.4)
+OS_REL_CFLAGS         += -DLINUX2_4
+MKSHLIB			= $(LD) -shared
+endif
+
+XINC = /usr/X11R6/include
+INCLUDES += -I$(XINC)
+
+BSDECHO	= echo
+

+ 38 - 0
config/Makefile

@@ -0,0 +1,38 @@
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright 2001 Sun Microsystems, Inc.
+# Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+#! gmake
+
+DEPTH	= ..
+
+HSRCS	= pathsub.h
+CSRCS	= nsinstall.c pathsub.c
+
+PLSRCS	= nfspwd.pl revdepth.pl
+
+ifneq ($(subst /,_,$(shell uname -s)),WINNT)
+PROGRAM	= nsinstall
+OBJS	= $(CSRCS:.c=.o)
+endif
+
+TARGETS	= $(PROGRAM) $(PLSRCS:.pl=)
+
+# IMPORTANT: Disable NSBUILDROOT for this directory only, otherwise we have
+# a recursive rule for finding nsinstall and the perl scripts
+ifdef NSBUILDROOT
+override NSBUILDROOT :=
+endif
+
+include $(DEPTH)/config/rules.mk
+
+# Redefine MAKE_OBJDIR for just this directory
+define MAKE_OBJDIR
+if test ! -d $(@D); then rm -rf $(@D); mkdir $(@D); fi
+endef
+
+export:: $(TARGETS)
+install:: $(TARGETS)

+ 14 - 0
config/SunOS5.8.mk

@@ -0,0 +1,14 @@
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright 2001 Sun Microsystems, Inc.
+# Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+#
+# Config stuff for SunOS5.8
+#
+
+SOL_CFLAGS	= -D_SVID_GETTOD -DSOLARIS_55_OR_GREATER
+
+include $(DEPTH)/config/SunOS5.mk

+ 14 - 0
config/SunOS5.8_i86pc.mk

@@ -0,0 +1,14 @@
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright 2001 Sun Microsystems, Inc.
+# Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+#
+# Config stuff for SunOS5.8
+#
+
+SOL_CFLAGS	= -D_SVID_GETTOD -DSOLARIS_55_OR_GREATER
+
+include $(DEPTH)/config/SunOS5.mk

+ 14 - 0
config/SunOS5.9.mk

@@ -0,0 +1,14 @@
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright 2001 Sun Microsystems, Inc.
+# Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+#
+# Config stuff for SunOS5.9
+#
+
+SOL_CFLAGS	= -D_SVID_GETTOD -DSOLARIS_55_OR_GREATER
+
+include $(DEPTH)/config/SunOS5.mk

+ 14 - 0
config/UNIX.mk

@@ -0,0 +1,14 @@
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright 2001 Sun Microsystems, Inc.
+# Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+# A small start on what nspr20/config did
+XP_DEFINE	= -DXP_UNIX
+LIB_SUFFIX	= a
+#
+DLL_SUFFIX	= so
+AR		= ar cr $@
+

+ 56 - 0
config/WINNT5.0.mk

@@ -0,0 +1,56 @@
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright 2001 Sun Microsystems, Inc.
+# Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+#
+# Config stuff for WINNT 5.0
+#
+
+CC=cl
+CCC=cl
+LINK = link
+RANLIB = echo
+BSDECHO = echo
+
+OTHER_DIRT = 
+GARBAGE = vc20.pdb
+
+ifdef DEBUG_RUNTIME
+RTLIBFLAGS:=-MDd
+else
+RTLIBFLAGS:=-MD
+endif
+
+PROCESSOR := $(shell uname -p)
+USE_KERNEL_THREADS=1
+_PR_USECPU=1
+ifeq ($(PROCESSOR), I386)
+CPU_ARCH = x386
+OS_CFLAGS = $(OPTIMIZER) -GT $(RTLIBFLAGS) -W3 -nologo -D_X86_ -Dx386 -D_WINDOWS -DWIN32 -DHW_THREADS
+else 
+ifeq ($(PROCESSOR), MIPS)
+CPU_ARCH = MIPS
+#OS_CFLAGS = $(OPTIMIZER) $(RTLIBFLAGS) -W3 -nologo -D_MIPS_ -D_WINDOWS -DWIN32 -DHW_THREADS
+OS_CFLAGS = $(OPTIMIZER) $(RTLIBFLAGS) -W3 -nologo -D_WINDOWS -DWIN32 -DHW_THREADS
+else 
+ifeq ($(PROCESSOR), ALPHA)
+CPU_ARCH = ALPHA
+OS_CFLAGS = $(OPTIMIZER) $(RTLIBFLAGS) -W3 -nologo -D_ALPHA_=1 -D_WINDOWS -DWIN32 -DHW_THREADS
+else 
+CPU_ARCH = processor_is_undefined
+endif
+endif
+endif
+
+ifeq ($(SERVER_BUILD), 1)
+OS_CFLAGS += -DSERVER_BUILD
+endif
+
+OS_DLLFLAGS = -nologo -DLL -SUBSYSTEM:WINDOWS -MAP -PDB:NONE
+OS_LFLAGS = -nologo -PDB:NONE -INCREMENT:NO -SUBSYSTEM:console
+OS_LIBS = kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib
+
+OS_DEFS= SERVER_BUILD=$(SERVER_BUILD) NSPR_VERSION=$(VERSION) NS_PRODUCT=$(NS_PRODUCT)

+ 120 - 0
config/common.mn

@@ -0,0 +1,120 @@
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright 2001 Sun Microsystems, Inc.
+# Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+######################################################################
+### Comon Manifest File
+### Cross-platform defines used on all platforms (in theory)
+######################################################################
+
+# The VERSION_NUMBER is suffixed onto the end of the DLLs we ship.
+# Since the longest of these is 5 characters without the suffix,
+# be sure to not set VERSION_NUMBER to anything longer than 3 
+# characters for Win16's sake.
+#
+# Also... If you change this value, there are several other places
+# you'll need to change (because they're not reached by this 
+# variable): 
+#	sun-java/nsjava/nsjava32.def
+#	sun-java/nsjava/nsjava16.def
+#	sun-java/classsrc/sun/audio/AudioDevice.java
+#	sun-java/classsrc/sun/awt/windows/WToolkit.java
+
+VERSION_NUMBER = 40
+
+ZIP_NAME = java_$(VERSION_NUMBER)
+JAR_NAME = java_$(VERSION_NUMBER).jar
+
+######################################################################
+### Cross-Platform Java Stuff
+######################################################################
+## java interpreter
+
+# get class files from the directory they are compiled to
+JAVA_CLASSPATH = $(JAVA_DESTPATH)
+
+JAVA_FLAGS = -classpath $(JAVA_CLASSPATH) -ms8m
+JAVA = $(JAVA_PROG) $(JAVA_FLAGS) 
+
+JAVA_DEFINES =			   \
+	-DZIP_NAME=\"$(ZIP_NAME)\" \
+	-DJAR_NAME=\"$(JAR_NAME)\" \
+	-DJRTDLL=\"$(JRTDLL)\"	   \
+	-DMMDLL=\"$(MMDLL)\"	   \
+	-DAWTDLL=\"$(AWTDLL)\"	   \
+	-DJITDLL=\"$(JITDLL)\"
+
+######################################################################
+## javac
+
+# to run the compiler in the interpreter
+JAVAC_PROG = -ms8m -classpath $(JAVAC_ZIP) sun.tools.javac.Main
+JAVAC = $(JAVA_PROG) $(JAVAC_PROG) $(JAVAC_FLAGS)
+
+# std set of options passed to the compiler
+JAVAC_FLAGS = -classpath $(JAVAC_CLASSPATH) $(JAVA_OPTIMIZER) -d $(JAVA_DESTPATH)
+
+##
+## The canonical Java classpath is:
+## JAVA_DESTPATH, JAVA_SOURCEPATH, JAVA_LIBS
+## 
+## appropriately delimited, in that order
+##
+JAVAC_CLASSPATH	= $(JAVA_DESTPATH)$(PATH_SEPARATOR)$(JAVA_SOURCEPATH)
+
+######################################################################
+## javadoc
+
+# Rules to build java .html files from java source files
+
+JAVADOC_PROG = $(JAVA) sun.tools.javadoc.Main
+JAVADOC_FLAGS = -classpath $(JAVAC_CLASSPATH)
+JAVADOC = $(JAVADOC_PROG) $(JAVADOC_FLAGS)
+
+######################################################################
+## javah
+
+JAVAH_FLAGS = -classpath $(JAVA_CLASSPATH)
+JAVAH = $(JAVAH_PROG) $(JAVAH_FLAGS)
+
+######################################################################
+## jmc
+
+JMCSRCDIR = $(XPDIST)/_jmc
+JMC_PROG = $(JAVA) netscape.tools.jmc.Main
+JMC_CLASSPATH = $(JMCSRCDIR)$(PATH_SEPARATOR)$(JAVAC_CLASSPATH)
+JMC_FLAGS = -classpath $(JMC_CLASSPATH) -verbose
+JMC = $(JMC_PROG) $(JMC_FLAGS)
+
+######################################################################
+## zip
+
+ZIP = $(ZIP_PROG) $(ZIP_FLAGS)
+
+######################################################################
+## idl2java
+
+ORBTOOLS = $(DEPTH)/modules/iiop/tools/orbtools.zip
+ORB_CLASSPATH = $(ORBTOOLS)$(PATH_SEPARATOR)$(JAVA_CLASSPATH)
+
+IDL2JAVA_PROG = $(JAVA_PROG)
+IDL2JAVA_FLAGS = -classpath $(ORB_CLASSPATH) pomoco.tools.idl2java
+IDL2JAVA = $(IDL2JAVA_PROG) $(IDL2JAVA_FLAGS)
+
+######################################################################
+## lex and yacc
+
+JAVALEX_PROG = $(JAVA_PROG) -classpath $(ORB_CLASSPATH) sbktech.tools.jax.driver
+JAVALEX_FLAGS = 
+JAVALEX = $(JAVALEX_PROG) $(JAVALEX_FLAGS)
+
+JAVACUP_PROG = $(JAVA_PROG) -classpath $(ORB_CLASSPATH) java_cup.Main
+JAVACUP_FLAGS = 
+JAVACUP = $(JAVACUP_PROG) $(JAVACUP_FLAGS)
+
+######################################################################
+
+

+ 520 - 0
config/config.mk

@@ -0,0 +1,520 @@
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright 2001 Sun Microsystems, Inc.
+# Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+#! gmake
+
+include $(DEPTH)/config/common.mn
+
+#
+# Important internal static macros
+#
+OS_ARCH		:= $(subst /,_,$(shell uname -s))
+OS_TEST		:= $(shell uname -m)
+
+# Force the IRIX64 machines to use IRIX.
+ifeq ($(OS_ARCH),IRIX64)
+OS_ARCH		:= IRIX
+endif
+
+# Attempt to differentiate between SunOS 5.4 and x86 5.4
+ifeq ($(OS_TEST),i86pc)
+OS_RELEASE	:= $(shell uname -r)_$(OS_TEST)
+else
+OS_RELEASE	:= $(shell uname -r)
+endif
+
+ifeq ($(OS_ARCH),AIX)
+OS_RELEASE	:= $(shell uname -v).$(shell uname -r)
+endif
+
+# SINIX changes name to ReliantUNIX with 5.43
+ifeq ($(OS_ARCH),ReliantUNIX-N)
+OS_ARCH		:= ReliantUNIX
+OS_RELEASE	:= 5.4
+endif
+ifeq ($(OS_ARCH),SINIX-N)
+OS_ARCH		:= ReliantUNIX
+OS_RELEASE	:= 5.4
+endif
+
+# SVR5 (UnixWare[7])
+ifeq ($(OS_ARCH),UnixWare)
+# For now get the OS release for backward compatibility (UnixWare5)
+OS_RELEASE    := $(shell uname -r)
+endif
+
+# Catch NCR butchering of SVR4
+ifeq ($(OS_ARCH),UNIX_SV)
+ifneq ($(findstring NCR, $(shell grep NCR /etc/bcheckrc | head -1 )),)
+OS_ARCH		:= NCR
+OS_RELEASE	:= $(shell uname -v)
+else # !NCR
+# Make UnixWare something human readable
+OS_ARCH               := UNIXWARE
+# Check for UW2 using UDK, which looks like a Gemini (UnixWare[3,5,7]) build
+OS_RELEASE    := $(shell $(DEPTH)/netsite/nsarch -f | sed 's/UnixWare //')
+ifeq ($(OS_RELEASE),5)
+OS_ARCH               := UnixWare
+else # OS_RELEASE = 5
+# Get the OS release number, not 4.2
+OS_RELEASE    := $(shell uname -v)
+ifeq ($(OS_RELEASE),2.1.2)
+OS_RELEASE    := 2.1
+endif # OS_RELEASE = 2.1.2
+endif # OS_RELEASE = 5
+endif # !NCR
+endif # UNIX_SV
+
+
+ifeq ($(OS_ARCH),Linux)
+#
+# Handle FreeBSD 2.2-STABLE and Linux 2.0.30-osfmach3 and 2.2.14-5.0smp
+#
+ifeq (,$(filter-out Linux FreeBSD,$(NSOS_ARCH)))
+ OS_RELEASE  := $(shell echo $(OS_RELEASE) | sed 's/-.*//')
+endif
+OS_RELEASE := $(basename $(OS_RELEASE))
+  ifeq (86,$(findstring 86,$(OS_TEST)))
+    CPU_TAG = _x86
+  else
+    CPU_TAG = _$(OS_TEST)
+  endif
+  ifeq ($(USE_LIBC),1)
+    LIBC_TAG = _libc
+  else
+    LIBC_TAG = _glibc
+  endif
+# always use pthreads
+  USE_PTHREADS = 1
+  ifeq ($(USE_PTHREADS),1)
+    IMPL_STRATEGY = _PTH
+  endif
+  ifeq ($(USE_EGCS),1)
+    COMPILER_TAG = _egcs
+  endif
+endif
+
+# Clean up SCO
+ifeq ($(OS_ARCH),SCO_SV)
+OS_ARCH         := SCOOS
+ifeq (5.0,$(findstring 5.0,$(shell ls /var/opt/K/SCO/Unix)))
+OS_RELEASE      := 5.0
+else
+OS_RELEASE      := UNKNOWN
+endif
+endif
+
+# Furnish the extra libraries for using ld on OSF1 
+ifeq ($(OS_ARCH),OSF1)
+LDEXTRA		:= -lcxx -lexc -lc
+#
+# Distinguish between OSF1 V4.0B and V4.0D
+#
+ifeq ($(OS_RELEASE),V4.0)
+	OS_VERSION := $(shell uname -v)
+	ifeq ($(OS_VERSION),564)
+		OS_RELEASE := V4.0B
+	endif
+	ifeq ($(OS_VERSION),878)
+		OS_RELEASE := V4.0D
+	endif
+endif
+else
+LDEXTRA		:=
+endif
+
+# Relative pathname from top-of-tree to current source directory
+ifneq ($(OS_ARCH),WINNT)
+REVDEPTH	:= $(DEPTH)/config/revdepth
+SRCDIR		:= $(shell perl $(REVDEPTH).pl $(DEPTH))
+endif
+
+# define an include-at-most-once flag
+NS_CONFIG_MK	= 1
+
+#
+# Default command macros; can be overridden in <arch>.mk.
+#
+AS		= $(CC)
+ASFLAGS		= $(CFLAGS)
+CCF		= $(CC) $(CFLAGS)
+PURIFY		= purify $(PURIFYOPTIONS)
+LINK_EXE	= $(LINK) $(OS_LFLAGS) $(LFLAGS)
+LINK_DLL	= $(LINK) $(OS_DLLFLAGS) $(DLLFLAGS)
+NFSPWD		= $(DEPTH)/config/nfspwd
+
+ifeq ($(OS_ARCH),WINNT)
+RC		= rc.exe
+XP_DEFINE	= -DXP_PC
+LIB_SUFFIX	= lib
+DLL_SUFFIX	= dll
+AR		= lib -NOLOGO -OUT:"$@"
+DLLFLAGS	= $(XLFLAGS) -OUT:"$@"
+LFLAGS		= $(OBJS) $(DEPLIBS) $(EXTRA_LIBS) -OUT:"$@"
+NSINSTALL	= nsinstall
+INSTALL		= $(NSINSTALL)
+else
+include $(DEPTH)/config/UNIX.mk
+endif
+
+ifdef BUILD_OPT
+ifeq ($(OS_ARCH),WINNT)
+OPTIMIZER	= -O2
+XCFLAGS		= $(LCFLAGS)
+XLFLAGS		= $(LLFLAGS)
+else
+OPTIMIZER	= -O
+JAVA_OPTIMIZER	= -O
+DEFINES		= -UDEBUG -DNDEBUG -DTRIMMED
+endif
+OBJDIR_TAG	= _OPT
+else
+ifeq ($(OS_ARCH),WINNT)
+OPTIMIZER	= -Od -Z7
+LDFLAGS		= -DEBUG
+
+XCFLAGS		= $(LCFLAGS)
+XLFLAGS		= -DEBUG $(LLFLAGS)
+XBCFLAGS	= -FR$*
+JAVA_OPTIMIZER	= -Od -Z7
+else
+ifeq ($(ARCH), ReliantUNIX)
+OPTIMIZER	= -gdwarf
+JAVA_OPTIMIZER	= -gdwarf
+else
+OPTIMIZER	= -g
+JAVA_OPTIMIZER	= -g
+endif
+ifeq ($(OS_ARCH),OSF1)
+DEFINES		= -DDEBUG_$(shell whoami) -DTRACING
+else
+DEFINES		= -DDEBUG -UNDEBUG -DDEBUG_$(shell whoami) -DTRACING
+endif
+endif
+OBJDIR_TAG	= _DBG
+endif
+
+LIBNT		= $(DIST)/lib/libnt.$(LIB_SUFFIX)
+LIBAWT		= $(DIST)/lib/libawt.$(LIB_SUFFIX)
+LIBMMEDIA	= $(DIST)/lib/libmmedia.$(LIB_SUFFIX)
+LIBNSPR		= $(DIST)/lib/libnspr.$(LIB_SUFFIX)
+PURELIBNSPR	= $(DIST)/lib/libpurenspr.$(LIB_SUFFIX)
+
+ifeq ($(OS_ARCH),WINNT)
+LIBNSJAVA	= $(DIST)/lib/jrt3221.$(LIB_SUFFIX)
+else
+LIBNSJAVA	= $(DIST)/lib/nsjava32.$(LIB_SUFFIX)
+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) -I$(DEPTH)/include $(LOCAL_INCLUDES)
+
+CFLAGS		= $(XP_DEFINE) $(OPTIMIZER) $(OS_CFLAGS) $(DEFINES) $(INCLUDES) $(XCFLAGS)
+# For purify
+NOMD_CFLAGS	= $(XP_DEFINE) $(OPTIMIZER) $(NOMD_OS_CFLAGS) $(DEFINES) $(INCLUDES) $(XCFLAGS)
+
+#
+# To build on SunOS5.8 when some SunOS5.8 components or config
+# files are missing, just pretend you're on SunOS5.6 by setting
+#   NSOS_RELEASE_OVERRIDE=5.6
+#
+ifdef NSOS_RELEASE_OVERRIDE
+OS_RELEASE := $(NSOS_RELEASE_OVERRIDE)
+endif
+
+include $(DEPTH)/config/$(OS_ARCH)$(OS_RELEASE).mk
+
+OS_CONFIG	:= $(OS_ARCH)$(OS_RELEASE)
+
+include $(DEPTH)/config/$(OS_CONFIG).mk
+
+# now take care of default GCC (rus@5/5/97)
+
+ifdef NS_USE_GCC
+# if gcc-settings are redefined already - don't touch it
+# 
+ifeq (,$(findstring gcc, $(CC)))
+CC	= gcc
+CCC	= g++
+CXX	= g++
+# always use -fpic - some makefiles are still broken and don't distinguish
+# situation when they build shared and static libraries
+CFLAGS	+= -fpic -Wall -DNS_USE_GCC $(GCC_FLAGS_EXTRA)
+OS_LIBS += -L/usr/local/lib -lstdc++ -lg++ -lgcc
+endif
+endif
+###
+
+# Name of the binary code directories
+ifeq ($(OS_ARCH),WINNT)
+ifneq ($(PROCESSOR_ARCHITECTURE),x86)
+OBJDIR_NAME	= $(OS_CONFIG)$(PROCESSOR_ARCHITECTURE)$(OBJDIR_TAG).OBJ
+else
+OBJDIR_NAME	= $(OS_CONFIG)$(OBJDIR_TAG).OBJ
+endif
+else   # WINNT
+ifeq ($(OS_ARCH),Linux)
+OBJDIR_NAME     = $(OS_CONFIG)$(CPU_TAG)$(COMPILER_TAG)$(LIBC_TAG)$(IMPL_STRATEGY)$(OBJDIR_TAG).OBJ
+else
+ifeq ($(OS_ARCH), IRIX)
+ ifeq ($(USE_PTHREADS), 1)
+  ifeq ($(USE_N32), 1)
+   OBJDIR_NAME   = $(OS_CONFIG)_n32_PTH$(OBJDIR_TAG).OBJ
+  else
+   OBJDIR_NAME   = $(OS_CONFIG)_PTH$(OBJDIR_TAG).OBJ
+  endif
+ else
+  OBJDIR_NAME   = $(OS_CONFIG)$(OBJDIR_TAG).OBJ
+ endif
+else
+ OBJDIR_NAME   = $(OS_CONFIG)$(OBJDIR_TAG).OBJ
+endif	# IRIX
+endif   # Linux
+endif   # WINNT
+
+# 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
+
+# Personal makefile customizations go in these optional make include files.
+MY_CONFIG	= $(DEPTH)/config/myconfig.mk
+MY_RULES	= $(DEPTH)/config/myrules.mk
+
+-include $(MY_CONFIG)
+
+######################################################################
+
+# Specify that we are building a client.
+# This will instruct the cross platform libraries to
+# include all the client specific cruft.
+ifndef SERVER_BUILD
+ifndef LIVEWIRE
+DEFINES += -DMOZILLA_CLIENT -DNETSCAPE
+endif
+else
+DEFINES += -DSERVER_BUILD
+endif
+DEFINES += -DNETSCAPE
+
+# Now test variables that might have been set or overridden by $(MY_CONFIG).
+
+# if ((BUILD_EDITOR || BUILD_EDT) && !NO_EDITOR) -> -DEDITOR is defined
+ifndef NO_EDITOR
+ifdef BUILD_EDITOR
+OBJDIR_TAG	:= $(OBJDIR_TAG)_EDT
+DEFINES		+= -DEDITOR -DGOLD
+# This is the product classification not the feature classification.
+# It effects things like where are the release notes, etc..
+BUILD_GOLD = yea
+else
+# We ought to get rid of this now that BUILD_EDITOR has replaced it.
+ifdef BUILD_EDT
+OBJDIR_TAG	:= $(OBJDIR_TAG)_EDT
+DEFINES		+= -DEDITOR -DGOLD
+BUILD_EDITOR	= yea
+endif 
+endif 
+endif
+
+# Build layers by default
+ifndef NO_LAYERS
+DEFINES		+= -DLAYERS
+endif
+
+# if (BUILD_EDITOR_UI && !NO_EDITOR_UI) -> -DEDITOR_UI is defined
+ifdef BUILD_EDITOR_UI
+ifndef NO_EDITOR_UI
+DEFINES		+= -DEDITOR_UI
+endif
+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 -DNSPR20
+endif
+
+ifndef NO_JAVA
+DEFINES		+= -DJAVA
+endif
+
+ifeq ($(LW_JAVA), 1)
+DEFINES += -DJAVA
+endif
+
+ifndef NO_MOCHA
+DEFINES		+= -DMOCHA
+endif
+
+ifdef FORTEZZA
+DEFINES		+= -DFORTEZZA
+endif
+
+######################################################################
+
+GARBAGE		= $(DEPENDENCIES) core
+
+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
+
+ifndef PLATFORM_HOSTS
+PLATFORM_HOSTS	=		\
+		  atm		\
+		  bsdi		\
+		  diva		\
+		  gunwale	\
+		  openwound	\
+		  server2	\
+		  server3	\
+		  server9	\
+		  zot		\
+		  $(NULL)
+endif
+
+######################################################################
+
+# always copy files for the sdk
+SDKINSTALL	= $(NSINSTALL) -t
+
+ifndef SDK
+SDK		= $(DEPTH)/dist/sdk
+endif
+
+######################################################################
+### Java Stuff
+######################################################################
+## java interpreter
+
+JAVA_PROG = java	# from the ether
+
+# Let user over-ride CLASSPATH from environment
+#ifdef xCLASSPATH	# bad idea
+#JAVA_CLASSPATH = $(CLASSPATH)
+#else
+# keep sun-java/classsrc until bootstrapped
+#JAVA_CLASSPATH = $(XPDIST)/classes:$(DEPTH)/sun-java/classsrc
+#endif
+
+#JAVA_FLAGS = -classpath $(JAVA_CLASSPATH) -ms8m
+#JAVA = $(JAVA_PROG) $(JAVA_FLAGS) 
+
+######################################################################
+## java compiler
+# XXX - ram included from common.mn
+#JAVAC_PROG = javac	# from the ether
+#JAVAC_CLASSPATH = $(JAVA_CLASSPATH):/usr/local/netscape/java/lib/javac.zip
+#JAVAC_FLAGS = -classpath $(JAVAC_CLASSPATH) $(JAVA_OPTIMIZER)
+#JAVAC = $(JAVAC_PROG) $(JAVAC_FLAGS)
+
+PATH_SEPARATOR	= :
+JAVAC_ZIP	= /usr/local/netscape/java/lib/javac.zip
+
+#
+# The canonical classpath for building java libraries
+# includes these two entries first, then any additional zips
+# or directories
+#
+# see "JAVAC_CLASSPATH" in common.mn
+#
+
+# 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
+JAVA_SOURCEPATH	= $(DEPTH)/sun-java/classsrc
+
+######################################################################
+## javadoc
+
+# Rules to build java .html files from java source files
+
+JAVADOC_PROG = $(JAVA) sun.tools.javadoc.Main
+JAVADOC_FLAGS = -classpath $(JAVAC_CLASSPATH)
+JAVADOC = $(JAVADOC_PROG) $(JAVADOC_FLAGS)
+
+######################################################################
+## javah
+
+ifndef JAVAH_IN_JAVA
+JAVAH_PROG = $(DIST)/bin/javah
+else 
+JAVAH_PROG = $(JAVA) netscape.tools.jric.Main
+endif
+JAVAH_FLAGS = -classpath $(JAVA_CLASSPATH)
+JAVAH = $(JAVAH_PROG) $(JAVAH_FLAGS)
+
+######################################################################
+## jmc
+
+JMCSRCDIR = $(XPDIST)/_jmc
+JMC_PROG = $(JAVA) netscape.tools.jmc.Main
+JMC_CLASSPATH = $(JMCSRCDIR):$(JAVAC_CLASSPATH)
+JMC_FLAGS = -classpath $(JMC_CLASSPATH) -verbose
+JMC = $(JMC_PROG) $(JMC_FLAGS)
+
+######################################################################
+## zip
+
+ZIP_PROG = zip
+ZIP_FLAGS = -0rq
+ZIP = $(ZIP_PROG) $(ZIP_FLAGS)
+
+######################################################################
+JRTDLL		= libjrt.$(DLL_SUFFIX)
+MMDLL		= libmm32$(VERSION_NUMBER).$(DLL_SUFFIX)
+AWTDLL		= libawt.$(DLL_SUFFIX)
+JITDLL		= libjit
+

+ 21 - 0
config/nfspwd.pl

@@ -0,0 +1,21 @@
+#! /usr/local/bin/perl
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright 2001 Sun Microsystems, Inc.
+# Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+
+require "fastcwd.pl";
+
+$_ = &fastcwd;
+if (m@^/[uh]/@o || s@^/tmp_mnt/@/@o) {
+    print("$_\n");
+} elsif ((($user, $rest) = m@^/usr/people/(\w+)/(.*)@o)
+      && readlink("/u/$user") eq "/usr/people/$user") {
+    print("/u/$user/$rest\n");
+} else {
+    chop($host = `hostname`);
+    print("/h/$host$_\n");
+}

+ 305 - 0
config/nsinstall.c

@@ -0,0 +1,305 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+/*
+** Netscape portable install command.
+**
+** Brendan Eich, 7/20/95
+*/
+#include <stdio.h>  /* OSF/1 requires this before grp.h, so put it first */
+#include <assert.h>
+#include <fcntl.h>
+#include <grp.h>
+#include <pwd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <utime.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include "pathsub.h"
+
+#define HAVE_LCHOWN
+
+#if defined(AIXV3) || defined(BSDI) || defined(HPUX) || defined(LINUX) || defined(SUNOS4) || defined(SCO) || defined(SNI)
+#undef HAVE_LCHOWN
+#endif
+
+#ifdef LINUX
+# include <getopt.h>
+#endif
+
+#if defined(SCO) || defined(UNIXWARE) || defined(SNI) || defined (NCR) || defined(UnixWare)
+#if !defined(S_ISLNK) && defined(S_IFLNK)
+#define S_ISLNK(a)	(((a) & S_IFMT) == S_IFLNK)
+#endif
+#endif
+
+static void
+usage(void)
+{
+    fprintf(stderr,
+	"usage: %s [-C cwd] [-L linkprefix] [-m mode] [-o owner] [-g group]\n"
+	"       %*s [-DdltR] file [file ...] directory\n",
+	program, strlen(program), "");
+    exit(2);
+}
+
+static int
+mkdirs(char *path, mode_t mode)
+{
+    char *cp;
+    struct stat sb;
+    
+    while (*path == '/' && path[1] == '/')
+	path++;
+    while ((cp = strrchr(path, '/')) && cp[1] == '\0')
+	*cp = '\0';
+    if (cp && cp != path) {
+	*cp = '\0';
+	if ((lstat(path, &sb) < 0 || !S_ISDIR(sb.st_mode)) &&
+	    mkdirs(path, mode) < 0) {
+	    return -1;
+	}
+	*cp = '/';
+    }
+    return mkdir(path, mode);
+}
+
+static uid_t
+touid(char *owner)
+{
+    struct passwd *pw;
+    uid_t uid;
+    char *cp;
+
+    pw = getpwnam(owner);
+    if (pw)
+	return pw->pw_uid;
+    uid = strtol(owner, &cp, 0);
+    if (uid == 0 && cp == owner)
+	fail("cannot find uid for %s", owner);
+    return uid;
+}
+
+static gid_t
+togid(char *group)
+{
+    struct group *gr;
+    gid_t gid;
+    char *cp;
+
+    gr = getgrnam(group);
+    if (gr)
+	return gr->gr_gid;
+    gid = strtol(group, &cp, 0);
+    if (gid == 0 && cp == group)
+	fail("cannot find gid for %s", group);
+    return gid;
+}
+
+int
+main(int argc, char **argv)
+{
+    int onlydir, dodir, dolink, dorelsymlink, dotimes;
+    mode_t mode;
+    char *linkprefix, *owner, *group;
+    int opt, len, lplen, tdlen, bnlen, exists, fromfd, tofd, cc, wc;
+    char *cp, *cwd, *todir, *toname, *name, *base, *linkname;
+    uid_t uid;
+    gid_t gid;
+    char *bp, buf[BUFSIZ];
+    struct stat sb, tosb;
+    struct utimbuf utb;
+
+    program = argv[0];
+    cwd = 0;
+    onlydir = dodir = dolink = dorelsymlink = dotimes = 0;
+    mode = 0755;
+    linkprefix = owner = group = 0;
+
+    while ((opt = getopt(argc, argv, "C:DdlL:Rm:o:g:t")) != EOF) {
+	switch (opt) {
+	  case 'C':
+	    cwd = optarg;
+	    break;
+	  case 'D':
+	    onlydir = 1;
+	    break;
+	  case 'd':
+	    dodir = 1;
+	    break;
+	  case 'l':
+	    dolink = 1;
+	    break;
+	  case 'L':
+	    linkprefix = optarg;
+	    lplen = strlen(linkprefix);
+	    dolink = 1;
+	    break;
+	  case 'R':
+	    dolink = dorelsymlink = 1;
+	    break;
+	  case 'm':
+	    mode = strtoul(optarg, &cp, 8);
+	    if (mode == 0 && cp == optarg)
+		usage();
+	    break;
+	  case 'o':
+	    owner = optarg;
+	    break;
+	  case 'g':
+	    group = optarg;
+	    break;
+	  case 't':
+	    dotimes = 1;
+	    break;
+	  default:
+	    usage();
+	}
+    }
+
+    argc -= optind;
+    argv += optind;
+    if (argc < 2 - onlydir)
+	usage();
+
+    todir = argv[argc-1];
+    if ((stat(todir, &sb) < 0 || !S_ISDIR(sb.st_mode)) &&
+	mkdirs(todir, 0777) < 0) {
+	fail("cannot make directory %s", todir);
+    }
+    if (onlydir)
+	return 0;
+
+    if (!cwd)
+	cwd = getcwd(0, PATH_MAX);
+    xchdir(todir);
+    todir = getcwd(0, PATH_MAX);
+    tdlen = strlen(todir);
+    xchdir(cwd);
+    tdlen = strlen(todir);
+
+    uid = owner ? touid(owner) : -1;
+    gid = group ? togid(group) : -1;
+
+    while (--argc > 0) {
+	name = *argv++;
+	len = strlen(name);
+	base = xbasename(name);
+	bnlen = strlen(base);
+	toname = xmalloc(tdlen + 1 + bnlen + 1);
+	sprintf(toname, "%s/%s", todir, base);
+	exists = (lstat(toname, &tosb) == 0);
+
+	if (dodir) {
+	    /* -d means create a directory, always */
+	    if (exists && !S_ISDIR(tosb.st_mode)) {
+		(void) unlink(toname);
+		exists = 0;
+	    }
+	    if (!exists && mkdir(toname, mode) < 0)
+		fail("cannot make directory %s", toname);
+	    if ((owner || group) && chown(toname, uid, gid) < 0)
+		fail("cannot change owner of %s", toname);
+	} else if (dolink) {
+	    if (*name == '/') {
+		/* source is absolute pathname, link to it directly */
+		linkname = 0;
+	    } else {
+		if (linkprefix) {
+		    /* -L implies -l and prefixes names with a $cwd arg. */
+		    len += lplen + 1;
+		    linkname = xmalloc(len + 1);
+		    sprintf(linkname, "%s/%s", linkprefix, name);
+		} else if (dorelsymlink) {
+		    /* Symlink the relative path from todir to source name. */
+		    linkname = xmalloc(PATH_MAX);
+
+		    if (*todir == '/') {
+			/* todir is absolute: skip over common prefix. */
+			lplen = relatepaths(todir, cwd, linkname);
+			strcpy(linkname + lplen, name);
+		    } else {
+			/* todir is named by a relative path: reverse it. */
+			reversepath(todir, name, len, linkname);
+			xchdir(cwd);
+		    }
+
+		    len = strlen(linkname);
+		}
+		name = linkname;
+	    }
+
+	    /* Check for a pre-existing symlink with identical content. */
+	    if (exists &&
+		(!S_ISLNK(tosb.st_mode) ||
+		 readlink(toname, buf, sizeof buf) != len ||
+		 strncmp(buf, name, len) != 0)) {
+		(void) (S_ISDIR(tosb.st_mode) ? rmdir : unlink)(toname);
+		exists = 0;
+	    }
+	    if (!exists && symlink(name, toname) < 0)
+		fail("cannot make symbolic link %s", toname);
+#ifdef HAVE_LCHOWN
+	    if ((owner || group) && lchown(toname, uid, gid) < 0)
+		fail("cannot change owner of %s", toname);
+#endif
+
+	    if (linkname) {
+		free(linkname);
+		linkname = 0;
+	    }
+	} else {
+	    /* Copy from name to toname, which might be the same file. */
+	    fromfd = open(name, O_RDONLY);
+	    if (fromfd < 0 || fstat(fromfd, &sb) < 0)
+		fail("cannot access %s", name);
+	    if (exists && (!S_ISREG(tosb.st_mode) || access(toname, W_OK) < 0))
+		(void) (S_ISDIR(tosb.st_mode) ? rmdir : unlink)(toname);
+	    tofd = open(toname, O_CREAT | O_WRONLY, 0666);
+	    if (tofd < 0)
+		fail("cannot create %s", toname);
+
+	    bp = buf;
+	    while ((cc = read(fromfd, bp, sizeof buf)) > 0) {
+		while ((wc = write(tofd, bp, cc)) > 0) {
+		    if ((cc -= wc) == 0)
+			break;
+		    bp += wc;
+		}
+		if (wc < 0)
+		    fail("cannot write to %s", toname);
+	    }
+	    if (cc < 0)
+		fail("cannot read from %s", name);
+
+	    if (ftruncate(tofd, sb.st_size) < 0)
+		fail("cannot truncate %s", toname);
+	    if (dotimes) {
+		utb.actime = sb.st_atime;
+		utb.modtime = sb.st_mtime;
+		if (utime(toname, &utb) < 0)
+		    fail("cannot set times of %s", toname);
+	    }
+	    if (fchmod(tofd, mode) < 0)
+		fail("cannot change mode of %s", toname);
+	    if ((owner || group) && fchown(tofd, uid, gid) < 0)
+		fail("cannot change owner of %s", toname);
+
+	    /* Must check for delayed (NFS) write errors on close. */
+	    if (close(tofd) < 0)
+		fail("cannot write to %s", toname);
+	    close(fromfd);
+	}
+
+	free(toname);
+    }
+
+    free(cwd);
+    free(todir);
+    return 0;
+}

+ 206 - 0
config/pathsub.c

@@ -0,0 +1,206 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+/*
+** Pathname subroutines.
+**
+** Brendan Eich, 8/29/95
+*/
+#include <assert.h>
+#include <dirent.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include "pathsub.h"
+#ifdef USE_REENTRANT_LIBC
+#include <libc_r.h>
+#endif /* USE_REENTRANT_LIBC */
+
+char *program;
+
+void
+fail(char *format, ...)
+{
+    int error;
+    va_list ap;
+
+#ifdef USE_REENTRANT_LIBC
+    R_STRERROR_INIT_R();
+#endif
+
+    error = errno;
+    fprintf(stderr, "%s: ", program);
+    va_start(ap, format);
+    vfprintf(stderr, format, ap);
+    va_end(ap);
+    if (error)
+
+#ifdef USE_REENTRANT_LIBC
+    R_STRERROR_R(errno);
+	fprintf(stderr, ": %s", r_strerror_r);
+#else
+	fprintf(stderr, ": %s", strerror(errno));
+#endif
+
+    putc('\n', stderr);
+    exit(1);
+}
+
+char *
+getcomponent(char *path, char *name)
+{
+    if (*path == '\0')
+	return 0;
+    if (*path == '/') {
+	*name++ = '/';
+    } else {
+	do {
+	    *name++ = *path++;
+	} while (*path != '/' && *path != '\0');
+    }
+    *name = '\0';
+    while (*path == '/')
+	path++;
+    return path;
+}
+
+#ifdef UNIXWARE
+/* Sigh.  The static buffer in Unixware's readdir is too small. */
+struct dirent * readdir(DIR *d)
+{
+        static struct dirent *buf = NULL;
+#define MAX_PATH_LEN 1024
+
+
+        if(buf == NULL)
+                buf = (struct dirent *) malloc(sizeof(struct dirent) + MAX_PATH_LEN)
+;
+        return(readdir_r(d, buf));
+}
+#endif
+
+char *
+ino2name(ino_t ino, char *dir)
+{
+    DIR *dp;
+    struct dirent *ep;
+    char *name;
+
+    dp = opendir("..");
+    if (!dp)
+	fail("cannot read parent directory");
+    for (;;) {
+	if (!(ep = readdir(dp)))
+	    fail("cannot find current directory");
+	if (ep->d_ino == ino)
+	    break;
+    }
+    name = xstrdup(ep->d_name);
+    closedir(dp);
+    return name;
+}
+
+void *
+xmalloc(size_t size)
+{
+    void *p = malloc(size);
+    if (!p)
+	fail("cannot allocate %u bytes", size);
+    return p;
+}
+
+char *
+xstrdup(char *s)
+{
+    return strcpy(xmalloc(strlen(s) + 1), s);
+}
+
+char *
+xbasename(char *path)
+{
+    char *cp;
+
+    while ((cp = strrchr(path, '/')) && cp[1] == '\0')
+	*cp = '\0';
+    if (!cp) return path;
+    return cp + 1;
+}
+
+void
+xchdir(char *dir)
+{
+    if (chdir(dir) < 0)
+	fail("cannot change directory to %s", dir);
+}
+
+int
+relatepaths(char *from, char *to, char *outpath)
+{
+    char *cp, *cp2;
+    int len;
+    char buf[NAME_MAX];
+
+    assert(*from == '/' && *to == '/');
+    for (cp = to, cp2 = from; *cp == *cp2; cp++, cp2++)
+	if (*cp == '\0')
+	    break;
+    while (cp[-1] != '/')
+	cp--, cp2--;
+    if (cp - 1 == to) {
+	/* closest common ancestor is /, so use full pathname */
+	len = strlen(strcpy(outpath, to));
+	if (outpath[len] != '/') {
+	    outpath[len++] = '/';
+	    outpath[len] = '\0';
+	}
+    } else {
+	len = 0;
+	while ((cp2 = getcomponent(cp2, buf)) != 0) {
+	    strcpy(outpath + len, "../");
+	    len += 3;
+	}
+	while ((cp = getcomponent(cp, buf)) != 0) {
+	    sprintf(outpath + len, "%s/", buf);
+	    len += strlen(outpath + len);
+	}
+    }
+    return len;
+}
+
+void
+reversepath(char *inpath, char *name, int len, char *outpath)
+{
+    char *cp, *cp2;
+    char buf[NAME_MAX];
+    struct stat sb;
+
+    cp = strcpy(outpath + PATH_MAX - (len + 1), name);
+    cp2 = inpath;
+    while ((cp2 = getcomponent(cp2, buf)) != 0) {
+	if (strcmp(buf, ".") == 0)
+	    continue;
+	if (strcmp(buf, "..") == 0) {
+	    if (stat(".", &sb) < 0)
+		fail("cannot stat current directory");
+	    name = ino2name(sb.st_ino, "..");
+	    len = strlen(name);
+	    cp -= len + 1;
+	    strcpy(cp, name);
+	    cp[len] = '/';
+	    free(name);
+	    xchdir("..");
+	} else {
+	    cp -= 3;
+	    strncpy(cp, "../", 3);
+	    xchdir(buf);
+	}
+    }
+    strcpy(outpath, cp);
+}

+ 46 - 0
config/pathsub.h

@@ -0,0 +1,46 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef pathsub_h___
+#define pathsub_h___
+/*
+** Pathname subroutines.
+**
+** Brendan Eich, 8/29/95
+*/
+#include <limits.h>
+#include <sys/types.h>
+
+#if SUNOS4
+#include "../nspr/include/sunos4.h"
+#endif
+
+#ifndef PATH_MAX
+#define PATH_MAX 1024
+#endif
+
+/*
+ * Just prevent stupidity
+ */
+#undef NAME_MAX
+#define NAME_MAX 256
+
+extern char *program;
+
+extern void fail(char *format, ...);
+extern char *getcomponent(char *path, char *name);
+extern char *ino2name(ino_t ino, char *dir);
+extern void *xmalloc(size_t size);
+extern char *xstrdup(char *s);
+extern char *xbasename(char *path);
+extern void xchdir(char *dir);
+
+/* Relate absolute pathnames from and to returning the result in outpath. */
+extern int relatepaths(char *from, char *to, char *outpath);
+
+/* XXX changes current working directory -- caveat emptor */
+extern void reversepath(char *inpath, char *name, int len, char *outpath);
+
+#endif /* pathsub_h___ */

+ 19 - 0
config/revdepth-nt.pl

@@ -0,0 +1,19 @@
+#! /usr/local/bin/perl
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright 2001 Sun Microsystems, Inc.
+# Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+
+require "/ns/config/fastcwd.pl";
+
+$cur = &fastcwd;
+chdir($ARGV[0]);
+$newcur = &fastcwd;
+$newcurlen = length($newcur);
+
+# Skip common separating / unless $newcur is "/"
+$cur = substr($cur, $newcurlen + ($newcurlen > 1));
+print $cur;

+ 22 - 0
config/revdepth.pl

@@ -0,0 +1,22 @@
+#! /usr/local/bin/perl
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright 2001 Sun Microsystems, Inc.
+# Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+
+unshift(@INC, '/usr/lib/perl');
+unshift(@INC, '/usr/local/lib/perl');
+
+require "fastcwd.pl";
+
+$cur = &fastcwd;
+chdir($ARGV[0]);
+$newcur = &fastcwd;
+$newcurlen = length($newcur);
+
+# Skip common separating / unless $newcur is "/"
+$cur = substr($cur, $newcurlen + ($newcurlen > 1));
+print $cur;

+ 707 - 0
config/rules.mk

@@ -0,0 +1,707 @@
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright 2001 Sun Microsystems, Inc.
+# Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+################################################################################
+# Wow this is complicated! The story is that we now have a 4 pass build process:
+#
+# Pass 1. export - Create generated headers and stubs. Publish public headers to
+#		dist/<arch>/include.
+#
+# Pass 2. libs - Create libraries. Publish libraries to dist/<arch>/lib.
+#
+# Pass 3. all - Create programs. 
+#
+# Pass 4. install - Publish programs to dist/<arch>/bin.
+#
+# Parameters to this makefile (set these before including):
+#
+# a)
+#	TARGETS	-- the target to create 
+#			(defaults to $LIBRARY $PROGRAM)
+# b)
+#	DIRS	-- subdirectories for make to recurse on
+#			(the 'all' rule builds $TARGETS $DIRS)
+# c)
+#	CSRCS, CPPSRCS -- .c and .cpp files to compile
+#			(used to define $OBJS)
+# d)
+#	PROGRAM	-- the target program name to create from $OBJS
+#			($OBJDIR automatically prepended to it)
+# e)
+#	LIBRARY	-- the target library name to create from $OBJS
+#			($OBJDIR automatically prepended to it)
+# f)
+#	JSRCS	-- java source files to compile into class files
+#			(if you don't specify this it will default to *.java)
+#	PACKAGE	-- the package to put the .class files into
+#			(e.g. netscape/applet)
+#	JMC_EXPORT -- java files to be exported for use by JMC_GEN
+#			(this is a list of Class names)
+# g)
+#	JRI_GEN	-- files to run through javah to generate headers and stubs
+#			(output goes into the _jri sub-dir)
+# h)
+#	JMC_GEN	-- files to run through jmc to generate headers and stubs
+#			(output goes into the _jmc sub-dir)
+#
+################################################################################
+
+#
+# Common rules used by lots of makefiles...
+#
+ifndef NS_CONFIG_MK
+include $(DEPTH)/config/config.mk
+endif
+
+ifdef PROGRAM
+PROGRAM		:= $(addprefix $(OBJDIR)/, $(PROGRAM))
+endif
+
+ifndef LIBRARY
+ifdef LIBRARY_NAME
+LIBRARY		:= lib$(LIBRARY_NAME).$(LIB_SUFFIX)
+endif
+endif
+
+ifdef LIBRARY
+LIBRARY		:= $(addprefix $(OBJDIR)/, $(LIBRARY))
+ifdef MKSHLIB
+SHARED_LIBRARY	:= $(LIBRARY:.$(LIB_SUFFIX)=$(DLL_PRESUF).$(DLL_SUFFIX))
+endif
+endif
+
+ifndef TARGETS
+TARGETS		= $(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM)
+endif
+
+ifndef OBJS
+OBJS		= $(JRI_STUB_CFILES) $(addsuffix .o, $(JMC_GEN)) $(CSRCS:.c=.o) $(CPPSRCS:.cpp=.o) $(ASFILES:.s=.o)
+endif
+
+ifdef OBJS
+OBJS		:= $(addprefix $(OBJDIR)/, $(OBJS))
+endif
+
+ifdef REQUIRES
+MODULE_PREINCLUDES	= $(addprefix -I$(XPDIST)/public/, $(REQUIRES))
+endif
+
+ifeq ($(OS_ARCH),WINNT)
+ifdef DLL
+DLL		:= $(addprefix $(OBJDIR)/, $(DLL))
+LIB		:= $(addprefix $(OBJDIR)/, $(LIB))
+endif
+endif
+define MAKE_OBJDIR
+if test ! -d $(@D); then rm -rf $(@D); $(NSINSTALL) -D $(@D); fi
+endef
+
+ALL_TRASH		= $(TARGETS) $(OBJS) $(OBJDIR) LOGS TAGS $(GARBAGE) \
+			  $(NOSUCHFILE) $(JDK_HEADER_CFILES) $(JDK_STUB_CFILES) \
+			  $(JRI_HEADER_CFILES) $(JRI_STUB_CFILES) $(JMC_STUBS) \
+			  $(JMC_HEADERS) $(JMC_EXPORT_FILES) so_locations \
+			  _gen _jmc _jri _stubs \
+			  $(wildcard $(JAVA_DESTPATH)/$(PACKAGE)/*.class)
+
+ifdef JDIRS
+ALL_TRASH		+= $(addprefix $(JAVA_DESTPATH)/,$(JDIRS))
+endif
+
+ifdef NSBUILDROOT
+JDK_GEN_DIR		= $(XPDIST)/_gen
+JMC_GEN_DIR		= $(XPDIST)/_jmc
+JRI_GEN_DIR		= $(XPDIST)/_jri
+JDK_STUB_DIR		= $(XPDIST)/_stubs
+else
+JDK_GEN_DIR		= _gen
+JMC_GEN_DIR		= _jmc
+JRI_GEN_DIR		= _jri
+JDK_STUB_DIR		= _stubs
+endif
+
+#
+# If this is an "official" build, try to build everything.
+# I.e., don't exit on errors.
+#
+ifdef BUILD_OFFICIAL
+EXIT_ON_ERROR		= +e
+CLICK_STOPWATCH		= date
+else
+EXIT_ON_ERROR		= -e
+CLICK_STOPWATCH		= true
+endif
+
+
+################################################################################
+
+ifdef ALL_PLATFORMS
+all_platforms:: $(NFSPWD)
+	@d=`$(NFSPWD)`;                                                       \
+	if test ! -d LOGS; then rm -rf LOGS; mkdir LOGS; fi;                  \
+	for h in $(PLATFORM_HOSTS); do                                        \
+		echo "On $$h: $(MAKE) $(ALL_PLATFORMS) >& LOGS/$$h.log";      \
+		rsh $$h -n "(chdir $$d;                                       \
+			     $(MAKE) $(ALL_PLATFORMS) >& LOGS/$$h.log;        \
+			     echo DONE) &" 2>&1 > LOGS/$$h.pid &              \
+		sleep 1;                                                      \
+	done
+
+$(NFSPWD):
+	cd $(@D); $(MAKE) $(@F)
+endif
+
+ifdef REQUIRES
+ifndef NO_NSPR
+INCLUDES += -I$(XPDIST)/$(OBJDIR)/include/nspr20/pr $(addprefix -I$(XPDIST)/public/, $(REQUIRES))
+else
+INCLUDES += $(addprefix -I$(XPDIST)/public/, $(REQUIRES))
+endif
+endif
+
+all:: $(TARGETS)
+	+$(LOOP_OVER_DIRS)
+
+libs:: $(LIBRARY) $(SHARED_LIBRARY)
+
+$(PROGRAM): $(OBJS)
+	@$(MAKE_OBJDIR)
+ifeq ($(OS_ARCH),WINNT)
+	$(CC) $(OBJS) -Fe$@ -link $(LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS)
+else
+	$(CC) -o $@ $(CFLAGS) $(OBJS) $(LDFLAGS)
+endif
+
+$(LIBRARY): $(OBJS)
+	@$(MAKE_OBJDIR)
+	rm -f $@
+	$(AR) $(OBJS)
+	$(RANLIB) $@
+
+$(SHARED_LIBRARY): $(OBJS)
+	@$(MAKE_OBJDIR)
+	rm -f $@
+	$(MKSHLIB) -o $@ $(OBJS) $(EXTRA_SHLIBS)
+	chmod +x $@
+
+ifeq ($(OS_ARCH),WINNT)
+$(DLL): $(OBJS) $(EXTRA_LIBS)
+	@$(MAKE_OBJDIR)
+	rm -f $@
+	$(LINK_DLL) $(OBJS) $(OS_LIBS) $(EXTRA_LIBS)
+endif
+
+.SUFFIXES: .i .pl .class .java .html
+
+.PRECIOUS: .java
+
+$(OBJDIR)/%: %.c
+	@$(MAKE_OBJDIR)
+ifeq ($(OS_ARCH),WINNT)
+	$(CC) -Fo$@ -c $(CFLAGS) $*.c
+else
+	$(CC) -o $@ $(CFLAGS) $*.c $(LDFLAGS)
+endif
+
+$(OBJDIR)/%.o: %.c
+	@$(MAKE_OBJDIR)
+ifeq ($(OS_ARCH),WINNT)
+	$(CC) -Fo$@ -c $(CFLAGS) $*.c
+else
+	$(CC) -o $@ -c $(CFLAGS) $*.c
+endif
+
+$(OBJDIR)/%.o: %.s
+	@$(MAKE_OBJDIR)
+	$(AS) -o $@ $(ASFLAGS) -c $*.s
+
+$(OBJDIR)/%.o: %.S
+	@$(MAKE_OBJDIR)
+	$(AS) -o $@ $(ASFLAGS) -c $*.S
+
+$(OBJDIR)/%: %.cpp
+	@$(MAKE_OBJDIR)
+	$(CCC) -o $@ $(CFLAGS) $*.c $(LDFLAGS)
+
+#
+# Please keep the next two rules in sync.
+#
+$(OBJDIR)/%.o: %.cc
+	@$(MAKE_OBJDIR)
+	$(CCC) -o $@ -c $(CFLAGS) $*.cc
+
+$(OBJDIR)/%.o: %.cpp
+	@$(MAKE_OBJDIR)
+ifdef STRICT_CPLUSPLUS_SUFFIX
+	echo "#line 1 \"$*.cpp\"" | cat - $*.cpp > $(OBJDIR)/t_$*.cc
+	$(CCC) -o $@ -c $(CFLAGS) $(OBJDIR)/t_$*.cc
+	rm -f $(OBJDIR)/t_$*.cc
+else
+ifeq ($(OS_ARCH),WINNT)
+	$(CCC) -Fo$@ -c $(CFLAGS) $*.cpp
+else
+	$(CCC) -o $@ -c $(CFLAGS) $*.cpp
+endif
+endif #STRICT_CPLUSPLUS_SUFFIX
+
+%.i: %.cpp
+	$(CCC) -C -E $(CFLAGS) $< > $*.i
+
+%.i: %.c
+	$(CC) -C -E $(CFLAGS) $< > $*.i
+
+%: %.pl
+	rm -f $@; cp $*.pl $@; chmod +x $@
+
+%: %.sh
+	rm -f $@; cp $*.sh $@; chmod +x $@
+
+#
+# If this is an "official" build, try to build everything.
+# I.e., don't exit on errors.
+#
+ifdef BUILD_OFFICIAL
+EXIT_ON_ERROR	= +e
+else
+EXIT_ON_ERROR	= -e
+endif
+
+ifdef DIRS
+ifneq ($(OS_ARCH),WINNT)
+override MAKEFLAGS :=
+endif
+LOOP_OVER_DIRS =						\
+	@for d in $(DIRS); do					\
+		if test -d $$d; then				\
+			set $(EXIT_ON_ERROR);			\
+			echo "cd $$d; $(MAKE) $(MAKEFLAGS) $@";		\
+			cd $$d; $(MAKE) $(MAKEFLAGS) $@; cd ..;		\
+			set +e;					\
+		else						\
+			echo "Skipping non-directory $$d...";	\
+		fi;						\
+		$(CLICK_STOPWATCH);				\
+done
+
+$(DIRS)::
+	@if test -d $@; then				\
+		set $(EXIT_ON_ERROR);			\
+		echo "cd $@; $(MAKE) $(MAKEFLAGS)";			\
+		cd $@; $(MAKE) $(MAKEFLAGS);				\
+		set +e;					\
+	else						\
+		echo "Skipping non-directory $@...";	\
+	fi						\
+        $(CLICK_STOPWATCH);
+endif # DIRS
+
+clean::
+	rm -f $(OBJS) $(NOSUCHFILE)
+	+$(LOOP_OVER_DIRS)
+
+clobber::
+	rm -f $(OBJS) $(TARGETS) $(GARBAGE) $(NOSUCHFILE)
+	+$(LOOP_OVER_DIRS)
+
+realclean clobber_all::
+	rm -rf LOGS TAGS $(wildcard *.OBJ) $(OBJS) $(TARGETS) $(GARBAGE) $(NOSUCHFILE)
+	+$(LOOP_OVER_DIRS)
+
+alltags:
+	rm -f TAGS
+	find . -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' \) -print | xargs etags -a
+
+export::
+	+$(LOOP_OVER_DIRS)
+
+libs::
+	+$(LOOP_OVER_DIRS)
+
+install::
+	+$(LOOP_OVER_DIRS)
+
+mac::
+	+$(LOOP_OVER_DIRS)
+
+################################################################################
+### Bunch of things that extend the 'export' rule (in order):
+################################################################################
+### JSRCS -- for compiling java files
+
+ifndef PACKAGE
+PACKAGE = .
+endif
+$(JAVA_DESTPATH) $(JAVA_DESTPATH)/$(PACKAGE) $(JMCSRCDIR)::
+	@if test ! -d $@; then	    \
+		echo Creating $@;   \
+		rm -rf $@;	    \
+		$(NSINSTALL) -D $@; \
+	fi
+
+ifneq ($(JSRCS),)
+export:: $(JAVA_DESTPATH) $(JAVA_DESTPATH)/$(PACKAGE)
+	@list=`perl $(DEPTH)/config/outofdate.pl $(PERLARG)	\
+		    -d $(JAVA_DESTPATH)/$(PACKAGE) $(JSRCS)`;	\
+	if test "$$list"x != "x"; then				\
+	    echo $(JAVAC) $$list;				\
+	    $(JAVAC) $$list;					\
+	fi
+
+all:: export
+
+clobber::
+	rm -f $(XPDIST)/classes/$(PACKAGE)/*.class
+
+endif
+
+################################################################################
+## JDIRS -- like JSRCS, except you can give a list of directories and it will
+## compile all the out-of-date java files recursively below those directories.
+
+ifdef JDIRS
+
+export:: $(JAVA_DESTPATH) $(JAVA_DESTPATH)/$(PACKAGE)
+	@for d in $(JDIRS); do							      \
+		if test -d $$d; then						      \
+			set $(EXIT_ON_ERROR);					      \
+			files=`echo $$d/*.java`;			      \
+			list=`perl $(DEPTH)/config/outofdate.pl $(PERLARG)	      \
+				    -d $(JAVA_DESTPATH)/$(PACKAGE) $$files`;	      \
+			if test "$${list}x" != "x"; then			      \
+			    echo Building all java files in $$d;		      \
+			    echo $(JAVAC) $$list;		      \
+			    $(JAVAC) $$list;		      \
+			fi;							      \
+			set +e;							      \
+		else								      \
+			echo "Skipping non-directory $$d...";			      \
+		fi;								      \
+		$(CLICK_STOPWATCH);						\
+	done
+
+all:: export
+
+clobber::
+	@for d in $(JDIRS); do			   \
+		echo rm -rf $(XPDIST)/classes/$$d; \
+		rm -rf $(XPDIST)/classes/$$d;	   \
+	done
+
+endif
+
+################################################################################
+### JDK_GEN -- for generating "old style" native methods 
+
+# Generate JDK Headers and Stubs into the '_gen' and '_stubs' directory
+
+ifneq ($(JDK_GEN),)
+
+ifdef NSBUILDROOT
+JDK_GEN_DIR	= $(XPDIST)/_gen
+JDK_STUB_DIR	= $(XPDIST)/_stubs
+else
+JDK_GEN_DIR	= _gen
+JDK_STUB_DIR	= _stubs
+endif
+
+INCLUDES += -I$(JDK_GEN_DIR)
+
+JDK_PACKAGE_CLASSES = $(JDK_GEN)
+JDK_PATH_CLASSES = $(subst .,/,$(JDK_PACKAGE_CLASSES))
+JDK_PATH_CLASSES = $(subst .,/,$(JDK_PACKAGE_CLASSES))
+JDK_HEADER_CLASSFILES	= $(patsubst %,$(JAVA_DESTPATH)/%.class,$(JDK_PATH_CLASSES))
+JDK_STUB_CLASSFILES	= $(patsubst %,$(JAVA_DESTPATH)/%.class,$(JDK_PATH_CLASSES))
+JDK_HEADER_CFILES	= $(patsubst %,$(JDK_GEN_DIR)/%.h,$(JDK_GEN))
+JDK_STUB_CFILES		= $(patsubst %,$(JDK_STUB_DIR)/%.c,$(JDK_GEN))
+
+$(JDK_HEADER_CFILES): $(JDK_HEADER_CLASSFILES)
+$(JDK_STUB_CFILES): $(JDK_STUB_CLASSFILES)
+
+export::
+	@echo Generating/Updating JDK headers 
+	$(JAVAH) -d $(JDK_GEN_DIR) $(JDK_PACKAGE_CLASSES)
+	@echo Generating/Updating JDK stubs
+	$(JAVAH) -stubs -d $(JDK_STUB_DIR) $(JDK_PACKAGE_CLASSES)
+
+mac::
+	@echo Generating/Updating JDK headers for the Mac
+	$(JAVAH) -mac -d $(DEPTH)/lib/mac/Java/_gen $(JDK_PACKAGE_CLASSES)
+	@echo Generating/Updating JDK stubs for the Mac
+	$(JAVAH) -mac -stubs -d $(DEPTH)/lib/mac/Java/_stubs $(JDK_PACKAGE_CLASSES)
+
+# Don't delete them if the don't compile (makes it hard to debug):
+.PRECIOUS: $(JDK_HEADERS) $(JDK_STUBS)
+
+clobber::
+	rm -rf $(JDK_HEADER_CFILES) $(JDK_STUB_CFILES)
+
+endif
+
+################################################################################
+### JRI_GEN -- for generating JRI native methods
+
+# Generate JRI Headers and Stubs into the 'jri' directory
+
+ifneq ($(JRI_GEN),)
+
+ifdef NSBUILDROOT
+JRI_GEN_DIR	= $(XPDIST)/_jri
+else
+JRI_GEN_DIR	= _jri
+endif
+
+INCLUDES += -I$(JRI_GEN_DIR)
+
+JRI_PACKAGE_CLASSES = $(JRI_GEN)
+JRI_PATH_CLASSES = $(subst .,/,$(JRI_PACKAGE_CLASSES))
+
+## dependency fu
+JRI_HEADER_CLASSFILES = $(patsubst %,$(XPDIST)/classes/%.class,$(JRI_PATH_CLASSES))
+JRI_HEADER_CFILES = $(patsubst %,$(JRI_GEN_DIR)/%.h,$(JRI_GEN))
+$(JRI_HEADER_CFILES): $(JRI_HEADER_CLASSFILES)
+
+## dependency fu
+JRI_STUB_CLASSFILES = $(patsubst %,$(XPDIST)/classes/%.class,$(JRI_PATH_CLASSES))
+JRI_STUB_CFILES = $(patsubst %,$(JRI_GEN_DIR)/%.c,$(JRI_GEN))
+$(JRI_STUB_CFILES): $(JRI_STUB_CLASSFILES)
+
+export::
+	@echo Generating/Updating JRI headers 
+	$(JAVAH) -jri -d $(JRI_GEN_DIR) $(JRI_PACKAGE_CLASSES)
+	@echo Generating/Updating JRI stubs
+	$(JAVAH) -jri -stubs -d $(JRI_GEN_DIR) $(JRI_PACKAGE_CLASSES)
+	@if test ! -d $(DEPTH)/lib/mac/Java/; then						\
+		echo "!!! You need to have a ns/lib/mac/Java directory checked out.";		\
+		echo "!!! This allows us to automatically update generated files for the mac.";	\
+		echo "!!! If you see any modified files there, please check them in.";		\
+	fi
+	@echo Generating/Updating JRI headers for the Mac
+	$(JAVAH) -jri -mac -d $(DEPTH)/lib/mac/Java/_jri $(JRI_PACKAGE_CLASSES)
+	@echo Generating/Updating JRI stubs for the Mac
+	$(JAVAH) -jri -mac -stubs -d $(DEPTH)/lib/mac/Java/_jri $(JRI_PACKAGE_CLASSES)
+
+# Don't delete them if the don't compile (makes it hard to debug):
+.PRECIOUS: $(JRI_HEADERS) $(JRI_STUBS)
+
+clobber::
+	rm -rf $(JRI_HEADER_CFILES) $(JRI_STUB_CFILES)
+
+endif
+
+################################################################################
+## JMC_EXPORT -- for declaring which java classes are to be exported for jmc
+
+ifneq ($(JMC_EXPORT),)
+
+JMC_EXPORT_PATHS = $(subst .,/,$(JMC_EXPORT))
+JMC_EXPORT_FILES = $(patsubst %,$(XPDIST)/classes/$(PACKAGE)/%.class,$(JMC_EXPORT_PATHS))
+
+# We're doing NSINSTALL -t here (copy mode) because calling INSTALL will pick up 
+# your NSDISTMODE and make links relative to the current directory. This is a
+# problem because the source isn't in the current directory:
+
+export:: $(JMC_EXPORT_FILES) $(JMCSRCDIR)
+	$(NSINSTALL) -t -m 444 $(JMC_EXPORT_FILES) $(JMCSRCDIR)
+
+clobber::
+	rm -rf $(JMC_EXPORT_FILES)
+
+endif
+
+
+################################################################################
+## EXPORTS
+#
+# Copy each element of EXPORTS to $(XPDIST)/public/$(MODULE)/
+#
+
+ifneq ($(EXPORTS),)
+
+$(XPDIST)/public/$(MODULE)::
+	@if test ! -d $@; then	    \
+		echo Creating $@;   \
+		rm -rf $@;	    \
+		mkdir -p $@;	    \
+	fi
+
+export:: $(EXPORTS) $(XPDIST)/public/$(MODULE)
+	$(NSINSTALL) -t -m 444 $(EXPORTS) $(XPDIST)/public/$(MODULE)
+
+endif
+
+################################################################################
+## JMC_GEN -- for generating java modules
+
+# Provide default export & install rules when using JMC_GEN
+ifneq ($(JMC_GEN),)
+
+ifdef NSBUILDROOT
+JMC_GEN_DIR	= $(XPDIST)/_jmc
+else
+JMC_GEN_DIR	= _jmc
+endif
+
+INCLUDES += -I$(JMC_GEN_DIR)
+
+JMC_HEADERS = $(patsubst %,$(JMC_GEN_DIR)/%.h,$(JMC_GEN))
+JMC_STUBS = $(patsubst %,$(JMC_GEN_DIR)/%.c,$(JMC_GEN))
+JMC_OBJS = $(patsubst %,$(OBJDIR)/%.o,$(JMC_GEN))
+
+$(JMC_GEN_DIR)/M%.h: $(JMCSRCDIR)/%.class
+	$(JMC) -d $(JMC_GEN_DIR) -interface $(JMC_GEN_FLAGS) $(?F:.class=)
+
+$(JMC_GEN_DIR)/M%.c: $(JMCSRCDIR)/%.class
+	$(JMC) -d $(JMC_GEN_DIR) -module $(JMC_GEN_FLAGS) $(?F:.class=)
+
+$(OBJDIR)/M%.o: $(JMC_GEN_DIR)/M%.h $(JMC_GEN_DIR)/M%.c
+	@$(MAKE_OBJDIR)
+	$(CC) -o $@ -c $(CFLAGS) $(JMC_GEN_DIR)/M$*.c
+
+export:: $(JMC_HEADERS) $(JMC_STUBS)
+
+# Don't delete them if the don't compile (makes it hard to debug):
+.PRECIOUS: $(JMC_HEADERS) $(JMC_STUBS)
+
+clobber::
+	rm -rf $(JMC_HEADERS) $(JMC_STUBS)
+
+endif
+
+################################################################################
+## LIBRARY -- default rules for for building libraries
+
+ifdef LIBRARY
+libs:: $(LIBRARY)
+	$(INSTALL) -m 444 $(LIBRARY) $(DIST)/lib
+
+install:: $(LIBRARY)
+	$(INSTALL) -m 444 $(LIBRARY) $(DIST)/lib
+endif
+
+ifdef SHARED_LIBRARY
+libs:: $(SHARED_LIBRARY)
+	$(INSTALL) -m 555 $(SHARED_LIBRARY) $(DIST)/bin
+
+install:: $(SHARED_LIBRARY)
+	$(INSTALL) -m 555 $(SHARED_LIBRARY) $(DIST)/bin
+endif
+
+################################################################################
+## PROGRAM -- this is now needed because final programs are distributed
+##	      through dist and link with dynamic libraries
+
+ifdef PROGRAM
+libs:: $(PROGRAM)
+	$(INSTALL) -m 444 $(PROGRAM) $(DIST)/bin
+
+install:: $(PROGRAM)
+	$(INSTALL) -m 444 $(PROGRAM) $(DIST)/bin
+endif
+
+################################################################################
+
+-include $(DEPENDENCIES)
+
+ifneq ($(OS_ARCH),WINNT)
+# Can't use sed because of its 4000-char line length limit, so resort to perl
+.DEFAULT:
+	@perl -e '                                                            \
+	    open(MD, "< $(DEPENDENCIES)");                                    \
+	    while (<MD>) {                                                    \
+		if (m@ \.*/*$< @) {                                           \
+		    $$found = 1;                                              \
+		    last;                                                     \
+		}                                                             \
+	    }                                                                 \
+	    if ($$found) {                                                    \
+		print "Removing stale dependency $< from $(DEPENDENCIES)\n";  \
+		seek(MD, 0, 0);                                               \
+		$$tmpname = "$(OBJDIR)/fix.md" . $$$$;                        \
+		open(TMD, "> " . $$tmpname);                                  \
+		while (<MD>) {                                                \
+		    s@ \.*/*$< @ @;                                           \
+		    if (!print TMD "$$_") {                                   \
+			unlink(($$tmpname));                                  \
+			exit(1);                                              \
+		    }                                                         \
+		}                                                             \
+		close(TMD);                                                   \
+		if (!rename($$tmpname, "$(DEPENDENCIES)")) {                  \
+		    unlink(($$tmpname));                                      \
+		}                                                             \
+	    } elsif ("$<" ne "$(DEPENDENCIES)") {                             \
+		print "$(MAKE): *** No rule to make target $<.  Stop.\n";     \
+		exit(1);                                                      \
+	    }'
+endif
+
+#############################################################################
+# X dependency system
+#############################################################################
+
+ifneq ($(OS_ARCH),WINNT)
+
+$(MKDEPENDENCIES)::
+	@$(MAKE_OBJDIR)
+	touch $(MKDEPENDENCIES)
+	$(MKDEPEND) -p$(OBJDIR_NAME)/ -o'.o' -f$(MKDEPENDENCIES) $(INCLUDES) $(CSRCS) $(CPPSRCS)
+
+$(MKDEPEND)::
+	cd $(MKDEPEND_DIR); $(MAKE)
+
+ifdef OBJS
+depend:: $(MKDEPEND) $(MKDEPENDENCIES)
+else
+depend::
+endif
+	+$(LOOP_OVER_DIRS)
+
+dependclean::
+	rm -f $(MKDEPENDENCIES)
+	+$(LOOP_OVER_DIRS)
+
+#-include $(OBJDIR)/depend.mk
+
+endif
+
+#############################################################################
+
+-include $(MY_RULES)
+
+$(MY_CONFIG):
+$(MY_RULES):
+
+# Generate Emacs tags in a file named TAGS if ETAGS was set in $(MY_CONFIG)
+# or in $(MY_RULES)
+ifdef ETAGS
+ifneq ($(CSRCS)$(HEADERS),)
+all:: TAGS
+TAGS:: $(CSRCS) $(HEADERS)
+	$(ETAGS) $(CSRCS) $(HEADERS)
+endif
+endif
+
+################################################################################
+# Special gmake rules.
+################################################################################
+
+#
+# Re-define the list of default suffixes, so gmake won't have to churn through
+# hundreds of built-in suffix rules for stuff we don't need.
+#
+.SUFFIXES:
+.SUFFIXES: .out .a .ln .o .c .cc .C .cpp .y .l .s .S .h .sh .i .pl .class .java .html
+
+#
+# Don't delete these files if we get killed.
+#
+.PRECIOUS: .java $(JDK_HEADERS) $(JDK_STUBS) $(JRI_HEADERS) $(JRI_STUBS) $(JMC_HEADERS) $(JMC_STUBS)
+
+#
+# Fake targets.  Always run these rules, even if a file/directory with that
+# name already exists.
+#
+.PHONY: all all_platforms alltags boot clean clobber clobber_all export install libs realclean $(OBJDIR) $(DIRS)

+ 24 - 0
config/webint.mk

@@ -0,0 +1,24 @@
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright 2001 Sun Microsystems, Inc.
+# Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+ifdef WEBSERVER_LANGS
+LANG_LOOP=							\
+  @for d in $(WEBSERVER_LANGS); do				\
+    if test ! -d $$d; then					\
+      echo Directory $$d does not exist. Creating...;		\
+      mkdir -p $$d;						\
+    fi;								\
+    echo cd $$d;						\
+    cd $$d;							\
+    echo $(MAKE) -f ../Makefile $(MAKEFLAGS) INT_SUBDIR=1;	\
+    $(MAKE) -f ../Makefile $(MAKEFLAGS) INT_SUBDIR=1;		\
+    cd ..;							\
+  done
+else
+LANG_LOOP= @echo "No foreign languages in this build"
+endif
+

+ 125 - 0
dirver.pl

@@ -0,0 +1,125 @@
+#!/usr/bin/perl
+#-----------------------------------------------------------------
+# dirver.pl: Generates ascii format #define for FILEVERSION
+#   resource identifier used by Windows executable binaries.
+#
+#   Usage: dirver.pl -v <major.minor.patch> [-d mm/dd/yy] [-o outfile]
+#   Example: dirver.pl -v 6.5.2 -d 1/19/2005 -o fileversion.h
+#
+#   -v <major.minor.patch>    Version number.
+#   -d <mm/dd/yy>             Date. (optional)
+#   -o <outfile>              Output header file. (optional)
+#   -H                        Print this help message
+#-----------------------------------------------------------------
+
+use Getopt::Std;
+use FileHandle;
+                                                                                             
+autoflush STDERR 1;
+                                                                                             
+getopts('v:d:o:H');
+                                                                                             
+if ($opt_H) {exitHelp();}
+
+# Load arguments
+$version = $opt_v || exitHelp();
+$date = $opt_d;
+$outfile = $opt_o;
+
+# Separate version into components
+my @verComponents = split(/\./, $version);
+
+# Set version components to 0 if not defined
+if ($verComponents[1] == undef) { $verComponents[1] = "0"; }
+if ($verComponents[2] == undef) { $verComponents[2] = "0"; }
+
+# Calculate build version and build date
+my $buildVersion = calcVersion(@verComponents);
+my $buildDate = calcBuildDate($date);
+
+# Write #defines out to stdout or a file is requested
+if ($outfile) {
+    open(OUTFILE,">$outfile") || die "Error: Can't create $outfile: $!";
+    $outhdl = OUTFILE;
+} else {
+    $outhdl = STDOUT;
+}
+
+print $outhdl "#define VI_PRODUCTVERSION $verComponents[0].$verComponents[1]\n";
+print $outhdl "#define PRODUCTTEXT \"$version\"\n";
+print $outhdl "#define VI_FILEVERSION $buildVersion, 0, 0, $buildDate\n";
+print $outhdl "#define VI_FileVersion \"$version Build $buildDate\\0\"\n";
+
+# Close file if not using STDOUT
+if ($outfile) {
+    close(OUTFILE);
+}
+
+#---------- calcVersion subroutine ----------
+sub calcVersion {
+    my @ver = shift;
+    my $nVersion = 0;
+
+    $nVersion = $ver[0];
+    $nVersion <<= 5;
+    $nVersion += $ver[1];
+    $nVersion <<= 7;
+    $nVersion += $ver[2];
+    $nVersion &= 0xFFFF;
+
+    return $nVersion;
+}
+
+#---------- calcBuildDate subroutine ----------
+sub calcBuildDate {
+    my $date = shift;
+    my @dateComponents = ();
+    my $month, $date, $year;
+    my $buildDate = "";
+
+    # Use date if passed in, otherwise use system date
+    if ($date) {
+        # Separate date into month, day, and year
+        @dateComponents = split(/\//, $date);
+
+        # Use struct tm range for month
+        $dateComponents[0]--;
+
+        # Handle 2 digit years like (20)00
+        if ($dateComponents[2] < 70) {
+            $dateComponents[2] += 20;
+        }
+
+        $month = $dateComponents[0];
+        $day = $dateComponents[1];
+        $year = $dateComponents[2];
+    } else {
+        $month = (localtime)[4];
+        $day = (localtime)[3];
+        $year = (localtime)[5] - 80;
+    }
+
+    $buildDate = $year;
+    $buildDate <<= 4;
+    $buildDate += $month;
+    $buildDate <<= 5;
+    $buildDate += $day;
+    $buildDate &= 0xFFFF;
+
+    return $buildDate;
+}
+
+#---------- exitHelp subroutine ----------
+sub exitHelp {
+    print(STDERR "$0: Generates ascii format #define for FILEVERSION
+    \tresource identifier used by Windows executable binaries.
+
+    \tUsage: $0 -v <major.minor.patch> [-d mm/dd/yy] [-o outfile]
+    \tExample: $0 -v 6.5.2 -d 1/19/2005 -o fileversion.h
+
+    \t-v <major.minor.patch>    Version number.
+    \t-d <mm/dd/yy>             Date. \(optional\)
+    \t-o <outfile>              Output header file. \(optional\)
+    \t-H                        Print this help message\n");
+    exit(0);
+}

+ 500 - 0
httpd/autobuild

@@ -0,0 +1,500 @@
+#!/bin/sh
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright 2001 Sun Microsystems, Inc.
+# Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+
+UNAME=`../nsarch`
+NSUNAME=`uname -s | sed -e 's%/%_%g'``uname -r`
+DATE="`date +%d-%h`"
+
+# OS tweaks
+
+if [ "$UNAME" = "SUNOS4" ]; then
+    PATH=/usr/local/sun4/bin:/usr/bin/X11:$PATH; export PATH
+    GTAR=/share/builds/f/gtar/bin/sunos-gtar
+    HTTPDLIB=ns-httpd.so
+
+elif [ "$UNAME" = "SOLARIS" ]; then
+    PATH=/usr/ccs/bin:/usr/openwin/bin:$PATH; export PATH
+    OPENWINHOME=/usr/openwin; export OPENWINHOME
+    GTAR=/share/builds/f/gtar/bin/solaris-gtar
+    HTTPDLIB=ns-httpd.so
+
+elif [ "$UNAME" = "SOLARISx86" ]; then
+    PATH=/usr/ccs/bin:/usr/openwin/bin:$PATH; export PATH
+    OPENWINHOME=/usr/openwin; export OPENWINHOME
+    HTTPDLIB=ns-httpd.so
+
+elif [ "$UNAME" = "HPUX" ]; then
+  PATH=/usr/local/hpux/bin:/usr/bin/X11:$PATH; export PATH
+  GTAR=/share/builds/f/gtar/bin/hpux-gtar
+  HTTPDLIB=libnshttpd.sl
+
+elif [ "$UNAME" = "BSDI" ]; then
+  PATH=/usr/local/bin:/usr/X11/bin:$PATH; export PATH
+  GTAR=/share/builds/f/gtar/bin/bsdi-gtar
+
+elif [ "$UNAME" = "OSF1" ]; then
+#  NOJAVA=true
+  PATH=/usr/local/dec/bin:/usr/bin/X11:$PATH; export PATH
+  GTAR=/share/builds/f/gtar/bin/osf1-gtar
+  HTTPDLIB=ns-httpd.so
+
+elif [ "$UNAME" = "AIX" ]; then
+  PATH=/usr/local/aix32/bin:/usr/bin/X11:$PATH; export PATH
+  GTAR=/share/builds/f/gtar/bin/aix-gtar
+  HTTPDLIB=ns-httpd.a
+
+elif [ "$UNAME" = "IRIX" ]; then
+  GTAR=/share/builds/f/gtar/bin/irix-gtar
+  HTTPDLIB=ns-httpd.so
+
+elif [ "$UNAME" = "SONY" ]; then
+  PATH=/usr/bin/X11:$PATH; export PATH
+  HTTPDLIB=ns-httpd.so
+
+elif [ "$UNAME" = "NECSVR4" ]; then
+  PATH=/u/malmer/nec/usr/local/bin:/usr/bin/X11:$PATH; export PATH
+  HTTPDLIB=ns-httpd.so
+
+elif [ "$UNAME" = "ReliantUNIX" ]; then
+  PATH=/usr/local/bin:$PATH; export PATH
+  GTAR=tar
+  HTTPDLIB=ns-httpd.so
+
+elif [ "$UNAME" = "SCO" ]; then
+  PATH=/usr/local/bin:/usr/bin/X11:$PATH; export PATH
+  GTAR=/usr/local/bin/gtar
+  HTTPDLIB=ns-httpd.so
+
+elif [ "$UNAME" = "UNIXWARE" ]; then
+  PATH=/usr/local/bin:/usr/bin/X11:$PATH; export PATH
+  GTAR=/usr/local/bin/gtar
+  HTTPDLIB=ns-httpd.so
+
+fi
+
+set -- `getopt p: $*` || {
+	echo "### `basename $0`:  ERROR:  unknown option" 1>&2
+	exit 1
+}
+
+BuildInPhases=0
+
+while [ "$1" != "--" ] ; do
+	case "$1" in
+		-p) BuildInPhases=1; shift; Phase=$1
+			;;
+	esac
+	shift
+done
+shift
+
+
+buildit() {
+
+#  Initialize some variables
+
+ADMINDIR=../built/$UNAME-$SECTYPE-admserv
+if [ "$PRODUCT" = "personal" ]; then
+  BINDIR=httpd
+  TARNAME=nshttpd.tar
+elif [ "$PRODUCT" = "catalog" ]; then
+  BINDIR=catalog
+  TARNAME=ns-catalog.tar
+elif [ "$PRODUCT" = "rds" ]; then
+  BINDIR=rds
+  TARNAME=ns-rds.tar
+elif [ "$PRODUCT" = "cms" ]; then
+  BINDIR=https
+  TARNAME=ns-cms.tar
+else
+  BINDIR=https
+  TARNAME=nshttps.tar
+fi
+SOURCEDIR=../built/$UNAME-$SECTYPE-$BINDIR
+TARGETDIR=$TYPE/$UNAME-$SECTYPE-$BINDIR
+TARGETUNTAR=$TYPE/$UNAME-$SECTYPE-$BINDIR/untarred
+
+TARGETHTBIN=$TYPE/$UNAME-$SECTYPE-$BINDIR/untarred/bin/$BINDIR
+mkdir -p $TARGETUNTAR 2> /dev/null
+
+if [ $BuildInPhases = 1 ]
+then
+	if [ "$Phase" = "server" ]
+	then
+		buildserver
+	elif [ "$Phase" = "admin" ]
+	then
+		buildadmin
+	elif [ "$Phase" = "batman" ]
+	then
+		buildbatman
+	elif [ "$Phase" = "tar" ]
+	then
+		(cd $TARGETUNTAR; tar cvf ../$TARNAME *)
+	else
+		echo "`basename $0`:  ERROR:  unknown build phase"
+		exit 1
+	fi
+else
+	buildserver
+	buildadmin
+	buildbatman
+	(cd $TARGETUNTAR; tar cvf ../$TARNAME *)
+fi
+}
+
+buildserver() {
+
+(cd ..; ./config $BOMB $PRODUCT $SECCONFIG $OPTIMIZE)
+gmake
+
+if [ $? -ne 0 ]; then
+  exit 2
+fi
+
+(cd ../mc-icons; gmake)
+if [ $? -ne 0 ]; then
+  exit 2
+fi
+
+(cd ../include; gmake)
+if [ $? -ne 0 ]; then
+  exit 2
+fi
+
+(cd nsapi; gmake)
+if [ $? -ne 0 ]; then
+  exit 2
+fi
+
+(cd extras; gmake)
+if [ $? -ne 0 ]; then
+  exit 2
+fi
+
+if [ "$NOJAVA" != "true" ]; then
+  (cd ../lib/sjava; gmake)
+  if [ $? -ne 0 ]; then
+    exit 2
+  fi
+fi
+
+# generate DBMs in admin/bin directory
+(cd $SOURCEDIR/admin/bin; ./mkdbm)
+
+# Each product has different manuals
+if [ "$BINDIR" = "catalog" -o "$BINDIR" = "rds" ]; then
+	# Batman
+	ADMINMANUALS="html/manual/ag html/manual/design html/manual/beta2"
+else
+	# Enterprise and FastTrack
+	ADMINMANUALS="html/manual/ag html/manual/pg html/manual/javascript"
+fi
+for i in icons html html/info html/manual $ADMINMANUALS bin; do
+  mkdir -p $TARGETUNTAR/bin/$BINDIR/admin/$i
+  cp $SOURCEDIR/admin/$i/* $TARGETHTBIN/admin/$i
+done
+
+/bin/rm -f $TARGETHTBIN/admin/bin/*.o
+$STRIP $TARGETHTBIN/admin/bin/*
+
+for i in misc icons html bin; do
+  mkdir -p $TARGETHTBIN/install/$i
+  cp $SOURCEDIR/install/$i/* $TARGETHTBIN/install/$i
+done
+$STRIP $TARGETHTBIN/install/bin/*
+mv $TARGETHTBIN/install/bin/ns-setup $TARGETDIR
+mv $TARGETHTBIN/install/bin/ns-config $TARGETHTBIN/ns-config
+
+
+mkdir -p $TARGETUNTAR/ns-icons
+cp $SOURCEDIR/mc-icons/* $TARGETUNTAR/ns-icons
+
+if [ -d $SOURCEDIR/nsapi -a "$UNAME" != "BSDI" ]; then
+    mkdir -p $TARGETUNTAR/nsapi
+    cp -r $SOURCEDIR/nsapi/* $TARGETUNTAR/nsapi
+fi
+
+mkdir -p $TARGETUNTAR/extras
+cp -r $SOURCEDIR/extras/* $TARGETUNTAR/extras
+$STRIP $TARGETUNTAR/extras/*/*
+
+cp $SOURCEDIR/ns-httpd $TARGETHTBIN/ns-httpd
+if [ "$HTTPDLIB" != "" ]; then
+  cp $SOURCEDIR/$HTTPDLIB $TARGETHTBIN/$HTTPDLIB
+fi
+$STRIP $TARGETHTBIN/ns-httpd
+if [ "$UNAME" != "IRIX" -a "$UNAME" != "SUNOS4" ]; then
+  $STRIP $TARGETHTBIN/$HTTPDLIB
+fi
+
+if [ "$UNAME" = "AIX" ]; then
+  cp /usr/lib/libsvld.a $TARGETHTBIN/libsvld.a
+fi
+
+
+cp README $TARGETDIR
+cp newinst/misc/license.txt $TARGETDIR
+
+mkdir -p $TARGETUNTAR/userdb
+mkdir -p $TARGETUNTAR/httpacl
+mkdir -p $TARGETUNTAR/authdb
+mkdir -p $TARGETUNTAR/authdb/default
+
+if [ "$PRODUCT" = "enterprise" ]; then
+mkdir -p $TARGETUNTAR/plugins/search/admin
+mkdir -p $TARGETUNTAR/plugins/search/tmp
+chmod a+w $TARGETUNTAR/plugins/search/tmp
+mkdir -p $TARGETUNTAR/plugins/search/collections
+chmod a+w $TARGETUNTAR/plugins/search/collections
+cp -r plugins/search $TARGETUNTAR/plugins
+(cd $TARGETUNTAR/plugins/search; rm -r `find . -name CVS -print`)
+cp $SOURCEDIR/lib/vsearch $TARGETUNTAR/plugins/search/vsearch
+cp $SOURCEDIR/admin/bin/ia* $TARGETUNTAR/plugins/search/vsearch
+$STRIP $TARGETUNTAR/plugins/search/vsearch/ia*
+cp ../lib/libsearch/searching/query.err $TARGETUNTAR/plugins/search/vsearch
+mkdir -p $TARGETUNTAR/plugins/search/ui/icons
+mkdir -p $TARGETUNTAR/plugins/search/ui/usa
+cp ../lib/libsearch/searching/ui/icons/* $TARGETUNTAR/plugins/search/ui/icons
+cp ../lib/libsearch/searching/ui/usa/* $TARGETUNTAR/plugins/search/ui/usa
+
+mkdir -p $TARGETUNTAR/plugins/snmp
+mkdir -p $TARGETUNTAR/plugins/snmp/magt
+mkdir -p $TARGETUNTAR/plugins/snmp/sagt
+if [ -d $SOURCEDIR/plugin/snmp -a -f $SOURCEDIR/plugin/snmp/httpagt ]; then
+  cp $SOURCEDIR/plugin/snmp/httpagt $TARGETUNTAR/plugins/snmp/httpagt
+fi
+cp plugins/snmp/netscape.pub $TARGETUNTAR/plugins/snmp/netscape.mib
+
+mkdir -p $TARGETUNTAR/plugins/mks/bin
+	cp $SOURCEDIR/plugins/mks/bin/*.so $TARGETUNTAR/plugins/mks/bin
+
+if [ "$UNAME" = "SUNOS4" ]; then
+  cp ../../../peer/sunos/magt/* $TARGETUNTAR/plugins/snmp/magt
+  cp ../../../peer/sunos/sagt/* $TARGETUNTAR/plugins/snmp/sagt
+elif [ "$UNAME" = "SOLARIS" ]; then
+  cp ../../../peer/solaris/magt/* $TARGETUNTAR/plugins/snmp/magt
+  cp ../../../peer/solaris/sagt/* $TARGETUNTAR/plugins/snmp/sagt
+elif [ "$UNAME" = "HPUX" ]; then
+  cp ../../../peer/hp/magt/* $TARGETUNTAR/plugins/snmp/magt
+  cp ../../../peer/hp/sagt/* $TARGETUNTAR/plugins/snmp/sagt
+elif [ "$UNAME" = "OSF1" ]; then
+  cp ../../../peer/osf/magt/* $TARGETUNTAR/plugins/snmp/magt
+  cp ../../../peer/osf/sagt/* $TARGETUNTAR/plugins/snmp/sagt
+elif [ "$UNAME" = "AIX" ]; then
+  cp ../../../peer/aix/magt/* $TARGETUNTAR/plugins/snmp/magt
+  cp ../../../peer/aix/sagt/* $TARGETUNTAR/plugins/snmp/sgat
+elif [ "$UNAME" = "IRIX" ]; then
+  cp ../../../peer/irix/magt/* $TARGETUNTAR/plugins/snmp/magt
+  cp ../../../peer/irix/sagt/* $TARGETUNTAR/plugins/snmp/sagt
+fi
+fi	#  PRODUCT = enterprise
+
+
+if [ "$NOJAVA" != "true" ]; then
+  mkdir -p $TARGETUNTAR/plugins/java/bin
+  cp $SOURCEDIR/lib/libsjava.so $TARGETUNTAR/plugins/java/bin
+
+  mkdir -p $TARGETUNTAR/plugins/java/classes
+  cp ../../sun-java/classsrc/serv2_0.zip $TARGETUNTAR/plugins/java/classes
+
+  cp plugins/java/javac $TARGETUNTAR/plugins/java
+  cp plugins/java/README $TARGETUNTAR/plugins/java
+
+  mkdir -p $TARGETUNTAR/plugins/java/applets
+  cp plugins/java/applets/* $TARGETUNTAR/plugins/java/applets
+
+#  mkdir -p $TARGETUNTAR/plugins/java/local-classes
+#  cp plugins/java/local-classes/* $TARGETUNTAR/plugins/java/local-classes
+
+# XXXrobm these docs assume that we have Sun's HTML and images
+#  mkdir -p $TARGETUNTAR/plugins/java/docs/images
+#  cp plugins/java/docs/*.html $TARGETUNTAR/plugins/java/docs
+#  cp ../../sun-java/javadoc/*.gif $TARGETUNTAR/plugins/java/docs/images
+fi
+
+mkdir $TARGETUNTAR/install
+cp ./newinst/src/upgrade $TARGETUNTAR/install
+cp ./newinst/src/ObjConf.pm $TARGETUNTAR/install
+cp ./newinst/src/Magnus.pm $TARGETUNTAR/install
+cp ./newinst/src/start $TARGETUNTAR/install
+cp ./newinst/src/stop $TARGETUNTAR/install
+cp ./newinst/src/restart $TARGETUNTAR/install
+cp ./newinst/src/rotate $TARGETUNTAR/install
+cp ./newinst/perl5/$UNAME-perl5/perl $TARGETUNTAR/install
+cp ./newinst/perl5/artistic $TARGETUNTAR/install
+if [ "$UNAME" = "IRIX" ] || [ "$UNAME" = "SOLARIS" ] || [ "$UNAME" = "OSF1" ] ; then
+  cp ./newinst/src/kernelThreads.pl $TARGETUNTAR/install/threads.pl
+fi
+cp $SOURCEDIR/extras/database/mkuser $TARGETUNTAR/install
+cp $SOURCEDIR/extras/database/ndbmdump $TARGETUNTAR/install
+cp $SOURCEDIR/extras/database/rcert11 $TARGETUNTAR/install
+cp $SOURCEDIR/extras/database/rkey11 $TARGETUNTAR/install
+$STRIP $TARGETUNTAR/install/*
+
+if [ "$DO_LIVEWIRE" = "yes" ]; then
+	if [ "$UNAME" = "IRIX" ] ; then
+		PLATSFX=sgi
+	elif [ "$UNAME" = "SOLARIS" ] ; then
+		PLATSFX=sol
+	elif [ "$UNAME" = "HPUX" ] ; then
+		PLATSFX=hpx
+	fi
+	LIVEWIRETAR=livewire_$PLATSFX.tar
+	if [ -d $TARGETUNTAR/LiveWire ]; then
+		rm -rf $TARGETUNTAR/LiveWire
+	fi
+	mkdir $TARGETUNTAR/LiveWire
+	cp ./newinst/src/$LIVEWIRETAR.gz $TARGETUNTAR/LiveWire
+	gunzip $TARGETUNTAR/LiveWire/$LIVEWIRETAR
+	(cd $TARGETUNTAR/LiveWire; tar xf livewire*.tar)
+	cp $TARGETUNTAR/LiveWire/server/* $TARGETUNTAR/bin/$BINDIR
+	cp $TARGETUNTAR/LiveWire/bin/* $TARGETUNTAR/bin/$BINDIR
+	rm -rf $TARGETUNTAR/LiveWire/server $TARGETUNTAR/LiveWire/bin
+	rm $TARGETUNTAR/LiveWire/livewire*.tar
+fi
+
+
+(cd $TARGETUNTAR; find . -name \*.o -print | xargs rm -f)
+
+}
+
+buildadmin() {
+
+# BONEHEAD
+(cd ..; ./config $BOMB admin $SECCONFIG $OPTIMIZE)
+(cd ../admserv; gmake)
+if [ $? -ne 0 ]; then
+  exit 2
+fi
+
+mkdir -p $TARGETUNTAR/admserv
+cp $ADMINDIR/ns-admin $TARGETUNTAR/admserv
+$STRIP $TARGETUNTAR/admserv/ns-admin
+
+for i in icons html html/info bin cfgstuff; do
+  mkdir -p $TARGETUNTAR/bin/admserv/$i
+  cp $ADMINDIR/cgi/$i/* $TARGETUNTAR/bin/admserv/$i
+done
+$STRIP $TARGETUNTAR/bin/admserv/bin/*
+
+}
+
+buildbatman() {
+
+# For AutoCatalog from Batman -Darren
+if [ "$DO_AUTOCATALOG" = "yes" ]; then
+	# We need to re-run config to get our own library versions, etc.
+	(cd ..; ./config $BOMB batman $SECCONFIG $OPTIMIZE)
+
+	#  This ugly hack is needed because nspr.a must be rebuilt on
+	#  SOLARIS for batman.  There are symbols required by the gcc
+	#  generated code that SparcWorks doesn't provide - nothing links.
+
+	if [ "$UNAME" = "SOLARIS" ]; then
+		NSPRDIR=../../nspr/src/${NSUNAME}_${NSTAG}.OBJ
+		mv $NSPRDIR/nspr.a $NSPRDIR/GCCnspr.a
+		if [ -f $NSPRDIR/SPARCWKnspr.a ] ; then
+			mv $NSPRDIR/SPARCWKnspr.a $NSPRDIR/nspr.a
+		else
+			rm -f $NSPRDIR/*.o
+		fi
+	fi
+	(NS_USE_NATIVE=1; export NS_USE_NATIVE; cd ../batman; gmake MINIRDS_INSTALLDIR="../../httpd/$TARGETUNTAR/plugins" NSAPIDIR="$TARGETUNTAR/nsapi" minirds)
+	if [ $? -ne 0 ]; then
+  		exit 2
+	fi
+	$STRIP $TARGETUNTAR/plugins/autocatalog/bin/*
+	$STRIP $TARGETUNTAR/plugins/autocatalog/*
+	if [ "$UNAME" = "SOLARIS" ] ; then
+		mv $NSPRDIR/nspr.a $NSPRDIR/SPARCWKnspr.a
+		mv $NSPRDIR/GCCnspr.a $NSPRDIR/nspr.a
+	fi
+fi
+
+}
+
+if [ "`echo $* | grep final`" != "" ]; then
+  TYPE=final
+  BOMB=nobomb
+
+elif [ "`echo $* | grep beta`" != "" ]; then
+  TYPE=beta
+  BOMB=bomb
+
+else
+  echo "You must choose to build either a beta or final version."
+  exit 2
+fi
+
+
+if [ "$NOJAVA" = "" -a "`echo $* | grep java`" != "" ]; then
+  NOJAVA=false
+else
+  NOJAVA=true
+fi
+
+if [ "$DO_AUTOCATALOG" = "" -a "`echo $* | grep autocatalog`" != "" ]; then
+  DO_AUTOCATALOG=yes
+else
+  DO_AUTOCATALOG=no
+fi
+# need to export DO_AUTOCATALOG so that it's passed down through all gmakes
+export DO_AUTOCATALOG
+
+if [ "$DO_LIVEWIRE" = "" ]; then
+	if [ "`echo $* | grep livewire`" != "" ]; then
+	  DO_LIVEWIRE=yes
+	else
+	  DO_LIVEWIRE=no
+	fi
+fi
+export DO_LIVEWIRE
+
+OPTIMIZE=optimize
+NSTAG=OPT
+STRIP=strip
+if [ "`echo $* | grep debug`" != "" ]; then
+  OPTIMIZE=debug
+  NSTAG=DBG
+  STRIP=echo
+fi
+
+NSDISTDIR=../../dist/${NSUNAME}_${NSTAG}.OBJ
+
+if [ "`echo $* | grep personal`" != "" ]; then
+  PRODUCT=personal
+elif [ "`echo $* | grep ns_catalog`" != "" ]; then
+  PRODUCT=catalog
+elif [ "`echo $* | grep ns_rds`" != "" ]; then
+  PRODUCT=rds
+elif [ "`echo $* | grep cms`" != "" ]; then
+  PRODUCT=cms
+else
+  PRODUCT=enterprise
+fi
+
+
+if [ "`echo $* | grep unsecure`" != "" -o "`echo $* | grep all`" != "" ]; then
+  SECTYPE=none
+  SECCONFIG=unsecure
+  buildit
+fi
+
+if [ "`echo $* | grep export`" != "" -o "`echo $* | grep all`" != "" ]; then
+  SECTYPE=export
+  SECCONFIG=export
+  buildit
+fi
+
+if [ "`echo $* | grep domestic`" != "" -o "`echo $* | grep all`" != "" ]; then
+  SECTYPE=domestic
+  SECCONFIG=domestic
+  buildit
+fi

+ 229 - 0
httpd/src/Makefile

@@ -0,0 +1,229 @@
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright 2001 Sun Microsystems, Inc.
+# Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+# Makefile.cpp for the Netsite Commerce and Communications servers.
+
+MCOM_ROOT = ../../..
+
+MODULE=httpdBinary
+
+ifneq ($(ARCH), WINNT)
+OLD_MCOM_ROOT := $(MCOM_ROOT)
+MCOM_ROOT := $(shell cd $(OLD_MCOM_ROOT); pwd)
+BUILDSO=mocha admin
+endif
+
+HTTPD_DIR=$(OBJDIR)
+OBJDEST=$(HTTPD_DIR)/obj
+
+include ../../nsconfig.mk
+
+MCC_INCLUDE += $(ADMINUTIL_INCLUDE)
+
+ifeq ($(ARCH), WINNT)
+BINS=$(HTTPD_DIR)/httpd.exe
+DLLS=$(HTTPD_DIR)/$(HTTPDLL_NAME).dll
+HTTPD_LIB=$(HTTPD_DIR)/$(HTTPDLL_NAME).lib
+NSAPI20=$(HTTPD_DIR)/ns-httpd20.dll
+LOCAL_LINK_EXE = link -OUT:"$@" /STACK:0x20000,0x2000 /MAP  $(ARCH_LINK_DEBUG) $(LCFLAGS) /NOLOGO /PDB:NONE /INCREMENTAL:NO \
+                  /SUBSYSTEM:windows $(EXTRA_LIBS)
+EXTRA_LIBS+=$(NSPRLINK)
+
+ifeq ($(BSCINFO), yes)
+BSCS=$(HTTPD_DIR)/httpd.bsc
+endif
+
+else
+BINS=$(HTTPD_DIR)/ns-httpd
+endif
+
+ifeq ($(ARCH), SCO)
+EXTRA_OPTS := -Wl,-Bexport
+endif
+
+ifeq ($(ARCH), UNIXWARE)
+EXTRA_OPTS := -W l,-Bexport
+endif
+
+ifeq ($(ARCH), NCR)
+EXTRA_OPTS := -Wl,-Bexport
+endif
+
+ifeq ($(ARCH), SUNOS4)
+EXTRA_LIBS=-nostdlib /usr/lib/libc.a
+endif
+
+ifeq ($(ARCH), AIX)
+EXTRA_OPTS = -blibpath:../../bin/https:$(DEF_LIBPATH)
+endif
+
+ifeq ($(ARCH), SOLARIS)
+EXTRA_LIBS=$(GCCLIBS)
+endif
+
+ifeq ($(ARCH), WINNT)
+OS_TARGETS= admin libhttpdaemon $(DLLS)
+endif
+
+all: $(OBJDEST) $(OS_TARGETS) $(BINS) $(BSCS)
+
+include unixso.mk
+
+ifeq ($(ARCH), HPUX)
+comma:=,
+#EXTRA_LIBS +=/opt/CC/lib/cxxshl.o
+EXTRA_LIBS += $(NSCP_DISTDIR)/lib/libprstrms.$(LIB_SUFFIX)
+EXTRA_LIBS := $(subst -E,-E$(comma)+s,$(EXTRA_LIBS))
+EXTRA_OPTS := -Wl,+s,-E
+#The extra library below is required to debug shared libraries.
+ifeq ($(BUILD_DEBUG), full)
+EXTRA_LIBS += /opt/langtools/lib/end.o
+endif
+# THIS IS A TEMPORARY SOLUTION TO THE HPUX COMPILER LIMITATION.  WE
+# NEED TO INCLUDE ALL OF THE eh/LIBC object files into our main executable
+# to avoid having undefined symbols with plugins.
+LIBCARCHIVE = /opt/CC/lib/eh/libC.a
+endif
+
+$(OBJDEST):
+	mkdir -p $(OBJDEST)
+
+HTTPD_LIBS=$(FRAME) $(HTTPDAEMON)
+
+ifeq ($(ARCH), WINNT)
+ifeq ($(NO_MOCHA), 1)
+MOCHA =
+MCC_SERVER += -DNO_MOCHA
+else
+MOCHA=$(NSCP_DISTDIR)/lib/mocha.lib
+endif
+OSOBJS = ntmagnus.o ntnsapi.o
+HTTPD_LIBS += $(SAFS) $(LIBCRYPT)
+FVERSION_FLAGS+=-s$(BUILD_SECURITY)
+else
+OSOBJS = main.o
+endif
+
+ifneq ($(ARCH), WINNT)
+OBJS=$(addprefix $(OBJDEST)/, $(OSOBJS) index.o shtml.o upload.o \
+                              cookie.o nsconfig.o)
+else
+EXEOBJS=$(addprefix $(OBJDEST)/, password.res ntmain.o)
+OBJS=$(addprefix $(OBJDEST)/, $(OSOBJS) index.o shtml.o upload.o \
+                               cookie.o nsconfig.o)
+endif
+
+MODULE_CFLAGS=
+
+# Unixware linker braindamage.  The libnspr.so won't override select
+# at link time
+ifeq ($(ARCH), UNIXWARE)
+OBJS+=$(HTTPD_DIR)/obj/uxwrap.o
+endif
+
+ifeq ($(ARCH), NCR)
+#OBJS+=$(HTTPD_DIR)/httpd-lib/nspr20/uxwrap.o
+endif
+
+ifdef PRODUCT_IS_DIRECTORY_SERVER
+# Primitive NT link process for nshttpd.dll requires httpdaemon
+  ifeq ($(ARCH), WINNT)
+    DAEMONLIB=$(OBJDIR)/lib/libhttpdaemon
+  else
+    DAEMONLIB=
+  endif
+else
+  DAEMONLIB=$(OBJDIR)/lib/libhttpdaemon
+endif
+
+ifeq ($(ARCH), WINNT)
+# Don't define DEPLIBS for NT because standard macros like LINK_EXE
+# and LINK_DLL automatically pick up DEPLIBS which we don't always wan't.
+#                    $(LIBDIRMON) (temporily removed)
+DEPLIBS = $(addsuffix .$(LIB_SUFFIX), $(addprefix $(OBJDIR)/lib/lib, $(LIBADMIN) $(LIBLDAPU) $(LIBACCESS) $(HTTPD_LIBS))) \
+ $(addsuffix .$(LIB_SUFFIX), $(OBJDIR)/lib/libmsgdisp)
+DEPLIBS += $(LIBSECURITY) \
+           $(LIBNSPR) \
+           $(LIBLDAP) \
+           $(LIBDBM) \
+		   $(ADMINUTIL_DEP)
+
+DEPLINK = /LIBPATH:$(OBJDIR)/lib $(addsuffix .$(LIB_SUFFIX), $(addprefix lib, $(LIBADMIN) $(LIBLDAPU) $(LIBACCESS) $(HTTPD_LIBS))) \
+	libmsgdisp.$(LIB_SUFFIX) $(ADMINUTIL_LINK) $(LDAPLINK) $(SECURITYLINK) \
+	$(NSPRLINK) $(DBMLINK)
+else
+# unixso.mk may define DEPLIBS
+ifndef DEPLIBS
+DEPLIBS = $(addsuffix .$(LIB_SUFFIX), \
+                    $(addprefix $(OBJDIR)/lib/lib,$(HTTPD_LIBS)) \
+                    $(DAEMONLIB) \
+                    $(OBJDIR)/lib/libaccess \
+                    $(OBJDIR)/lib/libbase \
+                    $(OBJDIR)/lib/libsi18n \
+                    $(OBJDIR)/lib/libmsgdisp) \
+                    $(LIBSSLIO)
+DEPLIBS += $(SECURITY_DEP) \
+           $(NSPR_DEP) \
+		   $(ADMINUTIL_DEP)
+
+DEPLINK = $(addsuffix .$(LIB_SUFFIX), \
+                    $(addprefix $(OBJDIR)/lib/lib,$(HTTPD_LIBS)) \
+                    $(DAEMONLIB) \
+                    $(OBJDIR)/lib/libaccess \
+                    $(OBJDIR)/lib/libbase \
+                    $(OBJDIR)/lib/libsi18n \
+                    $(OBJDIR)/lib/libmsgdisp) \
+                    $(SECURITYLINK) \
+                    $(NSPRLINK) \
+                    $(LIBSSLIO) \
+					$(ADMINUTILLINK)
+endif
+
+endif
+
+ifndef PRODUCT_IS_DIRECTORY_SERVER
+ifeq ($(ARCH), AIX)
+ifdef OLD_AIX_LINKING
+# why is this redefined here?
+CCC = svxlC_r
+endif
+endif
+endif
+ifneq ($(ARCH), WINNT)
+$(BINS): $(DEPLIBS) $(OBJS)
+ifndef PRODUCT_IS_DIRECTORY_SERVER
+	echo "why are we doing this for directory server?"
+	cd $(HTTPD_DIR); $(PURIFY) $(CCC) -o ns-httpd $(OBJS) \
+            $(EXTRA_OPTS) $(DEPLINK) $(EXTRA_LIBS)
+endif # Netscape Directory Server
+else # WINNT
+
+$(MOCHA):
+	cd $(MCOM_ROOT)/mocha; $(MAKE) export $(NSDEFS)
+
+$(DLLS): $(OBJS) $(DEPLIBS) $(OBJDEST)/ns-httpd.res
+	-@echo EXTRA_LIBS = $(EXTRA_LIBS)
+	$(PURIFY) $(LINK_DLL) $(DEPLINK) $(OBJDEST)/ns-httpd.res $(OBJS) $(EXTRA_LIBS)
+	cp $(HTTPD_LIB) $(NSCP_DISTDIR)/lib
+	echo $(DLLS) finished
+
+$(BINS): $(OBJS) $(EXEOBJS) $(HTTPD_LIB)
+	rm -f $@
+	$(PURIFY) $(LOCAL_LINK_EXE) $(EXEOBJS) $(HTTPD_LIB)
+	echo $(BINS) finished
+
+$(NSAPI20): $(HTTPD_LIB) $(OBJDIR)/lib/frame/nsapi20.o
+	$(PURIFY) $(LINK_DLL) $(LIBNSPR) $(HTTPD_LIB) $(OBJDIR)/lib/frame/nsapi20.o $(EXTRA_LIBS)
+
+ifeq ($(BSCINFO), yes)
+$(BSCS): $(OBJS)
+	$(BSCMAKE) $(OBJDEST)/*.sbr
+endif
+endif
+
+
+include $(INCLUDE_DEPENDS)

+ 383 - 0
httpd/src/ntnsapi.c

@@ -0,0 +1,383 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+/*
+ * Aruna Victor	
+ * NT NSAPI works differently from UNIX. The DLL doesn't know the addresses
+ * of the functions in the server process and needs to be told them.
+ */
+
+#include <nt/nsapi.h>
+extern int upload_file(pblock *pb, Session *sn, Request *rq);
+
+#ifdef BUILD_DLL
+
+#include <libadmin/libadmin.h>
+#include <libadmin/dstats.h>
+#include <libaccess/nsadb.h>
+#include <libadminutil/admutil.h>
+#include <libadminutil/distadm.h>
+#if 0
+#ifndef NO_MOCHA
+#include <mocha/mo_atom.h>
+#include <mocha/mo_scope.h>
+#include <mocha/mochaapi.h>
+#endif /* NO_MOCHA */
+#endif
+#include <base/fsmutex.h>
+
+extern char *system_winerr(void);                                               
+extern char *system_winsockerr(void);                                           
+
+VOID NsapiDummy()
+{	
+	int i = 0;
+	SafTable = (SafFunction **)MALLOC(400 * sizeof(VOID*));
+
+    /* Force references to libadmin */
+
+	/* Functions from libadmin:keyconf.c */
+	SafTable[i++] = (SafFunction *)get_alias_dir;
+	/* Functions from libadmin:objconf.c */
+	SafTable[i++] = (SafFunction *)get_mag_init;
+	/* Functions from libadmin:form_post.c */
+	SafTable[i++] = (SafFunction *)post_begin;
+	/* Functions from libadmin:form_get.c */
+	SafTable[i++] = (SafFunction *)open_html_file;
+	/* Functions from libadmin:userdb.c */
+#if 0
+	SafTable[i++] = (SafFunction *)detect_db_type;
+#endif
+	/* Functions from libadmin:authdb.c */
+	SafTable[i++] = (SafFunction *)list_auth_dbs;
+	/* Functions from libadmin:error.c */
+	SafTable[i++] = (SafFunction *)report_error;
+	/* Functions from libadmin:template.c */
+	SafTable[i++] = (SafFunction *)directive_is;
+	/* Functions from libaccess:pcontrol.c */
+	SafTable[i++] = (SafFunction *)restart_http;
+	/* Functions from libadmin:admserv.c */
+	SafTable[i++] = (SafFunction *)read_server_lst;
+	/* Functions from libadmin:multconf.c */
+	SafTable[i++] = (SafFunction *)make_conflist;
+	/* Functions from libadmin:password */
+	SafTable[i++] = (SafFunction *)pw_enc;
+	/* Functions from libadmin:cron_conf.c */
+#if 0
+	SafTable[i++] = (SafFunction *)cron_conf_create_obj;
+#endif
+	/* Functions from libadmin:dstats.c */
+	SafTable[i++] = (SafFunction *)dstats_open;
+	/* Functions from libadmin:distadm.c */
+	SafTable[i++] = (SafFunction *)ADM_InitializePermissions;
+
+#ifndef NO_MOCHA
+    /* Force references to mocha */
+	/* Functions from mocha:mo_atom.c */
+	SafTable[i++] = (SafFunction *)mocha_Atomize;
+	/* Functions from mocha:mo_fun.c */
+	/* SafTable[i++] = (SafFunction *)mocha_NewFunctionObject; */
+	/* Functions from mocha:mo_scope.c */
+	SafTable[i++] = (SafFunction *)mocha_DefineSymbol;
+	/* Functions from mocha:mochaapi.c */
+	SafTable[i++] = (SafFunction *)MOCHA_CanConvertDatum;
+#endif /* NO_MOCHA */
+	
+    /* Force references to base */
+    SafTable[i++] = (SafFunction *)fsmutex_init;
+
+	/* Force references to libmsgdisp */
+	SafTable[i++] = (SafFunction *)NSORB_Init;
+	SafTable[i++] = (SafFunction *)ConsumerCreatePush;
+	SafTable[i++] = (SafFunction *)CMNewBTree;
+	SafTable[i++] = (SafFunction *)NSObjArrayNew;
+}
+#endif /* BUILD_DLL */
+
+VOID InitializeSafFunctions() 
+{
+
+	SafTable = (SafFunction **)MALLOC(400 * sizeof(VOID *));
+
+/* Functions from buffer.c */
+	
+	SafTable[FILEBUF_OPEN] = (SafFunction *)filebuf_open;
+	SafTable[NETBUF_OPEN] = (SafFunction *)netbuf_open;
+	SafTable[FILEBUF_OPEN_NOSTAT] = (SafFunction *)filebuf_open_nostat;
+	SafTable[PIPEBUF_OPEN] = (SafFunction *)pipebuf_open;
+	SafTable[PIPEBUF_CLOSE] = (SafFunction *)pipebuf_close;
+	SafTable[FILEBUF_OPEN_NOSTAT] = (SafFunction *)filebuf_open_nostat;
+	SafTable[NETBUF_NEXT] = (SafFunction *)netbuf_next;
+	SafTable[PIPEBUF_NEXT] = (SafFunction *)pipebuf_next;
+	SafTable[FILEBUF_CLOSE] = (SafFunction *)filebuf_close;
+	SafTable[NETBUF_CLOSE] = (SafFunction *)netbuf_close;
+	SafTable[FILEBUF_GRAB] = (SafFunction *)filebuf_grab;
+	SafTable[NETBUF_GRAB] = (SafFunction *)netbuf_grab;
+	SafTable[PIPEBUF_GRAB] = (SafFunction *)pipebuf_grab;
+	SafTable[NETBUF_BUF2SD] = (SafFunction *)netbuf_buf2sd;
+	SafTable[FILEBUF_BUF2SD] = (SafFunction *)filebuf_buf2sd;
+	SafTable[PIPEBUF_BUF2SD] = (SafFunction *)pipebuf_buf2sd;
+	SafTable[PIPEBUF_NETBUF2SD] = (SafFunction *)pipebuf_netbuf2sd;
+
+/* Functions from daemon.h */
+	SafTable[NTDAEMON_RUN] = (SafFunction *)daemon_run;
+	SafTable[CHILD_STATUS] = (SafFunction *)child_status;
+
+/* Functions from file.h */
+	SafTable[SYSTEM_STAT] = (SafFunction *)system_stat;
+	SafTable[SYSTEM_FOPENRO] = (SafFunction *)system_fopenRO;
+	SafTable[SYSTEM_FOPENWA] = (SafFunction *)system_fopenWA;
+	SafTable[SYSTEM_FOPENRW] = (SafFunction *)system_fopenRW;
+	SafTable[SYSTEM_NOCOREDUMPS] = (SafFunction *)system_nocoredumps;
+	SafTable[SYSTEM_FWRITE] = (SafFunction *)system_fwrite;
+	SafTable[SYSTEM_FWRITE_ATOMIC] = (SafFunction *)system_fwrite_atomic;
+	SafTable[SYSTEM_WINERR] = (SafFunction *)system_winerr;
+	SafTable[SYSTEM_WINSOCKERR] = (SafFunction *)system_winsockerr;
+
+	SafTable[FILE_NOTFOUND] = (SafFunction *)file_notfound;
+    /* Removed from main code- 9-2-96
+     *
+	SafTable[SYSTEM_INITLOCK] = (SafFunction *)system_initlock;*/
+	SafTable[FILE_UNIX2LOCAL] = (SafFunction *)file_unix2local;
+	SafTable[DIR_OPEN] = (SafFunction *)dir_open;
+	SafTable[DIR_READ] = (SafFunction *)dir_read;
+	SafTable[DIR_CLOSE] = (SafFunction *)dir_close;
+
+/* Functions from cinfo.h */
+	SafTable[CINFO_INIT] = (SafFunction *)cinfo_init;
+	SafTable[CINFO_TERMINATE] = (SafFunction *)cinfo_terminate;
+	SafTable[CINFO_MERGE] = (SafFunction *)cinfo_merge;
+	SafTable[CINFO_FIND] = (SafFunction *)cinfo_find;
+	SafTable[CINFO_LOOKUP] = (SafFunction *)cinfo_lookup;
+	SafTable[CINFO_DUMP_DATABASE] = (SafFunction *)cinfo_dump_database;
+
+/* Functions from ereport.h */
+	SafTable[EREPORT] = (SafFunction *)ereport ;
+	SafTable[EREPORT_INIT] = (SafFunction *)ereport_init;
+	SafTable[EREPORT_TERMINATE] = (SafFunction *)ereport_terminate;
+	SafTable[EREPORT_GETFD] = (SafFunction *)ereport_getfd;
+
+#ifdef NET_SSL
+/* Functions from minissl.h */
+	SafTable[SSL_CLOSE] = (SafFunction *)PR_Close;
+	SafTable[SSL_SOCKET] = (SafFunction *)PR_NewTCPSocket;
+	SafTable[SSL_GET_SOCKOPT] = (SafFunction *)PR_GetSocketOption;
+	SafTable[SSL_SET_SOCKOPT] = (SafFunction *)PR_SetSocketOption;
+	SafTable[SSL_BIND] = (SafFunction *)PR_Bind;
+	SafTable[SSL_LISTEN] = (SafFunction *)PR_Listen;
+	SafTable[SSL_ACCEPT] = (SafFunction *)PR_Accept;
+	SafTable[SSL_READ] = (SafFunction *)PR_Read;
+	SafTable[SSL_WRITE] = (SafFunction *)PR_Write;
+	SafTable[SSL_GETPEERNAME] = (SafFunction *)PR_GetPeerName;
+#endif /* NET_SSL */
+
+
+/* Functions from net.h */
+
+	SafTable[NET_BIND] = (SafFunction *)net_bind;
+	SafTable[NET_READ] = (SafFunction *)net_read;
+	SafTable[NET_WRITE] = (SafFunction *)net_write;
+	/* SafTable[NET_FIND_FQDN] = (SafFunction *)net_find_fqdn; */
+	SafTable[NET_IP2HOST] = (SafFunction *)net_ip2host;
+
+/* Functions from pblock.h */
+	SafTable[PARAM_CREATE] = (SafFunction *)param_create;
+	SafTable[PARAM_FREE] = (SafFunction *)param_free;
+	SafTable[PBLOCK_CREATE] = (SafFunction *)pblock_create;
+	SafTable[PBLOCK_FREE] = (SafFunction *)pblock_free;
+	SafTable[PBLOCK_FINDVAL] = (SafFunction *)pblock_findval;
+	SafTable[PBLOCK_NVINSERT] = (SafFunction *)pblock_nvinsert;
+	SafTable[PBLOCK_NNINSERT] = (SafFunction *)pblock_nninsert;
+	SafTable[PBLOCK_PINSERT] = (SafFunction *)pblock_pinsert;
+	SafTable[PBLOCK_STR2PBLOCK] = (SafFunction *)pblock_str2pblock;
+	SafTable[PBLOCK_PBLOCK2STR] = (SafFunction *)pblock_pblock2str;
+	SafTable[PBLOCK_COPY] = (SafFunction *)pblock_copy;
+	SafTable[PBLOCK_PB2ENV] = (SafFunction *)pblock_pb2env;
+	SafTable[PBLOCK_FR] = (SafFunction *)pblock_fr;
+
+/* Functions from sem.h */
+	SafTable[SEM_INIT] = (SafFunction *)sem_init;
+	SafTable[SEM_TERMINATE] = (SafFunction *)sem_terminate;
+	SafTable[SEM_GRAB] = (SafFunction *)sem_grab;
+	SafTable[SEM_TGRAB] = (SafFunction *)sem_grab;
+	SafTable[SEM_RELEASE] = (SafFunction *)sem_release;
+
+/* Functions from session.h */
+	SafTable[SESSION_CREATE] = (SafFunction *)session_create;
+	SafTable[SESSION_FREE] = (SafFunction *)session_free;
+	SafTable[SESSION_DNS_LOOKUP] = (SafFunction *)session_dns_lookup;
+
+/* Functions from shexp.h */
+	SafTable[SHEXP_VALID] = (SafFunction *)shexp_valid;
+	SafTable[SHEXP_MATCH] = (SafFunction *)shexp_match;
+	SafTable[SHEXP_CMP] = (SafFunction *)shexp_cmp;
+	SafTable[SHEXP_CASECMP] = (SafFunction *)shexp_casecmp;
+
+/* Functions from systhr.h */
+	SafTable[SYSTHREAD_START] = (SafFunction *)systhread_start;
+	SafTable[SYSTHREAD_ATTACH] = (SafFunction *)systhread_attach;
+	SafTable[SYSTHREAD_TERMINATE] = (SafFunction *)systhread_terminate;
+	SafTable[SYSTHREAD_SLEEP] = (SafFunction *)systhread_sleep;
+	SafTable[SYSTHREAD_INIT] = (SafFunction *)systhread_init;
+	SafTable[SYSTHREAD_NEWKEY] = (SafFunction *)systhread_newkey;
+	SafTable[SYSTHREAD_GETDATA] = (SafFunction *)systhread_getdata;
+	SafTable[SYSTHREAD_SETDATA] = (SafFunction *)systhread_setdata;
+
+/* Functions from shmem.h */
+	SafTable[SHMEM_ALLOC] = (SafFunction *)shmem_alloc;
+	SafTable[SHMEM_FREE] = (SafFunction *)shmem_free;
+
+/* Functions from systems.h */
+	SafTable[UTIL_STRCASECMP] = (SafFunction *)util_strcasecmp;
+	SafTable[UTIL_STRNCASECMP] = (SafFunction *)util_strncasecmp;
+
+/* Functions from util.h */
+	SafTable[UTIL_GETLINE] = (SafFunction *)util_getline;
+	SafTable[UTIL_ENV_CREATE] = (SafFunction *)util_env_create;
+	SafTable[UTIL_ENV_STR] = (SafFunction *)util_env_str;
+#if 0
+	/* Removed from ntcgi.c --- obsolete; MB 1-26-96 */
+	SafTable[NTUTIL_ENV_STR] = (SafFunction *)ntutil_env_str;
+#endif
+	SafTable[UTIL_ENV_REPLACE] = (SafFunction *)util_env_replace;
+	SafTable[UTIL_ENV_FREE] = (SafFunction *)util_env_free;
+	SafTable[UTIL_ENV_FIND] = (SafFunction *)util_env_find;
+	SafTable[UTIL_HOSTNAME] = (SafFunction *)util_hostname;
+	SafTable[UTIL_CHDIR2PATH] = (SafFunction *)util_chdir2path;
+	SafTable[UTIL_IS_MOZILLA] = (SafFunction *)util_is_mozilla;
+	SafTable[UTIL_IS_URL] = (SafFunction *)util_is_url;
+	SafTable[UTIL_LATER_THAN] = (SafFunction *)util_later_than;
+	SafTable[UTIL_URI_IS_EVIL] = (SafFunction *)util_uri_is_evil;
+	SafTable[UTIL_URI_PARSE] = (SafFunction *)util_uri_parse;
+	SafTable[UTIL_URI_UNESCAPE] = (SafFunction *)util_uri_unescape;
+	SafTable[UTIL_URI_ESCAPE] = (SafFunction *)util_uri_escape;
+	SafTable[UTIL_URL_ESCAPE] = (SafFunction *)util_url_escape;
+	SafTable[UTIL_SH_ESCAPE] = (SafFunction *)util_sh_escape;
+	SafTable[UTIL_ITOA] = (SafFunction *)util_itoa;
+	SafTable[UTIL_VSPRINTF] = (SafFunction *)util_vsprintf;
+	SafTable[UTIL_SPRINTF] = (SafFunction *)util_sprintf;
+	SafTable[UTIL_VSNPRINTF] = (SafFunction *)util_vsnprintf;
+	SafTable[UTIL_SNPRINTF] = (SafFunction *)util_snprintf;
+
+//	SafTable[INITIALIZE_ADMIN_LOGGING] = (SafFunction *)InitializeAdminLogging;
+//	SafTable[INITIALIZE_HTTPD_LOGGING] = (SafFunction *)InitializeHttpdLogging;
+//	SafTable[TERMINATE_ADMIN_LOGGING] = (SafFunction *)TerminateAdminLogging;
+//	SafTable[TERMINATE_HTTPD_LOGGING] = (SafFunction *)TerminateHttpdLogging;
+
+	SafTable[LOG_ERROR_EVENT] = (SafFunction *)LogErrorEvent;
+
+/* Functions from conf.h */
+	SafTable[CONF_INIT] = (SafFunction *)conf_init;
+	SafTable[CONF_TERMINATE] = (SafFunction *)conf_terminate;
+	SafTable[CONF_GETGLOBALS] = (SafFunction *)conf_getglobals;
+	SafTable[CONF_VARS2DAEMON] = (SafFunction *)conf_vars2daemon;
+
+	SafTable[FUNC_INIT]	= (SafFunction *)func_init;
+	SafTable[FUNC_FIND]	= (SafFunction *)func_find;
+	SafTable[FUNC_EXEC]	= (SafFunction *)func_exec;
+	SafTable[FUNC_INSERT] = (SafFunction *)func_insert;
+	SafTable[HTTP_SCAN_HEADERS]	= (SafFunction *)http_scan_headers;
+	SafTable[HTTP_START_RESPONSE] = (SafFunction *)http_start_response;
+	SafTable[HTTP_HDRS2_ENV] = (SafFunction *)http_hdrs2env;
+	SafTable[HTTP_STATUS] = (SafFunction *)http_status;
+	SafTable[HTTP_SET_FINFO] = (SafFunction *)http_set_finfo;
+	SafTable[HTTP_DUMP822] = (SafFunction *)http_dump822;
+	SafTable[HTTP_FINISH_REQUEST] = (SafFunction *)http_finish_request;
+	SafTable[HTTP_HANDLE_SESSION] = (SafFunction *)http_handle_session;
+	SafTable[HTTP_URI2URL] = (SafFunction *)http_uri2url;
+
+/* Functions from log.h */
+	SafTable[LOG_ERROR] = (SafFunction *)log_error;
+	SafTable[DIRECTIVE_NAME2NUM] = (SafFunction *)directive_name2num;
+	SafTable[DIRECTIVE_NUM2NAME] = (SafFunction *)directive_num2name;
+	SafTable[OBJECT_CREATE] = (SafFunction *)object_create;
+	SafTable[OBJECT_FREE] = (SafFunction *)object_free;
+	SafTable[OBJECT_ADD_DIRECTIVE] = (SafFunction *)object_add_directive;
+	SafTable[OBJECT_EXECUTE] = (SafFunction *)object_execute;
+	SafTable[OBJSET_SCAN_BUFFER] = (SafFunction *)objset_scan_buffer;
+	SafTable[OBJSET_FREE] = (SafFunction *)objset_free;
+	SafTable[OBJSET_FREE_SETONLY] = (SafFunction *)objset_free_setonly;
+	SafTable[OBJSET_NEW_OBJECT] = (SafFunction *)objset_new_object;
+	SafTable[OBJSET_ADD_OBJECT] = (SafFunction *)objset_add_object;
+	SafTable[OBJSET_FINDBYNAME] = (SafFunction *)objset_findbyname;
+	SafTable[OBJSET_FINDBYPPATH] = (SafFunction *)objset_findbyppath;
+
+	SafTable[REQUEST_CREATE] = (SafFunction *)request_create;
+	SafTable[REQUEST_FREE] = (SafFunction *)request_free;
+	SafTable[REQUEST_RESTART_INTERNAL] = (SafFunction *)request_restart_internal;
+	SafTable[REQUEST_TRANSLATE_URI] = (SafFunction *)request_translate_uri;
+	SafTable[REQUEST_HEADER] = (SafFunction *)request_header;
+	SafTable[REQUEST_STAT_PATH] = (SafFunction *)request_stat_path;
+
+	/* temporarily remove definitions till they are added into the header file. */
+	SafTable[REQUEST_HANDLE_PROCESSED] = (SafFunction *)request_handle_processed;
+	
+	SafTable[MAGNUS_ATRESTART] = (SafFunction *)magnus_atrestart;
+
+        SafTable[SYSTEM_FOPENWT] = (SafFunction *)system_fopenWT;
+        SafTable[SYSTEM_MALLOC] = (SafFunction *)system_malloc;
+        SafTable[SYSTEM_FREE] = (SafFunction *)system_free;
+        SafTable[SYSTEM_REALLOC] = (SafFunction *)system_realloc;
+        SafTable[SYSTEM_STRDUP] = (SafFunction *)system_strdup;
+
+    SafTable[UPLOAD_FILE] = (SafFunction *)upload_file;
+
+        SafTable[CRIT_INIT] = (SafFunction *)crit_init;
+        SafTable[CRIT_ENTER] = (SafFunction *)crit_enter;
+        SafTable[CRIT_EXIT] = (SafFunction *)crit_exit;
+        SafTable[CRIT_TERMINATE] = (SafFunction *)crit_terminate;
+        SafTable[SYSTHREAD_CURRENT] = (SafFunction *)systhread_current;
+
+        SafTable[NET_ACCEPT] = (SafFunction *)net_accept;
+        SafTable[NET_CLOSE] = (SafFunction *)net_close;
+        SafTable[NET_CONNECT] = (SafFunction *)net_connect;
+        SafTable[NET_IOCTL] = (SafFunction *)net_ioctl;
+        SafTable[NET_LISTEN] = (SafFunction *)net_listen;
+        SafTable[NET_SETSOCKOPT] = (SafFunction *)net_setsockopt;
+        SafTable[NET_SOCKET] = (SafFunction *)net_socket;
+
+
+	/* msgdisp functions */
+   SafTable[NSORB_INIT] = (SafFunction *)NSORB_Init;
+   SafTable[NSORB_INST_ID] = (SafFunction *)NSORB_InstanceID;
+   SafTable[NSORB_GET_INST] = (SafFunction *)NSORB_GetInstance;
+   SafTable[NSORB_REG_INT] = (SafFunction *)NSORB_RegisterInterface;
+   SafTable[NSORB_FIND_OBJ] = (SafFunction *)NSORB_FindObject;
+   SafTable[NSORB_GET_INTERFACE] = (SafFunction *)NSORB_GetInterface;
+
+   SafTable[ARR_NEW] = (SafFunction *)NSObjArrayNew;
+   SafTable[ARR_FREE] = (SafFunction *)NSObjArrayFree;
+   SafTable[ARR_GET_OBJ] = (SafFunction *)NSObjArrayGetObj;
+   SafTable[ARR_GET_LAST_OBJ] = (SafFunction *)NSObjArrayGetLastObj;
+   SafTable[ARR_NEW_OBJ] = (SafFunction *)NSObjArrayNewObj;
+   SafTable[ARR_GET_NUM_OBJ] = (SafFunction *)NSObjArrayGetNumObj;
+   SafTable[ARR_RESET] = (SafFunction *)NSObjArrayReset;
+   SafTable[ARR_REMOVEOBJ] = (SafFunction *)NSObjArrayRemoveObj;
+   SafTable[ARR_GET_OBJ_NUM] = (SafFunction *)NSObjArrayGetObjNum;
+
+   SafTable[CM_BT_NEW] = (SafFunction *)CMNewBTree;
+   SafTable[CM_BT_ADD_NODE] = (SafFunction *)CMBTreeAddNode;
+   SafTable[CM_BT_FIND_NODE] = (SafFunction *)CMBTreeFindNode;
+   SafTable[CM_BT_DEL_NODE] = (SafFunction *)CMBTreeDeleteNode;
+   SafTable[CM_BT_DESTROY] = (SafFunction *)CMBTreeDestroy;
+   SafTable[CM_BT_GET_NUM] = (SafFunction *)CMBTreeGetNumNode;
+   SafTable[CM_BT_TRAVEL] = (SafFunction *)CMBTreeInorderTravel;
+
+   SafTable[CM_STR_NEW] = (SafFunction *)NewCMStrObj;
+   SafTable[CM_STR_ADD] = (SafFunction *)CMStrObjAdd;
+   SafTable[CM_STR_REL] = (SafFunction *)CMStrObjRelease;
+   SafTable[CM_STR_FREE] = (SafFunction *)CMStrObjFree;
+   SafTable[CM_STR_GET] = (SafFunction *)CMStrObjGetString;
+   SafTable[CM_STR_SIZE] = (SafFunction *)CMStrObjGetSize;
+   SafTable[CM_COPY_STR] = (SafFunction *)CMCopyString;
+   SafTable[CM_MAKE_UID] = (SafFunction *)MakeUID;
+
+   SafTable[MS_NEW] = (SafFunction *)ConsumerNewPush;
+   SafTable[MS_CREATE] = (SafFunction *)ConsumerCreatePush;
+
+
+
+}
+

+ 38 - 0
httpd/src/unixso.exp

@@ -0,0 +1,38 @@
+acl_write_rights
+acl_read_rights
+SEC_ERROR_INVALID_AVA
+SEC_ERROR_INPUT_LEN
+SEC_ERROR_BAD_KEY
+SEC_ERROR_EXPIRED_CERTIFICATE
+SSL_ERROR_BAD_CERT_DOMAIN
+SEC_ERROR_UNTRUSTED_CERT
+SEC_ERROR_UNKNOWN_ISSUER
+SEC_ERROR_BAD_SIGNATURE
+SEC_ERROR_IO
+SEC_ERROR_INVALID_TIME
+XP_ERRNO_EWOULDBLOCK
+XP_ERRNO_EAGAIN
+pr_fdTable
+XP_ERRNO_EIO
+XP_ERRNO_EISCONN
+XP_ERRNO_EINVAL
+XP_ERRNO_EBADF
+XP_ERRNO_ECONNREFUSED
+SSL_ERROR_US_ONLY_SERVER
+SSL_ERROR_EXPORT_ONLY_SERVER
+SSL_ERROR_BAD_CERTIFICATE
+SSL_ERROR_UNSUPPORTED_CERTIFICATE_TYPE
+SSL_ERROR_NO_CERTIFICATE
+SSL_ERROR_UNSUPPORTED_VERSION
+SSL_ERROR_NO_CYPHER_OVERLAP
+SSL_ERROR_BAD_SERVER
+SSL_ERROR_BAD_CLIENT
+SEC_ERROR_OUTPUT_LEN
+SEC_ERROR_INVALID_ARGS
+SEC_ERROR_BAD_DATA
+SEC_ERROR_NO_MEMORY
+SEC_ERROR_BAD_DATABASE
+SEC_ERROR_BAD_DER
+SEC_ERROR_INVALID_ALGORITHM
+SEC_ERROR_LIBRARY_FAILURE
+SEC_ERROR_BAD_PASSWORD

+ 246 - 0
httpd/src/unixso.mk

@@ -0,0 +1,246 @@
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright 2001 Sun Microsystems, Inc.
+# Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+LIBSECDIR=$(MCOM_ROOT)/lib/libsec/$(NSOBJDIR_NAME)
+
+ifneq ($(ARCH), WINNT)
+
+SRCDIR=$(MCOM_ROOT)/ldapserver/httpd/src
+
+AR = ar
+
+ifeq ($(ARCH), OSF1)
+DLL_LDFLAGS += -soname $(SONAME)
+EXTRA_LIBS += -Wl,-rpath,.:../../lib:../../bin/https:../../plugins/java/bin:../../wai/lib
+ADM_EXTRA = -lcxx -lpthread -lmach -lexc -lc
+AR = rm -f ________64ELEL_ ; ar
+endif
+
+ifeq ($(ARCH), IRIX)
+DLL_LDFLAGS += -soname $(SONAME)
+ifeq ($(USE_N32), 1)
+ DLL_LDFLAGS += -n32 -mips3
+endif
+EXTRA_LIBS += -rpath .:../../lib:../../bin/https:../../plugins/java/bin:../wai/lib
+# IRIX likes it twice!
+SOLINK2=$(SOLINK)
+endif
+
+ifeq ($(ARCH), SOLARIS)
+DLL_LDFLAGS += -h $(SONAME)
+EXTRA_LIBS += -R .:../../lib:../../bin/https:../../plugins/java/bin:../wai/lib
+ADM_EXTRA = $(GCCLIB)
+endif
+
+ifdef USE_LD_RUN_PATH
+EXTRA_LIBS += -L.
+export LD_RUN_PATH=./.:../../lib:../../bin/https:../../plugins/java/bin:../wai/lib
+endif
+
+ifeq ($(ARCH), SONY)
+DLL_LDFLAGS += -soname $(SONAME)
+EXTRA_LIBS += -rpath .
+endif
+
+ifeq ($(ARCH), NEC)
+DLL_LDFLAGS += -h $(SONAME)
+endif
+
+ifeq ($(ARCH), HPUX)
+DLL_LDFLAGS += -L. 
+SOLINK=-L. -l$(HTTPDSO_NAME)$(DLL_PRESUF)
+EXTRA_LIBS += -Wl,+b.:../../lib:../../bin/https:../../plugins/java/bin:../wai/lib
+# The line below is required for LiveWire DB2 to work.
+EXTRA_LIBS += -Wl,-uallow_unaligned_data_access -lhppa
+LD=$(CCC) 
+# Well HPUX's not happy about including libnspr.sl(-lnspr) into our executable,
+# it's that ___ +eh again.  
+NSPRLINK=$(NOTHING)
+#LDAPLINK=-L. $(addsuffix .a, $(addprefix lib, $(LDAP_DOTALIB_NAMES))) \
+#	 $(addprefix -l, $(LDAP_SOLIB_NAMES))
+endif
+
+ifeq ($(ARCH), AIX)
+MKSHLIB_FLAGS += -berok -brtl
+SOLINK=-L. -L../../lib -lns-dshttpd$(DLL_PRESUF)
+LIBSECDIR=$(MCOM_ROOT)/lib/libsec/$(NSOBJDIR_NAME)
+#LDAPLINK=-L. $(addsuffix .a, $(addprefix lib, $(LDAP_DOTALIB_NAMES))) \
+#	 $(addprefix -l, $(LDAP_SOLIB_NAMES))
+#NSPRLINK = -L. -lnspr$(DLL_PRESUF)
+#NSPRLINK = -L. -ldsnspr$(DLL_PRESUF)
+ADM_EXTRA := -L. -L../../lib $(LDAPLINK) $(NSPRLINK) $(EXTRA_LIBS) 
+#ADM_EXTRA := -L. -L../../lib $(LDAPLINK) $(NSPRLINK) $(EXTRA_LIBS) -L$(LIBSECDIR) -lsec-$(WHICHA)
+ifdef FORTEZZA
+ADM_EXTRA += $(NSCP_DISTDIR)/lib/libci.$(LIB_SUFFIX)
+endif
+DEF_LIBPATH := .:../../lib:$(DEF_LIBPATH)
+endif
+
+ifeq ($(ARCH), SUNOS4)
+EXTRA_LIBS += -L.
+ADM_EXTRA = $(EXTRA_LIBS)
+endif
+
+ifeq ($(ARCH), UnixWare)
+DLL_LDFLAGS += -h $(SONAME)
+NSPRLINK = -L. -ldsnspr$(DLL_PRESUF)
+endif
+
+EXTRA_LIBS += $(MATHLIB)
+
+ifndef SONAME
+SONAME=$(HTTPDSO_NAME)$(DLL_PRESUF).$(DLL_SUFFIX)
+endif
+
+ifndef SOLINK
+SOLINK=./$(HTTPDSO_NAME)$(DLL_PRESUF).$(DLL_SUFFIX)
+endif
+
+#ifndef LDAPLINK
+#LDAPLINK=$(LDAPOBJNAME)
+#endif
+
+ifndef NSPRLINK
+NSPRLINK=libnspr$(DLL_PRESUF).$(DLL_SUFFIX)
+endif
+
+# Temporary directory for the libraries and their object files
+$(OBJDIR)/httpd-lib:
+ifeq ($(ARCH), HPUX)
+	mkdir -p $(OBJDIR)/httpd-lib/nspr20
+endif
+	mkdir -p $(OBJDIR)/httpd-lib/sslio
+	mkdir -p $(OBJDIR)/httpd-lib/arlib
+	mkdir -p $(OBJDIR)/httpd-lib/mocha
+	mkdir -p $(OBJDIR)/httpd-lib/libsec
+	mkdir -p $(OBJDIR)/httpd-lib/libdbm
+	mkdir -p $(OBJDIR)/httpd-lib/xp
+
+# Define a LIBSEC which doesn't include libdbm and xp.
+LIBSECNAME=$(MCOM_LIBDIR)/libsec/$(NSOBJDIR_NAME)/libsec-$(WHICHA).$(LIB_SUFFIX)
+ifndef LIBSECOBJS
+LIBSEC1=$(LIBSECNAME)
+else
+LIBSEC1=$(LIBSECOBJS)
+endif
+
+ifdef PRODUCT_IS_DIRECTORY_SERVER
+  DAEMONLIB=
+else
+  DAEMONLIB=$(OBJDIR)/lib/libhttpdaemon.a
+endif
+
+DEPLIBS = ${DAEMONLIB} $(OBJDIR)/lib/libsi18n.a $(ADMLIB) $(LDAPSDK_DEP)
+
+ifdef FORTEZZA
+LIBSEC1 += $(NSCP_DISTDIR)/lib/libci.$(LIB_SUFFIX)
+endif
+
+DEPLINK = ${DAEMONLIB} $(OBJDIR)/lib/libsi18n.a
+ifneq ($(BUILD_MODULE), HTTP_PERSONAL)
+DEPLINK +=	$(OBJDIR)/lib/libmsgdisp.a
+endif
+DEPLINK +=	$(SOLINK) $(LDAPLINK) $(NSPRLINK) $(SOLINK2)
+
+# Relative to the directory that contains the .so
+BUILTDIR = .
+
+ifndef NO_VERITY
+
+ifeq ($(DO_SEARCH), yes)
+ifdef VERITY_TASKSTUB
+TASKSTUB = ./taskstub.o
+else
+TASKSTUB =
+endif
+
+ifndef VERITY_SOLINK
+VERITY_SOLINK=$(TASKSTUB) -L. $(addprefix -l, $(VERITY_LIBNAMES))
+endif
+
+VERITYDEP=$(addprefix $(OBJDIR)/, $(VERITYOBJNAMES) $(TASKSTUB))
+
+$(VERITYDEP) : $(LIBVERITY)
+	cp $(LIBVERITY) $(VERITY_TASKSTUB) $(OBJDIR)
+
+DEPLINK += $(VERITY_SOLINK)
+DEPLIBS += $(VERITYDEP)
+endif
+
+endif
+
+SERVLIBS = $(addprefix $(OBJDIR)/lib/, libadmin.a libframe.a libaccess.a \
+		libldapu.a libbase.a libsi18n.a)
+SERVLIB_DIRS = $(addprefix $(OBJDIR)/lib/, libadmin frame libaccess base \
+                           ldaputil libmsgdisp libsi18n)
+SERVLIB_OBJS = $(subst $(OBJDIR)/,$(BUILTDIR)/, \
+                       $(filter-out $(OBJDIR)/lib/libadmin/nsnews.o, \
+                               $(wildcard $(addsuffix /*.o, $(SERVLIB_DIRS)))))
+
+MOCHA=$(NSCP_DISTDIR)/lib/mocha.a
+
+# Removed for ns-security integration
+#NSLIBS = $(SECLIB) $(LIBSSLIO)
+
+ADMLIB_LIBS = $(SERVLIBS) $(NSLIBS)
+
+mocha:
+	cd $(MCOM_ROOT)/mocha; $(MAKE) export $(NSDEFS)
+
+
+admobjs:
+ifeq ($(ARCH), HPUX)
+	cd $(OBJDIR)/httpd-lib/nspr20; $(AR) x $(LIBNSPR)
+endif
+	cd $(OBJDIR)/httpd-lib/sslio; $(AR) x $(LIBSSLIO)
+ifndef NSPR20
+	cd $(OBJDIR)/httpd-lib/mocha; $(AR) x $(MOCHA)
+endif
+	cd $(OBJDIR)/httpd-lib/libdbm; $(AR) x $(LIBDBM)
+	cd $(OBJDIR)/httpd-lib/xp; $(AR) x $(LIBXP)
+	cd $(OBJDIR)/httpd-lib/libdbm; $(AR) x $(LIBDBM)
+	cd $(OBJDIR)/httpd-lib/xp; $(AR) x $(LIBXP)
+	rm -f $(addprefix $(OBJDIR)/httpd-lib/xp/, xp_time.o xplocale.o \
+                                                   xp_cntxt.o)
+
+#$(LDAPOBJNAME):	ldapobjs
+
+#ldapobjs:
+#	(cd $(OBJDIR); rm -f $(LDAPOBJNAME))
+#	cp $(LIBLDAP) $(OBJDIR)
+
+# Removed for ns-security integration.
+#OBJRULES += ldapobjs
+
+# Removed the httpd-lib from link for ns-security integration.
+#ADMOBJS=$(SERVLIB_OBJS) $(BUILTDIR)/httpd-lib/*/*.o
+#OBJRULES += admobjs
+ADMLIB=$(OBJDIR)/$(SONAME)
+
+$(ADMLIB): $(ADMLIB_LIBS)
+ifeq ($(ARCH), IRIX)
+    ifeq ($(USE_N32), 1)	# no -objectlist any more
+	cd $(OBJDIR) ; \
+	$(LINK_DLL) \
+             $(SERVLIB_OBJS) $(ADM_EXTRA)
+    else
+	echo "$(SERVLIB_OBJS)" > /tmp/objectlist
+	tr ' ' '\012' < /tmp/objectlist > /tmp/objectlist.NEW
+	mv /tmp/objectlist.NEW /tmp/objectlist
+	cd $(OBJDIR) ; \
+	$(LINK_DLL) \
+	     -objectlist /tmp/objectlist $(ADM_EXTRA)
+	rm /tmp/objectlist
+    endif
+else
+	cd $(OBJDIR) ; \
+	$(LINK_DLL) \
+             $(SERVLIB_OBJS) $(ADM_EXTRA)
+endif
+
+
+endif

+ 85 - 0
include/Makefile

@@ -0,0 +1,85 @@
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright 2001 Sun Microsystems, Inc.
+# Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+# Makefile for netsite.h
+
+MCOM_ROOT = ../..
+MODULE=netsiteInclude
+
+include ../nsdefs.mk
+
+HDRDEST=$(OBJDIR)/include
+
+NSPRDEST=$(HDRDEST)
+NSPRHDRS= \
+	prio.h \
+	prlong.h \
+	prtypes.h \
+	prtime.h \
+	prthread.h \
+	prinrval.h \
+	md/prcpucfg.h \
+	obsolete/protypes.h
+
+NSPRBINS=$(addprefix $(NSPRDEST)/, $(NSPRHDRS))
+
+PREFIX=copyrght.h
+
+
+NOSTDSTRIP=true
+NOSTDDEPEND=true
+
+HDRS=netsite.h version.h
+
+BINS=$(addprefix $(HDRDEST)/,$(HDRS))
+
+all: stuff nspr
+
+strip:
+depend:
+
+include ../nsconfig.mk
+
+ifeq ($(NSAPI_CAPABLE), true)
+
+stuff: $(HDRDEST) $(BINS) sub-hdrs
+
+$(HDRDEST):
+	mkdir -p $(HDRDEST)
+
+ifeq ($(PRODUCT), "Netscape Proxy Server")
+sub-hdrs:
+	cd base; gmake
+	cd frame; gmake
+	cd libproxy; gmake
+else
+sub-hdrs:
+	cd base; gmake
+	cd frame; gmake
+endif
+
+$(HDRDEST)/%.h: %.h
+	cat $(PREFIX) $< > $(HDRDEST)/$*.h
+
+else
+stuff:
+
+endif
+
+$(NSPRDEST): 
+	mkdir -p $(NSPRDEST)
+
+$(NSPRDEST)/md: $(NSPRDEST)
+	mkdir -p $(NSPRDEST)/md
+
+$(NSPRDEST)/obsolete: $(NSPRDEST)
+	mkdir -p $(NSPRDEST)/obsolete
+
+$(NSPRDEST)/%.h: 
+	cp $(NSCP_DISTDIR)/include/nspr20/pr/$*.h $(NSPRDEST)/$*.h
+
+nspr: $(NSPRDEST)/md $(NSPRDEST)/obsolete $(NSPRBINS)

+ 40 - 0
include/base/Makefile

@@ -0,0 +1,40 @@
+#
+# BEGIN COPYRIGHT BLOCK
+# Copyright 2001 Sun Microsystems, Inc.
+# Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+# Makefile for netsite.h
+
+MCOM_ROOT = ../../..
+MODULE=netsiteIncludeBase
+
+include ../../nsdefs.mk
+
+HDRDEST=$(OBJDIR)/include/base
+
+PREFIX=../copyrght.h
+
+
+NOSTDSTRIP=true
+NOSTDDEPEND=true
+
+#HDRS=$(wildcard *.h)
+HDRS=daemon.h cinfo.h crit.h ereport.h buffer.h net.h pblock.h sem.h session.h shexp.h shmem.h systhr.h util.h file.h pool.h regexp.h systems.h
+
+
+BINS=$(addprefix $(HDRDEST)/,$(HDRS))
+
+all: $(HDRDEST) $(BINS)
+
+$(HDRDEST):
+	mkdir -p $(HDRDEST)
+
+strip:
+depend:
+
+include ../../nsconfig.mk
+
+$(HDRDEST)/%.h: %.h
+	cat $(PREFIX) $< > $(HDRDEST)/$*.h

+ 209 - 0
include/base/crit.h

@@ -0,0 +1,209 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef BASE_CRIT_H
+#define BASE_CRIT_H
+
+#ifndef NOINTNSAPI
+#define INTNSAPI
+#endif /* !NOINTNSAPI */
+
+/*
+ * crit.h: Critical section abstraction. Used in threaded servers to protect
+ *         areas where two threads can interfere with each other.
+ *
+ *         Condvars are condition variables that are used for thread-thread 
+ *         synchronization.
+ * 
+ * Rob McCool
+ */
+
+#ifndef NETSITE_H
+#include "netsite.h"
+#endif /* !NETSITE_H */
+
+/* Define C interface */
+#ifndef PUBLIC_BASE_CRIT_H
+#include "public/base/crit.h"
+#endif /* !PUBLIC_BASE_CRIT_H */
+
+/* Define C++ interface */
+#ifdef __cplusplus
+
+#ifndef BASE_NSASSERT_H
+#include "nsassert.h"
+#endif /* !BASE_NSASSERT_H */
+
+#ifndef prmon_h___
+#include "prmon.h"
+#endif /* !prmon_h___ */
+
+class NSAPI_PUBLIC CriticalSection
+{
+public:
+    CriticalSection();
+    ~CriticalSection();
+    void Acquire(){PR_EnterMonitor(_crtsec);}
+    void Release(){PR_ExitMonitor(_crtsec);}
+
+private:
+    PRMonitor *_crtsec;
+};
+
+inline CriticalSection::CriticalSection():_crtsec(0)
+{
+    _crtsec = PR_NewMonitor();
+    NS_ASSERT(_crtsec);
+}
+
+inline CriticalSection::~CriticalSection()
+{
+    if (_crtsec)
+        PR_DestroyMonitor(_crtsec);
+}
+
+class SafeLock {
+ public:
+    SafeLock (CriticalSection&);		// acquire lock
+    ~SafeLock (); 						// release lock
+ private:
+    CriticalSection& lock; 
+};
+
+inline SafeLock::SafeLock (CriticalSection& _lock) : lock(_lock)
+{
+    lock.Acquire();
+}
+
+inline SafeLock::~SafeLock ()
+{
+    lock.Release();
+}
+#endif /* __cplusplus */
+
+/* --- Begin function prototypes --- */
+
+#ifdef INTNSAPI
+
+NSPR_BEGIN_EXTERN_C
+
+/* ASSERT function only */
+NSAPI_PUBLIC int crit_owner_is_me(CRITICAL id);
+
+/*
+ * INTcrit_init creates and returns a new critical section variable. At the 
+ * time of creation no one has entered it.
+ */
+NSAPI_PUBLIC CRITICAL INTcrit_init(void);
+
+/*
+ * INTcrit_enter enters a critical section. If someone is already in the
+ * section, the calling thread is blocked until that thread exits.
+ */
+NSAPI_PUBLIC void INTcrit_enter(CRITICAL id);
+
+
+/*
+ * INTcrit_exit exits a critical section. If another thread is blocked waiting
+ * to enter, it will be unblocked and given ownership of the section.
+ */
+NSAPI_PUBLIC void INTcrit_exit(CRITICAL id);
+
+
+/*
+ * INTcrit_terminate removes a previously allocated critical section variable.
+ */
+NSAPI_PUBLIC void INTcrit_terminate(CRITICAL id);
+
+
+/*
+ * INTcondvar_init initializes and returns a new condition variable. You 
+ * must provide a critical section to be associated with this condition 
+ * variable.
+ */
+NSAPI_PUBLIC CONDVAR INTcondvar_init(CRITICAL id);
+
+
+/*
+ * INTcondvar_wait blocks on the given condition variable. The calling thread
+ * will be blocked until another thread calls INTcondvar_notify on this variable.
+ * The caller must have entered the critical section associated with this
+ * condition variable prior to waiting for it.
+ */
+NSAPI_PUBLIC void INTcondvar_wait(CONDVAR cv);
+NSAPI_PUBLIC void condvar_timed_wait(CONDVAR _cv, long secs);
+
+
+/*
+ * INTcondvar_notify awakens any threads blocked on the given condition
+ * variable. The caller must have entered the critical section associated
+ * with this variable first.
+ */
+NSAPI_PUBLIC void INTcondvar_notify(CONDVAR cv);
+
+/*
+ * INTcondvar_notifyAll awakens all threads blocked on the given condition
+ * variable. The caller must have entered the critical section associated
+ * with this variable first.
+ */
+NSAPI_PUBLIC void INTcondvar_notifyAll(CONDVAR cv);
+
+/*
+ * INTcondvar_terminate frees the given previously allocated condition variable
+ */
+NSAPI_PUBLIC void INTcondvar_terminate(CONDVAR cv);
+
+
+/*
+ * Create a counting semaphore.  
+ * Return non-zero on success, 0 on failure.
+ */
+NSAPI_PUBLIC COUNTING_SEMAPHORE INTcs_init(int initial_count);
+
+/*
+ * Destroy a counting semaphore 
+ */
+NSAPI_PUBLIC void INTcs_terminate(COUNTING_SEMAPHORE csp);
+
+/*
+ * Wait to "enter" the semaphore.
+ * Return 0 on success, -1 on failure.
+ */
+NSAPI_PUBLIC int INTcs_wait(COUNTING_SEMAPHORE csp);
+
+/*
+ * Enter the semaphore if the count is > 0.  Otherwise return -1.
+ *
+ */
+NSAPI_PUBLIC int INTcs_trywait(COUNTING_SEMAPHORE csp);
+
+/*
+ * Release the semaphore- allowing a thread to enter.
+ * Return 0 on success, -1 on failure.
+ */
+NSAPI_PUBLIC int INTcs_release(COUNTING_SEMAPHORE csp);
+
+NSPR_END_EXTERN_C
+
+/* --- End function prototypes --- */
+
+#define crit_init INTcrit_init
+#define crit_enter INTcrit_enter
+#define crit_exit INTcrit_exit
+#define crit_terminate INTcrit_terminate
+#define condvar_init INTcondvar_init
+#define condvar_wait INTcondvar_wait
+#define condvar_notify INTcondvar_notify
+#define condvar_notifyAll INTcondvar_notifyAll
+#define condvar_terminate INTcondvar_terminate
+#define cs_init INTcs_init
+#define cs_terminate INTcs_terminate
+#define cs_wait INTcs_wait
+#define cs_trywait INTcs_trywait
+#define cs_release INTcs_release
+
+#endif /* INTNSAPI */
+
+#endif /* !BASE_CRIT_H */

+ 217 - 0
include/base/dbtbase.h

@@ -0,0 +1,217 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+
+#define LIBRARY_NAME "base"
+
+static char dbtbaseid[] = "$DBT: base referenced v1 $";
+
+#include "i18n.h"
+
+BEGIN_STR(base)
+	ResDef( DBT_LibraryID_, -1, dbtbaseid )/* extracted from dbtbase.h*/
+	ResDef( DBT_insufficientMemoryToCreateHashTa_, 1, "insufficient memory to create hash table" )/*extracted from cache.cpp*/
+	ResDef( DBT_insufficientMemoryToCreateHashTa_1, 2, "insufficient memory to create hash table" )/*extracted from cache.cpp*/
+	ResDef( DBT_cacheDestroyCacheTablesAppearCor_, 3, "cache_destroy: cache tables appear corrupt." )/*extracted from cache.cpp*/
+	ResDef( DBT_unableToAllocateHashEntry_, 4, "unable to allocate hash entry" )/*extracted from cache.cpp*/
+	ResDef( DBT_cacheInsertUnableToCreateCacheEn_, 5, "cache_insert: unable to create cache entry" )/*extracted from cache.cpp*/
+	ResDef( DBT_http10200OkNcontentTypeTextHtmlN_, 6, "HTTP/1.0 200 OK\nContent-type: text/html\n\n" )/*extracted from cache.cpp*/
+	ResDef( DBT_H2NetscapeCacheStatusReportH2N_, 7, "<H2>Netscape cache status report</H2>\n" )/*extracted from cache.cpp*/
+	ResDef( DBT_noCachesOnSystemP_, 8, "No caches on system<P>" )/*extracted from cache.cpp*/
+	ResDef( DBT_H2SCacheH2N_, 9, "<H2>%s cache</H2>\n" )/*extracted from cache.cpp*/
+	ResDef( DBT_cacheHitRatioDDFPNPN_, 10, "Cache hit ratio: %d/%d (%f)</P>\n</P>\n" )/*extracted from cache.cpp*/
+	ResDef( DBT_cacheSizeDDPNPN_, 11, "Cache size: %d/%d</P>\n</P>\n" )/*extracted from cache.cpp*/
+	ResDef( DBT_hashTableSizeDPNPN_, 12, "Hash table size: %d</P>\n</P>\n" )/*extracted from cache.cpp*/
+	ResDef( DBT_mruDPNlruDPN_, 13, "mru       : %d</P>\nlru       : %d</P>\n" )/*extracted from cache.cpp*/
+	ResDef( DBT_UlTableBorder4ThBucketThThAddres_, 14, "<UL><TABLE BORDER=4> <TH>Bucket</TH> <TH>Address</TH> <TH>Key</TH> <TH>Access Count</TH> <TH>Delete</TH> <TH>Next</TH> <TH>LRU</TH> <TH>MRU</TH> <TH>Data</TH>\n" )/*extracted from cache.cpp*/
+	ResDef( DBT_munmapFailedS_, 15, "munmap failed (%s)" )/*extracted from buffer.cpp*/
+	ResDef( DBT_munmapFailedS_1, 16, "munmap failed (%s)" )/*extracted from buffer.cpp*/
+	ResDef( DBT_closeFailedS_, 17, "close failed (%s)" )/*extracted from buffer.cpp*/
+	ResDef( DBT_daemonUnableToForkNewProcessSN_, 18, "daemon: unable to fork new process (%s)\n" )/*extracted from daemon.cpp*/
+	ResDef( DBT_daemonSetsidFailedSN_, 19, "daemon: setsid failed (%s)\n" )/*extracted from daemon.cpp*/
+	ResDef( DBT_daemonCanTLogPidToSSN_, 20, "daemon: can't log pid to %s (%s)\n" )/*extracted from daemon.cpp*/
+	ResDef( DBT_warningCouldNotSetGroupIdToDSN_, 21, "warning: could not set group id to %d (%s)\n" )/*extracted from daemon.cpp*/
+	ResDef( DBT_warningCouldNotSetUserIdToDSN_, 22, "warning: could not set user id to %d (%s)\n" )/*extracted from daemon.cpp*/
+	ResDef( DBT_warningDaemonIsRunningAsSuperUse_, 23, "warning: daemon is running as super-user\n" )/*extracted from daemon.cpp*/
+	ResDef( DBT_couldNotDetermineCurrentUserName_, 24, "could not determine current user name\n" )/*extracted from daemon.cpp*/
+	ResDef( DBT_errorChrootToSFailedSN_, 25, "error: chroot to %s failed (%s)\n" )/*extracted from daemon.cpp*/
+	ResDef( DBT_AddressS_, 27, ", address %s" )/*extracted from daemon.cpp*/
+	ResDef( DBT_warningStatisticsDisabledSN_, 28, "warning: statistics disabled (%s)\n" )/*extracted from daemon.cpp*/
+	ResDef( DBT_securityHandshakeTimedOutForPidD_, 29, "security handshake timed out for pid %d" )/*extracted from daemon.cpp*/
+	ResDef( DBT_warningStatisticsDisabledSN_1, 30, "warning: statistics disabled (%s)\n" )/*extracted from daemon.cpp*/
+	ResDef( DBT_secureHandshakeFailedCodeDN_, 31, "secure handshake failed (code %d)\n" )/*extracted from daemon.cpp*/
+	ResDef( DBT_acceptFailedS_, 32, "accept failed (%s)" )/*extracted from daemon.cpp*/
+	ResDef( DBT_warningStatisticsDisabledSN_2, 33, "warning: statistics disabled (%s)\n" )/*extracted from daemon.cpp*/
+	ResDef( DBT_selectThreadMiss_, 34, "select thread miss" )/*extracted from daemon.cpp*/
+	ResDef( DBT_keepaliveWorkerAwokenWithNoWorkT_, 35, "keepalive worker awoken with no work to do" )/*extracted from daemon.cpp*/
+	ResDef( DBT_couldNotCreateNewThreadDS_, 36, "could not create new thread: %d (%s)" )/*extracted from daemon.cpp*/
+	ResDef( DBT_waitForSemaSucceededButNothingTo_, 37, "wait for sema succeeded, but nothing to dequeue" )/*extracted from daemon.cpp*/
+	ResDef( DBT_queueSemaCreationFailure_, 38, "queue-sema creation failure" )/*extracted from daemon.cpp*/
+	ResDef( DBT_errorGettingProcessorInfoForProc_, 39, "error getting processor info for processor %d" )/*extracted from daemon.cpp*/
+	ResDef( DBT_errorBindingToProcessorD_, 40, "Error binding to processor %d" )/*extracted from daemon.cpp*/
+	ResDef( DBT_boundProcessDToProcessorD_, 41, "bound process %d to processor %d" )/*extracted from daemon.cpp*/
+	ResDef( DBT_netscapeServerIsNotExplicitlyBin_, 42, "Netscape server is not explicitly binding to any processors." )/*extracted from daemon.cpp*/
+	ResDef( DBT_cacheMonitorExited_, 43, "cache monitor exited" )/*extracted from daemon.cpp*/
+	ResDef( DBT_cacheBatchUpdateDaemonExited_, 44, "cache batch update daemon exited" )/*extracted from daemon.cpp*/
+	ResDef( DBT_usingSingleThreadedAccepts_, 45, "Using single threaded accepts." )/*extracted from daemon.cpp*/
+	ResDef( DBT_usingMultiThreadedAccepts_, 46, "Using multi threaded accepts." )/*extracted from daemon.cpp*/
+	ResDef( DBT_usingPartialSingleThreadedAccept_, 47, "Using partial single threaded accepts." )/*extracted from daemon.cpp*/
+	ResDef( DBT_thisMachineHasDProcessors_, 48, "This machine has %d processors." )/*extracted from daemon.cpp*/
+	ResDef( DBT_errorCallingThrSeconcurrencyDS_, 49, "Error calling thr_seconcurrency(%d)- (%s)" )/*extracted from daemon.cpp*/
+	ResDef( DBT_setConncurrencyToD_, 50, "Set conncurrency to %d." )/*extracted from daemon.cpp*/
+	ResDef( DBT_warningNetscapeExecutableAndLibr_, 51, "WARNING! netscape executable and library have different versions.\n" )/*extracted from daemon.cpp*/
+	ResDef( DBT_seminitFailedSN_, 54, "seminit failed (%s)\n" )/*extracted from daemon.cpp*/
+	ResDef( DBT_thisBetaSoftwareHasExpiredN_, 55, "This beta software has expired.\n" )/*extracted from daemon.cpp*/
+	ResDef( DBT_cacheMonitorRespawned_, 56, "Cache monitor respawned" )/*extracted from daemon.cpp*/
+	ResDef( DBT_cacheBatchUpdateDaemonRespawned_, 57, "Cache batch update daemon respawned" )/*extracted from daemon.cpp*/
+	ResDef( DBT_canTFindEmptyStatisticsSlot_, 58, "can't find empty statistics slot" )/*extracted from daemon.cpp*/
+	ResDef( DBT_canTForkNewProcessS_, 59, "can't fork new process (%s)" )/*extracted from daemon.cpp*/
+	ResDef( DBT_assertFailedSN_, 60, "assert failed! %s\n" )/*extracted from multiplex.c*/
+	ResDef( DBT_mrTableInit_, 61, "mr_table_init()" )/*extracted from multiplex.c*/
+	ResDef( DBT_mallocFailed_, 62, "malloc failed" )/*extracted from multiplex.c*/
+	ResDef( DBT_mallocFailed_1, 63, "malloc failed!" )/*extracted from multiplex.c*/
+	ResDef( DBT_mrAddIoDTypeDFileD_, 64, "mr_add_io(%d, type %d, file %d)" )/*extracted from multiplex.c*/
+	ResDef( DBT_mrAddIoStage1_, 65, "mr_add_io - stage 1" )/*extracted from multiplex.c*/
+	ResDef( DBT_mrAddIoStage2_, 66, "mr_add_io - stage 2" )/*extracted from multiplex.c*/
+	ResDef( DBT_mrAddIoFoundInvalidIoTypeD_, 67, "mr_add_io found invalid IO type %d" )/*extracted from multiplex.c*/
+	ResDef( DBT_mrAddIoAddingTimeout_, 68, "mr_add_io - adding timeout" )/*extracted from multiplex.c*/
+	ResDef( DBT_outOfMemoryN_, 69, "Out of memory!\n" )/*extracted from multiplex.c*/
+	ResDef( DBT_doneWithMrAddIo_, 70, "done with mr_add_io" )/*extracted from multiplex.c*/
+	ResDef( DBT_mrDelIoDTypeDFileD_, 71, "mr_del_io(%d, type %d, file %d)" )/*extracted from multiplex.c*/
+	ResDef( DBT_mrDelIoFoundInvalidIoTypeD_, 72, "mr_del_io found invalid IO type %d" )/*extracted from multiplex.c*/
+	ResDef( DBT_mrLookupIoD_, 73, "mr_lookup_io(%d)" )/*extracted from multiplex.c*/
+	ResDef( DBT_mrAsyncIoDDBytesFileD_, 74, "mr_async_io(%d, %d bytes, file %d)" )/*extracted from multiplex.c*/
+	ResDef( DBT_mallocFailureAddingAsyncIo_, 75, "malloc failure adding async IO" )/*extracted from multiplex.c*/
+	ResDef( DBT_errorAddingAsyncIo_, 76, "Error adding async io!" )/*extracted from multiplex.c*/
+	ResDef( DBT_cannotSeekForRead_, 77, "Cannot seek for read!" )/*extracted from multiplex.c*/
+	ResDef( DBT_readFailureDS_, 78, "read failure! (%d, %s)" )/*extracted from multiplex.c*/
+	ResDef( DBT_doReadReadDBytesForFileD_, 79, "do_read read %d bytes for file %d" )/*extracted from multiplex.c*/
+	ResDef( DBT_cannotSeekForWrite_, 80, "Cannot seek for write!" )/*extracted from multiplex.c*/
+	ResDef( DBT_writevFailureDS_, 81, "writev failure! (%d, %s)" )/*extracted from multiplex.c*/
+	ResDef( DBT_writeFailureDS_, 82, "write failure! (%d, %s)" )/*extracted from multiplex.c*/
+	ResDef( DBT_doWriteWroteDBytesForFileD_, 83, "do_write wrote %d bytes for file %d" )/*extracted from multiplex.c*/
+	ResDef( DBT_doTimeoutMrpD_, 84, "do_timeout(mrp %d)" )/*extracted from multiplex.c*/
+	ResDef( DBT_doTimeoutFoundIoTimerDTimeD_, 85, "do_timeout: found IO (timer=%d, time=%d)" )/*extracted from multiplex.c*/
+	ResDef( DBT_errorDeletingIo_, 86, "error deleting io" )/*extracted from multiplex.c*/
+	ResDef( DBT_timeoutCallbackFailureForDN_, 87, "timeout callback failure for %d\n" )/*extracted from multiplex.c*/
+	ResDef( DBT_mrGetEventDOutstandingIoD_, 88, "mr_get_event(%d) - outstanding io %d" )/*extracted from multiplex.c*/
+	ResDef( DBT_mrGetEventWaitingForReadsOnFd_, 89, "mr_get_event: Waiting for reads on FD:" )/*extracted from multiplex.c*/
+	ResDef( DBT_mrGetEventWaitingForWritesOnFd_, 90, "mr_get_event: Waiting for writes on FD:" )/*extracted from multiplex.c*/
+	ResDef( DBT_TD_, 91, "\t%d" )/*extracted from multiplex.c*/
+	ResDef( DBT_TD_1, 92, "\t%d" )/*extracted from multiplex.c*/
+	ResDef( DBT_mrGetEventSetNoTimeout_, 93, "mr_get_event set no timeout" )/*extracted from multiplex.c*/
+	ResDef( DBT_mrGetEventSetTimeoutToDDSec_, 94, "mr_get_event set timeout to: %d.%d sec" )/*extracted from multiplex.c*/
+	ResDef( DBT_errorInSelectDS_, 95, "error in select (%d, %s)" )/*extracted from multiplex.c*/
+	ResDef( DBT_mrGetEventSelectFoundD_, 96, "mr_get_event() - select found %d" )/*extracted from multiplex.c*/
+	ResDef( DBT_errorLookingUpIoFdD_, 97, "error looking up IO fd %d" )/*extracted from multiplex.c*/
+	ResDef( DBT_readFailedForFdD_, 98, "read failed for fd %d" )/*extracted from multiplex.c*/
+	ResDef( DBT_errorDeletingIo_1, 99, "error deleting io" )/*extracted from multiplex.c*/
+	ResDef( DBT_callbackFailureForDN_, 100, "callback failure for %d\n" )/*extracted from multiplex.c*/
+	ResDef( DBT_errorLookingUpIoFdD_1, 101, "error looking up IO fd %d" )/*extracted from multiplex.c*/
+	ResDef( DBT_writingHeaderLenDWritelenDTotalD_, 102, "writing: header len %d, writelen %d, total %d" )/*extracted from multiplex.c*/
+	ResDef( DBT_writeFailedForFdD_, 103, "write failed for fd %d" )/*extracted from multiplex.c*/
+	ResDef( DBT_errorDeletingIo_2, 104, "error deleting io" )/*extracted from multiplex.c*/
+	ResDef( DBT_callbackFailureForDN_1, 105, "callback failure for %d\n" )/*extracted from multiplex.c*/
+	ResDef( DBT_errorCreatingDnsCache_, 106, "Error creating dns cache" )/*extracted from dns_cache.cpp*/
+	ResDef( DBT_dnsCacheInitHashSize0UsingD_, 107, "dns_cache_init: hash_size <= 0, using %d" )/*extracted from dns_cache.cpp*/
+	ResDef( DBT_dnsCacheInitCacheSizeDUsingD_, 108, "dns_cache_init: cache-size <= %d, using %d" )/*extracted from dns_cache.cpp*/
+	ResDef( DBT_dnsCacheInitCacheSizeIsDIsTooLar_, 109, "dns_cache_init: cache-size is %d is too large, using %d." )/*extracted from dns_cache.cpp*/
+	ResDef( DBT_dnsCacheInitExpireTime0UsingD_, 110, "dns_cache_init: expire_time <= 0, using %d" )/*extracted from dns_cache.cpp*/
+	ResDef( DBT_dnsCacheInitExpireIsDIsTooLargeU_, 111, "dns_cache_init: expire is %d is too large, using %d seconds." )/*extracted from dns_cache.cpp*/
+	ResDef( DBT_errorCreatingDnsCache_1, 112, "Error creating dns cache" )/*extracted from dns_cache.cpp*/
+	ResDef( DBT_dnsCacheInsertErrorAllocatingEnt_, 113, "dns-cache-insert: Error allocating entry" )/*extracted from dns_cache.cpp*/
+	ResDef( DBT_dnsCacheInsertMallocFailure_, 114, "dns-cache-insert: malloc failure" )/*extracted from dns_cache.cpp*/
+	ResDef( DBT_successfulServerStartup_, 115, "successful server startup" )/*extracted from ereport.cpp*/
+	ResDef( DBT_SBS_, 116, "%s B%s" )/*extracted from ereport.cpp*/
+	ResDef( DBT_netscapeExecutableAndSharedLibra_, 117, "Netscape executable and shared library have different versions" )/*extracted from ereport.cpp*/
+	ResDef( DBT_executableVersionIsS_, 118, "   executable version is %s" )/*extracted from ereport.cpp*/
+	ResDef( DBT_sharedLibraryVersionIsS_, 119, "   shared library version is %s" )/*extracted from ereport.cpp*/
+	ResDef( DBT_errorReportingShuttingDown_, 120, "error reporting shutting down" )/*extracted from ereport.cpp*/
+	ResDef( DBT_warning_, 121, "warning" )/*extracted from ereport.cpp*/
+	ResDef( DBT_config_, 122, "config" )/*extracted from ereport.cpp*/
+	ResDef( DBT_security_, 123, "security" )/*extracted from ereport.cpp*/
+	ResDef( DBT_failure_, 124, "failure" )/*extracted from ereport.cpp*/
+	ResDef( DBT_catastrophe_, 125, "catastrophe" )/*extracted from ereport.cpp*/
+	ResDef( DBT_info_, 126, "info" )/*extracted from ereport.cpp*/
+	ResDef( DBT_verbose_, 127, "verbose" )/*extracted from ereport.cpp*/
+	ResDef( DBT_eventHandlerFailedToWaitOnEvents_, 128, "event_handler:Failed to wait on events %s" )/*extracted from eventhandler.cpp*/
+	ResDef( DBT_couldNotWaitOnResumeEventEventS_, 129, "could not wait on resume event event  (%s)" )/*extracted from eventhandler.cpp*/
+	ResDef( DBT_dlopenOfSFailedS_, 130, "dlopen of %s failed (%s)" )/*extracted from LibMgr.cpp*/
+	ResDef( DBT_dlopenOfSFailedS_1, 131, "dlopen of %s failed (%s)" )/*extracted from LibMgr.cpp*/
+	ResDef( DBT_theServerIsTerminatingDueToAnErr_, 132, "The server is terminating due to an error. Check the event viewer for the error message. SERVER EXITING!" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_terminatingTheServerS_, 133, "Terminating the server %s" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_killServerCannotOpenServerEventS_, 134, "kill_server:cannot open server event %s" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_killServerCannotSetServerEventS_, 135, "kill_server:cannot set server event %s" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_errorCouldNotGetSocketSN_, 136, "error: could not get socket (%s)\n" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_errorCouldNotSetSocketOptionSN_, 137, "error: could not set socket option (%s)\n" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_terminatingServiceErrorCouldNotB_, 138, "Terminating Service:error: could not bind to address %s port %d (%s)\n" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_terminatingServiceErrorCouldNotB_1, 139, "Terminating Service:error: could not bind to port %d (%s)\n" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_sethandlenoninheritableCouldNotD_, 140, "SetHandleNonInheritable: could not duplicate socket (%s)" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_sethandlenoninheritableClosingTh_, 141, "SetHandleNonInheritable: closing the original socket failed (%s)" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_couldNotSethandleinformationS_, 142, "Could not SetHandleInformation (%s)" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_terminatingServiceFailureCouldNo_, 143, "Terminating Service:Failure: Could not open statistics file (%s)\n" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_couldNotSetThreadLocalStorageVal_, 144, "Could not set Thread Local Storage Value for thread at slot %d" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_secureHandshakeFailedCodeDN_1, 145, "secure handshake failed (code %d)\n" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_acceptFailedDS_, 146, "accept failed %d (%s)" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_failedToPulseEventDS_, 147, "Failed to pulse Event %d %s" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_failedToSendMobgrowthEventToPare_, 148, "Failed to send MobGrowth Event to parent %s" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_pulsingMobrespawnEventD_, 149, "Pulsing MobRespawn Event %d" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_respawnThreadPoolToDD_, 150, "respawn thread pool to %d (%d)" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_couldNotOpenEventToSignalRotateA_, 151, "Could not open event to signal rotate application. Could not create the MoveLog event:%s" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_failedToSendMovelogEventToRotate_, 152, "Failed to send MoveLog Event to rotate app %s" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_growingThreadPoolFromDToD_, 153, "growing thread pool from %d to %d" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_couldNotOpenTheServicecontrolman_, 154, "Could not open the ServiceControlManager, Error %d" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_startnetsiteserviceCouldNotOpenT_, 155, "StartNetsiteService:Could not open the service %s: Error %d" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_startnetsiteserviceCouldNotStart_, 156, "StartNetsiteService:Could not start the service %s" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_serviceStartupCouldNotAllocateSe_, 157, "Service Startup: Could not allocate security descriptor" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_serviceStartupCouldNotInitSecuri_, 158, "Service Startup: Could not init security descriptor" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_serviceStartupCouldNotSetTheSecu_, 159, "Service Startup: Could not set the security Dacl" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_terminatingServiceWinsockInitFai_, 160, "Terminating Service:WinSock init failed: %s" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_httpdServerStartupFailedS_, 161, "Httpd Server Startup failed: %s" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_canTFindEmptyStatisticsSlot_1, 162, "can't find empty statistics slot" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_ntDaemonCouldNotCreateNewThreadD_, 163, "NT daemon: could not create new thread %d" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_serviceStartupFailureTerminating_, 164, "Service Startup Failure. Terminating Service:Could not create event %d:%s" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_serviceStartupErrorCouldNotCreat_, 165, "Service Startup Error. Could not create the MoveLog event:%s" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_failedToWaitOnEventObjectsS_, 166, "Failed to wait on Event objects %s" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_failedToWaitOnEventObjectsS_1, 167, "Failed to wait on Event objects %s" )/*extracted from ntdaemon.cpp*/
+	ResDef( DBT_pipebufBuf2sdPipebufGrabIoErrorD_, 168, "pipebuf_buf2sd: pipebuf_grab IO_ERROR %d" )/*extracted from ntpipe.cpp*/
+	ResDef( DBT_poolInitMemoryPoolsDisabled_, 169, "pool-init: memory pools disabled" )/*extracted from pool.cpp*/
+	ResDef( DBT_poolInitFreeSize0UsingD_, 170, "pool-init: free_size <= 0, using %d" )/*extracted from pool.cpp*/
+	ResDef( DBT_poolCreateBlockOutOfMemory_, 171, "pool-create-block: out of memory" )/*extracted from pool.cpp*/
+	ResDef( DBT_poolCreateOutOfMemory_, 172, "pool-create: out of memory" )/*extracted from pool.cpp*/
+	ResDef( DBT_poolCreateOutOfMemory_1, 173, "pool-create: out of memory" )/*extracted from pool.cpp*/
+	ResDef( DBT_poolMallocOutOfMemory_, 174, "pool-malloc: out of memory" )/*extracted from pool.cpp*/
+	ResDef( DBT_freeUsedWherePermFreeShouldHaveB_, 175, "FREE() used where PERM_FREE() should have been used- problem corrected and supressing further warnings." )/*extracted from pool.cpp*/
+	ResDef( DBT_regexErrorSRegexS_, 176, "regex error: %s (regex: '%s')" )/*extracted from regexp.cpp*/
+	ResDef( DBT_canTCreateIpcPipeS_, 177, "can't create IPC pipe (%s)" )/*extracted from thrconn.cpp*/
+	ResDef( DBT_writeToWakeupPipeFailedS_, 178, "write to wakeup pipe failed (%s)" )/*extracted from thrconn.cpp*/
+	ResDef( DBT_flushingDConnectionsCurrentDTotD_, 179, "flushing %d connections; current %d; tot %d" )/*extracted from thrconn.cpp*/
+	ResDef( DBT_acceptFailedS_1, 180, "accept failed (%s)" )/*extracted from thrconn.cpp*/
+	ResDef( DBT_errorCreatingTimeCache_, 181, "Error creating time cache" )/*extracted from time_cache.cpp*/
+	ResDef( DBT_timeCacheCacheDisabled_, 182, "time-cache: cache disabled" )/*extracted from time_cache.cpp*/
+	ResDef( DBT_timeCacheInitHashSizeDUsingDefau_, 183, "time_cache_init: hash_size < %d, using default, %d" )/*extracted from time_cache.cpp*/
+	ResDef( DBT_timeCacheInitHashSizeDUsingDefau_1, 184, "time_cache_init: hash_size > %d, using default, %d" )/*extracted from time_cache.cpp*/
+	ResDef( DBT_timeCacheInitCacheSizeDUsingDefa_, 185, "time_cache_init: cache_size < %d, using default, %d" )/*extracted from time_cache.cpp*/
+	ResDef( DBT_timeCacheInitCacheSizeDUsingDefa_1, 186, "time_cache_init: cache_size > %d, using default, %d" )/*extracted from time_cache.cpp*/
+	ResDef( DBT_errorAllocatingMemoryForTimeCach_, 187, "Error allocating memory for time_cache" )/*extracted from time_cache.cpp*/
+	ResDef( DBT_errorAllocatingMemoryForTimeCach_1, 188, "Error allocating memory for time_cache entry" )/*extracted from time_cache.cpp*/
+	ResDef( DBT_errorAllocatingMemoryForTimeCach_2, 189, "Error allocating memory for time_cache entry" )/*extracted from time_cache.cpp*/
+	ResDef( DBT_errorInsertingNewTimeCacheEntry_, 190, "Error inserting new time_cache entry" )/*extracted from time_cache.cpp*/
+	ResDef( DBT_errorAllocatingMemoryForTimeCach_3, 191, "Error allocating memory for time_cache" )/*extracted from time_cache.cpp*/
+	ResDef( DBT_csTerminateFailureS_, 192, "cs-terminate failure (%s)" )/*extracted from crit.cpp*/
+	ResDef( DBT_csInitFailureS_, 193, "cs-init failure (%s)" )/*extracted from crit.cpp*/
+	ResDef( DBT_csWaitFailureS_, 194, "cs-wait failure (%s)" )/*extracted from crit.cpp*/
+	ResDef( DBT_csPostFailureS_, 195, "cs-post failure (%s)" )/*extracted from crit.cpp*/
+	ResDef( DBT_unableToCreateNonblockingSocketS_, 196, "Unable to create nonblocking socket (%s)" )/*extracted from net.cpp*/
+	ResDef( DBT_errorCouldNotSetKeepaliveSN_, 197, "error: could not set keepalive (%s)\n" )/*extracted from net.cpp*/
+	ResDef( DBT_errorCouldNotSetRecvTimeoutSN_, 198, "error: could not set recv timeout (%s)\n" )/*extracted from net.cpp*/
+	ResDef( DBT_errorCouldNotSetSendTimeoutSN_, 199, "error: could not set send timeout (%s)\n" )/*extracted from net.cpp*/
+	ResDef( DBT_unableToCreateNonblockingSocketS_1, 200, "Unable to create nonblocking socket (%s)" )/*extracted from net.cpp*/
+	ResDef( DBT_semGrabFailedS_, 201, "sem_grab failed (%s)" )/*extracted from net.cpp*/
+	ResDef( DBT_semReleaseFailedS_, 202, "sem_release failed (%s)" )/*extracted from net.cpp*/
+	ResDef( DBT_semReleaseFailedS_1, 203, "sem_release failed (%s)" )/*extracted from net.cpp*/
+	ResDef( DBT_couldNotRemoveTemporaryDirectory_, 204, "Could not remove temporary directory %s,  Error %d" )/*extracted from util.cpp*/
+	ResDef( DBT_couldNotRemoveTemporaryDirectory_1, 205, "Could not remove temporary directory %s, Error %d" )/*extracted from util.cpp*/
+END_STR(base)

+ 76 - 0
include/base/ereport.h

@@ -0,0 +1,76 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef BASE_EREPORT_H
+#define BASE_EREPORT_H
+
+#ifndef NOINTNSAPI
+#define INTNSAPI
+#endif /* !NOINTNSAPI */
+
+/*
+ * ereport.h: Records transactions, reports errors to administrators, etc.
+ * 
+ * Rob McCool
+ */
+
+#ifndef BASE_SESSION_H
+#include "session.h"
+#endif /* !BASE_SESSION_H */
+
+#ifndef PUBLIC_BASE_EREPORT_H
+#include "public/base/ereport.h"
+#endif /* !PUBLIC_BASE_EREPORT_H */
+
+/* --- Begin function prototypes --- */
+
+#ifdef INTNSAPI
+
+NSPR_BEGIN_EXTERN_C
+
+/*
+ * INTereport logs an error of the given degree and formats the arguments with 
+ * the printf() style fmt. Returns whether the log was successful. Records 
+ * the current date.
+ */
+
+NSAPI_PUBLIC int INTereport(int degree, char *fmt, ...);
+NSAPI_PUBLIC int INTereport_v(int degree, char *fmt, va_list args);
+
+/*
+ * INTereport_init initializes the error logging subsystem and opens the static
+ * file descriptors. It returns NULL upon success and an error string upon
+ * error. If a userpw is given, the logs will be chowned to that user.
+ * 
+ * email is the address of a person to mail upon catastrophic error. It
+ * can be NULL if no e-mail is desired. INTereport_init will not duplicate
+ * its own copy of this string; you must make sure it stays around and free
+ * it when you shut down the server.
+ */
+
+NSAPI_PUBLIC
+char *INTereport_init(char *err_fn, char *email, PASSWD pwuser, char *version);
+
+/*
+ * log_terminate closes the error and common log file descriptors.
+ */
+NSAPI_PUBLIC void INTereport_terminate(void);
+
+/* For restarts */
+NSAPI_PUBLIC SYS_FILE INTereport_getfd(void);
+
+NSPR_END_EXTERN_C
+
+/* --- End function prototypes --- */
+
+#define ereport INTereport
+#define ereport_v INTereport_v
+#define ereport_init INTereport_init
+#define ereport_terminate INTereport_terminate
+#define ereport_getfd INTereport_getfd
+
+#endif /* INTNSAPI */
+
+#endif /* !BASE_EREPORT_H */

+ 73 - 0
include/base/eventhandler.h

@@ -0,0 +1,73 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+/*
+ * eventhandler.h: Handle registration of event handlers
+ *
+ * This is a facility in the NT server to provide a way to register event
+ * handling functions. Often there is a need to send a control signal of some
+ * kind to the server. This could be a signal for the server to rotate its
+ * logs, or a signal to collect and return statistical information of some kind
+ * such as perfmon stats.
+ * 
+ * This file specifies the structures and functions necessary to set up this
+ * kind of asynchronous special event handling.
+ * 
+ * Aruna Victor 2/21/96
+ */
+
+#ifndef EVENTHANDLER_H
+#define EVENTHANDLER_H
+
+#include "netsite.h"
+
+/* ------------------------------ Structures ------------------------------ */
+
+/* EVENT_HANDLER specifies
+    1. The name of the event. This is the event that the event handler will
+       create and wait on for a signal.
+    2. The name of the function should be called to handle the event.
+    3. The argument that should be passed to this function.
+    4. The next EVENT_HANDLER on the list this structure is on. */
+
+typedef struct event_handler {
+	int event_number;
+    char *event_name;
+    void (*_event_handler)(void *);
+    void *argument;
+    struct event_handler *next;
+} EVENT_HANDLER;
+
+/* ------------------------------ Prototypes ------------------------------ */
+
+NSPR_BEGIN_EXTERN_C
+
+char *initialize_event_handler(char *serverid);
+
+char *terminate_event_handler();
+
+char *add_handler(char *event, void (*fn)(void *), void *arg);
+
+char *delete_handler(char *event);
+
+char *add_rotation_handler(char *event, void (*fn)(void *), void *arg);
+
+NSPR_END_EXTERN_C
+
+#endif /* !EVENTHANDLER	 */
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+ 34 - 0
include/base/eventlog.h

@@ -0,0 +1,34 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+// EVENTLOG.H
+//
+// This file contains the defines that make NT an installable service.
+//
+// 1/12/95 aruna
+//
+
+// Functions in eventlog.c
+
+#ifndef _EVENTLOG_H_
+#define _EVENTLOG_H_
+
+#include "netsite.h"
+
+
+#if defined(XP_WIN32)
+
+NSPR_BEGIN_EXTERN_C
+
+NSAPI_PUBLIC HANDLE InitializeLogging(char *szEventLogName);
+NSAPI_PUBLIC BOOL TerminateLogging(HANDLE hEventSource);
+NSAPI_PUBLIC BOOL LogErrorEvent(HANDLE hEventSource, WORD fwEventType, WORD fwCategory, DWORD IDEvent, LPTSTR chMsg, LPTSTR lpszMsg);
+
+NSPR_END_EXTERN_C
+
+#endif /* XP_WIN32 */
+
+
+#endif

+ 121 - 0
include/base/file.h

@@ -0,0 +1,121 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef BASE_FILE_H
+#define BASE_FILE_H
+
+#ifndef NOINTNSAPI
+#define INTNSAPI
+#endif /* !NOINTNSAPI */
+
+/* GLOBAL FUNCTIONS:
+ * DESCRIPTION:
+ * system-specific functions for reading/writing files
+ */
+
+#ifndef NETSITE_H
+#include "../netsite.h"
+#endif /* !NETSITE_H */
+
+#ifndef PUBLIC_BASE_FILE_H
+#include "public/base/file.h"
+#endif /* !PUBLIC_BASE_FILE_H */
+
+/* --- Begin function prototypes --- */
+
+#ifdef INTNSAPI
+
+NSPR_BEGIN_EXTERN_C
+
+void INTsystem_errmsg_init(void);
+
+NSAPI_PUBLIC SYS_FILE INTsystem_fopenRO(char *path);
+NSAPI_PUBLIC SYS_FILE INTsystem_fopenWA(char *path);
+NSAPI_PUBLIC SYS_FILE INTsystem_fopenRW(char *path);
+NSAPI_PUBLIC SYS_FILE INTsystem_fopenWT(char *path);
+NSAPI_PUBLIC int INTsystem_fread(SYS_FILE fd, char *buf, int sz);
+NSAPI_PUBLIC int INTsystem_fwrite(SYS_FILE fd,char *buf,int sz);
+NSAPI_PUBLIC int INTsystem_fwrite_atomic(SYS_FILE fd, char *buf, int sz);
+NSAPI_PUBLIC int INTsystem_lseek(SYS_FILE fd, int off, int wh);
+NSAPI_PUBLIC int INTsystem_fclose(SYS_FILE fd);
+NSAPI_PUBLIC int INTsystem_stat(char *name, struct stat *finfo);
+NSAPI_PUBLIC int INTsystem_rename(char *oldpath, char *newpath);
+NSAPI_PUBLIC int INTsystem_unlink(char *path);
+NSAPI_PUBLIC int INTsystem_tlock(SYS_FILE fd);
+NSAPI_PUBLIC int INTsystem_flock(SYS_FILE fd);
+NSAPI_PUBLIC int INTsystem_ulock(SYS_FILE fd);
+
+#ifdef XP_WIN32
+NSAPI_PUBLIC SYS_DIR INTdir_open(char *path);
+NSAPI_PUBLIC SYS_DIRENT *INTdir_read(SYS_DIR ds);
+NSAPI_PUBLIC void INTdir_close(SYS_DIR ds);
+#endif /* XP_WIN32 */
+
+NSAPI_PUBLIC int INTdir_create_all(char *dir);
+
+/* --- OBSOLETE ----------------------------------------------------------
+ * The following macros/functions are obsolete and are only maintained for
+ * compatibility.  Do not use them. 11-19-96
+ * -----------------------------------------------------------------------
+ */
+
+#ifdef XP_WIN32
+NSAPI_PUBLIC char *INTsystem_winsockerr(void);
+NSAPI_PUBLIC char *INTsystem_winerr(void);
+NSAPI_PUBLIC int INTsystem_pread(SYS_FILE fd, char *buf, int sz);
+NSAPI_PUBLIC int INTsystem_pwrite(SYS_FILE fd, char *buf, int sz);
+NSAPI_PUBLIC void INTfile_unix2local(char *path, char *p2);
+#endif /* XP_WIN32 */
+
+NSAPI_PUBLIC int INTsystem_nocoredumps(void);
+NSAPI_PUBLIC int INTfile_setinherit(SYS_FILE fd, int value);
+NSAPI_PUBLIC int INTfile_notfound(void);
+NSAPI_PUBLIC char *INTsystem_errmsg(void);
+NSAPI_PUBLIC int INTsystem_errmsg_fn(char **buff, size_t maxlen);
+
+NSPR_END_EXTERN_C
+
+#define system_errmsg_init INTsystem_errmsg_init
+#define system_fopenRO INTsystem_fopenRO
+#define system_fopenWA INTsystem_fopenWA
+#define system_fopenRW INTsystem_fopenRW
+#define system_fopenWT INTsystem_fopenWT
+#define system_fread INTsystem_fread
+#define system_fwrite INTsystem_fwrite
+#define system_fwrite_atomic INTsystem_fwrite_atomic
+#define system_lseek INTsystem_lseek
+#define system_fclose INTsystem_fclose
+#define system_stat INTsystem_stat
+#define system_rename INTsystem_rename
+#define system_unlink INTsystem_unlink
+#define system_tlock INTsystem_tlock
+#define system_flock INTsystem_flock
+#define system_ulock INTsystem_ulock
+#ifdef XP_WIN32
+#define dir_open INTdir_open
+#define dir_read INTdir_read
+#define dir_close INTdir_close
+#endif /* XP_WIN32 */
+#define dir_create_all INTdir_create_all
+
+/* Obsolete */
+#ifdef XP_WIN32
+#define system_winsockerr INTsystem_winsockerr
+#define system_winerr INTsystem_winerr
+#define system_pread INTsystem_pread
+#define system_pwrite INTsystem_pwrite
+#define file_unix2local INTfile_unix2local
+#endif /* XP_WIN32 */
+
+#define system_nocoredumps INTsystem_nocoredumps
+#define file_setinherit INTfile_setinherit
+#define file_notfound INTfile_notfound
+#define rtfile_notfound INTfile_notfound
+#define system_errmsg INTsystem_errmsg
+#define system_errmsg_fn INTsystem_errmsg_fn
+
+#endif /* INTNSAPI */
+
+#endif /* BASE_FILE_H */

+ 94 - 0
include/base/fsmutex.h

@@ -0,0 +1,94 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+/*
+ * fsmutex: Mutexes that are filesystem-based so they're available from more
+ * than one process and address space
+ * 
+ * Rob McCool
+ */
+
+
+#ifndef FSMUTEX_H
+#define FSMUTEX_H
+
+#include "netsite.h"
+
+typedef void * FSMUTEX;
+
+
+/* ------------------------------ Prototypes ------------------------------ */
+
+NSPR_BEGIN_EXTERN_C
+
+/* 
+   Flags to fsmutex_init. 
+
+   FSMUTEX_VISIBLE makes a filesystem mutex which can be opened by other
+   programs or processes.
+
+   FSMUTEX_NEEDCRIT specifies that the fsmutex_lock and fsmutex_unlock 
+   functions should also use a critical section to ensure that more than
+   one thread does not acquire the mutex at a time. If this flag is not 
+   specified, it is up to the caller to ensure that only thread within a 
+   process tries to acquire the lock at any given time.
+ */
+#define FSMUTEX_VISIBLE 0x01
+#define FSMUTEX_NEEDCRIT 0x02
+
+
+/*
+   fsmutex_init creates a new filesystem-based mutex. The resulting mutex
+   is part of the filesystem. The name and number parameters are used to
+   create a name for the mutex. If the FSMUTEX_VISIBLE flag is specified, 
+   the mutex will be left in the filesystem for other programs and processes
+   to access. If a mutex with the given name/number combination already
+   exists, the calling process is allowed access to it. If the mutex does
+   not already exist, the mutex is created.
+
+   Returns NULL on failure, a void pointer to a fsmutex structure otherwise.
+   This fsmutex structure is local to the current process.
+ */
+NSAPI_PUBLIC FSMUTEX fsmutex_init(char *name, int number, int flags);
+
+/* 
+   Sets the ownership of the underlying filesystem object to the given
+   uid and gid. Only effective if the server is running as root.
+ */
+#ifdef XP_UNIX
+#include <unistd.h>
+#ifdef __sony
+#include <sys/types.h>
+#endif
+NSAPI_PUBLIC void fsmutex_setowner(FSMUTEX fsm, uid_t uid, gid_t gid);
+#endif
+
+
+
+/*
+   fsmutex_terminate deletes a filesystem-based mutex. A mutex will only
+   be deleted when every process which has an open pointer to the mutex 
+   calls this function.
+ */
+NSAPI_PUBLIC void fsmutex_terminate(FSMUTEX id);
+
+/*
+   fsmutex_lock attempts to acquire the given filesystem-based mutex. If 
+   another process is holding the mutex, or if the FSMUTEX_NEEDCRIT flag
+   was passed to fsmutex_init and another thread in the current process is 
+   holding the mutex, then the calling thread will block until the mutex
+   is available.
+ */
+NSAPI_PUBLIC void fsmutex_lock(FSMUTEX id);
+
+/*
+   fsmutex_unlock releases a filesystem-based mutex previously acquired
+   by fsmutex_lock.
+ */
+NSAPI_PUBLIC void fsmutex_unlock(FSMUTEX id);
+
+NSPR_END_EXTERN_C
+
+#endif

+ 89 - 0
include/base/lexer.h

@@ -0,0 +1,89 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef __lexer_h
+#define __lexer_h
+
+#ifndef _POOL_H_
+#include "base/pool.h"
+#endif /* _POOL_H_ */
+
+/* Define error codes */
+#define LEXERR_MALLOC	-1		/* insufficient dynamic memory */
+
+
+typedef struct LEXStream_s LEXStream_t;
+typedef int (*LEXStreamGet_t)(LEXStream_t *);
+struct LEXStream_s {
+    LEXStream_t * lst_next;		/* link for "include" parent stream */
+    void * lst_strmid;			/* client stream identifier */
+    LEXStreamGet_t lst_get;		/* pointer to stream "get" function */
+    char * lst_buf;			/* stream buffer pointer */
+    char * lst_cp;			/* current position in buffer */
+    int lst_len;			/* remaining bytes in buffer */
+    int lst_buflen;			/* buffer length */
+    int lst_flags;			/* bit flags */
+#define LST_FREEBUF	0x1		/* free lst_buf in stream destroy */
+};
+NSPR_BEGIN_EXTERN_C
+
+/* Functions in lexer.c */
+NSAPI_PUBLIC
+int lex_class_check(void * chtab, char code, unsigned long cbits);
+
+NSAPI_PUBLIC
+int lex_class_create(int classc, char * classv[], void **pchtab);
+
+NSAPI_PUBLIC void lex_class_destroy(void * chtab);
+
+NSAPI_PUBLIC
+LEXStream_t * lex_stream_create(LEXStreamGet_t strmget, void * strmid,
+                                char * buf, int buflen);
+
+NSAPI_PUBLIC void lex_stream_destroy(LEXStream_t * lst);
+
+NSAPI_PUBLIC int
+lex_token_new(pool_handle_t * pool, int initlen, int growlen, void **token);
+
+NSAPI_PUBLIC int lex_token_start(void * token);
+
+NSAPI_PUBLIC
+char * lex_token_info(void * token, int * tdatalen, int * tbufflen);
+
+NSAPI_PUBLIC char * lex_token(void * token);
+
+NSAPI_PUBLIC void lex_token_destroy(void * token);
+
+NSAPI_PUBLIC
+char * lex_token_get(void * token, int * tdatalen, int * tbufflen);
+
+NSAPI_PUBLIC char * lex_token_take(void * token);
+
+NSAPI_PUBLIC
+int lex_token_append(void * token, int nbytes, char * src);
+
+NSAPI_PUBLIC
+int lex_next_char(LEXStream_t * lst, void * chtab, unsigned long cbits);
+
+NSAPI_PUBLIC
+int lex_scan_over(LEXStream_t * lst, void * chtab, unsigned long cbits,
+			 void * token);
+
+NSAPI_PUBLIC
+int lex_scan_string(LEXStream_t * lst, void * token, int flags);
+
+NSAPI_PUBLIC
+int lex_scan_to(LEXStream_t * lst, void * chtab, unsigned long cbits,
+                void * token);
+
+NSAPI_PUBLIC
+int lex_skip_over(LEXStream_t * lst, void * chtab, unsigned long cbits);
+
+NSAPI_PUBLIC
+int lex_skip_to(LEXStream_t * lst, void * chtab, unsigned long cbits);
+
+NSPR_END_EXTERN_C
+
+#endif /* __lexer_h */

+ 21 - 0
include/base/nterr.h

@@ -0,0 +1,21 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+/*
+ * Added function prototypes for nterror stuff.
+ *
+ * Robin Maxwell
+ */
+
+#ifndef _NTERR_H
+#define _NTERR_H
+NSPR_BEGIN_EXTERN_C
+
+char * FindError(int error);
+NSAPI_PUBLIC void HashNtErrors();
+
+NSPR_END_EXTERN_C
+
+#endif /* _NTERR_H */

+ 67 - 0
include/base/nterrors.h

@@ -0,0 +1,67 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+/* DO NOT EDIT THIS FILE - it is automatically generated */
+
+typedef struct _NtError {
+	int ErrorNumber;
+	char *ErrorString;
+	struct _NtError *next;
+} NtError;
+
+NtError NtErrorStrings[] = {
+{ 10004 , "WSAEINTR" },
+{ 10009 , "WSAEBADF" },
+{ 10013 , "WSAEACCES" },
+{ 10014 , "WSAEFAULT" },
+{ 10022 , "WSAEINVAL" },
+{ 10024 , "WSAEMFILE" },
+{ 10035 , "WSAEWOULDBLOCK" },
+{ 10036 , "WSAEINPROGRESS" },
+{ 10037 , "WSAEALREADY" },
+{ 10038 , "WSAENOTSOCK" },
+{ 10039 , "WSAEDESTADDRREQ" },
+{ 10040 , "WSAEMSGSIZE" },
+{ 10041 , "WSAEPROTOTYPE" },
+{ 10042 , "WSAENOPROTOOPT" },
+{ 10043 , "WSAEPROTONOSUPPORT" },
+{ 10044 , "WSAESOCKTNOSUPPORT" },
+{ 10045 , "WSAEOPNOTSUPP" },
+{ 10046 , "WSAEPFNOSUPPORT" },
+{ 10047 , "WSAEAFNOSUPPORT" },
+{ 10048 , "WSAEADDRINUSE" },
+{ 10049 , "WSAEADDRNOTAVAIL" },
+{ 10050 , "WSAENETDOWN" },
+{ 10051 , "WSAENETUNREACH" },
+{ 10052 , "WSAENETRESET" },
+{ 10053 , "WSAECONNABORTED" },
+{ 10054 , "WSAECONNRESET" },
+{ 10055 , "WSAENOBUFS" },
+{ 10056 , "WSAEISCONN" },
+{ 10057 , "WSAENOTCONN" },
+{ 10058 , "WSAESHUTDOWN" },
+{ 10059 , "WSAETOOMANYREFS" },
+{ 10060 , "WSAETIMEDOUT" },
+{ 10061 , "WSAECONNREFUSED" },
+{ 10062 , "WSAELOOP" },
+{ 10063 , "WSAENAMETOOLONG" },
+{ 10064 , "WSAEHOSTDOWN" },
+{ 10065 , "WSAEHOSTUNREACH" },
+{ 10066 , "WSAENOTEMPTY" },
+{ 10067 , "WSAEPROCLIM" },
+{ 10068 , "WSAEUSERS" },
+{ 10069 , "WSAEDQUOT" },
+{ 10070 , "WSAESTALE" },
+{ 10071 , "WSAEREMOTE" },
+{ 10101 , "WSAEDISCON" },
+{ 10091 , "WSASYSNOTREADY" },
+{ 10092 , "WSAVERNOTSUPPORTED" },
+{ 10093 , "WSANOTINITIALISED" },
+{ 11001 , "WSAHOST_NOT_FOUND" },
+{ 11002 , "WSATRY_AGAIN" },
+{ 11003 , "WSANO_RECOVERY" },
+{ 11004 , "WSANO_DATA" },
+{ 0, NULL }
+};

+ 61 - 0
include/base/plist.h

@@ -0,0 +1,61 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef _PLIST_H
+#define _PLIST_H
+
+#ifndef NOINTNSACL
+#define INTNSACL
+#endif /* !NOINTNSACL */
+
+/*
+ * TYPE:        PList_t
+ *
+ * DESCRIPTION:
+ *
+ *      This type defines a handle for a property list.
+ */
+
+#include "base/pool.h"
+
+#ifndef PUBLIC_NSACL_PLISTDEF_H
+#include "../public/nsacl/plistdef.h"
+#endif /* !PUBLIC_NSACL_PLISTDEF_H */
+
+#ifdef INTNSACL
+
+/* Functions in plist.c */
+NSPR_BEGIN_EXTERN_C
+
+NSAPI_PUBLIC extern int PListAssignValue(PList_t plist, const char *pname,
+                            const void *pvalue, PList_t ptype);
+NSAPI_PUBLIC extern PList_t PListCreate(pool_handle_t *mempool,
+                           int resvprop, int maxprop, int flags);
+NSAPI_PUBLIC extern int PListDefProp(PList_t plist, int pindex, 
+                        const char *pname, const int flags);
+NSAPI_PUBLIC extern const void * PListDeleteProp(PList_t plist, int pindex, const char *pname);
+NSAPI_PUBLIC extern int PListFindValue(PList_t plist,
+                          const char *pname, void **pvalue, PList_t *type);
+NSAPI_PUBLIC extern int PListInitProp(PList_t plist, int pindex, const char *pname,
+                         const void *pvalue, PList_t ptype);
+NSAPI_PUBLIC extern PList_t PListNew(pool_handle_t *mempool);
+NSAPI_PUBLIC extern void PListDestroy(PList_t plist);
+NSAPI_PUBLIC extern int PListGetValue(PList_t plist,
+                         int pindex, void **pvalue, PList_t *type);
+NSAPI_PUBLIC extern int PListNameProp(PList_t plist, int pindex, const char *pname);
+NSAPI_PUBLIC extern int PListSetType(PList_t plist, int pindex, PList_t type);
+NSAPI_PUBLIC extern int PListSetValue(PList_t plist,
+                         int pindex, const void *pvalue, PList_t type);
+NSAPI_PUBLIC extern void PListEnumerate(PList_t plist, PListFunc_t *user_func, 
+                           void *user_data);
+NSAPI_PUBLIC extern PList_t
+PListDuplicate(PList_t plist, pool_handle_t *new_mempool, int flags);
+NSAPI_PUBLIC extern pool_handle_t *PListGetPool(PList_t plist);
+
+NSPR_END_EXTERN_C
+
+#endif /* INTNSACL */
+
+#endif /* _PLIST_H */

+ 103 - 0
include/base/pool.h

@@ -0,0 +1,103 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef BASE_POOL_H
+#define BASE_POOL_H
+
+#ifndef NOINTNSAPI
+#define INTNSAPI
+#endif /* !NOINTNSAPI */
+
+/*
+ * pool.h
+ *
+ * Module for handling memory allocations.
+ *
+ * Notes:
+ * This module is used instead of the NSPR prarena module because the prarenas
+ * did not fit as cleanly into the existing server.
+ *
+ * Mike Belshe
+ * 10-02-95
+ *
+ */
+
+#ifdef MALLOC_POOLS
+
+#ifndef NETSITE_H
+#include "netsite.h"
+#endif /* !NETSITE_H */
+
+#ifndef BASE_PBLOCK_H
+#include "pblock.h"
+#endif /* !BASE_PBLOCK_H */
+
+#ifndef BASE_SESSION_H
+#include "session.h"
+#endif /* !BASE_SESSION_H */
+
+#ifndef FRAME_REQ_H
+#include "frame/req.h"
+#endif /* !FRAME_REQ_H */
+
+#ifndef PUBLIC_BASE_POOL_H
+#include "public/base/pool.h"
+#endif /* !PUBLIC_BASE_POOL_H */
+
+/* --- Begin function prototypes --- */
+
+#ifdef INTNSAPI
+
+NSPR_BEGIN_EXTERN_C
+
+int pool_internal_init(void);
+
+NSAPI_PUBLIC int INTpool_init(pblock *pb, Session *sn, Request *rq);
+
+#ifdef DEBUG_CACHES
+NSAPI_PUBLIC int INTpool_service_debug(pblock *pb, Session *sn, Request *rq);
+#endif
+
+NSAPI_PUBLIC pool_handle_t *INTpool_create(void);
+
+NSAPI_PUBLIC void INTpool_destroy(pool_handle_t *pool_handle);
+
+NSAPI_PUBLIC int INTpool_enabled(void);
+
+NSAPI_PUBLIC void *INTpool_malloc(pool_handle_t *pool_handle, size_t size );
+
+NSAPI_PUBLIC void INTpool_free(pool_handle_t *pool_handle, void *ptr );
+
+NSAPI_PUBLIC 
+void *INTpool_calloc(pool_handle_t *pool_handle, size_t nelem, size_t elsize);
+
+NSAPI_PUBLIC 
+void *INTpool_realloc(pool_handle_t *pool_handle, void *ptr, size_t size );
+
+NSAPI_PUBLIC
+char *INTpool_strdup(pool_handle_t *pool_handle, const char *orig_str );
+
+NSPR_END_EXTERN_C
+
+#define pool_init INTpool_init
+
+#ifdef DEBUG_CACHES
+#define pool_service_debug INTpool_service_debug
+#endif /* DEBUG_CACHES */
+
+#define pool_create INTpool_create
+#define pool_destroy INTpool_destroy
+#define pool_enabled INTpool_enabled
+#define pool_malloc INTpool_malloc
+#define pool_free INTpool_free
+#define pool_calloc INTpool_calloc
+#define pool_realloc INTpool_realloc
+#define pool_strdup INTpool_strdup
+
+#endif /* INTNSAPI */
+
+#endif /* MALLOC_POOLS */
+
+#endif /* !BASE_POOL_H_ */

+ 54 - 0
include/base/rwlock.h

@@ -0,0 +1,54 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+/*
+ * rwlock.h: Shared/Exclusive lock abstraction. 
+ * 
+ * Sanjay Krishnamurthi
+ */
+#ifndef _BASE_RWLOCK_H_
+#define _BASE_RWLOCK_H_
+
+#include "netsite.h"
+#include "crit.h"
+
+NSPR_BEGIN_EXTERN_C
+
+typedef void* RWLOCK;
+
+/*
+ * rwlock_Init()
+ *  creates and returns a new readwrite lock variable. 
+ */
+NSAPI_PUBLIC RWLOCK rwlock_Init(void);
+
+/*
+ * rwlock_ReadLock()
+ */
+NSAPI_PUBLIC void rwlock_ReadLock(RWLOCK lock);
+
+/*
+ * rwlock_WriteLock()
+ */
+NSAPI_PUBLIC void rwlock_WriteLock(RWLOCK lock);
+
+/*
+ * rwlock_Unlock()
+ */
+NSAPI_PUBLIC void rwlock_Unlock(RWLOCK lock);
+
+/*
+ * rwlock_DemoteLock()
+ */
+NSAPI_PUBLIC void rwlock_DemoteLock(RWLOCK lock);
+
+/*
+ * rwlock_terminate removes a previously allocated RWLOCK variable.
+ */
+NSAPI_PUBLIC void rwlock_Terminate(RWLOCK lock);
+
+NSPR_END_EXTERN_C
+
+#endif /* _BASE_RWLOCK_H_ */

+ 114 - 0
include/base/shexp.h

@@ -0,0 +1,114 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef BASE_SHEXP_H
+#define BASE_SHEXP_H
+
+#ifndef NOINTNSAPI
+#define INTNSAPI
+#endif /* !NOINTNSAPI */
+
+/*
+ * shexp.h: Defines and prototypes for shell exp. match routines
+ * 
+ *
+ * This routine will match a string with a shell expression. The expressions
+ * accepted are based loosely on the expressions accepted by zsh.
+ * 
+ * o * matches anything
+ * o ? matches one character
+ * o \ will escape a special character
+ * o $ matches the end of the string
+ * o [abc] matches one occurence of a, b, or c. The only character that needs
+ *         to be escaped in this is ], all others are not special.
+ * o [a-z] matches any character between a and z
+ * o [^az] matches any character except a or z
+ * o ~ followed by another shell expression will remove any pattern
+ *     matching the shell expression from the match list
+ * o (foo|bar) will match either the substring foo, or the substring bar.
+ *             These can be shell expressions as well.
+ * 
+ * The public interface to these routines is documented in
+ * public/base/shexp.h.
+ * 
+ * Rob McCool
+ * 
+ */
+
+/*
+ * Requires that the macro MALLOC be set to a "safe" malloc that will 
+ * exit if no memory is available. If not under MCC httpd, define MALLOC
+ * to be the real malloc and play with fire, or make your own function.
+ */
+
+#ifndef NETSITE_H
+#include "../netsite.h"
+#endif /* !NETSITE_H */
+
+#ifndef OS_CTYPE_H
+#include <ctype.h>  /* isalnum */
+#define OS_CTYPE_H
+#endif /* !OS_CTYPE_H */
+
+#ifndef OS_STRING_H
+#include <string.h> /* strlen */
+#define OS_STRING_H
+#endif /* !OS_STRING_H */
+
+/* See public/base/shexp.h or public/base/regexp.h concerning USE_REGEX */
+
+/*
+ * This little bit of nonsense is because USE_REGEX is currently
+ * supposed to be recognized only by the proxy.  If that's the
+ * case, only the proxy should define USE_REGEX, but I'm playing
+ * it safe.  XXXHEP 12/96
+ */
+#ifndef MCC_PROXY
+#ifdef USE_REGEX
+#define SAVED_USE_REGEX USE_REGEX
+#undef USE_REGEX
+#endif /* USE_REGEX */
+#endif /* !MCC_PROXY */
+
+#ifndef PUBLIC_BASE_SHEXP_H
+#include "public/base/shexp.h"
+#endif /* !PUBLIC_BASE_SHEXP_H */
+
+/* --- Begin function prototypes --- */
+
+#ifdef INTNSAPI
+
+NSPR_BEGIN_EXTERN_C
+
+NSAPI_PUBLIC int INTshexp_valid(char *exp);
+
+NSAPI_PUBLIC int INTshexp_match(char *str, char *exp);
+
+NSAPI_PUBLIC int INTshexp_cmp(char *str, char *exp);
+
+NSAPI_PUBLIC int INTshexp_casecmp(char *str, char *exp);
+
+NSPR_END_EXTERN_C
+
+/* --- End function prototypes --- */
+
+#define shexp_valid INTshexp_valid
+#define shexp_match INTshexp_match
+#define shexp_cmp INTshexp_cmp
+#define shexp_casecmp INTshexp_casecmp
+
+#endif /* INTNSAPI */
+
+/* Restore USE_REGEX definition for non-proxy.  See above. */
+#ifdef SAVED_USE_REGEX
+#define USE_REGEX SAVED_USE_REGEX
+#undef SAVED_USE_REGEX
+#endif /* SAVED_USE_REGEX */
+
+#ifdef USE_REGEX
+#include "base/regexp.h"
+#endif /* USE_REGEX */
+
+#endif /* !BASE_SHEXP_H */

+ 565 - 0
include/base/systems.h

@@ -0,0 +1,565 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef BASE_SYSTEMS_H
+#define BASE_SYSTEMS_H
+
+#ifndef NOINTNSAPI
+#define INTNSAPI
+#endif /* !NOINTNSAPI */
+
+/*
+ * systems.h: Lists of defines for systems
+ * 
+ * This sets what general flavor the system is (UNIX, etc.), 
+ * and defines what extra functions your particular system needs.
+ */
+
+
+/* --- Begin common definitions for all supported platforms --- */
+
+#define DAEMON_ANY
+#define DAEMON_STATS
+
+/* --- End common definitions for all supported platforms --- */
+
+/* --- Begin platform-specific definitions --- */
+
+#if defined(AIX)
+
+#define ACCELERATOR_CACHE
+#define AUTH_DBM
+#define BSD_RLIMIT
+#undef BSD_SIGNALS
+/* AIX can handle really big shoes */
+#define DAEMON_LISTEN_SIZE 4096
+#define DAEMON_NEEDS_SEMAPHORE
+#define DAEMON_UNIX_MOBRULE
+#define DLL_CAPABLE
+#define DLL_DLOPEN
+#define DLL_DLOPEN_FLAGS RTLD_NOW|RTLD_GLOBAL
+#define DNS_CACHE
+#define FILE_INHERIT_FCNTL
+#define FILE_MMAP_FLAGS MAP_SHARED
+#define HAS_STATFS
+#define HAVE_ATEXIT
+#define HAVE_PW_R /* reent passwd routines */
+#define HAVE_STRERROR_R
+#define HAVE_STRTOK_R
+#define HAVE_TIME_R 2 /* arg count */
+#define HAVE_STRFTIME /* no cftime */
+#define JAVA_STATIC_LINK
+#undef NEED_CRYPT_H
+#define NEED_SETEID_PROTO /* setegid, seteuid */
+#define NEED_STRINGS_H /* for strcasecmp */
+#define NET_SOCKETS
+#define SA_HANDLER_T(x) (void (*)(int))x
+#if OSVERSION < 4210
+#define SA_NOCLDWAIT 0 /* AIX < 4.2 don't got this */
+#endif /* OSVERSION < 4210 */
+#define SHMEM_MMAP_FLAGS MAP_SHARED
+#ifdef HW_THREADS
+#define THREAD_ANY
+#endif
+
+#elif defined(BSDI)
+
+#define ACCELERATOR_CACHE
+#define AUTH_DBM
+#define BSD_MAIL
+#define BSD_RLIMIT
+#define BSD_SIGNALS
+#define BSD_TIME
+#define DAEMON_UNIX_MOBRULE
+#define DNS_CACHE
+#define FILE_INHERIT_FCNTL
+#define FILE_MMAP_FLAGS (MAP_FILE | MAP_SHARED)
+#define HAS_STATFS
+#define HAVE_ATEXIT
+#undef NEED_CRYPT_PROTO
+#define NET_SOCKETS
+#ifndef NO_DOMAINNAME
+#define NO_DOMAINNAME
+#endif
+#define SHMEM_MMAP_FLAGS MAP_SHARED
+#define JAVA_STATIC_LINK
+
+#elif defined(HPUX)
+
+#define ACCELERATOR_CACHE
+#define AUTH_DBM
+#undef BSD_RLIMIT
+#undef BSD_SIGNALS
+#ifdef MCC_PROXY
+#define DAEMON_NEEDS_SEMAPHORE
+#else
+#undef DAEMON_NEEDS_SEMAPHORE
+#endif
+#define DAEMON_UNIX_MOBRULE
+#define DLL_CAPABLE
+#define DLL_HPSHL
+#define DNS_CACHE
+#define FILE_INHERIT_FCNTL
+#define FILE_MMAP_FLAGS MAP_PRIVATE
+#define HAS_STATFS
+#define HAVE_ATEXIT
+#define HAVE_STRFTIME
+#define JAVA_STATIC_LINK
+#undef NEED_CRYPT_H
+#define NET_SOCKETS
+#define SA_HANDLER_T(x) (void (*)(int))x
+/* warning: mmap doesn't work under 9.04 */
+#define SHMEM_MMAP_FLAGS MAP_FILE | MAP_VARIABLE | MAP_SHARED
+
+#elif defined (IRIX)
+
+#define ACCELERATOR_CACHE
+#define AUTH_DBM
+#define BSD_RLIMIT
+#undef BSD_SIGNALS
+#define DAEMON_UNIX_MOBRULE
+#define DLL_CAPABLE
+#define DLL_DLOPEN
+#define DLL_DLOPEN_FLAGS RTLD_NOW
+#define DNS_CACHE
+#define FILE_INHERIT_FCNTL
+#define FILE_MMAP_FLAGS MAP_SHARED
+#define HAS_STATVFS
+#define HAVE_ATEXIT
+#define HAVE_STRTOK_R
+#ifdef IRIX
+#define HAVE_TIME_R 2 /* arg count */
+#else
+#define HAVE_TIME_R 3 /* arg count */
+#define NEED_SETEID_PROTO /* setegid, seteuid */
+#endif
+#define JAVA_STATIC_LINK
+#define NEED_CRYPT_H
+#define NET_SOCKETS
+#define SA_HANDLER_T(x) (void (*)(int))x
+#define SHMEM_MMAP_FLAGS MAP_SHARED
+#define THROW_HACK throw()
+
+#elif defined(NCR)
+
+#define ACCELERATOR_CACHE
+#define AUTH_DBM
+#undef BSD_RLIMIT
+/* #define DAEMON_NEEDS_SEMAPHORE */
+#define DAEMON_UNIX_MOBRULE
+#define DLL_CAPABLE
+#define DLL_DLOPEN
+#define DLL_DLOPEN_FLAGS RTLD_NOW
+#define DNS_CACHE
+#define FILE_INHERIT_FCNTL
+#define FILE_MMAP_FLAGS MAP_SHARED
+#define HAS_STATVFS
+#define HAVE_ATEXIT
+#define HAVE_STRTOK_R
+#define JAVA_STATIC_LINK
+#define NEED_CRYPT_H
+#define NEED_FILIO
+#define NEED_GHN_PROTO
+#define NET_SOCKETS
+#define SHMEM_MMAP_FLAGS MAP_SHARED
+
+#elif defined(NEC)
+
+#define ACCELERATOR_CACHE
+#define DNS_CACHE
+#define AUTH_DBM
+#undef BSD_RLIMIT
+#define DAEMON_NEEDS_SEMAPHORE
+#define DAEMON_UNIX_MOBRULE
+#define DLL_DLOPEN
+#define DLL_DLOPEN_FLAGS RTLD_NOW
+#define DLL_CAPABLE
+#define FILE_INHERIT_FCNTL
+#define FILE_MMAP_FLAGS MAP_SHARED
+#define HAS_STATVFS
+#define HAVE_ATEXIT
+#define HAVE_STRTOK_R
+#define HAVE_TIME_R 2 /* arg count */
+#define JAVA_STATIC_LINK
+#define NEED_CRYPT_H
+#define NEED_FILIO
+#define NET_SOCKETS
+#define SHMEM_MMAP_FLAGS MAP_SHARED
+
+#elif defined(OSF1)
+
+#define ACCELERATOR_CACHE
+#define AUTH_DBM
+#define BSD_RLIMIT
+#undef BSD_SIGNALS
+#define BSD_TIME
+#define DAEMON_NEEDS_SEMAPHORE
+#define DAEMON_UNIX_MOBRULE
+#define DLL_CAPABLE
+#define DLL_DLOPEN
+#define DLL_DLOPEN_FLAGS RTLD_NOW
+#define DNS_CACHE
+#define FILE_INHERIT_FCNTL
+#define FILE_MMAP_FLAGS MAP_SHARED
+#define HAVE_ATEXIT
+#define HAVE_STRFTIME /* no cftime */
+#define HAVE_TIME_R 2 /* ctime_r arg count */
+#define NET_SOCKETS
+#define SA_HANDLER_T(x) (void (*)(int))x
+#define SHMEM_MMAP_FLAGS MAP_SHARED
+
+#elif defined(SCO)
+
+#define ACCELERATOR_CACHE
+#define AUTH_DBM
+#undef BSD_RLIMIT
+#undef BSD_SIGNALS
+#define DAEMON_NEEDS_SEMAPHORE
+#define DAEMON_UNIX_MOBRULE
+#define DLL_CAPABLE
+#define DLL_DLOPEN
+#define DLL_DLOPEN_FLAGS RTLD_NOW
+#define DNS_CACHE
+#define FILE_INHERIT_FCNTL
+#define FILE_MMAP_FLAGS MAP_SHARED
+#define HAS_STATVFS
+#define HAVE_ATEXIT
+#undef NEED_CRYPT_H
+#undef NEED_FILIO
+#undef NEED_GHN_PROTO
+#undef NEED_SETEID_PROTO /* setegid, seteuid */
+#define NET_SOCKETS
+#define SHMEM_MMAP_FLAGS MAP_SHARED
+#define SA_HANDLER_T(x) (void (*)(int))x
+
+
+#elif defined(SNI)
+
+#define ACCELERATOR_CACHE
+#define AUTH_DBM
+#undef BSD_RLIMIT
+#define DAEMON_NEEDS_SEMAPHORE
+#define DAEMON_UNIX_MOBRULE
+#define DLL_CAPABLE
+#define DLL_DLOPEN
+#define DLL_DLOPEN_FLAGS RTLD_NOW
+#define DNS_CACHE
+#define FILE_INHERIT_FCNTL
+#define FILE_MMAP_FLAGS MAP_SHARED
+#define HAS_STATVFS
+#define HAVE_ATEXIT
+#define JAVA_STATIC_LINK
+#define NEED_CRYPT_H
+#define NEED_FILIO
+#define NEED_SETEID_PROTO /* setegid, seteuid */
+#define NET_SOCKETS
+#define SHMEM_MMAP_FLAGS MAP_SHARED
+#define TCPLEN_T size_t
+#define USE_PIPE
+/*
+ * define this if your C++ platform has separate inline functions for
+ * e.g. const char *strchr(const char *, char)
+ *  and
+ *      char *strchr(char *, char)
+ * and your compiler complains about this:
+ * func(const char *bla)
+ * {
+ *     char *fasel = strchr(bla, '.');
+ * ....
+ * because it says that you cannot initialize a char * with a const char *
+ */
+#define HAS_CONSTVALUED_STRFUNCS
+
+/* hack for C++ platforms where bool is a keyword */
+#ifndef boolean
+#define boolean boolean
+#endif
+
+#elif defined(Linux)
+
+#define ACCELERATOR_CACHE
+#define DNS_CACHE
+#define FILE_INHERIT_FCNTL
+#define DAEMON_UNIX_MOBRULE
+#define BSD_RLIMIT
+#undef BSD_SIGNALS
+#define FILE_UNIX_MMAP
+#define FILE_MMAP_FLAGS (MAP_FILE | MAP_SHARED)
+#define SHMEM_UNIX_MMAP
+#define SHMEM_MMAP_FLAGS MAP_SHARED
+#define AUTH_DBM
+#define SEM_FLOCK
+#define DLL_CAPABLE
+#define DLL_DLOPEN
+#define DLL_DLOPEN_FLAGS RTLD_NOW
+#define HAVE_ATEXIT
+#define HAS_STATFS
+#define JAVA_STATIC_LINK
+#define SA_HANDLER_T(x) (void (*)(int))(x)
+#define SA_NOCLDWAIT 0 /* Linux doesn't have this */
+#define TCPLEN_T size_t
+
+#undef NEED_CRYPT_PROTO
+#define NET_SOCKETS
+#ifndef NO_DOMAINNAME
+#define NO_DOMAINNAME
+#endif
+#elif defined(SOLARIS) || defined(SOLARISx86)
+
+#define ACCELERATOR_CACHE
+#define AUTH_DBM
+#define BSD_RLIMIT
+#undef BSD_SIGNALS
+#define DAEMON_NEEDS_SEMAPHORE
+#define DAEMON_UNIX_MOBRULE
+#define DLL_CAPABLE
+#define DLL_DLOPEN
+#define DLL_DLOPEN_FLAGS RTLD_NOW
+#define DNS_CACHE
+#define FILE_INHERIT_FCNTL
+#define FILE_MMAP_FLAGS MAP_SHARED
+#define HAS_STATVFS
+#define HAVE_ATEXIT
+#define HAVE_PW_R
+#define HAVE_STRTOK_R
+#define HAVE_TIME_R 3 /* arg count */
+#define NEED_CRYPT_H
+#define NEED_FILIO
+#if OSVERSION < 506 || OSVERSION == 50501
+#define NEED_GHN_PROTO
+#endif
+#define NET_SOCKETS
+#if OSVERSION > 504 
+#define SA_HANDLER_T(x) x 
+#endif
+#define SHMEM_MMAP_FLAGS MAP_SHARED
+
+#elif defined (SONY)
+
+#define AUTH_DBM
+#undef BSD_RLIMIT
+#define DAEMON_NEEDS_SEMAPHORE
+#define DAEMON_UNIX_MOBRULE
+#define DLL_CAPABLE
+#define FILE_INHERIT_FCNTL
+#define FILE_MMAP_FLAGS MAP_SHARED
+#define HAVE_ATEXIT
+#define NEED_CRYPT_H
+#define NEED_FILIO
+#define NET_SOCKETS
+#define SHMEM_MMAP_FLAGS MAP_SHARED
+
+#elif defined(SUNOS4)
+
+#define ACCELERATOR_CACHE
+#define AUTH_DBM
+#define BSD_MAIL
+#define BSD_RLIMIT
+#define BSD_SIGNALS
+#define BSD_TIME
+#define DAEMON_UNIX_MOBRULE
+#define DLL_CAPABLE
+#define DLL_DLOPEN
+#define DLL_DLOPEN_FLAGS 1
+#define DNS_CACHE
+#define FILE_INHERIT_FCNTL
+#define FILE_MMAP_FLAGS MAP_SHARED
+#define HAS_STATFS
+#undef HAVE_ATEXIT
+#undef NEED_CRYPT_H
+#define NEED_CRYPT_PROTO
+#define NEED_FILIO
+#define NET_SOCKETS
+#define SHMEM_MMAP_FLAGS MAP_SHARED
+
+#elif defined(UNIXWARE) || defined(UnixWare)
+
+#define ACCELERATOR_CACHE
+#define AUTH_DBM
+#undef BSD_RLIMIT
+#define DAEMON_UNIX_MOBRULE
+#define DLL_CAPABLE
+#define DLL_DLOPEN
+#define DLL_DLOPEN_FLAGS RTLD_NOW
+#define DNS_CACHE
+#define FILE_INHERIT_FCNTL
+#define FILE_MMAP_FLAGS MAP_SHARED
+#define HAS_STATVFS
+#define HAVE_ATEXIT
+#define NEED_CRYPT_H
+#define NEED_FILIO
+#define NEED_GHN_PROTO
+#define NEED_SETEID_PROTO /* setegid, seteuid */
+#define NET_SOCKETS
+#define SHMEM_MMAP_FLAGS MAP_SHARED
+
+#ifndef boolean
+#define boolean boolean
+#endif
+
+#if defined (UnixWare)
+/* UnixWare but not UNIXWARE... */
+#define NEED_STRINGS_H /* for strcasecmp */
+#define SA_HANDLER_T(x) (void (*)(int))x
+#endif
+
+#elif defined (XP_WIN32)      /* Windows NT */
+
+#include <wtypes.h>
+#include <winbase.h>
+
+typedef void* PASSWD;
+
+#define ACCELERATOR_CACHE
+#define AUTH_DBM
+/* size has been raised to 200 with NT 4.0 server; NT 4.0 workstation is still
+ * limited
+ */
+#define DAEMON_LISTEN_SIZE 200
+#define DAEMON_WIN32
+#define DLL_CAPABLE
+#define DLL_WIN32
+#define DNS_CACHE
+#define LOG_BUFFERING
+#define HAVE_STRFTIME /* no cftime */
+#define NEED_CRYPT_PROTO
+#define NEEDS_WRITEV
+#define NET_SOCKETS
+#ifndef NO_DOMAINNAME
+#define NO_DOMAINNAME
+#endif
+#ifdef BUILD_DLL
+#define NSAPI_PUBLIC __declspec(dllexport)
+#else
+#define NSAPI_PUBLIC
+#endif /* BUILD_DLL */
+#define THREAD_ANY
+#define THREAD_NSPR_KERNEL
+#define USE_NSPR
+#define USE_STRFTIME /* no cftime */
+
+#else
+
+#error "Missing defines in ns/netsite/include/base/systems.h"
+
+#endif	/* Windows NT */
+
+/* Pick up the configuration symbols in the public interface */
+#ifndef PUBLIC_BASE_SYSTEMS_H
+#include "public/base/systems.h"
+#endif /* PUBLIC_BASE_SYSTEMS_H */
+
+/* --- Begin defaults for values not defined above --- */
+
+#ifndef DAEMON_LISTEN_SIZE
+#define DAEMON_LISTEN_SIZE 128
+#endif /* !DAEMON_LISTEN_SIZE */
+
+#ifndef SA_HANDLER_T
+#define SA_HANDLER_T(x) (void (*)())x 
+#endif
+
+#ifdef HAS_CONSTVALUED_STRFUNCS
+#define CONSTVALSTRCAST (char *)
+#else
+#define CONSTVALSTRCAST
+#endif
+
+#ifndef TCPLEN_T
+#define TCPLEN_T int
+#endif
+
+#ifndef THROW_HACK
+#define THROW_HACK /* as nothing */
+#endif
+
+
+/* --- End defaults for values not defined above --- */
+
+/* --- Begin the great debate --- */
+
+/* NS_MAIL builds sec-key.c which calls systhread_init, which requires */
+/* that USE_NSPR is defined when systhr.c is compiled.  --lachman */
+/* MCC_PROXY does the same thing now --nbreslow -- LIKE HELL --ari */
+#if (defined(MCC_HTTPD) || defined(MCC_ADMSERV) || defined(MCC_PROXY) || defined(NS_MAIL)) && defined(XP_UNIX)
+#define USE_NSPR
+/* XXXrobm This is UNIX-only for the moment */
+#define LOG_BUFFERING
+#ifdef SW_THREADS
+#define THREAD_NSPR_USER
+#else
+#define THREAD_NSPR_KERNEL
+#ifdef IRIX 
+#undef SEM_FLOCK
+#define SEM_IRIX
+#endif 
+#endif
+#define THREAD_ANY
+#endif
+
+/* --- End the great debate --- */
+
+#ifndef APSTUDIO_READONLY_SYMBOLS
+
+#ifndef NSPR_PRIO_H
+#include <prio.h>
+#define NSPR_PRIO_H
+#endif /* !NSPR_PRIO_H */
+
+/*
+ * These types have to be defined early, because they are defined
+ * as (void *) in the public API.
+ */
+
+#ifndef SYS_FILE_T
+typedef PRFileDesc *SYS_FILE;
+#define SYS_FILE_T PRFileDesc *
+#endif /* !SYS_FILE_T */
+
+#ifndef SYS_NETFD_T
+typedef PRFileDesc *SYS_NETFD;
+#define SYS_NETFD_T PRFileDesc *
+#endif /* !SYS_NETFD_T */
+
+#ifdef SEM_WIN32
+
+typedef HANDLE SEMAPHORE;
+#define SEMAPHORE_T HANDLE
+#define SEM_ERROR NULL
+/* That oughta hold them (I hope) */
+#define SEM_MAXVALUE 32767
+
+#elif defined(SEM_IRIX)
+
+#ifndef OS_ULOCKS_H
+#include <ulocks.h>
+#define OS_ULOCKS_H
+#endif /* !OS_ULOCKS_H */
+
+typedef struct {
+    usptr_t *arena;
+    usema_t *sem;
+} semirix_s;
+typedef semirix_s* SEMAPHORE;
+#define SEMAPHORE_T semirix_s *
+#define SEM_ERROR NULL
+
+#elif defined(SEM_FLOCK)
+
+#define SEMAPHORE_T SYS_FILE
+typedef SYS_FILE SEMAPHORE;
+#define SEM_ERROR NULL
+
+#else /* ! SEM_WIN32, !SEM_IRIX */
+
+typedef int SEMAPHORE;
+#define SEMAPHORE_T int
+#define SEM_ERROR -1
+
+#endif /* SEM_WIN32 */
+
+#endif /* !APSTUDIO_READONLY_SYMBOLS */
+
+#endif /* BASE_SYSTEMS_H */

+ 91 - 0
include/base/systhr.h

@@ -0,0 +1,91 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef BASE_SYSTHR_H
+#define BASE_SYSTHR_H
+
+#ifndef NOINTNSAPI
+#define INTNSAPI
+#endif /* !NOINTNSAPI */
+
+/*
+ * systhr.h: Abstracted threading mechanisms
+ * 
+ * Rob McCool
+ */
+
+#ifndef NETSITE_H
+#include "netsite.h"
+#endif /* !NETSITE_H */
+
+#ifdef THREAD_ANY
+
+#ifndef PUBLIC_BASE_SYSTHR_H
+#include "public/base/systhr.h"
+#endif /* !PUBLIC_BASE_SYSTHR_H */
+
+/* --- Begin function prototypes --- */
+
+#ifdef INTNSAPI
+
+NSPR_BEGIN_EXTERN_C
+
+#ifdef UnixWare
+typedef void(*ArgFn_systhread_start)(void *);
+NSAPI_PUBLIC
+SYS_THREAD INTsysthread_start( int prio, int stksz, \
+                              ArgFn_systhread_start, void *arg);
+#else
+NSAPI_PUBLIC
+SYS_THREAD INTsysthread_start(int prio, int stksz, void (*fn)(void *), void *arg);
+#endif
+
+NSAPI_PUBLIC SYS_THREAD INTsysthread_current(void);
+
+NSAPI_PUBLIC void INTsysthread_yield(void);
+
+NSAPI_PUBLIC SYS_THREAD INTsysthread_attach(void);
+
+NSAPI_PUBLIC void INTsysthread_detach(SYS_THREAD thr);
+
+NSAPI_PUBLIC void INTsysthread_terminate(SYS_THREAD thr);
+
+NSAPI_PUBLIC void INTsysthread_sleep(int milliseconds);
+
+NSAPI_PUBLIC void INTsysthread_init(char *name);
+
+NSAPI_PUBLIC void INTsysthread_timerset(int usec);
+
+NSAPI_PUBLIC int INTsysthread_newkey(void);
+
+NSAPI_PUBLIC void *INTsysthread_getdata(int key);
+
+NSAPI_PUBLIC void INTsysthread_setdata(int key, void *data);
+
+NSAPI_PUBLIC 
+void INTsysthread_set_default_stacksize(unsigned long size);
+
+NSPR_END_EXTERN_C
+
+/* --- End function prototypes --- */
+#define systhread_start INTsysthread_start
+#define systhread_current INTsysthread_current
+#define systhread_yield INTsysthread_yield
+#define systhread_attach INTsysthread_attach
+#define systhread_detach INTsysthread_detach
+#define systhread_terminate INTsysthread_terminate
+#define systhread_sleep INTsysthread_sleep
+#define systhread_init INTsysthread_init
+#define systhread_timerset INTsysthread_timerset
+#define systhread_newkey INTsysthread_newkey
+#define systhread_getdata INTsysthread_getdata
+#define systhread_setdata INTsysthread_setdata
+#define systhread_set_default_stacksize INTsysthread_set_default_stacksize
+
+#endif /* INTNSAPI */
+
+#endif /* THREAD_ANY */
+
+#endif /* !BASE_SYSTHR_H */

+ 210 - 0
include/base/util.h

@@ -0,0 +1,210 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef BASE_UTIL_H
+#define BASE_UTIL_H
+
+#ifndef NOINTNSAPI
+#define INTNSAPI
+#endif /* !NOINTNSAPI */
+
+/*
+ * util.h: A hodge podge of utility functions and standard functions which 
+ *         are unavailable on certain systems
+ * 
+ * Rob McCool
+ */
+
+/* Needed for various reentrant functions */
+#define DEF_CTIMEBUF 26
+#define DEF_ERRBUF 256
+#define DEF_PWBUF 256
+
+#ifndef BASE_BUFFER_H
+#include "buffer.h"    /* filebuf for getline */
+#endif /* !BASE_BUFFER_H */
+
+#ifndef PUBLIC_BASE_UTIL_H
+#include "public/base/util.h"
+#endif /* !PUBLIC_BASE_UTIL_H */
+
+/* --- Begin common function prototypes --- */
+
+#ifdef INTNSAPI
+
+NSPR_BEGIN_EXTERN_C
+
+NSAPI_PUBLIC
+int INTutil_getline(filebuffer *buf, int lineno, int maxlen, char *l);
+
+NSAPI_PUBLIC char **INTutil_env_create(char **env, int n, int *pos);
+
+NSAPI_PUBLIC char *INTutil_env_str(char *name, char *value);
+
+NSAPI_PUBLIC void INTutil_env_replace(char **env, char *name, char *value);
+
+NSAPI_PUBLIC void INTutil_env_free(char **env);
+
+NSAPI_PUBLIC char **INTutil_env_copy(char **src, char **dst);
+
+NSAPI_PUBLIC char *INTutil_env_find(char **env, char *name);
+
+NSAPI_PUBLIC char *INTutil_hostname(void);
+
+NSAPI_PUBLIC int INTutil_chdir2path(char *path);
+
+NSAPI_PUBLIC int INTutil_is_mozilla(char *ua, char *major, char *minor);
+
+NSAPI_PUBLIC int INTutil_is_url(char *url);
+
+NSAPI_PUBLIC int INTutil_later_than(struct tm *lms, char *ims);
+
+NSAPI_PUBLIC int INTutil_time_equal(struct tm *lms, char *ims);
+
+NSAPI_PUBLIC int INTutil_str_time_equal(char *t1, char *t2);
+
+NSAPI_PUBLIC int INTutil_uri_is_evil(char *t);
+
+NSAPI_PUBLIC void INTutil_uri_parse(char *uri);
+
+NSAPI_PUBLIC void INTutil_uri_unescape(char *s);
+
+NSAPI_PUBLIC char *INTutil_uri_escape(char *d, char *s);
+
+NSAPI_PUBLIC char *INTutil_url_escape(char *d, char *s);
+
+NSAPI_PUBLIC char *INTutil_sh_escape(char *s);
+
+NSAPI_PUBLIC int INTutil_mime_separator(char *sep);
+
+NSAPI_PUBLIC int INTutil_itoa(int i, char *a);
+
+NSAPI_PUBLIC
+int INTutil_vsprintf(char *s, register const char *fmt, va_list args);
+
+NSAPI_PUBLIC int INTutil_sprintf(char *s, const char *fmt, ...);
+
+NSAPI_PUBLIC int INTutil_vsnprintf(char *s, int n, register const char *fmt, 
+                                  va_list args);
+
+NSAPI_PUBLIC int INTutil_snprintf(char *s, int n, const char *fmt, ...);
+
+NSAPI_PUBLIC int INTutil_strftime(char *s, const char *format, const struct tm *t);
+
+NSAPI_PUBLIC char *INTutil_strtok(char *s1, const char *s2, char **lasts);
+
+NSAPI_PUBLIC struct tm *INTutil_localtime(const time_t *clock, struct tm *res);
+
+NSAPI_PUBLIC char *INTutil_ctime(const time_t *clock, char *buf, int buflen);
+
+NSAPI_PUBLIC char *INTutil_strerror(int errnum, char *msg, int buflen);
+
+NSAPI_PUBLIC struct tm *INTutil_gmtime(const time_t *clock, struct tm *res);
+
+NSAPI_PUBLIC char *INTutil_asctime(const struct tm *tm,char *buf, int buflen);
+
+#ifdef NEED_STRCASECMP
+NSAPI_PUBLIC int INTutil_strcasecmp(CASECMPARG_T char *one, CASECMPARG_T char *two);
+#endif /* NEED_STRCASECMP */
+
+#ifdef NEED_STRNCASECMP
+NSAPI_PUBLIC int INTutil_strncasecmp(CASECMPARG_T char *one, CASECMPARG_T char *two, int n);
+#endif /* NEED_STRNCASECMP */
+
+/* --- End common function prototypes --- */
+
+/* --- Begin Unix-only function prototypes --- */
+
+#ifdef XP_UNIX
+
+NSAPI_PUBLIC int INTutil_can_exec(struct stat *finfo, uid_t uid, gid_t gid);
+
+NSAPI_PUBLIC
+struct passwd *INTutil_getpwnam(const char *name, struct passwd *result,
+                               char *buffer,  int buflen);
+
+NSAPI_PUBLIC pid_t INTutil_waitpid(pid_t pid, int *statptr, int options);
+
+#endif /* XP_UNIX */
+
+/* --- End Unix-only function prototypes --- */
+
+/* --- Begin Windows-only function prototypes --- */
+
+#ifdef XP_WIN32
+
+NSAPI_PUBLIC
+VOID INTutil_delete_directory(char *FileName, BOOL delete_directory);
+
+#endif /* XP_WIN32 */
+
+/* --- End Windows-only function prototypes --- */
+
+NSPR_END_EXTERN_C
+
+#define util_getline INTutil_getline
+#define util_env_create INTutil_env_create
+#define util_env_str INTutil_env_str
+#define util_env_replace INTutil_env_replace
+#define util_env_free INTutil_env_free
+#define util_env_copy INTutil_env_copy
+#define util_env_find INTutil_env_find
+#define util_hostname INTutil_hostname
+#define util_chdir2path INTutil_chdir2path
+#define util_is_mozilla INTutil_is_mozilla
+#define util_is_url INTutil_is_url
+#define util_later_than INTutil_later_than
+#define util_time_equal INTutil_time_equal
+#define util_str_time_equal INTutil_str_time_equal
+#define util_uri_is_evil INTutil_uri_is_evil
+#define util_uri_parse INTutil_uri_parse
+#define util_uri_unescape INTutil_uri_unescape
+#define util_uri_escape INTutil_uri_escape
+#define util_url_escape INTutil_url_escape
+#define util_sh_escape INTutil_sh_escape
+#define util_mime_separator INTutil_mime_separator
+#define util_itoa INTutil_itoa
+#define util_vsprintf INTutil_vsprintf
+#define util_sprintf INTutil_sprintf
+#define util_vsnprintf INTutil_vsnprintf
+#define util_snprintf INTutil_snprintf
+#define util_strftime INTutil_strftime
+#define util_strcasecmp INTutil_strcasecmp
+#define util_strncasecmp INTutil_strncasecmp
+#define util_strtok INTutil_strtok
+#define util_localtime INTutil_localtime
+#define util_ctime INTutil_ctime
+#define util_strerror INTutil_strerror
+#define util_gmtime INTutil_gmtime
+#define util_asctime INTutil_asctime
+
+#ifdef XP_UNIX
+#define util_can_exec INTutil_can_exec
+#define util_getpwnam INTutil_getpwnam
+#define util_waitpid INTutil_waitpid
+#endif /* XP_UNIX */
+
+#ifdef XP_WIN32
+#define util_delete_directory INTutil_delete_directory
+#endif /* XP_WIN32 */
+
+#ifdef NEED_STRCASECMP
+#define util_strcasecmp INTutil_strcasecmp
+#define strcasecmp INTutil_strcasecmp
+#endif /* NEED_STRCASECMP */
+
+#ifdef NEED_STRINGS_H /* usually for strcasecmp */
+#include <strings.h>
+#endif
+
+#ifdef NEED_STRNCASECMP
+#define util_strncasecmp INTutil_strncasecmp
+#define strncasecmp INTutil_strncasecmp
+#endif /* NEED_STRNCASECMP */
+
+#endif /* INTNSAPI */
+
+#endif /* !BASE_UTIL_H */
+

+ 6 - 0
include/copyrght.h

@@ -0,0 +1,6 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+

+ 245 - 0
include/i18n.h

@@ -0,0 +1,245 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+
+#ifndef I18N_H
+#define I18N_H
+
+/* Make NSAPI_PUBLIC available */
+#include "base/systems.h"
+#include "libadminutil/resource.h"
+
+typedef res_RESOURCE_TABLE RESOURCE_TABLE;
+typedef res_RESOURCE_GLOBAL RESOURCE_GLOBAL;
+
+/*******************************************************************************/
+
+/*
+ * In accordance with the recommendations in the 
+ * "Netscape Coding Standard for Server Internationalization",
+ * the following aliases are defined for fprintf, et al., and
+ * these aliases should be used to clearly indicate the intended
+ * destination for output.
+ */
+
+#define AdminFprintf  fprintf
+#define DebugFprintf  fprintf
+
+#define ClientSprintf sprintf
+#define AdminSprintf  sprintf
+#define DebugSprintf  sprintf
+
+#define ClientFputs   fputs
+#define AdminFputs    fputs
+#define DebugFputs    fputs
+
+/* more #define, as needed */
+
+/*******************************************************************************/
+
+/*
+ * Function prototypes for application and libraries
+ */
+
+
+#ifdef __cplusplus
+extern "C" 
+{
+#endif
+
+/***************************/
+/* XP_InitStringDatabase() */
+/***************************/
+
+NSAPI_PUBLIC
+void
+XP_InitStringDatabase(char* pathCWD, char* databaseName);
+
+/* Initialize the resource string database */
+
+/******************************/
+/* XP_GetStringFromDatabase() */
+/******************************/
+
+NSAPI_PUBLIC
+extern char*
+XP_GetStringFromDatabase(char* strLibraryName,
+                         char* strLanguage,
+                         int iToken);
+
+/* Given the LibraryName, Language and Token, extracts the string corresponding
+   to that library and token from the database in the language requested and
+   returns a pointer to the string.  Note: Use the macros XP_GetClientStr() and
+   XP_GetAdminStr() defined below to simplify source code. */
+
+/*****************/
+/* SetLanguage() */
+/*****************/
+enum
+{
+	CLIENT_LANGUAGE,
+	ADMIN_LANGUAGE,
+	DEFAULT_LANGUAGE
+};
+
+NSAPI_PUBLIC
+extern void
+SetLanguage(int type, char *language);
+
+/* Set language for Client, Admin and Default, XP_GetStringFromDatabase will
+   base on the setting to retrieve correct string for specific language */
+ 
+/***********************/
+/* GetClientLanguage() */
+/***********************/
+
+NSAPI_PUBLIC
+extern char*
+GetClientLanguage(void);
+
+/* Returns a pointer to a string with the name of the language requested by
+   the current client; intended to be passed to XP_GetStringFromDatabase()
+   and used by the front end macro XP_GetClientStr(). */
+
+/**********************/
+/* GetAdminLanguage() */
+/**********************/
+
+NSAPI_PUBLIC
+extern char*
+GetAdminLanguage(void);
+
+/* Returns a pointer to a string with the name of the language requested by
+   the administrator; intended to be passed to XP_GetStringFromDatabase()
+   and used by the front end macro XP_GetAdminStr(). */
+
+/************************/
+/* GetDefaultLanguage() */
+/************************/
+
+NSAPI_PUBLIC
+extern char*
+GetDefaultLanguage(void);
+
+/* Returns a pointer to a string with the name of the default language
+   for the installation from the configuration file. */
+
+/************************/
+/* GetFileForLanguage() */
+/************************/
+
+NSAPI_PUBLIC
+int
+GetFileForLanguage(char* filepath,char* language,char* existingFilepath);
+
+/* Looks for a file in the appropriate language.
+
+   Input: filePath,language
+   filePath is of the form "/xxx/xxx/$$LANGDIR/xxx/xxx/filename"
+            or of the form "/xxx/xxx/xxx/xxx/filename".
+   filename may or may not have an extension.
+   language is an Accept-Language list; each language-range will be
+     tried as a subdirectory name and possibly as a filename modifier.
+     "*" is ignored - default always provided if needed.
+     "-" is replaced by "_".
+   $$LANGDIR is a special string replaced by language. It is optional.
+     For the default case, $$LANGDIR/ is replaced by nothing
+     (so // is not created).
+   
+   Returned: existingPath
+   existingFilePath is the path of a satisfactory, existing file.
+   if no file is found, an empty string "" is returned.
+   
+   int returned: -1 if no file found (existingFilePath = "")
+                  0 if default file is returned
+                  1 if language file is returned (any in list) */
+
+/********************/
+/* XP_AccLangList() */
+/********************/
+
+#define MAX_ACCEPT_LANGUAGE 16
+#define MAX_ACCEPT_LENGTH 18
+
+typedef char ACCEPT_LANGUAGE_LIST[MAX_ACCEPT_LANGUAGE][MAX_ACCEPT_LENGTH];
+
+NSAPI_PUBLIC
+int
+XP_AccLangList(char* AcceptLanguage,
+               ACCEPT_LANGUAGE_LIST AcceptLanguageList);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+/*******************************************************************************/
+
+/*
+ * Function prototypes for building string database
+ */
+
+extern int XP_MakeStringDatabase(void);
+
+/* Used to create the string database at build time; not used by the application
+   itself.  Returns 0 is successful. */
+
+extern void XP_PrintStringDatabase(void);
+
+/* DEBUG: Prints out entire string database to standard output. */
+
+/*******************************************************************************/
+
+/*
+ * Macros to simplify calls to XP_GetStringFromDatabase
+ * (need one argument instead of three)
+ */
+
+#define XP_GetClientStr(DBTTokenName)                  \
+        XP_GetStringFromDatabase(LIBRARY_NAME,         \
+                                 GetClientLanguage(),  \
+                                 DBTTokenName)
+
+#define XP_GetAdminStr(DBTTokenName)                   \
+        XP_GetStringFromDatabase(LIBRARY_NAME,         \
+                                 "en",   \
+                                 DBTTokenName)
+
+/*******************************************************************************/
+
+
+/*******************************************************************************/
+
+/*
+ * Define the ResDef macro to simplify the maintenance of strings which are to
+ * be added to the library or application header file (dbtxxx.h). This enables
+ * source code to refer to the strings by theit TokenNames, and allows the
+ * strings to be stored in the database.
+ *
+ * Usage:   ResDef(TokenName,TokenValue,String)
+ *
+ * Example: ResDef(DBT_HelloWorld_, \
+ *                 1,"Hello, World!")
+ *          ResDef(DBT_TheCowJumpedOverTheMoon_, \
+ *                 2,"The cow jumped over the moon.")
+ *          ResDef(DBT_TheValueOfPiIsAbout31415926536_, \
+ *                 3,"The value of PI is about 3.1415926536."
+ *
+ * RESOURCE_STR is used by makstrdb.c only.  It is not used by getstrdb.c or
+ * in library or application source code.
+ */
+ 
+#if 0
+#define BEGIN_STR(argLibraryName) \
+                          enum {
+#define ResDef(argToken,argID,argString) \
+                          argToken = argID,
+#define END_STR(argLibraryName) \
+                          argLibraryName ## top };
+
+#endif
+/*******************************************************************************/
+
+#endif

+ 27 - 0
include/ldaputil/cert.h

@@ -0,0 +1,27 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef _LDAPU_CERT_H
+#define _LDAPU_CERT_H
+
+#ifndef NSAPI_PUBLIC
+#ifdef XP_WIN32
+#define NSAPI_PUBLIC __declspec(dllexport)
+#else
+#define NSAPI_PUBLIC 
+#endif
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+NSAPI_PUBLIC int ldapu_get_cert (void *SSLendpoint, void **cert);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _LDAPU_CERT_H */

+ 124 - 0
include/ldaputil/certmap.h

@@ -0,0 +1,124 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef _LDAPU_CERTMAP_H
+#define _LDAPU_CERTMAP_H
+
+#ifndef INTLDAPU
+#define INTLDAPU
+#endif /* INTLDAPU */
+
+#include "extcmap.h"
+
+enum {
+    LDAPU_STR_FILTER_DEFAULT,
+    LDAPU_STR_FILTER_USER,
+    LDAPU_STR_FILTER_GROUP,
+    LDAPU_STR_FILTER_MEMBER,
+    LDAPU_STR_FILTER_MEMBER_RECURSE,
+    LDAPU_STR_ATTR_USER,
+    LDAPU_STR_ATTR_CERT,
+    LDAPU_STR_ATTR_CERT_NOSUBTYPE,
+    LDAPU_STR_MAX_INDEX
+};
+
+static char *ldapu_strings[] = {
+    "objectclass=*",		/* LDAPU_STR_DEFAULT */
+    "uid=%s",			/* LDAPU_STR_FILTER_USER */
+    "(& (cn=%s) (| (objectclass=groupofuniquenames) (objectclass=groupofnames)))", /* LDAPU_STR_FILTER_GROUP */
+    "(| (uniquemember=%s) (member=%s))",	/* LDAPU_STR_FILTER_MEMBER */
+    "(& %s (| (objectclass=groupofuniquenames) (objectclass=groupofnames))", /* LDAPU_STR_FILTER_MEMBER_RECURSE */
+    "uid",			/* LDAPU_STR_ATTR_USER */
+    "userCertificate;binary",	/* LDAPU_STR_ATTR_CERT */
+    "userCertificate"	/* LDAPU_STR_ATTR_CERT_NOSUBTYPE */
+};
+    
+typedef struct {
+    char *str;
+    int size;
+    int len;
+} LDAPUStr_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+NSAPI_PUBLIC int ldapu_cert_to_ldap_entry (void *cert, LDAP *ld,
+					   const char *basedn,
+					   LDAPMessage **res);
+
+NSAPI_PUBLIC int ldapu_set_cert_mapfn (const char *issuerDN,
+				       CertMapFn_t mapfn);
+
+
+NSAPI_PUBLIC CertMapFn_t ldapu_get_cert_mapfn (const char *issuerDN);
+
+NSAPI_PUBLIC int ldapu_set_cert_searchfn (const char *issuerDN,
+					  CertSearchFn_t searchfn);
+
+
+NSAPI_PUBLIC CertSearchFn_t ldapu_get_cert_searchfn (const char *issuerDN);
+
+NSAPI_PUBLIC int ldapu_set_cert_verifyfn (const char *issuerDN,
+					  CertVerifyFn_t verifyFn);
+
+NSAPI_PUBLIC CertVerifyFn_t ldapu_get_cert_verifyfn (const char *issuerDN);
+
+
+NSAPI_PUBLIC int ldapu_get_cert_subject_dn (void *cert, char **subjectDN);
+
+
+NSAPI_PUBLIC int ldapu_get_cert_issuer_dn (void *cert, char **issuerDN);
+
+
+NSAPI_PUBLIC int ldapu_get_cert_ava_val (void *cert, int which_dn,
+					 const char *attr, char ***val);
+
+
+NSAPI_PUBLIC int ldapu_free_cert_ava_val (char **val);
+
+
+NSAPI_PUBLIC int ldapu_get_cert_der (void *cert, unsigned char **derCert,
+				     unsigned int *len);
+
+
+NSAPI_PUBLIC int ldapu_issuer_certinfo (const char *issuerDN,
+					void **certmap_info);
+
+
+NSAPI_PUBLIC int ldapu_certmap_info_attrval (void *certmap_info,
+					     const char *attr, char **val);
+
+
+NSAPI_PUBLIC char *ldapu_err2string (int err);
+
+/* Keep the old fn for backward compatibility */
+NSAPI_PUBLIC void ldapu_free_old (char *ptr);
+
+
+NSAPI_PUBLIC void *ldapu_malloc (int size);
+
+
+NSAPI_PUBLIC char *ldapu_strdup (const char *ptr);
+
+
+NSAPI_PUBLIC void *ldapu_realloc (void *ptr, int size);
+
+
+NSAPI_PUBLIC void ldapu_free (void *ptr);
+
+
+NSAPI_PUBLIC int ldapu_string_set (const int type, const char *filter);
+
+
+NSAPI_PUBLIC const char *ldapu_string_get (const int type);
+
+NSAPI_PUBLIC int ldaputil_exit ();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _LDAPU_CERTMAP_H */

+ 91 - 0
include/ldaputil/dbconf.h

@@ -0,0 +1,91 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef _LDAPU_DBCONF_H
+#define _LDAPU_DBCONF_H
+
+#include <stdio.h>
+
+#ifndef NSAPI_PUBLIC
+#ifdef XP_WIN32
+#define NSAPI_PUBLIC __declspec(dllexport)
+#else
+#define NSAPI_PUBLIC 
+#endif
+#endif
+
+typedef struct dbconf_propval {
+    char *prop;			    /* Property name */
+    char *val;			    /* Property value */
+    struct dbconf_propval *next;    /* Pointer to the next prop-val pair */
+} DBPropVal_t;
+
+typedef struct dbconf_dbinfo {
+    char *dbname;		/* Database name */
+    char *url;			/* Database URL */
+    DBPropVal_t *firstprop;	/* pointer to first property-value pair */
+    DBPropVal_t *lastprop;	/* pointer to last property-value pair */
+    struct dbconf_dbinfo *next;	/* pointer to next db info */
+} DBConfDBInfo_t;
+
+typedef struct {
+    DBConfDBInfo_t *firstdb;	/* pointer to first db info */
+    DBConfDBInfo_t *lastdb;	/* pointer to last db info */
+} DBConfInfo_t;
+
+#define DBCONF_DEFAULT_DBNAME "default"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+NSAPI_PUBLIC extern int dbconf_read_default_dbinfo (const char *file,
+						    DBConfDBInfo_t **db_info);
+NSAPI_PUBLIC extern int dbconf_read_config_file (const char *file,
+						 DBConfInfo_t **conf_info);
+
+NSAPI_PUBLIC extern int ldapu_dbinfo_attrval (DBConfDBInfo_t *db_info,
+					      const char *attr, char **val);
+
+NSAPI_PUBLIC extern void dbconf_free_confinfo (DBConfInfo_t *conf_info);
+NSAPI_PUBLIC extern void dbconf_free_dbinfo (DBConfDBInfo_t *db_info);
+
+extern void dbconf_free_propval (DBPropVal_t *propval);
+
+extern void dbconf_print_confinfo (DBConfInfo_t *conf_info);
+extern void dbconf_print_dbinfo (DBConfDBInfo_t *db_info);
+extern void dbconf_print_propval (DBPropVal_t *propval);
+
+
+NSAPI_PUBLIC int dbconf_output_db_directive (FILE *fp, const char *dbname,
+				       const char *url);
+
+NSAPI_PUBLIC int dbconf_output_propval (FILE *fp, const char *dbname,
+				  const char *prop, const char *val,
+				  const int encoded);
+
+/* Following functions are required by certmap.c file */
+extern int dbconf_read_config_file_sub (const char *file,
+					const char *directive,
+					const int directive_len,
+					DBConfInfo_t **conf_info_out);
+
+extern int dbconf_read_default_dbinfo_sub (const char *file,
+					   const char *directive,
+					   const int directive_len,
+					   DBConfDBInfo_t **db_info_out);
+
+NSAPI_PUBLIC int dbconf_get_dbnames (const char *dbmap, char ***dbnames, int *cnt);
+
+NSAPI_PUBLIC int dbconf_free_dbnames (char **dbnames);
+
+
+extern int ldapu_strcasecmp (const char *s1, const char *s2); 
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _LDAPU_DBCONF_H */

+ 29 - 0
include/ldaputil/encode.h

@@ -0,0 +1,29 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef _LDAPU_ENCODE_H
+#define _LDAPU_ENCODE_H
+
+#ifndef NSAPI_PUBLIC
+#ifdef XP_WIN32
+#define NSAPI_PUBLIC __declspec(dllexport)
+#else
+#define NSAPI_PUBLIC 
+#endif
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+NSAPI_PUBLIC extern char *dbconf_encodeval(const char *val);
+
+NSAPI_PUBLIC extern char *dbconf_decodeval (const char *val);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _LDAPU_ENCODE_H */

+ 108 - 0
include/ldaputil/errors.h

@@ -0,0 +1,108 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef _LDAPU_ERRORS_H
+#define _LDAPU_ERRORS_H
+
+#ifndef NSAPI_PUBLIC
+#ifdef XP_WIN32
+#define NSAPI_PUBLIC __declspec(dllexport)
+#else
+#define NSAPI_PUBLIC 
+#endif
+#endif
+
+#ifdef DBG_PRINT
+#include <stdio.h>
+#define DBG_PRINT1(x) fprintf(stderr, x)
+#define DBG_PRINT2(x,y) fprintf(stderr, x, y)
+#define DBG_PRINT3(x,y,z) fprintf(stderr, x, y, z)
+#define DBG_PRINT4(x,y,z,a) fprintf(stderr, x, y, z, a)
+#else
+#define DBG_PRINT1(x) 
+#define DBG_PRINT2(x,y) 
+#define DBG_PRINT3(x,y,z) 
+#define DBG_PRINT4(x,y,z,a) 
+#endif
+
+/* Common error codes */
+#define LDAPU_ERR_NOT_IMPLEMENTED	     -1000
+#define LDAPU_ERR_INTERNAL		     -1001
+/* #define LDAPU_SUCCESS	0 */	    /* defined in extcmap.h */
+/* #define LDAPU_FAILED		-1 */	    /* defined in extcmap.h */
+/* #define LDAPU_CERT_MAP_FUNCTION_FAILED    -2 *//* defined in extcmap.h */
+/* #define LDAPU_CERT_VERIFY_FUNCTION_FAILED -3 *//* defined in extcmap.h */
+/* #define LDAPU_CERT_VERIFY_FUNCTION_FAILED -4 *//* defined in extcmap.h */
+/* #define LDAPU_CERT_MAP_INITFN_FAILED      -5 *//* defined in extcmap.h */
+
+/* Error codes returned by ldapdb.c */
+#define LDAPU_ERR_OUT_OF_MEMORY		     -110
+#define LDAPU_ERR_URL_INVALID_PREFIX	     -112
+#define LDAPU_ERR_URL_NO_BASEDN		     -113
+#define LDAPU_ERR_URL_PARSE_FAILED	     -114
+    
+#define LDAPU_ERR_LDAP_INIT_FAILED	     -120
+#define LDAPU_ERR_LCACHE_INIT_FAILED	     -121 
+#define LDAPU_ERR_LDAP_SET_OPTION_FAILED     -122 
+#define LDAPU_ERR_NO_DEFAULT_CERTDB          -123
+
+/* Errors returned by dbconf.c */
+#define LDAPU_ERR_CANNOT_OPEN_FILE	     -141
+#define LDAPU_ERR_DBNAME_IS_MISSING	     -142
+#define LDAPU_ERR_PROP_IS_MISSING	     -143
+#define LDAPU_ERR_DIRECTIVE_IS_MISSING	     -145
+#define LDAPU_ERR_NOT_PROPVAL		     -146
+#define LDAPU_ATTR_NOT_FOUND		     -147
+
+/* Error codes returned by certmap.c */
+#define LDAPU_ERR_NO_ISSUERDN_IN_CERT	     -181
+#define LDAPU_ERR_NO_ISSUERDN_IN_CONFIG_FILE -182
+#define LDAPU_ERR_CERTMAP_INFO_MISSING	     -183
+#define LDAPU_ERR_MALFORMED_SUBJECT_DN	     -184
+#define LDAPU_ERR_MAPPED_ENTRY_NOT_FOUND     -185
+#define LDAPU_ERR_UNABLE_TO_LOAD_PLUGIN	     -186
+#define LDAPU_ERR_MISSING_INIT_FN_IN_LIB     -187
+#define LDAPU_ERR_MISSING_INIT_FN_IN_CONFIG  -188
+#define LDAPU_ERR_CERT_VERIFY_FAILED	     -189
+#define LDAPU_ERR_CERT_VERIFY_NO_CERTS	     -190
+#define LDAPU_ERR_MISSING_LIBNAME	     -191
+#define LDAPU_ERR_MISSING_INIT_FN_NAME	     -192
+
+#define LDAPU_ERR_EMPTY_LDAP_RESULT	     -193
+#define LDAPU_ERR_MULTIPLE_MATCHES	     -194
+#define LDAPU_ERR_MISSING_RES_ENTRY	     -195
+#define LDAPU_ERR_MISSING_UID_ATTR	     -196
+#define LDAPU_ERR_WRONG_ARGS		     -197
+#define LDAPU_ERR_RENAME_FILE_FAILED	     -198
+
+#define LDAPU_ERR_MISSING_VERIFYCERT_VAL     -199
+#define LDAPU_ERR_CANAME_IS_MISSING	     -200
+#define LDAPU_ERR_CAPROP_IS_MISSING	     -201
+#define LDAPU_ERR_UNKNOWN_CERT_ATTR	     -202
+#define LDAPU_ERR_INVALID_ARGUMENT	     -203
+#define LDAPU_ERR_INVALID_SUFFIX	     -204
+
+/* Error codes returned by cert.c */
+#define LDAPU_ERR_EXTRACT_SUBJECTDN_FAILED  -300
+#define LDAPU_ERR_EXTRACT_ISSUERDN_FAILED   -301
+#define LDAPU_ERR_EXTRACT_DERCERT_FAILED    -302
+
+/* Error codes returned by ldapauth.c */
+#define LDAPU_ERR_CIRCULAR_GROUPS	    -400
+#define LDAPU_ERR_INVALID_STRING	    -401
+#define LDAPU_ERR_INVALID_STRING_INDEX	    -402
+#define LDAPU_ERR_MISSING_ATTR_VAL	    -403
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+    /* NSAPI_PUBLIC extern char *ldapu_err2string(int err); */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LDAPUTIL_LDAPU_H */

+ 634 - 0
include/ldaputil/extcmap.h

@@ -0,0 +1,634 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef _PUBLIC_CERTMAP_H
+#define _PUBLIC_CERTMAP_H
+
+#include <ldap.h>
+
+#ifndef NSAPI_PUBLIC
+#if defined( _WINDOWS ) || defined( _WIN32 ) || defined( XP_WIN32 )
+#define NSAPI_PUBLIC __declspec(dllexport)
+#else
+#define NSAPI_PUBLIC 
+#endif
+#endif
+
+
+#define LDAPU_ATTR_INITFN		"InitFn"
+#define LDAPU_ATTR_LIBRARY		"library"
+#define LDAPU_ATTR_DNCOMPS		"DNComps"
+#define LDAPU_ATTR_FILTERCOMPS		"FilterComps"
+#define LDAPU_ATTR_VERIFYCERT 		"VerifyCert"
+#define LDAPU_ATTR_CERTMAP_LDAP_ATTR 	"CmapLdapAttr"
+
+/* Error/Success codes */
+#define LDAPU_SUCCESS			   0
+#define LDAPU_FAILED			  -1
+#define LDAPU_CERT_MAP_FUNCTION_FAILED    -2
+#define LDAPU_CERT_SEARCH_FUNCTION_FAILED -3
+#define LDAPU_CERT_VERIFY_FUNCTION_FAILED -4
+#define LDAPU_CERT_MAP_INITFN_FAILED      -5
+
+
+/*
+ * CertMapFn_t -
+ *  This is a typedef for cert mapping function.  The mapping function is
+ *  called by the function ldapu_cert_to_ldap_entry.
+ * Parameters:
+ *  cert         -  cert to be mapped.  You can pass this to
+ *		    functions ldapu_get_cert_XYZ.
+ *  ld		 -  Handle to the connection to the directory server.
+ *  certmap_info -  This structure contains information about the 
+ *		    configuration parameters for the cert's issuer (CA).
+ *		    This structure can be passed to the function
+ *		    ldapu_certmap_info_attrval to get value for a particular
+ *		    configuration attribute (or a property).
+ *  ldapdn	 -  The mapping function should allocate memory for ldapdn
+ *		    using malloc and set this variable using the 'cert' and
+ *		    'certmap_info'.  This DN will be used for ldap lookup.
+ *  filter	 -  The mapping function should allocate memory for filter
+ *		    using malloc and set this variable using the 'cert' and
+ *		    'certmap_info'.  This will be used as ldap filter for ldap
+ *		    lookup of the ldapdn.
+ *
+ * Return Value:
+ *  return LDAPU_SUCCESS upon successful completion (cert is mapped)
+ *  return LDAPU_FAILED there is no unexpected error but cert could not
+ *		    mapped (probably because ldap entry doesn't exist).
+ *  otherwise return LDAPU_CERT_MAP_FUNCTION_FAILED.
+ */
+typedef int (*CertMapFn_t)(void *cert, LDAP *ld, void *certmap_info,
+			   char **ldapdn, char **filter);
+
+
+/*
+ * CertSearchFn_t -
+ *  This is a typedef for cert search function.  The search function is
+ *  called by the function ldapu_cert_to_ldap_entry after calling the mapping
+ *  function.  The candidate 'dn' and 'filter' returned by the mapping
+ *  function is passed to this function.
+ *  The default search function works as follows:
+ *	1.  If the 'filter' is NULL, default it to 'objectclass=*'.
+ *	2.  If the 'dn' is non-NULL, do a base level search with the 'dn' and
+ *	    'filter'.  If it succeeds, we are done.  If there is no serious
+ *	    error (LDAP_NO_SUCH_OBJECT is not serious error yet), continue.
+ *	3.  If the 'dn' is NULL, default it to 'basedn'.
+ *	4.  Perform a 'subtree' search in LDAP for the 'dn' and the 'filter'.
+ *	5.  Return the results of the last search.
+ * Parameters:
+ *  cert         -  cert to be mapped.  You can pass this to
+ *		    functions ldapu_get_cert_XYZ.
+ *  ld		 -  Handle to the connection to the directory server.
+ *  certmap_info -  This structure contains information about the 
+ *		    configuration parameters for the cert's issuer (CA).
+ *		    This structure can be passed to the function
+ *		    ldapu_certmap_info_attrval to get value for a particular
+ *		    configuration attribute (or a property).
+ *  suffix	 -  If the ldapdn is empty then use this DN to begin the
+ *		    search.  This is the DN of the root object in LDAP
+ *		    Directory.
+ *  ldapdn	 -  candidate 'dn' returned by the mapping function.
+ *  filter	 -  returned by the mapping function.
+ *  attrs	 -  list of attributes to return from the search.  If this is
+ *		    NULL, all attributes are returned.
+ *  res		 -  result of the search which is passed to the verify
+ *		    function.
+ *
+ * Return Value:
+ *  return LDAPU_SUCCESS upon successful completion
+ *  return LDAPU_FAILED there is no unexpected error but entries matching the
+ *  'dn' and 'filter' doesn't exist.
+ *  otherwise return LDAPU_CERT_SEARCH_FUNCTION_FAILED.
+ */
+typedef int (*CertSearchFn_t)(void *cert, LDAP *ld, void *certmap_info,
+			      const char *suffix, const char *ldapdn,
+			      const char *filter, const char **attrs,
+			      LDAPMessage ***res);
+
+
+/*
+ * CertVerifyFn_t -
+ *  This is a typedef for cert verify function.  The verify function is
+ *  called by the function ldapu_cert_to_ldap_entry after the cert is
+ *  successfully mapped to ldapdn and filter, and an entry matching that
+ *  exists in the directory server.   The verify fn may get called for
+ *  multiple matched entries.  This function must go through all the entries
+ *  and check which one is appropriate.  The pointer to that entry must be
+ *  passed back in the 'LDAPMessage **entry' parameter.
+ * Parameters:
+ *  cert	 -  Original cert to be mapped.  You can pass this to
+ *		    functions ldapu_get_cert_XYZ.
+ *  ld		 -  Handle to the connection to the directory server.
+ *  certmap_info -  This structure contains information about the 
+ *		    configuration parameters for the cert's issuer (CA).
+ *		    This structure can be passed to the function
+ *		    ldapu_certmap_info_attrval to get value for a particular
+ *		    configuration attribute (or a property).
+ *  res		 -  cert is first mapped to ldapdn and filter.  'res' is the
+ *		    result of ldap search using the ldapdn and filter.
+ *		    'ld' and 'res' can be used in the calls to ldapsdk API.
+ *  entry	 -  pointer to the entry from 'res' which is the correct match
+ *		    according to the verify function.
+ *		    
+ * Return Values:
+ *  return LDAPU_SUCCESS upon successful completion (cert is verified)
+ *  return LDAPU_FAILED there is no unexpected error but cert could not
+ *			verified (probably because it was revoked).
+ *  otherwise return LDAPU_CERT_VERIFY_FUNCTION_FAILED.
+ */
+typedef int (*CertVerifyFn_t)(void *cert, LDAP *ld, void *certmap_info,
+			      LDAPMessage *res, LDAPMessage **entry);
+
+
+
+/*
+ * CertmapInitFn_t -
+ *  This is a typedef for user defined init function.  An init function can be
+ *  specified in the config file (<ServerRoot>/userdb/certmap.conf) per issuer
+ *  of a certificate.  This init function must from the user's library, also
+ *  loaded from the config file using the 'library' property.  The init
+ *  function is specified in the config file using the 'InitFn' property.
+ *  When the config file is loaded, any user defined init functions will be
+ *  called with the certmap_info pertaining to the issuer (CA).
+ * Parameters:
+ *  certmap_info -  This structure contains information about the 
+ *		    configuration parameters for the cert's issuer (CA).
+ *		    This structure can be passed to the function
+ *		    ldapu_certmap_info_attrval to get value for a particular
+ *		    configuration attribute (or a property).
+ * 
+ * Return Value:
+ *  return LDAPU_SUCCESS upon successful completion
+ *  otherwise return LDAPU_CERT_MAP_INITFN_FAILED.  The server startup will be
+ *  aborted if the return value is not LDAPU_SUCCESS.
+ */
+typedef int (*CertMapInitFn_t)(void *certmap_info, const char *issuerName,
+			       const char *issuerDN, const char *libname);
+
+/*
+ * Refer to the description of the function ldapu_get_cert_ava_val
+ */
+enum {
+    LDAPU_SUBJECT_DN,
+    LDAPU_ISSUER_DN
+};
+
+/* ldapu_cert_to_ldap_entry */
+typedef int (*t_ldapu_cert_to_ldap_entry)(void *cert, LDAP *ld,
+					  const char *suffix,
+					  LDAPMessage **res);
+
+/* ldapu_set_cert_mapfn */
+typedef int (*t_ldapu_set_cert_mapfn)(const char *issuerDN,
+				      CertMapFn_t mapfn);
+
+/* ldapu_get_cert_mapfn */
+typedef CertMapFn_t (*t_ldapu_get_cert_mapfn) (const char *issuerDN);
+
+/* ldapu_set_cert_searchfn */
+typedef int (*t_ldapu_set_cert_searchfn) (const char *issuerDN,
+					  CertSearchFn_t searchfn);
+
+/* ldapu_get_cert_searchfn */
+typedef CertSearchFn_t (*t_ldapu_get_cert_searchfn) (const char *issuerDN);
+
+/* ldapu_set_cert_verifyfn */
+typedef int (*t_ldapu_set_cert_verifyfn) (const char *issuerDN,
+					  CertVerifyFn_t verifyFn);
+
+/* ldapu_get_cert_verifyfn */
+typedef CertVerifyFn_t (*t_ldapu_get_cert_verifyfn) (const char *issuerDN);
+
+/* ldapu_get_cert_subject_dn */
+typedef int (*t_ldapu_get_cert_subject_dn) (void *cert, char **subjectDN);
+
+/* ldapu_get_cert_issuer_dn */
+typedef int (*t_ldapu_get_cert_issuer_dn) (void *cert, char **issuerDN);
+
+/* ldapu_get_cert_ava_val */
+typedef int (*t_ldapu_get_cert_ava_val) (void *cert, int which_dn,
+					 const char *attr, char ***val);
+
+/* ldapu_free_cert_ava_val */
+typedef int (*t_ldapu_free_cert_ava_val) (char **val);
+
+/* ldapu_get_cert_der */
+typedef int (*t_ldapu_get_cert_der) (void *cert, unsigned char **derCert,
+				     unsigned int *len);
+
+/* ldapu_issuer_certinfo */
+typedef int (*t_ldapu_issuer_certinfo) (const char *issuerDN,
+					void **certmap_info);
+
+/* ldapu_certmap_info_attrval */
+typedef int (*t_ldapu_certmap_info_attrval) (void *certmap_info,
+					     const char *attr, char **val);
+
+/* ldapu_err2string */
+typedef char * (*t_ldapu_err2string) (int err);
+
+/* ldapu_free */
+typedef void (*t_ldapu_free_old) (char *ptr);
+typedef void (*t_ldapu_free) (void *ptr);
+
+/* ldapu_malloc */
+typedef void *(*t_ldapu_malloc) (int size);
+
+/* ldapu_strdup */
+typedef char *(*t_ldapu_strdup) (const char *ptr);
+
+
+typedef struct LDAPUDispatchVector LDAPUDispatchVector_t;
+struct LDAPUDispatchVector {
+    t_ldapu_cert_to_ldap_entry      f_ldapu_cert_to_ldap_entry;
+    t_ldapu_set_cert_mapfn	    f_ldapu_set_cert_mapfn;
+    t_ldapu_get_cert_mapfn	    f_ldapu_get_cert_mapfn;
+    t_ldapu_set_cert_searchfn	    f_ldapu_set_cert_searchfn;
+    t_ldapu_get_cert_searchfn	    f_ldapu_get_cert_searchfn;
+    t_ldapu_set_cert_verifyfn	    f_ldapu_set_cert_verifyfn;
+    t_ldapu_get_cert_verifyfn	    f_ldapu_get_cert_verifyfn;
+    t_ldapu_get_cert_subject_dn     f_ldapu_get_cert_subject_dn;
+    t_ldapu_get_cert_issuer_dn	    f_ldapu_get_cert_issuer_dn;
+    t_ldapu_get_cert_ava_val	    f_ldapu_get_cert_ava_val;
+    t_ldapu_free_cert_ava_val	    f_ldapu_free_cert_ava_val;
+    t_ldapu_get_cert_der	    f_ldapu_get_cert_der;
+    t_ldapu_issuer_certinfo	    f_ldapu_issuer_certinfo;
+    t_ldapu_certmap_info_attrval    f_ldapu_certmap_info_attrval;
+    t_ldapu_err2string		    f_ldapu_err2string;
+    t_ldapu_free_old		    f_ldapu_free_old;
+    t_ldapu_malloc		    f_ldapu_malloc;
+    t_ldapu_strdup		    f_ldapu_strdup;
+    t_ldapu_free		    f_ldapu_free;
+};
+
+
+#ifdef INTLDAPU
+NSAPI_PUBLIC extern LDAPUDispatchVector_t *__ldapu_table;
+#else
+typedef int (*CertMapDLLInitFn_t)(LDAPUDispatchVector_t **table);
+
+NSAPI_PUBLIC extern int CertMapDLLInitFn(LDAPUDispatchVector_t **table);
+
+extern LDAPUDispatchVector_t *__ldapu_table;
+
+#if defined( _WINDOWS ) || defined( _WIN32 ) || defined( XP_WIN32 )
+#define CertmapDLLInitFnTbl LDAPUDispatchVector_t *__ldapu_table;
+#define CertmapDLLInit(rv, libname) \
+{\
+	HANDLE h = LoadLibrary((libname)); \
+	CertMapDLLInitFn_t init_fn; \
+	if (!h) return LDAPU_CERT_MAP_INITFN_FAILED; \
+	init_fn = (CertMapDLLInitFn_t)GetProcAddress(h, "CertMapDLLInitFn"); \
+	rv = init_fn(&__ldapu_table); \
+}
+#else
+#define CertmapDLLInit(rv, libname)
+#define CertmapDLLInitFnTbl
+#endif
+
+#endif /* INTLDAPU */
+
+#ifndef INTLDAPU
+
+/*
+ * ldapu_cert_to_ldap_entry -
+ *  This function is called to map a cert to an ldap entry.  It extracts the
+ *  cert issuer information from the given cert.  The mapping function set for
+ *  the issuer (if any) or the default mapping function is called to map the
+ *  subject DN from the cert to a candidate ldap DN and filter for ldap
+ *  search.  If the mapped ldap DN is NULL, the 'basedn' passed into this
+ *  function is used as a starting place for the search.  If the mapped filter
+ *  is NULL, "objectclass=*" is used as a filter.  A base level search is
+ *  performed to see if the candidate DN exists in the LDAP database matching
+ *  the filter.  If there is no match, a scoped search (sub-tree search) is
+ *  performed.  If at least one entry matched the mapped DN and filter, the
+ *  result is passed to the appropriate verify function.  The verify function
+ *  is called only if 'VerifyCert' parameter has been set for the cert issuer
+ *  in the certmap.conf file.
+ *  If the verify function succeeds, it must return the pointer to the matched
+ *  'entry'.  If at the end, there is only one matching entry, the mapping is
+ *  successful.
+ * Parameters:
+ *  cert         -  cert to be mapped.  You can pass this to
+ *		    functions ldapu_get_cert_XYZ.
+ *  ld		 -  Handle to the connection to the directory server.
+ *  suffix	 -  If the subject dn is mapped to empty LDAP DN then use this
+ *		    DN to begin the search.  This is the DN of the root object
+ *		    in LDAP Directory.
+ *  res		 -  cert is first mapped to ldapdn and filter.  'res' is the
+ *		    result of ldap search using the ldapdn and filter.
+ *		    'ld' and 'res' can be used in the calls to ldapsdk API.
+ *		    When done with 'res', free it using ldap_msgfree(res)
+ * 
+ * Return Value:
+ *  return LDAPU_SUCCESS upon successful completion
+ *  otherwise returns an error code that can be passed to ldapu_err2string.
+ */
+#define ldapu_cert_to_ldap_entry (*__ldapu_table->f_ldapu_cert_to_ldap_entry)
+
+/*
+ * ldapu_set_cert_mapfn -
+ *  This function can be used to set the cert mapping function for the given
+ *  issuer (CA).  If the mapping information doesn't exist for the given
+ *  issuer then a new one will be created and the mapping function will be
+ *  set.  When creating the new mapping information, the default mapping
+ *  information is copied.
+ * Parameters:
+ *  issuerDN	 -  DN of the cert issuer.  This mapping function will be used
+ *		    for all certs issued by this issuer.  If the issuerDN is
+ *		    NULL, the given 'mapfn' becomes the default mapping
+ *		    function (which is used when no mapping function has been
+ *		    set for the cert's issuer).
+ *  mapfn	 -  the mapping function.  Look at the desciption of
+ *		    CertMapFn_t to find out more about the mapping functions.
+ *
+ * Return Value:
+ *  return LDAPU_SUCCESS upon successful completion
+ *  otherwise returns an error code that can be passed to ldapu_err2string.
+ */
+#define ldapu_set_cert_mapfn (*__ldapu_table->f_ldapu_set_cert_mapfn)
+
+
+/*
+ * ldapu_get_cert_mapfn -
+ *  This function can be used to get the cert mapping function for the given
+ *  issuer (CA).  This will always return a non-NULL function.
+ * Parameters:
+ *  issuerDN	 -  DN of the cert issuer for which the mapping function is to
+ *		    be retrieved.  If this is NULL, default mapping function
+ *		    is returned.
+ *
+ * Return Value:
+ *  The mapping function set for the issuer is returned.  If the issuerDN is
+ *  NULL or if no specific mapping function has been set for the issuer, the
+ *  default mapping function is returned.
+ */
+#define ldapu_get_cert_mapfn (*__ldapu_table->f_ldapu_get_cert_mapfn)
+
+/*
+ * ldapu_set_cert_searchfn -
+ *  This function can be used to set the cert search function for the given
+ *  issuer (CA).
+ * Parameters:
+ *  issuerDN	 -  DN of the cert issuer.  This search function will be used
+ *		    for all certs issued by this issuer.  If the issuerDN is
+ *		    NULL, the given 'searchfn' becomes the default search
+ *		    function (which is used when no search function has been
+ *		    set for the cert's issuer).
+ *  searchfn	 -  the search function.  Look at the desciption of
+ *		    CertSearchFn_t to find out more about the search functions.
+ *
+ * Return Value:
+ *  return LDAPU_SUCCESS upon successful completion
+ *  otherwise returns an error code that can be passed to ldapu_err2string.
+ */
+#define ldapu_set_cert_searchfn (*__ldapu_table->f_ldapu_set_cert_searchfn)
+
+
+/*
+ * ldapu_get_cert_searchfn -
+ *  This function can be used to get the cert search function for the given
+ *  issuer (CA).  This will always return a non-NULL function.
+ * Parameters:
+ *  issuerDN	 -  DN of the cert issuer for which the search function is to
+ *		    be retrieved.  If this is NULL, the default search
+ *		    function is returned.
+ *
+ * Return Value:
+ *  The search function set for the issuer is returned.  If the issuerDN is
+ *  NULL or if no specific search function has been set for the issuer, the
+ *  default search function is returned.
+ */
+#define ldapu_get_cert_searchfn (*__ldapu_table->f_ldapu_get_cert_searchfn)
+
+/*
+ * ldapu_set_cert_verifyfn -
+ *  This function can be used to set the cert verify function for the given
+ *  issuer (CA).  If the mapping information doesn't exist for the given
+ *  issuer then a new one will be created and the verify function will be
+ *  set.  When creating the new mapping information, the default mapping
+ *  information is copied.
+ * Parameters:
+ *  issuerDN	 -  DN of the cert issuer.  This verify function will be used
+ *		    for all certs issued by this issuer.  If the issuerDN is
+ *		    NULL, the given 'verifyFn' becomes the default verify
+ *		    function (which is used when no verify function has been
+ *		    set for the cert's issuer).
+ *  verifyFn	 -  the verify function.  Look at the desciption of
+ *		    CertMapFn_t to find out more about the verify functions.
+ *
+ * Return Value:
+ *  return LDAPU_SUCCESS upon successful completion
+ *  otherwise returns an error code that can be passed to ldapu_err2string.
+ */
+#define ldapu_set_cert_verifyfn (*__ldapu_table->f_ldapu_set_cert_verifyfn)
+
+/*
+ * ldapu_get_cert_verifyfn -
+ *  This function can be used to get the cert verify function for the given
+ *  issuer (CA).  This function can return NULL when there is no applicable
+ *  verify function.
+ * Parameters:
+ *  issuerDN	 -  DN of the cert issuer for which the verify function is to
+ *		    be retrieved.  If this is NULL, default verify function
+ *		    is returned.
+ *
+ * Return Value:
+ *  The verify function set for the issuer is returned.  If the issuerDN is
+ *  NULL or if no specific verify function has been set for the issuer, the
+ *  default verify function is returned.  This function can return NULL when
+ *  there is no applicable verify function.
+ */
+#define ldapu_get_cert_verifyfn (*__ldapu_table->f_ldapu_get_cert_verifyfn)
+
+
+/*
+ * ldapu_get_cert_subject_dn -
+ *  This function can be used to get the subject DN from the cert.  Free the
+ *  subjectDN using 'free' after you are done using it.
+ * Parameters:
+ *  cert	 -  cert from which the DN is to be extracted.
+ *  subjectDN	 -  subjectDN extracted from the cert.  Free it using 'free'
+ *		    after it is no longer required.
+ *
+ * Return Value:
+ *  return LDAPU_SUCCESS upon successful completion
+ *  otherwise returns an error code that can be passed to ldapu_err2string.
+ */
+#define ldapu_get_cert_subject_dn (*__ldapu_table->f_ldapu_get_cert_subject_dn)
+
+
+/*
+ * ldapu_get_cert_issuer_dn -
+ *  This function can be used to get the issuer DN from the cert.  Free the
+ *  issuerDN using 'free' after you are done using it.
+ * Parameters:
+ *  cert	 -  cert from which the DN is to be extracted.
+ *  issuerDN	 -  issuerDN extracted from the cert.  Free it using 'free'
+ *		    after it is no longer required.
+ *
+ * Return Value:
+ *  return LDAPU_SUCCESS upon successful completion
+ *  otherwise returns an error code that can be passed to ldapu_err2string.
+ */
+#define ldapu_get_cert_issuer_dn (*__ldapu_table->f_ldapu_get_cert_issuer_dn)
+
+
+/*
+ * ldapu_get_cert_ava_val -
+ *  This function can be used to get value of the given attribute from either
+ *  the subject DN or the issuer DN from the cert.
+ * Parameters:
+ *  cert	 -  cert from which the values are to be extracted.
+ *  which_dn	 -  Should be either LDAPU_ISSUER_DN or LDAPU_SUBJECT_DN.
+ *  attr	 -  Should be one of "CN", "OU", "O", "C", "UID", "MAIL",
+ *		    "E", "L", and "ST".
+ *  val		 -  An array of attribute values extracted from the cert.
+ *		    There could be multiple values.  The last entry in the
+ *		    array is NULL.  You must free this array of strings after
+ *		    you are done with it (using the function
+ *		    ldapu_free_cert_ava_val).  'val' is initialized to NULL if
+ *		    there is an error.
+ *
+ * Return Value:
+ *  return LDAPU_SUCCESS upon successful completion
+ *  otherwise returns an error code that can be passed to ldapu_err2string.
+ */
+#define ldapu_get_cert_ava_val (*__ldapu_table->f_ldapu_get_cert_ava_val)
+
+
+/*
+ * ldapu_free_cert_ava_val -
+ *  This function can be used to free the array returned by the
+ *  ldapu_get_cert_ava_val function.
+ * Parameters:
+ *  val		 -  An array of attribute values returned by
+ *		    ldapu_get_cert_ava_val. 
+ *
+ * Return Value:
+ *  return LDAPU_SUCCESS upon successful completion
+ *  otherwise returns an error code that can be passed to ldapu_err2string.
+ */
+#define ldapu_free_cert_ava_val (*__ldapu_table->f_ldapu_free_cert_ava_val)
+
+
+/*
+ * ldapu_get_cert_der -
+ *  This function can be used to get the original DER encoded cert for the
+ *  given cert.
+ * Parameters:
+ *  cert	 -  cert from which the original DER is to be extracted.
+ *  derCert	 -  the original DER encoded cert
+ *  len		 -  length of derCert
+ *
+ * Return Value:
+ *  return LDAPU_SUCCESS upon successful completion
+ *  otherwise returns an error code that can be passed to ldapu_err2string.
+ */
+#define ldapu_get_cert_der (*__ldapu_table->f_ldapu_get_cert_der)
+
+
+/*
+ * ldapu_issuer_certinfo -
+ *  This function can be used to get the handle on the internal structure for
+ *  the given issuer.  This handle can be passed to ldapu_certmap_info_attrval
+ *  to get configuration attribute values for the issuer.
+ * Parameters:
+ *  issuerDN	 -  DN of the issuer for whom the handle on internal structure
+ *		    is requested.  If issuerDN is NULL, the handle to the
+ *		    default configuration information is returned.
+ *  certmap_info -  This structure contains information about the 
+ *		    configuration parameters for the cert's issuer (CA).
+ *		    This structure can be passed to the function
+ *		    ldapu_certmap_info_attrval to get value for a particular
+ *		    configuration attribute (or a property).
+ *
+ * Return Value:
+ *  return LDAPU_SUCCESS upon successful completion
+ *  otherwise returns an error code that can be passed to ldapu_err2string.
+ *  CAUTION: DON'T FREE THE 'certmap_info' STRUCTURE.
+ */
+#define ldapu_issuer_certinfo (*__ldapu_table->f_ldapu_issuer_certinfo)
+
+
+/*
+ * ldapu_certmap_info_attrval -
+ *  This function can be used to get values for the given attribute/property
+ *  from the given certmap_info.  You can get handle on the certmap_info by
+ *  calling the ldapu_issuer_certinfo function.  Free the 'val' using 'free'
+ *  after it is no longer required.
+ * Parameters:
+ *  certmap_info -  This structure contains information about the 
+ *		    configuration parameters for the cert's issuer (CA).
+ *  attr	 -  name of the attribute/property for which the value is to
+ *		    be returned.  The attribute can be one of the attributes
+ *		    listed above (LDAPU_ATTR_XYZ).  User defined attributes
+ *		    can also be used.
+ *  val		 -  Value of the 'attr' from the 'certmap_info'.
+ *
+ * Return Value:
+ *  return LDAPU_SUCCESS upon successful completion
+ *  otherwise returns an error code that can be passed to ldapu_err2string.
+ */
+#define ldapu_certmap_info_attrval (*__ldapu_table->f_ldapu_certmap_info_attrval)
+
+
+/*
+ * ldapu_err2string -
+ *  This function can be used to print any of the ldaputil or LDAP error
+ *  code.
+ * Parameters:
+ *  err		 -  error code to be converted to printable string.
+ *
+ * Return Value:
+ *  Printable representation of the given error code.
+ */
+#define ldapu_err2string (*__ldapu_table->f_ldapu_err2string)
+
+/*
+ * ldapu_free -
+ *  This function should be used to free the memory allocated by
+ *  ldapu_* functions if the ldapu_* function doesn't have a corresponding
+ *  'free' function.  Use this function for free'ing the memory allocated by
+ *  the following functions:
+ *	ldapu_get_cert_subject_dn
+ *	ldapu_get_cert_issuer_dn
+ *	ldapu_get_cert_der
+ *	ldapu_certmap_info_attrval
+ *  To free memory allocated by ldapu_get_cert_ava_val, use
+ *  ldapu_free_cert_ava_val.  Do not free the certmap_info pointer returned by
+ *  ldapu_issuer_certinfo.
+ * Parameters:
+ *  ptr		 -  pointer returned by ldapu_get_cert_* functions.
+ */
+#define ldapu_free (*__ldapu_table->f_ldapu_free)
+
+/*
+ * ldapu_malloc -
+ *  This function is a cover function for the 'malloc' system call.  On NT, it
+ *  is best to alloc & free the memory in the same DLL.
+ * Parameters:
+ *  size	 -  size of the memory to be allocated
+ * Return Value:
+ *  same as 'malloc' -- pointer to the allocated memory or NULL on failure.
+ */
+#define ldapu_malloc (*__ldapu_table->f_ldapu_malloc)
+
+/*
+ * ldapu_strdup -
+ *  This function is a cover function for the 'strdup' system call.  On NT, it
+ *  is best to alloc & free the memory in the same DLL.
+ * Parameters:
+ *  ptr		 -  Pointer to the string to be copied
+ * Return Value:
+ *  same as 'strdup' -- pointer to the copied string or NULL on failure.
+ */
+#define ldapu_strdup (*__ldapu_table->f_ldapu_strdup)
+
+
+#endif /* !INTLDAPU */
+
+#endif /* _PUBLIC_CERTMAP_H */

+ 23 - 0
include/ldaputil/init.h

@@ -0,0 +1,23 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef _LDAPU_INIT_H
+#define _LDAPU_INIT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+NSAPI_PUBLIC extern int ldaputil_init (const char *config_file,
+				       const char *dllname,
+				       const char *serv_root,
+				       const char *serv_type,
+				       const char *serv_id);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _LDAPU_INIT_H */

+ 94 - 0
include/ldaputil/ldapauth.h

@@ -0,0 +1,94 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+
+#ifndef LDAPU_AUTH_H
+#define LDAPU_AUTH_H
+
+#include <ldap.h>
+
+#ifndef NSAPI_PUBLIC
+#ifdef XP_WIN32
+#define NSAPI_PUBLIC __declspec(dllexport)
+#else
+#define NSAPI_PUBLIC 
+#endif
+#endif
+
+typedef int (*LDAPU_GroupCmpFn_t)(const void *groupids, const char *group,
+				  const int len);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int ldapu_find (LDAP *ld, const char *base, int scope,
+		       const char *filter, const char **attrs,
+		       int attrsonly, LDAPMessage **res);
+
+int ldapu_find_entire_tree (LDAP *ld, int scope,
+			    const char *filter, const char **attrs,
+			    int attrsonly, LDAPMessage ***res);
+
+extern int ldapu_auth_userdn_groupdn (LDAP *ld, const char *userdn,
+				      const char *groupdn,
+				      const char *base);
+
+extern int ldapu_auth_uid_groupdn (LDAP *ld, const char *uid,
+				   const char *groupdn, const char *base);
+
+extern int ldapu_auth_uid_groupid (LDAP *ld, const char *uid,
+				   const char *groupid, const char *base);
+
+extern int ldapu_auth_userdn_groupid (LDAP *ld,
+				      const char *userdn, const char *groupid,
+				      const char *base);
+
+extern int ldapu_auth_userdn_groupids (LDAP *ld, const char *userdn,
+				       void *groupids,
+				       LDAPU_GroupCmpFn_t grpcmpfn,
+				       const char *base,
+				       char **group_out);
+
+extern int ldapu_auth_userdn_attrfilter (LDAP *ld,
+					 const char *userdn,
+					 const char *attrfilter);
+
+extern int ldapu_auth_uid_attrfilter (LDAP *ld, const char *uid,
+				      const char *attrfilter,
+				      const char *base);
+
+extern int ldapu_auth_userdn_password (LDAP *ld,
+				       const char *userdn,
+				       const char *password);
+
+extern int ldapu_find_uid_attrs (LDAP *ld, const char *uid,
+				 const char *base, const char **attrs,
+				 int attrsonly, LDAPMessage **res);
+
+extern int ldapu_find_uid (LDAP *ld, const char *uid,
+			   const char *base, LDAPMessage **res);
+
+NSAPI_PUBLIC extern int ldapu_find_userdn (LDAP *ld, const char *uid,
+			      const char *base, char **dn);
+
+extern int ldapu_find_group_attrs (LDAP *ld, const char *groupid,
+				   const char *base, const char **attrs,
+				   int attrsonly, LDAPMessage **res);
+
+extern int ldapu_find_group (LDAP *ld, const char *groupid,
+			     const char *base, LDAPMessage **res);
+
+extern int ldapu_find_groupdn (LDAP *ld, const char *groupid,
+			       const char *base, char **dn);
+
+extern int ldapu_auth_uid_password (LDAP *ld, const char *uid,
+				    const char *password, const char *base);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LDAPU_AUTH_H */

+ 100 - 0
include/ldaputil/ldapdb.h

@@ -0,0 +1,100 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef _LDAPU_LDAPDB_H
+#define _LDAPU_LDAPDB_H
+
+#include <ldap.h>
+/* removed for LDAPSDK31 integration
+#include <lcache.h>
+*/
+#ifdef LDAPDB_THREAD_SAFE
+/* In the past, we used CRITICAL objects from lib/base/crit.cpp.
+ * Now we use PRMonitor to avoid ldapu to depend on lib/base.
+ */
+#include <prmon.h>
+#else
+#define PRMonitor void
+#endif /* LDAPDB_THREAD_SAFE */
+
+#ifndef NSAPI_PUBLIC
+#ifdef XP_WIN32
+#define NSAPI_PUBLIC __declspec(dllexport)
+#else
+#define NSAPI_PUBLIC 
+#endif
+#endif
+
+#define LDAPDB_URL_PREFIX "ldapdb:"
+#define LDAPDB_URL_PREFIX_LEN 7
+
+typedef struct {
+    int use_ssl;    /* Set to 0 in case of local LDAP cache */
+    char *host;     /* Set to 0 in case of local LDAP cache */
+    int port;	    /* Set to 0 in case of local LDAP cache */
+    char *basedn;
+    char *scope;
+    char *filter;
+    LDAP *ld;
+    char *binddn;   /* Set to 0 in case of local LDAP cache */
+    char *bindpw;   /* Set to 0 in case of local LDAP cache */
+    int bound;	    /* If 0 then not bound with binddn & bindpw */
+    PRMonitor* crit;/* to control critical sections */
+} LDAPDatabase_t;
+
+#define LDAPU_ATTR_BINDDN	"binddn"
+#define LDAPU_ATTR_BINDPW	"bindpw"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+NSAPI_PUBLIC extern int ldapu_url_parse (const char *url, const char *binddn,
+					 const char *bindpw,
+					 LDAPDatabase_t **ldb);
+
+NSAPI_PUBLIC extern int ldapu_ldapdb_url_parse (const char *url,
+						LDAPDatabase_t **ldb);
+
+NSAPI_PUBLIC extern int ldapu_is_local_db (const LDAPDatabase_t *ldb);
+
+NSAPI_PUBLIC extern void ldapu_free_LDAPDatabase_t (LDAPDatabase_t *ldb);
+
+NSAPI_PUBLIC extern LDAPDatabase_t *ldapu_copy_LDAPDatabase_t (const LDAPDatabase_t *ldb);
+
+NSAPI_PUBLIC extern int ldapu_ldap_init (LDAPDatabase_t *ldb);
+
+NSAPI_PUBLIC extern int ldapu_ldap_init_and_bind (LDAPDatabase_t *ldb);
+
+NSAPI_PUBLIC extern int ldapu_ldap_rebind (LDAPDatabase_t *ldb);
+
+NSAPI_PUBLIC extern int ldapu_ldap_reinit_and_rebind (LDAPDatabase_t *ldb);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*
+ * LDAPU_REQ --
+ * 'ld' is cached in the 'ldb' structure.  If the LDAP server goes down since
+ * it was cached, the ldap lookup commands fail with LDAP_SERVER_DOWN.  This
+ * macro can be used to rebind to the server and retry the command once if
+ * this happens.
+ */
+#define LDAPU_REQ(rv, ldb, cmd) \
+{ \
+      int numtry = 0; \
+      while(1) { \
+	  rv = cmd; \
+	  if (rv != LDAP_SERVER_DOWN || numtry++ != 0) break; \
+	  /* Server went down since our last ldap lookup ... reconnect */ \
+	  rv = ldapu_ldap_reinit_and_rebind(ldb); \
+	  if (rv != LDAPU_SUCCESS) break; \
+      } \
+}
+
+
+#endif /* LDAPUTIL_LDAPDB_H */

+ 132 - 0
include/ldaputil/ldaputil.h

@@ -0,0 +1,132 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef _LDAPU_LDAPUTIL_H
+#define _LDAPU_LDAPUTIL_H
+
+#include <ldaputil/dbconf.h>
+#include <ldaputil/certmap.h>
+
+typedef struct ldapu_list_node {
+    void *info;				/* pointer to the corresponding info */
+    struct ldapu_list_node *next;	/* pointer to the next node */
+    struct ldapu_list_node *prev;	/* pointer to the prev node */
+} LDAPUListNode_t;
+
+typedef struct ldapu_list {
+    LDAPUListNode_t *head;
+    LDAPUListNode_t *tail;
+} LDAPUList_t;
+
+typedef struct {
+    char *prop;			/* property name */
+    char *val;			/* value -- only char* supported for now */
+} LDAPUPropVal_t;
+
+typedef LDAPUList_t LDAPUPropValList_t;
+
+enum {
+    COMPS_COMMENTED_OUT,
+    COMPS_EMPTY,
+    COMPS_HAS_ATTRS
+};
+
+typedef struct {
+    char *issuerName;		  /* issuer (symbolic/short) name */
+    char *issuerDN;		  /* cert issuer's DN */
+    LDAPUPropValList_t *propval;  /* pointer to the prop-val pairs list */
+    CertMapFn_t mapfn;		  /* cert to ldapdn & filter mapping func */
+    CertVerifyFn_t verifyfn;	  /* verify cert function */
+    CertSearchFn_t searchfn;	  /* search ldap entry function */
+    long dncomps;		  /* bitmask: components to form ldap dn */
+    long filtercomps;		  /* components used to form ldap filter */
+    int verifyCert;		  /* Verify the cert? */
+    char *searchAttr;		  /* LDAP attr used by the search fn */
+    int dncompsState;		  /* Empty, commented out, or attr names */
+    int filtercompsState;	  /* Empty, commented out, or attr names */
+} LDAPUCertMapInfo_t;
+
+typedef LDAPUList_t LDAPUCertMapListInfo_t;
+
+typedef void * (*LDAPUListNodeFn_t)(void *info, void *arg);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int certmap_read_default_certinfo (const char *file);
+
+extern int certmap_read_certconfig_file (const char *file);
+
+extern void ldapu_certinfo_free (void *certmap_info);
+
+extern void ldapu_certmap_listinfo_free (void *certmap_listinfo);
+
+extern void ldapu_propval_list_free (void *propval_list);
+
+NSAPI_PUBLIC extern int ldaputil_exit ();
+
+NSAPI_PUBLIC extern int ldapu_cert_to_user (void *cert, LDAP *ld,
+					    const char *basedn,
+					    LDAPMessage **res,
+					    char **user);
+
+NSAPI_PUBLIC extern int ldapu_certmap_init (const char *config_file,
+					    const char *libname,
+					    LDAPUCertMapListInfo_t **certmap_list,
+					    LDAPUCertMapInfo_t
+					    **certmap_default);
+
+NSAPI_PUBLIC extern int ldapu_certinfo_modify (const char *issuerName,
+					       const char *issuerDN,
+					       const LDAPUPropValList_t *propval);
+
+NSAPI_PUBLIC extern int ldapu_certinfo_delete (const char *issuerDN);
+
+NSAPI_PUBLIC extern int ldapu_certinfo_save (const char *fname,
+					     const char *old_fname,
+					     const char *tmp_fname);
+
+NSAPI_PUBLIC extern int ldapu_list_alloc (LDAPUList_t **list);
+NSAPI_PUBLIC extern int ldapu_propval_alloc (const char *prop, const char *val,
+					     LDAPUPropVal_t **propval);
+NSAPI_PUBLIC extern int ldapu_list_add_info (LDAPUList_t *list, void *info);
+
+#ifndef DONT_USE_LDAP_SSL
+#define USE_LDAP_SSL
+#endif
+
+typedef struct {
+#ifdef USE_LDAP_SSL
+    LDAP*       (LDAP_CALL LDAP_CALLBACK *ldapuV_ssl_init)         ( const char*, int, int );
+#else
+    LDAP*       (LDAP_CALL LDAP_CALLBACK *ldapuV_init)             ( const char*, int );
+#endif
+    int         (LDAP_CALL LDAP_CALLBACK *ldapuV_set_option)       ( LDAP*, int, void* );
+    int         (LDAP_CALL LDAP_CALLBACK *ldapuV_simple_bind_s)    ( LDAP*, const char*, const char* );
+    int         (LDAP_CALL LDAP_CALLBACK *ldapuV_unbind)           ( LDAP* );
+    int         (LDAP_CALL LDAP_CALLBACK *ldapuV_search_s)         ( LDAP*, const char*, int, const char*, char**, int, LDAPMessage** );
+    int         (LDAP_CALL LDAP_CALLBACK *ldapuV_count_entries)    ( LDAP*, LDAPMessage* );
+    LDAPMessage*(LDAP_CALL LDAP_CALLBACK *ldapuV_first_entry)      ( LDAP*, LDAPMessage* );
+    LDAPMessage*(LDAP_CALL LDAP_CALLBACK *ldapuV_next_entry)       ( LDAP*, LDAPMessage* );
+    int         (LDAP_CALL LDAP_CALLBACK *ldapuV_msgfree)          ( LDAP*, LDAPMessage* );
+    char*       (LDAP_CALL LDAP_CALLBACK *ldapuV_get_dn)           ( LDAP*, LDAPMessage* );
+    void        (LDAP_CALL LDAP_CALLBACK *ldapuV_memfree)          ( LDAP*, void* );
+    char*       (LDAP_CALL LDAP_CALLBACK *ldapuV_first_attribute)  ( LDAP*, LDAPMessage*, BerElement** );
+    char*       (LDAP_CALL LDAP_CALLBACK *ldapuV_next_attribute)   ( LDAP*, LDAPMessage*, BerElement* );
+    void        (LDAP_CALL LDAP_CALLBACK *ldapuV_ber_free)         ( LDAP*, BerElement*, int );
+    char**      (LDAP_CALL LDAP_CALLBACK *ldapuV_get_values)       ( LDAP*, LDAPMessage*, const char* );
+    void        (LDAP_CALL LDAP_CALLBACK *ldapuV_value_free)       ( LDAP*, char** );
+    struct berval**(LDAP_CALL LDAP_CALLBACK *ldapuV_get_values_len)( LDAP*, LDAPMessage*, const char* );
+    void           (LDAP_CALL LDAP_CALLBACK *ldapuV_value_free_len)( LDAP*, struct berval** );
+} LDAPUVTable_t;
+
+NSAPI_PUBLIC extern void ldapu_VTable_set (LDAPUVTable_t*);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _LDAPU_LDAPUTIL_H */

+ 41 - 0
include/libaccess/acl.h

@@ -0,0 +1,41 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef ACL_HEADER
+#define ACL_HEADER
+
+#ifndef NOINTNSACL
+#define INTNSACL
+#endif /* NOINTNSACL */
+
+#include <netsite.h>
+#include <base/pool.h>
+#include <base/pblock.h>
+#include <base/plist.h>
+#include <libaccess/nserror.h>
+
+#ifndef FALSE
+#define	FALSE			0
+#endif
+#ifndef TRUE
+#define	TRUE			1
+#endif
+
+#ifndef PUBLIC_NSACL_ACLAPI_H
+#include "public/nsacl/aclapi.h"
+#endif /* !PUBLIC_NSACL_ACLAPI_H */
+
+#ifdef INTNSACL
+
+NSPR_BEGIN_EXTERN_C
+
+extern	char	*generic_rights[];
+extern	char	*http_generic[];
+
+NSPR_END_EXTERN_C
+
+#endif /* INTNSACL */
+
+#endif

+ 79 - 0
include/libaccess/acladmin.h

@@ -0,0 +1,79 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef __acladmin_h
+#define __acladmin_h
+
+
+/*
+ * Description (acladmin.h)
+ *
+ *	This file describes the interface to access control list (ACL)
+ *	administration functions.  This interface provides mechanisms
+ *	for inspecting, modifying, and writing out in text form ACL
+ *	structures.
+ */
+
+#include "aclstruct.h"
+
+NSPR_BEGIN_EXTERN_C
+
+/* Flags used for various functions */
+#define ACLF_NPREFIX	0x1		/* ACL name string is a name prefix */
+#define ACLF_REXACT	0x2		/* rights must match exactly */
+#define ACLF_RALL	0x4		/* must have all specified rights */
+
+/* Functions in acladmin.c */
+extern NSAPI_PUBLIC int aclDNSAddHost(char * newhost,
+				      char ***alist, int * asize);
+extern NSAPI_PUBLIC int aclDNSAddAliases(char * host,
+					 char ***alist, int * asize);
+extern NSAPI_PUBLIC int aclDNSPutHost(char * hname, int fqdn, int aliases,
+				      char ***alist, int * asize);
+extern NSAPI_PUBLIC int aclFindByName(ACContext_t * acc, char * aclname,
+			 char **rights, int flags, ACL_t **pacl);
+extern NSAPI_PUBLIC char * aclGetAuthMethod(ACL_t * acl, int dirno);
+extern NSAPI_PUBLIC char * aclGetDatabase(ACL_t * acl, int dirno);
+extern NSAPI_PUBLIC char **aclGetHosts(ACL_t * acl, int dirno, int clsno);
+extern NSAPI_PUBLIC char * aclGetPrompt(ACL_t * acl, int dirno);
+extern NSAPI_PUBLIC char **aclGetRights(ACL_t * acl);
+extern NSAPI_PUBLIC unsigned long aclGetRightsMask(ACContext_t * acc, char **rlist);
+extern NSAPI_PUBLIC char * aclGetSignature(ACL_t * acl);
+extern NSAPI_PUBLIC char **aclGetUsers(ACL_t * acl, int dirno, int clsno);
+extern NSAPI_PUBLIC int aclDNSFilterStrings(char **list, DNSFilter_t * dnf);
+extern NSAPI_PUBLIC int aclIPFilterStrings(char **list, IPFilter_t * ipf);
+extern NSAPI_PUBLIC int aclIdsToNames(char **list,
+			 USIList_t * uilptr, int uflag, Realm_t * rlm);
+extern NSAPI_PUBLIC int aclMakeNew(ACContext_t * acc, char * aclsig, char * aclname,
+		      char **rights, int flags, ACL_t **pacl);
+extern NSAPI_PUBLIC int aclPutAllowDeny(NSErr_t * errp, ACL_t * acl,
+			   int always, int allow, char **users, char **hosts);
+extern NSAPI_PUBLIC int aclPutAuth(NSErr_t * errp, ACL_t * acl,
+		      int always, int amethod, char * dbname, char * prompt);
+extern NSAPI_PUBLIC char * aclSafeIdent(char * str);
+extern NSAPI_PUBLIC int aclSetRights(ACL_t * acl, char **rights, int replace);
+extern NSAPI_PUBLIC int accWriteFile(ACContext_t * acc, char * filename, int flags);
+extern NSAPI_PUBLIC int aclStringGet(LEXStream_t * lst);
+extern NSAPI_PUBLIC int aclStringOpen(NSErr_t * errp,
+			 int slen, char * sptr, int flags, ACLFile_t **pacf);
+extern NSAPI_PUBLIC int aclCheckUsers(NSErr_t * errp, char * dbpath, char * usernames,
+			 char * groupnames, char ***uglist, char ***badulist,
+			 char ***badglist);
+extern NSAPI_PUBLIC int aclCheckHosts(NSErr_t * errp,
+			 int hexpand, char * dnsspecs, char * ipspecs,
+			 char ***hlist, char ***baddns, char ***badip);
+
+#ifdef NOTDEF
+extern int aclSetAuthMethod(ACL_t * acl, int dirno, char * amethod);
+extern int aclSetDatabase(ACL_t * acl, int dirno, char * dbname);
+extern int aclSetExecOptions(ACL_t * acl, char **options);
+extern int aclSetHosts(ACL_t * acl, int dirno, char **hostlist);
+extern int aclSetPrompt(ACL_t * acl, int dirno, char * prompt);
+extern int aclSetUsers(ACL_t * acl, int dirno, char **userlist);
+#endif /* NOTDEF */
+
+NSPR_END_EXTERN_C
+
+#endif /* __acladmin_h */

+ 56 - 0
include/libaccess/aclbuild.h

@@ -0,0 +1,56 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef __aclbuild_h
+#define __aclbuild_h
+
+/*
+ * Description (aclbuild.h)
+ *
+ *	This file describes the interface to a module which provides
+ *	functions for building Access Control List (ACL) structures
+ *	in memory.
+ */
+
+#include "usi.h"
+#include "nserror.h"
+#include "aclstruct.h"
+
+/* Define flags for aclAuthNameAdd() return value */
+#define ANA_GROUP	0x1		/* name matches group name */
+#define ANA_USER	0x2		/* name matches user name */
+#define ANA_DUP		0x4		/* name already in AuthNode_t */
+
+NSPR_BEGIN_EXTERN_C
+
+/* Functions in aclbuild.c */
+extern int accCreate(NSErr_t * errp, void * stp, ACContext_t **pacc);
+extern void accDestroy(ACContext_t * acc, int flags);
+extern int accDestroySym(Symbol_t * sym, void * argp);
+extern int accReadFile(NSErr_t * errp, char * aclfile, ACContext_t **pacc);
+extern int aclAuthDNSAdd(HostSpec_t **hspp, char * dnsspec, int fqdn);
+extern int aclAuthIPAdd(HostSpec_t **hspp, IPAddr_t ipaddr, IPAddr_t netmask);
+extern int aclAuthNameAdd(NSErr_t * errp, UserSpec_t * usp,
+			  Realm_t * rlm, char * name);
+extern ACClients_t * aclClientsDirCreate();
+extern int aclCreate(NSErr_t * errp,
+		     ACContext_t * acc, char * aclname, ACL_t **pacl);
+extern void aclDestroy(ACL_t * acl);
+extern void aclDelete(ACL_t * acl);
+extern int aclDirectiveAdd(ACL_t * acl, ACDirective_t * acd);
+extern ACDirective_t * aclDirectiveCreate();
+extern void aclDirectiveDestroy(ACDirective_t * acd);
+extern int aclDNSSpecDestroy(Symbol_t * sym, void * parg);
+extern void aclHostSpecDestroy(HostSpec_t * hsp);
+extern void aclRealmSpecDestroy(RealmSpec_t * rsp);
+extern int aclRightDef(NSErr_t * errp,
+		       ACContext_t * acc, char * rname, RightDef_t **prd);
+extern void aclRightSpecDestroy(RightSpec_t * rsp);
+extern UserSpec_t * aclUserSpecCreate();
+extern void aclUserSpecDestroy(UserSpec_t * usp);
+
+NSPR_END_EXTERN_C
+
+#endif /* __aclbuild_h */

+ 307 - 0
include/libaccess/aclerror.h

@@ -0,0 +1,307 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef __aclerror_h
+#define __aclerror_h
+
+/* ACL facility name string (in aclbuild.c) */
+NSPR_BEGIN_EXTERN_C
+extern char * ACL_Program;
+NSPR_END_EXTERN_C
+
+/* Define error identifiers */
+
+/* Errors generated in aclparse.c */
+
+/* aclAuthListParse() */
+#define ACLERR1000	1000	/* dynamic memory shortage */
+
+/* aclAuthHostsParse() */
+#define ACLERR1100	1100	/* unsupported list of host lists */
+#define ACLERR1120	1120	/* host list name not found where expected */
+#define ACLERR1140	1140	/* undefined host list name */
+#define ACLERR1160	1160	/* *unused* */
+#define ACLERR1180	1180	/* error adding IP filter entry */
+#define ACLERR1200	1200	/* error adding DNS filter entry */
+#define ACLERR1220	1220	/* ")" missing */
+
+/* aclAuthUsersParse() */
+#define ACLERR1300	1300	/* *unused* */
+#define ACLERR1320	1320	/* *unused* */
+#define ACLERR1340	1340	/* *unused* */
+#define ACLERR1360	1360	/* undefined user or group name */
+#define ACLERR1380	1380	/* duplicate user or group name */
+#define ACLERR1400	1400	/* ")" missing */
+#define ACLERR1420	1420	/* empty auth-user-elem */
+#define ACLERR1440	1440	/* duplicate or conflicting use of "all" */
+#define ACLERR1460	1460	/* duplicate or conflicting use of "any" */
+#define ACLERR1480	1480	/* conflicting use of "all" or "any" */
+#define ACLERR1500	1500	/* insufficient dynamic memory */
+#define ACLERR1520	1520	/* insufficient dynamic memory */
+
+/* aclDirectivesParse() */
+#define ACLERR1600	1600	/* dir-access missing */
+#define ACLERR1620	1620	/* invalid dir-access specification */
+#define ACLERR1640	1640	/* error adding ACD_AUTH directive to ACL */
+#define ACLERR1650	1650	/* error adding directive to ACL */
+#define ACLERR1660	1660	/* insufficient dynamic memory */
+#define ACLERR1680	1680	/* insufficient dynamic memory */
+#define ACLERR1685	1685	/* insufficient dynamic memory */
+#define ACLERR1690	1690	/* error adding directive to ACL */
+#define ACLERR1695	1695	/* error in "execute" directive */
+
+/* aclACLParse() */
+#define ACLERR1700	1700	/* ACL statement missing */
+#define ACLERR1720	1720	/* ACL name missing */
+#define ACLERR1740	1740	/* opening "{" missing */
+#define ACLERR1760	1760	/* closing "}" missing */
+#define ACLERR1780	1780	/* unrecognized ACL statement */
+
+/* aclFileOpen() */
+#define ACLERR1900	1900	/* file open error */
+#define ACLERR1920	1920	/* memory shortage for ACLFile_t */
+#define ACLERR1940	1940	/* memory shortage for token */
+#define ACLERR1960	1960	/* memory shortage for LEX stream */
+
+/* aclGetDNSString() */
+#define ACLERR2100	2100	/* */
+#define ACLERR2120	2120	/* */
+#define ACLERR2140	2140	/* */
+
+/* aclGetIPAddr() */
+#define ACLERR2200	2200	/* */
+#define ACLERR2220	2220	/* */
+#define ACLERR2240	2240	/* */
+#define ACLERR2260	2260	/* */
+#define ACLERR2280	2280	/* */
+#define ACLERR2300	2300	/* */
+#define ACLERR2320	2320	/* */
+
+/* aclGetToken() */
+#define ACLERR2400	2400	/* aclGetToken() parse error */
+
+/* aclParseInit() */
+
+/* aclRealmSpecParse() */
+#define ACLERR2500	2500	/* missing realm name */
+#define ACLERR2520	2520	/* undefined realm name */
+#define ACLERR2540	2540	/* insufficient dynamic memory */
+#define ACLERR2560	2560	/* missing realm directive */
+#define ACLERR2570	2570	/* missing database filespec */
+#define ACLERR2580	2580	/* missing authentication method name */
+#define ACLERR2600	2600	/* unknown authentication method name */
+#define ACLERR2605	2605	/* realm prompt string missing */
+#define ACLERR2610	2610	/* unknown realm directive */
+#define ACLERR2620	2620	/* missing "}" */
+
+/* aclRightsParse() */
+#define ACLERR2700	2700	/* missing rights list element */
+#define ACLERR2720	2720	/* missing rights list name */
+#define ACLERR2740	2740	/* undefined rights list name */
+#define ACLERR2760	2760	/* insufficient dynamic memory */
+#define ACLERR2780	2780	/* insufficient dynamic memory */
+#define ACLERR2800	2800	/* error creating access right definition */
+#define ACLERR2820	2820	/* insufficient dynamic memory */
+#define ACLERR2840	2840	/* missing ")" */
+
+/* aclGetFileSpec() */
+#define ACLERR2900	2900	/* skip over whitespace failed */
+#define ACLERR2920	2920	/* scan over filename failed */
+#define ACLERR2940	2940	/* missing filename */
+
+/* aclStringOpen() */
+#define ACLERR5000	5000	/* memory shortage for ACLFile_t */
+#define ACLERR5020	5020	/* memory shortage for token */
+#define ACLERR5040	5040	/* memory shortage for LEX stream */
+
+/* Errors generated in aclbuild.c */
+
+/* accCreate() */
+#define ACLERR3000	3000		/* insufficient dynamic memory */
+#define ACLERR3020	3020		/* insufficient dynamic memory */
+
+/* accFileRead() */
+#define ACLERR3100	3100		/* error initializing ACL parser */
+#define ACLERR3120	3120		/* error creating ACL symbol table */
+
+/* aclCreate() */
+#define ACLERR3200	3200		/* insufficient dynamic memory */
+#define ACLERR3220	3220		/* duplicate ACL name */
+
+/* aclAuthNameAdd() */
+#define ACLERR3400	3400		/* realm missing for user/group name */
+#define ACLERR3420	3420		/* error opening authentication DB */
+#define ACLERR3440	3440		/* error finding name in DB */
+#define ACLERR3460	3460		/* insufficient dynamic memory */
+
+/* aclRightDef() */
+#define ACLERR3600	3600		/* insufficient dynamic memory */
+#define ACLERR3620	3620		/* add right to symbol table failed */
+
+/* ACL_ListPostParseForAuth() */
+#define ACLERR3800	3800		/* Undefined method/database */
+#define ACLERR3810	3810		/* insufficient dynamic memory */
+
+/* Register.cpp */
+#define ACLERR3900	3900		/* Duplicate LAS registered */
+
+/* ACL_EvalBuildContext */
+#define ACLERR4000	4000		/* Unable to create context hash */
+#define ACLERR4010	4010		/* Unable to alloc cache structure */
+#define ACLERR4020	4020		/* Unable to alloc ACE entry */
+#define ACLERR4030	4030		/* Unable to alloc ACE entry */
+#define ACLERR4040	4040		/* Unable to alloc Auth Ptr Array */
+#define ACLERR4050	4050		/* Unable to alloc Auth Ptr Array */
+
+/* ACL_EvalTestRights */
+#define ACLERR4100	4100		/* Interim absolute, non-allow value */
+#define ACLERR4110	4110		/* BuildContext call failed */
+
+/* ACL_ModuleRegister */
+#define ACLERR4200	4200		/* module name missing */
+#define ACLERR4210	4210		/* module registration call failed */
+
+/* ACL_GetAttribute */
+#define ACLERR4300	4300		/* Couldn't determine method */
+#define ACLERR4310	4310		/* Couldn't locate Getter */
+#define ACLERR4320	4320		/* Couldn't Set Attr */
+#define ACLERR4330	4330		/* Couldn't Get Attr */
+#define ACLERR4340	4340		/* All getters declined */
+#define ACLERR4350	4350		/* All getters declined */
+#define ACLERR4360	4360		/* All getters declined */
+#define ACLERR4370	4370		/* All getters declined */
+#define ACLERR4380	4380		/* Couldn't determine dbtype */
+
+/* reg_dbname_internal */
+#define ACLERR4400	4400		/* dbtype not defined yet */
+#define ACLERR4410	4410		/* dbtype not defined yet */
+#define ACLERR4420	4420		/* out of memory */
+
+/* ACL_DatabaseRegister */
+#define ACLERR4500	4500		/* database name is missing */
+
+/* ACL_ReadDbMapFile */
+#define	ACLERR4600	4600		/* Error reading the Map file */
+#define	ACLERR4610	4610		/* Couldn't determine dbtype */
+#define	ACLERR4620	4620		/* Missing URL for database */
+#define	ACLERR4630	4630		/* Invalid proprty pair */
+#define	ACLERR4640	4640		/* Register database failed */
+#define	ACLERR4650	4650		/* Default database not LDAP */
+#define	ACLERR4660	4660		/* Multiple default databases */
+#define	ACLERR4670	4670		/* No default database */
+
+/* LASDnsBuild */
+#define	ACLERR4700	4700		/* Cannot allocatae hash */
+#define	ACLERR4710	4710		/* Cannot add token to hash */
+#define	ACLERR4720	4720		/* Cannot add token to hash */
+#define	ACLERR4730	4730		/* Cannot add token to hash */
+#define	ACLERR4740	4740		/* Cannot add token to hash */
+#define	ACLERR4750	4750		/* Cannot add token to hash */
+#define	ACLERR4760	4760		/* Cannot add token to hash */
+
+/* LASDnsEval */
+#define	ACLERR4800	4800		/* Wrong attribute name */
+#define	ACLERR4810	4810		/* Illegal comparator */
+#define	ACLERR4820	4820		/* Cannot allocate context struct */
+#define	ACLERR4830	4830		/* Cannot get DNS attribute */
+
+/* LASGroupEval */
+#define ACLERR4900	4900		/* wrong attribute */
+#define ACLERR4910	4910		/* bad comparator */
+#define ACLERR4920	4920		/* unable to get database name */
+
+/* LASIpTreeAllocNode */
+#define	ACLERR5000	5000		/* Cannot allocate IP tree */
+
+/* LASIpAddPattern */
+#define	ACLERR5100	5100		/* Cannot allocate IP tree node */
+#define	ACLERR5110	5110		/* Cannot allocate IP tree node */
+
+/* LASIpEval */
+#define	ACLERR5200	5200		/* Wrong attribute */
+#define	ACLERR5210	5210		/* Bad comparator */
+#define	ACLERR5220	5220		/* Cannot get session pointer */
+#define	ACLERR5230	5230		/* Cannot allocate context */
+#define	ACLERR5240	5240		/* Tested 32 bits without conclusion */
+
+/* LASProgramEval */
+#define	ACLERR5300	5300		/* Wrong attribute */
+#define	ACLERR5310	5310		/* Bad comparator */
+#define	ACLERR5320	5320		/* Can't get request pointer */
+#define	ACLERR5330	5330		/* Invalid program expression */
+#define	ACLERR5340	5340		/* Rejecting Request */
+
+/* LASDayOfWeekEval */
+#define	ACLERR5400	5400		/* wrong attribute */
+#define	ACLERR5410	5410		/* bad comparator */
+
+/* LASTimeOfDayEval */
+#define ACLERR5600	5600		/* wrong attribute */
+#define ACLERR5610	5610		/* bad comparator */
+
+/* LASUserEval */
+#define ACLERR5700	5700		/* wrong attribute */
+#define ACLERR5710	5710		/* bad comparator */
+#define ACLERR5720	5720		/* Out of memory */
+
+/* ldapacl.cpp */
+#define	ACLERR5800	5800		/* missing the database url */
+#define	ACLERR5810	5810		/* missing the database name */
+#define	ACLERR5820	5820		/* error parsing the db url */
+#define	ACLERR5830	5830		/* unable to get db name */
+#define ACLERR5840	5840		/* can't get parsed db name */
+#define ACLERR5850	5850		/* can't init ldap connection */
+#define ACLERR5860	5860		/* passwd check ldap error */
+#define ACLERR5870	5870		/* Out of memory */
+#define ACLERR5880	5880		/* User doesn't exist anymore */
+#define ACLERR5890	5890		/* PList error */
+
+/* get_user_ismember_ldap */
+#define ACLERR5900	5900		/* Can't get db name */
+#define ACLERR5910	5910		/* Can't get parsed db name */
+#define	ACLERR5920	5920		/* Out of memory */
+#define	ACLERR5930	5930		/* Can't init ldap connection */
+#define	ACLERR5940	5940		/* Group doesn't exist */
+#define	ACLERR5950	5950		/* LDAP error */
+
+/* ACL_LDAPDatabaseHandle */
+#define ACLERR6000	6000		/* Not a registered db */
+#define ACLERR6010	6010		/* Not an LDAP db */
+#define ACLERR6020	6020		/* Out of memory */
+#define ACLERR6030	6030		/* Can't init ldap connection */
+#define ACLERR6040	6040		/* Can't bind to ldap server */
+
+
+
+/* Define error return codes */
+#define ACLERRNOMEM	-1		/* insufficient dynamic memory */
+#define ACLERROPEN	-2		/* file open error */
+#define ACLERRDUPSYM	-3		/* duplicate symbol */
+#define ACLERRSYNTAX	-4		/* syntax error */
+#define ACLERRUNDEF	-5		/* undefined symbol */
+#define ACLERRADB	-6		/* authentication DB access error */
+#define ACLERRPARSE	-7		/* ACL parsing error */
+#define ACLERRNORLM	-8		/* missing authentication realm */
+#define ACLERRIO	-9		/* IO error */
+#define ACLERRINTERNAL	-10		/* internal processing error */
+/* #define ACLERRFAIL	-11 */	/* defined in include/public/nsacl/acldef.h */
+#define ACLERRINVAL	-12		/* invalid argument */
+#define ACLERRCONFIG	-13		/* auth realms don't math acl */
+
+#include "nserror.h"
+
+#ifndef PUBLIC_NSACL_ACLDEF_H
+#include "public/nsacl/acldef.h"
+#endif /* !PUBLIC_NSACL_ACLDEF_H */
+
+NSPR_BEGIN_EXTERN_C
+
+/* Functions in aclerror.c */
+extern void aclErrorFmt(NSErr_t * errp,
+			char * msgbuf, int maxlen, int maxdepth);
+
+NSPR_END_EXTERN_C
+
+#endif /* __aclerror_h */

+ 37 - 0
include/libaccess/acleval.h

@@ -0,0 +1,37 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef __acleval_h
+#define __acleval_h
+
+/*
+ * Description (acleval.h)
+ *
+ *	This file defines the interface to the ACL evaluation module.
+ */
+
+#include "nserror.h"
+#include "nsauth.h"
+#include "aclstruct.h"
+
+/* Define values returned by lookup routines */
+#define ACL_NOMATCH	0		/* no match */
+#define ACL_IPMATCH	0x1		/* IP address match */
+#define ACL_DNMATCH	0x2		/* DNS name match */
+#define ACL_USMATCH	0x4		/* user name match */
+#define ACL_GRMATCH	0x8		/* user is member of group */
+
+NSPR_BEGIN_EXTERN_C
+
+/* Functions in acleval.c */
+extern int aclDNSLookup(DNSFilter_t * dnf,
+			char * dnsspec, int fqdn, char **match);
+extern int aclIPLookup(IPFilter_t * ipf, IPAddr_t ipaddr, void **match);
+extern int aclUserLookup(UidUser_t * uup, UserObj_t * uoptr);
+extern int aclEvaluate(ACL_t * acl, USI_t arid, ClAuth_t * clauth, int * padn);
+
+NSPR_END_EXTERN_C
+
+#endif /* __acleval_h */

+ 52 - 0
include/libaccess/aclglobal.h

@@ -0,0 +1,52 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+/*
+**	Header file containing global data elements.  These are duplicated
+**	when a cache flush is done.
+*/
+
+#include	<libaccess/acl.h>
+
+struct ACLGlobal_s {
+	ACLListHandle_t	*masterlist;
+	pool_handle_t	*pool;	/* Deallocate at the start of cache flush */
+	pool_handle_t	*databasepool;
+	pool_handle_t	*methodpool;
+	PRHashTable	*urihash;
+	PRHashTable	*urigethash;
+	PRHashTable	*listhash;
+	PRHashTable	*evalhash;
+	PRHashTable	*flushhash;
+	PRHashTable	*methodhash;
+	PRHashTable	*dbtypehash;
+	PRHashTable	*dbnamehash;
+	PRHashTable	*attrgetterhash;
+	PRHashTable	*userLdbHash; /* user's LDAP handle hash */
+};
+
+typedef struct ACLGlobal_s ACLGlobal_t;
+typedef struct ACLGlobal_s *ACLGlobal_p;
+
+#define acl_uri_hash_pool	ACLGlobal->pool
+#define acl_uri_hash		ACLGlobal->urihash
+#define acl_uri_get_hash	ACLGlobal->urigethash
+#define ACLListHash		ACLGlobal->listhash
+#define	ACLLasEvalHash		ACLGlobal->evalhash
+#define ACLLasFlushHash		ACLGlobal->flushhash
+#define ACLMethodHash		ACLGlobal->methodhash
+#define	ACLDbTypeHash		ACLGlobal->dbtypehash
+#define	ACLDbNameHash		ACLGlobal->dbnamehash
+#define	ACLAttrGetterHash	ACLGlobal->attrgetterhash
+#define	ACLUserLdbHash		ACLGlobal->userLdbHash
+#define ACL_DATABASE_POOL	ACLGlobal->databasepool
+#define ACL_METHOD_POOL		ACLGlobal->methodpool
+
+NSPR_BEGIN_EXTERN_C
+
+extern ACLGlobal_p ACLGlobal;
+extern ACLGlobal_p oldACLGlobal;
+
+NSPR_END_EXTERN_C

+ 112 - 0
include/libaccess/aclparse.h

@@ -0,0 +1,112 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef __aclparse_h
+#define __aclparse_h
+
+/*
+ * Description (aclparse.h)
+ *
+ *	This file describes the interface to a parser for files
+ *	containing Access Control List (ACL) definitions.  The parser
+ *	uses the services of the aclbuild module to construct an
+ *	in-memory representation of the ACLs it parses.
+ */
+
+#include "nserror.h"
+#include "aclbuild.h"
+
+/* Define keywords */
+#define KEYWORD_ACL	"acl"
+#define KEYWORD_ALL	"all"
+#define KEYWORD_ALLOW	"allow"
+#define KEYWORD_ANY	"anyone"
+#define KEYWORD_AT	"at"
+#define KEYWORD_AUTH	"authenticate"
+#define KEYWORD_BASIC	"basic"
+#define KEYWORD_DATABASE "database"
+#define KEYWORD_DEFAULT	"default"
+#define KEYWORD_DENY	"deny"
+#define KEYWORD_EXECUTE	"execute"
+#define KEYWORD_HOSTS	"hosts"
+#define KEYWORD_IF	"if"
+#define KEYWORD_IN	"in"
+#define KEYWORD_INCLUDE	"include"
+#define KEYWORD_METHOD	"method"
+#define KEYWORD_PROMPT	"prompt"
+#define KEYWORD_REALM	"realm"
+#define KEYWORD_RIGHTS	"rights"
+#define KEYWORD_SSL	"ssl"
+
+/* Define character classes */
+#define CCM_WS		0x1	/* whitespace */
+#define CCM_NL		0x2	/* newline */
+#define CCM_SPECIAL	0x4	/* special characters */
+#define CCM_DIGIT	0x8	/* digits */
+#define CCM_LETTER	0x10	/* letters */
+#define CCM_HYPHEN	0x20	/* hyphen */
+#define CCM_USCORE	0x40	/* underscore */
+#define CCM_FILESPEC	0x80	/* filename special characters */
+
+#define CCM_HYPUND	(CCM_HYPHEN|CCM_USCORE)
+#define CCM_IDENT	(CCM_LETTER|CCM_DIGIT|CCM_HYPUND)
+#define CCM_FILENAME	(CCM_LETTER|CCM_DIGIT|CCM_FILESPEC)
+
+/* Define token numbers */
+#define TOKEN_ERROR	-1	/* error in reading data stream */
+#define TOKEN_EOF	0	/* end-of-file */
+#define TOKEN_EOS	1	/* end-of-statement */
+#define TOKEN_IDENT	2	/* identifier */
+#define TOKEN_NUMBER	3	/* number */
+#define TOKEN_COMMA	4	/* comma */
+#define TOKEN_SEMI	5	/* semicolon */
+#define TOKEN_PERIOD	6	/* period */
+#define TOKEN_LPAREN	7	/* left parenthesis */
+#define TOKEN_RPAREN	8	/* right parenthesis */
+#define TOKEN_LBRACE	9	/* left brace */
+#define TOKEN_RBRACE	10	/* right brace */
+#define TOKEN_AT	11	/* at sign */
+#define TOKEN_PLUS	12	/* plus sign */
+#define TOKEN_STAR	13	/* asterisk */
+#define TOKEN_STRING	14	/* quoted string */
+#define TOKEN_HUH	15	/* unrecognized input */
+
+/* Define flags bits for aclGetToken() */
+#define AGT_NOSKIP	0x1		/* don't skip leading whitespace */
+#define AGT_APPEND	0x2		/* append next to token buffer */
+
+NSPR_BEGIN_EXTERN_C
+
+extern void * aclChTab;			/* character table for ACL parsing */
+
+/* Functions in aclparse.c */
+extern int aclAuthListParse(NSErr_t * errp, ACLFile_t * acf,
+			    ACContext_t * acc, Realm_t * rlm,
+			    ACClients_t **clsp);
+extern int aclAuthHostsParse(NSErr_t * errp, ACLFile_t * acf,
+			     ACContext_t * acc, HostSpec_t **hspp);
+extern int aclAuthUsersParse(NSErr_t * errp, ACLFile_t * acf,
+			     Realm_t * rlm, UserSpec_t **uspp, char ***elist);
+extern int aclDirectivesParse(NSErr_t * errp, ACLFile_t * acf, ACL_t * acl);
+extern int aclACLParse(NSErr_t * errp,
+		       ACLFile_t * acf, ACContext_t * acc, int flags);
+extern void aclFileClose(ACLFile_t * acf, int flags);
+extern int aclFileOpen(NSErr_t * errp,
+		       char * filename, int flags, ACLFile_t **pacf);
+extern int aclGetDNSString(NSErr_t * errp, ACLFile_t * acf);
+extern int aclGetFileSpec(NSErr_t * errp, ACLFile_t * acf, int flags);
+extern int aclGetIPAddr(NSErr_t * errp,
+			ACLFile_t * acf, IPAddr_t * pip, IPAddr_t * pmask);
+extern int aclGetToken(NSErr_t * errp, ACLFile_t * acf, int flags);
+extern int aclParseInit();
+extern int aclRealmSpecParse(NSErr_t * errp, ACLFile_t * acf,
+			     ACContext_t * acc, RealmSpec_t **rspp);
+extern int aclRightsParse(NSErr_t * errp, ACLFile_t * acf, ACContext_t * acc,
+			  RightSpec_t **rights);
+extern int aclStreamGet(LEXStream_t * lst);
+
+NSPR_END_EXTERN_C
+
+#endif /* __aclparse_h */

+ 156 - 0
include/libaccess/aclproto.h

@@ -0,0 +1,156 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef ACL_PROTO_HEADER
+#define ACL_PROTO_HEADER
+
+#ifndef NOINTNSACL
+#define INTNSACL
+#endif /* !NOINTNSACL */
+
+#ifndef PUBLIC_NSACL_ACLDEF_H
+#include "public/nsacl/acldef.h"
+#endif /* !PUBLIC_NSACL_ACLDEF_H */
+
+#ifdef INTNSACL
+
+NSPR_BEGIN_EXTERN_C
+
+/*********************************************************************
+ *  ACL language and file interfaces
+ *********************************************************************/
+
+NSAPI_PUBLIC ACLListHandle_t * ACL_ParseFile(NSErr_t *errp, char *filename);
+NSAPI_PUBLIC ACLListHandle_t * ACL_ParseString(NSErr_t *errp, char *buffer);
+NSAPI_PUBLIC int ACL_Decompose(NSErr_t *errp, char **acl, ACLListHandle_t *acl_list);
+NSAPI_PUBLIC int ACL_WriteString(NSErr_t *errp, char **acl, ACLListHandle_t *acllist);
+NSAPI_PUBLIC int ACL_WriteFile(NSErr_t *errp, char *filename, ACLListHandle_t *acllist);
+NSAPI_PUBLIC int ACL_FileRenameAcl(NSErr_t *errp, char *filename, char *acl_name, char *new_acl_name, int flags);
+NSAPI_PUBLIC int ACL_FileDeleteAcl(NSErr_t *errp, char *filename, char *acl_name, int flags);
+NSAPI_PUBLIC int ACL_FileGetAcl(NSErr_t *errp, char *filename, char *acl_name, char **acl_text, int flags);
+NSAPI_PUBLIC int ACL_FileSetAcl(NSErr_t *errp, char *filename, char *acl_text, int flags);
+NSAPI_PUBLIC int ACL_FileMergeAcl(NSErr_t *errp, char *filename, char **acl_name_list, char *new_acl_name, int  flags);
+NSAPI_PUBLIC int ACL_FileMergeFile(NSErr_t *errp, char *filename, char **file_list, int  flags);
+
+
+/*********************************************************************
+ *  ACL Expression construction interfaces
+ *********************************************************************/
+NSAPI_PUBLIC ACLExprHandle_t *ACL_ExprNew(const ACLExprType_t expr_type);
+NSAPI_PUBLIC void ACL_ExprDestroy(ACLExprHandle_t *expr);
+NSAPI_PUBLIC int ACL_ExprSetPFlags(NSErr_t *errp, ACLExprHandle_t *expr, PFlags_t flags);
+NSAPI_PUBLIC int ACL_ExprClearPFlags(NSErr_t *errp, ACLExprHandle_t *expr);
+NSAPI_PUBLIC int ACL_ExprTerm(NSErr_t *errp, ACLExprHandle_t *acl_expr, char *attr_name, CmpOp_t cmp, char *attr_pattern);
+NSAPI_PUBLIC int ACL_ExprNot(NSErr_t *errp, ACLExprHandle_t *acl_expr);
+NSAPI_PUBLIC int ACL_ExprAnd(NSErr_t *errp, ACLExprHandle_t *acl_expr);
+NSAPI_PUBLIC int ACL_ExprOr(NSErr_t *errp, ACLExprHandle_t *acl_expr);
+NSAPI_PUBLIC int ACL_ExprAddAuthInfo(ACLExprHandle_t *expr, PList_t auth_info);
+NSAPI_PUBLIC int ACL_ExprAddArg(NSErr_t *errp, ACLExprHandle_t *expr, char *arg);
+NSAPI_PUBLIC int ACL_ExprSetDenyWith(NSErr_t *errp, ACLExprHandle_t *expr, char *deny_type, char *deny_response);
+NSAPI_PUBLIC int ACL_ExprGetDenyWith(NSErr_t *errp, ACLExprHandle_t *expr, char **deny_type, char **deny_response);
+
+/*********************************************************************
+ * ACL manipulation
+ *********************************************************************/
+
+NSAPI_PUBLIC ACLHandle_t * ACL_AclNew(NSErr_t *errp, char *tag);
+NSAPI_PUBLIC void ACL_AclDestroy(NSErr_t *errp, ACLHandle_t *acl);
+NSAPI_PUBLIC int ACL_ExprAppend(NSErr_t *errp, ACLHandle_t *acl, ACLExprHandle_t *expr);
+NSAPI_PUBLIC const char *ACL_AclGetTag(ACLHandle_t *acl);
+
+/*********************************************************************
+ * ACL list manipulation
+ *********************************************************************/
+
+NSAPI_PUBLIC ACLListHandle_t * ACL_ListNew(NSErr_t *errp);
+NSAPI_PUBLIC int ACL_ListConcat(NSErr_t *errp, ACLListHandle_t *acl_list1, ACLListHandle_t *acl_list2, int flags);
+NSAPI_PUBLIC int ACL_ListAppend(NSErr_t *errp, ACLListHandle_t *acllist, ACLHandle_t *acl, int flags);
+NSAPI_PUBLIC void ACL_ListDestroy(NSErr_t *errp, ACLListHandle_t *acllist);
+NSAPI_PUBLIC ACLHandle_t * ACL_ListFind(NSErr_t *errp, ACLListHandle_t *acllist, char *aclname, int flags);
+NSAPI_PUBLIC int ACL_ListAclDelete(NSErr_t *errp, ACLListHandle_t *acl_list, char *acl_name, int flags);
+NSAPI_PUBLIC int ACL_ListGetNameList(NSErr_t *errp, ACLListHandle_t *acl_list, char ***name_list);
+NSAPI_PUBLIC int ACL_FileGetNameList(NSErr_t *errp, char * filename, char ***name_list);
+NSAPI_PUBLIC int ACL_NameListDestroy(NSErr_t *errp, char **name_list);
+NSAPI_PUBLIC ACLHandle_t *ACL_ListGetFirst(ACLListHandle_t *acl_list,
+                                           ACLListEnum_t *acl_enum);
+NSAPI_PUBLIC ACLHandle_t *ACL_ListGetNext(ACLListHandle_t *acl_list,
+                                           ACLListEnum_t *acl_enum);
+
+/* Only used for asserts.  Probably shouldn't be publicly advertized */
+extern int ACL_AssertAcllist( ACLListHandle_t *acllist );
+
+/* Need to be ACL_LIB_INTERNAL */
+NSAPI_PUBLIC int ACL_ListPostParseForAuth(NSErr_t *errp, ACLListHandle_t *acl_list);
+
+/*********************************************************************
+ * ACL evaluation 
+ *********************************************************************/
+
+NSAPI_PUBLIC int ACL_EvalTestRights(NSErr_t *errp, ACLEvalHandle_t *acleval, char **rights, char **map_generic, char **deny_type, char **deny_response, char **acl_tag, int *expr_num);
+NSAPI_PUBLIC int ACL_CachableAclList(ACLListHandle_t *acllist);
+NSAPI_PUBLIC ACLEvalHandle_t * ACL_EvalNew(NSErr_t *errp, pool_handle_t *pool);
+NSAPI_PUBLIC void ACL_EvalDestroy(NSErr_t *errp, pool_handle_t *pool, ACLEvalHandle_t *acleval);
+NSAPI_PUBLIC void ACL_EvalDestroyNoDecrement(NSErr_t *errp, pool_handle_t *pool, ACLEvalHandle_t *acleval);
+NSAPI_PUBLIC int ACL_ListDecrement(NSErr_t *errp, ACLListHandle_t *acllist);
+NSAPI_PUBLIC int ACL_EvalSetACL(NSErr_t *errp, ACLEvalHandle_t *acleval, ACLListHandle_t *acllist);
+NSAPI_PUBLIC PList_t ACL_EvalGetSubject(NSErr_t *errp, ACLEvalHandle_t *acleval);
+NSAPI_PUBLIC int ACL_EvalSetSubject(NSErr_t *errp, ACLEvalHandle_t *acleval, PList_t subject);
+NSAPI_PUBLIC PList_t ACL_EvalGetResource(NSErr_t *errp, ACLEvalHandle_t *acleval);
+NSAPI_PUBLIC int ACL_EvalSetResource(NSErr_t *errp, ACLEvalHandle_t *acleval, PList_t resource);
+
+/*
+ *	The following entities are only meant to be called by whole server
+ *	products that include libaccess.  E.g. the HTTP server, the Directory
+ *	server etc.  They should not be called by ACL callers, LASs etc.
+ */
+
+/*********************************************************************
+ * ACL misc routines 
+ *********************************************************************/
+
+NSAPI_PUBLIC int ACL_Init(void);
+NSAPI_PUBLIC int ACL_InitPostMagnus(void);
+NSAPI_PUBLIC int ACL_LateInitPostMagnus(void);
+NSAPI_PUBLIC void ACL_ListHashUpdate(ACLListHandle_t **acllistp);
+NSAPI_PUBLIC void ACL_GetPathAcls(char *path, ACLListHandle_t **acllist_p, char *prefix, ACLListHandle_t *masterlist);
+NSAPI_PUBLIC int ACL_ReadDbMapFile(NSErr_t *errp, const char *map_file, int default_only); 
+
+NSAPI_PUBLIC int ACL_MethodNamesGet(NSErr_t *errp, char ***names, int *count);
+NSAPI_PUBLIC int ACL_MethodNamesFree(NSErr_t *errp, char **names, int count);
+
+NSAPI_PUBLIC int ACL_DatabaseNamesGet(NSErr_t *errp, char ***names, int *count);
+NSAPI_PUBLIC int ACL_DatabaseNamesFree(NSErr_t *errp, char **names, int count);
+
+NSAPI_PUBLIC int ACL_InitAttr2Index(void);
+NSAPI_PUBLIC int ACL_Attr2Index(const char *attrname);
+
+/*********************************************************************
+ * ACL cache and flush utility 
+ *********************************************************************/
+
+NSAPI_PUBLIC int ACL_CacheCheck(char *uri, ACLListHandle_t **acllist_p);
+NSAPI_PUBLIC int ACL_CacheCheckGet(char *uri, ACLListHandle_t **acllist_p);
+NSAPI_PUBLIC void ACL_CacheEnter(char *uri, ACLListHandle_t **acllist_p);
+NSAPI_PUBLIC void ACL_CacheEnterGet(char *uri, ACLListHandle_t **acllist_p);
+NSAPI_PUBLIC int ACL_ListHashCheck(ACLListHandle_t **acllist_p);
+NSAPI_PUBLIC void ACL_ListHashEnter(ACLListHandle_t **acllist_p);
+NSAPI_PUBLIC int ACL_CacheFlush(void);
+NSAPI_PUBLIC void ACL_Restart(void *clntData);
+NSAPI_PUBLIC void ACL_CritEnter(void);
+NSAPI_PUBLIC void ACL_CritExit(void);
+
+/*********************************************************************
+ * ACL CGI routines
+ *********************************************************************/
+
+NSAPI_PUBLIC void ACL_OutputSelector(char *name, char **item);
+
+
+NSPR_END_EXTERN_C
+
+#endif /* INTNSACL */
+
+#endif
+

+ 264 - 0
include/libaccess/aclstruct.h

@@ -0,0 +1,264 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef __aclstruct_h
+#define __aclstruct_h
+
+/*
+ * Description (aclstruct.h)
+ *
+ *	This file defines types and data structures used to construct
+ *	representations of Access Control Lists (ACLs) in memory.
+ */
+
+#include "base/systems.h"
+#include "base/file.h"
+#include "base/lexer.h"
+#include "nsauth.h"		/* authentication types */
+#include "symbols.h"		/* typed symbol support */
+#include "ipfstruct.h"		/* IP address filter structures */
+#include "dnfstruct.h"		/* DNS name filter structures */
+
+
+NSPR_BEGIN_EXTERN_C
+
+/* Forward type definitions */
+typedef struct ACL_s ACL_t;
+
+/*
+ * Description (InetHost_t)
+ *
+ *	This type defines a structure which represents a list of Internet
+ *	hosts by IP address and netmask, or by fully or partially
+ *	qualified DNS name.
+ */
+
+typedef struct InetHost_s InetHost_t;
+struct InetHost_s {
+    IPFilter_t inh_ipf;			/* reference to IP filter */
+    DNSFilter_t inh_dnf;		/* reference to DNS filter */
+};
+
+/*
+ * Description (HostSpec_t)
+ *
+ *	This type describes a named list of hosts.
+ */
+
+typedef struct HostSpec_s HostSpec_t;
+struct HostSpec_s {
+    Symbol_t hs_sym;			/* symbol name, type ACLSYMHOST */
+    InetHost_t hs_host;			/* host information */
+};
+
+/*
+ * Description (UidUser_t)
+ *
+ *	This type represents a list of users and groups using unique
+ *	integer identifiers.
+ */
+
+typedef struct UidUser_s UidUser_t;
+struct UidUser_s {
+    USIList_t uu_user;			/* list of user ids */
+    USIList_t uu_group;			/* list of group ids */
+};
+
+/*
+ * Description (UserSpec_t)
+ *
+ *	This type describes a named list of users and groups.
+ */
+
+typedef struct UserSpec_s UserSpec_t;
+struct UserSpec_s {
+    Symbol_t us_sym;			/* list name, type ACLSYMUSER */
+    int us_flags;			/* bit flags */
+#define ACL_USALL	0x1		/* any authenticated user */
+
+    UidUser_t us_user;			/* user list structure */
+};
+
+/*
+ * Description (ACClients_t)
+ *
+ *	This type defines the structure of action-specific information
+ *	for access control directives with action codes ACD_ALLOW and
+ *	ACD_DENY.  These directives specify access control constraints
+ *	on users/groups and hosts.
+ */
+
+typedef struct ACClients_s ACClients_t;
+struct ACClients_s {
+    ACClients_t * cl_next;		/* list link */
+    HostSpec_t * cl_host;		/* host specification pointer */
+    UserSpec_t * cl_user;		/* user list pointer */
+};
+
+/*
+ * Description (RealmSpec_t)
+ *
+ *	This type describes a named realm.
+ */
+
+typedef struct RealmSpec_s RealmSpec_t;
+struct RealmSpec_s {
+    Symbol_t rs_sym;			/* realm name, type ACLSYMREALM */
+    Realm_t rs_realm;			/* realm information */
+};
+
+/*
+ * Description (ACAuth_t)
+ *
+ *	This type defines the structure of action-specific information
+ *	for an access control directive with action code ACD_AUTH,
+ *	which specifies information about authentication requirements.
+ */
+
+typedef struct ACAuth_s ACAuth_t;
+struct ACAuth_s {
+    RealmSpec_t * au_realm;		/* pointer to realm information */
+};
+
+/*
+ * Description (ACDirective_t)
+ *
+ *	This type defines a structure which represents an access control
+ *	directive.  Each directive specifies an access control action
+ *	to be taken during ACL evaluation.  The ACDirective_t structure
+ *	begins an action-specific structure which contains the
+ *	parameters for an action.
+ */
+
+typedef struct ACDirective_s ACDirective_t;
+struct ACDirective_s {
+    ACDirective_t * acd_next;		/* next directive in ACL */
+    short acd_action;			/* directive action code */
+    short acd_flags;			/* action modifier flags */
+
+    /* Begin action-specific information */
+    union {
+	ACClients_t * acu_cl;		/* ACD_ALLOW, ACD_DENY */
+	ACAuth_t acu_auth;		/* ACD_AUTH */
+    } acd_u;
+};
+
+#define acd_cl		acd_u.acu_cl
+#define acd_auth	acd_u.acu_auth
+
+/* Define acd_action codes */
+#define ACD_ALLOW	1		/* allow access */
+#define ACD_DENY	2		/* deny access */
+#define ACD_AUTH	3		/* specify authentication realm */
+#define ACD_EXEC	4		/* execute (conditionally) */
+
+/* Define acd_flags values */
+#define ACD_ACTION	0xf		/* bits reserved for acd_action */
+#define ACD_FORCE	0x10		/* force of action */
+#define ACD_DEFAULT	0		/* default action */
+#define ACD_ALWAYS	ACD_FORCE	/* immediate action */
+#define ACD_EXALLOW	0x20		/* execute if allow */
+#define ACD_EXDENY	0x40		/* execute if deny */
+#define ACD_EXAUTH	0x80		/* execute if authenticate */
+
+/*
+ * Description (RightDef_t)
+ *
+ *	This type describes a named access right.  Each access right has
+ *	an associated unique integer id.  A list of all access rights
+ *	known in an ACL context is maintained, with its head in the
+ *	ACContext_t structure.
+ */
+
+typedef struct RightDef_s RightDef_t;
+struct RightDef_s {
+    Symbol_t rd_sym;			/* right name, type ACLSYMRIGHT */
+    RightDef_t * rd_next;		/* next on ACContext_t list */
+    USI_t rd_id;			/* unique id */
+};
+
+/*
+ * Description (RightSpec_t)
+ *
+ *	This type describes a named list of access rights.
+ */
+
+typedef struct RightSpec_s RightSpec_t;
+struct RightSpec_s {
+    Symbol_t rs_sym;			/* list name, type ACLSYMRDEF */
+    USIList_t rs_list;			/* list of right ids */
+};
+
+/*
+ * Description (ACContext_t)
+ *
+ *	This type defines a structure that defines a context for a set
+ *	of Access Control Lists.  This includes references to an
+ *	authentication database, if any, and a symbol table containing
+ *	access right definitions.  It also serves as a list head for the
+ *	ACLs which are defined in the specified context.
+ */
+
+typedef struct ACContext_s ACContext_t;
+struct ACContext_s {
+    void * acc_stp;			/* symbol table handle */
+    ACL_t * acc_acls;			/* list of ACLs */
+    RightDef_t * acc_rights;		/* list of access right definitions */
+    int acc_refcnt;			/* reference count */
+};
+
+/*
+ * Description (ACL_t)
+ *
+ *	This type defines the structure that represents an Access Control
+ *	List (ACL).  An ACL has a user-assigned name and an internally
+ *	assigned identifier (which is an index in an object directory).
+ *	It references a list of access rights which are to be allowed or
+ *	denied, according to the ACL specifications.  It references an
+ *	ordered list of ACL directives, which specify who has and who does
+ *	not have the associated access rights.
+ */
+
+struct ACL_s {
+    Symbol_t acl_sym;			/* ACL name, type ACLSYMACL */
+    ACL_t * acl_next;			/* next ACL on a list */
+    ACContext_t * acl_acc;		/* context for this ACL */
+    USI_t acl_id;			/* id of this ACL */
+    int acl_refcnt;			/* reference count */
+    RightSpec_t * acl_rights;		/* access rights list */
+    ACDirective_t * acl_dirf;		/* first directive pointer */
+    ACDirective_t * acl_dirl;		/* last directive pointer */
+};
+
+/* Define symbol type codes */
+#define ACLSYMACL	0		/* ACL */
+#define ACLSYMRIGHT	1		/* access right */
+#define ACLSYMRDEF	2		/* access rights list */
+#define ACLSYMREALM	3		/* realm name */
+#define ACLSYMHOST	4		/* host specifications */
+#define ACLSYMUSER	5		/* user/group list */
+
+/*
+ * Description (ACLFile_t)
+ *
+ *	This type describes a structure containing information about
+ *	an open ACL description file.
+ */
+
+typedef struct ACLFile_s ACLFile_t;
+struct ACLFile_s {
+    ACLFile_t * acf_next;		/* list link */
+    char * acf_filename;		/* pointer to filename string */
+    LEXStream_t * acf_lst;		/* LEX stream handle */
+    SYS_FILE acf_fd;			/* file descriptor */
+    int acf_flags;			/* bit flags (unused) */
+    int acf_lineno;			/* current line number */
+    void * acf_token;			/* LEX token handle */
+    int acf_ttype;			/* current token type */
+};
+
+NSPR_END_EXTERN_C
+
+#endif /* __aclstruct_h */

+ 157 - 0
include/libaccess/attrec.h

@@ -0,0 +1,157 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef __attrec_h
+#define __attrec_h
+
+/*
+ * Description (attrec.h)
+ *
+ *	This file describes the encoding and decoding of attribute
+ *	records.  Attribute records consist of a sequence of items
+ *	of the form:
+ *
+ *		<tag><length><contents>
+ *
+ *	The <tag> is an integer code which identifies a particular
+ *	attribute.  The <length> is the integer length in bytes of
+ *	the <contents>.  The encoding of the contents is determined
+ *	by the <tag>, and is application-specific.
+ *
+ *	Primitive data types currently supported are unsigned
+ *	integers (USI) and null-terminated strings (NTS).  The
+ *	encoding of USI values less than 128 is simply an octet
+ *	containing the value.  For values 128 or greater, the first
+ *	octet is 0x80 plus the length of the value, in octets.
+ *	This octet is followed by the indicated number of octets,
+ *	containing the USI value, with the most significant bits in
+ *	the first octet, and the least significant bits in the last
+ *	octet.
+ *
+ *	Examples of USI encoding:
+ *
+ *		Value		Encoding (each value is an octet)
+ *		    4		0x04
+ *		  127		0x7f
+ *		   -1		(this is not a USI)
+ *		  128		0x81 0x80
+ *		 1023		0x82 0x03 0xff
+ *
+ *	The encoding of a null-terminated string (NTS) is simply the
+ *	sequence of octets which comprise the string, including the
+ *	terminating null (0x00) octet.  The terminating null octet is
+ *	the only null value in the string.  The character set used to
+ *	encode the other string octets is ASCII.
+ */
+
+#include "usi.h"
+
+NSPR_BEGIN_EXTERN_C
+
+/* Define a type to reference an attribute record */
+typedef unsigned char * ATR_t;
+
+/*
+ * Description (USILENGTH)
+ *
+ *	This macro returns the length of the USI encoding for a specified
+ *	unsigned integer value.  The length is the number of octets
+ *	required.  It will be greater than zero, and less than or equal
+ *	to USIALLOC().  This is a partial inline optimization of
+ *	USI_Length().
+ */
+
+#define USILENGTH(val)	(((USI_t)(val) <= 0x7f) ? 1 : USI_Length((USI_t)(val)))
+
+/*
+ * Description (USIALLOC)
+ *
+ *	This macro returns the maximum length of an unsigned integer
+ *	encoding.
+ */
+
+#define USIALLOC()	(5)
+
+/*
+ * Description (USIENCODE)
+ *
+ *	This macro encodes a USI value into a specified buffer.  It
+ *	returns a pointer to the first octet after the encoding.
+ *	This is a partial inline optimization for USI_Encode().
+ */
+
+#define USIENCODE(cp, val) (((USI_t)(val) <= 0x7f) ? (*(cp) = (val), (cp)+1) \
+						   : USI_Encode((cp), (val)))
+
+/*
+ * Description (USIINSERT)
+ *
+ *	This macro performs a variation of USIENCODE which always
+ *	generates the maximum-sized USI encoding, i.e. the number of
+ *	octets indicated by USIALLOC().
+ */
+
+#define USIINSERT(cp, val) USI_Insert((ATR_t)(cp), (USI_t)(val))
+
+/*
+ * Description (USIDECODE)
+ *
+ *	This macro decodes a USI value from a specified buffer.  It
+ *	returns a pointer to the first octet after the encoding.
+ *	This is a partial inline optimization for USI_Decode().
+ */
+
+#define USIDECODE(cp, pval) \
+	((*(cp) & 0x80) ? USI_Decode((cp), (pval)) \
+			: (((pval) ? (*(pval) = *(cp)) : 0), (cp)+1))
+
+/* Define a type to reference a null-terminated string */
+typedef unsigned char * NTS_t;
+
+/*
+ * Decription (NTSLENGTH)
+ *
+ *	Return the length, in octets, of a null-terminated string.
+ *	It includes the terminating null octet.
+ */
+
+#define NTSLENGTH(nts) ((nts) ? strlen((char *)(nts)) + 1 : 1)
+
+/*
+ * Description (NTSENCODE)
+ *
+ *	This macro copies a null-terminated string to a specified
+ *	attribute record buffer.  It returns a pointer to the octet
+ *	following the NTS in the buffer.
+ */
+
+#define NTSENCODE(cp, nts) \
+	((ATR_t)memccpy((void *)(cp), \
+			(void *)((nts) ? (NTS_t)(nts) : (NTS_t)""), \
+			0, NTSLENGTH(nts)))
+
+/*
+ * Description (NTSDECODE)
+ *
+ *	This macro decodes a null-terminated string in a specified
+ *	attribute record buffer into a dynamically allocated buffer.
+ *	It returns a pointer to the first octet after the NTS in the
+ *	attribute record buffer.
+ */
+
+#define NTSDECODE(cp, pnts) NTS_Decode((cp), (pnts))
+
+/* Functions in attrec.c */
+extern int NTS_Length(NTS_t ntsp);
+extern ATR_t NTS_Decode(ATR_t cp, NTS_t * pnts);
+extern ATR_t NTS_Encode(ATR_t cp, NTS_t nts);
+extern ATR_t USI_Decode(ATR_t cp, USI_t * pval);
+extern ATR_t USI_Encode(ATR_t cp, USI_t val);
+extern ATR_t USI_Insert(ATR_t cp, USI_t val);
+extern int USI_Length(USI_t val);
+
+NSPR_END_EXTERN_C
+
+#endif /* __attrec_h */

+ 24 - 0
include/libaccess/authdb.h

@@ -0,0 +1,24 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef AUTHDB_H
+#define AUTHDB_H
+
+#include <base/plist.h>
+#include <libaccess/nserror.h>
+#include <libaccess/las.h>
+
+#define URL_PREFIX_LDAP		    "ldap"
+#define URL_PREFIX_LDAP_LEN	    4
+
+typedef struct {
+    char *dbname;
+    ACLDbType_t dbtype;
+    void *dbinfo;
+} AuthdbInfo_t;
+
+extern int acl_num_databases();
+
+#endif /* AUTHDB_H */

+ 40 - 0
include/libaccess/ava.h

@@ -0,0 +1,40 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef _ava_h
+#define _ava_h
+
+#define ENTRIES_ALLOCSIZE 100
+#define ORGS_ALLOCSIZE    15
+
+
+#ifdef XP_WIN32
+#define NSAPI_PUBLIC __declspec(dllexport)
+#else /* !XP_WIN32 */
+#define NSAPI_PUBLIC
+#endif
+
+
+typedef struct {
+  char *email;
+  char *locality;
+  char *userid; 
+  char *state;
+  char *country;
+  char *company;
+  int numOrgs;
+  char **organizations;
+  char *CNEntry;
+} AVAEntry;
+
+typedef struct {
+  char *userdb;
+  int numEntries;
+  AVAEntry **enteredTable; 
+} AVATable;
+
+
+#endif
+

+ 15 - 0
include/libaccess/avadb.h

@@ -0,0 +1,15 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef _avadb_h_
+#define _avadb_h_
+
+#define USE_NSAPI 
+
+USE_NSAPI int   AddEntry    (char *key, char *value);
+USE_NSAPI int   DeleteEntry (char *key);
+USE_NSAPI char *GetValue    (char *key);
+
+#endif /*_avadb_h_*/

+ 59 - 0
include/libaccess/avapfile.h

@@ -0,0 +1,59 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef _avaparsedfiles_h_
+#define _avaparsedfiles_h_
+
+#include "libaccess/ava.h"
+#include "frame/req.h"
+#include "base/session.h"
+
+#define AUTH_DB_FILE "AvaCertmap"
+#define AVADB_TAG    "avadb"
+#define AVA_DB_SEL   "ava_db_sel" /*Variable name used in
+				   *outputAVAdbs
+				   */
+
+
+extern void outputAVAdbs (char *chosen); /*Outputs the selector of auth databases
+					  *and makes it so that the form submits 
+					  *when onChange event occurs. 
+					  */
+
+
+/*For the following 3 functions, enter the full path of 
+ *ava database file includint tag and filename
+ */
+/*Before calling _getTable, initializa yy_sn and yy_rq.  Set to NULL if no
+ *Session* or Request* variables exist and an error will be reported with 
+ *function report_error(libamin.h).  Otherwise error will be logged into
+ *the server's error log
+ */
+extern AVATable *_getTable (char *avadbfile);
+extern AVATable *_wasParsed (char *avadbfile);/*Assumes a call to yyparse was just
+					       *completed
+					       */
+extern int _hasBeenParsed (char *avadbfile);/*Check if _getTable returns NULL or not*/
+
+extern AVAEntry* _getAVAEntry (char *groupid, AVATable *table);
+extern AVAEntry* _deleteAVAEntry (char *groupid, AVATable *table);
+extern void _addAVAtoTable (AVAEntry *entry, AVATable *table);
+extern void AVAEntry_Free (AVAEntry *entry);
+
+/*Functions for writing out files*/
+extern void PrintHeader (FILE *outfile);
+extern void writeOutFile (char *avadbfilename, AVATable *table);
+
+
+extern int yyparse();
+extern FILE *yyin;
+
+extern char *currFile;
+
+extern Session *yy_sn;
+extern Request *yy_rq;
+
+
+#endif /*_avaparsedfiles_h_*/

+ 161 - 0
include/libaccess/dbtlibaccess.h

@@ -0,0 +1,161 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+
+#define LIBRARY_NAME "libaccess"
+
+static char dbtlibaccessid[] = "$DBT: libaccess referenced v1 $";
+
+#include "i18n.h"
+
+BEGIN_STR(libaccess)
+	ResDef( DBT_LibraryID_, -1, dbtlibaccessid )/* extracted from dbtlibaccess.h*/
+	ResDef( DBT_basicNcsa_, 1, "basic-ncsa" )/*extracted from userauth.cpp*/
+	ResDef( DBT_cannotOpenDatabaseS_, 2, "cannot open database %s" )/*extracted from userauth.cpp*/
+	ResDef( DBT_basicNcsa_1, 3, "basic-ncsa" )/*extracted from userauth.cpp*/
+	ResDef( DBT_userSPasswordDidNotMatchDatabase_, 4, "user %s password did not match database %s" )/*extracted from userauth.cpp*/
+	ResDef( DBT_basicNcsa_2, 5, "basic-ncsa" )/*extracted from userauth.cpp*/
+	ResDef( DBT_cannotOpenConnectionToLdapServer_, 6, "cannot open connection to LDAP server on %s:%d" )/*NOT USED - extracted from userauth.cpp*/
+	ResDef( DBT_basicNcsa_3, 7, "basic-ncsa" )/*extracted from userauth.cpp*/
+	ResDef( DBT_userSPasswordDidNotMatchLdapOnSD_, 8, "user %s password did not match LDAP on %s:%d" )/*NOT USED - extracted from userauth.cpp*/
+	ResDef( DBT_aclState_, 9, "acl-state" )/*extracted from userauth.cpp*/
+	ResDef( DBT_missingRealm_, 10, "missing realm" )/*extracted from userauth.cpp*/
+	ResDef( DBT_unableToAllocateAclListHashN_, 11, "Unable to allocate ACL List Hash\n" )/*extracted from cache.cpp*/
+	ResDef( DBT_aclevalbuildcontextUnableToPermM_, 12, "ACLEvalBuildContext unable to PERM_MALLOC cache structure\n" )/*extracted from eval.cpp*/
+	ResDef( DBT_aclevalbuildcontextUnableToCreat_, 13, "ACLEvalBuildContext unable to create hash table\n" )/*extracted from eval.cpp*/
+	ResDef( DBT_aclevalbuildcontextUnableToAlloc_, 14, "ACLEvalBuildContext unable to allocate ACE Entry\n" )/*extracted from eval.cpp*/
+	ResDef( DBT_aclevalbuildcontextUnableToAlloc_1, 15, "ACLEvalBuildContext unable to allocate ACE entry\n" )/*extracted from eval.cpp*/
+	ResDef( DBT_aclevalbuildcontextUnableToAlloc_2, 16, "ACLEvalBuildContext unable to allocate Boundary Entry\n" )/*extracted from eval.cpp*/
+	ResDef( DBT_aclevalbuildcontextFailedN_, 17, "ACLEvalBuildContext failed.\n" )/*extracted from eval.cpp*/
+	ResDef( DBT_aclEvaltestrightsAnInterimAbsolu_, 18, "ACL_EvalTestRights: an interim, absolute non-allow value was encountered. right=%s, value=%d\n" )/*NOT USED - extracted from eval.cpp*/
+	ResDef( DBT_lasdnsbuildUnableToAllocateHashT_, 19, "LASDnsBuild unable to allocate hash table header\n" )/*extracted from lasdns.cpp*/
+	ResDef( DBT_lasdnsbuildUnableToAddKeySN_, 20, "LASDnsBuild unable to add key %s\n" )/*extracted from lasdns.cpp*/
+	ResDef( DBT_lasdnsbuildUnableToAddKeySN_1, 21, "LASDnsBuild unable to add key %s\n" )/*extracted from lasdns.cpp*/
+	ResDef( DBT_lasdnsbuildUnableToAddKeySN_2, 22, "LASDnsBuild unable to add key %s\n" )/*extracted from lasdns.cpp*/
+	ResDef( DBT_lasdnsbuildUnableToAddKeySN_3, 23, "LASDnsBuild unable to add key %s\n" )/*extracted from lasdns.cpp*/
+	ResDef( DBT_lasdnsbuildUnableToAddKeySN_4, 24, "LASDnsBuild unable to add key %s\n" )/*extracted from lasdns.cpp*/
+	ResDef( DBT_lasDnsBuildReceivedRequestForAtt_, 25, "LAS DNS build received request for attribute %s\n" )/*extracted from lasdns.cpp*/
+	ResDef( DBT_lasdnsevalIllegalComparatorDN_, 26, "LASDnsEval - illegal comparator %s\n" )/*extracted from lasdns.cpp*/
+	ResDef( DBT_lasdnsevalUnableToAllocateContex_, 27, "LASDnsEval unable to allocate Context struct\n\n" )/*extracted from lasdns.cpp*/
+	ResDef( DBT_lasdnsevalUnableToGetSessionAddr_, 28, "LASDnsEval unable to get session address %d\n" )/*NOT USED - extracted from lasdns.cpp*/
+	ResDef( DBT_lasdnsevalUnableToGetDnsErrorDN_, 29, "LASDnsEval unable to get DNS - error=%s\n" )/*extracted from lasdns.cpp*/
+	ResDef( DBT_lasGroupEvalReceivedRequestForAt_, 30, "LAS Group Eval received request for attribute %s\n" )/*extracted from lasgroup.cpp*/
+	ResDef( DBT_lasgroupevalIllegalComparatorDN_, 31, "LASGroupEval - illegal comparator %s\n" )/*extracted from lasgroup.cpp*/
+	ResDef( DBT_lasgroupevalRanOutOfMemoryN_, 32, "LASGroupEval - ran out of memory\n" )/*extracted from lasgroup.cpp*/
+	ResDef( DBT_lasgroupevalUnableToGetSessionAd_, 33, "LASGroupEval unable to get session address %d\n" )/*NOT USED - extracted from lasgroup.cpp*/
+	ResDef( DBT_lasgroupevalUnableToGetSessionAd_1, 34, "LASGroupEval unable to get session address %d\n" )/*NOT USED - extracted from lasgroup.cpp*/
+	ResDef( DBT_lasgroupevalCouldnTLocateGetterF_, 35, "LASGroupEval - couldn't locate getter for auth-user\n" )/*extracted from lasgroup.cpp*/
+	ResDef( DBT_lasgroupevalAttributeGetterForAu_, 36, "LASGroupEval - Attribute getter for auth-user failed\n" )/*extracted from lasgroup.cpp*/
+	ResDef( DBT_lasgroupevalAttributeGetterDidnT_, 37, "LASGroupEval - Attribute getter didn't set auth-user\n" )/*extracted from lasgroup.cpp*/
+	ResDef( DBT_checkGroupMembershipOfUserSForGr_, 38, "Check group membership of user \"%s\" for group \"%s\"\n" )/*extracted from lasgroup.cpp*/
+	ResDef( DBT_ldapuSuccessForGroupSN_, 39, "LDAPU_SUCCESS for group \"%s\"\n" )/*extracted from lasgroup.cpp*/
+	ResDef( DBT_ldapuFailedForGroupSN_, 40, "LDAPU_FAILED for group \"%s\"\n" )/*extracted from lasgroup.cpp*/
+	ResDef( DBT_lasEvalFalseN_, 41, "LAS_EVAL_FALSE\n" )/*extracted from lasgroup.cpp*/
+	ResDef( DBT_lasEvalTrueN_, 42, "LAS_EVAL_TRUE\n" )/*extracted from lasgroup.cpp*/
+	ResDef( DBT_lasiptreeallocNoMemoryN_, 43, "LASIpTreeAlloc - no memory\n" )/*extracted from lasip.cpp*/
+	ResDef( DBT_ipLasUnableToAllocateTreeNodeN_, 44, "IP LAS unable to allocate tree node\n" )/*extracted from lasip.cpp*/
+	ResDef( DBT_ipLasUnableToAllocateTreeNodeN_1, 45, "IP LAS unable to allocate tree node\n" )/*extracted from lasip.cpp*/
+	ResDef( DBT_lasIpBuildReceivedRequestForAttr_, 46, "LAS IP build received request for attribute %s\n" )/*extracted from lasip.cpp*/
+	ResDef( DBT_lasipevalIllegalComparatorDN_, 47, "LASIpEval - illegal comparator %s\n" )/*extracted from lasip.cpp*/
+	ResDef( DBT_lasipevalUnableToGetSessionAddre_, 48, "LASIpEval unable to get session address - error=%s\n" )/*extracted from lasip.cpp*/
+	ResDef( DBT_lasipevalUnableToAllocateContext_, 49, "LASIpEval unable to allocate Context struct\n\n" )/*extracted from lasip.cpp*/
+	ResDef( DBT_lasipevalReach32BitsWithoutConcl_, 50, "LASIpEval - reach 32 bits without conclusion value=%s" )/*extracted from lasip.cpp*/
+	ResDef( DBT_lasProgramEvalReceivedRequestFor_, 51, "LAS Program Eval received request for attribute %s\n" )/*extracted from lasprogram.cpp*/
+	ResDef( DBT_lasprogramevalIllegalComparatorD_, 52, "LASProgramEval - illegal comparator %s\n" )/*extracted from lasprogram.cpp*/
+	ResDef( DBT_lasprogramUnableToGetSessionAddr_, 53, "LASProgram unable to get session address %d\n" )/*NOT USED - extracted from lasprogram.cpp*/
+	ResDef( DBT_bin_, 54, "bin" )/*extracted from lasprogram.cpp*/
+	ResDef( DBT_lasprogramevalRequestNotOfTypeAd_, 55, "LASProgramEval: request not of type admin or bin, passing.\n" )/*extracted from lasprogram.cpp*/
+	ResDef( DBT_lasprogramevalCheckIfProgramSMat_, 56, "LASProgramEval: check if program %s matches pattern %s.\n" )/*extracted from lasprogram.cpp*/
+	ResDef( DBT_lasprogramevalInvalidWildcardExp_, 57, "LASProgramEval: Invalid wildcard expression %s.\n" )/*extracted from lasprogram.cpp*/
+	ResDef( DBT_lasEvalFalseN_1, 58, "LAS_EVAL_FALSE\n" )/*extracted from lasprogram.cpp*/
+	ResDef( DBT_lasEvalTrueN_1, 59, "LAS_EVAL_TRUE\n" )/*extracted from lasprogram.cpp*/
+	ResDef( DBT_unexpectedAttributeInDayofweekSN_, 60, "Unexpected attribute in dayOfWeek - %s\n" )/*extracted from lastod.cpp*/
+	ResDef( DBT_illegalComparatorForDayofweekDN_, 61, "Illegal comparator for dayOfWeek - %s\n" )/*extracted from lastod.cpp*/
+	ResDef( DBT_unexpectedAttributeInTimeofdaySN_, 62, "Unexpected attribute in timeOfDay - %s\n" )/*extracted from lastod.cpp*/
+	ResDef( DBT_lasUserEvalReceivedRequestForAtt_, 63, "LAS User Eval received request for attribute %s\n" )/*extracted from lasuser.cpp*/
+	ResDef( DBT_lasuserevalIllegalComparatorDN_, 64, "LASUserEval - illegal comparator %s\n" )/*extracted from lasuser.cpp*/
+	ResDef( DBT_lasuserevalRanOutOfMemoryN_, 65, "LASUserEval - ran out of memory\n" )/*extracted from lasuser.cpp*/
+	ResDef( DBT_lasuserevalUnableToGetSessionAdd_, 66, "LASUserEval unable to get session address %d\n" )/*NOT USED - extracted from lasuser.cpp*/
+	ResDef( DBT_lasuserevalUnableToGetSessionAdd_1, 67, "LASUserEval unable to get session address %d\n" )/*NOT USED - extracted from lasuser.cpp*/
+	ResDef( DBT_lasgroupevalCouldnTLocateGetterF_1, 68, "LASGroupEval - couldn't locate getter for auth-user\n" )/*extracted from lasuser.cpp*/
+	ResDef( DBT_lasgroupevalAttributeGetterForAu_1, 69, "LASGroupEval - Attribute getter for auth-user failed\n" )/*extracted from lasuser.cpp*/
+	ResDef( DBT_lasgroupevalAttributeGetterDidnT_1, 70, "LASGroupEval - Attribute getter didn't set auth-user\n" )/*extracted from lasuser.cpp*/
+	ResDef( DBT_checkIfUidUserIECheckSSN_, 71, "Check if uid == user (i.e. check \"%s\" == \"%s)\"\n" )/*extracted from lasuser.cpp*/
+	ResDef( DBT_successForUserSN_, 72, "SUCCESS for user \"%s\"\n" )/*extracted from lasuser.cpp*/
+	ResDef( DBT_failedForUserSN_, 73, "FAILED for user \"%s\"\n" )/*extracted from lasuser.cpp*/
+	ResDef( DBT_lasEvalFalseN_2, 74, "LAS_EVAL_FALSE\n" )/*extracted from lasuser.cpp*/
+	ResDef( DBT_lasEvalTrueN_2, 75, "LAS_EVAL_TRUE\n" )/*extracted from lasuser.cpp*/
+	ResDef( DBT_Unused76, 76, "")
+	ResDef( DBT_lasProgramUnableToGetRequest_, 77, "LASProgram unable to get request address - error=%s" ) /*extracted from lasprogram.cpp*/
+	ResDef( DBT_lasProgramRejectingRequestForProgram_, 78, "LASProgram rejecting request for program %s from pattern %s" ) /*extracted from lasprogram.cpp*/
+	ResDef( DBT_aclcacheflushCannotParseFile, 79, "ACL_CacheFlush: unable to parse file \"%s\"\n" )
+	ResDef( DBT_aclcacheflushCannotConcatList, 80, "ACL_CacheFlush: unable to concatenate ACL list \"%s\"\n" )
+	ResDef( DBT_aclcacheflushCannotOpenMagnus, 81, "ACL_CacheFlush: unable to open and process the magnus file \"%s\"\n" )
+	ResDef( DBT_illegalComparatorForTimeOfDayDN_, 82, "Illegal comparator for timeOfDay - %s\n" )/*extracted from lastod.cpp*/
+	ResDef( DBT_EvalBuildContextUnableToCreateHash, 83, "ACL_EvalBuildContext unable to create hash table\n")
+	ResDef( DBT_EvalBuildContextUnableToAllocCache, 84, "ACL_EvalBuildContext unable to PERM_CALLOC cache structure\n")
+	ResDef( DBT_EvalBuildContextUnableToAllocAceEntry, 85, "ACL_EvalBuildContext unable to allocate ACE entry\n")
+	ResDef( DBT_EvalBuildContextUnableToAllocAuthPointerArray, 86, "ACL_EvalBuildContext unable to allocate auth pointer array\n")
+	ResDef( DBT_EvalBuildContextUnableToAllocAuthPlist, 87, "ACL_EvalBuildContext unable to allocate auth plist\n")
+	ResDef( DBT_EvalTestRightsInterimAbsoluteNonAllowValue, 88, "ACL_EvalTestRights: an interim, absolute non-allow value was encountered. right=%s, value=%s\n")
+	ResDef( DBT_EvalTestRightsEvalBuildContextFailed, 89, "ACL_INTEvalTestRights: call to ACL_EvalBuildContext returned failure status\n")
+	ResDef( DBT_ModuleRegisterModuleNameMissing, 90, "ACL_ModuleRegister: module name is missing\n")
+	ResDef( DBT_ModuleRegisterFailed, 91, "ACL_ModuleRegister: call to module init function returned a failed status\n")
+	ResDef( DBT_GetAttributeCouldntDetermineMethod, 92, "ACL_GetAttribute: couldn't determine method for %s\n")
+	ResDef( DBT_GetAttributeCouldntLocateGetter, 93,  "ACL_GetAttribute: couldn't locate getter for %s")
+	ResDef( DBT_GetAttributeDidntGetAttr, 94, "ACL_GetAttribute: attr getter failed to get %s")
+	ResDef( DBT_GetAttributeDidntSetAttr, 95, "ACL_GetAttribute: attr getter failed to get %s")
+	ResDef( DBT_GetAttributeAllGettersDeclined, 96, "ACL_GetAttribute: All attribute getters declined for attr %s")
+	ResDef( DBT_DbtypeNoteDefinedYet, 97, "ACL_DatabaseRegister: dbtype for database \"%s\" is not defined yet!")
+	ResDef( DBT_DatabaseRegisterDatabaseNameMissing, 98, "ACL_DatabaseRegister: database name is missing")
+	ResDef( DBT_ReadDbMapFileErrorReadingFile, 99,  "Error reading the DB Map File: %s. Reason: %s")
+	ResDef( DBT_ReadDbMapFileMissingUrl, 100, "URL is missing for database %s")
+	ResDef( DBT_ReadDbMapFileInvalidPropertyPair, 101,  "Invalid property value pair for database %s")
+	ResDef( DBT_ReadDbMapFileDefaultDatabaseNotLdap, 102,  "\"default\" database must be an LDAP database")
+	ResDef( DBT_ReadDbMapFileMultipleDefaultDatabases, 103, "Multiple \"default\" databases are being registered")
+	ResDef( DBT_ReadDbMapFileMissingDefaultDatabase, 104, "\"default\" LDAP database must be registered")
+	ResDef( DBT_lasGroupEvalUnableToGetDatabaseName, 105, "LASGroupEval unable to get database name - error= %s")
+	ResDef( DBT_lasProgramReceivedInvalidProgramExpression, 106, "received invalid program expression %s")
+	ResDef( DBT_ldapaclDatabaseUrlIsMissing, 107, "parse_ldap_url: database url is missing")
+	ResDef( DBT_ldapaclDatabaseNameIsMissing, 108, "parse_ldap_url: database name is missing")
+ 	ResDef( DBT_ldapaclErrorParsingLdapUrl, 109, "parse_ldap_url: error in parsing ldap url. Reason: %s")
+	ResDef( DBT_ldapaclUnableToGetDatabaseName, 110,  "ldap password check: unable to get database name - error=%s")
+	ResDef( DBT_ldapaclUnableToGetParsedDatabaseName, 111, "ldap password check: unable to get parsed database %s")
+	ResDef( DBT_ldapaclCoudlntInitializeConnectionToLdap, 112, "ldap password check: couldn't initialize connection to LDAP. Reason: %s")
+	ResDef( DBT_ldapaclPassworkCheckLdapError, 113, "ldap password check: LDAP error: \"%s\"")
+	ResDef( DBT_GetUserIsMemberLdapUnabelToGetDatabaseName, 114, "get_user_ismember_ldap unable to get database name - error=%s")
+	ResDef( DBT_GetUserIsMemberLdapUnableToGetParsedDatabaseName, 115, "get_user_ismember_ldap unable to get parsed database %s")
+	ResDef( DBT_GetUserIsMemberLdapCouldntInitializeConnectionToLdap, 116, "ldap password check: couldn't initialize connection to LDAP. Reason: %s")
+	ResDef( DBT_GetUserIsMemberLdapGroupDoesntExist, 117, "get_user_ismember_ldap: group %s does not exist")
+	ResDef( DBT_GetUserIsMemberLdapError, 118, "get_user_ismember_ldap: LDAP error: \"%s\"")
+	ResDef( DBT_LdapDatabaseHandleNotARegisteredDatabase, 119, "ACL_LDAPDatabaseHandle: %s is not a registered database")
+	ResDef( DBT_LdapDatabaseHandleNotAnLdapDatabase, 120, "ACL_LDAPDatabaseHandle: %s is not an LDAP database")
+	ResDef( DBT_LdapDatabaseHandleOutOfMemory, 121, "ACL_LDAPDatabaseHandle: out of memory")
+	ResDef( DBT_LdapDatabaseHandleCouldntInitializeConnectionToLdap, 122, "ACL_LDAPDatabaseHandle: couldn't initialize connection to LDAP. Reason: %s")
+	ResDef(  DBT_LdapDatabaseHandleCouldntBindToLdapServer, 123,  "ACL_LDAPDatabaseHandle: couldn't bind to LDAP server. Reason: %s")
+	ResDef( DBT_AclerrfmtAclerrnomem, 124, "insufficient dynamic memory")
+	ResDef( DBT_AclerrfmtAclerropen, 125, "error opening file, %s: %s")
+	ResDef( DBT_AclerrfmtAclerrdupsym1, 126, "duplicate definition of %s")
+	ResDef( DBT_AclerrfmtAclerrdupsym3, 127,  "file %s, line %s: duplicate definition of %s")
+	ResDef( DBT_AclerrfmtAclerrsyntax, 128, "file %s, line %s: syntax error")
+	ResDef( DBT_AclerrfmtAclerrundef, 129, "file %s, line %s: %s is undefined")
+	ResDef( DBT_AclerrfmtAclaclundef, 130, "in acl %s, %s %s is undefined")
+	ResDef( DBT_AclerrfmtAclerradb, 131, "database %s: error accessing %s")
+	ResDef( DBT_AclerrfmtAclerrparse1, 132, "%s")
+	ResDef( DBT_AclerrfmtAclerrparse2, 133, "file %s, line %s: invalid syntax")
+	ResDef( DBT_AclerrfmtAclerrparse3, 134, "file %s, line %s: syntax error at \"%s\"")
+	ResDef( DBT_AclerrfmtAclerrnorlm, 135, "realm %s is not defined")
+	ResDef( DBT_AclerrfmtUnknownerr, 136, "error code = %d")
+	ResDef( DBT_AclerrfmtAclerrinternal, 137, "internal ACL error")
+	ResDef( DBT_AclerrfmtAclerrinval, 138, "invalid argument")
+	ResDef( DBT_DbtypeNotDefinedYet, 139, "ACL_DatabaseRegister: dbtype for database \"%s\" is not defined yet!")
+	ResDef( DBT_ReadDbMapFileCouldntDetermineDbtype, 140, "couldn't determine dbtype from: %s")
+	ResDef( DBT_ReadDbMapFileRegisterDatabaseFailed, 141,  "Failed to register database %s")
+	ResDef( DBT_AclerrfmtAclerrfail, 142, "ACL call returned failed status")
+	ResDef( DBT_AclerrfmtAclerrio, 143, "file %s: ACL IO error - %s")
+	ResDef( DBT_AclUserExistsOutOfMemory, 144, "acl_user_exists: out of memory")
+	ResDef( DBT_AclUserExistsNot, 145, "acl_user_exists: user doesn't exist anymore")
+	ResDef( DBT_AclUserPlistError, 146, "acl_user_exists: plist error")
+END_STR(libaccess)

+ 51 - 0
include/libaccess/dnfstruct.h

@@ -0,0 +1,51 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef __dnfstruct_h
+#define __dnfstruct_h
+
+/*
+ * Description (dnfstruct_h)
+ *
+ *	This file defines types and structures used to represent a DNS
+ *	name filter in memory.  A DNS name filter contains specifications
+ *	of fully or partially qualified DNS names.  Each of these
+ *	specifications can be associated with whatever information is
+ *	appropriate for a particular use of a DNS name filter.
+ */
+
+#include "nspr.h"
+#include "plhash.h"
+
+NSPR_BEGIN_EXTERN_C
+
+/*
+ * Description (DNSLeaf_t)
+ *
+ *	This type describes the structure of information associated with
+ *	an entry in a DNS filter.  The filter itself is implemented as a
+ *	hash table, keyed by the DNS name specification string.  The
+ *	value associated with a key is a pointer to a DNSLeaf_t structure.
+ */
+
+typedef struct DNSLeaf_s DNSLeaf_t;
+struct DNSLeaf_s {
+    PLHashEntry dnl_he;		/* NSPR hash table entry */
+};
+
+#define dnl_next dnl_he.next		/* hash table collision link */
+#define dnl_keyhash dnl_he.keyHash	/* symbol hash value */
+#define dnl_key dnl_he.key		/* pointer to Symbol_t structure */
+#define dnl_ref dnl_he.value		/* pointer to named structure */
+
+typedef struct DNSFilter_s DNSFilter_t;
+struct DNSFilter_s {
+    DNSFilter_t * dnf_next;	/* link to next filter */
+    void * dnf_hash;		/* pointer to constructed hash table */
+};
+
+NSPR_END_EXTERN_C
+
+#endif /* __dnfstruct_h */

+ 81 - 0
include/libaccess/ipfstruct.h

@@ -0,0 +1,81 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef __ipfstruct_h
+#define __ipfstruct_h
+
+/*
+ * Description (ipfstruct.h)
+ *
+ *	This file defines types and structures used to represent an
+ *	IP address filter in memory.  An IP address filter contains
+ *	specifications of IP host and network addresses.  Each of
+ *	these specifications can be associated with whatever information
+ *	is appropriate for a particular use of an IP address filter.
+ */
+
+/* Define a scalar IP address value */
+#ifndef __IPADDR_T_
+#define __IPADDR_T_
+typedef unsigned long IPAddr_t;
+#endif /* __IPADDR_T_ */
+
+/*
+ * Description (IPNode_t)
+ *
+ * This type describes an internal node in the radix tree.  An internal
+ * node has a link up the tree to its parent, and up to three links
+ * down the tree to its descendants.  Each internal node is used to
+ * test a particular bit in a given IP address, and traverse down the
+ * tree in a direction which depends on whether the bit is set, clear,
+ * or masked out.  The descendants of an internal node may be internal
+ * nodes or leaf nodes (IPLeaf_t).
+ */
+
+/* Define indices of links in an IPNode_t */
+#define IPN_CLEAR	0	/* link to node with ipn_bit clear */
+#define IPN_SET		1	/* link to node with ipn_bit set */
+#define IPN_MASKED	2	/* link to node with ipn_bit masked out */
+#define IPN_NLINKS	3	/* number of links */
+
+typedef struct IPNode_s IPNode_t;
+struct IPNode_s {
+    char ipn_type;		/* node type */
+#define IPN_LEAF	0	/* leaf node */
+#define IPN_NODE	1	/* internal node */
+
+    char ipn_bit;		/* bit number (31-0) to test */
+    IPNode_t * ipn_parent;	/* link to parent node */
+    IPNode_t * ipn_links[IPN_NLINKS];	
+};
+
+/* Helper definitions */
+#define ipn_clear	ipn_links[IPN_CLEAR]
+#define ipn_set		ipn_links[IPN_SET]
+#define ipn_masked	ipn_links[IPN_MASKED]
+
+/*
+ * Description (IPLeaf_t)
+ *
+ * This type describes a leaf node in the radix tree.  A leaf node
+ * contains an IP host or network address, and a network mask.  A
+ * given IP address matches a leaf node if the IP address, when masked
+ * by ipl_netmask, equals ipl_ipaddr.
+ */
+
+typedef struct IPLeaf_s IPLeaf_t;
+struct IPLeaf_s {
+    char ipl_type;		/* see ipn_type in IPNode_t */
+    IPAddr_t ipl_netmask;	/* IP network mask */
+    IPAddr_t ipl_ipaddr;	/* IP address of host or network */
+};
+
+typedef struct IPFilter_s IPFilter_t;
+struct IPFilter_s {
+    IPFilter_t * ipf_next;	/* link to next filter */
+    IPNode_t * ipf_tree;	/* pointer to radix tree structure */
+};
+
+#endif /* __ipfstruct_h */

+ 184 - 0
include/libaccess/las.h

@@ -0,0 +1,184 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+
+#ifndef ACL_LAS_HEADER
+#define ACL_LAS_HEADER
+
+#ifndef NOINTNSACL
+#define INTNSACL
+#endif /* !NOINTNSACL */
+
+/* #include <prhash.h>  */
+#include <plhash.h> 
+#include <prclist.h>
+
+#include <base/pblock.h>
+#include <base/plist.h>
+#include <libaccess/nserror.h>
+#include <libaccess/acl.h>
+
+#ifndef PUBLIC_NSACL_ACLDEF_H
+#include "public/nsacl/acldef.h"
+#endif /* !PUBLIC_NSACL_ACLDEF_H */
+
+#define	ACL_MAX_METHOD		32
+#define	ACL_MAX_DBTYPE		32
+
+struct ACLAttrGetter {
+	PRCList			list;	/* must be first */
+	ACLMethod_t		method;
+	ACLDbType_t		dbtype;
+	ACLAttrGetterFn_t	fn;
+	void			*arg;
+};
+
+NSPR_BEGIN_EXTERN_C
+
+NSAPI_PUBLIC extern int
+	ACL_LasRegister(NSErr_t *errp, char *attr_name, LASEvalFunc_t
+	eval_func, LASFlushFunc_t flush_func);
+NSAPI_PUBLIC extern int
+	ACL_LasFindEval(NSErr_t *errp, char *attr_name, LASEvalFunc_t
+	*eval_funcp);
+NSAPI_PUBLIC extern int
+	ACL_LasFindFlush(NSErr_t *errp, char *attr_name, LASFlushFunc_t
+	*flush_funcp);
+extern void
+	ACL_LasHashInit(void);
+extern void
+	ACL_LasHashDestroy(void);
+
+/*
+ *	Revised, normalized method/dbtype registration routines
+ */
+NSAPI_PUBLIC extern int
+	ACL_MethodRegister(NSErr_t *errp, const char *name, ACLMethod_t *t);
+NSAPI_PUBLIC extern int
+	ACL_MethodIsEqual(NSErr_t *errp, const ACLMethod_t t1, const ACLMethod_t t2);
+NSAPI_PUBLIC extern int
+	ACL_MethodNameIsEqual(NSErr_t *errp, const ACLMethod_t t, const char *name);
+NSAPI_PUBLIC extern int
+	ACL_MethodFind(NSErr_t *errp, const char *name, ACLMethod_t *t);
+NSAPI_PUBLIC extern ACLMethod_t
+	ACL_MethodGetDefault(NSErr_t *errp);
+NSAPI_PUBLIC extern int
+	ACL_MethodSetDefault(NSErr_t *errp, const ACLMethod_t t);
+NSAPI_PUBLIC extern int
+	ACL_AuthInfoGetMethod(NSErr_t *errp, PList_t auth_info, ACLMethod_t *t);
+NSAPI_PUBLIC extern int
+	ACL_AuthInfoSetMethod(NSErr_t *errp, PList_t auth_info, ACLMethod_t t);
+NSAPI_PUBLIC extern int
+	ACL_DbTypeRegister(NSErr_t *errp, const char *name, DbParseFn_t func, ACLDbType_t *t);
+NSAPI_PUBLIC extern int
+	ACL_DbTypeIsEqual(NSErr_t *errp, const ACLDbType_t t1, const ACLDbType_t t2);
+NSAPI_PUBLIC extern int
+	ACL_DbTypeNameIsEqual(NSErr_t *errp, const ACLDbType_t t, const char *name);
+NSAPI_PUBLIC extern int
+	ACL_DbTypeFind(NSErr_t *errp, const char *name, ACLDbType_t *t);
+NSAPI_PUBLIC extern ACLDbType_t
+	ACL_DbTypeGetDefault(NSErr_t *errp);
+NSAPI_PUBLIC extern const char *
+	ACL_DatabaseGetDefault(NSErr_t *errp);
+NSAPI_PUBLIC extern int
+	ACL_DatabaseSetDefault(NSErr_t *errp, const char *dbname);
+NSAPI_PUBLIC extern int
+	ACL_AuthInfoGetDbType(NSErr_t *errp, PList_t auth_info, ACLDbType_t *t);
+NSAPI_PUBLIC extern int
+	ACL_DbTypeIsRegistered(NSErr_t *errp, const ACLDbType_t dbtype);
+NSAPI_PUBLIC extern int
+	ACL_AttrGetterRegister(NSErr_t *errp, const char *attr,
+                               ACLAttrGetterFn_t fn, ACLMethod_t m,
+                               ACLDbType_t d, int position, void *arg);
+
+extern ACLDbType_t ACL_DbTypeLdap;
+
+NSAPI_PUBLIC extern int
+	ACL_DbTypeSetDefault(NSErr_t *errp, ACLDbType_t t);
+NSAPI_PUBLIC extern DbParseFn_t
+	ACL_DbTypeParseFn(NSErr_t *errp, const ACLDbType_t dbtype);
+NSAPI_PUBLIC extern int
+	ACL_AttrGetterFind(NSErr_t *errp, const char *attr,
+			   ACLAttrGetterList_t *getters);
+NSAPI_PUBLIC extern ACLAttrGetter_t *
+	ACL_AttrGetterFirst(ACLAttrGetterList_t *getters);
+NSAPI_PUBLIC extern ACLAttrGetter_t *
+	ACL_AttrGetterNext(ACLAttrGetterList_t *getters,
+			   ACLAttrGetter_t *last);
+
+/* typedef PRHashTable AttrGetterTable_t; */
+typedef PLHashTable AttrGetterTable_t;
+
+typedef struct {
+    char *method;
+    char *authtype;
+    char *dbtype;
+    AttrGetterTable_t *attrGetters;
+} MethodInfo_t;
+
+NSAPI_PUBLIC int ACL_ModuleRegister (NSErr_t *errp, const char *moduleName, AclModuleInitFunc func);
+
+NSAPI_PUBLIC int ACL_GetAttribute(NSErr_t *errp, const char *attr, void **val, PList_t subject, PList_t resource, PList_t auth_info, PList_t global_auth);
+
+NSAPI_PUBLIC int ACL_DatabaseRegister(NSErr_t *errp, ACLDbType_t dbtype, const char *dbname, const char *url, PList_t plist);
+
+NSAPI_PUBLIC int ACL_RegisterDbFromACL(NSErr_t *errp, const char *url, ACLDbType_t *dbtype);
+NSAPI_PUBLIC int ACL_DatabaseFind(NSErr_t *errp, const char *dbname,
+				  ACLDbType_t *dbtype, void **db);
+NSAPI_PUBLIC int ACL_LDAPDatabaseHandle (NSErr_t *errp,
+                                         const char *dbname, LDAP **ld,
+					 char **basedn);
+NSAPI_PUBLIC int ACL_AuthInfoGetDbname (PList_t auth_info, char **dbname);
+NSAPI_PUBLIC int ACL_AuthInfoSetDbname (NSErr_t *errp, PList_t auth_info,
+					const char *dbname);
+NSAPI_PUBLIC int ACL_CacheFlushRegister(AclCacheFlushFunc_t func);
+NSAPI_PUBLIC int ACL_SetDefaultResult (NSErr_t *errp,
+				       ACLEvalHandle_t *acleval,
+				       int result);
+NSAPI_PUBLIC int ACL_GetDefaultResult (ACLEvalHandle_t *acleval);
+
+struct program_groups {
+	char *type;
+	char **groups;
+	char **programs;
+};
+
+extern int LASTimeOfDayEval(NSErr_t *errp, char *attribute, CmpOp_t comparator,
+			char *pattern, ACLCachable_t *cachable, void **las_cookie,
+			PList_t subject, PList_t resource, PList_t auth_info,
+			PList_t global_auth);
+extern int LASDayOfWeekEval(NSErr_t *errp, char *attribute, CmpOp_t comparator,
+			char *pattern, ACLCachable_t *cachable, void **las_cookie,
+			PList_t subject, PList_t resource, PList_t auth_info,
+			PList_t global_auth);
+extern int LASIpEval(NSErr_t *errp, char *attribute, CmpOp_t comparator,
+			char *pattern, ACLCachable_t *cachable, void **las_cookie,
+			PList_t subject, PList_t resource, PList_t auth_info,
+			PList_t global_auth);
+extern int LASDnsEval(NSErr_t *errp, char *attribute, CmpOp_t comparator,
+			char *pattern, ACLCachable_t *cachable, void **las_cookie,
+			PList_t subject, PList_t resource, PList_t auth_info,
+			PList_t global_auth);
+extern int LASGroupEval(NSErr_t *errp, char *attribute, CmpOp_t comparator,
+			char *pattern, ACLCachable_t *cachable, void **las_cookie,
+			PList_t subject, PList_t resource, PList_t auth_info,
+			PList_t global_auth);
+extern int LASUserEval(NSErr_t *errp, char *attribute, CmpOp_t comparator,
+			char *pattern, ACLCachable_t *cachable, void **las_cookie,
+			PList_t subject, PList_t resource, PList_t auth_info,
+			PList_t global_auth);
+extern int LASProgramEval(NSErr_t *errp, char *attribute, CmpOp_t comparator,
+			char *pattern, ACLCachable_t *cachable, void **las_cookie,
+			PList_t subject, PList_t resource, PList_t auth_info,
+			PList_t global_auth);
+
+extern void LASTimeOfDayFlush(void **cookie);
+extern void LASDayOfWeekFlush(void **cookie);
+extern void LASIpFlush(void **cookie);
+extern void LASDnsFlush(void **cookie);
+
+NSPR_END_EXTERN_C
+
+#endif	/* ACL_LAS_HEADER */

+ 62 - 0
include/libaccess/ldapacl.h

@@ -0,0 +1,62 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+
+#ifndef ACL_AUTH_H
+#define ACL_AUTH_H
+
+#include <ldap.h>
+#include <base/plist.h>
+#include <ldaputil/ldapdb.h>
+#include <libaccess/nserror.h>
+
+NSPR_BEGIN_EXTERN_C
+
+extern void init_ldb_rwlock ();
+
+NSAPI_PUBLIC extern int parse_ldap_url (NSErr_t *errp, ACLDbType_t dbtype,
+					const char *name, const char *url,
+					PList_t plist, void **db);
+
+extern int get_is_valid_password_basic_ldap (NSErr_t *errp,
+					     PList_t subject,
+					     PList_t resource,
+					     PList_t auth_info,
+					     PList_t global_auth,
+					     void *arg);
+
+extern int get_user_ismember_ldap (NSErr_t *errp,
+				   PList_t subject,
+				   PList_t resource,
+				   PList_t auth_info,
+				   PList_t global_auth,
+				   void *arg);
+
+extern int get_userdn_ldap (NSErr_t *errp,
+			    PList_t subject,
+			    PList_t resource,
+			    PList_t auth_info,
+			    PList_t global_auth,
+			    void *arg);
+
+extern int ACL_NeedLDAPOverSSL();
+
+extern int acl_map_cert_to_user (NSErr_t *errp, const char *dbname,
+				 LDAPDatabase_t *ldb, void *cert,
+				 PList_t resource, pool_handle_t *pool,
+				 char **user, char **userdn);
+
+extern int get_user_exists_ldap (NSErr_t *errp, PList_t subject,
+				 PList_t resource, PList_t auth_info,
+				 PList_t global_auth, void *unused);
+
+NSAPI_PUBLIC extern int acl_user_exists (const char *user,
+					 const char *userdn,
+					 const char *dbname,
+					 const int logerr);
+
+NSPR_END_EXTERN_C
+
+#endif /* ACL_AUTH_H */

+ 87 - 0
include/libaccess/nsadb.h

@@ -0,0 +1,87 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef __nsadb_h
+#define __nsadb_h
+
+/*
+ * Description (nsadb.h)
+ *
+ *	This file describes the interface for retrieving information
+ *	from a Netscape authentication database.  This facility is
+ *	built on top of the Netscape (server) database interface as
+ *	defined in nsdb.h.  It represents a subclass of a more general
+ *	authentication database interface defined in nsauth.h.
+ */
+
+#include "nserror.h"		/* error frame list support */
+#include "nsautherr.h"		/* authentication error codes */
+#include "nsauth.h"
+
+/* Begin private definitions */
+#ifdef __PRIVATE_NSADB
+
+#include "nsdb.h"
+
+#if defined(CLIENT_AUTH)
+#define ADBDBNAMES	3		/* number of named files */
+#else
+#define ADBDBNAMES	2		/* number of named files */
+#endif
+#define ADBUSERDBNAME	"Users"		/* name of user database */
+#define ADBGROUPDBNAME	"Groups"	/* name of group database */
+#if defined(CLIENT_AUTH)
+#define ADBCERTDBNAME	"Certs"		/* name of certificate mapping DB */
+#define ADBUMAPDBNAME	"Certs.nm"	/* name of mapped user names DB */
+#endif
+
+typedef struct AuthDB_s AuthDB_t;
+struct AuthDB_s {
+    char * adb_dbname;			/* database name */
+    void * adb_userdb;			/* handle for user database */
+    void * adb_groupdb;			/* handle for group database */
+#if defined(CLIENT_AUTH)
+    void * adb_certdb;			/* handle for cert mapping database */
+    void * adb_certlock;		/* lock for cert mapping database */
+    void * adb_certnm;			/* handle for username-to-certid DB */
+#endif
+    int adb_flags;			/* flags */
+};
+
+/* Definitions for adb_flags (also used on nsadbOpenXxxx() calls) */
+#define ADBF_NEW	0x1		/* newly created database */
+#define ADBF_UREAD	0x10		/* user database open for read */
+#define ADBF_UWRITE	0x20		/* user database open for write */
+#define ADBF_GREAD	0x100		/* group database open for read */
+#define ADBF_GWRITE	0x200		/* group database open for write */
+#define ADBF_CREAD	0x1000		/* cert database open for read */
+#define ADBF_CWRITE	0x2000		/* cert database open for write */
+#endif /* __PRIVATE_NSADB */
+
+NSPR_BEGIN_EXTERN_C
+
+/* Functions in nsadb.c */
+extern NSAPI_PUBLIC int nsadbOpen(NSErr_t * errp,
+				  char * adbname, int flags, void **rptr);
+extern NSAPI_PUBLIC void nsadbClose(void * authdb, int flags);
+extern NSAPI_PUBLIC int nsadbOpenUsers(NSErr_t * errp,
+				       void * authdb, int flags);
+extern NSAPI_PUBLIC int nsadbOpenGroups(NSErr_t * errp,
+					void * authdb, int flags);
+extern NSAPI_PUBLIC int nsadbIdToName(NSErr_t * errp, void * authdb,
+				      USI_t id, int flags, char **rptr);
+extern NSAPI_PUBLIC int nsadbFindByName(NSErr_t * errp, void * authdb,
+					char * name, int flags, void **rptr);
+
+#if defined(CLIENT_AUTH)
+#include "nscert.h"
+#endif
+
+/* Authentication database interface structure in nsadb.c */
+extern AuthIF_t NSADB_AuthIF;
+
+NSPR_END_EXTERN_C
+
+#endif /* __nsadb_h */

+ 122 - 0
include/libaccess/nsamgmt.h

@@ -0,0 +1,122 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef __nsamgmt_h
+#define __nsamgmt_h
+
+/*
+ * Description (nsamgmt.h)
+ *
+ *	This file defines the interface for managing information in a
+ *	Netscape authentication database.  An authentication database
+ *	consists of a user database and a group database.  This
+ *	implementation of an authentication database based on Netscape
+ *	user and group databases defined in nsuser.h and nsgroup.h,
+ *	which in turn are based on the Netscape (server) database
+ *	implementation defined in nsdb.h.  The interface for retrieving
+ *	information from an authentication database is described
+ *	separately in nsadb.h.
+ */
+
+#include "nsadb.h"
+
+/* Flags used in enumeration call-back function return value */
+#define ADBF_KEEPOBJ	0x1		/* do not free user or group object */
+#define ADBF_STOPENUM	0x2		/* stop the enumeration */
+
+NSPR_BEGIN_EXTERN_C
+
+/* Functions in nsamgmt.c */
+NSAPI_PUBLIC extern int nsadbAddGroupToGroup(NSErr_t * errp, void * authdb,
+					     GroupObj_t * pgoptr,
+					     GroupObj_t * cgoptr);
+
+NSAPI_PUBLIC extern int nsadbAddUserToGroup(NSErr_t * errp, void * authdb,
+					    GroupObj_t * goptr,
+					    UserObj_t * uoptr);
+
+NSAPI_PUBLIC extern int nsadbCreateGroup(NSErr_t * errp,
+					 void * authdb, GroupObj_t * goptr);
+
+NSAPI_PUBLIC extern int nsadbCreateUser(NSErr_t * errp,
+					void * authdb, UserObj_t * uoptr);
+
+/*
+for ANSI C++ standard on SCO UDK must typedef fn in arg list, otherwise fn
+name is managled
+*/
+
+#ifdef UnixWare
+typedef int(*ArgFn_EnumUsers)(NSErr_t * ferrp, void * authdb, void * parg,
+                 UserObj_t * uoptr);
+
+NSAPI_PUBLIC extern int nsadbEnumerateUsers(NSErr_t * errp, void * authdb,
+					void * argp, ArgFn_EnumUsers);
+#else /* UnixWare */
+NSAPI_PUBLIC extern int nsadbEnumerateUsers(NSErr_t * errp, void * authdb,
+					    void * argp,
+					    int (*func)(NSErr_t * ferrp,
+							void * authdb,
+							void * parg,
+							UserObj_t * uoptr));
+#endif /* UnixWare */
+ 
+#ifdef UnixWare
+typedef int(*ArgFn_EnumGroups)(NSErr_t * ferrp, void * authdb, void * parg,
+                 GroupObj_t * goptr);
+NSAPI_PUBLIC extern int nsadbEnumerateGroups(NSErr_t * errp,
+						void * authdb, void * argp,
+                       				ArgFn_EnumGroups);
+#else /* UnixWare */
+NSAPI_PUBLIC extern int nsadbEnumerateGroups(NSErr_t * errp,
+                                             void * authdb, void * argp,
+					     int (*func)(NSErr_t * ferrp,
+							 void * authdb,
+							 void * parg,
+							 GroupObj_t * goptr));
+#endif /* UnixWare */
+
+NSAPI_PUBLIC extern int nsadbIsUserInGroup(NSErr_t * errp, void * authdb,
+					   USI_t uid, USI_t gid,
+					   int ngroups, USI_t * grplist);
+
+NSAPI_PUBLIC extern int nsadbModifyGroup(NSErr_t * errp,
+					 void * authdb, GroupObj_t * goptr);
+
+NSAPI_PUBLIC extern int nsadbModifyUser(NSErr_t * errp,
+					void * authdb, UserObj_t * uoptr);
+
+NSAPI_PUBLIC extern int nsadbRemoveGroup(NSErr_t * errp,
+					 void * authdb, char * name);
+
+NSAPI_PUBLIC extern int nsadbRemoveUser(NSErr_t * errp,
+					void * authdb, char * name);
+
+NSAPI_PUBLIC extern int nsadbRemGroupFromGroup(NSErr_t * errp, void * authdb,
+					       GroupObj_t * pgoptr,
+					       GroupObj_t * cgoptr);
+
+NSAPI_PUBLIC extern int nsadbRemUserFromGroup(NSErr_t * errp, void * authdb,
+					      GroupObj_t * goptr,
+					      UserObj_t * uoptr);
+
+NSAPI_PUBLIC extern int nsadbSuperGroups(NSErr_t * errp, void * authdb,
+					 GroupObj_t * goptr,
+					 USIList_t * gsuper);
+
+
+NSPR_END_EXTERN_C
+
+#if defined(CLIENT_AUTH)
+
+/* Removed for new ns security integration
+#include <sec.h>
+*/
+#include <key.h>
+#include <cert.h>
+
+#endif /* defined(CLIENT_AUTH) */
+
+#endif /* __nsamgmt_h */

+ 288 - 0
include/libaccess/nsauth.h

@@ -0,0 +1,288 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef __nsauth_h
+#define __nsauth_h
+
+/*
+ * Description (nsauth.h)
+ *
+ *	This file defines types and interfaces which pertain to client
+ *	authentication.  The key types are Realm_t, which describes a
+ *	context for authentication, and ClAuth_t, which is used to
+ *	pass authentication information about a particular client
+ *	into and out of authentication interface functions.
+ */
+
+#ifdef CLIENT_AUTH
+
+#include "ssl.h"
+
+#if 0
+/* Removed for new ns security */
+#include "sec.h"		/* SECCertificate */
+#endif
+#include "cert.h"               /* CERTCertificate for new ns security bin */
+#endif /* CLIENT_AUTH */
+
+#include "usi.h"		/* identifier list support */
+#include "attrec.h"		/* attribute record types */
+#include "nserror.h"		/* error frame list support */
+#include "nsautherr.h"		/* authentication error codes */
+
+/* Define a scalar IP address value */
+#ifndef __IPADDR_T_
+#define __IPADDR_T_
+typedef unsigned long IPAddr_t;
+#endif /* __IPADDR_T_ */
+
+/*
+ * Description (UserObj_t)
+ *
+ *	This type defines the structure of a user object.  A user object
+ *	contains information about a user which might be contained in
+ *	an authentication database, including user name, password, user id,
+ *	and group membership.
+ */
+
+typedef struct UserObj_s UserObj_t;
+struct UserObj_s {
+    NTS_t uo_name;		/* user account name */
+    NTS_t uo_pwd;		/* encrypted password */
+    USI_t uo_uid;		/* user id */
+    USI_t uo_flags;		/* bit flags */
+#define UOF_DBFLAGS	0x1f	/* mask for flags stored in DB file */
+#define UOF_ERROR	0x20	/* error on last operation */
+#define UOF_NEW		0x40	/* new user object */
+#define UOF_MODIFIED	0x80	/* internal object modified */
+#define UOF_DELPEND	0x100	/* delete pending */
+
+    NTS_t uo_rname;		/* real user name (gecos string) */
+    USIList_t uo_groups;	/* list of group ids containing user */
+};
+
+/*
+ * Description (GroupObj_t)
+ *
+ *	This type defines the structure of a group object.  A group object
+ *	contains information about a group which might be contained in
+ *	an authentication database, including group name, group id, and
+ *	relationships to other groups.
+ */
+
+typedef struct GroupObj_s GroupObj_t;
+struct GroupObj_s {
+    NTS_t go_name;		/* group name */
+    USI_t go_gid;		/* group id */
+    USI_t go_flags;		/* bit flags */
+#define GOF_DBFLAGS	0x3f	/* mask for flags stored in DB file */
+#define GOF_NEW		0x40	/* new group object */
+#define GOF_MODIFIED	0x80	/* internal object modified */
+#define GOF_DELPEND	0x100	/* delete pending */
+
+    NTS_t go_desc;		/* group description */
+    USIList_t go_users;		/* list of user members (uids) */
+    USIList_t go_groups;	/* list of group members (gids) */
+    USIList_t go_pgroups;	/* list of parent groups (gids) */
+};
+
+/*
+ * Description (AuthIF_t)
+ *
+ *	This type describes a structure containing pointers to functions
+ *	which provide a standard interface to an authentication database.
+ *	The functions are described below.
+ *
+ *   Description (aif_close)
+ *
+ *	The referenced function closes an authentication database which
+ *	was previously opened via the aif_open function.
+ *
+ *   Arguments:
+ *
+ *	authdb			- handle for database returned by aif_open
+ *	flags			- close flags (unused - must be zero)
+ *
+ *
+ *   Description (aif_findid)
+ *
+ *	The referenced function looks up a specified user or group id
+ *	in a given authentication database.  Flags can be specified to
+ *	search for only matching user ids, only matching group ids,
+ *	or both.  The result value for a successful search indicates
+ *	whether a matching user or group id was found, and a pointer to
+ *	a user or group object is returned accordingly.
+ *
+ *   Arguments:
+ *
+ *	authdb			- handle for database returned by aif_open
+ *	id			- user/group id value
+ *	flags			- bit flags to control search
+ *	rptr			- pointer to returned user or group object
+ *				  pointer (may be null)
+ *
+ *   Returns:
+ *
+ *	If successful, the result value is greater than zero, and contains
+ *	a subset of the search flags, indicating what was found, and a user
+ *	or group object pointer is returned through 'rptr' if it is non-null.
+ *	An unsuccessful search is indicated by a return value of zero.  An
+ *	error is indicated by a negative return value (defined in
+ *	nsautherr.h).
+ *
+ *
+ *   Description (aif_findname)
+ *
+ *	The referenced function looks up a specified user or group name
+ *	in a given authentication database.  Flags can be specified to
+ *	search for only matching user names, only matching group names,
+ *	or both.  The result value for a successful search indicates
+ *	whether a matching user or group was found, and a pointer to a
+ *	user or group object is returned accordingly.
+ *
+ *   Arguments:
+ *
+ *	authdb			- handle for database returned by aif_open
+ *	name			- user/group name string pointer
+ *	flags			- bit flags to control search
+ *	rptr			- pointer to returned user or group object
+ *				  pointer (may be null)
+ *
+ *   Returns:
+ *
+ *	If successful, the result value is greater than zero, and contains
+ *	a subset of the search flags, indicating what was found, and a user
+ *	or group object pointer is returned through 'rptr' if it is non-null.
+ *	An unsuccessful search is indicated by a return value of zero.  An
+ *	error is indicated by a negative return value (defined in
+ *	nsautherr.h).
+ *
+ *
+ *   Description (aif_idtoname)
+ *
+ *	The referenced function looks up a specified user or group id
+ *	in a given authentication database, and returns the associated
+ *	user or group name.  Flags can be specified to search for only
+ *	matching user ids, only matching group ids, or both.  The result
+ *	value for a successful search indicates whether a matching user
+ *	or group id was found, and a pointer to the user or group name
+ *	is returned accordingly.
+ *
+ *   Arguments:
+ *
+ *	authdb			- handle for database returned by aif_open
+ *	id			- user/group id value
+ *	flags			- bit flags to control search
+ *	rptr			- pointer to returned user or group name
+ *				  pointer (may be null)
+ *
+ *   Returns:
+ *
+ *	If successful, the result value is greater than zero, and contains
+ *	a subset of the search flags, indicating what was found, and a user
+ *	or group name pointer is returned through 'rptr' if it is non-null.
+ *	An unsuccessful search is indicated by a return value of zero.  An
+ *	error is indicated by a negative return value (defined in
+ *	nsautherr.h).
+ *
+ *
+ *   Description (aif_open)
+ *
+ *	The referenced function opens a named authentication database of
+ *	the type supported by this interface.  The actual effect of the
+ *	open function depends on the particular type of database, but a
+ *	call to the aif_open function should generally be followed by a
+ *	call to the aif_close function at some point.
+ *
+ *   Arguments:
+ *
+ *	adbname			- authentication database name string pointer
+ *	flags			- open flags (definitions below)
+ *	rptr			- pointer to returned handle for the database
+ *
+ *   Returns:
+ *
+ *	The return value is zero if the operation is successful, and a
+ *	handle for the authentication database is returned through 'rptr'.
+ *	An error is indicated by a negative return value (defined in
+ *	nsautherr.h).
+ */
+
+typedef struct AuthIF_s AuthIF_t;
+struct AuthIF_s {
+    int (*aif_findid)(NSErr_t * errp,
+		      void * authdb, USI_t id, int flags, void **rptr);
+    int (*aif_findname)(NSErr_t * errp,
+			void * authdb, char * name, int flags, void **rptr);
+    int (*aif_idtoname)(NSErr_t * errp,
+			void * authdb, USI_t id, int flags, char **rptr);
+    int (*aif_open)(NSErr_t * errp, char * adbname, int flags, void **rptr);
+    void (*aif_close)(void * authdb, int flags);
+    int (*aif_addmember)(void **pmlist, char * name, int flags);
+    int (*aif_ismember)(void * mlist, char * name, int flags);
+};
+
+/* Define flags for the aif_open function */
+#define AIF_CREATE	0x1		/* new database (create it) */
+
+/*
+ * Define bits for flags and return value of aif_findid, aif_findid,
+ * and aif_idtoname functions.
+ */
+#define AIF_NONE	0		/* no matching group or user name */
+#define AIF_GROUP	0x1		/* matching group name/id found */
+#define AIF_USER	0x2		/* matching user name/id found */
+
+/*
+ * Description (Realm_t)
+ *
+ *	This type defines a structure which represents an authentication
+ *	realm.  Each realm has a unique name, which is accessed through
+ *	a Symbol_t structure, which in turn references a Realm_t as the
+ *	symbol value.  This structure specifies an authentication
+ *	method and an authentication database.
+ */
+
+typedef struct Realm_s Realm_t;
+struct Realm_s {
+    int rlm_ameth;		/* authentication method type */
+    char * rlm_dbname;		/* authentication database name */
+    AuthIF_t * rlm_aif;		/* authentication interface pointer */
+    void * rlm_authdb;		/* authentication database handle */
+    char * rlm_prompt;		/* realm prompt string */
+};
+
+/* Define supported authentication method codes for rlm_ameth */
+#define AUTH_METHOD_BASIC	1	/* basic authentication */
+#define AUTH_METHOD_SSL		2	/* SSL client authentication */
+
+/*
+ * Description (ClAuth_t)
+ *
+ *	This type describes a structure containing information about a
+ *	particular client.  It is used to pass information into and out
+ *	of authentication support functions, as well as to other functions
+ *	needing access to client authentication information.
+ * FUTURE:
+ *	- add client certificate pointer
+ */
+
+typedef struct ClAuth_s ClAuth_t;
+struct ClAuth_s {
+    Realm_t * cla_realm;	/* authentication realm pointer */
+    IPAddr_t cla_ipaddr;	/* IP address */
+    char * cla_dns;		/* DNS name string pointer */
+    UserObj_t * cla_uoptr;	/* authenticated user object pointer */
+    GroupObj_t * cla_goptr;	/* pointer to list of group objects */
+#ifdef CLIENT_AUTH
+#if 0
+  /* Removed for new ns security  */
+    SECCertificate * cla_cert;	/* certificate from SSL client auth */
+#endif
+    CERTCertificate * cla_cert;	/* certificate from SSL client auth */
+#endif /* CLIENT_AUTH */
+};
+
+#endif /* __nsauth_h */

+ 97 - 0
include/libaccess/nsautherr.h

@@ -0,0 +1,97 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef __nsautherr_h
+#define __nsautherr_h
+
+/* Define error id codes */
+
+/* Define error ids generated by nsumgmt.c */
+
+/* userRename() */
+#define NSAUERR1000	1000		/* insufficient dynamic memory */
+
+/* userStore() */
+#define NSAUERR1100	1100		/* insufficient dynamic memory */
+
+/* Define error ids generated by nsgmgmt.c */
+
+/* groupStore() */
+#define NSAUERR2000	2000		/* insufficient dynamic memory */
+
+/* Define error ids generated by nsadb.c */
+
+/* nsadbOpen() */
+#define NSAUERR3000	3000		/* invalid function argument */
+#define NSAUERR3020	3020		/* insufficient dynamic memory */
+#define NSAUERR3040	3040		/* create directory operation failed */
+#define NSAUERR3060	3060		/* open directory operation failed */
+
+/* nsadbOpenUsers() */
+#define NSAUERR3200	3200		/* invalid function argument */
+#define NSAUERR3220	3220		/* insufficient dynamic memory */
+#define NSAUERR3240	3240		/* error opening user database */
+
+/* nsadbOpenGroups() */
+#define NSAUERR3300	3300		/* invalid function argument */
+#define NSAUERR3320	3320		/* insufficient dynamic memory */
+#define NSAUERR3340	3340		/* error opening group database */
+
+#if defined(CLIENT_AUTH)
+/* nsadbOpenClients() */
+#define NSAUERR3400	3400		/* invalid function argument */
+#define NSAUERR3420	3420		/* insufficient dynamic memory */
+#define NSAUERR3430	3430		/* error initializing DB lock */
+#define NSAUERR3440	3440		/* error opening group database */
+
+/* nsadbPutUserByCert() */
+#define NSAUERR3500	3500		/* invalid username length */
+#define NSAUERR3520	3520		/* user-to-cert map already exists */
+
+/* nsadbOpenCertUsers() */
+#define NSAUERR3600	3600		/* error opening user-to-cert id DB */
+
+/* nsadbFindCertUser() */
+#define NSAUERR3700	3700		/* specified user name not found */
+
+/* nsadbAddCertUser() */
+#define NSAUERR3800	3800		/* error adding entry to database */
+
+/* nsadbRemoveCertUser() */
+#define NSAUERR3900	3900		/* error deleting entry in database */
+
+#endif /*  defined(CLIENT_AUTH) */
+
+/* Define error ids generated by nsamgmt.c */
+
+/* nsadbRemoveUser() */
+#define NSAUERR4000	4000		/* user name not found */
+
+/* nsadbRemoveGroup() */
+#define NSAUERR4100	4100		/* group name not found */
+
+/* Define error codes */
+#define NSAERRNOMEM	-1		/* insufficient dynamic memory */
+#define NSAERRINVAL	-2		/* invalid function argument */
+#define NSAERROPEN	-3		/* error opening database */
+#define NSAERRMKDIR	-4		/* error creating database directory */
+#define NSAERRNAME	-5		/* user or group name not found */
+#define NSAERRPUT	-6		/* error writing record to database */
+#define NSAERRCMAP	-7		/* certificate map already exists */
+#define NSAERRDEL	-8		/* error deleting database entry */
+#define NSAERRLOCK	-9		/* error initializing DB lock */
+
+NSPR_BEGIN_EXTERN_C
+
+/* Authentication facility name in nsuser.c */
+extern char * NSAuth_Program;
+
+    /* Functions in nsautherr.c */
+extern NSAPI_PUBLIC void nsadbErrorFmt(NSErr_t * errp,
+			  char * msgbuf, int maxlen, int maxdepth);
+
+NSPR_END_EXTERN_C
+
+#endif /* __nsautherr_h */

+ 102 - 0
include/libaccess/nscert.h

@@ -0,0 +1,102 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef __nscert_h
+#define __nscert_h
+
+/*
+ * Description (nscert.h)
+ *
+ *	This file describes the interface for accessing and storing
+ *	information in a Netscape client certificate to username
+ *	database.  This facility is built on top of the Netscape
+ *	(server) database interface as defined in nsdb.h.  
+ */
+
+#include <libaccess/nserror.h>		/* error frame list support */
+#include <libaccess/nsautherr.h>	/* authentication error codes */
+#include <libaccess/nsauth.h>
+
+#include <prtypes.h>
+/* Removed for new ns security integration
+#include <sec.h>
+*/
+#include <cert.h>
+
+#if defined(CLIENT_AUTH)
+
+/* Certificate to user record attribute tags */
+#define CAT_USERNAME	0x61		/* username associated with cert */
+#define CAT_CERTID	0x62		/* id assigned to cert */
+
+/* Attribute tags used in certificate key encoding */
+#define KAT_ISSUER	0x01		/* issuer DER */
+#define KAT_SUBJECT	0x02		/* subject DER */
+
+typedef struct CertObj_s CertObj_t;
+struct CertObj_s {
+    SECItem co_issuer;		/* issuing authority */
+    SECItem co_subject;		/* certicate's subject */
+    char * co_username;		/* the local name it mapps to */
+    USI_t co_certid;		/* internal id for this client certificate */
+};
+
+typedef int (*CertEnumCallback)(NSErr_t * ferrp, void * authdb,
+				void * argp, CertObj_t * coptr);
+    
+NSPR_BEGIN_EXTERN_C
+
+extern NSAPI_PUBLIC int nsadbCertInitialize(void);
+
+extern NSAPI_PUBLIC int nsadbDecodeCertKey(int keylen, char * keyptr,
+					   SECItem * issuer,
+					   SECItem * subject);
+
+extern NSAPI_PUBLIC int nsadbDecodeCertRec(int reclen, char * recptr,
+					   CertObj_t * coptr);
+
+extern NSAPI_PUBLIC int nsadbEncodeCertKey(SECItem * issuer, SECItem * subject,
+					   int * keylen, char **keyptr);
+
+extern NSAPI_PUBLIC int nsadbEnumerateCerts(NSErr_t * errp, void * authdb,
+					    void * argp,
+					    CertEnumCallback func);
+
+extern NSAPI_PUBLIC void nsadbFreeCertObj(CertObj_t * coptr);
+
+extern NSAPI_PUBLIC int nsadbGetCertById(NSErr_t * errp, void * authdb,
+					 USI_t certid, CertObj_t **coptr);
+
+extern NSAPI_PUBLIC int nsadbGetUserByCert(NSErr_t * errp, void * authdb,
+					   CERTCertificate * cert,
+					   char **username);
+
+extern NSAPI_PUBLIC int nsadbOpenCerts(NSErr_t * errp,
+				       void * authdb, int flags);
+
+extern NSAPI_PUBLIC int nsadbPutUserByCert(NSErr_t * errp, void * authdb,
+					   CERTCertificate * cert,
+					   const char * username);
+
+extern NSAPI_PUBLIC int nsadbRemoveCert(NSErr_t * errp, void * authdb,
+					void * username, CertObj_t * coptr);
+
+extern NSAPI_PUBLIC int nsadbRemoveUserCert(NSErr_t * errp, void * authdb,
+					    char * username);
+
+extern NSAPI_PUBLIC void nsadbCloseCerts(void * authdb, int flags);
+
+extern NSAPI_PUBLIC void nsadbCloseCertUsers(void * authdb, int flags);
+
+extern NSAPI_PUBLIC int nsadbFindCertUser(NSErr_t * errp, void * authdb,
+					  const char * username, USI_t * id);
+
+
+NSPR_END_EXTERN_C
+
+#endif /* CLIENT_AUTH */
+
+
+#endif /* __nscert_h */

+ 182 - 0
include/libaccess/nsdb.h

@@ -0,0 +1,182 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef __nsdb_h
+#define __nsdb_h
+
+/*
+ * Description (nsdb.h)
+ *
+ *	This file describes the interface for retrieving information
+ *	from a Netscape (server) database.  A database is composed of
+ *	two (libdbm) DB files.  One of these (<dbname>.db) contains
+ *	records indexed by a string key.  These records contain the
+ *	primary information in the database.  A second DB file
+ *	(<dbname>.id) is used to map an integer id value to a string
+ *	key, which can then be used to locate a record in the first file.
+ *	The interface for managing information in a database is described
+ *	in nsdbmgmt.h.
+ */
+
+/* Begin private definitions */
+#ifdef __PRIVATE_NSDB
+
+#include "mcom_db.h"
+
+/*
+ * Description (NSDB_t)
+ *
+ *	This type describes the structure that used to represent a
+ *	Netscape server database.  It includes fields to reference
+ *	both the primary and id-to-name DB files, and information
+ *	about the current state of the database.
+ */
+
+typedef struct NSDB_s NSDB_t;
+struct NSDB_s {
+    char * ndb_pname;			/* primary DB file name pointer */
+    DB * ndb_pdb;			/* primary DB file handle */
+    char * ndb_iname;			/* id-to-name DB file name pointer */
+    DB * ndb_idb;			/* id-to-name DB file handle */
+    int ndb_flags;			/* bit flags */
+#define NDBF_RDNAME	0x1		/* primary DB open for read */
+#define NDBF_WRNAME	0x2		/* primary DB open for write */
+#define NDBF_NONAME	0x4		/* primary DB does not exist */
+#define NDBF_RDID	0x10		/* id-to-name DB open for read */
+#define NDBF_WRID	0x20		/* id-to-name DB open for write */
+#define NDBF_NOID	0x40		/* id-to-name DB does not exist */
+
+    int ndb_dbtype;			/* database type */
+    int ndb_version;			/* type-specific version number */
+};
+
+/* Define metadata record keys (must start with NDB_MDPREFIX) */
+#define NDB_DBTYPE	"?dbtype"	/* database type and version info */
+#define NDB_IDMAP	"?idmap"	/* id allocation bitmap */
+
+#endif /* __PRIVATE_NSDB */
+
+/* Begin public definitions */
+
+#include "nserror.h"		/* error frame list support */
+#include "nsdberr.h"		/* error codes for NSDB facility */
+
+/* Define the NSDB version number */
+#define NDB_VERSION		0x10	/* NSDB version 1.0 */
+
+/* Define reserved database type codes for ndb_dbtype */
+#define NDB_TYPE_USERDB		1	/* user database */
+#define NDB_TYPE_GROUPDB	2	/* group database */
+#define NDB_TYPE_CLIENTDB	3	/* client database */
+#define NDB_TYPE_ACLDB		4	/* access control list database */
+
+/*
+ * Define the metadata record key prefix character.  Normal data record
+ * keys (names) cannot begin with this character.
+ */
+#define NDB_MDPREFIX	'?'
+
+/* Define flags for ndbEnumerate() */
+#define NDBF_ENUMNORM	0x1		/* enumerate normal data records */
+#define NDBF_ENUMMETA	0x2		/* enumerate metadata records */
+
+/* Define return values for a user function called by ndbEnumerate */
+#define NDB_ENUMSTOP	-1		/* terminate enumeration */
+#define NDB_ENUMCONT	0		/* continue enumeration */
+#define NDB_ENUMRESET	1		/* restart enumeration at beginning */
+
+NSPR_BEGIN_EXTERN_C
+
+/* Functions for database information retrieval in nsdb.c */
+extern void ndbClose(void * ndb, int flags);
+
+/* for ANSI C++ standard on SCO UDK, otherwise fn name is mangled */
+#ifdef UnixWare
+typedef int (*ArgFn_ndbEnum)(NSErr_t * ferrp, void * parg, int namelen,
+                           char * name, int reclen, char * recptr);
+extern int ndbEnumerate(NSErr_t * errp, void * ndb, int flags, void * argp,
+                        ArgFn_ndbEnum);
+#else /* UnixWare */
+extern int ndbEnumerate(NSErr_t * errp, void * ndb, int flags, void * argp,
+			int (*func)(NSErr_t * ferrp, void * parg,
+				    int namelen, char * name,
+				    int reclen, char * recptr));
+#endif /* UnixWare */
+extern int ndbFindName(NSErr_t * errp, void * ndb, int namelen, char * name,
+		       int * reclen, char **recptr);
+extern int ndbIdToName(NSErr_t * errp,
+		       void * ndb, unsigned int id, int * plen, char **pname);
+extern int ndbInitPrimary(NSErr_t * errp, void * ndb);
+extern void * ndbOpen(NSErr_t * errp,
+		      char * dbname, int flags, int dbtype, int * version);
+extern int ndbReOpen(NSErr_t * errp, void * ndb, int flags);
+
+NSPR_END_EXTERN_C
+
+/* richm - 20020218 - these macros were added as part of the port to DBM 1.6
+ * apparently, these were exported for outside use from mcom_db.h in
+ * DBM 1.5x and earlier, but were made private in 1.6 - so I copied them
+ * here
+ */
+/*
+ * Little endian <==> big endian 32-bit swap macros.
+ *	M_32_SWAP	swap a memory location
+ *	P_32_SWAP	swap a referenced memory location
+ *	P_32_COPY	swap from one location to another
+ */
+#ifndef M_32_SWAP
+#define	M_32_SWAP(a) {							\
+	uint32 _tmp = a;						\
+	((char *)&a)[0] = ((char *)&_tmp)[3];				\
+	((char *)&a)[1] = ((char *)&_tmp)[2];				\
+	((char *)&a)[2] = ((char *)&_tmp)[1];				\
+	((char *)&a)[3] = ((char *)&_tmp)[0];				\
+}
+#endif
+#ifndef P_32_SWAP
+#define	P_32_SWAP(a) {							\
+	uint32 _tmp = *(uint32 *)a;				\
+	((char *)a)[0] = ((char *)&_tmp)[3];				\
+	((char *)a)[1] = ((char *)&_tmp)[2];				\
+	((char *)a)[2] = ((char *)&_tmp)[1];				\
+	((char *)a)[3] = ((char *)&_tmp)[0];				\
+}
+#endif
+#ifndef P_32_COPY
+#define	P_32_COPY(a, b) {						\
+	((char *)&(b))[0] = ((char *)&(a))[3];				\
+	((char *)&(b))[1] = ((char *)&(a))[2];				\
+	((char *)&(b))[2] = ((char *)&(a))[1];				\
+	((char *)&(b))[3] = ((char *)&(a))[0];				\
+}
+#endif
+/*
+ * Little endian <==> big endian 16-bit swap macros.
+ *	M_16_SWAP	swap a memory location
+ *	P_16_SWAP	swap a referenced memory location
+ *	P_16_COPY	swap from one location to another
+ */
+#ifndef M_16_SWAP
+#define	M_16_SWAP(a) {							\
+	uint16 _tmp = a;						\
+	((char *)&a)[0] = ((char *)&_tmp)[1];				\
+	((char *)&a)[1] = ((char *)&_tmp)[0];				\
+}
+#endif
+#ifndef P_16_SWAP
+#define	P_16_SWAP(a) {							\
+	uint16 _tmp = *(uint16 *)a;				\
+	((char *)a)[0] = ((char *)&_tmp)[1];				\
+	((char *)a)[1] = ((char *)&_tmp)[0];				\
+}
+#endif
+#ifndef P_16_COPY
+#define	P_16_COPY(a, b) {						\
+	((char *)&(b))[0] = ((char *)&(a))[1];				\
+	((char *)&(b))[1] = ((char *)&(a))[0];				\
+}
+#endif
+
+#endif /* __nsdb_h */

+ 92 - 0
include/libaccess/nsdberr.h

@@ -0,0 +1,92 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef __nsdberr_h
+#define __nsdberr_h
+
+/* NSDB facility name (defined in nsdb,c) */
+extern char * NSDB_Program;
+
+/* Define error identifiers for NSDB facility */
+
+/* Errors generated in nsdb.c */
+
+/* ndbFindName() */
+#define NSDBERR1000	1000	/* primary DB get operation failed */
+
+/* ndbIdToName() */
+#define NSDBERR1100	1100	/* id-to-name DB get operation failed */
+
+/* ndbInitPrimary() */
+#define NSDBERR1200	1200	/* primary database already exists */
+#define NSDBERR1220	1220	/* primary database open failed */
+#define NSDBERR1240	1240	/* primary DB put operation failed */
+#define NSDBERR1260	1260	/* primary DB put operation failed */
+
+/* ndbOpen() */
+#define NSDBERR1400	1400	/* insufficient dynamic memory */
+#define NSDBERR1420	1420	/* insufficient dynamic memory */
+#define NSDBERR1440	1440	/* insufficient dynamic memory */
+#define NSDBERR1460	1460	/* primary DB get metadata operation failed */
+#define NSDBERR1480	1480	/* metadata format error */
+#define NSDBERR1500	1500	/* unsupported database version number */
+#define NSDBERR1520	1520	/* wrong database type */
+
+/* ndbReOpen() */
+#define NSDBERR1600	1600	/* create primary DB failed */
+#define NSDBERR1620	1620	/* open primary/write failed */
+#define NSDBERR1640	1640	/* open primary/read failed */
+#define NSDBERR1660	1660	/* create id-to-name DB failed */
+#define NSDBERR1680	1680	/* open id-to-name DB for write failed */
+#define NSDBERR1700	1700	/* open id-to-name DB for read failed */
+
+/* Define error ids generated in nsdbmgmt.c */
+
+/* ndbAllocId() */
+#define NSDBERR2000	2000	/* bad DB name key */
+#define NSDBERR2020	2020	/* metadata get operation failed */
+#define NSDBERR2040	2040	/* no space to grow DB id bitmap */
+#define NSDBERR2060	2060	/* no space to copy DB id bitmap */
+#define NSDBERR2080	2080	/* put bitmap to DB operation failed */
+#define NSDBERR2100	2100	/* put id-to-name operation failed */
+
+/* ndbDeleteName() */
+#define NSDBERR2200	2200	/* error deleting record */
+
+/* ndbFreeId() */
+#define NSDBERR2300	2300	/* invalid id value */
+#define NSDBERR2320	2320	/* error deleting id-to-name record */
+#define NSDBERR2340	2340	/* error reading id bitmap from primary DB */
+#define NSDBERR2360	2360	/* invalid id value */
+#define NSDBERR2380	2380	/* insufficient dynamic memory */
+#define NSDBERR2400	2400	/* error writing id bitmap back to DB */
+
+/* ndbRenameId() */
+#define NSDBERR2500	2500	/* invalid new key name string */
+#define NSDBERR2520	2520	/* get id record operation failed */
+#define NSDBERR2540	2540	/* put id record operation failed */
+
+/* ndbStoreName() */
+#define NSDBERR2700	2700	/* database put operation failed */
+
+/* Define error return codes */
+#define NDBERRNOMEM	-1		/* insufficient dynamic memory */
+#define NDBERRNAME	-2		/* invalid key name string */
+#define NDBERROPEN	-3		/* database open error */
+#define NDBERRMDGET	-4		/* database metadata get failed */
+#define NDBERRMDPUT	-5		/* database metadata put failed */
+#define NDBERRIDPUT	-6		/* id-to-name record put failed */
+#define NDBERRNMDEL	-7		/* delete named record failed */
+#define NDBERRPINIT	-8		/* error creating primary DB file */
+#define NDBERRGET	-9		/* database get failed */
+#define NDBERREXIST	-10		/* DB already exists */
+#define NDBERRMDFMT	-11		/* invalid metadata format */
+#define NDBERRDBTYPE	-12		/* wrong DB type */
+#define NDBERRBADID	-13		/* invalid id value for name */
+#define NDBERRPUT	-14		/* database put operation failed */
+#define NDBERRVERS	-15		/* unsupported database version */
+#define NDBERRIDDEL	-16		/* delete id-to-name record failed */
+
+#endif /* __nsdberr_h */

+ 52 - 0
include/libaccess/nsdbmgmt.h

@@ -0,0 +1,52 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef __nsdbmgmt_h
+#define __nsdbmgmt_h
+
+/*
+ * Description (nsdbmgmt.h)
+ *
+ *	The file describes the interface for managing information in
+ *	a Netscape (server) database.  A database is composed of
+ *	two (libdbm) DB files.  One of these (<dbname>.db) contains
+ *	records indexed by a string key.  These records contain the
+ *	primary information in the database.  A second DB file
+ *	(<dbname>.id) is used to map an integer id value to a string
+ *	key, which can then be used to locate a record in the first file.
+ *	The interface for retrieving information from a database is
+ *	described in nsdb.h.
+ *
+ * FUTURE:
+ *	Normally the records in the primary DB file will contain the
+ *	id values which are used to key the id-to-name DB.  When this
+ *	is the case, it is possible to construct the id-to-name DB from
+ *	the primary DB file, and an interface is provided to facilitate
+ *	this.
+ */
+
+#include "nsdb.h"			/* database access */
+
+/* Define flags for ndbStoreName() */
+#define NDBF_NEWNAME	0x1		/* this is (should be) a new name */
+
+NSPR_BEGIN_EXTERN_C
+
+/* Functions for database management in nsdbmgmt.c */
+extern int ndbAllocId(NSErr_t * errp, void * ndb,
+		      int namelen, char * name, unsigned int * id);
+extern int ndbDeleteName(NSErr_t * errp,
+			 void * ndb, int flags, int namelen, char * name);
+extern int ndbFreeId(NSErr_t * errp,
+		     void * ndb, int namelen, char * name, unsigned int id);
+extern int ndbRenameId(NSErr_t * errp, void * ndb,
+		       int namelen, char * newname, unsigned int id);
+extern int ndbStoreName(NSErr_t * errp, void * ndb, int flags,
+			int namelen, char * name, int reclen, char * recptr);
+extern int ndbSync(NSErr_t * errp, void * ndb, int flags);
+
+NSPR_END_EXTERN_C
+
+#endif /* __nsdbmgmt_h */

+ 47 - 0
include/libaccess/nserror.h

@@ -0,0 +1,47 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef __nserror_h
+#define __nserror_h
+
+#ifndef NOINTNSACL
+#define INTNSACL
+#endif /* !NOINTNSACL */
+
+/*
+ * Description (nserror.h)
+ *
+ *	This file describes the interface to an error handling mechanism
+ *	that is intended for general use.  This mechanism uses a data
+ *	structure known as an "error frame" to capture information about
+ *	an error.  Multiple error frames are used in nested function calls
+ *	to capture the interpretation of an error at the different levels
+ *	of a nested call.
+ */
+
+#include <stdarg.h>
+#include <prtypes.h>
+#include "public/nsacl/nserrdef.h"
+
+#ifdef INTNSACL
+
+NSPR_BEGIN_EXTERN_C
+
+/* Functions in nseframe.c */
+extern void nserrDispose(NSErr_t * errp);
+extern NSEFrame_t * nserrFAlloc(NSErr_t * errp);
+extern void nserrFFree(NSErr_t * errp, NSEFrame_t * efp);
+extern NSEFrame_t * nserrGenerate(NSErr_t * errp, long retcode, long errorid,
+				  char * program, int errc, ...);
+
+/* Functions in nserrmsg.c */
+extern char * nserrMessage(NSEFrame_t * efp, int flags);
+extern char * nserrRetrieve(NSEFrame_t * efp, int flags);
+
+NSPR_END_EXTERN_C
+
+#endif /* INTNSACL */
+
+#endif /* __nserror_h */

+ 35 - 0
include/libaccess/nsgmgmt.h

@@ -0,0 +1,35 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef __nsgmgmt_h
+#define __nsgmgmt_h
+
+/*
+ * Description (nsgmgmt.h)
+ *
+ *	This file defines the interface to group management facilities
+ *	implemented using a Netscape group database.  This interface
+ *	provides functions for adding, modifying, and removing group
+ *	entries in the database, using the group object (GroupObj_t)
+ *	structure to convey information across the interface.
+ */
+
+#define __PRIVATE_NSGROUP
+#include "nsgroup.h"		/* group object access */
+
+NSPR_BEGIN_EXTERN_C
+
+/* Group information management operations in nsgmgmt.c */
+extern NSAPI_PUBLIC int groupAddMember(GroupObj_t * goptr, int isgid, USI_t id);
+extern NSAPI_PUBLIC GroupObj_t * groupCreate(NTS_t name, NTS_t desc);
+extern NSAPI_PUBLIC int groupDeleteMember(GroupObj_t * goptr, int isgid, USI_t id);
+extern NSAPI_PUBLIC int groupEncode(GroupObj_t * goptr, int * ureclen, ATR_t * urecptr);
+extern NSAPI_PUBLIC int groupRemove(NSErr_t * errp, void * groupdb, int flags, NTS_t name);
+extern NSAPI_PUBLIC int groupStore(NSErr_t * errp,
+		      void * groupdb, int flags, GroupObj_t * goptr);
+
+NSPR_END_EXTERN_C
+
+#endif /* __nsgmgmt_h */

+ 73 - 0
include/libaccess/nsgroup.h

@@ -0,0 +1,73 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef __nsgroup_h
+#define __nsgroup_h
+
+/*
+ * Description (nsgroup.h)
+ *
+ *	This file describes the interface to group information stored in
+ *	a Netscape group database.  Information about a group is provided
+ *	to the caller in the form of a group object (GroupObj_t), defined
+ *	in nsauth.h.  This interface provides only read access to group
+ *	information.  The interface for managing the group database is
+ *	described in nsgmgmt.h.
+ */
+
+#include "nserror.h"		/* error frame list support */
+#include "nsautherr.h"		/* authentication error codes */
+#include "nsauth.h"		/* authentication types */
+
+/* Begin private definitions */
+#ifdef __PRIVATE_NSGROUP
+
+#include "nsdb.h"
+
+/*
+ * Define structure used to communicate between groupEnumerate() and
+ * groupEnumHelp().
+ */
+
+typedef struct GroupEnumArgs_s GroupEnumArgs_t;
+struct GroupEnumArgs_s {
+    void * groupdb;			/* group database handle */
+    int flags;				/* groupEnumerate() flags */
+    int (*func)(NSErr_t * ferrp, void * parg,
+		GroupObj_t * goptr);	/* user function pointer */
+    void * user;			/* user's argp pointer */
+};
+
+/* Define attribute tags for group DB records */
+#define GAT_GID		0x50		/* group id (USI) */
+#define GAT_FLAGS	0x51		/* flags (USI) */
+#define GAT_DESCRIPT	0x52		/* group description (NTS) */
+#define GAT_USERS	0x53		/* list of users (USI...) */
+#define GAT_GROUPS	0x54		/* list of groups (USI...) */
+#define GAT_PGROUPS	0x55		/* list of paret groups (USI...) */
+
+#endif /* __PRIVATE_NSGROUP */
+
+/* Begin public definitions */
+
+/* Define flags for groupEnumerate() */
+#define GOF_ENUMKEEP	0x1		/* don't free group objects */
+
+NSPR_BEGIN_EXTERN_C
+
+    /* Operations on a group object (see nsgroup.c) */
+extern NSAPI_PUBLIC GroupObj_t * groupDecode(NTS_t name, int ureclen, ATR_t urecptr);
+extern NSAPI_PUBLIC int groupEnumerate(NSErr_t * errp,
+			  void * groupdb, int flags, void * argp,
+			  int (*func)(NSErr_t * ferrp,
+				     void * parg, GroupObj_t * goptr));
+extern NSAPI_PUBLIC GroupObj_t * groupFindByName(NSErr_t * errp,
+				    void * groupdb, NTS_t name);
+extern NSAPI_PUBLIC GroupObj_t * groupFindByGid(NSErr_t * errp, void * groupdb, USI_t gid);
+extern NSAPI_PUBLIC void groupFree(GroupObj_t * goptr);
+
+NSPR_END_EXTERN_C
+
+#endif /* __nsgroup_h */

+ 74 - 0
include/libaccess/nslock.h

@@ -0,0 +1,74 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef __nslock_h
+#define __nslock_h
+
+/*
+ * Description (nslock.h)
+ *
+ *	This file defines to interface for a locking facility that
+ *	provides exclusive access to a resource across multiple
+ *	server processes.
+ */
+
+#include "nserror.h"
+#include "base/crit.h"
+
+#ifdef __PRIVATE_NSLOCK
+
+/*
+ * Description (NSLock_t)
+ *
+ *	This type represents a lock.  It includes a name which
+ *	uniquely identifies the lock, and a handle for referencing
+ *	the lock once it has been initialized.
+ */
+
+typedef struct NSLock_s NSLock_t;
+struct NSLock_s {
+    NSLock_t * nl_next;			/* next lock on NSLock_List */
+    char * nl_name;			/* name associate with lock */
+#if defined(FILE_UNIX)
+    CRITICAL nl_crit;			/* critical section for threads */
+    SYS_FILE nl_fd;			/* file descriptor */
+    int nl_cnt;				/* nsLockAcquire() count */
+#elif defined(XP_WIN32)
+#else
+#error "nslock.h needs work for this platform"
+#endif
+};
+
+#endif /* __PRIVATE_NSLOCK */
+
+/* Define error identifiers */
+
+/* nsLockOpen() */
+#define NSLERR1000	1000		/* insufficient dynamic memory */
+#define NSLERR1020	1020		/* error creating lock */
+#define NSLERR1040	1040		/* error accessing lock */
+
+/* nsLockAcquire() */
+#define NSLERR1100	1100		/* error acquiring lock */
+
+/* Define error return codes */
+
+#define NSLERRNOMEM	-1		/* insufficient dynamic memory */
+#define NSLERRCREATE	-2		/* error creating lock */
+#define NSLERROPEN	-3		/* error accessing lock */
+#define NSLERRLOCK	-4		/* error acquiring lock */
+
+NSPR_BEGIN_EXTERN_C
+
+/* Functions in nslock.c */
+extern NSAPI_PUBLIC int nsLockOpen(NSErr_t * errp,
+				   char * lockname, void **plock);
+extern NSAPI_PUBLIC int nsLockAcquire(NSErr_t * errp, void * lock);
+extern NSAPI_PUBLIC void nsLockRelease(void * lock);
+extern NSAPI_PUBLIC void nsLockClose(void * lock);
+
+NSPR_END_EXTERN_C
+
+#endif __nslock_h

+ 36 - 0
include/libaccess/nsumgmt.h

@@ -0,0 +1,36 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef __nsumgmt_h
+#define __nsumgmt_h
+
+/*
+ * Description (nsumgmt.h)
+ *
+ *	This file defines the interface to user management facilities
+ *	implemented using a Netscape user database.  This interface
+ *	provides functions for adding, modifying, and removing user
+ *	entries in the database, using the user object (UserObj_t)
+ *	structure to convey information across the interface.
+ */
+
+#include "nsuser.h"		/* user object access */
+
+NSPR_BEGIN_EXTERN_C
+
+/* User information management operations in nsumgmt.c */
+extern int userAddGroup(UserObj_t * uoptr, USI_t gid);
+extern NSAPI_PUBLIC UserObj_t * userCreate(NTS_t name, NTS_t pwd, NTS_t rname);
+extern int userDeleteGroup(UserObj_t * uoptr, USI_t gid);
+extern int userEncode(UserObj_t * uoptr, int * ureclen, ATR_t * urecptr);
+extern NSAPI_PUBLIC int userRemove(NSErr_t * errp, void * userdb, int flags, NTS_t name);
+extern NSAPI_PUBLIC int userRename(NSErr_t * errp,
+		      void * userdb, UserObj_t * uoptr, NTS_t newname);
+extern NSAPI_PUBLIC int userStore(NSErr_t * errp,
+		     void * userdb, int flags, UserObj_t * uoptr);
+
+NSPR_END_EXTERN_C
+
+#endif /* __nsumgmt_h */

+ 70 - 0
include/libaccess/nsuser.h

@@ -0,0 +1,70 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef __nsuser_h
+#define __nsuser_h
+
+/*
+ * Description (nsuser.h)
+ *
+ *	This file describes the interface to user information stored in
+ *	a Netscape user database.  Information about a user is provided
+ *	to the caller in the form of a user object (UserObj_t), defined
+ *	in nsauth.h.  This interface provides only read access to user
+ *	information.  The interface for managing the user database is
+ *	described in nsumgmt.h.
+ */
+
+#include "nserror.h"		/* error frame list support */
+#include "nsautherr.h"		/* authentication error codes */
+#include "nsauth.h"		/* authentication types */
+
+/* Begin private definitions */
+#ifdef __PRIVATE_NSUSER
+
+#include "nsdb.h"
+
+/*
+ * Define structure used to communicate between userEnumerate() and
+ * userEnumHelp().
+ */
+
+typedef struct UserEnumArgs_s UserEnumArgs_t;
+struct UserEnumArgs_s {
+    void * userdb;			/* user database handle */
+    int flags;				/* userEnumerate() flags */
+    int (*func)(NSErr_t * ferrp, void * parg,
+		UserObj_t * uoptr);	/* user function pointer */
+    void * user;			/* user's argp pointer */
+};
+
+/* Define attribute tags for user DB records */
+#define UAT_PASSWORD	0x40		/* password (NTS) */
+#define UAT_UID		0x41		/* user id (USI) */
+#define UAT_ACCFLAGS	0x42		/* account flags (USI) */
+#define UAT_REALNAME	0x43		/* real name (NTS) */
+#define UAT_GROUPS	0x44		/* list of groups (USI...) */
+
+#endif /* __PRIVATE_NSUSER */
+
+/* Begin public definitions */
+
+/* Define flags for userEnumerate() */
+#define UOF_ENUMKEEP	0x1		/* don't free user objects */
+
+NSPR_BEGIN_EXTERN_C
+
+/* User information retrieval operations in nsuser.c */
+extern UserObj_t * userDecode(NTS_t name, int ureclen, ATR_t urecptr);
+extern int userEnumerate(NSErr_t * errp, void * userdb, int flags, void * argp,
+			 int (*func)(NSErr_t * ferrp,
+				     void * parg, UserObj_t * uoptr));
+extern UserObj_t * userFindByName(NSErr_t * errp, void * userdb, NTS_t name);
+extern UserObj_t * userFindByUid(NSErr_t * errp, void * userdb, USI_t uid);
+NSAPI_PUBLIC extern void userFree(UserObj_t * uoptr);
+
+NSPR_END_EXTERN_C
+
+#endif /* __nsuser_h */

+ 215 - 0
include/libaccess/register.h

@@ -0,0 +1,215 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+
+#ifndef ACL_REGISTER_HEADER
+#define ACL_REGISTER_HEADER
+
+#include <prhash.h>
+
+#include <ldap.h>
+#include <base/pblock.h>
+#include <base/plist.h>
+#include <libaccess/nserror.h>
+#include <libaccess/acl.h>
+
+typedef	void * ACLMethod_t;
+#define	ACL_METHOD_ANY		(ACLMethod_t)-1
+#define	ACL_METHOD_INVALID	(ACLMethod_t)-2
+extern ACLMethod_t ACL_METHOD_BASIC;
+
+typedef	void * ACLDbType_t;
+#define	ACL_DBTYPE_ANY		(ACLDbType_t)-1
+#define	ACL_DBTYPE_INVALID	(ACLDbType_t)-2
+extern ACLDbType_t ACL_ACL_DBTYPE_LDAP;
+
+typedef int (*AttrGetterFn)(NSErr_t *errp, PList_t subject, PList_t resource, PList_t auth_info, PList_t global_auth, void *arg);
+typedef int (*AclModuleInitFunc)(pblock *pb, Session *sn, Request *rq);
+typedef int (*DbParseFn_t)(NSErr_t *errp, ACLDbType_t dbtype,
+			   const char *name, const char *url,
+			   PList_t plist, void **db);
+typedef int (*AclCacheFlushFunc_t)(void);
+
+#ifdef __cplusplus
+typedef int (*LASEvalFunc_t)(NSErr_t*, char*, CmpOp_t, char*, int*, void**, PList_t, PList_t, PList_t, PList_t);
+typedef void (*LASFlushFunc_t)(void **);
+#else
+typedef int (*LASEvalFunc_t)();
+typedef void (*LASFlushFunc_t)();
+#endif
+
+/* We need to hide ACLGetter_t */
+typedef struct ACLGetter_s {
+	ACLMethod_t	method;
+	ACLDbType_t	db;
+	AttrGetterFn	fn;
+	void 		*arg;
+} ACLGetter_t;
+typedef ACLGetter_t *ACLGetter_p;
+
+/*
+ *	Command values for the "position" argument to ACL_RegisterGetter
+ *	Any positive >0 value is the specific position in the list to insert
+ *	the new function.
+ */
+#define	ACL_AT_FRONT		0
+#define	ACL_AT_END		-1
+#define	ACL_REPLACE_ALL 	-2
+#define	ACL_REPLACE_MATCHING	-3
+
+#ifdef	ACL_LIB_INTERNAL
+#define	ACL_MAX_METHOD		32
+#define	ACL_MAX_DBTYPE		32
+#endif
+
+NSPR_BEGIN_EXTERN_C
+
+NSAPI_PUBLIC extern int
+	ACL_LasRegister( NSErr_t *errp, char *attr_name, LASEvalFunc_t
+	eval_func, LASFlushFunc_t flush_func );
+NSAPI_PUBLIC extern int
+	ACL_LasFindEval( NSErr_t *errp, char *attr_name, LASEvalFunc_t
+	*eval_funcp );
+NSAPI_PUBLIC extern int
+	ACL_LasFindFlush( NSErr_t *errp, char *attr_name, LASFlushFunc_t
+	*flush_funcp );
+extern void
+	ACL_LasHashInit( void );
+extern void
+	ACL_LasHashDestroy( void );
+
+/*
+ *	Revised, normalized method/dbtype registration routines
+ */
+NSAPI_PUBLIC extern int
+	ACL_MethodRegister(const char *name, ACLMethod_t *t);
+NSAPI_PUBLIC extern int
+	ACL_MethodIsEqual(const ACLMethod_t t1, const ACLMethod_t t2);
+NSAPI_PUBLIC extern int
+	ACL_MethodNameIsEqual(const ACLMethod_t t, const char *name);
+NSAPI_PUBLIC extern int
+	ACL_MethodFind(const char *name, ACLMethod_t *t);
+NSAPI_PUBLIC extern ACLMethod_t
+	ACL_MethodGetDefault();
+NSAPI_PUBLIC extern void
+	ACL_MethodSetDefault(const ACLMethod_t t);
+NSAPI_PUBLIC extern int
+	ACL_AuthInfoGetMethod(PList_t auth_info, ACLMethod_t *t);
+
+NSAPI_PUBLIC extern int
+	ACL_DbTypeRegister(const char *name, DbParseFn_t func, ACLDbType_t *t);
+NSAPI_PUBLIC extern int
+	ACL_DbTypeIsEqual(const ACLDbType_t t1, const ACLDbType_t t2);
+NSAPI_PUBLIC extern int
+	ACL_DbTypeNameIsEqual(const ACLDbType_t t, const char *name);
+NSAPI_PUBLIC extern int
+	ACL_DbTypeFind(const char *name, ACLDbType_t *t);
+NSAPI_PUBLIC extern const ACLDbType_t
+	ACL_DbTypeGetDefault();
+NSAPI_PUBLIC extern void
+	ACL_DbTypeSetDefault(ACLDbType_t t);
+NSAPI_PUBLIC extern int
+	ACL_AuthInfoGetDbType(PList_t auth_info, ACLDbType_t *t);
+NSAPI_PUBLIC extern int
+	ACL_DbTypeIsRegistered(const ACLDbType_t dbtype);
+NSAPI_PUBLIC extern DbParseFn_t
+	ACL_DbTypeParseFn(const ACLDbType_t dbtype);
+
+NSAPI_PUBLIC extern int
+	ACL_AttrGetterRegister(const char *attr, AttrGetterFn fn, ACLMethod_t m,
+	ACLDbType_t d, int position, void *arg);
+typedef ACLGetter_t *AttrGetterList; /* TEMPORARY */
+NSAPI_PUBLIC extern int
+	ACL_AttrGetterFind(PList_t auth_info, const char *attr,
+	AttrGetterList *getters);
+
+NSPR_END_EXTERN_C
+
+
+/* LAS return codes - Must all be negative numbers */
+#define	LAS_EVAL_TRUE		-1
+#define	LAS_EVAL_FALSE		-2
+#define	LAS_EVAL_DECLINE	-3
+#define	LAS_EVAL_FAIL		-4
+#define	LAS_EVAL_INVALID	-5
+#define	LAS_EVAL_NEED_MORE_INFO	-6
+
+#define ACL_ATTR_GROUP	    "group"
+#define ACL_ATTR_RAW_USER_LOGIN "user-login"
+#define ACL_ATTR_AUTH_USER	    "auth-user"
+#define ACL_ATTR_AUTH_TYPE	    "auth-type"
+#define ACL_ATTR_AUTH_DB	    "auth-db"
+#define ACL_ATTR_AUTH_PASSWORD  "auth-password"
+#define ACL_ATTR_USER	    "user"
+#define ACL_ATTR_PASSWORD	    "pw"
+#define ACL_ATTR_USERDN	    "userdn"
+#define ACL_ATTR_RAW_USER	    "raw-user"
+#define ACL_ATTR_RAW_PASSWORD   "raw-pw"
+#define ACL_ATTR_USER_ISMEMBER  "user-ismember"
+#define ACL_ATTR_DATABASE	    "database"
+#define ACL_ATTR_DBTYPE	    "dbtype"
+#define ACL_ATTR_DBNAME	    "dbname"
+#define ACL_ATTR_DATABASE_URL   "url"
+#define ACL_ATTR_METHOD	    "method"
+#define ACL_ATTR_AUTHTYPE	    "authtype"
+#define ACL_ATTR_AUTHORIZATION  "authorization"
+#define ACL_ATTR_PARSEFN	    "parsefn"
+#define ACL_ATTR_ATTRIBUTE	    "attr"
+#define ACL_ATTR_GETTERFN	    "getterfunc"
+#define ACL_ATTR_IP		    "ip"
+#define ACL_ATTR_DNS	    "dns"
+#define ACL_ATTR_MODULE	    "module"
+#define ACL_ATTR_MODULEFUNC	    "func"
+#define ACL_ATTR_GROUPS	    "groups"
+#define ACL_ATTR_IS_VALID_PASSWORD "isvalid-password"
+#define ACL_ATTR_CERT2USER	    "cert2user"
+#define ACL_ATTR_USER_CERT	    "cert"
+#define ACL_ATTR_PROMPT	    "prompt"
+#define ACL_ATTR_TIME	    "time"
+#define ACL_ATTR_USERS_GROUP    "users-group"
+
+#define ACL_DBTYPE_LDAP	    "ldap"
+
+#define METHOD_DEFAULT	    "default"
+
+typedef PRHashTable AttrGetterTable_t;
+
+typedef struct {
+    char *method;
+    char *authtype;
+    char *dbtype;
+    AttrGetterTable_t *attrGetters;
+} MethodInfo_t;
+
+NSPR_BEGIN_EXTERN_C
+
+NSAPI_PUBLIC int ACL_FindMethod (NSErr_t *errp, const char *method, MethodInfo_t **method_info_handle);
+NSAPI_PUBLIC int ACL_RegisterModule (NSErr_t *errp, const char *moduleName, AclModuleInitFunc func);
+NSAPI_PUBLIC int ACL_RegisterMethod (NSErr_t *errp, const char *method, const char *authtype, const char *dbtype, MethodInfo_t **method_info_handle);
+NSAPI_PUBLIC int ACL_RegisterAttrGetter (NSErr_t *errp, MethodInfo_t *method_info_handle, const char *attr, AttrGetterFn func);
+NSAPI_PUBLIC int ACL_UseAttrGettersFromMethod (NSErr_t *errp, const char *method, const char *usefrom);
+NSAPI_PUBLIC int ACL_GetAttribute(NSErr_t *errp, const char *attr, void **val, PList_t subject, PList_t resource, PList_t auth_info, PList_t global_auth);
+NSAPI_PUBLIC int ACL_FindAttrGetter (NSErr_t *errp, const char *method, const char *attr, AttrGetterFn *func);
+NSAPI_PUBLIC int ACL_CallAttrGetter (NSErr_t *errp, const char *method, const char *attr, PList_t subject, PList_t resource, PList_t auth_info, PList_t global_auth);
+NSAPI_PUBLIC int ACL_RegisterDbType(NSErr_t *errp, const char *dbtype, DbParseFn_t func);
+NSAPI_PUBLIC int ACL_RegisterDbName(NSErr_t *errp, ACLDbType_t dbtype, const char *dbname, const char *url, PList_t plist);
+NSAPI_PUBLIC int ACL_RegisterDbFromACL(NSErr_t *errp, const char *url, ACLDbType_t *dbtype);
+NSAPI_PUBLIC int ACL_DatabaseFind(NSErr_t *errp, const char *dbname,
+				  ACLDbType_t *dbtype, void **db);
+NSAPI_PUBLIC int ACL_SetDefaultDatabase (NSErr_t *errp, const char *dbname);
+NSAPI_PUBLIC int ACL_SetDefaultMethod (NSErr_t *errp, const char *method);
+NSAPI_PUBLIC const char *ACL_DbnameGetDefault (NSErr_t *errp);
+NSAPI_PUBLIC int ACL_LDAPDatabaseHandle (NSErr_t *errp, const char *dbname, LDAP **ld);
+NSAPI_PUBLIC int ACL_AuthInfoGetDbname (NSErr_t *errp, PList_t auth_info, char **dbname);
+NSAPI_PUBLIC int ACL_CacheFlushRegister(AclCacheFlushFunc_t func);
+
+NSPR_END_EXTERN_C
+
+struct program_groups {
+	char **groups;
+	char **programs;
+};
+  
+#endif

+ 6 - 0
include/libaccess/stubs.h

@@ -0,0 +1,6 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+typedef	void	PropList_t;

+ 99 - 0
include/libaccess/symbols.h

@@ -0,0 +1,99 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef __symbols_h
+#define __symbols_h
+
+/*
+ * Description (symbols.h)
+ *
+ *	This file describes the interface to an ACL symbol table
+ *	implementation.  The symbol table provides for storing symbols
+ *	keyed by name and type, creating a separate name space for
+ *	each symbol type.
+ */
+
+#ifdef __PRIVATE_SYMBOLS
+
+#include "plhash.h"
+#include "base/crit.h"
+
+/*
+ * Description (SymTable_t)
+ *
+ *	This type describes a symbols table.  It contains a pointer to
+ *	an NSPR hash table and a pointer to a monitor.  The monitor is
+ *	needed even for read access to the symbol table because NSPR
+ *	modifies the list for a hash bucket when a name is looked up.
+ */
+
+typedef struct SymTable_s SymTable_t;
+struct SymTable_s {
+    CRITICAL stb_crit;			/* monitor pointer */
+    PLHashTable * stb_ht;		/* hash table pointer */
+};
+
+
+/* Private functions defined in symbols.c */
+/*
+static PLHashEntry * symAllocEntry(void * pool, const void *unused);
+static void * symAllocTable(void * pool, PRSize size);
+static int symCmpName(const void * name1, const void * name2);
+static int symCmpValue(const void * value1, const void * value2);
+static PLHashNumber symHash(const void * symkey);
+static void symFreeEntry(void * pool, PLHashEntry * he, PRUintn flag);
+static void symFreeTable(void * pool, void * item);
+*/
+#endif /* __PRIVATE_SYMBOLS */
+
+/*
+ * Description (Symbol_t)
+ *
+ *	This type describes a symbol table entry.  A symbol is
+ *	identified by the combination of its name and type.  This
+ *	structure is normally embedded in a structure for a particular
+ *	symbol type, which will contain the symbol "value" information
+ *	as well.
+ */
+
+typedef struct Symbol_s Symbol_t;
+struct Symbol_s {
+    char * sym_name;			/* pointer to symbol name string */
+    int sym_type;			/* symbol type */
+    void *sym_data;			/* symbol data storage */
+};
+
+/* Define error return codes */
+#define SYMERRNOMEM	-1		/* insufficient dynamic memory */
+#define SYMERRDUPSYM	-2		/* duplicate symbol name and type */
+#define SYMERRNOSYM	-3		/* symbol name and type not found */
+
+/* Define return flags for symTableEnumerate() func() */
+#define SYMENUMSTOP	0x1		/* terminate enumeration */
+#define SYMENUMREMOVE	0x2		/* remove entry from symbol table */
+
+NSPR_BEGIN_EXTERN_C
+
+/* Public functions defined in symbols.c */
+extern int symTableAddSym(void * table, Symbol_t * newsym, void * symref);
+extern void symTableRemoveSym(void * table, Symbol_t * sym);
+extern void symTableDestroy(void * table, int flags);
+
+/* for ANSI C++ on SCO UDK, otherwise fn name is managled */
+#ifdef UnixWare
+typedef int (*ArgFn_symTableEnum)(Symbol_t * sym, void * parg);
+extern void symTableEnumerate(void * table, void * argp, ArgFn_symTableEnum);
+#else /* UnixWare */
+extern void symTableEnumerate(void * table, void * argp,
+                              int (*func)(Symbol_t * sym, void * parg));
+#endif /* UnixWare */
+
+extern int symTableFindSym(void * table, char * symname,
+			   int symtype, void **psymref);
+extern int symTableNew(void **ptable);
+
+NSPR_END_EXTERN_C
+
+#endif /* __symbols_h */

+ 13 - 0
include/libaccess/userauth.h

@@ -0,0 +1,13 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef USERAUTH_H
+#define USERAUTH_H
+
+NSPR_BEGIN_EXTERN_C
+
+
+NSPR_END_EXTERN_C
+#endif

+ 81 - 0
include/libaccess/usi.h

@@ -0,0 +1,81 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+#ifndef __usi_h
+#define __usi_h
+
+/*
+ * Description (usi.h)
+ *
+ *	This file defines the interface to an unsigned integer datatype.
+ *	Unsigned integers are used to represent object identifiers of
+ *	various sorts, including user ids and group ids.  Functions
+ *	for manipulating lists of USIs are also provided in this
+ *	interface.
+ */
+
+/* Define a type to contain an unsigned integer value */
+typedef unsigned int USI_t;
+
+/* Define a type to describe a list of USI_t values */
+typedef struct USIList_s USIList_t;
+struct USIList_s {
+    int uil_count;		/* number of active values in list */
+    int uil_size;		/* current size of list area in USI_t */
+    USI_t * uil_list;		/* pointer to array of values */
+};
+
+/* Define macro to initialize a USIList_t structure */
+#define UILINIT(uilptr) \
+	{ \
+	    (uilptr)->uil_count = 0; \
+	    (uilptr)->uil_size = 0; \
+	    (uilptr)->uil_list = 0; \
+	}
+
+/* Define a macro to replace the contents of one USIList_t with another's */
+#define UILREPLACE(dst, src) \
+	{ \
+	    if ((dst)->uil_size > 0) { \
+		FREE((dst)->uil_list); \
+	    } \
+	    (dst)->uil_count = (src)->uil_count; \
+	    (dst)->uil_size = (src)->uil_size; \
+	    (dst)->uil_list = (src)->uil_list; \
+	    (src)->uil_count = 0; \
+	    (src)->uil_size = 0; \
+	    (src)->uil_list = 0; \
+	}
+
+/* Define a variation of UILINIT() that frees any allocated space */
+#define UILFREE(uilptr) \
+	{ \
+	    if ((uilptr)->uil_size > 0) { \
+		FREE((uilptr)->uil_list); \
+	    } \
+	    (uilptr)->uil_count = 0; \
+	    (uilptr)->uil_size = 0; \
+	    (uilptr)->uil_list = 0; \
+	}
+
+/* Define a macro to extract the current number of items in a USIList_t */
+#define UILCOUNT(uilptr) ((uilptr)->uil_count)
+
+/* Define a macro to return a pointer to the array of values */
+#define UILLIST(uilptr) ((uilptr)->uil_list)
+
+NSPR_BEGIN_EXTERN_C
+
+/* Define functions in usi.c */
+extern USI_t * usiAlloc(USIList_t * uilptr, int count);
+extern int usiInsert(USIList_t * uilptr, USI_t usi);
+extern int usiPresent(USIList_t * uilptr, USI_t usi);
+extern int usiRemove(USIList_t * uilptr, USI_t usi);
+extern int uilDuplicate(USIList_t * dstptr, USIList_t * srcptr);
+extern int uilMerge(USIList_t * dstptr, USIList_t * srcptr);
+
+NSPR_END_EXTERN_C
+
+#endif /* __usi_h */

+ 104 - 0
include/libaccess/usrcache.h

@@ -0,0 +1,104 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright 2001 Sun Microsystems, Inc.
+ * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
+ * All rights reserved.
+ * END COPYRIGHT BLOCK **/
+
+#ifndef ACL_USER_CACHE_H
+#define ACL_USER_CACHE_H
+
+#ifdef NSPR20
+#include <plhash.h>
+#else
+#include <nspr/prhash.h>
+#endif
+
+#include <sys/types.h>
+#include <time.h>
+/* Removed for new ns security integration
+#include <sec.h>
+*/
+#include <key.h>
+#include <cert.h>
+#include <prclist.h>
+
+typedef struct {
+    PRCList list;		/* pointer to next & prev obj */
+    char *uid;			/* unique within a database */
+    char *userdn;		/* LDAP DN if using LDAP db */
+    char *passwd;		/* password */
+    SECItem *derCert;		/* raw certificate data */
+    char *group;		/* group recently checked for membership */
+    time_t time;		/* last time when the cache was validated */
+    PRHashTable *hashtable;	/* hash table where this obj is being used */
+} UserCacheObj;
+
+NSPR_BEGIN_EXTERN_C
+
+/* Set the number of seconds the cache is valid */
+extern int acl_usr_cache_set_timeout (const int nsec);
+
+/* Is the cache enabled? */
+extern int acl_usr_cache_enabled();
+
+/* initialize user cache */
+extern int acl_usr_cache_init ();
+
+/* Creates a new user obj entry */
+extern int acl_usr_cache_insert (const char *uid, const char *dbname,
+				 const char *dn, const char *passwd,
+				 const char *group, const SECItem *derCert,
+				 const time_t time);
+
+/* Add group to the user's cache obj. */
+extern int acl_usr_cache_set_group (const char *uid, const char *dbname,
+				    const char *group, const time_t time);
+
+/* Add userdn to the user's cache obj. */
+extern int acl_usr_cache_set_userdn (const char *uid, const char *dbname,
+				     const char *userdn, const time_t time);
+
+/* Returns LAS_EVAL_TRUE if the user's password matches -- also returns the dn */
+extern int acl_usr_cache_passwd_check (const char *uid, const char *dbname,
+				       const char *passwd,
+				       const time_t time, char **dn,
+				       pool_handle_t *pool);
+
+/* Returns LAS_EVAL_TRUE if the user is a member of the group */
+extern int acl_usr_cache_group_check (const char *uid, const char *dbname,
+				      const char *group, const time_t time);
+
+/* Returns LAS_EVAL_TRUE if the user is a member of the group */
+extern int acl_usr_cache_group_len_check (const char *uid, const char *dbname,
+					  const char *group,
+					  const int len,
+					  const time_t time);
+
+/* Returns LAS_EVAL_TRUE if the user's cache is valid and has a group */
+extern int acl_usr_cache_get_group (const char *uid, const char *dbname,
+				    const time_t time, char **group,
+				    pool_handle_t *pool);
+
+/* Returns LAS_EVAL_TRUE if the user is a member of the group */
+extern int acl_usr_cache_userdn_check (const char *uid, const char *dbname,
+				       const char *userdn, const time_t time);
+
+/* Returns LAS_EVAL_TRUE if the user's cache is valid and has userdn */
+extern int acl_usr_cache_get_userdn (const char *uid, const char *dbname,
+				     const time_t time, char **userdn,
+				     pool_handle_t *pool);
+
+/* Creates a new user obj entry for cert to user mapping */
+extern int acl_cert_cache_insert (void *cert, const char *dbname,
+				  const char *uid, const char *dn,
+				  const time_t time);
+
+/* Returns LAS_EVAL_TRUE if the user's cache is valid and returns uid */
+extern int acl_cert_cache_get_uid (void *cert, const char *dbname,
+				   const time_t time, char **uid,
+				   char **dn, pool_handle_t *pool);
+
+NSPR_END_EXTERN_C
+
+
+#endif /* ACL_USER_CACHE_H */

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