summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2012-06-28 08:38:43 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2012-06-28 08:38:43 +0200
commit42acc4c0e8fc117b1783dbf194139b844543f7fe (patch)
treedc37a1f290a194dda4ca8b6000980b257453d9da
parent77fee46b90d40e6aa07a6fdc43a6798216c3c5fa (diff)
TestDisk: If user press enter when asked for partition created unde Vista or later, default to yes
-rw-r--r--src/intrfn.c43
-rw-r--r--src/intrfn.h1
-rw-r--r--src/tdiskop.c3
3 files changed, 44 insertions, 3 deletions
diff --git a/src/intrfn.c b/src/intrfn.c
index e5a2018..9929bb1 100644
--- a/src/intrfn.c
+++ b/src/intrfn.c
@@ -988,13 +988,13 @@ void aff_LBA2CHS(const disk_t *disk_car, const unsigned long int pos_LBA)
int ask_YN(WINDOW *window)
{
- char res;
+ int res;
curs_set(1);
wrefresh(window);
do
{
res=toupper(wgetch(window));
- } while((res!=c_NO)&&(res!=c_YES));
+ } while(res!=c_NO && res!=c_YES);
curs_set(0);
wprintw(window,"%c\n",res);
return (res==c_YES);
@@ -1018,6 +1018,45 @@ int ask_confirmation(const char*_format, ...)
return res;
}
+int ask_confirmation_with_default(const int key_default, const char*_format, ...)
+{
+ va_list ap;
+ int res;
+ WINDOW *window=newwin(LINES, COLS, 0, 0); /* full screen */
+ aff_copy(window);
+ va_start(ap,_format);
+ vaff_txt(4, window, _format, ap);
+ va_end(ap);
+ curs_set(1);
+ wrefresh(window);
+ do
+ {
+ res=wgetch(window);
+ switch(res)
+ {
+#ifdef PADENTER
+ case PADENTER:
+#endif
+ case KEY_ENTER:
+ case '\n':
+ case '\r':
+ res=key_default;
+ break;
+ default:
+ res=toupper(res);
+ break;
+ }
+ } while(res!=c_NO && res!=c_YES);
+ curs_set(0);
+ wprintw(window,"%c\n",res);
+ delwin(window);
+ (void) clearok(stdscr, TRUE);
+#ifdef HAVE_TOUCHWIN
+ touchwin(stdscr);
+#endif
+ return (res==c_YES);
+}
+
void not_implemented(const char *msg)
{
WINDOW *window=newwin(LINES, COLS, 0, 0); /* full screen */
diff --git a/src/intrfn.h b/src/intrfn.h
index f6cc759..52d9fe9 100644
--- a/src/intrfn.h
+++ b/src/intrfn.h
@@ -46,6 +46,7 @@ void aff_part(WINDOW *window, const unsigned int newline, const disk_t *disk_car
unsigned long long int ask_number(const unsigned long long int val_cur, const unsigned long long int val_min, const unsigned long long int val_max, const char * _format, ...) __attribute__ ((format (printf, 4, 5)));
int ask_YN(WINDOW *window);
int ask_confirmation(const char*_format, ...) __attribute__ ((format (printf, 1, 2)));
+int ask_confirmation_with_default(const int key_default, const char*_format, ...) __attribute__ ((format (printf, 2, 3)));
int check_enter_key_or_s(WINDOW *window);
void dump2(WINDOW *window, const void *dump_1, const void *dump_2, const unsigned int lng);
void dump(WINDOW *window,const void *nom_dump,unsigned int lng);
diff --git a/src/tdiskop.c b/src/tdiskop.c
index ee9c04f..9bed5ce 100644
--- a/src/tdiskop.c
+++ b/src/tdiskop.c
@@ -181,7 +181,8 @@ static int menu_disk_ncurses(disk_t *disk_car, const int verbose,int dump_ind, c
if(search_vista_part==0)
{
log_info("Ask the user for vista mode\n");
- if(ask_confirmation("Should TestDisk search for partition created under Vista or later ? [Y/N] (answer Yes if unsure)")!=0)
+ if(ask_confirmation_with_default('Y',
+ "Should TestDisk search for partition created under Vista or later ? [Y/N] (answer Yes if unsure)")!=0)
search_vista_part=1;
}
log_info("search_vista_part: %d\n", search_vista_part);