1 /*
2 * Error functions
3 *
4 * Copyright (C) 2010-2020, Joachim Metz <joachim.metz@gmail.com>
5 *
6 * Refer to AUTHORS for acknowledgements.
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22 #include <common.h>
23 #include <file_stream.h>
24 #include <types.h>
25
26 #include "libfcache_error.h"
27 #include "libfcache_libcerror.h"
28
29 #if !defined( HAVE_LOCAL_LIBFCACHE )
30
31 /* Free an error and its elements
32 */
libfcache_error_free(libfcache_error_t ** error)33 void libfcache_error_free(
34 libfcache_error_t **error )
35 {
36 libcerror_error_free(
37 (libcerror_error_t **) error );
38 }
39
40 /* Prints a descriptive string of the error to the stream
41 * Returns the number of printed characters if successful or -1 on error
42 */
libfcache_error_fprint(libfcache_error_t * error,FILE * stream)43 int libfcache_error_fprint(
44 libfcache_error_t *error,
45 FILE *stream )
46 {
47 int print_count = 0;
48
49 print_count = libcerror_error_fprint(
50 (libcerror_error_t *) error,
51 stream );
52
53 return( print_count );
54 }
55
56 /* Prints a descriptive string of the error to the string
57 * The end-of-string character is not included in the return value
58 * Returns the number of printed characters if successful or -1 on error
59 */
libfcache_error_sprint(libfcache_error_t * error,char * string,size_t size)60 int libfcache_error_sprint(
61 libfcache_error_t *error,
62 char *string,
63 size_t size )
64 {
65 int print_count = 0;
66
67 print_count = libcerror_error_sprint(
68 (libcerror_error_t *) error,
69 string,
70 size );
71
72 return( print_count );
73 }
74
75 /* Prints a backtrace of the error to the stream
76 * Returns the number of printed characters if successful or -1 on error
77 */
libfcache_error_backtrace_fprint(libfcache_error_t * error,FILE * stream)78 int libfcache_error_backtrace_fprint(
79 libfcache_error_t *error,
80 FILE *stream )
81 {
82 int print_count = 0;
83
84 print_count = libcerror_error_backtrace_fprint(
85 (libcerror_error_t *) error,
86 stream );
87
88 return( print_count );
89 }
90
91 /* Prints a backtrace of the error to the string
92 * The end-of-string character is not included in the return value
93 * Returns the number of printed characters if successful or -1 on error
94 */
libfcache_error_backtrace_sprint(libfcache_error_t * error,char * string,size_t size)95 int libfcache_error_backtrace_sprint(
96 libfcache_error_t *error,
97 char *string,
98 size_t size )
99 {
100 int print_count = 0;
101
102 print_count = libcerror_error_backtrace_sprint(
103 (libcerror_error_t *) error,
104 string,
105 size );
106
107 return( print_count );
108 }
109
110 #endif /* !defined( HAVE_LOCAL_LIBFCACHE ) */
111
112