Compare commits
3 Commits
NSS_3_12_A
...
Bugzilla_P
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b52a1dc48a | ||
|
|
48b5f960fd | ||
|
|
73bf11394f |
@@ -1,53 +0,0 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = dbm
|
||||
DIRS = include src
|
||||
|
||||
ifdef ENABLE_TESTS
|
||||
DIRS += tests
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = dbm
|
||||
|
||||
EXPORTS = \
|
||||
nsres.h \
|
||||
cdefs.h \
|
||||
mcom_db.h \
|
||||
ncompat.h \
|
||||
winfile.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
PRIVATE_EXPORTS = \
|
||||
hsearch.h \
|
||||
page.h \
|
||||
extern.h \
|
||||
ndbm.h \
|
||||
queue.h \
|
||||
hash.h \
|
||||
mpool.h \
|
||||
search.h \
|
||||
$(NULL)
|
||||
|
||||
PRIVATE_EXPORTS := $(addprefix $(srcdir)/, $(PRIVATE_EXPORTS))
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Makefile to build the cert library
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
!if "$(MOZ_BITS)" == "16"
|
||||
!ifndef MOZ_DEBUG
|
||||
OPTIMIZER=-Os -UDEBUG -DNDEBUG
|
||||
!endif
|
||||
!endif
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Specify the depth of the current directory relative to the
|
||||
#// root of NS
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
DEPTH= ..\..
|
||||
|
||||
!ifndef MAKE_OBJ_TYPE
|
||||
MAKE_OBJ_TYPE=EXE
|
||||
!endif
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// install headers
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
EXPORTS=nsres.h cdefs.h mcom_db.h ncompat.h winfile.h
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Include the common makefile rules
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
CFLAGS = $(CFLAGS) -DMOZILLA_CLIENT
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* Copyright (c) 1991, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Berkeley Software Design, Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. ***REMOVED*** - see
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)cdefs.h 8.7 (Berkeley) 1/21/94
|
||||
*/
|
||||
|
||||
#ifndef _CDEFS_H_
|
||||
#define _CDEFS_H_
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#define __BEGIN_DECLS extern "C" {
|
||||
#define __END_DECLS }
|
||||
#else
|
||||
#define __BEGIN_DECLS
|
||||
#define __END_DECLS
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The __CONCAT macro is used to concatenate parts of symbol names, e.g.
|
||||
* with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
|
||||
* The __CONCAT macro is a bit tricky -- make sure you don't put spaces
|
||||
* in between its arguments. __CONCAT can also concatenate double-quoted
|
||||
* strings produced by the __STRING macro, but this only works with ANSI C.
|
||||
*/
|
||||
#if defined(__STDC__) || defined(__cplusplus) || defined(_WINDOWS) || defined(XP_OS2)
|
||||
#define __P(protos) protos /* full-blown ANSI C */
|
||||
#define __CONCAT(x,y) x ## y
|
||||
#define __STRING(x) #x
|
||||
|
||||
/* On HP-UX 11.00, <sys/stdsyms.h> defines __const. */
|
||||
#ifndef __const
|
||||
#define __const const /* define reserved names to standard */
|
||||
#endif /* __const */
|
||||
#define __signed signed
|
||||
#define __volatile volatile
|
||||
#ifndef _WINDOWS
|
||||
#if defined(__cplusplus)
|
||||
#define __inline inline /* convert to C++ keyword */
|
||||
#else
|
||||
#if !defined(__GNUC__) && !defined(__MWERKS__)
|
||||
#define __inline /* delete GCC keyword */
|
||||
#endif /* !__GNUC__ */
|
||||
#endif /* !__cplusplus */
|
||||
#endif /* !_WINDOWS */
|
||||
|
||||
#else /* !(__STDC__ || __cplusplus) */
|
||||
#define __P(protos) () /* traditional C preprocessor */
|
||||
#define __CONCAT(x,y) x/**/y
|
||||
#define __STRING(x) "x"
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define __const /* delete pseudo-ANSI C keywords */
|
||||
#define __inline
|
||||
#define __signed
|
||||
#define __volatile
|
||||
/*
|
||||
* In non-ANSI C environments, new programs will want ANSI-only C keywords
|
||||
* deleted from the program and old programs will want them left alone.
|
||||
* When using a compiler other than gcc, programs using the ANSI C keywords
|
||||
* const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
|
||||
* When using "gcc -traditional", we assume that this is the intent; if
|
||||
* __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
|
||||
*/
|
||||
#ifndef NO_ANSI_KEYWORDS
|
||||
#define const /* delete ANSI C keywords */
|
||||
#define inline
|
||||
#define signed
|
||||
#define volatile
|
||||
#endif
|
||||
#endif /* !__GNUC__ */
|
||||
#endif /* !(__STDC__ || __cplusplus) */
|
||||
|
||||
/*
|
||||
* GCC1 and some versions of GCC2 declare dead (non-returning) and
|
||||
* pure (no side effects) functions using "volatile" and "const";
|
||||
* unfortunately, these then cause warnings under "-ansi -pedantic".
|
||||
* GCC2 uses a new, peculiar __attribute__((attrs)) style. All of
|
||||
* these work for GNU C++ (modulo a slight glitch in the C++ grammar
|
||||
* in the distribution version of 2.5.5).
|
||||
*/
|
||||
#if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC_MINOR__ < 5
|
||||
#define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */
|
||||
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
|
||||
#define __dead __volatile
|
||||
#define __pure __const
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Delete pseudo-keywords wherever they are not available or needed. */
|
||||
#ifndef __dead
|
||||
#define __dead
|
||||
#define __pure
|
||||
#endif
|
||||
|
||||
#endif /* !_CDEFS_H_ */
|
||||
@@ -1,63 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. ***REMOVED*** - see
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)extern.h 8.4 (Berkeley) 6/16/94
|
||||
*/
|
||||
|
||||
BUFHEAD *__add_ovflpage (HTAB *, BUFHEAD *);
|
||||
int __addel (HTAB *, BUFHEAD *, const DBT *, const DBT *);
|
||||
int __big_delete (HTAB *, BUFHEAD *);
|
||||
int __big_insert (HTAB *, BUFHEAD *, const DBT *, const DBT *);
|
||||
int __big_keydata (HTAB *, BUFHEAD *, DBT *, DBT *, int);
|
||||
int __big_return (HTAB *, BUFHEAD *, int, DBT *, int);
|
||||
int __big_split (HTAB *, BUFHEAD *, BUFHEAD *, BUFHEAD *,
|
||||
uint32, uint32, SPLIT_RETURN *);
|
||||
int __buf_free (HTAB *, int, int);
|
||||
void __buf_init (HTAB *, int);
|
||||
uint32 __call_hash (HTAB *, char *, size_t);
|
||||
int __delpair (HTAB *, BUFHEAD *, int);
|
||||
int __expand_table (HTAB *);
|
||||
int __find_bigpair (HTAB *, BUFHEAD *, int, char *, int);
|
||||
uint16 __find_last_page (HTAB *, BUFHEAD **);
|
||||
void __free_ovflpage (HTAB *, BUFHEAD *);
|
||||
BUFHEAD *__get_buf (HTAB *, uint32, BUFHEAD *, int);
|
||||
int __get_page (HTAB *, char *, uint32, int, int, int);
|
||||
int __ibitmap (HTAB *, int, int, int);
|
||||
uint32 __log2 (uint32);
|
||||
int __put_page (HTAB *, char *, uint32, int, int);
|
||||
void __reclaim_buf (HTAB *, BUFHEAD *);
|
||||
int __split_page (HTAB *, uint32, uint32);
|
||||
|
||||
/* Default hash routine. */
|
||||
extern uint32 (*__default_hash) (const void *, size_t);
|
||||
|
||||
#ifdef HASH_STATISTICS
|
||||
extern int hash_accesses, hash_collisions, hash_expansions, hash_overflows;
|
||||
#endif
|
||||
@@ -1,335 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Margo Seltzer.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. ***REMOVED*** - see
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)hash.h 8.3 (Berkeley) 5/31/94
|
||||
*/
|
||||
|
||||
/* Operations */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "mcom_db.h"
|
||||
typedef enum {
|
||||
HASH_GET, HASH_PUT, HASH_PUTNEW, HASH_DELETE, HASH_FIRST, HASH_NEXT
|
||||
} ACTION;
|
||||
|
||||
/* Buffer Management structures */
|
||||
typedef struct _bufhead BUFHEAD;
|
||||
|
||||
struct _bufhead {
|
||||
BUFHEAD *prev; /* LRU links */
|
||||
BUFHEAD *next; /* LRU links */
|
||||
BUFHEAD *ovfl; /* Overflow page buffer header */
|
||||
uint32 addr; /* Address of this page */
|
||||
char *page; /* Actual page data */
|
||||
char is_disk;
|
||||
char flags;
|
||||
#define BUF_MOD 0x0001
|
||||
#define BUF_DISK 0x0002
|
||||
#define BUF_BUCKET 0x0004
|
||||
#define BUF_PIN 0x0008
|
||||
};
|
||||
|
||||
#define IS_BUCKET(X) ((X) & BUF_BUCKET)
|
||||
|
||||
typedef BUFHEAD **SEGMENT;
|
||||
|
||||
typedef int DBFILE_PTR;
|
||||
#define NO_FILE -1
|
||||
#ifdef macintosh
|
||||
#define DBFILE_OPEN(path, flag,mode) open((path), flag)
|
||||
#define EXISTS(path)
|
||||
#else
|
||||
#define DBFILE_OPEN(path, flag,mode) open((path), (flag), (mode))
|
||||
#endif
|
||||
/* Hash Table Information */
|
||||
typedef struct hashhdr { /* Disk resident portion */
|
||||
int32 magic; /* Magic NO for hash tables */
|
||||
int32 version; /* Version ID */
|
||||
uint32 lorder; /* Byte Order */
|
||||
int32 bsize; /* Bucket/Page Size */
|
||||
int32 bshift; /* Bucket shift */
|
||||
int32 dsize; /* Directory Size */
|
||||
int32 ssize; /* Segment Size */
|
||||
int32 sshift; /* Segment shift */
|
||||
int32 ovfl_point; /* Where overflow pages are being
|
||||
* allocated */
|
||||
int32 last_freed; /* Last overflow page freed */
|
||||
int32 max_bucket; /* ID of Maximum bucket in use */
|
||||
int32 high_mask; /* Mask to modulo into entire table */
|
||||
int32 low_mask; /* Mask to modulo into lower half of
|
||||
* table */
|
||||
int32 ffactor; /* Fill factor */
|
||||
int32 nkeys; /* Number of keys in hash table */
|
||||
int32 hdrpages; /* Size of table header */
|
||||
uint32 h_charkey; /* value of hash(CHARKEY) */
|
||||
#define NCACHED 32 /* number of bit maps and spare
|
||||
* points */
|
||||
int32 spares[NCACHED];/* spare pages for overflow */
|
||||
uint16 bitmaps[NCACHED]; /* address of overflow page
|
||||
* bitmaps */
|
||||
} HASHHDR;
|
||||
|
||||
typedef struct htab { /* Memory resident data structure */
|
||||
HASHHDR hdr; /* Header */
|
||||
int nsegs; /* Number of allocated segments */
|
||||
int exsegs; /* Number of extra allocated
|
||||
* segments */
|
||||
uint32 /* Hash function */
|
||||
(*hash)(const void *, size_t);
|
||||
int flags; /* Flag values */
|
||||
DBFILE_PTR fp; /* File pointer */
|
||||
char *filename;
|
||||
char *tmp_buf; /* Temporary Buffer for BIG data */
|
||||
char *tmp_key; /* Temporary Buffer for BIG keys */
|
||||
BUFHEAD *cpage; /* Current page */
|
||||
int cbucket; /* Current bucket */
|
||||
int cndx; /* Index of next item on cpage */
|
||||
int dbmerrno; /* Error Number -- for DBM
|
||||
* compatability */
|
||||
int new_file; /* Indicates if fd is backing store
|
||||
* or no */
|
||||
int save_file; /* Indicates whether we need to flush
|
||||
* file at
|
||||
* exit */
|
||||
uint32 *mapp[NCACHED]; /* Pointers to page maps */
|
||||
int nmaps; /* Initial number of bitmaps */
|
||||
int nbufs; /* Number of buffers left to
|
||||
* allocate */
|
||||
BUFHEAD bufhead; /* Header of buffer lru list */
|
||||
SEGMENT *dir; /* Hash Bucket directory */
|
||||
off_t file_size; /* in bytes */
|
||||
char is_temp; /* unlink file on close */
|
||||
char updateEOF; /* force EOF update on flush */
|
||||
} HTAB;
|
||||
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
#define DATABASE_CORRUPTED_ERROR -999 /* big ugly abort, delete database */
|
||||
#define OLD_MAX_BSIZE 65536 /* 2^16 */
|
||||
#define MAX_BSIZE 32l*1024l /* 2^15 */
|
||||
#define MIN_BUFFERS 6
|
||||
#define MINHDRSIZE 512
|
||||
#define DEF_BUFSIZE 65536l /* 64 K */
|
||||
#define DEF_BUCKET_SIZE 4096
|
||||
#define DEF_BUCKET_SHIFT 12 /* log2(BUCKET) */
|
||||
#define DEF_SEGSIZE 256
|
||||
#define DEF_SEGSIZE_SHIFT 8 /* log2(SEGSIZE) */
|
||||
#define DEF_DIRSIZE 256
|
||||
#define DEF_FFACTOR 65536l
|
||||
#define MIN_FFACTOR 4
|
||||
#define SPLTMAX 8
|
||||
#define CHARKEY "%$sniglet^&"
|
||||
#define NUMKEY 1038583l
|
||||
#define BYTE_SHIFT 3
|
||||
#define INT_TO_BYTE 2
|
||||
#define INT_BYTE_SHIFT 5
|
||||
#define ALL_SET ((uint32)0xFFFFFFFF)
|
||||
#define ALL_CLEAR 0
|
||||
|
||||
#define PTROF(X) ((ptrdiff_t)(X) == BUF_DISK ? 0 : (X))
|
||||
#define ISDISK(X) ((X) ? ((ptrdiff_t)(X) == BUF_DISK ? BUF_DISK \
|
||||
: (X)->is_disk) : 0)
|
||||
|
||||
#define BITS_PER_MAP 32
|
||||
|
||||
/* Given the address of the beginning of a big map, clear/set the nth bit */
|
||||
#define CLRBIT(A, N) ((A)[(N)/BITS_PER_MAP] &= ~(1<<((N)%BITS_PER_MAP)))
|
||||
#define SETBIT(A, N) ((A)[(N)/BITS_PER_MAP] |= (1<<((N)%BITS_PER_MAP)))
|
||||
#define ISSET(A, N) ((A)[(N)/BITS_PER_MAP] & (1<<((N)%BITS_PER_MAP)))
|
||||
|
||||
/* Overflow management */
|
||||
/*
|
||||
* Overflow page numbers are allocated per split point. At each doubling of
|
||||
* the table, we can allocate extra pages. So, an overflow page number has
|
||||
* the top 5 bits indicate which split point and the lower 11 bits indicate
|
||||
* which page at that split point is indicated (pages within split points are
|
||||
* numberered starting with 1).
|
||||
*/
|
||||
|
||||
#define SPLITSHIFT 11
|
||||
#define SPLITMASK 0x7FF
|
||||
#define SPLITNUM(N) (((uint32)(N)) >> SPLITSHIFT)
|
||||
#define OPAGENUM(N) ((N) & SPLITMASK)
|
||||
#define OADDR_OF(S,O) ((uint32)((uint32)(S) << SPLITSHIFT) + (O))
|
||||
|
||||
#define BUCKET_TO_PAGE(B) \
|
||||
(B) + hashp->HDRPAGES + ((B) ? hashp->SPARES[__log2((uint32)((B)+1))-1] : 0)
|
||||
#define OADDR_TO_PAGE(B) \
|
||||
BUCKET_TO_PAGE ( (1 << SPLITNUM((B))) -1 ) + OPAGENUM((B));
|
||||
|
||||
/*
|
||||
* page.h contains a detailed description of the page format.
|
||||
*
|
||||
* Normally, keys and data are accessed from offset tables in the top of
|
||||
* each page which point to the beginning of the key and data. There are
|
||||
* four flag values which may be stored in these offset tables which indicate
|
||||
* the following:
|
||||
*
|
||||
*
|
||||
* OVFLPAGE Rather than a key data pair, this pair contains
|
||||
* the address of an overflow page. The format of
|
||||
* the pair is:
|
||||
* OVERFLOW_PAGE_NUMBER OVFLPAGE
|
||||
*
|
||||
* PARTIAL_KEY This must be the first key/data pair on a page
|
||||
* and implies that page contains only a partial key.
|
||||
* That is, the key is too big to fit on a single page
|
||||
* so it starts on this page and continues on the next.
|
||||
* The format of the page is:
|
||||
* KEY_OFF PARTIAL_KEY OVFL_PAGENO OVFLPAGE
|
||||
*
|
||||
* KEY_OFF -- offset of the beginning of the key
|
||||
* PARTIAL_KEY -- 1
|
||||
* OVFL_PAGENO - page number of the next overflow page
|
||||
* OVFLPAGE -- 0
|
||||
*
|
||||
* FULL_KEY This must be the first key/data pair on the page. It
|
||||
* is used in two cases.
|
||||
*
|
||||
* Case 1:
|
||||
* There is a complete key on the page but no data
|
||||
* (because it wouldn't fit). The next page contains
|
||||
* the data.
|
||||
*
|
||||
* Page format it:
|
||||
* KEY_OFF FULL_KEY OVFL_PAGENO OVFL_PAGE
|
||||
*
|
||||
* KEY_OFF -- offset of the beginning of the key
|
||||
* FULL_KEY -- 2
|
||||
* OVFL_PAGENO - page number of the next overflow page
|
||||
* OVFLPAGE -- 0
|
||||
*
|
||||
* Case 2:
|
||||
* This page contains no key, but part of a large
|
||||
* data field, which is continued on the next page.
|
||||
*
|
||||
* Page format it:
|
||||
* DATA_OFF FULL_KEY OVFL_PAGENO OVFL_PAGE
|
||||
*
|
||||
* KEY_OFF -- offset of the beginning of the data on
|
||||
* this page
|
||||
* FULL_KEY -- 2
|
||||
* OVFL_PAGENO - page number of the next overflow page
|
||||
* OVFLPAGE -- 0
|
||||
*
|
||||
* FULL_KEY_DATA
|
||||
* This must be the first key/data pair on the page.
|
||||
* There are two cases:
|
||||
*
|
||||
* Case 1:
|
||||
* This page contains a key and the beginning of the
|
||||
* data field, but the data field is continued on the
|
||||
* next page.
|
||||
*
|
||||
* Page format is:
|
||||
* KEY_OFF FULL_KEY_DATA OVFL_PAGENO DATA_OFF
|
||||
*
|
||||
* KEY_OFF -- offset of the beginning of the key
|
||||
* FULL_KEY_DATA -- 3
|
||||
* OVFL_PAGENO - page number of the next overflow page
|
||||
* DATA_OFF -- offset of the beginning of the data
|
||||
*
|
||||
* Case 2:
|
||||
* This page contains the last page of a big data pair.
|
||||
* There is no key, only the tail end of the data
|
||||
* on this page.
|
||||
*
|
||||
* Page format is:
|
||||
* DATA_OFF FULL_KEY_DATA <OVFL_PAGENO> <OVFLPAGE>
|
||||
*
|
||||
* DATA_OFF -- offset of the beginning of the data on
|
||||
* this page
|
||||
* FULL_KEY_DATA -- 3
|
||||
* OVFL_PAGENO - page number of the next overflow page
|
||||
* OVFLPAGE -- 0
|
||||
*
|
||||
* OVFL_PAGENO and OVFLPAGE are optional (they are
|
||||
* not present if there is no next page).
|
||||
*/
|
||||
|
||||
#define OVFLPAGE 0
|
||||
#define PARTIAL_KEY 1
|
||||
#define FULL_KEY 2
|
||||
#define FULL_KEY_DATA 3
|
||||
#define REAL_KEY 4
|
||||
|
||||
/* Short hands for accessing structure */
|
||||
#undef BSIZE
|
||||
#define BSIZE hdr.bsize
|
||||
#undef BSHIFT
|
||||
#define BSHIFT hdr.bshift
|
||||
#define DSIZE hdr.dsize
|
||||
#define SGSIZE hdr.ssize
|
||||
#define SSHIFT hdr.sshift
|
||||
#define LORDER hdr.lorder
|
||||
#define OVFL_POINT hdr.ovfl_point
|
||||
#define LAST_FREED hdr.last_freed
|
||||
#define MAX_BUCKET hdr.max_bucket
|
||||
#define FFACTOR hdr.ffactor
|
||||
#define HIGH_MASK hdr.high_mask
|
||||
#define LOW_MASK hdr.low_mask
|
||||
#define NKEYS hdr.nkeys
|
||||
#define HDRPAGES hdr.hdrpages
|
||||
#define SPARES hdr.spares
|
||||
#define BITMAPS hdr.bitmaps
|
||||
#define VERSION hdr.version
|
||||
#define MAGIC hdr.magic
|
||||
#define NEXT_FREE hdr.next_free
|
||||
#define H_CHARKEY hdr.h_charkey
|
||||
|
||||
extern uint32 (*__default_hash) (const void *, size_t);
|
||||
void __buf_init(HTAB *hashp, int32 nbytes);
|
||||
int __big_delete(HTAB *hashp, BUFHEAD *bufp);
|
||||
BUFHEAD * __get_buf(HTAB *hashp, uint32 addr, BUFHEAD *prev_bp, int newpage);
|
||||
uint32 __call_hash(HTAB *hashp, char *k, size_t len);
|
||||
#include "page.h"
|
||||
extern int __big_split(HTAB *hashp, BUFHEAD *op,BUFHEAD *np,
|
||||
BUFHEAD *big_keyp,uint32 addr,uint32 obucket, SPLIT_RETURN *ret);
|
||||
void __free_ovflpage(HTAB *hashp, BUFHEAD *obufp);
|
||||
BUFHEAD * __add_ovflpage(HTAB *hashp, BUFHEAD *bufp);
|
||||
int __big_insert(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val);
|
||||
int __expand_table(HTAB *hashp);
|
||||
uint32 __log2(uint32 num);
|
||||
void __reclaim_buf(HTAB *hashp, BUFHEAD *bp);
|
||||
int __get_page(HTAB *hashp, char * p, uint32 bucket, int is_bucket, int is_disk, int is_bitmap);
|
||||
int __put_page(HTAB *hashp, char *p, uint32 bucket, int is_bucket, int is_bitmap);
|
||||
int __ibitmap(HTAB *hashp, int pnum, int nbits, int ndx);
|
||||
int __buf_free(HTAB *hashp, int do_free, int to_disk);
|
||||
int __find_bigpair(HTAB *hashp, BUFHEAD *bufp, int ndx, char *key, int size);
|
||||
uint16 __find_last_page(HTAB *hashp, BUFHEAD **bpp);
|
||||
int __addel(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT * val);
|
||||
int __big_return(HTAB *hashp, BUFHEAD *bufp, int ndx, DBT *val, int set_current);
|
||||
int __delpair(HTAB *hashp, BUFHEAD *bufp, int ndx);
|
||||
int __big_keydata(HTAB *hashp, BUFHEAD *bufp, DBT *key, DBT *val, int set);
|
||||
int __split_page(HTAB *hashp, uint32 obucket, uint32 nbucket);
|
||||
@@ -1,49 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Margo Seltzer.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. ***REMOVED*** - see
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)search.h 8.1 (Berkeley) 6/4/93
|
||||
*/
|
||||
|
||||
/* Backward compatibility to hsearch interface. */
|
||||
typedef struct entry {
|
||||
char *key;
|
||||
char *data;
|
||||
} ENTRY;
|
||||
|
||||
typedef enum {
|
||||
FIND, ENTER
|
||||
} ACTION;
|
||||
|
||||
int hcreate (unsigned int);
|
||||
void hdestroy (void);
|
||||
ENTRY *hsearch (ENTRY, ACTION);
|
||||
@@ -1,424 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. ***REMOVED*** - see
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)db.h 8.7 (Berkeley) 6/16/94
|
||||
*/
|
||||
|
||||
#ifndef _DB_H_
|
||||
#define _DB_H_
|
||||
|
||||
|
||||
#ifdef WINCE
|
||||
#define off_t long
|
||||
#endif
|
||||
|
||||
#ifndef macintosh
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#include "prtypes.h"
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef __DBINTERFACE_PRIVATE
|
||||
|
||||
#ifdef HAVE_SYS_CDEFS_H
|
||||
#include <sys/cdefs.h>
|
||||
#else
|
||||
#include "cdefs.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_BYTEORDER_H
|
||||
#include <sys/byteorder.h>
|
||||
#endif
|
||||
|
||||
#if defined(__linux) || defined(__BEOS__)
|
||||
#include <endian.h>
|
||||
#ifndef BYTE_ORDER
|
||||
#define BYTE_ORDER __BYTE_ORDER
|
||||
#define BIG_ENDIAN __BIG_ENDIAN
|
||||
#define LITTLE_ENDIAN __LITTLE_ENDIAN
|
||||
#endif
|
||||
#endif /* __linux */
|
||||
|
||||
#ifdef __sgi
|
||||
#define BYTE_ORDER BIG_ENDIAN
|
||||
#define BIG_ENDIAN 4321
|
||||
#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax, all NT risc */
|
||||
#endif
|
||||
|
||||
#ifdef __sun
|
||||
#define BIG_ENDIAN 4321
|
||||
#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax, all NT risc */
|
||||
|
||||
#ifndef __SVR4
|
||||
/* compat.h is only in 4.1.3 machines. - dp */
|
||||
#include <compat.h>
|
||||
#endif
|
||||
|
||||
/* XXX - dp
|
||||
* Need to find a general way of defining endian-ness in SunOS 5.3
|
||||
* SunOS 5.4 defines _BIG_ENDIAN and _LITTLE_ENDIAN
|
||||
* SunOS 5.3 does nothing like this.
|
||||
*/
|
||||
|
||||
#ifndef BYTE_ORDER
|
||||
|
||||
#if defined(_BIG_ENDIAN)
|
||||
#define BYTE_ORDER BIG_ENDIAN
|
||||
#elif defined(_LITTLE_ENDIAN)
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
#elif !defined(__SVR4)
|
||||
/* 4.1.3 is always BIG_ENDIAN as it was released only on sparc platforms. */
|
||||
#define BYTE_ORDER BIG_ENDIAN
|
||||
#elif !defined(vax) && !defined(ntohl) && !defined(lint) && !defined(i386)
|
||||
/* 5.3 big endian. Copied this above line from sys/byteorder.h */
|
||||
/* Now we are in a 5.3 SunOS rather non 5.4 or above SunOS */
|
||||
#define BYTE_ORDER BIG_ENDIAN
|
||||
#else
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
#endif /* !BYTE_ORDER */
|
||||
#endif /* __sun */
|
||||
|
||||
#if defined(__hpux) || defined(__hppa)
|
||||
#define BYTE_ORDER BIG_ENDIAN
|
||||
#define BIG_ENDIAN 4321
|
||||
#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax, all NT risc */
|
||||
#endif
|
||||
|
||||
#if defined(AIXV3) || defined(AIX)
|
||||
/* BYTE_ORDER, LITTLE_ENDIAN, BIG_ENDIAN are all defined here */
|
||||
#include <sys/machine.h>
|
||||
#endif
|
||||
|
||||
/* Digital Unix */
|
||||
#ifdef __osf__
|
||||
#include <machine/endian.h>
|
||||
#endif
|
||||
|
||||
#ifdef __alpha
|
||||
#ifndef WIN32
|
||||
#else
|
||||
/* Alpha NT */
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
#define BIG_ENDIAN 4321
|
||||
#define LITTLE_ENDIAN 1234
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef NCR
|
||||
#include <sys/endian.h>
|
||||
#endif
|
||||
|
||||
#ifdef __QNX__
|
||||
#ifdef __QNXNTO__
|
||||
#include <sys/param.h>
|
||||
#else
|
||||
#define LITTLE_ENDIAN 1234
|
||||
#define BIG_ENDIAN 4321
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SNI
|
||||
/* #include <sys/hetero.h> */
|
||||
#define BYTE_ORDER BIG_ENDIAN
|
||||
#define BIG_ENDIAN 4321
|
||||
#define LITTLE_ENDIAN 1234
|
||||
#endif
|
||||
|
||||
#if defined(_WINDOWS) || defined(XP_OS2_VACPP)
|
||||
#ifdef BYTE_ORDER
|
||||
#undef BYTE_ORDER
|
||||
#endif
|
||||
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax, all NT risc */
|
||||
#define BIG_ENDIAN 4321
|
||||
#endif
|
||||
|
||||
#ifdef macintosh
|
||||
#define BIG_ENDIAN 4321
|
||||
#define LITTLE_ENDIAN 1234
|
||||
#define BYTE_ORDER BIG_ENDIAN
|
||||
#endif
|
||||
|
||||
#endif /* __DBINTERFACE_PRIVATE */
|
||||
|
||||
#ifdef SCO
|
||||
#define MAXPATHLEN 1024
|
||||
#endif
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#if defined(_WINDOWS) || defined(XP_OS2)
|
||||
#include <stdio.h>
|
||||
#include <io.h>
|
||||
|
||||
#ifndef XP_OS2
|
||||
#define MAXPATHLEN 1024
|
||||
#endif
|
||||
|
||||
#ifdef XP_OS2_VACPP
|
||||
#include <os2.h>
|
||||
#define MAXPATHLEN CCHMAXPATH
|
||||
#define EPERM EINVAL
|
||||
#define ENOTDIR EBADPOS
|
||||
#define S_ISDIR(s) ((s) & S_IFDIR)
|
||||
#endif
|
||||
|
||||
#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */
|
||||
|
||||
#ifndef STDERR_FILENO
|
||||
#define STDIN_FILENO 0 /* ANSI C #defines */
|
||||
#define STDOUT_FILENO 1
|
||||
#define STDERR_FILENO 2
|
||||
#endif
|
||||
|
||||
#ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */
|
||||
#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef macintosh
|
||||
#include <stdio.h>
|
||||
#include "xp_mcom.h"
|
||||
#define O_ACCMODE 3 /* Mask for file access modes */
|
||||
#define EFTYPE 2000
|
||||
PR_BEGIN_EXTERN_C
|
||||
int mkstemp(const char *path);
|
||||
PR_END_EXTERN_C
|
||||
#endif /* MACINTOSH */
|
||||
|
||||
#if !defined(_WINDOWS) && !defined(macintosh)
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
/* define EFTYPE since most don't */
|
||||
#ifndef EFTYPE
|
||||
#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */
|
||||
#endif
|
||||
|
||||
#define RET_ERROR -1 /* Return values. */
|
||||
#define RET_SUCCESS 0
|
||||
#define RET_SPECIAL 1
|
||||
|
||||
#define MAX_PAGE_NUMBER 0xffffffff /* >= # of pages in a file */
|
||||
|
||||
#ifndef __sgi
|
||||
typedef uint32 pgno_t;
|
||||
#endif
|
||||
|
||||
#define MAX_PAGE_OFFSET 65535 /* >= # of bytes in a page */
|
||||
typedef uint16 indx_t;
|
||||
#define MAX_REC_NUMBER 0xffffffff /* >= # of records in a tree */
|
||||
typedef uint32 recno_t;
|
||||
|
||||
/* Key/data structure -- a Data-Base Thang. */
|
||||
typedef struct {
|
||||
void *data; /* data */
|
||||
size_t size; /* data length */
|
||||
} DBT;
|
||||
|
||||
/* Routine flags. */
|
||||
#define R_CURSOR 1 /* del, put, seq */
|
||||
#define __R_UNUSED 2 /* UNUSED */
|
||||
#define R_FIRST 3 /* seq */
|
||||
#define R_IAFTER 4 /* put (RECNO) */
|
||||
#define R_IBEFORE 5 /* put (RECNO) */
|
||||
#define R_LAST 6 /* seq (BTREE, RECNO) */
|
||||
#define R_NEXT 7 /* seq */
|
||||
#define R_NOOVERWRITE 8 /* put */
|
||||
#define R_PREV 9 /* seq (BTREE, RECNO) */
|
||||
#define R_SETCURSOR 10 /* put (RECNO) */
|
||||
#define R_RECNOSYNC 11 /* sync (RECNO) */
|
||||
|
||||
typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE;
|
||||
|
||||
typedef enum { LockOutDatabase, UnlockDatabase } DBLockFlagEnum;
|
||||
|
||||
/*
|
||||
* !!!
|
||||
* The following flags are included in the dbopen(3) call as part of the
|
||||
* open(2) flags. In order to avoid conflicts with the open flags, start
|
||||
* at the top of the 16 or 32-bit number space and work our way down. If
|
||||
* the open flags were significantly expanded in the future, it could be
|
||||
* a problem. Wish I'd left another flags word in the dbopen call.
|
||||
*
|
||||
* !!!
|
||||
* None of this stuff is implemented yet. The only reason that it's here
|
||||
* is so that the access methods can skip copying the key/data pair when
|
||||
* the DB_LOCK flag isn't set.
|
||||
*/
|
||||
#if UINT_MAX > 65535
|
||||
#define DB_LOCK 0x20000000 /* Do locking. */
|
||||
#define DB_SHMEM 0x40000000 /* Use shared memory. */
|
||||
#define DB_TXN 0x80000000 /* Do transactions. */
|
||||
#else
|
||||
#define DB_LOCK 0x2000 /* Do locking. */
|
||||
#define DB_SHMEM 0x4000 /* Use shared memory. */
|
||||
#define DB_TXN 0x8000 /* Do transactions. */
|
||||
#endif
|
||||
|
||||
/* Access method description structure. */
|
||||
typedef struct __db {
|
||||
DBTYPE type; /* Underlying db type. */
|
||||
int (*close) (struct __db *);
|
||||
int (*del) (const struct __db *, const DBT *, uint);
|
||||
int (*get) (const struct __db *, const DBT *, DBT *, uint);
|
||||
int (*put) (const struct __db *, DBT *, const DBT *, uint);
|
||||
int (*seq) (const struct __db *, DBT *, DBT *, uint);
|
||||
int (*sync) (const struct __db *, uint);
|
||||
void *internal; /* Access method private. */
|
||||
int (*fd) (const struct __db *);
|
||||
} DB;
|
||||
|
||||
#define BTREEMAGIC 0x053162
|
||||
#define BTREEVERSION 3
|
||||
|
||||
/* Structure used to pass parameters to the btree routines. */
|
||||
typedef struct {
|
||||
#define R_DUP 0x01 /* duplicate keys */
|
||||
uint32 flags;
|
||||
uint cachesize; /* bytes to cache */
|
||||
int maxkeypage; /* maximum keys per page */
|
||||
int minkeypage; /* minimum keys per page */
|
||||
uint psize; /* page size */
|
||||
int (*compare) /* comparison function */
|
||||
(const DBT *, const DBT *);
|
||||
size_t (*prefix) /* prefix function */
|
||||
(const DBT *, const DBT *);
|
||||
int lorder; /* byte order */
|
||||
} BTREEINFO;
|
||||
|
||||
#define HASHMAGIC 0x061561
|
||||
#define HASHVERSION 2
|
||||
|
||||
/* Structure used to pass parameters to the hashing routines. */
|
||||
typedef struct {
|
||||
uint bsize; /* bucket size */
|
||||
uint ffactor; /* fill factor */
|
||||
uint nelem; /* number of elements */
|
||||
uint cachesize; /* bytes to cache */
|
||||
uint32 /* hash function */
|
||||
(*hash) (const void *, size_t);
|
||||
int lorder; /* byte order */
|
||||
} HASHINFO;
|
||||
|
||||
/* Structure used to pass parameters to the record routines. */
|
||||
typedef struct {
|
||||
#define R_FIXEDLEN 0x01 /* fixed-length records */
|
||||
#define R_NOKEY 0x02 /* key not required */
|
||||
#define R_SNAPSHOT 0x04 /* snapshot the input */
|
||||
uint32 flags;
|
||||
uint cachesize; /* bytes to cache */
|
||||
uint psize; /* page size */
|
||||
int lorder; /* byte order */
|
||||
size_t reclen; /* record length (fixed-length records) */
|
||||
uint8 bval; /* delimiting byte (variable-length records */
|
||||
char *bfname; /* btree file name */
|
||||
} RECNOINFO;
|
||||
|
||||
#ifdef __DBINTERFACE_PRIVATE
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
#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]; \
|
||||
}
|
||||
#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]; \
|
||||
}
|
||||
#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]; \
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
#define M_16_SWAP(a) { \
|
||||
uint16 _tmp = a; \
|
||||
((char *)&a)[0] = ((char *)&_tmp)[1]; \
|
||||
((char *)&a)[1] = ((char *)&_tmp)[0]; \
|
||||
}
|
||||
#define P_16_SWAP(a) { \
|
||||
uint16 _tmp = *(uint16 *)a; \
|
||||
((char *)a)[0] = ((char *)&_tmp)[1]; \
|
||||
((char *)a)[1] = ((char *)&_tmp)[0]; \
|
||||
}
|
||||
#define P_16_COPY(a, b) { \
|
||||
((char *)&(b))[0] = ((char *)&(a))[1]; \
|
||||
((char *)&(b))[1] = ((char *)&(a))[0]; \
|
||||
}
|
||||
#endif
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
#if defined(__WATCOMC__) || defined(__WATCOM_CPLUSPLUS__)
|
||||
extern DB *
|
||||
#else
|
||||
PR_EXTERN(DB *)
|
||||
#endif
|
||||
dbopen (const char *, int, int, DBTYPE, const void *);
|
||||
|
||||
/* set or unset a global lock flag to disable the
|
||||
* opening of any DBM file
|
||||
*/
|
||||
void dbSetOrClearDBLock(DBLockFlagEnum type);
|
||||
|
||||
#ifdef __DBINTERFACE_PRIVATE
|
||||
DB *__bt_open (const char *, int, int, const BTREEINFO *, int);
|
||||
DB *__hash_open (const char *, int, int, const HASHINFO *, int);
|
||||
DB *__rec_open (const char *, int, int, const RECNOINFO *, int);
|
||||
void __dbpanic (DB *dbp);
|
||||
#endif
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif /* !_DB_H_ */
|
||||
@@ -1,97 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. ***REMOVED*** - see
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)mpool.h 8.2 (Berkeley) 7/14/94
|
||||
*/
|
||||
|
||||
#include <sys/queue.h>
|
||||
|
||||
/*
|
||||
* The memory pool scheme is a simple one. Each in-memory page is referenced
|
||||
* by a bucket which is threaded in up to two of three ways. All active pages
|
||||
* are threaded on a hash chain (hashed by page number) and an lru chain.
|
||||
* Inactive pages are threaded on a free chain. Each reference to a memory
|
||||
* pool is handed an opaque MPOOL cookie which stores all of this information.
|
||||
*/
|
||||
#define HASHSIZE 128
|
||||
#define HASHKEY(pgno) ((pgno - 1) % HASHSIZE)
|
||||
|
||||
/* The BKT structures are the elements of the queues. */
|
||||
typedef struct _bkt {
|
||||
CIRCLEQ_ENTRY(_bkt) hq; /* hash queue */
|
||||
CIRCLEQ_ENTRY(_bkt) q; /* lru queue */
|
||||
void *page; /* page */
|
||||
pgno_t pgno; /* page number */
|
||||
|
||||
#define MPOOL_DIRTY 0x01 /* page needs to be written */
|
||||
#define MPOOL_PINNED 0x02 /* page is pinned into memory */
|
||||
uint8 flags; /* flags */
|
||||
} BKT;
|
||||
|
||||
typedef struct MPOOL {
|
||||
CIRCLEQ_HEAD(_lqh, _bkt) lqh; /* lru queue head */
|
||||
/* hash queue array */
|
||||
CIRCLEQ_HEAD(_hqh, _bkt) hqh[HASHSIZE];
|
||||
pgno_t curcache; /* current number of cached pages */
|
||||
pgno_t maxcache; /* max number of cached pages */
|
||||
pgno_t npages; /* number of pages in the file */
|
||||
uint32 pagesize; /* file page size */
|
||||
int fd; /* file descriptor */
|
||||
/* page in conversion routine */
|
||||
void (*pgin) (void *, pgno_t, void *);
|
||||
/* page out conversion routine */
|
||||
void (*pgout) (void *, pgno_t, void *);
|
||||
void *pgcookie; /* cookie for page in/out routines */
|
||||
#ifdef STATISTICS
|
||||
uint32 cachehit;
|
||||
uint32 cachemiss;
|
||||
uint32 pagealloc;
|
||||
uint32 pageflush;
|
||||
uint32 pageget;
|
||||
uint32 pagenew;
|
||||
uint32 pageput;
|
||||
uint32 pageread;
|
||||
uint32 pagewrite;
|
||||
#endif
|
||||
} MPOOL;
|
||||
|
||||
__BEGIN_DECLS
|
||||
MPOOL *mpool_open (void *, int, pgno_t, pgno_t);
|
||||
void mpool_filter (MPOOL *, void (*)(void *, pgno_t, void *),
|
||||
void (*)(void *, pgno_t, void *), void *);
|
||||
void *mpool_new (MPOOL *, pgno_t *);
|
||||
void *mpool_get (MPOOL *, pgno_t, uint);
|
||||
int mpool_put (MPOOL *, void *, uint);
|
||||
int mpool_sync (MPOOL *);
|
||||
int mpool_close (MPOOL *);
|
||||
#ifdef STATISTICS
|
||||
void mpool_stat (MPOOL *);
|
||||
#endif
|
||||
__END_DECLS
|
||||
@@ -1,230 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. ***REMOVED*** - see
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)compat.h 8.13 (Berkeley) 2/21/94
|
||||
*/
|
||||
|
||||
#ifndef _COMPAT_H_
|
||||
#define _COMPAT_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
/*
|
||||
* If your system doesn't typedef u_long, u_short, or u_char, change
|
||||
* the 0 to a 1.
|
||||
*/
|
||||
#if 0
|
||||
typedef unsigned char u_char; /* 4.[34]BSD names. */
|
||||
typedef unsigned int u_int;
|
||||
typedef unsigned long u_long;
|
||||
typedef unsigned short u_short;
|
||||
#endif
|
||||
|
||||
/* If your system doesn't typedef size_t, change the 0 to a 1. */
|
||||
#if 0
|
||||
typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */
|
||||
#endif
|
||||
|
||||
/* If your system doesn't typedef ssize_t, change the 0 to a 1. */
|
||||
#if 0
|
||||
typedef int ssize_t; /* POSIX names. */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If your system doesn't have the POSIX type for a signal mask,
|
||||
* change the 0 to a 1.
|
||||
*/
|
||||
#if 0 /* POSIX 1003.1 signal mask type. */
|
||||
typedef unsigned int sigset_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If your system's vsprintf returns a char *, not an int,
|
||||
* change the 0 to a 1.
|
||||
*/
|
||||
#if defined (__sun) && !defined(__SVR4) /* SUNOS */
|
||||
#define VSPRINTF_CHARSTAR
|
||||
#endif
|
||||
/*
|
||||
* If you don't have POSIX 1003.1 signals, the signal code surrounding the
|
||||
* temporary file creation is intended to block all of the possible signals
|
||||
* long enough to create the file and unlink it. All of this stuff is
|
||||
* intended to use old-style BSD calls to fake POSIX 1003.1 calls.
|
||||
*/
|
||||
#ifdef NO_POSIX_SIGNALS
|
||||
#define sigemptyset(set) (*(set) = 0)
|
||||
#define sigfillset(set) (*(set) = ~(sigset_t)0, 0)
|
||||
#define sigaddset(set,signo) (*(set) |= sigmask(signo), 0)
|
||||
#define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0)
|
||||
#define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0)
|
||||
|
||||
#define SIG_BLOCK 1
|
||||
#define SIG_UNBLOCK 2
|
||||
#define SIG_SETMASK 3
|
||||
|
||||
static int __sigtemp; /* For the use of sigprocmask */
|
||||
|
||||
/* Repeated test of oset != NULL is to avoid "*0". */
|
||||
#define sigprocmask(how, set, oset) \
|
||||
((__sigtemp = \
|
||||
(((how) == SIG_BLOCK) ? \
|
||||
sigblock(0) | *(set) : \
|
||||
(((how) == SIG_UNBLOCK) ? \
|
||||
sigblock(0) & ~(*(set)) : \
|
||||
((how) == SIG_SETMASK ? \
|
||||
*(set) : sigblock(0))))), \
|
||||
((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \
|
||||
sigsetmask(__sigtemp)), 0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If your system doesn't have an include file with the appropriate
|
||||
* byte order set, make sure you specify the correct one.
|
||||
*/
|
||||
#ifndef BYTE_ORDER
|
||||
#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */
|
||||
#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */
|
||||
#define BYTE_ORDER BIG_ENDIAN /* Set for your system. */
|
||||
#endif
|
||||
|
||||
#if defined(SYSV) || defined(SYSTEM5) || defined(__sun)
|
||||
#define index(a, b) strchr(a, b)
|
||||
#define rindex(a, b) strrchr(a, b)
|
||||
#define bzero(a, b) memset(a, 0, b)
|
||||
#define bcmp(a, b, n) memcmp(a, b, n)
|
||||
#define bcopy(a, b, n) memmove(b, a, n)
|
||||
#endif
|
||||
|
||||
#if defined(BSD) || defined(BSD4_3)
|
||||
#define strchr(a, b) index(a, b)
|
||||
#define strrchr(a, b) rindex(a, b)
|
||||
#define memcmp(a, b, n) bcmp(a, b, n)
|
||||
#define memmove(a, b, n) bcopy(b, a, n)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 32-bit machine. The db routines are theoretically independent of
|
||||
* the size of u_shorts and u_longs, but I don't know that anyone has
|
||||
* ever actually tried it. At a minimum, change the following #define's
|
||||
* if you are trying to compile on a different type of system.
|
||||
*/
|
||||
#ifndef USHRT_MAX
|
||||
#define USHRT_MAX 0xFFFF
|
||||
#define ULONG_MAX 0xFFFFFFFF
|
||||
#endif
|
||||
|
||||
#ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */
|
||||
#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
|
||||
#endif
|
||||
|
||||
#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */
|
||||
#define _POSIX2_RE_DUP_MAX 255
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If you can't provide lock values in the open(2) call. Note, this
|
||||
* allows races to happen.
|
||||
*/
|
||||
#ifndef O_EXLOCK /* 4.4BSD extension. */
|
||||
#define O_EXLOCK 0
|
||||
#endif
|
||||
|
||||
#ifndef O_SHLOCK /* 4.4BSD extension. */
|
||||
#define O_SHLOCK 0
|
||||
#endif
|
||||
|
||||
#ifndef EFTYPE
|
||||
#define EFTYPE EINVAL /* POSIX 1003.1 format errno. */
|
||||
#endif
|
||||
|
||||
#ifndef WCOREDUMP /* 4.4BSD extension */
|
||||
#define WCOREDUMP(a) 0
|
||||
#endif
|
||||
|
||||
#ifndef STDERR_FILENO
|
||||
#define STDIN_FILENO 0 /* ANSI C #defines */
|
||||
#define STDOUT_FILENO 1
|
||||
#define STDERR_FILENO 2
|
||||
#endif
|
||||
|
||||
#ifndef SEEK_END
|
||||
#define SEEK_SET 0 /* POSIX 1003.1 seek values */
|
||||
#define SEEK_CUR 1
|
||||
#define SEEK_END 2
|
||||
#endif
|
||||
|
||||
#ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */
|
||||
#define _POSIX_VDISABLE 0 /* Some systems used 0. */
|
||||
#endif
|
||||
|
||||
#ifndef TCSASOFT /* 4.4BSD extension. */
|
||||
#define TCSASOFT 0
|
||||
#endif
|
||||
|
||||
#ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */
|
||||
#define _POSIX2_RE_DUP_MAX 255
|
||||
#endif
|
||||
|
||||
#ifndef NULL /* ANSI C #defines NULL everywhere. */
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#ifndef MAX /* Usually found in <sys/param.h>. */
|
||||
#define MAX(_a,_b) ((_a)<(_b)?(_b):(_a))
|
||||
#endif
|
||||
#ifndef MIN /* Usually found in <sys/param.h>. */
|
||||
#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b))
|
||||
#endif
|
||||
|
||||
/* Default file permissions. */
|
||||
#ifndef DEFFILEMODE /* 4.4BSD extension. */
|
||||
#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
|
||||
#endif
|
||||
|
||||
#ifndef __sun
|
||||
#ifndef S_ISDIR /* POSIX 1003.1 file type tests. */
|
||||
#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */
|
||||
#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */
|
||||
#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */
|
||||
#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */
|
||||
#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */
|
||||
#endif
|
||||
#ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */
|
||||
#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */
|
||||
#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */
|
||||
#endif
|
||||
#endif /* __sun */
|
||||
|
||||
/* The type of a va_list. */
|
||||
#ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */
|
||||
#define _BSD_VA_LIST_ char *
|
||||
#endif
|
||||
|
||||
#endif /* !_COMPAT_H_ */
|
||||
@@ -1,94 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Margo Seltzer.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. ***REMOVED*** - see
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)page.h 8.2 (Berkeley) 5/31/94
|
||||
*/
|
||||
|
||||
/*
|
||||
* Definitions for hashing page file format.
|
||||
*/
|
||||
|
||||
/*
|
||||
* routines dealing with a data page
|
||||
*
|
||||
* page format:
|
||||
* +------------------------------+
|
||||
* p | n | keyoff | datoff | keyoff |
|
||||
* +------------+--------+--------+
|
||||
* | datoff | free | ptr | --> |
|
||||
* +--------+---------------------+
|
||||
* | F R E E A R E A |
|
||||
* +--------------+---------------+
|
||||
* | <---- - - - | data |
|
||||
* +--------+-----+----+----------+
|
||||
* | key | data | key |
|
||||
* +--------+----------+----------+
|
||||
*
|
||||
* Pointer to the free space is always: p[p[0] + 2]
|
||||
* Amount of free space on the page is: p[p[0] + 1]
|
||||
*/
|
||||
|
||||
/*
|
||||
* How many bytes required for this pair?
|
||||
* 2 shorts in the table at the top of the page + room for the
|
||||
* key and room for the data
|
||||
*
|
||||
* We prohibit entering a pair on a page unless there is also room to append
|
||||
* an overflow page. The reason for this it that you can get in a situation
|
||||
* where a single key/data pair fits on a page, but you can't append an
|
||||
* overflow page and later you'd have to split the key/data and handle like
|
||||
* a big pair.
|
||||
* You might as well do this up front.
|
||||
*/
|
||||
#ifndef PAGE_H
|
||||
#define PAGE_H
|
||||
|
||||
#define PAIRSIZE(K,D) (2*sizeof(uint16) + (K)->size + (D)->size)
|
||||
#define BIGOVERHEAD (4*sizeof(uint16))
|
||||
#define KEYSIZE(K) (4*sizeof(uint16) + (K)->size);
|
||||
#define OVFLSIZE (2*sizeof(uint16))
|
||||
#define FREESPACE(P) ((P)[(P)[0]+1])
|
||||
#define OFFSET(P) ((P)[(P)[0]+2])
|
||||
#define PAIRFITS(P,K,D) \
|
||||
(((P)[2] >= REAL_KEY) && \
|
||||
(PAIRSIZE((K),(D)) + OVFLSIZE) <= FREESPACE((P)))
|
||||
#define PAGE_META(N) (((N)+3) * sizeof(uint16))
|
||||
|
||||
typedef struct {
|
||||
BUFHEAD *newp;
|
||||
BUFHEAD *oldp;
|
||||
BUFHEAD *nextp;
|
||||
uint16 next_addr;
|
||||
} SPLIT_RETURN;
|
||||
#endif
|
||||
|
||||
@@ -1,243 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1991, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. ***REMOVED*** - see
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)queue.h 8.3 (Berkeley) 12/13/93
|
||||
*/
|
||||
|
||||
#ifndef _QUEUE_H_
|
||||
#define _QUEUE_H_
|
||||
|
||||
/*
|
||||
* This file defines three types of data structures: lists, tail queues,
|
||||
* and circular queues.
|
||||
*
|
||||
* A list is headed by a single forward pointer (or an array of forward
|
||||
* pointers for a hash table header). The elements are doubly linked
|
||||
* so that an arbitrary element can be removed without a need to
|
||||
* traverse the list. New elements can be added to the list after
|
||||
* an existing element or at the head of the list. A list may only be
|
||||
* traversed in the forward direction.
|
||||
*
|
||||
* A tail queue is headed by a pair of pointers, one to the head of the
|
||||
* list and the other to the tail of the list. The elements are doubly
|
||||
* linked so that an arbitrary element can be removed without a need to
|
||||
* traverse the list. New elements can be added to the list after
|
||||
* an existing element, at the head of the list, or at the end of the
|
||||
* list. A tail queue may only be traversed in the forward direction.
|
||||
*
|
||||
* A circle queue is headed by a pair of pointers, one to the head of the
|
||||
* list and the other to the tail of the list. The elements are doubly
|
||||
* linked so that an arbitrary element can be removed without a need to
|
||||
* traverse the list. New elements can be added to the list before or after
|
||||
* an existing element, at the head of the list, or at the end of the list.
|
||||
* A circle queue may be traversed in either direction, but has a more
|
||||
* complex end of list detection.
|
||||
*
|
||||
* For details on the use of these macros, see the queue(3) manual page.
|
||||
*/
|
||||
|
||||
/*
|
||||
* List definitions.
|
||||
*/
|
||||
#define LIST_HEAD(name, type) \
|
||||
struct name { \
|
||||
struct type *lh_first; /* first element */ \
|
||||
}
|
||||
|
||||
#define LIST_ENTRY(type) \
|
||||
struct { \
|
||||
struct type *le_next; /* next element */ \
|
||||
struct type **le_prev; /* address of previous next element */ \
|
||||
}
|
||||
|
||||
/*
|
||||
* List functions.
|
||||
*/
|
||||
#define LIST_INIT(head) { \
|
||||
(head)->lh_first = NULL; \
|
||||
}
|
||||
|
||||
#define LIST_INSERT_AFTER(listelm, elm, field) { \
|
||||
if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
|
||||
(listelm)->field.le_next->field.le_prev = \
|
||||
&(elm)->field.le_next; \
|
||||
(listelm)->field.le_next = (elm); \
|
||||
(elm)->field.le_prev = &(listelm)->field.le_next; \
|
||||
}
|
||||
|
||||
#define LIST_INSERT_HEAD(head, elm, field) { \
|
||||
if (((elm)->field.le_next = (head)->lh_first) != NULL) \
|
||||
(head)->lh_first->field.le_prev = &(elm)->field.le_next;\
|
||||
(head)->lh_first = (elm); \
|
||||
(elm)->field.le_prev = &(head)->lh_first; \
|
||||
}
|
||||
|
||||
#define LIST_REMOVE(elm, field) { \
|
||||
if ((elm)->field.le_next != NULL) \
|
||||
(elm)->field.le_next->field.le_prev = \
|
||||
(elm)->field.le_prev; \
|
||||
*(elm)->field.le_prev = (elm)->field.le_next; \
|
||||
}
|
||||
|
||||
/*
|
||||
* Tail queue definitions.
|
||||
*/
|
||||
#define TAILQ_HEAD(name, type) \
|
||||
struct name { \
|
||||
struct type *tqh_first; /* first element */ \
|
||||
struct type **tqh_last; /* addr of last next element */ \
|
||||
}
|
||||
|
||||
#define TAILQ_ENTRY(type) \
|
||||
struct { \
|
||||
struct type *tqe_next; /* next element */ \
|
||||
struct type **tqe_prev; /* address of previous next element */ \
|
||||
}
|
||||
|
||||
/*
|
||||
* Tail queue functions.
|
||||
*/
|
||||
#define TAILQ_INIT(head) { \
|
||||
(head)->tqh_first = NULL; \
|
||||
(head)->tqh_last = &(head)->tqh_first; \
|
||||
}
|
||||
|
||||
#define TAILQ_INSERT_HEAD(head, elm, field) { \
|
||||
if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
|
||||
(elm)->field.tqe_next->field.tqe_prev = \
|
||||
&(elm)->field.tqe_next; \
|
||||
else \
|
||||
(head)->tqh_last = &(elm)->field.tqe_next; \
|
||||
(head)->tqh_first = (elm); \
|
||||
(elm)->field.tqe_prev = &(head)->tqh_first; \
|
||||
}
|
||||
|
||||
#define TAILQ_INSERT_TAIL(head, elm, field) { \
|
||||
(elm)->field.tqe_next = NULL; \
|
||||
(elm)->field.tqe_prev = (head)->tqh_last; \
|
||||
*(head)->tqh_last = (elm); \
|
||||
(head)->tqh_last = &(elm)->field.tqe_next; \
|
||||
}
|
||||
|
||||
#define TAILQ_INSERT_AFTER(head, listelm, elm, field) { \
|
||||
if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
|
||||
(elm)->field.tqe_next->field.tqe_prev = \
|
||||
&(elm)->field.tqe_next; \
|
||||
else \
|
||||
(head)->tqh_last = &(elm)->field.tqe_next; \
|
||||
(listelm)->field.tqe_next = (elm); \
|
||||
(elm)->field.tqe_prev = &(listelm)->field.tqe_next; \
|
||||
}
|
||||
|
||||
#define TAILQ_REMOVE(head, elm, field) { \
|
||||
if (((elm)->field.tqe_next) != NULL) \
|
||||
(elm)->field.tqe_next->field.tqe_prev = \
|
||||
(elm)->field.tqe_prev; \
|
||||
else \
|
||||
(head)->tqh_last = (elm)->field.tqe_prev; \
|
||||
*(elm)->field.tqe_prev = (elm)->field.tqe_next; \
|
||||
}
|
||||
|
||||
/*
|
||||
* Circular queue definitions.
|
||||
*/
|
||||
#define CIRCLEQ_HEAD(name, type) \
|
||||
struct name { \
|
||||
struct type *cqh_first; /* first element */ \
|
||||
struct type *cqh_last; /* last element */ \
|
||||
}
|
||||
|
||||
#define CIRCLEQ_ENTRY(type) \
|
||||
struct { \
|
||||
struct type *cqe_next; /* next element */ \
|
||||
struct type *cqe_prev; /* previous element */ \
|
||||
}
|
||||
|
||||
/*
|
||||
* Circular queue functions.
|
||||
*/
|
||||
#define CIRCLEQ_INIT(head) { \
|
||||
(head)->cqh_first = (void *)(head); \
|
||||
(head)->cqh_last = (void *)(head); \
|
||||
}
|
||||
|
||||
#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) { \
|
||||
(elm)->field.cqe_next = (listelm)->field.cqe_next; \
|
||||
(elm)->field.cqe_prev = (listelm); \
|
||||
if ((listelm)->field.cqe_next == (void *)(head)) \
|
||||
(head)->cqh_last = (elm); \
|
||||
else \
|
||||
(listelm)->field.cqe_next->field.cqe_prev = (elm); \
|
||||
(listelm)->field.cqe_next = (elm); \
|
||||
}
|
||||
|
||||
#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) { \
|
||||
(elm)->field.cqe_next = (listelm); \
|
||||
(elm)->field.cqe_prev = (listelm)->field.cqe_prev; \
|
||||
if ((listelm)->field.cqe_prev == (void *)(head)) \
|
||||
(head)->cqh_first = (elm); \
|
||||
else \
|
||||
(listelm)->field.cqe_prev->field.cqe_next = (elm); \
|
||||
(listelm)->field.cqe_prev = (elm); \
|
||||
}
|
||||
|
||||
#define CIRCLEQ_INSERT_HEAD(head, elm, field) { \
|
||||
(elm)->field.cqe_next = (head)->cqh_first; \
|
||||
(elm)->field.cqe_prev = (void *)(head); \
|
||||
if ((head)->cqh_last == (void *)(head)) \
|
||||
(head)->cqh_last = (elm); \
|
||||
else \
|
||||
(head)->cqh_first->field.cqe_prev = (elm); \
|
||||
(head)->cqh_first = (elm); \
|
||||
}
|
||||
|
||||
#define CIRCLEQ_INSERT_TAIL(head, elm, field) { \
|
||||
(elm)->field.cqe_next = (void *)(head); \
|
||||
(elm)->field.cqe_prev = (head)->cqh_last; \
|
||||
if ((head)->cqh_first == (void *)(head)) \
|
||||
(head)->cqh_first = (elm); \
|
||||
else \
|
||||
(head)->cqh_last->field.cqe_next = (elm); \
|
||||
(head)->cqh_last = (elm); \
|
||||
}
|
||||
|
||||
#define CIRCLEQ_REMOVE(head, elm, field) { \
|
||||
if ((elm)->field.cqe_next == (void *)(head)) \
|
||||
(head)->cqh_last = (elm)->field.cqe_prev; \
|
||||
else \
|
||||
(elm)->field.cqe_next->field.cqe_prev = \
|
||||
(elm)->field.cqe_prev; \
|
||||
if ((elm)->field.cqe_prev == (void *)(head)) \
|
||||
(head)->cqh_first = (elm)->field.cqe_next; \
|
||||
else \
|
||||
(elm)->field.cqe_prev->field.cqe_next = \
|
||||
(elm)->field.cqe_next; \
|
||||
}
|
||||
#endif /* !_QUEUE_H_ */
|
||||
@@ -1,49 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Margo Seltzer.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. ***REMOVED*** - see
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)search.h 8.1 (Berkeley) 6/4/93
|
||||
*/
|
||||
|
||||
/* Backward compatibility to hsearch interface. */
|
||||
typedef struct entry {
|
||||
char *key;
|
||||
char *data;
|
||||
} ENTRY;
|
||||
|
||||
typedef enum {
|
||||
FIND, ENTER
|
||||
} ACTION;
|
||||
|
||||
int hcreate (unsigned int);
|
||||
void hdestroy (void);
|
||||
ENTRY *hsearch (ENTRY, ACTION);
|
||||
@@ -1,26 +0,0 @@
|
||||
#if defined(__WATCOMC__) || defined(__WATCOM_CPLUSPLUS__)
|
||||
#ifndef __WATCOM_FIX_H__
|
||||
#define __WATCOM_FIX_H__ 1
|
||||
/*
|
||||
* WATCOM's C compiler doesn't default to "__cdecl" conventions for external
|
||||
* symbols and functions. Rather than adding an explicit __cdecl modifier to
|
||||
* every external symbol and function declaration and definition, we use the
|
||||
* following pragma to (attempt to) change WATCOM c's default to __cdecl.
|
||||
* These pragmas were taken from pages 180-181, 266 & 269 of the
|
||||
* Watcom C/C++ version 11 User's Guide, 3rd edition.
|
||||
*/
|
||||
#if defined(XP_WIN16) || defined(WIN16)
|
||||
#pragma aux default "_*" \
|
||||
parm caller [] \
|
||||
value struct float struct routine [ax] \
|
||||
modify [ax bx cx dx es]
|
||||
#else
|
||||
#pragma aux default "_*" \
|
||||
parm caller [] \
|
||||
value struct float struct routine [eax] \
|
||||
modify [eax ecx edx]
|
||||
#endif
|
||||
#pragma aux default far
|
||||
|
||||
#endif /* once */
|
||||
#endif /* WATCOM compiler */
|
||||
@@ -1,112 +0,0 @@
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
Stuff to fake unix file I/O on windows boxes
|
||||
------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef WINFILE_H
|
||||
#define WINFILE_H
|
||||
|
||||
#ifdef _WINDOWS
|
||||
/* hacked out of <dirent.h> on an SGI */
|
||||
#if defined(XP_WIN32) || defined(_WIN32)
|
||||
/* 32-bit stuff here */
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef __MINGW32__
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#else
|
||||
#include <sys\types.h>
|
||||
#include <sys\stat.h>
|
||||
#endif
|
||||
|
||||
typedef struct DIR_Struct {
|
||||
void * directoryPtr;
|
||||
WIN32_FIND_DATA data;
|
||||
} DIR;
|
||||
|
||||
#define _ST_FSTYPSZ 16
|
||||
|
||||
#if !defined(__BORLANDC__) && !defined(__GNUC__)
|
||||
typedef unsigned long mode_t;
|
||||
typedef long uid_t;
|
||||
typedef long gid_t;
|
||||
|
||||
#ifdef WINCE
|
||||
typedef long ino_t;
|
||||
#else
|
||||
typedef long off_t;
|
||||
#endif
|
||||
|
||||
typedef unsigned long nlink_t;
|
||||
#endif
|
||||
|
||||
typedef struct timestruc {
|
||||
time_t tv_sec; /* seconds */
|
||||
long tv_nsec; /* and nanoseconds */
|
||||
} timestruc_t;
|
||||
|
||||
|
||||
struct dirent { /* data from readdir() */
|
||||
ino_t d_ino; /* inode number of entry */
|
||||
off_t d_off; /* offset of disk direntory entry */
|
||||
unsigned short d_reclen; /* length of this record */
|
||||
char d_name[_MAX_FNAME]; /* name of file */
|
||||
};
|
||||
|
||||
#if !defined(__BORLANDC__) && !defined (__GNUC__)
|
||||
#define S_ISDIR(s) ((s) & _S_IFDIR)
|
||||
#endif
|
||||
|
||||
#else /* _WIN32 */
|
||||
/* 16-bit windows stuff */
|
||||
|
||||
#include <sys\types.h>
|
||||
#include <sys\stat.h>
|
||||
#include <dos.h>
|
||||
|
||||
|
||||
|
||||
/* Getting cocky to support multiple file systems */
|
||||
typedef struct dirStruct_tag {
|
||||
struct _find_t file_data;
|
||||
char c_checkdrive;
|
||||
} dirStruct;
|
||||
|
||||
typedef struct DIR_Struct {
|
||||
void * directoryPtr;
|
||||
dirStruct data;
|
||||
} DIR;
|
||||
|
||||
#define _ST_FSTYPSZ 16
|
||||
typedef unsigned long mode_t;
|
||||
typedef long uid_t;
|
||||
typedef long gid_t;
|
||||
typedef long off_t;
|
||||
typedef unsigned long nlink_t;
|
||||
|
||||
typedef struct timestruc {
|
||||
time_t tv_sec; /* seconds */
|
||||
long tv_nsec; /* and nanoseconds */
|
||||
} timestruc_t;
|
||||
|
||||
struct dirent { /* data from readdir() */
|
||||
ino_t d_ino; /* inode number of entry */
|
||||
off_t d_off; /* offset of disk direntory entry */
|
||||
unsigned short d_reclen; /* length of this record */
|
||||
#ifdef XP_WIN32
|
||||
char d_name[_MAX_FNAME]; /* name of file */
|
||||
#else
|
||||
char d_name[20]; /* name of file */
|
||||
#endif
|
||||
};
|
||||
|
||||
#define S_ISDIR(s) ((s) & _S_IFDIR)
|
||||
|
||||
#endif /* 16-bit windows */
|
||||
|
||||
#define CONST const
|
||||
|
||||
#endif /* _WINDOWS */
|
||||
|
||||
#endif /* WINFILE_H */
|
||||
@@ -1,95 +0,0 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
LIBRARY_NAME = mozdbm_s
|
||||
LIB_IS_C_ONLY = 1
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
LIBRARY_NAME = dbm$(MOZ_BITS)
|
||||
endif
|
||||
|
||||
CSRCS = \
|
||||
db.c \
|
||||
h_bigkey.c \
|
||||
h_func.c \
|
||||
h_log2.c \
|
||||
h_page.c \
|
||||
hash.c \
|
||||
hash_buf.c \
|
||||
hsearch.c \
|
||||
mktemp.c \
|
||||
ndbm.c \
|
||||
strerror.c \
|
||||
nsres.c \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
CSRCS += memmove.c snprintf.c
|
||||
else
|
||||
ifeq (,$(filter -DHAVE_MEMMOVE=1,$(ACDEFINES)))
|
||||
CSRCS += memmove.c
|
||||
endif
|
||||
|
||||
ifeq (,$(filter -DHAVE_SNPRINTF=1,$(ACDEFINES)))
|
||||
CSRCS += snprintf.c
|
||||
endif
|
||||
endif # WINNT
|
||||
|
||||
LOCAL_INCLUDES = -I$(srcdir)/../include
|
||||
|
||||
FORCE_STATIC_LIB = 1
|
||||
FORCE_USE_PIC = 1
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -DMEMMOVE -D__DBINTERFACE_PRIVATE $(SECURITY_FLAG)
|
||||
|
||||
ifeq ($(OS_ARCH),WINCE)
|
||||
DEFINES += -D__STDC__ -DDBM_REOPEN_ON_FLUSH
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),AIX)
|
||||
OS_LIBS += -lc_r
|
||||
endif
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Makefile to build the cert library
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
!if "$(MOZ_BITS)" == "16"
|
||||
!ifndef MOZ_DEBUG
|
||||
OPTIMIZER=-Os -UDEBUG -DNDEBUG
|
||||
!endif
|
||||
!endif
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Specify the depth of the current directory relative to the
|
||||
#// root of NS
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
DEPTH= ..\..
|
||||
|
||||
!ifndef MAKE_OBJ_TYPE
|
||||
MAKE_OBJ_TYPE=EXE
|
||||
!endif
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Define any Public Make Variables here: (ie. PDFFILE, MAPFILE, ...)
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
LIBNAME=dbm$(MOZ_BITS)
|
||||
PDBFILE=$(LIBNAME).pdb
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Define the files necessary to build the target (ie. OBJS)
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
OBJS= \
|
||||
.\$(OBJDIR)\db.obj \
|
||||
.\$(OBJDIR)\h_bigkey.obj \
|
||||
.\$(OBJDIR)\h_func.obj \
|
||||
.\$(OBJDIR)\h_log2.obj \
|
||||
.\$(OBJDIR)\h_page.obj \
|
||||
.\$(OBJDIR)\hash.obj \
|
||||
.\$(OBJDIR)\hash_buf.obj \
|
||||
.\$(OBJDIR)\hsearch.obj \
|
||||
.\$(OBJDIR)\memmove.obj \
|
||||
.\$(OBJDIR)\mktemp.obj \
|
||||
.\$(OBJDIR)\ndbm.obj \
|
||||
.\$(OBJDIR)\snprintf.obj \
|
||||
.\$(OBJDIR)\strerror.obj \
|
||||
.\$(OBJDIR)\nsres.obj \
|
||||
$(NULL)
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Define any Public Targets here (ie. PROGRAM, LIBRARY, DLL, ...)
|
||||
#// (these must be defined before the common makefiles are included)
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
LIBRARY = .\$(OBJDIR)\$(LIBNAME).lib
|
||||
LINCS = -I..\include
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Include the common makefile rules
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
CFLAGS = $(CFLAGS) -DMOZILLA_CLIENT -D__DBINTERFACE_PRIVATE
|
||||
|
||||
install:: $(LIBRARY)
|
||||
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
|
||||
|
||||
|
||||
@@ -1,142 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. ***REMOVED*** - see
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)db.c 8.4 (Berkeley) 2/21/94";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "watcomfx.h"
|
||||
|
||||
#ifndef __DBINTERFACE_PRIVATE
|
||||
#define __DBINTERFACE_PRIVATE
|
||||
#endif
|
||||
#ifdef macintosh
|
||||
#include <unix.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "mcom_db.h"
|
||||
|
||||
/* a global flag that locks closed all databases */
|
||||
int all_databases_locked_closed = 0;
|
||||
|
||||
/* set or unset a global lock flag to disable the
|
||||
* opening of any DBM file
|
||||
*/
|
||||
void
|
||||
dbSetOrClearDBLock(DBLockFlagEnum type)
|
||||
{
|
||||
if(type == LockOutDatabase)
|
||||
all_databases_locked_closed = 1;
|
||||
else
|
||||
all_databases_locked_closed = 0;
|
||||
}
|
||||
|
||||
#if defined(__WATCOMC__) || defined(__WATCOM_CPLUSPLUS__)
|
||||
DB *
|
||||
#else
|
||||
PR_IMPLEMENT(DB *)
|
||||
#endif
|
||||
dbopen(const char *fname, int flags,int mode, DBTYPE type, const void *openinfo)
|
||||
{
|
||||
|
||||
/* lock out all file databases. Let in-memory databases through
|
||||
*/
|
||||
if(all_databases_locked_closed && fname)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
#define DB_FLAGS (DB_LOCK | DB_SHMEM | DB_TXN)
|
||||
|
||||
|
||||
#if 0 /* most systems don't have EXLOCK and SHLOCK */
|
||||
#define USE_OPEN_FLAGS \
|
||||
(O_CREAT | O_EXCL | O_EXLOCK | O_NONBLOCK | O_RDONLY | \
|
||||
O_RDWR | O_SHLOCK | O_TRUNC)
|
||||
#else
|
||||
#define USE_OPEN_FLAGS \
|
||||
(O_CREAT | O_EXCL | O_RDONLY | \
|
||||
O_RDWR | O_TRUNC)
|
||||
#endif
|
||||
|
||||
if ((flags & ~(USE_OPEN_FLAGS | DB_FLAGS)) == 0)
|
||||
switch (type) {
|
||||
/* we don't need btree and recno right now */
|
||||
#if 0
|
||||
case DB_BTREE:
|
||||
return (__bt_open(fname, flags & USE_OPEN_FLAGS,
|
||||
mode, openinfo, flags & DB_FLAGS));
|
||||
case DB_RECNO:
|
||||
return (__rec_open(fname, flags & USE_OPEN_FLAGS,
|
||||
mode, openinfo, flags & DB_FLAGS));
|
||||
#endif
|
||||
|
||||
case DB_HASH:
|
||||
return (__hash_open(fname, flags & USE_OPEN_FLAGS,
|
||||
mode, (const HASHINFO *)openinfo, flags & DB_FLAGS));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
errno = EINVAL;
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
__dberr()
|
||||
{
|
||||
return (RET_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* __DBPANIC -- Stop.
|
||||
*
|
||||
* Parameters:
|
||||
* dbp: pointer to the DB structure.
|
||||
*/
|
||||
void
|
||||
__dbpanic(DB *dbp)
|
||||
{
|
||||
/* The only thing that can succeed is a close. */
|
||||
dbp->del = (int (*)(const struct __db *, const DBT *, uint))__dberr;
|
||||
dbp->fd = (int (*)(const struct __db *))__dberr;
|
||||
dbp->get = (int (*)(const struct __db *, const DBT *, DBT *, uint))__dberr;
|
||||
dbp->put = (int (*)(const struct __db *, DBT *, const DBT *, uint))__dberr;
|
||||
dbp->seq = (int (*)(const struct __db *, DBT *, DBT *, uint))__dberr;
|
||||
dbp->sync = (int (*)(const struct __db *, uint))__dberr;
|
||||
}
|
||||
@@ -1,711 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Margo Seltzer.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. ***REMOVED*** - see
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)hash_bigkey.c 8.3 (Berkeley) 5/31/94";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "watcomfx.h"
|
||||
|
||||
/*
|
||||
* PACKAGE: hash
|
||||
* DESCRIPTION:
|
||||
* Big key/data handling for the hashing package.
|
||||
*
|
||||
* ROUTINES:
|
||||
* External
|
||||
* __big_keydata
|
||||
* __big_split
|
||||
* __big_insert
|
||||
* __big_return
|
||||
* __big_delete
|
||||
* __find_last_page
|
||||
* Internal
|
||||
* collect_key
|
||||
* collect_data
|
||||
*/
|
||||
|
||||
#if !defined(_WIN32) && !defined(_WINDOWS) && !defined(macintosh) && !defined(XP_OS2_VACPP)
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef DEBUG
|
||||
#include <assert.h>
|
||||
#endif
|
||||
|
||||
#include "mcom_db.h"
|
||||
#include "hash.h"
|
||||
#include "page.h"
|
||||
/* #include "extern.h" */
|
||||
|
||||
static int collect_key __P((HTAB *, BUFHEAD *, int, DBT *, int));
|
||||
static int collect_data __P((HTAB *, BUFHEAD *, int, int));
|
||||
|
||||
/*
|
||||
* Big_insert
|
||||
*
|
||||
* You need to do an insert and the key/data pair is too big
|
||||
*
|
||||
* Returns:
|
||||
* 0 ==> OK
|
||||
*-1 ==> ERROR
|
||||
*/
|
||||
extern int
|
||||
__big_insert(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val)
|
||||
{
|
||||
register uint16 *p;
|
||||
uint key_size, n, val_size;
|
||||
uint16 space, move_bytes, off;
|
||||
char *cp, *key_data, *val_data;
|
||||
|
||||
cp = bufp->page; /* Character pointer of p. */
|
||||
p = (uint16 *)cp;
|
||||
|
||||
key_data = (char *)key->data;
|
||||
key_size = key->size;
|
||||
val_data = (char *)val->data;
|
||||
val_size = val->size;
|
||||
|
||||
/* First move the Key */
|
||||
for (space = FREESPACE(p) - BIGOVERHEAD; key_size;
|
||||
space = FREESPACE(p) - BIGOVERHEAD) {
|
||||
move_bytes = PR_MIN(space, key_size);
|
||||
off = OFFSET(p) - move_bytes;
|
||||
memmove(cp + off, key_data, move_bytes);
|
||||
key_size -= move_bytes;
|
||||
key_data += move_bytes;
|
||||
n = p[0];
|
||||
p[++n] = off;
|
||||
p[0] = ++n;
|
||||
FREESPACE(p) = off - PAGE_META(n);
|
||||
OFFSET(p) = off;
|
||||
p[n] = PARTIAL_KEY;
|
||||
bufp = __add_ovflpage(hashp, bufp);
|
||||
if (!bufp)
|
||||
return (-1);
|
||||
n = p[0];
|
||||
if (!key_size) {
|
||||
if (FREESPACE(p)) {
|
||||
move_bytes = PR_MIN(FREESPACE(p), val_size);
|
||||
off = OFFSET(p) - move_bytes;
|
||||
p[n] = off;
|
||||
memmove(cp + off, val_data, move_bytes);
|
||||
val_data += move_bytes;
|
||||
val_size -= move_bytes;
|
||||
p[n - 2] = FULL_KEY_DATA;
|
||||
FREESPACE(p) = FREESPACE(p) - move_bytes;
|
||||
OFFSET(p) = off;
|
||||
} else
|
||||
p[n - 2] = FULL_KEY;
|
||||
}
|
||||
p = (uint16 *)bufp->page;
|
||||
cp = bufp->page;
|
||||
bufp->flags |= BUF_MOD;
|
||||
}
|
||||
|
||||
/* Now move the data */
|
||||
for (space = FREESPACE(p) - BIGOVERHEAD; val_size;
|
||||
space = FREESPACE(p) - BIGOVERHEAD) {
|
||||
move_bytes = PR_MIN(space, val_size);
|
||||
/*
|
||||
* Here's the hack to make sure that if the data ends on the
|
||||
* same page as the key ends, FREESPACE is at least one.
|
||||
*/
|
||||
if (space == val_size && val_size == val->size)
|
||||
move_bytes--;
|
||||
off = OFFSET(p) - move_bytes;
|
||||
memmove(cp + off, val_data, move_bytes);
|
||||
val_size -= move_bytes;
|
||||
val_data += move_bytes;
|
||||
n = p[0];
|
||||
p[++n] = off;
|
||||
p[0] = ++n;
|
||||
FREESPACE(p) = off - PAGE_META(n);
|
||||
OFFSET(p) = off;
|
||||
if (val_size) {
|
||||
p[n] = FULL_KEY;
|
||||
bufp = __add_ovflpage(hashp, bufp);
|
||||
if (!bufp)
|
||||
return (-1);
|
||||
cp = bufp->page;
|
||||
p = (uint16 *)cp;
|
||||
} else
|
||||
p[n] = FULL_KEY_DATA;
|
||||
bufp->flags |= BUF_MOD;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when bufp's page contains a partial key (index should be 1)
|
||||
*
|
||||
* All pages in the big key/data pair except bufp are freed. We cannot
|
||||
* free bufp because the page pointing to it is lost and we can't get rid
|
||||
* of its pointer.
|
||||
*
|
||||
* Returns:
|
||||
* 0 => OK
|
||||
*-1 => ERROR
|
||||
*/
|
||||
extern int
|
||||
__big_delete(HTAB *hashp, BUFHEAD *bufp)
|
||||
{
|
||||
register BUFHEAD *last_bfp, *rbufp;
|
||||
uint16 *bp, pageno;
|
||||
int key_done, n;
|
||||
|
||||
rbufp = bufp;
|
||||
last_bfp = NULL;
|
||||
bp = (uint16 *)bufp->page;
|
||||
pageno = 0;
|
||||
key_done = 0;
|
||||
|
||||
while (!key_done || (bp[2] != FULL_KEY_DATA)) {
|
||||
if (bp[2] == FULL_KEY || bp[2] == FULL_KEY_DATA)
|
||||
key_done = 1;
|
||||
|
||||
/*
|
||||
* If there is freespace left on a FULL_KEY_DATA page, then
|
||||
* the data is short and fits entirely on this page, and this
|
||||
* is the last page.
|
||||
*/
|
||||
if (bp[2] == FULL_KEY_DATA && FREESPACE(bp))
|
||||
break;
|
||||
pageno = bp[bp[0] - 1];
|
||||
rbufp->flags |= BUF_MOD;
|
||||
rbufp = __get_buf(hashp, pageno, rbufp, 0);
|
||||
if (last_bfp)
|
||||
__free_ovflpage(hashp, last_bfp);
|
||||
last_bfp = rbufp;
|
||||
if (!rbufp)
|
||||
return (-1); /* Error. */
|
||||
bp = (uint16 *)rbufp->page;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we get here then rbufp points to the last page of the big
|
||||
* key/data pair. Bufp points to the first one -- it should now be
|
||||
* empty pointing to the next page after this pair. Can't free it
|
||||
* because we don't have the page pointing to it.
|
||||
*/
|
||||
|
||||
/* This is information from the last page of the pair. */
|
||||
n = bp[0];
|
||||
pageno = bp[n - 1];
|
||||
|
||||
/* Now, bp is the first page of the pair. */
|
||||
bp = (uint16 *)bufp->page;
|
||||
if (n > 2) {
|
||||
/* There is an overflow page. */
|
||||
bp[1] = pageno;
|
||||
bp[2] = OVFLPAGE;
|
||||
bufp->ovfl = rbufp->ovfl;
|
||||
} else
|
||||
/* This is the last page. */
|
||||
bufp->ovfl = NULL;
|
||||
n -= 2;
|
||||
bp[0] = n;
|
||||
FREESPACE(bp) = hashp->BSIZE - PAGE_META(n);
|
||||
OFFSET(bp) = hashp->BSIZE - 1;
|
||||
|
||||
bufp->flags |= BUF_MOD;
|
||||
if (rbufp)
|
||||
__free_ovflpage(hashp, rbufp);
|
||||
if (last_bfp != rbufp)
|
||||
__free_ovflpage(hashp, last_bfp);
|
||||
|
||||
hashp->NKEYS--;
|
||||
return (0);
|
||||
}
|
||||
/*
|
||||
* Returns:
|
||||
* 0 = key not found
|
||||
* -1 = get next overflow page
|
||||
* -2 means key not found and this is big key/data
|
||||
* -3 error
|
||||
*/
|
||||
extern int
|
||||
__find_bigpair(HTAB *hashp, BUFHEAD *bufp, int ndx, char *key, int size)
|
||||
{
|
||||
register uint16 *bp;
|
||||
register char *p;
|
||||
int ksize;
|
||||
uint16 bytes;
|
||||
char *kkey;
|
||||
|
||||
bp = (uint16 *)bufp->page;
|
||||
p = bufp->page;
|
||||
ksize = size;
|
||||
kkey = key;
|
||||
|
||||
for (bytes = hashp->BSIZE - bp[ndx];
|
||||
bytes <= size && bp[ndx + 1] == PARTIAL_KEY;
|
||||
bytes = hashp->BSIZE - bp[ndx]) {
|
||||
if (memcmp(p + bp[ndx], kkey, bytes))
|
||||
return (-2);
|
||||
kkey += bytes;
|
||||
ksize -= bytes;
|
||||
bufp = __get_buf(hashp, bp[ndx + 2], bufp, 0);
|
||||
if (!bufp)
|
||||
return (-3);
|
||||
p = bufp->page;
|
||||
bp = (uint16 *)p;
|
||||
ndx = 1;
|
||||
}
|
||||
|
||||
if (bytes != ksize || memcmp(p + bp[ndx], kkey, bytes)) {
|
||||
#ifdef HASH_STATISTICS
|
||||
++hash_collisions;
|
||||
#endif
|
||||
return (-2);
|
||||
} else
|
||||
return (ndx);
|
||||
}
|
||||
|
||||
/*
|
||||
* Given the buffer pointer of the first overflow page of a big pair,
|
||||
* find the end of the big pair
|
||||
*
|
||||
* This will set bpp to the buffer header of the last page of the big pair.
|
||||
* It will return the pageno of the overflow page following the last page
|
||||
* of the pair; 0 if there isn't any (i.e. big pair is the last key in the
|
||||
* bucket)
|
||||
*/
|
||||
extern uint16
|
||||
__find_last_page(HTAB *hashp, BUFHEAD **bpp)
|
||||
{
|
||||
BUFHEAD *bufp;
|
||||
uint16 *bp, pageno;
|
||||
uint n;
|
||||
|
||||
bufp = *bpp;
|
||||
bp = (uint16 *)bufp->page;
|
||||
for (;;) {
|
||||
n = bp[0];
|
||||
|
||||
/*
|
||||
* This is the last page if: the tag is FULL_KEY_DATA and
|
||||
* either only 2 entries OVFLPAGE marker is explicit there
|
||||
* is freespace on the page.
|
||||
*/
|
||||
if (bp[2] == FULL_KEY_DATA &&
|
||||
((n == 2) || (bp[n] == OVFLPAGE) || (FREESPACE(bp))))
|
||||
break;
|
||||
|
||||
/* LJM bound the size of n to reasonable limits
|
||||
*/
|
||||
if(n > hashp->BSIZE/sizeof(uint16))
|
||||
return(0);
|
||||
|
||||
pageno = bp[n - 1];
|
||||
bufp = __get_buf(hashp, pageno, bufp, 0);
|
||||
if (!bufp)
|
||||
return (0); /* Need to indicate an error! */
|
||||
bp = (uint16 *)bufp->page;
|
||||
}
|
||||
|
||||
*bpp = bufp;
|
||||
if (bp[0] > 2)
|
||||
return (bp[3]);
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the data for the key/data pair that begins on this page at this
|
||||
* index (index should always be 1).
|
||||
*/
|
||||
extern int
|
||||
__big_return(
|
||||
HTAB *hashp,
|
||||
BUFHEAD *bufp,
|
||||
int ndx,
|
||||
DBT *val,
|
||||
int set_current)
|
||||
{
|
||||
BUFHEAD *save_p;
|
||||
uint16 *bp, len, off, save_addr;
|
||||
char *tp;
|
||||
int save_flags;
|
||||
|
||||
bp = (uint16 *)bufp->page;
|
||||
while (bp[ndx + 1] == PARTIAL_KEY) {
|
||||
bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
|
||||
if (!bufp)
|
||||
return (-1);
|
||||
bp = (uint16 *)bufp->page;
|
||||
ndx = 1;
|
||||
}
|
||||
|
||||
if (bp[ndx + 1] == FULL_KEY) {
|
||||
bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
|
||||
if (!bufp)
|
||||
return (-1);
|
||||
bp = (uint16 *)bufp->page;
|
||||
save_p = bufp;
|
||||
save_addr = save_p->addr;
|
||||
off = bp[1];
|
||||
len = 0;
|
||||
} else
|
||||
if (!FREESPACE(bp)) {
|
||||
/*
|
||||
* This is a hack. We can't distinguish between
|
||||
* FULL_KEY_DATA that contains complete data or
|
||||
* incomplete data, so we require that if the data
|
||||
* is complete, there is at least 1 byte of free
|
||||
* space left.
|
||||
*/
|
||||
off = bp[bp[0]];
|
||||
len = bp[1] - off;
|
||||
save_p = bufp;
|
||||
save_addr = bufp->addr;
|
||||
bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
|
||||
if (!bufp)
|
||||
return (-1);
|
||||
bp = (uint16 *)bufp->page;
|
||||
} else {
|
||||
/* The data is all on one page. */
|
||||
tp = (char *)bp;
|
||||
off = bp[bp[0]];
|
||||
val->data = (uint8 *)tp + off;
|
||||
val->size = bp[1] - off;
|
||||
if (set_current) {
|
||||
if (bp[0] == 2) { /* No more buckets in
|
||||
* chain */
|
||||
hashp->cpage = NULL;
|
||||
hashp->cbucket++;
|
||||
hashp->cndx = 1;
|
||||
} else {
|
||||
hashp->cpage = __get_buf(hashp,
|
||||
bp[bp[0] - 1], bufp, 0);
|
||||
if (!hashp->cpage)
|
||||
return (-1);
|
||||
hashp->cndx = 1;
|
||||
if (!((uint16 *)
|
||||
hashp->cpage->page)[0]) {
|
||||
hashp->cbucket++;
|
||||
hashp->cpage = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* pin our saved buf so that we don't lose if
|
||||
* we run out of buffers */
|
||||
save_flags = save_p->flags;
|
||||
save_p->flags |= BUF_PIN;
|
||||
val->size = collect_data(hashp, bufp, (int)len, set_current);
|
||||
save_p->flags = save_flags;
|
||||
if (val->size == (size_t)-1)
|
||||
return (-1);
|
||||
if (save_p->addr != save_addr) {
|
||||
/* We are pretty short on buffers. */
|
||||
errno = EINVAL; /* OUT OF BUFFERS */
|
||||
return (-1);
|
||||
}
|
||||
memmove(hashp->tmp_buf, (save_p->page) + off, len);
|
||||
val->data = (uint8 *)hashp->tmp_buf;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Count how big the total datasize is by looping through the pages. Then
|
||||
* allocate a buffer and copy the data in the second loop. NOTE: Our caller
|
||||
* may already have a bp which it is holding onto. The caller is
|
||||
* responsible for copying that bp into our temp buffer. 'len' is how much
|
||||
* space to reserve for that buffer.
|
||||
*/
|
||||
static int
|
||||
collect_data(
|
||||
HTAB *hashp,
|
||||
BUFHEAD *bufp,
|
||||
int len, int set)
|
||||
{
|
||||
register uint16 *bp;
|
||||
BUFHEAD *save_bufp;
|
||||
int save_flags;
|
||||
int mylen, totlen;
|
||||
|
||||
/*
|
||||
* save the input buf head because we need to walk the list twice.
|
||||
* pin it to make sure it doesn't leave the buffer pool.
|
||||
* This has the effect of growing the buffer pool if necessary.
|
||||
*/
|
||||
save_bufp = bufp;
|
||||
save_flags = save_bufp->flags;
|
||||
save_bufp->flags |= BUF_PIN;
|
||||
|
||||
/* read the length of the buffer */
|
||||
for (totlen = len; bufp ; bufp = __get_buf(hashp, bp[bp[0]-1], bufp, 0)) {
|
||||
bp = (uint16 *)bufp->page;
|
||||
mylen = hashp->BSIZE - bp[1];
|
||||
|
||||
/* if mylen ever goes negative it means that the
|
||||
* page is screwed up.
|
||||
*/
|
||||
if (mylen < 0) {
|
||||
save_bufp->flags = save_flags;
|
||||
return (-1);
|
||||
}
|
||||
totlen += mylen;
|
||||
if (bp[2] == FULL_KEY_DATA) { /* End of Data */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bufp) {
|
||||
save_bufp->flags = save_flags;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* allocate a temp buf */
|
||||
if (hashp->tmp_buf)
|
||||
free(hashp->tmp_buf);
|
||||
if ((hashp->tmp_buf = (char *)malloc((size_t)totlen)) == NULL) {
|
||||
save_bufp->flags = save_flags;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* copy the buffers back into temp buf */
|
||||
for (bufp = save_bufp; bufp ;
|
||||
bufp = __get_buf(hashp, bp[bp[0]-1], bufp, 0)) {
|
||||
bp = (uint16 *)bufp->page;
|
||||
mylen = hashp->BSIZE - bp[1];
|
||||
memmove(&hashp->tmp_buf[len], (bufp->page) + bp[1], (size_t)mylen);
|
||||
len += mylen;
|
||||
if (bp[2] == FULL_KEY_DATA) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* 'clear' the pin flags */
|
||||
save_bufp->flags = save_flags;
|
||||
|
||||
/* update the database cursor */
|
||||
if (set) {
|
||||
hashp->cndx = 1;
|
||||
if (bp[0] == 2) { /* No more buckets in chain */
|
||||
hashp->cpage = NULL;
|
||||
hashp->cbucket++;
|
||||
} else {
|
||||
hashp->cpage = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
|
||||
if (!hashp->cpage)
|
||||
return (-1);
|
||||
else if (!((uint16 *)hashp->cpage->page)[0]) {
|
||||
hashp->cbucket++;
|
||||
hashp->cpage = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (totlen);
|
||||
}
|
||||
|
||||
/*
|
||||
* Fill in the key and data for this big pair.
|
||||
*/
|
||||
extern int
|
||||
__big_keydata(
|
||||
HTAB *hashp,
|
||||
BUFHEAD *bufp,
|
||||
DBT *key, DBT *val,
|
||||
int set)
|
||||
{
|
||||
key->size = collect_key(hashp, bufp, 0, val, set);
|
||||
if (key->size == (size_t)-1)
|
||||
return (-1);
|
||||
key->data = (uint8 *)hashp->tmp_key;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Count how big the total key size is by recursing through the pages. Then
|
||||
* collect the data, allocate a buffer and copy the key as you recurse up.
|
||||
*/
|
||||
static int
|
||||
collect_key(
|
||||
HTAB *hashp,
|
||||
BUFHEAD *bufp,
|
||||
int len,
|
||||
DBT *val,
|
||||
int set)
|
||||
{
|
||||
BUFHEAD *xbp;
|
||||
char *p;
|
||||
int mylen, totlen;
|
||||
uint16 *bp, save_addr;
|
||||
|
||||
p = bufp->page;
|
||||
bp = (uint16 *)p;
|
||||
mylen = hashp->BSIZE - bp[1];
|
||||
|
||||
save_addr = bufp->addr;
|
||||
totlen = len + mylen;
|
||||
if (bp[2] == FULL_KEY || bp[2] == FULL_KEY_DATA) { /* End of Key. */
|
||||
if (hashp->tmp_key != NULL)
|
||||
free(hashp->tmp_key);
|
||||
if ((hashp->tmp_key = (char *)malloc((size_t)totlen)) == NULL)
|
||||
return (-1);
|
||||
if (__big_return(hashp, bufp, 1, val, set))
|
||||
return (-1);
|
||||
} else {
|
||||
xbp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
|
||||
if (!xbp || ((totlen =
|
||||
collect_key(hashp, xbp, totlen, val, set)) < 1))
|
||||
return (-1);
|
||||
}
|
||||
if (bufp->addr != save_addr) {
|
||||
errno = EINVAL; /* MIS -- OUT OF BUFFERS */
|
||||
return (-1);
|
||||
}
|
||||
memmove(&hashp->tmp_key[len], (bufp->page) + bp[1], (size_t)mylen);
|
||||
return (totlen);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns:
|
||||
* 0 => OK
|
||||
* -1 => error
|
||||
*/
|
||||
extern int
|
||||
__big_split(
|
||||
HTAB *hashp,
|
||||
BUFHEAD *op, /* Pointer to where to put keys that go in old bucket */
|
||||
BUFHEAD *np, /* Pointer to new bucket page */
|
||||
/* Pointer to first page containing the big key/data */
|
||||
BUFHEAD *big_keyp,
|
||||
uint32 addr, /* Address of big_keyp */
|
||||
uint32 obucket,/* Old Bucket */
|
||||
SPLIT_RETURN *ret)
|
||||
{
|
||||
register BUFHEAD *tmpp;
|
||||
register uint16 *tp;
|
||||
BUFHEAD *bp;
|
||||
DBT key, val;
|
||||
uint32 change;
|
||||
uint16 free_space, n, off;
|
||||
|
||||
bp = big_keyp;
|
||||
|
||||
/* Now figure out where the big key/data goes */
|
||||
if (__big_keydata(hashp, big_keyp, &key, &val, 0))
|
||||
return (-1);
|
||||
change = (__call_hash(hashp,(char*) key.data, key.size) != obucket);
|
||||
|
||||
if ((ret->next_addr = __find_last_page(hashp, &big_keyp))) {
|
||||
if (!(ret->nextp =
|
||||
__get_buf(hashp, ret->next_addr, big_keyp, 0)))
|
||||
return (-1);;
|
||||
} else
|
||||
ret->nextp = NULL;
|
||||
|
||||
/* Now make one of np/op point to the big key/data pair */
|
||||
#ifdef DEBUG
|
||||
assert(np->ovfl == NULL);
|
||||
#endif
|
||||
if (change)
|
||||
tmpp = np;
|
||||
else
|
||||
tmpp = op;
|
||||
|
||||
tmpp->flags |= BUF_MOD;
|
||||
#ifdef DEBUG1
|
||||
(void)fprintf(stderr,
|
||||
"BIG_SPLIT: %d->ovfl was %d is now %d\n", tmpp->addr,
|
||||
(tmpp->ovfl ? tmpp->ovfl->addr : 0), (bp ? bp->addr : 0));
|
||||
#endif
|
||||
tmpp->ovfl = bp; /* one of op/np point to big_keyp */
|
||||
tp = (uint16 *)tmpp->page;
|
||||
|
||||
|
||||
#if 0 /* this get's tripped on database corrupted error */
|
||||
assert(FREESPACE(tp) >= OVFLSIZE);
|
||||
#endif
|
||||
if(FREESPACE(tp) < OVFLSIZE)
|
||||
return(DATABASE_CORRUPTED_ERROR);
|
||||
|
||||
n = tp[0];
|
||||
off = OFFSET(tp);
|
||||
free_space = FREESPACE(tp);
|
||||
tp[++n] = (uint16)addr;
|
||||
tp[++n] = OVFLPAGE;
|
||||
tp[0] = n;
|
||||
OFFSET(tp) = off;
|
||||
FREESPACE(tp) = free_space - OVFLSIZE;
|
||||
|
||||
/*
|
||||
* Finally, set the new and old return values. BIG_KEYP contains a
|
||||
* pointer to the last page of the big key_data pair. Make sure that
|
||||
* big_keyp has no following page (2 elements) or create an empty
|
||||
* following page.
|
||||
*/
|
||||
|
||||
ret->newp = np;
|
||||
ret->oldp = op;
|
||||
|
||||
tp = (uint16 *)big_keyp->page;
|
||||
big_keyp->flags |= BUF_MOD;
|
||||
if (tp[0] > 2) {
|
||||
/*
|
||||
* There may be either one or two offsets on this page. If
|
||||
* there is one, then the overflow page is linked on normally
|
||||
* and tp[4] is OVFLPAGE. If there are two, tp[4] contains
|
||||
* the second offset and needs to get stuffed in after the
|
||||
* next overflow page is added.
|
||||
*/
|
||||
n = tp[4];
|
||||
free_space = FREESPACE(tp);
|
||||
off = OFFSET(tp);
|
||||
tp[0] -= 2;
|
||||
FREESPACE(tp) = free_space + OVFLSIZE;
|
||||
OFFSET(tp) = off;
|
||||
tmpp = __add_ovflpage(hashp, big_keyp);
|
||||
if (!tmpp)
|
||||
return (-1);
|
||||
tp[4] = n;
|
||||
} else
|
||||
tmpp = big_keyp;
|
||||
|
||||
if (change)
|
||||
ret->newp = tmpp;
|
||||
else
|
||||
ret->oldp = tmpp;
|
||||
return (0);
|
||||
}
|
||||
@@ -1,209 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Margo Seltzer.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. ***REMOVED*** - see
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)hash_func.c 8.2 (Berkeley) 2/21/94";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "watcomfx.h"
|
||||
|
||||
#ifndef macintosh
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#include "mcom_db.h"
|
||||
#include "hash.h"
|
||||
#include "page.h"
|
||||
/* #include "extern.h" */
|
||||
|
||||
#if 0
|
||||
static uint32 hash1 __P((const void *, size_t));
|
||||
static uint32 hash2 __P((const void *, size_t));
|
||||
static uint32 hash3 __P((const void *, size_t));
|
||||
#endif
|
||||
static uint32 hash4 __P((const void *, size_t));
|
||||
|
||||
/* Global default hash function */
|
||||
uint32 (*__default_hash) __P((const void *, size_t)) = hash4;
|
||||
|
||||
/*
|
||||
* HASH FUNCTIONS
|
||||
*
|
||||
* Assume that we've already split the bucket to which this key hashes,
|
||||
* calculate that bucket, and check that in fact we did already split it.
|
||||
*
|
||||
* This came from ejb's hsearch.
|
||||
*/
|
||||
|
||||
#define PRIME1 37
|
||||
#define PRIME2 1048583
|
||||
|
||||
#if 0
|
||||
static uint32
|
||||
hash1(const void *keyarg, register size_t len)
|
||||
{
|
||||
register const uint8 *key;
|
||||
register uint32 h;
|
||||
|
||||
/* Convert string to integer */
|
||||
for (key = (const uint8 *)keyarg, h = 0; len--;)
|
||||
h = h * PRIME1 ^ (*key++ - ' ');
|
||||
h %= PRIME2;
|
||||
return (h);
|
||||
}
|
||||
|
||||
/*
|
||||
* Phong's linear congruential hash
|
||||
*/
|
||||
#define dcharhash(h, c) ((h) = 0x63c63cd9*(h) + 0x9c39c33d + (c))
|
||||
|
||||
static uint32
|
||||
hash2(const void *keyarg, size_t len)
|
||||
{
|
||||
register const uint8 *e, *key;
|
||||
register uint32 h;
|
||||
register uint8 c;
|
||||
|
||||
key = (const uint8 *)keyarg;
|
||||
e = key + len;
|
||||
for (h = 0; key != e;) {
|
||||
c = *key++;
|
||||
if (!c && key > e)
|
||||
break;
|
||||
dcharhash(h, c);
|
||||
}
|
||||
return (h);
|
||||
}
|
||||
|
||||
/*
|
||||
* This is INCREDIBLY ugly, but fast. We break the string up into 8 byte
|
||||
* units. On the first time through the loop we get the "leftover bytes"
|
||||
* (strlen % 8). On every other iteration, we perform 8 HASHC's so we handle
|
||||
* all 8 bytes. Essentially, this saves us 7 cmp & branch instructions. If
|
||||
* this routine is heavily used enough, it's worth the ugly coding.
|
||||
*
|
||||
* OZ's original sdbm hash
|
||||
*/
|
||||
static uint32
|
||||
hash3(const void *keyarg, register size_t len)
|
||||
{
|
||||
register const uint8 *key;
|
||||
register size_t loop;
|
||||
register uint32 h;
|
||||
|
||||
#define HASHC h = *key++ + 65599 * h
|
||||
|
||||
h = 0;
|
||||
key = (const uint8 *)keyarg;
|
||||
if (len > 0) {
|
||||
loop = (len + 8 - 1) >> 3;
|
||||
|
||||
switch (len & (8 - 1)) {
|
||||
case 0:
|
||||
do {
|
||||
HASHC;
|
||||
/* FALLTHROUGH */
|
||||
case 7:
|
||||
HASHC;
|
||||
/* FALLTHROUGH */
|
||||
case 6:
|
||||
HASHC;
|
||||
/* FALLTHROUGH */
|
||||
case 5:
|
||||
HASHC;
|
||||
/* FALLTHROUGH */
|
||||
case 4:
|
||||
HASHC;
|
||||
/* FALLTHROUGH */
|
||||
case 3:
|
||||
HASHC;
|
||||
/* FALLTHROUGH */
|
||||
case 2:
|
||||
HASHC;
|
||||
/* FALLTHROUGH */
|
||||
case 1:
|
||||
HASHC;
|
||||
} while (--loop);
|
||||
}
|
||||
}
|
||||
return (h);
|
||||
}
|
||||
#endif /* 0 */
|
||||
|
||||
/* Hash function from Chris Torek. */
|
||||
static uint32
|
||||
hash4(const void *keyarg, register size_t len)
|
||||
{
|
||||
register const uint8 *key;
|
||||
register size_t loop;
|
||||
register uint32 h;
|
||||
|
||||
#define HASH4a h = (h << 5) - h + *key++;
|
||||
#define HASH4b h = (h << 5) + h + *key++;
|
||||
#define HASH4 HASH4b
|
||||
|
||||
h = 0;
|
||||
key = (const uint8 *)keyarg;
|
||||
if (len > 0) {
|
||||
loop = (len + 8 - 1) >> 3;
|
||||
|
||||
switch (len & (8 - 1)) {
|
||||
case 0:
|
||||
do {
|
||||
HASH4;
|
||||
/* FALLTHROUGH */
|
||||
case 7:
|
||||
HASH4;
|
||||
/* FALLTHROUGH */
|
||||
case 6:
|
||||
HASH4;
|
||||
/* FALLTHROUGH */
|
||||
case 5:
|
||||
HASH4;
|
||||
/* FALLTHROUGH */
|
||||
case 4:
|
||||
HASH4;
|
||||
/* FALLTHROUGH */
|
||||
case 3:
|
||||
HASH4;
|
||||
/* FALLTHROUGH */
|
||||
case 2:
|
||||
HASH4;
|
||||
/* FALLTHROUGH */
|
||||
case 1:
|
||||
HASH4;
|
||||
} while (--loop);
|
||||
}
|
||||
}
|
||||
return (h);
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Margo Seltzer.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. ***REMOVED*** - see
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)hash_log2.c 8.2 (Berkeley) 5/31/94";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "watcomfx.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#ifndef macintosh
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#include "mcom_db.h"
|
||||
|
||||
uint32 __log2(uint32 num)
|
||||
{
|
||||
register uint32 i, limit;
|
||||
|
||||
limit = 1;
|
||||
for (i = 0; limit < num; limit = limit << 1, i++) {}
|
||||
return (i);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,412 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Margo Seltzer.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. ***REMOVED*** - see
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)hash_buf.c 8.5 (Berkeley) 7/15/94";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "watcomfx.h"
|
||||
|
||||
/*
|
||||
* PACKAGE: hash
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* Contains buffer management
|
||||
*
|
||||
* ROUTINES:
|
||||
* External
|
||||
* __buf_init
|
||||
* __get_buf
|
||||
* __buf_free
|
||||
* __reclaim_buf
|
||||
* Internal
|
||||
* newbuf
|
||||
*/
|
||||
#if !defined(_WIN32) && !defined(_WINDOWS) && !defined(macintosh) && !defined(XP_OS2_VACPP)
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef DEBUG
|
||||
#include <assert.h>
|
||||
#endif
|
||||
|
||||
#include "mcom_db.h"
|
||||
#include "hash.h"
|
||||
#include "page.h"
|
||||
/* #include "extern.h" */
|
||||
|
||||
static BUFHEAD *newbuf __P((HTAB *, uint32, BUFHEAD *));
|
||||
|
||||
/* Unlink B from its place in the lru */
|
||||
#define BUF_REMOVE(B) { \
|
||||
(B)->prev->next = (B)->next; \
|
||||
(B)->next->prev = (B)->prev; \
|
||||
}
|
||||
|
||||
/* Insert B after P */
|
||||
#define BUF_INSERT(B, P) { \
|
||||
(B)->next = (P)->next; \
|
||||
(B)->prev = (P); \
|
||||
(P)->next = (B); \
|
||||
(B)->next->prev = (B); \
|
||||
}
|
||||
|
||||
#define MRU hashp->bufhead.next
|
||||
#define LRU hashp->bufhead.prev
|
||||
|
||||
#define MRU_INSERT(B) BUF_INSERT((B), &hashp->bufhead)
|
||||
#define LRU_INSERT(B) BUF_INSERT((B), LRU)
|
||||
|
||||
/*
|
||||
* We are looking for a buffer with address "addr". If prev_bp is NULL, then
|
||||
* address is a bucket index. If prev_bp is not NULL, then it points to the
|
||||
* page previous to an overflow page that we are trying to find.
|
||||
*
|
||||
* CAVEAT: The buffer header accessed via prev_bp's ovfl field may no longer
|
||||
* be valid. Therefore, you must always verify that its address matches the
|
||||
* address you are seeking.
|
||||
*/
|
||||
extern BUFHEAD *
|
||||
__get_buf(HTAB *hashp, uint32 addr, BUFHEAD *prev_bp, int newpage)
|
||||
/* If prev_bp set, indicates a new overflow page. */
|
||||
{
|
||||
register BUFHEAD *bp;
|
||||
register uint32 is_disk_mask;
|
||||
register int is_disk, segment_ndx = 0;
|
||||
SEGMENT segp = 0;
|
||||
|
||||
is_disk = 0;
|
||||
is_disk_mask = 0;
|
||||
if (prev_bp) {
|
||||
bp = prev_bp->ovfl;
|
||||
if (!bp || (bp->addr != addr))
|
||||
bp = NULL;
|
||||
if (!newpage)
|
||||
is_disk = BUF_DISK;
|
||||
} else {
|
||||
/* Grab buffer out of directory */
|
||||
segment_ndx = addr & (hashp->SGSIZE - 1);
|
||||
|
||||
/* valid segment ensured by __call_hash() */
|
||||
segp = hashp->dir[addr >> hashp->SSHIFT];
|
||||
#ifdef DEBUG
|
||||
assert(segp != NULL);
|
||||
#endif
|
||||
|
||||
bp = PTROF(segp[segment_ndx]);
|
||||
|
||||
is_disk_mask = ISDISK(segp[segment_ndx]);
|
||||
is_disk = is_disk_mask || !hashp->new_file;
|
||||
}
|
||||
|
||||
if (!bp) {
|
||||
bp = newbuf(hashp, addr, prev_bp);
|
||||
if (!bp)
|
||||
return(NULL);
|
||||
if(__get_page(hashp, bp->page, addr, !prev_bp, is_disk, 0))
|
||||
{
|
||||
/* free bp and its page */
|
||||
if(prev_bp)
|
||||
{
|
||||
/* if prev_bp is set then the new page that
|
||||
* failed is hooked onto prev_bp as an overflow page.
|
||||
* if we don't remove the pointer to the bad page
|
||||
* we may try and access it later and we will die
|
||||
* horribly because it will have already been
|
||||
* free'd and overwritten with bogus data.
|
||||
*/
|
||||
prev_bp->ovfl = NULL;
|
||||
}
|
||||
BUF_REMOVE(bp);
|
||||
free(bp->page);
|
||||
free(bp);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if (!prev_bp)
|
||||
{
|
||||
#if 0
|
||||
/* 16 bit windows and mac can't handle the
|
||||
* oring of the is disk flag.
|
||||
*/
|
||||
segp[segment_ndx] =
|
||||
(BUFHEAD *)((ptrdiff_t)bp | is_disk_mask);
|
||||
#else
|
||||
/* set the is_disk thing inside the structure
|
||||
*/
|
||||
bp->is_disk = is_disk_mask;
|
||||
segp[segment_ndx] = bp;
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
BUF_REMOVE(bp);
|
||||
MRU_INSERT(bp);
|
||||
}
|
||||
return (bp);
|
||||
}
|
||||
|
||||
/*
|
||||
* We need a buffer for this page. Either allocate one, or evict a resident
|
||||
* one (if we have as many buffers as we're allowed) and put this one in.
|
||||
*
|
||||
* If newbuf finds an error (returning NULL), it also sets errno.
|
||||
*/
|
||||
static BUFHEAD *
|
||||
newbuf(HTAB *hashp, uint32 addr, BUFHEAD *prev_bp)
|
||||
{
|
||||
register BUFHEAD *bp; /* The buffer we're going to use */
|
||||
register BUFHEAD *xbp; /* Temp pointer */
|
||||
register BUFHEAD *next_xbp;
|
||||
SEGMENT segp;
|
||||
int segment_ndx;
|
||||
uint16 oaddr, *shortp;
|
||||
|
||||
oaddr = 0;
|
||||
bp = LRU;
|
||||
/*
|
||||
* If LRU buffer is pinned, the buffer pool is too small. We need to
|
||||
* allocate more buffers.
|
||||
*/
|
||||
if (hashp->nbufs || (bp->flags & BUF_PIN)) {
|
||||
/* Allocate a new one */
|
||||
if ((bp = (BUFHEAD *)malloc(sizeof(BUFHEAD))) == NULL)
|
||||
return (NULL);
|
||||
|
||||
/* this memset is supposedly unnecessary but lets add
|
||||
* it anyways.
|
||||
*/
|
||||
memset(bp, 0xff, sizeof(BUFHEAD));
|
||||
|
||||
if ((bp->page = (char *)malloc((size_t)hashp->BSIZE)) == NULL) {
|
||||
free(bp);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* this memset is supposedly unnecessary but lets add
|
||||
* it anyways.
|
||||
*/
|
||||
memset(bp->page, 0xff, (size_t)hashp->BSIZE);
|
||||
|
||||
if (hashp->nbufs)
|
||||
hashp->nbufs--;
|
||||
} else {
|
||||
/* Kick someone out */
|
||||
BUF_REMOVE(bp);
|
||||
/*
|
||||
* If this is an overflow page with addr 0, it's already been
|
||||
* flushed back in an overflow chain and initialized.
|
||||
*/
|
||||
if ((bp->addr != 0) || (bp->flags & BUF_BUCKET)) {
|
||||
/*
|
||||
* Set oaddr before __put_page so that you get it
|
||||
* before bytes are swapped.
|
||||
*/
|
||||
shortp = (uint16 *)bp->page;
|
||||
if (shortp[0])
|
||||
{
|
||||
if(shortp[0] > (hashp->BSIZE / sizeof(uint16)))
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
oaddr = shortp[shortp[0] - 1];
|
||||
}
|
||||
if ((bp->flags & BUF_MOD) && __put_page(hashp, bp->page,
|
||||
bp->addr, (int)IS_BUCKET(bp->flags), 0))
|
||||
return (NULL);
|
||||
/*
|
||||
* Update the pointer to this page (i.e. invalidate it).
|
||||
*
|
||||
* If this is a new file (i.e. we created it at open
|
||||
* time), make sure that we mark pages which have been
|
||||
* written to disk so we retrieve them from disk later,
|
||||
* rather than allocating new pages.
|
||||
*/
|
||||
if (IS_BUCKET(bp->flags)) {
|
||||
segment_ndx = bp->addr & (hashp->SGSIZE - 1);
|
||||
segp = hashp->dir[bp->addr >> hashp->SSHIFT];
|
||||
#ifdef DEBUG
|
||||
assert(segp != NULL);
|
||||
#endif
|
||||
|
||||
if (hashp->new_file &&
|
||||
((bp->flags & BUF_MOD) ||
|
||||
ISDISK(segp[segment_ndx])))
|
||||
segp[segment_ndx] = (BUFHEAD *)BUF_DISK;
|
||||
else
|
||||
segp[segment_ndx] = NULL;
|
||||
}
|
||||
/*
|
||||
* Since overflow pages can only be access by means of
|
||||
* their bucket, free overflow pages associated with
|
||||
* this bucket.
|
||||
*/
|
||||
for (xbp = bp; xbp->ovfl;) {
|
||||
next_xbp = xbp->ovfl;
|
||||
xbp->ovfl = 0;
|
||||
xbp = next_xbp;
|
||||
|
||||
/* leave pinned pages alone, we are still using
|
||||
* them. */
|
||||
if (xbp->flags & BUF_PIN) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Check that ovfl pointer is up date. */
|
||||
if (IS_BUCKET(xbp->flags) ||
|
||||
(oaddr != xbp->addr))
|
||||
break;
|
||||
|
||||
shortp = (uint16 *)xbp->page;
|
||||
if (shortp[0])
|
||||
{
|
||||
/* LJM is the number of reported
|
||||
* pages way too much?
|
||||
*/
|
||||
if(shortp[0] > hashp->BSIZE/sizeof(uint16))
|
||||
return NULL;
|
||||
/* set before __put_page */
|
||||
oaddr = shortp[shortp[0] - 1];
|
||||
}
|
||||
if ((xbp->flags & BUF_MOD) && __put_page(hashp,
|
||||
xbp->page, xbp->addr, 0, 0))
|
||||
return (NULL);
|
||||
xbp->addr = 0;
|
||||
xbp->flags = 0;
|
||||
BUF_REMOVE(xbp);
|
||||
LRU_INSERT(xbp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Now assign this buffer */
|
||||
bp->addr = addr;
|
||||
#ifdef DEBUG1
|
||||
(void)fprintf(stderr, "NEWBUF1: %d->ovfl was %d is now %d\n",
|
||||
bp->addr, (bp->ovfl ? bp->ovfl->addr : 0), 0);
|
||||
#endif
|
||||
bp->ovfl = NULL;
|
||||
if (prev_bp) {
|
||||
/*
|
||||
* If prev_bp is set, this is an overflow page, hook it in to
|
||||
* the buffer overflow links.
|
||||
*/
|
||||
#ifdef DEBUG1
|
||||
(void)fprintf(stderr, "NEWBUF2: %d->ovfl was %d is now %d\n",
|
||||
prev_bp->addr, (prev_bp->ovfl ? bp->ovfl->addr : 0),
|
||||
(bp ? bp->addr : 0));
|
||||
#endif
|
||||
prev_bp->ovfl = bp;
|
||||
bp->flags = 0;
|
||||
} else
|
||||
bp->flags = BUF_BUCKET;
|
||||
MRU_INSERT(bp);
|
||||
return (bp);
|
||||
}
|
||||
|
||||
extern void __buf_init(HTAB *hashp, int32 nbytes)
|
||||
{
|
||||
BUFHEAD *bfp;
|
||||
int npages;
|
||||
|
||||
bfp = &(hashp->bufhead);
|
||||
npages = (nbytes + hashp->BSIZE - 1) >> hashp->BSHIFT;
|
||||
npages = PR_MAX(npages, MIN_BUFFERS);
|
||||
|
||||
hashp->nbufs = npages;
|
||||
bfp->next = bfp;
|
||||
bfp->prev = bfp;
|
||||
/*
|
||||
* This space is calloc'd so these are already null.
|
||||
*
|
||||
* bfp->ovfl = NULL;
|
||||
* bfp->flags = 0;
|
||||
* bfp->page = NULL;
|
||||
* bfp->addr = 0;
|
||||
*/
|
||||
}
|
||||
|
||||
extern int
|
||||
__buf_free(HTAB *hashp, int do_free, int to_disk)
|
||||
{
|
||||
BUFHEAD *bp;
|
||||
int status = -1;
|
||||
|
||||
/* Need to make sure that buffer manager has been initialized */
|
||||
if (!LRU)
|
||||
return (0);
|
||||
for (bp = LRU; bp != &hashp->bufhead;) {
|
||||
/* Check that the buffer is valid */
|
||||
if (bp->addr || IS_BUCKET(bp->flags)) {
|
||||
if (to_disk && (bp->flags & BUF_MOD) &&
|
||||
(status = __put_page(hashp, bp->page,
|
||||
bp->addr, IS_BUCKET(bp->flags), 0))) {
|
||||
|
||||
if (do_free) {
|
||||
if (bp->page)
|
||||
free(bp->page);
|
||||
BUF_REMOVE(bp);
|
||||
free(bp);
|
||||
}
|
||||
|
||||
return (status);
|
||||
}
|
||||
}
|
||||
/* Check if we are freeing stuff */
|
||||
if (do_free) {
|
||||
if (bp->page)
|
||||
free(bp->page);
|
||||
BUF_REMOVE(bp);
|
||||
free(bp);
|
||||
bp = LRU;
|
||||
} else
|
||||
bp = bp->prev;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
extern void
|
||||
__reclaim_buf(HTAB *hashp, BUFHEAD *bp)
|
||||
{
|
||||
bp->ovfl = 0;
|
||||
bp->addr = 0;
|
||||
bp->flags = 0;
|
||||
BUF_REMOVE(bp);
|
||||
LRU_INSERT(bp);
|
||||
}
|
||||
@@ -1,148 +0,0 @@
|
||||
#if defined(__sun) && !defined(__SVR4)
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Chris Torek.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. ***REMOVED*** - see
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)bcopy.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "watcomfx.h"
|
||||
|
||||
#ifdef HAVE_SYS_CDEFS_H
|
||||
#include <sys/cdefs.h>
|
||||
#else
|
||||
#include "cdefs.h"
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* sizeof(word) MUST BE A POWER OF TWO
|
||||
* SO THAT wmask BELOW IS ALL ONES
|
||||
*/
|
||||
typedef int word; /* "word" used for optimal copy speed */
|
||||
|
||||
#define wsize sizeof(word)
|
||||
#define wmask (wsize - 1)
|
||||
|
||||
/*
|
||||
* Copy a block of memory, handling overlap.
|
||||
* This is the routine that actually implements
|
||||
* (the portable versions of) bcopy, memcpy, and memmove.
|
||||
*/
|
||||
#ifdef MEMCOPY
|
||||
void *
|
||||
memcpy(dst0, src0, length)
|
||||
#else
|
||||
#ifdef MEMMOVE
|
||||
void *
|
||||
memmove(dst0, src0, length)
|
||||
#else
|
||||
void
|
||||
bcopy(src0, dst0, length)
|
||||
#endif
|
||||
#endif
|
||||
void *dst0;
|
||||
const void *src0;
|
||||
register size_t length;
|
||||
{
|
||||
register char *dst = dst0;
|
||||
register const char *src = src0;
|
||||
register size_t t;
|
||||
|
||||
if (length == 0 || dst == src) /* nothing to do */
|
||||
goto done;
|
||||
|
||||
/*
|
||||
* Macros: loop-t-times; and loop-t-times, t>0
|
||||
*/
|
||||
#define TLOOP(s) if (t) TLOOP1(s)
|
||||
#define TLOOP1(s) do { s; } while (--t)
|
||||
|
||||
if ((unsigned long)dst < (unsigned long)src) {
|
||||
/*
|
||||
* Copy forward.
|
||||
*/
|
||||
t = (int)src; /* only need low bits */
|
||||
if ((t | (int)dst) & wmask) {
|
||||
/*
|
||||
* Try to align operands. This cannot be done
|
||||
* unless the low bits match.
|
||||
*/
|
||||
if ((t ^ (int)dst) & wmask || length < wsize)
|
||||
t = length;
|
||||
else
|
||||
t = wsize - (t & wmask);
|
||||
length -= t;
|
||||
TLOOP1(*dst++ = *src++);
|
||||
}
|
||||
/*
|
||||
* Copy whole words, then mop up any trailing bytes.
|
||||
*/
|
||||
t = length / wsize;
|
||||
TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize);
|
||||
t = length & wmask;
|
||||
TLOOP(*dst++ = *src++);
|
||||
} else {
|
||||
/*
|
||||
* Copy backwards. Otherwise essentially the same.
|
||||
* Alignment works as before, except that it takes
|
||||
* (t&wmask) bytes to align, not wsize-(t&wmask).
|
||||
*/
|
||||
src += length;
|
||||
dst += length;
|
||||
t = (int)src;
|
||||
if ((t | (int)dst) & wmask) {
|
||||
if ((t ^ (int)dst) & wmask || length <= wsize)
|
||||
t = length;
|
||||
else
|
||||
t &= wmask;
|
||||
length -= t;
|
||||
TLOOP1(*--dst = *--src);
|
||||
}
|
||||
t = length / wsize;
|
||||
TLOOP(src -= wsize; dst -= wsize; *(word *)dst = *(word *)src);
|
||||
t = length & wmask;
|
||||
TLOOP(*--dst = *--src);
|
||||
}
|
||||
done:
|
||||
#if defined(MEMCOPY) || defined(MEMMOVE)
|
||||
return (dst0);
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
#endif /* no __sgi */
|
||||
|
||||
/* Some compilers don't like an empty source file. */
|
||||
static int dummy = 0;
|
||||
@@ -1,164 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. ***REMOVED*** - see
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)mktemp.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "watcomfx.h"
|
||||
|
||||
#ifdef macintosh
|
||||
#include <unix.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include "mcom_db.h"
|
||||
|
||||
#if !defined(_WINDOWS) && !defined(XP_OS2_VACPP)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef XP_OS2_VACPP
|
||||
#include <process.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include <process.h>
|
||||
#include "winfile.h"
|
||||
#endif
|
||||
|
||||
static int _gettemp(char *path, register int *doopen, int extraFlags);
|
||||
|
||||
int
|
||||
mkstemp(char *path)
|
||||
{
|
||||
#ifdef XP_OS2
|
||||
FILE *temp = tmpfile();
|
||||
|
||||
return (temp ? fileno(temp) : -1);
|
||||
#else
|
||||
int fd;
|
||||
|
||||
return (_gettemp(path, &fd, 0) ? fd : -1);
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
mkstempflags(char *path, int extraFlags)
|
||||
{
|
||||
int fd;
|
||||
|
||||
return (_gettemp(path, &fd, extraFlags) ? fd : -1);
|
||||
}
|
||||
|
||||
char *
|
||||
mktemp(char *path)
|
||||
{
|
||||
return(_gettemp(path, (int *)NULL, 0) ? path : (char *)NULL);
|
||||
}
|
||||
|
||||
/* NB: This routine modifies its input string, and does not always restore it.
|
||||
** returns 1 on success, 0 on failure.
|
||||
*/
|
||||
static int
|
||||
_gettemp(char *path, register int *doopen, int extraFlags)
|
||||
{
|
||||
#if !defined(_WINDOWS) || defined(_WIN32)
|
||||
extern int errno;
|
||||
#endif
|
||||
register char *start, *trv;
|
||||
struct stat sbuf;
|
||||
unsigned int pid;
|
||||
|
||||
pid = getpid();
|
||||
for (trv = path; *trv; ++trv); /* extra X's get set to 0's */
|
||||
while (*--trv == 'X') {
|
||||
*trv = (pid % 10) + '0';
|
||||
pid /= 10;
|
||||
}
|
||||
|
||||
/*
|
||||
* check the target directory; if you have six X's and it
|
||||
* doesn't exist this runs for a *very* long time.
|
||||
*/
|
||||
for (start = trv + 1;; --trv) {
|
||||
char saved;
|
||||
if (trv <= path)
|
||||
break;
|
||||
saved = *trv;
|
||||
if (saved == '/' || saved == '\\') {
|
||||
int rv;
|
||||
*trv = '\0';
|
||||
rv = stat(path, &sbuf);
|
||||
*trv = saved;
|
||||
if (rv)
|
||||
return(0);
|
||||
if (!S_ISDIR(sbuf.st_mode)) {
|
||||
errno = ENOTDIR;
|
||||
return(0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
if (doopen) {
|
||||
if ((*doopen =
|
||||
open(path, O_CREAT|O_EXCL|O_RDWR|extraFlags, 0600)) >= 0)
|
||||
return(1);
|
||||
if (errno != EEXIST)
|
||||
return(0);
|
||||
}
|
||||
else if (stat(path, &sbuf))
|
||||
return(errno == ENOENT ? 1 : 0);
|
||||
|
||||
/* tricky little algorithm for backward compatibility */
|
||||
for (trv = start;;) {
|
||||
if (!*trv)
|
||||
return(0);
|
||||
if (*trv == 'z')
|
||||
*trv++ = 'a';
|
||||
else {
|
||||
if (isdigit(*trv))
|
||||
*trv = 'a';
|
||||
else
|
||||
++*trv;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
#ifndef HAVE_SNPRINTF
|
||||
|
||||
#include "watcomfx.h"
|
||||
#include <sys/types.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef HAVE_SYS_CDEFS_H
|
||||
#include <sys/cdefs.h>
|
||||
#else
|
||||
#include "cdefs.h"
|
||||
#endif
|
||||
|
||||
#include "prtypes.h"
|
||||
|
||||
#include <ncompat.h>
|
||||
|
||||
/* The OS/2 VAC compiler doesn't appear to define __STDC__ and won't let us define it either */
|
||||
#if defined(__STDC__) || defined(XP_OS2_VACPP)
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
int
|
||||
#if defined(__STDC__) || defined(XP_OS2_VACPP)
|
||||
snprintf(char *str, size_t n, const char *fmt, ...)
|
||||
#else
|
||||
snprintf(str, n, fmt, va_alist)
|
||||
char *str;
|
||||
size_t n;
|
||||
const char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
#ifdef VSPRINTF_CHARSTAR
|
||||
char *rp;
|
||||
#else
|
||||
int rval;
|
||||
#endif
|
||||
#if defined(__STDC__) || defined(XP_OS2_VACPP)
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
va_start(ap);
|
||||
#endif
|
||||
#ifdef VSPRINTF_CHARSTAR
|
||||
rp = vsprintf(str, fmt, ap);
|
||||
va_end(ap);
|
||||
return (strlen(rp));
|
||||
#else
|
||||
rval = vsprintf(str, fmt, ap);
|
||||
va_end(ap);
|
||||
return (rval);
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
vsnprintf(str, n, fmt, ap)
|
||||
char *str;
|
||||
size_t n;
|
||||
const char *fmt;
|
||||
va_list ap;
|
||||
{
|
||||
#ifdef VSPRINTF_CHARSTAR
|
||||
return (strlen(vsprintf(str, fmt, ap)));
|
||||
#else
|
||||
return (vsprintf(str, fmt, ap));
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* HAVE_SNPRINTF */
|
||||
|
||||
/* Some compilers don't like an empty source file. */
|
||||
static int dummy = 0;
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1988, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. ***REMOVED*** - see
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)strerror.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "watcomfx.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _DLL
|
||||
#define sys_nerr (*_sys_nerr_dll)
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRERROR
|
||||
#ifndef _AFXDLL
|
||||
char *
|
||||
strerror(num)
|
||||
int num;
|
||||
{
|
||||
extern int sys_nerr;
|
||||
extern char *sys_errlist[];
|
||||
#define UPREFIX "Unknown error: "
|
||||
static char ebuf[40] = UPREFIX; /* 64-bit number + slop */
|
||||
register unsigned int errnum;
|
||||
register char *p, *t;
|
||||
char tmp[40];
|
||||
|
||||
errnum = num; /* convert to unsigned */
|
||||
if (errnum < sys_nerr)
|
||||
return(sys_errlist[errnum]);
|
||||
|
||||
/* Do this by hand, so we don't include stdio(3). */
|
||||
t = tmp;
|
||||
do {
|
||||
*t++ = "0123456789"[errnum % 10];
|
||||
} while (errnum /= 10);
|
||||
for (p = ebuf + sizeof(UPREFIX) - 1;;) {
|
||||
*p++ = *--t;
|
||||
if (t <= tmp)
|
||||
break;
|
||||
}
|
||||
return(ebuf);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* !HAVE_STRERROR */
|
||||
@@ -1,62 +0,0 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = dbm
|
||||
|
||||
PACKAGE_FILE = dbmtest.pkg
|
||||
|
||||
PROGRAM = lots$(BIN_SUFFIX)
|
||||
|
||||
CSRCS = lots.c
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
EXTRA_DSO_LIBS = dbm$(MOZ_BITS)
|
||||
else
|
||||
EXTRA_DSO_LIBS = mozdbm_s
|
||||
endif
|
||||
|
||||
LIBS = $(EXTRA_DSO_LIBS)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
[gecko-tests]
|
||||
dist/bin/lots@BINS@
|
||||
@@ -1,638 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* use sequental numbers printed to strings
|
||||
* to store lots and lots of entries in the
|
||||
* database.
|
||||
*
|
||||
* Start with 100 entries, put them and then
|
||||
* read them out. Then delete the first
|
||||
* half and verify that all of the first half
|
||||
* is gone and then verify that the second
|
||||
* half is still there.
|
||||
* Then add the first half back and verify
|
||||
* again. Then delete the middle third
|
||||
* and verify again.
|
||||
* Then increase the size by 1000 and do
|
||||
* the whole add delete thing again.
|
||||
*
|
||||
* The data for each object is the number string translated
|
||||
* to hex and replicated a random number of times. The
|
||||
* number of times that the data is replicated is the first
|
||||
* int32 in the data.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#ifdef STDC_HEADERS
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MEMORY_H
|
||||
#include <memory.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include "mcom_db.h"
|
||||
|
||||
DB *database=0;
|
||||
int MsgPriority=5;
|
||||
|
||||
#if defined(_WINDOWS) && !defined(WIN32)
|
||||
#define int32 long
|
||||
#define uint32 unsigned long
|
||||
#else
|
||||
#define int32 int
|
||||
#define uint32 unsigned int
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
USE_LARGE_KEY,
|
||||
USE_SMALL_KEY
|
||||
} key_type_enum;
|
||||
|
||||
#define TraceMe(priority, msg) \
|
||||
do { \
|
||||
if(priority <= MsgPriority) \
|
||||
{ \
|
||||
ReportStatus msg; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
int
|
||||
ReportStatus(char *string, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
va_start(args, string);
|
||||
#else
|
||||
va_start(args);
|
||||
#endif
|
||||
vfprintf(stderr, string, args);
|
||||
va_end(args);
|
||||
|
||||
fprintf (stderr, "\n");
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
ReportError(char *string, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
va_start(args, string);
|
||||
#else
|
||||
va_start(args);
|
||||
#endif
|
||||
fprintf (stderr, "\n ");
|
||||
vfprintf(stderr, string, args);
|
||||
fprintf (stderr, "\n");
|
||||
va_end(args);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
DBT * MakeLargeKey(int32 num)
|
||||
{
|
||||
int32 low_bits;
|
||||
static DBT rv;
|
||||
static char *string_rv=0;
|
||||
int rep_char;
|
||||
size_t size;
|
||||
|
||||
if(string_rv)
|
||||
free(string_rv);
|
||||
|
||||
/* generate a really large text key derived from
|
||||
* an int32
|
||||
*/
|
||||
low_bits = (num % 10000) + 1;
|
||||
|
||||
/* get the repeat char from the low 26 */
|
||||
rep_char = (char) ((low_bits % 26) + 'a');
|
||||
|
||||
/* malloc a string low_bits wide */
|
||||
size = low_bits*sizeof(char);
|
||||
string_rv = (char *)malloc(size);
|
||||
|
||||
memset(string_rv, rep_char, size);
|
||||
|
||||
rv.data = string_rv;
|
||||
rv.size = size;
|
||||
|
||||
return(&rv);
|
||||
}
|
||||
|
||||
DBT * MakeSmallKey(int32 num)
|
||||
{
|
||||
static DBT rv;
|
||||
static char data_string[64];
|
||||
|
||||
rv.data = data_string;
|
||||
|
||||
sprintf(data_string, "%ld", (long)num);
|
||||
rv.size = strlen(data_string);
|
||||
|
||||
return(&rv);
|
||||
|
||||
}
|
||||
|
||||
DBT * GenKey(int32 num, key_type_enum key_type)
|
||||
{
|
||||
DBT *key;
|
||||
|
||||
switch(key_type)
|
||||
{
|
||||
case USE_LARGE_KEY:
|
||||
key = MakeLargeKey(num);
|
||||
break;
|
||||
case USE_SMALL_KEY:
|
||||
key = MakeSmallKey(num);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
break;
|
||||
}
|
||||
|
||||
return(key);
|
||||
}
|
||||
|
||||
int
|
||||
SeqDatabase()
|
||||
{
|
||||
int status;
|
||||
DBT key, data;
|
||||
|
||||
ReportStatus("SEQuencing through database...");
|
||||
|
||||
/* seq throught the whole database */
|
||||
if(!(status = (*database->seq)(database, &key, &data, R_FIRST)))
|
||||
{
|
||||
while(!(status = (database->seq) (database, &key, &data, R_NEXT)));
|
||||
; /* null body */
|
||||
}
|
||||
|
||||
if(status < 0)
|
||||
ReportError("Error seq'ing database");
|
||||
|
||||
return(status);
|
||||
}
|
||||
|
||||
int
|
||||
VerifyData(DBT *data, int32 num, key_type_enum key_type)
|
||||
{
|
||||
int32 count, compare_num;
|
||||
size_t size;
|
||||
int32 *int32_array;
|
||||
|
||||
/* The first int32 is count
|
||||
* The other n entries should
|
||||
* all equal num
|
||||
*/
|
||||
if(data->size < sizeof(int32))
|
||||
{
|
||||
ReportError("Data size corrupted");
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(&count, data->data, sizeof(int32));
|
||||
|
||||
size = sizeof(int32)*(count+1);
|
||||
|
||||
if(size != data->size)
|
||||
{
|
||||
ReportError("Data size corrupted");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_array = (int32*)data->data;
|
||||
|
||||
for(;count > 0; count--)
|
||||
{
|
||||
memcpy(&compare_num, &int32_array[count], sizeof(int32));
|
||||
|
||||
if(compare_num != num)
|
||||
{
|
||||
ReportError("Data corrupted");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/* verify that a range of number strings exist
|
||||
* or don't exist. And that the data is valid
|
||||
*/
|
||||
#define SHOULD_EXIST 1
|
||||
#define SHOULD_NOT_EXIST 0
|
||||
int
|
||||
VerifyRange(int32 low, int32 high, int32 should_exist, key_type_enum key_type)
|
||||
{
|
||||
DBT *key, data;
|
||||
int32 num;
|
||||
int status;
|
||||
|
||||
TraceMe(1, ("Verifying: %ld to %ld, using %s keys",
|
||||
low, high, key_type == USE_SMALL_KEY ? "SMALL" : "LARGE"));
|
||||
|
||||
for(num = low; num <= high; num++)
|
||||
{
|
||||
|
||||
key = GenKey(num, key_type);
|
||||
|
||||
status = (*database->get)(database, key, &data, 0);
|
||||
|
||||
if(status == 0)
|
||||
{
|
||||
/* got the item */
|
||||
if(!should_exist)
|
||||
{
|
||||
ReportError("Item exists but shouldn't: %ld", num);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* else verify the data */
|
||||
VerifyData(&data, num, key_type);
|
||||
}
|
||||
}
|
||||
else if(status > 0)
|
||||
{
|
||||
/* item not found */
|
||||
if(should_exist)
|
||||
{
|
||||
ReportError("Item not found but should be: %ld", num);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* database error */
|
||||
ReportError("Database error");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TraceMe(1, ("Correctly verified: %ld to %ld", low, high));
|
||||
|
||||
return(0);
|
||||
|
||||
}
|
||||
|
||||
DBT *
|
||||
GenData(int32 num)
|
||||
{
|
||||
int32 n;
|
||||
static DBT *data=0;
|
||||
int32 *int32_array;
|
||||
size_t size;
|
||||
|
||||
if(!data)
|
||||
{
|
||||
data = (DBT*)malloc(sizeof(DBT));
|
||||
data->size = 0;
|
||||
data->data = 0;
|
||||
}
|
||||
else if(data->data)
|
||||
{
|
||||
free(data->data);
|
||||
}
|
||||
|
||||
n = rand();
|
||||
|
||||
n = n % 512; /* bound to a 2K size */
|
||||
|
||||
|
||||
size = sizeof(int32)*(n+1);
|
||||
int32_array = (int32 *) malloc(size);
|
||||
|
||||
memcpy(&int32_array[0], &n, sizeof(int32));
|
||||
|
||||
for(; n > 0; n--)
|
||||
{
|
||||
memcpy(&int32_array[n], &num, sizeof(int32));
|
||||
}
|
||||
|
||||
data->data = (void*)int32_array;
|
||||
data->size = size;
|
||||
|
||||
return(data);
|
||||
}
|
||||
|
||||
#define ADD_RANGE 1
|
||||
#define DELETE_RANGE 2
|
||||
|
||||
int
|
||||
AddOrDelRange(int32 low, int32 high, int action, key_type_enum key_type)
|
||||
{
|
||||
DBT *key, *data;
|
||||
#if 0 /* only do this if your really analy checking the puts */
|
||||
DBT tmp_data;
|
||||
#endif
|
||||
int32 num;
|
||||
int status;
|
||||
|
||||
if(action != ADD_RANGE && action != DELETE_RANGE)
|
||||
assert(0);
|
||||
|
||||
if(action == ADD_RANGE)
|
||||
{
|
||||
TraceMe(1, ("Adding: %ld to %ld: %s keys", low, high,
|
||||
key_type == USE_SMALL_KEY ? "SMALL" : "LARGE"));
|
||||
}
|
||||
else
|
||||
{
|
||||
TraceMe(1, ("Deleting: %ld to %ld: %s keys", low, high,
|
||||
key_type == USE_SMALL_KEY ? "SMALL" : "LARGE"));
|
||||
}
|
||||
|
||||
for(num = low; num <= high; num++)
|
||||
{
|
||||
|
||||
key = GenKey(num, key_type);
|
||||
|
||||
if(action == ADD_RANGE)
|
||||
{
|
||||
data = GenData(num);
|
||||
status = (*database->put)(database, key, data, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
status = (*database->del)(database, key, 0);
|
||||
}
|
||||
|
||||
if(status < 0)
|
||||
{
|
||||
ReportError("Database error %s item: %ld",
|
||||
action == ADD_RANGE ? "ADDING" : "DELETING",
|
||||
num);
|
||||
}
|
||||
else if(status > 0)
|
||||
{
|
||||
ReportError("Could not %s item: %ld",
|
||||
action == ADD_RANGE ? "ADD" : "DELETE",
|
||||
num);
|
||||
}
|
||||
else if(action == ADD_RANGE)
|
||||
{
|
||||
#define SYNC_EVERY_TIME
|
||||
#ifdef SYNC_EVERY_TIME
|
||||
status = (*database->sync)(database, 0);
|
||||
if(status != 0)
|
||||
ReportError("Database error syncing after add");
|
||||
#endif
|
||||
|
||||
#if 0 /* only do this if your really analy checking the puts */
|
||||
|
||||
/* make sure we can still get it
|
||||
*/
|
||||
status = (*database->get)(database, key, &tmp_data, 0);
|
||||
|
||||
if(status != 0)
|
||||
{
|
||||
ReportError("Database error checking item just added: %d",
|
||||
num);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* now verify that none of the ones we already
|
||||
* put in have disappeared
|
||||
*/
|
||||
VerifyRange(low, num, SHOULD_EXIST, key_type);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(action == ADD_RANGE)
|
||||
{
|
||||
TraceMe(1, ("Successfully added: %ld to %ld", low, high));
|
||||
}
|
||||
else
|
||||
{
|
||||
TraceMe(1, ("Successfully deleted: %ld to %ld", low, high));
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
TestRange(int32 low, int32 range, key_type_enum key_type)
|
||||
{
|
||||
int status; int32 low_of_range1, high_of_range1; int32 low_of_range2, high_of_range2;
|
||||
int32 low_of_range3, high_of_range3;
|
||||
|
||||
status = AddOrDelRange(low, low+range, ADD_RANGE, key_type);
|
||||
status = VerifyRange(low, low+range, SHOULD_EXIST, key_type);
|
||||
|
||||
TraceMe(1, ("Finished with sub test 1"));
|
||||
|
||||
SeqDatabase();
|
||||
|
||||
low_of_range1 = low;
|
||||
high_of_range1 = low+(range/2);
|
||||
low_of_range2 = high_of_range1+1;
|
||||
high_of_range2 = low+range;
|
||||
status = AddOrDelRange(low_of_range1, high_of_range1, DELETE_RANGE, key_type);
|
||||
status = VerifyRange(low_of_range1, high_of_range1, SHOULD_NOT_EXIST, key_type);
|
||||
status = VerifyRange(low_of_range2, low_of_range2, SHOULD_EXIST, key_type);
|
||||
|
||||
TraceMe(1, ("Finished with sub test 2"));
|
||||
|
||||
SeqDatabase();
|
||||
|
||||
status = AddOrDelRange(low_of_range1, high_of_range1, ADD_RANGE, key_type);
|
||||
/* the whole thing should exist now */
|
||||
status = VerifyRange(low, low+range, SHOULD_EXIST, key_type);
|
||||
|
||||
TraceMe(1, ("Finished with sub test 3"));
|
||||
|
||||
SeqDatabase();
|
||||
|
||||
status = AddOrDelRange(low_of_range2, high_of_range2, DELETE_RANGE, key_type);
|
||||
status = VerifyRange(low_of_range1, high_of_range1, SHOULD_EXIST, key_type);
|
||||
status = VerifyRange(low_of_range2, high_of_range2, SHOULD_NOT_EXIST, key_type);
|
||||
|
||||
TraceMe(1, ("Finished with sub test 4"));
|
||||
|
||||
SeqDatabase();
|
||||
|
||||
status = AddOrDelRange(low_of_range2, high_of_range2, ADD_RANGE, key_type);
|
||||
/* the whole thing should exist now */
|
||||
status = VerifyRange(low, low+range, SHOULD_EXIST, key_type);
|
||||
|
||||
TraceMe(1, ("Finished with sub test 5"));
|
||||
|
||||
SeqDatabase();
|
||||
|
||||
low_of_range1 = low;
|
||||
high_of_range1 = low+(range/3);
|
||||
low_of_range2 = high_of_range1+1;
|
||||
high_of_range2 = high_of_range1+(range/3);
|
||||
low_of_range3 = high_of_range2+1;
|
||||
high_of_range3 = low+range;
|
||||
/* delete range 2 */
|
||||
status = AddOrDelRange(low_of_range2, high_of_range2, DELETE_RANGE, key_type);
|
||||
status = VerifyRange(low_of_range1, high_of_range1, SHOULD_EXIST, key_type);
|
||||
status = VerifyRange(low_of_range2, low_of_range2, SHOULD_NOT_EXIST, key_type);
|
||||
status = VerifyRange(low_of_range3, low_of_range2, SHOULD_EXIST, key_type);
|
||||
|
||||
TraceMe(1, ("Finished with sub test 6"));
|
||||
|
||||
SeqDatabase();
|
||||
|
||||
status = AddOrDelRange(low_of_range2, high_of_range2, ADD_RANGE, key_type);
|
||||
/* the whole thing should exist now */
|
||||
status = VerifyRange(low, low+range, SHOULD_EXIST, key_type);
|
||||
|
||||
TraceMe(1, ("Finished with sub test 7"));
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
#define START_RANGE 109876
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int32 i, j=0;
|
||||
int quick_exit = 0;
|
||||
int large_keys = 0;
|
||||
HASHINFO hash_info = {
|
||||
16*1024,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0};
|
||||
|
||||
|
||||
if(argc > 1)
|
||||
{
|
||||
while(argc > 1)
|
||||
{
|
||||
if(!strcmp(argv[argc-1], "-quick"))
|
||||
quick_exit = 1;
|
||||
else if(!strcmp(argv[argc-1], "-large"))
|
||||
{
|
||||
large_keys = 1;
|
||||
}
|
||||
argc--;
|
||||
}
|
||||
}
|
||||
|
||||
database = dbopen("test.db", O_RDWR | O_CREAT, 0644, DB_HASH, &hash_info);
|
||||
|
||||
if(!database)
|
||||
{
|
||||
ReportError("Could not open database");
|
||||
#ifdef unix
|
||||
perror("");
|
||||
#endif
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(quick_exit)
|
||||
{
|
||||
if(large_keys)
|
||||
TestRange(START_RANGE, 200, USE_LARGE_KEY);
|
||||
else
|
||||
TestRange(START_RANGE, 200, USE_SMALL_KEY);
|
||||
|
||||
(*database->sync)(database, 0);
|
||||
(*database->close)(database);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
for(i=100; i < 10000000; i+=200)
|
||||
{
|
||||
if(1 || j)
|
||||
{
|
||||
TestRange(START_RANGE, i, USE_LARGE_KEY);
|
||||
j = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
TestRange(START_RANGE, i, USE_SMALL_KEY);
|
||||
j = 1;
|
||||
}
|
||||
|
||||
if(1 == rand() % 3)
|
||||
{
|
||||
(*database->sync)(database, 0);
|
||||
}
|
||||
|
||||
if(1 == rand() % 3)
|
||||
{
|
||||
/* close and reopen */
|
||||
(*database->close)(database);
|
||||
database = dbopen("test.db", O_RDWR | O_CREAT, 0644, DB_HASH, 0);
|
||||
if(!database)
|
||||
{
|
||||
ReportError("Could not reopen database");
|
||||
#ifdef unix
|
||||
perror("");
|
||||
#endif
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* reopen database without closeing the other */
|
||||
database = dbopen("test.db", O_RDWR | O_CREAT, 0644, DB_HASH, 0);
|
||||
if(!database)
|
||||
{
|
||||
ReportError("Could not reopen database "
|
||||
"after not closing the other");
|
||||
#ifdef unix
|
||||
perror("");
|
||||
#endif
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
#! gmake
|
||||
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
|
||||
MOD_DEPTH = .
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(MOD_DEPTH)/config/autoconf.mk
|
||||
|
||||
MAKE := $(patsubst -j%,,$(MAKE)) -j1
|
||||
|
||||
DIRS = config pr lib
|
||||
|
||||
ifdef MOZILLA_CLIENT
|
||||
# Make nsinstall use absolute symlinks by default for Mozilla OSX builds
|
||||
# http://bugzilla.mozilla.org/show_bug.cgi?id=193164
|
||||
ifeq ($(OS_ARCH),Darwin)
|
||||
ifndef NSDISTMODE
|
||||
NSDISTMODE=absolute_symlink
|
||||
export NSDISTMODE
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
DIST_GARBAGE = config.cache config.log config.status
|
||||
|
||||
all:: config.status export
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
config.status:: configure
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
sh $(srcdir)/configure --no-create --no-recursion
|
||||
else
|
||||
./config.status --recheck && ./config.status
|
||||
endif
|
||||
|
||||
#
|
||||
# The -ll option of zip converts CR LF to LF.
|
||||
#
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
ZIP_ASCII_OPT = -ll
|
||||
endif
|
||||
|
||||
# Delete config/autoconf.mk last because it is included by every makefile.
|
||||
distclean::
|
||||
@echo "cd pr/tests; $(MAKE) $@"
|
||||
@$(MAKE) -C pr/tests $@
|
||||
rm -f config/autoconf.mk
|
||||
rm -f `cat unallmakefiles` unallmakefiles
|
||||
|
||||
release::
|
||||
echo $(BUILD_NUMBER) > $(RELEASE_DIR)/$(BUILD_NUMBER)/version.df
|
||||
@if test -f imports.df; then \
|
||||
echo "cp -f imports.df $(RELEASE_DIR)/$(BUILD_NUMBER)/imports.df"; \
|
||||
cp -f imports.df $(RELEASE_DIR)/$(BUILD_NUMBER)/imports.df; \
|
||||
else \
|
||||
echo "echo > $(RELEASE_DIR)/$(BUILD_NUMBER)/imports.df"; \
|
||||
echo > $(RELEASE_DIR)/$(BUILD_NUMBER)/imports.df; \
|
||||
fi
|
||||
cd $(RELEASE_DIR)/$(BUILD_NUMBER)/$(OBJDIR_NAME); \
|
||||
rm -rf META-INF; mkdir META-INF; cd META-INF; \
|
||||
echo "Manifest-Version: 1.0" > MANIFEST.MF; \
|
||||
echo "" >> MANIFEST.MF; \
|
||||
cd ..; rm -f mdbinary.jar; zip -r mdbinary.jar META-INF bin lib; \
|
||||
rm -rf META-INF; \
|
||||
cd include; \
|
||||
rm -rf META-INF; mkdir META-INF; cd META-INF; \
|
||||
echo "Manifest-Version: 1.0" > MANIFEST.MF; \
|
||||
echo "" >> MANIFEST.MF; \
|
||||
cd ..; rm -f mdheader.jar; zip $(ZIP_ASCII_OPT) -r mdheader.jar *; \
|
||||
rm -rf META-INF
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
@if test ! -d $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER); then \
|
||||
rm -rf $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER); \
|
||||
echo "making directory $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)"; \
|
||||
$(topsrcdir)/config/prmkdir.bat $(MDIST_DOS)\\$(MOD_NAME)\\$(BUILD_NUMBER); \
|
||||
fi
|
||||
@if test ! -d $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME); then \
|
||||
rm -rf $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME); \
|
||||
echo "making directory $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME)"; \
|
||||
$(topsrcdir)/config/prmkdir.bat $(MDIST_DOS)\\$(MOD_NAME)\\$(BUILD_NUMBER)\\$(RELEASE_OBJDIR_NAME); \
|
||||
fi
|
||||
else
|
||||
@if test ! -d $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER); then \
|
||||
rm -rf $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER); \
|
||||
echo "making directory $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)"; \
|
||||
$(NSINSTALL) -D $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER); \
|
||||
chmod 775 $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER); \
|
||||
fi
|
||||
@if test ! -d $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME); then \
|
||||
rm -rf $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME); \
|
||||
echo "making directory $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME)"; \
|
||||
$(NSINSTALL) -D $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME); \
|
||||
chmod 775 $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME); \
|
||||
fi
|
||||
endif
|
||||
cd $(RELEASE_DIR)/$(BUILD_NUMBER); \
|
||||
cp -f version.df imports.df $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER); \
|
||||
chmod 664 $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/version.df; \
|
||||
chmod 664 $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/imports.df; \
|
||||
cd $(OBJDIR_NAME); \
|
||||
cp -f mdbinary.jar $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME); \
|
||||
chmod 664 $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME)/mdbinary.jar; \
|
||||
cd include; \
|
||||
cp -f mdheader.jar $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME); \
|
||||
chmod 664 $(MDIST)/$(MOD_NAME)/$(BUILD_NUMBER)/$(RELEASE_OBJDIR_NAME)/mdheader.jar
|
||||
|
||||
package:
|
||||
@echo "cd pkg; $(MAKE) publish"
|
||||
$(MAKE) -C pkg publish
|
||||
|
||||
depend:
|
||||
@echo "NSPR20 has no dependencies. Skipped."
|
||||
@@ -1,75 +0,0 @@
|
||||
#!/bin/perl
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998-2001
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
#
|
||||
# explode.pl -- Unpack .jar files into bin, lib, include directories
|
||||
#
|
||||
# syntax: perl explode.pl
|
||||
#
|
||||
# Description:
|
||||
# explode.pl unpacks the .jar files created by the NSPR build
|
||||
# procedure.
|
||||
#
|
||||
# Suggested use: After copying the platform directories to
|
||||
# /s/b/c/nspr20/<release>. CD to /s/b/c/nspr20/<release> and
|
||||
# run explode.pl. This will unpack the jar files into bin, lib,
|
||||
# include directories.
|
||||
#
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
@dirs = `ls -d *.OBJ*`;
|
||||
|
||||
foreach $dir (@dirs) {
|
||||
chop($dir);
|
||||
if (-l $dir) {
|
||||
print "Skipping symbolic link $dir\n";
|
||||
next;
|
||||
}
|
||||
print "Unzipping $dir/mdbinary.jar\n";
|
||||
system ("unzip", "-o", "$dir/mdbinary.jar",
|
||||
"-d", "$dir");
|
||||
system ("rm", "-rf", "$dir/META-INF");
|
||||
mkdir "$dir/include", 0755;
|
||||
print "Unzipping $dir/mdheader.jar\n";
|
||||
system ("unzip", "-o", "-aa",
|
||||
"$dir/mdheader.jar",
|
||||
"-d", "$dir/include");
|
||||
system ("rm", "-rf", "$dir/include/META-INF");
|
||||
}
|
||||
# --- end explode.pl ----------------------------------------------
|
||||
@@ -1,79 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998-2001
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# makeTargetDirs.sh -- Create target directories for building NSPR
|
||||
#
|
||||
# syntax: makeTargetDirs.sh
|
||||
#
|
||||
# Description:
|
||||
# makeTargetDirs.sh creates a set of directories intended for use
|
||||
# with NSPR's autoconf based build system.
|
||||
#
|
||||
# The enumerated directories are the same as those built for NSPR
|
||||
# 4.1.1. Adjust as needed.
|
||||
#
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
mkdir AIX4.3_64_DBG.OBJ
|
||||
mkdir AIX4.3_64_OPT.OBJ
|
||||
mkdir AIX4.3_DBG.OBJ
|
||||
mkdir AIX4.3_OPT.OBJ
|
||||
mkdir HP-UXB.11.00_64_DBG.OBJ
|
||||
mkdir HP-UXB.11.00_64_OPT.OBJ
|
||||
mkdir HP-UXB.11.00_DBG.OBJ
|
||||
mkdir HP-UXB.11.00_OPT.OBJ
|
||||
mkdir IRIX6.5_n32_PTH_DBG.OBJ
|
||||
mkdir IRIX6.5_n32_PTH_OPT.OBJ
|
||||
mkdir Linux2.2_x86_glibc_PTH_DBG.OBJ
|
||||
mkdir Linux2.2_x86_glibc_PTH_OPT.OBJ
|
||||
mkdir Linux2.4_x86_glibc_PTH_DBG.OBJ
|
||||
mkdir Linux2.4_x86_glibc_PTH_OPT.OBJ
|
||||
mkdir OSF1V4.0D_DBG.OBJ
|
||||
mkdir OSF1V4.0D_OPT.OBJ
|
||||
mkdir SunOS5.6_DBG.OBJ
|
||||
mkdir SunOS5.6_OPT.OBJ
|
||||
mkdir SunOS5.7_64_DBG.OBJ
|
||||
mkdir SunOS5.7_64_OPT.OBJ
|
||||
mkdir WIN954.0_DBG.OBJ
|
||||
mkdir WIN954.0_DBG.OBJD
|
||||
mkdir WIN954.0_OPT.OBJ
|
||||
mkdir WINNT4.0_DBG.OBJ
|
||||
mkdir WINNT4.0_DBG.OBJD
|
||||
mkdir WINNT4.0_OPT.OBJ
|
||||
# --- end makeTargetDirs.sh ---------------------------------------
|
||||
@@ -1,211 +0,0 @@
|
||||
#! /bin/sh
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998-2001
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# repackage.sh -- Repackage NSPR from /s/b/c to mozilla.org format
|
||||
#
|
||||
# syntax: repackage.sh
|
||||
#
|
||||
# Description:
|
||||
# repackage.sh creates NSPR binary distributions for mozilla.org from
|
||||
# the internal binary distributions in /share/builds/components/nspr20.
|
||||
# There are reasons why we can't just push the internal binary distributions
|
||||
# to mozilla.org. External developers prefer to use the common archive
|
||||
# file format for their platforms, rather than the jar files we use internally.
|
||||
#
|
||||
# On Unix, we create a tar.gz file. On Windows, we create a zip file.
|
||||
# For example: NSPR 4.1.1, these would be nspr-4.1.1.tar.gz and nspr-4.1.1.zip.
|
||||
#
|
||||
# When unpacked, nspr-4.1.1.tar.gz or nspr-4.1.1.zip should expand to a
|
||||
# nspr-4.1.1 directory that contains three subdirectories: include, lib,
|
||||
# and bin. The header files, with the correct line endings for the
|
||||
# platform, are in nspr-4.1.1/include. The libraries are in nspr-4.1.1/lib.
|
||||
# The executable programs are in nspr-4.1.1/bin.
|
||||
#
|
||||
# Note! Files written with Gnu tar are not readable by some non-Gnu
|
||||
# versions. Sun, in particular.
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
FROMTOP=/share/builds/components/nspr20/v4.7
|
||||
TOTOP=./v4.7
|
||||
NSPRDIR=nspr-4.7
|
||||
SOURCETAG=NSPR_4_7_RTM
|
||||
|
||||
#
|
||||
# enumerate Unix object directories on /s/b/c
|
||||
UNIX_OBJDIRS="
|
||||
HP-UXB.11.11_64_DBG.OBJ
|
||||
HP-UXB.11.11_64_OPT.OBJ
|
||||
HP-UXB.11.11_DBG.OBJ
|
||||
HP-UXB.11.11_OPT.OBJ
|
||||
HP-UXB.11.23_ia64_32_DBG.OBJ
|
||||
HP-UXB.11.23_ia64_32_OPT.OBJ
|
||||
HP-UXB.11.23_ia64_64_DBG.OBJ
|
||||
HP-UXB.11.23_ia64_64_OPT.OBJ
|
||||
Linux2.4_x86_glibc_PTH_DBG.OBJ
|
||||
Linux2.4_x86_glibc_PTH_OPT.OBJ
|
||||
Linux2.6_x86_64_glibc_PTH_DBG.OBJ
|
||||
Linux2.6_x86_64_glibc_PTH_OPT.OBJ
|
||||
Linux2.6_x86_glibc_PTH_DBG.OBJ
|
||||
Linux2.6_x86_glibc_PTH_OPT.OBJ
|
||||
SunOS5.9_64_DBG.OBJ
|
||||
SunOS5.9_64_OPT.OBJ
|
||||
SunOS5.9_DBG.OBJ
|
||||
SunOS5.9_OPT.OBJ
|
||||
"
|
||||
#
|
||||
# enumerate Windows object directories on /s/b/c
|
||||
WIN_OBJDIRS="
|
||||
WIN954.0_DBG.OBJ
|
||||
WIN954.0_DBG.OBJD
|
||||
WIN954.0_OPT.OBJ
|
||||
WINNT5.0_DBG.OBJ
|
||||
WINNT5.0_DBG.OBJD
|
||||
WINNT5.0_OPT.OBJ
|
||||
"
|
||||
|
||||
#
|
||||
# Create the destination directory.
|
||||
#
|
||||
echo "removing directory $TOTOP"
|
||||
rm -rf $TOTOP
|
||||
echo "creating directory $TOTOP"
|
||||
mkdir -p $TOTOP
|
||||
|
||||
#
|
||||
# Generate the tar.gz files for Unix platforms.
|
||||
#
|
||||
for OBJDIR in $UNIX_OBJDIRS; do
|
||||
echo "removing directory $NSPRDIR"
|
||||
rm -rf $NSPRDIR
|
||||
echo "creating directory $NSPRDIR"
|
||||
mkdir $NSPRDIR
|
||||
|
||||
echo "creating directory $NSPRDIR/include"
|
||||
mkdir $NSPRDIR/include
|
||||
echo "copying $FROMTOP/$OBJDIR/include"
|
||||
cp -r $FROMTOP/$OBJDIR/include $NSPRDIR
|
||||
|
||||
echo "copying $FROMTOP/$OBJDIR/lib"
|
||||
cp -r $FROMTOP/$OBJDIR/lib $NSPRDIR
|
||||
|
||||
echo "copying $FROMTOP/$OBJDIR/bin"
|
||||
cp -r $FROMTOP/$OBJDIR/bin $NSPRDIR
|
||||
|
||||
echo "creating directory $TOTOP/$OBJDIR"
|
||||
mkdir $TOTOP/$OBJDIR
|
||||
echo "creating $TOTOP/$OBJDIR/$NSPRDIR.tar"
|
||||
tar cvf $TOTOP/$OBJDIR/$NSPRDIR.tar $NSPRDIR
|
||||
echo "gzipping $TOTOP/$OBJDIR/$NSPRDIR.tar"
|
||||
gzip $TOTOP/$OBJDIR/$NSPRDIR.tar
|
||||
done
|
||||
|
||||
#
|
||||
# Generate the zip files for Windows platforms.
|
||||
#
|
||||
for OBJDIR in $WIN_OBJDIRS; do
|
||||
echo "removing directory $NSPRDIR"
|
||||
rm -rf $NSPRDIR
|
||||
echo "creating directory $NSPRDIR"
|
||||
mkdir $NSPRDIR
|
||||
|
||||
echo "creating directory $NSPRDIR/include"
|
||||
mkdir $NSPRDIR/include
|
||||
echo "creating directory $NSPRDIR/include/private"
|
||||
mkdir $NSPRDIR/include/private
|
||||
echo "creating directory $NSPRDIR/include/obsolete"
|
||||
mkdir $NSPRDIR/include/obsolete
|
||||
|
||||
# copy headers and adjust unix line-end to Windows line-end
|
||||
# Note: Watch out for the "sed" command line.
|
||||
# when editing the command, take care to preserve the "^M" as the literal
|
||||
# cntl-M character! in vi, use "cntl-v cntl-m" to enter it!
|
||||
#
|
||||
headers=`ls $FROMTOP/$OBJDIR/include/*.h`
|
||||
for header in $headers; do
|
||||
sed -e 's/$/
|
||||
/g' $header > $NSPRDIR/include/`basename $header`
|
||||
done
|
||||
headers=`ls $FROMTOP/$OBJDIR/include/obsolete/*.h`
|
||||
for header in $headers; do
|
||||
sed -e 's/$/
|
||||
/g' $header > $NSPRDIR/include/obsolete/`basename $header`
|
||||
done
|
||||
headers=`ls $FROMTOP/$OBJDIR/include/private/*.h`
|
||||
for header in $headers; do
|
||||
sed -e 's/$/
|
||||
/g' $header > $NSPRDIR/include/private/`basename $header`
|
||||
done
|
||||
|
||||
echo "copying $FROMTOP/$OBJDIR/lib"
|
||||
cp -r $FROMTOP/$OBJDIR/lib $NSPRDIR
|
||||
|
||||
echo "copying $FROMTOP/$OBJDIR/bin"
|
||||
cp -r $FROMTOP/$OBJDIR/bin $NSPRDIR
|
||||
|
||||
echo "creating directory $TOTOP/$OBJDIR"
|
||||
mkdir -p $TOTOP/$OBJDIR
|
||||
echo "creating $TOTOP/$OBJDIR/$NSPRDIR.zip"
|
||||
zip -r $TOTOP/$OBJDIR/$NSPRDIR.zip $NSPRDIR
|
||||
done
|
||||
|
||||
#
|
||||
# package the source from CVS
|
||||
#
|
||||
echo "Packaging source"
|
||||
echo "removing directory $NSPRDIR"
|
||||
rm -rf $NSPRDIR
|
||||
echo "creating directory $NSPRDIR"
|
||||
mkdir $NSPRDIR
|
||||
myWD=`pwd`
|
||||
cd $NSPRDIR
|
||||
echo "Pulling source from CVS with tag $SOURCETAG"
|
||||
cvs co -r $SOURCETAG mozilla/nsprpub
|
||||
cd $myWD
|
||||
mkdir $TOTOP/src
|
||||
echo "Creating source tar file: $TOTOP/src/$NSPRDIR.tar"
|
||||
tar cvf $TOTOP/src/$NSPRDIR.tar $NSPRDIR
|
||||
echo "gzip $TOTOP/src/$NSPRDIR.tar"
|
||||
gzip $TOTOP/src/$NSPRDIR.tar
|
||||
|
||||
#
|
||||
# Remove the working directory.
|
||||
#
|
||||
@@ -1,75 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998-2001
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# symlinks.sh -- create links from NSPR builds
|
||||
#
|
||||
# syntax: symlinks.sh
|
||||
#
|
||||
# Description:
|
||||
# symlinks.sh creates some symbolic links for NSPR build targets
|
||||
# that are not actually build, but for which there are NSPR
|
||||
# binaries suitable for running on the intended target. ... got
|
||||
# that?
|
||||
#
|
||||
# Suggested use: After copying NSPR binaries to
|
||||
# /s/b/c/nspr20/<platform> run symlinks.sh to create the links
|
||||
# for all supported platforms.
|
||||
#
|
||||
# The symlinks in this script correspond to the NSPR 4.1.1
|
||||
# release. Adjust as necessary.
|
||||
#
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
ln -s SunOS5.6_DBG.OBJ SunOS5.7_DBG.OBJ
|
||||
ln -s SunOS5.6_OPT.OBJ SunOS5.7_OPT.OBJ
|
||||
|
||||
ln -s SunOS5.6_DBG.OBJ SunOS5.8_DBG.OBJ
|
||||
ln -s SunOS5.6_OPT.OBJ SunOS5.8_OPT.OBJ
|
||||
|
||||
ln -s SunOS5.7_64_DBG.OBJ SunOS5.8_64_DBG.OBJ
|
||||
ln -s SunOS5.7_64_OPT.OBJ SunOS5.8_64_OPT.OBJ
|
||||
|
||||
ln -s OSF1V4.0D_DBG.OBJ OSF1V5.0_DBG.OBJ
|
||||
ln -s OSF1V4.0D_OPT.OBJ OSF1V5.0_OPT.OBJ
|
||||
|
||||
ln -s WINNT4.0_DBG.OBJ WINNT5.0_DBG.OBJ
|
||||
ln -s WINNT4.0_DBG.OBJD WINNT5.0_DBG.OBJD
|
||||
ln -s WINNT4.0_OPT.OBJ WINNT5.0_OPT.OBJ
|
||||
# --- end symlinks.sh ---------------------------------------------
|
||||
|
||||
1481
mozilla/nsprpub/build/autoconf/config.guess
vendored
1481
mozilla/nsprpub/build/autoconf/config.guess
vendored
File diff suppressed because it is too large
Load Diff
1595
mozilla/nsprpub/build/autoconf/config.sub
vendored
1595
mozilla/nsprpub/build/autoconf/config.sub
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,119 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# install - install a program, script, or datafile
|
||||
# This comes from X11R5; it is not part of GNU.
|
||||
#
|
||||
# $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch.
|
||||
#
|
||||
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
|
||||
instcmd="$mvprog"
|
||||
chmodcmd=""
|
||||
chowncmd=""
|
||||
chgrpcmd=""
|
||||
stripcmd=""
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=""
|
||||
dst=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-c) instcmd="$cpprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd="$stripprog"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
then
|
||||
src=$1
|
||||
else
|
||||
dst=$1
|
||||
fi
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
then
|
||||
echo "install: no input file specified"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "install: no destination specified"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# If destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d $dst ]
|
||||
then
|
||||
dst="$dst"/`basename $src`
|
||||
fi
|
||||
|
||||
# Make a temp file name in the proper directory.
|
||||
|
||||
dstdir=`dirname $dst`
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
|
||||
# Move or copy the file name to the temp name
|
||||
|
||||
$doit $instcmd $src $dsttmp
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; fi
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; fi
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; fi
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; fi
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
|
||||
$doit $rmcmd $dst
|
||||
$doit $mvcmd $dsttmp $dst
|
||||
|
||||
|
||||
exit 0
|
||||
@@ -1,75 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Stupid wrapper to avoid win32 dospath/cygdrive issues
|
||||
# Try not to spawn programs from within this file. If the stuff in here looks royally
|
||||
# confusing, see bug: http://bugzilla.mozilla.org/show_bug.cgi?id=206643
|
||||
# and look at the older versions of this file that are easier to read, but
|
||||
# do basically the same thing
|
||||
#
|
||||
|
||||
prog=$1
|
||||
shift
|
||||
if test -z "$prog"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# If $CYGDRIVE_MOUNT was not set in configure, give $mountpoint the results of mount -p
|
||||
mountpoint=$CYGDRIVE_MOUNT
|
||||
if test -z "$mountpoint"; then
|
||||
mountpoint=`mount -p`
|
||||
if test -z "$mountpoint"; then
|
||||
print "Cannot determine cygwin mount points. Exiting"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Delete everything but "/cygdrive" (or other mountpoint) from mount=`mount -p`
|
||||
mountpoint=${mountpoint#*/}
|
||||
mountpoint=/${mountpoint%%[!A-Za-z0-9_]*}
|
||||
mountpoint=${mountpoint%/}
|
||||
|
||||
args=""
|
||||
up=""
|
||||
if test "${prog}" = "-up"; then
|
||||
up=1
|
||||
prog=${1}
|
||||
shift
|
||||
fi
|
||||
|
||||
process=1
|
||||
|
||||
# Convert the mountpoint in parameters to Win32 filenames
|
||||
# For instance: /cygdrive/c/foo -> c:/foo
|
||||
for i in "${@}"
|
||||
do
|
||||
if test "${i}" = "-wrap"; then
|
||||
process=1
|
||||
else
|
||||
if test "${i}" = "-nowrap"; then
|
||||
process=
|
||||
else
|
||||
if test -n "${process}"; then
|
||||
if test -n "${up}"; then
|
||||
pathname=${i#-I[a-zA-Z]:/}
|
||||
if ! test "${pathname}" = "${i}"; then
|
||||
no_i=${i#-I}
|
||||
driveletter=${no_i%%:*}
|
||||
i=-I${mountpoint}/${driveletter}/${pathname}
|
||||
fi
|
||||
else
|
||||
eval 'leader=${i%%'${mountpoint}'/[a-zA-Z]/*}'
|
||||
if ! test "${leader}" = "${i}"; then
|
||||
eval 'pathname=${i#'${leader}${mountpoint}'/[a-zA-Z]/}'
|
||||
eval 'no_mountpoint=${i#'${leader}${mountpoint}'/}'
|
||||
driveletter=${no_mountpoint%%/*}
|
||||
i=${leader}${driveletter}:/${pathname}
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
args="${args} ${i}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
exec $prog $args
|
||||
@@ -1,160 +0,0 @@
|
||||
#! gmake
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
MOD_DEPTH = ..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(MOD_DEPTH)/config/autoconf.mk
|
||||
|
||||
# Indicate that this directory builds build tools.
|
||||
INTERNAL_TOOLS = 1
|
||||
|
||||
# For sanity's sake, we compile nsinstall without the wrapped system
|
||||
# headers, so that we can use it to set up the wrapped system headers.
|
||||
VISIBILITY_FLAGS =
|
||||
|
||||
# autoconf.mk must be deleted last (from the top-level directory)
|
||||
# because it is included by every makefile.
|
||||
DIST_GARBAGE = nsprincl.mk nsprincl.sh nspr-config
|
||||
|
||||
RELEASE_BINS = nspr-config
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
CSRCS = now.c
|
||||
|
||||
# This version hasn't been ported for us; the one in mozilla/config has
|
||||
ifneq ($(OS_ARCH),OS2)
|
||||
CSRCS += nsinstall.c
|
||||
|
||||
PLSRCS = nfspwd.pl
|
||||
endif
|
||||
|
||||
ifeq (,$(CROSS_COMPILE)$(filter-out WINNT OS2,$(OS_ARCH)))
|
||||
PROG_SUFFIX = .exe
|
||||
else
|
||||
PROG_SUFFIX =
|
||||
endif
|
||||
|
||||
# Temporary workaround to disable the generation of
|
||||
# library build time because now.c uses the 'long long'
|
||||
# data type that's not available on some platforms.
|
||||
ifeq (,$(filter-out NEC NEXTSTEP QNX SCOOS UNIXWARE,$(OS_ARCH)))
|
||||
DEFINES += -DOMIT_LIB_BUILD_TIME
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH), IRIX)
|
||||
ifeq ($(basename $(OS_RELEASE)),6)
|
||||
ifndef NS_USE_GCC
|
||||
ifeq ($(USE_N32),1)
|
||||
XLDOPTS += -n32 -Wl,-woff,85
|
||||
else
|
||||
ifeq ($(USE_64),1)
|
||||
XLDOPTS += -64
|
||||
else
|
||||
XLDOPTS += -32
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH), HP-UX)
|
||||
ifeq ($(USE_64),1)
|
||||
XLDOPTS += +DD64
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_OS2_TOOLS),EMX)
|
||||
XCFLAGS = $(OS_CFLAGS)
|
||||
ifeq ($(MOZ_OS2_EMX_OBJECTFORMAT),OMF)
|
||||
XLDOPTS = -Zlinker /PM:VIO
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_OS2_TOOLS),PGCC)
|
||||
XCFLAGS = $(OS_CFLAGS)
|
||||
XLDOPTS = -Zlinker /PM:VIO
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
PROGS = $(OBJDIR)/now$(PROG_SUFFIX)
|
||||
|
||||
ifeq (,$(CROSS_COMPILE)$(filter-out OS2 WINNT,$(OS_ARCH)))
|
||||
TARGETS = $(PROGS)
|
||||
else
|
||||
PROGS += $(OBJDIR)/nsinstall$(PROG_SUFFIX)
|
||||
TARGETS = $(PROGS) $(PLSRCS:.pl=)
|
||||
endif
|
||||
|
||||
OUTOPTION = -o # end of the line
|
||||
ifeq (,$(filter-out WINNT WIN95,$(OS_TARGET)))
|
||||
ifndef NS_USE_GCC
|
||||
OUTOPTION = -Fe
|
||||
endif
|
||||
endif
|
||||
|
||||
# Redefine MAKE_OBJDIR for just this directory
|
||||
define MAKE_OBJDIR
|
||||
if test ! -d $(@D); then rm -rf $(@D); mkdir $(@D); else true; fi
|
||||
endef
|
||||
|
||||
export:: $(TARGETS)
|
||||
rm -f $(dist_bindir)/nspr-config
|
||||
|
||||
ifdef WRAP_SYSTEM_INCLUDES
|
||||
export::
|
||||
if test ! -d system_wrappers; then mkdir system_wrappers; fi
|
||||
$(PERL) $(srcdir)/make-system-wrappers.pl system_wrappers < $(srcdir)/system-headers
|
||||
$(INSTALL) system_wrappers $(dist_includedir)
|
||||
endif
|
||||
|
||||
$(OBJDIR)/%$(PROG_SUFFIX): $(OBJDIR)/%.$(OBJ_SUFFIX)
|
||||
@$(MAKE_OBJDIR)
|
||||
ifeq ($(MOZ_OS2_TOOLS),VACPP)
|
||||
$(LD) $(EXEFLAGS) $<
|
||||
else
|
||||
$(CC) $(XCFLAGS) $< $(LDFLAGS) $(XLDOPTS) $(OUTOPTION)$@
|
||||
endif
|
||||
|
||||
install:: nspr.m4
|
||||
$(NSINSTALL) -D $(DESTDIR)$(datadir)/aclocal
|
||||
$(NSINSTALL) -t -m 0644 $< $(DESTDIR)$(datadir)/aclocal
|
||||
@@ -1,130 +0,0 @@
|
||||
# -*- Mode: Makefile -*-
|
||||
|
||||
INCLUDED_AUTOCONF_MK = 1
|
||||
USE_AUTOCONF = 1
|
||||
@SHELL_OVERRIDE@
|
||||
MOZILLA_CLIENT = @MOZILLA_CLIENT@
|
||||
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
bindir = @bindir@
|
||||
includedir = @includedir@
|
||||
libdir = @libdir@
|
||||
datadir = @datadir@
|
||||
|
||||
dist_prefix = @dist_prefix@
|
||||
dist_bindir = @dist_bindir@
|
||||
dist_includedir = @dist_includedir@
|
||||
dist_libdir = @dist_libdir@
|
||||
|
||||
DIST = $(dist_prefix)
|
||||
|
||||
RELEASE_OBJDIR_NAME = @RELEASE_OBJDIR_NAME@
|
||||
OBJDIR_NAME = @OBJDIR_NAME@
|
||||
OBJDIR = @OBJDIR@
|
||||
OBJ_SUFFIX = @OBJ_SUFFIX@
|
||||
LIB_SUFFIX = @LIB_SUFFIX@
|
||||
DLL_SUFFIX = @DLL_SUFFIX@
|
||||
ASM_SUFFIX = @ASM_SUFFIX@
|
||||
MOD_NAME = @NSPR_MODNAME@
|
||||
|
||||
MOD_MAJOR_VERSION = @MOD_MAJOR_VERSION@
|
||||
MOD_MINOR_VERSION = @MOD_MINOR_VERSION@
|
||||
MOD_PATCH_VERSION = @MOD_PATCH_VERSION@
|
||||
|
||||
LIBNSPR = @LIBNSPR@
|
||||
LIBPLC = @LIBPLC@
|
||||
|
||||
CROSS_COMPILE = @CROSS_COMPILE@
|
||||
BUILD_OPT = @MOZ_OPTIMIZE@
|
||||
|
||||
USE_CPLUS = @USE_CPLUS@
|
||||
USE_IPV6 = @USE_IPV6@
|
||||
USE_N32 = @USE_N32@
|
||||
USE_64 = @USE_64@
|
||||
GC_LEAK_DETECTOR = @GC_LEAK_DETECTOR@
|
||||
ENABLE_STRIP = @ENABLE_STRIP@
|
||||
|
||||
USE_PTHREADS = @USE_PTHREADS@
|
||||
USE_BTHREADS = @USE_BTHREADS@
|
||||
PTHREADS_USER = @USE_USER_PTHREADS@
|
||||
CLASSIC_NSPR = @USE_NSPR_THREADS@
|
||||
|
||||
AS = @AS@
|
||||
ASFLAGS = @ASFLAGS@
|
||||
CC = @CC@
|
||||
CCC = @CXX@
|
||||
NS_USE_GCC = @GNU_CC@
|
||||
GCC_USE_GNU_LD = @GCC_USE_GNU_LD@
|
||||
MSC_VER = @MSC_VER@
|
||||
AR = @AR@
|
||||
AR_FLAGS = @AR_FLAGS@
|
||||
LD = @LD@
|
||||
RANLIB = @RANLIB@
|
||||
PERL = @PERL@
|
||||
RC = @RC@
|
||||
RCFLAGS = @RCFLAGS@
|
||||
STRIP = @STRIP@
|
||||
NSINSTALL = @NSINSTALL@
|
||||
FILTER = @FILTER@
|
||||
IMPLIB = @IMPLIB@
|
||||
CYGWIN_WRAPPER = @CYGWIN_WRAPPER@
|
||||
MT = @MT@
|
||||
|
||||
OS_CPPFLAGS = @CPPFLAGS@
|
||||
OS_CFLAGS = $(OS_CPPFLAGS) @CFLAGS@ $(DSO_CFLAGS)
|
||||
OS_CXXFLAGS = $(OS_CPPFLAGS) @CXXFLAGS@ $(DSO_CFLAGS)
|
||||
OS_LIBS = @OS_LIBS@
|
||||
OS_LDFLAGS = @LDFLAGS@
|
||||
OS_DLLFLAGS = @OS_DLLFLAGS@
|
||||
DLLFLAGS = @DLLFLAGS@
|
||||
EXEFLAGS = @EXEFLAGS@
|
||||
OPTIMIZER = @OPTIMIZER@
|
||||
|
||||
MKSHLIB = @MKSHLIB@
|
||||
DSO_CFLAGS = @DSO_CFLAGS@
|
||||
DSO_LDOPTS = @DSO_LDOPTS@
|
||||
|
||||
RESOLVE_LINK_SYMBOLS = @RESOLVE_LINK_SYMBOLS@
|
||||
|
||||
HOST_CC = @HOST_CC@
|
||||
HOST_CFLAGS = @HOST_CFLAGS@
|
||||
HOST_LDFLAGS = @HOST_LDFLAGS@
|
||||
|
||||
DEFINES = @DEFINES@ @DEFS@
|
||||
|
||||
MDCPUCFG_H = @MDCPUCFG_H@
|
||||
PR_MD_CSRCS = @PR_MD_CSRCS@
|
||||
PR_MD_ASFILES = @PR_MD_ASFILES@
|
||||
PR_MD_ARCH_DIR = @PR_MD_ARCH_DIR@
|
||||
CPU_ARCH = @CPU_ARCH@
|
||||
|
||||
OS_TARGET = @OS_TARGET@
|
||||
OS_ARCH = @OS_ARCH@
|
||||
OS_RELEASE = @OS_RELEASE@
|
||||
OS_TEST = @OS_TEST@
|
||||
|
||||
NOSUCHFILE = @NOSUCHFILE@
|
||||
AIX_LINK_OPTS = @AIX_LINK_OPTS@
|
||||
MOZ_OBJFORMAT = @MOZ_OBJFORMAT@
|
||||
ULTRASPARC_LIBRARY = @ULTRASPARC_LIBRARY@
|
||||
|
||||
OBJECT_MODE = @OBJECT_MODE@
|
||||
ifdef OBJECT_MODE
|
||||
export OBJECT_MODE
|
||||
endif
|
||||
|
||||
VISIBILITY_FLAGS = @VISIBILITY_FLAGS@
|
||||
WRAP_SYSTEM_INCLUDES = @WRAP_SYSTEM_INCLUDES@
|
||||
|
||||
MACOSX_DEPLOYMENT_TARGET = @MACOSX_DEPLOYMENT_TARGET@
|
||||
ifdef MACOSX_DEPLOYMENT_TARGET
|
||||
export MACOSX_DEPLOYMENT_TARGET
|
||||
endif
|
||||
|
||||
MACOS_SDK_DIR = @MACOS_SDK_DIR@
|
||||
|
||||
NEXT_ROOT = @NEXT_ROOT@
|
||||
ifdef NEXT_ROOT
|
||||
export NEXT_ROOT
|
||||
endif
|
||||
@@ -1,164 +0,0 @@
|
||||
#! gmake
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
# Configuration information for building in the NSPR source module
|
||||
|
||||
# Define an include-at-most-once-flag
|
||||
NSPR_CONFIG_MK = 1
|
||||
|
||||
#
|
||||
# The variable definitions in this file are inputs to NSPR's
|
||||
# build system. This file, if present, is included at the
|
||||
# beginning of config.mk.
|
||||
#
|
||||
# For example:
|
||||
#
|
||||
# BUILD_OPT=1
|
||||
# USE_PTHREADS=1
|
||||
# NS_USE_GCC=
|
||||
#
|
||||
ifndef topsrcdir
|
||||
topsrcdir=$(MOD_DEPTH)
|
||||
endif
|
||||
|
||||
ifndef srcdir
|
||||
srcdir=.
|
||||
endif
|
||||
|
||||
NFSPWD = $(MOD_DEPTH)/config/nfspwd
|
||||
|
||||
CFLAGS = $(VISIBILITY_FLAGS) $(CC_ONLY_FLAGS) $(OPTIMIZER)\
|
||||
$(OS_CFLAGS) $(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS)
|
||||
CCCFLAGS = $(VISIBILITY_FLAGS) $(CCC_ONLY_FLAGS) $(OPTIMIZER)\
|
||||
$(OS_CFLAGS) $(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS)
|
||||
# For purify
|
||||
NOMD_CFLAGS = $(CC_ONLY_FLAGS) $(OPTIMIZER) $(NOMD_OS_CFLAGS)\
|
||||
$(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS)
|
||||
NOMD_CCFLAGS = $(CCC_ONLY_FLAGS) $(OPTIMIZER) $(NOMD_OS_CFLAGS)\
|
||||
$(XP_DEFINE) $(DEFINES) $(INCLUDES) $(XCFLAGS)
|
||||
|
||||
LDFLAGS = $(OS_LDFLAGS)
|
||||
|
||||
define MAKE_OBJDIR
|
||||
if test ! -d $(@D); then rm -rf $(@D); $(NSINSTALL) -D $(@D); fi
|
||||
endef
|
||||
|
||||
LINK_DLL = $(LD) $(OS_DLLFLAGS) $(DLLFLAGS)
|
||||
|
||||
ifeq ($(OS_ARCH),Darwin)
|
||||
PWD := $(shell pwd)
|
||||
endif
|
||||
|
||||
ifeq (,$(CROSS_COMPILE)$(filter-out WINNT OS2, $(OS_ARCH)))
|
||||
INSTALL = $(NSINSTALL)
|
||||
else
|
||||
ifeq ($(NSDISTMODE),copy)
|
||||
# copy files, but preserve source mtime
|
||||
INSTALL = $(NSINSTALL) -t
|
||||
else
|
||||
ifeq ($(NSDISTMODE),absolute_symlink)
|
||||
# install using absolute symbolic links
|
||||
ifeq ($(OS_ARCH),Darwin)
|
||||
INSTALL = $(NSINSTALL) -L $(PWD)
|
||||
else
|
||||
INSTALL = $(NSINSTALL) -L `$(NFSPWD)`
|
||||
endif
|
||||
else
|
||||
# install using relative symbolic links
|
||||
INSTALL = $(NSINSTALL) -R
|
||||
endif
|
||||
endif
|
||||
endif # (WINNT || OS2) && !CROSS_COMPILE
|
||||
|
||||
DEPENDENCIES = $(OBJDIR)/.md
|
||||
|
||||
ifdef BUILD_DEBUG_GC
|
||||
DEFINES += -DDEBUG_GC
|
||||
endif
|
||||
|
||||
GARBAGE += $(DEPENDENCIES) core $(wildcard core.[0-9]*)
|
||||
|
||||
DIST_GARBAGE += Makefile
|
||||
|
||||
####################################################################
|
||||
#
|
||||
# The NSPR-specific configuration
|
||||
#
|
||||
####################################################################
|
||||
|
||||
DEFINES += -DFORCE_PR_LOG
|
||||
|
||||
ifeq ($(_PR_NO_CLOCK_TIMER),1)
|
||||
DEFINES += -D_PR_NO_CLOCK_TIMER
|
||||
endif
|
||||
|
||||
ifeq ($(USE_PTHREADS), 1)
|
||||
DEFINES += -D_PR_PTHREADS -UHAVE_CVAR_BUILT_ON_SEM
|
||||
endif
|
||||
|
||||
ifeq ($(PTHREADS_USER), 1)
|
||||
DEFINES += -DPTHREADS_USER -UHAVE_CVAR_BUILT_ON_SEM
|
||||
endif
|
||||
|
||||
ifeq ($(USE_IPV6),1)
|
||||
DEFINES += -D_PR_INET6
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_UNICODE),1)
|
||||
DEFINES += -DMOZ_UNICODE
|
||||
endif
|
||||
|
||||
####################################################################
|
||||
#
|
||||
# Configuration for the release process
|
||||
#
|
||||
####################################################################
|
||||
|
||||
MDIST = /m/dist
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
MDIST = //helium/dist
|
||||
MDIST_DOS = $(subst /,\\,$(MDIST))
|
||||
endif
|
||||
|
||||
# RELEASE_DIR is ns/dist/<module name>
|
||||
|
||||
RELEASE_DIR = $(MOD_DEPTH)/dist/release/$(MOD_NAME)
|
||||
|
||||
RELEASE_INCLUDE_DIR = $(RELEASE_DIR)/$(BUILD_NUMBER)/$(OBJDIR_NAME)/include
|
||||
RELEASE_BIN_DIR = $(RELEASE_DIR)/$(BUILD_NUMBER)/$(OBJDIR_NAME)/bin
|
||||
RELEASE_LIB_DIR = $(RELEASE_DIR)/$(BUILD_NUMBER)/$(OBJDIR_NAME)/lib
|
||||
@@ -1,2 +0,0 @@
|
||||
/* Begin all files as hidden visibility */
|
||||
#pragma GCC visibility push(hidden)
|
||||
@@ -1,158 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* libc_r.h -- macros, defines, etc. to make using reentrant libc calls */
|
||||
/* a bit easier. This was initially done for AIX pthreads, */
|
||||
/* but should be usable for anyone... */
|
||||
|
||||
/* Most of these use locally defined space instead of static library space. */
|
||||
/* Because of this, we use the _INIT_R to declare/allocate space (stack), */
|
||||
/* and the plain routines to actually do it..._WARNING_: avoid allocating */
|
||||
/* memory wherever possible. Memory allocation is fairly expensive, at */
|
||||
/* least on AIX...use arrays instead (which allocate from the stack.) */
|
||||
/* I know the names are a bit strange, but I wanted to be fairly certain */
|
||||
/* that we didn't have any namespace corruption...in general, the inits are */
|
||||
/* R_<name>_INIT_R(), and the actual calls are R_<name>_R(). */
|
||||
|
||||
#ifndef _LIBC_R_H
|
||||
#define _LIBC_R_H
|
||||
|
||||
/************/
|
||||
/* strtok */
|
||||
/************/
|
||||
#define R_STRTOK_INIT_R() \
|
||||
char *r_strtok_r=NULL
|
||||
|
||||
#define R_STRTOK_R(return,source,delim) \
|
||||
return=strtok_r(source,delim,&r_strtok_r)
|
||||
|
||||
#define R_STRTOK_NORET_R(source,delim) \
|
||||
strtok_r(source,delim,&r_strtok_r)
|
||||
|
||||
/**************/
|
||||
/* strerror */
|
||||
/**************/
|
||||
#define R_MAX_STRERROR_LEN_R 8192 /* Straight from limits.h */
|
||||
|
||||
#define R_STRERROR_INIT_R() \
|
||||
char r_strerror_r[R_MAX_STRERROR_LEN_R]
|
||||
|
||||
#define R_STRERROR_R(val) \
|
||||
strerror_r(val,r_strerror_r,R_MAX_STRERROR_LEN_R)
|
||||
|
||||
/*****************/
|
||||
/* time things */
|
||||
/*****************/
|
||||
#define R_ASCTIME_INIT_R() \
|
||||
char r_asctime_r[26]
|
||||
|
||||
#define R_ASCTIME_R(val) \
|
||||
asctime_r(val,r_asctime_r)
|
||||
|
||||
#define R_CTIME_INIT_R() \
|
||||
char r_ctime_r[26]
|
||||
|
||||
#define R_CTIME_R(val) \
|
||||
ctime_r(val,r_ctime_r)
|
||||
|
||||
#define R_GMTIME_INIT_R() \
|
||||
struct tm r_gmtime_r
|
||||
|
||||
#define R_GMTIME_R(time) \
|
||||
gmtime_r(time,&r_gmtime_r)
|
||||
|
||||
#define R_LOCALTIME_INIT_R() \
|
||||
struct tm r_localtime_r
|
||||
|
||||
#define R_LOCALTIME_R(val) \
|
||||
localtime_r(val,&r_localtime_r)
|
||||
|
||||
/***********/
|
||||
/* crypt */
|
||||
/***********/
|
||||
#include <crypt.h>
|
||||
#define R_CRYPT_INIT_R() \
|
||||
CRYPTD r_cryptd_r; \
|
||||
bzero(&r_cryptd_r,sizeof(CRYPTD))
|
||||
|
||||
#define R_CRYPT_R(pass,salt) \
|
||||
crypt_r(pass,salt,&r_cryptd_r)
|
||||
|
||||
/**************/
|
||||
/* pw stuff */
|
||||
/**************/
|
||||
#define R_MAX_PW_LEN_R 1024
|
||||
/* The following must be after the last declaration, but */
|
||||
/* before the first bit of code... */
|
||||
#define R_GETPWNAM_INIT_R(pw_ptr) \
|
||||
struct passwd r_getpwnam_pw_r; \
|
||||
char r_getpwnam_line_r[R_MAX_PW_LEN_R]; \
|
||||
pw_ptr = &r_getpwnam_pw_r
|
||||
|
||||
#define R_GETPWNAM_R(name) \
|
||||
getpwnam_r(name,&r_getpwnam_pw_r,r_getpwnam_line_r,R_MAX_PW_LEN_R)
|
||||
|
||||
/*******************/
|
||||
/* gethost stuff */
|
||||
/*******************/
|
||||
#define R_GETHOSTBYADDR_INIT_R() \
|
||||
struct hostent r_gethostbyaddr_r; \
|
||||
struct hostent_data r_gethostbyaddr_data_r
|
||||
|
||||
#define R_GETHOSTBYADDR_R(addr,len,type,xptr_ent) \
|
||||
bzero(&r_gethostbyaddr_r,sizeof(struct hostent)); \
|
||||
bzero(&r_gethostbyaddr_data_r,sizeof(struct hostent_data)); \
|
||||
xptr_ent = &r_gethostbyaddr_r; \
|
||||
if (gethostbyaddr_r(addr,len,type, \
|
||||
&r_gethostbyaddr_r,&r_gethostbyaddr_data_r) == -1) { \
|
||||
xptr_ent = NULL; \
|
||||
}
|
||||
|
||||
#define R_GETHOSTBYNAME_INIT_R() \
|
||||
struct hostent r_gethostbyname_r; \
|
||||
struct hostent_data r_gethostbyname_data_r
|
||||
|
||||
#define R_GETHOSTBYNAME_R(name,xptr_ent) \
|
||||
bzero(&r_gethostbyname_r,sizeof(struct hostent)); \
|
||||
bzero(&r_gethostbyname_data_r,sizeof(struct hostent_data)); \
|
||||
xptr_ent = &r_gethostbyname_r; \
|
||||
if (gethostbyname_r(name, \
|
||||
&r_gethostbyname_r,&r_gethostbyname_data_r) == -1) { \
|
||||
xptr_ent = NULL; \
|
||||
}
|
||||
|
||||
#endif /* _LIBC_R_H */
|
||||
@@ -1,59 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# IBM Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2004
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Brian Ryner <bryner@brianryner.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
$output_dir = shift;
|
||||
|
||||
while (<STDIN>) {
|
||||
chomp;
|
||||
if (-e "$output_dir/$_") {
|
||||
next;
|
||||
}
|
||||
|
||||
if (/(.*)\/[^\/*]/) {
|
||||
mkdir "$output_dir/$1";
|
||||
}
|
||||
|
||||
open OUT, ">$output_dir/$_";
|
||||
print OUT "#pragma GCC system_header\n"; # suppress include_next warning
|
||||
print OUT "#pragma GCC visibility push(default)\n";
|
||||
print OUT "#include_next \<$_\>\n";
|
||||
print OUT "#pragma GCC visibility pop\n";
|
||||
close OUT;
|
||||
}
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
#! perl
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE 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");
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(VMS)
|
||||
#include <sys/timeb.h>
|
||||
#elif defined(XP_UNIX) || defined(XP_OS2_EMX) || defined(XP_BEOS)
|
||||
#include <sys/time.h>
|
||||
#elif defined(WIN32)
|
||||
#include <windows.h>
|
||||
#elif defined(XP_OS2_VACPP)
|
||||
#include <sys/timeb.h>
|
||||
#else
|
||||
#error "Architecture not supported"
|
||||
#endif
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
#if defined(OMIT_LIB_BUILD_TIME)
|
||||
/*
|
||||
* Some platforms don't have any 64-bit integer type
|
||||
* such as 'long long'. Because we can't use NSPR's
|
||||
* PR_snprintf in this program, it is difficult to
|
||||
* print a static initializer for PRInt64 (a struct).
|
||||
* So we print nothing. The makefiles that build the
|
||||
* shared libraries will detect the empty output string
|
||||
* of this program and omit the library build time
|
||||
* in PRVersionDescription.
|
||||
*/
|
||||
#elif defined(VMS)
|
||||
long long now;
|
||||
struct timeb b;
|
||||
ftime(&b);
|
||||
now = b.time;
|
||||
now *= 1000000;
|
||||
now += (1000 * b.millitm);
|
||||
fprintf(stdout, "%Ld", now);
|
||||
#elif defined(XP_UNIX) || defined(XP_OS2_EMX) || defined(XP_BEOS)
|
||||
long long now;
|
||||
struct timeval tv;
|
||||
#ifdef HAVE_SVID_GETTOD
|
||||
gettimeofday(&tv);
|
||||
#else
|
||||
gettimeofday(&tv, NULL);
|
||||
#endif
|
||||
now = ((1000000LL) * tv.tv_sec) + (long long)tv.tv_usec;
|
||||
#if defined(OSF1)
|
||||
fprintf(stdout, "%ld", now);
|
||||
#elif defined(BEOS) && defined(__POWERPC__)
|
||||
fprintf(stdout, "%Ld", now); /* Metroworks on BeOS PPC */
|
||||
#else
|
||||
fprintf(stdout, "%lld", now);
|
||||
#endif
|
||||
|
||||
#elif defined(WIN32)
|
||||
__int64 now;
|
||||
FILETIME ft;
|
||||
GetSystemTimeAsFileTime(&ft);
|
||||
CopyMemory(&now, &ft, sizeof(now));
|
||||
/*
|
||||
* 116444736000000000 is the number of 100-nanosecond intervals
|
||||
* between Jan. 1, 1601 and Jan. 1, 1970.
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
now = (now - 116444736000000000LL) / 10LL;
|
||||
fprintf(stdout, "%lld", now);
|
||||
#else
|
||||
now = (now - 116444736000000000i64) / 10i64;
|
||||
fprintf(stdout, "%I64d", now);
|
||||
#endif
|
||||
|
||||
#elif defined(XP_OS2_VACPP)
|
||||
/* no long long or i64 so we use a string */
|
||||
#include <string.h>
|
||||
char buf[24];
|
||||
char tbuf[7];
|
||||
time_t now;
|
||||
long mtime;
|
||||
int i;
|
||||
|
||||
struct timeb b;
|
||||
ftime(&b);
|
||||
now = b.time;
|
||||
_ltoa(now, buf, 10);
|
||||
|
||||
mtime = b.millitm * 1000;
|
||||
if (mtime == 0){
|
||||
++now;
|
||||
strcat(buf, "000000");
|
||||
} else {
|
||||
_ltoa(mtime, tbuf, 10);
|
||||
for (i = strlen(tbuf); i < 6; ++i)
|
||||
strcat(buf, "0");
|
||||
strcat(buf, tbuf);
|
||||
}
|
||||
fprintf(stdout, "%s", buf);
|
||||
|
||||
#else
|
||||
#error "Architecture not supported"
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
} /* main */
|
||||
|
||||
/* now.c */
|
||||
@@ -1,602 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE 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 <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <utime.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#ifdef USE_REENTRANT_LIBC
|
||||
#include "libc_r.h"
|
||||
#endif /* USE_REENTRANT_LIBC */
|
||||
|
||||
#include "pathsub.h"
|
||||
|
||||
#define HAVE_FCHMOD
|
||||
|
||||
#if defined(BEOS)
|
||||
#undef HAVE_FCHMOD
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Does getcwd() take NULL as the first argument and malloc
|
||||
* the result buffer?
|
||||
*/
|
||||
#if !defined(DARWIN) && !defined(NEXTSTEP) && !defined(VMS)
|
||||
#define GETCWD_CAN_MALLOC
|
||||
#endif
|
||||
|
||||
#ifdef NEXTSTEP
|
||||
#include <bsd/libc.h>
|
||||
|
||||
/*
|
||||
** balazs.pataki@sztaki.hu: The getcwd is broken in NEXTSTEP (returns 0),
|
||||
** when called on a mounted fs. Did anyone notice this? Here's an ugly
|
||||
** workaround ...
|
||||
*/
|
||||
#define getcwd(b,s) my_getcwd(b,s)
|
||||
|
||||
static char *
|
||||
my_getcwd (char *buf, size_t size)
|
||||
{
|
||||
FILE *pwd = popen("pwd", "r");
|
||||
char *result = fgets(buf, size, pwd);
|
||||
|
||||
if (result) {
|
||||
buf[strlen(buf)-1] = '\0';
|
||||
}
|
||||
pclose (pwd);
|
||||
return buf;
|
||||
}
|
||||
#endif /* NEXTSTEP */
|
||||
|
||||
#if defined(LINUX) || defined(__GNU__) || defined(__GLIBC__)
|
||||
#include <getopt.h>
|
||||
#endif
|
||||
|
||||
#if defined(SCO) || defined(UNIXWARE) || defined(SNI) || defined(NCR) || defined(NEC) || defined(NEXTSTEP)
|
||||
#if !defined(S_ISLNK) && defined(S_IFLNK)
|
||||
#define S_ISLNK(a) (((a) & S_IFMT) == S_IFLNK)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(SNI)
|
||||
extern int fchmod(int fildes, mode_t mode);
|
||||
#endif
|
||||
|
||||
#ifdef QNX
|
||||
#define d_ino d_stat.st_ino
|
||||
#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, (int)strlen(program), "");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
static int
|
||||
mkdirs(char *path, mode_t mode)
|
||||
{
|
||||
char *cp;
|
||||
struct stat sb;
|
||||
int res;
|
||||
|
||||
while (*path == '/' && path[1] == '/')
|
||||
path++;
|
||||
for (cp = strrchr(path, '/'); cp && cp != path && cp[-1] == '/'; cp--)
|
||||
;
|
||||
if (cp && cp != path) {
|
||||
*cp = '\0';
|
||||
if ((stat(path, &sb) < 0 || !S_ISDIR(sb.st_mode)) &&
|
||||
mkdirs(path, mode) < 0) {
|
||||
return -1;
|
||||
}
|
||||
*cp = '/';
|
||||
}
|
||||
res = mkdir(path, mode);
|
||||
if ((res != 0) && (errno == EEXIST))
|
||||
return 0;
|
||||
else
|
||||
return res;
|
||||
}
|
||||
|
||||
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, opt, len, lplen, tdlen, bnlen, exists, fromfd, tofd, cc, wc;
|
||||
mode_t mode = 0755;
|
||||
char *linkprefix, *owner, *group, *cp, *cwd, *todir, *toname, *name, *base, *linkname, *bp, buf[BUFSIZ];
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
struct stat sb, tosb;
|
||||
struct utimbuf utb;
|
||||
|
||||
program = argv[0];
|
||||
cwd = linkname = linkprefix = owner = group = 0;
|
||||
onlydir = dodir = dolink = dorelsymlink = dotimes = lplen = 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) {
|
||||
#ifdef GETCWD_CAN_MALLOC
|
||||
cwd = getcwd(0, PATH_MAX);
|
||||
#else
|
||||
cwd = malloc(PATH_MAX + 1);
|
||||
cwd = getcwd(cwd, PATH_MAX);
|
||||
#endif
|
||||
}
|
||||
xchdir(todir);
|
||||
#ifdef GETCWD_CAN_MALLOC
|
||||
todir = getcwd(0, PATH_MAX);
|
||||
#else
|
||||
todir = malloc(PATH_MAX + 1);
|
||||
todir = getcwd(todir, PATH_MAX);
|
||||
#endif
|
||||
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 = (char*)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 = (char*)xmalloc(len + 1);
|
||||
sprintf(linkname, "%s/%s", linkprefix, name);
|
||||
} else if (dorelsymlink) {
|
||||
/* Symlink the relative path from todir to source name. */
|
||||
linkname = (char*)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);
|
||||
/*
|
||||
** On OpenVMS we can't chmod() until the file is closed, and we
|
||||
** have to utime() last since fchown/chmod alter the timestamps.
|
||||
*/
|
||||
#ifndef VMS
|
||||
if (dotimes) {
|
||||
utb.actime = sb.st_atime;
|
||||
utb.modtime = sb.st_mtime;
|
||||
if (utime(toname, &utb) < 0)
|
||||
fail("cannot set times of %s", toname);
|
||||
}
|
||||
#ifdef HAVE_FCHMOD
|
||||
if (fchmod(tofd, mode) < 0)
|
||||
#else
|
||||
if (chmod(toname, mode) < 0)
|
||||
#endif
|
||||
fail("cannot change mode of %s", toname);
|
||||
#endif
|
||||
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);
|
||||
#ifdef VMS
|
||||
if (chmod(toname, mode) < 0)
|
||||
fail("cannot change mode of %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);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
free(toname);
|
||||
}
|
||||
|
||||
free(cwd);
|
||||
free(todir);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Pathname subroutines.
|
||||
**
|
||||
** Brendan Eich, 8/29/95
|
||||
*/
|
||||
|
||||
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_READDIR_BUFFER_TOO_SMALL
|
||||
/* 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((char*)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);
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
prefix=@prefix@
|
||||
|
||||
major_version=@MOD_MAJOR_VERSION@
|
||||
minor_version=@MOD_MINOR_VERSION@
|
||||
patch_version=@MOD_PATCH_VERSION@
|
||||
|
||||
usage()
|
||||
{
|
||||
cat <<EOF
|
||||
Usage: nspr-config [OPTIONS] [LIBRARIES]
|
||||
Options:
|
||||
[--prefix[=DIR]]
|
||||
[--exec-prefix[=DIR]]
|
||||
[--includedir[=DIR]]
|
||||
[--libdir[=DIR]]
|
||||
[--version]
|
||||
[--libs]
|
||||
[--cflags]
|
||||
Libraries:
|
||||
nspr
|
||||
plc
|
||||
plds
|
||||
EOF
|
||||
exit $1
|
||||
}
|
||||
|
||||
if test $# -eq 0; then
|
||||
usage 1 1>&2
|
||||
fi
|
||||
|
||||
lib_nspr=yes
|
||||
lib_plc=yes
|
||||
lib_plds=yes
|
||||
|
||||
while test $# -gt 0; do
|
||||
case "$1" in
|
||||
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
|
||||
*) optarg= ;;
|
||||
esac
|
||||
|
||||
case $1 in
|
||||
--prefix=*)
|
||||
prefix=$optarg
|
||||
;;
|
||||
--prefix)
|
||||
echo_prefix=yes
|
||||
;;
|
||||
--exec-prefix=*)
|
||||
exec_prefix=$optarg
|
||||
;;
|
||||
--exec-prefix)
|
||||
echo_exec_prefix=yes
|
||||
;;
|
||||
--includedir=*)
|
||||
includedir=$optarg
|
||||
;;
|
||||
--includedir)
|
||||
echo_includedir=yes
|
||||
;;
|
||||
--libdir=*)
|
||||
libdir=$optarg
|
||||
;;
|
||||
--libdir)
|
||||
echo_libdir=yes
|
||||
;;
|
||||
--version)
|
||||
echo ${major_version}.${minor_version}.${patch_version}
|
||||
;;
|
||||
--cflags)
|
||||
echo_cflags=yes
|
||||
;;
|
||||
--libs)
|
||||
echo_libs=yes
|
||||
;;
|
||||
nspr)
|
||||
lib_nspr=yes
|
||||
;;
|
||||
plc)
|
||||
lib_plc=yes
|
||||
;;
|
||||
plds)
|
||||
lib_plds=yes
|
||||
;;
|
||||
*)
|
||||
usage 1 1>&2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# Set variables that may be dependent upon other variables
|
||||
if test -z "$exec_prefix"; then
|
||||
exec_prefix=@exec_prefix@
|
||||
fi
|
||||
if test -z "$includedir"; then
|
||||
includedir=@includedir@
|
||||
fi
|
||||
if test -z "$libdir"; then
|
||||
libdir=@libdir@
|
||||
fi
|
||||
|
||||
if test "$echo_prefix" = "yes"; then
|
||||
echo $prefix
|
||||
fi
|
||||
|
||||
if test "$echo_exec_prefix" = "yes"; then
|
||||
echo $exec_prefix
|
||||
fi
|
||||
|
||||
if test "$echo_includedir" = "yes"; then
|
||||
echo $includedir
|
||||
fi
|
||||
|
||||
if test "$echo_libdir" = "yes"; then
|
||||
echo $libdir
|
||||
fi
|
||||
|
||||
if test "$echo_cflags" = "yes"; then
|
||||
echo -I$includedir
|
||||
fi
|
||||
|
||||
if test "$echo_libs" = "yes"; then
|
||||
libdirs=-L$libdir
|
||||
if test -n "$lib_plds"; then
|
||||
libdirs="$libdirs -lplds${major_version}"
|
||||
fi
|
||||
if test -n "$lib_plc"; then
|
||||
libdirs="$libdirs -lplc${major_version}"
|
||||
fi
|
||||
if test -n "$lib_nspr"; then
|
||||
libdirs="$libdirs -lnspr${major_version}"
|
||||
fi
|
||||
os_ldflags="@LDFLAGS@"
|
||||
for i in $os_ldflags ; do
|
||||
if echo $i | grep \^-L >/dev/null; then
|
||||
libdirs="$libdirs $i"
|
||||
fi
|
||||
done
|
||||
echo $libdirs @OS_LIBS@
|
||||
fi
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
# -*- tab-width: 4; -*-
|
||||
# Configure paths for NSPR
|
||||
# Public domain - Chris Seawood <cls@seawood.org> 2001-04-05
|
||||
# Based upon gtk.m4 (also PD) by Owen Taylor
|
||||
|
||||
dnl AM_PATH_NSPR([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
|
||||
dnl Test for NSPR, and define NSPR_CFLAGS and NSPR_LIBS
|
||||
AC_DEFUN([AM_PATH_NSPR],
|
||||
[dnl
|
||||
|
||||
AC_ARG_WITH(nspr-prefix,
|
||||
[ --with-nspr-prefix=PFX Prefix where NSPR is installed],
|
||||
nspr_config_prefix="$withval",
|
||||
nspr_config_prefix="")
|
||||
|
||||
AC_ARG_WITH(nspr-exec-prefix,
|
||||
[ --with-nspr-exec-prefix=PFX
|
||||
Exec prefix where NSPR is installed],
|
||||
nspr_config_exec_prefix="$withval",
|
||||
nspr_config_exec_prefix="")
|
||||
|
||||
if test -n "$nspr_config_exec_prefix"; then
|
||||
nspr_config_args="$nspr_config_args --exec-prefix=$nspr_config_exec_prefix"
|
||||
if test -z "$NSPR_CONFIG"; then
|
||||
NSPR_CONFIG=$nspr_config_exec_prefix/bin/nspr-config
|
||||
fi
|
||||
fi
|
||||
if test -n "$nspr_config_prefix"; then
|
||||
nspr_config_args="$nspr_config_args --prefix=$nspr_config_prefix"
|
||||
if test -z "$NSPR_CONFIG"; then
|
||||
NSPR_CONFIG=$nspr_config_prefix/bin/nspr-config
|
||||
fi
|
||||
fi
|
||||
|
||||
unset ac_cv_path_NSPR_CONFIG
|
||||
AC_PATH_PROG(NSPR_CONFIG, nspr-config, no)
|
||||
min_nspr_version=ifelse([$1], ,4.0.0,$1)
|
||||
AC_MSG_CHECKING(for NSPR - version >= $min_nspr_version (skipping))
|
||||
|
||||
no_nspr=""
|
||||
if test "$NSPR_CONFIG" = "no"; then
|
||||
no_nspr="yes"
|
||||
else
|
||||
NSPR_CFLAGS=`$NSPR_CONFIG $nspr_config_args --cflags`
|
||||
NSPR_LIBS=`$NSPR_CONFIG $nspr_config_args --libs`
|
||||
|
||||
dnl Skip version check for now
|
||||
nspr_config_major_version=`$NSPR_CONFIG $nspr_config_args --version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
|
||||
nspr_config_minor_version=`$NSPR_CONFIG $nspr_config_args --version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
|
||||
nspr_config_micro_version=`$NSPR_CONFIG $nspr_config_args --version | \
|
||||
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
|
||||
fi
|
||||
|
||||
if test -z "$no_nspr"; then
|
||||
AC_MSG_RESULT(yes)
|
||||
ifelse([$2], , :, [$2])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
|
||||
|
||||
AC_SUBST(NSPR_CFLAGS)
|
||||
AC_SUBST(NSPR_LIBS)
|
||||
|
||||
])
|
||||
@@ -1,5 +0,0 @@
|
||||
# Include in Makefiles to define NSPR variables
|
||||
|
||||
NSPR_VERSION = @NSPR_VERSION@
|
||||
NSPR_LIB = -lnspr@NSPR_VERSION@
|
||||
NSPR_EXTRA_LIBS = @EXTRA_LIBS@
|
||||
@@ -1,5 +0,0 @@
|
||||
# Include in shell scripts to define NSPR variables
|
||||
|
||||
NSPR_VERSION=@NSPR_VERSION@
|
||||
NSPR_LIB=-lnspr$NSPR_VERSION
|
||||
NSPR_EXTRA_LIBS="@EXTRA_LIBS@"
|
||||
@@ -1,78 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef pathsub_h___
|
||||
#define pathsub_h___
|
||||
/*
|
||||
** Pathname subroutines.
|
||||
**
|
||||
** Brendan Eich, 8/29/95
|
||||
*/
|
||||
#include <limits.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if SUNOS4
|
||||
#include "../pr/include/md/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___ */
|
||||
@@ -1,44 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* A dummy header file that is a dependency for all the object files.
|
||||
* Used to force a full recompilation of NSPR in Mozilla's Tinderbox
|
||||
* depend builds. See comments in rules.mk.
|
||||
*/
|
||||
|
||||
#error "Do not include this header file."
|
||||
@@ -1,38 +0,0 @@
|
||||
REM
|
||||
REM ***** BEGIN LICENSE BLOCK *****
|
||||
REM Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
REM
|
||||
REM The contents of this file are subject to the Mozilla Public License Version
|
||||
REM 1.1 (the "License"); you may not use this file except in compliance with
|
||||
REM the License. You may obtain a copy of the License at
|
||||
REM http://www.mozilla.org/MPL/
|
||||
REM
|
||||
REM Software distributed under the License is distributed on an "AS IS" basis,
|
||||
REM WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
REM for the specific language governing rights and limitations under the
|
||||
REM License.
|
||||
REM
|
||||
REM The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
REM
|
||||
REM The Initial Developer of the Original Code is
|
||||
REM Netscape Communications Corporation.
|
||||
REM Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
REM the Initial Developer. All Rights Reserved.
|
||||
REM
|
||||
REM Contributor(s):
|
||||
REM
|
||||
REM Alternatively, the contents of this file may be used under the terms of
|
||||
REM either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
REM the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
REM in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
REM of those above. If you wish to allow use of your version of this file only
|
||||
REM under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
REM use your version of this file under the terms of the MPL, indicate your
|
||||
REM decision by deleting the provisions above and replace them with the notice
|
||||
REM and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
REM the provisions above, a recipient may use your version of this file under
|
||||
REM the terms of any one of the MPL, the GPL or the LGPL.
|
||||
REM
|
||||
REM ***** END LICENSE BLOCK *****
|
||||
|
||||
mkdir %1
|
||||
@@ -1,527 +0,0 @@
|
||||
#! gmake
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
################################################################################
|
||||
# We used to have a 4 pass build process. Now we do everything in one pass.
|
||||
#
|
||||
# export - Create generated headers and stubs. Publish public headers to
|
||||
# dist/<arch>/include.
|
||||
# Create libraries. Publish libraries to dist/<arch>/lib.
|
||||
# Create programs.
|
||||
#
|
||||
# libs - obsolete. Now a synonym of "export".
|
||||
#
|
||||
# all - the default makefile target. Now a synonym of "export".
|
||||
#
|
||||
# install - Install headers, libraries, and programs on the system.
|
||||
#
|
||||
# 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 -- .c 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)
|
||||
#
|
||||
################################################################################
|
||||
|
||||
ifndef topsrcdir
|
||||
topsrcdir=$(MOD_DEPTH)
|
||||
endif
|
||||
|
||||
ifndef srcdir
|
||||
srcdir=.
|
||||
endif
|
||||
|
||||
ifndef NSPR_CONFIG_MK
|
||||
include $(topsrcdir)/config/config.mk
|
||||
endif
|
||||
|
||||
ifdef USE_AUTOCONF
|
||||
ifdef CROSS_COMPILE
|
||||
ifdef INTERNAL_TOOLS
|
||||
CC=$(HOST_CC)
|
||||
CCC=$(HOST_CXX)
|
||||
CFLAGS=$(HOST_CFLAGS)
|
||||
CXXFLAGS=$(HOST_CXXFLAGS)
|
||||
LDFLAGS=$(HOST_LDFLAGS)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
#
|
||||
# This makefile contains rules for building the following kinds of
|
||||
# libraries:
|
||||
# - LIBRARY: a static (archival) library
|
||||
# - SHARED_LIBRARY: a shared (dynamic link) library
|
||||
# - IMPORT_LIBRARY: an import library, used only on Windows and OS/2
|
||||
#
|
||||
# The names of these libraries can be generated by simply specifying
|
||||
# LIBRARY_NAME and LIBRARY_VERSION.
|
||||
#
|
||||
|
||||
ifdef LIBRARY_NAME
|
||||
ifeq (,$(filter-out WINNT OS2,$(OS_ARCH)))
|
||||
|
||||
#
|
||||
# Win95, Win16, and OS/2 require library names conforming to the 8.3 rule.
|
||||
# other platforms do not.
|
||||
#
|
||||
ifeq (,$(filter-out WIN95 OS2,$(OS_TARGET)))
|
||||
LIBRARY = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION)_s.$(LIB_SUFFIX)
|
||||
SHARED_LIBRARY = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX)
|
||||
IMPORT_LIBRARY = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION).$(LIB_SUFFIX)
|
||||
SHARED_LIB_PDB = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION).pdb
|
||||
else
|
||||
LIBRARY = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION)_s.$(LIB_SUFFIX)
|
||||
SHARED_LIBRARY = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX)
|
||||
IMPORT_LIBRARY = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION).$(LIB_SUFFIX)
|
||||
SHARED_LIB_PDB = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION).pdb
|
||||
endif
|
||||
|
||||
else
|
||||
|
||||
LIBRARY = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION).$(LIB_SUFFIX)
|
||||
ifeq ($(OS_ARCH)$(OS_RELEASE), AIX4.1)
|
||||
SHARED_LIBRARY = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION)_shr.a
|
||||
else
|
||||
ifdef MKSHLIB
|
||||
SHARED_LIBRARY = $(OBJDIR)/lib$(LIBRARY_NAME)$(LIBRARY_VERSION).$(DLL_SUFFIX)
|
||||
endif
|
||||
endif
|
||||
|
||||
endif
|
||||
endif
|
||||
|
||||
ifndef TARGETS
|
||||
ifeq (,$(filter-out WINNT OS2,$(OS_ARCH)))
|
||||
TARGETS = $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY)
|
||||
ifndef BUILD_OPT
|
||||
ifdef MSC_VER
|
||||
ifneq (,$(filter-out 1100 1200,$(MSC_VER)))
|
||||
TARGETS += $(SHARED_LIB_PDB)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
else
|
||||
TARGETS = $(LIBRARY) $(SHARED_LIBRARY)
|
||||
endif
|
||||
endif
|
||||
|
||||
#
|
||||
# OBJS is the list of object files. It can be constructed by
|
||||
# specifying CSRCS (list of C source files) and ASFILES (list
|
||||
# of assembly language source files).
|
||||
#
|
||||
|
||||
ifndef OBJS
|
||||
OBJS = $(addprefix $(OBJDIR)/,$(CSRCS:.c=.$(OBJ_SUFFIX))) \
|
||||
$(addprefix $(OBJDIR)/,$(ASFILES:.$(ASM_SUFFIX)=.$(OBJ_SUFFIX)))
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_OS2_TOOLS),VACPP)
|
||||
EXTRA_LIBS := $(patsubst -l%,$(DIST)/lib/%.$(LIB_SUFFIX),$(EXTRA_LIBS))
|
||||
endif
|
||||
|
||||
ALL_TRASH = $(TARGETS) $(OBJS) $(RES) $(filter-out . .., $(OBJDIR)) LOGS TAGS $(GARBAGE) \
|
||||
$(NOSUCHFILE) \
|
||||
so_locations
|
||||
|
||||
ifeq ($(OS_ARCH),OpenVMS)
|
||||
ALL_TRASH += $(wildcard *.c*_defines)
|
||||
ifdef SHARED_LIBRARY
|
||||
VMS_SYMVEC_FILE = $(SHARED_LIBRARY:.$(DLL_SUFFIX)=_symvec.opt)
|
||||
VMS_SYMVEC_FILE_MODULE = $(srcdir)/$(LIBRARY_NAME)_symvec.opt
|
||||
ALL_TRASH += $(VMS_SYMVEC_FILE)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifndef RELEASE_LIBS_DEST
|
||||
RELEASE_LIBS_DEST = $(RELEASE_LIB_DIR)
|
||||
endif
|
||||
|
||||
ifdef DIRS
|
||||
LOOP_OVER_DIRS = \
|
||||
@for d in $(DIRS); do \
|
||||
if test -d $$d; then \
|
||||
set -e; \
|
||||
echo "cd $$d; $(MAKE) $@"; \
|
||||
$(MAKE) -C $$d $@; \
|
||||
set +e; \
|
||||
else \
|
||||
echo "Skipping non-directory $$d..."; \
|
||||
fi; \
|
||||
done
|
||||
endif
|
||||
|
||||
################################################################################
|
||||
|
||||
all:: export
|
||||
|
||||
export::
|
||||
+$(LOOP_OVER_DIRS)
|
||||
|
||||
libs:: export
|
||||
|
||||
clean::
|
||||
rm -rf $(OBJS) $(RES) so_locations $(NOSUCHFILE) $(GARBAGE)
|
||||
+$(LOOP_OVER_DIRS)
|
||||
|
||||
clobber::
|
||||
rm -rf $(OBJS) $(RES) $(TARGETS) $(filter-out . ..,$(OBJDIR)) $(GARBAGE) so_locations $(NOSUCHFILE)
|
||||
+$(LOOP_OVER_DIRS)
|
||||
|
||||
realclean clobber_all::
|
||||
rm -rf $(wildcard *.OBJ *.OBJD) dist $(ALL_TRASH)
|
||||
+$(LOOP_OVER_DIRS)
|
||||
|
||||
distclean::
|
||||
rm -rf $(wildcard *.OBJ *.OBJD) dist $(ALL_TRASH) $(DIST_GARBAGE)
|
||||
+$(LOOP_OVER_DIRS)
|
||||
|
||||
install:: $(RELEASE_BINS) $(RELEASE_HEADERS) $(RELEASE_LIBS)
|
||||
ifdef RELEASE_BINS
|
||||
$(NSINSTALL) -t -m 0755 $(RELEASE_BINS) $(DESTDIR)$(bindir)
|
||||
endif
|
||||
ifdef RELEASE_HEADERS
|
||||
$(NSINSTALL) -t -m 0644 $(RELEASE_HEADERS) $(DESTDIR)$(includedir)/$(include_subdir)
|
||||
endif
|
||||
ifdef RELEASE_LIBS
|
||||
$(NSINSTALL) -t -m 0755 $(RELEASE_LIBS) $(DESTDIR)$(libdir)/$(lib_subdir)
|
||||
endif
|
||||
+$(LOOP_OVER_DIRS)
|
||||
|
||||
release:: export
|
||||
ifdef RELEASE_BINS
|
||||
@echo "Copying executable programs and scripts to release directory"
|
||||
@if test -z "$(BUILD_NUMBER)"; then \
|
||||
echo "BUILD_NUMBER must be defined"; \
|
||||
false; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
@if test ! -d $(RELEASE_BIN_DIR); then \
|
||||
rm -rf $(RELEASE_BIN_DIR); \
|
||||
$(NSINSTALL) -D $(RELEASE_BIN_DIR);\
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
cp $(RELEASE_BINS) $(RELEASE_BIN_DIR)
|
||||
endif
|
||||
ifdef RELEASE_LIBS
|
||||
@echo "Copying libraries to release directory"
|
||||
@if test -z "$(BUILD_NUMBER)"; then \
|
||||
echo "BUILD_NUMBER must be defined"; \
|
||||
false; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
@if test ! -d $(RELEASE_LIBS_DEST); then \
|
||||
rm -rf $(RELEASE_LIBS_DEST); \
|
||||
$(NSINSTALL) -D $(RELEASE_LIBS_DEST);\
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
cp $(RELEASE_LIBS) $(RELEASE_LIBS_DEST)
|
||||
endif
|
||||
ifdef RELEASE_HEADERS
|
||||
@echo "Copying header files to release directory"
|
||||
@if test -z "$(BUILD_NUMBER)"; then \
|
||||
echo "BUILD_NUMBER must be defined"; \
|
||||
false; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
@if test ! -d $(RELEASE_HEADERS_DEST); then \
|
||||
rm -rf $(RELEASE_HEADERS_DEST); \
|
||||
$(NSINSTALL) -D $(RELEASE_HEADERS_DEST);\
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
cp $(RELEASE_HEADERS) $(RELEASE_HEADERS_DEST)
|
||||
endif
|
||||
+$(LOOP_OVER_DIRS)
|
||||
|
||||
alltags:
|
||||
rm -f TAGS tags
|
||||
find . -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' \) -print | xargs etags -a
|
||||
find . -name dist -prune -o \( -name '*.[hc]' -o -name '*.cp' -o -name '*.cpp' \) -print | xargs ctags -a
|
||||
|
||||
$(NFSPWD):
|
||||
cd $(@D); $(MAKE) $(@F)
|
||||
|
||||
$(PROGRAM): $(OBJS)
|
||||
@$(MAKE_OBJDIR)
|
||||
ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT)
|
||||
$(CC) $(OBJS) -Fe$@ -link $(LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS)
|
||||
ifdef MT
|
||||
@if test -f $@.manifest; then \
|
||||
$(MT) -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
|
||||
rm -f $@.manifest; \
|
||||
fi
|
||||
endif # MSVC with manifest tool
|
||||
else # WINNT && !GCC
|
||||
ifeq ($(MOZ_OS2_TOOLS),VACPP)
|
||||
$(CC) $(OBJS) -Fe$@ $(LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS)
|
||||
else
|
||||
$(CC) -o $@ $(CFLAGS) $(OBJS) $(LDFLAGS)
|
||||
endif
|
||||
endif # WINNT && !GCC
|
||||
ifdef ENABLE_STRIP
|
||||
$(STRIP) $@
|
||||
endif
|
||||
|
||||
$(LIBRARY): $(OBJS)
|
||||
@$(MAKE_OBJDIR)
|
||||
rm -f $@
|
||||
ifeq ($(MOZ_OS2_TOOLS),VACPP)
|
||||
$(AR) $(subst /,\\,$(OBJS)) $(AR_FLAGS)
|
||||
else
|
||||
$(AR) $(AR_FLAGS) $(OBJS) $(AR_EXTRA_ARGS)
|
||||
endif
|
||||
$(RANLIB) $@
|
||||
|
||||
ifeq ($(OS_TARGET), OS2)
|
||||
$(IMPORT_LIBRARY): $(MAPFILE)
|
||||
rm -f $@
|
||||
$(IMPLIB) $@ $(MAPFILE)
|
||||
endif
|
||||
|
||||
$(SHARED_LIBRARY): $(OBJS) $(RES) $(MAPFILE)
|
||||
@$(MAKE_OBJDIR)
|
||||
rm -f $@
|
||||
ifeq ($(OS_ARCH)$(OS_RELEASE), AIX4.1)
|
||||
echo "#!" > $(OBJDIR)/lib$(LIBRARY_NAME)_syms
|
||||
nm -B -C -g $(OBJS) \
|
||||
| awk '/ [T,D] / {print $$3}' \
|
||||
| sed -e 's/^\.//' \
|
||||
| sort -u >> $(OBJDIR)/lib$(LIBRARY_NAME)_syms
|
||||
$(LD) $(XCFLAGS) -o $@ $(OBJS) -bE:$(OBJDIR)/lib$(LIBRARY_NAME)_syms \
|
||||
-bM:SRE -bnoentry $(OS_LIBS) $(EXTRA_LIBS)
|
||||
else # AIX 4.1
|
||||
ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT)
|
||||
$(LINK_DLL) -MAP $(DLLBASE) $(DLL_LIBS) $(EXTRA_LIBS) $(OBJS) $(RES)
|
||||
ifdef MT
|
||||
@if test -f $@.manifest; then \
|
||||
$(MT) -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;2; \
|
||||
rm -f $@.manifest; \
|
||||
fi
|
||||
endif # MSVC with manifest tool
|
||||
else # WINNT && !GCC
|
||||
ifeq ($(MOZ_OS2_TOOLS),VACPP)
|
||||
$(LINK_DLL) $(DLLBASE) $(OBJS) $(OS_LIBS) $(EXTRA_LIBS) $(MAPFILE)
|
||||
else # !os2 vacpp
|
||||
ifeq ($(OS_TARGET), OpenVMS)
|
||||
@if test ! -f $(VMS_SYMVEC_FILE); then \
|
||||
if test -f $(VMS_SYMVEC_FILE_MODULE); then \
|
||||
echo Creating component options file $(VMS_SYMVEC_FILE); \
|
||||
cp $(VMS_SYMVEC_FILE_MODULE) $(VMS_SYMVEC_FILE); \
|
||||
fi; \
|
||||
fi
|
||||
endif # OpenVMS
|
||||
$(MKSHLIB) $(OBJS) $(RES) $(EXTRA_LIBS)
|
||||
endif # OS2 vacpp
|
||||
endif # WINNT && !GCC
|
||||
endif # AIX 4.1
|
||||
ifdef ENABLE_STRIP
|
||||
$(STRIP) $@
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
$(RES): $(RESNAME)
|
||||
@$(MAKE_OBJDIR)
|
||||
# The resource compiler does not understand the -U option.
|
||||
ifdef NS_USE_GCC
|
||||
$(RC) $(RCFLAGS) $(filter-out -U%,$(DEFINES)) $(INCLUDES:-I%=--include-dir %) -o $@ $<
|
||||
else
|
||||
$(RC) $(RCFLAGS) $(filter-out -U%,$(DEFINES)) $(INCLUDES) -Fo$@ $<
|
||||
endif # GCC
|
||||
@echo $(RES) finished
|
||||
endif
|
||||
|
||||
$(MAPFILE): $(LIBRARY_NAME).def
|
||||
@$(MAKE_OBJDIR)
|
||||
ifeq ($(OS_ARCH),SunOS)
|
||||
grep -v ';-' $< | \
|
||||
sed -e 's,;+,,' -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,;,' > $@
|
||||
endif
|
||||
ifeq ($(OS_ARCH),OS2)
|
||||
echo LIBRARY $(LIBRARY_NAME)$(LIBRARY_VERSION) INITINSTANCE TERMINSTANCE > $@
|
||||
echo PROTMODE >> $@
|
||||
echo CODE LOADONCALL MOVEABLE DISCARDABLE >> $@
|
||||
echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $@
|
||||
echo EXPORTS >> $@
|
||||
ifeq ($(MOZ_OS2_TOOLS),VACPP)
|
||||
grep -v ';+' $< | grep -v ';-' | \
|
||||
sed -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,,' >> $@
|
||||
else
|
||||
grep -v ';+' $< | grep -v ';-' | \
|
||||
sed -e 's; DATA ;;' -e 's,;;,,' -e 's,;.*,,' -e 's,\([\t ]*\),\1_,' | \
|
||||
awk 'BEGIN {ord=1;} { print($$0 " @" ord " RESIDENTNAME"); ord++;}' >> $@
|
||||
$(ADD_TO_DEF_FILE)
|
||||
endif
|
||||
endif
|
||||
|
||||
#
|
||||
# Translate source filenames to absolute paths. This is required for
|
||||
# debuggers under Windows and OS/2 to find source files automatically.
|
||||
#
|
||||
|
||||
ifeq (,$(filter-out AIX OS2,$(OS_ARCH)))
|
||||
NEED_ABSOLUTE_PATH = 1
|
||||
endif
|
||||
|
||||
ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT)
|
||||
NEED_ABSOLUTE_PATH = 1
|
||||
endif
|
||||
|
||||
ifdef NEED_ABSOLUTE_PATH
|
||||
PWD := $(shell pwd)
|
||||
abspath = $(if $(findstring :,$(1)),$(1),$(if $(filter /%,$(1)),$(1),$(PWD)/$(1)))
|
||||
endif
|
||||
|
||||
$(OBJDIR)/%.$(OBJ_SUFFIX): %.cpp
|
||||
@$(MAKE_OBJDIR)
|
||||
ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT)
|
||||
$(CCC) -Fo$@ -c $(CCCFLAGS) $(call abspath,$<)
|
||||
else
|
||||
ifeq ($(MOZ_OS2_TOOLS),VACPP)
|
||||
$(CCC) -Fo$@ -c $(CCCFLAGS) $(call abspath,$<)
|
||||
else
|
||||
ifdef NEED_ABSOLUTE_PATH
|
||||
$(CCC) -o $@ -c $(CCCFLAGS) $(call abspath,$<)
|
||||
else
|
||||
$(CCC) -o $@ -c $(CCCFLAGS) $<
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
WCCFLAGS1 = $(subst /,\\,$(CFLAGS))
|
||||
WCCFLAGS2 = $(subst -I,-i=,$(WCCFLAGS1))
|
||||
WCCFLAGS3 = $(subst -D,-d,$(WCCFLAGS2))
|
||||
$(OBJDIR)/%.$(OBJ_SUFFIX): %.c
|
||||
@$(MAKE_OBJDIR)
|
||||
ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT)
|
||||
$(CC) -Fo$@ -c $(CFLAGS) $(call abspath,$<)
|
||||
else
|
||||
ifeq ($(MOZ_OS2_TOOLS),VACPP)
|
||||
$(CC) -Fo$@ -c $(CFLAGS) $(call abspath,$<)
|
||||
else
|
||||
ifdef NEED_ABSOLUTE_PATH
|
||||
$(CC) -o $@ -c $(CFLAGS) $(call abspath,$<)
|
||||
else
|
||||
$(CC) -o $@ -c $(CFLAGS) $<
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
$(OBJDIR)/%.$(OBJ_SUFFIX): %.s
|
||||
@$(MAKE_OBJDIR)
|
||||
$(AS) -o $@ $(ASFLAGS) -c $<
|
||||
|
||||
ifeq ($(MOZ_OS2_TOOLS),VACPP)
|
||||
$(OBJDIR)/%.$(OBJ_SUFFIX): %.asm
|
||||
@$(MAKE_OBJDIR)
|
||||
$(AS) -Fdo:./$(OBJDIR) $(ASFLAGS) $<
|
||||
endif
|
||||
|
||||
%.i: %.c
|
||||
$(CC) -C -E $(CFLAGS) $< > $*.i
|
||||
|
||||
%: %.pl
|
||||
rm -f $@; cp $< $@; chmod +x $@
|
||||
|
||||
#
|
||||
# HACK ALERT
|
||||
#
|
||||
# The only purpose of this rule is to pass Mozilla's Tinderbox depend
|
||||
# builds (http://tinderbox.mozilla.org/showbuilds.cgi). Mozilla's
|
||||
# Tinderbox builds NSPR continuously as part of the Mozilla client.
|
||||
# Because NSPR's make depend is not implemented, whenever we change
|
||||
# an NSPR header file, the depend build does not recompile the NSPR
|
||||
# files that depend on the header.
|
||||
#
|
||||
# This rule makes all the objects depend on a dummy header file.
|
||||
# Touch this dummy header file to force the depend build to recompile
|
||||
# everything.
|
||||
#
|
||||
# This rule should be removed when make depend is implemented.
|
||||
#
|
||||
|
||||
DUMMY_DEPEND_H = $(topsrcdir)/config/prdepend.h
|
||||
|
||||
$(filter $(OBJDIR)/%.$(OBJ_SUFFIX),$(OBJS)): $(OBJDIR)/%.$(OBJ_SUFFIX): $(DUMMY_DEPEND_H)
|
||||
|
||||
# END OF HACK
|
||||
|
||||
################################################################################
|
||||
# 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: .a .$(OBJ_SUFFIX) .c .cpp .s .h .i .pl
|
||||
|
||||
#
|
||||
# Fake targets. Always run these rules, even if a file/directory with that
|
||||
# name already exists.
|
||||
#
|
||||
.PHONY: all alltags clean export install libs realclean release
|
||||
|
||||
#
|
||||
# List the target pattern of an implicit rule as a dependency of the
|
||||
# special target .PRECIOUS to preserve intermediate files made by
|
||||
# implicit rules whose target patterns match that file's name.
|
||||
# (See GNU Make documentation, Edition 0.51, May 1996, Sec. 10.4,
|
||||
# p. 107.)
|
||||
#
|
||||
.PRECIOUS: $(OBJDIR)/%.$(OBJ_SUFFIX)
|
||||
@@ -1,172 +0,0 @@
|
||||
Aliases.h
|
||||
arpa/inet.h
|
||||
assert.h
|
||||
bsd/libc.h
|
||||
bsd/syscall.h
|
||||
bstring.h
|
||||
builtin.h
|
||||
c_asm.h
|
||||
cf.h
|
||||
CFBundle.h
|
||||
CFData.h
|
||||
CFDictionary.h
|
||||
CFString.h
|
||||
CFURL.h
|
||||
CodeFragments.h
|
||||
commdlg.h
|
||||
crt_externs.h
|
||||
crypt.h
|
||||
ctype.h
|
||||
descrip.h
|
||||
Devices.h
|
||||
direct.h
|
||||
dirent.h
|
||||
dlfcn.h
|
||||
dl.h
|
||||
DriverServices.h
|
||||
dvidef.h
|
||||
errno.h
|
||||
Errors.h
|
||||
Events.h
|
||||
fcntl.h
|
||||
fibdef.h
|
||||
files.h
|
||||
Files.h
|
||||
float.h
|
||||
Folders.h
|
||||
Gestalt.h
|
||||
getopt.h
|
||||
grp.h
|
||||
ia64/sys/inline.h
|
||||
ifaddrs.h
|
||||
image.h
|
||||
ints.h
|
||||
iodef.h
|
||||
io.h
|
||||
iostream.h
|
||||
kernel/OS.h
|
||||
lib$routines.h
|
||||
limits.h
|
||||
loader.h
|
||||
locale.h
|
||||
LowMem.h
|
||||
MacErrors.h
|
||||
machine/builtins.h
|
||||
machine/clock.h
|
||||
machine/endian.h
|
||||
machine/inline.h
|
||||
mach/mach_init.h
|
||||
mach/mach_host.h
|
||||
mach-o/dyld.h
|
||||
MacTypes.h
|
||||
Math64.h
|
||||
math.h
|
||||
mbstring.h
|
||||
memory.h
|
||||
MixedMode.h
|
||||
model.h
|
||||
mswsock.h
|
||||
Multiprocessing.h
|
||||
mutex.h
|
||||
netdb.h
|
||||
net/if.h
|
||||
netinet/in.h
|
||||
netinet/in_systm.h
|
||||
netinet/tcp.h
|
||||
OpenTptInternet.h
|
||||
OpenTransport.h
|
||||
os2.h
|
||||
OS.h
|
||||
osreldate.h
|
||||
OSUtils.h
|
||||
poll.h
|
||||
PPCToolbox.h
|
||||
Processes.h
|
||||
process.h
|
||||
pthread.h
|
||||
pwd.h
|
||||
QDOffscreen.h
|
||||
Resources.h
|
||||
rld_interface.h
|
||||
rpc/types.h
|
||||
semaphore.h
|
||||
setjmp.h
|
||||
share.h
|
||||
signal.h
|
||||
ssdef.h
|
||||
starlet.h
|
||||
stat.h
|
||||
stdarg.h
|
||||
stddef.h
|
||||
stdio.h
|
||||
stdlib.h
|
||||
string.h
|
||||
stropts.h
|
||||
stsdef.h
|
||||
support/SupportDefs.h
|
||||
support/TLS.h
|
||||
synch.h
|
||||
sys/atomic_op.h
|
||||
syscall.h
|
||||
sys/cfgodm.h
|
||||
sys/file.h
|
||||
sys/filio.h
|
||||
sys/immu.h
|
||||
sys/ioctl.h
|
||||
sys/ipc.h
|
||||
sys/ldr.h
|
||||
sys/locking.h
|
||||
sys/lwp.h
|
||||
sys/mman.h
|
||||
sys/mpctl.h
|
||||
sys/param.h
|
||||
sys/pda.h
|
||||
sys/poll.h
|
||||
sys/prctl.h
|
||||
sys/priv.h
|
||||
sys/procfs.h
|
||||
sys/pstat.h
|
||||
sys/regset.h
|
||||
sys/resource.h
|
||||
sys/sched.h
|
||||
sys/select.h
|
||||
sys/sem.h
|
||||
sys/sendfile.h
|
||||
sys/shm.h
|
||||
sys/socket.h
|
||||
sys/stack.h
|
||||
sys/stat.h
|
||||
sys/statvfs.h
|
||||
sys/syscall.h
|
||||
sys/sysctl.h
|
||||
sys/sysmp.h
|
||||
sys/syssgi.h
|
||||
sys/systeminfo.h
|
||||
sys/timeb.h
|
||||
sys/time.h
|
||||
sys/times.h
|
||||
sys/types.h
|
||||
sys/ucontext.h
|
||||
sys/uio.h
|
||||
sys/utsname.h
|
||||
sys/wait.h
|
||||
task.h
|
||||
TextUtils.h
|
||||
thread.h
|
||||
time.h
|
||||
Timer.h
|
||||
types.h
|
||||
Types.h
|
||||
ucontext.h
|
||||
ucx$inetdef.h
|
||||
ulocks.h
|
||||
unistd.h
|
||||
unix.h
|
||||
unixlib.h
|
||||
utime.h
|
||||
wchar.h
|
||||
winbase.h
|
||||
win/compobj.h
|
||||
windef.h
|
||||
windows.h
|
||||
winsock.h
|
||||
6347
mozilla/nsprpub/configure
vendored
6347
mozilla/nsprpub/configure
vendored
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,56 +0,0 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
#! gmake
|
||||
|
||||
MOD_DEPTH = ..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(MOD_DEPTH)/config/autoconf.mk
|
||||
|
||||
export NSPR20=1
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
DIRS = ds libc
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
export:: $(TARGETS)
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist directory
|
||||
#
|
||||
|
||||
plarenas.h
|
||||
plarena.h
|
||||
plhash.h
|
||||
@@ -1,197 +0,0 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
#! gmake
|
||||
|
||||
MOD_DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(MOD_DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
INCLUDES = -I$(dist_includedir) -I$(topsrcdir)/pr/include
|
||||
|
||||
CSRCS = \
|
||||
plarena.c \
|
||||
plhash.c \
|
||||
plvrsion.c \
|
||||
$(NULL)
|
||||
|
||||
HEADERS = \
|
||||
plarenas.h \
|
||||
plarena.h \
|
||||
plhash.h \
|
||||
$(NULL)
|
||||
|
||||
HEADERS := $(addprefix $(srcdir)/, $(HEADERS))
|
||||
|
||||
ifeq ($(OS_ARCH), WINNT)
|
||||
RES=$(OBJDIR)/plds.res
|
||||
RESNAME=plds.rc
|
||||
endif # WINNT
|
||||
|
||||
ifeq ($(OS_ARCH), AIX)
|
||||
ifeq ($(CLASSIC_NSPR),1)
|
||||
OS_LIBS = -lc
|
||||
else
|
||||
OS_LIBS = -lc_r
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),IRIX)
|
||||
OS_LIBS = -lc
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),SunOS)
|
||||
OS_LIBS = -lc
|
||||
MAPFILE = $(OBJDIR)/pldsmap.sun
|
||||
GARBAGE += $(MAPFILE)
|
||||
ifdef NS_USE_GCC
|
||||
ifdef GCC_USE_GNU_LD
|
||||
MKSHLIB += -Wl,--version-script,$(MAPFILE)
|
||||
else
|
||||
MKSHLIB += -Wl,-M,$(MAPFILE)
|
||||
endif
|
||||
else
|
||||
MKSHLIB += -M $(MAPFILE)
|
||||
endif
|
||||
# The -R '$ORIGIN' linker option instructs this library to search for its
|
||||
# dependencies in the same directory where it resides.
|
||||
MKSHLIB += -R '$$ORIGIN'
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),OS2)
|
||||
MAPFILE = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION).def
|
||||
GARBAGE += $(MAPFILE)
|
||||
MKSHLIB += $(MAPFILE)
|
||||
endif
|
||||
|
||||
EXTRA_LIBS = $(LIBNSPR)
|
||||
|
||||
# On NCR and SCOOS, we can't link with extra libraries when
|
||||
# we build a shared library. If we do so, the linker doesn't
|
||||
# complain, but we would run into weird problems at run-time.
|
||||
# Therefore on these platforms, we link just the .o files.
|
||||
ifeq ($(OS_ARCH),NCR)
|
||||
EXTRA_LIBS =
|
||||
endif
|
||||
ifeq ($(OS_ARCH),SCOOS)
|
||||
EXTRA_LIBS =
|
||||
endif
|
||||
|
||||
ifdef RESOLVE_LINK_SYMBOLS
|
||||
EXTRA_LIBS += $(OS_LIBS)
|
||||
endif
|
||||
|
||||
LIBRARY_NAME = plds
|
||||
LIBRARY_VERSION = $(MOD_MAJOR_VERSION)
|
||||
|
||||
RELEASE_HEADERS = $(HEADERS)
|
||||
RELEASE_HEADERS_DEST = $(RELEASE_INCLUDE_DIR)
|
||||
RELEASE_LIBS = $(TARGETS)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
#
|
||||
# Version information generation (begin)
|
||||
#
|
||||
ECHO = echo
|
||||
TINC = $(OBJDIR)/_pl_bld.h
|
||||
PROD = $(notdir $(SHARED_LIBRARY))
|
||||
NOW = $(MOD_DEPTH)/config/$(OBJDIR)/now
|
||||
SH_DATE = $(shell date "+%Y-%m-%d %T")
|
||||
SH_NOW = $(shell $(NOW))
|
||||
|
||||
ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT)
|
||||
SUF = i64
|
||||
else
|
||||
SUF = LL
|
||||
endif
|
||||
|
||||
GARBAGE += $(TINC)
|
||||
|
||||
$(TINC):
|
||||
@$(MAKE_OBJDIR)
|
||||
@$(ECHO) '#define _BUILD_STRING "$(SH_DATE)"' > $(TINC)
|
||||
@if test ! -z "$(SH_NOW)"; then \
|
||||
$(ECHO) '#define _BUILD_TIME $(SH_NOW)$(SUF)' >> $(TINC); \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
@$(ECHO) '#define _PRODUCTION "$(PROD)"' >> $(TINC)
|
||||
|
||||
|
||||
$(OBJDIR)/plvrsion.$(OBJ_SUFFIX): plvrsion.c $(TINC)
|
||||
ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT)
|
||||
$(CC) -Fo$@ -c $(CFLAGS) -I$(OBJDIR) $<
|
||||
else
|
||||
ifeq ($(MOZ_OS2_TOOLS), VACPP)
|
||||
$(CC) -Fo$@ -c $(CFLAGS) -I$(OBJDIR) $<
|
||||
else
|
||||
$(CC) -o $@ -c $(CFLAGS) -I$(OBJDIR) $<
|
||||
endif
|
||||
endif
|
||||
#
|
||||
# Version information generation (end)
|
||||
#
|
||||
|
||||
#
|
||||
# The Client build wants the shared libraries in $(dist_bindir),
|
||||
# so we also install them there.
|
||||
#
|
||||
|
||||
export:: $(TARGETS)
|
||||
$(INSTALL) -m 444 $(HEADERS) $(dist_includedir)
|
||||
$(INSTALL) -m 444 $(TARGETS) $(dist_libdir)
|
||||
ifdef SHARED_LIBRARY
|
||||
ifeq ($(OS_ARCH),HP-UX)
|
||||
$(INSTALL) -m 755 $(SHARED_LIBRARY) $(dist_libdir)
|
||||
$(INSTALL) -m 755 $(SHARED_LIBRARY) $(dist_bindir)
|
||||
else
|
||||
$(INSTALL) -m 444 $(SHARED_LIBRARY) $(dist_bindir)
|
||||
endif
|
||||
endif
|
||||
ifeq ($(MOZ_BITS),16)
|
||||
$(INSTALL) -m 444 $(HEADERS) $(MOZ_INCL)
|
||||
$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/lib
|
||||
$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/bin
|
||||
endif
|
||||
|
||||
|
||||
@@ -1,432 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998-2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
/*
|
||||
* Lifetime-based fast allocation, inspired by much prior art, including
|
||||
* "Fast Allocation and Deallocation of Memory Based on Object Lifetimes"
|
||||
* David R. Hanson, Software -- Practice and Experience, Vol. 20(1).
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "plarena.h"
|
||||
#include "prmem.h"
|
||||
#include "prbit.h"
|
||||
#include "prlog.h"
|
||||
#include "prlock.h"
|
||||
#include "prinit.h"
|
||||
|
||||
static PLArena *arena_freelist;
|
||||
|
||||
#ifdef PL_ARENAMETER
|
||||
static PLArenaStats *arena_stats_list;
|
||||
|
||||
#define COUNT(pool,what) (pool)->stats.what++
|
||||
#else
|
||||
#define COUNT(pool,what) /* nothing */
|
||||
#endif
|
||||
|
||||
#define PL_ARENA_DEFAULT_ALIGN sizeof(double)
|
||||
|
||||
static PRLock *arenaLock;
|
||||
static PRCallOnceType once;
|
||||
|
||||
/*
|
||||
** InitializeArenas() -- Initialize arena operations.
|
||||
**
|
||||
** InitializeArenas() is called exactly once and only once from
|
||||
** LockArena(). This function creates the arena protection
|
||||
** lock: arenaLock.
|
||||
**
|
||||
** Note: If the arenaLock cannot be created, InitializeArenas()
|
||||
** fails quietly, returning only PR_FAILURE. This percolates up
|
||||
** to the application using the Arena API. He gets no arena
|
||||
** from PL_ArenaAllocate(). It's up to him to fail gracefully
|
||||
** or recover.
|
||||
**
|
||||
*/
|
||||
static PRStatus InitializeArenas( void )
|
||||
{
|
||||
PR_ASSERT( arenaLock == NULL );
|
||||
arenaLock = PR_NewLock();
|
||||
if ( arenaLock == NULL )
|
||||
return PR_FAILURE;
|
||||
else
|
||||
return PR_SUCCESS;
|
||||
} /* end ArenaInitialize() */
|
||||
|
||||
static PRStatus LockArena( void )
|
||||
{
|
||||
PRStatus rc = PR_CallOnce( &once, InitializeArenas );
|
||||
|
||||
if ( PR_FAILURE != rc )
|
||||
PR_Lock( arenaLock );
|
||||
return(rc);
|
||||
} /* end LockArena() */
|
||||
|
||||
static void UnlockArena( void )
|
||||
{
|
||||
PR_Unlock( arenaLock );
|
||||
return;
|
||||
} /* end UnlockArena() */
|
||||
|
||||
PR_IMPLEMENT(void) PL_InitArenaPool(
|
||||
PLArenaPool *pool, const char *name, PRUint32 size, PRUint32 align)
|
||||
{
|
||||
#if defined(XP_MAC)
|
||||
#pragma unused (name)
|
||||
#endif
|
||||
|
||||
if (align == 0)
|
||||
align = PL_ARENA_DEFAULT_ALIGN;
|
||||
pool->mask = PR_BITMASK(PR_CeilingLog2(align));
|
||||
pool->first.next = NULL;
|
||||
pool->first.base = pool->first.avail = pool->first.limit =
|
||||
(PRUword)PL_ARENA_ALIGN(pool, &pool->first + 1);
|
||||
pool->current = &pool->first;
|
||||
pool->arenasize = size;
|
||||
#ifdef PL_ARENAMETER
|
||||
memset(&pool->stats, 0, sizeof pool->stats);
|
||||
pool->stats.name = strdup(name);
|
||||
pool->stats.next = arena_stats_list;
|
||||
arena_stats_list = &pool->stats;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** PL_ArenaAllocate() -- allocate space from an arena pool
|
||||
**
|
||||
** Description: PL_ArenaAllocate() allocates space from an arena
|
||||
** pool.
|
||||
**
|
||||
** First, try to satisfy the request from arenas starting at
|
||||
** pool->current.
|
||||
**
|
||||
** If there is not enough space in the arena pool->current, try
|
||||
** to claim an arena, on a first fit basis, from the global
|
||||
** freelist (arena_freelist).
|
||||
**
|
||||
** If no arena in arena_freelist is suitable, then try to
|
||||
** allocate a new arena from the heap.
|
||||
**
|
||||
** Returns: pointer to allocated space or NULL
|
||||
**
|
||||
** Notes: The original implementation had some difficult to
|
||||
** solve bugs; the code was difficult to read. Sometimes it's
|
||||
** just easier to rewrite it. I did that. larryh.
|
||||
**
|
||||
** See also: bugzilla: 45343.
|
||||
**
|
||||
*/
|
||||
|
||||
PR_IMPLEMENT(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb)
|
||||
{
|
||||
PLArena *a;
|
||||
char *rp; /* returned pointer */
|
||||
|
||||
PR_ASSERT((nb & pool->mask) == 0);
|
||||
|
||||
nb = (PRUword)PL_ARENA_ALIGN(pool, nb); /* force alignment */
|
||||
|
||||
/* attempt to allocate from arenas at pool->current */
|
||||
{
|
||||
a = pool->current;
|
||||
do {
|
||||
if ( a->avail +nb <= a->limit ) {
|
||||
pool->current = a;
|
||||
rp = (char *)a->avail;
|
||||
a->avail += nb;
|
||||
return rp;
|
||||
}
|
||||
} while( NULL != (a = a->next) );
|
||||
}
|
||||
|
||||
/* attempt to allocate from arena_freelist */
|
||||
{
|
||||
PLArena *p; /* previous pointer, for unlinking from freelist */
|
||||
|
||||
/* lock the arena_freelist. Make access to the freelist MT-Safe */
|
||||
if ( PR_FAILURE == LockArena())
|
||||
return(0);
|
||||
|
||||
for ( a = arena_freelist, p = NULL; a != NULL ; p = a, a = a->next ) {
|
||||
if ( a->base +nb <= a->limit ) {
|
||||
if ( p == NULL )
|
||||
arena_freelist = a->next;
|
||||
else
|
||||
p->next = a->next;
|
||||
UnlockArena();
|
||||
a->avail = a->base;
|
||||
rp = (char *)a->avail;
|
||||
a->avail += nb;
|
||||
/* the newly allocated arena is linked after pool->current
|
||||
* and becomes pool->current */
|
||||
a->next = pool->current->next;
|
||||
pool->current->next = a;
|
||||
pool->current = a;
|
||||
if ( NULL == pool->first.next )
|
||||
pool->first.next = a;
|
||||
return(rp);
|
||||
}
|
||||
}
|
||||
UnlockArena();
|
||||
}
|
||||
|
||||
/* attempt to allocate from the heap */
|
||||
{
|
||||
PRUint32 sz = PR_MAX(pool->arenasize, nb);
|
||||
sz += sizeof *a + pool->mask; /* header and alignment slop */
|
||||
a = (PLArena*)PR_MALLOC(sz);
|
||||
if ( NULL != a ) {
|
||||
a->limit = (PRUword)a + sz;
|
||||
a->base = a->avail = (PRUword)PL_ARENA_ALIGN(pool, a + 1);
|
||||
rp = (char *)a->avail;
|
||||
a->avail += nb;
|
||||
/* the newly allocated arena is linked after pool->current
|
||||
* and becomes pool->current */
|
||||
a->next = pool->current->next;
|
||||
pool->current->next = a;
|
||||
pool->current = a;
|
||||
if ( NULL == pool->first.next )
|
||||
pool->first.next = a;
|
||||
PL_COUNT_ARENA(pool,++);
|
||||
COUNT(pool, nmallocs);
|
||||
return(rp);
|
||||
}
|
||||
}
|
||||
|
||||
/* we got to here, and there's no memory to allocate */
|
||||
return(NULL);
|
||||
} /* --- end PL_ArenaAllocate() --- */
|
||||
|
||||
PR_IMPLEMENT(void *) PL_ArenaGrow(
|
||||
PLArenaPool *pool, void *p, PRUint32 size, PRUint32 incr)
|
||||
{
|
||||
void *newp;
|
||||
|
||||
PL_ARENA_ALLOCATE(newp, pool, size + incr);
|
||||
if (newp)
|
||||
memcpy(newp, p, size);
|
||||
return newp;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free tail arenas linked after head, which may not be the true list head.
|
||||
* Reset pool->current to point to head in case it pointed at a tail arena.
|
||||
*/
|
||||
static void FreeArenaList(PLArenaPool *pool, PLArena *head, PRBool reallyFree)
|
||||
{
|
||||
PLArena **ap, *a;
|
||||
|
||||
ap = &head->next;
|
||||
a = *ap;
|
||||
if (!a)
|
||||
return;
|
||||
|
||||
#ifdef DEBUG
|
||||
do {
|
||||
PR_ASSERT(a->base <= a->avail && a->avail <= a->limit);
|
||||
a->avail = a->base;
|
||||
PL_CLEAR_UNUSED(a);
|
||||
} while ((a = a->next) != 0);
|
||||
a = *ap;
|
||||
#endif
|
||||
|
||||
if (reallyFree) {
|
||||
do {
|
||||
*ap = a->next;
|
||||
PL_CLEAR_ARENA(a);
|
||||
PL_COUNT_ARENA(pool,--);
|
||||
PR_DELETE(a);
|
||||
} while ((a = *ap) != 0);
|
||||
} else {
|
||||
/* Insert the whole arena chain at the front of the freelist. */
|
||||
do {
|
||||
ap = &(*ap)->next;
|
||||
} while (*ap);
|
||||
LockArena();
|
||||
*ap = arena_freelist;
|
||||
arena_freelist = a;
|
||||
head->next = 0;
|
||||
UnlockArena();
|
||||
}
|
||||
|
||||
pool->current = head;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void) PL_ArenaRelease(PLArenaPool *pool, char *mark)
|
||||
{
|
||||
PLArena *a;
|
||||
|
||||
for (a = pool->first.next; a; a = a->next) {
|
||||
if (PR_UPTRDIFF(mark, a->base) < PR_UPTRDIFF(a->avail, a->base)) {
|
||||
a->avail = (PRUword)PL_ARENA_ALIGN(pool, mark);
|
||||
FreeArenaList(pool, a, PR_FALSE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void) PL_FreeArenaPool(PLArenaPool *pool)
|
||||
{
|
||||
FreeArenaList(pool, &pool->first, PR_FALSE);
|
||||
COUNT(pool, ndeallocs);
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void) PL_FinishArenaPool(PLArenaPool *pool)
|
||||
{
|
||||
FreeArenaList(pool, &pool->first, PR_TRUE);
|
||||
#ifdef PL_ARENAMETER
|
||||
{
|
||||
PLArenaStats *stats, **statsp;
|
||||
|
||||
if (pool->stats.name)
|
||||
PR_DELETE(pool->stats.name);
|
||||
for (statsp = &arena_stats_list; (stats = *statsp) != 0;
|
||||
statsp = &stats->next) {
|
||||
if (stats == &pool->stats) {
|
||||
*statsp = stats->next;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void) PL_CompactArenaPool(PLArenaPool *ap)
|
||||
{
|
||||
#if XP_MAC
|
||||
#pragma unused (ap)
|
||||
#if 0
|
||||
PRArena *curr = &(ap->first);
|
||||
while (curr) {
|
||||
reallocSmaller(curr, curr->avail - (uprword_t)curr);
|
||||
curr->limit = curr->avail;
|
||||
curr = curr->next;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void) PL_ArenaFinish(void)
|
||||
{
|
||||
PLArena *a, *next;
|
||||
|
||||
for (a = arena_freelist; a; a = next) {
|
||||
next = a->next;
|
||||
PR_DELETE(a);
|
||||
}
|
||||
arena_freelist = NULL;
|
||||
|
||||
if (arenaLock) {
|
||||
PR_DestroyLock(arenaLock);
|
||||
arenaLock = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PL_ARENAMETER
|
||||
PR_IMPLEMENT(void) PL_ArenaCountAllocation(PLArenaPool *pool, PRUint32 nb)
|
||||
{
|
||||
pool->stats.nallocs++;
|
||||
pool->stats.nbytes += nb;
|
||||
if (nb > pool->stats.maxalloc)
|
||||
pool->stats.maxalloc = nb;
|
||||
pool->stats.variance += nb * nb;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void) PL_ArenaCountInplaceGrowth(
|
||||
PLArenaPool *pool, PRUint32 size, PRUint32 incr)
|
||||
{
|
||||
pool->stats.ninplace++;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void) PL_ArenaCountGrowth(
|
||||
PLArenaPool *pool, PRUint32 size, PRUint32 incr)
|
||||
{
|
||||
pool->stats.ngrows++;
|
||||
pool->stats.nbytes += incr;
|
||||
pool->stats.variance -= size * size;
|
||||
size += incr;
|
||||
if (size > pool->stats.maxalloc)
|
||||
pool->stats.maxalloc = size;
|
||||
pool->stats.variance += size * size;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void) PL_ArenaCountRelease(PLArenaPool *pool, char *mark)
|
||||
{
|
||||
pool->stats.nreleases++;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void) PL_ArenaCountRetract(PLArenaPool *pool, char *mark)
|
||||
{
|
||||
pool->stats.nfastrels++;
|
||||
}
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
PR_IMPLEMENT(void) PL_DumpArenaStats(FILE *fp)
|
||||
{
|
||||
PLArenaStats *stats;
|
||||
double mean, variance;
|
||||
|
||||
for (stats = arena_stats_list; stats; stats = stats->next) {
|
||||
if (stats->nallocs != 0) {
|
||||
mean = (double)stats->nbytes / stats->nallocs;
|
||||
variance = fabs(stats->variance / stats->nallocs - mean * mean);
|
||||
} else {
|
||||
mean = variance = 0;
|
||||
}
|
||||
|
||||
fprintf(fp, "\n%s allocation statistics:\n", stats->name);
|
||||
fprintf(fp, " number of arenas: %u\n", stats->narenas);
|
||||
fprintf(fp, " number of allocations: %u\n", stats->nallocs);
|
||||
fprintf(fp, " number of free arena reclaims: %u\n", stats->nreclaims);
|
||||
fprintf(fp, " number of malloc calls: %u\n", stats->nmallocs);
|
||||
fprintf(fp, " number of deallocations: %u\n", stats->ndeallocs);
|
||||
fprintf(fp, " number of allocation growths: %u\n", stats->ngrows);
|
||||
fprintf(fp, " number of in-place growths: %u\n", stats->ninplace);
|
||||
fprintf(fp, "number of released allocations: %u\n", stats->nreleases);
|
||||
fprintf(fp, " number of fast releases: %u\n", stats->nfastrels);
|
||||
fprintf(fp, " total bytes allocated: %u\n", stats->nbytes);
|
||||
fprintf(fp, " mean allocation size: %g\n", mean);
|
||||
fprintf(fp, " standard deviation: %g\n", sqrt(variance));
|
||||
fprintf(fp, " maximum allocation size: %u\n", stats->maxalloc);
|
||||
}
|
||||
}
|
||||
#endif /* PL_ARENAMETER */
|
||||
@@ -1,213 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998-2000 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#ifndef plarena_h___
|
||||
#define plarena_h___
|
||||
/*
|
||||
* Lifetime-based fast allocation, inspired by much prior art, including
|
||||
* "Fast Allocation and Deallocation of Memory Based on Object Lifetimes"
|
||||
* David R. Hanson, Software -- Practice and Experience, Vol. 20(1).
|
||||
*
|
||||
* Also supports LIFO allocation (PL_ARENA_MARK/PL_ARENA_RELEASE).
|
||||
*/
|
||||
#include "prtypes.h"
|
||||
#include "plarenas.h"
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
typedef struct PLArena PLArena;
|
||||
|
||||
struct PLArena {
|
||||
PLArena *next; /* next arena for this lifetime */
|
||||
PRUword base; /* aligned base address, follows this header */
|
||||
PRUword limit; /* one beyond last byte in arena */
|
||||
PRUword avail; /* points to next available byte */
|
||||
};
|
||||
|
||||
#ifdef PL_ARENAMETER
|
||||
typedef struct PLArenaStats PLArenaStats;
|
||||
|
||||
struct PLArenaStats {
|
||||
PLArenaStats *next; /* next in arenaStats list */
|
||||
char *name; /* name for debugging */
|
||||
PRUint32 narenas; /* number of arenas in pool */
|
||||
PRUint32 nallocs; /* number of PL_ARENA_ALLOCATE() calls */
|
||||
PRUint32 nreclaims; /* number of reclaims from freeArenas */
|
||||
PRUint32 nmallocs; /* number of malloc() calls */
|
||||
PRUint32 ndeallocs; /* number of lifetime deallocations */
|
||||
PRUint32 ngrows; /* number of PL_ARENA_GROW() calls */
|
||||
PRUint32 ninplace; /* number of in-place growths */
|
||||
PRUint32 nreleases; /* number of PL_ARENA_RELEASE() calls */
|
||||
PRUint32 nfastrels; /* number of "fast path" releases */
|
||||
PRUint32 nbytes; /* total bytes allocated */
|
||||
PRUint32 maxalloc; /* maximum allocation size in bytes */
|
||||
PRFloat64 variance; /* size variance accumulator */
|
||||
};
|
||||
#endif
|
||||
|
||||
struct PLArenaPool {
|
||||
PLArena first; /* first arena in pool list */
|
||||
PLArena *current; /* arena from which to allocate space */
|
||||
PRUint32 arenasize; /* net exact size of a new arena */
|
||||
PRUword mask; /* alignment mask (power-of-2 - 1) */
|
||||
#ifdef PL_ARENAMETER
|
||||
PLArenaStats stats;
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
* If the including .c file uses only one power-of-2 alignment, it may define
|
||||
* PL_ARENA_CONST_ALIGN_MASK to the alignment mask and save a few instructions
|
||||
* per ALLOCATE and GROW.
|
||||
*/
|
||||
#ifdef PL_ARENA_CONST_ALIGN_MASK
|
||||
#define PL_ARENA_ALIGN(pool, n) (((PRUword)(n) + PL_ARENA_CONST_ALIGN_MASK) \
|
||||
& ~PL_ARENA_CONST_ALIGN_MASK)
|
||||
|
||||
#define PL_INIT_ARENA_POOL(pool, name, size) \
|
||||
PL_InitArenaPool(pool, name, size, PL_ARENA_CONST_ALIGN_MASK + 1)
|
||||
#else
|
||||
#define PL_ARENA_ALIGN(pool, n) (((PRUword)(n) + (pool)->mask) & ~(pool)->mask)
|
||||
#endif
|
||||
|
||||
#define PL_ARENA_ALLOCATE(p, pool, nb) \
|
||||
PR_BEGIN_MACRO \
|
||||
PLArena *_a = (pool)->current; \
|
||||
PRUint32 _nb = PL_ARENA_ALIGN(pool, nb); \
|
||||
PRUword _p = _a->avail; \
|
||||
PRUword _q = _p + _nb; \
|
||||
if (_q > _a->limit) \
|
||||
_p = (PRUword)PL_ArenaAllocate(pool, _nb); \
|
||||
else \
|
||||
_a->avail = _q; \
|
||||
p = (void *)_p; \
|
||||
PL_ArenaCountAllocation(pool, nb); \
|
||||
PR_END_MACRO
|
||||
|
||||
#define PL_ARENA_GROW(p, pool, size, incr) \
|
||||
PR_BEGIN_MACRO \
|
||||
PLArena *_a = (pool)->current; \
|
||||
PRUint32 _incr = PL_ARENA_ALIGN(pool, incr); \
|
||||
PRUword _p = _a->avail; \
|
||||
PRUword _q = _p + _incr; \
|
||||
if (_p == (PRUword)(p) + PL_ARENA_ALIGN(pool, size) && \
|
||||
_q <= _a->limit) { \
|
||||
_a->avail = _q; \
|
||||
PL_ArenaCountInplaceGrowth(pool, size, incr); \
|
||||
} else { \
|
||||
p = PL_ArenaGrow(pool, p, size, incr); \
|
||||
} \
|
||||
PL_ArenaCountGrowth(pool, size, incr); \
|
||||
PR_END_MACRO
|
||||
|
||||
#define PL_ARENA_MARK(pool) ((void *) (pool)->current->avail)
|
||||
#define PR_UPTRDIFF(p,q) ((PRUword)(p) - (PRUword)(q))
|
||||
|
||||
#ifdef DEBUG
|
||||
#define PL_FREE_PATTERN 0xDA
|
||||
#define PL_CLEAR_UNUSED(a) (PR_ASSERT((a)->avail <= (a)->limit), \
|
||||
memset((void*)(a)->avail, PL_FREE_PATTERN, \
|
||||
(a)->limit - (a)->avail))
|
||||
#define PL_CLEAR_ARENA(a) memset((void*)(a), PL_FREE_PATTERN, \
|
||||
(a)->limit - (PRUword)(a))
|
||||
#else
|
||||
#define PL_CLEAR_UNUSED(a)
|
||||
#define PL_CLEAR_ARENA(a)
|
||||
#endif
|
||||
|
||||
#define PL_ARENA_RELEASE(pool, mark) \
|
||||
PR_BEGIN_MACRO \
|
||||
char *_m = (char *)(mark); \
|
||||
PLArena *_a = (pool)->current; \
|
||||
if (PR_UPTRDIFF(_m, _a->base) <= PR_UPTRDIFF(_a->avail, _a->base)) { \
|
||||
_a->avail = (PRUword)PL_ARENA_ALIGN(pool, _m); \
|
||||
PL_CLEAR_UNUSED(_a); \
|
||||
PL_ArenaCountRetract(pool, _m); \
|
||||
} else { \
|
||||
PL_ArenaRelease(pool, _m); \
|
||||
} \
|
||||
PL_ArenaCountRelease(pool, _m); \
|
||||
PR_END_MACRO
|
||||
|
||||
#ifdef PL_ARENAMETER
|
||||
#define PL_COUNT_ARENA(pool,op) ((pool)->stats.narenas op)
|
||||
#else
|
||||
#define PL_COUNT_ARENA(pool,op)
|
||||
#endif
|
||||
|
||||
#define PL_ARENA_DESTROY(pool, a, pnext) \
|
||||
PR_BEGIN_MACRO \
|
||||
PL_COUNT_ARENA(pool,--); \
|
||||
if ((pool)->current == (a)) (pool)->current = &(pool)->first; \
|
||||
*(pnext) = (a)->next; \
|
||||
PL_CLEAR_ARENA(a); \
|
||||
free(a); \
|
||||
(a) = 0; \
|
||||
PR_END_MACRO
|
||||
|
||||
#ifdef PL_ARENAMETER
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
PR_EXTERN(void) PL_ArenaCountAllocation(PLArenaPool *pool, PRUint32 nb);
|
||||
|
||||
PR_EXTERN(void) PL_ArenaCountInplaceGrowth(
|
||||
PLArenaPool *pool, PRUint32 size, PRUint32 incr);
|
||||
|
||||
PR_EXTERN(void) PL_ArenaCountGrowth(
|
||||
PLArenaPool *pool, PRUint32 size, PRUint32 incr);
|
||||
|
||||
PR_EXTERN(void) PL_ArenaCountRelease(PLArenaPool *pool, char *mark);
|
||||
|
||||
PR_EXTERN(void) PL_ArenaCountRetract(PLArenaPool *pool, char *mark);
|
||||
|
||||
PR_EXTERN(void) PL_DumpArenaStats(FILE *fp);
|
||||
|
||||
#else /* !PL_ARENAMETER */
|
||||
|
||||
#define PL_ArenaCountAllocation(ap, nb) /* nothing */
|
||||
#define PL_ArenaCountInplaceGrowth(ap, size, incr) /* nothing */
|
||||
#define PL_ArenaCountGrowth(ap, size, incr) /* nothing */
|
||||
#define PL_ArenaCountRelease(ap, mark) /* nothing */
|
||||
#define PL_ArenaCountRetract(ap, mark) /* nothing */
|
||||
|
||||
#endif /* !PL_ARENAMETER */
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif /* plarena_h___ */
|
||||
@@ -1,115 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#if defined(PLARENAS_H)
|
||||
#else /* defined(PLARENAS_H) */
|
||||
#define PLARENAS_H
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
typedef struct PLArenaPool PLArenaPool;
|
||||
|
||||
/*
|
||||
** Allocate an arena pool as specified by the parameters.
|
||||
**
|
||||
** This is equivelant to allocating the space yourself and then
|
||||
** calling PL_InitArenaPool().
|
||||
**
|
||||
** This function may fail (and return a NULL) for a variety of
|
||||
** reasons. The reason for a particular failure can be discovered
|
||||
** by calling PR_GetError().
|
||||
*/
|
||||
#if 0 /* Not implemented */
|
||||
PR_EXTERN(PLArenaPool*) PL_AllocArenaPool(
|
||||
const char *name, PRUint32 size, PRUint32 align);
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Destroy an arena pool previously allocated by PL_AllocArenaPool().
|
||||
**
|
||||
** This function may fail if the arena is not empty and the caller
|
||||
** wishes to check for empty upon descruction.
|
||||
*/
|
||||
#if 0 /* Not implemented */
|
||||
PR_EXTERN(PRStatus) PL_DestroyArenaPool(PLArenaPool *pool, PRBool checkEmpty);
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
** Initialize an arena pool with the given name for debugging and metering,
|
||||
** with a minimum size per arena of size bytes.
|
||||
**/
|
||||
PR_EXTERN(void) PL_InitArenaPool(
|
||||
PLArenaPool *pool, const char *name, PRUint32 size, PRUint32 align);
|
||||
|
||||
/*
|
||||
** Finish using arenas, freeing all memory associated with them.
|
||||
**/
|
||||
PR_EXTERN(void) PL_ArenaFinish(void);
|
||||
|
||||
/*
|
||||
** Free the arenas in pool. The user may continue to allocate from pool
|
||||
** after calling this function. There is no need to call PL_InitArenaPool()
|
||||
** again unless PL_FinishArenaPool(pool) has been called.
|
||||
**/
|
||||
PR_EXTERN(void) PL_FreeArenaPool(PLArenaPool *pool);
|
||||
|
||||
/*
|
||||
** Free the arenas in pool and finish using it altogether.
|
||||
**/
|
||||
PR_EXTERN(void) PL_FinishArenaPool(PLArenaPool *pool);
|
||||
|
||||
/*
|
||||
** Compact all of the arenas in a pool so that no space is wasted.
|
||||
**/
|
||||
PR_EXTERN(void) PL_CompactArenaPool(PLArenaPool *pool);
|
||||
|
||||
/*
|
||||
** Friend functions used by the PL_ARENA_*() macros.
|
||||
**/
|
||||
PR_EXTERN(void *) PL_ArenaAllocate(PLArenaPool *pool, PRUint32 nb);
|
||||
|
||||
PR_EXTERN(void *) PL_ArenaGrow(
|
||||
PLArenaPool *pool, void *p, PRUint32 size, PRUint32 incr);
|
||||
|
||||
PR_EXTERN(void) PL_ArenaRelease(PLArenaPool *pool, char *mark);
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif /* defined(PLARENAS_H) */
|
||||
|
||||
/* plarenas */
|
||||
@@ -1,83 +0,0 @@
|
||||
;+#
|
||||
;+# ***** BEGIN LICENSE BLOCK *****
|
||||
;+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
;+#
|
||||
;+# The contents of this file are subject to the Mozilla Public License Version
|
||||
;+# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
;+# the License. You may obtain a copy of the License at
|
||||
;+# http://www.mozilla.org/MPL/
|
||||
;+#
|
||||
;+# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
;+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
;+# for the specific language governing rights and limitations under the
|
||||
;+# License.
|
||||
;+#
|
||||
;+# The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
;+#
|
||||
;+# The Initial Developer of the Original Code is
|
||||
;+# Netscape Communications Corporation.
|
||||
;+# Portions created by the Initial Developer are Copyright (C) 2002-2003
|
||||
;+# the Initial Developer. All Rights Reserved.
|
||||
;+#
|
||||
;+# Contributor(s):
|
||||
;+#
|
||||
;+# Alternatively, the contents of this file may be used under the terms of
|
||||
;+# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
;+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
;+# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
;+# of those above. If you wish to allow use of your version of this file only
|
||||
;+# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
;+# use your version of this file under the terms of the MPL, indicate your
|
||||
;+# decision by deleting the provisions above and replace them with the notice
|
||||
;+# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
;+# the provisions above, a recipient may use your version of this file under
|
||||
;+# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
;+#
|
||||
;+# ***** END LICENSE BLOCK *****
|
||||
;+#
|
||||
;+# OK, this file is meant to support SUN, LINUX, AIX, OS/2 and WINDOWS
|
||||
;+# 1. For all unix platforms, the string ";-" means "remove this line"
|
||||
;+# 2. For all unix platforms, the string " DATA " will be removed from any
|
||||
;+# line on which it occurs.
|
||||
;+# 3. Lines containing ";+" will have ";+" removed on SUN and LINUX.
|
||||
;+# On AIX, lines containing ";+" will be removed.
|
||||
;+# 4. For all unix platforms, the string ";;" will thave the ";;" removed.
|
||||
;+# 5. For all unix platforms, after the above processing has taken place,
|
||||
;+# all characters after the first ";" on the line will be removed.
|
||||
;+# And for AIX, the first ";" will also be removed.
|
||||
;+# This file is passed directly to windows. Since ';' is a comment, all UNIX
|
||||
;+# directives are hidden behind ";", ";+", and ";-"
|
||||
;+NSPR_4.0 {
|
||||
;+ global:
|
||||
LIBRARY plds4 ;-
|
||||
EXPORTS ;-
|
||||
PL_ArenaAllocate;
|
||||
PL_ArenaFinish;
|
||||
PL_ArenaGrow;
|
||||
PL_ArenaRelease;
|
||||
PL_CompactArenaPool;
|
||||
PL_CompareStrings;
|
||||
PL_CompareValues;
|
||||
PL_FinishArenaPool;
|
||||
PL_FreeArenaPool;
|
||||
PL_HashString;
|
||||
PL_HashTableAdd;
|
||||
PL_HashTableDestroy;
|
||||
PL_HashTableDump;
|
||||
PL_HashTableEnumerateEntries;
|
||||
PL_HashTableLookup;
|
||||
PL_HashTableRawAdd;
|
||||
PL_HashTableRawLookup;
|
||||
PL_HashTableRawRemove;
|
||||
PL_HashTableRemove;
|
||||
PL_InitArenaPool;
|
||||
PL_NewHashTable;
|
||||
libVersionPoint;
|
||||
;+ local: *;
|
||||
;+};
|
||||
;+
|
||||
;+NSPR_4.1 {
|
||||
;+ global:
|
||||
PL_HashTableLookupConst;
|
||||
PL_HashTableRawLookupConst;
|
||||
;+} NSPR_4.0;
|
||||
@@ -1,101 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "prinit.h"
|
||||
#include <winver.h>
|
||||
|
||||
#define MY_LIBNAME "plds"
|
||||
#define MY_FILEDESCRIPTION "PLDS Library"
|
||||
|
||||
#define STRINGIZE(x) #x
|
||||
#define STRINGIZE2(x) STRINGIZE(x)
|
||||
#define PR_VMAJOR_STR STRINGIZE2(PR_VMAJOR)
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define MY_DEBUG_STR " (debug)"
|
||||
#define MY_FILEFLAGS_1 VS_FF_DEBUG
|
||||
#else
|
||||
#define MY_DEBUG_STR ""
|
||||
#define MY_FILEFLAGS_1 0x0L
|
||||
#endif
|
||||
#if PR_BETA
|
||||
#define MY_FILEFLAGS_2 MY_FILEFLAGS_1|VS_FF_PRERELEASE
|
||||
#else
|
||||
#define MY_FILEFLAGS_2 MY_FILEFLAGS_1
|
||||
#endif
|
||||
|
||||
#ifdef WINNT
|
||||
#define MY_FILEOS VOS_NT_WINDOWS32
|
||||
#define MY_INTERNAL_NAME "lib" MY_LIBNAME PR_VMAJOR_STR
|
||||
#else
|
||||
#define MY_FILEOS VOS__WINDOWS32
|
||||
#define MY_INTERNAL_NAME MY_LIBNAME PR_VMAJOR_STR
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version-information resource
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION PR_VMAJOR,PR_VMINOR,PR_VPATCH,0
|
||||
PRODUCTVERSION PR_VMAJOR,PR_VMINOR,PR_VPATCH,0
|
||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||
FILEFLAGS MY_FILEFLAGS_2
|
||||
FILEOS MY_FILEOS
|
||||
FILETYPE VFT_DLL
|
||||
FILESUBTYPE 0x0L // not used
|
||||
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904B0" // Lang=US English, CharSet=Unicode
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Mozilla Foundation\0"
|
||||
VALUE "FileDescription", MY_FILEDESCRIPTION MY_DEBUG_STR "\0"
|
||||
VALUE "FileVersion", PR_VERSION "\0"
|
||||
VALUE "InternalName", MY_INTERNAL_NAME "\0"
|
||||
VALUE "OriginalFilename", MY_INTERNAL_NAME ".dll\0"
|
||||
VALUE "ProductName", "Netscape Portable Runtime\0"
|
||||
VALUE "ProductVersion", PR_VERSION "\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
@@ -1,37 +0,0 @@
|
||||
! Fixed section of symbol vector for LIBPLDS4
|
||||
!
|
||||
GSMATCH=LEQUAL,2,2
|
||||
case_sensitive=YES
|
||||
!
|
||||
! --------------------------------------------------------------------------
|
||||
! Ident 2,2 introduced for Mozilla 1.3
|
||||
! Previously this was empty. Now we include everything that's specified in
|
||||
! plds.def.
|
||||
! --------------------------------------------------------------------------
|
||||
!
|
||||
! NSPR 4.0
|
||||
SYMBOL_VECTOR=(PL_ArenaAllocate=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_ArenaFinish=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_ArenaGrow=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_ArenaRelease=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_CompactArenaPool=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_CompareStrings=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_CompareValues=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_FinishArenaPool=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_FreeArenaPool=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_HashString=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_HashTableAdd=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_HashTableDestroy=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_HashTableDump=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_HashTableEnumerateEntries=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_HashTableLookup=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_HashTableRawAdd=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_HashTableRawLookup=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_HashTableRawRemove=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_HashTableRemove=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_InitArenaPool=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_NewHashTable=PROCEDURE)
|
||||
SYMBOL_VECTOR=(libVersionPoint=PROCEDURE)
|
||||
! NSPR 4.1
|
||||
SYMBOL_VECTOR=(PL_HashTableLookupConst=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_HashTableRawLookupConst=PROCEDURE)
|
||||
@@ -1,541 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* PL hash table package.
|
||||
*/
|
||||
#include "plhash.h"
|
||||
#include "prbit.h"
|
||||
#include "prlog.h"
|
||||
#include "prmem.h"
|
||||
#include "prtypes.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Compute the number of buckets in ht */
|
||||
#define NBUCKETS(ht) (1 << (PL_HASH_BITS - (ht)->shift))
|
||||
|
||||
/* The smallest table has 16 buckets */
|
||||
#define MINBUCKETSLOG2 4
|
||||
#define MINBUCKETS (1 << MINBUCKETSLOG2)
|
||||
|
||||
/* Compute the maximum entries given n buckets that we will tolerate, ~90% */
|
||||
#define OVERLOADED(n) ((n) - ((n) >> 3))
|
||||
|
||||
/* Compute the number of entries below which we shrink the table by half */
|
||||
#define UNDERLOADED(n) (((n) > MINBUCKETS) ? ((n) >> 2) : 0)
|
||||
|
||||
/*
|
||||
** Stubs for default hash allocator ops.
|
||||
*/
|
||||
static void * PR_CALLBACK
|
||||
DefaultAllocTable(void *pool, PRSize size)
|
||||
{
|
||||
#if defined(XP_MAC)
|
||||
#pragma unused (pool)
|
||||
#endif
|
||||
|
||||
return PR_MALLOC(size);
|
||||
}
|
||||
|
||||
static void PR_CALLBACK
|
||||
DefaultFreeTable(void *pool, void *item)
|
||||
{
|
||||
#if defined(XP_MAC)
|
||||
#pragma unused (pool)
|
||||
#endif
|
||||
|
||||
PR_Free(item);
|
||||
}
|
||||
|
||||
static PLHashEntry * PR_CALLBACK
|
||||
DefaultAllocEntry(void *pool, const void *key)
|
||||
{
|
||||
#if defined(XP_MAC)
|
||||
#pragma unused (pool,key)
|
||||
#endif
|
||||
|
||||
return PR_NEW(PLHashEntry);
|
||||
}
|
||||
|
||||
static void PR_CALLBACK
|
||||
DefaultFreeEntry(void *pool, PLHashEntry *he, PRUintn flag)
|
||||
{
|
||||
#if defined(XP_MAC)
|
||||
#pragma unused (pool)
|
||||
#endif
|
||||
|
||||
if (flag == HT_FREE_ENTRY)
|
||||
PR_Free(he);
|
||||
}
|
||||
|
||||
static PLHashAllocOps defaultHashAllocOps = {
|
||||
DefaultAllocTable, DefaultFreeTable,
|
||||
DefaultAllocEntry, DefaultFreeEntry
|
||||
};
|
||||
|
||||
PR_IMPLEMENT(PLHashTable *)
|
||||
PL_NewHashTable(PRUint32 n, PLHashFunction keyHash,
|
||||
PLHashComparator keyCompare, PLHashComparator valueCompare,
|
||||
const PLHashAllocOps *allocOps, void *allocPriv)
|
||||
{
|
||||
PLHashTable *ht;
|
||||
PRSize nb;
|
||||
|
||||
if (n <= MINBUCKETS) {
|
||||
n = MINBUCKETSLOG2;
|
||||
} else {
|
||||
n = PR_CeilingLog2(n);
|
||||
if ((PRInt32)n < 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!allocOps) allocOps = &defaultHashAllocOps;
|
||||
|
||||
ht = (PLHashTable*)((*allocOps->allocTable)(allocPriv, sizeof *ht));
|
||||
if (!ht)
|
||||
return 0;
|
||||
memset(ht, 0, sizeof *ht);
|
||||
ht->shift = PL_HASH_BITS - n;
|
||||
n = 1 << n;
|
||||
#if defined(WIN16)
|
||||
if (n > 16000) {
|
||||
(*allocOps->freeTable)(allocPriv, ht);
|
||||
return 0;
|
||||
}
|
||||
#endif /* WIN16 */
|
||||
nb = n * sizeof(PLHashEntry *);
|
||||
ht->buckets = (PLHashEntry**)((*allocOps->allocTable)(allocPriv, nb));
|
||||
if (!ht->buckets) {
|
||||
(*allocOps->freeTable)(allocPriv, ht);
|
||||
return 0;
|
||||
}
|
||||
memset(ht->buckets, 0, nb);
|
||||
|
||||
ht->keyHash = keyHash;
|
||||
ht->keyCompare = keyCompare;
|
||||
ht->valueCompare = valueCompare;
|
||||
ht->allocOps = allocOps;
|
||||
ht->allocPriv = allocPriv;
|
||||
return ht;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void)
|
||||
PL_HashTableDestroy(PLHashTable *ht)
|
||||
{
|
||||
PRUint32 i, n;
|
||||
PLHashEntry *he, *next;
|
||||
const PLHashAllocOps *allocOps = ht->allocOps;
|
||||
void *allocPriv = ht->allocPriv;
|
||||
|
||||
n = NBUCKETS(ht);
|
||||
for (i = 0; i < n; i++) {
|
||||
for (he = ht->buckets[i]; he; he = next) {
|
||||
next = he->next;
|
||||
(*allocOps->freeEntry)(allocPriv, he, HT_FREE_ENTRY);
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
memset(ht->buckets, 0xDB, n * sizeof ht->buckets[0]);
|
||||
#endif
|
||||
(*allocOps->freeTable)(allocPriv, ht->buckets);
|
||||
#ifdef DEBUG
|
||||
memset(ht, 0xDB, sizeof *ht);
|
||||
#endif
|
||||
(*allocOps->freeTable)(allocPriv, ht);
|
||||
}
|
||||
|
||||
/*
|
||||
** Multiplicative hash, from Knuth 6.4.
|
||||
*/
|
||||
#define GOLDEN_RATIO 0x9E3779B9U /* 2/(1+sqrt(5))*(2^32) */
|
||||
|
||||
PR_IMPLEMENT(PLHashEntry **)
|
||||
PL_HashTableRawLookup(PLHashTable *ht, PLHashNumber keyHash, const void *key)
|
||||
{
|
||||
PLHashEntry *he, **hep, **hep0;
|
||||
PLHashNumber h;
|
||||
|
||||
#ifdef HASHMETER
|
||||
ht->nlookups++;
|
||||
#endif
|
||||
h = keyHash * GOLDEN_RATIO;
|
||||
h >>= ht->shift;
|
||||
hep = hep0 = &ht->buckets[h];
|
||||
while ((he = *hep) != 0) {
|
||||
if (he->keyHash == keyHash && (*ht->keyCompare)(key, he->key)) {
|
||||
/* Move to front of chain if not already there */
|
||||
if (hep != hep0) {
|
||||
*hep = he->next;
|
||||
he->next = *hep0;
|
||||
*hep0 = he;
|
||||
}
|
||||
return hep0;
|
||||
}
|
||||
hep = &he->next;
|
||||
#ifdef HASHMETER
|
||||
ht->nsteps++;
|
||||
#endif
|
||||
}
|
||||
return hep;
|
||||
}
|
||||
|
||||
/*
|
||||
** Same as PL_HashTableRawLookup but doesn't reorder the hash entries.
|
||||
*/
|
||||
PR_IMPLEMENT(PLHashEntry **)
|
||||
PL_HashTableRawLookupConst(PLHashTable *ht, PLHashNumber keyHash,
|
||||
const void *key)
|
||||
{
|
||||
PLHashEntry *he, **hep;
|
||||
PLHashNumber h;
|
||||
|
||||
#ifdef HASHMETER
|
||||
ht->nlookups++;
|
||||
#endif
|
||||
h = keyHash * GOLDEN_RATIO;
|
||||
h >>= ht->shift;
|
||||
hep = &ht->buckets[h];
|
||||
while ((he = *hep) != 0) {
|
||||
if (he->keyHash == keyHash && (*ht->keyCompare)(key, he->key)) {
|
||||
break;
|
||||
}
|
||||
hep = &he->next;
|
||||
#ifdef HASHMETER
|
||||
ht->nsteps++;
|
||||
#endif
|
||||
}
|
||||
return hep;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(PLHashEntry *)
|
||||
PL_HashTableRawAdd(PLHashTable *ht, PLHashEntry **hep,
|
||||
PLHashNumber keyHash, const void *key, void *value)
|
||||
{
|
||||
PRUint32 i, n;
|
||||
PLHashEntry *he, *next, **oldbuckets;
|
||||
PRSize nb;
|
||||
|
||||
/* Grow the table if it is overloaded */
|
||||
n = NBUCKETS(ht);
|
||||
if (ht->nentries >= OVERLOADED(n)) {
|
||||
oldbuckets = ht->buckets;
|
||||
#if defined(WIN16)
|
||||
if (2 * n > 16000)
|
||||
return 0;
|
||||
#endif /* WIN16 */
|
||||
nb = 2 * n * sizeof(PLHashEntry *);
|
||||
ht->buckets = (PLHashEntry**)
|
||||
((*ht->allocOps->allocTable)(ht->allocPriv, nb));
|
||||
if (!ht->buckets) {
|
||||
ht->buckets = oldbuckets;
|
||||
return 0;
|
||||
}
|
||||
memset(ht->buckets, 0, nb);
|
||||
#ifdef HASHMETER
|
||||
ht->ngrows++;
|
||||
#endif
|
||||
ht->shift--;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
for (he = oldbuckets[i]; he; he = next) {
|
||||
next = he->next;
|
||||
hep = PL_HashTableRawLookup(ht, he->keyHash, he->key);
|
||||
PR_ASSERT(*hep == 0);
|
||||
he->next = 0;
|
||||
*hep = he;
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
memset(oldbuckets, 0xDB, n * sizeof oldbuckets[0]);
|
||||
#endif
|
||||
(*ht->allocOps->freeTable)(ht->allocPriv, oldbuckets);
|
||||
hep = PL_HashTableRawLookup(ht, keyHash, key);
|
||||
}
|
||||
|
||||
/* Make a new key value entry */
|
||||
he = (*ht->allocOps->allocEntry)(ht->allocPriv, key);
|
||||
if (!he)
|
||||
return 0;
|
||||
he->keyHash = keyHash;
|
||||
he->key = key;
|
||||
he->value = value;
|
||||
he->next = *hep;
|
||||
*hep = he;
|
||||
ht->nentries++;
|
||||
return he;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(PLHashEntry *)
|
||||
PL_HashTableAdd(PLHashTable *ht, const void *key, void *value)
|
||||
{
|
||||
PLHashNumber keyHash;
|
||||
PLHashEntry *he, **hep;
|
||||
|
||||
keyHash = (*ht->keyHash)(key);
|
||||
hep = PL_HashTableRawLookup(ht, keyHash, key);
|
||||
if ((he = *hep) != 0) {
|
||||
/* Hit; see if values match */
|
||||
if ((*ht->valueCompare)(he->value, value)) {
|
||||
/* key,value pair is already present in table */
|
||||
return he;
|
||||
}
|
||||
if (he->value)
|
||||
(*ht->allocOps->freeEntry)(ht->allocPriv, he, HT_FREE_VALUE);
|
||||
he->value = value;
|
||||
return he;
|
||||
}
|
||||
return PL_HashTableRawAdd(ht, hep, keyHash, key, value);
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void)
|
||||
PL_HashTableRawRemove(PLHashTable *ht, PLHashEntry **hep, PLHashEntry *he)
|
||||
{
|
||||
PRUint32 i, n;
|
||||
PLHashEntry *next, **oldbuckets;
|
||||
PRSize nb;
|
||||
|
||||
*hep = he->next;
|
||||
(*ht->allocOps->freeEntry)(ht->allocPriv, he, HT_FREE_ENTRY);
|
||||
|
||||
/* Shrink table if it's underloaded */
|
||||
n = NBUCKETS(ht);
|
||||
if (--ht->nentries < UNDERLOADED(n)) {
|
||||
oldbuckets = ht->buckets;
|
||||
nb = n * sizeof(PLHashEntry*) / 2;
|
||||
ht->buckets = (PLHashEntry**)(
|
||||
(*ht->allocOps->allocTable)(ht->allocPriv, nb));
|
||||
if (!ht->buckets) {
|
||||
ht->buckets = oldbuckets;
|
||||
return;
|
||||
}
|
||||
memset(ht->buckets, 0, nb);
|
||||
#ifdef HASHMETER
|
||||
ht->nshrinks++;
|
||||
#endif
|
||||
ht->shift++;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
for (he = oldbuckets[i]; he; he = next) {
|
||||
next = he->next;
|
||||
hep = PL_HashTableRawLookup(ht, he->keyHash, he->key);
|
||||
PR_ASSERT(*hep == 0);
|
||||
he->next = 0;
|
||||
*hep = he;
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
memset(oldbuckets, 0xDB, n * sizeof oldbuckets[0]);
|
||||
#endif
|
||||
(*ht->allocOps->freeTable)(ht->allocPriv, oldbuckets);
|
||||
}
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(PRBool)
|
||||
PL_HashTableRemove(PLHashTable *ht, const void *key)
|
||||
{
|
||||
PLHashNumber keyHash;
|
||||
PLHashEntry *he, **hep;
|
||||
|
||||
keyHash = (*ht->keyHash)(key);
|
||||
hep = PL_HashTableRawLookup(ht, keyHash, key);
|
||||
if ((he = *hep) == 0)
|
||||
return PR_FALSE;
|
||||
|
||||
/* Hit; remove element */
|
||||
PL_HashTableRawRemove(ht, hep, he);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void *)
|
||||
PL_HashTableLookup(PLHashTable *ht, const void *key)
|
||||
{
|
||||
PLHashNumber keyHash;
|
||||
PLHashEntry *he, **hep;
|
||||
|
||||
keyHash = (*ht->keyHash)(key);
|
||||
hep = PL_HashTableRawLookup(ht, keyHash, key);
|
||||
if ((he = *hep) != 0) {
|
||||
return he->value;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Same as PL_HashTableLookup but doesn't reorder the hash entries.
|
||||
*/
|
||||
PR_IMPLEMENT(void *)
|
||||
PL_HashTableLookupConst(PLHashTable *ht, const void *key)
|
||||
{
|
||||
PLHashNumber keyHash;
|
||||
PLHashEntry *he, **hep;
|
||||
|
||||
keyHash = (*ht->keyHash)(key);
|
||||
hep = PL_HashTableRawLookupConst(ht, keyHash, key);
|
||||
if ((he = *hep) != 0) {
|
||||
return he->value;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Iterate over the entries in the hash table calling func for each
|
||||
** entry found. Stop if "f" says to (return value & PR_ENUMERATE_STOP).
|
||||
** Return a count of the number of elements scanned.
|
||||
*/
|
||||
PR_IMPLEMENT(int)
|
||||
PL_HashTableEnumerateEntries(PLHashTable *ht, PLHashEnumerator f, void *arg)
|
||||
{
|
||||
PLHashEntry *he, **hep;
|
||||
PRUint32 i, nbuckets;
|
||||
int rv, n = 0;
|
||||
PLHashEntry *todo = 0;
|
||||
|
||||
nbuckets = NBUCKETS(ht);
|
||||
for (i = 0; i < nbuckets; i++) {
|
||||
hep = &ht->buckets[i];
|
||||
while ((he = *hep) != 0) {
|
||||
rv = (*f)(he, n, arg);
|
||||
n++;
|
||||
if (rv & (HT_ENUMERATE_REMOVE | HT_ENUMERATE_UNHASH)) {
|
||||
*hep = he->next;
|
||||
if (rv & HT_ENUMERATE_REMOVE) {
|
||||
he->next = todo;
|
||||
todo = he;
|
||||
}
|
||||
} else {
|
||||
hep = &he->next;
|
||||
}
|
||||
if (rv & HT_ENUMERATE_STOP) {
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
hep = &todo;
|
||||
while ((he = *hep) != 0) {
|
||||
PL_HashTableRawRemove(ht, hep, he);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
#ifdef HASHMETER
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
PR_IMPLEMENT(void)
|
||||
PL_HashTableDumpMeter(PLHashTable *ht, PLHashEnumerator dump, FILE *fp)
|
||||
{
|
||||
double mean, variance;
|
||||
PRUint32 nchains, nbuckets;
|
||||
PRUint32 i, n, maxChain, maxChainLen;
|
||||
PLHashEntry *he;
|
||||
|
||||
variance = 0;
|
||||
nchains = 0;
|
||||
maxChainLen = 0;
|
||||
nbuckets = NBUCKETS(ht);
|
||||
for (i = 0; i < nbuckets; i++) {
|
||||
he = ht->buckets[i];
|
||||
if (!he)
|
||||
continue;
|
||||
nchains++;
|
||||
for (n = 0; he; he = he->next)
|
||||
n++;
|
||||
variance += n * n;
|
||||
if (n > maxChainLen) {
|
||||
maxChainLen = n;
|
||||
maxChain = i;
|
||||
}
|
||||
}
|
||||
mean = (double)ht->nentries / nchains;
|
||||
variance = fabs(variance / nchains - mean * mean);
|
||||
|
||||
fprintf(fp, "\nHash table statistics:\n");
|
||||
fprintf(fp, " number of lookups: %u\n", ht->nlookups);
|
||||
fprintf(fp, " number of entries: %u\n", ht->nentries);
|
||||
fprintf(fp, " number of grows: %u\n", ht->ngrows);
|
||||
fprintf(fp, " number of shrinks: %u\n", ht->nshrinks);
|
||||
fprintf(fp, " mean steps per hash: %g\n", (double)ht->nsteps
|
||||
/ ht->nlookups);
|
||||
fprintf(fp, "mean hash chain length: %g\n", mean);
|
||||
fprintf(fp, " standard deviation: %g\n", sqrt(variance));
|
||||
fprintf(fp, " max hash chain length: %u\n", maxChainLen);
|
||||
fprintf(fp, " max hash chain: [%u]\n", maxChain);
|
||||
|
||||
for (he = ht->buckets[maxChain], i = 0; he; he = he->next, i++)
|
||||
if ((*dump)(he, i, fp) != HT_ENUMERATE_NEXT)
|
||||
break;
|
||||
}
|
||||
#endif /* HASHMETER */
|
||||
|
||||
PR_IMPLEMENT(int)
|
||||
PL_HashTableDump(PLHashTable *ht, PLHashEnumerator dump, FILE *fp)
|
||||
{
|
||||
int count;
|
||||
|
||||
count = PL_HashTableEnumerateEntries(ht, dump, fp);
|
||||
#ifdef HASHMETER
|
||||
PL_HashTableDumpMeter(ht, dump, fp);
|
||||
#endif
|
||||
return count;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(PLHashNumber)
|
||||
PL_HashString(const void *key)
|
||||
{
|
||||
PLHashNumber h;
|
||||
const PRUint8 *s;
|
||||
|
||||
h = 0;
|
||||
for (s = (const PRUint8*)key; *s; s++)
|
||||
h = (h >> 28) ^ (h << 4) ^ *s;
|
||||
return h;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(int)
|
||||
PL_CompareStrings(const void *v1, const void *v2)
|
||||
{
|
||||
return strcmp((const char*)v1, (const char*)v2) == 0;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(int)
|
||||
PL_CompareValues(const void *v1, const void *v2)
|
||||
{
|
||||
return v1 == v2;
|
||||
}
|
||||
@@ -1,165 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef plhash_h___
|
||||
#define plhash_h___
|
||||
/*
|
||||
* API to portable hash table code.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "prtypes.h"
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
typedef struct PLHashEntry PLHashEntry;
|
||||
typedef struct PLHashTable PLHashTable;
|
||||
typedef PRUint32 PLHashNumber;
|
||||
#define PL_HASH_BITS 32 /* Number of bits in PLHashNumber */
|
||||
typedef PLHashNumber (PR_CALLBACK *PLHashFunction)(const void *key);
|
||||
typedef PRIntn (PR_CALLBACK *PLHashComparator)(const void *v1, const void *v2);
|
||||
|
||||
#if defined(XP_OS2_VACPP) && defined(VACPP_FLIP) /* for nsSpaceManager.cpp */
|
||||
PR_END_EXTERN_C /* and nsHTMLDocument.cpp */
|
||||
#endif
|
||||
typedef PRIntn (PR_CALLBACK *PLHashEnumerator)(PLHashEntry *he, PRIntn i, void *arg);
|
||||
|
||||
#if defined(XP_OS2_VACPP) && defined(VACPP_FLIP)
|
||||
PR_BEGIN_EXTERN_C
|
||||
#endif
|
||||
|
||||
/* Flag bits in PLHashEnumerator's return value */
|
||||
#define HT_ENUMERATE_NEXT 0 /* continue enumerating entries */
|
||||
#define HT_ENUMERATE_STOP 1 /* stop enumerating entries */
|
||||
#define HT_ENUMERATE_REMOVE 2 /* remove and free the current entry */
|
||||
#define HT_ENUMERATE_UNHASH 4 /* just unhash the current entry */
|
||||
|
||||
typedef struct PLHashAllocOps {
|
||||
void * (PR_CALLBACK *allocTable)(void *pool, PRSize size);
|
||||
void (PR_CALLBACK *freeTable)(void *pool, void *item);
|
||||
PLHashEntry * (PR_CALLBACK *allocEntry)(void *pool, const void *key);
|
||||
void (PR_CALLBACK *freeEntry)(void *pool, PLHashEntry *he, PRUintn flag);
|
||||
} PLHashAllocOps;
|
||||
|
||||
#define HT_FREE_VALUE 0 /* just free the entry's value */
|
||||
#define HT_FREE_ENTRY 1 /* free value and entire entry */
|
||||
|
||||
struct PLHashEntry {
|
||||
PLHashEntry *next; /* hash chain linkage */
|
||||
PLHashNumber keyHash; /* key hash function result */
|
||||
const void *key; /* ptr to opaque key */
|
||||
void *value; /* ptr to opaque value */
|
||||
};
|
||||
|
||||
struct PLHashTable {
|
||||
PLHashEntry **buckets; /* vector of hash buckets */
|
||||
PRUint32 nentries; /* number of entries in table */
|
||||
PRUint32 shift; /* multiplicative hash shift */
|
||||
PLHashFunction keyHash; /* key hash function */
|
||||
PLHashComparator keyCompare; /* key comparison function */
|
||||
PLHashComparator valueCompare; /* value comparison function */
|
||||
const PLHashAllocOps *allocOps; /* allocation operations */
|
||||
void *allocPriv; /* allocation private data */
|
||||
#ifdef HASHMETER
|
||||
PRUint32 nlookups; /* total number of lookups */
|
||||
PRUint32 nsteps; /* number of hash chains traversed */
|
||||
PRUint32 ngrows; /* number of table expansions */
|
||||
PRUint32 nshrinks; /* number of table contractions */
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
* Create a new hash table.
|
||||
* If allocOps is null, use default allocator ops built on top of malloc().
|
||||
*/
|
||||
PR_EXTERN(PLHashTable *)
|
||||
PL_NewHashTable(PRUint32 numBuckets, PLHashFunction keyHash,
|
||||
PLHashComparator keyCompare, PLHashComparator valueCompare,
|
||||
const PLHashAllocOps *allocOps, void *allocPriv);
|
||||
|
||||
PR_EXTERN(void)
|
||||
PL_HashTableDestroy(PLHashTable *ht);
|
||||
|
||||
/* Higher level access methods */
|
||||
PR_EXTERN(PLHashEntry *)
|
||||
PL_HashTableAdd(PLHashTable *ht, const void *key, void *value);
|
||||
|
||||
PR_EXTERN(PRBool)
|
||||
PL_HashTableRemove(PLHashTable *ht, const void *key);
|
||||
|
||||
PR_EXTERN(void *)
|
||||
PL_HashTableLookup(PLHashTable *ht, const void *key);
|
||||
|
||||
PR_EXTERN(void *)
|
||||
PL_HashTableLookupConst(PLHashTable *ht, const void *key);
|
||||
|
||||
PR_EXTERN(PRIntn)
|
||||
PL_HashTableEnumerateEntries(PLHashTable *ht, PLHashEnumerator f, void *arg);
|
||||
|
||||
/* General-purpose C string hash function. */
|
||||
PR_EXTERN(PLHashNumber)
|
||||
PL_HashString(const void *key);
|
||||
|
||||
/* Compare strings using strcmp(), return true if equal. */
|
||||
PR_EXTERN(PRIntn)
|
||||
PL_CompareStrings(const void *v1, const void *v2);
|
||||
|
||||
/* Stub function just returns v1 == v2 */
|
||||
PR_EXTERN(PRIntn)
|
||||
PL_CompareValues(const void *v1, const void *v2);
|
||||
|
||||
/* Low level access methods */
|
||||
PR_EXTERN(PLHashEntry **)
|
||||
PL_HashTableRawLookup(PLHashTable *ht, PLHashNumber keyHash, const void *key);
|
||||
|
||||
PR_EXTERN(PLHashEntry **)
|
||||
PL_HashTableRawLookupConst(PLHashTable *ht, PLHashNumber keyHash,
|
||||
const void *key);
|
||||
|
||||
PR_EXTERN(PLHashEntry *)
|
||||
PL_HashTableRawAdd(PLHashTable *ht, PLHashEntry **hep, PLHashNumber keyHash,
|
||||
const void *key, void *value);
|
||||
|
||||
PR_EXTERN(void)
|
||||
PL_HashTableRawRemove(PLHashTable *ht, PLHashEntry **hep, PLHashEntry *he);
|
||||
|
||||
/* This can be trivially implemented using PL_HashTableEnumerateEntries. */
|
||||
PR_EXTERN(PRIntn)
|
||||
PL_HashTableDump(PLHashTable *ht, PLHashEnumerator dump, FILE *fp);
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif /* plhash_h___ */
|
||||
@@ -1,125 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "prinit.h"
|
||||
#include "prvrsion.h"
|
||||
|
||||
/************************************************************************/
|
||||
/**************************IDENTITY AND VERSIONING***********************/
|
||||
/************************************************************************/
|
||||
#include "_pl_bld.h"
|
||||
#if !defined(_BUILD_TIME)
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#define _BUILD_TIME 0
|
||||
#else
|
||||
#define _BUILD_TIME {0, 0}
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(_BUILD_STRING)
|
||||
#define _BUILD_STRING ""
|
||||
#endif
|
||||
#if !defined(_PRODUCTION)
|
||||
#define _PRODUCTION ""
|
||||
#endif
|
||||
#if defined(DEBUG)
|
||||
#define _DEBUG_STRING " (debug)"
|
||||
#else
|
||||
#define _DEBUG_STRING ""
|
||||
#endif
|
||||
|
||||
/*
|
||||
* A trick to expand the PR_VMAJOR macro before concatenation.
|
||||
*/
|
||||
#define CONCAT(x, y) x ## y
|
||||
#define CONCAT2(x, y) CONCAT(x, y)
|
||||
#define VERSION_DESC_NAME CONCAT2(prVersionDescription_libplds, PR_VMAJOR)
|
||||
|
||||
PRVersionDescription VERSION_DESC_NAME =
|
||||
{
|
||||
/* version */ 2, /* this is the only one supported */
|
||||
/* buildTime */ _BUILD_TIME, /* usecs since midnight 1/1/1970 GMT */
|
||||
/* buildTimeString */ _BUILD_STRING, /* ditto, but human readable */
|
||||
/* vMajor */ PR_VMAJOR, /* NSPR's version number */
|
||||
/* vMinor */ PR_VMINOR, /* and minor version */
|
||||
/* vPatch */ PR_VPATCH, /* and patch */
|
||||
/* beta */ PR_BETA, /* beta build boolean */
|
||||
#if defined(DEBUG)
|
||||
/* debug */ PR_TRUE, /* a debug build */
|
||||
#else
|
||||
/* debug */ PR_FALSE, /* an optomized build */
|
||||
#endif
|
||||
/* special */ PR_FALSE, /* they're all special, but ... */
|
||||
/* filename */ _PRODUCTION, /* the produced library name */
|
||||
/* description */ "Portable runtime", /* what we are */
|
||||
/* security */ "N/A", /* not applicable here */
|
||||
/* copywrite */ "Copyright (c) 1998 Netscape Communications Corporation. All Rights Reserved",
|
||||
/* comment */ "http://www.mozilla.org/MPL/",
|
||||
/* specialString */ ""
|
||||
};
|
||||
|
||||
#ifdef XP_UNIX
|
||||
|
||||
/*
|
||||
* Version information for the 'ident' and 'what commands
|
||||
*
|
||||
* NOTE: the first component of the concatenated rcsid string
|
||||
* must not end in a '$' to prevent rcs keyword substitution.
|
||||
*/
|
||||
static char rcsid[] = "$Header: NSPR " PR_VERSION _DEBUG_STRING
|
||||
" " _BUILD_STRING " $";
|
||||
static char sccsid[] = "@(#)NSPR " PR_VERSION _DEBUG_STRING
|
||||
" " _BUILD_STRING;
|
||||
|
||||
#endif /* XP_UNIX */
|
||||
|
||||
PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint()
|
||||
{
|
||||
#ifdef XP_UNIX
|
||||
/*
|
||||
* Add dummy references to rcsid and sccsid to prevent them
|
||||
* from being optimized away as unused variables.
|
||||
*/
|
||||
const char *dummy;
|
||||
|
||||
dummy = rcsid;
|
||||
dummy = sccsid;
|
||||
#endif
|
||||
return &VERSION_DESC_NAME;
|
||||
} /* versionEntryPointType */
|
||||
|
||||
/* plvrsion.c */
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
#! gmake
|
||||
|
||||
MOD_DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(MOD_DEPTH)/config/autoconf.mk
|
||||
|
||||
export NSPR20=1
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
DIRS = include src
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
export:: $(TARGETS)
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
NSPR 2.0 libc functions
|
||||
-----------------------
|
||||
|
||||
Last edited: AOF 04 March 1997
|
||||
|
||||
This directory contains various libc-types of functions. All functions in
|
||||
this directory are platform independent, thread friendly (both safe and
|
||||
efficient). They are contributed from various sources, though the contri-
|
||||
butions are monitored by the NSPR group (mailto:freier).
|
||||
|
||||
All API items exported by these functions will contain the same three
|
||||
character prefix, "PL_" (Portable Library). Internal function names
|
||||
that are not exported (static) are of little concern, though some caution
|
||||
must be used on those elements that are 'extern' but not really intended
|
||||
to be part of the API. Those should all have a prefix of "_PL_" (is that
|
||||
legal?).
|
||||
|
||||
The responsibility for contributions in this area are distributed among
|
||||
all interested parties.
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist directory
|
||||
#
|
||||
|
||||
plbase64.h
|
||||
plerror.h
|
||||
plgetopt.h
|
||||
plresolv.h
|
||||
plstr.h
|
||||
@@ -1,61 +0,0 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
#! gmake
|
||||
|
||||
MOD_DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(MOD_DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
HEADERS = $(wildcard $(srcdir)/*.h)
|
||||
|
||||
RELEASE_HEADERS = $(HEADERS)
|
||||
RELEASE_HEADERS_DEST = $(RELEASE_INCLUDE_DIR)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
export:: $(HEADERS)
|
||||
$(INSTALL) -m 444 $(HEADERS) $(dist_includedir)
|
||||
ifeq ($(MOZ_BITS),16)
|
||||
$(INSTALL) -m 444 $(HEADERS) $(MOZ_INCL)
|
||||
endif
|
||||
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
NSPR 2.0 libc functions
|
||||
-----------------------
|
||||
|
||||
Last edited: AOF 04 March 1997
|
||||
|
||||
This directory contains the API for various libc-types of functions.
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _plbase64_h
|
||||
#define _plbase64_h
|
||||
|
||||
#include "prtypes.h"
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
/*
|
||||
* PL_Base64Encode
|
||||
*
|
||||
* This routine encodes the data pointed to by the "src" parameter using the
|
||||
* base64 algorithm, and returns a pointer to the result. If the "srclen"
|
||||
* parameter is not zero, it specifies the length of the source data. If it
|
||||
* is zero, the source data is assumed to be null-terminated, and PL_strlen
|
||||
* is used to determine the source length. If the "dest" parameter is not
|
||||
* null, it is assumed to point to a buffer of sufficient size (which may be
|
||||
* calculated: ((srclen + 2)/3)*4) into which the encoded data is placed
|
||||
* (without any termination). If the "dest" parameter is null, a buffer is
|
||||
* allocated from the heap to hold the encoded data, and the result *will*
|
||||
* be terminated with an extra null character. It is the caller's
|
||||
* responsibility to free the result when it is allocated. A null is returned
|
||||
* if the allocation fails.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_Base64Encode
|
||||
(
|
||||
const char *src,
|
||||
PRUint32 srclen,
|
||||
char *dest
|
||||
);
|
||||
|
||||
/*
|
||||
* PL_Base64Decode
|
||||
*
|
||||
* This routine decodes the data pointed to by the "src" parameter using
|
||||
* the base64 algorithm, and returns a pointer to the result. The source
|
||||
* may either include or exclude any trailing '=' characters. If the
|
||||
* "srclen" parameter is not zero, it specifies the length of the source
|
||||
* data. If it is zero, PL_strlen will be used to determine the source
|
||||
* length. If the "dest" parameter is not null, it is assumed to point to
|
||||
* a buffer of sufficient size (which may be calculated: (srclen * 3)/4
|
||||
* when srclen includes the '=' characters) into which the decoded data
|
||||
* is placed (without any termination). If the "dest" parameter is null,
|
||||
* a buffer is allocated from the heap to hold the decoded data, and the
|
||||
* result *will* be terminated with an extra null character. It is the
|
||||
* caller's responsibility to free the result when it is allocated. A null
|
||||
* is retuned if the allocation fails, or if the source is not well-coded.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_Base64Decode
|
||||
(
|
||||
const char *src,
|
||||
PRUint32 srclen,
|
||||
char *dest
|
||||
);
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif /* _plbase64_h */
|
||||
@@ -1,66 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
** File: plerror.h
|
||||
** Description: Simple routine to print translate the calling thread's
|
||||
** error numbers and print them.
|
||||
*/
|
||||
|
||||
#if defined(PLERROR_H)
|
||||
#else
|
||||
#define PLERROR_H
|
||||
|
||||
#include "prio.h"
|
||||
#include "prtypes.h"
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
/*
|
||||
** Print the messages to "syserr" prepending 'msg' if not NULL.
|
||||
*/
|
||||
PR_EXTERN(void) PL_PrintError(const char *msg);
|
||||
|
||||
/*
|
||||
** Print the messages to specified output file prepending 'msg' if not NULL.
|
||||
*/
|
||||
PR_EXTERN(void) PL_FPrintError(PRFileDesc *output, const char *msg);
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif /* defined(PLERROR_H) */
|
||||
|
||||
/* plerror.h */
|
||||
@@ -1,156 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
** File: plgetopt.h
|
||||
** Description: utilities to parse argc/argv
|
||||
*/
|
||||
|
||||
#if defined(PLGETOPT_H_)
|
||||
#else
|
||||
#define PLGETOPT_H_
|
||||
|
||||
#include "prtypes.h"
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
typedef struct PLOptionInternal PLOptionInternal;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PL_OPT_OK, /* all's well with the option */
|
||||
PL_OPT_EOL, /* end of options list */
|
||||
PL_OPT_BAD /* invalid option (and value) */
|
||||
} PLOptStatus;
|
||||
|
||||
typedef struct PLLongOpt
|
||||
{
|
||||
const char * longOptName; /* long option name string */
|
||||
PRIntn longOption; /* value put in PLOptState for this option. */
|
||||
PRBool valueRequired; /* If option name not followed by '=', */
|
||||
/* value is the next argument from argv. */
|
||||
} PLLongOpt;
|
||||
|
||||
typedef struct PLOptState
|
||||
{
|
||||
char option; /* the name of the option */
|
||||
const char *value; /* the value of that option | NULL */
|
||||
|
||||
PLOptionInternal *internal; /* private processing state */
|
||||
|
||||
PRIntn longOption; /* value from PLLongOpt put here */
|
||||
PRIntn longOptIndex; /* index into caller's array of PLLongOpts */
|
||||
} PLOptState;
|
||||
|
||||
/*
|
||||
* PL_CreateOptState
|
||||
*
|
||||
* The argument "options" points to a string of single-character option
|
||||
* names. Option names that may have an option argument value must be
|
||||
* followed immediately by a ':' character.
|
||||
*/
|
||||
PR_EXTERN(PLOptState*) PL_CreateOptState(
|
||||
PRIntn argc, char **argv, const char *options);
|
||||
|
||||
/*
|
||||
* PL_CreateLongOptState
|
||||
*
|
||||
* Alternative to PL_CreateOptState.
|
||||
* Allows caller to specify BOTH a string of single-character option names,
|
||||
* AND an array of structures describing "long" (keyword) option names.
|
||||
* The array is terminated by a structure in which longOptName is NULL.
|
||||
* Long option values (arguments) may always be given as "--name=value".
|
||||
* If PLLongOpt.valueRequired is not PR_FALSE, and the option name was not
|
||||
* followed by '=' then the next argument from argv is taken as the value.
|
||||
*/
|
||||
PR_EXTERN(PLOptState*) PL_CreateLongOptState(
|
||||
PRIntn argc, char **argv, const char *options,
|
||||
const PLLongOpt *longOpts);
|
||||
/*
|
||||
* PL_DestroyOptState
|
||||
*
|
||||
* Call this to destroy the PLOptState returned from PL_CreateOptState or
|
||||
* PL_CreateLongOptState.
|
||||
*/
|
||||
PR_EXTERN(void) PL_DestroyOptState(PLOptState *opt);
|
||||
|
||||
/*
|
||||
* PL_GetNextOpt
|
||||
*
|
||||
* When this function returns PL_OPT_OK,
|
||||
* - opt->option will hold the single-character option name that was parsed,
|
||||
* or zero.
|
||||
* When opt->option is zero, the token parsed was either a "long" (keyword)
|
||||
* option or a positional parameter.
|
||||
* For a positional parameter,
|
||||
* - opt->longOptIndex will contain -1, and
|
||||
* - opt->value will point to the positional parameter string.
|
||||
* For a long option name,
|
||||
* - opt->longOptIndex will contain the non-negative index of the
|
||||
* PLLongOpt structure in the caller's array of PLLongOpt structures
|
||||
8 corresponding to the long option name, and
|
||||
* For a single-character or long option,
|
||||
* - opt->longOption will contain the value of the single-character option
|
||||
* name, or the value of the longOption from the PLLongOpt structure
|
||||
* for that long option. See notes below.
|
||||
* - opt->value will point to the argument option string, or will
|
||||
* be NULL if no argument option string was given.
|
||||
* When opt->option is non-zero,
|
||||
* - opt->longOptIndex will be -1
|
||||
* When this function returns PL_OPT_EOL, or PL_OPT_BAD, the contents of
|
||||
* opt are undefined.
|
||||
*
|
||||
* Notes: It is possible to ignore opt->option, and always look at
|
||||
* opt->longOption instead. opt->longOption will contain the same value
|
||||
* as opt->option for single-character option names, and will contain the
|
||||
* value of longOption from the PLLongOpt structure for long option names.
|
||||
* This means that it is possible to equivalence long option names to
|
||||
* single character names by giving the longOption in the PLLongOpt struct
|
||||
* the same value as the single-character option name.
|
||||
* For long options that are NOT intended to be equivalent to any single-
|
||||
* character option, the longOption value should be chosen to not match
|
||||
* any possible single character name. It might be advisable to choose
|
||||
* longOption values greater than 0xff for such long options.
|
||||
*/
|
||||
PR_EXTERN(PLOptStatus) PL_GetNextOpt(PLOptState *opt);
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif /* defined(PLGETOPT_H_) */
|
||||
|
||||
/* plgetopt.h */
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* plresolv.h - asynchronous name resolution using DNS
|
||||
*/
|
||||
|
||||
#ifndef _PLRESOLV_H_
|
||||
#define _PLRESOLV_H_
|
||||
|
||||
/*
|
||||
** THIS IS WORK IN PROGRESS. DO NOT ATTEMPT TO USE ANY PORTION OF THIS
|
||||
** API UNTIL THIS MESSAGE NO LONGER EXISTS. IF YOU DO, THEN YOU SURRENDER
|
||||
** THE RIGHT TO COMPLAIN ABOUT ANY CONTENT.
|
||||
*/
|
||||
|
||||
#if defined(XP_UNIX)
|
||||
|
||||
#include <prtypes.h>
|
||||
#include <prnetdb.h>
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
#define PL_RESOLVE_MAXHOSTENTBUF 1024
|
||||
#define PL_RESOLVE_DEFAULT_TIMEOUT 0
|
||||
|
||||
/* Error return codes */
|
||||
#define PL_RESOLVE_OK 0
|
||||
#define PL_RESOLVE_EWINIT 1 /* Failed to initialize window */
|
||||
#define PL_RESOLVE_EMAKE 2 /* Failed to create request */
|
||||
#define PL_RESOLVE_ELAUNCH 3 /* Error launching Async request */
|
||||
#define PL_RESOLVE_ETIMEDOUT 4 /* Request timed-out */
|
||||
#define PL_RESOLVE_EINVAL 5 /* Invalid argument */
|
||||
#define PL_RESOLVE_EOVERFLOW 6 /* Buffer Overflow */
|
||||
#define PL_RESOLVE_EUNKNOWN 7 /* berserk error */
|
||||
|
||||
/* ----------- Function Prototypes ----------------*/
|
||||
|
||||
PR_EXTERN(PRStatus) PL_ResolveName(
|
||||
const char *name, unsigned char *buf,
|
||||
PRIntn bufsize, PRIntervalTime timeout,
|
||||
PRHostEnt *hostentry, PRIntervalTime *ttl);
|
||||
|
||||
PR_EXTERN(PRStatus) PL_ResolveAddr(
|
||||
const PRNetAddr *address, unsigned char *buf,
|
||||
PRIntn bufsize, PRIntervalTime timeout,
|
||||
PRHostEnt *hostentry, PRIntervalTime *ttl);
|
||||
|
||||
typedef struct PLResolveStats {
|
||||
int re_errors;
|
||||
int re_nu_look;
|
||||
int re_na_look;
|
||||
int re_replies;
|
||||
int re_requests;
|
||||
int re_resends;
|
||||
int re_sent;
|
||||
int re_timeouts;
|
||||
} PLResolveStats;
|
||||
|
||||
typedef struct PLResoveInfo {
|
||||
PRBool enabled;
|
||||
PRUint32 numNameLookups;
|
||||
PRUint32 numAddrLookups;
|
||||
PRUint32 numLookupsInProgress;
|
||||
PLResolveStats stats;
|
||||
} PLResoveInfo;
|
||||
|
||||
PR_EXTERN(void) PL_ResolveInfo(PLResoveInfo *info);
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif /* defined(XP_UNIX) */
|
||||
|
||||
#endif /* _PLRESOLV_H_ */
|
||||
@@ -1,470 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Roland Mainz <roland mainz@informatik.med.uni-giessen.de>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _plstr_h
|
||||
#define _plstr_h
|
||||
|
||||
/*
|
||||
* plstr.h
|
||||
*
|
||||
* This header file exports the API to the NSPR portable library or string-
|
||||
* handling functions.
|
||||
*
|
||||
* This API was not designed as an "optimal" or "ideal" string library; it
|
||||
* was based on the good ol' unix string.3 functions, and was written to
|
||||
*
|
||||
* 1) replace the libc functions, for cross-platform consistency,
|
||||
* 2) complete the API on platforms lacking common functions (e.g.,
|
||||
* strcase*), and
|
||||
* 3) to implement some obvious "closure" functions that I've seen
|
||||
* people hacking around in our code.
|
||||
*
|
||||
* Point number three largely means that most functions have an "strn"
|
||||
* limited-length version, and all comparison routines have a non-case-
|
||||
* sensitive version available.
|
||||
*/
|
||||
|
||||
#include "prtypes.h"
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
/*
|
||||
* PL_strlen
|
||||
*
|
||||
* Returns the length of the provided string, not including the trailing '\0'.
|
||||
*/
|
||||
|
||||
PR_EXTERN(PRUint32)
|
||||
PL_strlen(const char *str);
|
||||
|
||||
/*
|
||||
* PL_strnlen
|
||||
*
|
||||
* Returns the length of the provided string, not including the trailing '\0',
|
||||
* up to the indicated maximum. The string will not be examined beyond the
|
||||
* maximum; if no terminating '\0' is found, the maximum will be returned.
|
||||
*/
|
||||
|
||||
PR_EXTERN(PRUint32)
|
||||
PL_strnlen(const char *str, PRUint32 max);
|
||||
|
||||
/*
|
||||
* PL_strcpy
|
||||
*
|
||||
* Copies the source string, up to and including the trailing '\0', into the
|
||||
* destination buffer. It does not (can not) verify that the destination
|
||||
* buffer is large enough. It returns the "dest" argument.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strcpy(char *dest, const char *src);
|
||||
|
||||
/*
|
||||
* PL_strncpy
|
||||
*
|
||||
* Copies the source string into the destination buffer, up to and including
|
||||
* the trailing '\0' or up to and including the max'th character, whichever
|
||||
* comes first. It does not (can not) verify that the destination buffer is
|
||||
* large enough. If the source string is longer than the maximum length,
|
||||
* the result will *not* be null-terminated (JLRU).
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strncpy(char *dest, const char *src, PRUint32 max);
|
||||
|
||||
/*
|
||||
* PL_strncpyz
|
||||
*
|
||||
* Copies the source string into the destination buffer, up to and including
|
||||
* the trailing '\0' or up but not including the max'th character, whichever
|
||||
* comes first. It does not (can not) verify that the destination buffer is
|
||||
* large enough. The destination string is always terminated with a '\0',
|
||||
* unlike the traditional libc implementation. It returns the "dest" argument.
|
||||
*
|
||||
* NOTE: If you call this with a source "abcdefg" and a max of 5, the
|
||||
* destination will end up with "abcd\0" (i.e., its strlen length will be 4)!
|
||||
*
|
||||
* This means you can do this:
|
||||
*
|
||||
* char buffer[ SOME_SIZE ];
|
||||
* PL_strncpyz(buffer, src, sizeof(buffer));
|
||||
*
|
||||
* and the result will be properly terminated.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strncpyz(char *dest, const char *src, PRUint32 max);
|
||||
|
||||
/*
|
||||
* PL_strdup
|
||||
*
|
||||
* Returns a pointer to a malloc'd extent of memory containing a duplicate
|
||||
* of the argument string. The size of the allocated extent is one greater
|
||||
* than the length of the argument string, because of the terminator. A
|
||||
* null argument, like a zero-length argument, will result in a pointer to
|
||||
* a one-byte extent containing the null value. This routine returns null
|
||||
* upon malloc failure.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strdup(const char *s);
|
||||
|
||||
/*
|
||||
* PL_strfree
|
||||
*
|
||||
* Free memory allocated by PL_strdup
|
||||
*/
|
||||
|
||||
PR_EXTERN(void)
|
||||
PL_strfree(char *s);
|
||||
|
||||
/*
|
||||
* PL_strndup
|
||||
*
|
||||
* Returns a pointer to a malloc'd extent of memory containing a duplicate
|
||||
* of the argument string, up to the maximum specified. If the argument
|
||||
* string has a length greater than the value of the specified maximum, the
|
||||
* return value will be a pointer to an extent of memory of length one
|
||||
* greater than the maximum specified. A null string, a zero-length string,
|
||||
* or a zero maximum will all result in a pointer to a one-byte extent
|
||||
* containing the null value. This routine returns null upon malloc failure.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strndup(const char *s, PRUint32 max);
|
||||
|
||||
/*
|
||||
* PL_strcat
|
||||
*
|
||||
* Appends a copy of the string pointed to by the second argument to the
|
||||
* end of the string pointed to by the first. The destination buffer is
|
||||
* not (can not be) checked for sufficient size. A null destination
|
||||
* argument returns null; otherwise, the first argument is returned.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strcat(char *dst, const char *src);
|
||||
|
||||
/*
|
||||
* PL_strncat
|
||||
*
|
||||
* Appends a copy of the string pointed to by the second argument, up to
|
||||
* the maximum size specified, to the end of the string pointed to by the
|
||||
* first. The destination buffer is not (can not be) checked for sufficient
|
||||
* size. A null destination argument returns null; otherwise, the first
|
||||
* argument is returned. If the maximum size limits the copy, then the
|
||||
* result will *not* be null-terminated (JLRU). A null destination
|
||||
* returns null; otherwise, the destination argument is returned.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strncat(char *dst, const char *src, PRUint32 max);
|
||||
|
||||
/*
|
||||
* PL_strcatn
|
||||
*
|
||||
* Appends a copy of the string pointed to by the third argument, to the
|
||||
* end of the string pointed to by the first. The second argument specifies
|
||||
* the maximum size of the destination buffer, including the null termination.
|
||||
* If the existing string in dst is longer than the max, no action is taken.
|
||||
* The resulting string will be null-terminated. A null destination returns
|
||||
* null; otherwise, the destination argument is returned.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strcatn(char *dst, PRUint32 max, const char *src);
|
||||
|
||||
/*
|
||||
* PL_strcmp
|
||||
*
|
||||
* Returns an integer, the sign of which -- positive, zero, or negative --
|
||||
* reflects the lexical sorting order of the two strings indicated. The
|
||||
* result is positive if the first string comes after the second. The
|
||||
* NSPR implementation is not i18n.
|
||||
*/
|
||||
|
||||
PR_EXTERN(PRIntn)
|
||||
PL_strcmp(const char *a, const char *b);
|
||||
|
||||
/*
|
||||
* PL_strncmp
|
||||
*
|
||||
* Returns an integer, the sign of which -- positive, zero, or negative --
|
||||
* reflects the lexical sorting order of the two strings indicated, up to
|
||||
* the maximum specified. The result is positive if the first string comes
|
||||
* after the second. The NSPR implementation is not i18n. If the maximum
|
||||
* is zero, only the existance or non-existance (pointer is null) of the
|
||||
* strings is compared.
|
||||
*/
|
||||
|
||||
PR_EXTERN(PRIntn)
|
||||
PL_strncmp(const char *a, const char *b, PRUint32 max);
|
||||
|
||||
/*
|
||||
* PL_strcasecmp
|
||||
*
|
||||
* Returns an integer, the sign of which -- positive, zero or negative --
|
||||
* reflects the case-insensitive lexical sorting order of the two strings
|
||||
* indicated. The result is positive if the first string comes after the
|
||||
* second. The NSPR implementation is not i18n.
|
||||
*/
|
||||
|
||||
PR_EXTERN(PRIntn)
|
||||
PL_strcasecmp(const char *a, const char *b);
|
||||
|
||||
/*
|
||||
* PL_strncasecmp
|
||||
*
|
||||
* Returns an integer, the sign of which -- positive, zero or negative --
|
||||
* reflects the case-insensitive lexical sorting order of the first n characters
|
||||
* of the two strings indicated. The result is positive if the first string comes
|
||||
* after the second. The NSPR implementation is not i18n.
|
||||
*/
|
||||
|
||||
PR_EXTERN(PRIntn)
|
||||
PL_strncasecmp(const char *a, const char *b, PRUint32 max);
|
||||
|
||||
/*
|
||||
* PL_strchr
|
||||
*
|
||||
* Returns a pointer to the first instance of the specified character in the
|
||||
* provided string. It returns null if the character is not found, or if the
|
||||
* provided string is null. The character may be the null character.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strchr(const char *s, char c);
|
||||
|
||||
/*
|
||||
* PL_strrchr
|
||||
*
|
||||
* Returns a pointer to the last instance of the specified character in the
|
||||
* provided string. It returns null if the character is not found, or if the
|
||||
* provided string is null. The character may be the null character.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strrchr(const char *s, char c);
|
||||
|
||||
/*
|
||||
* PL_strnchr
|
||||
*
|
||||
* Returns a pointer to the first instance of the specified character within the
|
||||
* first n characters of the provided string. It returns null if the character
|
||||
* is not found, or if the provided string is null. The character may be the
|
||||
* null character.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strnchr(const char *s, char c, PRUint32 n);
|
||||
|
||||
/*
|
||||
* PL_strnrchr
|
||||
*
|
||||
* Returns a pointer to the last instance of the specified character within the
|
||||
* first n characters of the provided string. It returns null if the character is
|
||||
* not found, or if the provided string is null. The character may be the null
|
||||
* character.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strnrchr(const char *s, char c, PRUint32 n);
|
||||
|
||||
/*
|
||||
* NOTE: Looking for strcasechr, strcaserchr, strncasechr, or strncaserchr?
|
||||
* Use strpbrk, strprbrk, strnpbrk or strnprbrk.
|
||||
*/
|
||||
|
||||
/*
|
||||
* PL_strpbrk
|
||||
*
|
||||
* Returns a pointer to the first instance in the first string of any character
|
||||
* (not including the terminating null character) of the second string. It returns
|
||||
* null if either string is null.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strpbrk(const char *s, const char *list);
|
||||
|
||||
/*
|
||||
* PL_strprbrk
|
||||
*
|
||||
* Returns a pointer to the last instance in the first string of any character
|
||||
* (not including the terminating null character) of the second string. It returns
|
||||
* null if either string is null.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strprbrk(const char *s, const char *list);
|
||||
|
||||
/*
|
||||
* PL_strnpbrk
|
||||
*
|
||||
* Returns a pointer to the first instance (within the first n characters) of any
|
||||
* character (not including the terminating null character) of the second string.
|
||||
* It returns null if either string is null.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strnpbrk(const char *s, const char *list, PRUint32 n);
|
||||
|
||||
/*
|
||||
* PL_strnprbrk
|
||||
*
|
||||
* Returns a pointer to the last instance (within the first n characters) of any
|
||||
* character (not including the terminating null character) of the second string.
|
||||
* It returns null if either string is null.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strnprbrk(const char *s, const char *list, PRUint32 n);
|
||||
|
||||
/*
|
||||
* PL_strstr
|
||||
*
|
||||
* Returns a pointer to the first instance of the little string within the
|
||||
* big one. It returns null if either string is null.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strstr(const char *big, const char *little);
|
||||
|
||||
/*
|
||||
* PL_strrstr
|
||||
*
|
||||
* Returns a pointer to the last instance of the little string within the big one.
|
||||
* It returns null if either string is null.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strrstr(const char *big, const char *little);
|
||||
|
||||
/*
|
||||
* PL_strnstr
|
||||
*
|
||||
* Returns a pointer to the first instance of the little string within the first
|
||||
* n characters of the big one. It returns null if either string is null. It
|
||||
* returns null if the length of the little string is greater than n.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strnstr(const char *big, const char *little, PRUint32 n);
|
||||
|
||||
/*
|
||||
* PL_strnrstr
|
||||
*
|
||||
* Returns a pointer to the last instance of the little string within the first
|
||||
* n characters of the big one. It returns null if either string is null. It
|
||||
* returns null if the length of the little string is greater than n.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strnrstr(const char *big, const char *little, PRUint32 max);
|
||||
|
||||
/*
|
||||
* PL_strcasestr
|
||||
*
|
||||
* Returns a pointer to the first instance of the little string within the big one,
|
||||
* ignoring case. It returns null if either string is null.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strcasestr(const char *big, const char *little);
|
||||
|
||||
/*
|
||||
* PL_strcaserstr
|
||||
*
|
||||
* Returns a pointer to the last instance of the little string within the big one,
|
||||
* ignoring case. It returns null if either string is null.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strcaserstr(const char *big, const char *little);
|
||||
|
||||
/*
|
||||
* PL_strncasestr
|
||||
*
|
||||
* Returns a pointer to the first instance of the little string within the first
|
||||
* n characters of the big one, ignoring case. It returns null if either string is
|
||||
* null. It returns null if the length of the little string is greater than n.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strncasestr(const char *big, const char *little, PRUint32 max);
|
||||
|
||||
/*
|
||||
* PL_strncaserstr
|
||||
*
|
||||
* Returns a pointer to the last instance of the little string within the first
|
||||
* n characters of the big one, ignoring case. It returns null if either string is
|
||||
* null. It returns null if the length of the little string is greater than n.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strncaserstr(const char *big, const char *little, PRUint32 max);
|
||||
|
||||
/*
|
||||
* PL_strtok_r
|
||||
*
|
||||
* Splits the string s1 into tokens, separated by one or more characters
|
||||
* from the separator string s2. The argument lasts points to a
|
||||
* user-supplied char * pointer in which PL_strtok_r stores information
|
||||
* for it to continue scanning the same string.
|
||||
*
|
||||
* In the first call to PL_strtok_r, s1 points to a string and the value
|
||||
* of *lasts is ignored. PL_strtok_r returns a pointer to the first
|
||||
* token, writes '\0' into the character following the first token, and
|
||||
* updates *lasts.
|
||||
*
|
||||
* In subsequent calls, s1 is null and lasts must stay unchanged from the
|
||||
* previous call. The separator string s2 may be different from call to
|
||||
* call. PL_strtok_r returns a pointer to the next token in s1. When no
|
||||
* token remains in s1, PL_strtok_r returns null.
|
||||
*/
|
||||
|
||||
PR_EXTERN(char *)
|
||||
PL_strtok_r(char *s1, const char *s2, char **lasts);
|
||||
|
||||
/*
|
||||
* Things not (yet?) included: strspn/strcspn, strsep.
|
||||
* memchr, memcmp, memcpy, memccpy, index, rindex, bcmp, bcopy, bzero.
|
||||
* Any and all i18n/l10n stuff.
|
||||
*/
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif /* _plstr_h */
|
||||
@@ -1,197 +0,0 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
|
||||
#! gmake
|
||||
|
||||
MOD_DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(MOD_DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
INCLUDES = -I$(dist_includedir)
|
||||
|
||||
CSRCS =\
|
||||
plvrsion.c \
|
||||
strlen.c \
|
||||
strcpy.c \
|
||||
strdup.c \
|
||||
strcat.c \
|
||||
strcmp.c \
|
||||
strccmp.c \
|
||||
strchr.c \
|
||||
strpbrk.c \
|
||||
strstr.c \
|
||||
strcstr.c \
|
||||
strtok.c \
|
||||
base64.c \
|
||||
plerror.c \
|
||||
plgetopt.c \
|
||||
$(NULL)
|
||||
|
||||
LIBRARY_NAME = plc
|
||||
LIBRARY_VERSION = $(MOD_MAJOR_VERSION)
|
||||
|
||||
RELEASE_LIBS = $(TARGETS)
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
RES=$(OBJDIR)/plc.res
|
||||
RESNAME=plc.rc
|
||||
endif # WINNT
|
||||
|
||||
ifeq ($(OS_ARCH), AIX)
|
||||
ifeq ($(CLASSIC_NSPR),1)
|
||||
OS_LIBS = -lc
|
||||
else
|
||||
OS_LIBS = -lc_r
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),IRIX)
|
||||
OS_LIBS = -lc
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),SunOS)
|
||||
OS_LIBS = -lc
|
||||
MAPFILE = $(OBJDIR)/plcmap.sun
|
||||
GARBAGE += $(MAPFILE)
|
||||
ifdef NS_USE_GCC
|
||||
ifdef GCC_USE_GNU_LD
|
||||
MKSHLIB += -Wl,--version-script,$(MAPFILE)
|
||||
else
|
||||
MKSHLIB += -Wl,-M,$(MAPFILE)
|
||||
endif
|
||||
else
|
||||
MKSHLIB += -M $(MAPFILE)
|
||||
endif
|
||||
# The -R '$ORIGIN' linker option instructs this library to search for its
|
||||
# dependencies in the same directory where it resides.
|
||||
MKSHLIB += -R '$$ORIGIN'
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),OS2)
|
||||
MAPFILE = $(OBJDIR)/$(LIBRARY_NAME)$(LIBRARY_VERSION).def
|
||||
GARBAGE += $(MAPFILE)
|
||||
MKSHLIB += $(MAPFILE)
|
||||
endif
|
||||
|
||||
EXTRA_LIBS = $(LIBNSPR)
|
||||
|
||||
# On NCR and SCOOS, we can't link with extra libraries when
|
||||
# we build a shared library. If we do so, the linker doesn't
|
||||
# complain, but we would run into weird problems at run-time.
|
||||
# Therefore on these platforms, we link just the .o files.
|
||||
ifeq ($(OS_ARCH),NCR)
|
||||
EXTRA_LIBS =
|
||||
endif
|
||||
ifeq ($(OS_ARCH),SCOOS)
|
||||
EXTRA_LIBS =
|
||||
endif
|
||||
|
||||
ifdef RESOLVE_LINK_SYMBOLS
|
||||
EXTRA_LIBS += $(OS_LIBS)
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
#
|
||||
# Version information generation (begin)
|
||||
#
|
||||
ECHO = echo
|
||||
TINC = $(OBJDIR)/_pl_bld.h
|
||||
PROD = $(notdir $(SHARED_LIBRARY))
|
||||
NOW = $(MOD_DEPTH)/config/$(OBJDIR)/now
|
||||
SH_DATE = $(shell date "+%Y-%m-%d %T")
|
||||
SH_NOW = $(shell $(NOW))
|
||||
|
||||
ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT)
|
||||
SUF = i64
|
||||
else
|
||||
SUF = LL
|
||||
endif
|
||||
|
||||
GARBAGE += $(TINC)
|
||||
|
||||
$(TINC):
|
||||
@$(MAKE_OBJDIR)
|
||||
@$(ECHO) '#define _BUILD_STRING "$(SH_DATE)"' > $(TINC)
|
||||
@if test ! -z "$(SH_NOW)"; then \
|
||||
$(ECHO) '#define _BUILD_TIME $(SH_NOW)$(SUF)' >> $(TINC); \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
@$(ECHO) '#define _PRODUCTION "$(PROD)"' >> $(TINC)
|
||||
|
||||
|
||||
$(OBJDIR)/plvrsion.$(OBJ_SUFFIX): plvrsion.c $(TINC)
|
||||
ifeq ($(NS_USE_GCC)_$(OS_ARCH),_WINNT)
|
||||
$(CC) -Fo$@ -c $(CFLAGS) -I$(OBJDIR) $<
|
||||
else
|
||||
ifeq ($(MOZ_OS2_TOOLS), VACPP)
|
||||
$(CC) -Fo$@ -c $(CFLAGS) -I$(OBJDIR) $<
|
||||
else
|
||||
$(CC) -o $@ -c $(CFLAGS) -I$(OBJDIR) $<
|
||||
endif
|
||||
endif
|
||||
#
|
||||
# Version information generation (end)
|
||||
#
|
||||
|
||||
#
|
||||
# The Client build wants the shared libraries in $(dist_bindir),
|
||||
# so we also install them there.
|
||||
#
|
||||
|
||||
export:: $(TARGETS)
|
||||
$(INSTALL) -m 444 $(TARGETS) $(dist_libdir)
|
||||
ifdef SHARED_LIBRARY
|
||||
ifeq ($(OS_ARCH),HP-UX)
|
||||
$(INSTALL) -m 755 $(SHARED_LIBRARY) $(dist_libdir)
|
||||
$(INSTALL) -m 755 $(SHARED_LIBRARY) $(dist_bindir)
|
||||
else
|
||||
$(INSTALL) -m 444 $(SHARED_LIBRARY) $(dist_bindir)
|
||||
endif
|
||||
endif
|
||||
ifeq ($(MOZ_BITS),16)
|
||||
$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/lib
|
||||
$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/bin
|
||||
endif
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
NSPR 2.0 libc functions
|
||||
-----------------------
|
||||
|
||||
Last edited: AOF 04 March 1997
|
||||
|
||||
This directory contains various libc-types of functions. All functions in
|
||||
this directory are platform independent, thread friendly (both safe and
|
||||
efficient). They are contributed from various sources, though the contri-
|
||||
butions are monitored by the NSPR group (mailto:freier).
|
||||
|
||||
All API items exported by these functions will contain the same three
|
||||
character prefix, "PL_" (Portable Library). Internal function names
|
||||
that are not exported (static) are of little concern, though some caution
|
||||
must be used on those elements that are 'extern' but not really intended
|
||||
to be part of the API. Those should all have a prefix of "_PL_" (is that
|
||||
legal?).
|
||||
|
||||
The responsibility for contributions in this area are distributed among
|
||||
all interested parties.
|
||||
|
||||
@@ -1,428 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "plbase64.h"
|
||||
#include "prlog.h" /* For PR_NOT_REACHED */
|
||||
#include "prmem.h" /* for malloc / PR_MALLOC */
|
||||
#include "plstr.h" /* for PL_strlen */
|
||||
|
||||
static unsigned char *base = (unsigned char *)"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
static void
|
||||
encode3to4
|
||||
(
|
||||
const unsigned char *src,
|
||||
unsigned char *dest
|
||||
)
|
||||
{
|
||||
PRUint32 b32 = (PRUint32)0;
|
||||
PRIntn i, j = 18;
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
b32 <<= 8;
|
||||
b32 |= (PRUint32)src[i];
|
||||
}
|
||||
|
||||
for( i = 0; i < 4; i++ )
|
||||
{
|
||||
dest[i] = base[ (PRUint32)((b32>>j) & 0x3F) ];
|
||||
j -= 6;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
encode2to4
|
||||
(
|
||||
const unsigned char *src,
|
||||
unsigned char *dest
|
||||
)
|
||||
{
|
||||
dest[0] = base[ (PRUint32)((src[0]>>2) & 0x3F) ];
|
||||
dest[1] = base[ (PRUint32)(((src[0] & 0x03) << 4) | ((src[1] >> 4) & 0x0F)) ];
|
||||
dest[2] = base[ (PRUint32)((src[1] & 0x0F) << 2) ];
|
||||
dest[3] = (unsigned char)'=';
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
encode1to4
|
||||
(
|
||||
const unsigned char *src,
|
||||
unsigned char *dest
|
||||
)
|
||||
{
|
||||
dest[0] = base[ (PRUint32)((src[0]>>2) & 0x3F) ];
|
||||
dest[1] = base[ (PRUint32)((src[0] & 0x03) << 4) ];
|
||||
dest[2] = (unsigned char)'=';
|
||||
dest[3] = (unsigned char)'=';
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
encode
|
||||
(
|
||||
const unsigned char *src,
|
||||
PRUint32 srclen,
|
||||
unsigned char *dest
|
||||
)
|
||||
{
|
||||
while( srclen >= 3 )
|
||||
{
|
||||
encode3to4(src, dest);
|
||||
src += 3;
|
||||
dest += 4;
|
||||
srclen -= 3;
|
||||
}
|
||||
|
||||
switch( srclen )
|
||||
{
|
||||
case 2:
|
||||
encode2to4(src, dest);
|
||||
break;
|
||||
case 1:
|
||||
encode1to4(src, dest);
|
||||
break;
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
PR_NOT_REACHED("coding error");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* PL_Base64Encode
|
||||
*
|
||||
* If the destination argument is NULL, a return buffer is
|
||||
* allocated, and the data therein will be null-terminated.
|
||||
* If the destination argument is not NULL, it is assumed to
|
||||
* be of sufficient size, and the contents will not be null-
|
||||
* terminated by this routine.
|
||||
*
|
||||
* Returns null if the allocation fails.
|
||||
*/
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_Base64Encode
|
||||
(
|
||||
const char *src,
|
||||
PRUint32 srclen,
|
||||
char *dest
|
||||
)
|
||||
{
|
||||
if( 0 == srclen )
|
||||
{
|
||||
srclen = PL_strlen(src);
|
||||
}
|
||||
|
||||
if( (char *)0 == dest )
|
||||
{
|
||||
PRUint32 destlen = ((srclen + 2)/3) * 4;
|
||||
dest = (char *)PR_MALLOC(destlen + 1);
|
||||
if( (char *)0 == dest )
|
||||
{
|
||||
return (char *)0;
|
||||
}
|
||||
dest[ destlen ] = (char)0; /* null terminate */
|
||||
}
|
||||
|
||||
encode((const unsigned char *)src, srclen, (unsigned char *)dest);
|
||||
return dest;
|
||||
}
|
||||
|
||||
static PRInt32
|
||||
codetovalue
|
||||
(
|
||||
unsigned char c
|
||||
)
|
||||
{
|
||||
if( (c >= (unsigned char)'A') && (c <= (unsigned char)'Z') )
|
||||
{
|
||||
return (PRInt32)(c - (unsigned char)'A');
|
||||
}
|
||||
else if( (c >= (unsigned char)'a') && (c <= (unsigned char)'z') )
|
||||
{
|
||||
return ((PRInt32)(c - (unsigned char)'a') +26);
|
||||
}
|
||||
else if( (c >= (unsigned char)'0') && (c <= (unsigned char)'9') )
|
||||
{
|
||||
return ((PRInt32)(c - (unsigned char)'0') +52);
|
||||
}
|
||||
else if( (unsigned char)'+' == c )
|
||||
{
|
||||
return (PRInt32)62;
|
||||
}
|
||||
else if( (unsigned char)'/' == c )
|
||||
{
|
||||
return (PRInt32)63;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static PRStatus
|
||||
decode4to3
|
||||
(
|
||||
const unsigned char *src,
|
||||
unsigned char *dest
|
||||
)
|
||||
{
|
||||
PRUint32 b32 = (PRUint32)0;
|
||||
PRInt32 bits;
|
||||
PRIntn i;
|
||||
|
||||
for( i = 0; i < 4; i++ )
|
||||
{
|
||||
bits = codetovalue(src[i]);
|
||||
if( bits < 0 )
|
||||
{
|
||||
return PR_FAILURE;
|
||||
}
|
||||
|
||||
b32 <<= 6;
|
||||
b32 |= bits;
|
||||
}
|
||||
|
||||
dest[0] = (unsigned char)((b32 >> 16) & 0xFF);
|
||||
dest[1] = (unsigned char)((b32 >> 8) & 0xFF);
|
||||
dest[2] = (unsigned char)((b32 ) & 0xFF);
|
||||
|
||||
return PR_SUCCESS;
|
||||
}
|
||||
|
||||
static PRStatus
|
||||
decode3to2
|
||||
(
|
||||
const unsigned char *src,
|
||||
unsigned char *dest
|
||||
)
|
||||
{
|
||||
PRUint32 b32 = (PRUint32)0;
|
||||
PRInt32 bits;
|
||||
PRUint32 ubits;
|
||||
|
||||
bits = codetovalue(src[0]);
|
||||
if( bits < 0 )
|
||||
{
|
||||
return PR_FAILURE;
|
||||
}
|
||||
|
||||
b32 = (PRUint32)bits;
|
||||
b32 <<= 6;
|
||||
|
||||
bits = codetovalue(src[1]);
|
||||
if( bits < 0 )
|
||||
{
|
||||
return PR_FAILURE;
|
||||
}
|
||||
|
||||
b32 |= (PRUint32)bits;
|
||||
b32 <<= 4;
|
||||
|
||||
bits = codetovalue(src[2]);
|
||||
if( bits < 0 )
|
||||
{
|
||||
return PR_FAILURE;
|
||||
}
|
||||
|
||||
ubits = (PRUint32)bits;
|
||||
b32 |= (ubits >> 2);
|
||||
|
||||
dest[0] = (unsigned char)((b32 >> 8) & 0xFF);
|
||||
dest[1] = (unsigned char)((b32 ) & 0xFF);
|
||||
|
||||
return PR_SUCCESS;
|
||||
}
|
||||
|
||||
static PRStatus
|
||||
decode2to1
|
||||
(
|
||||
const unsigned char *src,
|
||||
unsigned char *dest
|
||||
)
|
||||
{
|
||||
PRUint32 b32;
|
||||
PRUint32 ubits;
|
||||
PRInt32 bits;
|
||||
|
||||
bits = codetovalue(src[0]);
|
||||
if( bits < 0 )
|
||||
{
|
||||
return PR_FAILURE;
|
||||
}
|
||||
|
||||
ubits = (PRUint32)bits;
|
||||
b32 = (ubits << 2);
|
||||
|
||||
bits = codetovalue(src[1]);
|
||||
if( bits < 0 )
|
||||
{
|
||||
return PR_FAILURE;
|
||||
}
|
||||
|
||||
ubits = (PRUint32)bits;
|
||||
b32 |= (ubits >> 4);
|
||||
|
||||
dest[0] = (unsigned char)b32;
|
||||
|
||||
return PR_SUCCESS;
|
||||
}
|
||||
|
||||
static PRStatus
|
||||
decode
|
||||
(
|
||||
const unsigned char *src,
|
||||
PRUint32 srclen,
|
||||
unsigned char *dest
|
||||
)
|
||||
{
|
||||
PRStatus rv;
|
||||
|
||||
while( srclen >= 4 )
|
||||
{
|
||||
rv = decode4to3(src, dest);
|
||||
if( PR_SUCCESS != rv )
|
||||
{
|
||||
return PR_FAILURE;
|
||||
}
|
||||
|
||||
src += 4;
|
||||
dest += 3;
|
||||
srclen -= 4;
|
||||
}
|
||||
|
||||
switch( srclen )
|
||||
{
|
||||
case 3:
|
||||
rv = decode3to2(src, dest);
|
||||
break;
|
||||
case 2:
|
||||
rv = decode2to1(src, dest);
|
||||
break;
|
||||
case 1:
|
||||
rv = PR_FAILURE;
|
||||
break;
|
||||
case 0:
|
||||
rv = PR_SUCCESS;
|
||||
break;
|
||||
default:
|
||||
PR_NOT_REACHED("coding error");
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*
|
||||
* PL_Base64Decode
|
||||
*
|
||||
* If the destination argument is NULL, a return buffer is
|
||||
* allocated and the data therein will be null-terminated.
|
||||
* If the destination argument is not null, it is assumed
|
||||
* to be of sufficient size, and the data will not be null-
|
||||
* terminated by this routine.
|
||||
*
|
||||
* Returns null if the allocation fails, or if the source string is
|
||||
* not well-formed.
|
||||
*/
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_Base64Decode
|
||||
(
|
||||
const char *src,
|
||||
PRUint32 srclen,
|
||||
char *dest
|
||||
)
|
||||
{
|
||||
PRStatus status;
|
||||
PRBool allocated = PR_FALSE;
|
||||
|
||||
if( (char *)0 == src )
|
||||
{
|
||||
return (char *)0;
|
||||
}
|
||||
|
||||
if( 0 == srclen )
|
||||
{
|
||||
srclen = PL_strlen(src);
|
||||
}
|
||||
|
||||
if( srclen && (0 == (srclen & 3)) )
|
||||
{
|
||||
if( (char)'=' == src[ srclen-1 ] )
|
||||
{
|
||||
if( (char)'=' == src[ srclen-2 ] )
|
||||
{
|
||||
srclen -= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
srclen -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( (char *)0 == dest )
|
||||
{
|
||||
PRUint32 destlen = ((srclen * 3) / 4);
|
||||
dest = (char *)PR_MALLOC(destlen + 1);
|
||||
if( (char *)0 == dest )
|
||||
{
|
||||
return (char *)0;
|
||||
}
|
||||
dest[ destlen ] = (char)0; /* null terminate */
|
||||
allocated = PR_TRUE;
|
||||
}
|
||||
|
||||
status = decode((const unsigned char *)src, srclen, (unsigned char *)dest);
|
||||
if( PR_SUCCESS != status )
|
||||
{
|
||||
if( PR_TRUE == allocated )
|
||||
{
|
||||
PR_DELETE(dest);
|
||||
}
|
||||
|
||||
return (char *)0;
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
;+#
|
||||
;+# ***** BEGIN LICENSE BLOCK *****
|
||||
;+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
;+#
|
||||
;+# The contents of this file are subject to the Mozilla Public License Version
|
||||
;+# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
;+# the License. You may obtain a copy of the License at
|
||||
;+# http://www.mozilla.org/MPL/
|
||||
;+#
|
||||
;+# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
;+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
;+# for the specific language governing rights and limitations under the
|
||||
;+# License.
|
||||
;+#
|
||||
;+# The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
;+#
|
||||
;+# The Initial Developer of the Original Code is
|
||||
;+# Netscape Communications Corporation.
|
||||
;+# Portions created by the Initial Developer are Copyright (C) 2002-2003
|
||||
;+# the Initial Developer. All Rights Reserved.
|
||||
;+#
|
||||
;+# Contributor(s):
|
||||
;+#
|
||||
;+# Alternatively, the contents of this file may be used under the terms of
|
||||
;+# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
;+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
;+# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
;+# of those above. If you wish to allow use of your version of this file only
|
||||
;+# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
;+# use your version of this file under the terms of the MPL, indicate your
|
||||
;+# decision by deleting the provisions above and replace them with the notice
|
||||
;+# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
;+# the provisions above, a recipient may use your version of this file under
|
||||
;+# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
;+#
|
||||
;+# ***** END LICENSE BLOCK *****
|
||||
;+#
|
||||
;+# OK, this file is meant to support SUN, LINUX, AIX, OS/2 and WINDOWS
|
||||
;+# 1. For all unix platforms, the string ";-" means "remove this line"
|
||||
;+# 2. For all unix platforms, the string " DATA " will be removed from any
|
||||
;+# line on which it occurs.
|
||||
;+# 3. Lines containing ";+" will have ";+" removed on SUN and LINUX.
|
||||
;+# On AIX, lines containing ";+" will be removed.
|
||||
;+# 4. For all unix platforms, the string ";;" will thave the ";;" removed.
|
||||
;+# 5. For all unix platforms, after the above processing has taken place,
|
||||
;+# all characters after the first ";" on the line will be removed.
|
||||
;+# And for AIX, the first ";" will also be removed.
|
||||
;+# This file is passed directly to windows. Since ';' is a comment, all UNIX
|
||||
;+# directives are hidden behind ";", ";+", and ";-"
|
||||
;+NSPR_4.0 {
|
||||
;+ global:
|
||||
LIBRARY plc4 ;-
|
||||
EXPORTS ;-
|
||||
PL_Base64Decode;
|
||||
PL_Base64Encode;
|
||||
PL_CreateOptState;
|
||||
PL_DestroyOptState;
|
||||
PL_FPrintError;
|
||||
PL_GetNextOpt;
|
||||
PL_PrintError;
|
||||
PL_strcasecmp;
|
||||
PL_strcaserstr;
|
||||
PL_strcasestr;
|
||||
PL_strcat;
|
||||
PL_strcatn;
|
||||
PL_strchr;
|
||||
PL_strcmp;
|
||||
PL_strcpy;
|
||||
PL_strdup;
|
||||
PL_strfree;
|
||||
PL_strlen;
|
||||
PL_strncasecmp;
|
||||
PL_strncaserstr;
|
||||
PL_strncasestr;
|
||||
PL_strncat;
|
||||
PL_strnchr;
|
||||
PL_strncmp;
|
||||
PL_strncpy;
|
||||
PL_strncpyz;
|
||||
PL_strndup;
|
||||
PL_strnlen;
|
||||
PL_strnpbrk;
|
||||
PL_strnprbrk;
|
||||
PL_strnrchr;
|
||||
PL_strnrstr;
|
||||
PL_strnstr;
|
||||
PL_strpbrk;
|
||||
PL_strprbrk;
|
||||
PL_strrchr;
|
||||
PL_strrstr;
|
||||
PL_strstr;
|
||||
libVersionPoint;
|
||||
;+ local: *;
|
||||
;+};
|
||||
;+
|
||||
;+NSPR_4.2 {
|
||||
;+ global:
|
||||
PL_strtok_r;
|
||||
;+} NSPR_4.0;
|
||||
;+
|
||||
;+NSPR_4.7 {
|
||||
;+ global:
|
||||
PL_CreateLongOptState;
|
||||
;+} NSPR_4.2;
|
||||
@@ -1,102 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
|
||||
#include "prinit.h"
|
||||
#include <winver.h>
|
||||
|
||||
#define MY_LIBNAME "plc"
|
||||
#define MY_FILEDESCRIPTION "PLC Library"
|
||||
|
||||
#define STRINGIZE(x) #x
|
||||
#define STRINGIZE2(x) STRINGIZE(x)
|
||||
#define PR_VMAJOR_STR STRINGIZE2(PR_VMAJOR)
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define MY_DEBUG_STR " (debug)"
|
||||
#define MY_FILEFLAGS_1 VS_FF_DEBUG
|
||||
#else
|
||||
#define MY_DEBUG_STR ""
|
||||
#define MY_FILEFLAGS_1 0x0L
|
||||
#endif
|
||||
#if PR_BETA
|
||||
#define MY_FILEFLAGS_2 MY_FILEFLAGS_1|VS_FF_PRERELEASE
|
||||
#else
|
||||
#define MY_FILEFLAGS_2 MY_FILEFLAGS_1
|
||||
#endif
|
||||
|
||||
#ifdef WINNT
|
||||
#define MY_FILEOS VOS_NT_WINDOWS32
|
||||
#define MY_INTERNAL_NAME "lib" MY_LIBNAME PR_VMAJOR_STR
|
||||
#else
|
||||
#define MY_FILEOS VOS__WINDOWS32
|
||||
#define MY_INTERNAL_NAME MY_LIBNAME PR_VMAJOR_STR
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version-information resource
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION PR_VMAJOR,PR_VMINOR,PR_VPATCH,0
|
||||
PRODUCTVERSION PR_VMAJOR,PR_VMINOR,PR_VPATCH,0
|
||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||
FILEFLAGS MY_FILEFLAGS_2
|
||||
FILEOS MY_FILEOS
|
||||
FILETYPE VFT_DLL
|
||||
FILESUBTYPE 0x0L // not used
|
||||
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904B0" // Lang=US English, CharSet=Unicode
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Mozilla Foundation\0"
|
||||
VALUE "FileDescription", MY_FILEDESCRIPTION MY_DEBUG_STR "\0"
|
||||
VALUE "FileVersion", PR_VERSION "\0"
|
||||
VALUE "InternalName", MY_INTERNAL_NAME "\0"
|
||||
VALUE "OriginalFilename", MY_INTERNAL_NAME ".dll\0"
|
||||
VALUE "ProductName", "Netscape Portable Runtime\0"
|
||||
VALUE "ProductVersion", PR_VERSION "\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
@@ -1,53 +0,0 @@
|
||||
! Fixed section of symbol vector for LIBPLC4
|
||||
!
|
||||
GSMATCH=LEQUAL,2,2
|
||||
case_sensitive=YES
|
||||
!
|
||||
! --------------------------------------------------------------------------
|
||||
! Ident 2,2 introduced for Mozilla 1.3
|
||||
! Previously this was empty. Now we include everything that's specified in
|
||||
! plc.def.
|
||||
! --------------------------------------------------------------------------
|
||||
!
|
||||
! NSPR 4.0
|
||||
SYMBOL_VECTOR=(PL_Base64Decode=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_Base64Encode=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_CreateOptState=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_DestroyOptState=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_FPrintError=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_GetNextOpt=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_PrintError=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strcasecmp=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strcaserstr=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strcasestr=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strcat=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strcatn=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strchr=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strcmp=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strcpy=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strdup=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strfree=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strlen=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strncasecmp=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strncaserstr=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strncasestr=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strncat=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strnchr=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strncmp=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strncpy=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strncpyz=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strndup=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strnlen=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strnpbrk=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strnprbrk=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strnrchr=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strnrstr=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strnstr=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strpbrk=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strprbrk=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strrchr=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strrstr=PROCEDURE)
|
||||
SYMBOL_VECTOR=(PL_strstr=PROCEDURE)
|
||||
SYMBOL_VECTOR=(libVersionPoint=PROCEDURE)
|
||||
! NSPR 4.2
|
||||
SYMBOL_VECTOR=(PL_strtok_r=PROCEDURE)
|
||||
@@ -1,88 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
** File:plerror.c
|
||||
** Description: Simple routine to print translate the calling thread's
|
||||
** error numbers and print them to "syserr".
|
||||
*/
|
||||
|
||||
#include "plerror.h"
|
||||
|
||||
#include "prprf.h"
|
||||
#include "prerror.h"
|
||||
|
||||
PR_IMPLEMENT(void) PL_FPrintError(PRFileDesc *fd, const char *msg)
|
||||
{
|
||||
PRErrorCode error = PR_GetError();
|
||||
PRInt32 oserror = PR_GetOSError();
|
||||
const char *name = PR_ErrorToName(error);
|
||||
|
||||
if (NULL != msg) PR_fprintf(fd, "%s: ", msg);
|
||||
if (NULL == name)
|
||||
PR_fprintf(
|
||||
fd, " (%d)OUT OF RANGE, oserror = %d\n", error, oserror);
|
||||
else
|
||||
PR_fprintf(
|
||||
fd, "%s(%d), oserror = %d\n",
|
||||
name, error, oserror);
|
||||
} /* PL_FPrintError */
|
||||
|
||||
PR_IMPLEMENT(void) PL_PrintError(const char *msg)
|
||||
{
|
||||
static PRFileDesc *fd = NULL;
|
||||
if (NULL == fd) fd = PR_GetSpecialFD(PR_StandardError);
|
||||
PL_FPrintError(fd, msg);
|
||||
} /* PL_PrintError */
|
||||
|
||||
#if defined(WIN16)
|
||||
/*
|
||||
** libmain() is a required function for win16
|
||||
**
|
||||
*/
|
||||
int CALLBACK LibMain( HINSTANCE hInst, WORD wDataSeg,
|
||||
WORD cbHeapSize, LPSTR lpszCmdLine )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* WIN16 */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* plerror.c */
|
||||
@@ -1,254 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
** File: plgetopt.c
|
||||
** Description: utilities to parse argc/argv
|
||||
*/
|
||||
|
||||
#include "prmem.h"
|
||||
#include "prlog.h"
|
||||
#include "prerror.h"
|
||||
#include "plstr.h"
|
||||
#include "plgetopt.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
static char static_Nul = 0;
|
||||
|
||||
struct PLOptionInternal
|
||||
{
|
||||
const char *options; /* client options list specification */
|
||||
PRIntn argc; /* original number of arguments */
|
||||
char **argv; /* vector of pointers to arguments */
|
||||
PRIntn xargc; /* which one we're processing now */
|
||||
const char *xargv; /* where within *argv[xargc] */
|
||||
PRIntn minus; /* do we already have the '-'? */
|
||||
const PLLongOpt *longOpts; /* Caller's array */
|
||||
PRBool endOfOpts; /* have reached a "--" argument */
|
||||
PRIntn optionsLen; /* is strlen(options) */
|
||||
};
|
||||
|
||||
/*
|
||||
** Create the state in which to parse the tokens.
|
||||
**
|
||||
** argc the sum of the number of options and their values
|
||||
** argv the options and their values
|
||||
** options vector of single character options w/ | w/o ':
|
||||
*/
|
||||
PR_IMPLEMENT(PLOptState*) PL_CreateOptState(
|
||||
PRIntn argc, char **argv, const char *options)
|
||||
{
|
||||
return PL_CreateLongOptState( argc, argv, options, NULL);
|
||||
} /* PL_CreateOptState */
|
||||
|
||||
PR_IMPLEMENT(PLOptState*) PL_CreateLongOptState(
|
||||
PRIntn argc, char **argv, const char *options,
|
||||
const PLLongOpt *longOpts)
|
||||
{
|
||||
PLOptState *opt = NULL;
|
||||
PLOptionInternal *internal;
|
||||
|
||||
if (NULL == options)
|
||||
{
|
||||
PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
|
||||
return opt;
|
||||
}
|
||||
|
||||
opt = PR_NEWZAP(PLOptState);
|
||||
if (NULL == opt)
|
||||
{
|
||||
PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
|
||||
return opt;
|
||||
}
|
||||
|
||||
internal = PR_NEW(PLOptionInternal);
|
||||
if (NULL == internal)
|
||||
{
|
||||
PR_DELETE(opt);
|
||||
PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
opt->option = 0;
|
||||
opt->value = NULL;
|
||||
opt->internal = internal;
|
||||
opt->longOption = 0;
|
||||
opt->longOptIndex = -1;
|
||||
|
||||
internal->argc = argc;
|
||||
internal->argv = argv;
|
||||
internal->xargc = 0;
|
||||
internal->xargv = &static_Nul;
|
||||
internal->minus = 0;
|
||||
internal->options = options;
|
||||
internal->longOpts = longOpts;
|
||||
internal->endOfOpts = PR_FALSE;
|
||||
internal->optionsLen = PL_strlen(options);
|
||||
|
||||
return opt;
|
||||
} /* PL_CreateLongOptState */
|
||||
|
||||
/*
|
||||
** Destroy object created by CreateOptState()
|
||||
*/
|
||||
PR_IMPLEMENT(void) PL_DestroyOptState(PLOptState *opt)
|
||||
{
|
||||
PR_DELETE(opt->internal);
|
||||
PR_DELETE(opt);
|
||||
} /* PL_DestroyOptState */
|
||||
|
||||
PR_IMPLEMENT(PLOptStatus) PL_GetNextOpt(PLOptState *opt)
|
||||
{
|
||||
PLOptionInternal *internal = opt->internal;
|
||||
|
||||
opt->longOption = 0;
|
||||
opt->longOptIndex = -1;
|
||||
/*
|
||||
** If the current xarg points to nul, advance to the next
|
||||
** element of the argv vector. If the vector index is equal
|
||||
** to argc, we're out of arguments, so return an EOL.
|
||||
** Note whether the first character of the new argument is
|
||||
** a '-' and skip by it if it is.
|
||||
*/
|
||||
while (0 == *internal->xargv)
|
||||
{
|
||||
internal->xargc += 1;
|
||||
if (internal->xargc >= internal->argc)
|
||||
{
|
||||
opt->option = 0;
|
||||
opt->value = NULL;
|
||||
return PL_OPT_EOL;
|
||||
}
|
||||
internal->xargv = internal->argv[internal->xargc];
|
||||
internal->minus = 0;
|
||||
if (!internal->endOfOpts && ('-' == *internal->xargv))
|
||||
{
|
||||
internal->minus++;
|
||||
internal->xargv++; /* and consume */
|
||||
if ('-' == *internal->xargv && internal->longOpts)
|
||||
{
|
||||
internal->minus++;
|
||||
internal->xargv++;
|
||||
if (0 == *internal->xargv)
|
||||
{
|
||||
internal->endOfOpts = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** If we already have a '-' or '--' in hand, xargv points to the next
|
||||
** option. See if we can find a match in the list of possible
|
||||
** options supplied.
|
||||
*/
|
||||
|
||||
if (internal->minus == 2)
|
||||
{
|
||||
char * foundEqual = strchr(internal->xargv,'=');
|
||||
PRIntn optNameLen = foundEqual ? (foundEqual - internal->xargv) :
|
||||
strlen(internal->xargv);
|
||||
const PLLongOpt *longOpt = internal->longOpts;
|
||||
|
||||
opt->option = 0;
|
||||
opt->value = NULL;
|
||||
|
||||
for (; longOpt->longOptName; ++longOpt)
|
||||
{
|
||||
if (strncmp(longOpt->longOptName, internal->xargv, optNameLen))
|
||||
continue; /* not a possible match */
|
||||
if (strlen(longOpt->longOptName) != optNameLen)
|
||||
continue; /* not a match */
|
||||
/* option name match */
|
||||
opt->longOptIndex = longOpt - internal->longOpts;
|
||||
opt->longOption = longOpt->longOption;
|
||||
if (foundEqual)
|
||||
{
|
||||
opt->value = foundEqual[1] ? foundEqual + 1 : NULL;
|
||||
}
|
||||
else if (longOpt->valueRequired)
|
||||
{
|
||||
opt->value = internal->argv[++(internal->xargc)];
|
||||
}
|
||||
internal->xargv = &static_Nul; /* consume this */
|
||||
return PL_OPT_OK;
|
||||
}
|
||||
internal->xargv = &static_Nul; /* consume this */
|
||||
return PL_OPT_BAD;
|
||||
}
|
||||
if (internal->minus)
|
||||
{
|
||||
PRIntn cop;
|
||||
PRIntn eoo = internal->optionsLen;
|
||||
for (cop = 0; cop < eoo; ++cop)
|
||||
{
|
||||
if (internal->options[cop] == *internal->xargv)
|
||||
{
|
||||
opt->option = *internal->xargv++;
|
||||
opt->longOption = opt->option & 0xff;
|
||||
/*
|
||||
** if options indicates that there's an associated
|
||||
** value, this argv is finished and the next is the
|
||||
** option's value.
|
||||
*/
|
||||
if (':' == internal->options[cop + 1])
|
||||
{
|
||||
if (0 != *internal->xargv)
|
||||
return PL_OPT_BAD;
|
||||
opt->value = internal->argv[++(internal->xargc)];
|
||||
internal->xargv = &static_Nul;
|
||||
internal->minus = 0;
|
||||
}
|
||||
else
|
||||
opt->value = NULL;
|
||||
return PL_OPT_OK;
|
||||
}
|
||||
}
|
||||
internal->xargv += 1; /* consume that option */
|
||||
return PL_OPT_BAD;
|
||||
}
|
||||
/*
|
||||
** No '-', so it must be a standalone value. The option is nul.
|
||||
*/
|
||||
opt->value = internal->argv[internal->xargc];
|
||||
internal->xargv = &static_Nul;
|
||||
opt->option = 0;
|
||||
return PL_OPT_OK;
|
||||
} /* PL_GetNextOpt */
|
||||
|
||||
/* plgetopt.c */
|
||||
@@ -1,125 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "prinit.h"
|
||||
#include "prvrsion.h"
|
||||
|
||||
/************************************************************************/
|
||||
/**************************IDENTITY AND VERSIONING***********************/
|
||||
/************************************************************************/
|
||||
#include "_pl_bld.h"
|
||||
#if !defined(_BUILD_TIME)
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#define _BUILD_TIME 0
|
||||
#else
|
||||
#define _BUILD_TIME {0, 0}
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(_BUILD_STRING)
|
||||
#define _BUILD_STRING ""
|
||||
#endif
|
||||
#if !defined(_PRODUCTION)
|
||||
#define _PRODUCTION ""
|
||||
#endif
|
||||
#if defined(DEBUG)
|
||||
#define _DEBUG_STRING " (debug)"
|
||||
#else
|
||||
#define _DEBUG_STRING ""
|
||||
#endif
|
||||
|
||||
/*
|
||||
* A trick to expand the PR_VMAJOR macro before concatenation.
|
||||
*/
|
||||
#define CONCAT(x, y) x ## y
|
||||
#define CONCAT2(x, y) CONCAT(x, y)
|
||||
#define VERSION_DESC_NAME CONCAT2(prVersionDescription_libplc, PR_VMAJOR)
|
||||
|
||||
PRVersionDescription VERSION_DESC_NAME =
|
||||
{
|
||||
/* version */ 2, /* this is the only one supported */
|
||||
/* buildTime */ _BUILD_TIME, /* usecs since midnight 1/1/1970 GMT */
|
||||
/* buildTimeString */ _BUILD_STRING, /* ditto, but human readable */
|
||||
/* vMajor */ PR_VMAJOR, /* NSPR's version number */
|
||||
/* vMinor */ PR_VMINOR, /* and minor version */
|
||||
/* vPatch */ PR_VPATCH, /* and patch */
|
||||
/* beta */ PR_BETA, /* beta build boolean */
|
||||
#if defined(DEBUG)
|
||||
/* debug */ PR_TRUE, /* a debug build */
|
||||
#else
|
||||
/* debug */ PR_FALSE, /* an optomized build */
|
||||
#endif
|
||||
/* special */ PR_FALSE, /* they're all special, but ... */
|
||||
/* filename */ _PRODUCTION, /* the produced library name */
|
||||
/* description */ "Portable runtime", /* what we are */
|
||||
/* security */ "N/A", /* not applicable here */
|
||||
/* copywrite */ "Copyright (c) 1998 Netscape Communications Corporation. All Rights Reserved",
|
||||
/* comment */ "http://www.mozilla.org/MPL/",
|
||||
/* specialString */ ""
|
||||
};
|
||||
|
||||
#ifdef XP_UNIX
|
||||
|
||||
/*
|
||||
* Version information for the 'ident' and 'what commands
|
||||
*
|
||||
* NOTE: the first component of the concatenated rcsid string
|
||||
* must not end in a '$' to prevent rcs keyword substitution.
|
||||
*/
|
||||
static char rcsid[] = "$Header: NSPR " PR_VERSION _DEBUG_STRING
|
||||
" " _BUILD_STRING " $";
|
||||
static char sccsid[] = "@(#)NSPR " PR_VERSION _DEBUG_STRING
|
||||
" " _BUILD_STRING;
|
||||
|
||||
#endif /* XP_UNIX */
|
||||
|
||||
PR_IMPLEMENT(const PRVersionDescription*) libVersionPoint()
|
||||
{
|
||||
#ifdef XP_UNIX
|
||||
/*
|
||||
* Add dummy references to rcsid and sccsid to prevent them
|
||||
* from being optimized away as unused variables.
|
||||
*/
|
||||
const char *dummy;
|
||||
|
||||
dummy = rcsid;
|
||||
dummy = sccsid;
|
||||
#endif
|
||||
return &VERSION_DESC_NAME;
|
||||
} /* versionEntryPointType */
|
||||
|
||||
/* plvrsion.c */
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "plstr.h"
|
||||
#include <string.h>
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strcat(char *dest, const char *src)
|
||||
{
|
||||
if( ((char *)0 == dest) || ((const char *)0 == src) )
|
||||
return dest;
|
||||
|
||||
return strcat(dest, src);
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strncat(char *dest, const char *src, PRUint32 max)
|
||||
{
|
||||
char *rv;
|
||||
|
||||
if( ((char *)0 == dest) || ((const char *)0 == src) || (0 == max) )
|
||||
return dest;
|
||||
|
||||
for( rv = dest; *dest; dest++ )
|
||||
;
|
||||
|
||||
(void)PL_strncpy(dest, src, max);
|
||||
return rv;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strcatn(char *dest, PRUint32 max, const char *src)
|
||||
{
|
||||
char *rv;
|
||||
PRUint32 dl;
|
||||
|
||||
if( ((char *)0 == dest) || ((const char *)0 == src) )
|
||||
return dest;
|
||||
|
||||
for( rv = dest, dl = 0; *dest; dest++, dl++ )
|
||||
;
|
||||
|
||||
if( max <= dl ) return rv;
|
||||
(void)PL_strncpyz(dest, src, max-dl);
|
||||
|
||||
return rv;
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "plstr.h"
|
||||
|
||||
static const unsigned char uc[] =
|
||||
{
|
||||
'\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
|
||||
'\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
|
||||
'\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
|
||||
'\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
|
||||
' ', '!', '"', '#', '$', '%', '&', '\'',
|
||||
'(', ')', '*', '+', ',', '-', '.', '/',
|
||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', ':', ';', '<', '=', '>', '?',
|
||||
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
||||
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
||||
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
||||
'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
|
||||
'`', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
||||
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
||||
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
||||
'X', 'Y', 'Z', '{', '|', '}', '~', '\177',
|
||||
0200, 0201, 0202, 0203, 0204, 0205, 0206, 0207,
|
||||
0210, 0211, 0212, 0213, 0214, 0215, 0216, 0217,
|
||||
0220, 0221, 0222, 0223, 0224, 0225, 0226, 0227,
|
||||
0230, 0231, 0232, 0233, 0234, 0235, 0236, 0237,
|
||||
0240, 0241, 0242, 0243, 0244, 0245, 0246, 0247,
|
||||
0250, 0251, 0252, 0253, 0254, 0255, 0256, 0257,
|
||||
0260, 0261, 0262, 0263, 0264, 0265, 0266, 0267,
|
||||
0270, 0271, 0272, 0273, 0274, 0275, 0276, 0277,
|
||||
0300, 0301, 0302, 0303, 0304, 0305, 0306, 0307,
|
||||
0310, 0311, 0312, 0313, 0314, 0315, 0316, 0317,
|
||||
0320, 0321, 0322, 0323, 0324, 0325, 0326, 0327,
|
||||
0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337,
|
||||
0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347,
|
||||
0350, 0351, 0352, 0353, 0354, 0355, 0356, 0357,
|
||||
0360, 0361, 0362, 0363, 0364, 0365, 0366, 0367,
|
||||
0370, 0371, 0372, 0373, 0374, 0375, 0376, 0377
|
||||
};
|
||||
|
||||
PR_IMPLEMENT(PRIntn)
|
||||
PL_strcasecmp(const char *a, const char *b)
|
||||
{
|
||||
const unsigned char *ua = (const unsigned char *)a;
|
||||
const unsigned char *ub = (const unsigned char *)b;
|
||||
|
||||
if( ((const char *)0 == a) || (const char *)0 == b )
|
||||
return (PRIntn)(a-b);
|
||||
|
||||
while( (uc[*ua] == uc[*ub]) && ('\0' != *a) )
|
||||
{
|
||||
a++;
|
||||
ua++;
|
||||
ub++;
|
||||
}
|
||||
|
||||
return (PRIntn)(uc[*ua] - uc[*ub]);
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(PRIntn)
|
||||
PL_strncasecmp(const char *a, const char *b, PRUint32 max)
|
||||
{
|
||||
const unsigned char *ua = (const unsigned char *)a;
|
||||
const unsigned char *ub = (const unsigned char *)b;
|
||||
|
||||
if( ((const char *)0 == a) || (const char *)0 == b )
|
||||
return (PRIntn)(a-b);
|
||||
|
||||
while( max && (uc[*ua] == uc[*ub]) && ('\0' != *a) )
|
||||
{
|
||||
a++;
|
||||
ua++;
|
||||
ub++;
|
||||
max--;
|
||||
}
|
||||
|
||||
if( 0 == max ) return (PRIntn)0;
|
||||
|
||||
return (PRIntn)(uc[*ua] - uc[*ub]);
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "plstr.h"
|
||||
#include <string.h>
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strchr(const char *s, char c)
|
||||
{
|
||||
if( (const char *)0 == s ) return (char *)0;
|
||||
|
||||
return strchr(s, c);
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strrchr(const char *s, char c)
|
||||
{
|
||||
if( (const char *)0 == s ) return (char *)0;
|
||||
|
||||
return strrchr(s, c);
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strnchr(const char *s, char c, PRUint32 n)
|
||||
{
|
||||
if( (const char *)0 == s ) return (char *)0;
|
||||
|
||||
for( ; n && *s; s++, n-- )
|
||||
if( *s == c )
|
||||
return (char *)s;
|
||||
|
||||
if( ((char)0 == c) && (n > 0) && ((char)0 == *s) ) return (char *)s;
|
||||
|
||||
return (char *)0;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strnrchr(const char *s, char c, PRUint32 n)
|
||||
{
|
||||
const char *p;
|
||||
|
||||
if( (const char *)0 == s ) return (char *)0;
|
||||
|
||||
for( p = s; n && *p; p++, n-- )
|
||||
;
|
||||
|
||||
if( ((char)0 == c) && (n > 0) && ((char)0 == *p) ) return (char *)p;
|
||||
|
||||
for( p--; p >= s; p-- )
|
||||
if( *p == c )
|
||||
return (char *)p;
|
||||
|
||||
return (char *)0;
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "plstr.h"
|
||||
#include <string.h>
|
||||
|
||||
PR_IMPLEMENT(PRIntn)
|
||||
PL_strcmp(const char *a, const char *b)
|
||||
{
|
||||
if( ((const char *)0 == a) || (const char *)0 == b )
|
||||
return (PRIntn)(a-b);
|
||||
|
||||
return (PRIntn)strcmp(a, b);
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(PRIntn)
|
||||
PL_strncmp(const char *a, const char *b, PRUint32 max)
|
||||
{
|
||||
if( ((const char *)0 == a) || (const char *)0 == b )
|
||||
return (PRIntn)(a-b);
|
||||
|
||||
return (PRIntn)strncmp(a, b, (size_t)max);
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "plstr.h"
|
||||
#include <string.h>
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strcpy(char *dest, const char *src)
|
||||
{
|
||||
if( ((char *)0 == dest) || ((const char *)0 == src) ) return (char *)0;
|
||||
|
||||
return strcpy(dest, src);
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strncpy(char *dest, const char *src, PRUint32 max)
|
||||
{
|
||||
char *rv;
|
||||
|
||||
if( (char *)0 == dest ) return (char *)0;
|
||||
if( (const char *)0 == src ) return (char *)0;
|
||||
|
||||
for( rv = dest; max && ((*dest = *src) != 0); dest++, src++, max-- )
|
||||
;
|
||||
|
||||
#ifdef JLRU
|
||||
/* XXX I (wtc) think the -- and ++ operators should be postfix. */
|
||||
while( --max )
|
||||
*++dest = '\0';
|
||||
#endif /* JLRU */
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strncpyz(char *dest, const char *src, PRUint32 max)
|
||||
{
|
||||
char *rv;
|
||||
|
||||
if( (char *)0 == dest ) return (char *)0;
|
||||
if( (const char *)0 == src ) return (char *)0;
|
||||
if( 0 == max ) return (char *)0;
|
||||
|
||||
for( rv = dest, max--; max && ((*dest = *src) != 0); dest++, src++, max-- )
|
||||
;
|
||||
|
||||
*dest = '\0';
|
||||
|
||||
return rv;
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "plstr.h"
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strcasestr(const char *big, const char *little)
|
||||
{
|
||||
PRUint32 ll;
|
||||
|
||||
if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0;
|
||||
if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0;
|
||||
|
||||
ll = PL_strlen(little);
|
||||
|
||||
for( ; *big; big++ )
|
||||
/* obvious improvement available here */
|
||||
if( 0 == PL_strncasecmp(big, little, ll) )
|
||||
return (char *)big;
|
||||
|
||||
return (char *)0;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strcaserstr(const char *big, const char *little)
|
||||
{
|
||||
const char *p;
|
||||
PRUint32 bl, ll;
|
||||
|
||||
if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0;
|
||||
if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0;
|
||||
|
||||
bl = PL_strlen(big);
|
||||
ll = PL_strlen(little);
|
||||
if( bl < ll ) return (char *)0;
|
||||
p = &big[ bl - ll ];
|
||||
|
||||
for( ; p >= big; p-- )
|
||||
/* obvious improvement available here */
|
||||
if( 0 == PL_strncasecmp(p, little, ll) )
|
||||
return (char *)p;
|
||||
|
||||
return (char *)0;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strncasestr(const char *big, const char *little, PRUint32 max)
|
||||
{
|
||||
PRUint32 ll;
|
||||
|
||||
if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0;
|
||||
if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0;
|
||||
|
||||
ll = PL_strlen(little);
|
||||
if( ll > max ) return (char *)0;
|
||||
max -= ll;
|
||||
max++;
|
||||
|
||||
for( ; max && *big; big++, max-- )
|
||||
/* obvious improvement available here */
|
||||
if( 0 == PL_strncasecmp(big, little, ll) )
|
||||
return (char *)big;
|
||||
|
||||
return (char *)0;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strncaserstr(const char *big, const char *little, PRUint32 max)
|
||||
{
|
||||
const char *p;
|
||||
PRUint32 ll;
|
||||
|
||||
if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0;
|
||||
if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0;
|
||||
|
||||
ll = PL_strlen(little);
|
||||
|
||||
for( p = big; max && *p; p++, max-- )
|
||||
;
|
||||
|
||||
p -= ll;
|
||||
if( p < big ) return (char *)0;
|
||||
|
||||
for( ; p >= big; p-- )
|
||||
/* obvious improvement available here */
|
||||
if( 0 == PL_strncasecmp(p, little, ll) )
|
||||
return (char *)p;
|
||||
|
||||
return (char *)0;
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "plstr.h"
|
||||
#include "prmem.h"
|
||||
#include <string.h>
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strdup(const char *s)
|
||||
{
|
||||
char *rv;
|
||||
size_t n;
|
||||
|
||||
if( (const char *)0 == s )
|
||||
s = "";
|
||||
|
||||
n = strlen(s) + 1;
|
||||
|
||||
rv = (char *)malloc(n);
|
||||
if( (char *)0 == rv ) return rv;
|
||||
|
||||
(void)memcpy(rv, s, n);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void)
|
||||
PL_strfree(char *s)
|
||||
{
|
||||
free(s);
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strndup(const char *s, PRUint32 max)
|
||||
{
|
||||
char *rv;
|
||||
size_t l;
|
||||
|
||||
if( (const char *)0 == s )
|
||||
s = "";
|
||||
|
||||
l = PL_strnlen(s, max);
|
||||
|
||||
rv = (char *)malloc(l+1);
|
||||
if( (char *)0 == rv ) return rv;
|
||||
|
||||
(void)memcpy(rv, s, l);
|
||||
rv[l] = '\0';
|
||||
|
||||
return rv;
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "plstr.h"
|
||||
#include "prtypes.h"
|
||||
#include "prlog.h"
|
||||
#include <string.h>
|
||||
|
||||
PR_IMPLEMENT(PRUint32)
|
||||
PL_strlen(const char *str)
|
||||
{
|
||||
size_t l;
|
||||
|
||||
if( (const char *)0 == str ) return 0;
|
||||
|
||||
l = strlen(str);
|
||||
|
||||
/* error checking in case we have a 64-bit platform -- make sure
|
||||
* we don't have ultra long strings that overflow an int32
|
||||
*/
|
||||
if( sizeof(PRUint32) < sizeof(size_t) )
|
||||
PR_ASSERT(l < 2147483647);
|
||||
|
||||
return (PRUint32)l;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(PRUint32)
|
||||
PL_strnlen(const char *str, PRUint32 max)
|
||||
{
|
||||
register const char *s;
|
||||
|
||||
if( (const char *)0 == str ) return 0;
|
||||
for( s = str; max && *s; s++, max-- )
|
||||
;
|
||||
|
||||
return (PRUint32)(s - str);
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Netscape Portable Runtime (NSPR).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998-2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "plstr.h"
|
||||
#include <string.h>
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strpbrk(const char *s, const char *list)
|
||||
{
|
||||
if( ((const char *)0 == s) || ((const char *)0 == list) ) return (char *)0;
|
||||
|
||||
return strpbrk(s, list);
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strprbrk(const char *s, const char *list)
|
||||
{
|
||||
const char *p;
|
||||
const char *r;
|
||||
|
||||
if( ((const char *)0 == s) || ((const char *)0 == list) ) return (char *)0;
|
||||
|
||||
for( r = s; *r; r++ )
|
||||
;
|
||||
|
||||
for( r--; r >= s; r-- )
|
||||
for( p = list; *p; p++ )
|
||||
if( *r == *p )
|
||||
return (char *)r;
|
||||
|
||||
return (char *)0;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strnpbrk(const char *s, const char *list, PRUint32 max)
|
||||
{
|
||||
const char *p;
|
||||
|
||||
if( ((const char *)0 == s) || ((const char *)0 == list) ) return (char *)0;
|
||||
|
||||
for( ; max && *s; s++, max-- )
|
||||
for( p = list; *p; p++ )
|
||||
if( *s == *p )
|
||||
return (char *)s;
|
||||
|
||||
return (char *)0;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(char *)
|
||||
PL_strnprbrk(const char *s, const char *list, PRUint32 max)
|
||||
{
|
||||
const char *p;
|
||||
const char *r;
|
||||
|
||||
if( ((const char *)0 == s) || ((const char *)0 == list) ) return (char *)0;
|
||||
|
||||
for( r = s; max && *r; r++, max-- )
|
||||
;
|
||||
|
||||
for( r--; r >= s; r-- )
|
||||
for( p = list; *p; p++ )
|
||||
if( *r == *p )
|
||||
return (char *)r;
|
||||
|
||||
return (char *)0;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user