engine/sqlite/src/loadext.cpp
author Sebastian Brannstrom <sebastianb@symbian.org>
Fri, 09 Jul 2010 22:49:31 +0100
branchsymbian1
changeset 173 8466fe8528b6
parent 2 29cda98b007e
permissions -rw-r--r--
Minor fix for highlight move in queue view
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     1
/*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     2
** 2006 June 7
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     3
**
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     4
** The author disclaims copyright to this source code.  In place of
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     5
** a legal notice, here is a blessing:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     6
**
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     7
**    May you do good and not evil.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     8
**    May you find forgiveness for yourself and forgive others.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     9
**    May you share freely, never taking more than you give.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    10
**
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    11
*************************************************************************
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    12
** This file contains code used to dynamically load extensions into
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    13
** the SQLite library.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    14
*/
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    15
#ifndef SQLITE_OMIT_LOAD_EXTENSION
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    16
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    17
#define SQLITE_CORE 1  /* Disable the API redefinition in sqlite3ext.h */
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    18
#include "sqlite3ext.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    19
#include "sqliteInt.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    20
#include <string.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    21
#include <ctype.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    22
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    23
/*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    24
** Some API routines are omitted when various features are
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    25
** excluded from a build of SQLite.  Substitute a NULL pointer
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    26
** for any missing APIs.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    27
*/
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    28
#ifndef SQLITE_ENABLE_COLUMN_METADATA
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    29
# define sqlite3_column_database_name   0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    30
# define sqlite3_column_database_name16 0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    31
# define sqlite3_column_table_name      0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    32
# define sqlite3_column_table_name16    0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    33
# define sqlite3_column_origin_name     0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    34
# define sqlite3_column_origin_name16   0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    35
# define sqlite3_table_column_metadata  0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    36
#endif
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    37
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    38
#ifdef SQLITE_OMIT_AUTHORIZATION
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    39
# define sqlite3_set_authorizer         0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    40
#endif
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    41
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    42
#ifdef SQLITE_OMIT_UTF16
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    43
# define sqlite3_bind_text16            0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    44
# define sqlite3_collation_needed16     0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    45
# define sqlite3_column_decltype16      0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    46
# define sqlite3_column_name16          0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    47
# define sqlite3_column_text16          0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    48
# define sqlite3_complete16             0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    49
# define sqlite3_create_collation16     0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    50
# define sqlite3_create_function16      0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    51
# define sqlite3_errmsg16               0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    52
# define sqlite3_open16                 0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    53
# define sqlite3_prepare16              0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    54
# define sqlite3_prepare16_v2           0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    55
# define sqlite3_result_error16         0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    56
# define sqlite3_result_text16          0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    57
# define sqlite3_result_text16be        0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    58
# define sqlite3_result_text16le        0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    59
# define sqlite3_value_text16           0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    60
# define sqlite3_value_text16be         0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    61
# define sqlite3_value_text16le         0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    62
# define sqlite3_column_database_name16 0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    63
# define sqlite3_column_table_name16    0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    64
# define sqlite3_column_origin_name16   0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    65
#endif
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    66
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    67
#ifdef SQLITE_OMIT_COMPLETE
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    68
# define sqlite3_complete 0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    69
# define sqlite3_complete16 0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    70
#endif
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    71
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    72
#ifdef SQLITE_OMIT_PROGRESS_CALLBACK
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    73
# define sqlite3_progress_handler 0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    74
#endif
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    75
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    76
#ifdef SQLITE_OMIT_VIRTUALTABLE
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    77
# define sqlite3_create_module 0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    78
# define sqlite3_create_module_v2 0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    79
# define sqlite3_declare_vtab 0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    80
#endif
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    81
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    82
#ifdef SQLITE_OMIT_SHARED_CACHE
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    83
# define sqlite3_enable_shared_cache 0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    84
#endif
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    85
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    86
#ifdef SQLITE_OMIT_TRACE
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    87
# define sqlite3_profile       0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    88
# define sqlite3_trace         0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    89
#endif
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    90
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    91
#ifdef SQLITE_OMIT_GET_TABLE
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    92
# define sqlite3_free_table    0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    93
# define sqlite3_get_table     0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    94
#endif
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    95
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    96
#ifdef SQLITE_OMIT_INCRBLOB
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    97
#define sqlite3_bind_zeroblob  0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    98
#define sqlite3_blob_bytes     0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    99
#define sqlite3_blob_close     0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   100
#define sqlite3_blob_open      0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   101
#define sqlite3_blob_read      0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   102
#define sqlite3_blob_write     0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   103
#endif
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   104
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   105
/*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   106
** The following structure contains pointers to all SQLite API routines.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   107
** A pointer to this structure is passed into extensions when they are
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   108
** loaded so that the extension can make calls back into the SQLite
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   109
** library.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   110
**
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   111
** When adding new APIs, add them to the bottom of this structure
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   112
** in order to preserve backwards compatibility.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   113
**
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   114
** Extensions that use newer APIs should first call the
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   115
** sqlite3_libversion_number() to make sure that the API they
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   116
** intend to use is supported by the library.  Extensions should
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   117
** also check to make sure that the pointer to the function is
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   118
** not NULL before calling it.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   119
*/
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   120
const sqlite3_api_routines sqlite3_apis = {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   121
  sqlite3_aggregate_context,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   122
  sqlite3_aggregate_count,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   123
  sqlite3_bind_blob,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   124
  sqlite3_bind_double,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   125
  sqlite3_bind_int,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   126
  sqlite3_bind_int64,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   127
  sqlite3_bind_null,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   128
  sqlite3_bind_parameter_count,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   129
  sqlite3_bind_parameter_index,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   130
  sqlite3_bind_parameter_name,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   131
  sqlite3_bind_text,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   132
  sqlite3_bind_text16,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   133
  sqlite3_bind_value,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   134
  sqlite3_busy_handler,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   135
  sqlite3_busy_timeout,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   136
  sqlite3_changes,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   137
  sqlite3_close,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   138
  sqlite3_collation_needed,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   139
  sqlite3_collation_needed16,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   140
  sqlite3_column_blob,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   141
  sqlite3_column_bytes,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   142
  sqlite3_column_bytes16,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   143
  sqlite3_column_count,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   144
  sqlite3_column_database_name,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   145
  sqlite3_column_database_name16,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   146
  sqlite3_column_decltype,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   147
  sqlite3_column_decltype16,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   148
  sqlite3_column_double,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   149
  sqlite3_column_int,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   150
  sqlite3_column_int64,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   151
  sqlite3_column_name,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   152
  sqlite3_column_name16,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   153
  sqlite3_column_origin_name,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   154
  sqlite3_column_origin_name16,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   155
  sqlite3_column_table_name,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   156
  sqlite3_column_table_name16,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   157
  sqlite3_column_text,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   158
  sqlite3_column_text16,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   159
  sqlite3_column_type,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   160
  sqlite3_column_value,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   161
  sqlite3_commit_hook,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   162
  sqlite3_complete,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   163
  sqlite3_complete16,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   164
  sqlite3_create_collation,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   165
  sqlite3_create_collation16,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   166
  sqlite3_create_function,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   167
  sqlite3_create_function16,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   168
  sqlite3_create_module,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   169
  sqlite3_data_count,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   170
  sqlite3_db_handle,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   171
  sqlite3_declare_vtab,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   172
  sqlite3_enable_shared_cache,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   173
  sqlite3_errcode,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   174
  sqlite3_errmsg,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   175
  sqlite3_errmsg16,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   176
  sqlite3_exec,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   177
  sqlite3_expired,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   178
  sqlite3_finalize,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   179
  sqlite3_free,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   180
  sqlite3_free_table,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   181
  sqlite3_get_autocommit,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   182
  sqlite3_get_auxdata,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   183
  sqlite3_get_table,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   184
  0,     /* Was sqlite3_global_recover(), but that function is deprecated */
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   185
  sqlite3_interrupt,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   186
  sqlite3_last_insert_rowid,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   187
  sqlite3_libversion,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   188
  sqlite3_libversion_number,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   189
  sqlite3_malloc,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   190
  sqlite3_mprintf,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   191
  sqlite3_open,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   192
  sqlite3_open16,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   193
  sqlite3_prepare,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   194
  sqlite3_prepare16,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   195
  sqlite3_profile,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   196
  sqlite3_progress_handler,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   197
  sqlite3_realloc,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   198
  sqlite3_reset,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   199
  sqlite3_result_blob,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   200
  sqlite3_result_double,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   201
  sqlite3_result_error,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   202
  sqlite3_result_error16,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   203
  sqlite3_result_int,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   204
  sqlite3_result_int64,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   205
  sqlite3_result_null,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   206
  sqlite3_result_text,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   207
  sqlite3_result_text16,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   208
  sqlite3_result_text16be,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   209
  sqlite3_result_text16le,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   210
  sqlite3_result_value,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   211
  sqlite3_rollback_hook,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   212
  sqlite3_set_authorizer,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   213
  sqlite3_set_auxdata,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   214
  sqlite3_snprintf,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   215
  sqlite3_step,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   216
  sqlite3_table_column_metadata,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   217
  sqlite3_thread_cleanup,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   218
  sqlite3_total_changes,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   219
  sqlite3_trace,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   220
  sqlite3_transfer_bindings,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   221
  sqlite3_update_hook,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   222
  sqlite3_user_data,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   223
  sqlite3_value_blob,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   224
  sqlite3_value_bytes,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   225
  sqlite3_value_bytes16,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   226
  sqlite3_value_double,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   227
  sqlite3_value_int,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   228
  sqlite3_value_int64,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   229
  sqlite3_value_numeric_type,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   230
  sqlite3_value_text,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   231
  sqlite3_value_text16,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   232
  sqlite3_value_text16be,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   233
  sqlite3_value_text16le,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   234
  sqlite3_value_type,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   235
  sqlite3_vmprintf,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   236
  /*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   237
  ** The original API set ends here.  All extensions can call any
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   238
  ** of the APIs above provided that the pointer is not NULL.  But
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   239
  ** before calling APIs that follow, extension should check the
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   240
  ** sqlite3_libversion_number() to make sure they are dealing with
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   241
  ** a library that is new enough to support that API.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   242
  *************************************************************************
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   243
  */
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   244
  sqlite3_overload_function,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   245
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   246
  /*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   247
  ** Added after 3.3.13
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   248
  */
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   249
  sqlite3_prepare_v2,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   250
  sqlite3_prepare16_v2,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   251
  sqlite3_clear_bindings,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   252
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   253
  /*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   254
  ** Added for 3.4.1
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   255
  */
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   256
  sqlite3_create_module_v2,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   257
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   258
  /*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   259
  ** Added for 3.5.0
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   260
  */
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   261
  sqlite3_bind_zeroblob,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   262
  sqlite3_blob_bytes,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   263
  sqlite3_blob_close,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   264
  sqlite3_blob_open,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   265
  sqlite3_blob_read,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   266
  sqlite3_blob_write,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   267
  sqlite3_create_collation_v2,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   268
  sqlite3_file_control,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   269
  sqlite3_memory_highwater,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   270
  sqlite3_memory_used,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   271
#ifdef SQLITE_MUTEX_NOOP
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   272
  0, 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   273
  0, 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   274
  0,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   275
  0,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   276
  0,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   277
#else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   278
  sqlite3_mutex_alloc,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   279
  sqlite3_mutex_enter,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   280
  sqlite3_mutex_free,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   281
  sqlite3_mutex_leave,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   282
  sqlite3_mutex_try,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   283
#endif
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   284
  sqlite3_open_v2,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   285
  sqlite3_release_memory,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   286
  sqlite3_result_error_nomem,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   287
  sqlite3_result_error_toobig,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   288
  sqlite3_sleep,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   289
  sqlite3_soft_heap_limit,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   290
  sqlite3_vfs_find,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   291
  sqlite3_vfs_register,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   292
  sqlite3_vfs_unregister,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   293
};
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   294
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   295
/*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   296
** Attempt to load an SQLite extension library contained in the file
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   297
** zFile.  The entry point is zProc.  zProc may be 0 in which case a
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   298
** default entry point name (sqlite3_extension_init) is used.  Use
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   299
** of the default name is recommended.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   300
**
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   301
** Return SQLITE_OK on success and SQLITE_ERROR if something goes wrong.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   302
**
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   303
** If an error occurs and pzErrMsg is not 0, then fill *pzErrMsg with 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   304
** error message text.  The calling function should free this memory
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   305
** by calling sqlite3_free().
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   306
*/
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   307
static int sqlite3LoadExtension(
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   308
  sqlite3 *db,          /* Load the extension into this database connection */
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   309
  const char *zFile,    /* Name of the shared library containing extension */
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   310
  const char *zProc,    /* Entry point.  Use "sqlite3_extension_init" if 0 */
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   311
  char **pzErrMsg       /* Put error message here if not 0 */
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   312
){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   313
  sqlite3_vfs *pVfs = db->pVfs;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   314
  void *handle;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   315
  int (*xInit)(sqlite3*,char**,const sqlite3_api_routines*);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   316
  char *zErrmsg = 0;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   317
  void **aHandle;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   318
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   319
  /* Ticket #1863.  To avoid a creating security problems for older
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   320
  ** applications that relink against newer versions of SQLite, the
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   321
  ** ability to run load_extension is turned off by default.  One
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   322
  ** must call sqlite3_enable_load_extension() to turn on extension
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   323
  ** loading.  Otherwise you get the following error.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   324
  */
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   325
  if( (db->flags & SQLITE_LoadExtension)==0 ){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   326
    if( pzErrMsg ){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   327
      *pzErrMsg = sqlite3_mprintf("not authorized");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   328
    }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   329
    return SQLITE_ERROR;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   330
  }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   331
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   332
  if( zProc==0 ){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   333
    zProc = "sqlite3_extension_init";
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   334
  }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   335
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   336
  handle = sqlite3OsDlOpen(pVfs, zFile);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   337
  if( handle==0 ){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   338
    if( pzErrMsg ){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   339
      char zErr[256];
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   340
      zErr[sizeof(zErr)-1] = '\0';
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   341
      sqlite3_snprintf(sizeof(zErr)-1, zErr, 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   342
          "unable to open shared library [%s]", zFile);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   343
      sqlite3OsDlError(pVfs, sizeof(zErr)-1, zErr);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   344
      *pzErrMsg = sqlite3DbStrDup(db, zErr);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   345
    }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   346
    return SQLITE_ERROR;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   347
  }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   348
  xInit = (int(*)(sqlite3*,char**,const sqlite3_api_routines*))
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   349
                   sqlite3OsDlSym(pVfs, handle, zProc);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   350
  if( xInit==0 ){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   351
    if( pzErrMsg ){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   352
      char zErr[256];
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   353
      zErr[sizeof(zErr)-1] = '\0';
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   354
      sqlite3_snprintf(sizeof(zErr)-1, zErr,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   355
          "no entry point [%s] in shared library [%s]", zProc,zFile);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   356
      sqlite3OsDlError(pVfs, sizeof(zErr)-1, zErr);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   357
      *pzErrMsg = sqlite3DbStrDup(db, zErr);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   358
      sqlite3OsDlClose(pVfs, handle);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   359
    }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   360
    return SQLITE_ERROR;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   361
  }else if( xInit(db, &zErrmsg, &sqlite3_apis) ){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   362
    if( pzErrMsg ){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   363
      *pzErrMsg = sqlite3_mprintf("error during initialization: %s", zErrmsg);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   364
    }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   365
    sqlite3_free(zErrmsg);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   366
    sqlite3OsDlClose(pVfs, handle);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   367
    return SQLITE_ERROR;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   368
  }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   369
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   370
  /* Append the new shared library handle to the db->aExtension array. */
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   371
  db->nExtension++;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   372
  aHandle = (void**)sqlite3DbMallocZero(db, sizeof(handle)*db->nExtension);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   373
  if( aHandle==0 ){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   374
    return SQLITE_NOMEM;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   375
  }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   376
  if( db->nExtension>0 ){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   377
    memcpy(aHandle, db->aExtension, sizeof(handle)*(db->nExtension-1));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   378
  }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   379
  sqlite3_free(db->aExtension);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   380
  db->aExtension = aHandle;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   381
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   382
  db->aExtension[db->nExtension-1] = handle;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   383
  return SQLITE_OK;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   384
}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   385
EXPORT_C int sqlite3_load_extension(
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   386
  sqlite3 *db,          /* Load the extension into this database connection */
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   387
  const char *zFile,    /* Name of the shared library containing extension */
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   388
  const char *zProc,    /* Entry point.  Use "sqlite3_extension_init" if 0 */
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   389
  char **pzErrMsg       /* Put error message here if not 0 */
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   390
){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   391
  int rc;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   392
  sqlite3_mutex_enter(db->mutex);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   393
  rc = sqlite3LoadExtension(db, zFile, zProc, pzErrMsg);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   394
  sqlite3_mutex_leave(db->mutex);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   395
  return rc;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   396
}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   397
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   398
/*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   399
** Call this routine when the database connection is closing in order
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   400
** to clean up loaded extensions
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   401
*/
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   402
void sqlite3CloseExtensions(sqlite3 *db){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   403
  int i;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   404
  assert( sqlite3_mutex_held(db->mutex) );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   405
  for(i=0; i<db->nExtension; i++){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   406
    sqlite3OsDlClose(db->pVfs, db->aExtension[i]);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   407
  }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   408
  sqlite3_free(db->aExtension);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   409
}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   410
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   411
/*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   412
** Enable or disable extension loading.  Extension loading is disabled by
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   413
** default so as not to open security holes in older applications.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   414
*/
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   415
EXPORT_C int sqlite3_enable_load_extension(sqlite3 *db, int onoff){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   416
  sqlite3_mutex_enter(db->mutex);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   417
  if( onoff ){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   418
    db->flags |= SQLITE_LoadExtension;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   419
  }else{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   420
    db->flags &= ~SQLITE_LoadExtension;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   421
  }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   422
  sqlite3_mutex_leave(db->mutex);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   423
  return SQLITE_OK;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   424
}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   425
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   426
/*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   427
** The following object holds the list of automatically loaded
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   428
** extensions.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   429
**
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   430
** This list is shared across threads.  The SQLITE_MUTEX_STATIC_MASTER
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   431
** mutex must be held while accessing this list.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   432
*/
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   433
static struct {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   434
  int nExt;        /* Number of entries in aExt[] */          
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   435
  void **aExt;     /* Pointers to the extension init functions */
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   436
} autoext = { 0, 0 };
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   437
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   438
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   439
/*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   440
** Register a statically linked extension that is automatically
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   441
** loaded by every new database connection.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   442
*/
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   443
EXPORT_C int sqlite3_auto_extension(void *xInit){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   444
  int i;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   445
  int rc = SQLITE_OK;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   446
  sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   447
  sqlite3_mutex_enter(mutex);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   448
  for(i=0; i<autoext.nExt; i++){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   449
    if( autoext.aExt[i]==xInit ) break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   450
  }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   451
  if( i==autoext.nExt ){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   452
    int nByte = (autoext.nExt+1)*sizeof(autoext.aExt[0]);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   453
    void **aNew;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   454
    aNew = (void**)sqlite3_realloc(autoext.aExt, nByte);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   455
    if( aNew==0 ){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   456
      rc = SQLITE_NOMEM;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   457
    }else{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   458
      autoext.aExt = aNew;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   459
      autoext.aExt[autoext.nExt] = xInit;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   460
      autoext.nExt++;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   461
    }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   462
  }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   463
  sqlite3_mutex_leave(mutex);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   464
  assert( (rc&0xff)==rc );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   465
  return rc;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   466
}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   467
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   468
/*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   469
** Reset the automatic extension loading mechanism.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   470
*/
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   471
EXPORT_C void sqlite3_reset_auto_extension(void){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   472
  sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   473
  sqlite3_mutex_enter(mutex);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   474
  sqlite3_free(autoext.aExt);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   475
  autoext.aExt = 0;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   476
  autoext.nExt = 0;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   477
  sqlite3_mutex_leave(mutex);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   478
}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   479
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   480
/*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   481
** Load all automatic extensions.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   482
*/
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   483
int sqlite3AutoLoadExtensions(sqlite3 *db){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   484
  int i;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   485
  int go = 1;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   486
  int rc = SQLITE_OK;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   487
  int (*xInit)(sqlite3*,char**,const sqlite3_api_routines*);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   488
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   489
  if( autoext.nExt==0 ){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   490
    /* Common case: early out without every having to acquire a mutex */
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   491
    return SQLITE_OK;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   492
  }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   493
  for(i=0; go; i++){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   494
    char *zErrmsg = 0;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   495
    sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   496
    sqlite3_mutex_enter(mutex);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   497
    if( i>=autoext.nExt ){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   498
      xInit = 0;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   499
      go = 0;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   500
    }else{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   501
      xInit = (int(*)(sqlite3*,char**,const sqlite3_api_routines*))
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   502
              autoext.aExt[i];
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   503
    }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   504
    sqlite3_mutex_leave(mutex);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   505
    if( xInit && xInit(db, &zErrmsg, &sqlite3_apis) ){
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   506
      sqlite3Error(db, SQLITE_ERROR,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   507
            "automatic extension loading failed: %s", zErrmsg);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   508
      go = 0;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   509
      rc = SQLITE_ERROR;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   510
      sqlite3_free(zErrmsg);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   511
    }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   512
  }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   513
  return rc;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   514
}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   515
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   516
#endif /* SQLITE_OMIT_LOAD_EXTENSION */