MCPcopy Create free account
hub / github.com/cgsecurity/testdisk / main

Function main

src/testdisk.c:217–527  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215
216
217int main( int argc, char **argv )
218{
219 int i;
220#ifdef SUDO_BIN
221 int use_sudo=0;
222#endif
223 int verbose=0, dump_ind=0;
224 int create_log=TD_LOG_NONE;
225 int do_list=0;
226 int unit=UNIT_DEFAULT;
227 int write_used;
228 int saveheader=0;
229 int create_backup=0;
230 int run_setlocale=1;
231 int done=0;
232 int safe=0;
233 int testdisk_mode=TESTDISK_O_RDWR|TESTDISK_O_READAHEAD_8K;
234 list_disk_t *list_disk=NULL;
235 list_disk_t *element_disk;
236 const char *cmd_device=NULL;
237 char *cmd_run=NULL;
238 const char *logfile="testdisk.log";
239 int log_opened=0;
240 int log_errno=0;
241 if(argc <= 0)
242 return 1;
243 /* srand needed for GPT creation (weak is ok) */
244 srand(time(NULL));
245#ifdef HAVE_SIGACTION
246 /* set up the signal handler for SIGINT & SIGHUP */
247 sigemptyset(&action.sa_mask);
248 sigaddset(&action.sa_mask, SIGINT);
249 sigaddset(&action.sa_mask, SIGHUP);
250 sigaddset(&action.sa_mask, SIGTERM);
251 action.sa_handler = &sighup_hdlr;
252 action.sa_flags = 0;
253 if( sigaction(SIGINT, &action, NULL)==-1 ||
254 sigaction(SIGHUP, &action, NULL)==-1 ||
255 sigaction(SIGTERM, &action, NULL)==-1 )
256 {
257 printf("Error on SIGACTION call\n");
258 return -1;
259 }
260#endif
261 printf("TestDisk %s, Data Recovery Utility, %s\nChristophe GRENIER <grenier@cgsecurity.org>\nhttps://www.cgsecurity.org\n",VERSION,TESTDISKDATE);
262 for(i=1;i<argc;i++)
263 {
264 if((strcmp(argv[i],"/dump")==0) || (strcmp(argv[i],"-dump")==0))
265 dump_ind=1;
266 else if((strcmp(argv[i],"/logname")==0) ||(strcmp(argv[i],"-logname")==0))
267 {
268 if(i+2>=argc)
269 {
270 display_help();
271 log_close();
272 return 1;
273 }
274 logfile=argv[++i];

Callers

nothing calls this directly

Calls 15

log_closeFunction · 0.85
log_openFunction · 0.85
insert_new_diskFunction · 0.85
screen_buffer_resetFunction · 0.85
display_disk_listFunction · 0.85
log_open_defaultFunction · 0.85
start_ncursesFunction · 0.85
ask_log_locationFunction · 0.85
get_osFunction · 0.85
get_compilerFunction · 0.85
get_compilation_dateFunction · 0.85

Tested by

no test coverage detected