PageRenderTime 26ms CodeModel.GetById 1ms app.highlight 20ms RepoModel.GetById 1ms app.codeStats 0ms

/src/zziplib/zzip/mmapped.h

https://bitbucket.org/cabalistic/ogredeps/
C++ Header | 138 lines | 86 code | 28 blank | 24 comment | 0 complexity | 8546e55c0d4f9a529d6c74aabecd299c MD5 | raw file
  1#ifndef _ZZIP_MMAPPED_H_
  2#define _ZZIP_MMAPPED_H_
  3/*
  4 * NOTE: this is part of libzzipmmapped (i.e. it is not libzzip).
  5 *
  6 * simplified zip disk access using a mmapping of the whole archive.
  7 *
  8 * Author:
  9 *      Guido Draheim <guidod@gmx.de>
 10 *
 11 * Copyright (c) 2003,2004 Guido Draheim
 12 *          All rights reserved,
 13 *          use under the restrictions of the
 14 *          Lesser GNU General Public License
 15 *          or alternatively the restrictions
 16 *          of the Mozilla Public License 1.1
 17 */
 18
 19
 20#include <zzip/types.h>
 21
 22#ifdef _ZZIP_DISK_FILE_STRUCT
 23#include <zlib.h> /* z_stream */
 24#endif
 25
 26#ifdef __cplusplus
 27extern "C" {
 28#endif
 29
 30typedef struct zzip_disk_file  ZZIP_DISK_FILE;
 31typedef struct zzip_disk       ZZIP_DISK;
 32/*  def struct zzip_disk_entry ZZIP_DISK_ENTRY; */
 33
 34/* we expose this structure so third party applications can augment
 35 * on them. The mmapped zip access usually just needs the two pointers
 36 * specifying the mmapped area, whereever you have that from.
 37 */
 38struct zzip_disk
 39{
 40    zzip_byte_t* buffer; /* start of mmapped area, the base of all seekvals */
 41    zzip_byte_t* endbuf; /* end of mmapped area, i.e. buffer + buflen */
 42    void* reserved;    /* - for later extensions (might be renamed) */
 43    void* user;        /* - free for applications (use this!) */
 44    long  flags;       /* bit 0: findfile searches case-insensitive */
 45    long  mapped;      /* used for mmap() wrappers of zzip/__mmap.h */
 46    long  unused;      /* - for later extensions (might be renamed) */
 47    long  code;        /* - free for applications (use this!) */
 48};
 49
 50/* fnmatch search shall be case insensitive */
 51#define ZZIP_DISK_FLAGS_MATCH_NOCASE 1
 52#define ZZIP_DISK_FLAGS_OWNED_BUFFER 2
 53
 54typedef int (*zzip_strcmp_fn_t)(char*, char*);
 55typedef int (*zzip_fnmatch_fn_t)(char*, char*, int);
 56
 57#define zzip_disk_extern extern
 58
 59zzip_disk_extern int
 60zzip_disk_init(ZZIP_DISK* disk, void* buffer, zzip_size_t buflen);
 61
 62zzip_disk_extern zzip__new__ ZZIP_DISK*
 63zzip_disk_new(void);
 64
 65zzip_disk_extern zzip__new__ ZZIP_DISK*
 66zzip_disk_mmap(int fd);
 67
 68zzip_disk_extern int
 69zzip_disk_munmap(ZZIP_DISK* disk);
 70
 71zzip_disk_extern zzip__new__ ZZIP_DISK*
 72zzip_disk_open(char* filename);
 73
 74zzip_disk_extern zzip__new__ ZZIP_DISK *
 75zzip_disk_buffer(void *buffer, size_t buflen);
 76
 77zzip_disk_extern int
 78zzip_disk_close(ZZIP_DISK* disk);
 79
 80
 81zzip_disk_extern ZZIP_DISK_ENTRY*
 82zzip_disk_findfirst(ZZIP_DISK* disk);
 83
 84zzip_disk_extern ZZIP_DISK_ENTRY*
 85zzip_disk_findnext(ZZIP_DISK* disk, ZZIP_DISK_ENTRY* entry);
 86
 87zzip_disk_extern zzip__new__ char*
 88zzip_disk_entry_strdup_name(ZZIP_DISK* disk, ZZIP_DISK_ENTRY* entry);
 89zzip_disk_extern zzip__new__ char*
 90zzip_disk_entry_strdup_comment(ZZIP_DISK* disk, ZZIP_DISK_ENTRY* entry);
 91zzip_disk_extern struct zzip_file_header*
 92zzip_disk_entry_to_file_header(ZZIP_DISK* disk, ZZIP_DISK_ENTRY* entry);
 93zzip_disk_extern zzip_byte_t*
 94zzip_disk_entry_to_data(ZZIP_DISK* disk, ZZIP_DISK_ENTRY* entry);
 95
 96zzip_disk_extern ZZIP_DISK_ENTRY*
 97zzip_disk_findfile(ZZIP_DISK* disk,
 98		   char* filename, ZZIP_DISK_ENTRY* after,
 99		   zzip_strcmp_fn_t compare);
100zzip_disk_extern ZZIP_DISK_ENTRY*
101zzip_disk_findmatch(ZZIP_DISK* disk,
102		    char* filespec, ZZIP_DISK_ENTRY* after,
103		    zzip_fnmatch_fn_t compare, int flags);
104
105
106zzip_disk_extern zzip__new__ ZZIP_DISK_FILE*
107zzip_disk_entry_fopen (ZZIP_DISK* disk, ZZIP_DISK_ENTRY* entry);
108
109zzip_disk_extern zzip__new__ ZZIP_DISK_FILE*
110zzip_disk_fopen (ZZIP_DISK* disk, char* filename);
111
112zzip_disk_extern _zzip_size_t
113zzip_disk_fread (void* ptr, _zzip_size_t size, _zzip_size_t nmemb,
114		 ZZIP_DISK_FILE* file);
115zzip_disk_extern int
116zzip_disk_fclose (ZZIP_DISK_FILE* file);
117int
118zzip_disk_feof (ZZIP_DISK_FILE* file);
119
120#ifdef _ZZIP_DISK_FILE_STRUCT
121/**
122 * typedef struct zzip_disk_file ZZIP_DISK_FILE;
123 */
124struct zzip_disk_file
125{
126    zzip_byte_t* buffer;               /* fopen disk->buffer */
127    zzip_byte_t* endbuf;               /* fopen disk->endbuf */
128    zzip_size_t avail;                 /* memorized for checks on EOF */
129    z_stream zlib;                     /* for inflated blocks */
130    zzip_byte_t* stored;               /* for stored blocks */
131};
132#endif
133
134#ifdef __cplusplus
135}
136#endif
137#endif
138