sqlite3_bctbx_vfs.h 2.81 KB
Newer Older
1
/*
2
sqlite3_bctbx_vfs_t.h
3 4 5 6 7 8 9 10 11 12 13 14 15 16
Copyright (C) 2016 Belledonne Communications SARL

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
17
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18 19
*/

20 21 22
#ifndef sqlite3_bctx_vfs_h
#define sqlite3_bctx_vfs_h

23 24 25 26 27
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <fcntl.h>

Ghislain MARY's avatar
Ghislain MARY committed
28
#include <bctoolbox/vfs.h>
29

30 31
#include "sqlite3.h"

Sandrine Avakian's avatar
Sandrine Avakian committed
32

33 34 35 36 37 38 39
/*
** The maximum pathname length supported by this VFS.
*/
#define MAXPATHNAME 512


/**
40
 * sqlite3_bctbx_file_t VFS file structure.
41
 */
42 43
typedef struct sqlite3_bctbx_file_t sqlite3_bctbx_file_t;
struct sqlite3_bctbx_file_t {
44
	sqlite3_file base;              /* Base class. Must be first. */
45
	bctbx_vfs_file_t* pbctbx_file;
46 47 48 49 50
};



/**
51 52
 * Very simple VFS structure based on sqlite3_vfs. 
 * Only the Open function is implemented, 
53
 */
54 55 56
typedef struct sqlite3_bctbx_vfs_t sqlite3_bctbx_vfs_t;
struct sqlite3_bctbx_vfs_t {
	sqlite3_bctbx_vfs_t *pNext;      /* Next registered VFS */
57 58 59 60 61
	const char *vfsName;       /* Virtual file system name */
	int (*xOpen)(sqlite3_vfs* pVfs, const char *fName, sqlite3_file *pFile,int flags, int *pOutFlags);
	
};

62 63 64 65

/****************************************************
VFS API to register this VFS to sqlite3 VFS
*****************************************************/
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87

/**
 * Returns a sqlite3_vfs pointer to the VFS named sqlite3bctbx_vfs 
 * implemented in this file.
 * Methods not implemented:
 *			xDelete 
 *			xAccess 
 *			xFullPathname 
 *			xDlOpen 
 *			xDlError 
 *			xDlSym 
 *			xDlClose 
 *			xRandomness 
 *			xSleep 
 *			xCurrentTime , xCurrentTimeInt64,
 *			xGetLastError
 *			xGetSystemCall
 *			xSetSystemCall
 *			xNextSystemCall
 *			To make the VFS available to SQLite
 * @return  Pointer to bctbx_vfs.
 */
88
sqlite3_vfs *sqlite3_bctbx_vfs_create(void);
89 90 91 92

/**
 * Registers sqlite3bctbx_vfs to SQLite VFS. If makeDefault is 1,
 * the VFS will be used by default.
93
 * Methods not implemented by sqlite3_bctbx_vfs_t are initialized to the one 
94 95 96
 * used by the unix-none VFS where all locking file operations are no-ops. 
 * @param  makeDefault  set to 1 to make the newly registered VFS be the default one, set to 0 instead.
 */
97
void sqlite3_bctbx_vfs_register(int makeDefault);
98 99 100 101 102


/**
 * Unregisters sqlite3bctbx_vfs from SQLite.
 */
103 104 105
void sqlite3_bctbx_vfs_unregister(void);

#endif