add js to tree

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3693 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Brian West
2006-12-18 15:53:47 +00:00
parent 855c7b9a77
commit fff98f6316
1137 changed files with 386873 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
Makefile
_pl_bld.h

View File

@@ -0,0 +1,22 @@
/.cvsignore/1.3/Mon May 14 22:11:59 2001//
/Makefile.in/1.31/Wed Jun 1 14:28:26 2005//
/README/3.1/Sat Mar 28 03:36:50 1998//
/base64.c/3.7/Sun Apr 25 15:00:36 2004//
/plc.def/1.6/Tue Mar 8 03:01:04 2005//
/plc.rc/3.6/Sun Apr 25 15:00:36 2004//
/plc_symvec.opt/1.2/Wed Jan 15 00:00:14 2003//
/plerror.c/3.7/Sun Apr 25 15:00:36 2004//
/plgetopt.c/3.6/Sun Apr 25 15:00:36 2004//
/plvrsion.c/3.14/Sun Apr 25 15:00:36 2004//
/strcat.c/3.7/Sun May 2 06:07:59 2004//
/strccmp.c/3.7/Sun Apr 25 15:00:36 2004//
/strchr.c/3.7/Sun Apr 25 15:00:36 2004//
/strcmp.c/3.6/Sun Apr 25 15:00:36 2004//
/strcpy.c/3.8/Sun May 2 06:07:59 2004//
/strcstr.c/3.6/Sun Apr 25 15:00:36 2004//
/strdup.c/3.7/Sun May 2 06:07:59 2004//
/strlen.c/3.7/Sun Apr 25 15:00:36 2004//
/strpbrk.c/3.7/Sun Apr 25 15:00:36 2004//
/strstr.c/3.9/Sun May 2 06:07:59 2004//
/strtok.c/1.2/Sun Apr 25 15:00:36 2004//
D

View File

@@ -0,0 +1 @@
mozilla/nsprpub/lib/libc/src

View File

@@ -0,0 +1 @@
:pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot

View File

@@ -0,0 +1,202 @@
#
# ***** 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)
ifdef NS_USE_GCC
DLLBASE=-Wl,--image-base -Wl,0x30000000
else
DLLBASE=-BASE:0x30000000
endif
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

View File

@@ -0,0 +1,20 @@
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.

View File

@@ -0,0 +1,428 @@
/* -*- 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;
}

View File

@@ -0,0 +1,99 @@
;+#
;+# ***** 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;

View File

@@ -0,0 +1,103 @@
/* -*- 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", "Netscape Communications Corporation\0"
VALUE "FileDescription", MY_FILEDESCRIPTION MY_DEBUG_STR "\0"
VALUE "FileVersion", PR_VERSION "\0"
VALUE "InternalName", MY_INTERNAL_NAME "\0"
VALUE "LegalCopyright", "Copyright \251 1996-2000 Netscape Communications Corporation\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

View File

@@ -0,0 +1,53 @@
! 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)

View File

@@ -0,0 +1,168 @@
/* -*- 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)
{
static const char *tags[] =
{
"PR_OUT_OF_MEMORY_ERROR",
"PR_BAD_DESCRIPTOR_ERROR",
"PR_WOULD_BLOCK_ERROR",
"PR_ACCESS_FAULT_ERROR",
"PR_INVALID_METHOD_ERROR",
"PR_ILLEGAL_ACCESS_ERROR",
"PR_UNKNOWN_ERROR",
"PR_PENDING_INTERRUPT_ERROR",
"PR_NOT_IMPLEMENTED_ERROR",
"PR_IO_ERROR",
"PR_IO_TIMEOUT_ERROR",
"PR_IO_PENDING_ERROR",
"PR_DIRECTORY_OPEN_ERROR",
"PR_INVALID_ARGUMENT_ERROR",
"PR_ADDRESS_NOT_AVAILABLE_ERROR",
"PR_ADDRESS_NOT_SUPPORTED_ERROR",
"PR_IS_CONNECTED_ERROR",
"PR_BAD_ADDRESS_ERROR",
"PR_ADDRESS_IN_USE_ERROR",
"PR_CONNECT_REFUSED_ERROR",
"PR_NETWORK_UNREACHABLE_ERROR",
"PR_CONNECT_TIMEOUT_ERROR",
"PR_NOT_CONNECTED_ERROR",
"PR_LOAD_LIBRARY_ERROR",
"PR_UNLOAD_LIBRARY_ERROR",
"PR_FIND_SYMBOL_ERROR",
"PR_INSUFFICIENT_RESOURCES_ERROR",
"PR_DIRECTORY_LOOKUP_ERROR",
"PR_TPD_RANGE_ERROR",
"PR_PROC_DESC_TABLE_FULL_ERROR",
"PR_SYS_DESC_TABLE_FULL_ERROR",
"PR_NOT_SOCKET_ERROR",
"PR_NOT_TCP_SOCKET_ERROR",
"PR_SOCKET_ADDRESS_IS_BOUND_ERROR",
"PR_NO_ACCESS_RIGHTS_ERROR",
"PR_OPERATION_NOT_SUPPORTED_ERROR",
"PR_PROTOCOL_NOT_SUPPORTED_ERROR",
"PR_REMOTE_FILE_ERROR",
"PR_BUFFER_OVERFLOW_ERROR",
"PR_CONNECT_RESET_ERROR",
"PR_RANGE_ERROR",
"PR_DEADLOCK_ERROR",
"PR_FILE_IS_LOCKED_ERROR",
"PR_FILE_TOO_BIG_ERROR",
"PR_NO_DEVICE_SPACE_ERROR",
"PR_PIPE_ERROR",
"PR_NO_SEEK_DEVICE_ERROR",
"PR_IS_DIRECTORY_ERROR",
"PR_LOOP_ERROR",
"PR_NAME_TOO_LONG_ERROR",
"PR_FILE_NOT_FOUND_ERROR",
"PR_NOT_DIRECTORY_ERROR",
"PR_READ_ONLY_FILESYSTEM_ERROR",
"PR_DIRECTORY_NOT_EMPTY_ERROR",
"PR_FILESYSTEM_MOUNTED_ERROR",
"PR_NOT_SAME_DEVICE_ERROR",
"PR_DIRECTORY_CORRUPTED_ERROR",
"PR_FILE_EXISTS_ERROR",
"PR_MAX_DIRECTORY_ENTRIES_ERROR",
"PR_INVALID_DEVICE_STATE_ERROR",
"PR_DEVICE_IS_LOCKED_ERROR",
"PR_NO_MORE_FILES_ERROR",
"PR_END_OF_FILE_ERROR",
"PR_FILE_SEEK_ERROR",
"PR_FILE_IS_BUSY_ERROR",
"<unused error code>",
"PR_IN_PROGRESS_ERROR",
"PR_ALREADY_INITIATED_ERROR",
"PR_GROUP_EMPTY_ERROR",
"PR_INVALID_STATE_ERROR",
"PR_NETWORK_DOWN_ERROR",
"PR_SOCKET_SHUTDOWN_ERROR",
"PR_CONNECT_ABORTED_ERROR",
"PR_HOST_UNREACHABLE_ERROR",
"PR_MAX_ERROR"
};
PRErrorCode error = PR_GetError();
PRInt32 oserror = PR_GetOSError();
PRIntn thoseIKnowAbout = sizeof(tags) / sizeof(char*);
PRIntn lastError = PR_NSPR_ERROR_BASE + thoseIKnowAbout;
if (NULL != msg) PR_fprintf(fd, "%s: ", msg);
if ((error < PR_NSPR_ERROR_BASE) || (error > lastError))
PR_fprintf(
fd, " (%d)OUT OF RANGE, oserror = %d\n", error, oserror);
else
PR_fprintf(
fd, "%s(%d), oserror = %d\n",
tags[error - PR_NSPR_ERROR_BASE], 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 */

View File

@@ -0,0 +1,184 @@
/* -*- 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] */
PRBool minus; /* do we already have the '-'? */
};
/*
** 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)
{
PLOptState *opt = NULL;
if (NULL == options)
PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
else
{
opt = PR_NEWZAP(PLOptState);
if (NULL == opt)
PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
else
{
PLOptionInternal *internal = PR_NEW(PLOptionInternal);
if (NULL == internal)
{
PR_DELETE(opt);
PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
}
else
{
opt->option = 0;
opt->value = NULL;
opt->internal = internal;
internal->argc = argc;
internal->argv = argv;
internal->xargc = 0;
internal->xargv = &static_Nul;
internal->minus = PR_FALSE;
internal->options = options;
}
}
}
return opt;
} /* PL_CreateOptState */
/*
** 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;
PRIntn cop, eoo = PL_strlen(internal->options);
/*
** 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 = ('-' == *internal->xargv ? PR_TRUE : PR_FALSE); /* not it */
if (internal->minus) internal->xargv += 1; /* and consume */
}
/*
** If we already have a '-' 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)
{
for (cop = 0; cop < eoo; ++cop)
{
if (internal->options[cop] == *internal->xargv)
{
opt->option = *internal->xargv;
internal->xargv += 1;
/*
** 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 = PR_FALSE;
}
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 */

View File

@@ -0,0 +1,125 @@
/* -*- 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 */

View File

@@ -0,0 +1,81 @@
/* -*- 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;
}

View File

@@ -0,0 +1,115 @@
/* -*- 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]);
}

View File

@@ -0,0 +1,88 @@
/* -*- 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;
}

View File

@@ -0,0 +1,57 @@
/* -*- 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);
}

View File

@@ -0,0 +1,84 @@
/* -*- 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;
}

View File

@@ -0,0 +1,123 @@
/* -*- 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 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);
p = &big[ PL_strlen(big) - 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;
}
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;
}

View File

@@ -0,0 +1,85 @@
/* -*- 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;
}

View File

@@ -0,0 +1,71 @@
/* -*- 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);
}

View File

@@ -0,0 +1,100 @@
/* -*- 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;
}

View File

@@ -0,0 +1,117 @@
/* -*- 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_strstr(const char *big, const char *little)
{
if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0;
if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0;
return strstr(big, little);
}
PR_IMPLEMENT(char *)
PL_strrstr(const char *big, const char *little)
{
const char *p;
size_t ll;
size_t bl;
if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0;
if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0;
ll = strlen(little);
bl = strlen(big);
if( bl < ll ) return (char *)0;
p = &big[ bl - ll ];
for( ; p >= big; p-- )
if( *little == *p )
if( 0 == strncmp(p, little, ll) )
return (char *)p;
return (char *)0;
}
PR_IMPLEMENT(char *)
PL_strnstr(const char *big, const char *little, PRUint32 max)
{
size_t ll;
if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0;
if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0;
ll = strlen(little);
if( ll > (size_t)max ) return (char *)0;
max -= (PRUint32)ll;
max++;
for( ; max && *big; big++, max-- )
if( *little == *big )
if( 0 == strncmp(big, little, ll) )
return (char *)big;
return (char *)0;
}
PR_IMPLEMENT(char *)
PL_strnrstr(const char *big, const char *little, PRUint32 max)
{
const char *p;
size_t ll;
if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0;
if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0;
ll = strlen(little);
for( p = big; max && *p; p++, max-- )
;
p -= ll;
if( p < big ) return (char *)0;
for( ; p >= big; p-- )
if( *little == *p )
if( 0 == strncmp(p, little, ll) )
return (char *)p;
return (char *)0;
}

View File

@@ -0,0 +1,89 @@
/* -*- 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) 2001
* 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 ***** */
#include "plstr.h"
PR_IMPLEMENT(char *)
PL_strtok_r(char *s1, const char *s2, char **lasts)
{
const char *sepp;
int c, sc;
char *tok;
if( s1 == NULL )
{
if( *lasts == NULL )
return NULL;
s1 = *lasts;
}
for( ; (c = *s1) != 0; s1++ )
{
for( sepp = s2 ; (sc = *sepp) != 0 ; sepp++ )
{
if( c == sc )
break;
}
if( sc == 0 )
break;
}
if( c == 0 )
{
*lasts = NULL;
return NULL;
}
tok = s1++;
for( ; (c = *s1) != 0; s1++ )
{
for( sepp = s2; (sc = *sepp) != 0; sepp++ )
{
if( c == sc )
{
*s1++ = '\0';
*lasts = s1;
return tok;
}
}
}
*lasts = NULL;
return tok;
}