uint8_t*	PffNodeEmailTransportHeaders::dataBuffer(void)
{
  uint8_t*		entry_string = NULL;
  libpff_item_t*	item = NULL;

  if (this->size() <= 0)
    return (NULL);

  if (this->pff_item == NULL)
  {
    if (libpff_file_get_item_by_identifier(*(this->pff_file), this->identifier, &item, this->pff_error) != 1)
    {
      return (NULL);
    }
  }
  else
    item = *(this->pff_item);	
  entry_string =  new uint8_t [this->size()];
  if (libpff_message_get_transport_headers(item, entry_string, this->size(), this->pff_error ) != 1 )
  {
    if (this->pff_item == NULL)
      libpff_item_free(&item, this->pff_error);
    delete entry_string;
    return (NULL);
  }
 
  if (this->pff_item == NULL)
    libpff_item_free(&item, this->pff_error);
  return (entry_string);
}
Exemple #2
0
/* Closes the info handle
 * Returns the 0 if succesful or -1 on error
 */
int info_handle_close(
     info_handle_t *info_handle,
     libcerror_error_t **error )
{
	static char *function = "info_handle_close";
	int result            = 0;

	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->root_item != NULL )
	{
		if( libpff_item_free(
		     &( info_handle->root_item ),
		     error ) != 1 )
		{
			libcerror_error_set(
			 error,
			 LIBCERROR_ERROR_DOMAIN_RUNTIME,
			 LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED,
			 "%s: unable to free root item.",
			 function );

			result = -1;
		}
	}
	if( libpff_file_close(
	     info_handle->input_file,
	     error ) != 0 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_IO,
		 LIBCERROR_IO_ERROR_CLOSE_FAILED,
		 "%s: unable to close input file.",
		 function );

		result = -1;
	}
	return( result );
}
Exemple #3
0
Attributes	PffNodeTask::_attributes(void)
{
  Attributes		attr;
  libpff_item_t*	item = NULL;

  
  if (this->pff_item == NULL)
  {
    if (libpff_file_get_item_by_identifier(*(this->pff_file), this->identifier, &item, this->pff_error) != 1)
      return attr;
  }
  else 
    item = *(this->pff_item);

  attr = this->allAttributes(item);
  Attributes	task;
  this->attributesTask(&task, item);
  attr[std::string("Task")] = new Variant(task);

  if (this->pff_item == NULL)
    libpff_item_free(&item, this->pff_error);

  return attr;
}
Exemple #4
0
/* Prints the message store to a stream
 * Returns 1 if successful or -1 on error
 */
int info_handle_message_store_fprint(
     info_handle_t *info_handle,
     libcerror_error_t **error )
{
	libpff_item_t *message_store        = NULL;
	libpff_record_entry_t *record_entry = NULL;
	libpff_record_set_t *record_set     = NULL;
	static char *function               = "info_handle_message_store_fprint";
	uint32_t password_checksum          = 0;
	uint32_t valid_folder_mask          = 0;
	int result                          = 0;

	if( info_handle == NULL )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
		 LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
		 "%s: invalid info handle.",
		 function );

		return( -1 );
	}
	result = libpff_file_get_message_store(
	          info_handle->input_file,
	          &message_store,
	          error );

	if( result == -1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
		 "%s: unable to retrieve message store.",
		 function );

		goto on_error;
	}
	else if( result == 0 )
	{
		return( 1 );
	}
	if( libpff_item_get_record_set_by_index(
	     message_store,
	     0,
	     &record_set,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
		 "%s: unable to retrieve record set.",
		 function );

		goto on_error;
	}
	fprintf(
	 info_handle->notify_stream,
	 "Message store:\n" );

	result = libpff_record_set_get_entry_by_type(
		  record_set,
		  LIBPFF_ENTRY_TYPE_MESSAGE_STORE_VALID_FOLDER_MASK,
		  LIBPFF_VALUE_TYPE_INTEGER_32BIT_SIGNED,
		  &record_entry,
		  0,
		  error );

	if( result == -1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
		 "%s: unable to retrieve valid folder mask record entry.",
		 function );

		goto on_error;
	}
	else if( result != 0 )
	{
		if( libpff_record_entry_get_value_32bit(
		     record_entry,
		     &valid_folder_mask,
		     error ) != 1 )
		{
			libcerror_error_set(
			 error,
			 LIBCERROR_ERROR_DOMAIN_RUNTIME,
			 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
			 "%s: unable to retrieve valid folder mask value.",
			 function );

			goto on_error;
		}
		fprintf(
		 info_handle->notify_stream,
		 "\tFolders:\t\t" );

		if( ( valid_folder_mask & LIBPFF_VALID_FOLDER_MASK_SUBTREE ) != 0 )
		{
			fprintf(
			 info_handle->notify_stream,
			 "Subtree, " );
		}
		if( ( valid_folder_mask & LIBPFF_VALID_FOLDER_MASK_INBOX ) != 0 )
		{
			fprintf(
			 info_handle->notify_stream,
			 "Inbox, " );
		}
		if( ( valid_folder_mask & LIBPFF_VALID_FOLDER_MASK_OUTBOX ) != 0 )
		{
			fprintf(
			 info_handle->notify_stream,
			 "Outbox, " );
		}
		if( ( valid_folder_mask & LIBPFF_VALID_FOLDER_MASK_WASTEBOX ) != 0 )
		{
			fprintf(
			 info_handle->notify_stream,
			 "Wastbox, " );
		}
		if( ( valid_folder_mask & LIBPFF_VALID_FOLDER_MASK_SENTMAIL ) != 0 )
		{
			fprintf(
			 info_handle->notify_stream,
			 "Sentmail, " );
		}
		if( ( valid_folder_mask & LIBPFF_VALID_FOLDER_MASK_VIEWS ) != 0 )
		{
			fprintf(
			 info_handle->notify_stream,
			 "Views, " );
		}
		if( ( valid_folder_mask & LIBPFF_VALID_FOLDER_MASK_COMMON_VIEWS ) != 0 )
		{
			fprintf(
			 info_handle->notify_stream,
			 "Common views, " );
		}
		if( ( valid_folder_mask & LIBPFF_VALID_FOLDER_MASK_FINDER ) != 0 )
		{
			fprintf(
			 info_handle->notify_stream,
			 "Finder" );
		}
		fprintf(
		 info_handle->notify_stream,
		 "\n" );

		if( libpff_record_entry_free(
		     &record_entry,
		     error ) != 1 )
		{
			libcerror_error_set(
			 error,
			 LIBCERROR_ERROR_DOMAIN_RUNTIME,
			 LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED,
			 "%s: unable to free record entry.",
			 function );

			goto on_error;
		}
	}
	result = libpff_record_set_get_entry_by_type(
		  record_set,
		  LIBPFF_ENTRY_TYPE_MESSAGE_STORE_PASSWORD_CHECKSUM,
		  LIBPFF_VALUE_TYPE_INTEGER_32BIT_SIGNED,
		  &record_entry,
		  0,
		  error );

	if( result == -1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
		 "%s: unable to retrieve password checksum record entry.",
		 function );

		goto on_error;
	}
	else if( result != 0 )
	{
		if( libpff_record_entry_get_value_32bit(
		     record_entry,
		     &valid_folder_mask,
		     error ) != 1 )
		{
			libcerror_error_set(
			 error,
			 LIBCERROR_ERROR_DOMAIN_RUNTIME,
			 LIBCERROR_RUNTIME_ERROR_GET_FAILED,
			 "%s: unable to retrieve password checksum value.",
			 function );

			goto on_error;
		}
		fprintf(
		 info_handle->notify_stream,
		 "\tPassword checksum:\t" );

		if( password_checksum == 0 )
		{
			fprintf(
			 info_handle->notify_stream,
			 "N/A" );
		}
		else
		{
			fprintf(
			 info_handle->notify_stream,
			 "0x%08" PRIx32 "",
			 password_checksum );
		}
		fprintf(
		 info_handle->notify_stream,
		 "\n" );

		if( libpff_record_entry_free(
		     &record_entry,
		     error ) != 1 )
		{
			libcerror_error_set(
			 error,
			 LIBCERROR_ERROR_DOMAIN_RUNTIME,
			 LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED,
			 "%s: unable to free record entry.",
			 function );

			goto on_error;
		}
	}
	fprintf(
	 info_handle->notify_stream,
	 "\n" );

	if( libpff_record_set_free(
	     &record_set,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED,
		 "%s: unable to free record set.",
		 function );

		goto on_error;
	}
	if( libpff_item_free(
	     &message_store,
	     error ) != 1 )
	{
		libcerror_error_set(
		 error,
		 LIBCERROR_ERROR_DOMAIN_RUNTIME,
		 LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED,
		 "%s: unable to free message store item.",
		 function );

		goto on_error;
	}
	return( 1 );

on_error:
	if( record_entry != NULL )
	{
		libpff_record_entry_free(
		 &record_entry,
		 NULL );
	}
	if( record_set != NULL )
	{
		libpff_record_set_free(
		 &record_set,
		 NULL );
	}
	if( message_store != NULL )
	{
		libpff_item_free(
		 &message_store,
		 NULL );
	}
	return( -1 );
}
Exemple #5
0
/* Frees an item object
 */
void pypff_item_free(
      pypff_item_t *pypff_item )
{
	libcerror_error_t *error    = NULL;
	struct _typeobject *ob_type = NULL;
	static char *function       = "pypff_item_free";

	if( pypff_item == NULL )
	{
		PyErr_Format(
		 PyExc_TypeError,
		 "%s: invalid item.",
		 function );

		return;
	}
	if( pypff_item->item == NULL )
	{
		PyErr_Format(
		 PyExc_TypeError,
		 "%s: invalid item - missing libpff item.",
		 function );

		return;
	}
	ob_type = Py_TYPE(
	           pypff_item );

	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( libpff_item_free(
	     &( pypff_item->item ),
	     &error ) != 1 )
	{
		pypff_error_raise(
		 error,
		 PyExc_IOError,
		 "%s: unable to free libpff item.",
		 function );

		libcerror_error_free(
		 &error );
	}
	if( pypff_item->file_object != NULL )
	{
		Py_DecRef(
		 (PyObject *) pypff_item->file_object );
	}
	ob_type->tp_free(
	 (PyObject*) pypff_item );
}