aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/sqlite/unix/sqlite-3.5.1/src/test_autoext.c
diff options
context:
space:
mode:
authordan miller2007-10-21 08:36:32 +0000
committerdan miller2007-10-21 08:36:32 +0000
commit2f8d7092bc2c9609fa98d6888106b96f38b22828 (patch)
treeda6c37579258cc965b52a75aee6135fe44237698 /libraries/sqlite/unix/sqlite-3.5.1/src/test_autoext.c
parent* Committing new PolicyManager based on an ACL system. (diff)
downloadopensim-SC-2f8d7092bc2c9609fa98d6888106b96f38b22828.zip
opensim-SC-2f8d7092bc2c9609fa98d6888106b96f38b22828.tar.gz
opensim-SC-2f8d7092bc2c9609fa98d6888106b96f38b22828.tar.bz2
opensim-SC-2f8d7092bc2c9609fa98d6888106b96f38b22828.tar.xz
libraries moved to opensim-libs, a new repository
Diffstat (limited to 'libraries/sqlite/unix/sqlite-3.5.1/src/test_autoext.c')
-rw-r--r--libraries/sqlite/unix/sqlite-3.5.1/src/test_autoext.c164
1 files changed, 0 insertions, 164 deletions
diff --git a/libraries/sqlite/unix/sqlite-3.5.1/src/test_autoext.c b/libraries/sqlite/unix/sqlite-3.5.1/src/test_autoext.c
deleted file mode 100644
index 0eaeda0..0000000
--- a/libraries/sqlite/unix/sqlite-3.5.1/src/test_autoext.c
+++ /dev/null
@@ -1,164 +0,0 @@
1/*
2** 2006 August 23
3**
4** The author disclaims copyright to this source code. In place of
5** a legal notice, here is a blessing:
6**
7** May you do good and not evil.
8** May you find forgiveness for yourself and forgive others.
9** May you share freely, never taking more than you give.
10**
11*************************************************************************
12** Test extension for testing the sqlite3_auto_extension() function.
13**
14** $Id: test_autoext.c,v 1.2 2006/12/19 18:57:11 drh Exp $
15*/
16#include "tcl.h"
17#ifndef SQLITE_OMIT_LOAD_EXTENSION
18#include "sqlite3ext.h"
19static SQLITE_EXTENSION_INIT1
20
21/*
22** The sqr() SQL function returns the square of its input value.
23*/
24static void sqrFunc(
25 sqlite3_context *context,
26 int argc,
27 sqlite3_value **argv
28){
29 double r = sqlite3_value_double(argv[0]);
30 sqlite3_result_double(context, r*r);
31}
32
33/*
34** This is the entry point to register the extension for the sqr() function.
35*/
36static int sqr_init(
37 sqlite3 *db,
38 char **pzErrMsg,
39 const sqlite3_api_routines *pApi
40){
41 SQLITE_EXTENSION_INIT2(pApi);
42 sqlite3_create_function(db, "sqr", 1, SQLITE_ANY, 0, sqrFunc, 0, 0);
43 return 0;
44}
45
46/*
47** The cube() SQL function returns the cube of its input value.
48*/
49static void cubeFunc(
50 sqlite3_context *context,
51 int argc,
52 sqlite3_value **argv
53){
54 double r = sqlite3_value_double(argv[0]);
55 sqlite3_result_double(context, r*r*r);
56}
57
58/*
59** This is the entry point to register the extension for the cube() function.
60*/
61static int cube_init(
62 sqlite3 *db,
63 char **pzErrMsg,
64 const sqlite3_api_routines *pApi
65){
66 SQLITE_EXTENSION_INIT2(pApi);
67 sqlite3_create_function(db, "cube", 1, SQLITE_ANY, 0, cubeFunc, 0, 0);
68 return 0;
69}
70
71/*
72** This is a broken extension entry point
73*/
74static int broken_init(
75 sqlite3 *db,
76 char **pzErrMsg,
77 const sqlite3_api_routines *pApi
78){
79 char *zErr;
80 SQLITE_EXTENSION_INIT2(pApi);
81 zErr = sqlite3_mprintf("broken autoext!");
82 *pzErrMsg = zErr;
83 return 1;
84}
85
86/*
87** tclcmd: sqlite3_auto_extension_sqr
88**
89** Register the "sqr" extension to be loaded automatically.
90*/
91static int autoExtSqrObjCmd(
92 void * clientData,
93 Tcl_Interp *interp,
94 int objc,
95 Tcl_Obj *CONST objv[]
96){
97 sqlite3_auto_extension((void*)sqr_init);
98 return SQLITE_OK;
99}
100
101/*
102** tclcmd: sqlite3_auto_extension_cube
103**
104** Register the "cube" extension to be loaded automatically.
105*/
106static int autoExtCubeObjCmd(
107 void * clientData,
108 Tcl_Interp *interp,
109 int objc,
110 Tcl_Obj *CONST objv[]
111){
112 sqlite3_auto_extension((void*)cube_init);
113 return SQLITE_OK;
114}
115
116/*
117** tclcmd: sqlite3_auto_extension_broken
118**
119** Register the broken extension to be loaded automatically.
120*/
121static int autoExtBrokenObjCmd(
122 void * clientData,
123 Tcl_Interp *interp,
124 int objc,
125 Tcl_Obj *CONST objv[]
126){
127 sqlite3_auto_extension((void*)broken_init);
128 return SQLITE_OK;
129}
130
131/*
132** tclcmd: sqlite3_reset_auto_extension
133**
134** Reset all auto-extensions
135*/
136static int resetAutoExtObjCmd(
137 void * clientData,
138 Tcl_Interp *interp,
139 int objc,
140 Tcl_Obj *CONST objv[]
141){
142 sqlite3_reset_auto_extension();
143 return SQLITE_OK;
144}
145
146
147#endif /* SQLITE_OMIT_LOAD_EXTENSION */
148
149/*
150** This procedure registers the TCL procs defined in this file.
151*/
152int Sqlitetest_autoext_Init(Tcl_Interp *interp){
153#ifndef SQLITE_OMIT_LOAD_EXTENSION
154 Tcl_CreateObjCommand(interp, "sqlite3_auto_extension_sqr",
155 autoExtSqrObjCmd, 0, 0);
156 Tcl_CreateObjCommand(interp, "sqlite3_auto_extension_cube",
157 autoExtCubeObjCmd, 0, 0);
158 Tcl_CreateObjCommand(interp, "sqlite3_auto_extension_broken",
159 autoExtBrokenObjCmd, 0, 0);
160 Tcl_CreateObjCommand(interp, "sqlite3_reset_auto_extension",
161 resetAutoExtObjCmd, 0, 0);
162#endif
163 return TCL_OK;
164}