Difference between revisions of "Truxton enumeration reset"

From truxwiki.com
Jump to navigation Jump to search
(Created page with "Resets the enumeration to the beginning. =Syntax= <source lang="C"> void truxton_enumeration_reset( uint64_t enumeration_handle ); </source> =Parameters= ==<code>enumeration...")
 
 
Line 12: Line 12:
 
=Sample=
 
=Sample=
 
<source lang="C" highlight="27">
 
<source lang="C" highlight="27">
void main()
+
void main( void )
 
{
 
{
 
   char investigation_name[256];
 
   char investigation_name[256];
Line 59: Line 59:
 
}
 
}
 
</source>
 
</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.
 
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.
 
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 10:53, 3 February 2024

Resets the enumeration to the beginning.

Syntax

void truxton_enumeration_reset( uint64_t enumeration_handle );

Parameters

enumeration_handle

The handle returned by calling truxton_enumeration_create().

Sample

void main( void )
{
   char investigation_name[256];

   truxton_start();

   uint64_t truxton = truxton_create();

   uint64_t enumerator = truxton_enumeration_create( truxton );

   truxton_enumeration_set_target( enumerator, Type_Investigation );

   uint64_t investigation_handle = truxton_enumeration_get_next( enumerator );

   uint64_t count = 0;

   print_details( enumerator );

   while( investigation_handle != 0 )
   {
      count++ 
      investigation_handle = truxton_enumeration_get_next( enumerator );
   }

   uint64_t internal_investigations = 0;

   truxton_enumeration_reset( enumerator );

   investigation_handle = truxton_enumeration_get_next( enumerator );
   
   while( investigation_handle != 0 )
   {
      if ( truxton_investigation_get_type( investigation_handle ) == INVESTIGATION_TYPE_INTERNAL )
      {
         internal_investigations++;
      }
 
      investigation_handle = truxton_enumeration_get_next( enumerator );
   }

   printf( "%" PRIu64 " investigations (%" PRIu64 " internal)\n", count, internal_investigations );

   truxton_enumeration_destroy( enumerator );
   truxton_destroy( truxton );
   truxton_stop();
}

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.