Truxton note get object type

From truxwiki.com
Jump to navigation Jump to search

This retrieves the type of object of the note is associated with.

Syntax

uint64_t truxton_note_get_object_type( uint64_t note_handle );

Parameters

note_handle

This handle comes from calling truxton_note_create()

Return value

One of the defined constants values and present in the [ID] column of the [ObjectType] reference table in the database.

Sample

void create_note( void )
{
   uint64_t truxton = truxton_create();

   uint64_t note = truxton_note_create( truxton_handle );

   truxton_note_set_object_id( note, "65feb292-7995-137d-77cb-3ed80000000a" );
   truxton_note_set_investigation_id( note, "01da7796-a010-3685-0000-018902cb3b22" );
   truxton_note_set_text( note, "This is an interesting file." );
   truxton_note_set_object_type( note, OBJECT_TYPE_FILE );

   if ( truxton_note_save( note ) == 0 )
   {
      printf( "Cannot save investigation note to the database.\n" );
   }

   uint64_t type = truxton_note_get_object_type( note );
   printf("Object ID: %" PRIu64 "\n", type);

   truxton_note_destroy( note );
   truxton_destroy( truxton );
}

The PRIu64 in the sample code above is a standard way of formatting a 64-bit unsigned integer in C. Over the years, different compilers on different operating systems used different format specifiers for things, these PRI macros, along with some tricky string concatenation the compilers perform for you, allow you to maintain a single code base without a bunch of macro magic.