Coverage Report

Created: 2025-08-29 06:55

/src/sleuthkit/tsk/base/tsk_base.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * The Sleuth Kit
3
 *
4
 * Brian Carrier [carrier <at> sleuthkit [dot] org]
5
 * Copyright (c) 2007-2011 Brian Carrier.  All Rights reserved
6
 *
7
 * This software is distributed under the Common Public License 1.0
8
 */
9
10
/** \file tsk_base.h
11
 * Contains the type and function definitions that are needed
12
 * by external programs to use the TSK library.
13
 * Note that this file is not meant to be directly included.
14
 * It is included by both libtsk.h and tsk_base_i.h.
15
 */
16
17
18
/**
19
 * \defgroup baselib C Base TSK Library Functions
20
 * \defgroup baselib_cpp C++ Base TSK Library Classes
21
 */
22
23
#ifndef _TSK_BASE_H
24
#define _TSK_BASE_H
25
26
// standard C header files
27
#include <inttypes.h>
28
#include <stdio.h>
29
#include <stdlib.h>
30
#include <stdarg.h>
31
32
/** Version of code in number form.
33
 * Upper byte is A, next is B, and next byte is C in version A.B.C.
34
 * Lowest byte is 0xff, except in beta releases, in which case it
35
 * increments from 1.  Nightly snapshots will have upper byte as
36
 * 0xff and next bytes with year, month, and date, respectively.
37
 * Note that you will not be able to differentiate between snapshots
38
 * from the trunk or branches with this method...
39
 * For example, 3.1.2 would be stored as 0x030102FF.
40
 * 3.1.2b1 would be 0x03010201.  Snapshot from Jan 2, 2003 would be
41
 * 0xFF030102.
42
 * See TSK_VERSION_STR for string form. */
43
#define TSK_VERSION_NUM 0x041400ff
44
45
/** Version of code in string form. See TSK_VERSION_NUM for
46
 * integer form. */
47
#define TSK_VERSION_STR "4.15.0-develop"
48
49
50
/* include the TSK-specific header file that we created in autoconf
51
 * On Win32 (Visual Studio) though, we will not have this file...
52
 */
53
#if !defined(_MSC_VER)
54
#include "tsk/tsk_incs.h"
55
#endif
56
57
// get some other TSK / OS settings
58
#include "tsk_os.h"
59
60
#ifdef TSK_WIN32
61
#define strncasecmp _strnicmp
62
#endif
63
64
#ifdef __cplusplus
65
extern "C" {
66
#endif
67
68
7.37M
#define TSK_ERROR_STRING_MAX_LENGTH 1024
69
typedef void(*TSK_ERROR_LISTENER_CB) (unsigned int errno, const char* errmsg);
70
71
    typedef struct {
72
        uint32_t t_errno;
73
        char errstr[TSK_ERROR_STRING_MAX_LENGTH + 1];
74
        char errstr2[TSK_ERROR_STRING_MAX_LENGTH + 1];
75
        char errstr_print[TSK_ERROR_STRING_MAX_LENGTH + 1];
76
    } TSK_ERROR_INFO;
77
78
    /* The core function here is to retrieve the per-thread error structure. Other functions to follow
79
     * are for convenience of performing common operations. */
80
    extern TSK_ERROR_INFO *tsk_error_get_info();
81
82
    extern uint32_t tsk_error_get_errno();
83
    extern void tsk_error_set_errno(uint32_t t_errno);
84
85
#ifdef __GNUC__
86
#define TSK_ERROR_FORMAT_ATTRIBUTE(n,m) __attribute__((format (printf, n, m)))
87
#else
88
#define TSK_ERROR_FORMAT_ATTRIBUTE(n,m)
89
#endif
90
91
    extern char *tsk_error_get_errstr();
92
    extern void tsk_error_set_errstr(const char *format,
93
        ...) TSK_ERROR_FORMAT_ATTRIBUTE(1, 2);
94
    extern void tsk_error_vset_errstr(const char *format, va_list args);
95
    extern char *tsk_error_get_errstr2();
96
    extern void tsk_error_set_errstr2(const char *format,
97
        ...) TSK_ERROR_FORMAT_ATTRIBUTE(1, 2);
98
    extern void tsk_error_vset_errstr2(const char *format, va_list args);
99
    extern void tsk_error_errstr2_concat(const char *format,
100
        ...) TSK_ERROR_FORMAT_ATTRIBUTE(1, 2);
101
102
    extern void tsk_error_set_error_listener(TSK_ERROR_LISTENER_CB listener);
103
104
    /** Return a human-readable form of tsk_error_get_errno **/
105
    extern const char *tsk_error_get();
106
107
    extern void tsk_error_print(FILE *);
108
    extern void tsk_error_reset();
109
110
111
#ifdef TSK_MULTITHREAD_LIB
112
#ifdef TSK_WIN32
113
    void *tsk_error_win32_get_per_thread_(unsigned struct_size);
114
    typedef struct {
115
        CRITICAL_SECTION critical_section;
116
    } tsk_lock_t;
117
118
    // non-windows
119
#else
120
/* Note that there is an assumption that TSK_MULTITHREADED_LIB was
121
 * set only if we have pthreads. If we add a check for HAVE_PTHREAD
122
 * here, it causes problems when you try to include the library in
123
 * a tool because they do not have tsk_config.h included.
124
 */
125
#include <pthread.h>
126
    typedef struct {
127
        pthread_mutex_t mutex;
128
    } tsk_lock_t;
129
130
#endif
131
132
    // single threaded lib
133
#else
134
    typedef struct {
135
        void *dummy;
136
    } tsk_lock_t;
137
#endif
138
139
/**
140
 * Return values for some TSK functions that need to differentiate between errors and corrupt data.
141
 */
142
    typedef enum {
143
        TSK_OK,                 ///< Ok -- success
144
        TSK_ERR,                ///< System error -- should abort
145
        TSK_COR,                ///< Data is corrupt, can still process another set of data
146
        TSK_STOP                ///< Stop further processing, not an error though.
147
    } TSK_RETVAL_ENUM;
148
149
150
    typedef struct TSK_LIST TSK_LIST;
151
    /**
152
    * Linked list structure that holds a 'key' and optional 'length'.
153
    * Note that the data is stored in reverse sort order so that inserts
154
    * are faster.  Also note that the length is a negative number. A key of
155
    * '6' and a len of '2' means that the run contains 6 and 5.
156
    */
157
    struct TSK_LIST {
158
        TSK_LIST *next;         ///< Pointer to next entry in list
159
        uint64_t key;           ///< Largest value in this run
160
        uint64_t len;           ///< Length of run (negative number, stored as positive)
161
    };
162
    extern uint8_t tsk_list_find(TSK_LIST * list, uint64_t key);
163
    extern uint8_t tsk_list_add(TSK_LIST ** list, uint64_t key);
164
    extern void tsk_list_free(TSK_LIST * list);
165
166
167
    // note that the stack code is in this file and not internal for convenience to users
168
    /**
169
     * Basic stack structure to push and pop (used for finding loops in recursion).
170
     */
171
    typedef struct {
172
        uint64_t *vals;         ///< Array that contains the values in the stack
173
        size_t top;             ///< Index to the top stack entry
174
        size_t len;             ///< Number of entries in the stack
175
    } TSK_STACK;
176
177
    extern uint8_t tsk_stack_push(TSK_STACK * stack, uint64_t key);
178
    extern void tsk_stack_pop(TSK_STACK * stack);
179
    extern uint8_t tsk_stack_find(TSK_STACK * stack, uint64_t key);
180
    extern void tsk_stack_free(TSK_STACK * stack);
181
    extern TSK_STACK *tsk_stack_create();
182
183
184
    // print internal UTF-8 strings to local platform Unicode format
185
    extern void tsk_fprintf(FILE * fd, const char *msg, ...);
186
    extern void tsk_printf(const char *msg, ...);
187
188
    // print path removing special characters
189
    extern int tsk_print_sanitized(FILE * fd, const char *str);
190
191
192
/** \name printf macros if system does not define them */
193
//@{
194
#ifndef PRIx64
195
#define PRIx64 "llx"
196
#endif
197
198
#ifndef PRIX64
199
#define PRIX64 "llX"
200
#endif
201
202
#ifndef PRIu64
203
#define PRIu64 "llu"
204
#endif
205
206
#ifndef PRId64
207
#define PRId64 "lld"
208
#endif
209
210
#ifndef PRIo64
211
#define PRIo64 "llo"
212
#endif
213
214
#ifndef PRIx32
215
#define PRIx32 "x"
216
#endif
217
218
#ifndef PRIX32
219
#define PRIX32 "X"
220
#endif
221
222
#ifndef PRIu32
223
#define PRIu32 "u"
224
#endif
225
226
#ifndef PRId32
227
#define PRId32 "d"
228
#endif
229
230
#ifndef PRIx16
231
#define PRIx16 "hx"
232
#endif
233
234
#ifndef PRIX16
235
#define PRIX16 "hX"
236
#endif
237
238
#ifndef PRIu16
239
#define PRIu16 "hu"
240
#endif
241
242
#ifndef PRIu8
243
#define PRIu8 "hhu"
244
#endif
245
246
#ifndef PRIx8
247
#define PRIx8 "hhx"
248
#endif
249
//@}
250
251
252
253
/** @name  Internal integer types and printf macros*/
254
//@{
255
    typedef uint64_t TSK_INUM_T;        ///< Data type used to internally store metadata / inode addresses
256
1.34M
#define PRIuINUM  PRIu64
257
#define PRIxINUM  PRIx64
258
259
    typedef uint32_t TSK_UID_T; ///< Data type used to internally store User IDs
260
0
#define PRIuUID     PRIu32
261
#define PRIxUID     PRIx32
262
263
    typedef uint32_t TSK_GID_T; ///< Data type used to internally store Group IDs
264
#define PRIuGID     PRIu32
265
#define PRIxGID     PRIx32
266
267
    typedef uint64_t TSK_DADDR_T;       ///< Data type used to internally store sector and block addresses
268
149k
#define PRIuDADDR   PRIu64
269
0
#define PRIxDADDR   PRIx64
270
271
    typedef int64_t TSK_OFF_T;  ///< Data type used to internally store volume, file, etc. sizes and offsets
272
#define PRIxOFF   PRIx64
273
625k
#define PRIdOFF   PRId64
274
275
    typedef uint32_t TSK_PNUM_T;        ///< Data type used to internally store partition addresses
276
#define PRIuPNUM  PRIu32
277
#define PRIxPNUM  PRIx32
278
//@}
279
280
281
    extern void tsk_version_print(FILE *);
282
    extern const char *tsk_version_get_str();
283
284
285
/*********** RETURN VALUES ************/
286
287
/**
288
 * Values that callback functions can return to calling walk function.
289
 */
290
    typedef enum {
291
        TSK_WALK_CONT = 0x0,    ///< Walk function should continue to next object
292
        TSK_WALK_STOP = 0x1,    ///< Walk function should stop processing units and return OK
293
        TSK_WALK_ERROR = 0x2   ///< Walk function should stop processing units and return error
294
    } TSK_WALK_RET_ENUM;
295
296
297
/************ ERROR HANDLING *************/
298
    //TODO: make this per-thread?
299
    extern int tsk_verbose;     ///< Set to 1 to have verbose debug messages printed to stderr
300
301
302
153k
#define TSK_ERR_AUX 0x01000000
303
259k
#define TSK_ERR_IMG 0x02000000
304
66.9k
#define TSK_ERR_VS  0x04000000
305
6.49M
#define TSK_ERR_FS  0x08000000
306
0
#define TSK_ERR_HDB 0x10000000
307
0
#define TSK_ERR_AUTO 0x20000000
308
45
#define TSK_ERR_POOL 0x40000000
309
0
#define TSK_ERR_MASK  0x00ffffff
310
311
909
#define TSK_ERR_AUX_MALLOC  (TSK_ERR_AUX | 0)
312
1.26k
#define TSK_ERR_AUX_GENERIC (TSK_ERR_AUX | 2)
313
0
#define TSK_ERR_AUX_MAX   2
314
315
0
#define TSK_ERR_IMG_NOFILE  (TSK_ERR_IMG | 0)
316
#define TSK_ERR_IMG_OFFSET  (TSK_ERR_IMG | 1)
317
0
#define TSK_ERR_IMG_UNKTYPE (TSK_ERR_IMG | 2)
318
0
#define TSK_ERR_IMG_UNSUPTYPE   (TSK_ERR_IMG | 3)
319
0
#define TSK_ERR_IMG_OPEN  (TSK_ERR_IMG | 4)
320
0
#define TSK_ERR_IMG_STAT  (TSK_ERR_IMG | 5)
321
0
#define TSK_ERR_IMG_SEEK  (TSK_ERR_IMG | 6)
322
0
#define TSK_ERR_IMG_READ  (TSK_ERR_IMG | 7)
323
222k
#define TSK_ERR_IMG_READ_OFF  (TSK_ERR_IMG | 8)
324
36.7k
#define TSK_ERR_IMG_ARG     (TSK_ERR_IMG | 9)
325
0
#define TSK_ERR_IMG_MAGIC (TSK_ERR_IMG | 10)
326
#define TSK_ERR_IMG_WRITE (TSK_ERR_IMG | 11)
327
#define TSK_ERR_IMG_CONVERT (TSK_ERR_IMG | 12)
328
#define TSK_ERR_IMG_PASSWD  (TSK_ERR_IMG | 13)
329
0
#define TSK_ERR_IMG_MAX   14
330
331
0
#define TSK_ERR_VS_UNKTYPE  (TSK_ERR_VS | 0)
332
0
#define TSK_ERR_VS_UNSUPTYPE  (TSK_ERR_VS | 1)
333
42.9k
#define TSK_ERR_VS_READ   (TSK_ERR_VS | 2)
334
23.0k
#define TSK_ERR_VS_MAGIC  (TSK_ERR_VS | 3)
335
0
#define TSK_ERR_VS_WALK_RNG (TSK_ERR_VS | 4)
336
0
#define TSK_ERR_VS_BUF    (TSK_ERR_VS | 5)
337
922
#define TSK_ERR_VS_BLK_NUM  (TSK_ERR_VS | 6)
338
0
#define TSK_ERR_VS_ARG      (TSK_ERR_VS | 7)
339
0
#define TSK_ERR_VS_ENCRYPTED    (TSK_ERR_VS | 8)
340
0
#define TSK_ERR_VS_MULTTYPE     (TSK_ERR_VS | 9)
341
0
#define TSK_ERR_VS_MAX    10
342
343
45
#define TSK_ERR_POOL_UNKTYPE    (TSK_ERR_POOL | 0)
344
0
#define TSK_ERR_POOL_UNSUPTYPE  (TSK_ERR_IMG | 1)
345
0
#define TSK_ERR_POOL_ARG        (TSK_ERR_POOL | 2)
346
0
#define TSK_ERR_POOL_GENPOOL    (TSK_ERR_POOL | 3)
347
0
#define TSK_ERR_POOL_MAX        4
348
349
0
#define TSK_ERR_FS_UNKTYPE  (TSK_ERR_FS | 0)
350
175
#define TSK_ERR_FS_UNSUPTYPE  (TSK_ERR_FS | 1)
351
24.4k
#define TSK_ERR_FS_UNSUPFUNC    (TSK_ERR_FS | 2)
352
1.10k
#define TSK_ERR_FS_WALK_RNG (TSK_ERR_FS | 3)
353
323k
#define TSK_ERR_FS_READ   (TSK_ERR_FS | 4)
354
7.32k
#define TSK_ERR_FS_READ_OFF (TSK_ERR_FS | 5)
355
5.01M
#define TSK_ERR_FS_ARG    (TSK_ERR_FS | 6)
356
14.4k
#define TSK_ERR_FS_BLK_NUM  (TSK_ERR_FS | 7)
357
6.27k
#define TSK_ERR_FS_INODE_NUM  (TSK_ERR_FS | 8)
358
253k
#define TSK_ERR_FS_INODE_COR  (TSK_ERR_FS | 9)
359
724
#define TSK_ERR_FS_MAGIC  (TSK_ERR_FS | 10)
360
34.9k
#define TSK_ERR_FS_FWALK  (TSK_ERR_FS | 11)
361
0
#define TSK_ERR_FS_WRITE  (TSK_ERR_FS | 12)
362
809
#define TSK_ERR_FS_UNICODE  (TSK_ERR_FS | 13)
363
4.64k
#define TSK_ERR_FS_RECOVER  (TSK_ERR_FS | 14)
364
85.1k
#define TSK_ERR_FS_GENFS  (TSK_ERR_FS | 15)
365
43.1k
#define TSK_ERR_FS_CORRUPT  (TSK_ERR_FS | 16)
366
680k
#define TSK_ERR_FS_ATTR_NOTFOUND (TSK_ERR_FS | 17)
367
0
#define TSK_ERR_FS_ENCRYPTED    (TSK_ERR_FS | 18)
368
0
#define TSK_ERR_FS_POSSIBLY_ENCRYPTED    (TSK_ERR_FS | 19)
369
0
#define TSK_ERR_FS_MULTTYPE    (TSK_ERR_FS | 20)
370
0
#define TSK_ERR_FS_BITLOCKER_ERROR    (TSK_ERR_FS | 21)
371
534
#define TSK_ERR_FS_LARGE_DIR_ERROR    (TSK_ERR_FS | 22)
372
0
#define TSK_ERR_FS_MAX    23
373
374
#define TSK_ERR_HDB_UNKTYPE     (TSK_ERR_HDB | 0)
375
#define TSK_ERR_HDB_UNSUPTYPE   (TSK_ERR_HDB | 1)
376
#define TSK_ERR_HDB_READDB  (TSK_ERR_HDB | 2)
377
#define TSK_ERR_HDB_READIDX (TSK_ERR_HDB | 3)
378
#define TSK_ERR_HDB_ARG   (TSK_ERR_HDB | 4)
379
#define TSK_ERR_HDB_WRITE (TSK_ERR_HDB | 5)
380
#define TSK_ERR_HDB_CREATE  (TSK_ERR_HDB | 6)
381
#define TSK_ERR_HDB_DELETE      (TSK_ERR_HDB | 7)
382
#define TSK_ERR_HDB_MISSING     (TSK_ERR_HDB | 8)
383
#define TSK_ERR_HDB_PROC        (TSK_ERR_HDB | 9)
384
#define TSK_ERR_HDB_OPEN        (TSK_ERR_HDB | 10)
385
#define TSK_ERR_HDB_CORRUPT     (TSK_ERR_HDB | 11)
386
#define TSK_ERR_HDB_UNSUPFUNC     (TSK_ERR_HDB | 11)
387
0
#define TSK_ERR_HDB_MAX   13
388
389
#define TSK_ERR_AUTO_DB (TSK_ERR_AUTO | 0)
390
#define TSK_ERR_AUTO_CORRUPT (TSK_ERR_AUTO | 1)
391
#define TSK_ERR_AUTO_UNICODE (TSK_ERR_AUTO | 2)
392
#define TSK_ERR_AUTO_NOTOPEN (TSK_ERR_AUTO | 3)
393
0
#define TSK_ERR_AUTO_MAX 4
394
//@}
395
396
397
/** \name Endian Ordering Functions */
398
//@{
399
    /**
400
     * Flag that identifies the endian ordering of the data being read.
401
     */
402
    typedef enum {
403
        TSK_UNKNOWN_ENDIAN = 0x00, ///< Endianness is unknown
404
        TSK_LIT_ENDIAN = 0x01,  ///< Data is in little endian
405
        TSK_BIG_ENDIAN = 0x02   ///< Data is in big endian
406
    } TSK_ENDIAN_ENUM;
407
408
//@}
409
410
411
412
    extern TSK_OFF_T tsk_parse_offset(const TSK_TCHAR *);
413
    extern int tsk_parse_pnum(const TSK_TCHAR * a_pnum_str,
414
        TSK_PNUM_T * a_pnum);
415
416
417
418
/** \name MD5 and SHA-1 hashing */
419
//@{
420
421
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
422
rights reserved.
423
424
License to copy and use this software is granted provided that it
425
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
426
Algorithm" in all material mentioning or referencing this software
427
or this function.
428
429
License is also granted to make and use derivative works provided
430
that such works are identified as "derived from the RSA Data
431
Security, Inc. MD5 Message-Digest Algorithm" in all material
432
mentioning or referencing the derived work.
433
434
RSA Data Security, Inc. makes no representations concerning either
435
the merchantability of this software or the suitability of this
436
software for any particular purpose. It is provided "as is"
437
without express or implied warranty of any kind.
438
439
These notices must be retained in any copies of any part of this
440
documentation and/or software.
441
 */
442
443
444
/* POINTER defines a generic pointer type */
445
    typedef unsigned char *POINTER;
446
447
/* UINT2 defines a two byte word */
448
//typedef unsigned short int UINT2;
449
    typedef uint16_t UINT2;
450
451
/* UINT4 defines a four byte word */
452
    typedef uint32_t UINT4;
453
454
/* Added for sha1 */
455
/* BYTE defines a unsigned character */
456
    typedef uint8_t BYTE;
457
458
#ifndef TRUE
459
131k
#define FALSE 0
460
99.4k
#define TRUE  ( !FALSE )
461
#endif                          /* TRUE */
462
463
464
465
/* MD5 context. */
466
#define TSK_MD5_DIGEST_LENGTH 16
467
    typedef struct {
468
        UINT4 state[4];         /* state (ABCD) */
469
        UINT4 count[2];         /* number of bits, modulo 2^64 (lsb first) */
470
        unsigned char buffer[64];       /* input buffer */
471
    } TSK_MD5_CTX;
472
473
    void TSK_MD5_Init(TSK_MD5_CTX *);
474
    void TSK_MD5_Update(TSK_MD5_CTX *, const unsigned char *, unsigned int);
475
    void TSK_MD5_Final(TSK_MD5_CTX *, unsigned char[16]);
476
477
478
479
/* sha.h */
480
481
/* The structure for storing SHS info */
482
#define TSK_SHA_DIGEST_LENGTH 32
483
    typedef struct {
484
        UINT4 digest[5];        /* Message digest */
485
        UINT4 countLo, countHi; /* 64-bit bit count */
486
        UINT4 data[16];         /* SHS data buffer */
487
        int Endianness;
488
    } TSK_SHA_CTX;
489
490
/* Message digest functions */
491
492
    void TSK_SHA_Init(TSK_SHA_CTX *);
493
    void TSK_SHA_Update(TSK_SHA_CTX *, const BYTE * buffer, unsigned int count);
494
    void TSK_SHA_Final(TSK_SHA_CTX *, BYTE * output);
495
496
/* Flags for which type of hash(es) to run */
497
  typedef enum{
498
    TSK_BASE_HASH_INVALID_ID = 0,
499
    TSK_BASE_HASH_MD5 = 0x01,
500
    TSK_BASE_HASH_SHA1 = 0x02
501
    //TSK_BASE_HASH_SHA256 = 0x04,
502
  } TSK_BASE_HASH_ENUM;
503
504
505
//@}
506
507
#ifdef __cplusplus
508
}
509
#endif
510
#ifdef __cplusplus
511
#if 0
512
class TskStack {
513
  private:
514
    TSK_STACK * m_stack;
515
516
  public:
517
    /**
518
    * Create a TSK_STACK structure. See tsk_stack_create() for details.
519
    * @returns Pointer to structure or NULL on error
520
    */
521
    TskStack() {
522
        m_stack = tsk_stack_create();
523
    };
524
   /**
525
   * Free an allocated TSK_STACK structure. See tsk_stack_free() for details.
526
   */
527
    ~TskStack() {
528
        tsk_stack_free(m_stack);
529
    };
530
    /**
531
    * Pop a value from the top of the stack. See tsk_stack_pop() for details.
532
    */
533
    void pop() {
534
        tsk_stack_pop(m_stack);
535
    };
536
    /**
537
    * Push a value to the top of TSK_STACK. See tsk_stack_push() for details.
538
    * @param a_val Value to push on
539
    * @returns 1 on error
540
    */
541
    uint8_t push(uint64_t a_val) {
542
        return tsk_stack_push(m_stack, a_val);
543
    };
544
    /**
545
    * Search a TSK_STACK for a given value. See tsk_stack_find() for details.
546
    * @param a_val Value to search for
547
    * @returns 1 if found and 0 if not
548
    */
549
    uint8_t find(uint64_t a_val) {
550
        return tsk_stack_find(m_stack, a_val);
551
    };
552
     /**
553
    * Return Number of entries in the stack
554
    * @returns number of entries in the stack
555
    */
556
    size_t length() {
557
        if (m_stack != NULL)
558
            return m_stack->len;
559
        else
560
            return 0;
561
    };
562
};
563
#endif
564
565
/**
566
 * \ingroup baselib_cpp
567
 * Allows access to most recent error message and code in the thread.
568
 */
569
class TskError {
570
  public:
571
    /**
572
    * Return the string with the current error message.  The string does not end with a
573
    * newline. See tsk_error_get() for details.
574
    *
575
    * @returns String with error message or NULL if there is no error
576
    */
577
0
    static const char *get() {
578
0
        return tsk_error_get();
579
0
    };
580
581
   /**
582
   * Print the current error message to a file. See tsk_error_print() for details.
583
   *
584
   * @param a_hFile File to print message to
585
   */
586
0
    static void print(FILE * a_hFile) {
587
0
        tsk_error_print(a_hFile);
588
0
    };
589
590
    /**
591
    * Clear the error number and error message. See tsk_error_reset() for details.
592
    */
593
0
    static void reset() {
594
0
        tsk_error_reset();
595
0
    };
596
};
597
598
#endif
599
#endif