Ejemplo n.º 1
0
/*
 * find the end of the current tag/value pair. string should be pointing just
 * after the equal sign. Handles quoted characters.
 */
const char *
NSSUTIL_ArgFindEnd(const char *string)
{
    char endChar = ' ';
    PRBool lastEscape = PR_FALSE;

    if (NSSUTIL_ArgIsQuote(*string)) {
        endChar = NSSUTIL_ArgGetPair(*string);
        string++;
    }

    for (; *string; string++) {
        if (lastEscape) {
            lastEscape = PR_FALSE;
            continue;
        }
        if (NSSUTIL_ArgIsEscape(*string) && !lastEscape) {
            lastEscape = PR_TRUE;
            continue;
        }
        if ((endChar == ' ') && NSSUTIL_ArgIsBlank(*string))
            break;
        if (*string == endChar) {
            break;
        }
    }

    return string;
}
Ejemplo n.º 2
0
const char *
NSSUTIL_ArgStrip(const char *c)
{
    while (*c && NSSUTIL_ArgIsBlank(*c))
        c++;
    return c;
}
static PRBool nssutil_argHasBlanks(char *v)
{
   for ( ;*v; v++) {
        if (NSSUTIL_ArgIsBlank(*v)) return PR_TRUE;
   }
   return PR_FALSE;
}
Ejemplo n.º 4
0
/*
 * parameters are tag value pairs. This function returns the tag or label (the
 * value before the equal size.
 */
char *
NSSUTIL_ArgGetLabel(const char *inString, int *next)
{
    char *name = NULL;
    const char *string;
    int len;

    /* look for the end of the <label>= */
    for (string = inString; *string; string++) {
        if (*string == '=') {
            break;
        }
        if (NSSUTIL_ArgIsBlank(*string))
            break;
    }

    len = string - inString;

    *next = len;
    if (*string == '=')
        (*next) += 1;
    if (len > 0) {
        name = PORT_Alloc(len + 1);
        PORT_Strncpy(name, inString, len);
        name[len] = 0;
    }
    return name;
}
/*
 * point to the next parameter in string
 */
char *
NSSUTIL_ArgSkipParameter(char *string) 
{
     char *end;
     /* look for the end of the <name>= */
     for (;*string; string++) {
	if (*string == '=') { string++; break; }
	if (NSSUTIL_ArgIsBlank(*string)) return(string); 
     }

     end = NSSUTIL_ArgFindEnd(string);
     if (*end) end++;
     return end;
}