X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=recover-src%2Fuparse.y;h=72ae6eb784e8475abd16a989993413c6a5ba2c7d;hb=21170aaf9015a4c519265834456fc309932f24c0;hp=3624cce669447c63f62c346bde13e3038540643d;hpb=3ab887b9bc819a846c75dd7f2ee5d41fac22b19f;p=debian%2Famanda diff --git a/recover-src/uparse.y b/recover-src/uparse.y index 3624cce..72ae6eb 100644 --- a/recover-src/uparse.y +++ b/recover-src/uparse.y @@ -24,7 +24,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: uparse.y,v 1.5.4.2.4.1.2.3 2003/01/01 23:28:52 martinea Exp $ + * $Id: uparse.y,v 1.13 2006/05/25 01:47:14 johnfranks Exp $ * * parser for amrecover interactive language */ @@ -32,22 +32,24 @@ #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 */ @@ -70,17 +72,27 @@ ucommand: | 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 { @@ -146,11 +158,9 @@ deletex_path: ; 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); } ; @@ -166,10 +176,9 @@ extract_command: /* ADDITIONAL C CODE */ %% -void yyerror(s) -char *s; +void +yyerror( + char * s) { - printf("Invalid command - %s\n", s); + g_printf("%s\n", s); } - -