From abb74bcae219c25cffb7e30db6a34c69dcd92f0a Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Mon, 6 Jul 2009 19:38:00 +0200 Subject: API cleanup for AFC Signed-off-by: Martin Szulecki --- include/libiphone/afc.h | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 include/libiphone/afc.h (limited to 'include/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 + +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 -- cgit v1.1-32-gdbae From 37f8ad0f3e64c23cd32c8c58636510f7964f1891 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Sun, 19 Jul 2009 20:07:21 +0200 Subject: New type afc_lock_op_t with allowed lock operations for afc_lock_file. Only non-blocking locks are supported via AFC. Signed-off-by: Martin Szulecki --- include/libiphone/afc.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'include/libiphone/afc.h') diff --git a/include/libiphone/afc.h b/include/libiphone/afc.h index 2a0bbad..b64510b 100644 --- a/include/libiphone/afc.h +++ b/include/libiphone/afc.h @@ -21,6 +21,12 @@ typedef enum { AFC_SYMLINK = 2 } afc_link_type_t; +typedef enum { + AFC_LOCK_SH = 1 | 4, // shared lock + AFC_LOCK_EX = 2 | 4, // exclusive lock + AFC_LOCK_UN = 8 | 4 // unlock +} afc_lock_op_t; + struct afc_client_int; typedef struct afc_client_int *afc_client_t; @@ -36,7 +42,7 @@ iphone_error_t afc_get_dir_list ( afc_client_t client, const char *dir, char *** 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_lock_file ( afc_client_t client, uint64_t handle, afc_lock_op_t 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); -- cgit v1.1-32-gdbae From 4c81f3c622d80a9291f3c13de2075afd753a0e1c Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Fri, 24 Jul 2009 14:56:24 +0200 Subject: Add missing copyright to afc and notification_proxy headers --- include/libiphone/afc.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'include/libiphone/afc.h') diff --git a/include/libiphone/afc.h b/include/libiphone/afc.h index b64510b..af801b1 100644 --- a/include/libiphone/afc.h +++ b/include/libiphone/afc.h @@ -1,3 +1,23 @@ +/* + * afc.h + * + * Copyright (c) 2009 Nikias Bassen All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + #ifndef AFC_H #define AFC_H -- cgit v1.1-32-gdbae From 50be30047dbb0d38fd8d61763c13ec75d2b52543 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Sat, 25 Jul 2009 03:26:39 +0200 Subject: Update AFC API and use error codes from the STATUS operation response --- include/libiphone/afc.h | 72 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 20 deletions(-) (limited to 'include/libiphone/afc.h') diff --git a/include/libiphone/afc.h b/include/libiphone/afc.h index af801b1..4b024a1 100644 --- a/include/libiphone/afc.h +++ b/include/libiphone/afc.h @@ -27,6 +27,39 @@ extern "C" { #include +/* Error Codes */ +#define AFC_E_SUCCESS 0 +#define AFC_E_UNKNOWN_ERROR 1 +#define AFC_E_OP_HEADER_INVALID 2 +#define AFC_E_NO_RESOURCES 3 +#define AFC_E_READ_ERROR 4 +#define AFC_E_WRITE_ERROR 5 +#define AFC_E_UNKNOWN_PACKET_TYPE 6 +#define AFC_E_INVALID_ARGUMENT 7 +#define AFC_E_OBJECT_NOT_FOUND 8 +#define AFC_E_OBJECT_IS_DIR 9 +#define AFC_E_PERM_DENIED 10 +#define AFC_E_SERVICE_NOT_CONNECTED 11 +#define AFC_E_OP_TIMEOUT 12 +#define AFC_E_TOO_MUCH_DATA 13 +#define AFC_E_END_OF_DATA 14 +#define AFC_E_OP_NOT_SUPPORTED 15 +#define AFC_E_OBJECT_EXISTS 16 +#define AFC_E_OBJECT_BUSY 17 +#define AFC_E_NO_SPACE_LEFT 18 +#define AFC_E_OP_WOULD_BLOCK 19 +#define AFC_E_IO_ERROR 20 +#define AFC_E_OP_INTERRUPTED 21 +#define AFC_E_OP_IN_PROGRESS 22 +#define AFC_E_INTERNAL_ERROR 23 + +#define AFC_E_MUX_ERROR 30 +#define AFC_E_NO_MEM 31 +#define AFC_E_NOT_ENOUGH_DATA 32 + +typedef int16_t afc_error_t; + +/* Flags */ typedef enum { AFC_FOPEN_RDONLY = 0x00000001, // r O_RDONLY AFC_FOPEN_RW = 0x00000002, // r+ O_RDWR | O_CREAT @@ -50,28 +83,27 @@ typedef enum { 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 ); +/* Interface */ +afc_error_t afc_client_new(iphone_device_t device, int dst_port, afc_client_t *client); +afc_error_t afc_client_free(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, afc_lock_op_t 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); +afc_error_t afc_get_device_info(afc_client_t client, char ***infos); +afc_error_t afc_read_directory(afc_client_t client, const char *dir, char ***list); +afc_error_t afc_get_file_info(afc_client_t client, const char *filename, char ***infolist); +afc_error_t afc_get_connection_info(afc_client_t client, char ***infolist); +afc_error_t afc_file_open(afc_client_t client, const char *filename, afc_file_mode_t file_mode, uint64_t *handle); +afc_error_t afc_file_close(afc_client_t client, uint64_t handle); +afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t operation); +afc_error_t afc_file_read(afc_client_t client, uint64_t handle, char *data, int length, uint32_t *bytes); +afc_error_t afc_file_write(afc_client_t client, uint64_t handle, const char *data, int length, uint32_t *bytes); +afc_error_t afc_file_seek(afc_client_t client, uint64_t handle, int64_t offset, int whence); +afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t newsize); +afc_error_t afc_remove_path(afc_client_t client, const char *path); +afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *to); +afc_error_t afc_make_directory(afc_client_t client, const char *dir); +afc_error_t afc_truncate(afc_client_t client, const char *path, off_t newsize); +afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname); #ifdef __cplusplus } -- cgit v1.1-32-gdbae From 8415e1f13dfc8c31fe4d1ff695af26189297795b Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Sat, 25 Jul 2009 03:46:13 +0200 Subject: Remove AFC to errno conversion and make afc_receive_data() return AFC errors --- include/libiphone/afc.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include/libiphone/afc.h') diff --git a/include/libiphone/afc.h b/include/libiphone/afc.h index 4b024a1..18bf32d 100644 --- a/include/libiphone/afc.h +++ b/include/libiphone/afc.h @@ -86,8 +86,6 @@ typedef struct afc_client_int *afc_client_t; /* Interface */ afc_error_t afc_client_new(iphone_device_t device, int dst_port, afc_client_t *client); afc_error_t afc_client_free(afc_client_t client); -int afc_get_afcerror ( afc_client_t client ); -int afc_get_errno ( afc_client_t client ); afc_error_t afc_get_device_info(afc_client_t client, char ***infos); afc_error_t afc_read_directory(afc_client_t client, const char *dir, char ***list); afc_error_t afc_get_file_info(afc_client_t client, const char *filename, char ***infolist); -- cgit v1.1-32-gdbae From 0e255cfe381caedf0375e6834021333d971f8050 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Sat, 25 Jul 2009 03:46:54 +0200 Subject: Implement afc_file_tell() and adjust afc_receive_data() to handle it --- include/libiphone/afc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/libiphone/afc.h') diff --git a/include/libiphone/afc.h b/include/libiphone/afc.h index 18bf32d..08122a1 100644 --- a/include/libiphone/afc.h +++ b/include/libiphone/afc.h @@ -96,6 +96,7 @@ afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t op afc_error_t afc_file_read(afc_client_t client, uint64_t handle, char *data, int length, uint32_t *bytes); afc_error_t afc_file_write(afc_client_t client, uint64_t handle, const char *data, int length, uint32_t *bytes); afc_error_t afc_file_seek(afc_client_t client, uint64_t handle, int64_t offset, int whence); +afc_error_t afc_file_tell(afc_client_t client, uint64_t handle, uint64_t *position); afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t newsize); afc_error_t afc_remove_path(afc_client_t client, const char *path); afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *to); -- cgit v1.1-32-gdbae From da94f0ebc7232e8e9d0e629fe559b7bc93d9a1c6 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Sat, 25 Jul 2009 18:12:49 +0200 Subject: Update doxygen config and allow generation of documentation --- include/libiphone/afc.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include/libiphone/afc.h') diff --git a/include/libiphone/afc.h b/include/libiphone/afc.h index 08122a1..71730cc 100644 --- a/include/libiphone/afc.h +++ b/include/libiphone/afc.h @@ -1,5 +1,7 @@ -/* - * afc.h +/** + * @file libiphone/afc.h + * @brief AFC Implementation + * \internal * * Copyright (c) 2009 Nikias Bassen All Rights Reserved. * -- cgit v1.1-32-gdbae