Truxton message get signature

From truxwiki.com
Jump to navigation Jump to search

Gives you the first four bytes of the file's contents. This signature is often times called a magic value.

Syntax

uint32_t truxton_message_get_signature( uint64_t message_handle );

Parameters

message_handle

The handle to a message created by the truxton_message_create call.

Return value

The first four bytes of the file's contents. If the file length is less than four, this value will be padded with zeroes.

Sample

void dump_signature( uint64_t message )
{
   uint32_t signature = truxton_message_get_signature( message );

   printf( "Signature is %08" PRIX32 "\n", signature );
}

The PRIX32 in the sample code above is a standard way of formatting a 32-bit unsigned integer as hexadecimal 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.