summaryrefslogtreecommitdiffstats
path: root/src/AFC.c
diff options
context:
space:
mode:
authorGravatar Zach C2008-08-31 11:25:22 -0700
committerGravatar Jonathan Beck2008-11-24 22:49:07 +0100
commitf4c4b783c8dbe2fe8e7e6f6b5f19f0d44b489c9a (patch)
tree9ef8c57fe298a4ae9e0a443d7103e6126c869020 /src/AFC.c
parent8c3a01e11bb9c74e2a1bb7da143cb35469f29fba (diff)
downloadlibimobiledevice-f4c4b783c8dbe2fe8e7e6f6b5f19f0d44b489c9a.tar.gz
libimobiledevice-f4c4b783c8dbe2fe8e7e6f6b5f19f0d44b489c9a.tar.bz2
Added binary-plist support (tweaked slightly to move stuff around)
Signed-off-by: Matt Colyer <matt@colyer.name> fix makefile to take correct main function into account
Diffstat (limited to 'src/AFC.c')
-rw-r--r--src/AFC.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/src/AFC.c b/src/AFC.c
index 54ea1bb..899bd47 100644
--- a/src/AFC.c
+++ b/src/AFC.c
@@ -245,7 +245,7 @@ static int receive_AFC_data(iphone_afc_client_t client, char **dump_here)
245 return retval; 245 return retval;
246 } 246 }
247 247
248 uint32 param1 = buffer[sizeof(AFCPacket)]; 248 uint32_t param1 = buffer[sizeof(AFCPacket)];
249 free(buffer); 249 free(buffer);
250 250
251 if (r_packet->operation == AFC_ERROR && !(client->afc_packet->operation == AFC_DELETE && param1 == 7)) { 251 if (r_packet->operation == AFC_ERROR && !(client->afc_packet->operation == AFC_DELETE && param1 == 7)) {
@@ -474,7 +474,7 @@ iphone_error_t iphone_afc_delete_file(iphone_afc_client_t client, const char *pa
474iphone_error_t iphone_afc_rename_file(iphone_afc_client_t client, const char *from, const char *to) 474iphone_error_t iphone_afc_rename_file(iphone_afc_client_t client, const char *from, const char *to)
475{ 475{
476 char *response = NULL; 476 char *response = NULL;
477 char *send = (char *) malloc(sizeof(char) * (strlen(from) + strlen(to) + 1 + sizeof(uint32))); 477 char *send = (char *) malloc(sizeof(char) * (strlen(from) + strlen(to) + 1 + sizeof(uint32_t)));
478 int bytes = 0; 478 int bytes = 0;
479 479
480 if (!client || !from || !to || !client->afc_packet || !client->connection) 480 if (!client || !from || !to || !client->afc_packet || !client->connection)
@@ -660,7 +660,7 @@ iphone_afc_open_file(iphone_afc_client_t client, const char *filename,
660 iphone_afc_file_mode_t file_mode, iphone_afc_file_t * file) 660 iphone_afc_file_mode_t file_mode, iphone_afc_file_t * file)
661{ 661{
662 iphone_afc_file_t file_loc = NULL; 662 iphone_afc_file_t file_loc = NULL;
663 uint32 ag = 0; 663 uint32_t ag = 0;
664 int bytes = 0, length = 0; 664 int bytes = 0, length = 0;
665 char *data = (char *) malloc(sizeof(char) * (8 + strlen(filename) + 1)); 665 char *data = (char *) malloc(sizeof(char) * (8 + strlen(filename) + 1));
666 666
@@ -795,7 +795,7 @@ iphone_afc_write_file(iphone_afc_client_t client, iphone_afc_file_t file,
795{ 795{
796 char *acknowledgement = NULL; 796 char *acknowledgement = NULL;
797 const int MAXIMUM_WRITE_SIZE = 1 << 15; 797 const int MAXIMUM_WRITE_SIZE = 1 << 15;
798 uint32 zero = 0, bytes_loc = 0, segments = (length / MAXIMUM_WRITE_SIZE), current_count = 0, i = 0; 798 uint32_t zero = 0, bytes_loc = 0, segments = (length / MAXIMUM_WRITE_SIZE), current_count = 0, i = 0;
799 char *out_buffer = NULL; 799 char *out_buffer = NULL;
800 800
801 if (!client || !client->afc_packet || !client->connection || !file || !bytes) 801 if (!client || !client->afc_packet || !client->connection || !file || !bytes)
@@ -812,8 +812,8 @@ iphone_afc_write_file(iphone_afc_client_t client, iphone_afc_file_t file,
812 client->afc_packet->entire_length = client->afc_packet->this_length + MAXIMUM_WRITE_SIZE; 812 client->afc_packet->entire_length = client->afc_packet->this_length + MAXIMUM_WRITE_SIZE;
813 client->afc_packet->operation = AFC_WRITE; 813 client->afc_packet->operation = AFC_WRITE;
814 out_buffer = (char *) malloc(sizeof(char) * client->afc_packet->entire_length - sizeof(AFCPacket)); 814 out_buffer = (char *) malloc(sizeof(char) * client->afc_packet->entire_length - sizeof(AFCPacket));
815 memcpy(out_buffer, (char *) &file->filehandle, sizeof(uint32)); 815 memcpy(out_buffer, (char *) &file->filehandle, sizeof(uint32_t));
816 memcpy(out_buffer + 4, (char *) &zero, sizeof(uint32)); 816 memcpy(out_buffer + 4, (char *) &zero, sizeof(uint32_t));
817 memcpy(out_buffer + 8, data + current_count, MAXIMUM_WRITE_SIZE); 817 memcpy(out_buffer + 8, data + current_count, MAXIMUM_WRITE_SIZE);
818 bytes_loc = dispatch_AFC_packet(client, out_buffer, MAXIMUM_WRITE_SIZE + 8); 818 bytes_loc = dispatch_AFC_packet(client, out_buffer, MAXIMUM_WRITE_SIZE + 8);
819 if (bytes_loc < 0) { 819 if (bytes_loc < 0) {
@@ -845,8 +845,8 @@ iphone_afc_write_file(iphone_afc_client_t client, iphone_afc_file_t file,
845 client->afc_packet->entire_length = client->afc_packet->this_length + (length - current_count); 845 client->afc_packet->entire_length = client->afc_packet->this_length + (length - current_count);
846 client->afc_packet->operation = AFC_WRITE; 846 client->afc_packet->operation = AFC_WRITE;
847 out_buffer = (char *) malloc(sizeof(char) * client->afc_packet->entire_length - sizeof(AFCPacket)); 847 out_buffer = (char *) malloc(sizeof(char) * client->afc_packet->entire_length - sizeof(AFCPacket));
848 memcpy(out_buffer, (char *) &file->filehandle, sizeof(uint32)); 848 memcpy(out_buffer, (char *) &file->filehandle, sizeof(uint32_t));
849 memcpy(out_buffer + 4, (char *) &zero, sizeof(uint32)); 849 memcpy(out_buffer + 4, (char *) &zero, sizeof(uint32_t));
850 memcpy(out_buffer + 8, data + current_count, (length - current_count)); 850 memcpy(out_buffer + 8, data + current_count, (length - current_count));
851 bytes_loc = dispatch_AFC_packet(client, out_buffer, (length - current_count) + 8); 851 bytes_loc = dispatch_AFC_packet(client, out_buffer, (length - current_count) + 8);
852 free(out_buffer); 852 free(out_buffer);
@@ -881,7 +881,7 @@ iphone_error_t iphone_afc_close_file(iphone_afc_client_t client, iphone_afc_file
881 if (!client || !file) 881 if (!client || !file)
882 return IPHONE_E_INVALID_ARG; 882 return IPHONE_E_INVALID_ARG;
883 char *buffer = malloc(sizeof(char) * 8); 883 char *buffer = malloc(sizeof(char) * 8);
884 uint32 zero = 0; 884 uint32_t zero = 0;
885 int bytes = 0; 885 int bytes = 0;
886 886
887 afc_lock(client); 887 afc_lock(client);
@@ -889,8 +889,8 @@ iphone_error_t iphone_afc_close_file(iphone_afc_client_t client, iphone_afc_file
889 log_debug_msg("afc_close_file: File handle %i\n", file->filehandle); 889 log_debug_msg("afc_close_file: File handle %i\n", file->filehandle);
890 890
891 // Send command 891 // Send command
892 memcpy(buffer, &file->filehandle, sizeof(uint32)); 892 memcpy(buffer, &file->filehandle, sizeof(uint32_t));
893 memcpy(buffer + sizeof(uint32), &zero, sizeof(zero)); 893 memcpy(buffer + sizeof(uint32_t), &zero, sizeof(zero));
894 client->afc_packet->operation = AFC_FILE_CLOSE; 894 client->afc_packet->operation = AFC_FILE_CLOSE;
895 client->afc_packet->entire_length = client->afc_packet->this_length = 0; 895 client->afc_packet->entire_length = client->afc_packet->this_length = 0;
896 bytes = dispatch_AFC_packet(client, buffer, sizeof(char) * 8); 896 bytes = dispatch_AFC_packet(client, buffer, sizeof(char) * 8);
@@ -926,7 +926,7 @@ iphone_error_t iphone_afc_close_file(iphone_afc_client_t client, iphone_afc_file
926iphone_error_t iphone_afc_seek_file(iphone_afc_client_t client, iphone_afc_file_t file, int seekpos) 926iphone_error_t iphone_afc_seek_file(iphone_afc_client_t client, iphone_afc_file_t file, int seekpos)
927{ 927{
928 char *buffer = (char *) malloc(sizeof(char) * 24); 928 char *buffer = (char *) malloc(sizeof(char) * 24);
929 uint32 seekto = 0, bytes = 0, zero = 0; 929 uint32_t seekto = 0, bytes = 0, zero = 0;
930 930
931 if (seekpos < 0) 931 if (seekpos < 0)
932 seekpos = file->size - abs(seekpos); 932 seekpos = file->size - abs(seekpos);
@@ -935,12 +935,12 @@ iphone_error_t iphone_afc_seek_file(iphone_afc_client_t client, iphone_afc_file_
935 935
936 // Send the command 936 // Send the command
937 seekto = seekpos; 937 seekto = seekpos;
938 memcpy(buffer, &file->filehandle, sizeof(uint32)); // handle 938 memcpy(buffer, &file->filehandle, sizeof(uint32_t)); // handle
939 memcpy(buffer + 4, &zero, sizeof(uint32)); // pad 939 memcpy(buffer + 4, &zero, sizeof(uint32_t)); // pad
940 memcpy(buffer + 8, &zero, sizeof(uint32)); // fromwhere 940 memcpy(buffer + 8, &zero, sizeof(uint32_t)); // fromwhere
941 memcpy(buffer + 12, &zero, sizeof(uint32)); // pad 941 memcpy(buffer + 12, &zero, sizeof(uint32_t)); // pad
942 memcpy(buffer + 16, &seekto, sizeof(uint32)); // offset 942 memcpy(buffer + 16, &seekto, sizeof(uint32_t)); // offset
943 memcpy(buffer + 20, &zero, sizeof(uint32)); // pad 943 memcpy(buffer + 20, &zero, sizeof(uint32_t)); // pad
944 client->afc_packet->operation = AFC_FILE_SEEK; 944 client->afc_packet->operation = AFC_FILE_SEEK;
945 client->afc_packet->this_length = client->afc_packet->entire_length = 0; 945 client->afc_packet->this_length = client->afc_packet->entire_length = 0;
946 bytes = dispatch_AFC_packet(client, buffer, 23); 946 bytes = dispatch_AFC_packet(client, buffer, 23);
@@ -979,14 +979,14 @@ iphone_error_t iphone_afc_seek_file(iphone_afc_client_t client, iphone_afc_file_
979iphone_error_t iphone_afc_truncate_file(iphone_afc_client_t client, iphone_afc_file_t file, uint32_t newsize) 979iphone_error_t iphone_afc_truncate_file(iphone_afc_client_t client, iphone_afc_file_t file, uint32_t newsize)
980{ 980{
981 char *buffer = (char *) malloc(sizeof(char) * 16); 981 char *buffer = (char *) malloc(sizeof(char) * 16);
982 uint32 bytes = 0, zero = 0; 982 uint32_t bytes = 0, zero = 0;
983 983
984 afc_lock(client); 984 afc_lock(client);
985 985
986 // Send command 986 // Send command
987 memcpy(buffer, &file->filehandle, sizeof(uint32)); // handle 987 memcpy(buffer, &file->filehandle, sizeof(uint32_t)); // handle
988 memcpy(buffer + 4, &zero, sizeof(uint32)); // pad 988 memcpy(buffer + 4, &zero, sizeof(uint32_t)); // pad
989 memcpy(buffer + 8, &newsize, sizeof(uint32)); // newsize 989 memcpy(buffer + 8, &newsize, sizeof(uint32_t)); // newsize
990 memcpy(buffer + 12, &zero, 3); // pad 990 memcpy(buffer + 12, &zero, 3); // pad
991 client->afc_packet->operation = AFC_FILE_TRUNCATE; 991 client->afc_packet->operation = AFC_FILE_TRUNCATE;
992 client->afc_packet->this_length = client->afc_packet->entire_length = 0; 992 client->afc_packet->this_length = client->afc_packet->entire_length = 0;
@@ -1012,7 +1012,7 @@ iphone_error_t iphone_afc_truncate_file(iphone_afc_client_t client, iphone_afc_f
1012 } 1012 }
1013} 1013}
1014 1014
1015uint32 iphone_afc_get_file_handle(iphone_afc_file_t file) 1015uint32_t iphone_afc_get_file_handle(iphone_afc_file_t file)
1016{ 1016{
1017 return file->filehandle; 1017 return file->filehandle;
1018} 1018}