aboutsummaryrefslogtreecommitdiffstats
path: root/Plugins/DbSqliteWx/sqlite3secure.c
blob: 585cc9b9ce369d2ed08bd42c8517a47bae6947fe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// To enable the extension functions define SQLITE_ENABLE_EXTFUNC on compiling this module
// To enable the reading CSV files define SQLITE_ENABLE_CSV on compiling this module
#if defined(SQLITE_ENABLE_EXTFUNC) || defined(SQLITE_ENABLE_CSV)
#define wx_sqlite3_open    wx_sqlite3_open_internal
#define wx_sqlite3_open16  wx_sqlite3_open16_internal
#define wx_sqlite3_open_v2 wx_sqlite3_open_v2_internal
#endif

// Enable the user authentication feature
#ifndef SQLITE_USER_AUTHENTICATION
#define SQLITE_USER_AUTHENTICATION 1
#endif

#include "wxsqlite3.c"
#ifdef SQLITE_USER_AUTHENTICATION
#include "sha2.h"
#include "sha2.c"
#include "userauth.c"
#endif

#if defined(SQLITE_ENABLE_EXTFUNC) || defined(SQLITE_ENABLE_CSV)
#undef wx_sqlite3_open
#undef wx_sqlite3_open16
#undef wx_sqlite3_open_v2
#endif

#ifndef SQLITE_OMIT_DISKIO

#ifdef SQLITE_HAS_CODEC

/*
** Get the codec argument for this pager
*/

void* mySqlite3PagerGetCodec(
  Pager *pPager
){
#if (SQLITE_VERSION_NUMBER >= 3006016)
  return wx_sqlite3PagerGetCodec(pPager);
#else
  return (pPager->xCodec) ? pPager->pCodecArg : NULL;
#endif
}

/*
** Set the codec argument for this pager
*/

void mySqlite3PagerSetCodec(
  Pager *pPager,
  void *(*xCodec)(void*,void*,Pgno,int),
  void (*xCodecSizeChng)(void*,int,int),
  void (*xCodecFree)(void*),
  void *pCodec
){
  wx_sqlite3PagerSetCodec(pPager, xCodec, xCodecSizeChng, xCodecFree, pCodec);
}

#include "rijndael.c"
#include "codec.c"
#include "codecext.c"

#endif

#endif

/* Extension functions */
#ifdef SQLITE_ENABLE_EXTFUNC
#include "extensionfunctions.c"
#endif

/* CSV import */
#ifdef SQLITE_ENABLE_CSV
#include "csv.c"
#endif

#if defined(SQLITE_ENABLE_EXTFUNC) || defined(SQLITE_ENABLE_CSV)

SQLITE_API int wx_sqlite3_open(
  const char *filename,   /* Database filename (UTF-8) */
  wx_sqlite3 **ppDb          /* OUT: SQLite db handle */
)
{
  int ret = wx_sqlite3_open_internal(filename, ppDb);
  if (ret == 0)
  {
#ifdef SQLITE_ENABLE_EXTFUNC
    RegisterExtensionFunctions(*ppDb);
#endif
#ifdef SQLITE_ENABLE_CSV
    wx_sqlite3_csv_init(*ppDb, NULL, NULL);
#endif
  }
  return ret;
}

SQLITE_API int wx_sqlite3_open16(
  const void *filename,   /* Database filename (UTF-16) */
  wx_sqlite3 **ppDb          /* OUT: SQLite db handle */
)
{
  int ret = wx_sqlite3_open16_internal(filename, ppDb);
  if (ret == 0)
  {
#ifdef SQLITE_ENABLE_EXTFUNC
    RegisterExtensionFunctions(*ppDb);
#endif
#ifdef SQLITE_ENABLE_CSV
    wx_sqlite3_csv_init(*ppDb, NULL, NULL);
#endif
  }
  return ret;
}

SQLITE_API int wx_sqlite3_open_v2(
  const char *filename,   /* Database filename (UTF-8) */
  wx_sqlite3 **ppDb,         /* OUT: SQLite db handle */
  int flags,              /* Flags */
  const char *zVfs        /* Name of VFS module to use */
)
{
  int ret = wx_sqlite3_open_v2_internal(filename, ppDb, flags, zVfs);
  if (ret == 0)
  {
#ifdef SQLITE_ENABLE_EXTFUNC
    RegisterExtensionFunctions(*ppDb);
#endif
#ifdef SQLITE_ENABLE_CSV
    wx_sqlite3_csv_init(*ppDb, NULL, NULL);
#endif
  }
  return ret;
}

#endif