Annotation of embedaddon/bird/sysdep/unix/config.Y, revision 1.1

1.1     ! misho       1: /*
        !             2:  *     BIRD -- UNIX Configuration
        !             3:  *
        !             4:  *     (c) 1999--2000 Martin Mares <mj@ucw.cz>
        !             5:  *
        !             6:  *     Can be freely distributed and used under the terms of the GNU GPL.
        !             7:  */
        !             8: 
        !             9: CF_HDR
        !            10: 
        !            11: #include "lib/unix.h"
        !            12: #include <stdio.h>
        !            13: 
        !            14: CF_DECLS
        !            15: 
        !            16: CF_KEYWORDS(LOG, SYSLOG, ALL, DEBUG, TRACE, INFO, REMOTE, WARNING, ERROR, AUTH, FATAL, BUG, STDERR, SOFT)
        !            17: CF_KEYWORDS(TIMEFORMAT, ISO, OLD, SHORT, LONG, BASE, NAME, CONFIRM, UNDO, CHECK, TIMEOUT)
        !            18: CF_KEYWORDS(DEBUG, LATENCY, LIMIT, WATCHDOG, WARNING, TIMEOUT)
        !            19: 
        !            20: %type <i> log_mask log_mask_list log_cat cfg_timeout
        !            21: %type <g> log_file
        !            22: %type <t> cfg_name
        !            23: %type <tf> timeformat_which
        !            24: %type <t> syslog_name
        !            25: 
        !            26: CF_GRAMMAR
        !            27: 
        !            28: CF_ADDTO(conf, log_config)
        !            29: 
        !            30: log_config: LOG log_file log_mask ';' {
        !            31:     struct log_config *c = cfg_allocz(sizeof(struct log_config));
        !            32:     c->fh = $2;
        !            33:     c->mask = $3;
        !            34:     add_tail(&new_config->logfiles, &c->n);
        !            35:   }
        !            36:  ;
        !            37: 
        !            38: syslog_name:
        !            39:    NAME text { $$ = $2; }
        !            40:  | { $$ = bird_name; }
        !            41:  ;
        !            42: 
        !            43: log_file:
        !            44:    text {
        !            45:      FILE *f = tracked_fopen(new_config->pool, $1, "a");
        !            46:      if (!f) cf_error("Unable to open log file `%s': %m", $1);
        !            47:      $$ = f;
        !            48:    }
        !            49:  | SYSLOG syslog_name { $$ = NULL; new_config->syslog_name = $2; }
        !            50:  | STDERR { $$ = stderr; }
        !            51:  ;
        !            52: 
        !            53: log_mask:
        !            54:    ALL { $$ = ~0; }
        !            55:  | '{' log_mask_list '}' { $$ = $2; }
        !            56:  ;
        !            57: 
        !            58: log_mask_list:
        !            59:    log_cat { $$ = 1 << $1; }
        !            60:  | log_mask_list ',' log_cat { $$ = $1 | (1 << $3); }
        !            61:  ;
        !            62: 
        !            63: log_cat:
        !            64:    DEBUG { $$ = L_DEBUG[0]; }
        !            65:  | TRACE { $$ = L_TRACE[0]; }
        !            66:  | INFO { $$ = L_INFO[0]; }
        !            67:  | REMOTE { $$ = L_REMOTE[0]; }
        !            68:  | WARNING { $$ = L_WARN[0]; }
        !            69:  | ERROR { $$ = L_ERR[0]; }
        !            70:  | AUTH { $$ = L_AUTH[0]; }
        !            71:  | FATAL { $$ = L_FATAL[0]; }
        !            72:  | BUG { $$ = L_BUG[0]; }
        !            73:  ;
        !            74: 
        !            75: 
        !            76: CF_ADDTO(conf, mrtdump_base)
        !            77: 
        !            78: mrtdump_base:
        !            79:    MRTDUMP PROTOCOLS mrtdump_mask ';' { new_config->proto_default_mrtdump = $3; }
        !            80:  | MRTDUMP text ';' {
        !            81:      FILE *f = tracked_fopen(new_config->pool, $2, "a");
        !            82:      if (!f) cf_error("Unable to open MRTDump file '%s': %m", $2);
        !            83:      new_config->mrtdump_file = fileno(f);
        !            84:    }
        !            85:  ;
        !            86: 
        !            87: 
        !            88: CF_ADDTO(conf, timeformat_base)
        !            89: 
        !            90: timeformat_which:
        !            91:    ROUTE { $$ = &new_config->tf_route; }
        !            92:  | PROTOCOL { $$ = &new_config->tf_proto; }
        !            93:  | BASE { $$ = &new_config->tf_base; }
        !            94:  | LOG { $$ = &new_config->tf_log; }
        !            95: 
        !            96: timeformat_spec:
        !            97:    timeformat_which TEXT { *$1 = (struct timeformat){$2, NULL, 0}; }
        !            98:  | timeformat_which TEXT expr TEXT { *$1 = (struct timeformat){$2, $4, $3}; }
        !            99:  | timeformat_which ISO SHORT { *$1 = (struct timeformat){"%T", "%F", 20*3600}; }
        !           100:  | timeformat_which ISO LONG  { *$1 = (struct timeformat){"%F %T", NULL, 0}; }
        !           101:  | timeformat_which OLD SHORT { *$1 = (struct timeformat){NULL, NULL, 0}; }
        !           102:  | timeformat_which OLD LONG  { *$1 = (struct timeformat){"%d-%m-%Y %T", NULL, 0}; }
        !           103:  ;
        !           104: 
        !           105: timeformat_base:
        !           106:    TIMEFORMAT timeformat_spec ';'
        !           107:  ;
        !           108: 
        !           109: 
        !           110: CF_ADDTO(conf, debug_unix)
        !           111: 
        !           112: debug_unix:
        !           113:    DEBUG LATENCY bool { new_config->latency_debug = $3; }
        !           114:  | DEBUG LATENCY LIMIT expr_us { new_config->latency_limit = $4; }
        !           115:  | WATCHDOG WARNING expr_us { new_config->watchdog_warning = $3; }
        !           116:  | WATCHDOG TIMEOUT expr_us { new_config->watchdog_timeout = ($3 + 999999) TO_S; }
        !           117:  ;
        !           118: 
        !           119: 
        !           120: /* Unix specific commands */
        !           121: 
        !           122: CF_CLI_HELP(CONFIGURE, ..., [[Reload configuration]])
        !           123: 
        !           124: CF_CLI(CONFIGURE, cfg_name cfg_timeout, [\"<file>\"] [timeout [<sec>]], [[Reload configuration]])
        !           125: { cmd_reconfig($2, RECONFIG_HARD, $3); } ;
        !           126: 
        !           127: CF_CLI(CONFIGURE SOFT, cfg_name cfg_timeout, [\"<file>\"] [timeout [<sec>]], [[Reload configuration and ignore changes in filters]])
        !           128: { cmd_reconfig($3, RECONFIG_SOFT, $4); } ;
        !           129: 
        !           130: /* Hack to get input completion for 'timeout' */
        !           131: CF_CLI_CMD(CONFIGURE TIMEOUT, [<sec>], [[Reload configuration with undo timeout]])
        !           132: CF_CLI_CMD(CONFIGURE SOFT TIMEOUT, [<sec>], [[Reload configuration with undo timeout]])
        !           133: 
        !           134: CF_CLI(CONFIGURE CONFIRM,,, [[Confirm last configuration change - deactivate undo timeout]])
        !           135: { cmd_reconfig_confirm(); } ;
        !           136: 
        !           137: CF_CLI(CONFIGURE UNDO,,, [[Undo last configuration change]])
        !           138: { cmd_reconfig_undo(); } ;
        !           139: 
        !           140: CF_CLI(CONFIGURE CHECK, cfg_name, [\"<file>\"], [[Parse configuration and check its validity]])
        !           141: { cmd_check_config($3); } ;
        !           142: 
        !           143: CF_CLI(DOWN,,, [[Shut the daemon down]])
        !           144: { cmd_shutdown(); } ;
        !           145: 
        !           146: cfg_name:
        !           147:    /* empty */ { $$ = NULL; }
        !           148:  | TEXT
        !           149:  ;
        !           150: 
        !           151: cfg_timeout:
        !           152:    /* empty */ { $$ = 0; }
        !           153:  | TIMEOUT { $$ = UNIX_DEFAULT_CONFIGURE_TIMEOUT; }
        !           154:  | TIMEOUT expr { $$ = $2; }
        !           155:  ;
        !           156: 
        !           157: CF_CODE
        !           158: 
        !           159: CF_END

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>