diff --git a/src/file_sig.c b/src/file_sig.c index 1376c60d..32f8aec9 100644 --- a/src/file_sig.c +++ b/src/file_sig.c @@ -42,6 +42,7 @@ #endif #include "types.h" #include "filegen.h" +#include "file_sig.h" #include "common.h" #include "log.h" @@ -149,6 +150,17 @@ static signature_t signatures={ .list = TD_LIST_HEAD_INIT(signatures.list) }; +static char *custom_sig_file = NULL; + +void set_custom_signature_file(const char *path) +{ + if(custom_sig_file != NULL) + { + free(custom_sig_file); + } + custom_sig_file = (path != NULL) ? strdup(path) : NULL; +} + /*@ @ assigns \nothing; @*/ @@ -261,6 +273,20 @@ static int header_check_sig(const unsigned char *buffer, const unsigned int buff static FILE *open_signature_file(void) { + if(custom_sig_file != NULL) + { + FILE *handle = fopen(custom_sig_file, "rb"); + if(handle != NULL) + { +#ifndef DISABLED_FOR_FRAMAC + log_info("Open signature file %s\n", custom_sig_file); +#endif + return handle; + } +#ifndef DISABLED_FOR_FRAMAC + log_error("Failed to open signature file %s\n", custom_sig_file); +#endif + } #if defined(__CYGWIN__) || defined(__MINGW32__) { char *path; diff --git a/src/file_sig.h b/src/file_sig.h new file mode 100644 index 00000000..c210c02b --- /dev/null +++ b/src/file_sig.h @@ -0,0 +1,34 @@ +/* + + File: file_sig.h + + Copyright (C) 2010 Christophe GRENIER + + 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. + + */ +#ifndef _FILE_SIG_H +#define _FILE_SIG_H + +#ifdef __cplusplus +extern "C" { +#endif + +void set_custom_signature_file(const char *path); + +#ifdef __cplusplus +} +#endif +#endif \ No newline at end of file diff --git a/src/phmain.c b/src/phmain.c index 056ae398..3cbf7d2c 100644 --- a/src/phmain.c +++ b/src/phmain.c @@ -86,6 +86,7 @@ #include "ext2_dir.h" #include "file_jpg.h" #include "file_gz.h" +#include "file_sig.h" #include "ntfs_dir.h" #include "pdiskseln.h" #include "dfxml.h" @@ -124,12 +125,13 @@ static void sighup_hdlr(int sig) static void display_help(void) { - printf("\nUsage: photorec [/log] [/logjson log.jsonl] [/debug] [/d recup_dir] [file.dd|file.e01|device]\n"\ + printf("\nUsage: photorec [/log] [/logjson log.jsonl] [/debug] [/sigfile photorec.sig] [/d recup_dir] [file.dd|file.e01|device]\n"\ " photorec /version\n" \ "\n" \ "/log : create a photorec.log file\n" \ "/logjson : create a log in JSON format\n" \ "/debug : add debug information\n" \ + "/sigfile : specify a custom signature file\n" \ "\n" \ "PhotoRec searches for various file formats (JPEG, Office...). It stores files\n" \ "in the recup_dir directory.\n"); @@ -286,6 +288,11 @@ int main( int argc, char **argv ) } i++; } + else if(i+1