• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef SQLITE3SYM_H
17 #define SQLITE3SYM_H
18 
19 #define SQLITE3_EXPORT_SYMBOLS
20 #define SQLITE_OMIT_LOAD_EXTENSION
21 
22 // We extend the original purpose of the "sqlite3ext.h".
23 #include "sqlite3ext.h"
24 
25 /*************************************************************************
26 ** BINLOG CONFIG
27 */
28 #define SQLITE_DBCONFIG_ENABLE_BINLOG    2006 /* Sqlite3BinlogConfig */
29 
30 typedef enum BinlogFileCleanMode {
31   BINLOG_FILE_CLEAN_ALL_MODE = 0,
32   BINLOG_FILE_CLEAN_READ_MODE = 1,
33   BINLOG_FILE_CLEAN_MODE_MAX,
34 } BinlogFileCleanModeE;
35 
36 typedef enum {
37   ROW = 0,
38 } Sqlite3BinlogMode;
39 
40 typedef struct Sqlite3BinlogConfig {
41     Sqlite3BinlogMode mode;
42     unsigned short fullCallbackThreshold;
43     unsigned int maxFileSize;
44     void (*xErrorCallback)(void *pCtx, int errNo, char *errMsg, const char *dbPath);
45     void (*xLogFullCallback)(void *pCtx, unsigned short currentCount, const char *dbPath);
46     void *callbackCtx;
47 } Sqlite3BinlogConfig;
48 /*
49 ** END OF BINLOG CONFIG
50 *************************************************************************/
51 
52 struct sqlite3_api_routines_extra {
53   int (*initialize)();
54   int (*config)(int,...);
55   int (*key)(sqlite3*,const void*,int);
56   int (*key_v2)(sqlite3*,const char*,const void*,int);
57   int (*rekey)(sqlite3*,const void*,int);
58   int (*rekey_v2)(sqlite3*,const char*,const void*,int);
59   int (*is_support_binlog)(const char*);
60   int (*replay_binlog)(sqlite3*, sqlite3*);
61   int (*clean_binlog)(sqlite3*, BinlogFileCleanModeE);
62   int (*compressdb_backup)(sqlite3*, const char*);
63 };
64 
65 extern const struct sqlite3_api_routines_extra *sqlite3_export_extra_symbols;
66 #define sqlite3_initialize          sqlite3_export_extra_symbols->initialize
67 #define sqlite3_config              sqlite3_export_extra_symbols->config
68 #define sqlite3_key                 sqlite3_export_extra_symbols->key
69 #define sqlite3_key_v2              sqlite3_export_extra_symbols->key_v2
70 #define sqlite3_rekey               sqlite3_export_extra_symbols->rekey
71 #define sqlite3_rekey_v2            sqlite3_export_extra_symbols->rekey_v2
72 #define sqlite3_is_support_binlog   sqlite3_export_extra_symbols->is_support_binlog
73 #define sqlite3_replay_binlog       sqlite3_export_extra_symbols->replay_binlog
74 #define sqlite3_clean_binlog        sqlite3_export_extra_symbols->clean_binlog
75 #define sqlite3_compressdb_backup   sqlite3_export_extra_symbols->compressdb_backup
76 
77 struct sqlite3_api_routines_cksumvfs {
78   int (*register_cksumvfs)(const char *);
79   int (*unregister_cksumvfs)();
80 };
81 extern const struct sqlite3_api_routines_cksumvfs *sqlite3_export_cksumvfs_symbols;
82 #define sqlite3_register_cksumvfs sqlite3_export_cksumvfs_symbols->register_cksumvfs
83 #define sqlite3_unregister_cksumvfs sqlite3_export_cksumvfs_symbols->unregister_cksumvfs
84 
85 #endif
86