basic(3)

πŸ“¦ version 1.1.23, in arch rolling

πŸ’– basic(3) β€” the basic device management API πŸ’–

🌸 NAME 🌸

basic β€” The basic device management API. yes bestie, that's the whole name and the whole vibe πŸ’…


✨ SYNOPSIS ✨

🧚 Macros 🧚

#define LIBMTP_STORAGE_SORTBY_NOTSORTED   0
#define LIBMTP_STORAGE_SORTBY_FREESPACE   1
#define LIBMTP_STORAGE_SORTBY_MAXSPACE   2

🧚 Functions 🧚

LIBMTP_error_number_t LIBMTP_Detect_Raw_Devices (LIBMTP_raw_device_t **,
    int *)
int LIBMTP_Check_Specific_Device (int busno, int devno)
LIBMTP_mtpdevice_t * LIBMTP_Open_Raw_Device (LIBMTP_raw_device_t *)
LIBMTP_mtpdevice_t * LIBMTP_Open_Raw_Device_Uncached
    (LIBMTP_raw_device_t *)
LIBMTP_mtpdevice_t * LIBMTP_Get_Device (int)
LIBMTP_mtpdevice_t * LIBMTP_Get_First_Device (void)
LIBMTP_mtpdevice_t * LIBMTP_Get_Device_By_SerialNumber (char *)
LIBMTP_mtpdevice_t * LIBMTP_Get_Device_By_ID (char *)
LIBMTP_error_number_t LIBMTP_Get_Connected_Devices (LIBMTP_mtpdevice_t
    **)
uint32_t LIBMTP_Number_Devices_In_List (LIBMTP_mtpdevice_t *)
void LIBMTP_Release_Device_List (LIBMTP_mtpdevice_t *)
void LIBMTP_Release_Device (LIBMTP_mtpdevice_t *)
void LIBMTP_Dump_Device_Info (LIBMTP_mtpdevice_t *)
int LIBMTP_Reset_Device (LIBMTP_mtpdevice_t *)
char * LIBMTP_Get_Manufacturername (LIBMTP_mtpdevice_t *)
char * LIBMTP_Get_Modelname (LIBMTP_mtpdevice_t *)
char * LIBMTP_Get_Serialnumber (LIBMTP_mtpdevice_t *)
char * LIBMTP_Get_Deviceversion (LIBMTP_mtpdevice_t *)
char * LIBMTP_Get_Friendlyname (LIBMTP_mtpdevice_t *)
int LIBMTP_Set_Friendlyname (LIBMTP_mtpdevice_t *, char const *const)
char * LIBMTP_Get_Syncpartner (LIBMTP_mtpdevice_t *)
int LIBMTP_Set_Syncpartner (LIBMTP_mtpdevice_t *, char const *const)
int LIBMTP_Get_Batterylevel (LIBMTP_mtpdevice_t *, uint8_t *const,
    uint8_t *const)
int LIBMTP_Get_Secure_Time (LIBMTP_mtpdevice_t *, char **const)
int LIBMTP_Get_Device_Certificate (LIBMTP_mtpdevice_t *, char **const)
int LIBMTP_Get_Supported_Filetypes (LIBMTP_mtpdevice_t *, uint16_t
    **const, uint16_t *const)
int LIBMTP_Check_Capability (LIBMTP_mtpdevice_t *, LIBMTP_devicecap_t)
LIBMTP_error_t * LIBMTP_Get_Errorstack (LIBMTP_mtpdevice_t *)
void LIBMTP_Clear_Errorstack (LIBMTP_mtpdevice_t *)
void LIBMTP_Dump_Errorstack (LIBMTP_mtpdevice_t *)
void LIBMTP_FreeMemory (void *)
int LIBMTP_Get_Storage (LIBMTP_mtpdevice_t *, int const)
int LIBMTP_Format_Storage (LIBMTP_mtpdevice_t *, LIBMTP_devicestorage_t
    *)
char * LIBMTP_Get_String_From_Object (LIBMTP_mtpdevice_t *, uint32_t
    const, LIBMTP_property_t const)
uint64_t LIBMTP_Get_u64_From_Object (LIBMTP_mtpdevice_t *, uint32_t
    const, LIBMTP_property_t const, uint64_t const)
uint32_t LIBMTP_Get_u32_From_Object (LIBMTP_mtpdevice_t *, uint32_t
    const, LIBMTP_property_t const, uint32_t const)
uint16_t LIBMTP_Get_u16_From_Object (LIBMTP_mtpdevice_t *, uint32_t
    const, LIBMTP_property_t const, uint16_t const)
uint8_t LIBMTP_Get_u8_From_Object (LIBMTP_mtpdevice_t *, uint32_t const,
    LIBMTP_property_t const, uint8_t const)
int LIBMTP_Set_Object_String (LIBMTP_mtpdevice_t *, uint32_t const,
    LIBMTP_property_t const, char const *const)
int LIBMTP_Set_Object_u32 (LIBMTP_mtpdevice_t *, uint32_t const,
    LIBMTP_property_t const, uint32_t const)
int LIBMTP_Set_Object_u16 (LIBMTP_mtpdevice_t *, uint32_t const,
    LIBMTP_property_t const, uint16_t const)
int LIBMTP_Set_Object_u8 (LIBMTP_mtpdevice_t *, uint32_t const,
    LIBMTP_property_t const, uint8_t const)
char const * LIBMTP_Get_Property_Description (LIBMTP_property_t
    inproperty)
int LIBMTP_Is_Property_Supported (LIBMTP_mtpdevice_t *,
    LIBMTP_property_t const, LIBMTP_filetype_t const)
int LIBMTP_Get_Allowed_Property_Values (LIBMTP_mtpdevice_t *,
    LIBMTP_property_t const, LIBMTP_filetype_t const,
    LIBMTP_allowed_values_t *)
void LIBMTP_destroy_allowed_values_t (LIBMTP_allowed_values_t *)

🌈 Detailed Description 🌈

okay so this section is literally just the function-by-function tea below β€” no extra filler, bestie. let's get into it 🫢


πŸŽ€ Function Documentation πŸŽ€

🫢 int LIBMTP_Check_Capability (LIBMTP_mtpdevice_t * device, LIBMTP_devicecap_t cap) 🫢

this one checks if the device has some specific capabilities, so you can avoid calling APIs that may disturb the device. it's giving "look before you leap" energy πŸ’…

Parameters:

  • device β€” a pointer to the device to check the capability on. 🫢
  • cap β€” the capability to check. ✨

Returns:

  • 0 if not supported, any other value means the device has the requested capability. πŸ’–

References: LIBMTP_DEVICECAP_CopyObject, LIBMTP_DEVICECAP_EditObjects, LIBMTP_DEVICECAP_GetPartialObject, LIBMTP_DEVICECAP_MoveObject, LIBMTP_DEVICECAP_SendPartialObject, and LIBMTP_mtpdevice_struct::params.


πŸ” int LIBMTP_Check_Specific_Device (int busno, int devno) πŸ”

checks if a specific device with a certain bus and device number has an MTP type device descriptor. basically a vibe check for one exact device πŸ•΅οΈβ€β™€οΈ

Parameters:

  • busno β€” the bus number of the device to check. 🚌
  • devno β€” the device number of the device to check. πŸ”’

Returns:

  • 1 if the device is MTP else 0. periodt.

🧹 void LIBMTP_Clear_Errorstack (LIBMTP_mtpdevice_t * device) 🧹

this clears the error stack of a device and frees any memory used by it. call this when you're finished with using the errors, bestie β€” it's the cleanup era ✨

Parameters:

  • device β€” a pointer to the MTP device to clear the error stack for. 🫢

References: LIBMTP_mtpdevice_struct::errorstack.

Referenced by: LIBMTP_Release_Device().


πŸ’€ void LIBMTP_destroy_allowed_values_t (LIBMTP_allowed_values_t * allowed_vals) πŸ’€

destroys a LIBMTP_allowed_values_t struct. it's the "bye bye, struct" function, no cap πŸ’…

Parameters:

  • allowed_vals β€” the struct to destroy. πŸŽ€

References: LIBMTP_allowed_values_struct::datatype, and LIBMTP_allowed_values_struct::is_range.


πŸ•΅οΈβ€β™€οΈ LIBMTP_error_number_t LIBMTP_Detect_Raw_Devices (LIBMTP_raw_device_t ** devices, int * numdevs) πŸ•΅οΈβ€β™€οΈ

detects the raw MTP device descriptors and returns a list of the devices found. it's the "who's here?" function for hardware πŸ’–

Parameters:

  • devices β€” a pointer to a variable that will hold the list of raw devices found. This may be NULL on return if the number of detected devices is zero. The user shall simply free() this variable when finished with the raw devices, in order to release memory. 🫢
  • numdevs β€” a pointer to an integer that will hold the number of devices in the list. This may be 0. πŸ”’

Returns:

  • 0 if successful, any other value means failure. 😭

Examples: detect.c, files.c, folders.c, and tracks.c.

References: LIBMTP_raw_device_struct::bus_location, LIBMTP_raw_device_struct::device_entry, LIBMTP_device_entry_struct::device_flags, device_unknown(), LIBMTP_raw_device_struct::devnum, LIBMTP_device_entry_struct::product, LIBMTP_device_entry_struct::product_id, LIBMTP_device_entry_struct::vendor, and LIBMTP_device_entry_struct::vendor_id.

Referenced by: LIBMTP_Get_Connected_Devices(), LIBMTP_Get_Device(), and LIBMTP_Get_Device_By_SerialNumber().


πŸ“ void LIBMTP_Dump_Device_Info (LIBMTP_mtpdevice_t * device) πŸ“

this dumps out a large chunk of textual information provided from the PTP protocol and additionally some extra MTP-specific information where applicable. it's the "tell me everything" function and honestly? iconic ✨

Parameters:

  • device β€” a pointer to the MTP device to report info from. 🫢

References: LIBMTP_devicestorage_struct::AccessCapability, LIBMTP_mtpdevice_struct::default_album_folder, LIBMTP_mtpdevice_struct::default_music_folder, LIBMTP_mtpdevice_struct::default_organizer_folder, LIBMTP_mtpdevice_struct::default_picture_folder, LIBMTP_mtpdevice_struct::default_playlist_folder, LIBMTP_mtpdevice_struct::default_text_folder, LIBMTP_mtpdevice_struct::default_video_folder, LIBMTP_mtpdevice_struct::default_zencast_folder, LIBMTP_mtpdevice_struct::extensions, LIBMTP_devicestorage_struct::FilesystemType, LIBMTP_devicestorage_struct::FreeSpaceInBytes, LIBMTP_devicestorage_struct::FreeSpaceInObjects, LIBMTP_devicestorage_struct::id, LIBMTP_Get_Property_Description(), LIBMTP_device_extension_struct::major, LIBMTP_devicestorage_struct::MaxCapacity, LIBMTP_device_extension_struct::minor, LIBMTP_device_extension_struct::name, LIBMTP_device_extension_struct::next, LIBMTP_devicestorage_struct::next, LIBMTP_mtpdevice_struct::object_bitsize, LIBMTP_mtpdevice_struct::params, LIBMTP_mtpdevice_struct::storage, LIBMTP_devicestorage_struct::StorageDescription, LIBMTP_devicestorage_struct::StorageType, LIBMTP_mtpdevice_struct::usbinfo, and LIBMTP_devicestorage_struct::VolumeIdentifier.


πŸ’€ void LIBMTP_Dump_Errorstack (LIBMTP_mtpdevice_t * device) πŸ’€

this dumps the error stack to stderr. and yes, you still have to clear the stack though β€” dumping is not cleanup, bestie 😭

Parameters:

  • device β€” a pointer to the MTP device to dump the error stack for. 🫢

References: LIBMTP_mtpdevice_struct::errorstack.


⚠️ int LIBMTP_Format_Storage (LIBMTP_mtpdevice_t * device, LIBMTP_devicestorage_t * storage) ⚠️

formats device storage β€” if the device supports the operation.

⚠️ WARNING: This WILL delete all data from the device. Make sure you've got confirmation from the user BEFORE you call this function.

like, fr fr, do not skip the confirmation step. this is not the vibe to rush 😭

Parameters:

  • device β€” a pointer to the device containing the storage to format. πŸ’…
  • storage β€” the actual storage to format. πŸŽ€

Returns:

  • 0 on success, any other value means failure. 😭

References: LIBMTP_devicestorage_struct::id, and LIBMTP_mtpdevice_struct::params.


🫢 void LIBMTP_FreeMemory (void * mem) 🫢

frees memory allocated by libmtp. is doing the same as libc free(mem) in most cases. 🧚

and yeah, @mem β€” pointer to allocated memory. πŸ’…


πŸ’… int LIBMTP_Get_Allowed_Property_Values (LIBMTP_mtpdevice_t * device, LIBMTP_property_t const property, LIBMTP_filetype_t const filetype, LIBMTP_allowed_values_t * allowed_vals) πŸ’…

gets the allowed values β€” range or enum β€” for a property. it's the "what am I actually allowed to set?" function ✨

Parameters:

  • device β€” a pointer to an MTP device. 🫢
  • property β€” the property to query. πŸ”
  • filetype β€” the filetype of the object you want to set values for. πŸ“
  • allowed_vals β€” pointer to a LIBMTP_allowed_values_t struct to receive the allowed values. Call LIBMTP_destroy_allowed_values_t on this on successful completion. πŸŽ€

Returns:

  • 0 on success, any other value means failure. 😭

References: LIBMTP_allowed_values_struct::datatype, LIBMTP_allowed_values_struct::is_range, LIBMTP_allowed_values_struct::num_entries, and LIBMTP_mtpdevice_struct::params.


πŸ”‹ int LIBMTP_Get_Batterylevel (LIBMTP_mtpdevice_t * device, uint8_t *const maximum_level, uint8_t *const current_level) πŸ”‹

this function retrieves the current battery level on the device. battery check, bestie ✨

Parameters:

  • device β€” a pointer to the device to get the battery level for. 🫢
  • maximum_level β€” a pointer to a variable that will hold the maximum level of the battery if the call was successful. πŸ’–
  • current_level β€” a pointer to a variable that will hold the current level of the battery if the call was successful. A value of 0 means that the device is on external power. πŸ”Œ

Returns:

  • 0 if the storage info was successfully retrieved, any other means failure. A typical cause of failure is that the device does not support the battery level property. πŸ’€

part 2 has the rest of the function tea, coming right up πŸ’…

References: LIBMTP_mtpdevice_struct::maximum_battery_level, LIBMTP_mtpdevice_struct::params, and LIBMTP_mtpdevice_struct::usbinfo.

LIBMTP_error_number_t LIBMTP_Get_Connected_Devices (LIBMTP_mtpdevice_t ** device_list)

okay so this one grabs the first connected MTP device node in the linked list of devices. Currently this only provides access to USB devices, bestie β€” no cap.

Parameters

  • device_list β€” a list of devices ready to be used by the caller. You need to know how many there are.

Returns: any error information gathered from device connections.

See also: LIBMTP_Number_Devices_In_List()

References: LIBMTP_Detect_Raw_Devices().


LIBMTP_mtpdevice_t * LIBMTP_Get_Device (int device_nr)

Get a connected MTP device by its list position. slay.

Returns: a device pointer.

See also: LIBMTP_Get_Connected_Devices()

References: LIBMTP_Detect_Raw_Devices().

Referenced by: LIBMTP_Get_Device_By_ID(), and LIBMTP_Get_First_Device().


LIBMTP_mtpdevice_t * LIBMTP_Get_Device_By_ID (char * device_id)

Get a connected MTP device by list position or serial number. iykyk.

Returns: a device pointer.

See also: LIBMTP_Get_Connected_Devices()

References: LIBMTP_Get_Device(), and LIBMTP_Get_Device_By_SerialNumber().


LIBMTP_mtpdevice_t * LIBMTP_Get_Device_By_SerialNumber (char * serial_number)

Get a connected MTP device by serial number. periodt.

Returns: a device pointer.

See also: LIBMTP_Get_Connected_Devices()

References: LIBMTP_Detect_Raw_Devices(), LIBMTP_Release_Device(), and LIBMTP_mtpdevice_struct::params.

Referenced by: LIBMTP_Get_Device_By_ID().


int LIBMTP_Get_Device_Certificate (LIBMTP_mtpdevice_t * device, char **const devcert)

This function returns the device (public key) certificate as an XML document string from the device. iconic.

Parameters

  • device β€” a pointer to the device to get the device certificate for.
  • devcert β€” the device certificate as an XML string or NULL if the call failed or the device certificate property is not supported. This string must be free():ed by the caller after use.

Returns: 0 on success, any other value means failure.


char * LIBMTP_Get_Deviceversion (LIBMTP_mtpdevice_t * device)

This retrieves the device version (hardware and firmware version) of an MTP device. obsessed.

Parameters

  • device β€” a pointer to the device to get the device version for.

Returns: a newly allocated UTF-8 string representing the device version. The string must be freed by the caller after use. If the call was unsuccessful this will contain NULL.

References: LIBMTP_mtpdevice_struct::params.


LIBMTP_error_t * LIBMTP_Get_Errorstack (LIBMTP_mtpdevice_t * device)

This returns the error stack for a device in case you need to either reference the error numbers (e.g. when creating multilingual apps with multiple-language text representations for each error number) or when you need to build a multi-line error text widget or something like that. You need to call the LIBMTP_Clear_Errorstack to clear it when you're finished with it. bestie, that cleanup step is not optional.

Parameters

  • device β€” a pointer to the MTP device to get the error stack for.

Returns: the error stack or NULL if there are no errors on the stack.

See also: LIBMTP_Clear_Errorstack() and LIBMTP_Dump_Errorstack()

References: LIBMTP_mtpdevice_struct::errorstack.


LIBMTP_mtpdevice_t * LIBMTP_Get_First_Device (void )

Get the first (as in "first in the list of") connected MTP device. main character energy.

Returns: a device pointer.

See also: LIBMTP_Get_Connected_Devices()

References: LIBMTP_Get_Device().


char * LIBMTP_Get_Friendlyname (LIBMTP_mtpdevice_t * device)

This retrieves the "friendly name" of an MTP device. Usually this is simply the name of the owner or something like "John Doe's Digital Audio Player". This property should be supported by all MTP devices. cute.

Parameters

  • device β€” a pointer to the device to get the friendly name for.

Returns: a newly allocated UTF-8 string representing the friendly name. The string must be freed by the caller after use.

See also: LIBMTP_Set_Friendlyname()

References: LIBMTP_mtpdevice_struct::params.


char * LIBMTP_Get_Manufacturername (LIBMTP_mtpdevice_t * device)

This retrieves the manufacturer name of an MTP device. slay.

Parameters

  • device β€” a pointer to the device to get the manufacturer name for.

Returns: a newly allocated UTF-8 string representing the manufacturer name. The string must be freed by the caller after use. If the call was unsuccessful this will contain NULL.

References: LIBMTP_mtpdevice_struct::params.


char * LIBMTP_Get_Modelname (LIBMTP_mtpdevice_t * device)

This retrieves the model name (often equal to product name) of an MTP device. the way that this is usually just the product name is so real.

Parameters

  • device β€” a pointer to the device to get the model name for.

Returns: a newly allocated UTF-8 string representing the model name. The string must be freed by the caller after use. If the call was unsuccessful this will contain NULL.

References: LIBMTP_mtpdevice_struct::params.


char const * LIBMTP_Get_Property_Description (LIBMTP_property_t inproperty)

This helper function returns a textual description for a libmtp property to be used in dialog boxes etc. fr fr, it's giving helper-function realness.

Parameters

  • inproperty β€” the libmtp internal property to get a description for.

Returns: a string representing the filetype, this must NOT be free():ed by the caller!

References: propertymap_struct::description, and propertymap_struct::id.

Referenced by: LIBMTP_Dump_Device_Info().


int LIBMTP_Get_Secure_Time (LIBMTP_mtpdevice_t * device, char **const sectime)

This function returns the secure time as an XML document string from the device. secure the bag.

Parameters

  • device β€” a pointer to the device to get the secure time for.
  • sectime β€” the secure time string as an XML document or NULL if the call failed or the secure time property is not supported. This string must be free():ed by the caller after use.

Returns: 0 on success, any other value means failure.


char * LIBMTP_Get_Serialnumber (LIBMTP_mtpdevice_t * device)

This retrieves the serial number of an MTP device. no cap.

Parameters

  • device β€” a pointer to the device to get the serial number for.

Returns: a newly allocated UTF-8 string representing the serial number. The string must be freed by the caller after use. If the call was unsuccessful this will contain NULL.

References: LIBMTP_mtpdevice_struct::params.


int LIBMTP_Get_Storage (LIBMTP_mtpdevice_t * device, int const sortby)

okay so this function updates all the storage id's of a device and their properties, then creates a linked list and puts the list head into the device struct. It also optionally sorts this list. If you want to display storage information in your application you should call this function, then dereference the device struct (device->storage) to get out information on the storage. bestie, this is the storage glow-up.

You need to call this every time you want to update the device->storage list β€” for example anytime you need to check available storage somewhere.

⚠️ WARNING: since this list is dynamically updated, do not reference its fields in external applications by pointer! E.g do not put a reference to any char * field. instead strncpy() it!

Parameters

  • device β€” a pointer to the device to get the storage for.
  • sortby β€” an integer that determines the sorting of the storage list. Valid sort methods are defined in libmtp.h with beginning with LIBMTP_STORAGE_SORTBY_. 0 or LIBMTP_STORAGE_SORTBY_NOTSORTED to not sort.

Returns

  • 0 β€” success.
  • 1 β€” success but only with storage id's; storage properities could not be retrieved.
  • -1 β€” failure.

References: LIBMTP_devicestorage_struct::AccessCapability, LIBMTP_devicestorage_struct::FilesystemType, LIBMTP_devicestorage_struct::FreeSpaceInBytes, LIBMTP_devicestorage_struct::FreeSpaceInObjects, LIBMTP_devicestorage_struct::id, LIBMTP_devicestorage_struct::MaxCapacity, LIBMTP_devicestorage_struct::next, LIBMTP_mtpdevice_struct::params, LIBMTP_devicestorage_struct::prev, LIBMTP_mtpdevice_struct::storage, LIBMTP_devicestorage_struct::StorageDescription, LIBMTP_devicestorage_struct::StorageType, and LIBMTP_devicestorage_struct::VolumeIdentifier.

Referenced by: LIBMTP_Open_Raw_Device_Uncached().


char * LIBMTP_Get_String_From_Object (LIBMTP_mtpdevice_t * device, uint32_t const object_id, LIBMTP_property_t const attribute_id)

Get/set arbitrary properties. These do not update the cache; should only be used on properties not stored in structs. iykyk.

Retrieves a string from an object.

Parameters

  • device β€” a pointer to an MTP device.
  • object_id β€” object reference.
  • attribute_id β€” MTP attribute ID.

Returns: valid string or NULL on failure. The returned string must bee free():ed by the caller after use.


int LIBMTP_Get_Supported_Filetypes (LIBMTP_mtpdevice_t * device, uint16_t **const filetypes, uint16_t *const length)

This function retrieves a list of supported file types, i.e. the file types that this device claims it supports, e.g. audio file types that the device can play etc. This list is mitigated to include the file types that libmtp can handle, i.e. it will not list filetypes that libmtp will handle internally like playlists and folders. the way that it filters out libmtp's own internal faves is lowkey iconic.

Parameters

  • device β€” a pointer to the device to get the filetype capabilities for.
  • filetypes β€” a pointer to a pointer that will hold the list of supported filetypes if the call was successful. This list must be free():ed by the caller after use.
  • length β€” a pointer to a variable that will hold the length of the list of supported filetypes if the call was successful.

Returns: 0 on success, any other value means failure.

See also: LIBMTP_Get_Filetype_Description()

References: LIBMTP_mtpdevice_struct::params, and LIBMTP_mtpdevice_struct::usbinfo.


char * LIBMTP_Get_Syncpartner (LIBMTP_mtpdevice_t * device)

This retrieves the synchronization partner of an MTP device. This property should be supported by all MTP devices. matching vibes.

Parameters

  • device β€” a pointer to the device to get the sync partner for.

Returns: a newly allocated UTF-8 string representing the synchronization partner. The string must be freed by the caller after use.

See also: LIBMTP_Set_Syncpartner()

References: LIBMTP_mtpdevice_struct::params.


uint16_t LIBMTP_Get_u16_From_Object (LIBMTP_mtpdevice_t * device, uint32_t const object_id, LIBMTP_property_t const attribute_id, uint16_t const value_default)

Retrieves an unsigned 16-bit integer from an object attribute. little u16 moment.

Parameters

  • device β€” a pointer to an MTP device.
  • object_id β€” object reference.
  • attribute_id β€” MTP attribute ID.
  • value_default β€” default value to return on failure.

Returns β€” a value ✨


uint32_t LIBMTP_Get_u32_From_Object

uint32_t LIBMTP_Get_u32_From_Object (LIBMTP_mtpdevice_t * device, uint32_t
    const object_id, LIBMTP_property_t const attribute_id, uint32_t const
    value_default)

Pulls an unsigned 32-bit integer out of an object attribute, bestie πŸ’–

Parameters

  • device β€” a pointer to an MTP device.
  • object_id β€” Object reference
  • attribute_id β€” MTP attribute ID
  • value_default β€” Default value to return on failure

Returns β€” the value 🫢

uint64_t LIBMTP_Get_u64_From_Object

uint64_t LIBMTP_Get_u64_From_Object (LIBMTP_mtpdevice_t * device, uint32_t
    const object_id, LIBMTP_property_t const attribute_id, uint64_t const
    value_default)

Grabs an unsigned 64-bit integer from an object attribute, no cap ✨

Parameters

  • device β€” a pointer to an MTP device.
  • object_id β€” Object reference
  • attribute_id β€” MTP attribute ID
  • value_default β€” Default value to return on failure

Returns β€” the value 🌸

uint8_t LIBMTP_Get_u8_From_Object

uint8_t LIBMTP_Get_u8_From_Object (LIBMTP_mtpdevice_t * device, uint32_t
    const object_id, LIBMTP_property_t const attribute_id, uint8_t const
    value_default)

Retrieves an unsigned 8-bit integer from an object attribute β€” tiny but mighty πŸŽ€

Parameters

  • device β€” a pointer to an MTP device.
  • object_id β€” Object reference
  • attribute_id β€” MTP attribute ID
  • value_default β€” Default value to return on failure

Returns β€” a value πŸ’«

int LIBMTP_Is_Property_Supported

int LIBMTP_Is_Property_Supported (LIBMTP_mtpdevice_t * device,
    LIBMTP_property_t const property, LIBMTP_filetype_t const filetype)

Checks whether a property is supported for a given file type πŸ‘€

Parameters

  • device β€” a pointer to an MTP device
  • property β€” the property to query
  • filetype β€” the filetype of the object you want to set values for

Returns β€” 0 if not supported, positive if supported, negative on error πŸ’…

References: LIBMTP_mtpdevice_struct::params.

uint32_t LIBMTP_Number_Devices_In_List

uint32_t LIBMTP_Number_Devices_In_List (LIBMTP_mtpdevice_t * device_list)

Tells you how many devices are available in the listed device list πŸ”₯

Parameters

  • device_list β€” Pointer to a linked list of devices

Returns β€” Number of devices in the device list device_list πŸ‘‘

See also: LIBMTP_Get_Connected_Devices()

References: LIBMTP_mtpdevice_struct::next.

LIBMTP_mtpdevice_t * LIBMTP_Open_Raw_Device_Uncached

LIBMTP_mtpdevice_t * LIBMTP_Open_Raw_Device_Uncached (LIBMTP_raw_device_t *
    rawdevice)

This one opens a device from a raw device. It’s the preferred way to access devices in the new interface where several devices can come and go while the library is working on a certain device β€” main character energy fr fr πŸ¦‹

Parameters

  • rawdevice β€” the raw device to open a β€œreal” device for.

Returns β€” an open device ✨

References: LIBMTP_raw_device_struct::bus_location, LIBMTP_mtpdevice_struct::cached, LIBMTP_mtpdevice_struct::default_album_folder, LIBMTP_mtpdevice_struct::default_music_folder, LIBMTP_mtpdevice_struct::default_organizer_folder, LIBMTP_mtpdevice_struct::default_picture_folder, LIBMTP_mtpdevice_struct::default_playlist_folder, LIBMTP_mtpdevice_struct::default_text_folder, LIBMTP_mtpdevice_struct::default_video_folder, LIBMTP_mtpdevice_struct::default_zencast_folder, LIBMTP_raw_device_struct::device_entry, DEVICE_FLAG_FLAC_IS_UNKNOWN, DEVICE_FLAG_OGG_IS_UNKNOWN, LIBMTP_device_entry_struct::device_flags, DEVICE_FLAGS_ANDROID_BUGS, DEVICE_FLAGS_ARICENT_BUGS, DEVICE_FLAGS_SONY_NWZ_BUGS, LIBMTP_raw_device_struct::devnum, LIBMTP_mtpdevice_struct::errorstack, LIBMTP_mtpdevice_struct::extensions, LIBMTP_Get_Storage(), LIBMTP_mtpdevice_struct::maximum_battery_level, LIBMTP_device_extension_struct::name, LIBMTP_device_extension_struct::next, LIBMTP_mtpdevice_struct::object_bitsize, LIBMTP_mtpdevice_struct::params, _PTP_USB::rawdevice, LIBMTP_mtpdevice_struct::storage, and LIBMTP_mtpdevice_struct::usbinfo.

void LIBMTP_Release_Device

void LIBMTP_Release_Device (LIBMTP_mtpdevice_t * device)

Closes and releases an allocated MTP device. Cleanup era πŸ’…

Parameters

  • device β€” a pointer to the MTP device to release.

References: LIBMTP_mtpdevice_struct::extensions, LIBMTP_Clear_Errorstack(), LIBMTP_device_extension_struct::name, LIBMTP_device_extension_struct::next, LIBMTP_mtpdevice_struct::params, and LIBMTP_mtpdevice_struct::usbinfo.

Referenced by: LIBMTP_Get_Device_By_SerialNumber(), and LIBMTP_Release_Device_List().

void LIBMTP_Release_Device_List

void LIBMTP_Release_Device_List (LIBMTP_mtpdevice_t * device)

Also closes and releases an allocated MTP device 🧚

Parameters

  • device β€” a pointer to the MTP device to release.

References: LIBMTP_Release_Device(), LIBMTP_Release_Device_List(), and LIBMTP_mtpdevice_struct::next.

Referenced by: LIBMTP_Release_Device_List().

int LIBMTP_Reset_Device

int LIBMTP_Reset_Device (LIBMTP_mtpdevice_t * device)

Resets a device in case it supports the PTP_OC_ResetDevice operation code (0x1010) ⚑

Parameters

  • device β€” a pointer to the device to reset.

Returns β€” 0 on success, any other value means failure πŸ’€

References: LIBMTP_mtpdevice_struct::params.

int LIBMTP_Set_Friendlyname

int LIBMTP_Set_Friendlyname (LIBMTP_mtpdevice_t * device, char const *const
    friendlyname)

Sets the β€œfriendly name” of an MTP device β€” cute label moment πŸŽ€

Parameters

  • device β€” a pointer to the device to set the friendly name for.
  • friendlyname β€” the new friendly name for the device.

Returns β€” 0 on success, any other value means failure 😭

See also: LIBMTP_Get_Friendlyname()

References: LIBMTP_mtpdevice_struct::params.

int LIBMTP_Set_Object_String

int LIBMTP_Set_Object_String (LIBMTP_mtpdevice_t * device, uint32_t const
    object_id, LIBMTP_property_t const attribute_id, char const *const
    string)

Sets an object attribute from a string ✨

Parameters

  • device β€” a pointer to an MTP device.
  • object_id β€” Object reference
  • attribute_id β€” MTP attribute ID
  • string β€” string value to set

Returns β€” 0 on success, any other value means failure

int LIBMTP_Set_Object_u16

int LIBMTP_Set_Object_u16 (LIBMTP_mtpdevice_t * device, uint32_t const
    object_id, LIBMTP_property_t const attribute_id, uint16_t const value)

Sets an object attribute from an unsigned 16-bit integer πŸ’–

Parameters

  • device β€” a pointer to an MTP device.
  • object_id β€” Object reference
  • attribute_id β€” MTP attribute ID
  • value β€” 16-bit unsigned integer to set

Returns β€” 0 on success, any other value means failure

int LIBMTP_Set_Object_u32

int LIBMTP_Set_Object_u32 (LIBMTP_mtpdevice_t * device, uint32_t const
    object_id, LIBMTP_property_t const attribute_id, uint32_t const value)

Sets an object attribute from an unsigned 32-bit integer 🌈

Parameters

  • device β€” a pointer to an MTP device.
  • object_id β€” Object reference
  • attribute_id β€” MTP attribute ID
  • value β€” 32-bit unsigned integer to set

Returns β€” 0 on success, any other value means failure

int LIBMTP_Set_Object_u8

int LIBMTP_Set_Object_u8 (LIBMTP_mtpdevice_t * device, uint32_t const
    object_id, LIBMTP_property_t const attribute_id, uint8_t const value)

Sets an object attribute from an unsigned 8-bit integer πŸ“

Parameters

  • device β€” a pointer to an MTP device.
  • object_id β€” Object reference
  • attribute_id β€” MTP attribute ID
  • value β€” 8-bit unsigned integer to set

Returns β€” 0 on success, any other value means failure

int LIBMTP_Set_Syncpartner

int LIBMTP_Set_Syncpartner (LIBMTP_mtpdevice_t * device, char const *const
    syncpartner)

Sets the synchronization partner of an MTP device. Note that we have no idea what the effect of setting this to "foobar" may be. But the general idea seems to be to tell which program shall synchronize with this device and tell others to leave it alone πŸ‘€πŸ’…

Parameters

  • device β€” a pointer to the device to set the sync partner for.
  • syncpartner β€” the new synchronization partner for the device.

Returns β€” 0 on success, any other value means failure πŸ™ˆ

See also: LIBMTP_Get_Syncpartner()

References: LIBMTP_mtpdevice_struct::params.


πŸ‘‘ Author

Generated automatically by Doxygen for libmtp from the source code.


That’s the whole basic(3) vibe, bestie πŸ’– huge shoutout to libmtp, version 1.1.23, and the basic(3) page β€” the footer didn’t hand me a date, so I’m not inventing one, but the source/version is right there and it ate ✨🫢

πŸ“¦ where this page comes from