static gboolean enabled = TRUE;
static gchar *name = NULL;
+static gint account_id = 0;
static MatcherList *cond;
static GSList *action_list = NULL;
static FilteringAction *action = NULL;
MATCHER_PARSE_NO_EOL,
MATCHER_PARSE_ENABLED,
MATCHER_PARSE_NAME,
+ MATCHER_PARSE_ACCOUNT,
MATCHER_PARSE_CONDITION,
MATCHER_PARSE_FILTERING_ACTION,
};
void matcher_parser_start_parsing(FILE *f)
{
matcher_parserrestart(f);
+ account_id = 0;
matcher_parserparse();
}
return cond;
}
+MatcherList *matcher_parser_get_enabled(gchar *str)
+{
+ void *bufstate;
+
+ if (!check_quote_symetry(str)) {
+ cond = NULL;
+ return cond;
+ }
+
+ /* bad coding to enable the sub-grammar matching
+ in yacc */
+ matcher_parserlineno = 1;
+ matcher_parse_op = MATCHER_PARSE_ENABLED;
+ matcher_parserrestart(NULL);
+ matcher_parser_init();
+ bufstate = matcher_parser_scan_string(str);
+ matcher_parserparse();
+ matcher_parse_op = MATCHER_PARSE_FILE;
+ matcher_parser_delete_buffer(bufstate);
+ return cond;
+}
+
+MatcherList *matcher_parser_get_account(gchar *str)
+{
+ void *bufstate;
+
+ if (!check_quote_symetry(str)) {
+ cond = NULL;
+ return cond;
+ }
+
+ /* bad coding to enable the sub-grammar matching
+ in yacc */
+ matcher_parserlineno = 1;
+ matcher_parse_op = MATCHER_PARSE_ACCOUNT;
+ matcher_parserrestart(NULL);
+ matcher_parser_init();
+ bufstate = matcher_parser_scan_string(str);
+ matcher_parserparse();
+ matcher_parse_op = MATCHER_PARSE_FILE;
+ matcher_parser_delete_buffer(bufstate);
+ return cond;
+}
+
MatcherList *matcher_parser_get_cond(gchar *str)
{
void *bufstate;
%token MATCHER_ENABLED MATCHER_DISABLED
%token MATCHER_RULENAME
+%token MATCHER_ACCOUNT
%token <str> MATCHER_STRING
%token <str> MATCHER_SECTION
%token <str> MATCHER_INTEGER
;
instruction:
-enabled name condition filtering MATCHER_EOL
+enabled name account condition filtering MATCHER_EOL
+| enabled name account condition filtering
+| enabled name condition filtering MATCHER_EOL
| enabled name condition filtering
| name condition filtering MATCHER_EOL
| name condition filtering
if (matcher_parse_op == MATCHER_PARSE_NO_EOL)
YYACCEPT;
else {
- matcher_parsererror("parse error a");
+ matcher_parsererror("parse error [no eol]");
YYERROR;
}
}
if (matcher_parse_op == MATCHER_PARSE_ENABLED)
YYACCEPT;
else {
- matcher_parsererror("parse error enabled");
+ matcher_parsererror("parse error [enabled]");
+ YYERROR;
+ }
+}
+| account
+{
+ if (matcher_parse_op == MATCHER_PARSE_ACCOUNT)
+ YYACCEPT;
+ else {
+ matcher_parsererror("parse error [account]");
YYERROR;
}
}
if (matcher_parse_op == MATCHER_PARSE_NAME)
YYACCEPT;
else {
- matcher_parsererror("parse error b");
+ matcher_parsererror("parse error [name]");
YYERROR;
}
}
if (matcher_parse_op == MATCHER_PARSE_CONDITION)
YYACCEPT;
else {
- matcher_parsererror("parse error c");
+ matcher_parsererror("parse error [condition]");
YYERROR;
}
}
if (matcher_parse_op == MATCHER_PARSE_FILTERING_ACTION)
YYACCEPT;
else {
- matcher_parsererror("parse error d");
+ matcher_parsererror("parse error [filtering action]");
YYERROR;
}
}
}
;
+account:
+MATCHER_ACCOUNT MATCHER_INTEGER
+{
+ account_id = strtol($2, NULL, 10);
+fprintf(stderr, "parser %d\n", account_id);
+fflush(stderr);
+}
+;
+
filtering:
filtering_action_list
{
- filtering = filteringprop_new(enabled, name, cond, action_list);
+ filtering = filteringprop_new(enabled, name, account_id, cond, action_list);
enabled = TRUE;
+ account_id = 0;
g_free(name);
name = NULL;
if (enable_compatibility) {