Difference between revisions of "Truxton usb set media id"

From truxwiki.com
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 4: Line 4:
 
=Syntax=
 
=Syntax=
 
<source lang="C">
 
<source lang="C">
void truxton_usb_set_media_id( uint64_t usb_handle, char * id );
+
void truxton_usb_set_media_id( uint64_t usb_handle, char const * id );
 
</source>
 
</source>
  
Line 14: Line 14:
 
The string representation of a [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID.]
 
The string representation of a [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID.]
 
It corresponds to the <code>[MediaID]</code> column of the <code><nowiki>[</nowiki>[[USBDevice Table|USBDevice]]<nowiki>]</nowiki></code> table.
 
It corresponds to the <code>[MediaID]</code> column of the <code><nowiki>[</nowiki>[[USBDevice Table|USBDevice]]<nowiki>]</nowiki></code> table.
It should also be a value in the <code>[ID]</code> column of the <code>[Media]</code> table.
+
It should also be a value in the <code>[ID]</code> column of the <code><nowiki>[</nowiki>[[Media Table|Media]]<nowiki>]</nowiki></code> table.
  
 
=Sample=
 
=Sample=

Latest revision as of 07:47, 3 February 2024

This sets the media the USB information came from. This corresponds to the [MediaID] column of the [USBDevice] table.

Syntax

void truxton_usb_set_media_id( uint64_t usb_handle, char const * id );

Parameters

usb_handle

The handle to the USB device created by calling truxton_usb_create().

id

The string representation of a GUID. It corresponds to the [MediaID] column of the [USBDevice] table. It should also be a value in the [ID] column of the [Media] table.

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
   if ( truxton_usb_save( usb ) == 0 )
   {
      printf( "Cannot save USB to the database\n" );
   }
   else
   {
      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 );
}