diff options
Diffstat (limited to 'src/afc.c')
| -rw-r--r-- | src/afc.c | 28 |
1 files changed, 15 insertions, 13 deletions
| @@ -364,7 +364,7 @@ static afc_error_t afc_receive_data(afc_client_t client, char **dump_here, uint3 | |||
| 364 | } | 364 | } |
| 365 | 365 | ||
| 366 | if (current_count >= sizeof(uint64_t)) { | 366 | if (current_count >= sizeof(uint64_t)) { |
| 367 | param1 = GUINT64_FROM_LE(*(uint64_t*)(*dump_here)); | 367 | param1 = le64toh(*(uint64_t*)(*dump_here)); |
| 368 | } | 368 | } |
| 369 | 369 | ||
| 370 | debug_info("packet data size = %i", current_count); | 370 | debug_info("packet data size = %i", current_count); |
| @@ -577,8 +577,10 @@ afc_error_t afc_get_device_info_key(afc_client_t client, const char *key, char * | |||
| 577 | break; | 577 | break; |
| 578 | } | 578 | } |
| 579 | } | 579 | } |
| 580 | 580 | for (ptr = kvps; *ptr; ptr++) { | |
| 581 | g_strfreev(kvps); | 581 | free(*ptr); |
| 582 | } | ||
| 583 | free(kvps); | ||
| 582 | 584 | ||
| 583 | return ret; | 585 | return ret; |
| 584 | } | 586 | } |
| @@ -764,7 +766,7 @@ idevice_error_t | |||
| 764 | afc_file_open(afc_client_t client, const char *filename, | 766 | afc_file_open(afc_client_t client, const char *filename, |
| 765 | afc_file_mode_t file_mode, uint64_t *handle) | 767 | afc_file_mode_t file_mode, uint64_t *handle) |
| 766 | { | 768 | { |
| 767 | uint64_t file_mode_loc = GUINT64_TO_LE(file_mode); | 769 | uint64_t file_mode_loc = htole64(file_mode); |
| 768 | uint32_t bytes = 0; | 770 | uint32_t bytes = 0; |
| 769 | char *data = (char *) malloc(sizeof(char) * (8 + strlen(filename) + 1)); | 771 | char *data = (char *) malloc(sizeof(char) * (8 + strlen(filename) + 1)); |
| 770 | afc_error_t ret = AFC_E_UNKNOWN_ERROR; | 772 | afc_error_t ret = AFC_E_UNKNOWN_ERROR; |
| @@ -842,7 +844,7 @@ afc_file_read(afc_client_t client, uint64_t handle, char *data, uint32_t length, | |||
| 842 | /* Send the read command */ | 844 | /* Send the read command */ |
| 843 | AFCFilePacket *packet = (AFCFilePacket *) malloc(sizeof(AFCFilePacket)); | 845 | AFCFilePacket *packet = (AFCFilePacket *) malloc(sizeof(AFCFilePacket)); |
| 844 | packet->filehandle = handle; | 846 | packet->filehandle = handle; |
| 845 | packet->size = GUINT64_TO_LE(((length - current_count) < MAXIMUM_READ_SIZE) ? (length - current_count) : MAXIMUM_READ_SIZE); | 847 | packet->size = htole64(((length - current_count) < MAXIMUM_READ_SIZE) ? (length - current_count) : MAXIMUM_READ_SIZE); |
| 846 | client->afc_packet->operation = AFC_OP_READ; | 848 | client->afc_packet->operation = AFC_OP_READ; |
| 847 | client->afc_packet->entire_length = client->afc_packet->this_length = 0; | 849 | client->afc_packet->entire_length = client->afc_packet->this_length = 0; |
| 848 | ret = afc_dispatch_packet(client, (char *) packet, sizeof(AFCFilePacket), &bytes_loc); | 850 | ret = afc_dispatch_packet(client, (char *) packet, sizeof(AFCFilePacket), &bytes_loc); |
| @@ -1035,7 +1037,7 @@ afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t op | |||
| 1035 | { | 1037 | { |
| 1036 | char *buffer = malloc(16); | 1038 | char *buffer = malloc(16); |
| 1037 | uint32_t bytes = 0; | 1039 | uint32_t bytes = 0; |
| 1038 | uint64_t op = GUINT64_TO_LE(operation); | 1040 | uint64_t op = htole64(operation); |
| 1039 | afc_error_t ret = AFC_E_UNKNOWN_ERROR; | 1041 | afc_error_t ret = AFC_E_UNKNOWN_ERROR; |
| 1040 | 1042 | ||
| 1041 | if (!client || (handle == 0)) | 1043 | if (!client || (handle == 0)) |
| @@ -1084,8 +1086,8 @@ afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t op | |||
| 1084 | afc_error_t afc_file_seek(afc_client_t client, uint64_t handle, int64_t offset, int whence) | 1086 | afc_error_t afc_file_seek(afc_client_t client, uint64_t handle, int64_t offset, int whence) |
| 1085 | { | 1087 | { |
| 1086 | char *buffer = (char *) malloc(sizeof(char) * 24); | 1088 | char *buffer = (char *) malloc(sizeof(char) * 24); |
| 1087 | int64_t offset_loc = (int64_t)GUINT64_TO_LE(offset); | 1089 | int64_t offset_loc = (int64_t)htole64(offset); |
| 1088 | uint64_t whence_loc = GUINT64_TO_LE(whence); | 1090 | uint64_t whence_loc = htole64(whence); |
| 1089 | uint32_t bytes = 0; | 1091 | uint32_t bytes = 0; |
| 1090 | afc_error_t ret = AFC_E_UNKNOWN_ERROR; | 1092 | afc_error_t ret = AFC_E_UNKNOWN_ERROR; |
| 1091 | 1093 | ||
| @@ -1156,7 +1158,7 @@ afc_error_t afc_file_tell(afc_client_t client, uint64_t handle, uint64_t *positi | |||
| 1156 | if (bytes > 0 && buffer) { | 1158 | if (bytes > 0 && buffer) { |
| 1157 | /* Get the position */ | 1159 | /* Get the position */ |
| 1158 | memcpy(position, buffer, sizeof(uint64_t)); | 1160 | memcpy(position, buffer, sizeof(uint64_t)); |
| 1159 | *position = GUINT64_FROM_LE(*position); | 1161 | *position = le64toh(*position); |
| 1160 | } | 1162 | } |
| 1161 | if (buffer) | 1163 | if (buffer) |
| 1162 | free(buffer); | 1164 | free(buffer); |
| @@ -1182,7 +1184,7 @@ afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t new | |||
| 1182 | { | 1184 | { |
| 1183 | char *buffer = (char *) malloc(sizeof(char) * 16); | 1185 | char *buffer = (char *) malloc(sizeof(char) * 16); |
| 1184 | uint32_t bytes = 0; | 1186 | uint32_t bytes = 0; |
| 1185 | uint64_t newsize_loc = GUINT64_TO_LE(newsize); | 1187 | uint64_t newsize_loc = htole64(newsize); |
| 1186 | afc_error_t ret = AFC_E_UNKNOWN_ERROR; | 1188 | afc_error_t ret = AFC_E_UNKNOWN_ERROR; |
| 1187 | 1189 | ||
| 1188 | if (!client || (handle == 0)) | 1190 | if (!client || (handle == 0)) |
| @@ -1227,7 +1229,7 @@ afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize | |||
| 1227 | char *response = NULL; | 1229 | char *response = NULL; |
| 1228 | char *send = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8)); | 1230 | char *send = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8)); |
| 1229 | uint32_t bytes = 0; | 1231 | uint32_t bytes = 0; |
| 1230 | uint64_t size_requested = GUINT64_TO_LE(newsize); | 1232 | uint64_t size_requested = htole64(newsize); |
| 1231 | afc_error_t ret = AFC_E_UNKNOWN_ERROR; | 1233 | afc_error_t ret = AFC_E_UNKNOWN_ERROR; |
| 1232 | 1234 | ||
| 1233 | if (!client || !path || !client->afc_packet || !client->connection) | 1235 | if (!client || !path || !client->afc_packet || !client->connection) |
| @@ -1271,7 +1273,7 @@ afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const c | |||
| 1271 | char *response = NULL; | 1273 | char *response = NULL; |
| 1272 | char *send = (char *) malloc(sizeof(char) * (strlen(target)+1 + strlen(linkname)+1 + 8)); | 1274 | char *send = (char *) malloc(sizeof(char) * (strlen(target)+1 + strlen(linkname)+1 + 8)); |
| 1273 | uint32_t bytes = 0; | 1275 | uint32_t bytes = 0; |
| 1274 | uint64_t type = GUINT64_TO_LE(linktype); | 1276 | uint64_t type = htole64(linktype); |
| 1275 | afc_error_t ret = AFC_E_UNKNOWN_ERROR; | 1277 | afc_error_t ret = AFC_E_UNKNOWN_ERROR; |
| 1276 | 1278 | ||
| 1277 | if (!client || !target || !linkname || !client->afc_packet || !client->connection) | 1279 | if (!client || !target || !linkname || !client->afc_packet || !client->connection) |
| @@ -1319,7 +1321,7 @@ afc_error_t afc_set_file_time(afc_client_t client, const char *path, uint64_t mt | |||
| 1319 | char *response = NULL; | 1321 | char *response = NULL; |
| 1320 | char *send = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8)); | 1322 | char *send = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8)); |
| 1321 | uint32_t bytes = 0; | 1323 | uint32_t bytes = 0; |
| 1322 | uint64_t mtime_loc = GUINT64_TO_LE(mtime); | 1324 | uint64_t mtime_loc = htole64(mtime); |
| 1323 | afc_error_t ret = AFC_E_UNKNOWN_ERROR; | 1325 | afc_error_t ret = AFC_E_UNKNOWN_ERROR; |
| 1324 | 1326 | ||
| 1325 | if (!client || !path || !client->afc_packet || !client->connection) | 1327 | if (!client || !path || !client->afc_packet || !client->connection) |
