зеркало из https://github.com/mozilla/pjs.git
removing incompatibly licensed source.
This commit is contained in:
Родитель
ef48f556c8
Коммит
cd76285dce
|
@ -1,198 +0,0 @@
|
|||
|
||||
/* W3 Copyright statement
|
||||
Copyright 1995 by: Massachusetts Institute of Technology (MIT), INRIA</H2>
|
||||
|
||||
This W3C software is being provided by the copyright holders under the
|
||||
following license. By obtaining, using and/or copying this software,
|
||||
you agree that you have read, understood, and will comply with the
|
||||
following terms and conditions:
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee or royalty is hereby
|
||||
granted, provided that the full text of this NOTICE appears on
|
||||
<EM>ALL</EM> copies of the software and documentation or portions
|
||||
thereof, including modifications, that you make.
|
||||
|
||||
<B>THIS SOFTWARE IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO
|
||||
REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE,
|
||||
BUT NOT LIMITATION, COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR
|
||||
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR
|
||||
THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY
|
||||
THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
|
||||
COPYRIGHT HOLDERS WILL BEAR NO LIABILITY FOR ANY USE OF THIS SOFTWARE
|
||||
OR DOCUMENTATION.
|
||||
|
||||
The name and trademarks of copyright holders may NOT be used
|
||||
in advertising or publicity pertaining to the software without
|
||||
specific, written prior permission. Title to copyright in this
|
||||
software and any associated documentation will at all times remain
|
||||
with copyright holders.
|
||||
*/
|
||||
/* HTChunk.c
|
||||
** CHUNK HANDLING: FLEXIBLE ARRAYS
|
||||
**
|
||||
** (c) COPYRIGHT MIT 1995.
|
||||
** Please first read the full copyright statement in the file COPYRIGH.
|
||||
** @(#) $Id: htchunk.c,v 1.2 1999-05-07 05:26:11 neeti%netscape.com Exp $
|
||||
**
|
||||
** history: AL, HF 28 Apr 94, Now chunk->data is filled by '\0' so
|
||||
** that the string is terminated at any time. That makes
|
||||
** HTChunk_terminate not needed any more, but never mind.
|
||||
** EGP 15 Mar 96, Added CString conversions.
|
||||
**
|
||||
*/
|
||||
|
||||
/* Library include files */
|
||||
#include "xp_core.h"
|
||||
#include "plstr.h"
|
||||
/* #include "sysdep.h" 7/9/97 -- jhines */
|
||||
#include "htutils.h"
|
||||
#include "htchunk.h" /* Implemented here */
|
||||
|
||||
/* Create a chunk with a certain allocation unit
|
||||
** --------------
|
||||
*/
|
||||
PUBLIC HTChunk * HTChunk_new (PRInt32 grow)
|
||||
{
|
||||
HTChunk * ch;
|
||||
if ((ch = (HTChunk *) HT_CALLOC(1, sizeof(HTChunk))) == NULL)
|
||||
HT_OUTOFMEM("HTChunk_new");
|
||||
ch->growby = grow;
|
||||
return ch;
|
||||
}
|
||||
|
||||
|
||||
/* Clear a chunk of all data
|
||||
** --------------------------
|
||||
** Zero the space but do NOT HT_FREE it. We zero because we promise to have
|
||||
** a NUL terminated string at all times.
|
||||
*/
|
||||
PUBLIC void HTChunk_clear (HTChunk * ch)
|
||||
{
|
||||
if (ch) {
|
||||
ch->size = 0;
|
||||
memset((void *) ch->data, '\0', ch->allocated);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Free a chunk
|
||||
** ------------
|
||||
*/
|
||||
PUBLIC void HTChunk_delete (HTChunk * ch)
|
||||
{
|
||||
if (ch) {
|
||||
HT_FREE(ch->data);
|
||||
HT_FREE(ch);
|
||||
}
|
||||
}
|
||||
|
||||
/* Create a chunk from an allocated string
|
||||
** ---------------------------------------
|
||||
*/
|
||||
PUBLIC HTChunk * HTChunk_fromCString (char * str, PRInt32 grow)
|
||||
{
|
||||
HTChunk * ch;
|
||||
ch = HTChunk_new(grow);
|
||||
if (str) {
|
||||
ch->data = str; /* can't handle non-allocated str */
|
||||
ch->size = PL_strlen(str);
|
||||
}
|
||||
return ch;
|
||||
}
|
||||
|
||||
/* Free a chunk but keep the data
|
||||
** ------------------------------
|
||||
*/
|
||||
PUBLIC char * HTChunk_toCString (HTChunk * ch)
|
||||
{
|
||||
char * ret = 0;
|
||||
if (ch) {
|
||||
ret = ch->data;
|
||||
HT_FREE(ch);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Append a character
|
||||
** ------------------
|
||||
*/
|
||||
PUBLIC void HTChunk_putc (HTChunk * ch, char c)
|
||||
{
|
||||
if (ch) {
|
||||
if (ch->size >= ch->allocated-1) {
|
||||
if (ch->data) {
|
||||
if ((ch->data = (char *) HT_REALLOC(ch->data,ch->allocated+ch->growby)) == NULL)
|
||||
HT_OUTOFMEM("HTChunk_putc");
|
||||
memset((void *) (ch->data + ch->allocated), '\0', ch->growby);
|
||||
} else {
|
||||
if ((ch->data = (char *) HT_CALLOC(1, ch->allocated+ch->growby)) == NULL)
|
||||
HT_OUTOFMEM("HTChunk_putc");
|
||||
}
|
||||
ch->allocated += ch->growby;
|
||||
}
|
||||
*(ch->data+ch->size++) = c;
|
||||
}
|
||||
}
|
||||
|
||||
/* Append a string
|
||||
** ---------------
|
||||
*/
|
||||
PUBLIC void HTChunk_puts (HTChunk * ch, const char * s)
|
||||
{
|
||||
HTChunk_putb(ch, s, (PRInt32) PL_strlen(s));
|
||||
}
|
||||
|
||||
/* Append a block
|
||||
** ---------------
|
||||
** The string is always zero terminated
|
||||
*/
|
||||
PUBLIC void HTChunk_putb (HTChunk * ch, const char * block, PRInt32 len)
|
||||
{
|
||||
if (ch && block && len) {
|
||||
PRInt32 needed = ch->size+len;
|
||||
if (needed >= ch->allocated) {
|
||||
ch->allocated = needed - needed%ch->growby + ch->growby;
|
||||
if (ch->data) {
|
||||
if ((ch->data = (char *) HT_REALLOC(ch->data, ch->allocated)) == NULL)
|
||||
HT_OUTOFMEM("HTChunk_putb");
|
||||
memset((void *) (ch->data + needed), '\0', ch->allocated-needed);
|
||||
} else {
|
||||
if ((ch->data = (char *) HT_CALLOC(1, ch->allocated)) == NULL)
|
||||
HT_OUTOFMEM("HTChunk_putb");
|
||||
}
|
||||
}
|
||||
memcpy((void *) (ch->data+ch->size), block, len);
|
||||
ch->size = needed;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Ensure a certain size
|
||||
** ---------------------
|
||||
*/
|
||||
PUBLIC void HTChunk_ensure (HTChunk * ch, PRInt32 len)
|
||||
{
|
||||
if (ch && len) {
|
||||
PRInt32 needed = ch->size+len;
|
||||
if (needed >= ch->allocated) {
|
||||
ch->allocated = needed - needed%ch->growby + ch->growby;
|
||||
if (ch->data) {
|
||||
if ((ch->data = (char *) HT_REALLOC(ch->data, ch->allocated)) == NULL)
|
||||
HT_OUTOFMEM("HTChunk_putb");
|
||||
memset((void *) (ch->data + ch->size), '\0', ch->allocated-ch->size);
|
||||
} else {
|
||||
if ((ch->data = (char *) HT_CALLOC(1, ch->allocated)) == NULL)
|
||||
HT_OUTOFMEM("ch->data ");
|
||||
}
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
if (needed <= ch->allocated) return;
|
||||
ch->allocated = needed-1 - ((needed-1) % ch->growby)
|
||||
+ ch->growby; /* Round up */
|
||||
ch->data = ch->data ? (char *)PR_REALLOC(ch->data, ch->allocated)
|
||||
: (char *)HT_MALLOC(ch->allocated);
|
||||
if (ch->data == NULL) HT_OUTOFMEM(__FILE__, "HTChunk_ensure");
|
||||
#endif
|
||||
}
|
|
@ -1,192 +0,0 @@
|
|||
|
||||
/* W3 Copyright statement
|
||||
Copyright 1995 by: Massachusetts Institute of Technology (MIT), INRIA</H2>
|
||||
|
||||
This W3C software is being provided by the copyright holders under the
|
||||
following license. By obtaining, using and/or copying this software,
|
||||
you agree that you have read, understood, and will comply with the
|
||||
following terms and conditions:
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee or royalty is hereby
|
||||
granted, provided that the full text of this NOTICE appears on
|
||||
<EM>ALL</EM> copies of the software and documentation or portions
|
||||
thereof, including modifications, that you make.
|
||||
|
||||
<B>THIS SOFTWARE IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO
|
||||
REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE,
|
||||
BUT NOT LIMITATION, COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR
|
||||
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR
|
||||
THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY
|
||||
THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
|
||||
COPYRIGHT HOLDERS WILL BEAR NO LIABILITY FOR ANY USE OF THIS SOFTWARE
|
||||
OR DOCUMENTATION.
|
||||
|
||||
The name and trademarks of copyright holders may NOT be used
|
||||
in advertising or publicity pertaining to the software without
|
||||
specific, written prior permission. Title to copyright in this
|
||||
software and any associated documentation will at all times remain
|
||||
with copyright holders.
|
||||
*/
|
||||
/* W3C Reference Library libwww Chunk Class
|
||||
THE CHUNK CLASS
|
||||
|
||||
*/
|
||||
/*
|
||||
** (c) COPYRIGHT MIT 1995.
|
||||
** Please first read the full copyright statement in the file COPYRIGH.
|
||||
*/
|
||||
/*
|
||||
|
||||
The Chunk Class defines a way to automatically handle dynamic strings and other data
|
||||
types. You create a chunk with an initial size and it will then automatically grow to
|
||||
accomodate added data to the chunk. It is a general utility module. It is garanteed
|
||||
that the array is '\0' terminated at all times (and hence is a valid C type string).
|
||||
The method HTChunkTerminate can be used to explicitly add a terminating '\0'and then to
|
||||
include this character in the chunk size. If left out, the terminating character is
|
||||
_not_ considered part of the chunk.
|
||||
|
||||
_Note_: The names without a "_" (made as a #define's) are only provided for backwards
|
||||
compatibility and should not be used.
|
||||
|
||||
This module is implemented by HTChunk.c, and it is a part of the W3C Reference Library.
|
||||
|
||||
*/
|
||||
#ifndef HTCHUNK_H
|
||||
#define HTCHUNK_H
|
||||
|
||||
/*
|
||||
|
||||
THE CHUNK CLASS
|
||||
|
||||
This structure should not be referenced outside this module! We only keep it here to
|
||||
maintain high performance. _Don't _use it directly!
|
||||
|
||||
*/
|
||||
typedef struct {
|
||||
PRInt32 size; /* In bytes */
|
||||
PRInt32 growby; /* Allocation unit in bytes */
|
||||
PRInt32 allocated; /* Current size of *data */
|
||||
char * data; /* Pointer to malloced area or 0 */
|
||||
} HTChunk;
|
||||
/*
|
||||
|
||||
CREATE NEW CHUNK
|
||||
|
||||
Create a new chunk and specify the number of bytes to allocate at a time when the chunk
|
||||
is later extended. Arbitrary but normally a trade-off time vs. memory
|
||||
|
||||
*/
|
||||
#define HTChunkCreate(growby) HTChunk_new(growby)
|
||||
extern HTChunk * HTChunk_new (PRInt32 growby);
|
||||
/*
|
||||
|
||||
FREE A CHUNK
|
||||
|
||||
Free a chunk created by HTChunkCreatefrom memory
|
||||
|
||||
*/
|
||||
#define HTChunkFree(ch) HTChunk_delete(ch)
|
||||
extern void HTChunk_delete (HTChunk * ch);
|
||||
/*
|
||||
|
||||
CLEAR A CHUNK
|
||||
|
||||
Keep the chunk in memory but clear all data kept inside. This can be used if you know
|
||||
that you can reuse the allocated memory instead of allocating new memory.
|
||||
|
||||
*/
|
||||
#define HTChunkClear(ch) HTChunk_clear(ch)
|
||||
extern void HTChunk_clear (HTChunk * ch);
|
||||
/*
|
||||
|
||||
ENSURE A CHUNK HAS A CERTAIN AMOUNT OF FREE SPACE
|
||||
|
||||
Make sure that a chunk has a certain size. If this is not the case then the chunk is
|
||||
expanded. Nothing is done if the current size if bigger than the size requested.
|
||||
|
||||
*/
|
||||
#define HTChunkEnsure(ch, s) HTChunk_ensure(ch, s)
|
||||
extern void HTChunk_ensure (HTChunk * ch, PRInt32 s);
|
||||
/*
|
||||
|
||||
APPEND A CHARACTER TO A CHUNK
|
||||
|
||||
Add the character and increment the size of the chunk by one character
|
||||
|
||||
*/
|
||||
#define HTChunkPutc(ch, c) HTChunk_putc(ch, c)
|
||||
extern void HTChunk_putc (HTChunk * ch, char c);
|
||||
/*
|
||||
|
||||
APPEND A STRING TO A CHUNK
|
||||
|
||||
Add the string and increment the size of the chunk by the length of the string (without
|
||||
the trailing zero)
|
||||
|
||||
*/
|
||||
#define HTChunkPuts(ch, str) HTChunk_puts(ch, str)
|
||||
extern void HTChunk_puts (HTChunk * ch, const char *str);
|
||||
/*
|
||||
|
||||
APPEND A BLOCK TO A CHUNK
|
||||
|
||||
Add the block and increment the size of the chunk by the len
|
||||
|
||||
*/
|
||||
extern void HTChunk_putb (HTChunk * ch, const char *block, PRInt32 len);
|
||||
|
||||
/*
|
||||
|
||||
ZERO TERMINATE A CHUNK
|
||||
|
||||
As a chunk often is a dynamic string, it needs to be terminated by a zero in order to
|
||||
be used in C. However, _by default_ any chunk is _always_ zero terminated, so the only
|
||||
purpose of this function is to increment the size counter with one corresponding to the
|
||||
zero.
|
||||
|
||||
*/
|
||||
#define HTChunkTerminate(ch) HTChunk_terminate(ch)
|
||||
#define HTChunk_terminate(ch) HTChunk_putc((ch), '\0')
|
||||
/*
|
||||
|
||||
RETURN POINTER TO DATA
|
||||
|
||||
This define converts a chunk to a normal char pointer so that it can be parsed to any
|
||||
ANSI C string function.
|
||||
|
||||
*/
|
||||
#define HTChunkData(me) ((me) ? (me)->data : NULL)
|
||||
#define HTChunk_data(me) ((me) ? (me)->data : NULL)
|
||||
/*
|
||||
|
||||
CSTRING CONVERSIONS
|
||||
|
||||
A Chunk may be build from an allocated string. The chunk assumes control of the passes
|
||||
string, elminating the need for additional allocations and string copies.
|
||||
Once a string is built, the chunk may be destroyed and the string kept around.
|
||||
|
||||
*/
|
||||
extern HTChunk * HTChunk_fromCString (char * str, PRInt32 grow);
|
||||
extern char * HTChunk_toCString (HTChunk * ch);
|
||||
/*
|
||||
|
||||
RETURN CURRENT SIZE
|
||||
|
||||
Returns the current size of the chunk
|
||||
|
||||
*/
|
||||
#define HTChunkSize(me) ((me) ? (me)->size : -1)
|
||||
#define HTChunk_size(me) ((me) ? (me)->size : -1)
|
||||
/*
|
||||
|
||||
*/
|
||||
#endif
|
||||
/*
|
||||
|
||||
|
||||
___________________________________
|
||||
|
||||
@(#) $Id: htchunk.h,v 1.2 1999-05-07 05:26:11 neeti%netscape.com Exp $
|
||||
|
||||
*/
|
|
@ -1,211 +0,0 @@
|
|||
|
||||
/* W3 Copyright statement
|
||||
Copyright 1995 by: Massachusetts Institute of Technology (MIT), INRIA</H2>
|
||||
|
||||
This W3C software is being provided by the copyright holders under the
|
||||
following license. By obtaining, using and/or copying this software,
|
||||
you agree that you have read, understood, and will comply with the
|
||||
following terms and conditions:
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee or royalty is hereby
|
||||
granted, provided that the full text of this NOTICE appears on
|
||||
<EM>ALL</EM> copies of the software and documentation or portions
|
||||
thereof, including modifications, that you make.
|
||||
|
||||
<B>THIS SOFTWARE IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO
|
||||
REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE,
|
||||
BUT NOT LIMITATION, COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR
|
||||
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR
|
||||
THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY
|
||||
THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
|
||||
COPYRIGHT HOLDERS WILL BEAR NO LIABILITY FOR ANY USE OF THIS SOFTWARE
|
||||
OR DOCUMENTATION.
|
||||
|
||||
The name and trademarks of copyright holders may NOT be used
|
||||
in advertising or publicity pertaining to the software without
|
||||
specific, written prior permission. Title to copyright in this
|
||||
software and any associated documentation will at all times remain
|
||||
with copyright holders.
|
||||
*/
|
||||
/* HTList.c
|
||||
** MANAGEMENT OF LINKED LISTS
|
||||
**
|
||||
** (c) COPYRIGHT MIT 1995.
|
||||
** Please first read the full copyright statement in the file COPYRIGH.
|
||||
** @(#) $Id: htlist.c,v 1.2 1999-05-07 05:26:11 neeti%netscape.com Exp $
|
||||
**
|
||||
** A list is represented as a sequence of linked nodes of type HTList.
|
||||
** The first node is a header which contains no object.
|
||||
** New nodes are inserted between the header and the rest of the list.
|
||||
*/
|
||||
|
||||
/* Library include files */
|
||||
/* #include "sysdep.h" jhines -- 7/9/97 */
|
||||
#include "htutils.h"
|
||||
#include "htlist.h"
|
||||
|
||||
PUBLIC HTList * HTList_new (void)
|
||||
{
|
||||
HTList *newList;
|
||||
if ((newList = (HTList *) HT_CALLOC(1, sizeof (HTList))) == NULL)
|
||||
HT_OUTOFMEM("HTList_new");
|
||||
newList->object = NULL;
|
||||
newList->next = NULL;
|
||||
return newList;
|
||||
}
|
||||
|
||||
PUBLIC PRBool HTList_delete (HTList * me)
|
||||
{
|
||||
if (me) {
|
||||
HTList *current;
|
||||
while ((current = me) != NULL) {
|
||||
me = me->next;
|
||||
HT_FREE(current);
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
PUBLIC PRBool HTList_addObject (HTList * me, void * newObject)
|
||||
{
|
||||
if (me) {
|
||||
HTList *newNode;
|
||||
if ((newNode = (HTList *) HT_CALLOC(1, sizeof(HTList))) == NULL)
|
||||
HT_OUTOFMEM("HTList_addObject");
|
||||
newNode->object = newObject;
|
||||
newNode->next = me->next;
|
||||
me->next = newNode;
|
||||
return YES;
|
||||
} else {
|
||||
if (WWWTRACE)
|
||||
HTTrace(
|
||||
"HTList...... Can not add object %p to nonexisting list\n",
|
||||
newObject);
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
PUBLIC PRBool HTList_appendObject (HTList * me, void * newObject)
|
||||
{
|
||||
if (me) {
|
||||
while (me->next) me = me->next;
|
||||
return HTList_addObject(me, newObject);
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
PUBLIC PRBool HTList_removeObject (HTList * me, void * oldObject)
|
||||
{
|
||||
if (me) {
|
||||
HTList *previous;
|
||||
while (me->next) {
|
||||
previous = me;
|
||||
me = me->next;
|
||||
if (me->object == oldObject) {
|
||||
previous->next = me->next;
|
||||
HT_FREE(me);
|
||||
return YES; /* Success */
|
||||
}
|
||||
}
|
||||
}
|
||||
return NO; /* object not found or NULL list */
|
||||
}
|
||||
|
||||
PUBLIC void * HTList_removeLastObject (HTList * me)
|
||||
{
|
||||
if (me && me->next) {
|
||||
HTList *lastNode = me->next;
|
||||
void * lastObject = lastNode->object;
|
||||
me->next = lastNode->next;
|
||||
HT_FREE(lastNode);
|
||||
return lastObject;
|
||||
} else /* Empty list */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PUBLIC void * HTList_removeFirstObject (HTList * me)
|
||||
{
|
||||
if (me && me->next) {
|
||||
HTList * prevNode;
|
||||
void *firstObject;
|
||||
while (me->next) {
|
||||
prevNode = me;
|
||||
me = me->next;
|
||||
}
|
||||
firstObject = me->object;
|
||||
prevNode->next = NULL;
|
||||
HT_FREE(me);
|
||||
return firstObject;
|
||||
} else /* Empty list */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PUBLIC void * HTList_firstObject (HTList * me)
|
||||
{
|
||||
if (me && me->next) {
|
||||
HTList * prevNode;
|
||||
while (me->next) {
|
||||
prevNode = me;
|
||||
me = me->next;
|
||||
}
|
||||
return me->object;
|
||||
} else /* Empty list */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PUBLIC PRInt32 HTList_count (HTList * me)
|
||||
{
|
||||
PRInt32 count = 0;
|
||||
if (me)
|
||||
while ((me = me->next) != NULL)
|
||||
count++;
|
||||
return count;
|
||||
}
|
||||
|
||||
PUBLIC PRInt32 HTList_indexOf (HTList * me, void * object)
|
||||
{
|
||||
if (me) {
|
||||
PRInt32 position = 0;
|
||||
while ((me = me->next) != NULL) {
|
||||
if (me->object == object)
|
||||
return position;
|
||||
position++;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
PUBLIC void * HTList_objectAt (HTList * me, PRInt32 position)
|
||||
{
|
||||
if (position < 0)
|
||||
return NULL;
|
||||
if (me) {
|
||||
while ((me = me->next) != NULL) {
|
||||
if (position == 0)
|
||||
return me->object;
|
||||
position--;
|
||||
}
|
||||
}
|
||||
return NULL; /* Reached the end of the list */
|
||||
}
|
||||
|
||||
PRIVATE void * HTList_removeObjectAt (HTList * me, PRInt32 position)
|
||||
{
|
||||
if (position < 0)
|
||||
return NULL;
|
||||
if (me) {
|
||||
HTList * prevNode;
|
||||
prevNode = me;
|
||||
while ((me = me->next) != NULL) {
|
||||
if (position == 0) {
|
||||
prevNode->next = me->next;
|
||||
return me->object;
|
||||
}
|
||||
prevNode = me;
|
||||
position--;
|
||||
}
|
||||
}
|
||||
return NULL; /* Reached the end of the list */
|
||||
}
|
|
@ -1,163 +0,0 @@
|
|||
|
||||
/* W3 Copyright statement
|
||||
Copyright 1995 by: Massachusetts Institute of Technology (MIT), INRIA</H2>
|
||||
|
||||
This W3C software is being provided by the copyright holders under the
|
||||
following license. By obtaining, using and/or copying this software,
|
||||
you agree that you have read, understood, and will comply with the
|
||||
following terms and conditions:
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee or royalty is hereby
|
||||
granted, provided that the full text of this NOTICE appears on
|
||||
<EM>ALL</EM> copies of the software and documentation or portions
|
||||
thereof, including modifications, that you make.
|
||||
|
||||
<B>THIS SOFTWARE IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO
|
||||
REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE,
|
||||
BUT NOT LIMITATION, COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR
|
||||
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR
|
||||
THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY
|
||||
THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
|
||||
COPYRIGHT HOLDERS WILL BEAR NO LIABILITY FOR ANY USE OF THIS SOFTWARE
|
||||
OR DOCUMENTATION.
|
||||
|
||||
The name and trademarks of copyright holders may NOT be used
|
||||
in advertising or publicity pertaining to the software without
|
||||
specific, written prior permission. Title to copyright in this
|
||||
software and any associated documentation will at all times remain
|
||||
with copyright holders.
|
||||
*/
|
||||
/* W3C Reference Library libwww List Class
|
||||
THE LIST CLASS
|
||||
|
||||
*/
|
||||
/*
|
||||
** (c) COPYRIGHT MIT 1995.
|
||||
** Please first read the full copyright statement in the file COPYRIGH.
|
||||
*/
|
||||
/*
|
||||
|
||||
The list class defines a generic container for storing collections of things in order.
|
||||
In principle it could be implemented in many ways, but in practice knowing that it is a
|
||||
linked list is important for speed.
|
||||
|
||||
This module is implemented by HTList.c, and it is a part of the W3C Reference Library.
|
||||
|
||||
*/
|
||||
#ifndef HTLIST_H
|
||||
#define HTLIST_H
|
||||
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
|
||||
#ifndef BOOL
|
||||
#define BOOL PRBool
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct _HTList HTList;
|
||||
|
||||
struct _HTList {
|
||||
void * object;
|
||||
HTList * next;
|
||||
};
|
||||
/*
|
||||
|
||||
CREATION AND DELETION METHODS
|
||||
|
||||
These two functions create and deletes a list
|
||||
|
||||
*/
|
||||
extern HTList * HTList_new (void);
|
||||
extern PRBool HTList_delete (HTList *me);
|
||||
/*
|
||||
|
||||
ADD AN ELEMENT TO LIST
|
||||
|
||||
A new list element is added to the beginning of the list so that it is first element
|
||||
just after the head element.
|
||||
|
||||
*/
|
||||
extern PRBool HTList_addObject (HTList *me, void *newObject);
|
||||
/*
|
||||
|
||||
You can also append an element to the end of the list (the end is the first entered
|
||||
object) by using the following function:
|
||||
|
||||
*/
|
||||
extern PRBool HTList_appendObject (HTList * me, void * newObject);
|
||||
/*
|
||||
|
||||
REMOVE LIST ELEMENTS
|
||||
|
||||
You can delete elements in a list usin the following methods
|
||||
|
||||
*/
|
||||
extern PRBool HTList_removeObject (HTList *me, void *oldObject);
|
||||
extern void * HTList_removeLastObject (HTList *me);
|
||||
extern void * HTList_removeFirstObject (HTList *me);
|
||||
/*
|
||||
|
||||
SIZE OF A LIST
|
||||
|
||||
Two small function to ask for the size
|
||||
|
||||
*/
|
||||
#define HTList_isEmpty(me) (me ? me->next == NULL : YES)
|
||||
extern PRInt32 HTList_count (HTList *me);
|
||||
/*
|
||||
|
||||
REFERENCE LIST ELEMENTS BY INDEX
|
||||
|
||||
In some situations is is required to use an index in order to refer to a list element.
|
||||
This is for example the case if an element can be registered multiple times.
|
||||
|
||||
*/
|
||||
extern PRInt32 HTList_indexOf (HTList *me, void *object);
|
||||
extern void * HTList_objectAt (HTList *me, PRInt32 position);
|
||||
/*
|
||||
|
||||
FIND LIST ELEMENTS
|
||||
|
||||
This method returns the _last_ element to the list or NULL if list is empty
|
||||
|
||||
*/
|
||||
#define HTList_lastObject(me) \
|
||||
((me) && (me)->next ? (me)->next->object : NULL)
|
||||
/*
|
||||
|
||||
This method returns the _first_ element to the list or NULL if list is empty
|
||||
|
||||
*/
|
||||
extern void * HTList_firstObject (HTList * me);
|
||||
/*
|
||||
|
||||
TRAVERSE LIST
|
||||
|
||||
Fast macro to traverse the list. Call it first with copy of list header: it returns the
|
||||
first object and increments the passed list pointer. Call it with the same variable
|
||||
until it returns NULL.
|
||||
|
||||
*/
|
||||
#define HTList_nextObject(me) \
|
||||
((me) && ((me) = (me)->next) ? (me)->object : NULL)
|
||||
/*
|
||||
|
||||
FREE LIST
|
||||
|
||||
*/
|
||||
#define HTList_free(x) HT_FREE(x)
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif /* HTLIST_H */
|
||||
/*
|
||||
|
||||
|
||||
___________________________________
|
||||
|
||||
@(#) $Id: htlist.h,v 1.2 1999-05-07 05:26:11 neeti%netscape.com Exp $
|
||||
|
||||
*/
|
|
@ -1,186 +0,0 @@
|
|||
|
||||
/* W3 Copyright statement
|
||||
Copyright 1995 by: Massachusetts Institute of Technology (MIT), INRIA</H2>
|
||||
|
||||
This W3C software is being provided by the copyright holders under the
|
||||
following license. By obtaining, using and/or copying this software,
|
||||
you agree that you have read, understood, and will comply with the
|
||||
following terms and conditions:
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee or royalty is hereby
|
||||
granted, provided that the full text of this NOTICE appears on
|
||||
<EM>ALL</EM> copies of the software and documentation or portions
|
||||
thereof, including modifications, that you make.
|
||||
|
||||
<B>THIS SOFTWARE IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO
|
||||
REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE,
|
||||
BUT NOT LIMITATION, COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR
|
||||
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR
|
||||
THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY
|
||||
THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
|
||||
COPYRIGHT HOLDERS WILL BEAR NO LIABILITY FOR ANY USE OF THIS SOFTWARE
|
||||
OR DOCUMENTATION.
|
||||
|
||||
The name and trademarks of copyright holders may NOT be used
|
||||
in advertising or publicity pertaining to the software without
|
||||
specific, written prior permission. Title to copyright in this
|
||||
software and any associated documentation will at all times remain
|
||||
with copyright holders.
|
||||
*/
|
||||
/* W3C Reference Library libwww Dynamic Memory Handlers
|
||||
DYNAMIC MEMORY HANDLERS
|
||||
|
||||
*/
|
||||
/*
|
||||
** (c) COPYRIGHT MIT 1995.
|
||||
** Please first read the full copyright statement in the file COPYRIGH.
|
||||
*/
|
||||
/*
|
||||
|
||||
This module defines any memory handler to be used by libwww for allocating and
|
||||
de-allocating dynamic memory. As dynamic memory may be a scarce resource, it is
|
||||
required that an application can handle memory exhaustion gracefully. This module
|
||||
provides an interface that covers the following situations:
|
||||
|
||||
Handling of allocation, reallocation and de-allocation of dynamic memory
|
||||
|
||||
Recovering from temporary lack of available memory
|
||||
|
||||
Panic handling in case a new allocation fails
|
||||
|
||||
_Note_: The Library _core_ provides a default set of memory handlers for allocating and
|
||||
de-allocating dynamic memory. In order to maintain a reasonable performance, they are
|
||||
not registered dynamically but assigned using _C style macros_. Hence, it is not
|
||||
possible to swap memory handler at run time but this was considered to be a reasonable
|
||||
trade-off.
|
||||
|
||||
This module is implemented by HTMemory.c, and it is a part of the W3C Reference
|
||||
Library.
|
||||
|
||||
*/
|
||||
#ifndef HTMEMORY_H
|
||||
#define HTMEMORY_H
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
/*
|
||||
|
||||
ALLOCATION, REALLOCATION AND DE-ALLOCATION
|
||||
|
||||
The Library provides a default set of methods for handling dynamic memory. They are
|
||||
very basic and essentially identical to the C style malloc, calloc, realloc, and free:
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef BOOL
|
||||
#define BOOL PRBool
|
||||
#endif
|
||||
|
||||
|
||||
extern void* HTMemory_malloc(size_t size);
|
||||
extern void* HTMemory_calloc(size_t count, size_t size);
|
||||
extern void* HTMemory_realloc(void * ptr, size_t size);
|
||||
extern void HTMemory_free(void* ptr);
|
||||
|
||||
/*
|
||||
|
||||
Memory Macros
|
||||
|
||||
The methods above are not referred directly in the Library. Instead we use a set of C
|
||||
style macros. If you don't wany any memory management beyond normal malloc and alloc
|
||||
then you can just use that instead of the HTMemory_* function. You can of course also
|
||||
provide your own methods as well.
|
||||
|
||||
*/
|
||||
#ifndef __FILE__
|
||||
#define __FILE__ ""
|
||||
#endif
|
||||
|
||||
#ifndef __LINE__
|
||||
#define __LINE__ 0L
|
||||
#endif
|
||||
|
||||
#define HT_MALLOC(size) HTMemory_malloc((size))
|
||||
#define HT_CALLOC(count, size) HTMemory_calloc((count), (size))
|
||||
#define HT_REALLOC(ptr, size) HTMemory_realloc((ptr), (size))
|
||||
#define HT_FREE(pointer) {HTMemory_free((pointer));((pointer))=NULL;}
|
||||
/*
|
||||
|
||||
MEMORY FREER FUNCTIONS
|
||||
|
||||
The dynamic memory freer functions are typically functions that are capable of freeing
|
||||
large chunks of memory. In case a new allocation fails, the allocation method looks for
|
||||
any registered freer functions to call. There can be multiple freer functions and after
|
||||
each call, the allocation method tries again to allocate the desired amount of dynamic
|
||||
memory. The freer functions are called in reverseorder meaning that the lastone
|
||||
registered gets called first. That way, it is easy to add temporary freer functions
|
||||
which then are guaranteed to be called first if a methods fails.
|
||||
|
||||
Add a Freer Function
|
||||
|
||||
You can add a freer function by using the following method. The Library may itself
|
||||
register a set of free functions during initialization. If the application does not
|
||||
register any freer functions then the Library looks how it can free internal memory.
|
||||
The freer function is passed the total number of _bytes_ requested by the allocation.
|
||||
|
||||
*/
|
||||
typedef void (*HTMemoryCallback()); /* jhines -- 7/9/97 */
|
||||
/* typedef void HTMemoryCallback(size_t size); */
|
||||
|
||||
extern PRBool HTMemoryCall_add (HTMemoryCallback * cbf);
|
||||
/*
|
||||
|
||||
Delete a Freer Function
|
||||
|
||||
Freer functions can be deleted at any time in which case they are not called anymore.
|
||||
|
||||
*/
|
||||
extern PRBool HTMemoryCall_delete (HTMemoryCallback * cbf);
|
||||
extern PRBool HTMemoryCall_deleteAll (void);
|
||||
/*
|
||||
|
||||
PANIC HANDLING
|
||||
|
||||
If the freer functions are not capable of de-allocation enough memory then the
|
||||
application must have an organized way of closing down. This is done using the panic
|
||||
handler. In the libwww, each allocation is tested and HT_OUTOFMEMis called if a NULLwas
|
||||
returned. HT_OUTOFMEMis a macro which by default calls HTMemory_outofmem()but of course
|
||||
can point to any method. The default handler calls an exit function defined by the
|
||||
application in a call to HTMemory_setExit(). If the application has _not_ defined an
|
||||
exit function, HTMemory_outofmem()prints an error message and calls exit(1).
|
||||
|
||||
*/
|
||||
typedef void HTMemory_exitCallback(char *name, char *file, unsigned long line);
|
||||
|
||||
extern void HTMemory_setExit(HTMemory_exitCallback * pExit);
|
||||
extern HTMemory_exitCallback * HTMemory_exit(void);
|
||||
/*
|
||||
|
||||
Call the Exit Handler
|
||||
|
||||
If an allocation fails then this function is called. If the application has registered
|
||||
its own panic handler then this is called directly from this function. Otherwise, the
|
||||
default behavior is to write a small message to stderr and then exit.
|
||||
|
||||
*/
|
||||
#define outofmem(file, name) HT_OUTOFMEM(name)
|
||||
#define HT_OUTOFMEM(name) HTMemory_outofmem((name), __FILE__, __LINE__)
|
||||
|
||||
extern void HTMemory_outofmem(char * name, char * file, unsigned long line);
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif /* HTMEMORY_H */
|
||||
/*
|
||||
|
||||
|
||||
___________________________________
|
||||
|
||||
@(#) $Id: htmemory.h,v 1.2 1999-05-07 05:26:11 neeti%netscape.com Exp $
|
||||
|
||||
*/
|
|
@ -1,168 +0,0 @@
|
|||
|
||||
/* W3 Copyright statement
|
||||
Copyright 1995 by: Massachusetts Institute of Technology (MIT), INRIA</H2>
|
||||
|
||||
This W3C software is being provided by the copyright holders under the
|
||||
following license. By obtaining, using and/or copying this software,
|
||||
you agree that you have read, understood, and will comply with the
|
||||
following terms and conditions:
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee or royalty is hereby
|
||||
granted, provided that the full text of this NOTICE appears on
|
||||
<EM>ALL</EM> copies of the software and documentation or portions
|
||||
thereof, including modifications, that you make.
|
||||
|
||||
<B>THIS SOFTWARE IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO
|
||||
REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE,
|
||||
BUT NOT LIMITATION, COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR
|
||||
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR
|
||||
THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY
|
||||
THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
|
||||
COPYRIGHT HOLDERS WILL BEAR NO LIABILITY FOR ANY USE OF THIS SOFTWARE
|
||||
OR DOCUMENTATION.
|
||||
|
||||
The name and trademarks of copyright holders may NOT be used
|
||||
in advertising or publicity pertaining to the software without
|
||||
specific, written prior permission. Title to copyright in this
|
||||
software and any associated documentation will at all times remain
|
||||
with copyright holders.
|
||||
*/
|
||||
/* HTString.c
|
||||
** DYNAMIC STRING UTILITIES
|
||||
**
|
||||
** (c) COPYRIGHT MIT 1995.
|
||||
** Please first read the full copyright statement in the file COPYRIGH.
|
||||
** @(#) $Id: htstring.c,v 1.2 1999-05-07 05:26:12 neeti%netscape.com Exp $
|
||||
**
|
||||
** Original version came with listserv implementation.
|
||||
** Version TBL Oct 91 replaces one which modified the strings.
|
||||
** 02-Dec-91 (JFG) Added stralloccopy and stralloccat
|
||||
** 23 Jan 92 (TBL) Changed strallocc* to 8 char HTSAC* for VM and suchlike
|
||||
** 6 Oct 92 (TBL) Moved WWW_TraceFlag in here to be in library
|
||||
** 9 Oct 95 (KR) fixed problem with double quotes in HTNextField
|
||||
*/
|
||||
|
||||
/* Library include files */
|
||||
#include <stdarg.h>
|
||||
#include "plstr.h"
|
||||
/* #include "sysdep.h" jhines -- 7/9/97 */
|
||||
#include "htutils.h"
|
||||
#include "htstring.h" /* Implemented here */
|
||||
|
||||
#if WWWTRACE_MODE == WWWTRACE_FILE
|
||||
PUBLIC FILE *WWWTrace = NULL;
|
||||
#endif
|
||||
|
||||
#ifndef WWW_WIN_DLL
|
||||
PUBLIC PRInt32 WWW_TraceFlag = 0; /* Global trace flag for ALL W3 code */
|
||||
#endif
|
||||
|
||||
|
||||
/* Allocate a new copy of a string, and returns it
|
||||
*/
|
||||
PUBLIC char * HTSACopy (char ** dest, const char * src)
|
||||
{
|
||||
if (*dest) HT_FREE(*dest);
|
||||
if (! src)
|
||||
*dest = NULL;
|
||||
else {
|
||||
if ((*dest = (char *) HT_MALLOC(PL_strlen(src) + 1)) == NULL)
|
||||
HT_OUTOFMEM("HTSACopy");
|
||||
PL_strcpy (*dest, src);
|
||||
}
|
||||
return *dest;
|
||||
}
|
||||
|
||||
/* String Allocate and Concatenate
|
||||
*/
|
||||
PUBLIC char * HTSACat (char ** dest, const char * src)
|
||||
{
|
||||
if (src && *src) {
|
||||
if (*dest) {
|
||||
PRInt32 length = PL_strlen (*dest);
|
||||
if ((*dest = (char *) HT_REALLOC(*dest, length + PL_strlen(src) + 1)) == NULL)
|
||||
HT_OUTOFMEM("HTSACat");
|
||||
PL_strcpy (*dest + length, src);
|
||||
} else {
|
||||
if ((*dest = (char *) HT_MALLOC(PL_strlen(src) + 1)) == NULL)
|
||||
HT_OUTOFMEM("HTSACat");
|
||||
PL_strcpy (*dest, src);
|
||||
}
|
||||
}
|
||||
return *dest;
|
||||
}
|
||||
|
||||
|
||||
/* String Matching
|
||||
** ---------------
|
||||
** String comparison function for file names with one wildcard * in the
|
||||
** template. Arguments are:
|
||||
**
|
||||
** tmpl is a template string to match the name against.
|
||||
** agaist, may contain a single wildcard character * which
|
||||
** matches zero or more arbitrary characters.
|
||||
** name is the name to be matched agaist the template.
|
||||
**
|
||||
** return: - Empty string if perfect match
|
||||
** - pointer to part matched by wildcard if any
|
||||
** - NULL if no match
|
||||
*/
|
||||
PUBLIC char * HTStrMatch (const char * tmpl, const char * name)
|
||||
{
|
||||
while (*tmpl && *name && *tmpl==*name) tmpl++, name++;
|
||||
return ((!*tmpl && !*name) || *tmpl=='*') ? (char *) name : (char *) NULL;
|
||||
}
|
||||
|
||||
PUBLIC char * HTStrCaseMatch (const char * tmpl, const char * name)
|
||||
{
|
||||
while (*tmpl && *name && TOUPPER(*tmpl)==TOUPPER(*name)) tmpl++, name++;
|
||||
return ((!*tmpl && !*name) || *tmpl=='*') ? (char *) name : (char *) NULL;
|
||||
}
|
||||
|
||||
/* Strip white space off a string
|
||||
** ------------------------------
|
||||
** Return value points to first non-white character, or to 0 if none.
|
||||
** All trailing white space is OVERWRITTEN with zero.
|
||||
*/
|
||||
PUBLIC char * HTStrip (char * s)
|
||||
{
|
||||
if (s) {
|
||||
char * p=s;
|
||||
for(p=s;*p;p++); /* Find end of string */
|
||||
for(p--;p>=s;p--) {
|
||||
if (WHITE(*p))
|
||||
*p=0; /* Zap trailing blanks */
|
||||
else
|
||||
break;
|
||||
}
|
||||
while (WHITE(*s)) s++; /* Strip leading blanks */
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
PRIVATE HTTraceCallback * PHTTraceCallback;
|
||||
|
||||
PUBLIC void HTTrace_setCallback(HTTraceCallback * pCall)
|
||||
{
|
||||
PHTTraceCallback = pCall;
|
||||
}
|
||||
|
||||
PUBLIC HTTraceCallback * HTTrace_getCallback(void)
|
||||
{
|
||||
return PHTTraceCallback;
|
||||
}
|
||||
|
||||
PUBLIC PRInt32 HTTrace(const char * fmt, ...)
|
||||
{
|
||||
va_list pArgs;
|
||||
va_start(pArgs, fmt);
|
||||
if (PHTTraceCallback)
|
||||
(*PHTTraceCallback)(fmt, pArgs);
|
||||
#ifdef WWW_WIN_WINDOWS
|
||||
return (0);
|
||||
#else
|
||||
return (vfprintf(stderr, fmt, pArgs));
|
||||
#endif
|
||||
}
|
||||
|
|
@ -1,131 +0,0 @@
|
|||
|
||||
/* W3 Copyright statement
|
||||
Copyright 1995 by: Massachusetts Institute of Technology (MIT), INRIA</H2>
|
||||
|
||||
This W3C software is being provided by the copyright holders under the
|
||||
following license. By obtaining, using and/or copying this software,
|
||||
you agree that you have read, understood, and will comply with the
|
||||
following terms and conditions:
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee or royalty is hereby
|
||||
granted, provided that the full text of this NOTICE appears on
|
||||
<EM>ALL</EM> copies of the software and documentation or portions
|
||||
thereof, including modifications, that you make.
|
||||
|
||||
<B>THIS SOFTWARE IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO
|
||||
REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE,
|
||||
BUT NOT LIMITATION, COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR
|
||||
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR
|
||||
THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY
|
||||
THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
|
||||
COPYRIGHT HOLDERS WILL BEAR NO LIABILITY FOR ANY USE OF THIS SOFTWARE
|
||||
OR DOCUMENTATION.
|
||||
|
||||
The name and trademarks of copyright holders may NOT be used
|
||||
in advertising or publicity pertaining to the software without
|
||||
specific, written prior permission. Title to copyright in this
|
||||
software and any associated documentation will at all times remain
|
||||
with copyright holders.
|
||||
*/
|
||||
/* W3C Reference Library libwww Generic String Management
|
||||
GENERIC STRING MANAGEMENT
|
||||
|
||||
*/
|
||||
/*
|
||||
** (c) COPYRIGHT MIT 1995.
|
||||
** Please first read the full copyright statement in the file COPYRIGH.
|
||||
*/
|
||||
/*
|
||||
|
||||
These functions provide functionality for case-independent string comparison and
|
||||
allocations with copies etc.
|
||||
|
||||
This module is implemented by HTString.c, and it is a part of the W3C Reference
|
||||
Library.
|
||||
|
||||
*/
|
||||
#ifndef HTSTRING_H
|
||||
#define HTSTRING_H
|
||||
|
||||
#include "xp_core.h"
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
|
||||
/*
|
||||
|
||||
|
||||
DYNAMIC STRING MANIPULATION
|
||||
|
||||
These two functions are dynamic versions of strcpyand strcat. They use mallocfor
|
||||
allocating space for the string. If StrAllocCopyis called with a non-NULL dest, then
|
||||
this is freed before the new value is assigned so that only the laststring created has
|
||||
to be freed by the user. If StrAllocCatis called with a NULL pointer as destination
|
||||
then it is equivalent to StrAllocCopy.
|
||||
|
||||
*/
|
||||
#define StrAllocCopy(dest, src) HTSACopy (&(dest), src)
|
||||
#define StrAllocCat(dest, src) HTSACat (&(dest), src)
|
||||
|
||||
extern char * HTSACopy (char **dest, const char *src);
|
||||
extern char * HTSACat (char **dest, const char *src);
|
||||
/*
|
||||
|
||||
CASE-INSENSITIVE STRING COMPARISON
|
||||
|
||||
The usual routines (comp instead of cmp) had some problem.
|
||||
|
||||
*/
|
||||
/* extern PRInt32 strcasecomp (const char *a, const char *b); */
|
||||
/* extern PRInt32 strncasecomp (const char *a, const char *b, PRInt32 n); */
|
||||
/*
|
||||
|
||||
STRING COMPARISON WITH WILD CARD MATCH
|
||||
|
||||
String comparison function for file names with one wildcard * in the template.
|
||||
Arguments are:
|
||||
|
||||
tmpl is a template string to match the name against. agaist, may
|
||||
contain a single wildcard character * which matches zero or more
|
||||
arbitrary characters.
|
||||
|
||||
name is the name to be matched agaist the template.
|
||||
|
||||
Returns empty string ("") if perfect match, pointer to part matched by wildcard if any,
|
||||
or NULL if no match. This is basically the same as YES if match, else NO.
|
||||
|
||||
*/
|
||||
extern char * HTStrMatch (const char * tmpl, const char * name);
|
||||
extern char * HTStrCaseMatch (const char * tmpl, const char * name);
|
||||
/*
|
||||
|
||||
CASE-INSENSITIVE STRSTR
|
||||
|
||||
This works like strstr()but is not case-sensitive.
|
||||
|
||||
*/
|
||||
/* extern char * strcasestr (char * s1, char * s2); */
|
||||
/*
|
||||
|
||||
STRIP WHITE SPACE OFF A STRING
|
||||
|
||||
Return value points to first non-white character, or to '/0' if none. All trailing
|
||||
white space is OVERWRITTEN with zero.
|
||||
|
||||
*/
|
||||
extern char * HTStrip (char * s);
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
PR_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
/*
|
||||
|
||||
|
||||
___________________________________
|
||||
|
||||
@(#) $Id: htstring.h,v 1.2 1999-05-07 05:26:12 neeti%netscape.com Exp $
|
||||
|
||||
*/
|
|
@ -1,265 +0,0 @@
|
|||
|
||||
/* W3 Copyright statement
|
||||
Copyright 1995 by: Massachusetts Institute of Technology (MIT), INRIA</H2>
|
||||
|
||||
This W3C software is being provided by the copyright holders under the
|
||||
following license. By obtaining, using and/or copying this software,
|
||||
you agree that you have read, understood, and will comply with the
|
||||
following terms and conditions:
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee or royalty is hereby
|
||||
granted, provided that the full text of this NOTICE appears on
|
||||
<EM>ALL</EM> copies of the software and documentation or portions
|
||||
thereof, including modifications, that you make.
|
||||
|
||||
<B>THIS SOFTWARE IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO
|
||||
REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE,
|
||||
BUT NOT LIMITATION, COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR
|
||||
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR
|
||||
THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY
|
||||
THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
|
||||
COPYRIGHT HOLDERS WILL BEAR NO LIABILITY FOR ANY USE OF THIS SOFTWARE
|
||||
OR DOCUMENTATION.
|
||||
|
||||
The name and trademarks of copyright holders may NOT be used
|
||||
in advertising or publicity pertaining to the software without
|
||||
specific, written prior permission. Title to copyright in this
|
||||
software and any associated documentation will at all times remain
|
||||
with copyright holders.
|
||||
*/
|
||||
/* W3C Reference Library libwww General Purpose Macros
|
||||
GENERAL PURPOSE MACROS
|
||||
|
||||
*/
|
||||
/*
|
||||
** (c) COPYRIGHT MIT 1995.
|
||||
** Please first read the full copyright statement in the file COPYRIGH.
|
||||
*/
|
||||
/*
|
||||
|
||||
This module is a part of the W3C Reference Library. See also the system dependent file
|
||||
sysdep module for system specific information.
|
||||
|
||||
*/
|
||||
#ifndef HTUTILS_H
|
||||
#define HTUTILS_H
|
||||
|
||||
#include "xp_core.h"
|
||||
/*
|
||||
|
||||
DEBUG MESSAGE CONTROL
|
||||
|
||||
This is the global flag for setting the WWWTRACEoptions. The verbose mode is no longer
|
||||
a simple boolean but a bit field so that it is possible to see parts of the output
|
||||
messages.
|
||||
|
||||
*/
|
||||
#ifndef DEBUG
|
||||
#define DEBUG /* No one ever turns this off as trace is too important */
|
||||
#endif
|
||||
/*
|
||||
|
||||
Definition of the Global Trace Flag
|
||||
|
||||
The global trace flag variable is available everywhere.
|
||||
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
#ifdef WWW_WIN_DLL
|
||||
extern PRInt32 * WWW_TraceFlag; /* In DLLs, we need the indirection */
|
||||
#define WWWTRACE (*WWW_TraceFlag)
|
||||
#else
|
||||
extern PRInt32 WWW_TraceFlag; /* Global flag for all W3 trace */
|
||||
#define WWWTRACE (WWW_TraceFlag)
|
||||
#endif /* WWW_WIN_DLL */
|
||||
#else
|
||||
#define WWWTRACE 0
|
||||
#endif /* DEBUG */
|
||||
/*
|
||||
|
||||
The WWWTRACEdefine outputs messages if verbose mode is active according to the
|
||||
following rules:
|
||||
|
||||
*/
|
||||
typedef enum _HTTraceFlags {
|
||||
SHOW_UTIL_TRACE = 0x1, /* 1 */
|
||||
SHOW_APP_TRACE = 0x2, /* 10 */
|
||||
SHOW_CACHE_TRACE = 0x4, /* 100 */
|
||||
SHOW_SGML_TRACE = 0x8, /* 1000 */
|
||||
SHOW_BIND_TRACE = 0x10, /* 1.0000 */
|
||||
SHOW_THREAD_TRACE = 0x20, /* 10.0000 */
|
||||
SHOW_STREAM_TRACE = 0x40, /* 100.0000 */
|
||||
SHOW_PROTOCOL_TRACE = 0x80, /* 1000.0000 */
|
||||
SHOW_MEM_TRACE = 0x100, /* 1.0000.0000 */
|
||||
SHOW_URI_TRACE = 0x200, /* 10.0000.0000 */
|
||||
SHOW_AUTH_TRACE = 0x400, /* 100.0000.0000 */
|
||||
SHOW_ANCHOR_TRACE = 0x800, /* 1000.0000.0000 */
|
||||
SHOW_PICS_TRACE = 0x1000, /* 1.0000.0000.0000 */
|
||||
SHOW_CORE_TRACE = 0x2000, /* 10.0000.0000.0000 */
|
||||
SHOW_ALL_TRACE = 0x3FFF /* 11.1111.1111.1111 */
|
||||
} HTTraceFlags;
|
||||
/*
|
||||
|
||||
The flags are made so that they can serve as a group flag for correlated trace
|
||||
messages, e.g. showing messages for SGML and HTML at the same time.
|
||||
|
||||
*/
|
||||
#define UTIL_TRACE (WWWTRACE & SHOW_UTIL_TRACE)
|
||||
#define APP_TRACE (WWWTRACE & SHOW_APP_TRACE)
|
||||
#define CACHE_TRACE (WWWTRACE & SHOW_CACHE_TRACE)
|
||||
#define SGML_TRACE (WWWTRACE & SHOW_SGML_TRACE)
|
||||
#define BIND_TRACE (WWWTRACE & SHOW_BIND_TRACE)
|
||||
#define THD_TRACE (WWWTRACE & SHOW_THREAD_TRACE)
|
||||
#define STREAM_TRACE (WWWTRACE & SHOW_STREAM_TRACE)
|
||||
#define PROT_TRACE (WWWTRACE & SHOW_PROTOCOL_TRACE)
|
||||
#define MEM_TRACE (WWWTRACE & SHOW_MEM_TRACE)
|
||||
#define URI_TRACE (WWWTRACE & SHOW_URI_TRACE)
|
||||
#define AUTH_TRACE (WWWTRACE & SHOW_AUTH_TRACE)
|
||||
#define ANCH_TRACE (WWWTRACE & SHOW_ANCHOR_TRACE)
|
||||
#define PICS_TRACE (WWWTRACE & SHOW_PICS_TRACE)
|
||||
#define CORE_TRACE (WWWTRACE & SHOW_CORE_TRACE)
|
||||
/*
|
||||
|
||||
Destination for Trace Messages
|
||||
|
||||
You can send trace messages to various destinations depending on the type of your
|
||||
application. By default, on Unix the messages are sent to stderr using fprintf() and if
|
||||
we are on Windows and have a windows applications then register a HTTraceCallback
|
||||
function. This is done with HTTrace_setCallback. It tells HTTrace to call a
|
||||
HTTraceCallback. If your compiler has problems with va_list, then you may forget about
|
||||
registering the callback and instead macro HTTrace as follows: #define HTTrace
|
||||
MyAppSpecificTrace
|
||||
|
||||
*/
|
||||
typedef PRInt32 (*HTTraceCallback)(); /* jhines--7/9/97 */
|
||||
/* typedef PRInt32 HTTraceCallback(const char * fmt, va_list pArgs); */
|
||||
|
||||
extern void HTTrace_setCallback(HTTraceCallback * pCall);
|
||||
extern HTTraceCallback * HTTrace_getCallback(void);
|
||||
|
||||
extern PRInt32 HTTrace(const char * fmt, ...);
|
||||
/*
|
||||
|
||||
MACROS FOR FUNCTION DECLARATIONS
|
||||
|
||||
*/
|
||||
/* #define PUBLIC */ /* Accessible outside this module */
|
||||
/* #define PRIVATE static */ /* Accessible only within this module */
|
||||
/*
|
||||
|
||||
OFTEN USED INTERGER MACROS
|
||||
|
||||
Min and Max functions
|
||||
|
||||
*/
|
||||
#ifndef HTMIN
|
||||
#define HTMIN(a,b) ((a) <= (b) ? (a) : (b))
|
||||
#define HTMAX(a,b) ((a) >= (b) ? (a) : (b))
|
||||
#endif
|
||||
/*
|
||||
|
||||
Double abs function
|
||||
|
||||
*/
|
||||
#ifndef HTDABS
|
||||
#define HTDABS(a) ((a) < 0.0 ? (-(a)) : (a))
|
||||
#endif
|
||||
/*
|
||||
|
||||
RETURN CODES FOR PROTOCOL MODULES AND STREAMS
|
||||
|
||||
Theese are the codes returned from the protocol modules, and the stream modules.
|
||||
Success are (>=0) and failure are (<0)
|
||||
|
||||
*/
|
||||
#define HT_OK 0 /* Generic success */
|
||||
#define HT_ALL 1 /* Used by Net Manager */
|
||||
|
||||
#define HT_CONTINUE 29991 /* Continue an operation */
|
||||
#define HT_CLOSED 29992 /* The socket was closed */
|
||||
#define HT_PERSISTENT 29993 /* Wait for persistent connection */
|
||||
#define HT_IGNORE 29994 /* Ignore this in the Net manager */
|
||||
#define HT_NO_DATA 29995 /* OK but no data was loaded */
|
||||
#define HT_RELOAD 29996 /* If we must reload the document */
|
||||
#define HT_PERM_REDIRECT 29997 /* Redo the retrieve with a new URL */
|
||||
#define HT_TEMP_REDIRECT 29998 /* Redo the retrieve with a new URL */
|
||||
#define HT_LOADED 29999 /* Instead of a socket */
|
||||
|
||||
#define HT_ERROR -1 /* Generic failure */
|
||||
|
||||
#define HT_NO_ACCESS -10 /* Access not available */
|
||||
#define HT_FORBIDDEN -11 /* Access forbidden */
|
||||
#define HT_RETRY -13 /* If service isn't available */
|
||||
#define HT_NO_PROXY_ACCESS -14 /* No proxy access */
|
||||
|
||||
#define HT_INTERNAL -100 /* Weird -- should never happen. */
|
||||
|
||||
#define HT_WOULD_BLOCK -29997 /* If we are in a select */
|
||||
#define HT_INTERRUPTED -29998 /* Note the negative value! */
|
||||
#define HT_PAUSE -29999 /* If we want to pause a stream */
|
||||
/*
|
||||
|
||||
UPPER- AND LOWERCASE MACROS
|
||||
|
||||
The problem here is that toupper(x) is not defined officially unless isupper(x) is.
|
||||
These macros are CERTAINLY needed on #if defined(pyr) || define(mips) or BDSI
|
||||
platforms. For safefy, we make them mandatory.
|
||||
|
||||
*/
|
||||
/* #ifndef TOLOWER */
|
||||
/* #define TOLOWER(c) tolower(c) */
|
||||
/* #define TOUPPER(c) toupper(c) */
|
||||
#define TOUPPER(x) ((((PRUint32) (x)) > 0x7f) ? x : toupper(x))
|
||||
/* #endif */
|
||||
/*
|
||||
|
||||
MAX AND MIN VALUES FOR INTEGERS AND FLOATING POINT
|
||||
|
||||
*/
|
||||
#ifdef FLT_EPSILON /* The ANSI C way define */
|
||||
#define HT_EPSILON FLT_EPSILON
|
||||
#else
|
||||
#define HT_EPSILON 0.00000001
|
||||
#endif
|
||||
/*
|
||||
|
||||
WHITE CHARACTERS
|
||||
|
||||
Is character _c_ white space?
|
||||
|
||||
*/
|
||||
/* #define WHITE(c) isspace(c) */
|
||||
#define WHITE(c) isspace(c)
|
||||
/*
|
||||
|
||||
THE LOCAL EQUIVALENTS OF CR AND LF
|
||||
|
||||
We can check for these after net ascii text has been converted to the local
|
||||
representation. Similarly, we include them in strings to be sent as net ascii after
|
||||
translation.
|
||||
|
||||
*/
|
||||
/* #define LF FROMASCII('\012') */ /* ASCII line feed LOCAL EQUIVALENT */
|
||||
/* #define CR FROMASCII('\015') */ /* Will be converted to ^M for transmission */
|
||||
/*
|
||||
|
||||
LIBRARY DYNAMIC MEMORY MAGEMENT
|
||||
|
||||
The Library has it's own dynamic memory API which is declared in memory management
|
||||
module.
|
||||
|
||||
*/
|
||||
#include "htmemory.h"
|
||||
/*
|
||||
|
||||
*/
|
||||
#endif /* HT_UTILS.h */
|
||||
/*
|
||||
|
||||
|
||||
___________________________________
|
||||
|
||||
@(#) $Id: htutils.h,v 1.2 1999-05-07 05:26:12 neeti%netscape.com Exp $
|
||||
|
||||
*/
|
Загрузка…
Ссылка в новой задаче