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

Function main

src/phmain.c:156–497  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154#endif
155
156int main( int argc, char **argv )
157{
158 list_disk_t *list_disk=NULL;
159 /*@ assert list_disk == \null; */
160 /*@ assert valid_list_disk(list_disk); */
161 int i;
162#ifdef DISABLED_FOR_FRAMAC
163 char *argv_framac[]={ "photorec", "/cmd", "file.dd", "search", NULL };
164#endif
165#ifdef SUDO_BIN
166 int use_sudo=0;
167#endif
168 int create_log=TD_LOG_NONE;
169 int run_setlocale=1;
170 int testdisk_mode=TESTDISK_O_RDONLY|TESTDISK_O_READAHEAD_32K;
171 list_disk_t *element_disk;
172 const char *logfile="photorec.log";
173 int log_opened=0;
174 int log_errno=0;
175 struct ph_options options={
176 .paranoid=1,
177 .keep_corrupted_file=0,
178 .mode_ext2=0,
179 .expert=0,
180 .lowmem=0,
181 .verbose=0,
182 .list_file_format=array_file_enable
183 };
184 struct ph_param params;
185 if(argc <= 0)
186 return 1;
187 /*@ assert valid_list_disk(list_disk); */ ;
188 params.recup_dir=NULL;
189 params.cmd_device=NULL;
190 params.cmd_run=NULL;
191 params.carve_free_space_only=0;
192 params.disk=NULL;
193 /*@ assert valid_ph_param(&params); */
194 /* random (weak is ok) is needed for GPT */
195 srand(time(NULL)& (long)0xffffffff);
196 /*@ assert valid_list_disk(list_disk); */ ;
197#ifdef HAVE_SIGACTION
198 /* set up the signal handler for SIGINT & SIGHUP */
199 sigemptyset(&action.sa_mask);
200 sigaddset(&action.sa_mask, SIGINT);
201 sigaddset(&action.sa_mask, SIGHUP);
202 sigaddset(&action.sa_mask, SIGTERM);
203 action.sa_handler = &sighup_hdlr;
204 action.sa_flags = 0;
205 if(sigaction(SIGINT, &action, NULL)==-1)
206 {
207 printf("Error on SIGACTION call\n");
208 return -1;
209 }
210 if(sigaction(SIGHUP, &action, NULL)==-1)
211 {
212 printf("Error on SIGACTION call\n");
213 return -1;

Callers

nothing calls this directly

Calls 15

MALLOCFunction · 0.85
insert_new_diskFunction · 0.85
xml_set_command_lineFunction · 0.85
log_openFunction · 0.85
log_open_defaultFunction · 0.85
start_ncursesFunction · 0.85
log_closeFunction · 0.85
ask_log_locationFunction · 0.85
get_osFunction · 0.85
get_compilerFunction · 0.85
get_compilation_dateFunction · 0.85
td_ext2fs_versionFunction · 0.85

Tested by

no test coverage detected