1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Add API functions sqlite3_open_varargs(), sqlite3_open16_varargs() and

sqlite3_complete16(). (CVS 1479)

FossilOrigin-Name: 203af2b2e3a25f4fe0e128e350c21834cad0bd7f
This commit is contained in:
danielk1977
2004-05-27 23:56:16 +00:00
parent d3194f5a4a
commit 61de0d1b99
7 changed files with 138 additions and 21 deletions

View File

@@ -14,7 +14,7 @@
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
** $Id: main.c,v 1.194 2004/05/26 16:54:43 drh Exp $
** $Id: main.c,v 1.195 2004/05/27 23:56:16 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@@ -1101,6 +1101,88 @@ int sqlite3_open16(
return rc;
}
/*
** Open a new database handle.
*/
int sqlite3_open_vararg(
const char *filename, /* Database filename (UTF-8) */
sqlite3 **ppDb, /* OUT: SQLite db handle */
... /* Option strings */
){
va_list ap;
const char **aOpts = 0;
int nOpts = 0;
int rc;
/* Count the arguments */
va_start(ap, ppDb);
while( va_arg(ap, const char *) ) nOpts++;
va_end(ap);
/* If there are more than zero arguments, construct an array */
if( nOpts ){
aOpts = (const char **)sqliteMalloc(sizeof(const char *)*nOpts+1);
if( !aOpts ){
*ppDb = 0;
return SQLITE_NOMEM;
}
va_start(ap, ppDb);
nOpts = 0;
while( va_arg(ap, const char *) ){
aOpts[nOpts] = va_arg(ap, const char *);
nOpts++;
}
aOpts[nOpts] = 0;
va_end(ap);
}
/* Call the regular sqlite3_open() */
rc = sqlite3_open(filename, ppDb, aOpts);
if( aOpts ) sqliteFree(aOpts);
return rc;
}
/*
** Open a new database handle.
*/
int sqlite3_open16_vararg(
const void *filename, /* Database filename (UTF-16) */
sqlite3 **ppDb, /* OUT: SQLite db handle */
... /* Option strings */
){
va_list ap;
const char **aOpts = 0;
int nOpts = 0;
int rc;
/* Count the arguments */
va_start(ap, ppDb);
while( va_arg(ap, const char *) ) nOpts++;
va_end(ap);
/* If there are more than zero arguments, construct an array */
if( nOpts ){
aOpts = (const char **)sqliteMalloc(sizeof(const char *)*nOpts+1);
if( !aOpts ){
*ppDb = 0;
return SQLITE_NOMEM;
}
va_start(ap, ppDb);
nOpts = 0;
while( va_arg(ap, const char *) ){
aOpts[nOpts] = va_arg(ap, const char *);
nOpts++;
}
aOpts[nOpts] = 0;
va_end(ap);
}
/* Call the regular sqlite3_open16() */
rc = sqlite3_open16(filename, ppDb, aOpts);
if( aOpts ) sqliteFree(aOpts);
return rc;
}
/*
** The following routine destroys a virtual machine that is created by
** the sqlite3_compile() routine. The integer returned is an SQLITE_