diff options
| -rw-r--r-- | src/libirecovery.c | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/src/libirecovery.c b/src/libirecovery.c index 87ec520..f51ca3d 100644 --- a/src/libirecovery.c +++ b/src/libirecovery.c | |||
| @@ -48,8 +48,6 @@ static int libirecovery_debug = 0; | |||
| 48 | static libusb_context* libirecovery_context = NULL; | 48 | static libusb_context* libirecovery_context = NULL; |
| 49 | #endif | 49 | #endif |
| 50 | 50 | ||
| 51 | int irecv_write_file(const char* filename, const void* data, size_t size); | ||
| 52 | int irecv_read_file(const char* filename, char** data, uint32_t* size); | ||
| 53 | 51 | ||
| 54 | static unsigned int dfu_hash_t1[256] = { | 52 | static unsigned int dfu_hash_t1[256] = { |
| 55 | 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, | 53 | 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, |
| @@ -1369,68 +1367,6 @@ const char* irecv_strerror(irecv_error_t error) { | |||
| 1369 | return NULL; | 1367 | return NULL; |
| 1370 | } | 1368 | } |
| 1371 | 1369 | ||
| 1372 | int irecv_write_file(const char* filename, const void* data, size_t size) { | ||
| 1373 | size_t bytes = 0; | ||
| 1374 | FILE* file = NULL; | ||
| 1375 | |||
| 1376 | debug("Writing data to %s\n", filename); | ||
| 1377 | file = fopen(filename, "wb"); | ||
| 1378 | if (file == NULL) { | ||
| 1379 | //error("read_file: Unable to open file %s\n", filename); | ||
| 1380 | return -1; | ||
| 1381 | } | ||
| 1382 | |||
| 1383 | bytes = fwrite(data, 1, size, file); | ||
| 1384 | fclose(file); | ||
| 1385 | |||
| 1386 | if (bytes != size) { | ||
| 1387 | //error("ERROR: Unable to write entire file: %s: %d of %d\n", filename, bytes, size); | ||
| 1388 | return -1; | ||
| 1389 | } | ||
| 1390 | |||
| 1391 | return size; | ||
| 1392 | } | ||
| 1393 | |||
| 1394 | int irecv_read_file(const char* filename, char** data, uint32_t* size) { | ||
| 1395 | size_t bytes = 0; | ||
| 1396 | size_t length = 0; | ||
| 1397 | FILE* file = NULL; | ||
| 1398 | char* buffer = NULL; | ||
| 1399 | debug("Reading data from %s\n", filename); | ||
| 1400 | |||
| 1401 | *size = 0; | ||
| 1402 | *data = NULL; | ||
| 1403 | |||
| 1404 | file = fopen(filename, "rb"); | ||
| 1405 | if (file == NULL) { | ||
| 1406 | //error("read_file: File %s not found\n", filename); | ||
| 1407 | return -1; | ||
| 1408 | } | ||
| 1409 | |||
| 1410 | fseek(file, 0, SEEK_END); | ||
| 1411 | length = ftell(file); | ||
| 1412 | rewind(file); | ||
| 1413 | |||
| 1414 | buffer = (char*) malloc(length); | ||
| 1415 | if(buffer == NULL) { | ||
| 1416 | //error("ERROR: Out of memory\n"); | ||
| 1417 | fclose(file); | ||
| 1418 | return -1; | ||
| 1419 | } | ||
| 1420 | bytes = fread(buffer, 1, length, file); | ||
| 1421 | fclose(file); | ||
| 1422 | |||
| 1423 | if(bytes != length) { | ||
| 1424 | //error("ERROR: Unable to read entire file\n"); | ||
| 1425 | free(buffer); | ||
| 1426 | return -1; | ||
| 1427 | } | ||
| 1428 | |||
| 1429 | *size = length; | ||
| 1430 | *data = buffer; | ||
| 1431 | return 0; | ||
| 1432 | } | ||
| 1433 | |||
| 1434 | irecv_error_t irecv_reset_counters(irecv_client_t client) { | 1370 | irecv_error_t irecv_reset_counters(irecv_client_t client) { |
| 1435 | if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE; | 1371 | if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE; |
| 1436 | if ((client->mode == kDfuMode) || (client->mode == kWTFMode)) { | 1372 | if ((client->mode == kDfuMode) || (client->mode == kWTFMode)) { |
