1 /*
2  * Error functions
3  *
4  * Copyright (C) 2013-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 "libluksde_error.h"
27 #include "libluksde_libcerror.h"
28 
29 #if !defined( HAVE_LOCAL_LIBLUKSDE )
30 
31 /* Free an error and its elements
32  */
libluksde_error_free(libluksde_error_t ** error)33 void libluksde_error_free(
34       libluksde_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  */
libluksde_error_fprint(libluksde_error_t * error,FILE * stream)43 int libluksde_error_fprint(
44      libluksde_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  */
libluksde_error_sprint(libluksde_error_t * error,char * string,size_t size)60 int libluksde_error_sprint(
61      libluksde_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  */
libluksde_error_backtrace_fprint(libluksde_error_t * error,FILE * stream)78 int libluksde_error_backtrace_fprint(
79      libluksde_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  */
libluksde_error_backtrace_sprint(libluksde_error_t * error,char * string,size_t size)95 int libluksde_error_backtrace_sprint(
96      libluksde_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_LIBLUKSDE ) */
111 
112