diff options
Diffstat (limited to 'src/AFC.c')
| -rw-r--r-- | src/AFC.c | 128 |
1 files changed, 64 insertions, 64 deletions
| @@ -25,7 +25,7 @@ | |||
| 25 | 25 | ||
| 26 | #include "AFC.h" | 26 | #include "AFC.h" |
| 27 | #include "iphone.h" | 27 | #include "iphone.h" |
| 28 | #include "utils.h" | 28 | #include "debug.h" |
| 29 | 29 | ||
| 30 | // This is the maximum size an AFC data packet can be | 30 | // This is the maximum size an AFC data packet can be |
| 31 | static const int MAXIMUM_PACKET_SIZE = (2 << 15); | 31 | static const int MAXIMUM_PACKET_SIZE = (2 << 15); |
| @@ -36,7 +36,7 @@ static const int MAXIMUM_PACKET_SIZE = (2 << 15); | |||
| 36 | */ | 36 | */ |
| 37 | static void afc_lock(afc_client_t client) | 37 | static void afc_lock(afc_client_t client) |
| 38 | { | 38 | { |
| 39 | log_debug_msg("%s: Locked\n", __func__); | 39 | debug_info("Locked"); |
| 40 | g_mutex_lock(client->mutex); | 40 | g_mutex_lock(client->mutex); |
| 41 | } | 41 | } |
| 42 | 42 | ||
| @@ -46,30 +46,33 @@ static void afc_lock(afc_client_t client) | |||
| 46 | */ | 46 | */ |
| 47 | static void afc_unlock(afc_client_t client) | 47 | static void afc_unlock(afc_client_t client) |
| 48 | { | 48 | { |
| 49 | log_debug_msg("%s: Unlocked\n", __func__); | 49 | debug_info("Unlocked"); |
| 50 | g_mutex_unlock(client->mutex); | 50 | g_mutex_unlock(client->mutex); |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | /** Makes a connection to the AFC service on the phone. | 53 | /** Makes a connection to the AFC service on the phone. |
| 54 | * | 54 | * |
| 55 | * @param phone The iPhone to connect on. | 55 | * @param device The device to connect to. |
| 56 | * @param s_port The source port. | 56 | * @param port The destination port. |
| 57 | * @param d_port The destination port. | 57 | * @param client Pointer that will be set to a newly allocated afc_client_t |
| 58 | * upon successful return. | ||
| 58 | * | 59 | * |
| 59 | * @return A handle to the newly-connected client or NULL upon error. | 60 | * @return AFC_E_SUCCESS on success, AFC_E_INVALID_ARGUMENT when device or port |
| 61 | * is invalid, AFC_E_MUX_ERROR when the connection failed, or AFC_E_NO_MEM | ||
| 62 | * when there's a memory allocation problem. | ||
| 60 | */ | 63 | */ |
| 61 | afc_error_t afc_client_new(iphone_device_t device, int dst_port, afc_client_t * client) | 64 | afc_error_t afc_client_new(iphone_device_t device, uint16_t port, afc_client_t * client) |
| 62 | { | 65 | { |
| 63 | /* makes sure thread environment is available */ | 66 | /* makes sure thread environment is available */ |
| 64 | if (!g_thread_supported()) | 67 | if (!g_thread_supported()) |
| 65 | g_thread_init(NULL); | 68 | g_thread_init(NULL); |
| 66 | 69 | ||
| 67 | if (!device) | 70 | if (!device || port==0) |
| 68 | return AFC_E_INVALID_ARGUMENT; | 71 | return AFC_E_INVALID_ARGUMENT; |
| 69 | 72 | ||
| 70 | /* attempt connection */ | 73 | /* attempt connection */ |
| 71 | iphone_connection_t connection = NULL; | 74 | iphone_connection_t connection = NULL; |
| 72 | if (iphone_device_connect(device, dst_port, &connection) != IPHONE_E_SUCCESS) { | 75 | if (iphone_device_connect(device, port, &connection) != IPHONE_E_SUCCESS) { |
| 73 | return AFC_E_MUX_ERROR; | 76 | return AFC_E_MUX_ERROR; |
| 74 | } | 77 | } |
| 75 | 78 | ||
| @@ -155,12 +158,11 @@ static afc_error_t afc_dispatch_packet(afc_client_t client, const char *data, ui | |||
| 155 | if (client->afc_packet->this_length != client->afc_packet->entire_length) { | 158 | if (client->afc_packet->this_length != client->afc_packet->entire_length) { |
| 156 | offset = client->afc_packet->this_length - sizeof(AFCPacket); | 159 | offset = client->afc_packet->this_length - sizeof(AFCPacket); |
| 157 | 160 | ||
| 158 | log_debug_msg("%s: Offset: %i\n", __func__, offset); | 161 | debug_info("Offset: %i", offset); |
| 159 | if ((length) < (client->afc_packet->entire_length - client->afc_packet->this_length)) { | 162 | if ((length) < (client->afc_packet->entire_length - client->afc_packet->this_length)) { |
| 160 | log_debug_msg("%s: Length did not resemble what it was supposed", __func__); | 163 | debug_info("Length did not resemble what it was supposed to based on packet"); |
| 161 | log_debug_msg("to based on the packet.\n"); | 164 | debug_info("length minus offset: %i", length - offset); |
| 162 | log_debug_msg("%s: length minus offset: %i\n", __func__, length - offset); | 165 | debug_info("rest of packet: %i\n", client->afc_packet->entire_length - client->afc_packet->this_length); |
| 163 | log_debug_msg("%s: rest of packet: %i\n", __func__, client->afc_packet->entire_length - client->afc_packet->this_length); | ||
| 164 | return AFC_E_INTERNAL_ERROR; | 166 | return AFC_E_INTERNAL_ERROR; |
| 165 | } | 167 | } |
| 166 | 168 | ||
| @@ -182,10 +184,10 @@ static afc_error_t afc_dispatch_packet(afc_client_t client, const char *data, ui | |||
| 182 | } | 184 | } |
| 183 | *bytes_sent += sent; | 185 | *bytes_sent += sent; |
| 184 | 186 | ||
| 185 | log_debug_msg("%s: sent the first now go with the second\n", __func__); | 187 | debug_info("sent the first now go with the second"); |
| 186 | log_debug_msg("%s: Length: %i\n", __func__, length - offset); | 188 | debug_info("Length: %i", length - offset); |
| 187 | log_debug_msg("%s: Buffer: \n", __func__); | 189 | debug_info("Buffer: "); |
| 188 | log_debug_buffer(data + offset, length - offset); | 190 | debug_buffer(data + offset, length - offset); |
| 189 | 191 | ||
| 190 | sent = 0; | 192 | sent = 0; |
| 191 | iphone_device_send(client->connection, data + offset, length - offset, &sent); | 193 | iphone_device_send(client->connection, data + offset, length - offset, &sent); |
| @@ -193,11 +195,10 @@ static afc_error_t afc_dispatch_packet(afc_client_t client, const char *data, ui | |||
| 193 | *bytes_sent = sent; | 195 | *bytes_sent = sent; |
| 194 | return AFC_E_SUCCESS; | 196 | return AFC_E_SUCCESS; |
| 195 | } else { | 197 | } else { |
| 196 | log_debug_msg("%s: doin things the old way\n", __func__); | 198 | debug_info("doin things the old way"); |
| 197 | log_debug_msg("%s: packet length = %i\n", __func__, client->afc_packet->this_length); | 199 | debug_info("packet length = %i", client->afc_packet->this_length); |
| 198 | 200 | ||
| 199 | log_debug_buffer((char*)client->afc_packet, sizeof(AFCPacket)); | 201 | debug_buffer((char*)client->afc_packet, sizeof(AFCPacket)); |
| 200 | log_debug_msg("\n"); | ||
| 201 | 202 | ||
| 202 | /* send AFC packet header */ | 203 | /* send AFC packet header */ |
| 203 | AFCPacket_to_LE(client->afc_packet); | 204 | AFCPacket_to_LE(client->afc_packet); |
| @@ -209,10 +210,9 @@ static afc_error_t afc_dispatch_packet(afc_client_t client, const char *data, ui | |||
| 209 | *bytes_sent += sent; | 210 | *bytes_sent += sent; |
| 210 | /* send AFC packet data (if there's data to send) */ | 211 | /* send AFC packet data (if there's data to send) */ |
| 211 | if (length > 0) { | 212 | if (length > 0) { |
| 212 | log_debug_msg("%s: packet data follows\n", __func__); | 213 | debug_info("packet data follows"); |
| 213 | 214 | ||
| 214 | log_debug_buffer(data, length); | 215 | debug_buffer(data, length); |
| 215 | log_debug_msg("\n"); | ||
| 216 | iphone_device_send(client->connection, data, length, &sent); | 216 | iphone_device_send(client->connection, data, length, &sent); |
| 217 | *bytes_sent += sent; | 217 | *bytes_sent += sent; |
| 218 | } | 218 | } |
| @@ -244,36 +244,36 @@ static afc_error_t afc_receive_data(afc_client_t client, char **dump_here, uint3 | |||
| 244 | iphone_device_recv(client->connection, (char*)&header, sizeof(AFCPacket), bytes_recv); | 244 | iphone_device_recv(client->connection, (char*)&header, sizeof(AFCPacket), bytes_recv); |
| 245 | AFCPacket_from_LE(&header); | 245 | AFCPacket_from_LE(&header); |
| 246 | if (*bytes_recv == 0) { | 246 | if (*bytes_recv == 0) { |
| 247 | log_debug_msg("%s: Just didn't get enough.\n", __func__); | 247 | debug_info("Just didn't get enough."); |
| 248 | *dump_here = NULL; | 248 | *dump_here = NULL; |
| 249 | return AFC_E_MUX_ERROR; | 249 | return AFC_E_MUX_ERROR; |
| 250 | } else if (*bytes_recv < sizeof(AFCPacket)) { | 250 | } else if (*bytes_recv < sizeof(AFCPacket)) { |
| 251 | log_debug_msg("%s: Did not even get the AFCPacket header\n", __func__); | 251 | debug_info("Did not even get the AFCPacket header"); |
| 252 | *dump_here = NULL; | 252 | *dump_here = NULL; |
| 253 | return AFC_E_MUX_ERROR; | 253 | return AFC_E_MUX_ERROR; |
| 254 | } | 254 | } |
| 255 | 255 | ||
| 256 | /* check if it's a valid AFC header */ | 256 | /* check if it's a valid AFC header */ |
| 257 | if (strncmp(header.magic, AFC_MAGIC, AFC_MAGIC_LEN)) { | 257 | if (strncmp(header.magic, AFC_MAGIC, AFC_MAGIC_LEN)) { |
| 258 | log_debug_msg("%s: Invalid AFC packet received (magic != " AFC_MAGIC ")!\n", __func__); | 258 | debug_info("Invalid AFC packet received (magic != " AFC_MAGIC ")!"); |
| 259 | } | 259 | } |
| 260 | 260 | ||
| 261 | /* check if it has the correct packet number */ | 261 | /* check if it has the correct packet number */ |
| 262 | if (header.packet_num != client->afc_packet->packet_num) { | 262 | if (header.packet_num != client->afc_packet->packet_num) { |
| 263 | /* otherwise print a warning but do not abort */ | 263 | /* otherwise print a warning but do not abort */ |
| 264 | log_debug_msg("%s: ERROR: Unexpected packet number (%lld != %lld) aborting.\n", __func__, header.packet_num, client->afc_packet->packet_num); | 264 | debug_info("ERROR: Unexpected packet number (%lld != %lld) aborting.", header.packet_num, client->afc_packet->packet_num); |
| 265 | *dump_here = NULL; | 265 | *dump_here = NULL; |
| 266 | return AFC_E_OP_HEADER_INVALID; | 266 | return AFC_E_OP_HEADER_INVALID; |
| 267 | } | 267 | } |
| 268 | 268 | ||
| 269 | /* then, read the attached packet */ | 269 | /* then, read the attached packet */ |
| 270 | if (header.this_length < sizeof(AFCPacket)) { | 270 | if (header.this_length < sizeof(AFCPacket)) { |
| 271 | log_debug_msg("%s: Invalid AFCPacket header received!\n", __func__); | 271 | debug_info("Invalid AFCPacket header received!"); |
| 272 | *dump_here = NULL; | 272 | *dump_here = NULL; |
| 273 | return AFC_E_OP_HEADER_INVALID; | 273 | return AFC_E_OP_HEADER_INVALID; |
| 274 | } else if ((header.this_length == header.entire_length) | 274 | } else if ((header.this_length == header.entire_length) |
| 275 | && header.entire_length == sizeof(AFCPacket)) { | 275 | && header.entire_length == sizeof(AFCPacket)) { |
| 276 | log_debug_msg("%s: Empty AFCPacket received!\n", __func__); | 276 | debug_info("Empty AFCPacket received!"); |
| 277 | *dump_here = NULL; | 277 | *dump_here = NULL; |
| 278 | *bytes_recv = 0; | 278 | *bytes_recv = 0; |
| 279 | if (header.operation == AFC_OP_DATA) { | 279 | if (header.operation == AFC_OP_DATA) { |
| @@ -283,14 +283,14 @@ static afc_error_t afc_receive_data(afc_client_t client, char **dump_here, uint3 | |||
| 283 | } | 283 | } |
| 284 | } | 284 | } |
| 285 | 285 | ||
| 286 | log_debug_msg("%s: received AFC packet, full len=%lld, this len=%lld, operation=0x%llx\n", __func__, header.entire_length, header.this_length, header.operation); | 286 | debug_info("received AFC packet, full len=%lld, this len=%lld, operation=0x%llx", header.entire_length, header.this_length, header.operation); |
| 287 | 287 | ||
| 288 | entire_len = (uint32_t)header.entire_length - sizeof(AFCPacket); | 288 | entire_len = (uint32_t)header.entire_length - sizeof(AFCPacket); |
| 289 | this_len = (uint32_t)header.this_length - sizeof(AFCPacket); | 289 | this_len = (uint32_t)header.this_length - sizeof(AFCPacket); |
| 290 | 290 | ||
| 291 | /* this is here as a check (perhaps a different upper limit is good?) */ | 291 | /* this is here as a check (perhaps a different upper limit is good?) */ |
| 292 | if (entire_len > (uint32_t)MAXIMUM_PACKET_SIZE) { | 292 | if (entire_len > (uint32_t)MAXIMUM_PACKET_SIZE) { |
| 293 | fprintf(stderr, "%s: entire_len is larger than MAXIMUM_PACKET_SIZE, (%d > %d)!\n", __func__, entire_len, MAXIMUM_PACKET_SIZE); | 293 | fprintf(stderr, "%s: entire_len is larger than MAXIMUM_PACKET_SIZE, (%d > %d)!", __func__, entire_len, MAXIMUM_PACKET_SIZE); |
| 294 | } | 294 | } |
| 295 | 295 | ||
| 296 | *dump_here = (char*)malloc(entire_len); | 296 | *dump_here = (char*)malloc(entire_len); |
| @@ -299,12 +299,12 @@ static afc_error_t afc_receive_data(afc_client_t client, char **dump_here, uint3 | |||
| 299 | if (*bytes_recv <= 0) { | 299 | if (*bytes_recv <= 0) { |
| 300 | free(*dump_here); | 300 | free(*dump_here); |
| 301 | *dump_here = NULL; | 301 | *dump_here = NULL; |
| 302 | log_debug_msg("%s: Did not get packet contents!\n", __func__); | 302 | debug_info("Did not get packet contents!"); |
| 303 | return AFC_E_NOT_ENOUGH_DATA; | 303 | return AFC_E_NOT_ENOUGH_DATA; |
| 304 | } else if (*bytes_recv < this_len) { | 304 | } else if (*bytes_recv < this_len) { |
| 305 | free(*dump_here); | 305 | free(*dump_here); |
| 306 | *dump_here = NULL; | 306 | *dump_here = NULL; |
| 307 | log_debug_msg("%s: Could not receive this_len=%d bytes\n", __func__, this_len); | 307 | debug_info("Could not receive this_len=%d bytes", this_len); |
| 308 | return AFC_E_NOT_ENOUGH_DATA; | 308 | return AFC_E_NOT_ENOUGH_DATA; |
| 309 | } | 309 | } |
| 310 | } | 310 | } |
| @@ -315,13 +315,13 @@ static afc_error_t afc_receive_data(afc_client_t client, char **dump_here, uint3 | |||
| 315 | while (current_count < entire_len) { | 315 | while (current_count < entire_len) { |
| 316 | iphone_device_recv(client->connection, (*dump_here)+current_count, entire_len - current_count, bytes_recv); | 316 | iphone_device_recv(client->connection, (*dump_here)+current_count, entire_len - current_count, bytes_recv); |
| 317 | if (*bytes_recv <= 0) { | 317 | if (*bytes_recv <= 0) { |
| 318 | log_debug_msg("%s: Error receiving data (recv returned %d)\n", __func__, *bytes_recv); | 318 | debug_info("Error receiving data (recv returned %d)", *bytes_recv); |
| 319 | break; | 319 | break; |
| 320 | } | 320 | } |
| 321 | current_count += *bytes_recv; | 321 | current_count += *bytes_recv; |
| 322 | } | 322 | } |
| 323 | if (current_count < entire_len) { | 323 | if (current_count < entire_len) { |
| 324 | log_debug_msg("%s: WARNING: could not receive full packet (read %s, size %d)\n", __func__, current_count, entire_len); | 324 | debug_info("WARNING: could not receive full packet (read %s, size %d)", current_count, entire_len); |
| 325 | } | 325 | } |
| 326 | } | 326 | } |
| 327 | 327 | ||
| @@ -329,14 +329,14 @@ static afc_error_t afc_receive_data(afc_client_t client, char **dump_here, uint3 | |||
| 329 | param1 = *(uint64_t*)(*dump_here); | 329 | param1 = *(uint64_t*)(*dump_here); |
| 330 | } | 330 | } |
| 331 | 331 | ||
| 332 | log_debug_msg("%s: packet data size = %i\n", __func__, current_count); | 332 | debug_info("packet data size = %i", current_count); |
| 333 | log_debug_msg("%s: packet data follows\n", __func__); | 333 | debug_info("packet data follows"); |
| 334 | log_debug_buffer(*dump_here, current_count); | 334 | debug_buffer(*dump_here, current_count); |
| 335 | 335 | ||
| 336 | /* check operation types */ | 336 | /* check operation types */ |
| 337 | if (header.operation == AFC_OP_STATUS) { | 337 | if (header.operation == AFC_OP_STATUS) { |
| 338 | /* status response */ | 338 | /* status response */ |
| 339 | log_debug_msg("%s: got a status response, code=%lld\n", __func__, param1); | 339 | debug_info("got a status response, code=%lld", param1); |
| 340 | 340 | ||
| 341 | if (param1 != AFC_E_SUCCESS) { | 341 | if (param1 != AFC_E_SUCCESS) { |
| 342 | /* error status */ | 342 | /* error status */ |
| @@ -347,21 +347,21 @@ static afc_error_t afc_receive_data(afc_client_t client, char **dump_here, uint3 | |||
| 347 | } | 347 | } |
| 348 | } else if (header.operation == AFC_OP_DATA) { | 348 | } else if (header.operation == AFC_OP_DATA) { |
| 349 | /* data response */ | 349 | /* data response */ |
| 350 | log_debug_msg("%s: got a data response\n", __func__); | 350 | debug_info("got a data response"); |
| 351 | } else if (header.operation == AFC_OP_FILE_OPEN_RES) { | 351 | } else if (header.operation == AFC_OP_FILE_OPEN_RES) { |
| 352 | /* file handle response */ | 352 | /* file handle response */ |
| 353 | log_debug_msg("%s: got a file handle response, handle=%lld\n", __func__, param1); | 353 | debug_info("got a file handle response, handle=%lld", param1); |
| 354 | } else if (header.operation == AFC_OP_FILE_TELL_RES) { | 354 | } else if (header.operation == AFC_OP_FILE_TELL_RES) { |
| 355 | /* tell response */ | 355 | /* tell response */ |
| 356 | log_debug_msg("%s: got a tell response, position=%lld\n", __func__, param1); | 356 | debug_info("got a tell response, position=%lld", param1); |
| 357 | } else { | 357 | } else { |
| 358 | /* unknown operation code received */ | 358 | /* unknown operation code received */ |
| 359 | free(*dump_here); | 359 | free(*dump_here); |
| 360 | *dump_here = NULL; | 360 | *dump_here = NULL; |
| 361 | *bytes_recv = 0; | 361 | *bytes_recv = 0; |
| 362 | 362 | ||
| 363 | log_debug_msg("%s: WARNING: Unknown operation code received 0x%llx param1=%lld\n", __func__, header.operation, param1); | 363 | debug_info("WARNING: Unknown operation code received 0x%llx param1=%lld", header.operation, param1); |
| 364 | fprintf(stderr, "%s: WARNING: Unknown operation code received 0x%llx param1=%lld\n", __func__, (long long)header.operation, (long long)param1); | 364 | fprintf(stderr, "%s: WARNING: Unknown operation code received 0x%llx param1=%lld", __func__, (long long)header.operation, (long long)param1); |
| 365 | 365 | ||
| 366 | return AFC_E_OP_NOT_SUPPORTED; | 366 | return AFC_E_OP_NOT_SUPPORTED; |
| 367 | } | 367 | } |
| @@ -728,7 +728,7 @@ afc_file_open(afc_client_t client, const char *filename, | |||
| 728 | free(data); | 728 | free(data); |
| 729 | 729 | ||
| 730 | if (ret != AFC_E_SUCCESS) { | 730 | if (ret != AFC_E_SUCCESS) { |
| 731 | log_debug_msg("%s: Didn't receive a response to the command\n", __func__); | 731 | debug_info("Didn't receive a response to the command"); |
| 732 | afc_unlock(client); | 732 | afc_unlock(client); |
| 733 | return AFC_E_NOT_ENOUGH_DATA; | 733 | return AFC_E_NOT_ENOUGH_DATA; |
| 734 | } | 734 | } |
| @@ -743,7 +743,7 @@ afc_file_open(afc_client_t client, const char *filename, | |||
| 743 | return ret; | 743 | return ret; |
| 744 | } | 744 | } |
| 745 | 745 | ||
| 746 | log_debug_msg("%s: Didn't get any further data\n", __func__); | 746 | debug_info("Didn't get any further data"); |
| 747 | 747 | ||
| 748 | afc_unlock(client); | 748 | afc_unlock(client); |
| 749 | 749 | ||
| @@ -770,14 +770,14 @@ afc_file_read(afc_client_t client, uint64_t handle, char *data, uint32_t length, | |||
| 770 | 770 | ||
| 771 | if (!client || !client->afc_packet || !client->connection || handle == 0) | 771 | if (!client || !client->afc_packet || !client->connection || handle == 0) |
| 772 | return AFC_E_INVALID_ARGUMENT; | 772 | return AFC_E_INVALID_ARGUMENT; |
| 773 | log_debug_msg("%s: called for length %i\n", __func__, length); | 773 | debug_info("called for length %i", length); |
| 774 | 774 | ||
| 775 | afc_lock(client); | 775 | afc_lock(client); |
| 776 | 776 | ||
| 777 | // Looping here to get around the maximum amount of data that | 777 | // Looping here to get around the maximum amount of data that |
| 778 | // afc_receive_data can handle | 778 | // afc_receive_data can handle |
| 779 | while (current_count < length) { | 779 | while (current_count < length) { |
| 780 | log_debug_msg("%s: current count is %i but length is %i\n", __func__, current_count, length); | 780 | debug_info("current count is %i but length is %i", current_count, length); |
| 781 | 781 | ||
| 782 | // Send the read command | 782 | // Send the read command |
| 783 | AFCFilePacket *packet = (AFCFilePacket *) malloc(sizeof(AFCFilePacket)); | 783 | AFCFilePacket *packet = (AFCFilePacket *) malloc(sizeof(AFCFilePacket)); |
| @@ -794,8 +794,8 @@ afc_file_read(afc_client_t client, uint64_t handle, char *data, uint32_t length, | |||
| 794 | } | 794 | } |
| 795 | // Receive the data | 795 | // Receive the data |
| 796 | ret = afc_receive_data(client, &input, &bytes_loc); | 796 | ret = afc_receive_data(client, &input, &bytes_loc); |
| 797 | log_debug_msg("%s: afc_receive_data returned error: %d\n", __func__, ret); | 797 | debug_info("afc_receive_data returned error: %d", ret); |
| 798 | log_debug_msg("%s: bytes returned: %i\n", __func__, bytes_loc); | 798 | debug_info("bytes returned: %i", bytes_loc); |
| 799 | if (ret != AFC_E_SUCCESS) { | 799 | if (ret != AFC_E_SUCCESS) { |
| 800 | afc_unlock(client); | 800 | afc_unlock(client); |
| 801 | return ret; | 801 | return ret; |
| @@ -808,7 +808,7 @@ afc_file_read(afc_client_t client, uint64_t handle, char *data, uint32_t length, | |||
| 808 | return ret; | 808 | return ret; |
| 809 | } else { | 809 | } else { |
| 810 | if (input) { | 810 | if (input) { |
| 811 | log_debug_msg("%s: %d\n", __func__, bytes_loc); | 811 | debug_info("%d", bytes_loc); |
| 812 | memcpy(data + current_count, input, (bytes_loc > length) ? length : bytes_loc); | 812 | memcpy(data + current_count, input, (bytes_loc > length) ? length : bytes_loc); |
| 813 | free(input); | 813 | free(input); |
| 814 | input = NULL; | 814 | input = NULL; |
| @@ -816,7 +816,7 @@ afc_file_read(afc_client_t client, uint64_t handle, char *data, uint32_t length, | |||
| 816 | } | 816 | } |
| 817 | } | 817 | } |
| 818 | } | 818 | } |
| 819 | log_debug_msg("%s: returning current_count as %i\n", __func__, current_count); | 819 | debug_info("returning current_count as %i", current_count); |
| 820 | 820 | ||
| 821 | afc_unlock(client); | 821 | afc_unlock(client); |
| 822 | *bytes_read = current_count; | 822 | *bytes_read = current_count; |
| @@ -849,7 +849,7 @@ afc_file_write(afc_client_t client, uint64_t handle, const char *data, uint32_t | |||
| 849 | 849 | ||
| 850 | afc_lock(client); | 850 | afc_lock(client); |
| 851 | 851 | ||
| 852 | log_debug_msg("%s: Write length: %i\n", __func__, length); | 852 | debug_info("Write length: %i", length); |
| 853 | 853 | ||
| 854 | // Divide the file into segments. | 854 | // Divide the file into segments. |
| 855 | for (i = 0; i < segments; i++) { | 855 | for (i = 0; i < segments; i++) { |
| @@ -909,7 +909,7 @@ afc_file_write(afc_client_t client, uint64_t handle, const char *data, uint32_t | |||
| 909 | ret = afc_receive_data(client, &acknowledgement, &bytes_loc); | 909 | ret = afc_receive_data(client, &acknowledgement, &bytes_loc); |
| 910 | afc_unlock(client); | 910 | afc_unlock(client); |
| 911 | if (ret != AFC_E_SUCCESS) { | 911 | if (ret != AFC_E_SUCCESS) { |
| 912 | log_debug_msg("%s: uh oh?\n", __func__); | 912 | debug_info("uh oh?"); |
| 913 | } else { | 913 | } else { |
| 914 | free(acknowledgement); | 914 | free(acknowledgement); |
| 915 | } | 915 | } |
| @@ -933,7 +933,7 @@ afc_error_t afc_file_close(afc_client_t client, uint64_t handle) | |||
| 933 | 933 | ||
| 934 | afc_lock(client); | 934 | afc_lock(client); |
| 935 | 935 | ||
| 936 | log_debug_msg("%s: File handle %i\n", __func__, handle); | 936 | debug_info("File handle %i", handle); |
| 937 | 937 | ||
| 938 | // Send command | 938 | // Send command |
| 939 | memcpy(buffer, &handle, sizeof(uint64_t)); | 939 | memcpy(buffer, &handle, sizeof(uint64_t)); |
| @@ -981,7 +981,7 @@ afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t op | |||
| 981 | 981 | ||
| 982 | afc_lock(client); | 982 | afc_lock(client); |
| 983 | 983 | ||
| 984 | log_debug_msg("%s: file handle %i\n", __func__, handle); | 984 | debug_info("file handle %i", handle); |
| 985 | 985 | ||
| 986 | // Send command | 986 | // Send command |
| 987 | memcpy(buffer, &handle, sizeof(uint64_t)); | 987 | memcpy(buffer, &handle, sizeof(uint64_t)); |
| @@ -995,13 +995,13 @@ afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t op | |||
| 995 | 995 | ||
| 996 | if (ret != AFC_E_SUCCESS) { | 996 | if (ret != AFC_E_SUCCESS) { |
| 997 | afc_unlock(client); | 997 | afc_unlock(client); |
| 998 | log_debug_msg("%s: could not send lock command\n", __func__); | 998 | debug_info("could not send lock command"); |
| 999 | return AFC_E_UNKNOWN_ERROR; | 999 | return AFC_E_UNKNOWN_ERROR; |
| 1000 | } | 1000 | } |
| 1001 | // Receive the response | 1001 | // Receive the response |
| 1002 | ret = afc_receive_data(client, &buffer, &bytes); | 1002 | ret = afc_receive_data(client, &buffer, &bytes); |
| 1003 | if (buffer) { | 1003 | if (buffer) { |
| 1004 | log_debug_buffer(buffer, bytes); | 1004 | debug_buffer(buffer, bytes); |
| 1005 | free(buffer); | 1005 | free(buffer); |
| 1006 | } | 1006 | } |
| 1007 | afc_unlock(client); | 1007 | afc_unlock(client); |
| @@ -1214,9 +1214,9 @@ afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const c | |||
| 1214 | 1214 | ||
| 1215 | afc_lock(client); | 1215 | afc_lock(client); |
| 1216 | 1216 | ||
| 1217 | log_debug_msg("%s: link type: %lld\n", __func__, type); | 1217 | debug_info("link type: %lld", type); |
| 1218 | log_debug_msg("%s: target: %s, length:%d\n", __func__, target, strlen(target)); | 1218 | debug_info("target: %s, length:%d", target, strlen(target)); |
| 1219 | log_debug_msg("%s: linkname: %s, length:%d\n", __func__, linkname, strlen(linkname)); | 1219 | debug_info("linkname: %s, length:%d", linkname, strlen(linkname)); |
| 1220 | 1220 | ||
| 1221 | // Send command | 1221 | // Send command |
| 1222 | memcpy(send, &type, 8); | 1222 | memcpy(send, &type, 8); |
