Difference between revisions of "Truxton usb create"
Jump to navigation
Jump to search
(Created page with "This creates an object you can use to record a USB device in Truxton. This adds records to the <code><nowiki>[</nowiki>USBDevice<nowiki>]</nowiki></code> t...") |
|||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
This creates an object you can use to record a USB device in Truxton. | This creates an object you can use to record a USB device in Truxton. | ||
| − | This adds | + | This adds a record to the <code><nowiki>[</nowiki>[[USBDevice Table|USBDevice]]<nowiki>]</nowiki></code> table. |
=Syntax= | =Syntax= | ||
| Line 17: | Line 17: | ||
=Sample= | =Sample= | ||
<source lang="C" highlight="9"> | <source lang="C" highlight="9"> | ||
| − | void add_thumb_drive( uint64_t truxton, uint64_t media, uint64_t child_file, uint64_t when ) | + | void add_thumb_drive( uint64_t truxton, uint64_t media, uint64_t child_file, uint64_t when, uint64_t where ) |
{ | { | ||
char media_id[ 65 ]; | char media_id[ 65 ]; | ||
char file_id[ 65 ]; | char file_id[ 65 ]; | ||
| + | char usb_id[ 65 ]; | ||
truxton_media_get_id( media, media_id, sizeof( media_id ) ); | truxton_media_get_id( media, media_id, sizeof( media_id ) ); | ||
| Line 29: | Line 30: | ||
truxton_usb_set_file_id( usb, file_id ); | truxton_usb_set_file_id( usb, file_id ); | ||
truxton_usb_set_media_id( usb, media_id ); | truxton_usb_set_media_id( usb, media_id ); | ||
| − | truxton_usb_set_when( when ); | + | truxton_usb_set_when( usb, when ); |
| + | truxton_usb_set_vendor_id( usb, 0x8EC ); | ||
| + | truxton_usb_set_product_id( usb, 0x16 ); | ||
| + | truxton_usb_set_file_offset( usb, where ); | ||
// Commit the data to the database | // Commit the data to the database | ||
| − | truxton_usb_save( | + | truxton_usb_save( usb ); |
| − | truxton_usb_destroy( | + | |
| + | truxton_usb_get_id( usb, usb_id, sizeof( usb_id ) ); | ||
| + | printf( "USB information saved to record id %s\n", usb_id ); | ||
| + | truxton_usb_destroy( usb ); | ||
} | } | ||
</source> | </source> | ||
Latest revision as of 07:36, 26 January 2021
This creates an object you can use to record a USB device in Truxton.
This adds a record to the [USBDevice] table.
Syntax
uint64_t truxton_usb_create( uint64_t truxton_handle );
Parameters
truxton_handle
The Truxton instance this USB device will belong.
This handle comes from calling truxton_create().
Return value
A handle to a USB object.
Sample
void add_thumb_drive( uint64_t truxton, uint64_t media, uint64_t child_file, uint64_t when, uint64_t where )
{
char media_id[ 65 ];
char file_id[ 65 ];
char usb_id[ 65 ];
truxton_media_get_id( media, media_id, sizeof( media_id ) );
truxton_child_file_get_id( child_file, file_id, sizeof( file_id ) );
uint64_t usb = truxton_usb_create( truxton );
truxton_usb_set_file_id( usb, file_id );
truxton_usb_set_media_id( usb, media_id );
truxton_usb_set_when( usb, when );
truxton_usb_set_vendor_id( usb, 0x8EC );
truxton_usb_set_product_id( usb, 0x16 );
truxton_usb_set_file_offset( usb, where );
// Commit the data to the database
truxton_usb_save( usb );
truxton_usb_get_id( usb, usb_id, sizeof( usb_id ) );
printf( "USB information saved to record id %s\n", usb_id );
truxton_usb_destroy( usb );
}