c - 我想用 c 语言使用 libimobiledevice 但我不明白

标签 c pointers

idevice_error_t idevice_get_device_list (char ***devices, int *count) 的含义是什么

我如何在idevice_get_device_list中传递参数

char ***devices 的含义是什么? 我如何创建变量并将其传递给 ***devices

请给我一个例子来说明如何使用此功能...

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. 

最佳答案

看来idevice_get_device_list接受一个指向 char** 类型变量的指针并将其设置为指向 char* 类型的值数组,也就是说,字符串。它还需要一个指向int类型变量的指针。并将其设置为该数组中的字符串数。

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

关于c - 我想用 c 语言使用 libimobiledevice 但我不明白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26961152/

相关文章:

c - RLE算法有缺陷吗?

从头开始创建 grep 命令

c - sizeof Pointer 因同一架构上的数据类型而异

c - main 和 main() 之间的区别

c - 用户的预期输入是 3 个字符串,但如果用户只给出 2 个字符串,那么我希望我的代码继续进行

c - 为什么没有不可变的整数集而不可变的字符集是可能的?

c - 将队列数据结构作为数组实现的问题

c++ - vector 指针,继承

c++ - 使用它的结构指针访问函数内的结构

c - Z3 无符号变量 - 简化