summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2008-03-24 16:30:07 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2008-03-24 16:30:07 +0100
commit4e7502c9596cf1c16cc3a270dd72574e88ff49ef (patch)
tree3d7a9908255049093db5fa9ddc968a3d961e381b /src
parent5f39b5f995633c1afc73dddeff22fd695b3cfd46 (diff)
Reports OS version and compiler version
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am4
-rw-r--r--src/common.h17
-rw-r--r--src/misc.c237
-rw-r--r--src/misc.h23
-rw-r--r--src/photorec.c25
-rw-r--r--src/testdisk.c10
6 files changed, 285 insertions, 31 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 35ea4f4..ecbf87b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -10,8 +10,8 @@ endif
sbin_PROGRAMS = testdisk photorec
#diskcp
-base_C = common.c crc.c ewf.c fnctdsk.c hdaccess.c hdcache.c intrf.c log.c parti386.c partgpt.c partmac.c partsun.c partnone.c partxbox.c chgtype.c io_redir.c ntfs_io.c ntfs_utl.c partauto.c sudo.c unicode.c win32.c
-base_H = common.h crc.h ewf.h fnctdsk.h hdaccess.h guid_cmp.h guid_cpy.h hdcache.h intrf.h intrfn.h lang.h log.h types.h chgtype.h io_redir.h ntfs_utl.h partgpt.h partmac.h partnone.h partxbox.h partauto.h sudo.h unicode.h win32.h
+base_C = common.c crc.c ewf.c fnctdsk.c hdaccess.c hdcache.c intrf.c log.c misc.c parti386.c partgpt.c partmac.c partsun.c partnone.c partxbox.c chgtype.c io_redir.c ntfs_io.c ntfs_utl.c partauto.c sudo.c unicode.c win32.c
+base_H = common.h crc.h ewf.h fnctdsk.h hdaccess.h guid_cmp.h guid_cpy.h hdcache.h intrf.h intrfn.h lang.h log.h misc.h types.h chgtype.h io_redir.h ntfs_utl.h partgpt.h partmac.h partnone.h partxbox.h partauto.h sudo.h unicode.h win32.h
fs_C = analyse.c bfs.c bsd.c cramfs.c fat.c fatx.c ext2.c jfs.c hfs.c hfsp.c luks.c lvm.c md.c netware.c ntfs.c rfs.c savehdr.c sun.c swap.c sysv.c ufs.c xfs.c
fs_H = analyse.h bfs.h bsd.h cramfs.h fat.h fatx.h ext2.h jfs_superblock.h jfs.h hfs.h hfsp.h luks.h lvm.h md.h netware.h ntfs.h rfs.h savehdr.h sun.h swap.h sysv.h ufs.h xfs.h
diff --git a/src/common.h b/src/common.h
index ff16edb..a72f0b8 100644
--- a/src/common.h
+++ b/src/common.h
@@ -418,21 +418,4 @@ int strncasecmp(const char * s1, const char * s2, size_t len);
void create_dir(const char *dir_name, const unsigned int is_dir_name);
unsigned int filename_convert(char *dst, const char*src, const unsigned int n);
-#ifdef DJGPP
- #define TESTDISK_OS "Dos version"
-#elif defined(TARGET_BSD)
- #define TESTDISK_OS "BSD version"
-#elif defined(TARGET_LINUX)
- #define TESTDISK_OS "Linux version"
-#elif defined(TARGET_SOLARIS)
- #define TESTDISK_OS "Solaris version"
-#elif defined(__CYGWIN__) || defined(__MINGW32__)
- #define TESTDISK_OS "Windows version"
-#elif defined(__APPLE__)
- #define TESTDISK_OS "Apple version"
-#elif defined(__OS2__)
- #define TESTDISK_OS "OS2 version"
-#else
- #define TESTDISK_OS "Undefined OS"
-#endif
#endif
diff --git a/src/misc.c b/src/misc.c
new file mode 100644
index 0000000..13b1d9a
--- /dev/null
+++ b/src/misc.c
@@ -0,0 +1,237 @@
+/*
+
+ File: misc.c
+
+ Copyright (C) 2008 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.
+
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+#include <ctype.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef HAVE_WINDOWS_H
+# include <windows.h>
+#endif
+#ifdef HAVE_SYS_UTSNAME_H
+# include <sys/utsname.h>
+#endif
+#ifdef HAVE_CYGWIN_VERSION_H
+#include <cygwin/version.h>
+#endif
+#include "types.h"
+#include "common.h"
+#include "misc.h"
+
+const char *get_os(void)
+{
+ static char buffer[100] = {0x00};
+#ifdef WIN32
+ {
+ /* For more information, read
+http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getting_the_system_version.asp
+ */
+ OSVERSIONINFOEX Ver;
+ int Extended = 1;
+ memset(&Ver,0,sizeof(OSVERSIONINFOEX));
+ Ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+
+ if (!GetVersionEx((OSVERSIONINFO *)&Ver)) {
+ Extended = 0;
+ Ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ if (!GetVersionEx((OSVERSIONINFO *)&Ver)) {
+ snprintf(buffer, sizeof(buffer) - 1, "Windows");
+ return buffer;
+ }
+ }
+
+ /* ----------------- 9x/NT4 family ------------------ */
+
+ if (Ver.dwMajorVersion == 4 && Ver.dwMinorVersion == 0)
+ {
+ /* no info about Win95 SP1, Win95 OSR2.1, Win95 OSR2.5.... */
+ if(Ver.dwBuildNumber == 950)
+ snprintf(buffer, sizeof(buffer) - 1, "Windows 95");
+ else if (Ver.dwBuildNumber == 1111)
+ snprintf(buffer, sizeof(buffer) - 1, "Windows 95 OSR2.x");
+ else if(Ver.dwBuildNumber == 1381)
+ snprintf(buffer, sizeof(buffer) - 1, "Windows NT 4.0");
+ else
+ snprintf(buffer, sizeof(buffer) - 1, "Windows 95 or NT 4.0 (%lu)", Ver.dwBuildNumber);
+ }
+ else if (Ver.dwMajorVersion == 4 && Ver.dwMinorVersion == 10)
+ {
+ /* no info about Win98 SP1.... */
+ if(Ver.dwBuildNumber == 1998)
+ snprintf(buffer, sizeof(buffer) - 1, "Windows 98");
+ else if (Ver.dwBuildNumber == 2222)
+ snprintf(buffer, sizeof(buffer) - 1, "Windows 98 SE");
+ else
+ snprintf(buffer, sizeof(buffer) - 1, "Windows 98 (%lu)", Ver.dwBuildNumber);
+ }
+ else if (Ver.dwMajorVersion == 4 && Ver.dwMinorVersion == 90)
+ {
+ if(Ver.dwBuildNumber == 3000)
+ snprintf(buffer, sizeof(buffer) - 1, "Windows ME");
+ else
+ snprintf(buffer, sizeof(buffer) - 1, "Windows ME (%lu)", Ver.dwBuildNumber);
+ }
+ else if (Ver.dwMajorVersion == 5 && Ver.dwMinorVersion == 0)
+ {
+ if(Ver.dwBuildNumber == 2195)
+ snprintf(buffer, sizeof(buffer) - 1, "Windows 2000");
+ else
+ snprintf(buffer, sizeof(buffer) - 1, "Windows 2000 (%lu)", Ver.dwBuildNumber);
+ }
+ else if (Ver.dwMajorVersion == 5 && Ver.dwMinorVersion == 1)
+ {
+ if(Ver.dwBuildNumber == 2600)
+ {
+ snprintf(buffer, sizeof(buffer) - 1, "Windows XP");
+#if defined(_MSC_VER) && _MSC_VER > 1200 /* 6.0 has it undeclared */
+ if (Extended) {
+ if (Ver.wSuiteMask & VER_SUITE_PERSONAL) {
+ snprintf(buffer+strlen(buffer), sizeof(buffer) - 1 - strlen(buffer)," Home");
+ } else {
+ snprintf(buffer+strlen(buffer), sizeof(buffer) - 1 - strlen(buffer)," Pro");
+ }
+ }
+#endif
+ }
+ else
+ snprintf(buffer, sizeof(buffer) - 1, "Windows XP (%lu)", Ver.dwBuildNumber);
+ }
+ else if (Ver.dwMajorVersion == 5 && Ver.dwMinorVersion == 2)
+ {
+ snprintf(buffer, sizeof(buffer) - 1, "Windows 2003 (%lu)", Ver.dwBuildNumber);
+ }
+ else if (Ver.dwMajorVersion == 6 && Ver.dwMinorVersion == 0)
+ {
+ snprintf(buffer, sizeof(buffer) - 1, "Windows Vista (%lu)", Ver.dwBuildNumber);
+ }
+ else if (Ver.dwMajorVersion == 6 && Ver.dwMinorVersion > 0)
+ {
+ snprintf(buffer, sizeof(buffer) - 1, "Windows Server 2007 (%lu)", Ver.dwBuildNumber);
+ }
+ else
+ {
+ snprintf(buffer, sizeof(buffer) - 1, "Windows %i.%i.%i",(int)Ver.dwMajorVersion,(int)Ver.dwMinorVersion,(int)Ver.dwBuildNumber);
+ }
+
+ if (Extended && Ver.wServicePackMajor != 0) {
+ snprintf(buffer+strlen(buffer), sizeof(buffer) - 1 - strlen(buffer)," SP%i",Ver.wServicePackMajor);
+ }
+ }
+#elif defined(DJGPP)
+ snprintf(buffer, sizeof(buffer) - 1, "DOS");
+#elif defined(HAVE_SYS_UTSNAME_H)
+ {
+ struct utsname Ver;
+ uname(&Ver);
+ snprintf(buffer, sizeof(buffer) - 1, "%s, kernel %s (%s)", Ver.sysname, Ver.release, Ver.version);
+ }
+#elif defined(__FreeBSD__)
+ snprintf(buffer, sizeof(buffer) - 1, "FreeBSD");
+#elif defined(__NetBSD__)
+ snprintf(buffer, sizeof(buffer) - 1, "NetBSD");
+#elif defined(__OpenBSD__)
+ snprintf(buffer, sizeof(buffer) - 1, "OpenBSD");
+#elif defined(__GNU__)
+ snprintf(buffer, sizeof(buffer) - 1, "GNU/Hurd");
+#elif defined(sun) || defined(__sun) || defined(__sun__)
+# ifdef __SVR4
+ snprintf(buffer, sizeof(buffer) - 1, "Sun Solaris");
+# else
+ snprintf(buffer, sizeof(buffer) - 1, "SunOS");
+# endif
+#elif defined(hpux) || defined(__hpux) || defined(__hpux__)
+ snprintf(buffer, sizeof(buffer) - 1, "HP-UX");
+#elif defined(ultrix) || defined(__ultrix) || defined(__ultrix__)
+ snprintf(buffer, sizeof(buffer) - 1, "DEC Ultrix");
+#elif defined(sgi) || defined(__sgi)
+ snprintf(buffer, sizeof(buffer) - 1, "SGI Irix");
+#elif defined(__osf__)
+ snprintf(buffer, sizeof(buffer) - 1, "OSF Unix");
+#elif defined(bsdi) || defined(__bsdi__)
+ snprintf(buffer, sizeof(buffer) - 1, "BSDI Unix");
+#elif defined(_AIX)
+ snprintf(buffer, sizeof(buffer) - 1, "AIX Unix");
+#elif defined(_UNIXWARE)
+ snprintf(buffer, sizeof(buffer) - 1, "SCO Unixware");
+#elif defined(DGUX)
+ snprintf(buffer, sizeof(buffer) - 1, "DG Unix");
+#elif defined(__QNX__)
+ snprintf(buffer, sizeof(buffer) - 1, "QNX");
+#elif defined(__APPLE__)
+ snprintf(buffer, sizeof(buffer) - 1, "Apple");
+#elif defined(__OS2__)
+ snprintf(buffer, sizeof(buffer) - 1, "OS2");
+#else
+ snprintf(buffer, sizeof(buffer) - 1, "unknown");
+#endif
+ return buffer;
+}
+
+const char *get_compiler(void)
+{
+ static char buffer[100] = {0x00};
+#ifdef WIN32
+# ifdef _MSC_VER
+ if (_MSC_VER == 1200) { /* ? */
+ snprintf(buffer, sizeof(buffer) - 1, "MS VC 6.0");
+ } else if (_MSC_VER == 1300) {
+ snprintf(buffer, sizeof(buffer) - 1, "MS VC .NET 2002");
+ } else if (_MSC_VER == 1310) {
+ snprintf(buffer, sizeof(buffer) - 1, "MS VC .NET 2003");
+ } else if (_MSC_VER == 1400) {
+ snprintf(buffer, sizeof(buffer) - 1, "MS VC .NET 2005");
+ } else {
+ snprintf(buffer, sizeof(buffer) - 1, "MS VC %i",_MSC_VER);
+ }
+# elif defined(__BORLANDC__)
+ snprintf(buffer, sizeof(buffer) - 1, "Borland C++ %i",__BORLANDC__);
+# elif defined(__MINGW32__)
+ snprintf(buffer, sizeof(buffer) - 1, "GCC %i.%i, MinGW %i.%i", __GNUC__, __GNUC_MINOR__, __MINGW32_MAJOR_VERSION, __MINGW32_MINOR_VERSION);
+# elif defined(__CYGWIN__)
+#if defined(CYGWIN_VERSION_DLL_MAJOR) && defined(CYGWIN_VERSION_DLL_MINOR)
+ snprintf(buffer, sizeof(buffer) - 1, "GCC %i.%i, Cygwin %i.%i", __GNUC__, __GNUC_MINOR__, CYGWIN_VERSION_DLL_MAJOR, CYGWIN_VERSION_DLL_MINOR);
+#else
+ snprintf(buffer, sizeof(buffer) - 1, "GCC %i.%i, Cygwin", __GNUC__, __GNUC_MINOR__);
+#endif
+# elif defined(__GNUC__)
+ snprintf(buffer, sizeof(buffer) - 1, "GCC %i.%i", __GNUC__, __GNUC_MINOR__);
+# else
+ snprintf(buffer, sizeof(buffer) - 1, "unknown compiler");
+# endif
+#elif defined(DJGPP)
+ snprintf(buffer, sizeof(buffer) - 1, "djgpp %d.%d", __DJGPP, __DJGPP_MINOR);
+#elif defined(__GNUC__)
+ snprintf(buffer, sizeof(buffer) - 1, "GCC %i.%i", __GNUC__, __GNUC_MINOR__);
+#elif defined(__SUNPRO_CC)
+ snprintf(buffer, sizeof(buffer) - 1, "Sun C++ %x", __SUNPRO_CC);
+#elif defined(__INTEL_COMPILER)
+ snprintf(buffer, sizeof(buffer) - 1, "Intel Compiler %ld", __INTEL_COMPILER);
+#else
+ snprintf(buffer, sizeof(buffer) - 1, "unknown compiler");
+#endif
+ return buffer;
+}
diff --git a/src/misc.h b/src/misc.h
new file mode 100644
index 0000000..42f027f
--- /dev/null
+++ b/src/misc.h
@@ -0,0 +1,23 @@
+/*
+
+ File: misc.h
+
+ Copyright (C) 2008 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.
+
+ */
+const char *get_os(void);
+const char *get_compiler(void);
diff --git a/src/photorec.c b/src/photorec.c
index f0a3853..3531511 100644
--- a/src/photorec.c
+++ b/src/photorec.c
@@ -66,6 +66,9 @@
#else
#include <stdio.h>
#endif
+#ifdef HAVE_JPEGLIB_H
+#include <jpeglib.h>
+#endif
#include "dir.h"
#include "filegen.h"
#include "photorec.h"
@@ -80,6 +83,9 @@
#include "hdaccess.h"
#include "sudo.h"
#include "phcfg.h"
+#include "misc.h"
+#include "ext2_dir.h"
+#include "ntfs_dir.h"
/* #define DEBUG_FILE_FINISH */
/* #define DEBUG_UPDATE_SEARCH_SPACE */
@@ -492,7 +498,7 @@ unsigned int photorec_mkdir(const char *recup_dir, const unsigned int initial_di
if(mkdir(working_recup_dir, 0775)!=0 && errno==EEXIST)
#endif
#else
-#warn You need a mkdir function!
+#warning You need a mkdir function!
#endif
{
dir_num++;
@@ -1002,15 +1008,18 @@ int main( int argc, char **argv )
return 1;
#endif
create_log=log_open("photorec.log", create_log, 1, "PhotoRec", argc, argv);
- log_info("PhotoRec %s, Data Recovery Utility, %s\nChristophe GRENIER <grenier@cgsecurity.org>\nhttp://www.cgsecurity.org\n",VERSION,TESTDISKDATE);
- log_info(TESTDISK_OS);
- log_info(" (ewf lib: %s)\n", td_ewf_version());
-#if 0
-#if defined(HAVE_LIBJPEG) && defined(JPEG_LIB_VERSION)
- log_info(", libjpeg: %u)\n", JPEG_LIB_VERSION);
+ log_info("PhotoRec %s, Data Recovery Utility, %s\nChristophe GRENIER <grenier@cgsecurity.org>\nhttp://www.cgsecurity.org\n", VERSION, TESTDISKDATE);
+ log_info("OS: %s - Compiler: %s\n", get_os(), get_compiler());
+ log_info("ext2fs lib: %s, ntfs lib: %s, ewf lib: %s, libjpeg: ",
+ td_ext2fs_version(), td_ntfs_version(), td_ewf_version());
+#if defined(HAVE_LIBJPEG)
+#if defined(JPEG_LIB_VERSION)
+ log_info("%u", JPEG_LIB_VERSION);
#else
- log_info(", libjpeg: none)\n");
+ log_info("yes");
#endif
+#else
+ log_info("none");
#endif
log_info("\n");
#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(DJGPP)
diff --git a/src/testdisk.c b/src/testdisk.c
index dfcc3ae..aa3a13c 100644
--- a/src/testdisk.c
+++ b/src/testdisk.c
@@ -2,7 +2,7 @@
File: testdisk.c
- Copyright (C) 1998-2007 Christophe GRENIER <grenier@cgsecurity.org>
+ Copyright (C) 1998-2008 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
@@ -62,6 +62,7 @@
#include "hdaccess.h"
#include "sudo.h"
#include "partauto.h"
+#include "misc.h"
extern const arch_fnct_t arch_i386;
extern const arch_fnct_t arch_mac;
@@ -286,9 +287,10 @@ int main( int argc, char **argv )
create_log=ask_testdisk_log_creation();
}
create_log=log_open("testdisk.log", create_log, 1, "TestDisk", argc, argv);
- log_info("TestDisk %s, Data Recovery Utility, %s\nChristophe GRENIER <grenier@cgsecurity.org>\nhttp://www.cgsecurity.org\n",VERSION,TESTDISKDATE);
- log_info(TESTDISK_OS);
- 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());
+ log_info("TestDisk %s, Data Recovery Utility, %s\nChristophe GRENIER <grenier@cgsecurity.org>\nhttp://www.cgsecurity.org\n", VERSION, TESTDISKDATE);
+ log_info("OS: %s - Compiler: %s\n", get_os(), get_compiler());
+ 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());
#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(DJGPP)
#else
#ifdef HAVE_GETEUID