summaryrefslogtreecommitdiffstats
path: root/src/libirecovery.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2023-05-13 03:37:38 +0200
committerGravatar Nikias Bassen2023-05-13 03:37:38 +0200
commit0360cdc603abbfbce76c4c10d20cf80d98c0b1d6 (patch)
tree6771cee2c78aeb43f0bb900384e299b745b8284c /src/libirecovery.c
parent3b4ef6a3d109702694435087311258355df1b63a (diff)
downloadlibirecovery-0360cdc603abbfbce76c4c10d20cf80d98c0b1d6.tar.gz
libirecovery-0360cdc603abbfbce76c4c10d20cf80d98c0b1d6.tar.bz2
Coding style changes
Diffstat (limited to 'src/libirecovery.c')
-rw-r--r--src/libirecovery.c229
1 files changed, 136 insertions, 93 deletions
diff --git a/src/libirecovery.c b/src/libirecovery.c
index a91a742..6e7647b 100644
--- a/src/libirecovery.c
+++ b/src/libirecovery.c
@@ -2,7 +2,7 @@
* libirecovery.c
* Communication to iBoot/iBSS on Apple iOS devices via USB
*
- * Copyright (c) 2011-2020 Nikias Bassen <nikias@gmx.li>
+ * Copyright (c) 2011-2023 Nikias Bassen <nikias@gmx.li>
* Copyright (c) 2012-2020 Martin Szulecki <martin.szulecki@libimobiledevice.org>
* Copyright (c) 2010 Chronic-Dev Team
* Copyright (c) 2010 Joshua Hill
@@ -94,7 +94,7 @@ struct irecv_client_private {
#define APPLE_VENDOR_ID 0x05AC
#define BUFFER_SIZE 0x1000
-#define debug(...) if(libirecovery_debug) fprintf(stderr, __VA_ARGS__)
+#define debug(...) if (libirecovery_debug) fprintf(stderr, __VA_ARGS__)
static int libirecovery_debug = 0;
#ifndef USE_DUMMY
@@ -506,8 +506,8 @@ BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved)
#endif
#ifdef HAVE_IOKIT
-static int iokit_get_string_descriptor_ascii(irecv_client_t client, uint8_t desc_index, unsigned char * buffer, int size) {
-
+static int iokit_get_string_descriptor_ascii(irecv_client_t client, uint8_t desc_index, unsigned char * buffer, int size)
+{
IOReturn result;
IOUSBDevRequest request;
unsigned char descriptor[256];
@@ -554,7 +554,8 @@ static int iokit_get_string_descriptor_ascii(irecv_client_t client, uint8_t desc
}
#endif
-static int irecv_get_string_descriptor_ascii(irecv_client_t client, uint8_t desc_index, unsigned char * buffer, int size) {
+static int irecv_get_string_descriptor_ascii(irecv_client_t client, uint8_t desc_index, unsigned char * buffer, int size)
+{
#ifndef WIN32
#ifdef HAVE_IOKIT
return iokit_get_string_descriptor_ascii(client, desc_index, buffer, size);
@@ -640,10 +641,10 @@ static void irecv_load_device_info_from_iboot_string(irecv_client_t client, cons
char tmp[256];
tmp[0] = '\0';
ptr = strstr(iboot_string, "SRNM:[");
- if(ptr != NULL) {
+ if (ptr != NULL) {
sscanf(ptr, "SRNM:[%s]", tmp);
ptr = strrchr(tmp, ']');
- if(ptr != NULL) {
+ if (ptr != NULL) {
*ptr = '\0';
}
client->device_info.srnm = strdup(tmp);
@@ -651,10 +652,10 @@ static void irecv_load_device_info_from_iboot_string(irecv_client_t client, cons
tmp[0] = '\0';
ptr = strstr(iboot_string, "IMEI:[");
- if(ptr != NULL) {
+ if (ptr != NULL) {
sscanf(ptr, "IMEI:[%s]", tmp);
ptr = strrchr(tmp, ']');
- if(ptr != NULL) {
+ if (ptr != NULL) {
*ptr = '\0';
}
client->device_info.imei = strdup(tmp);
@@ -662,10 +663,10 @@ static void irecv_load_device_info_from_iboot_string(irecv_client_t client, cons
tmp[0] = '\0';
ptr = strstr(iboot_string, "SRTG:[");
- if(ptr != NULL) {
+ if (ptr != NULL) {
sscanf(ptr, "SRTG:[%s]", tmp);
ptr = strrchr(tmp, ']');
- if(ptr != NULL) {
+ if (ptr != NULL) {
*ptr = '\0';
}
client->device_info.srtg = strdup(tmp);
@@ -774,7 +775,8 @@ irecv_error_t mobiledevice_openpipes(irecv_client_t client);
void mobiledevice_closepipes(irecv_client_t client);
irecv_error_t mobiledevice_connect(irecv_client_t* client, uint64_t ecid);
-irecv_error_t mobiledevice_connect(irecv_client_t* client, uint64_t ecid) {
+irecv_error_t mobiledevice_connect(irecv_client_t* client, uint64_t ecid)
+{
int found = 0;
SP_DEVICE_INTERFACE_DATA currentInterface;
HDEVINFO usbDevices;
@@ -786,7 +788,7 @@ irecv_error_t mobiledevice_connect(irecv_client_t* client, uint64_t ecid) {
usbDevices = SetupDiGetClassDevs(&GUID_DEVINTERFACE_DFU, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
memset(&currentInterface, '\0', sizeof(SP_DEVICE_INTERFACE_DATA));
currentInterface.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
- for(i = 0; usbDevices && SetupDiEnumDeviceInterfaces(usbDevices, NULL, &GUID_DEVINTERFACE_DFU, i, &currentInterface); i++) {
+ for (i = 0; usbDevices && SetupDiEnumDeviceInterfaces(usbDevices, NULL, &GUID_DEVINTERFACE_DFU, i, &currentInterface); i++) {
free(_client->DfuPath);
_client->DfuPath = NULL;
_client->handle = NULL;
@@ -795,7 +797,7 @@ irecv_error_t mobiledevice_connect(irecv_client_t* client, uint64_t ecid) {
SetupDiGetDeviceInterfaceDetailA(usbDevices, &currentInterface, NULL, 0, &requiredSize, NULL);
details = (PSP_DEVICE_INTERFACE_DETAIL_DATA_A) malloc(requiredSize);
details->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_A);
- if(!SetupDiGetDeviceInterfaceDetailA(usbDevices, &currentInterface, details, requiredSize, NULL, NULL)) {
+ if (!SetupDiGetDeviceInterfaceDetailA(usbDevices, &currentInterface, details, requiredSize, NULL, NULL)) {
free(details);
continue;
} else {
@@ -879,7 +881,7 @@ irecv_error_t mobiledevice_connect(irecv_client_t* client, uint64_t ecid) {
usbDevices = SetupDiGetClassDevs(&GUID_DEVINTERFACE_IBOOT, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
memset(&currentInterface, '\0', sizeof(SP_DEVICE_INTERFACE_DATA));
currentInterface.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
- for(i = 0; usbDevices && SetupDiEnumDeviceInterfaces(usbDevices, NULL, &GUID_DEVINTERFACE_IBOOT, i, &currentInterface); i++) {
+ for (i = 0; usbDevices && SetupDiEnumDeviceInterfaces(usbDevices, NULL, &GUID_DEVINTERFACE_IBOOT, i, &currentInterface); i++) {
free(_client->iBootPath);
_client->iBootPath = NULL;
_client->handle = NULL;
@@ -888,7 +890,7 @@ irecv_error_t mobiledevice_connect(irecv_client_t* client, uint64_t ecid) {
SetupDiGetDeviceInterfaceDetailA(usbDevices, &currentInterface, NULL, 0, &requiredSize, NULL);
details = (PSP_DEVICE_INTERFACE_DETAIL_DATA_A) malloc(requiredSize);
details->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_A);
- if(!SetupDiGetDeviceInterfaceDetailA(usbDevices, &currentInterface, details, requiredSize, NULL, NULL)) {
+ if (!SetupDiGetDeviceInterfaceDetailA(usbDevices, &currentInterface, details, requiredSize, NULL, NULL)) {
free(details);
continue;
} else {
@@ -964,7 +966,8 @@ irecv_error_t mobiledevice_connect(irecv_client_t* client, uint64_t ecid) {
return IRECV_E_SUCCESS;
}
-irecv_error_t mobiledevice_openpipes(irecv_client_t client) {
+irecv_error_t mobiledevice_openpipes(irecv_client_t client)
+{
if (client->iBootPath && !(client->hIB = CreateFileA(client->iBootPath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL))) {
irecv_close(client);
return IRECV_E_UNABLE_TO_CONNECT;
@@ -996,7 +999,8 @@ irecv_error_t mobiledevice_openpipes(irecv_client_t client) {
return IRECV_E_SUCCESS;
}
-void mobiledevice_closepipes(irecv_client_t client) {
+void mobiledevice_closepipes(irecv_client_t client)
+{
if (client->hDFU!=NULL) {
CloseHandle(client->hDFU);
client->hDFU = NULL;
@@ -1021,7 +1025,8 @@ static void iokit_cfdictionary_set_short(CFMutableDictionaryRef dict, const void
}
#endif
-static int check_context(irecv_client_t client) {
+static int check_context(irecv_client_t client)
+{
if (client == NULL || client->handle == NULL) {
return IRECV_E_NO_DEVICE;
}
@@ -1079,7 +1084,8 @@ static int iokit_usb_control_transfer(irecv_client_t client, uint8_t bm_request_
#endif
#endif
-int irecv_usb_control_transfer(irecv_client_t client, uint8_t bm_request_type, uint8_t b_request, uint16_t w_value, uint16_t w_index, unsigned char *data, uint16_t w_length, unsigned int timeout) {
+int irecv_usb_control_transfer(irecv_client_t client, uint8_t bm_request_type, uint8_t b_request, uint16_t w_value, uint16_t w_index, unsigned char *data, uint16_t w_length, unsigned int timeout)
+{
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
@@ -1140,8 +1146,8 @@ static int iokit_usb_bulk_transfer(irecv_client_t client,
unsigned char *data,
int length,
int *transferred,
- unsigned int timeout) {
-
+ unsigned int timeout)
+{
IOReturn result;
IOUSBInterfaceInterface300 **intf = client->usbInterface;
UInt32 size = length;
@@ -1194,7 +1200,8 @@ int irecv_usb_bulk_transfer(irecv_client_t client,
unsigned char *data,
int length,
int *transferred,
- unsigned int timeout) {
+ unsigned int timeout)
+{
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
@@ -1224,8 +1231,8 @@ int irecv_usb_bulk_transfer(irecv_client_t client,
#ifndef USE_DUMMY
#ifdef HAVE_IOKIT
-static irecv_error_t iokit_usb_open_service(irecv_client_t *pclient, io_service_t service) {
-
+static irecv_error_t iokit_usb_open_service(irecv_client_t *pclient, io_service_t service)
+{
IOReturn result;
irecv_error_t error;
irecv_client_t client;
@@ -1315,8 +1322,8 @@ static irecv_error_t iokit_usb_open_service(irecv_client_t *pclient, io_service_
return IRECV_E_SUCCESS;
}
-static io_iterator_t iokit_usb_get_iterator_for_pid(UInt16 pid) {
-
+static io_iterator_t iokit_usb_get_iterator_for_pid(UInt16 pid)
+{
IOReturn result;
io_iterator_t iterator;
CFMutableDictionaryRef matchingDict;
@@ -1332,8 +1339,8 @@ static io_iterator_t iokit_usb_get_iterator_for_pid(UInt16 pid) {
return iterator;
}
-static irecv_error_t iokit_open_with_ecid(irecv_client_t* pclient, uint64_t ecid) {
-
+static irecv_error_t iokit_open_with_ecid(irecv_client_t* pclient, uint64_t ecid)
+{
io_service_t service, ret_service;
io_iterator_t iterator;
CFStringRef usbSerial = NULL;
@@ -1410,13 +1417,14 @@ static irecv_error_t iokit_open_with_ecid(irecv_client_t* pclient, uint64_t ecid
#endif
#endif
-irecv_error_t irecv_open_with_ecid(irecv_client_t* pclient, uint64_t ecid) {
+irecv_error_t irecv_open_with_ecid(irecv_client_t* pclient, uint64_t ecid)
+{
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
int ret = IRECV_E_UNABLE_TO_CONNECT;
- if(libirecovery_debug) {
+ if (libirecovery_debug) {
irecv_set_debug_level(libirecovery_debug);
}
#ifndef WIN32
@@ -1563,7 +1571,8 @@ irecv_error_t irecv_open_with_ecid(irecv_client_t* pclient, uint64_t ecid) {
#endif
}
-irecv_error_t irecv_usb_set_configuration(irecv_client_t client, int configuration) {
+irecv_error_t irecv_usb_set_configuration(irecv_client_t client, int configuration)
+{
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
@@ -1599,8 +1608,8 @@ irecv_error_t irecv_usb_set_configuration(irecv_client_t client, int configurati
#ifndef USE_DUMMY
#ifdef HAVE_IOKIT
-static IOReturn iokit_usb_get_interface(IOUSBDeviceInterface320 **device, uint8_t ifc, io_service_t *usbInterfacep) {
-
+static IOReturn iokit_usb_get_interface(IOUSBDeviceInterface320 **device, uint8_t ifc, io_service_t *usbInterfacep)
+{
IOUSBFindInterfaceRequest request;
uint8_t current_interface;
kern_return_t kresult;
@@ -1627,7 +1636,8 @@ static IOReturn iokit_usb_get_interface(IOUSBDeviceInterface320 **device, uint8_
return kIOReturnSuccess;
}
-static irecv_error_t iokit_usb_set_interface(irecv_client_t client, int usb_interface, int usb_alt_interface) {
+static irecv_error_t iokit_usb_set_interface(irecv_client_t client, int usb_interface, int usb_alt_interface)
+{
IOReturn result;
io_service_t interface_service = IO_OBJECT_NULL;
IOCFPlugInInterface **plugInInterface = NULL;
@@ -1679,7 +1689,8 @@ static irecv_error_t iokit_usb_set_interface(irecv_client_t client, int usb_inte
#endif
#endif
-irecv_error_t irecv_usb_set_interface(irecv_client_t client, int usb_interface, int usb_alt_interface) {
+irecv_error_t irecv_usb_set_interface(irecv_client_t client, int usb_interface, int usb_alt_interface)
+{
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
@@ -1715,7 +1726,8 @@ irecv_error_t irecv_usb_set_interface(irecv_client_t client, int usb_interface,
#endif
}
-irecv_error_t irecv_reset(irecv_client_t client) {
+irecv_error_t irecv_reset(irecv_client_t client)
+{
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
@@ -1748,14 +1760,15 @@ irecv_error_t irecv_reset(irecv_client_t client) {
#endif
}
-irecv_error_t irecv_open_with_ecid_and_attempts(irecv_client_t* pclient, uint64_t ecid, int attempts) {
+irecv_error_t irecv_open_with_ecid_and_attempts(irecv_client_t* pclient, uint64_t ecid, int attempts)
+{
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
int i;
for (i = 0; i < attempts; i++) {
- if(*pclient) {
+ if (*pclient) {
irecv_close(*pclient);
*pclient = NULL;
}
@@ -1771,7 +1784,8 @@ irecv_error_t irecv_open_with_ecid_and_attempts(irecv_client_t* pclient, uint64_
#endif
}
-irecv_error_t irecv_event_subscribe(irecv_client_t client, irecv_event_type type, irecv_event_cb_t callback, void* user_data) {
+irecv_error_t irecv_event_subscribe(irecv_client_t client, irecv_event_type type, irecv_event_cb_t callback, void* user_data)
+{
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
@@ -1808,7 +1822,8 @@ irecv_error_t irecv_event_subscribe(irecv_client_t client, irecv_event_type type
#endif
}
-irecv_error_t irecv_event_unsubscribe(irecv_client_t client, irecv_event_type type) {
+irecv_error_t irecv_event_unsubscribe(irecv_client_t client, irecv_event_type type)
+{
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
@@ -2230,7 +2245,7 @@ static void *_irecv_event_handler(void* data)
details->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_A);
SP_DEVINFO_DATA devinfodata;
devinfodata.cbSize = sizeof(SP_DEVINFO_DATA);
- if(!SetupDiGetDeviceInterfaceDetailA(usbDevices, &currentInterface, details, requiredSize, NULL, &devinfodata)) {
+ if (!SetupDiGetDeviceInterfaceDetailA(usbDevices, &currentInterface, details, requiredSize, NULL, &devinfodata)) {
free(details);
continue;
}
@@ -2528,12 +2543,13 @@ irecv_error_t irecv_device_event_unsubscribe(irecv_device_event_context_t contex
#endif
}
-irecv_error_t irecv_close(irecv_client_t client) {
+irecv_error_t irecv_close(irecv_client_t client)
+{
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
if (client != NULL) {
- if(client->disconnected_callback != NULL) {
+ if (client->disconnected_callback != NULL) {
irecv_event_t event;
event.size = 0;
event.data = NULL;
@@ -2584,12 +2600,13 @@ irecv_error_t irecv_close(irecv_client_t client) {
#endif
}
-void irecv_set_debug_level(int level) {
+void irecv_set_debug_level(int level)
+{
libirecovery_debug = level;
#ifndef USE_DUMMY
#ifndef WIN32
#ifndef HAVE_IOKIT
- if(libirecovery_context) {
+ if (libirecovery_context) {
#if LIBUSB_API_VERSION >= 0x01000106
libusb_set_option(libirecovery_context, LIBUSB_OPTION_LOG_LEVEL, libirecovery_debug > 2 ? 1: 0);
#else
@@ -2602,7 +2619,8 @@ void irecv_set_debug_level(int level) {
}
#ifndef USE_DUMMY
-static irecv_error_t irecv_send_command_raw(irecv_client_t client, const char* command, uint8_t b_request) {
+static irecv_error_t irecv_send_command_raw(irecv_client_t client, const char* command, uint8_t b_request)
+{
unsigned int length = strlen(command);
if (length >= 0x100) {
return IRECV_E_INVALID_INPUT;
@@ -2616,7 +2634,8 @@ static irecv_error_t irecv_send_command_raw(irecv_client_t client, const char* c
}
#endif
-irecv_error_t irecv_send_command_breq(irecv_client_t client, const char* command, uint8_t b_request) {
+irecv_error_t irecv_send_command_breq(irecv_client_t client, const char* command, uint8_t b_request)
+{
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
@@ -2631,11 +2650,11 @@ irecv_error_t irecv_send_command_breq(irecv_client_t client, const char* command
}
irecv_event_t event;
- if(client->precommand_callback != NULL) {
+ if (client->precommand_callback != NULL) {
event.size = length;
event.data = command;
event.type = IRECV_PRECOMMAND;
- if(client->precommand_callback(client, &event)) {
+ if (client->precommand_callback(client, &event)) {
return IRECV_E_SUCCESS;
}
}
@@ -2647,11 +2666,11 @@ irecv_error_t irecv_send_command_breq(irecv_client_t client, const char* command
return error;
}
- if(client->postcommand_callback != NULL) {
+ if (client->postcommand_callback != NULL) {
event.size = length;
event.data = command;
event.type = IRECV_POSTCOMMAND;
- if(client->postcommand_callback(client, &event)) {
+ if (client->postcommand_callback(client, &event)) {
return IRECV_E_SUCCESS;
}
}
@@ -2660,11 +2679,13 @@ irecv_error_t irecv_send_command_breq(irecv_client_t client, const char* command
#endif
}
-irecv_error_t irecv_send_command(irecv_client_t client, const char* command) {
+irecv_error_t irecv_send_command(irecv_client_t client, const char* command)
+{
return irecv_send_command_breq(client, command, 0);
}
-irecv_error_t irecv_send_file(irecv_client_t client, const char* filename, int dfu_notify_finished) {
+irecv_error_t irecv_send_file(irecv_client_t client, const char* filename, int dfu_notify_finished)
+{
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
@@ -2704,7 +2725,8 @@ irecv_error_t irecv_send_file(irecv_client_t client, const char* filename, int d
}
#ifndef USE_DUMMY
-static irecv_error_t irecv_get_status(irecv_client_t client, unsigned int* status) {
+static irecv_error_t irecv_get_status(irecv_client_t client, unsigned int* status)
+{
if (check_context(client) != IRECV_E_SUCCESS) {
*status = 0;
return IRECV_E_NO_DEVICE;
@@ -2723,7 +2745,8 @@ static irecv_error_t irecv_get_status(irecv_client_t client, unsigned int* statu
}
#endif
-irecv_error_t irecv_send_buffer(irecv_client_t client, unsigned char* buffer, unsigned long length, int dfu_notify_finished) {
+irecv_error_t irecv_send_buffer(irecv_client_t client, unsigned char* buffer, unsigned long length, int dfu_notify_finished)
+{
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
@@ -2856,7 +2879,7 @@ irecv_error_t irecv_send_buffer(irecv_client_t client, unsigned char* buffer, un
}
count += size;
- if(client->progress_callback != NULL) {
+ if (client->progress_callback != NULL) {
irecv_event_t event;
event.progress = ((double) count/ (double) length) * 100.0;
event.type = IRECV_PROGRESS;
@@ -2896,7 +2919,8 @@ irecv_error_t irecv_send_buffer(irecv_client_t client, unsigned char* buffer, un
#endif
}
-irecv_error_t irecv_receive(irecv_client_t client) {
+irecv_error_t irecv_receive(irecv_client_t client)
+{
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
@@ -2930,7 +2954,8 @@ irecv_error_t irecv_receive(irecv_client_t client) {
#endif
}
-irecv_error_t irecv_getenv(irecv_client_t client, const char* variable, char** value) {
+irecv_error_t irecv_getenv(irecv_client_t client, const char* variable, char** value)
+{
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
@@ -2941,18 +2966,18 @@ irecv_error_t irecv_getenv(irecv_client_t client, const char* variable, char** v
*value = NULL;
- if(variable == NULL) {
+ if (variable == NULL) {
return IRECV_E_INVALID_INPUT;
}
memset(command, '\0', sizeof(command));
snprintf(command, sizeof(command)-1, "getenv %s", variable);
irecv_error_t error = irecv_send_command_raw(client, command, 0);
- if(error == IRECV_E_PIPE) {
+ if (error == IRECV_E_PIPE) {
return IRECV_E_SUCCESS;
}
- if(error != IRECV_E_SUCCESS) {
+ if (error != IRECV_E_SUCCESS) {
return error;
}
@@ -2970,7 +2995,8 @@ irecv_error_t irecv_getenv(irecv_client_t client, const char* variable, char** v
#endif
}
-irecv_error_t irecv_getret(irecv_client_t client, unsigned int* value) {
+irecv_error_t irecv_getret(irecv_client_t client, unsigned int* value)
+{
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
@@ -2993,7 +3019,8 @@ irecv_error_t irecv_getret(irecv_client_t client, unsigned int* value) {
#endif
}
-irecv_error_t irecv_get_mode(irecv_client_t client, int* mode) {
+irecv_error_t irecv_get_mode(irecv_client_t client, int* mode)
+{
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
@@ -3020,7 +3047,8 @@ const struct irecv_device_info* irecv_get_device_info(irecv_client_t client)
#ifndef USE_DUMMY
#ifdef HAVE_IOKIT
-static void *iokit_limera1n_usb_submit_request(void *argv) {
+static void *iokit_limera1n_usb_submit_request(void *argv)
+{
void **args = argv;
IOUSBDeviceInterface320 **dev = args[0];
IOUSBDevRequest *req = args[1];
@@ -3034,7 +3062,8 @@ static void *iokit_limera1n_usb_submit_request(void *argv) {
#endif
#endif
-irecv_error_t irecv_trigger_limera1n_exploit(irecv_client_t client) {
+irecv_error_t irecv_trigger_limera1n_exploit(irecv_client_t client)
+{
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
@@ -3085,7 +3114,8 @@ irecv_error_t irecv_trigger_limera1n_exploit(irecv_client_t client) {
#endif
}
-irecv_error_t irecv_execute_script(irecv_client_t client, const char* script) {
+irecv_error_t irecv_execute_script(irecv_client_t client, const char* script)
+{
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
@@ -3096,15 +3126,15 @@ irecv_error_t irecv_execute_script(irecv_client_t client, const char* script) {
char* body = strdup(script);
char* line = strtok(body, "\n");
- while(line != NULL) {
- if(line[0] != '#') {
+ while (line != NULL) {
+ if (line[0] != '#') {
error = irecv_send_command(client, line);
- if(error != IRECV_E_SUCCESS) {
+ if (error != IRECV_E_SUCCESS) {
break;
}
error = irecv_receive(client);
- if(error != IRECV_E_SUCCESS) {
+ if (error != IRECV_E_SUCCESS) {
break;
}
}
@@ -3117,12 +3147,13 @@ irecv_error_t irecv_execute_script(irecv_client_t client, const char* script) {
#endif
}
-irecv_error_t irecv_saveenv(irecv_client_t client) {
+irecv_error_t irecv_saveenv(irecv_client_t client)
+{
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
irecv_error_t error = irecv_send_command_raw(client, "saveenv", 0);
- if(error != IRECV_E_SUCCESS) {
+ if (error != IRECV_E_SUCCESS) {
return error;
}
@@ -3130,7 +3161,8 @@ irecv_error_t irecv_saveenv(irecv_client_t client) {
#endif
}
-irecv_error_t irecv_setenv(irecv_client_t client, const char* variable, const char* value) {
+irecv_error_t irecv_setenv(irecv_client_t client, const char* variable, const char* value)
+{
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
@@ -3139,14 +3171,14 @@ irecv_error_t irecv_setenv(irecv_client_t client, const char* variable, const ch
if (check_context(client) != IRECV_E_SUCCESS)
return IRECV_E_NO_DEVICE;
- if(variable == NULL || value == NULL) {
+ if (variable == NULL || value == NULL) {
return IRECV_E_UNKNOWN_ERROR;
}
memset(command, '\0', sizeof(command));
snprintf(command, sizeof(command)-1, "setenv %s %s", variable, value);
irecv_error_t error = irecv_send_command_raw(client, command, 0);
- if(error != IRECV_E_SUCCESS) {
+ if (error != IRECV_E_SUCCESS) {
return error;
}
@@ -3154,7 +3186,8 @@ irecv_error_t irecv_setenv(irecv_client_t client, const char* variable, const ch
#endif
}
-irecv_error_t irecv_setenv_np(irecv_client_t client, const char* variable, const char* value) {
+irecv_error_t irecv_setenv_np(irecv_client_t client, const char* variable, const char* value)
+{
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
@@ -3163,14 +3196,14 @@ irecv_error_t irecv_setenv_np(irecv_client_t client, const char* variable, const
if (check_context(client) != IRECV_E_SUCCESS)
return IRECV_E_NO_DEVICE;
- if(variable == NULL || value == NULL) {
+ if (variable == NULL || value == NULL) {
return IRECV_E_UNKNOWN_ERROR;
}
memset(command, '\0', sizeof(command));
snprintf(command, sizeof(command)-1, "setenvnp %s %s", variable, value);
irecv_error_t error = irecv_send_command_raw(client, command, 0);
- if(error != IRECV_E_SUCCESS) {
+ if (error != IRECV_E_SUCCESS) {
return error;
}
@@ -3178,12 +3211,13 @@ irecv_error_t irecv_setenv_np(irecv_client_t client, const char* variable, const
#endif
}
-irecv_error_t irecv_reboot(irecv_client_t client) {
+irecv_error_t irecv_reboot(irecv_client_t client)
+{
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
irecv_error_t error = irecv_send_command_raw(client, "reboot", 0);
- if(error != IRECV_E_SUCCESS) {
+ if (error != IRECV_E_SUCCESS) {
return error;
}
@@ -3191,7 +3225,8 @@ irecv_error_t irecv_reboot(irecv_client_t client) {
#endif
}
-const char* irecv_strerror(irecv_error_t error) {
+const char* irecv_strerror(irecv_error_t error)
+{
switch (error) {
case IRECV_E_SUCCESS:
return "Command completed successfully";
@@ -3239,7 +3274,8 @@ const char* irecv_strerror(irecv_error_t error) {
return NULL;
}
-irecv_error_t irecv_reset_counters(irecv_client_t client) {
+irecv_error_t irecv_reset_counters(irecv_client_t client)
+{
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
@@ -3254,7 +3290,8 @@ irecv_error_t irecv_reset_counters(irecv_client_t client) {
#endif
}
-irecv_error_t irecv_recv_buffer(irecv_client_t client, char* buffer, unsigned long length) {
+irecv_error_t irecv_recv_buffer(irecv_client_t client, char* buffer, unsigned long length)
+{
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
@@ -3284,7 +3321,7 @@ irecv_error_t irecv_recv_buffer(irecv_client_t client, char* buffer, unsigned lo
}
count += size;
- if(client->progress_callback != NULL) {
+ if (client->progress_callback != NULL) {
irecv_event_t event;
event.progress = ((double) count/ (double) length) * 100.0;
event.type = IRECV_PROGRESS;
@@ -3300,7 +3337,8 @@ irecv_error_t irecv_recv_buffer(irecv_client_t client, char* buffer, unsigned lo
#endif
}
-irecv_error_t irecv_finish_transfer(irecv_client_t client) {
+irecv_error_t irecv_finish_transfer(irecv_client_t client)
+{
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
@@ -3312,7 +3350,7 @@ irecv_error_t irecv_finish_transfer(irecv_client_t client) {
irecv_usb_control_transfer(client, 0x21, 1, 0, 0, 0, 0, USB_TIMEOUT);
- for(i = 0; i < 3; i++){
+ for (i = 0; i < 3; i++){
irecv_get_status(client, &status);
}
@@ -3322,11 +3360,13 @@ irecv_error_t irecv_finish_transfer(irecv_client_t client) {
#endif
}
-irecv_device_t irecv_devices_get_all(void) {
+irecv_device_t irecv_devices_get_all(void)
+{
return irecv_devices;
}
-irecv_error_t irecv_devices_get_device_by_client(irecv_client_t client, irecv_device_t* device) {
+irecv_error_t irecv_devices_get_device_by_client(irecv_client_t client, irecv_device_t* device)
+{
#ifdef USE_DUMMY
return IRECV_E_UNSUPPORTED;
#else
@@ -3352,7 +3392,8 @@ irecv_error_t irecv_devices_get_device_by_client(irecv_client_t client, irecv_de
#endif
}
-irecv_error_t irecv_devices_get_device_by_product_type(const char* product_type, irecv_device_t* device) {
+irecv_error_t irecv_devices_get_device_by_product_type(const char* product_type, irecv_device_t* device)
+{
int i = 0;
if (!product_type || !device)
@@ -3370,7 +3411,8 @@ irecv_error_t irecv_devices_get_device_by_product_type(const char* product_type,
return IRECV_E_NO_DEVICE;
}
-irecv_error_t irecv_devices_get_device_by_hardware_model(const char* hardware_model, irecv_device_t* device) {
+irecv_error_t irecv_devices_get_device_by_hardware_model(const char* hardware_model, irecv_device_t* device)
+{
int i = 0;
if (!hardware_model || !device)
@@ -3388,7 +3430,8 @@ irecv_error_t irecv_devices_get_device_by_hardware_model(const char* hardware_mo
return IRECV_E_NO_DEVICE;
}
-irecv_client_t irecv_reconnect(irecv_client_t client, int initial_pause) {
+irecv_client_t irecv_reconnect(irecv_client_t client, int initial_pause)
+{
#ifdef USE_DUMMY
return NULL;
#else
@@ -3413,7 +3456,7 @@ irecv_client_t irecv_reconnect(irecv_client_t client, int initial_pause) {
}
error = irecv_open_with_ecid_and_attempts(&new_client, ecid, 10);
- if(error != IRECV_E_SUCCESS) {
+ if (error != IRECV_E_SUCCESS) {
return NULL;
}