Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/file_sig.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#endif
#include "types.h"
#include "filegen.h"
#include "file_sig.h"
#include "common.h"
#include "log.h"

Expand Down Expand Up @@ -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;
@*/
Expand Down Expand Up @@ -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;
Expand Down
34 changes: 34 additions & 0 deletions src/file_sig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*

File: file_sig.h

Copyright (C) 2010 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.

*/
#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
9 changes: 8 additions & 1 deletion src/phmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 <file> : create a log in JSON format\n" \
"/debug : add debug information\n" \
"/sigfile <file> : 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");
Expand Down Expand Up @@ -286,6 +288,11 @@ int main( int argc, char **argv )
}
i++;
}
else if(i+1<argc && ((strcmp(argv[i],"/sigfile")==0)||(strcmp(argv[i],"-sigfile")==0)))
{
set_custom_signature_file(argv[i+1]);
i++;
}
else if((strcmp(argv[i],"/all")==0) || (strcmp(argv[i],"-all")==0))
testdisk_mode|=TESTDISK_O_ALL;
else if((strcmp(argv[i],"/direct")==0) || (strcmp(argv[i],"-direct")==0))
Expand Down