Beispiel #1
0
static int set_debug_option(
        char *caller_name,
        debug_option *options,
        char *value)
{
    debug_option *op;
    int level;
    char *eq;
    if (NULL != (eq = ss(value,'='))) {
        /* There is an '='. */
        *eq = 0;
        level = gn(eq+1);
    } else if (!('0' <= *value && *value <= '9')) {
        /* name with no '=', default to level 1. */
        level = 1;
    } else {
        /* level with no name, set all options to level. */
        level = gn(value);
        set_all_options(options,level);
        return(0);
    }
    op = find_debug_option(options,value);
    if (NULL != eq) {
        *eq = '=';
    }
    if (NULL != op) {
        /* Got a match. */
        if (NULL != op->level) {
            *(op->level) = level;
        } else {
            /* Value matched an entire sub_table */
            set_all_options(op,level);
        }
        return(0);
    }
    /* Unknown debug option. */
    if (NULL == caller_name) {
        /* Silently ignore it. */
        return(0);
    }
    printk(KERN_ERR "%s: unknown dbg option `%s', valid options are:\n",
           caller_name,value);
    print_all_options(caller_name,options);
    return(1);
}
Beispiel #2
0
static void set_all_options(
        debug_option *options,
        int level)
{
    debug_option *op;
    for (op = options; NULL != op && NULL != op->name; op++) {
        if (NULL == op->sub_table) {
            *(op->level) = level;
        } else {
            set_all_options(op->sub_table,level);
        }
    }
}
Beispiel #3
0
        std::locale generator::generate(std::locale const &base,std::string const &id) const
        {
            if(d->caching_enabled) {
                boost::unique_lock<boost::mutex> guard(d->cached_lock);
                data::cached_type::const_iterator p = d->cached.find(id);
                if(p!=d->cached.end()) {
                    return p->second;
                }
            }
            shared_ptr<localization_backend> backend(d->backend_manager.get());
            set_all_options(backend,id);

            std::locale result = base;
            locale_category_type facets = d->cats;
            character_facet_type chars = d->chars;

            for(locale_category_type facet = per_character_facet_first; facet <= per_character_facet_last && facet!=0; facet <<=1) {
                if(!(facets & facet))
                    continue;
                for(character_facet_type ch = character_first_facet ; ch<=character_last_facet;ch <<=1) {
                    if(!(ch & chars))
                        continue;
                    result = backend->install(result,facet,ch);
                }
            }
            for(locale_category_type facet = non_character_facet_first; facet <= non_character_facet_last && facet!=0; facet <<=1) {
                if(!(facets & facet))
                    continue;
                result = backend->install(result,facet);
            }
            if(d->caching_enabled) {
                boost::unique_lock<boost::mutex> guard(d->cached_lock);
                data::cached_type::const_iterator p = d->cached.find(id);
                if(p==d->cached.end()) {
                    d->cached[id] = result;
                }
            }
            return result;
        }