/[anubis]/anubis/src/rcfile.y
ViewVC logotype

Diff of /anubis/src/rcfile.y

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.18 by gray, Sun Jun 29 15:01:59 2003 UTC revision 1.19 by gray, Mon Jun 30 18:07:15 2003 UTC
# Line 53  static void rc_stmt_destroy(RC_STMT *); Line 53  static void rc_stmt_destroy(RC_STMT *);
53  static void rc_stmt_list_destroy(RC_STMT *);  static void rc_stmt_list_destroy(RC_STMT *);
54  static void rc_stmt_print(RC_STMT *, int);  static void rc_stmt_print(RC_STMT *, int);
55  static int reg_modifier_add(int *, char *);  static int reg_modifier_add(int *, char *);
56    static int check_kw(char *ident);
57    static int is_prog_allowed();
58    
59  static RC_SECTION *rc_section;  static RC_SECTION *rc_section;
60  static int debug_level;  static int debug_level;
61  static int error_count;  static int error_count;
62  static int def_regex_modifier = R_POSIX;  static int def_regex_modifier = R_POSIX;
63    static struct rc_secdef *rc_secdef;
64  %}  %}
65    
66  %union {  %union {
# Line 139  section  : /* empty */ EOL Line 142  section  : /* empty */ EOL
142  begin    : T_BEGIN { verbatim(); } string EOL  begin    : T_BEGIN { verbatim(); } string EOL
143             {             {
144                     $$ = $3;                     $$ = $3;
145                       rc_secdef = anubis_find_section($3);
146             }             }
147           | D_BEGIN EOL           | D_BEGIN EOL
148               {
149                       rc_secdef = anubis_find_section($1);
150               }              
151           ;           ;
152    
153  end      : T_END EOL  end      : T_END EOL
# Line 176  stmt     : /* empty */ EOL Line 183  stmt     : /* empty */ EOL
183    
184  asgn_stmt: keyword meq { verbatim(); } arglist  asgn_stmt: keyword meq { verbatim(); } arglist
185             {             {
186                       if (!check_kw($1)) {
187                               yyerror(_("unknown keyword"));
188                               YYERROR;
189                       }
190    
191                     $$ = rc_stmt_create(rc_stmt_asgn);                     $$ = rc_stmt_create(rc_stmt_asgn);
192                     $$->v.asgn.lhs = $1;                     $$->v.asgn.lhs = $1;
193                     $$->v.asgn.rhs = $4;                     $$->v.asgn.rhs = $4;
# Line 259  key      : regex Line 271  key      : regex
271                     $$.part = HEADER;                     $$.part = HEADER;
272                     $$.key = NULL;                     $$.key = NULL;
273                     $$.string = $2;                     $$.string = $2;
274             }                           }
275           ;           ;
276    
277  opt_key  : /* empty */  opt_key  : /* empty */
# Line 351  modifier   : ':' IDENT Line 363  modifier   : ':' IDENT
363           ;           ;
364    
365  if       : IF  if       : IF
366               {
367                       if (!is_prog_allowed())
368                               YYERROR;
369               }
370           ;           ;
371    
372  fi       : FI  fi       : FI
# Line 367  rule_stmt: rule_start EOL stmtlist DONE Line 383  rule_stmt: rule_start EOL stmtlist DONE
383             }             }
384           ;           ;
385    
386  rule_start: RULE opt_modlist string  rule_start: rule opt_modlist string
387             {             {
388                     $$ = rc_node_create(rc_node_expr);                     $$ = rc_node_create(rc_node_expr);
389                     $$->v.expr.part = HEADER;                     $$->v.expr.part = HEADER;
# Line 377  rule_start: RULE opt_modlist string Line 393  rule_start: RULE opt_modlist string
393             }             }
394           ;           ;
395    
396    rule     : RULE
397               {
398                       if (!is_prog_allowed())
399                               YYERROR;
400               }
401             ;
402    
403  string   : STRING  string   : STRING
404           | IDENT           | IDENT
405           ;           ;
406    
407  inst_stmt: STOP  inst_stmt: STOP
408             {             {
409                       if (!is_prog_allowed())
410                               YYERROR;
411                     $$ = rc_stmt_create(rc_stmt_inst);                     $$ = rc_stmt_create(rc_stmt_inst);
412                     $$->v.inst.opcode = inst_stop;                     $$->v.inst.opcode = inst_stop;
413                     $$->v.inst.part = NIL;                     $$->v.inst.part = NIL;
# Line 392  inst_stmt: STOP Line 417  inst_stmt: STOP
417             }             }
418           | CALL string           | CALL string
419             {             {
420                       if (!is_prog_allowed())
421                               YYERROR;
422                     $$ = rc_stmt_create(rc_stmt_inst);                     $$ = rc_stmt_create(rc_stmt_inst);
423                     $$->v.inst.opcode = inst_call;                     $$->v.inst.opcode = inst_call;
424                     $$->v.inst.key = NULL;                     $$->v.inst.key = NULL;
# Line 401  inst_stmt: STOP Line 428  inst_stmt: STOP
428             }             }
429           | ADD s_msgpart string           | ADD s_msgpart string
430             {             {
431                       if (!is_prog_allowed())
432                               YYERROR;
433                     $$ = rc_stmt_create(rc_stmt_inst);                     $$ = rc_stmt_create(rc_stmt_inst);
434                     $$->v.inst.opcode = inst_add;                     $$->v.inst.opcode = inst_add;
435                     $$->v.inst.part = $2.part;                     $$->v.inst.part = $2.part;
# Line 410  inst_stmt: STOP Line 439  inst_stmt: STOP
439             }             }
440           | REMOVE r_msgpart           | REMOVE r_msgpart
441             {             {
442                       if (!is_prog_allowed())
443                               YYERROR;
444                     $$ = rc_stmt_create(rc_stmt_inst);                     $$ = rc_stmt_create(rc_stmt_inst);
445                     $$->v.inst.opcode = inst_remove;                     $$->v.inst.opcode = inst_remove;
446                     $$->v.inst.part = $2.part;                     $$->v.inst.part = $2.part;
# Line 419  inst_stmt: STOP Line 450  inst_stmt: STOP
450             }             }
451           | MODIFY r_msgpart string_key string           | MODIFY r_msgpart string_key string
452             {             {
453                       if (!is_prog_allowed())
454                               YYERROR;
455                     $$ = rc_stmt_create(rc_stmt_inst);                     $$ = rc_stmt_create(rc_stmt_inst);
456                     $$->v.inst.opcode = inst_modify;                     $$->v.inst.opcode = inst_modify;
457                     $$->v.inst.part = $2.part;                     $$->v.inst.part = $2.part;
# Line 428  inst_stmt: STOP Line 461  inst_stmt: STOP
461             }             }
462           | MODIFY r_msgpart string_key           | MODIFY r_msgpart string_key
463             {             {
464                       if (!is_prog_allowed())
465                               YYERROR;
466                     $$ = rc_stmt_create(rc_stmt_inst);                     $$ = rc_stmt_create(rc_stmt_inst);
467                     $$->v.inst.opcode = inst_modify;                     $$->v.inst.opcode = inst_modify;
468                     $$->v.inst.part = $2.part;                     $$->v.inst.part = $2.part;
# Line 442  inst_stmt: STOP Line 477  inst_stmt: STOP
477    
478  modf_stmt: REGEX modlist  modf_stmt: REGEX modlist
479             {             {
480                       if (!is_prog_allowed())
481                               YYERROR;
482                     def_regex_modifier = $2;                     def_regex_modifier = $2;
483                     $$ = NULL;                     $$ = NULL;
484             }             }
# Line 452  modf_stmt: REGEX modlist Line 489  modf_stmt: REGEX modlist
489  int  int
490  yyerror(char *s)  yyerror(char *s)
491  {  {
492          anubis_error(SOFT, "%s:%d: %s",          anubis_error(SOFT, "%s:%d: %s", cfg_file, cfg_line_num, s);
                      cfg_file, cfg_line_num, s);  
493          error_count++;          error_count++;
494          return 0;          return 0;
495  }  }
# Line 597  rc_node_destroy(RC_NODE *node) Line 633  rc_node_destroy(RC_NODE *node)
633                                    
634          case rc_node_expr:          case rc_node_expr:
635                  free(node->v.expr.key);                  free(node->v.expr.key);
636                  anubis_regex_free(node->v.expr.re);                  anubis_regex_free(&node->v.expr.re);
637          }          }
638          xfree(node);          xfree(node);
639  }  }
# Line 682  rc_cond_destroy(RC_COND *cond) Line 718  rc_cond_destroy(RC_COND *cond)
718  void  void
719  rc_inst_destroy(RC_INST *inst)  rc_inst_destroy(RC_INST *inst)
720  {  {
721          anubis_regex_free(inst->key);          anubis_regex_free(&inst->key);
722          free(inst->key2);          free(inst->key2);
723          free(inst->arg);          free(inst->arg);
724  }  }
# Line 1198  rc_run_section_list(int method, RC_SECTI Line 1234  rc_run_section_list(int method, RC_SECTI
1234                  rc_run_section(method, sec, secdef, NULL, NULL);                  rc_run_section(method, sec, secdef, NULL, NULL);
1235  }  }
1236    
1237    static int
1238    check_kw(char *ident)
1239    {
1240            struct rc_secdef *p = rc_secdef;
1241            int key;
1242            
1243            if (!p)
1244                    p = anubis_find_section("RULE");
1245            return rc_child_lookup(p->child, ident, CF_ALL, &key) != NULL;
1246    }
1247    
1248    static int
1249    is_prog_allowed()
1250    {
1251            struct rc_secdef *p = rc_secdef;
1252            if (!p)
1253                    p = anubis_find_section("RULE");
1254            
1255            if (!p->allow_prog)
1256                    yyerror(_("program is not allowed in this section"));
1257            return p->allow_prog;
1258    }

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26