コード例 #1
0
ファイル: libbde_support.c プロジェクト: kholia/libbde
/* Sets the narrow system string codepage
 * A value of 0 represents no codepage, UTF-8 encoding is used instead
 * Returns 1 if successful or -1 on error
 */
int libbde_set_codepage(
     int codepage,
     libcerror_error_t **error )
{
	static char *function = "libbde_set_codepage";

	if( libclocale_codepage_set(
	     codepage,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to set codepage.",
		 function );

		return( -1 );
	}
	return( 1 );
}
コード例 #2
0
ファイル: libclocale_support.c プロジェクト: Bletchley13/MBA
/* Initializes the locale values
 * Returns 1 if successful or -1 on error
 */
int libclocale_initialize(
     const char *domain_name,
     libcerror_error_t **error )
{
	static char *function = "libclocale_initialize";

#if !defined( HAVE_WIDE_SYSTEM_CHARACTER )
	int codepage          = 0;
#endif

	if( domain_name == NULL )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
		 LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
		 "%s: invalid domain name.",
		 function );

		return( -1 );
	}
#if defined( HAVE_BINDTEXTDOMAIN ) && defined( HAVE_TEXTDOMAIN )
	if( bindtextdomain(
	     domain_name,
	     LOCALEDIR ) == NULL )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to bind text domain.",
		 function );

		return( -1 );
	}
	if( textdomain(
	     domain_name ) == NULL )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to set text domain.",
		 function );

		return( -1 );
	}
#endif /* defined( HAVE_BINDTEXTDOMAIN ) && defined( HAVE_TEXTDOMAIN ) */

#if !defined( HAVE_WIDE_SYSTEM_CHARACTER )
	if( libclocale_locale_get_codepage(
	     &codepage,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
		 "%s: unable to retrieve codepage.",
		 function );

		return( -1 );
	}
	if( libclocale_codepage_set(
	     codepage,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_SET_FAILED,
		 "%s: unable to set codepage.",
		 function );

		return( -1 );
	}
#endif /* !defined( HAVE_WIDE_SYSTEM_CHARACTER ) */

	return( 1 );
}