Пример #1
0
void cmdline_parse(const char *cmdline, const cmdline_option_t *options,
                          char vals[][MAX_VALUE_LEN])
{
    const char *p = cmdline;
    int i;

    /* copy default values to vals[] */
    for ( i = 0; options[i].name != NULL; i++ ) {
        vmm_strncpy(vals[i], options[i].def_val, MAX_VALUE_LEN-1);
        vals[i][MAX_VALUE_LEN-1] = '\0';
    }

    if ( p == NULL )
        return;

    /* parse options */
    while ( 1 ) {
        /* skip whitespace */
        while ( isspace(*p) )
            p++;
        if ( *p == '\0' )
            break;

        /* find end of current option */
        const char *opt_start = p;
        const char *opt_end = (const char*)vmm_strchr(opt_start, ' ');
        if ( opt_end == NULL )
            opt_end = opt_start + vmm_strlen(opt_start);
        p = opt_end;

        /* find value part; if no value found, use default and continue */
        const char *val_start = vmm_strchr(opt_start, '=');
        if ( val_start == NULL || val_start > opt_end )
            continue;
        val_start++;

        unsigned int opt_name_size = val_start - opt_start - 1;
        unsigned int copy_size = opt_end - val_start;
        if ( copy_size > MAX_VALUE_LEN - 1 )
            copy_size = MAX_VALUE_LEN - 1;
        if ( opt_name_size == 0 || copy_size == 0 )
            continue;

        /* value found, so copy it */
        for ( i = 0; options[i].name != NULL; i++ ) {
            if ( vmm_strncmp(options[i].name, opt_start, opt_name_size ) == 0 ) {
                vmm_strncpy(vals[i], val_start, copy_size);
                vals[i][copy_size] = '\0'; /* add '\0' to the end of string */
                break;
            }
        }
    }
}
Пример #2
0
static physical_addr_t acpi_get_table_base(const char * name)
{
    int i;

    for(i = 0; i < acpi_ctxt->nr_sys_hdr; i++) {
        if (vmm_strncmp(name, acpi_ctxt->sdt_trans[i].signature,
                        SDT_SIGN_LEN) == 0)
            return acpi_ctxt->rsdt->data[i];
    }

    return 0;
}
Пример #3
0
size_t acpi_get_table_length(const char * name)
{
    int i;

    for(i = 0; i < acpi_ctxt->nr_sys_hdr; i++) {
        if (vmm_strncmp(name, acpi_ctxt->sdt_trans[i].signature,
                        SDT_SIGN_LEN) == 0)
            return acpi_ctxt->sdt_trans[i].length;
    }

    return 0;
}
Пример #4
0
static int acpi_check_signature(const char *orig, const char *match)
{
    return vmm_strncmp(orig, match, SDT_SIGN_LEN);
}