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