abbas-h
abbas-h

Reputation: 450

i want work with libimobiledevice in c language but i dont understand

what is meaning of idevice_error_t idevice_get_device_list (char ***devices, int *count)

how i pass argument in idevice_get_device_list

what is meaning of char ***devices ? how i create variable and pass it for ***devices ?

please give me a example that show use this function ...

void    idevice_set_debug_level (int level)
    Sets the level of debugging.
idevice_error_t     idevice_event_subscribe (idevice_event_cb_t callback, void *user_data)
    Register a callback function that will be called when device add/remove events occur.
idevice_error_t     idevice_event_unsubscribe ()
    Release the event callback function that has been registered with idevice_event_subscribe().
idevice_error_t     idevice_get_device_list (char ***devices, int *count)
    Get a list of currently available devices.
idevice_error_t     idevice_device_list_free (char **devices)
    Free a list of device uuids.
idevice_error_t     idevice_new (idevice_t *device, const char *uuid)
    Creates an idevice_t structure for the device specified by uuid, if the device is available.
idevice_error_t     idevice_free (idevice_t device)
    Cleans up an idevice structure, then frees the structure itself.
idevice_error_t     idevice_connect (idevice_t device, uint16_t port, idevice_connection_t *connection)
    Set up a connection to the given device.
idevice_error_t     idevice_disconnect (idevice_connection_t connection)
    Disconnect from the device and clean up the connection structure.
idevice_error_t     idevice_connection_send (idevice_connection_t connection, const char *data, uint32_t len, uint32_t *sent_bytes)
    Send data to a device via the given connection.
idevice_error_t     idevice_connection_receive_timeout (idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes, unsigned int timeout)
    Receive data from a device via the given connection.
idevice_error_t     idevice_connection_receive (idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes)
    Receive data from a device via the given connection.
idevice_error_t     idevice_get_handle (idevice_t device, uint32_t *handle)
    Gets the handle of the device.
idevice_error_t     idevice_get_uuid (idevice_t device, char **uuid)
    Gets the unique id for the device. 

Upvotes: 1

Views: 595

Answers (1)

Jon Purdy
Jon Purdy

Reputation: 55059

It seems idevice_get_device_list takes a pointer to a variable of type char** and sets it to point to an array of values of type char*, which is to say, strings. It also takes a pointer to a variable of type int and sets it to the number of strings in that array.

char **device_list;
int count;

idevice_error_t status = idevice_get_device_list(&device_list, &count);

/* check status for error conditions here */

for (int i = 0; i < count; ++i) {
  printf("Device %d: %s\n", i, device_list[i]);
}

Upvotes: 1

Related Questions