Truxton enumeration create

From truxwiki.com
Jump to navigation Jump to search

Creates an enumeration object.

Syntax

uint64_t truxton_enumeration_create( uint64_t truxton_handle );

Parameters

truxton_handle

The Truxton instance this enumeration will use. This handle comes from calling truxton_create().

Return value

A non-zero value on success, zero on failure.

Sample

void dump_media_in_investigation( uint64_t truxton_handle, uint64_t investigation_handle )
{
    char media_name[ 256 ];
    char investigation_id[ 65 ];

    truxton_investigation_get_id( investigation_handle, investigation_id, sizeof( investigation_id ) );

    uint64_t enumerator = truxton_enumeration_create( truxton );

    // Now setup the enumeration to get the media in a particular investigation
    truxton_enumeration_set_scope( enumerator, Type_Investigation );
    truxton_enumeration_set_scope_id( enumerator, investigation_id );
    truxton_enumeration_set_target( enumerator, Type_Media );

    uint64_t media_handle = truxton_enumeration_get_next( enumerator );

    while( media_handle != 0 )
    {
        truxton_media_get_name( media_handle, media_name, sizeof( media_name ) );
        printf( "Media: %s\n", media_name );

        media_handle = truxton_enumeration_get_next( enumerator );
    }

    truxton_enumeration_destroy( enumerator );
}

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 );

    while( investigation_handle != 0 )
    {
        truxton_investigation_get_name( investigation_handle, investigation_name, sizeof( investigation_name ) );

        printf( "Investigation: %s\n", investigation_name );

        dump_media_in_investigation( truxton, investigation_handle );

        investigation_handle = truxton_enumeration_get_next( enumerator );
    }

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