Move interface_options_photorec_cli() and interface_options_photorec_log() to src/poptions.c
This commit is contained in:
parent
5ba0155f27
commit
068c665c49
6 changed files with 150 additions and 82 deletions
|
@ -290,9 +290,9 @@ file_C = filegen.c \
|
|||
|
||||
file_H = ext2.h filegen.h file_jpg.h file_sp3.h file_tar.h file_tiff.h file_txt.h ole.h pe.h suspend.h
|
||||
|
||||
photorec_C = photorec.c phcfg.c dir.c exfatp.c ext2grp.c ext2_dir.c ext2p.c fat_dir.c fatp.c file_found.c ntfs_dir.c ntfsp.c sessionp.c setdate.c dfxml.c list.c
|
||||
photorec_C = photorec.c phcfg.c dir.c exfatp.c ext2grp.c ext2_dir.c ext2p.c fat_dir.c fatp.c file_found.c ntfs_dir.c ntfsp.c poptions.c sessionp.c setdate.c dfxml.c list.c
|
||||
|
||||
photorec_H = photorec.h phcfg.h dir.h exfatp.h ext2grp.h ext2p.h ext2_dir.h ext2_inc.h fat_dir.h fatp.h file_found.h memmem.h ntfs_dir.h ntfsp.h ntfs_inc.h sessionp.h setdate.h dfxml.h
|
||||
photorec_H = photorec.h phcfg.h dir.h exfatp.h ext2grp.h ext2p.h ext2_dir.h ext2_inc.h fat_dir.h fatp.h file_found.h memmem.h ntfs_dir.h ntfsp.h ntfs_inc.h poptions.h sessionp.h setdate.h dfxml.h
|
||||
|
||||
photorec_ncurses_C = addpart.c askloc.c chgtype.c chgtypen.c fat_cluster.c fat_unformat.c geometry.c hiddenn.c intrfn.c nodisk.c parti386n.c partgptn.c partmacn.c partsunn.c partxboxn.c pbanner.c pblocksize.c pdisksel.c pfree_whole.c phbf.c phbs.c phnc.c phrecn.c ppartsel.c
|
||||
photorec_ncurses_H = addpart.h askloc.h chgtype.h chgtypen.h fat_cluster.h fat_unformat.h geometry.h hiddenn.h intrfn.h nodisk.h parti386n.h partgptn.h partmacn.h partsunn.h partxboxn.h pblocksize.h pdisksel.h pfree_whole.h pnext.h phbf.h phbs.h phnc.h phrecn.h ppartsel.h
|
||||
|
|
80
src/phrecn.c
80
src/phrecn.c
|
@ -77,6 +77,7 @@
|
|||
#include "phbs.h"
|
||||
#include "file_found.h"
|
||||
#include "dfxml.h"
|
||||
#include "poptions.h"
|
||||
|
||||
/* #define DEBUG */
|
||||
/* #define DEBUG_BF */
|
||||
|
@ -1051,7 +1052,7 @@ int photorec(struct ph_param *params, const struct ph_options *options, alloc_da
|
|||
}
|
||||
|
||||
#ifdef HAVE_NCURSES
|
||||
static void interface_options_photorec_ncurses(struct ph_options *options)
|
||||
void interface_options_photorec_ncurses(struct ph_options *options)
|
||||
{
|
||||
unsigned int menu = 5;
|
||||
struct MenuItem menuOptions[]=
|
||||
|
@ -1117,84 +1118,9 @@ static void interface_options_photorec_ncurses(struct ph_options *options)
|
|||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void interface_options_photorec(struct ph_options *options, char **current_cmd)
|
||||
{
|
||||
if(*current_cmd!=NULL)
|
||||
{
|
||||
int keep_asking=1;
|
||||
do
|
||||
{
|
||||
while(*current_cmd[0]==',')
|
||||
(*current_cmd)++;
|
||||
/* paranoid, longer option first */
|
||||
if(strncmp(*current_cmd,"paranoid_no",11)==0)
|
||||
{
|
||||
(*current_cmd)+=11;
|
||||
options->paranoid=0;
|
||||
}
|
||||
else if(strncmp(*current_cmd,"paranoid_bf",11)==0)
|
||||
{
|
||||
(*current_cmd)+=11;
|
||||
options->paranoid=2;
|
||||
}
|
||||
else if(strncmp(*current_cmd,"paranoid",8)==0)
|
||||
{
|
||||
(*current_cmd)+=8;
|
||||
options->paranoid=1;
|
||||
}
|
||||
/* keep_corrupted_file */
|
||||
else if(strncmp(*current_cmd,"keep_corrupted_file_no",22)==0)
|
||||
{
|
||||
(*current_cmd)+=22;
|
||||
options->keep_corrupted_file=0;
|
||||
}
|
||||
else if(strncmp(*current_cmd,"keep_corrupted_file",19)==0)
|
||||
{
|
||||
(*current_cmd)+=19;
|
||||
options->keep_corrupted_file=1;
|
||||
}
|
||||
/* mode_ext2 */
|
||||
else if(strncmp(*current_cmd,"mode_ext2",9)==0)
|
||||
{
|
||||
(*current_cmd)+=9;
|
||||
options->mode_ext2=1;
|
||||
}
|
||||
/* expert */
|
||||
else if(strncmp(*current_cmd,"expert",6)==0)
|
||||
{
|
||||
(*current_cmd)+=6;
|
||||
options->expert=1;
|
||||
}
|
||||
/* lowmem */
|
||||
else if(strncmp(*current_cmd,"lowmem",6)==0)
|
||||
{
|
||||
(*current_cmd)+=6;
|
||||
options->lowmem=1;
|
||||
}
|
||||
else
|
||||
keep_asking=0;
|
||||
} while(keep_asking>0);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef HAVE_NCURSES
|
||||
interface_options_photorec_ncurses(options);
|
||||
#endif
|
||||
}
|
||||
/* write new options to log file */
|
||||
log_info("New options :\n Paranoid : %s\n", options->paranoid?"Yes":"No");
|
||||
log_info(" Brute force : %s\n", ((options->paranoid)>1?"Yes":"No"));
|
||||
log_info(" Keep corrupted files : %s\n ext2/ext3 mode : %s\n Expert mode : %s\n Low memory : %s\n",
|
||||
options->keep_corrupted_file?"Yes":"No",
|
||||
options->mode_ext2?"Yes":"No",
|
||||
options->expert?"Yes":"No",
|
||||
options->lowmem?"Yes":"No");
|
||||
interface_options_photorec_log(options);
|
||||
}
|
||||
|
||||
#ifdef HAVE_NCURSES
|
||||
#define INTER_FSELECT_X 0
|
||||
#define INTER_FSELECT_Y (LINES-2)
|
||||
#define INTER_FSELECT (LINES-10)
|
||||
|
|
|
@ -25,7 +25,9 @@ extern "C" {
|
|||
|
||||
int photorec(struct ph_param *params, const struct ph_options *options, alloc_data_t *list_search_space);
|
||||
void interface_file_select(file_enable_t *files_enable, char**current_cmd);
|
||||
void interface_options_photorec(struct ph_options *options, char**current_cmd);
|
||||
#ifdef HAVE_NCURSES
|
||||
void interface_options_photorec_ncurses(struct ph_options *options);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* closing brace for extern "C" */
|
||||
|
|
108
src/poptions.c
Normal file
108
src/poptions.c
Normal file
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
|
||||
File: poptions.c
|
||||
|
||||
Copyright (C) 1998-2013 Christophe GRENIER <grenier@cgsecurity.org>
|
||||
|
||||
This software is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write the Free Software Foundation, Inc., 51
|
||||
Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#include "types.h"
|
||||
#include "common.h"
|
||||
#include "filegen.h"
|
||||
#include "photorec.h"
|
||||
#include "log.h"
|
||||
#include "poptions.h"
|
||||
|
||||
void interface_options_photorec_cli(struct ph_options *options, char **current_cmd)
|
||||
{
|
||||
if(*current_cmd==NULL)
|
||||
return ;
|
||||
while(1)
|
||||
{
|
||||
while(*current_cmd[0]==',')
|
||||
(*current_cmd)++;
|
||||
/* paranoid, longer option first */
|
||||
if(strncmp(*current_cmd,"paranoid_no",11)==0)
|
||||
{
|
||||
(*current_cmd)+=11;
|
||||
options->paranoid=0;
|
||||
}
|
||||
else if(strncmp(*current_cmd,"paranoid_bf",11)==0)
|
||||
{
|
||||
(*current_cmd)+=11;
|
||||
options->paranoid=2;
|
||||
}
|
||||
else if(strncmp(*current_cmd,"paranoid",8)==0)
|
||||
{
|
||||
(*current_cmd)+=8;
|
||||
options->paranoid=1;
|
||||
}
|
||||
/* keep_corrupted_file */
|
||||
else if(strncmp(*current_cmd,"keep_corrupted_file_no",22)==0)
|
||||
{
|
||||
(*current_cmd)+=22;
|
||||
options->keep_corrupted_file=0;
|
||||
}
|
||||
else if(strncmp(*current_cmd,"keep_corrupted_file",19)==0)
|
||||
{
|
||||
(*current_cmd)+=19;
|
||||
options->keep_corrupted_file=1;
|
||||
}
|
||||
/* mode_ext2 */
|
||||
else if(strncmp(*current_cmd,"mode_ext2",9)==0)
|
||||
{
|
||||
(*current_cmd)+=9;
|
||||
options->mode_ext2=1;
|
||||
}
|
||||
/* expert */
|
||||
else if(strncmp(*current_cmd,"expert",6)==0)
|
||||
{
|
||||
(*current_cmd)+=6;
|
||||
options->expert=1;
|
||||
}
|
||||
/* lowmem */
|
||||
else if(strncmp(*current_cmd,"lowmem",6)==0)
|
||||
{
|
||||
(*current_cmd)+=6;
|
||||
options->lowmem=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
interface_options_photorec_log(options);
|
||||
return ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void interface_options_photorec_log(const struct ph_options *options)
|
||||
{
|
||||
/* write new options to log file */
|
||||
log_info("New options :\n Paranoid : %s\n", options->paranoid?"Yes":"No");
|
||||
log_info(" Brute force : %s\n", ((options->paranoid)>1?"Yes":"No"));
|
||||
log_info(" Keep corrupted files : %s\n ext2/ext3 mode : %s\n Expert mode : %s\n Low memory : %s\n",
|
||||
options->keep_corrupted_file?"Yes":"No",
|
||||
options->mode_ext2?"Yes":"No",
|
||||
options->expert?"Yes":"No",
|
||||
options->lowmem?"Yes":"No");
|
||||
}
|
31
src/poptions.h
Normal file
31
src/poptions.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
|
||||
File: poptions.h
|
||||
|
||||
Copyright (C) 2013 Christophe GRENIER <grenier@cgsecurity.org>
|
||||
|
||||
This software is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write the Free Software Foundation, Inc., 51
|
||||
Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void interface_options_photorec_cli(struct ph_options *options, char**current_cmd);
|
||||
void interface_options_photorec_log(const struct ph_options *options);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* closing brace for extern "C" */
|
||||
#endif
|
|
@ -52,6 +52,7 @@
|
|||
#include "geometry.h"
|
||||
#include "addpart.h"
|
||||
#include "intrfn.h"
|
||||
#include "poptions.h"
|
||||
|
||||
extern const arch_fnct_t arch_none;
|
||||
|
||||
|
@ -189,7 +190,7 @@ void menu_photorec(struct ph_param *params, struct ph_options *options, alloc_da
|
|||
else if(strncmp(params->cmd_run,"options",7)==0)
|
||||
{
|
||||
params->cmd_run+=7;
|
||||
interface_options_photorec(options, ¶ms->cmd_run);
|
||||
interface_options_photorec_cli(options, ¶ms->cmd_run);
|
||||
}
|
||||
else if(strncmp(params->cmd_run,"fileopt",7)==0)
|
||||
{
|
||||
|
@ -427,7 +428,7 @@ void menu_photorec(struct ph_param *params, struct ph_options *options, alloc_da
|
|||
case 'o':
|
||||
case 'O':
|
||||
{
|
||||
interface_options_photorec(options, ¶ms->cmd_run);
|
||||
interface_options_photorec_ncurses(options);
|
||||
menu=1;
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue