/[monit]/monit/l.l
ViewVC logotype

Diff of /monit/l.l

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

revision 1.53 by martinp, Wed Aug 27 01:42:40 2003 UTC revision 1.54 by chopp, Fri Aug 29 14:41:19 2003 UTC
# Line 51  Line 51 
51    /* Prototypes */    /* Prototypes */
52    void yyerror(const char*);    void yyerror(const char*);
53    static char *handle_quoted_string(char *);    static char *handle_quoted_string(char *);
54      void steplinenobycr(char *);
55          
56  %}  %}
57    
58  ws          [ \t]+  ws          [ \t]+
# Line 224  check[ \t]+device { Line 225  check[ \t]+device {
225                      return CHECKDEV;                      return CHECKDEV;
226                    }                    }
227    
228  check[ \t]+file {  check[ \t]+file   {
229                      BEGIN(SERVICE_COND);                      BEGIN(SERVICE_COND);
230                      return CHECKFILE;                      return CHECKFILE;
231                    }                    }
# Line 248  check[ \t]+directory { Line 249  check[ \t]+directory {
249                            prog, yytext);                            prog, yytext);
250                        exit(1);                        exit(1);
251                      }                      }
252                       return PERCENT;                      return PERCENT;
253                    }                    }
254    
255  [a-zA-Z0-9]{str}  {  [a-zA-Z0-9]{str}  {
# Line 256  check[ \t]+directory { Line 257  check[ \t]+directory {
257                      return STRING;                      return STRING;
258                    }                    }
259    
260  \"[/][^"\n]*["\n] {  \"[/][^\"\n]*\"   {
261                      yylval.string= handle_quoted_string(yytext);                      yylval.string= handle_quoted_string(yytext);
262                      return PATH;                      return PATH;
263                    }                    }
264    
265  \'[/][^'\n]*['\n] {  \'[/][^\'\n]*\'   {
266                      yylval.string= handle_quoted_string(yytext);                      yylval.string= handle_quoted_string(yytext);
267                      return PATH;                      return PATH;
268                    }                    }
269    
270  ["'][^'"\n]*["'\n] {  \"[^\"]*\"        {
271                        steplinenobycr(yytext);
272                        yylval.string= handle_quoted_string(yytext);
273                        return STRING;
274                      }
275    
276    \'[^\']*\'        {
277                        steplinenobycr(yytext);
278                      yylval.string= handle_quoted_string(yytext);                      yylval.string= handle_quoted_string(yytext);
279                      return STRING;                      return STRING;
280                    }                    }
# Line 286  check[ \t]+directory { Line 294  check[ \t]+directory {
294                       return PATH;                       return PATH;
295                    }                    }
296    
297  "from:"[ \t\n]*{str}[@]{str} {  "from:"[ \t]*{str}[@]{str} {
298                        char *p= yytext+strlen("from:");                        char *p= yytext+strlen("from:");
299                        yylval.string = trim(xstrdup(p));                        yylval.string = trim(xstrdup(p));
300                        return MAILFROM;                        return MAILFROM;
# Line 300  check[ \t]+directory { Line 308  check[ \t]+directory {
308    
309  "message:"[^}]*   {  "message:"[^}]*   {
310                        char *p= yytext+strlen("message:");                        char *p= yytext+strlen("message:");
311    
312                          steplinenobycr(yytext);
313    
314                        yylval.string = trim(xstrdup(p));                        yylval.string = trim(xstrdup(p));
315                        return MAILBODY;                        return MAILBODY;
316                    }                    }
# Line 309  check[ \t]+directory { Line 320  check[ \t]+directory {
320                        return STRING;                        return STRING;
321                    }                    }
322    
323    [\"\']            {
324    
325                          yyerror("Unbalanced quotes");
326    
327                      }
328    
329    
330  <SERVICE_COND>{  <SERVICE_COND>{
331    
332    {ws}            ;    {ws}            ;
# Line 317  check[ \t]+directory { Line 335  check[ \t]+directory {
335                      lineno++;                      lineno++;
336                    }                    }
337    
338    [^ \n\t]+       {    {str}           {
339                      yylval.string= xstrdup(yytext);                      yylval.string= xstrdup(yytext);
340                      BEGIN(INITIAL);                      BEGIN(INITIAL);
341                      return SERVICENAME;                      return SERVICENAME;
342                    }                    }
343    
344      \"{str}\"       {
345                        yylval.string= handle_quoted_string(yytext);
346                        BEGIN(INITIAL);
347                        return SERVICENAME;
348                      }
349    
350      \'{str}\'       {
351                        yylval.string= handle_quoted_string(yytext);
352                        BEGIN(INITIAL);
353                        return SERVICENAME;
354                      }
355    
356      [\"\']          {
357                          yyerror("Unbalanced quotes");
358                      }
359    
360  }  }
361    
362  <DEPEND_COND>{  <DEPEND_COND>{
363    
364    {wws}           ;    {wws}           ;
365    
366   {wws}?[\n]{wws}? {    {wws}?[\n]{wws}? {
367                      lineno++;                      lineno++;
368                    }                    }
369    
370    [^ \n\t,]+      {    {str}           {
371                      yylval.string= xstrdup(yytext);                      yylval.string= xstrdup(yytext);
372                      return SERVICENAME;                      return SERVICENAME;
373                    }                    }
374    
375    [ \n\t]+[^,]    {    [ \n\t]+[^,]    {
376                      lineno++;                      steplinenobycr(yytext);
377    
378                      unput(yytext[strlen(yytext)-1]);                      unput(yytext[strlen(yytext)-1]);
379                      BEGIN(INITIAL);                      BEGIN(INITIAL);
380                    }                    }
# Line 358  check[ \t]+directory { Line 393  check[ \t]+directory {
393                        BEGIN(INITIAL);                        BEGIN(INITIAL);
394                    }                    }
395    
396    \'[^']*\'       {    \'[^\']*\'      {
397                          steplinenobycr(yytext);
398                        yylval.string= handle_quoted_string(yytext);                        yylval.string= handle_quoted_string(yytext);
399                        return STRING;                        return STRING;
400                    }                    }
# Line 367  check[ \t]+directory { Line 403  check[ \t]+directory {
403                        yyerror("Unbalanced quotes");                        yyerror("Unbalanced quotes");
404                    }                    }
405    
406    \{[^}]*\}       {      \{[^\}]*\}      {  /*
407                          * This helps constructions like:
408                          *   /bin/bash -c { cmd1; cmd2;..cmdn; }
409                          */
410                          steplinenobycr(yytext);
411                        yylval.string= xstrdup(yytext);                        yylval.string= xstrdup(yytext);
412                        return STRING;                        return STRING;
413                    }                    }
414    
415    [^ \t\n"]+      {    [^ \t\n\{\}]+     {
416                        yylval.string= xstrdup(yytext);                        yylval.string= xstrdup(yytext);
417                        return STRING;                        return STRING;
418                    }                    }
# Line 386  check[ \t]+directory { Line 426  check[ \t]+directory {
426    
427  %%  %%
428    
429    /*
430     * Do lineno++ for every occurrence of '\n' in a string.  This is
431     * necessary whenever a yytext has an unknown number of CRs.
432     */
433    
434    void steplinenobycr(char *string) {
435    
436      char *pos=string;
437    
438      while ( 0 != *pos ) {
439    
440        if ( '\n' == *pos ) {
441    
442          lineno++;
443    
444        }
445    
446        pos++;
447    
448      }
449    
450    }
451    
452  static char *handle_quoted_string(char *string) {  static char *handle_quoted_string(char *string) {
453    
454    char *buf= xstrdup(string);    char *buf= xstrdup(string);

Legend:
Removed from v.1.53  
changed lines
  Added in v.1.54

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