Difference between revisions of "Truxton message get depot offset"

From truxwiki.com
Jump to navigation Jump to search
(Created page with "This tells you where in the depot file the file contents begin. This corresponds to the <code>Offset</code> column of the <code>Content</code> table. =Syntax= <syntaxhighligh...")
 
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
This tells you where in the depot file the file contents begin.
+
This tells you where in the [[Depot | depot]] file the file contents begin.
This corresponds to the <code>Offset</code> column of the <code>Content</code> table.
+
This corresponds to the <code>[Offset]</code> column of the <code>[Content]</code> table.
  
 
=Syntax=
 
=Syntax=
<syntaxhighlight lang="C">
+
<source lang="C">
 
uint32_t truxton_message_get_depot_offset( uint64_t message_handle );
 
uint32_t truxton_message_get_depot_offset( uint64_t message_handle );
</syntaxhighlight>
+
</source>
  
 
=Parameters=
 
=Parameters=
Line 12: Line 12:
  
 
=Return value=
 
=Return value=
The offset into the depot file where the file's contents begin.
+
The offset into the [[Depot | depot]] file where the file's contents begin.
  
 
=Sample=
 
=Sample=
<syntaxhighlight lang="C" highlight="3">
+
<source lang="C" highlight="3">
void dump_offset(uint64_t message)
+
void dump_offset( uint64_t message )
 
{
 
{
 
   uint64_t value = truxton_message_get_depot_offset( message );
 
   uint64_t value = truxton_message_get_depot_offset( message );
Line 22: Line 22:
 
   printf( "Offset is %" PRIu64 "\n", value );
 
   printf( "Offset is %" PRIu64 "\n", value );
 
}
 
}
</syntaxhighlight>
+
</source>
 +
 
 +
The <code>PRIu64</code> in the sample code above is a standard way of [https://en.wikipedia.org/wiki/C_data_types#Printf_and_scanf_format_specifiers formatting] a 64-bit unsigned integer in C.
 +
Over the years, different compilers on different operating systems used different format specifiers for things, these <code>PRI</code> 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.

Latest revision as of 07:22, 6 February 2021

This tells you where in the depot file the file contents begin. This corresponds to the [Offset] column of the [Content] table.

Syntax

uint32_t truxton_message_get_depot_offset( uint64_t message_handle );

Parameters

message_handle

The handle to a message created by the truxton_message_create call.

Return value

The offset into the depot file where the file's contents begin.

Sample

void dump_offset( uint64_t message )
{
   uint64_t value = truxton_message_get_depot_offset( message );

   printf( "Offset is %" PRIu64 "\n", value );
}

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.