mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-01 06:27:03 +03:00
Change the src/shell.c file so that it is generated from a new script at
tool/mkshellc.tcl and the template file src/shell.c.in, and automatically includes the extensions it needs out of ext/misc. FossilOrigin-Name: 17e0bb12d82b510b86b6886b9fd0faf39b60b1374027344f89d7b89a32b842b9
This commit is contained in:
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\sa\sbackup2\stest\scase\sso\sthat\sit\sworks\son\sFreeBSD.
|
||||
D 2017-07-11T02:53:38.630
|
||||
C Change\sthe\ssrc/shell.c\sfile\sso\sthat\sit\sis\sgenerated\sfrom\sa\snew\sscript\sat\ntool/mkshellc.tcl\sand\sthe\stemplate\sfile\ssrc/shell.c.in,\sand\sautomatically\nincludes\sthe\sextensions\sit\sneeds\sout\sof\sext/misc.
|
||||
D 2017-07-11T13:34:40.462
|
||||
F Makefile.in 081e48dfe7f995d57ce1a88ddf4d2917b4349158648a6cd45b42beae30de3a12
|
||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||
F Makefile.msc 20850e3e8d4d4791e0531955852d768eb06f24138214870d543abb1a47346fba
|
||||
@ -450,7 +450,8 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384
|
||||
F src/resolve.c 6aa1fb1212e601f65b983ee1215d69a591986c8f97a3805c425c625a53839539
|
||||
F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac
|
||||
F src/select.c 6aa7e8ee53dcb9d0b77b05670bb44a1076d6747bc9b2c1f12a365b553ab6c828
|
||||
F src/shell.c c042ed1f74e80097f7a322bb05457d65c20e1df43459f065f76ad886da7331e0
|
||||
F src/shell.c 71a338b3a29502a4a7290fa646bc4547d911777aba55ebc040b5940786435833
|
||||
F src/shell.c.in 9d75c83c13fb1b96e60c56cce96146d84c4c8b3d18d11bd85e0759ebf744bcb2
|
||||
F src/sqlite.h.in 03a422ba13da1dfef7f1aaa1ba344acf18dc867112620b1fdb2a1426cabba634
|
||||
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
||||
F src/sqlite3ext.h 58fd0676d3111d02e62e5a35992a7d3da5d3f88753acc174f2d37b774fbbdd28
|
||||
@ -1568,6 +1569,7 @@ F tool/mkopcodec.tcl d1b6362bd3aa80d5520d4d6f3765badf01f6c43c
|
||||
F tool/mkopcodeh.tcl a01d2c1d8a6205b03fc635adf3735b4c523befd3
|
||||
F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e
|
||||
F tool/mkpragmatab.tcl 2144bc8550a6471a029db262a132d2df4b9e0db61b90398bf64f5b7b3f8d92cd
|
||||
F tool/mkshellc.tcl 69c38ecd7b74b2b0799a35ce20e1e3998e504d8c99c100ca4b98ae9d8f6279bc
|
||||
F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97
|
||||
F tool/mksqlite3c-noext.tcl fef88397668ae83166735c41af99d79f56afaabb
|
||||
F tool/mksqlite3c.tcl f6214285bec900d28441366ca31af327aade18bbc424b0480497966ec05bc43c
|
||||
@ -1629,7 +1631,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P 0e2135552757cc6566ac959475d3b87254b6d462425ee6c457c743001f3370e2
|
||||
R 07f4dd76f51d4ef1e51aa1dac340573b
|
||||
P 724819b456ca7a5ca6d68415b3b3554741c3ddbb5c416cb6b6b5fc54177f426e
|
||||
R 60a762ef308a5ae7a380cb2ce07b0a0c
|
||||
U drh
|
||||
Z 31bd69a2dcea4c4a51c6ef1c3a8fdda1
|
||||
Z 1a54bd7eb9eb8ff312901d65383e16cf
|
||||
|
@ -1 +1 @@
|
||||
724819b456ca7a5ca6d68415b3b3554741c3ddbb5c416cb6b6b5fc54177f426e
|
||||
17e0bb12d82b510b86b6886b9fd0faf39b60b1374027344f89d7b89a32b842b9
|
277
src/shell.c
277
src/shell.c
@ -1,3 +1,21 @@
|
||||
/* DO NOT EDIT!
|
||||
** This file is automatically generated by the script in the canonical
|
||||
** SQLite source tree at tool/mkshellc.tcl. That script combines source
|
||||
** code from various constituent source files of SQLite into this single
|
||||
** "shell.c" file used to implement the SQLite command-line shell.
|
||||
**
|
||||
** Most of the code found below comes from the "src/shell.c.in" file in
|
||||
** the canonical SQLite source tree. That main file contains "INCLUDE"
|
||||
** lines that specify other files in the canonical source tree that are
|
||||
** inserted to getnerate this complete program source file.
|
||||
**
|
||||
** The code from multiple files is combined into this single "shell.c"
|
||||
** source file to help make the command-line program easier to compile.
|
||||
**
|
||||
** To modify this program, get a copy of the canonical SQLite source tree,
|
||||
** edit the src/shell.c.in" and/or some of the other files that are included
|
||||
** by "src/shell.c.in", then rerun the tool/mkshellc.tcl script.
|
||||
*/
|
||||
/*
|
||||
** 2001 September 15
|
||||
**
|
||||
@ -784,10 +802,53 @@ static void shellAddSchemaName(
|
||||
sqlite3_result_value(pCtx, apVal[0]);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
** SHA3 hash implementation copied from ../ext/misc/shathree.c
|
||||
/*
|
||||
** The source code for several run-time loadable extensions is inserted
|
||||
** below by the ../tool/mkshellc.tcl script. Before processing that included
|
||||
** code, we need to override some macros to make the included program code
|
||||
** work here in the middle of this regular program.
|
||||
*/
|
||||
#define SQLITE_EXTENSION_INIT1
|
||||
#define SQLITE_EXTENSION_INIT2(X)
|
||||
|
||||
/************************* Begin ../ext/misc/shathree.c ******************/
|
||||
/*
|
||||
** 2017-03-08
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
******************************************************************************
|
||||
**
|
||||
** This SQLite extension implements a functions that compute SHA1 hashes.
|
||||
** Two SQL functions are implemented:
|
||||
**
|
||||
** sha3(X,SIZE)
|
||||
** sha3_query(Y,SIZE)
|
||||
**
|
||||
** The sha3(X) function computes the SHA3 hash of the input X, or NULL if
|
||||
** X is NULL.
|
||||
**
|
||||
** The sha3_query(Y) function evalutes all queries in the SQL statements of Y
|
||||
** and returns a hash of their results.
|
||||
**
|
||||
** The SIZE argument is optional. If omitted, the SHA3-256 hash algorithm
|
||||
** is used. If SIZE is included it must be one of the integers 224, 256,
|
||||
** 384, or 512, to determine SHA3 hash variant that is computed.
|
||||
*/
|
||||
SQLITE_EXTENSION_INIT1
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
typedef sqlite3_uint64 u64;
|
||||
|
||||
/******************************************************************************
|
||||
** The Hash Engine
|
||||
*/
|
||||
/*
|
||||
** Macros to determine whether the machine is big or little endian,
|
||||
** and whether or not that determination is run-time or compile-time.
|
||||
@ -825,10 +886,6 @@ struct SHA3Context {
|
||||
unsigned ixMask; /* Insert next input into u.x[nLoaded^ixMask]. */
|
||||
};
|
||||
|
||||
/* Allow the following routine to use the B0 variable, which is also
|
||||
** a macro in the termios.h header file */
|
||||
#undef B0
|
||||
|
||||
/*
|
||||
** A single step of the Keccak mixing function for a 1600-bit state
|
||||
*/
|
||||
@ -1239,6 +1296,8 @@ static unsigned char *SHA3Final(SHA3Context *p){
|
||||
}
|
||||
return &p->u.x[p->nRate];
|
||||
}
|
||||
/* End of the hashing logic
|
||||
*****************************************************************************/
|
||||
|
||||
/*
|
||||
** Implementation of the sha3(X,SIZE) function.
|
||||
@ -1375,10 +1434,6 @@ static void sha3QueryFunc(
|
||||
}
|
||||
nCol = sqlite3_column_count(pStmt);
|
||||
z = sqlite3_sql(pStmt);
|
||||
if( z==0 ){
|
||||
sqlite3_finalize(pStmt);
|
||||
continue;
|
||||
}
|
||||
n = (int)strlen(z);
|
||||
hash_step_vformat(&cx,"S%d:",n);
|
||||
SHA3Update(&cx,(unsigned char*)z,n);
|
||||
@ -1441,8 +1496,139 @@ static void sha3QueryFunc(
|
||||
}
|
||||
sqlite3_result_blob(context, SHA3Final(&cx), iSize/8, SQLITE_TRANSIENT);
|
||||
}
|
||||
/* End of SHA3 hashing logic copy/pasted from ../ext/misc/shathree.c
|
||||
********************************************************************************/
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
__declspec(dllexport)
|
||||
#endif
|
||||
int sqlite3_shathree_init(
|
||||
sqlite3 *db,
|
||||
char **pzErrMsg,
|
||||
const sqlite3_api_routines *pApi
|
||||
){
|
||||
int rc = SQLITE_OK;
|
||||
SQLITE_EXTENSION_INIT2(pApi);
|
||||
(void)pzErrMsg; /* Unused parameter */
|
||||
rc = sqlite3_create_function(db, "sha3", 1, SQLITE_UTF8, 0,
|
||||
sha3Func, 0, 0);
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = sqlite3_create_function(db, "sha3", 2, SQLITE_UTF8, 0,
|
||||
sha3Func, 0, 0);
|
||||
}
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = sqlite3_create_function(db, "sha3_query", 1, SQLITE_UTF8, 0,
|
||||
sha3QueryFunc, 0, 0);
|
||||
}
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = sqlite3_create_function(db, "sha3_query", 2, SQLITE_UTF8, 0,
|
||||
sha3QueryFunc, 0, 0);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/************************* End ../ext/misc/shathree.c ********************/
|
||||
/************************* Begin ../ext/misc/fileio.c ******************/
|
||||
/*
|
||||
** 2014-06-13
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
******************************************************************************
|
||||
**
|
||||
** This SQLite extension implements SQL functions readfile() and
|
||||
** writefile().
|
||||
*/
|
||||
SQLITE_EXTENSION_INIT1
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
** Implementation of the "readfile(X)" SQL function. The entire content
|
||||
** of the file named X is read and returned as a BLOB. NULL is returned
|
||||
** if the file does not exist or is unreadable.
|
||||
*/
|
||||
static void readfileFunc(
|
||||
sqlite3_context *context,
|
||||
int argc,
|
||||
sqlite3_value **argv
|
||||
){
|
||||
const char *zName;
|
||||
FILE *in;
|
||||
long nIn;
|
||||
void *pBuf;
|
||||
|
||||
zName = (const char*)sqlite3_value_text(argv[0]);
|
||||
if( zName==0 ) return;
|
||||
in = fopen(zName, "rb");
|
||||
if( in==0 ) return;
|
||||
fseek(in, 0, SEEK_END);
|
||||
nIn = ftell(in);
|
||||
rewind(in);
|
||||
pBuf = sqlite3_malloc( nIn );
|
||||
if( pBuf && 1==fread(pBuf, nIn, 1, in) ){
|
||||
sqlite3_result_blob(context, pBuf, nIn, sqlite3_free);
|
||||
}else{
|
||||
sqlite3_free(pBuf);
|
||||
}
|
||||
fclose(in);
|
||||
}
|
||||
|
||||
/*
|
||||
** Implementation of the "writefile(X,Y)" SQL function. The argument Y
|
||||
** is written into file X. The number of bytes written is returned. Or
|
||||
** NULL is returned if something goes wrong, such as being unable to open
|
||||
** file X for writing.
|
||||
*/
|
||||
static void writefileFunc(
|
||||
sqlite3_context *context,
|
||||
int argc,
|
||||
sqlite3_value **argv
|
||||
){
|
||||
FILE *out;
|
||||
const char *z;
|
||||
sqlite3_int64 rc;
|
||||
const char *zFile;
|
||||
|
||||
zFile = (const char*)sqlite3_value_text(argv[0]);
|
||||
if( zFile==0 ) return;
|
||||
out = fopen(zFile, "wb");
|
||||
if( out==0 ) return;
|
||||
z = (const char*)sqlite3_value_blob(argv[1]);
|
||||
if( z==0 ){
|
||||
rc = 0;
|
||||
}else{
|
||||
rc = fwrite(z, 1, sqlite3_value_bytes(argv[1]), out);
|
||||
}
|
||||
fclose(out);
|
||||
sqlite3_result_int64(context, rc);
|
||||
}
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
__declspec(dllexport)
|
||||
#endif
|
||||
int sqlite3_fileio_init(
|
||||
sqlite3 *db,
|
||||
char **pzErrMsg,
|
||||
const sqlite3_api_routines *pApi
|
||||
){
|
||||
int rc = SQLITE_OK;
|
||||
SQLITE_EXTENSION_INIT2(pApi);
|
||||
(void)pzErrMsg; /* Unused parameter */
|
||||
rc = sqlite3_create_function(db, "readfile", 1, SQLITE_UTF8, 0,
|
||||
readfileFunc, 0, 0);
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = sqlite3_create_function(db, "writefile", 2, SQLITE_UTF8, 0,
|
||||
writefileFunc, 0, 0);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/************************* End ../ext/misc/fileio.c ********************/
|
||||
|
||||
#if defined(SQLITE_ENABLE_SESSION)
|
||||
/*
|
||||
@ -3471,58 +3657,6 @@ static char *readFile(const char *zName, int *pnByte){
|
||||
return pBuf;
|
||||
}
|
||||
|
||||
/*
|
||||
** Implementation of the "readfile(X)" SQL function. The entire content
|
||||
** of the file named X is read and returned as a BLOB. NULL is returned
|
||||
** if the file does not exist or is unreadable.
|
||||
*/
|
||||
static void readfileFunc(
|
||||
sqlite3_context *context,
|
||||
int argc,
|
||||
sqlite3_value **argv
|
||||
){
|
||||
const char *zName;
|
||||
void *pBuf;
|
||||
int nBuf;
|
||||
|
||||
UNUSED_PARAMETER(argc);
|
||||
zName = (const char*)sqlite3_value_text(argv[0]);
|
||||
if( zName==0 ) return;
|
||||
pBuf = readFile(zName, &nBuf);
|
||||
if( pBuf ) sqlite3_result_blob(context, pBuf, nBuf, sqlite3_free);
|
||||
}
|
||||
|
||||
/*
|
||||
** Implementation of the "writefile(X,Y)" SQL function. The argument Y
|
||||
** is written into file X. The number of bytes written is returned. Or
|
||||
** NULL is returned if something goes wrong, such as being unable to open
|
||||
** file X for writing.
|
||||
*/
|
||||
static void writefileFunc(
|
||||
sqlite3_context *context,
|
||||
int argc,
|
||||
sqlite3_value **argv
|
||||
){
|
||||
FILE *out;
|
||||
const char *z;
|
||||
sqlite3_int64 rc;
|
||||
const char *zFile;
|
||||
|
||||
UNUSED_PARAMETER(argc);
|
||||
zFile = (const char*)sqlite3_value_text(argv[0]);
|
||||
if( zFile==0 ) return;
|
||||
out = fopen(zFile, "wb");
|
||||
if( out==0 ) return;
|
||||
z = (const char*)sqlite3_value_blob(argv[1]);
|
||||
if( z==0 ){
|
||||
rc = 0;
|
||||
}else{
|
||||
rc = fwrite(z, 1, sqlite3_value_bytes(argv[1]), out);
|
||||
}
|
||||
fclose(out);
|
||||
sqlite3_result_int64(context, rc);
|
||||
}
|
||||
|
||||
#if defined(SQLITE_ENABLE_SESSION)
|
||||
/*
|
||||
** Close a single OpenSession object and release all of its associated
|
||||
@ -3588,18 +3722,8 @@ static void open_db(ShellState *p, int keepAlive){
|
||||
#ifndef SQLITE_OMIT_LOAD_EXTENSION
|
||||
sqlite3_enable_load_extension(p->db, 1);
|
||||
#endif
|
||||
sqlite3_create_function(p->db, "readfile", 1, SQLITE_UTF8, 0,
|
||||
readfileFunc, 0, 0);
|
||||
sqlite3_create_function(p->db, "writefile", 2, SQLITE_UTF8, 0,
|
||||
writefileFunc, 0, 0);
|
||||
sqlite3_create_function(p->db, "sha3", 1, SQLITE_UTF8, 0,
|
||||
sha3Func, 0, 0);
|
||||
sqlite3_create_function(p->db, "sha3", 2, SQLITE_UTF8, 0,
|
||||
sha3Func, 0, 0);
|
||||
sqlite3_create_function(p->db, "sha3_query", 1, SQLITE_UTF8, 0,
|
||||
sha3QueryFunc, 0, 0);
|
||||
sqlite3_create_function(p->db, "sha3_query", 2, SQLITE_UTF8, 0,
|
||||
sha3QueryFunc, 0, 0);
|
||||
sqlite3_fileio_init(p->db, 0, 0);
|
||||
sqlite3_shathree_init(p->db, 0, 0);
|
||||
sqlite3_create_function(p->db, "shell_add_schema", 2, SQLITE_UTF8, 0,
|
||||
shellAddSchemaName, 0, 0);
|
||||
|
||||
@ -7676,3 +7800,4 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
|
||||
#endif
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
6968
src/shell.c.in
Normal file
6968
src/shell.c.in
Normal file
File diff suppressed because it is too large
Load Diff
46
tool/mkshellc.tcl
Normal file
46
tool/mkshellc.tcl
Normal file
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/tclsh
|
||||
#
|
||||
# Run this script to generate the "src/shell.c" source file from
|
||||
# constituent parts.
|
||||
#
|
||||
set topdir [file dir [file dir [file normal $argv0]]]
|
||||
puts "Overwriting $topdir/src/shell.c with new shell source code..."
|
||||
set out [open $topdir/src/shell.c wb]
|
||||
puts $out {/* DO NOT EDIT!
|
||||
** This file is automatically generated by the script in the canonical
|
||||
** SQLite source tree at tool/mkshellc.tcl. That script combines source
|
||||
** code from various constituent source files of SQLite into this single
|
||||
** "shell.c" file used to implement the SQLite command-line shell.
|
||||
**
|
||||
** Most of the code found below comes from the "src/shell.c.in" file in
|
||||
** the canonical SQLite source tree. That main file contains "INCLUDE"
|
||||
** lines that specify other files in the canonical source tree that are
|
||||
** inserted to getnerate this complete program source file.
|
||||
**
|
||||
** The code from multiple files is combined into this single "shell.c"
|
||||
** source file to help make the command-line program easier to compile.
|
||||
**
|
||||
** To modify this program, get a copy of the canonical SQLite source tree,
|
||||
** edit the src/shell.c.in" and/or some of the other files that are included
|
||||
** by "src/shell.c.in", then rerun the tool/mkshellc.tcl script.
|
||||
*/}
|
||||
set in [open $topdir/src/shell.c.in rb]
|
||||
while {![eof $in]} {
|
||||
set lx [gets $in]
|
||||
if {[regexp {^INCLUDE } $lx]} {
|
||||
set cfile [lindex $lx 1]
|
||||
puts $out "/************************* Begin $cfile ******************/"
|
||||
set in2 [open $topdir/src/$cfile rb]
|
||||
while {![eof $in2]} {
|
||||
set lx [gets $in2]
|
||||
if {[regexp {^#include "sqlite} $lx]} continue
|
||||
puts $out $lx
|
||||
}
|
||||
close $in2
|
||||
puts $out "/************************* End $cfile ********************/"
|
||||
continue
|
||||
}
|
||||
puts $out $lx
|
||||
}
|
||||
close $in
|
||||
close $out
|
Reference in New Issue
Block a user