int do_curses_photorec(struct ph_param *params, struct ph_options *options, const list_disk_t *list_disk) { static alloc_data_t list_search_space={ .list = TD_LIST_HEAD_INIT(list_search_space.list) }; if(params->cmd_device==NULL) { char *saved_device=NULL; char *saved_cmd=NULL; session_load(&saved_device, &saved_cmd,&list_search_space); if(saved_device!=NULL && saved_cmd!=NULL && !td_list_empty(&list_search_space.list) #ifdef HAVE_NCURSES && ask_confirmation("Continue previous session ? (Y/N)")!=0 #endif ) { /* yes */ params->cmd_run=saved_cmd; params->cmd_device=saved_device; } else { free(saved_device); free(saved_cmd); free_list_search_space(&list_search_space); } } if(params->cmd_device!=NULL && params->cmd_run!=NULL) { params->disk=photorec_disk_selection_cli(params->cmd_device, list_disk, &list_search_space); #ifdef HAVE_NCURSES if(params->disk==NULL) { log_critical("No disk found\n"); return intrf_no_disk_ncurses("PhotoRec"); } if(change_arch_type_cli(params->disk, options->verbose, ¶ms->cmd_run)==0 || change_arch_type_ncurses(params->disk, options->verbose)==0) { menu_photorec(params, options, &list_search_space); } return 0; #else if(params->disk==NULL) { log_critical("No disk found\n"); return 0; } change_arch_type_cli(params->disk, options->verbose, ¶ms->cmd_run); menu_photorec(params, options, &list_search_space); return 0; #endif } #ifdef HAVE_NCURSES return photorec_disk_selection_ncurses(params, options, list_disk, &list_search_space); #else return 0; #endif }
static int testdisk_disk_selection_cli(int verbose,int dump_ind, const list_disk_t *list_disk, const int saveheader, const char *cmd_device, char **current_cmd) { const list_disk_t *element_disk; const list_disk_t *current_disk=NULL; if(cmd_device!=NULL) { for(element_disk=list_disk;element_disk!=NULL;element_disk=element_disk->next) { if(strcmp(element_disk->disk->device,cmd_device)==0) current_disk=element_disk; } } else current_disk=list_disk; if(current_disk==NULL) { log_critical("No disk found\n"); return 0; } if(*current_cmd!=NULL) { while(*current_cmd[0]==',') (*current_cmd)++; { disk_t *disk=current_disk->disk; autodetect_arch(disk, NULL); autoset_unit(disk); if(interface_check_disk_capacity(disk)==0 && interface_check_disk_access(disk, current_cmd)==0 && (change_arch_type_cli(disk, verbose, current_cmd)==0 #ifdef HAVE_NCURSES || change_arch_type_ncurses(disk, verbose)==0 #endif )) { menu_disk(disk, verbose, dump_ind, saveheader, current_cmd); } } } return 0; }