static var_t * exp_eval_variable(exp_t *exp, var_t *mailspec) { var_t *value; char *name; if (exp->ex_type != EX_VARIABLE) { log_debug("exp_eval_variable: bad type"); return NULL; } name = exp->ex_data; value = acl_variable_get(mailspec, name); if (value == NULL) { log_debug("exp_eval_variable: %s not set", name); return EXP_EMPTY; } return value; }
static var_t * hitlist_record(hitlist_t *hl, var_t *attrs, int load_data) { ll_entry_t *pos; var_t *key; char *keystr; var_t *v; var_t *schema = NULL; VAR_INT_T zero = 0; char *name; name = hl->hl_table? hl->hl_table: hl->hl_name; schema = vlist_create(name, VF_KEEPNAME); if (schema == NULL) { log_error("hitlist_schema: vlist_create failed"); goto error; } pos = LL_START(hl->hl_keys); while ((key = ll_next(hl->hl_keys, &pos))) { // Impossible if (key->v_data == NULL) { log_error("hitlist_schema: key is NULL"); goto error; } // Bad configured if (key->v_type != VT_STRING) { log_error("hitlist_scheme: bad configuration %s:" " hitlist keys must be strings.", hl->hl_name); goto error; } keystr = key->v_data; // Variables if (keystr[0] == '$') { v = acl_variable_get(attrs, keystr); } // Regular symbol else { v = acl_symbol_get(attrs, keystr); } if (v == NULL) { log_error("hitlist_scheme: %s: lookup %s failed", hl->hl_name, keystr); goto error; } if (load_data && v->v_data == NULL) { log_error("hitlist_scheme: %s: key %s is NULL", hl->hl_name, keystr); goto error; } if (vlist_append_new(schema, v->v_type, keystr, load_data? v->v_data: NULL, VF_COPY | VF_KEY)) { log_error("hitlist_schema: %s: vlist_append_new" " failed", hl->hl_name); goto error; } } // Add value if (vlist_append_new(schema, VT_INT, hl->hl_value_field, load_data? &zero: NULL, VF_COPY)) { log_error("hitlist_schema: %s: vlist_append_new failed for %s", hl->hl_name, hl->hl_value_field); goto error; } if (vlist_append_new(schema, VT_INT, hl->hl_expire_field, load_data? &zero: NULL, VF_COPY)) { log_error("hitlist_schema: %s: vlist_append_new failed for %s", hl->hl_name, hl->hl_expire_field); goto error; } return schema; error: if (schema != NULL) { var_delete(schema); } return NULL; }