diff options
author | cvsadm <cvsadm> | 2005-01-21 00:44:34 +0000 |
---|---|---|
committer | cvsadm <cvsadm> | 2005-01-21 00:44:34 +0000 |
commit | b2093e3016027d6b5cf06b3f91f30769bfc099e2 (patch) | |
tree | cf58939393a9032182c4fbc4441164a9456e82f8 /include/base | |
download | ds-b2093e3016027d6b5cf06b3f91f30769bfc099e2.tar.gz ds-b2093e3016027d6b5cf06b3f91f30769bfc099e2.tar.xz ds-b2093e3016027d6b5cf06b3f91f30769bfc099e2.zip |
Moving NSCP Directory Server from DirectoryBranch to TRUNK, initial drop. (foxworth)ldapserver7x
Diffstat (limited to 'include/base')
-rw-r--r-- | include/base/Makefile | 40 | ||||
-rw-r--r-- | include/base/crit.h | 209 | ||||
-rw-r--r-- | include/base/dbtbase.h | 217 | ||||
-rw-r--r-- | include/base/ereport.h | 76 | ||||
-rw-r--r-- | include/base/eventhandler.h | 73 | ||||
-rw-r--r-- | include/base/eventlog.h | 34 | ||||
-rw-r--r-- | include/base/file.h | 121 | ||||
-rw-r--r-- | include/base/fsmutex.h | 94 | ||||
-rw-r--r-- | include/base/lexer.h | 89 | ||||
-rw-r--r-- | include/base/nterr.h | 21 | ||||
-rw-r--r-- | include/base/nterrors.h | 67 | ||||
-rw-r--r-- | include/base/plist.h | 61 | ||||
-rw-r--r-- | include/base/pool.h | 103 | ||||
-rw-r--r-- | include/base/rwlock.h | 54 | ||||
-rw-r--r-- | include/base/shexp.h | 114 | ||||
-rw-r--r-- | include/base/systems.h | 565 | ||||
-rw-r--r-- | include/base/systhr.h | 91 | ||||
-rw-r--r-- | include/base/util.h | 210 |
18 files changed, 2239 insertions, 0 deletions
diff --git a/include/base/Makefile b/include/base/Makefile new file mode 100644 index 00000000..9f2f6a35 --- /dev/null +++ b/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 diff --git a/include/base/crit.h b/include/base/crit.h new file mode 100644 index 00000000..1ff7e957 --- /dev/null +++ b/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 */ diff --git a/include/base/dbtbase.h b/include/base/dbtbase.h new file mode 100644 index 00000000..5f30d374 --- /dev/null +++ b/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) diff --git a/include/base/ereport.h b/include/base/ereport.h new file mode 100644 index 00000000..0c74e957 --- /dev/null +++ b/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 */ diff --git a/include/base/eventhandler.h b/include/base/eventhandler.h new file mode 100644 index 00000000..a68a231e --- /dev/null +++ b/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 */ + + + + + + + + + + + + + + diff --git a/include/base/eventlog.h b/include/base/eventlog.h new file mode 100644 index 00000000..a8dd6d27 --- /dev/null +++ b/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 diff --git a/include/base/file.h b/include/base/file.h new file mode 100644 index 00000000..6447bb83 --- /dev/null +++ b/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 */ diff --git a/include/base/fsmutex.h b/include/base/fsmutex.h new file mode 100644 index 00000000..486f0f4c --- /dev/null +++ b/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 diff --git a/include/base/lexer.h b/include/base/lexer.h new file mode 100644 index 00000000..129aa449 --- /dev/null +++ b/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 */ diff --git a/include/base/nterr.h b/include/base/nterr.h new file mode 100644 index 00000000..55d1be22 --- /dev/null +++ b/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 */ diff --git a/include/base/nterrors.h b/include/base/nterrors.h new file mode 100644 index 00000000..f9e4aa1f --- /dev/null +++ b/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 } +}; diff --git a/include/base/plist.h b/include/base/plist.h new file mode 100644 index 00000000..d9ab744f --- /dev/null +++ b/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 */ diff --git a/include/base/pool.h b/include/base/pool.h new file mode 100644 index 00000000..bca055c7 --- /dev/null +++ b/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_ */ diff --git a/include/base/rwlock.h b/include/base/rwlock.h new file mode 100644 index 00000000..2111e97b --- /dev/null +++ b/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_ */ diff --git a/include/base/shexp.h b/include/base/shexp.h new file mode 100644 index 00000000..f1a5aab6 --- /dev/null +++ b/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 */ diff --git a/include/base/systems.h b/include/base/systems.h new file mode 100644 index 00000000..ca28c453 --- /dev/null +++ b/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 */ diff --git a/include/base/systhr.h b/include/base/systhr.h new file mode 100644 index 00000000..714246df --- /dev/null +++ b/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 */ diff --git a/include/base/util.h b/include/base/util.h new file mode 100644 index 00000000..7778b924 --- /dev/null +++ b/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 */ + |