]> Pileus Git - ~andy/fetchmail/blob - rcfile_y.y
Remove same name dependencies.
[~andy/fetchmail] / rcfile_y.y
1 %{
2 /* Copyright 1993-95 by Carl Harris, Jr. Copyright 1996 by Eric S. Raymond
3  * All rights reserved.
4  * For license terms, see the file COPYING in this directory.
5  */
6
7 /***********************************************************************
8   module:       rcfile_y.y
9   project:      fetchmail
10   programmer:   Carl Harris, ceharris@mal.com
11                 Extensively hacked and fixed by esr.
12   description:  configuration file parser
13
14  ***********************************************************************/
15
16 #include <config.h>
17 #include <stdio.h>
18 extern char *rcfile;
19 extern int prc_lineno;
20 extern int prc_errflag;
21 extern char *yytext;
22
23 int yydebug;    /* in case we didn't generate with -- debug */
24 %}
25
26 %union {
27   int proto;
28   int flag;
29   char *sval;
30 }
31
32 %token KW_SERVER KW_PROTOCOL KW_USERNAME KW_PASSWORD KW_RPOPID
33 %token KW_REMOTEFOLDER KW_LOCALFOLDER KW_SMTPHOST KW_MDA KW_EOL KW_DEFAULTS
34 %token <proto> PROTO_AUTO PROTO_POP2 PROTO_POP3 PROTO_IMAP PROTO_APOP PROTO_RPOP
35 %token <sval> PARAM_STRING
36 %token <flag> KW_KEEP KW_FLUSH KW_FETCHALL KW_REWRITE KW_PORT
37 %type <proto> proto;
38
39 /* these are actually used by the lexer */
40 %token TRUE     1
41 %token FALSE    0
42
43 %%
44
45 rcfile:         rcline
46         |       rcfile rcline
47   ;
48
49 rcline:         statement KW_EOL
50   ;
51
52 statement:
53         |       define_server                   {prc_register(); prc_reset();}
54   ;
55
56 define_server:  KW_SERVER PARAM_STRING server_options   {prc_setserver($2);}
57         |       KW_SERVER PARAM_STRING                  {prc_setserver($2);}
58         |       KW_DEFAULTS server_options      {prc_setserver("defaults");}
59   ;
60
61 server_options: serv_option_clause
62         |       server_options serv_option_clause
63   ;
64
65 serv_option_clause: 
66                 KW_PROTOCOL proto               {prc_setproto($2);}
67         |       KW_USERNAME PARAM_STRING        {prc_remotename($2);}
68         |       KW_PASSWORD PARAM_STRING        {prc_setpassword($2);}
69         |       KW_RPOPID PARAM_STRING          {prc_setrpopid($2);}
70         |       KW_REMOTEFOLDER PARAM_STRING    {prc_setremote($2);}
71         |       KW_LOCALFOLDER PARAM_STRING     {prc_setlocal($2);}
72         |       KW_SMTPHOST PARAM_STRING        {prc_setsmtphost($2);}
73         |       KW_MDA PARAM_STRING             {prc_setmda($2);}
74         |       KW_KEEP                         {prc_setkeep($1);}
75         |       KW_FLUSH                        {prc_setflush($1);}
76         |       KW_FETCHALL                     {prc_setfetchall($1);}
77         |       KW_REWRITE                      {prc_setrewrite($1);}
78         |       KW_PORT PARAM_STRING            {prc_setport($2);}
79   ;
80
81 proto:          PROTO_POP2
82         |       PROTO_POP3
83         |       PROTO_IMAP
84         |       PROTO_APOP
85         |       PROTO_RPOP
86   ;
87
88 %%
89
90
91 yyerror (s)
92 char *s;
93 {
94   fprintf(stderr,"%s line %d: %s at %s\n", rcfile, prc_lineno, s, yytext);
95   prc_errflag++;
96 }