sqlite3: Implement some auxiliary functions

This adds `sqlite3_libversion()`, `sqlite3_libversion_number()`, and
`libsql3_threadsafe()`.
This commit is contained in:
Pekka Enberg 2024-07-17 12:53:55 +03:00
parent a08051b106
commit af7b8b6768
4 changed files with 21 additions and 3 deletions

View file

@ -773,15 +773,17 @@ pub unsafe extern "C" fn sqlite3_complete(_sql: *const std::ffi::c_char) -> ffi:
#[no_mangle]
pub unsafe extern "C" fn sqlite3_threadsafe() -> ffi::c_int {
todo!();
1
}
#[no_mangle]
pub unsafe extern "C" fn sqlite3_libversion() -> *const std::ffi::c_char {
todo!();
ffi::CStr::from_bytes_with_nul(b"3.42.0\0")
.unwrap()
.as_ptr()
}
#[no_mangle]
pub unsafe extern "C" fn sqlite3_libversion_number() -> ffi::c_int {
todo!();
3042000
}

View file

@ -15,6 +15,7 @@ CFLAGS = -g -Wall -std=c17 -MMD -MP
LIBS ?= -lsqlite3
OBJS += main.o
OBJS += test-aux.o
OBJS += test-close.o
OBJS += test-open.o
OBJS += test-prepare.o

View file

@ -1,3 +1,5 @@
extern void test_libversion();
extern void test_libversion_number();
extern void test_open_misuse();
extern void test_open_not_found();
extern void test_open_existing();
@ -6,6 +8,8 @@ extern void test_prepare_misuse();
int main(int argc, char *argv[])
{
test_libversion();
test_libversion_number();
test_open_misuse();
test_open_not_found();
test_open_existing();

11
sqlite3/tests/test-aux.c Normal file
View file

@ -0,0 +1,11 @@
#include "check.h"
#include <sqlite3.h>
void test_libversion(void) {
sqlite3_libversion();
}
void test_libversion_number(void) {
sqlite3_libversion_number();
}