[657] | 1 | #ifndef _ZZIP_MMAPPED_H_ |
---|
| 2 | #define _ZZIP_MMAPPED_H_ |
---|
| 3 | /* |
---|
| 4 | * simplified zip disk access using a mmapping of the whole archive. |
---|
| 5 | * |
---|
| 6 | * Author: |
---|
| 7 | * Guido Draheim <guidod@gmx.de> |
---|
| 8 | * |
---|
| 9 | * Copyright (c) 2003,2004 Guido Draheim |
---|
| 10 | * All rights reserved, |
---|
| 11 | * use under the restrictions of the |
---|
| 12 | * Lesser GNU General Public License |
---|
| 13 | * or alternatively the restrictions |
---|
| 14 | * of the Mozilla Public License 1.1 |
---|
| 15 | */ |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | #include <zzip/types.h> |
---|
| 19 | |
---|
| 20 | typedef struct zzip_disk_file ZZIP_DISK_FILE; |
---|
| 21 | typedef struct zzip_disk ZZIP_DISK; |
---|
| 22 | typedef struct zzip_disk_entry ZZIP_DISK_ENTRY; |
---|
| 23 | |
---|
| 24 | /* we expose this structure so third party applications can augment |
---|
| 25 | * on them. The mmapped zip access usually just needs the two pointers |
---|
| 26 | * specifying the mmapped area, whereever you have that from. |
---|
| 27 | */ |
---|
| 28 | struct zzip_disk |
---|
| 29 | { |
---|
| 30 | char* buffer; /* start of mmapped area, the base of all seekvals */ |
---|
| 31 | char* endbuf; /* end of mmapped area, i.e. buffer + buflen */ |
---|
| 32 | char* reserved; /* - for later extensions (might be renamed) */ |
---|
| 33 | char* user; /* - free for applications (use this!) */ |
---|
| 34 | long flags; /* bit 0: findfile searches case-insensitive */ |
---|
| 35 | long mapped; /* used for mmap() wrappers of zzip/__mmap.h */ |
---|
| 36 | long unused; /* - for later extensions (might be renamed) */ |
---|
| 37 | long code; /* - free for applications (use this!) */ |
---|
| 38 | }; |
---|
| 39 | |
---|
| 40 | typedef int (*zzip_strcmp_fn_t)(char*, char*); |
---|
| 41 | typedef int (*zzip_fnmatch_fn_t)(char*, char*, int); |
---|
| 42 | |
---|
| 43 | #define zzip_disk_extern extern |
---|
| 44 | |
---|
| 45 | zzip_disk_extern int |
---|
| 46 | zzip_disk_init(ZZIP_DISK* disk, char* buffer, zzip_size_t buflen); |
---|
| 47 | |
---|
| 48 | zzip_disk_extern ZZIP_DISK* _zzip_restrict |
---|
| 49 | zzip_disk_new(void); |
---|
| 50 | |
---|
| 51 | zzip_disk_extern ZZIP_DISK* _zzip_restrict |
---|
| 52 | zzip_disk_mmap(int fd); |
---|
| 53 | |
---|
| 54 | zzip_disk_extern int |
---|
| 55 | zzip_disk_munmap(ZZIP_DISK* disk); |
---|
| 56 | |
---|
| 57 | zzip_disk_extern ZZIP_DISK* _zzip_restrict |
---|
| 58 | zzip_disk_open(char* filename); |
---|
| 59 | |
---|
| 60 | zzip_disk_extern int |
---|
| 61 | zzip_disk_close(ZZIP_DISK* disk); |
---|
| 62 | |
---|
| 63 | |
---|
| 64 | zzip_disk_extern int |
---|
| 65 | zzip_disk_init (ZZIP_DISK* disk, char* buffer, _zzip_size_t buflen); |
---|
| 66 | |
---|
| 67 | zzip_disk_extern ZZIP_DISK_ENTRY* |
---|
| 68 | zzip_disk_findfirst(ZZIP_DISK* disk); |
---|
| 69 | |
---|
| 70 | zzip_disk_extern ZZIP_DISK_ENTRY* |
---|
| 71 | zzip_disk_findnext(ZZIP_DISK* disk, ZZIP_DISK_ENTRY* entry); |
---|
| 72 | |
---|
| 73 | char* _zzip_restrict |
---|
| 74 | zzip_disk_entry_strdup_name(ZZIP_DISK* disk, ZZIP_DISK_ENTRY* entry); |
---|
| 75 | struct zzip_file_header* |
---|
| 76 | zzip_disk_entry_to_file_header(ZZIP_DISK* disk, ZZIP_DISK_ENTRY* entry); |
---|
| 77 | char* |
---|
| 78 | zzip_disk_entry_to_data(ZZIP_DISK* disk, ZZIP_DISK_ENTRY* entry); |
---|
| 79 | |
---|
| 80 | zzip_disk_extern ZZIP_DISK_ENTRY* |
---|
| 81 | zzip_disk_findfile(ZZIP_DISK* disk, |
---|
| 82 | char* filename, ZZIP_DISK_ENTRY* after, |
---|
| 83 | zzip_strcmp_fn_t compare); |
---|
| 84 | zzip_disk_extern ZZIP_DISK_ENTRY* |
---|
| 85 | zzip_disk_findmatch(ZZIP_DISK* disk, |
---|
| 86 | char* filespec, ZZIP_DISK_ENTRY* after, |
---|
| 87 | zzip_fnmatch_fn_t compare, int flags); |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | zzip_disk_extern ZZIP_DISK_FILE* _zzip_restrict |
---|
| 91 | zzip_disk_entry_fopen (ZZIP_DISK* disk, ZZIP_DISK_ENTRY* entry); |
---|
| 92 | |
---|
| 93 | zzip_disk_extern ZZIP_DISK_FILE* _zzip_restrict |
---|
| 94 | zzip_disk_fopen (ZZIP_DISK* disk, char* filename); |
---|
| 95 | |
---|
| 96 | zzip_disk_extern _zzip_size_t |
---|
| 97 | zzip_disk_fread (void* ptr, _zzip_size_t size, _zzip_size_t nmemb, |
---|
| 98 | ZZIP_DISK_FILE* file); |
---|
| 99 | zzip_disk_extern int |
---|
| 100 | zzip_disk_fclose (ZZIP_DISK_FILE* file); |
---|
| 101 | int |
---|
| 102 | zzip_disk_feof (ZZIP_DISK_FILE* file); |
---|
| 103 | |
---|
| 104 | #endif |
---|
| 105 | |
---|