sqlite3secure.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // To enable the extension functions define SQLITE_ENABLE_EXTFUNC on compiling this module
  2. #ifdef SQLITE_ENABLE_EXTFUNC
  3. #define sqlite3_open sqlite3_open_internal
  4. #define sqlite3_open16 sqlite3_open16_internal
  5. #define sqlite3_open_v2 sqlite3_open_v2_internal
  6. #endif
  7. // Enable the user authentication feature
  8. #ifndef SQLITE_USER_AUTHENTICATION
  9. #define SQLITE_USER_AUTHENTICATION 1
  10. #endif
  11. #include "sqlite3.c"
  12. #ifdef SQLITE_USER_AUTHENTICATION
  13. #include "sha2.h"
  14. #include "sha2.c"
  15. #include "userauth.c"
  16. #endif
  17. #ifdef SQLITE_ENABLE_EXTFUNC
  18. #undef sqlite3_open
  19. #undef sqlite3_open16
  20. #undef sqlite3_open_v2
  21. #endif
  22. #ifndef SQLITE_OMIT_DISKIO
  23. #ifdef SQLITE_HAS_CODEC
  24. /*
  25. ** Get the codec argument for this pager
  26. */
  27. void* mySqlite3PagerGetCodec(
  28. Pager *pPager
  29. ){
  30. #if (SQLITE_VERSION_NUMBER >= 3006016)
  31. return sqlite3PagerGetCodec(pPager);
  32. #else
  33. return (pPager->xCodec) ? pPager->pCodecArg : NULL;
  34. #endif
  35. }
  36. /*
  37. ** Set the codec argument for this pager
  38. */
  39. void mySqlite3PagerSetCodec(
  40. Pager *pPager,
  41. void *(*xCodec)(void*,void*,Pgno,int),
  42. void (*xCodecSizeChng)(void*,int,int),
  43. void (*xCodecFree)(void*),
  44. void *pCodec
  45. ){
  46. sqlite3PagerSetCodec(pPager, xCodec, xCodecSizeChng, xCodecFree, pCodec);
  47. }
  48. #include "rijndael.c"
  49. #include "codec.c"
  50. #include "codecext.c"
  51. #endif
  52. #endif
  53. #ifdef SQLITE_ENABLE_EXTFUNC
  54. #include "extensionfunctions.c"
  55. SQLITE_API int sqlite3_open(
  56. const char *filename, /* Database filename (UTF-8) */
  57. sqlite3 **ppDb /* OUT: SQLite db handle */
  58. )
  59. {
  60. int ret = sqlite3_open_internal(filename, ppDb);
  61. if (ret == 0)
  62. {
  63. RegisterExtensionFunctions(*ppDb);
  64. }
  65. return ret;
  66. }
  67. SQLITE_API int sqlite3_open16(
  68. const void *filename, /* Database filename (UTF-16) */
  69. sqlite3 **ppDb /* OUT: SQLite db handle */
  70. )
  71. {
  72. int ret = sqlite3_open16_internal(filename, ppDb);
  73. if (ret == 0)
  74. {
  75. RegisterExtensionFunctions(*ppDb);
  76. }
  77. return ret;
  78. }
  79. SQLITE_API int sqlite3_open_v2(
  80. const char *filename, /* Database filename (UTF-8) */
  81. sqlite3 **ppDb, /* OUT: SQLite db handle */
  82. int flags, /* Flags */
  83. const char *zVfs /* Name of VFS module to use */
  84. )
  85. {
  86. int ret = sqlite3_open_v2_internal(filename, ppDb, flags, zVfs);
  87. if (ret == 0)
  88. {
  89. RegisterExtensionFunctions(*ppDb);
  90. }
  91. return ret;
  92. }
  93. #endif