Add get_compilation_date() and td_jpeg_version() functions

This commit is contained in:
Christophe Grenier 2011-04-23 14:39:51 +02:00
parent 791794a74f
commit f7a3262623
6 changed files with 69 additions and 60 deletions

View file

@ -51,6 +51,7 @@ typedef int boolean;
#include "filegen.h" #include "filegen.h"
#include "common.h" #include "common.h"
#include "log.h" #include "log.h"
#include "file_jpg.h"
#include "file_tiff.h" #include "file_tiff.h"
extern const file_hint_t file_hint_indd; extern const file_hint_t file_hint_indd;
@ -1445,3 +1446,18 @@ int data_check_jpg(const unsigned char *buffer, const unsigned int buffer_size,
} }
return 1; return 1;
} }
const char*td_jpeg_version(void)
{
#if defined(HAVE_LIBJPEG)
#if defined(JPEG_LIB_VERSION)
static char buffer[32];
sprintf(buffer,"%d", JPEG_LIB_VERSION);
return buffer;
#else
return "yes";
#endif
#else
return "none";
#endif
}

View file

@ -23,7 +23,7 @@
extern "C" { extern "C" {
#endif #endif
int64_t test_jpeg(FILE *infile); const char*td_jpeg_version(void);
#ifdef __cplusplus #ifdef __cplusplus
} /* closing brace for extern "C" */ } /* closing brace for extern "C" */

View file

@ -44,9 +44,9 @@
const char *get_os(void) const char *get_os(void)
{ {
static char buffer[100] = {0x00};
#ifdef WIN32 #ifdef WIN32
{ {
static char buffer[100] = {0x00};
/* For more information, read /* For more information, read
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getting_the_system_version.asp http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getting_the_system_version.asp
*/ */
@ -148,55 +148,60 @@ http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/ge
if (Extended && Ver.wServicePackMajor != 0) { if (Extended && Ver.wServicePackMajor != 0) {
snprintf(buffer+strlen(buffer), sizeof(buffer) - 1 - strlen(buffer)," SP%i",Ver.wServicePackMajor); snprintf(buffer+strlen(buffer), sizeof(buffer) - 1 - strlen(buffer)," SP%i",Ver.wServicePackMajor);
} }
return buffer;
} }
#elif defined(DJGPP) #elif defined(DJGPP)
snprintf(buffer, sizeof(buffer) - 1, "DOS"); return "DOS";
#elif defined(HAVE_SYS_UTSNAME_H) #elif defined(HAVE_SYS_UTSNAME_H)
{ {
struct utsname Ver; struct utsname Ver;
uname(&Ver); if(uname(&Ver)==0)
snprintf(buffer, sizeof(buffer) - 1, "%s, kernel %s (%s) %s", Ver.sysname, Ver.release, Ver.version, Ver.machine); {
static char buffer[100] = {0x00};
snprintf(buffer, sizeof(buffer) - 1, "%s, kernel %s (%s) %s", Ver.sysname, Ver.release, Ver.version, Ver.machine);
return buffer;
}
} }
#elif defined(__FreeBSD__) #endif
snprintf(buffer, sizeof(buffer) - 1, "FreeBSD"); #if defined(__FreeBSD__)
return "FreeBSD";
#elif defined(__NetBSD__) #elif defined(__NetBSD__)
snprintf(buffer, sizeof(buffer) - 1, "NetBSD"); return "NetBSD";
#elif defined(__OpenBSD__) #elif defined(__OpenBSD__)
snprintf(buffer, sizeof(buffer) - 1, "OpenBSD"); return "BSD";
#elif defined(__GNU__) #elif defined(__GNU__)
snprintf(buffer, sizeof(buffer) - 1, "GNU/Hurd"); return "GNU/Hurd";
#elif defined(sun) || defined(__sun) || defined(__sun__) #elif defined(sun) || defined(__sun) || defined(__sun__)
# ifdef __SVR4 # ifdef __SVR4
snprintf(buffer, sizeof(buffer) - 1, "Sun Solaris"); return "Sun Solaris";
# else # else
snprintf(buffer, sizeof(buffer) - 1, "SunOS"); return "SunOS";
# endif # endif
#elif defined(hpux) || defined(__hpux) || defined(__hpux__) #elif defined(hpux) || defined(__hpux) || defined(__hpux__)
snprintf(buffer, sizeof(buffer) - 1, "HP-UX"); return "HP-UX";
#elif defined(ultrix) || defined(__ultrix) || defined(__ultrix__) #elif defined(ultrix) || defined(__ultrix) || defined(__ultrix__)
snprintf(buffer, sizeof(buffer) - 1, "DEC Ultrix"); return "DEC Ultrix";
#elif defined(sgi) || defined(__sgi) #elif defined(sgi) || defined(__sgi)
snprintf(buffer, sizeof(buffer) - 1, "SGI Irix"); return "SGI Irix";
#elif defined(__osf__) #elif defined(__osf__)
snprintf(buffer, sizeof(buffer) - 1, "OSF Unix"); return "OSF Unix";
#elif defined(bsdi) || defined(__bsdi__) #elif defined(bsdi) || defined(__bsdi__)
snprintf(buffer, sizeof(buffer) - 1, "BSDI Unix"); return "BSDI Unix";
#elif defined(_AIX) #elif defined(_AIX)
snprintf(buffer, sizeof(buffer) - 1, "AIX Unix"); return "AIX Unix";
#elif defined(_UNIXWARE) #elif defined(_UNIXWARE)
snprintf(buffer, sizeof(buffer) - 1, "SCO Unixware"); return "SCO Unixware";
#elif defined(DGUX) #elif defined(DGUX)
snprintf(buffer, sizeof(buffer) - 1, "DG Unix"); return "DG Unix";
#elif defined(__QNX__) #elif defined(__QNX__)
snprintf(buffer, sizeof(buffer) - 1, "QNX"); return "QNX";
#elif defined(__APPLE__) #elif defined(__APPLE__)
snprintf(buffer, sizeof(buffer) - 1, "Apple"); return "Apple";
#elif defined(__OS2__) #elif defined(__OS2__)
snprintf(buffer, sizeof(buffer) - 1, "OS2"); return "OS2";
#else #else
snprintf(buffer, sizeof(buffer) - 1, "unknown"); return "unknown";
#endif #endif
return buffer;
} }
const char *get_compiler(void) const char *get_compiler(void)
@ -205,13 +210,13 @@ const char *get_compiler(void)
#ifdef WIN32 #ifdef WIN32
# ifdef _MSC_VER # ifdef _MSC_VER
if (_MSC_VER == 1200) { /* ? */ if (_MSC_VER == 1200) { /* ? */
snprintf(buffer, sizeof(buffer) - 1, "MS VC 6.0"); return "MS VC 6.0";
} else if (_MSC_VER == 1300) { } else if (_MSC_VER == 1300) {
snprintf(buffer, sizeof(buffer) - 1, "MS VC .NET 2002"); return "MS VC .NET 2002";
} else if (_MSC_VER == 1310) { } else if (_MSC_VER == 1310) {
snprintf(buffer, sizeof(buffer) - 1, "MS VC .NET 2003"); return "MS VC .NET 2003";
} else if (_MSC_VER == 1400) { } else if (_MSC_VER == 1400) {
snprintf(buffer, sizeof(buffer) - 1, "MS VC .NET 2005"); return "MS VC .NET 2005";
} else { } else {
snprintf(buffer, sizeof(buffer) - 1, "MS VC %i",_MSC_VER); snprintf(buffer, sizeof(buffer) - 1, "MS VC %i",_MSC_VER);
} }
@ -228,7 +233,7 @@ const char *get_compiler(void)
# elif defined(__GNUC__) # elif defined(__GNUC__)
snprintf(buffer, sizeof(buffer) - 1, "GCC %i.%i", __GNUC__, __GNUC_MINOR__); snprintf(buffer, sizeof(buffer) - 1, "GCC %i.%i", __GNUC__, __GNUC_MINOR__);
# else # else
snprintf(buffer, sizeof(buffer) - 1, "unknown compiler"); return "unknown compiler";
# endif # endif
#elif defined(DJGPP) #elif defined(DJGPP)
snprintf(buffer, sizeof(buffer) - 1, "djgpp %d.%d", __DJGPP, __DJGPP_MINOR); snprintf(buffer, sizeof(buffer) - 1, "djgpp %d.%d", __DJGPP, __DJGPP_MINOR);
@ -239,11 +244,16 @@ const char *get_compiler(void)
#elif defined(__INTEL_COMPILER) #elif defined(__INTEL_COMPILER)
snprintf(buffer, sizeof(buffer) - 1, "Intel Compiler %ld", __INTEL_COMPILER); snprintf(buffer, sizeof(buffer) - 1, "Intel Compiler %ld", __INTEL_COMPILER);
#else #else
snprintf(buffer, sizeof(buffer) - 1, "unknown compiler"); return "unknown compiler";
#endif #endif
return buffer;
}
const char *get_compilation_date(void)
{
static char buffer[100] = {0x00};
#ifdef __DATE__ #ifdef __DATE__
strcat(buffer, " - "); strcpy(buffer, __DATE__);
strcat(buffer, __DATE__);
#ifdef __TIME__ #ifdef __TIME__
strcat(buffer, " "); strcat(buffer, " ");
strcat(buffer, __TIME__); strcat(buffer, __TIME__);

View file

@ -25,6 +25,7 @@ extern "C" {
const char *get_os(void); const char *get_os(void);
const char *get_compiler(void); const char *get_compiler(void);
const char *get_compilation_date(void);
#ifdef __cplusplus #ifdef __cplusplus
} /* closing brace for extern "C" */ } /* closing brace for extern "C" */

View file

@ -62,9 +62,6 @@
#ifdef HAVE_NCURSES #ifdef HAVE_NCURSES
#include "intrfn.h" #include "intrfn.h"
#endif #endif
#ifdef HAVE_JPEGLIB_H
#include <jpeglib.h>
#endif
#include "dir.h" #include "dir.h"
#include "filegen.h" #include "filegen.h"
#include "photorec.h" #include "photorec.h"
@ -76,6 +73,7 @@
#include "phcfg.h" #include "phcfg.h"
#include "misc.h" #include "misc.h"
#include "ext2_dir.h" #include "ext2_dir.h"
#include "file_jpg.h"
#include "ntfs_dir.h" #include "ntfs_dir.h"
#include "pdisksel.h" #include "pdisksel.h"
extern const arch_fnct_t arch_none; extern const arch_fnct_t arch_none;
@ -219,18 +217,9 @@ int main( int argc, char **argv )
printf("\n"); printf("\n");
printf("Version: %s\n", VERSION); printf("Version: %s\n", VERSION);
printf("Compiler: %s\n", get_compiler()); printf("Compiler: %s\n", get_compiler());
printf("ext2fs lib: %s, ntfs lib: %s, ewf lib: %s, libjpeg: ", printf("Compilation date: %s\n", get_compilation_date());
td_ext2fs_version(), td_ntfs_version(), td_ewf_version()); printf("ext2fs lib: %s, ntfs lib: %s, ewf lib: %s, libjpeg: %s\n",
#if defined(HAVE_LIBJPEG) td_ext2fs_version(), td_ntfs_version(), td_ewf_version(), td_jpeg_version());
#if defined(JPEG_LIB_VERSION)
printf("%d", JPEG_LIB_VERSION);
#else
printf("yes");
#endif
#else
printf("none");
#endif
printf("\n");
printf("OS: %s\n" , get_os()); printf("OS: %s\n" , get_os());
return 0; return 0;
} }
@ -302,18 +291,9 @@ int main( int argc, char **argv )
log_info("PhotoRec %s, Data Recovery Utility, %s\nChristophe GRENIER <grenier@cgsecurity.org>\nhttp://www.cgsecurity.org\n", VERSION, TESTDISKDATE); log_info("PhotoRec %s, Data Recovery Utility, %s\nChristophe GRENIER <grenier@cgsecurity.org>\nhttp://www.cgsecurity.org\n", VERSION, TESTDISKDATE);
log_info("OS: %s\n" , get_os()); log_info("OS: %s\n" , get_os());
log_info("Compiler: %s\n", get_compiler()); log_info("Compiler: %s\n", get_compiler());
log_info("ext2fs lib: %s, ntfs lib: %s, ewf lib: %s, libjpeg: ", log_info("Compilation date: %s\n", get_compilation_date());
td_ext2fs_version(), td_ntfs_version(), td_ewf_version()); log_info("ext2fs lib: %s, ntfs lib: %s, ewf lib: %s, libjpeg: %s\n",
#if defined(HAVE_LIBJPEG) td_ext2fs_version(), td_ntfs_version(), td_ewf_version(), td_jpeg_version());
#if defined(JPEG_LIB_VERSION)
log_info("%d", JPEG_LIB_VERSION);
#else
log_info("yes");
#endif
#else
log_info("none");
#endif
log_info("\n");
#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(DJGPP) #if defined(__CYGWIN__) || defined(__MINGW32__) || defined(DJGPP)
#else #else
#ifdef HAVE_GETEUID #ifdef HAVE_GETEUID

View file

@ -222,6 +222,7 @@ int main( int argc, char **argv )
printf("\n"); printf("\n");
printf("Version: %s\n", VERSION); printf("Version: %s\n", VERSION);
printf("Compiler: %s\n", get_compiler()); printf("Compiler: %s\n", get_compiler());
printf("Compilation date: %s\n", get_compilation_date());
printf("ext2fs lib: %s, ntfs lib: %s, reiserfs lib: %s, ewf lib: %s\n", printf("ext2fs lib: %s, ntfs lib: %s, reiserfs lib: %s, ewf lib: %s\n",
td_ext2fs_version(), td_ntfs_version(), td_reiserfs_version(), td_ewf_version()); td_ext2fs_version(), td_ntfs_version(), td_reiserfs_version(), td_ewf_version());
printf("OS: %s\n" , get_os()); printf("OS: %s\n" , get_os());
@ -345,6 +346,7 @@ int main( int argc, char **argv )
log_info("TestDisk %s, Data Recovery Utility, %s\nChristophe GRENIER <grenier@cgsecurity.org>\nhttp://www.cgsecurity.org\n", VERSION, TESTDISKDATE); log_info("TestDisk %s, Data Recovery Utility, %s\nChristophe GRENIER <grenier@cgsecurity.org>\nhttp://www.cgsecurity.org\n", VERSION, TESTDISKDATE);
log_info("OS: %s\n" , get_os()); log_info("OS: %s\n" , get_os());
log_info("Compiler: %s\n", get_compiler()); log_info("Compiler: %s\n", get_compiler());
log_info("Compilation date: %s\n", get_compilation_date());
log_info("ext2fs lib: %s, ntfs lib: %s, reiserfs lib: %s, ewf lib: %s\n", log_info("ext2fs lib: %s, ntfs lib: %s, reiserfs lib: %s, ewf lib: %s\n",
td_ext2fs_version(), td_ntfs_version(), td_reiserfs_version(), td_ewf_version()); td_ext2fs_version(), td_ntfs_version(), td_reiserfs_version(), td_ewf_version());
#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(DJGPP) #if defined(__CYGWIN__) || defined(__MINGW32__) || defined(DJGPP)