本文整理汇总了C++中irecv_client_t类的典型用法代码示例。如果您正苦于以下问题:C++ irecv_client_t类的具体用法?C++ irecv_client_t怎么用?C++ irecv_client_t使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了irecv_client_t类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: irecv_close
irecv_error_t irecv_close(irecv_client_t client) {
if (client != NULL) {
if(client->disconnected_callback != NULL) {
irecv_event_t event;
event.size = 0;
event.data = NULL;
event.progress = 0;
event.type = IRECV_DISCONNECTED;
client->disconnected_callback(client, &event);
}
#ifndef WIN32
if (client->handle != NULL) {
if (client->mode != kDfuMode) {
libusb_release_interface(client->handle, client->interface);
}
libusb_close(client->handle);
client->handle = NULL;
}
#else
if (client->iBootPath!=NULL) {
free(client->iBootPath);
client->iBootPath = NULL;
}
if (client->DfuPath!=NULL) {
free(client->DfuPath);
client->DfuPath = NULL;
}
mobiledevice_closepipes(client);
#endif
free(client);
client = NULL;
}
return IRECV_E_SUCCESS;
}
开发者ID:EricSB,项目名称:idevicerestore,代码行数:35,代码来源:libirecovery.c
示例2: irecv_close
irecv_error_t irecv_close(irecv_client_t client) {
if (client != NULL) {
if(client->disconnected_callback != NULL) {
irecv_event_t event;
event.size = 0;
event.data = NULL;
event.progress = 0;
event.type = IRECV_DISCONNECTED;
client->disconnected_callback(client, &event);
}
if (client->handle != NULL) {
libusb_release_interface(client->handle, client->interface);
libusb_close(client->handle);
client->handle = NULL;
}
if (libirecovery_context != NULL) {
libusb_exit(libirecovery_context);
libirecovery_context = NULL;
}
free(client);
client = NULL;
}
return IRECV_E_SUCCESS;
}
开发者ID:Buzzard267,项目名称:libirecovery,代码行数:28,代码来源:libirecovery.c
示例3: irecv_receive
irecv_error_t irecv_receive(irecv_client_t client)
{
char buffer[BUFFER_SIZE];
int bytes = 0;
memset(buffer, '\0', BUFFER_SIZE);
if (check_context(client) != IRECV_E_SUCCESS)
return IRECV_E_NO_DEVICE;
while (irecv_bulk_transfer
(client, 0x81, (unsigned char *)buffer, BUFFER_SIZE, &bytes,
500) == 0) {
if (bytes > 0) {
if (client->received_callback != NULL) {
irecv_event_t event;
event.size = bytes;
event.data = buffer;
event.type = IRECV_RECEIVED;
if (client->received_callback(client, &event) !=
0) {
return IRECV_E_SUCCESS;
}
}
if (bytes < BUFFER_SIZE)
break;
} else
break;
}
return IRECV_E_SUCCESS;
}
开发者ID:mucit,项目名称:opensn0w,代码行数:31,代码来源:libirecovery.c
示例4: irecv_send_command
irecv_error_t irecv_send_command(irecv_client_t client, char *command)
{
irecv_error_t error = 0;
unsigned int length;
irecv_event_t event;
if (check_context(client) != IRECV_E_SUCCESS)
return IRECV_E_NO_DEVICE;
length = strlen(command);
if (length >= 0x100) {
length = 0xFF;
}
if (client->precommand_callback != NULL) {
event.size = length;
event.data = command;
event.type = IRECV_PRECOMMAND;
if (client->precommand_callback(client, &event)) {
return IRECV_E_SUCCESS;
}
}
error = irecv_send_command_raw(client, command);
if (error != IRECV_E_SUCCESS) {
DPRINT("Failed to send command %s\n", command);
if (error != IRECV_E_PIPE)
return error;
}
if (client->postcommand_callback != NULL) {
event.size = length;
event.data = command;
event.type = IRECV_POSTCOMMAND;
if (client->postcommand_callback(client, &event)) {
return IRECV_E_SUCCESS;
}
}
return IRECV_E_SUCCESS;
}
开发者ID:mucit,项目名称:opensn0w,代码行数:41,代码来源:libirecovery.c
示例5: irecv_recv_buffer
irecv_error_t irecv_recv_buffer(irecv_client_t client, char *buffer,
unsigned long length)
{
int recovery_mode = (client->mode != kDfuMode);
int packet_size, last, packets;
int i = 0;
int bytes = 0;
unsigned long count = 0;
if (check_context(client) != IRECV_E_SUCCESS)
return IRECV_E_NO_DEVICE;
packet_size = recovery_mode ? 0x2000 : 0x800;
last = length % packet_size;
packets = length / packet_size;
if (last != 0) {
packets++;
} else {
last = packet_size;
}
for (i = 0; i < packets; i++) {
unsigned short size = (i + 1) < packets ? packet_size : last;
bytes =
irecv_control_transfer(client, 0xA1, 2, 0, 0,
(unsigned char *)&buffer[i *
packet_size],
size, 1000);
if (bytes != size) {
return IRECV_E_USB_UPLOAD;
}
count += size;
if (client->progress_callback != NULL) {
irecv_event_t event;
event.progress =
((double)count / (double)length) * 100.0;
event.type = IRECV_PROGRESS;
event.data = "Downloading";
event.size = count;
client->progress_callback(client, &event);
} else {
DPRINT("Sent: %d bytes - %lu of %lu\n", bytes, count,
length);
}
}
return IRECV_E_SUCCESS;
}
开发者ID:mucit,项目名称:opensn0w,代码行数:50,代码来源:libirecovery.c
示例6: irecv_receive
irecv_error_t irecv_receive(irecv_client_t client) {
unsigned char buffer[BUFFER_SIZE];
memset(buffer, '\0', BUFFER_SIZE);
if (client == NULL || client->handle == NULL) {
return IRECV_E_NO_DEVICE;
}
int bytes = 0;
while (libusb_bulk_transfer(client->handle, 0x81, buffer, BUFFER_SIZE, &bytes, 100) == 0) {
if (bytes > 0) {
if (client->received_callback != NULL) {
irecv_event_t event;
event.size = bytes;
event.data = buffer;
event.type = IRECV_RECEIVED;
if (client->received_callback(client, &event) != 0) {
return IRECV_E_SUCCESS;
}
}
} else break;
}
return IRECV_E_SUCCESS;
}
开发者ID:Buzzard267,项目名称:libirecovery,代码行数:24,代码来源:libirecovery.c
示例7: irecv_send_buffer
irecv_error_t irecv_send_buffer(irecv_client_t client, unsigned char* buffer, unsigned long length, int dfuNotifyFinished) {
irecv_error_t error = 0;
int recovery_mode = (client->mode != kDfuMode);
if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE;
int packet_size = 0x800;
int last = length % packet_size;
int packets = length / packet_size;
if (last != 0) {
packets++;
} else {
last = packet_size;
}
/* initiate transfer */
if (recovery_mode) {
error = irecv_control_transfer(client, 0x41, 0, 0, 0, NULL, 0, 1000);
} else {
error = irecv_control_transfer(client, 0x21, 4, 0, 0, NULL, 0, 1000);
}
if (error != IRECV_E_SUCCESS) {
return error;
}
int i = 0;
double progress = 0;
unsigned long count = 0;
unsigned int status = 0;
int bytes = 0;
for (i = 0; i < packets; i++) {
int size = (i + 1) < packets ? packet_size : last;
/* Use bulk transfer for recovery mode and control transfer for DFU and WTF mode */
if (recovery_mode) {
error = irecv_bulk_transfer(client, 0x04, &buffer[i * packet_size], size, &bytes, 1000);
} else {
bytes = irecv_control_transfer(client, 0x21, 1, 0, 0, &buffer[i * packet_size], size, 1000);
}
if (bytes != size) {
return IRECV_E_USB_UPLOAD;
}
if (!recovery_mode) {
error = irecv_get_status(client, &status);
}
if (error != IRECV_E_SUCCESS) {
return error;
}
if (!recovery_mode && status != 5) {
return IRECV_E_USB_UPLOAD;
}
count += size;
if(client->progress_callback != NULL) {
irecv_event_t event;
event.progress = ((double) count/ (double) length) * 100.0;
event.type = IRECV_PROGRESS;
event.data = "Uploading";
event.size = count;
client->progress_callback(client, &event);
} else {
debug("Sent: %d bytes - %lu of %lu\n", bytes, count, length);
}
}
if (dfuNotifyFinished && !recovery_mode) {
irecv_control_transfer(client, 0x21, 1, 0, 0, (unsigned char*) buffer, 0, 1000);
for (i = 0; i < 3; i++) {
error = irecv_get_status(client, &status);
if (error != IRECV_E_SUCCESS) {
return error;
}
}
irecv_reset(client);
}
return IRECV_E_SUCCESS;
}
开发者ID:EricSB,项目名称:idevicerestore,代码行数:82,代码来源:libirecovery.c
注:本文中的irecv_client_t类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论