From 4105af17e9f2df5405afa6a74a02a304ed6bacff Mon Sep 17 00:00:00 2001
From: Nikias Bassen
Date: Mon, 6 Jul 2009 19:38:00 +0200
Subject: API cleanup for AFC

---
 dev/afccheck.c                | 21 ++++++++--------
 dev/main.c                    | 47 ++++++++++++++++++-----------------
 include/Makefile.am           |  2 +-
 include/libiphone/afc.h       | 54 ++++++++++++++++++++++++++++++++++++++++
 include/libiphone/libiphone.h | 40 ------------------------------
 src/AFC.c                     | 57 +++++++++++++++++++++++--------------------
 src/AFC.h                     |  5 +---
 7 files changed, 121 insertions(+), 105 deletions(-)
 create mode 100644 include/libiphone/afc.h

diff --git a/dev/afccheck.c b/dev/afccheck.c
index 965981b..b107437 100644
--- a/dev/afccheck.c
+++ b/dev/afccheck.c
@@ -25,13 +25,14 @@
 #include <glib.h>
 
 #include <libiphone/libiphone.h>
+#include <libiphone/afc.h>
 
 #define BUFFER_SIZE 20000
 #define NB_THREADS 10
 
 
 typedef struct {
-	iphone_afc_client_t afc;
+	afc_client_t afc;
 	int id;
 } param;
 
@@ -53,18 +54,18 @@ void check_afc(gpointer data)
 	uint64_t file = 0;
 	char path[50];
 	sprintf(path, "/Buf%i", ((param *) data)->id);
-	iphone_afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RW, &file);
-	iphone_afc_write_file(((param *) data)->afc, file, (char *) buf, buffersize, &bytes);
-	iphone_afc_close_file(((param *) data)->afc, file);
+	afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RW, &file);
+	afc_write_file(((param *) data)->afc, file, (char *) buf, buffersize, &bytes);
+	afc_close_file(((param *) data)->afc, file);
 	file = 0;
 	if (bytes != buffersize)
 		printf("Write operation failed\n");
 
 	//now read it
 	bytes = 0;
-	iphone_afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RDONLY, &file);
-	iphone_afc_read_file(((param *) data)->afc, file, (char *) buf2, buffersize, &bytes);
-	iphone_afc_close_file(((param *) data)->afc, file);
+	afc_open_file(((param *) data)->afc, path, AFC_FOPEN_RDONLY, &file);
+	afc_read_file(((param *) data)->afc, file, (char *) buf2, buffersize, &bytes);
+	afc_close_file(((param *) data)->afc, file);
 	if (bytes != buffersize)
 		printf("Read operation failed\n");
 
@@ -77,7 +78,7 @@ void check_afc(gpointer data)
 	}
 
 	//cleanup
-	iphone_afc_delete_file(((param *) data)->afc, path);
+	afc_delete_file(((param *) data)->afc, path);
 	g_thread_exit(0);
 }
 
@@ -87,7 +88,7 @@ int main(int argc, char *argv[])
 	iphone_device_t phone = NULL;
 	GError *err;
 	int port = 0;
-	iphone_afc_client_t afc = NULL;
+	afc_client_t afc = NULL;
 
 	if (IPHONE_E_SUCCESS != iphone_get_device(&phone)) {
 		printf("No iPhone found, is it plugged in?\n");
@@ -106,7 +107,7 @@ int main(int argc, char *argv[])
 		return 1;
 	}
 
-	iphone_afc_new_client(phone, port, &afc);
+	afc_new_client(phone, port, &afc);
 
 	//makes sure thread environment is available
 	if (!g_thread_supported())
diff --git a/dev/main.c b/dev/main.c
index c8c9dfa..fe340ff 100644
--- a/dev/main.c
+++ b/dev/main.c
@@ -25,6 +25,7 @@
 #include <usb.h>
 
 #include <libiphone/libiphone.h>
+#include <libiphone/afc.h>
 #include "../src/utils.h"
 
 void notifier(const char *notification)
@@ -97,8 +98,8 @@ int main(int argc, char *argv[])
 	iphone_lckd_start_service(control, "com.apple.afc", &port);
 
 	if (port) {
-		iphone_afc_client_t afc = NULL;
-		iphone_afc_new_client(phone, port, &afc);
+		afc_client_t afc = NULL;
+		afc_new_client(phone, port, &afc);
 		if (afc) {
 			iphone_lckd_start_service(control, "com.apple.mobile.notification_proxy", &npp);
 			if (npp) {
@@ -120,18 +121,18 @@ int main(int argc, char *argv[])
 
 			perform_notification(phone, control, NP_SYNC_WILL_START);
 
-			iphone_afc_open_file(afc, "/com.apple.itunes.lock_sync", AFC_FOPEN_RW, &lockfile);
+			afc_open_file(afc, "/com.apple.itunes.lock_sync", AFC_FOPEN_RW, &lockfile);
 			if (lockfile) {
 				printf("locking file\n");
-				iphone_afc_lock_file(afc, lockfile, 2 | 4);
+				afc_lock_file(afc, lockfile, 2 | 4);
 
 				perform_notification(phone, control, NP_SYNC_DID_START);
 			}
 
 			char **dirs = NULL;
-			iphone_afc_get_dir_list(afc, "/eafaedf", &dirs);
+			afc_get_dir_list(afc, "/eafaedf", &dirs);
 			if (!dirs)
-				iphone_afc_get_dir_list(afc, "/", &dirs);
+				afc_get_dir_list(afc, "/", &dirs);
 			printf("Directory time.\n");
 			for (i = 0; dirs[i]; i++) {
 				printf("/%s\n", dirs[i]);
@@ -140,7 +141,7 @@ int main(int argc, char *argv[])
 			g_strfreev(dirs);
 
 			dirs = NULL;
-			iphone_afc_get_devinfo(afc, &dirs);
+			afc_get_devinfo(afc, &dirs);
 			if (dirs) {
 				for (i = 0; dirs[i]; i += 2) {
 					printf("%s: %s\n", dirs[i], dirs[i + 1]);
@@ -151,7 +152,7 @@ int main(int argc, char *argv[])
 			uint64_t my_file = 0;
 			char **info = NULL;
 			uint64_t fsize = 0;
-			if (IPHONE_E_SUCCESS == iphone_afc_get_file_info(afc, "/readme.libiphone.fx", &info) && info) {
+			if (IPHONE_E_SUCCESS == afc_get_file_info(afc, "/readme.libiphone.fx", &info) && info) {
 				for (i = 0; info[i]; i += 2) {
 					printf("%s: %s\n", info[i], info[i+1]);
 					if (!strcmp(info[i], "st_size")) {
@@ -161,58 +162,58 @@ int main(int argc, char *argv[])
 			}
 
 			if (IPHONE_E_SUCCESS ==
-				iphone_afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file) && my_file) {
+				afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file) && my_file) {
 				printf("A file size: %i\n", fsize);
 				char *file_data = (char *) malloc(sizeof(char) * fsize);
-				iphone_afc_read_file(afc, my_file, file_data, fsize, &bytes);
+				afc_read_file(afc, my_file, file_data, fsize, &bytes);
 				if (bytes >= 0) {
 					printf("The file's data:\n");
 					fwrite(file_data, 1, bytes, stdout);
 				}
 				printf("\nClosing my file.\n");
-				iphone_afc_close_file(afc, my_file);
+				afc_close_file(afc, my_file);
 				free(file_data);
 			} else
 				printf("couldn't open a file\n");
 
-			iphone_afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_WR, &my_file);
+			afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_WR, &my_file);
 			if (my_file) {
 				char *outdatafile = strdup("this is a bitchin text file\n");
-				iphone_afc_write_file(afc, my_file, outdatafile, strlen(outdatafile), &bytes);
+				afc_write_file(afc, my_file, outdatafile, strlen(outdatafile), &bytes);
 				free(outdatafile);
 				if (bytes > 0)
 					printf("Wrote a surprise. ;)\n");
 				else
 					printf("I wanted to write a surprise, but... :(\n");
-				iphone_afc_close_file(afc, my_file);
+				afc_close_file(afc, my_file);
 			}
 			printf("Deleting a file...\n");
-			bytes = iphone_afc_delete_file(afc, "/delme");
+			bytes = afc_delete_file(afc, "/delme");
 			if (bytes)
 				printf("Success.\n");
 			else
 				printf("Failure. (expected unless you have a /delme file on your phone)\n");
 
 			printf("Renaming a file...\n");
-			bytes = iphone_afc_rename_file(afc, "/renme", "/renme2");
+			bytes = afc_rename_file(afc, "/renme", "/renme2");
 			if (bytes > 0)
 				printf("Success.\n");
 			else
 				printf("Failure. (expected unless you have a /renme file on your phone)\n");
 
 			printf("Seek & read\n");
-			iphone_afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file);
-			if (IPHONE_E_SUCCESS != iphone_afc_seek_file(afc, my_file, 5, SEEK_CUR))
+			afc_open_file(afc, "/readme.libiphone.fx", AFC_FOPEN_RDONLY, &my_file);
+			if (IPHONE_E_SUCCESS != afc_seek_file(afc, my_file, 5, SEEK_CUR))
 				printf("WARN: SEEK DID NOT WORK\n");
 			char *threeletterword = (char *) malloc(sizeof(char) * 5);
-			iphone_afc_read_file(afc, my_file, threeletterword, 3, &bytes);
+			afc_read_file(afc, my_file, threeletterword, 3, &bytes);
 			threeletterword[3] = '\0';
 			if (bytes > 0)
 				printf("Result: %s\n", threeletterword);
 			else
 				printf("Couldn't read!\n");
 			free(threeletterword);
-			iphone_afc_close_file(afc, my_file);
+			afc_close_file(afc, my_file);
 		}
 
 		if (gnp && lockfile) {
@@ -245,10 +246,10 @@ int main(int argc, char *argv[])
 			//perform_notification(phone, control, NP_SYNC_DID_FINISH);
 
 			printf("XXX unlocking file\n");
-			iphone_afc_lock_file(afc, lockfile, 8 | 4);
+			afc_lock_file(afc, lockfile, 8 | 4);
 
 			printf("XXX closing file\n");
-			iphone_afc_close_file(afc, lockfile);
+			afc_close_file(afc, lockfile);
 		}
 
 		if (gnp) {
@@ -256,7 +257,7 @@ int main(int argc, char *argv[])
 			gnp = NULL;
 		}
 
-		iphone_afc_free_client(afc);
+		afc_free_client(afc);
 	} else {
 		printf("Start service failure.\n");
 	}
diff --git a/include/Makefile.am b/include/Makefile.am
index a5f8766..4c17261 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -1 +1 @@
-nobase_include_HEADERS = libiphone/libiphone.h
+nobase_include_HEADERS = libiphone/libiphone.h libiphone/afc.h
diff --git a/include/libiphone/afc.h b/include/libiphone/afc.h
new file mode 100644
index 0000000..2a0bbad
--- /dev/null
+++ b/include/libiphone/afc.h
@@ -0,0 +1,54 @@
+#ifndef AFC_H
+#define AFC_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <libiphone/libiphone.h>
+
+typedef enum {
+	AFC_FOPEN_RDONLY   = 0x00000001, // r   O_RDONLY
+	AFC_FOPEN_RW       = 0x00000002, // r+  O_RDWR   | O_CREAT
+	AFC_FOPEN_WRONLY   = 0x00000003, // w   O_WRONLY | O_CREAT  | O_TRUNC
+	AFC_FOPEN_WR       = 0x00000004, // w+  O_RDWR   | O_CREAT  | O_TRUNC
+	AFC_FOPEN_APPEND   = 0x00000005, // a   O_WRONLY | O_APPEND | O_CREAT
+	AFC_FOPEN_RDAPPEND = 0x00000006  // a+  O_RDWR   | O_APPEND | O_CREAT
+} afc_file_mode_t;
+
+typedef enum {
+	AFC_HARDLINK = 1,
+	AFC_SYMLINK = 2
+} afc_link_type_t;
+
+struct afc_client_int;
+typedef struct afc_client_int *afc_client_t;
+
+//afc related functions
+iphone_error_t afc_new_client ( iphone_device_t device, int dst_port, afc_client_t *client );
+iphone_error_t afc_free_client ( afc_client_t client );
+int afc_get_afcerror ( afc_client_t client );
+int afc_get_errno ( afc_client_t client );
+
+iphone_error_t afc_get_devinfo ( afc_client_t client, char ***infos );
+iphone_error_t afc_get_dir_list ( afc_client_t client, const char *dir, char ***list);
+
+iphone_error_t afc_get_file_info ( afc_client_t client, const char *filename, char ***infolist );
+iphone_error_t afc_open_file ( afc_client_t client, const char *filename, afc_file_mode_t file_mode, uint64_t *handle );
+iphone_error_t afc_close_file ( afc_client_t client, uint64_t handle);
+iphone_error_t afc_lock_file ( afc_client_t client, uint64_t handle, int operation);
+iphone_error_t afc_read_file ( afc_client_t client, uint64_t handle, char *data, int length, uint32_t *bytes);
+iphone_error_t afc_write_file ( afc_client_t client, uint64_t handle, const char *data, int length, uint32_t *bytes);
+iphone_error_t afc_seek_file ( afc_client_t client, uint64_t handle, int64_t offset, int whence);
+iphone_error_t afc_truncate_file ( afc_client_t client, uint64_t handle, uint64_t newsize);
+iphone_error_t afc_delete_file ( afc_client_t client, const char *path);
+iphone_error_t afc_rename_file ( afc_client_t client, const char *from, const char *to);
+iphone_error_t afc_mkdir ( afc_client_t client, const char *dir);
+iphone_error_t afc_truncate ( afc_client_t client, const char *path, off_t newsize);
+iphone_error_t afc_make_link ( afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/libiphone/libiphone.h b/include/libiphone/libiphone.h
index 463efa7..3f5d86c 100644
--- a/include/libiphone/libiphone.h
+++ b/include/libiphone/libiphone.h
@@ -54,29 +54,12 @@ extern "C" {
 
 typedef int16_t iphone_error_t;
 
-typedef enum {
-	AFC_FOPEN_RDONLY   = 0x00000001, // r   O_RDONLY
-	AFC_FOPEN_RW       = 0x00000002, // r+  O_RDWR   | O_CREAT
-	AFC_FOPEN_WRONLY   = 0x00000003, // w   O_WRONLY | O_CREAT  | O_TRUNC
-	AFC_FOPEN_WR       = 0x00000004, // w+  O_RDWR   | O_CREAT  | O_TRUNC
-	AFC_FOPEN_APPEND   = 0x00000005, // a   O_WRONLY | O_APPEND | O_CREAT
-	AFC_FOPEN_RDAPPEND = 0x00000006  // a+  O_RDWR   | O_APPEND | O_CREAT
-} iphone_afc_file_mode_t;
-
-typedef enum {
-	IPHONE_AFC_HARDLINK = 1,
-	IPHONE_AFC_SYMLINK = 2
-} iphone_afc_link_type_t;
-
 struct iphone_device_int;
 typedef struct iphone_device_int *iphone_device_t;
 
 struct iphone_lckd_client_int;
 typedef struct iphone_lckd_client_int *iphone_lckd_client_t;
 
-struct iphone_afc_client_int;
-typedef struct iphone_afc_client_int *iphone_afc_client_t;
-
 struct iphone_msync_client_int;
 typedef struct iphone_msync_client_int *iphone_msync_client_t;
 
@@ -111,29 +94,6 @@ iphone_error_t iphone_lckd_recv ( iphone_lckd_client_t client, plist_t* plist);
 iphone_error_t iphone_lckd_send ( iphone_lckd_client_t client, plist_t plist);
 
 
-//afc related functions
-iphone_error_t iphone_afc_new_client ( iphone_device_t device, int dst_port, iphone_afc_client_t *client );
-iphone_error_t iphone_afc_free_client ( iphone_afc_client_t client );
-int iphone_afc_get_afcerror ( iphone_afc_client_t client );
-int iphone_afc_get_errno ( iphone_afc_client_t client );
-
-iphone_error_t iphone_afc_get_devinfo ( iphone_afc_client_t client, char ***infos );
-iphone_error_t iphone_afc_get_dir_list ( iphone_afc_client_t client, const char *dir, char ***list);
-
-iphone_error_t iphone_afc_get_file_info ( iphone_afc_client_t client, const char *filename, char ***infolist );
-iphone_error_t iphone_afc_open_file ( iphone_afc_client_t client, const char *filename, iphone_afc_file_mode_t file_mode, uint64_t *handle );
-iphone_error_t iphone_afc_close_file ( iphone_afc_client_t client, uint64_t handle);
-iphone_error_t iphone_afc_lock_file ( iphone_afc_client_t client, uint64_t handle, int operation);
-iphone_error_t iphone_afc_read_file ( iphone_afc_client_t client, uint64_t handle, char *data, int length, uint32_t *bytes);
-iphone_error_t iphone_afc_write_file ( iphone_afc_client_t client, uint64_t handle, const char *data, int length, uint32_t *bytes);
-iphone_error_t iphone_afc_seek_file ( iphone_afc_client_t client, uint64_t handle, int64_t offset, int whence);
-iphone_error_t iphone_afc_truncate_file ( iphone_afc_client_t client, uint64_t handle, uint64_t newsize);
-iphone_error_t iphone_afc_delete_file ( iphone_afc_client_t client, const char *path);
-iphone_error_t iphone_afc_rename_file ( iphone_afc_client_t client, const char *from, const char *to);
-iphone_error_t iphone_afc_mkdir ( iphone_afc_client_t client, const char *dir);
-iphone_error_t iphone_afc_truncate(iphone_afc_client_t client, const char *path, off_t newsize);
-iphone_error_t iphone_afc_make_link ( iphone_afc_client_t client, iphone_afc_link_type_t linktype, const char *target, const char *linkname);
-
 
 iphone_error_t iphone_msync_new_client(iphone_device_t device, int dst_port,
 									   iphone_msync_client_t * client);
diff --git a/src/AFC.c b/src/AFC.c
index 960d640..e666c45 100644
--- a/src/AFC.c
+++ b/src/AFC.c
@@ -24,8 +24,11 @@
 #include <errno.h>
 #include <unistd.h>
 #include "AFC.h"
+#include "iphone.h"
 #include "utils.h"
 
+#include <libiphone/afc.h>
+
 
 // This is the maximum size an AFC data packet can be
 const int MAXIMUM_PACKET_SIZE = (2 << 15);
@@ -34,7 +37,7 @@ const int MAXIMUM_PACKET_SIZE = (2 << 15);
  * 
  * @param client The AFC client connection to lock
  */
-static void afc_lock(iphone_afc_client_t client)
+static void afc_lock(afc_client_t client)
 {
 	log_debug_msg("Locked\n");
 	/*while (client->lock) {
@@ -48,7 +51,7 @@ static void afc_lock(iphone_afc_client_t client)
  * 
  * @param client The AFC 
  */
-static void afc_unlock(iphone_afc_client_t client)
+static void afc_unlock(afc_client_t client)
 {								// just to be pretty 
 	log_debug_msg("Unlocked\n");
 	//client->lock = 0;
@@ -63,7 +66,7 @@ static void afc_unlock(iphone_afc_client_t client)
  * 
  * @return A handle to the newly-connected client or NULL upon error.
  */
-iphone_error_t iphone_afc_new_client(iphone_device_t device, int dst_port, iphone_afc_client_t * client)
+iphone_error_t afc_new_client(iphone_device_t device, int dst_port, afc_client_t * client)
 {
 	//makes sure thread environment is available
 	if (!g_thread_supported())
@@ -78,7 +81,7 @@ iphone_error_t iphone_afc_new_client(iphone_device_t device, int dst_port, iphon
 		return IPHONE_E_UNKNOWN_ERROR; // ret;
 	}
 
-	iphone_afc_client_t client_loc = (iphone_afc_client_t) malloc(sizeof(struct iphone_afc_client_int));
+	afc_client_t client_loc = (afc_client_t) malloc(sizeof(struct afc_client_int));
 	client_loc->sfd = sfd;
 
 	// Allocate a packet
@@ -105,7 +108,7 @@ iphone_error_t iphone_afc_new_client(iphone_device_t device, int dst_port, iphon
  * 
  * @param client The client to disconnect.
  */
-iphone_error_t iphone_afc_free_client(iphone_afc_client_t client)
+iphone_error_t afc_free_client(afc_client_t client)
 {
 	if (!client || client->sfd < 0 || !client->afc_packet)
 		return IPHONE_E_INVALID_ARG;
@@ -127,7 +130,7 @@ iphone_error_t iphone_afc_free_client(iphone_afc_client_t client)
  *
  * @return AFC error code or -1 on error.
  */
-int iphone_afc_get_afcerror(iphone_afc_client_t client)
+int afc_get_afcerror(afc_client_t client)
 {
 	int res = -1;
 	if (client) {
@@ -140,13 +143,13 @@ int iphone_afc_get_afcerror(iphone_afc_client_t client)
 
 /** 
  * Tries to convert the AFC error value into a meaningful errno value.
- * Internally used by iphone_afc_get_errno.
+ * Internally used by afc_get_errno.
  *
  * @param afcerror AFC error value to convert
  *
  * @return errno value or -1 if the errno could not be determined.
  *
- * @see iphone_afc_get_errno
+ * @see afc_get_errno
  */
 static int afcerror_to_errno(int afcerror)
 {
@@ -189,7 +192,7 @@ static int afcerror_to_errno(int afcerror)
  *
  * @return errno value or -1 on error.
  */
-int iphone_afc_get_errno(iphone_afc_client_t client)
+int afc_get_errno(afc_client_t client)
 {
 	int res = -1;
 	if (client) {
@@ -213,7 +216,7 @@ int iphone_afc_get_errno(iphone_afc_client_t client)
  *          reason is that if you set them to different values, it indicates
  *          you want to send the data as two packets.
  */
-static int dispatch_AFC_packet(iphone_afc_client_t client, const char *data, uint64_t length)
+static int dispatch_AFC_packet(afc_client_t client, const char *data, uint64_t length)
 {
 	int bytes = 0, offset = 0;
 	char *buffer;
@@ -294,7 +297,7 @@ static int dispatch_AFC_packet(iphone_afc_client_t client, const char *data, uin
  *         received raised a non-trivial error condition (i.e. non-zero with
  *         AFC_ERROR operation)
  */
-static int receive_AFC_data(iphone_afc_client_t client, char **dump_here)
+static int receive_AFC_data(afc_client_t client, char **dump_here)
 {
 	AFCPacket header;
 	int bytes = 0;
@@ -468,7 +471,7 @@ static char **make_strings_list(char *tokens, int true_length)
  * @return A char ** list of files in that directory, terminated by an empty
  *         string for now or NULL if there was an error.
  */
-iphone_error_t iphone_afc_get_dir_list(iphone_afc_client_t client, const char *dir, char ***list)
+iphone_error_t afc_get_dir_list(afc_client_t client, const char *dir, char ***list)
 {
 	int bytes = 0;
 	char *data = NULL, **list_loc = NULL;
@@ -514,7 +517,7 @@ iphone_error_t iphone_afc_get_dir_list(iphone_afc_client_t client, const char *d
  * @return A char ** list of parameters as given by AFC or NULL if there was an
  *         error.
  */
-iphone_error_t iphone_afc_get_devinfo(iphone_afc_client_t client, char ***infos)
+iphone_error_t afc_get_devinfo(afc_client_t client, char ***infos)
 {
 	int bytes = 0;
 	char *data = NULL, **list = NULL;
@@ -556,7 +559,7 @@ iphone_error_t iphone_afc_get_devinfo(iphone_afc_client_t client, char ***infos)
  * @return IPHONE_E_SUCCESS if everythong went well, IPHONE_E_INVALID_ARG
  *         if arguments are NULL or invalid, IPHONE_E_NOT_ENOUGH_DATA otherwise.
  */
-iphone_error_t iphone_afc_delete_file(iphone_afc_client_t client, const char *path)
+iphone_error_t afc_delete_file(afc_client_t client, const char *path)
 {
 	char *response = NULL;
 	int bytes;
@@ -596,7 +599,7 @@ iphone_error_t iphone_afc_delete_file(iphone_afc_client_t client, const char *pa
  * @return IPHONE_E_SUCCESS if everythong went well, IPHONE_E_INVALID_ARG
  *         if arguments are NULL or invalid, IPHONE_E_NOT_ENOUGH_DATA otherwise.
  */
-iphone_error_t iphone_afc_rename_file(iphone_afc_client_t client, const char *from, const char *to)
+iphone_error_t afc_rename_file(afc_client_t client, const char *from, const char *to)
 {
 	char *response = NULL;
 	char *send = (char *) malloc(sizeof(char) * (strlen(from) + strlen(to) + 1 + sizeof(uint32_t)));
@@ -640,7 +643,7 @@ iphone_error_t iphone_afc_rename_file(iphone_afc_client_t client, const char *fr
  * @return IPHONE_E_SUCCESS if everythong went well, IPHONE_E_INVALID_ARG
  *         if arguments are NULL or invalid, IPHONE_E_NOT_ENOUGH_DATA otherwise.
  */
-iphone_error_t iphone_afc_mkdir(iphone_afc_client_t client, const char *dir)
+iphone_error_t afc_mkdir(afc_client_t client, const char *dir)
 {
 	int bytes = 0;
 	char *response = NULL;
@@ -682,7 +685,7 @@ iphone_error_t iphone_afc_mkdir(iphone_afc_client_t client, const char *dir)
  * @return IPHONE_E_SUCCESS on success or an IPHONE_E_* error value
  *         when something went wrong.
  */
-iphone_error_t iphone_afc_get_file_info(iphone_afc_client_t client, const char *path, char ***infolist)
+iphone_error_t afc_get_file_info(afc_client_t client, const char *path, char ***infolist)
 {
 	char *received = NULL;
 	int length;
@@ -726,8 +729,8 @@ iphone_error_t iphone_afc_get_file_info(iphone_afc_client_t client, const char *
  * @return IPHONE_E_SUCCESS on success or an IPHONE_E_* error on failure.
  */
 iphone_error_t
-iphone_afc_open_file(iphone_afc_client_t client, const char *filename,
-					 iphone_afc_file_mode_t file_mode, uint64_t *handle)
+afc_open_file(afc_client_t client, const char *filename,
+					 afc_file_mode_t file_mode, uint64_t *handle)
 {
 	uint32_t ag = 0;
 	int bytes = 0, length = 0;
@@ -786,7 +789,7 @@ iphone_afc_open_file(iphone_afc_client_t client, const char *filename,
  * @return The number of bytes read if successful. If there was an error -1.
  */
 iphone_error_t
-iphone_afc_read_file(iphone_afc_client_t client, uint64_t handle, char *data, int length, uint32_t * bytes)
+afc_read_file(afc_client_t client, uint64_t handle, char *data, int length, uint32_t * bytes)
 {
 	char *input = NULL;
 	int current_count = 0, bytes_loc = 0;
@@ -857,7 +860,7 @@ iphone_afc_read_file(iphone_afc_client_t client, uint64_t handle, char *data, in
  *         none were written...
  */
 iphone_error_t
-iphone_afc_write_file(iphone_afc_client_t client, uint64_t handle,
+afc_write_file(afc_client_t client, uint64_t handle,
 					  const char *data, int length, uint32_t * bytes)
 {
 	char *acknowledgement = NULL;
@@ -946,7 +949,7 @@ iphone_afc_write_file(iphone_afc_client_t client, uint64_t handle,
  * @param client The client to close the file with.
  * @param handle File handle of a previously opened file.
  */
-iphone_error_t iphone_afc_close_file(iphone_afc_client_t client, uint64_t handle)
+iphone_error_t afc_close_file(afc_client_t client, uint64_t handle)
 {
 	if (!client || (handle == 0))
 		return IPHONE_E_INVALID_ARG;
@@ -997,7 +1000,7 @@ iphone_error_t iphone_afc_close_file(iphone_afc_client_t client, uint64_t handle
  * @param handle File handle of a previously opened file.
  * @operation the lock or unlock operation to perform.
  */
-iphone_error_t iphone_afc_lock_file(iphone_afc_client_t client, uint64_t handle, int operation)
+iphone_error_t afc_lock_file(afc_client_t client, uint64_t handle, int operation)
 {
 	if (!client || (handle == 0))
 		return IPHONE_E_INVALID_ARG;
@@ -1046,7 +1049,7 @@ iphone_error_t iphone_afc_lock_file(iphone_afc_client_t client, uint64_t handle,
  * 
  * @return IPHONE_E_SUCCESS on success, IPHONE_E_NOT_ENOUGH_DATA on failure.
  */
-iphone_error_t iphone_afc_seek_file(iphone_afc_client_t client, uint64_t handle, int64_t offset, int whence)
+iphone_error_t afc_seek_file(afc_client_t client, uint64_t handle, int64_t offset, int whence)
 {
 	char *buffer = (char *) malloc(sizeof(char) * 24);
 	uint32_t zero = 0;
@@ -1093,7 +1096,7 @@ iphone_error_t iphone_afc_seek_file(iphone_afc_client_t client, uint64_t handle,
  * @note This function is more akin to ftruncate than truncate, and truncate
  *       calls would have to open the file before calling this, sadly.
  */
-iphone_error_t iphone_afc_truncate_file(iphone_afc_client_t client, uint64_t handle, uint64_t newsize)
+iphone_error_t afc_truncate_file(afc_client_t client, uint64_t handle, uint64_t newsize)
 {
 	char *buffer = (char *) malloc(sizeof(char) * 16);
 	int bytes = 0;
@@ -1135,7 +1138,7 @@ iphone_error_t iphone_afc_truncate_file(iphone_afc_client_t client, uint64_t han
  * @return IPHONE_E_SUCCESS if everything went well, IPHONE_E_INVALID_ARG
  *         if arguments are NULL or invalid, IPHONE_E_NOT_ENOUGH_DATA otherwise.
  */
-iphone_error_t iphone_afc_truncate(iphone_afc_client_t client, const char *path, off_t newsize)
+iphone_error_t afc_truncate(afc_client_t client, const char *path, off_t newsize)
 {
 	char *response = NULL;
 	char *send = (char *) malloc(sizeof(char) * (strlen(path) + 1 + 8));
@@ -1181,7 +1184,7 @@ iphone_error_t iphone_afc_truncate(iphone_afc_client_t client, const char *path,
  * @return IPHONE_E_SUCCESS if everything went well, IPHONE_E_INVALID_ARG
  *         if arguments are NULL or invalid, IPHONE_E_NOT_ENOUGH_DATA otherwise.
  */
-iphone_error_t iphone_afc_make_link(iphone_afc_client_t client, iphone_afc_link_type_t linktype, const char *target, const char *linkname)
+iphone_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname)
 {
 	char *response = NULL;
 	char *send = (char *) malloc(sizeof(char) * (strlen(target)+1 + strlen(linkname)+1 + 8));
diff --git a/src/AFC.h b/src/AFC.h
index a9c33c3..5d337e5 100644
--- a/src/AFC.h
+++ b/src/AFC.h
@@ -19,9 +19,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA 
  */
 
-#include "libiphone/libiphone.h"
-#include "iphone.h"
-
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -46,7 +43,7 @@ typedef struct __AFCToken {
 	char *token;
 } AFCToken;
 
-struct iphone_afc_client_int {
+struct afc_client_int {
 	int sfd;
 	AFCPacket *afc_packet;
 	int file_handle;
-- 
cgit v1.1-32-gdbae