openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/util-linux/2.33.2-r0/util-linux-2.33.2/libmount/src/optstr.c
int mnt_optstr_get_options(const char* optstr, char** subset,
                           const struct libmnt_optmap* map, int ignore)
{
    struct libmnt_optmap const* maps[1];
    char *name, *val, *str = (char*)optstr;
    size_t namesz, valsz;

    if (!optstr || !subset)
        return -EINVAL;

    maps[0] = map;
    *subset = NULL;

    while (!mnt_optstr_next_option(&str, &name, &namesz, &val, &valsz))
    {
        int rc = 0;
        const struct libmnt_optmap* ent;

        mnt_optmap_get_entry(maps, 1, name, namesz, &ent);

        if (!ent || !ent->id)
            continue; /* ignore undefined options (comments) */

        if (ignore && (ent->mask & ignore))
            continue;

        /* ignore name=<value> if options map expects <name> only */
        if (valsz && mnt_optmap_entry_novalue(ent))
            continue;

        rc = __mnt_optstr_append_option(subset, name, namesz, val, valsz);
        if (rc)
        {
            free(*subset);
            return rc;
        }
    }

    return 0;
}
/**
 * mnt_optstr_get_options
 * @optstr: string with a comma separated list of options
 * @subset: returns newly allocated string with options
 * @map: options map
 * @ignore: mask of the options that should be ignored
 *
 * Extracts options from @optstr that belong to the @map, for example:
 *
 *	 mnt_optstr_get_options(optstr, &p,
 *			mnt_get_builtin_optmap(MNT_LINUX_MAP),
 *			MNT_NOMTAB);
 *
 * the 'p' returns all VFS options, the options that do not belong to mtab
 * are ignored.
 *
 * Returns: 0 on success, or a negative number in case of error.
 */
mnt_optstr_get_options
@optstr: string with a comma separated list of options
@subset: returns newly allocated string with options
@map: options map
@ignore: mask of the options that should be ignored

Extracts options from @optstr that belong to the @map, for example.



the 'p' returns all VFS options, the options that do not belong to mtab
are ignored.

0 on success, or a negative number in case of error.
mnt_optstr_get_options @optstr : string with a comma separated list of options @subset : returns newly allocated string with options @map : options map @ignore : mask of the options that should be ignored Extracts options from @optstr that belong to the @map for example . the ' p ' returns all VFS options the options that do not belong to mtab are ignored . 0 on success or a negative number in case of error .
int mnt_optstr_get_options(const char* optstr, char** subset,
                           const struct libmnt_optmap* map, int ignore)
{
    struct libmnt_optmap const* maps[1];
    char *name, *val, *str = (char*)optstr;
    size_t namesz, valsz;
    if (!optstr || !subset)
        return -EINVAL;
    maps[0] = map;
    *subset = NULL;
    while (!mnt_optstr_next_option(&str, &name, &namesz, &val, &valsz))
    {
        int rc = 0;
        const struct libmnt_optmap* ent;
        mnt_optmap_get_entry(maps, 1, name, namesz, &ent);
        if (!ent || !ent->id)
            continue; 
        if (ignore && (ent->mask & ignore))
            continue;
        if (valsz && mnt_optmap_entry_novalue(ent))
            continue;
        rc = __mnt_optstr_append_option(subset, name, namesz, val, valsz);
        if (rc)
        {
            free(*subset);
            return rc;
        }
    }
    return 0;
}
int mnt_optstr_get_options ( const char * optstr , char * * subset , const struct libmnt_optmap * map , int ignore ) { struct libmnt_optmap const * maps [ 1 ] ; char * name , * val , * str = ( char * ) optstr ; size_t namesz , valsz ; if ( ! optstr || ! subset ) return - EINVAL ; maps [ 0 ] = map ; * subset = NULL ; while ( ! mnt_optstr_next_option ( & str , & name , & namesz , & val , & valsz ) ) { int rc = 0 ; const struct libmnt_optmap * ent ; mnt_optmap_get_entry ( maps , 1 , name , namesz , & ent ) ; if ( ! ent || ! ent -> id ) continue ; if ( ignore && ( ent -> mask & ignore ) ) continue ; if ( valsz && mnt_optmap_entry_novalue ( ent ) ) continue ; rc = __mnt_optstr_append_option ( subset , name , namesz , val , valsz ) ; if ( rc ) { free ( * subset ) ; return rc ; } } return 0 ; }
mnt_optstr_get_options
 @optstr: string with a comma separated list of options
 @subset: returns newly allocated string with options
 @map: options map
 @ignore: mask of the options that should be ignored
mnt_optstr_get_options @optstr : string with a comma separated list of options @subset : returns newly allocated string with options @map : options map @ignore : mask of the options that should be ignored
/* ignore undefined options (comments) */ /* ignore name=<value> if options map expects <name> only */