Пример #1
0
/* Prints a backtrace of the error to the stream
 * Returns the number of printed characters if successful or -1 on error
 */
int libmapidb_error_backtrace_fprint(
     libmapidb_error_t *error,
      FILE *stream )
{
	return( liberror_error_backtrace_fprint(
	         (liberror_error_t *) error,
	         stream ) );
}
Пример #2
0
/* Prints a backtrace of the error to the stream
 */
void libewf_error_backtrace_fprint(
      libewf_error_t *error,
      FILE *stream )
{
	liberror_error_backtrace_fprint(
	 (liberror_error_t *) error,
	 stream );
}
Пример #3
0
/* Prints the backtrace of the error on the notify stream
 * Returns the number of printed characters if successful or -1 on error
 */
int libsystem_notify_print_error_backtrace(
    liberror_error_t *error )
{
    if( libsystem_notify_stream == NULL )
    {
        return( -1 );
    }
    return( liberror_error_backtrace_fprint(
                error,
                libsystem_notify_stream ) );
}
Пример #4
0
/* Prints the backtrace of the error
 * Returns the amount of printed characters if successful or -1 on error
 */
int libnotify_fprint_error_backtrace(
     FILE *stream,
     liberror_error_t *error )
{
	if( stream == NULL )
	{
		return( -1 );
	}
	return( liberror_error_backtrace_fprint(
	         error,
	         stream ) );
}
Пример #5
0
/* Prints the backtrace of the error on the notify stream
 * Returns the number of printed characters if successful or -1 on error
 */
int libnotify_print_error_backtrace(
     liberror_error_t *error )
{
	if( libnotify_stream == NULL )
	{
		return( -1 );
	}
	if( liberror_error_backtrace_fprint(
	     error,
	     libnotify_stream ) != 1 )
	{
		return( -1 );
	}
	return( 1 );
}
Пример #6
0
/* Tests reading and writing chunks at a specific offset
 * Returns 1 if successful, 0 if not or -1 on error
 */
int ewf_test_read_write_chunk_at_offset(
     libewf_handle_t *handle,
     size32_t chunk_size,
     off64_t input_offset,
     int input_whence,
     size64_t input_size,
     off64_t expected_offset,
     size64_t expected_size )
{
	liberror_error_t *error   = NULL;
	uint8_t *chunk_buffer     = NULL;
	uint8_t *data_buffer      = NULL;
	const char *whence_string = NULL;
	size_t chunk_buffer_size  = 0;
	size_t data_buffer_size   = 0;
	int result                = 0;

	if( chunk_size == 0 )
	{
		return( -1 );
	}
#if SIZEOF_SIZE_T < 8
	if( (size_t) chunk_size > (size_t) SSIZE_MAX )
	{
		return( -1 );
	}
#endif
	if( input_whence == SEEK_CUR )
	{
		whence_string = "SEEK_CUR";
	}
	else if( input_whence == SEEK_END )
	{
		whence_string = "SEEK_END";
	}
	else if( input_whence == SEEK_SET )
	{
		whence_string = "SEEK_SET";
	}
	else
	{
		whence_string = "UNKNOWN";
	}
	fprintf(
	 stdout,
	 "Testing reading range and writing with offset: %" PRIi64 ", whence: %s and size: %" PRIu64 "\t",
	 input_offset,
	 whence_string,
	 input_size );

	result = ewf_test_seek_offset(
	          handle,
	          input_offset,
	          input_whence,
	          expected_offset,
	          &error );

	data_buffer_size = chunk_size;

	data_buffer = (uint8_t *) memory_allocate(
	                           sizeof( uint8_t ) * data_buffer_size );

	/* The compressed data can become larger than the uncompressed data
	 */
	chunk_buffer_size = chunk_size * 2;

	chunk_buffer = (uint8_t *) memory_allocate(
	                            sizeof( uint8_t ) * chunk_buffer_size );

	if( result == 1 )
	{
		if( input_offset >= 0 )
		{
			result = ewf_test_read_write_chunk(
				  handle,
				  data_buffer,
				  data_buffer_size,
				  chunk_buffer,
				  chunk_buffer_size,
				  input_size,
				  expected_size,
			          &error );
		}
	}
	memory_free(
	 chunk_buffer );
	memory_free(
	 data_buffer );

	if( result != 0 )
	{
		fprintf(
		 stdout,
		 "(PASS)" );
	}
	else
	{
		fprintf(
		 stdout,
		 "(FAIL)" );
	}
	fprintf(
	 stdout,
	 "\n" );

	if( result == -1 )
	{
		liberror_error_backtrace_fprint(
		 error,
		 stderr );

		liberror_error_free(
		 &error );
	}
	return( result );
}
Пример #7
0
/* Tests reading and writing a buffers at a specific offset
 * Returns 1 if successful, 0 if not or -1 on error
 */
int ewf_test_read_write_buffer_at_offset(
     libewf_handle_t *handle,
     off64_t input_offset,
     int input_whence,
     size64_t input_size,
     off64_t expected_offset,
     size64_t expected_size )
{
	liberror_error_t *error   = NULL;
	uint8_t *buffer           = NULL;
	const char *whence_string = NULL;
	int result                = 0;

	if( input_whence == SEEK_CUR )
	{
		whence_string = "SEEK_CUR";
	}
	else if( input_whence == SEEK_END )
	{
		whence_string = "SEEK_END";
	}
	else if( input_whence == SEEK_SET )
	{
		whence_string = "SEEK_SET";
	}
	else
	{
		whence_string = "UNKNOWN";
	}
	fprintf(
	 stdout,
	 "Testing reading and writing range with offset: %" PRIi64 ", whence: %s and size: %" PRIu64 "\t",
	 input_offset,
	 whence_string,
	 input_size );

	buffer = (uint8_t *) memory_allocate(
	                      EWF_TEST_BUFFER_SIZE );

	result = ewf_test_seek_offset(
	          handle,
	          input_offset,
	          input_whence,
	          expected_offset,
	          &error );

	if( result == 1 )
	{
		if( input_offset >= 0 )
		{
			result = ewf_test_read_write_buffer(
				  handle,
				  buffer,
				  EWF_TEST_BUFFER_SIZE,
				  input_size,
				  expected_size,
			          &error );
		}
	}
	memory_free(
	 buffer );

	if( result != 0 )
	{
		fprintf(
		 stdout,
		 "(PASS)" );
	}
	else
	{
		fprintf(
		 stdout,
		 "(FAIL)" );
	}
	fprintf(
	 stdout,
	 "\n" );

	if( result == -1 )
	{
		liberror_error_backtrace_fprint(
		 error,
		 stderr );

		liberror_error_free(
		 &error );
	}
	return( result );
}