# tsk_os.h

    00001 /*
    00002 ** The Sleuth Kit
    00003 **
    00004 ** $Date: 2007/04/19 19:01:35 $
    00005 **
    00006 ** Brian Carrier [carrier@sleuthkit.org]
    00007 ** Copyright (c) 2004-2005 Brian Carrier.  All rights reserved
    00008 */
    00009
    00010 #ifndef _TSK_OS_H
    00011 #define _TSK_OS_H
    00012
    00013     /*
    00014      * Solaris 2.x. Build for large files when dealing with filesystems > 2GB.
    00015      * With the 32-bit file model, needs pread() to access filesystems > 2GB.
    00016      */
    00017 #if defined(SUNOS5)
    00018 #define SUPPORTED
    00019 #define USE_LIBAFF
    00020 #define USE_LIBEWF
    00021 #define HAVE_UNISTD
    00022
    00023 #include <sys/sysmacros.h>
    00024
    00025 /* Sol 5.7 has inttypes, but sys/inttypes is needed for PRI.. macros */
    00026 #include <inttypes.h>
    00027 #include <sys/inttypes.h>
    00028 #endif
    00029
    00030
    00031     /*
    00032      * FreeBSD can handle filesystems > 2GB.
    00033      */
    00034 #if defined(FREEBSD2) || defined(FREEBSD3) || defined(FREEBSD4) || defined(FREEBSD5)
    00035 #define SUPPORTED
    00036 #define USE_LIBAFF
    00037 #define USE_LIBEWF
    00038 #define HAVE_UNISTD
    00039
    00040 /* FreeBSD 5 has inttypes and support for the printf macros */
    00041 #if defined(FREEBSD4) || defined(FREEBSD5)
    00042 #include <inttypes.h>
    00043 #endif
    00044
    00045 #endif                          /* FREEBSD */
    00046
    00047     /*
    00048      * BSD/OS can handle filesystems > 2GB.
    00049      */
    00050 #if defined(BSDI2) || defined(BSDI3) || defined(BSDI4)
    00051 #define SUPPORTED
    00052 #define USE_LIBAFF
    00053 #define USE_LIBEWF
    00054 #define HAVE_UNISTD
    00055
    00056 #include <inttypes.h>
    00057 #endif                          /* BSDI */
    00058
    00059
    00060 /*
    00061  * NetBSD
    00062  */
    00063 #if defined(NETBSD16)
    00064 #define SUPPORTED
    00065 #define USE_LIBAFF
    00066 #define USE_LIBEWF
    00067 #define HAVE_UNISTD
    00068
    00069 #include <inttypes.h>
    00070 #endif                          /* NETBSD */
    00071
    00072
    00073     /*
    00074      * OpenBSD looks like BSD/OS 3.x.
    00075      */
    00076 #if defined(OPENBSD2) || defined (OPENBSD3)
    00077 #define SUPPORTED
    00078 #define USE_LIBAFF
    00079 #define USE_LIBEWF
    00080 #define HAVE_UNISTD
    00081
    00082 #include <inttypes.h>
    00083 #endif
    00084
    00085
    00086
    00087 #if defined(DARWIN)
    00088 #define SUPPORTED
    00089 #define USE_LIBAFF
    00090 #define USE_LIBEWF
    00091 #define HAVE_UNISTD
    00092
    00093 #include <inttypes.h>
    00094 #endif                          /* DARWIN */
    00095
    00096
    00097     /*
    00098      * Linux 2.whatever.
    00099      */
    00100 #if defined(LINUX2)
    00101 #define SUPPORTED
    00102 #define USE_LIBAFF
    00103 #define USE_LIBEWF
    00104 #define HAVE_UNISTD
    00105
    00106 #include <inttypes.h>
    00107 #endif                          /* LINUX */
    00108
    00109
    00110
    00111 #if defined(CYGWIN)
    00112 #define SUPPORTED
    00113 #define USE_LIBAFF
    00114 #define USE_LIBEWF
    00115 #define HAVE_UNISTD
    00116
    00117 #include <inttypes.h>
    00118
    00119 #define roundup(x, y)   \
    00120         ( ( ((x)+((y) - 1)) / (y)) * (y) )
    00121
    00122 #endif                          /* CYGWIN */
    00123
    00124
    00125 #if defined(__INTERNIX)
    00126 #define SUPPORTED
    00127 #include <inttypes.h>
    00128 #define HAVE_UNISTD
    00129
    00130 #define roundup(x, y)   \
    00131         ( ( ((x)+((y) - 1)) / (y)) * (y) )
    00132
    00133 #endif                          /* INTERNIX */
    00134
    00135 #if defined(_WIN32) || defined (__WIN32__)
    00136 #define SUPPORTED
    00137 #define TSK_WIN32
    00138 #ifndef UNICODE
    00139 #define UNICODE
    00140 #endif
    00141 #ifndef _UNICODE
    00142 #define _UNICODE
    00143 #endif
    00144 #define WIN32_LEAN_AND_MEAN     /* somewhat limit Win32 pollution */
    00145
    00146 #include <windows.h>
    00147 #include <tchar.h>
    00148 #include <io.h>
    00149
    00150 #define _CRT_SECURE_NO_DEPRECATE        1
    00151
    00152 #include "intrin.h"
    00153
    00154 typedef unsigned __int8 uint8_t;
    00155 typedef __int8 int8_t;
    00156 typedef unsigned __int16 uint16_t;
    00157 typedef __int16 int16_t;
    00158 typedef unsigned __int32 uint32_t;
    00159 typedef __int32 int32_t;
    00160 typedef unsigned __int64 uint64_t;
    00161 typedef __int64 int64_t;
    00162 typedef int mode_t;
    00163 typedef uint16_t gid_t;
    00164 typedef uint16_t uid_t;
    00165
    00166 #define strtoull        strtoul
    00167 #define snprintf   _snprintf
    00168 #define strcasecmp(string1, string2)    _strnicmp(string1, string2, strlen(string1))
    00169
    00170 #define roundup(x, y)   \
    00171         ( ( ((x)+((y) - 1)) / (y)) * (y) )
    00172
    00173 #endif
    00174
    00175
    00176 /* When TSK deals with the outside world (printing / input), the data will
    00177  * be in either UTF-16 or UTF-8 (Windows or Unix).  TSK_TCHAR is defined
    00178  * as the data type needed and the following function map to the required
    00179  * function.
    00180  */
    00181
    00182 #ifdef TSK_WIN32
    00183
    00184 /* TSK_TCHAR is a wide 2-byte character */
    00185 typedef TCHAR TSK_TCHAR;
    00186 #define _TSK_T  _T
    00187
    00188 #define TSTAT _tstat
    00189 #define STAT_STR    _stat64i32
    00190 #define TSTRTOK _tcstok
    00191 #define TSTRLEN _tcslen
    00192 #define TSTRCMP _tcscmp
    00193 #define TSTRNCPY _tcsncpy
    00194 #define TSTRNCAT _tcsncat
    00195 #define TSTRCHR _tcschr
    00196 #define TSTRTOUL _tcstoul
    00197 #define TSTRTOULL _tcstoui64
    00198 #define TATOI   _tstoi
    00199 #define TFPRINTF fwprintf
    00200 #define TSNPRINTF _snwprintf
    00201 #define PUTENV  _wputenv
    00202 #define TZSET   _tzset
    00203
    00204 #define PRIcTSK _TSK_T("S")
    00205 #define PRIwTSK _TSK_T"s")
    00206
    00207 #define unlink _unlink
    00208 #define MAIN _tmain
    00209
    00210 #else
    00211
    00212 /* TSK_TCHAR is a 1-byte character */
    00213 typedef char TSK_TCHAR;
    00214 #define _TSK_T(x)       x
    00215
    00216 #define TSTAT   stat
    00217 #define STAT_STR    stat
    00218 #define TSTRTOK strtok
    00219 #define TSTRLEN strlen
    00220 #define TSTRCMP strcmp
    00221 #define TSTRNCPY strncpy
    00222 #define TSTRNCAT strncat
    00223 #define TSTRCHR strchr
    00224 #define TSTRTOUL strtoul
    00225 #define TSTRTOULL strtoull
    00226 #define TATOI   atoi
    00227 #define TFPRINTF fprintf
    00228 #define TSNPRINTF snprintf
    00229
    00230 #define PUTENV  putenv
    00231 #define TZSET   tzset
    00232
    00233 #define PRIcTSK _TSK_T("s")
    00234 #define PRIwTSK _TSK_T("S")
    00235
    00236 #define MAIN main
    00237
    00238 #endif
    00239
    00240     /*
    00241      * Catch-all.
    00242      */
    00243 #ifndef SUPPORTED
    00244 #error "This operating system is not supported"
    00245 #endif
    00246
    00247 #endif