Debian Codegraph @

vhditools/vhditools_output.c

raw symbols SCIP
1 /*
2 * Common output functions for the vhditools
3 *
4 * Copyright (C) 2012-2025, Joachim Metz <[email protected]>
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 <memory.h>
25 #include <types.h>
26
27 #include "vhditools_i18n.h"
28 #include "vhditools_libbfio.h"
29 #include "vhditools_libcerror.h"
30 #include "vhditools_libclocale.h"
31 #include "vhditools_libcnotify.h"
32 #include "vhditools_libvhdi.h"
33 #include "vhditools_libuna.h"
34 #include "vhditools_output.h"
35
36 /* Initializes output settings
37 * Returns 1 if successful or -1 on error
38 */
39 int vhditools_output_initialize(
40 int stdio_mode,
41 libcerror_error_t **error )
42 {
43 static char *function = "vhditools_output_initialize";
44
45 if( ( stdio_mode != _IOFBF )
46 && ( stdio_mode != _IOLBF )
47 && ( stdio_mode != _IONBF ) )
48 {
49 libcerror_error_set(
50 error,
51 LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
52 LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE,
53 "%s: unsupported standard IO mode.",
54 function );
55
56 return( -1 );
57 }
58 #if !defined( __BORLANDC__ )
59 if( setvbuf(
60 stdout,
61 NULL,
62 stdio_mode,
63 0 ) != 0 )
64 {
65 libcerror_error_set(
66 error,
67 LIBCERROR_ERROR_DOMAIN_RUNTIME,
68 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
69 "%s: unable to set IO mode of stdout.",
70 function );
71
72 return( -1 );
73 }
74 if( setvbuf(
75 stderr,
76 NULL,
77 stdio_mode,
78 0 ) != 0 )
79 {
80 libcerror_error_set(
81 error,
82 LIBCERROR_ERROR_DOMAIN_RUNTIME,
83 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
84 "%s: unable to set IO mode of stderr.",
85 function );
86
87 return( -1 );
88 }
89 #endif /* !defined( __BORLANDC__ ) */
90
91 return( 1 );
92 }
93
94 /* Prints the copyright information
95 */
96 void vhditools_output_copyright_fprint(
97 FILE *stream )
98 {
99 if( stream == NULL )
100 {
101 return;
102 }
103 /* TRANSLATORS: This is a proper name.
104 */
105 fprintf(
106 stream,
107 _( "Copyright (C) 2012-2025, %s.\n" ),
108 _( "Joachim Metz" ) );
109
110 fprintf(
111 stream,
112 _( "This is free software; see the source for copying conditions. There is NO\n"
113 "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" ) );
114
115 /* TRANSLATORS: The placeholder indicates the bug-reporting address
116 * for this package. Please add _another line_ saying
117 * "Report translation bugs to <...>\n" with the address for translation
118 * bugs (typically your translation team's web or email address).
119 */
120 fprintf(
121 stream,
122 _( "Report bugs to <%s>.\n" ),
123 PACKAGE_BUGREPORT );
124 }
125
126 /* Prints the (basic) version information
127 */
128 void vhditools_output_version_fprint(
129 FILE *stream,
130 const char *program )
131 {
132 if( stream == NULL )
133 {
134 return;
135 }
136 if( program == NULL )
137 {
138 return;
139 }
140 fprintf(
141 stream,
142 "%s %s\n\n",
143 program,
144 LIBVHDI_VERSION_STRING );
145 }
146
147 /* Prints the detailed version information
148 */
149 void vhditools_output_version_detailed_fprint(
150 FILE *stream,
151 const char *program )
152 {
153 if( stream == NULL )
154 {
155 return;
156 }
157 if( program == NULL )
158 {
159 return;
160 }
161 fprintf(
162 stream,
163 "%s %s (libvhdi %s",
164 program,
165 LIBVHDI_VERSION_STRING,
166 LIBVHDI_VERSION_STRING );
167
168 fprintf(
169 stream,
170 ", libuna %s",
171 LIBUNA_VERSION_STRING );
172
173 fprintf(
174 stream,
175 ", libbfio %s",
176 LIBBFIO_VERSION_STRING );
177
178 fprintf(
179 stream,
180 ")\n\n" );
181 }
182