| 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 <types.h> |
| 24 |
|
| 25 |
#if defined( HAVE_LIBINTL_H ) && defined( ENABLE_NLS ) |
| 26 |
#include <libintl.h> |
| 27 |
#endif |
| 28 |
|
| 29 |
#include "libclocale_codepage.h" |
| 30 |
#include "libclocale_definitions.h" |
| 31 |
#include "libclocale_libcerror.h" |
| 32 |
#include "libclocale_locale.h" |
| 33 |
#include "libclocale_support.h" |
| 34 |
|
| 35 |
#if !defined( HAVE_LOCAL_LIBCLOCALE ) |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
const char *libclocale_get_version( |
| 40 |
void ) |
| 41 |
{ |
| 42 |
return( (const char *) LIBCLOCALE_VERSION_STRING ); |
| 43 |
} |
| 44 |
|
| 45 |
#endif |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
int libclocale_initialize( |
| 51 |
const char *domain_name, |
| 52 |
libcerror_error_t **error ) |
| 53 |
{ |
| 54 |
static char *function = "libclocale_initialize"; |
| 55 |
|
| 56 |
#if !defined( HAVE_WIDE_SYSTEM_CHARACTER ) |
| 57 |
int codepage = 0; |
| 58 |
#endif |
| 59 |
|
| 60 |
if( domain_name == NULL ) |
| 61 |
{ |
| 62 |
libcerror_error_set( |
| 63 |
error, |
| 64 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 65 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 66 |
"%s: invalid domain name.", |
| 67 |
function ); |
| 68 |
|
| 69 |
return( -1 ); |
| 70 |
} |
| 71 |
#if defined( HAVE_BINDTEXTDOMAIN ) && defined( HAVE_TEXTDOMAIN ) && defined( LOCALEDIR ) |
| 72 |
if( bindtextdomain( |
| 73 |
domain_name, |
| 74 |
LOCALEDIR ) == NULL ) |
| 75 |
{ |
| 76 |
libcerror_error_set( |
| 77 |
error, |
| 78 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 79 |
LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
| 80 |
"%s: unable to bind text domain.", |
| 81 |
function ); |
| 82 |
|
| 83 |
return( -1 ); |
| 84 |
} |
| 85 |
if( textdomain( |
| 86 |
domain_name ) == NULL ) |
| 87 |
{ |
| 88 |
libcerror_error_set( |
| 89 |
error, |
| 90 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 91 |
LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
| 92 |
"%s: unable to set text domain.", |
| 93 |
function ); |
| 94 |
|
| 95 |
return( -1 ); |
| 96 |
} |
| 97 |
#endif |
| 98 |
|
| 99 |
#if !defined( HAVE_WIDE_SYSTEM_CHARACTER ) |
| 100 |
if( libclocale_locale_get_codepage( |
| 101 |
&codepage, |
| 102 |
error ) != 1 ) |
| 103 |
{ |
| 104 |
libcerror_error_set( |
| 105 |
error, |
| 106 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 107 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 108 |
"%s: unable to retrieve codepage.", |
| 109 |
function ); |
| 110 |
|
| 111 |
return( -1 ); |
| 112 |
} |
| 113 |
if( libclocale_codepage_set( |
| 114 |
codepage, |
| 115 |
error ) != 1 ) |
| 116 |
{ |
| 117 |
libcerror_error_set( |
| 118 |
error, |
| 119 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 120 |
LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
| 121 |
"%s: unable to set codepage.", |
| 122 |
function ); |
| 123 |
|
| 124 |
return( -1 ); |
| 125 |
} |
| 126 |
#endif |
| 127 |
|
| 128 |
return( 1 ); |
| 129 |
} |
| 130 |
|