HDF5 Extras  0.0.1
Convenience Functions for using HDF5 Better
hdf5vfs.h
Go to the documentation of this file.
1 #ifndef HDF5VFS_H_
2 #define HDF5VFS_H_
3 
4 #include <time.h>
5 #include <stdlib.h>
6 #include <stdarg.h>
7 #include <string.h>
8 #include <stdio.h>
9 #include <errno.h>
10 #include <sys/types.h>
11 #include <limits.h>
12 #include <float.h>
13 #include <math.h>
14 #include <complex.h>
15 
16 #include <hdf5.h>
17 
18 #include "sqlite3.h"
19 #include <dlfcn.h>
20 #include <spatialite.h>
21 
22 #include "ifile.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
30 #define TRUE 1
31 #define FALSE 0
32 
33 /*
34 ** Size of the write buffer used by journal files in bytes.
35 */
36 #ifndef SQLITE_DEMOVFS_BUFFERSZ
37 # define SQLITE_DEMOVFS_BUFFERSZ 8192
38 #endif
39 
40 /*
41 ** The maximum pathname length supported by this VFS.
42 */
43 #define MAXPATHNAME 512
44 
45 /*
46 ** When using this VFS, the sqlite3_file* handles that SQLite uses are
47 ** actually pointers to instances of type HDFFile.
48 */
49 typedef struct HDFFile HDFFile;
50 struct HDFFile {
51  sqlite3_file base; /* Base class. Must be first. */
52  IFILE *ifilep; /* the IFILE struct */
53 
54  char *aBuffer; /* Pointer to malloc'd buffer */
55  int nBuffer; /* Valid bytes of data in zBuffer */
56  sqlite3_int64 iBufferOfst; /* Offset in file of zBuffer[0] */
57 };
58 
59 
60 static int HDFDirectWrite(
61  HDFFile *p, /* File handle */
62  const void *zBuf, /* Buffer containing data to write */
63  int iAmt, /* Size of data to write in bytes */
64  sqlite_int64 iOfst /* File offset to write to */
65 );
66 
67 static int HDFFlushBuffer(HDFFile *p);
68 
69 static int HDFClose(sqlite3_file *pFile);
70 
71 static int HDFRead(
72  sqlite3_file *pFile,
73  void *zBuf,
74  int iAmt,
75  sqlite_int64 iOfst
76 );
77 
78 static int HDFWrite(
79  sqlite3_file *pFile,
80  const void *zBuf,
81  int iAmt,
82  sqlite_int64 iOfst
83 );
84 
85 static int HDFTruncate(sqlite3_file *pFile, sqlite_int64 size);
86 
87 static int HDFSync(sqlite3_file *pFile, int flags);
88 
89 static int HDFFileSize(sqlite3_file *pFile, sqlite_int64 *pSize);
90 
91 static int HDFLock(sqlite3_file *pFile, int eLock);
92 static int HDFUnlock(sqlite3_file *pFile, int eLock);
93 static int HDFCheckReservedLock(sqlite3_file *pFile, int *pResOut);
94 static int HDFFileControl(sqlite3_file *pFile, int op, void *pArg);
95 
96 
97 static int HDFSectorSize(sqlite3_file *pFile);
98 static int HDFDeviceCharacteristics(sqlite3_file *pFile);
99 
100 static int HDFOpen(
101  sqlite3_vfs *pVfs, /* VFS */
102  const char *zName, /* File to open, or 0 for a temp file */
103  sqlite3_file *pFile, /* Pointer to HDFFile struct to populate */
104  int flags, /* Input SQLITE_OPEN_XXX flags */
105  int *pOutFlags /* Output SQLITE_OPEN_XXX flags (or NULL) */
106 );
107 
108 
109 static int HDFDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync);
110 
111 static int HDFAccess(
112  sqlite3_vfs *pVfs,
113  const char *zPath,
114  int flags,
115  int *pResOut
116 );
117 
118 static int HDFFullPathname(
119  sqlite3_vfs *pVfs, /* VFS */
120  const char *zPath, /* Input path (possibly a relative path) */
121  int nPathOut, /* Size of output buffer in bytes */
122  char *zPathOut /* Pointer to output buffer */
123 );
124 
125 static void *HDFDlOpen(sqlite3_vfs *pVfs, const char *zPath);
126 static void HDFDlError(sqlite3_vfs *pVfs, int nByte, char *zErrMsg);
127 static void (*HDFDlSym(sqlite3_vfs *pVfs, void *pH, const char *z))(void);
128 static void HDFDlClose(sqlite3_vfs *pVfs, void *pHandle);
129 static int HDFRandomness(sqlite3_vfs *pVfs, int nByte, char *zByte);
130 
131 
132 static int HDFSleep(sqlite3_vfs *pVfs, int nMicro);
133 static int HDFCurrentTime(sqlite3_vfs *pVfs, double *pTime);
134 
135 sqlite3_vfs *sqlite3_HDFvfs(void);
136 
137 
138 
139 
140 
141 #ifdef __cplusplus
142 }
143 #endif
144 
145 #endif
Definition: hdf5vfs.h:50
Definition: ifile.h:33