diff options
Diffstat (limited to 'src/afc.h')
| -rw-r--r-- | src/afc.h | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/src/afc.h b/src/afc.h new file mode 100644 index 0000000..f8a5da3 --- /dev/null +++ b/src/afc.h | |||
| @@ -0,0 +1,100 @@ | |||
| 1 | /* | ||
| 2 | * afc.h | ||
| 3 | * Defines and structs and the like for the built-in AFC client | ||
| 4 | * | ||
| 5 | * Copyright (c) 2008 Zach C. All Rights Reserved. | ||
| 6 | * | ||
| 7 | * This library is free software; you can redistribute it and/or | ||
| 8 | * modify it under the terms of the GNU Lesser General Public | ||
| 9 | * License as published by the Free Software Foundation; either | ||
| 10 | * version 2.1 of the License, or (at your option) any later version. | ||
| 11 | * | ||
| 12 | * This library is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 15 | * Lesser General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU Lesser General Public | ||
| 18 | * License along with this library; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include <string.h> | ||
| 23 | #include <stdio.h> | ||
| 24 | #include <stdlib.h> | ||
| 25 | #include <sys/stat.h> | ||
| 26 | #include <glib.h> | ||
| 27 | #include <stdint.h> | ||
| 28 | |||
| 29 | #include "libiphone/afc.h" | ||
| 30 | |||
| 31 | #define AFC_MAGIC "CFA6LPAA" | ||
| 32 | #define AFC_MAGIC_LEN (8) | ||
| 33 | |||
| 34 | typedef struct { | ||
| 35 | char magic[AFC_MAGIC_LEN]; | ||
| 36 | uint64_t entire_length, this_length, packet_num, operation; | ||
| 37 | } AFCPacket; | ||
| 38 | |||
| 39 | #define AFCPacket_to_LE(x) \ | ||
| 40 | (x)->entire_length = GUINT64_TO_LE((x)->entire_length); \ | ||
| 41 | (x)->this_length = GUINT64_TO_LE((x)->this_length); \ | ||
| 42 | (x)->packet_num = GUINT64_TO_LE((x)->packet_num); \ | ||
| 43 | (x)->operation = GUINT64_TO_LE((x)->operation); | ||
| 44 | |||
| 45 | #define AFCPacket_from_LE(x) \ | ||
| 46 | (x)->entire_length = GUINT64_FROM_LE((x)->entire_length); \ | ||
| 47 | (x)->this_length = GUINT64_FROM_LE((x)->this_length); \ | ||
| 48 | (x)->packet_num = GUINT64_FROM_LE((x)->packet_num); \ | ||
| 49 | (x)->operation = GUINT64_FROM_LE((x)->operation); | ||
| 50 | |||
| 51 | typedef struct { | ||
| 52 | uint64_t filehandle, size; | ||
| 53 | } AFCFilePacket; | ||
| 54 | |||
| 55 | typedef struct __AFCToken { | ||
| 56 | struct __AFCToken *last, *next; | ||
| 57 | char *token; | ||
| 58 | } AFCToken; | ||
| 59 | |||
| 60 | struct afc_client_int { | ||
| 61 | iphone_connection_t connection; | ||
| 62 | AFCPacket *afc_packet; | ||
| 63 | int file_handle; | ||
| 64 | int lock; | ||
| 65 | GMutex *mutex; | ||
| 66 | }; | ||
| 67 | |||
| 68 | /* AFC Operations */ | ||
| 69 | enum { | ||
| 70 | AFC_OP_STATUS = 0x00000001, // Status | ||
| 71 | AFC_OP_DATA = 0x00000002, // Data | ||
| 72 | AFC_OP_READ_DIR = 0x00000003, // ReadDir | ||
| 73 | AFC_OP_READ_FILE = 0x00000004, // ReadFile | ||
| 74 | AFC_OP_WRITE_FILE = 0x00000005, // WriteFile | ||
| 75 | AFC_OP_WRITE_PART = 0x00000006, // WritePart | ||
| 76 | AFC_OP_TRUNCATE = 0x00000007, // TruncateFile | ||
| 77 | AFC_OP_REMOVE_PATH = 0x00000008, // RemovePath | ||
| 78 | AFC_OP_MAKE_DIR = 0x00000009, // MakeDir | ||
| 79 | AFC_OP_GET_FILE_INFO = 0x0000000a, // GetFileInfo | ||
| 80 | AFC_OP_GET_DEVINFO = 0x0000000b, // GetDeviceInfo | ||
| 81 | AFC_OP_WRITE_FILE_ATOM = 0x0000000c, // WriteFileAtomic (tmp file+rename) | ||
| 82 | AFC_OP_FILE_OPEN = 0x0000000d, // FileRefOpen | ||
| 83 | AFC_OP_FILE_OPEN_RES = 0x0000000e, // FileRefOpenResult | ||
| 84 | AFC_OP_READ = 0x0000000f, // FileRefRead | ||
| 85 | AFC_OP_WRITE = 0x00000010, // FileRefWrite | ||
| 86 | AFC_OP_FILE_SEEK = 0x00000011, // FileRefSeek | ||
| 87 | AFC_OP_FILE_TELL = 0x00000012, // FileRefTell | ||
| 88 | AFC_OP_FILE_TELL_RES = 0x00000013, // FileRefTellResult | ||
| 89 | AFC_OP_FILE_CLOSE = 0x00000014, // FileRefClose | ||
| 90 | AFC_OP_FILE_SET_SIZE = 0x00000015, // FileRefSetFileSize (ftruncate) | ||
| 91 | AFC_OP_GET_CON_INFO = 0x00000016, // GetConnectionInfo | ||
| 92 | AFC_OP_SET_CON_OPTIONS = 0x00000017, // SetConnectionOptions | ||
| 93 | AFC_OP_RENAME_PATH = 0x00000018, // RenamePath | ||
| 94 | AFC_OP_SET_FS_BS = 0x00000019, // SetFSBlockSize (0x800000) | ||
| 95 | AFC_OP_SET_SOCKET_BS = 0x0000001A, // SetSocketBlockSize (0x800000) | ||
| 96 | AFC_OP_FILE_LOCK = 0x0000001B, // FileRefLock | ||
| 97 | AFC_OP_MAKE_LINK = 0x0000001C, // MakeLink | ||
| 98 | AFC_OP_SET_FILE_TIME = 0x0000001E // set st_mtime | ||
| 99 | }; | ||
| 100 | |||
