diff options
Diffstat (limited to 'include/libiphone/afc.h')
| -rw-r--r-- | include/libiphone/afc.h | 103 |
1 files changed, 81 insertions, 22 deletions
diff --git a/include/libiphone/afc.h b/include/libiphone/afc.h index 2a0bbad..71730cc 100644 --- a/include/libiphone/afc.h +++ b/include/libiphone/afc.h | |||
| @@ -1,3 +1,25 @@ | |||
| 1 | /** | ||
| 2 | * @file libiphone/afc.h | ||
| 3 | * @brief AFC Implementation | ||
| 4 | * \internal | ||
| 5 | * | ||
| 6 | * Copyright (c) 2009 Nikias Bassen All Rights Reserved. | ||
| 7 | * | ||
| 8 | * This library is free software; you can redistribute it and/or | ||
| 9 | * modify it under the terms of the GNU Lesser General Public | ||
| 10 | * License as published by the Free Software Foundation; either | ||
| 11 | * version 2.1 of the License, or (at your option) any later version. | ||
| 12 | * | ||
| 13 | * This library is distributed in the hope that it will be useful, | ||
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 16 | * Lesser General Public License for more details. | ||
| 17 | * | ||
| 18 | * You should have received a copy of the GNU Lesser General Public | ||
| 19 | * License along with this library; if not, write to the Free Software | ||
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 21 | */ | ||
| 22 | |||
| 1 | #ifndef AFC_H | 23 | #ifndef AFC_H |
| 2 | #define AFC_H | 24 | #define AFC_H |
| 3 | 25 | ||
| @@ -7,6 +29,39 @@ extern "C" { | |||
| 7 | 29 | ||
| 8 | #include <libiphone/libiphone.h> | 30 | #include <libiphone/libiphone.h> |
| 9 | 31 | ||
| 32 | /* Error Codes */ | ||
| 33 | #define AFC_E_SUCCESS 0 | ||
| 34 | #define AFC_E_UNKNOWN_ERROR 1 | ||
| 35 | #define AFC_E_OP_HEADER_INVALID 2 | ||
| 36 | #define AFC_E_NO_RESOURCES 3 | ||
| 37 | #define AFC_E_READ_ERROR 4 | ||
| 38 | #define AFC_E_WRITE_ERROR 5 | ||
| 39 | #define AFC_E_UNKNOWN_PACKET_TYPE 6 | ||
| 40 | #define AFC_E_INVALID_ARGUMENT 7 | ||
| 41 | #define AFC_E_OBJECT_NOT_FOUND 8 | ||
| 42 | #define AFC_E_OBJECT_IS_DIR 9 | ||
| 43 | #define AFC_E_PERM_DENIED 10 | ||
| 44 | #define AFC_E_SERVICE_NOT_CONNECTED 11 | ||
| 45 | #define AFC_E_OP_TIMEOUT 12 | ||
| 46 | #define AFC_E_TOO_MUCH_DATA 13 | ||
| 47 | #define AFC_E_END_OF_DATA 14 | ||
| 48 | #define AFC_E_OP_NOT_SUPPORTED 15 | ||
| 49 | #define AFC_E_OBJECT_EXISTS 16 | ||
| 50 | #define AFC_E_OBJECT_BUSY 17 | ||
| 51 | #define AFC_E_NO_SPACE_LEFT 18 | ||
| 52 | #define AFC_E_OP_WOULD_BLOCK 19 | ||
| 53 | #define AFC_E_IO_ERROR 20 | ||
| 54 | #define AFC_E_OP_INTERRUPTED 21 | ||
| 55 | #define AFC_E_OP_IN_PROGRESS 22 | ||
| 56 | #define AFC_E_INTERNAL_ERROR 23 | ||
| 57 | |||
| 58 | #define AFC_E_MUX_ERROR 30 | ||
| 59 | #define AFC_E_NO_MEM 31 | ||
| 60 | #define AFC_E_NOT_ENOUGH_DATA 32 | ||
| 61 | |||
| 62 | typedef int16_t afc_error_t; | ||
| 63 | |||
| 64 | /* Flags */ | ||
| 10 | typedef enum { | 65 | typedef enum { |
| 11 | AFC_FOPEN_RDONLY = 0x00000001, // r O_RDONLY | 66 | AFC_FOPEN_RDONLY = 0x00000001, // r O_RDONLY |
| 12 | AFC_FOPEN_RW = 0x00000002, // r+ O_RDWR | O_CREAT | 67 | AFC_FOPEN_RW = 0x00000002, // r+ O_RDWR | O_CREAT |
| @@ -21,31 +76,35 @@ typedef enum { | |||
| 21 | AFC_SYMLINK = 2 | 76 | AFC_SYMLINK = 2 |
| 22 | } afc_link_type_t; | 77 | } afc_link_type_t; |
| 23 | 78 | ||
| 79 | typedef enum { | ||
| 80 | AFC_LOCK_SH = 1 | 4, // shared lock | ||
| 81 | AFC_LOCK_EX = 2 | 4, // exclusive lock | ||
| 82 | AFC_LOCK_UN = 8 | 4 // unlock | ||
| 83 | } afc_lock_op_t; | ||
| 84 | |||
| 24 | struct afc_client_int; | 85 | struct afc_client_int; |
| 25 | typedef struct afc_client_int *afc_client_t; | 86 | typedef struct afc_client_int *afc_client_t; |
| 26 | 87 | ||
| 27 | //afc related functions | 88 | /* Interface */ |
| 28 | iphone_error_t afc_new_client ( iphone_device_t device, int dst_port, afc_client_t *client ); | 89 | afc_error_t afc_client_new(iphone_device_t device, int dst_port, afc_client_t *client); |
| 29 | iphone_error_t afc_free_client ( afc_client_t client ); | 90 | afc_error_t afc_client_free(afc_client_t client); |
| 30 | int afc_get_afcerror ( afc_client_t client ); | 91 | afc_error_t afc_get_device_info(afc_client_t client, char ***infos); |
| 31 | int afc_get_errno ( afc_client_t client ); | 92 | afc_error_t afc_read_directory(afc_client_t client, const char *dir, char ***list); |
| 32 | 93 | afc_error_t afc_get_file_info(afc_client_t client, const char *filename, char ***infolist); | |
| 33 | iphone_error_t afc_get_devinfo ( afc_client_t client, char ***infos ); | 94 | afc_error_t afc_get_connection_info(afc_client_t client, char ***infolist); |
| 34 | iphone_error_t afc_get_dir_list ( afc_client_t client, const char *dir, char ***list); | 95 | afc_error_t afc_file_open(afc_client_t client, const char *filename, afc_file_mode_t file_mode, uint64_t *handle); |
| 35 | 96 | afc_error_t afc_file_close(afc_client_t client, uint64_t handle); | |
| 36 | iphone_error_t afc_get_file_info ( afc_client_t client, const char *filename, char ***infolist ); | 97 | afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t operation); |
| 37 | iphone_error_t afc_open_file ( afc_client_t client, const char *filename, afc_file_mode_t file_mode, uint64_t *handle ); | 98 | afc_error_t afc_file_read(afc_client_t client, uint64_t handle, char *data, int length, uint32_t *bytes); |
| 38 | iphone_error_t afc_close_file ( afc_client_t client, uint64_t handle); | 99 | afc_error_t afc_file_write(afc_client_t client, uint64_t handle, const char *data, int length, uint32_t *bytes); |
| 39 | iphone_error_t afc_lock_file ( afc_client_t client, uint64_t handle, int operation); | 100 | afc_error_t afc_file_seek(afc_client_t client, uint64_t handle, int64_t offset, int whence); |
| 40 | iphone_error_t afc_read_file ( afc_client_t client, uint64_t handle, char *data, int length, uint32_t *bytes); | 101 | afc_error_t afc_file_tell(afc_client_t client, uint64_t handle, uint64_t *position); |
| 41 | iphone_error_t afc_write_file ( afc_client_t client, uint64_t handle, const char *data, int length, uint32_t *bytes); | 102 | afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t newsize); |
| 42 | iphone_error_t afc_seek_file ( afc_client_t client, uint64_t handle, int64_t offset, int whence); | 103 | afc_error_t afc_remove_path(afc_client_t client, const char *path); |
| 43 | iphone_error_t afc_truncate_file ( afc_client_t client, uint64_t handle, uint64_t newsize); | 104 | afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *to); |
| 44 | iphone_error_t afc_delete_file ( afc_client_t client, const char *path); | 105 | afc_error_t afc_make_directory(afc_client_t client, const char *dir); |
| 45 | iphone_error_t afc_rename_file ( afc_client_t client, const char *from, const char *to); | 106 | afc_error_t afc_truncate(afc_client_t client, const char *path, off_t newsize); |
| 46 | iphone_error_t afc_mkdir ( afc_client_t client, const char *dir); | 107 | afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname); |
| 47 | iphone_error_t afc_truncate ( afc_client_t client, const char *path, off_t newsize); | ||
| 48 | iphone_error_t afc_make_link ( afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname); | ||
| 49 | 108 | ||
| 50 | #ifdef __cplusplus | 109 | #ifdef __cplusplus |
| 51 | } | 110 | } |
