zzip_disk_mmap(3)

NAME
zzip_disk_mmap, zzip_disk_init, zzip_disk_new, zzip_disk_munmap, zzip_disk_open, zzip_disk_buffer, zzip_disk_close - turn a filehandle into a mmapped zip disk archive handle

SYNOPSIS

#include <zzip/mmapped.h>

b'zzip__new__ ZZIP_DISK *\fInzzip_disk_mmap(int fd)
b'int\fInzzip_disk_init(ZZIP_DISK * disk, void *buffer, zzip_size_t buflen)
b'zzip__new__ ZZIP_DISK *\fInzzip_disk_new(void)
b'int\fInzzip_disk_munmap(ZZIP_DISK * disk)
b'zzip__new__ ZZIP_DISK *\fInzzip_disk_open(char *filename)
b'zzip__new__ ZZIP_DISK *\fInzzip_disk_buffer(void *buffer, size_t buflen) '
b'int\fInzzip_disk_close(ZZIP_DISK * disk)n'

DESCRIPTION
b'The zzip_disk_mmap function uses the given file-descriptor to detect the length of thefile and calls the system mmap(2) to put it in main memory. If it issuccessful then a newly allocated ZZIP_DISK* is returned withdisk->buffer pointing to the mapview of the zipdisk content.

b'The zzip_disk_mmap function may return null on errors (errno).n'

b' The zzip_disk_init function does primary initialization of a disk-buffer struct.

b'The zzip_disk_init function always returns 0 as success.n'

b' The zzip_disk_new function allocates a new disk-buffer with malloc(3)

b'The zzip_disk_new function may return null on errors (errno).n'

b' The zzip_disk_munmap function is the inverse of zzip_disk_mmap and using the systemmunmap(2) on the buffer area and free(3) on the ZZIP_DISK structure.n'

b"The zzip_disk_open function opens the given archive by name and turn the filehandleto zzip_disk_mmap for bringing it to main memory. If it can notbe mmap(2)'ed then we slurp the whole file into a newly malloc(2)'edmemory block. Only if that fails too then we return null. Since handlingof disk->buffer is ambiguous it should not be snatched away please.

b'The zzip_disk_open function may return null on errors (errno).n'

b' The zzip_disk_buffer function will attach a buffer with a zip imagethat was acquired from another source than a file.Note that if zzip_disk_mmap fails then zzip_disk_openwill fall back and try to read the full file to memorywrapping a ZZIP_DISK around the memory buffer just asthe zzip_disk_buffer function will do. Note that the zzip_disk_buffer function will notown the buffer, it will neither be written nor free()d.

b'The zzip_disk_buffer function may return null (errno).n'

b'The zzip_disk_close function will release all data needed to access a (mmapped)zip archive, including any malloc()ed blocks, sharedmem mappingsand it dumps the handle struct as well.

b'The zzip_disk_close function returns 0 on success (or whatever munmap says).n

AUTHOR
b'Guido Draheim <guidod@gmx.de>

COPYRIGHT
b'Copyright (c)Guido Draheim, use under copyleft (LGPL,MPL)n'