Index: dlg.c =================================================================== --- dlg.c (revision 31285) +++ dlg.c (revision 31286) @@ -137,7 +137,7 @@ role = save_rolee[ri]; nd = rnd_conf_lht_get_at_mainplug(role, ctx->path, 1, 0); if (nd == NULL) { - MKDIR_RULE_ROOT(nd, role, return); + MKDIR_RULE_ROOT(nd, role, RND_POL_OVERWRITE, return); MKDIR_RULES(nd, return); if ((nd->data.list.first == NULL) && (role != RND_CFR_USER)) { gdl_iterator_t it; @@ -442,13 +442,11 @@ do { \ if (*row->cell[1] != '\0') { \ const char *basename = rule_basename(row->cell[0]); \ - char *path = rnd_concat(DRC_CONF_PATH_RULES, basename, ":0", NULL); \ - nd = rnd_conf_lht_get_at_mainplug(role, path, 1, 0); \ + pcb_drc_query_rule_by_name(basename, &nd, 0); \ if (nd == NULL) { \ - rnd_message(RND_MSG_ERROR, "internal error: rule not found at %s\n", path); \ + rnd_message(RND_MSG_ERROR, "internal error: rule %s not found\n", basename); \ return; \ } \ - free(path); \ } \ else \ return; \ Index: drc_query.c =================================================================== --- drc_query.c (revision 31285) +++ drc_query.c (revision 31286) @@ -401,9 +401,9 @@ MKDIR_ND(nd, nd, LHT_LIST, "rules", errinstr); \ } while(0) -#define MKDIR_RULE_ROOT(nd, role, errinst) \ +#define MKDIR_RULE_ROOT(nd, role, pol, errinst) \ do { \ - nd = rnd_conf_lht_get_first(role, 1); \ + nd = rnd_conf_lht_get_first_crpol(role, pol, 1); \ if (nd == NULL) { \ rnd_message(RND_MSG_ERROR, "Internal error: failed to create role root, rule is NOT saved\n"); \ errinst; \ @@ -410,22 +410,29 @@ } \ } while(0) -static int pcb_drc_query_rule_by_name(const char *name, rnd_conf_native_t **nat_out, lht_node_t **nd_out, int do_create) +static int pcb_drc_query_rule_by_name(const char *name, lht_node_t **nd_out, int do_create) { - char *path = rnd_concat(DRC_CONF_PATH_RULES, name, NULL); - rnd_conf_native_t *nat = rnd_conf_get_field(path); - lht_node_t *nd = NULL; +/* char *path = rnd_concat(DRC_CONF_PATH_RULES, name, NULL);*/ + lht_node_t *n = NULL, *nd = NULL; int ret = -1, needs_update = 0; + gdl_iterator_t it; + rnd_conf_listitem_t *i; + rnd_conflist_foreach(&conf_drc_query.plugins.drc_query.rules, &it, i) { + n = i->prop.src; + if ((n != NULL) && (strcmp(n->name, name) == 0)) { + nd = n; + break; + } + } + if (!do_create) { - if (nat != NULL) { - nd = nat->prop[0].src; + if (nd != NULL) ret = 0; - } } else { - if (nat == NULL) { /* allocate new node */ - MKDIR_RULE_ROOT(nd, RND_CFR_DESIGN, goto skip); + if (nd == NULL) { /* allocate new node */ + MKDIR_RULE_ROOT(nd, RND_CFR_DESIGN, RND_POL_APPEND, goto skip); MKDIR_RULES(nd, goto skip); MKDIR_ND(nd, nd, LHT_HASH, name, goto skip); if (nd == NULL) /* failed to create */ @@ -442,10 +449,8 @@ rnd_conf_update(NULL, -1); skip:; - free(path); +/* free(path);*/ - if (nat_out != NULL) - *nat_out = nat; if (nd_out != NULL) *nd_out = nd; @@ -462,7 +467,7 @@ { lht_node_t *nd; - if (pcb_drc_query_rule_by_name(rule, NULL, &nd, 1) != 0) + if (pcb_drc_query_rule_by_name(rule, &nd, 1) != 0) return -1; /* do not re-create existing rule, force creating a new */ return 0; @@ -472,7 +477,7 @@ { lht_node_t *nd; - if (pcb_drc_query_rule_by_name(rule, NULL, &nd, 0) != 0) + if (pcb_drc_query_rule_by_name(rule, &nd, 0) != 0) return -1; MKDIR_ND_SET_TEXT(nd, rule, key, val -1); @@ -484,7 +489,7 @@ { lht_node_t *nd; - if (pcb_drc_query_rule_by_name(rule, NULL, &nd, 0) != 0) + if (pcb_drc_query_rule_by_name(rule, &nd, 0) != 0) return -1; res->type = FGW_STR;