openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/shadow/4.6-r0/shadow-4.6/lib/subordinateio.c
static void* subordinate_parse(const char* line)
{
    static struct subordinate_range range;
    static char rangebuf[1024];
    int i;
    char* cp;
    char* fields[NFIELDS];

    /*
     * Copy the string to a temporary buffer so the substrings can
     * be modified to be NULL terminated.
     */
    if (strlen(line) >= sizeof rangebuf)
        return NULL; /* fail if too long */
    strcpy(rangebuf, line);

    /*
     * Save a pointer to the start of each colon separated
     * field.  The fields are converted into NUL terminated strings.
     */

    for (cp = rangebuf, i = 0; (i < NFIELDS) && (NULL != cp); i++)
    {
        fields[i] = cp;
        while (('\0' != *cp) && (':' != *cp))
        {
            cp++;
        }

        if ('\0' != *cp)
        {
            *cp = '\0';
            cp++;
        }
        else
        {
            cp = NULL;
        }
    }

    /*
     * There must be exactly NFIELDS colon separated fields or
     * the entry is invalid.  Also, fields must be non-blank.
     */
    if (i != NFIELDS || *fields[0] == '\0' || *fields[1] == '\0' ||
        *fields[2] == '\0')
        return NULL;
    range.owner = fields[0];
    if (getulong(fields[1], &range.start) == 0)
        return NULL;
    if (getulong(fields[2], &range.count) == 0)
        return NULL;

    return &range;
}
/*
 * subordinate_parse:
 *
 * @line: a line to parse
 *
 * Returns a pointer to a subordinate_range struct representing the values
 * in @line, or NULL on failure.  Note that the returned value should not
 * be freed by the caller.
 */
@line: a line to parse

Returns a pointer to a subordinate_range struct representing the values
in @line, or NULL on failure.  Note that the returned value should not
be freed by the caller.
@line : a line to parse Returns a pointer to a subordinate_range struct representing the values in @line or NULL on failure . Note that the returned value should not be freed by the caller .
static void* subordinate_parse(const char* line)
{
    static struct subordinate_range range;
    static char rangebuf[1024];
    int i;
    char* cp;
    char* fields[NFIELDS];
    if (strlen(line) >= sizeof rangebuf)
        return NULL; 
    strcpy(rangebuf, line);
    for (cp = rangebuf, i = 0; (i < NFIELDS) && (NULL != cp); i++)
    {
        fields[i] = cp;
        while (('\0' != *cp) && (':' != *cp))
        {
            cp++;
        }
        if ('\0' != *cp)
        {
            *cp = '\0';
            cp++;
        }
        else
        {
            cp = NULL;
        }
    }
    if (i != NFIELDS || *fields[0] == '\0' || *fields[1] == '\0' ||
        *fields[2] == '\0')
        return NULL;
    range.owner = fields[0];
    if (getulong(fields[1], &range.start) == 0)
        return NULL;
    if (getulong(fields[2], &range.count) == 0)
        return NULL;
    return &range;
}
static void * subordinate_parse ( const char * line ) { static struct subordinate_range range ; static char rangebuf [ 1024 ] ; int i ; char * cp ; char * fields [ NFIELDS ] ; if ( strlen ( line ) >= sizeof rangebuf ) return NULL ; strcpy ( rangebuf , line ) ; for ( cp = rangebuf , i = 0 ; ( i < NFIELDS ) && ( NULL != cp ) ; i ++ ) { fields [ i ] = cp ; while ( ( ' \0 ' != * cp ) && ( ' ' != * cp ) ) { cp ++ ; } if ( ' \0 ' != * cp ) { * cp = ' \0 ' ; cp ++ ; } else { cp = NULL ; } } if ( i != NFIELDS || * fields [ 0 ] == ' \0 ' || * fields [ 1 ] == ' \0 ' || * fields [ 2 ] == ' \0 ' ) return NULL ; range . owner = fields [ 0 ] ; if ( getulong ( fields [ 1 ] , & range . start ) == 0 ) return NULL ; if ( getulong ( fields [ 2 ] , & range . count ) == 0 ) return NULL ; return & range ; }
subordinate_parse:
 @line: a line to parse
subordinate_parse : @line : a line to parse
/*
     * Copy the string to a temporary buffer so the substrings can
     * be modified to be NULL terminated.
     */ /* fail if too long */ /*
     * Save a pointer to the start of each colon separated
     * field.  The fields are converted into NUL terminated strings.
     */ /*
     * There must be exactly NFIELDS colon separated fields or
     * the entry is invalid.  Also, fields must be non-blank.
     */