/* * Returns 0 ok, 1 deprecated action, 2 rule error, * 3 multiple rule insert/delete */ static int audit_rule_setup(char *opt, int *filter, int *act, int lineno) { int rc; char *p; if (++multiple != 1) return 3; p = strchr(opt, ','); if (p == NULL || strchr(p+1, ',')) return 2; *p = 0; /* Try opt both ways */ if (lookup_filter(opt, filter) == 2) { rc = lookup_action(opt, act); if (rc != 0) { *p = ','; return rc; } } /* Repair the string */ *p = ','; opt = p+1; /* If flags are empty, p+1 must be the filter */ if (*filter == AUDIT_FILTER_UNSET) lookup_filter(opt, filter); else { rc = lookup_action(opt, act); if (rc != 0) return rc; } /* Make sure we set both */ if (*filter == AUDIT_FILTER_UNSET || *act == -1) return 2; /* Consolidate rules on exit filter */ if (*filter == AUDIT_FILTER_ENTRY) { *filter = AUDIT_FILTER_EXIT; fprintf(stderr, "Warning - entry rules deprecated, changing to exit rule"); if (lineno) fprintf(stderr, " in line %d", lineno); fprintf(stderr, "\n"); } return 0; }
void start_parsing_filter (mathmap_t *mathmap, top_level_decl_t *decl) { filter_t *filter; g_assert(mathmap->current_filter == NULL); if (lookup_filter(mathmap->filters, decl->name) != NULL) { sprintf(error_string, _("Filter `%s' is defined more than once."), decl->name); error_region = decl->region; JUMP(1); } filter = g_new0(filter_t, 1); filter->kind = FILTER_MATHMAP; filter->name = g_strdup(decl->name); filter->v.mathmap.decl = decl; init_internals(filter); filter->next = mathmap->filters; mathmap->filters = filter; mathmap->current_filter = filter; }
exprtree* make_function (scanner_ident_t *name_ident, exprtree *args) { char *name = name_ident->str; scanner_region_t name_region = name_ident->region; exprtree *tree = 0; exprtree *arg; function_arg_info_t *first, *last; overload_entry_t *entry; tuple_info_t info; if (lookup_userval(the_mathmap->current_filter->userval_infos, name) != 0) { userval_info_t *info = lookup_userval(the_mathmap->current_filter->userval_infos, name); return make_userval(info, args, name_region); } if (lookup_filter(the_mathmap->filters, name) != 0) { filter_t *filter = lookup_filter(the_mathmap->filters, name); return make_filter_call(filter, args, name_region); } first = last = (function_arg_info_t*)malloc(sizeof(function_arg_info_t)); arg = args; last->info = arg->result; last->next = 0; while (arg->next != 0) { arg = arg->next; last = last->next = (function_arg_info_t*)malloc(sizeof(function_arg_info_t)); last->info = arg->result; last->next = 0; } entry = resolve_function_call(name, first, &info); if (entry != 0) { if (entry->type == OVERLOAD_BUILTIN) { int is_constant = 1; for (arg = args; arg != 0; arg = arg->next) if (arg->type != EXPR_TUPLE_CONST) { is_constant = 0; break; } tree = alloc_exprtree(); tree->type = EXPR_FUNC; tree->val.func.entry = entry; tree->val.func.args = args; tree->result = info; } else if (entry->type == OVERLOAD_MACRO) tree = entry->v.macro(args); else g_assert_not_reached(); tree->region = scanner_region_merge(name_region, exprlist_region(args)); } else if (lookup_variable(the_mathmap->current_filter->v.mathmap.variables, name, &info)) { variable_t *var = lookup_variable(the_mathmap->current_filter->v.mathmap.variables, name, &info); if (info.number != image_tag_number || info.length != 1) { sprintf(error_string, _("Variable %s is not an image and cannot be invoked."), name); error_region = name_region; JUMP(1); } return make_image_call(make_var_exprtree(var, info, name_region), args, name_region); } else { const char *op_name = get_op_name_for_func(name); if (op_name) sprintf(error_string, _("Unable to resolve invocation of operator `%s'."), op_name); else sprintf(error_string, _("Unable to resolve invocation of function `%s'."), name); error_region = name_region; JUMP(1); } return tree; }