* file named AUTHORS, in the root directory of this distribution.
*/
/*
- * $Id: uparse.y,v 1.11 2003/01/01 23:28:17 martinea Exp $
+ * $Id: uparse.y,v 1.13 2006/05/25 01:47:14 johnfranks Exp $
*
* parser for amrecover interactive language
*/
#include "amanda.h"
#include "amrecover.h"
-void yyerror P((char *s));
-extern int yylex P((void));
+void yyerror(char *s);
+extern int yylex(void);
+extern char * yytext;
+
%}
/* DECLARATIONS */
%union {
- int intval;
- double floatval;
- char *strval;
- int subtok;
+ int intval;
+ double floatval;
+ char * strval;
+ int subtok;
}
/* literal keyword tokens */
-%token LISTDISK SETHOST SETDISK SETDATE SETTAPE SETMODE
-%token CD CDX QUIT DHIST LS ADD ADDX EXTRACT
+%token LISTHOST LISTDISK SETHOST SETDISK SETDATE SETTAPE SETMODE SETDEVICE
+%token CD CDX QUIT DHIST LS ADD ADDX EXTRACT DASH_H
%token LIST DELETE DELETEX PWD CLEAR HELP LCD LPWD MODE SMB TAR
/* typed tokens */
| local_command
| help_command
| extract_command
+ | {
+ char * errstr = vstralloc("Invalid command: ", yytext, NULL);
+ yyerror(errstr);
+ amfree(errstr);
+ YYERROR;
+ } /* Quiets compiler warnings about unused label */
;
set_command:
- LISTDISK PATH { list_disk($2); amfree($2); }
+ LISTHOST { list_host(); }
+ | LISTDISK PATH { list_disk($2); amfree($2); }
| LISTDISK { list_disk(NULL); }
| SETDATE DATE { set_date($2); amfree($2); }
| SETHOST PATH { set_host($2); amfree($2); }
| SETDISK PATH PATH { set_disk($2, $3); amfree($2); amfree($3); }
| SETDISK PATH { set_disk($2, NULL); amfree($2); }
| SETTAPE PATH { set_tape($2); amfree($2); }
- | SETTAPE { set_tape(""); }
+ | SETTAPE { set_tape("default"); }
+ | SETDEVICE PATH { set_device(NULL, $2); }
+ | SETDEVICE DASH_H PATH PATH { set_device($3, $4); }
+ | SETDEVICE { set_device(NULL, NULL); }
| CD PATH { cd_glob($2); amfree($2); }
| CDX PATH { cd_regex($2); amfree($2); }
| SETMODE SMB {
;
local_command:
- LPWD { char buf[STR_SIZE]; puts(getcwd(buf, sizeof(buf))); }
+ LPWD { char * buf= g_get_current_dir(); puts(buf); free(buf); }
| LCD PATH {
- if (chdir($2) == -1) {
- perror($2);
- }
+ local_cd($2);
amfree($2);
}
;
/* ADDITIONAL C CODE */
%%
-void yyerror(s)
-char *s;
+void
+yyerror(
+ char * s)
{
- printf("Invalid command - %s\n", s);
+ g_printf("%s\n", s);
}
-
-