%{ /* cfg.l - configuration language */ /* Written 1995-1999 by Werner Almesberger, EPFL-LRC/ICA */ #if HAVE_CONFIG_H #include #endif #include #include #include #include #include "atm.h" #include "cfg_y.h" static int lineno = 1; static int token; /* f@#%ing flex doesn't grok return after BEGIN */ void yyerror(const char *s); void yywarn(const char *s); %} %s N %s P %s R %% BEGIN(N); level return TOK_LEVEL; debug return TOK_DEBUG; info return TOK_INFO; warn return TOK_WARN; error return TOK_ERROR; fatal return TOK_FATAL; sig return TOK_SIG; uni30 return TOK_UNI30; uni31 return TOK_UNI31; uni40 return TOK_UNI40; [qQ].2963.1 return TOK_Q2963_1; mode return TOK_MODE; user return TOK_USER; network return TOK_NET; switch return TOK_SWITCH; saal return TOK_SAAL; vc return TOK_VC; io return TOK_IO; itf return TOK_ITF; vpci return TOK_VPCI; pcr return TOK_PCR; policy return TOK_POLICY; allow return TOK_ALLOW; reject return TOK_REJECT; entity return TOK_ENTITY; default return TOK_DEFAULT; dump { BEGIN(P); token = TOK_DUMP_DIR; } log { BEGIN(P); token = TOK_LOGFILE; } qos { BEGIN(P); /* syntacticly close to a path */ token = TOK_QOS; } from { BEGIN(P); /* syntacticly close to a path */ token = TOK_FROM; } to { BEGIN(P); /* syntacticly close to a path */ token = TOK_TO; } route { BEGIN(P); /* syntacticly close to a path */ token = TOK_ROUTE; } max_rate { BEGIN(R); /* rate */ token = TOK_MAX_RATE; } trace return TOK_TRACE; [0-9]+ { char *end; yylval.num = strtoul(yytext,&end,10); if (*end) yyerror("invalid number"); return TOK_NUMBER; } [0-9]+\.[0-9]+(\.[0-9]+)? { if (text2atm(yytext,(struct sockaddr *) &yylval.pvc, sizeof(yylval.pvc),T2A_PVC) < 0) yyerror("invalid signaling channel"); return TOK_PVC; }

[^\t\n ]+ { BEGIN(N); yylval.str = strdup(yytext); /* tiny leak ... */ if (!yylval.str) { perror("strdup"); exit(1); } return token; } [0-9]+\.?[0-9]*[\t ]*([kKmMgG]?[bBcC][pP][sS])? { const char *text; BEGIN(N); text = yytext; yylval.num = __t2q_get_rate(&text,1); if (yylval.num < 0) yyerror("invalid rate"); return token; } \n?[\t ]* lineno += *yytext == '\n'; #[^\n]*\n lineno++; . return *yytext; %% void yywarn(const char *s) { fprintf(stderr,"line %d: %s near \"%s\"\n",lineno,s,yytext); } void yyerror(const char *s) { yywarn(s); exit(1); }