]> Pileus Git - ~andy/fetchmail/blob - rcfile_y.y
Licensing and copyright changes pursuant to Carl Harris handing me the
[~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:       poprc_y.y
9   project:      popclient
10   programmer:   Carl Harris, ceharris@mal.com
11                 Extensively hacked and fixed by esr.
12   description:  .poprc parser
13
14  ***********************************************************************/
15
16 #include <config.h>
17 #include <stdio.h>
18 extern char *prc_pathname;
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
33 %token KW_REMOTEFOLDER KW_LOCALFOLDER KW_MDA KW_EOL KW_DEFAULTS
34 %token <proto> PROTO_POP2 PROTO_POP3 PROTO_IMAP PROTO_APOP PROTO_RPOP
35 %token <sval> PARAM_STRING
36 %token <flag> KW_KEEP KW_FLUSH KW_FETCHALL
37 %type <proto> proto;
38
39 %%
40
41 rcfile:         rcline
42         |       rcfile rcline
43   ;
44
45 rcline:         statement KW_EOL
46   ;
47
48 statement:
49         |       define_server                   {prc_register(); prc_reset();}
50   ;
51
52 define_server:  KW_SERVER PARAM_STRING server_options   {prc_setserver($2);}    
53         |       KW_SERVER PARAM_STRING                  {prc_setserver($2);}
54         |       KW_DEFAULTS server_options      {prc_setserver("defaults");}
55   ;
56
57 server_options: serv_option_clause
58         |       server_options serv_option_clause
59   ;
60
61 serv_option_clause: 
62                 KW_PROTOCOL proto               {prc_setproto($2);}
63         |       KW_USERNAME PARAM_STRING        {prc_setusername($2);}
64         |       KW_PASSWORD PARAM_STRING        {prc_setpassword($2);}
65         |       KW_REMOTEFOLDER PARAM_STRING    {prc_setremote($2);}
66         |       KW_LOCALFOLDER PARAM_STRING     {prc_setlocal($2);}
67         |       KW_MDA PARAM_STRING             {prc_setmda($2);}
68         |       KW_KEEP                         {prc_setkeep($1);}
69         |       KW_FLUSH                        {prc_setflush($1);}
70         |       KW_FETCHALL                     {prc_setfetchall($1);}
71   ;
72
73 proto:          PROTO_POP2
74         |       PROTO_POP3
75         |       PROTO_IMAP
76         |       PROTO_APOP
77         |       PROTO_RPOP
78   ;
79
80 %%
81
82
83 yyerror (s)
84 char *s;
85 {
86   fprintf(stderr,"%s line %d: %s at %s\n", prc_pathname, prc_lineno, s, yytext);
87   prc_errflag++;
88 }