| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 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 |
|
| 37 |
|
| 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 |
| 90 |
|
| 91 |
return( 1 ); |
| 92 |
} |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
void vhditools_output_copyright_fprint( |
| 97 |
FILE *stream ) |
| 98 |
{ |
| 99 |
if( stream == NULL ) |
| 100 |
{ |
| 101 |
return; |
| 102 |
} |
| 103 |
|
| 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 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
fprintf( |
| 121 |
stream, |
| 122 |
_( "Report bugs to <%s>.\n" ), |
| 123 |
PACKAGE_BUGREPORT ); |
| 124 |
} |
| 125 |
|
| 126 |
|
| 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 |
|
| 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 |
|