summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Jonathan Beck2008-08-25 23:50:22 +0200
committerGravatar Jonathan Beck2008-08-31 19:33:18 +0200
commite52da6fe75008174a254254ec83394766afb624b (patch)
tree9ad8cd860525a3340dd49e2dbc8cd685dcf1ca7e
parent6ac4ceb4c6ee63c279f4841381a3eb09598f3517 (diff)
downloadlibimobiledevice-e52da6fe75008174a254254ec83394766afb624b.tar.gz
libimobiledevice-e52da6fe75008174a254254ec83394766afb624b.tar.bz2
make it compile
-rw-r--r--src/AFC.c14
-rw-r--r--src/ifuse.c106
-rw-r--r--src/iphone.c8
-rw-r--r--src/lockdown.c32
-rw-r--r--src/usbmux.c4
5 files changed, 80 insertions, 84 deletions
diff --git a/src/AFC.c b/src/AFC.c
index 64a26b0..5866915 100644
--- a/src/AFC.c
+++ b/src/AFC.c
@@ -75,7 +75,7 @@ int iphone_afc_new_client ( iphone_device_t device, int src_port, int dst_port,
// Allocate a packet
client_loc->afc_packet = (AFCPacket*)malloc(sizeof(AFCPacket));
if (!client_loc->afc_packet) {
- mux_close_connection(client_loc->connection);
+ iphone_mux_free_client(client_loc->connection);
free(client_loc);
return IPHONE_E_UNKNOWN_ERROR;
}
@@ -157,7 +157,7 @@ static int dispatch_AFC_packet(iphone_afc_client_t client, const char *data, int
return -1;
}
memcpy(buffer+sizeof(AFCPacket), data, offset);
- bytes = mux_send(client->connection, buffer, client->afc_packet->this_length);
+ bytes = iphone_mux_send(client->connection, buffer, client->afc_packet->this_length);
free(buffer);
if (bytes <= 0) {
return bytes;
@@ -170,7 +170,7 @@ static int dispatch_AFC_packet(iphone_afc_client_t client, const char *data, int
fwrite(data+offset, 1, length-offset, stdout);
}
- bytes = mux_send(client->connection, data+offset, length-offset);
+ bytes = iphone_mux_send(client->connection, data+offset, length-offset);
return bytes;
} else {
if (debug) fprintf(stderr, "dispatch_AFC_packet doin things the old way\n");
@@ -181,7 +181,7 @@ static int dispatch_AFC_packet(iphone_afc_client_t client, const char *data, int
if (length > 0) { memcpy(buffer+sizeof(AFCPacket), data, length); buffer[sizeof(AFCPacket)+length] = '\0'; }
if (debug) fwrite(buffer, 1, client->afc_packet->this_length, stdout);
if (debug) fprintf(stderr, "\n");
- bytes = mux_send(client->connection, buffer, client->afc_packet->this_length);
+ bytes = iphone_mux_send(client->connection, buffer, client->afc_packet->this_length);
if (buffer) {
free(buffer);
@@ -210,7 +210,7 @@ static int receive_AFC_data(iphone_afc_client_t client, char **dump_here) {
int bytes = 0, recv_len = 0, current_count=0;
int retval = 0;
- bytes = mux_recv(client->connection, buffer, sizeof(AFCPacket) * 4);
+ bytes = iphone_mux_recv(client->connection, buffer, sizeof(AFCPacket) * 4);
if (bytes <= 0) {
free(buffer);
fprintf(stderr, "Just didn't get enough.\n");
@@ -263,7 +263,7 @@ static int receive_AFC_data(iphone_afc_client_t client, char **dump_here) {
buffer = (char*)malloc(sizeof(char) * (recv_len < MAXIMUM_PACKET_SIZE) ? recv_len : MAXIMUM_PACKET_SIZE);
final_buffer = (char*)malloc(sizeof(char) * recv_len);
while(current_count < recv_len){
- bytes = mux_recv(client->connection, buffer, recv_len-current_count);
+ bytes = iphone_mux_recv(client->connection, buffer, recv_len-current_count);
if (debug) fprintf(stderr, "receive_AFC_data: still collecting packets\n");
if (bytes < 0)
{
@@ -603,7 +603,7 @@ int iphone_afc_get_file_attr ( iphone_afc_client_t client, const char *filename,
stbuf->st_uid = getuid();
stbuf->st_gid = getgid();
- afc_close_file(client,file);
+ iphone_afc_close_file(client,file);
}
}
diff --git a/src/ifuse.c b/src/ifuse.c
index cc2072f..1c184a2 100644
--- a/src/ifuse.c
+++ b/src/ifuse.c
@@ -49,8 +49,9 @@ int debug = 0;
static int ifuse_getattr(const char *path, struct stat *stbuf) {
int res = 0;
- AFCFile *file;
- AFClient *afc = fuse_get_context()->private_data;
+
+ iphone_afc_client_t afc = fuse_get_context()->private_data;
+ res = iphone_afc_get_file_attr(afc, path, stbuf);
return res;
}
@@ -59,9 +60,9 @@ static int ifuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi) {
int i;
char **dirs;
- AFClient *afc = fuse_get_context()->private_data;
+ iphone_afc_client_t afc = fuse_get_context()->private_data;
- dirs = afc_get_dir_list(afc, path);
+ dirs = iphone_afc_get_dir_list(afc, path);
if(!dirs)
return -ENOENT;
@@ -77,10 +78,10 @@ static int ifuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
static int ifuse_create(const char *path, mode_t mode, struct fuse_file_info *fi) {
// exactly the same as open but using a different mode
- AFCFile *file;
- AFClient *afc = fuse_get_context()->private_data;
+ iphone_afc_file_t file;
+ iphone_afc_client_t afc = fuse_get_context()->private_data;
- file = afc_open_file(afc, path, AFC_FILE_WRITE);
+ iphone_afc_open_file(afc, path, AFC_FILE_WRITE, &file);
fh_index++;
fi->fh = fh_index;
g_hash_table_insert(file_handles, &fh_index, file);
@@ -88,8 +89,8 @@ static int ifuse_create(const char *path, mode_t mode, struct fuse_file_info *fi
}
static int ifuse_open(const char *path, struct fuse_file_info *fi) {
- AFCFile *file;
- AFClient *afc = fuse_get_context()->private_data;
+ iphone_afc_file_t file;
+ iphone_afc_client_t afc = fuse_get_context()->private_data;
uint32 mode = 0;
if ((fi->flags & 3) == O_RDWR || (fi->flags & 3) == O_WRONLY) {
@@ -100,7 +101,7 @@ static int ifuse_open(const char *path, struct fuse_file_info *fi) {
mode = AFC_FILE_READ;
}
- file = afc_open_file(afc, path, mode);
+ iphone_afc_open_file(afc, path, mode, &file);
fh_index++;
fi->fh = fh_index;
@@ -112,8 +113,8 @@ static int ifuse_open(const char *path, struct fuse_file_info *fi) {
static int ifuse_read(const char *path, char *buf, size_t size, off_t offset,
struct fuse_file_info *fi) {
int bytes;
- AFCFile *file;
- AFClient *afc = fuse_get_context()->private_data;
+ iphone_afc_file_t file;
+ iphone_afc_client_t afc = fuse_get_context()->private_data;
if (size == 0)
return 0;
@@ -123,23 +124,23 @@ static int ifuse_read(const char *path, char *buf, size_t size, off_t offset,
return -ENOENT;
}
- bytes = afc_seek_file(afc, file, offset);
- bytes = afc_read_file(afc, file, buf, size);
+ bytes = iphone_afc_seek_file(afc, file, offset);
+ bytes = iphone_afc_read_file(afc, file, buf, size);
return bytes;
}
static int ifuse_write(const char *path, const char *buf, size_t size, off_t offset, struct fuse_file_info *fi) {
int bytes = 0;
- AFCFile *file = NULL;
- AFClient *afc = fuse_get_context()->private_data;
+ iphone_afc_file_t file = NULL;
+ iphone_afc_client_t afc = fuse_get_context()->private_data;
if (size == 0) return 0;
file = g_hash_table_lookup(file_handles, &(fi->fh));
if (!file) return -ENOENT;
- bytes = afc_seek_file(afc, file, offset);
- bytes = afc_write_file(afc, file, buf, size);
+ bytes = iphone_afc_seek_file(afc, file, offset);
+ bytes = iphone_afc_write_file(afc, file, buf, size);
return bytes;
}
@@ -148,16 +149,15 @@ static int ifuse_fsync(const char *path, int datasync, struct fuse_file_info *fi
}
static int ifuse_release(const char *path, struct fuse_file_info *fi){
- AFCFile *file;
- AFClient *afc = fuse_get_context()->private_data;
+ iphone_afc_file_t file;
+ iphone_afc_client_t afc = fuse_get_context()->private_data;
file = g_hash_table_lookup(file_handles, &(fi->fh));
if (!file){
return -ENOENT;
}
- afc_close_file(afc, file);
+ iphone_afc_close_file(afc, file);
- free(file);
g_hash_table_remove(file_handles, &(fi->fh));
return 0;
@@ -165,49 +165,44 @@ static int ifuse_release(const char *path, struct fuse_file_info *fi){
void *ifuse_init(struct fuse_conn_info *conn) {
int port = 0;
- AFClient *afc = NULL;
+ iphone_afc_client_t afc = NULL;
conn->async_read = 0;
file_handles = g_hash_table_new(g_int_hash, g_int_equal);
- phone = get_iPhone();
+ iphone_get_device(&phone);
if (!phone){
fprintf(stderr, "No iPhone found, is it connected?\n");
- return NULL;
- }
-
- lockdownd_client *control = new_lockdownd_client(phone);
- if (!lockdownd_hello(control)) {
- fprintf(stderr, "Something went wrong in the lockdownd client.\n");
return NULL;
}
+
- if (!lockdownd_init(phone, &control)) {
- free_iPhone(phone);
+ if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) {
+ iphone_free_device(phone);
fprintf(stderr, "Something went wrong in the lockdownd client.\n");
return NULL;
}
- port = lockdownd_start_service(control, "com.apple.afc");
+ port = iphone_lckd_start_service(control, "com.apple.afc");
if (!port) {
- lockdownd_close(control);
- free_iPhone(phone);
+ iphone_lckd_free_client(control);
+ iphone_free_device(phone);
fprintf(stderr, "Something went wrong when starting AFC.");
return NULL;
}
- afc = afc_connect(phone, 3432, port);
+ iphone_afc_new_client(phone, 3432, port, &afc);
return afc;
}
void ifuse_cleanup(void *data) {
- AFClient *afc = (AFClient *)data;
+ iphone_afc_client_t afc = (iphone_afc_client_t )data;
- afc_disconnect(afc);
- lockdownd_close(control);
- free_iPhone(phone);
+ iphone_afc_free_client(afc);
+ iphone_lckd_free_client(control);
+ iphone_free_device(phone);
}
int ifuse_flush(const char *path, struct fuse_file_info *fi) {
@@ -215,8 +210,8 @@ int ifuse_flush(const char *path, struct fuse_file_info *fi) {
}
int ifuse_statfs(const char *path, struct statvfs *stats) {
- AFClient *afc = fuse_get_context()->private_data;
- char **info_raw = afc_get_devinfo(afc);
+ iphone_afc_client_t afc = fuse_get_context()->private_data;
+ char **info_raw = iphone_afc_get_devinfo(afc);
uint32 totalspace = 0, freespace = 0, blocksize = 0, i = 0;
if (!info_raw) return -ENOENT;
@@ -243,38 +238,39 @@ int ifuse_statfs(const char *path, struct statvfs *stats) {
int ifuse_truncate(const char *path, off_t size) {
int result = 0;
- AFClient *afc = fuse_get_context()->private_data;
- AFCFile *tfile = afc_open_file(afc, path, AFC_FILE_READ);
+ iphone_afc_client_t afc = fuse_get_context()->private_data;
+ iphone_afc_file_t tfile = NULL;
+ iphone_afc_open_file(afc, path, AFC_FILE_READ, &tfile);
if (!tfile) return -1;
- result = afc_truncate_file(afc, tfile, size);
- afc_close_file(afc, tfile);
+ result = iphone_afc_truncate_file(afc, tfile, size);
+ iphone_afc_close_file(afc, tfile);
return result;
}
int ifuse_ftruncate(const char *path, off_t size, struct fuse_file_info *fi) {
- AFClient *afc = fuse_get_context()->private_data;
- AFCFile *file = g_hash_table_lookup(file_handles, &fi->fh);
+ iphone_afc_client_t afc = fuse_get_context()->private_data;
+ iphone_afc_file_t file = g_hash_table_lookup(file_handles, &fi->fh);
if (!file) return -ENOENT;
- return afc_truncate_file(afc, file, size);
+ return iphone_afc_truncate_file(afc, file, size);
}
int ifuse_unlink(const char *path) {
- AFClient *afc = fuse_get_context()->private_data;
- if (afc_delete_file(afc, path)) return 0;
+ iphone_afc_client_t afc = fuse_get_context()->private_data;
+ if (iphone_afc_delete_file(afc, path)) return 0;
else return -1;
}
int ifuse_rename(const char *from, const char *to) {
- AFClient *afc = fuse_get_context()->private_data;
- if (afc_rename_file(afc, from, to)) return 0;
+ iphone_afc_client_t afc = fuse_get_context()->private_data;
+ if (iphone_afc_rename_file(afc, from, to)) return 0;
else return -1;
}
int ifuse_mkdir(const char *dir, mode_t ignored) {
- AFClient *afc = fuse_get_context()->private_data;
- if (afc_mkdir(afc, dir)) return 0;
+ iphone_afc_client_t afc = fuse_get_context()->private_data;
+ if (iphone_afc_mkdir(afc, dir)) return 0;
else return -1;
}
diff --git a/src/iphone.c b/src/iphone.c
index 9027e35..3d179de 100644
--- a/src/iphone.c
+++ b/src/iphone.c
@@ -76,7 +76,7 @@ int iphone_get_device ( iphone_device_t *device ){
// Check to see if we are connected
if (!phone->device || !phone->__device) {
- free_iPhone(phone);
+ iphone_free_device(phone);
if (debug) fprintf(stderr, "get_iPhone(): iPhone not found\n");
return IPHONE_E_NO_DEVICE;
}
@@ -99,7 +99,7 @@ int iphone_get_device ( iphone_device_t *device ){
// Check for bad response
if (bytes < 20) {
free(version);
- free_iPhone(phone);
+ iphone_free_device(phone);
if (debug) fprintf(stderr, "get_iPhone(): Invalid version message -- header too short.\n");
if (debug && bytes < 0) fprintf(stderr, "get_iPhone(): libusb error message %d: %s (%s)\n",
bytes, usb_strerror(), strerror(-bytes));
@@ -115,7 +115,7 @@ int iphone_get_device ( iphone_device_t *device ){
return IPHONE_E_SUCCESS;
} else {
// Bad header
- free_iPhone(phone);
+ iphone_free_device(phone);
free(version);
if (debug) fprintf(stderr, "get_iPhone(): Received a bad header/invalid version number.");
return IPHONE_E_BAD_HEADER;
@@ -123,7 +123,7 @@ int iphone_get_device ( iphone_device_t *device ){
// If it got to this point it's gotta be bad
if (debug) fprintf(stderr, "get_iPhone(): Unknown error.\n");
- free_iPhone(phone);
+ iphone_free_device(phone);
free(version);
return IPHONE_E_UNKNOWN_ERROR; // if it got to this point it's gotta be bad
}
diff --git a/src/lockdown.c b/src/lockdown.c
index 4950a9e..d30d6e0 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -97,7 +97,7 @@ iphone_lckd_client_t new_lockdownd_client(iphone_device_t phone) {
void iphone_lckd_free_client( iphone_lckd_client_t client ) {
if (!client) return;
if (client->connection) {
- mux_close_connection(client->connection);
+ iphone_mux_free_client(client->connection);
}
if (client->ssl_session) gnutls_deinit(*client->ssl_session);
@@ -118,12 +118,12 @@ int iphone_lckd_recv ( iphone_lckd_client_t client, char **dump_data ) {
char *receive;
uint32 datalen = 0, bytes = 0;
- if (!client->in_SSL) bytes = mux_recv(client->connection, (char *)&datalen, sizeof(datalen));
+ if (!client->in_SSL) bytes = iphone_mux_recv(client->connection, (char *)&datalen, sizeof(datalen));
else bytes = gnutls_record_recv(*client->ssl_session, &datalen, sizeof(datalen));
datalen = ntohl(datalen);
receive = (char*)malloc(sizeof(char) * datalen);
- if (!client->in_SSL) bytes = mux_recv(client->connection, receive, datalen);
+ if (!client->in_SSL) bytes = iphone_mux_recv(client->connection, receive, datalen);
else bytes = gnutls_record_recv(*client->ssl_session, receive, datalen);
*dump_data = receive;
return bytes;
@@ -157,7 +157,7 @@ int iphone_lckd_send ( iphone_lckd_client_t client, char *raw_data, uint32_t len
packet = NULL;
}
- if (!client->in_SSL) bytes = mux_send(client->connection, real_query, ntohl(length)+sizeof(length));
+ if (!client->in_SSL) bytes = iphone_mux_send(client->connection, real_query, ntohl(length)+sizeof(length));
else gnutls_record_send(*client->ssl_session, real_query, ntohl(length)+sizeof(length));
if (debug) printf("lockdownd_send(): sent it!\n");
free(real_query);
@@ -186,11 +186,11 @@ int lockdownd_hello(iphone_lckd_client_t control) {
uint32 length;
xmlDocDumpMemory(plist, (xmlChar **)&XML_content, &length);
- bytes = lockdownd_send(control, XML_content, length);
+ bytes = iphone_lckd_send(control, XML_content, length);
xmlFree(XML_content);
xmlFreeDoc(plist); plist = NULL;
- bytes = lockdownd_recv(control, &XML_content);
+ bytes = iphone_lckd_recv(control, &XML_content);
plist = xmlReadMemory(XML_content, bytes, NULL, NULL, 0);
if (!plist) return 0;
@@ -240,13 +240,13 @@ int lockdownd_generic_get_value(iphone_lckd_client_t control, char *req_key, cha
xmlDocDumpMemory(plist, (xmlChar**)&XML_content, &length);
/* send to iPhone */
- bytes = lockdownd_send(control, XML_content, length);
+ bytes = iphone_lckd_send(control, XML_content, length);
xmlFree(XML_content);
xmlFreeDoc(plist); plist = NULL;
/* Now get iPhone's answer */
- bytes = lockdownd_recv(control, &XML_content);
+ bytes = iphone_lckd_recv(control, &XML_content);
plist = xmlReadMemory(XML_content, bytes, NULL, NULL, 0);
if (!plist) return 0;
@@ -407,13 +407,13 @@ int lockdownd_pair_device(iphone_lckd_client_t control, char *uid, char *host_id
printf("XML Pairing request : %s\n",XML_content);
/* send to iPhone */
- bytes = lockdownd_send(control, XML_content, length);
+ bytes = iphone_lckd_send(control, XML_content, length);
xmlFree(XML_content);
xmlFreeDoc(plist); plist = NULL;
/* Now get iPhone's answer */
- bytes = lockdownd_recv(control, &XML_content);
+ bytes = iphone_lckd_recv(control, &XML_content);
if (debug) {
printf("lockdown_pair_device: iPhone's response to our pair request:\n");
@@ -621,13 +621,13 @@ int lockdownd_start_SSL_session(iphone_lckd_client_t control, const char *HostID
}
xmlDocDumpMemory(plist, (xmlChar **)&what2send, &len);
- bytes = lockdownd_send(control, what2send, len);
+ bytes = iphone_lckd_send(control, what2send, len);
xmlFree(what2send);
xmlFreeDoc(plist);
if (bytes > 0) {
- len = lockdownd_recv(control, &what2send);
+ len = iphone_lckd_recv(control, &what2send);
plist = xmlReadMemory(what2send, len, NULL, NULL, 0);
dict = xmlDocGetRootElement(plist);
for (dict = dict->children; dict; dict = dict->next) {
@@ -721,7 +721,7 @@ ssize_t lockdownd_secuwrite(gnutls_transport_ptr_t transport, char *buffer, size
control = (iphone_lckd_client_t)transport;
if (debug) printf("lockdownd_secuwrite() called\n");
if (debug) printf("pre-send\nlength = %zi\n", length);
- bytes = mux_send(control->connection, buffer, length);
+ bytes = iphone_mux_send(control->connection, buffer, length);
if (debug) printf("post-send\nsent %i bytes\n", bytes);
if (debug) {
FILE *my_ssl_packet = fopen("sslpacketwrite.out", "w+");
@@ -779,7 +779,7 @@ ssize_t lockdownd_securead(gnutls_transport_ptr_t transport, char *buffer, size_
char *recv_buffer = (char*)malloc(sizeof(char) * (length * 1000)); // ensuring nothing stupid happens
if (debug) printf("pre-read\nclient wants %zi bytes\n", length);
- bytes = mux_recv(control->connection, recv_buffer, (length * 1000));
+ bytes = iphone_mux_recv(control->connection, recv_buffer, (length * 1000));
if (debug) printf("post-read\nwe got %i bytes\n", bytes);
if (debug && bytes < 0) {
printf("lockdownd_securead(): uh oh\n");
@@ -838,10 +838,10 @@ int iphone_lckd_start_service ( iphone_lckd_client_t client, const char *service
xmlDocDumpMemory(plist, (xmlChar **)&XML_query, &length);
- lockdownd_send(client, XML_query, length);
+ iphone_lckd_send(client, XML_query, length);
free(XML_query);
- length = lockdownd_recv(client, &XML_query);
+ length = iphone_lckd_recv(client, &XML_query);
xmlFreeDoc(plist);
diff --git a/src/usbmux.c b/src/usbmux.c
index 48cb963..5e3f441 100644
--- a/src/usbmux.c
+++ b/src/usbmux.c
@@ -176,7 +176,7 @@ void iphone_mux_free_client ( iphone_umux_client_t client ) {
bytes = usb_bulk_write(client->phone->device, BULKOUT, (char*)client->header, sizeof(usbmux_tcp_header), 800);
if(debug && bytes < 0)
- printf("mux_close_connection(): when writing, libusb gave me the error: %s\n", usb_strerror());
+ printf("iphone_muxèfree_client(): when writing, libusb gave me the error: %s\n", usb_strerror());
bytes = usb_bulk_read(client->phone->device, BULKIN, (char*)client->header, sizeof(usbmux_tcp_header), 800);
if(debug && bytes < 0)
@@ -332,7 +332,7 @@ int iphone_mux_recv ( iphone_umux_client_t client, char *data, uint32_t datalen
// Free our buffer and continue.
free(buffer);
buffer = NULL;
- return mux_recv(client, data, datalen); // recurse back in to try again
+ return iphone_mux_recv(client, data, datalen); // recurse back in to try again
}
// The packet was absolutely meant for us if it hits this point.