Skip to content

Commit b74225d

Browse files
author
piotrkochan
committed
add /sigfile parameter
1 parent a3ad131 commit b74225d

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

src/file_sig.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,17 @@ static signature_t signatures={
149149
.list = TD_LIST_HEAD_INIT(signatures.list)
150150
};
151151

152+
static char *custom_sig_file = NULL;
153+
154+
void set_custom_signature_file(const char *path)
155+
{
156+
if(custom_sig_file != NULL)
157+
{
158+
free(custom_sig_file);
159+
}
160+
custom_sig_file = (path != NULL) ? strdup(path) : NULL;
161+
}
162+
152163
/*@
153164
@ assigns \nothing;
154165
@*/
@@ -261,6 +272,20 @@ static int header_check_sig(const unsigned char *buffer, const unsigned int buff
261272

262273
static FILE *open_signature_file(void)
263274
{
275+
if(custom_sig_file != NULL)
276+
{
277+
FILE *handle = fopen(custom_sig_file, "rb");
278+
if(handle != NULL)
279+
{
280+
#ifndef DISABLED_FOR_FRAMAC
281+
log_info("Open signature file %s\n", custom_sig_file);
282+
#endif
283+
return handle;
284+
}
285+
#ifndef DISABLED_FOR_FRAMAC
286+
log_error("Failed to open signature file %s\n", custom_sig_file);
287+
#endif
288+
}
264289
#if defined(__CYGWIN__) || defined(__MINGW32__)
265290
{
266291
char *path;

src/filegen.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,8 @@ time_t get_time_from_YYYYMMDD_HHMMSS(const char *date_asc);
476476
@*/
477477
void get_prev_location_smart(const alloc_data_t *list_search_space, alloc_data_t **current_search_space, uint64_t *offset, const uint64_t prev_location);
478478

479+
void set_custom_signature_file(const char *path);
480+
479481
#ifdef __cplusplus
480482
} /* closing brace for extern "C" */
481483
#endif

src/phmain.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,12 @@ static void sighup_hdlr(int sig)
123123

124124
static void display_help(void)
125125
{
126-
printf("\nUsage: photorec [/log] [/debug] [/d recup_dir] [file.dd|file.e01|device]\n"\
126+
printf("\nUsage: photorec [/log] [/debug] [/d recup_dir] [/sigfile photorec.sig] [file.dd|file.e01|device]\n"\
127127
" photorec /version\n" \
128128
"\n" \
129129
"/log : create a photorec.log file\n" \
130130
"/debug : add debug information\n" \
131+
"/sigfile path : specify custom path to signature file\n" \
131132
"\n" \
132133
"PhotoRec searches for various file formats (JPEG, Office...). It stores files\n" \
133134
"in the recup_dir directory.\n");
@@ -277,6 +278,11 @@ int main( int argc, char **argv )
277278
}
278279
i++;
279280
}
281+
else if(i+1<argc && ((strcmp(argv[i],"/sigfile")==0)||(strcmp(argv[i],"-sigfile")==0)))
282+
{
283+
set_custom_signature_file(argv[i+1]);
284+
i++;
285+
}
280286
else if((strcmp(argv[i],"/all")==0) || (strcmp(argv[i],"-all")==0))
281287
testdisk_mode|=TESTDISK_O_ALL;
282288
else if((strcmp(argv[i],"/direct")==0) || (strcmp(argv[i],"-direct")==0))

0 commit comments

Comments
 (0)