Beispiel #1
0
static void
load_acl(struct Configuration *cfg, const struct ConfParse *parse, const struct CF_Child *parent)
{
    struct CF_Token value = confparse_node_gettoken(parse, parent, 1);
    struct Cfg_AddrMatchList *acl;

    /* address-lists must be named when inside an "acl" statement */
    if (value.name_length == 0) {
        CONF_VALUE_MISSING(parse, &value);
        return;
    }

    /* parse the address-list */
    acl = conf_load_addrlist(cfg, parse, parent, &value, 65536);
    if (acl == NULL)
        return;

    /* make sure it has a name */
    acl->name = malloc(value.name_length + 1);
    memcpy(acl->name, value.name, value.name_length + 1);
    
    /*
     * Add to our named set of address-lists. This is so that later
     * configuration parameters can refer back to this list rather than
     * redefining their own
     */
    if (cfg->acls_length == 0)
        cfg->acls = malloc(sizeof(cfg->acls[0]));
    else
        cfg->acls = realloc(cfg->acls, sizeof(cfg->acls[0]) * (cfg->acls_length + 1));
    

    cfg->acls[cfg->acls_length++] = acl;

}
Beispiel #2
0
void
conf_load_zone( struct Configuration *cfg, 
                const struct ConfParse *parse, 
                const struct CF_Child *parent)
{
    struct CF_Token value = confparse_node_gettoken(parse, parent, 1);
    struct Cfg_Zone *zone;
    size_t i;

    if (value.name_length == 0) {
        CONF_VALUE_MISSING(parse, &value);
        return;
    }

    zone = conf_zone_create(value.name, value.name_length);

    /*
     * Parse all the options
     */
    for (i=0; i<parent->child_count; i++) {
        struct CF_Child child = confparse_node_getchild(parse, parent, i);

        conf_load_zone_item(cfg, parse, &child, zone);
    }

    /*
     * Add to our list of zones
     */
    if (cfg->zones_length == 0)
        cfg->zones = malloc(sizeof(cfg->zones[0]));
    else
        cfg->zones = realloc(cfg->zones, sizeof(cfg->zones[0]) * (cfg->zones_length + 1));
    cfg->zones[cfg->zones_length++] = zone;
}