2012 September 12
The author disclaims copyright to this source code. In place of a legal notice, here is a blessing:
May you do good and not evil. May you find forgiveness for yourself and forgive others. May you share freely, never taking more than you give.
Definition in file zipfile.c.#include <sqlite3ext.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <zlib.h>
Go to the source code of this file.
Data Structures | |
struct | zip_cursor |
Structure to describe ZIP virtual table cursor. More... | |
struct | zip_file |
Structure to implement ZIP file handle. More... | |
struct | zip_vtab |
Structure to describe a ZIP virtual table. More... | |
Defines | |
#define | ZIP_SIG_LEN 4 |
#define | ZIP_LOCAL_HEADER_SIG 0x04034b50 |
#define | ZIP_LOCAL_HEADER_FLAGS 6 |
#define | ZIP_LOCAL_PATHLEN_OFFS 26 |
#define | ZIP_LOCAL_EXTRA_OFFS 28 |
#define | ZIP_LOCAL_HEADER_LEN 30 |
#define | ZIP_CENTRAL_HEADER_SIG 0x02014b50 |
#define | ZIP_CENTRAL_HEADER_FLAGS 8 |
#define | ZIP_CENTRAL_HEADER_LEN 46 |
#define | ZIP_CENTRAL_COMPMETH_OFFS 10 |
#define | ZIP_CENTRAL_MTIME_OFFS 12 |
#define | ZIP_CENTRAL_MDATE_OFFS 14 |
#define | ZIP_CENTRAL_CRC32_OFFS 16 |
#define | ZIP_CENTRAL_COMPLEN_OFFS 20 |
#define | ZIP_CENTRAL_UNCOMPLEN_OFFS 24 |
#define | ZIP_CENTRAL_PATHLEN_OFFS 28 |
#define | ZIP_CENTRAL_EXTRALEN_OFFS 30 |
#define | ZIP_CENTRAL_COMMENTLEN_OFFS 32 |
#define | ZIP_CENTRAL_LOCALHDR_OFFS 42 |
#define | ZIP_CENTRAL_END_SIG 0x06054b50 |
#define | ZIP_CENTRAL_END_LEN 22 |
#define | ZIP_CENTRAL_ENTS_OFFS 8 |
#define | ZIP_CENTRAL_DIRSIZE_OFFS 12 |
#define | ZIP_CENTRAL_DIRSTART_OFFS 16 |
#define | ZIP_COMPMETH_STORED 0 |
#define | ZIP_COMPMETH_DEFLATED 8 |
#define | zip_read_int(p) ((p)[0] | ((p)[1] << 8) | ((p)[2] << 16) | ((p)[3] << 24)) |
#define | zip_read_short(p) ((p)[0] | ((p)[1] << 8)) |
Typedefs | |
typedef zip_file | zip_file |
typedef zip_vtab | zip_vtab |
Functions | |
zip_file * | zip_open (const char *filename) |
Memory map ZIP file for reading and return handle to it. | |
void | zip_close (zip_file *zip) |
Close ZIP file handle. | |
char * | unquote (char const *in) |
Strip off quotes given string. | |
int | zip_vtab_connect (sqlite3 *db, void *aux, int argc, const char *const *argv, sqlite3_vtab **vtabp, char **errp) |
Connect to virtual table. | |
int | zip_vtab_create (sqlite3 *db, void *aux, int argc, const char *const *argv, sqlite3_vtab **vtabp, char **errp) |
Create virtual table. | |
int | zip_vtab_disconnect (sqlite3_vtab *vtab) |
Disconnect virtual table. | |
int | zip_vtab_destroy (sqlite3_vtab *vtab) |
Destroy virtual table. | |
int | zip_vtab_bestindex (sqlite3_vtab *vtab, sqlite3_index_info *info) |
Determines information for filter function according to constraints. | |
int | zip_vtab_open (sqlite3_vtab *vtab, sqlite3_vtab_cursor **cursorp) |
Open virtual table and return cursor. | |
int | zip_vtab_close (sqlite3_vtab_cursor *cursor) |
Close virtual table cursor. | |
int | zip_vtab_next (sqlite3_vtab_cursor *cursor) |
Retrieve next row from virtual table cursor. | |
int | zip_vtab_filter (sqlite3_vtab_cursor *cursor, int idxNum, const char *idxStr, int argc, sqlite3_value **argv) |
Filter function for virtual table. | |
int | zip_vtab_eof (sqlite3_vtab_cursor *cursor) |
Return end of table state of virtual table cursor. | |
int | zip_vtab_column (sqlite3_vtab_cursor *cursor, sqlite3_context *ctx, int n) |
Return column data of virtual table. | |
int | zip_vtab_rowid (sqlite3_vtab_cursor *cursor, sqlite_int64 *rowidp) |
Return current rowid of virtual table cursor. | |
void | zip_vtab_matchfunc (sqlite3_context *ctx, int argc, sqlite3_value **argv) |
Internal MATCH function for virtual table. | |
int | zip_vtab_findfunc (sqlite3_vtab *vtab, int narg, const char *name, void(**pfunc)(sqlite3_context *, int, sqlite3_value **), void **parg) |
Find overloaded function on virtual table. | |
void | zip_crc32_func (sqlite3_context *ctx, int argc, sqlite3_value **argv) |
Compute CRC32 given blob. | |
void | zip_inflate_func (sqlite3_context *ctx, int argc, sqlite3_value **argv) |
Inflate data given blob. | |
void | zip_deflate_func (sqlite3_context *ctx, int argc, sqlite3_value **argv) |
Deflate data given blob and optional compression level. | |
void | zip_compress_func (sqlite3_context *ctx, int argc, sqlite3_value **argv) |
Compress data given blob and optional compression level. | |
int | zip_vtab_init (sqlite3 *db) |
Module initializer creating SQLite module and functions. | |
int | sqlite3_extension_init (sqlite3 *db, char **errmsg, const sqlite3_api_routines *api) |
Initializer for SQLite extension load mechanism. | |
Variables | |
const sqlite3_module | zip_vtab_mod |
SQLite module descriptor. |
|
Definition at line 66 of file zipfile.c. Referenced by zip_open(). |
|
Definition at line 62 of file zipfile.c. Referenced by zip_vtab_column(). |
|
Definition at line 58 of file zipfile.c. Referenced by zip_vtab_column(). |
|
Definition at line 61 of file zipfile.c. Referenced by zip_vtab_column(). |
|
Definition at line 72 of file zipfile.c. Referenced by zip_open(). |
|
Definition at line 73 of file zipfile.c. Referenced by zip_open(). |
|
Definition at line 70 of file zipfile.c. Referenced by zip_open(). |
|
Definition at line 69 of file zipfile.c. Referenced by zip_open(). |
|
Definition at line 71 of file zipfile.c. Referenced by zip_open(). |
|
Definition at line 65 of file zipfile.c. Referenced by zip_open(). |
|
|
|
Definition at line 57 of file zipfile.c. Referenced by zip_open(), zip_vtab_column(), and zip_vtab_filter(). |
|
Definition at line 55 of file zipfile.c. Referenced by zip_open(). |
|
Definition at line 67 of file zipfile.c. Referenced by zip_vtab_column(). |
|
Definition at line 60 of file zipfile.c. Referenced by zip_vtab_column(). |
|
Definition at line 59 of file zipfile.c. Referenced by zip_vtab_column(). |
|
Definition at line 64 of file zipfile.c. Referenced by zip_open(), zip_vtab_column(), and zip_vtab_filter(). |
|
Definition at line 63 of file zipfile.c. Referenced by zip_vtab_column(). |
|
Definition at line 76 of file zipfile.c. Referenced by zip_vtab_column(). |
|
Definition at line 75 of file zipfile.c. Referenced by zip_vtab_column(). |
|
Definition at line 52 of file zipfile.c. Referenced by zip_vtab_column(). |
|
|
|
Definition at line 53 of file zipfile.c. Referenced by zip_vtab_column(). |
|
|
|
Definition at line 51 of file zipfile.c. Referenced by zip_vtab_column(). |
|
Definition at line 78 of file zipfile.c. Referenced by zip_open(), and zip_vtab_column(). |
|
Definition at line 80 of file zipfile.c. Referenced by zip_open(), zip_vtab_column(), and zip_vtab_filter(). |
|
Definition at line 47 of file zipfile.c. Referenced by zip_open(). |
|
|
|
|
|
Initializer for SQLite extension load mechanism.
Definition at line 2293 of file zipfile.c. References zip_vtab_init(). |
|
Strip off quotes given string.
Definition at line 372 of file zipfile.c. Referenced by csv_vtab_connect(), drvcolumns(), drvforeignkeys(), and zip_vtab_connect(). |
|
Close ZIP file handle.
Definition at line 340 of file zipfile.c. References zip_file::data, zip_file::length, and zip_file::nentries. Referenced by zip_vtab_connect(), and zip_vtab_disconnect(). |
|
Compress data given blob and optional compression level.
Definition at line 1222 of file zipfile.c. Referenced by zip_vtab_init(). |
|
Compute CRC32 given blob.
Definition at line 1059 of file zipfile.c. Referenced by zip_vtab_init(). |
|
Deflate data given blob and optional compression level.
Definition at line 1158 of file zipfile.c. Referenced by zip_vtab_init(). |
|
Inflate data given blob.
Definition at line 1084 of file zipfile.c. Referenced by zip_vtab_init(). |
|
Memory map ZIP file for reading and return handle to it.
Definition at line 184 of file zipfile.c. References zip_file::baseoffs, zip_file::data, zip_file::entries, zip_file::length, zip_file::nentries, ZIP_CENTRAL_COMMENTLEN_OFFS, ZIP_CENTRAL_DIRSIZE_OFFS, ZIP_CENTRAL_DIRSTART_OFFS, ZIP_CENTRAL_END_LEN, ZIP_CENTRAL_END_SIG, ZIP_CENTRAL_ENTS_OFFS, ZIP_CENTRAL_EXTRALEN_OFFS, ZIP_CENTRAL_HEADER_LEN, ZIP_CENTRAL_HEADER_SIG, ZIP_CENTRAL_PATHLEN_OFFS, zip_read_int, zip_read_short, and ZIP_SIG_LEN. Referenced by zip_vtab_connect(). |
|
Determines information for filter function according to constraints.
Definition at line 516 of file zipfile.c. References zip_vtab::db, zip_file::entries, zip_file::nentries, zip_vtab::sorted, zip_vtab::tblname, and zip_vtab::zip. |
|
Close virtual table cursor.
Definition at line 631 of file zipfile.c. References zip_cursor::matches. |
|
Return column data of virtual table.
Definition at line 776 of file zipfile.c. References zip_file::baseoffs, zip_cursor::cursor, zip_file::data, zip_file::entries, zip_file::length, zip_cursor::matches, zip_file::nentries, zip_cursor::nmatches, zip_cursor::pos, zip_cursor::usematches, zip_vtab::zip, ZIP_CENTRAL_COMPLEN_OFFS, ZIP_CENTRAL_COMPMETH_OFFS, ZIP_CENTRAL_CRC32_OFFS, ZIP_CENTRAL_HEADER_LEN, ZIP_CENTRAL_LOCALHDR_OFFS, ZIP_CENTRAL_MDATE_OFFS, ZIP_CENTRAL_MTIME_OFFS, ZIP_CENTRAL_PATHLEN_OFFS, ZIP_CENTRAL_UNCOMPLEN_OFFS, ZIP_COMPMETH_DEFLATED, ZIP_COMPMETH_STORED, ZIP_LOCAL_EXTRA_OFFS, ZIP_LOCAL_HEADER_LEN, ZIP_LOCAL_PATHLEN_OFFS, zip_read_int, and zip_read_short. |
|
Connect to virtual table.
argv[0] - module name Definition at line 412 of file zipfile.c. References zip_vtab::db, zip_vtab::tblname, unquote(), zip_vtab::vtab, zip_vtab::zip, zip_close(), and zip_open(). Referenced by zip_vtab_create(). |
|
Create virtual table.
Definition at line 473 of file zipfile.c. References zip_vtab_connect(). |
|
Destroy virtual table.
Definition at line 503 of file zipfile.c. References zip_vtab_disconnect(). |
|
Disconnect virtual table.
Definition at line 487 of file zipfile.c. References zip_vtab::zip, and zip_close(). Referenced by zip_vtab_destroy(). |
|
Return end of table state of virtual table cursor.
Definition at line 753 of file zipfile.c. References zip_cursor::cursor, zip_file::nentries, zip_cursor::nmatches, zip_cursor::pos, zip_cursor::usematches, and zip_vtab::zip. |
|
Filter function for virtual table.
Definition at line 670 of file zipfile.c. References zip_cursor::cursor, zip_file::entries, zip_cursor::matches, zip_file::nentries, zip_cursor::nmatches, zip_cursor::pos, zip_cursor::usematches, zip_vtab::zip, ZIP_CENTRAL_HEADER_LEN, ZIP_CENTRAL_PATHLEN_OFFS, zip_read_short, and zip_vtab_next(). |
|
Find overloaded function on virtual table.
Definition at line 994 of file zipfile.c. References zip_vtab_matchfunc(). |
|
Module initializer creating SQLite module and functions.
Definition at line 2243 of file zipfile.c. References zip_compress_func(), zip_crc32_func(), zip_deflate_func(), zip_inflate_func(), and zip_vtab_mod. Referenced by sqlite3_extension_init(). |
|
Internal MATCH function for virtual table.
Definition at line 957 of file zipfile.c. Referenced by zip_vtab_findfunc(). |
|
Retrieve next row from virtual table cursor.
Definition at line 649 of file zipfile.c. References zip_cursor::nmatches, and zip_cursor::pos. Referenced by zip_vtab_filter(). |
|
Open virtual table and return cursor.
Definition at line 608 of file zipfile.c. References zip_cursor::cursor, zip_cursor::matches, zip_cursor::nmatches, zip_cursor::pos, and zip_cursor::usematches. |
|
Return current rowid of virtual table cursor.
Definition at line 931 of file zipfile.c. References zip_cursor::matches, zip_cursor::nmatches, zip_cursor::pos, and zip_cursor::usematches. |
|
Initial value: { 1, zip_vtab_create, zip_vtab_connect, zip_vtab_bestindex, zip_vtab_disconnect, zip_vtab_destroy, zip_vtab_open, zip_vtab_close, zip_vtab_filter, zip_vtab_next, zip_vtab_eof, zip_vtab_column, zip_vtab_rowid, 0, 0, 0, 0, 0, zip_vtab_findfunc, }
Definition at line 1026 of file zipfile.c. Referenced by zip_vtab_init(). |