Remove unused private implementation of strtok_r b=253794 p=mark@standard8.demon.co.uk sr=bienvenu

This commit is contained in:
neil%parkwaycc.co.uk 2005-01-03 12:45:28 +00:00
Родитель 56a49bbc45
Коммит f7b753a0bd
2 изменённых файлов: 0 добавлений и 152 удалений

Просмотреть файл

@ -110,79 +110,6 @@ typedef enum
XP_FILE_URL_PATH XP_PlatformFileToURL (const XP_FILE_NATIVE_PATH ) {return NULL;}
/*************************************************
The following functions are used to implement
a thread safe strtok
*************************************************/
/*
* Get next token from string *stringp, where tokens are (possibly empty)
* strings separated by characters from delim. Tokens are separated
* by exactly one delimiter iff the skip parameter is false; otherwise
* they are separated by runs of characters from delim, because we
* skip over any initial `delim' characters.
*
* Writes NULs into the string at *stringp to end tokens.
* delim will usually, but need not, remain CONSTant from call to call.
* On return, *stringp points past the last NUL written (if there might
* be further tokens), or is NULL (if there are definitely no more tokens).
*
* If *stringp is NULL, strtoken returns NULL.
*/
static
char *strtoken_r(char ** stringp, const char *delim, PRInt32 skip)
{
char *s;
const char *spanp;
PRInt32 c, sc;
char *tok;
if ((s = *stringp) == NULL)
return (NULL);
if (skip) {
/*
* Skip (span) leading delimiters (s += strspn(s, delim)).
*/
cont:
c = *s;
for (spanp = delim; (sc = *spanp++) != 0;) {
if (c == sc) {
s++;
goto cont;
}
}
if (c == 0) { /* no token found */
*stringp = NULL;
return (NULL);
}
}
/*
* Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
*/
tok = s;
while ((c = *s++)) {
for (spanp = delim; (sc = *spanp++);) {
if (sc == c) {
s[-1] = 0;
*stringp = s;
return( (char *) tok );
}
}
}
*stringp = NULL;
return( (char *) tok );
}
char *AB_pstrtok_r(char *s1, const char *s2, char **lasts)
{
if (s1)
*lasts = s1;
return (strtoken_r(lasts, s2, 1));
}
/*****************************************************************************
* Private structs and stuff
*/
@ -2379,81 +2306,6 @@ static nsresult DIR_AddCustomAttribute(DIR_Server *server, const char *attrName,
return status;
}
PRInt32 DIR_GetNumAttributeIDsForColumns(DIR_Server * server)
{
PRInt32 count = 0;
char * buffer = nsnull;
char * marker = nsnull;
if (server && server->columnAttributes)
{
buffer = nsCRT::strdup(server->columnAttributes);
if (buffer)
{
marker = buffer;
while (AB_pstrtok_r(0, ", ", &buffer))
count++;
PR_FREEIF(marker);
}
}
return count;
}
/* caller must free returned list of ids */
nsresult DIR_GetAttributeIDsForColumns(DIR_Server *server, DIR_AttributeId ** ids, PRInt32 * numIds)
{
DIR_AttributeId * idArray = nsnull;
nsresult status = NS_OK;
PRInt32 numAdded = 0; /* number of ids we actually added to the array...*/
PRInt32 indx = 0;
PRInt32 numItems = 0;
char * idName = nsnull;
char * marker = nsnull;
char * columnIDs = nsnull;
if (server && numIds && ids)
{
if (server->columnAttributes)
{
columnIDs = nsCRT::strdup(server->columnAttributes);
numItems = DIR_GetNumAttributeIDsForColumns(server);
}
if (columnIDs && numItems)
{
marker = columnIDs;
idArray = (DIR_AttributeId *) PR_Malloc(sizeof(DIR_AttributeId) * numItems);
if (idArray)
{
for (indx = 0; indx < numItems; indx++)
{
idName = AB_pstrtok_r(0,", ",&marker);
if (idName)
{
status = DIR_AttributeNameToId(server, idName, &idArray[numAdded]);
if (NS_SUCCEEDED(status))
numAdded++;
}
else
break;
}
}
else
status = NS_ERROR_OUT_OF_MEMORY;
}
PR_FREEIF(columnIDs);
}
if (ids)
*ids = idArray;
if (numIds)
*numIds = numAdded;
return status;
}
static nsresult dir_CreateTokenListFromWholePref(const char *pref, char ***outList, PRInt32 *outCount)
{
nsresult result = NS_OK;

Просмотреть файл

@ -361,10 +361,6 @@ PRBool DIR_IsUriAttribute (DIR_Server *s, const char *attrib);
nsresult DIR_AttributeNameToId (DIR_Server *server, const char *attrName, DIR_AttributeId *id);
PRInt32 DIR_GetNumAttributeIDsForColumns(DIR_Server * server);
/* caller must free returned list of ids */
nsresult DIR_GetAttributeIDsForColumns(DIR_Server *server, DIR_AttributeId ** ids , PRInt32 * numIds);
/* APIs for authentication */
void DIR_SetAuthDN (DIR_Server *s, const char *dn);
void DIR_SetPassword (DIR_Server *s, const char *password);