/* Frees a file object */ void pyevt_file_free( pyevt_file_t *pyevt_file ) { struct _typeobject *ob_type = NULL; libcerror_error_t *error = NULL; static char *function = "pyevt_file_free"; int result = 0; if( pyevt_file == NULL ) { PyErr_Format( PyExc_ValueError, "%s: invalid file.", function ); return; } ob_type = Py_TYPE( pyevt_file ); if( ob_type == NULL ) { PyErr_Format( PyExc_ValueError, "%s: missing ob_type.", function ); return; } if( ob_type->tp_free == NULL ) { PyErr_Format( PyExc_ValueError, "%s: invalid ob_type - missing tp_free.", function ); return; } if( pyevt_file->file != NULL ) { Py_BEGIN_ALLOW_THREADS result = libevt_file_free( &( pyevt_file->file ), &error ); Py_END_ALLOW_THREADS if( result != 1 ) { pyevt_error_raise( error, PyExc_MemoryError, "%s: unable to free libevt file.", function ); libcerror_error_free( &error ); } }
/* Frees an info handle * Returns 1 if successful or -1 on error */ int info_handle_free( info_handle_t **info_handle, libcerror_error_t **error ) { static char *function = "info_handle_free"; int result = 1; if( info_handle == NULL ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_ARGUMENTS, LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, "%s: invalid info handle.", function ); return( -1 ); } if( *info_handle != NULL ) { if( libevt_file_free( &( ( *info_handle )->input_file ), error ) != 1 ) { libcerror_error_set( error, LIBCERROR_ERROR_DOMAIN_RUNTIME, LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, "%s: unable to free input file.", function ); result = -1; } memory_free( *info_handle ); *info_handle = NULL; } return( result ); }
int main( int argc, char * const argv[] ) #endif { libcerror_error_t *error = NULL; libevt_file_t *file = NULL; size_t string_length = 0; uint32_t feature_flags = 0; int ascii_codepage = 0; int result = 0; if( argc != 2 ) { fprintf( stderr, "Unsupported number of arguments.\n" ); return( EXIT_FAILURE ); } feature_flags = LIBCLOCALE_CODEPAGE_FEATURE_FLAG_HAVE_ISO_8859 | LIBCLOCALE_CODEPAGE_FEATURE_FLAG_HAVE_KOI8 | LIBCLOCALE_CODEPAGE_FEATURE_FLAG_HAVE_WINDOWS; string_length = libcstring_system_string_length( argv[ 1 ] ); #if defined( LIBCSTRING_HAVE_WIDE_SYSTEM_CHARACTER ) result = libclocale_codepage_copy_from_string_wide( &ascii_codepage, argv[ 1 ], string_length, feature_flags, &error ); #else result = libclocale_codepage_copy_from_string( &ascii_codepage, argv[ 1 ], string_length, feature_flags, &error ); #endif if( result == -1 ) { fprintf( stderr, "Unable to determine ASCII codepage from: %" PRIs_LIBCSTRING_SYSTEM ".\n", argv[ 1 ] ); goto on_error; } if( libevt_file_initialize( &file, &error ) != 1 ) { fprintf( stderr, "Unable to create file.\n" ); goto on_error; } if( libevt_file_set_ascii_codepage( file, ascii_codepage, &error ) != 1 ) { fprintf( stderr, "Unable to set codepage: %" PRIs_LIBCSTRING_SYSTEM ".\n", argv[ 1 ] ); goto on_error; } if( libevt_file_free( &file, &error ) != 1 ) { fprintf( stderr, "Unable to free file.\n" ); goto on_error; } return( EXIT_SUCCESS ); on_error: if( error != NULL ) { libcerror_error_backtrace_fprint( error, stderr ); libcerror_error_free( &error ); } if( file != NULL ) { libevt_file_free( &file, NULL ); } return( -1 ); }