872d0b65adda6793766a626ca878eb1d3aa4235b
[debian/amanda] / recover-src / uparse.y
1 /*
2  * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3  * Copyright (c) 1991-1998, 2000 University of Maryland at College Park
4  * All Rights Reserved.
5  *
6  * Permission to use, copy, modify, distribute, and sell this software and its
7  * documentation for any purpose is hereby granted without fee, provided that
8  * the above copyright notice appear in all copies and that both that
9  * copyright notice and this permission notice appear in supporting
10  * documentation, and that the name of U.M. not be used in advertising or
11  * publicity pertaining to distribution of the software without specific,
12  * written prior permission.  U.M. makes no representations about the
13  * suitability of this software for any purpose.  It is provided "as is"
14  * without express or implied warranty.
15  *
16  * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
18  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22  *
23  * Authors: the Amanda Development Team.  Its members are listed in a
24  * file named AUTHORS, in the root directory of this distribution.
25  */
26 /*
27  * $Id: uparse.y,v 1.11 2003/01/01 23:28:17 martinea Exp $
28  *
29  * parser for amrecover interactive language
30  */
31 %{
32 #include "amanda.h"
33 #include "amrecover.h"
34
35 void yyerror P((char *s));
36 extern int yylex P((void));
37 %}
38
39 /* DECLARATIONS */
40 %union {
41   int intval;
42   double floatval;
43   char *strval;
44   int subtok;
45 }
46
47         /* literal keyword tokens */
48
49 %token LISTDISK SETHOST SETDISK SETDATE SETTAPE SETMODE
50 %token CD CDX QUIT DHIST LS ADD ADDX EXTRACT
51 %token LIST DELETE DELETEX PWD CLEAR HELP LCD LPWD MODE SMB TAR
52
53         /* typed tokens */
54
55 %token <strval> PATH
56 %token <strval> DATE
57
58
59 /* GRAMMAR */
60 %%
61
62 ucommand:
63         set_command
64   |     display_command
65   |     quit_command
66   |     add_command
67   |     addx_command
68   |     delete_command
69   |     deletex_command
70   |     local_command
71   |     help_command
72   |     extract_command
73   ;
74
75 set_command:
76         LISTDISK PATH { list_disk($2); amfree($2); }
77   |     LISTDISK { list_disk(NULL); }
78   |     SETDATE DATE { set_date($2); amfree($2); }
79   |     SETHOST PATH { set_host($2); amfree($2); }
80   |     SETDISK PATH PATH { set_disk($2, $3); amfree($2); amfree($3); }
81   |     SETDISK PATH { set_disk($2, NULL); amfree($2); }
82   |     SETTAPE PATH { set_tape($2); amfree($2); }
83   |     SETTAPE { set_tape(""); }
84   |     CD PATH { cd_glob($2); amfree($2); }
85   |     CDX PATH { cd_regex($2); amfree($2); }
86   |     SETMODE SMB {
87 #ifdef SAMBA_CLIENT
88                          set_mode(SAMBA_SMBCLIENT);
89 #endif /* SAMBA_CLIENT */
90                     }
91   |     SETMODE TAR {
92 #ifdef SAMBA_CLIENT
93                          set_mode(SAMBA_TAR);
94 #endif /* SAMBA_CLIENT */
95                     }
96   ;
97
98 display_command:
99         DHIST { list_disk_history(); }
100   |     LS { list_directory(); }
101   |     LIST PATH { display_extract_list($2); amfree($2); }
102   |     LIST { display_extract_list(NULL); }
103   |     PWD { show_directory(); }
104   |     CLEAR { clear_extract_list(); }    
105   |     MODE { show_mode (); }
106   ;
107
108 quit_command:
109         QUIT { quit(); }
110   ;
111
112 add_command:
113         ADD add_path
114   ;
115
116 add_path:
117         add_path PATH { add_glob($2); amfree($2); }
118   |     PATH { add_glob($1); amfree($1); }
119   ;
120
121 addx_command:
122         ADDX addx_path
123   ;
124
125 addx_path:
126         addx_path PATH { add_regex($2); amfree($2); }
127   |     PATH { add_regex($1); amfree($1); }
128   ;
129
130 delete_command:
131         DELETE delete_path
132   ;
133
134 delete_path:
135         delete_path PATH { delete_glob($2); amfree($2); }
136   |     PATH { delete_glob($1); amfree($1); }
137   ;
138
139 deletex_command:
140         DELETEX deletex_path
141   ;
142
143 deletex_path:
144         deletex_path PATH { delete_regex($2); amfree($2); }
145   |     PATH { delete_regex($1); amfree($1); }
146   ;
147
148 local_command:
149         LPWD { char buf[STR_SIZE]; puts(getcwd(buf, sizeof(buf))); }
150   |     LCD PATH {
151                 if (chdir($2) == -1) {
152                         perror($2);
153                 }
154                 amfree($2);
155         }
156   ;
157
158 help_command:
159         HELP { help_list(); }
160   ;
161
162 extract_command:
163         EXTRACT { extract_files(); }
164   ;
165
166 /* ADDITIONAL C CODE */
167 %%
168
169 void yyerror(s)
170 char *s;
171 {
172   printf("Invalid command - %s\n", s);
173 }
174
175