Exemple #1
0
static void parse_listener(config_t *c, config_line_t *l, lwan_t *lwan)
{
    lwan->config.listener = strdup(l->section.param);

    while (config_read_line(c, l)) {
        switch (l->type) {
        case CONFIG_LINE_TYPE_LINE:
            config_error(c, "Expecting prefix section");
            return;
        case CONFIG_LINE_TYPE_SECTION:
            if (!strcmp(l->section.name, "prefix")) {
                parse_listener_prefix(c, l, lwan, NULL);
            } else {
                const lwan_module_t *module = lwan_module_find(lwan, l->section.name);
                if (!module) {
                    config_error(c, "Invalid section name or module not found: %s",
                        l->section.name);
                } else {
                    parse_listener_prefix(c, l, lwan, module);
                }
            }
            break;
        case CONFIG_LINE_TYPE_SECTION_END:
            return;
        }
    }

    config_error(c, "Expecting section end while parsing listener");
}
Exemple #2
0
static void parse_listener(struct config *c, struct config_line *l,
                           struct lwan *lwan)
{
    free(lwan->config.listener);
    lwan->config.listener = strdup(l->value);

    while (config_read_line(c, l)) {
        switch (l->type) {
        case CONFIG_LINE_TYPE_LINE:
            config_error(c, "Expecting prefix section");
            return;
        case CONFIG_LINE_TYPE_SECTION:
            if (streq(l->key, "prefix")) {
                parse_listener_prefix(c, l, lwan, NULL, NULL);
                continue;
            }

            if (l->key[0] == '&') {
                l->key++;

                void *handler = find_handler(l->key);
                if (handler) {
                    parse_listener_prefix(c, l, lwan, NULL, handler);
                    continue;
                }

                config_error(c, "Could not find handler name: %s", l->key);
                return;
            }

            const struct lwan_module *module = find_module(l->key);
            if (module) {
                parse_listener_prefix(c, l, lwan, module, NULL);
                continue;
            }

            config_error(c, "Invalid section or module not found: %s", l->key);
            return;
        case CONFIG_LINE_TYPE_SECTION_END:
            return;
        }
    }

    config_error(c, "Expecting section end while parsing listener");
}
Exemple #3
0
static void parse_listener(config_t *c, config_line_t *l, lwan_t *lwan)
{
    lwan->config.port = parse_int(l->section.param, 8080);

    while (config_read_line(c, l)) {
        switch (l->type) {
        case CONFIG_LINE_TYPE_LINE:
            config_error(c, "Expecting prefix section");
            return;
        case CONFIG_LINE_TYPE_SECTION:
            if (!strcmp(l->section.name, "prefix"))
                parse_listener_prefix(c, l, lwan);
            else
                config_error(c, "Unknown section type: %s", l->section.name);
            break;
        case CONFIG_LINE_TYPE_SECTION_END:
            return;
        }
    }

    config_error(c, "Expecting section end while parsing listener");
}