Skip to content

Commit

Permalink
refactor(sys): solve taos_option core
Browse files Browse the repository at this point in the history
  • Loading branch information
qevolg committed Dec 30, 2024
1 parent e4d5f8d commit b009e87
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
5 changes: 2 additions & 3 deletions taos-ws-sys/src/native/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![allow(unused_variables)]

use std::ffi::{c_char, c_int, c_void, CStr, VaList};
use std::ffi::{c_char, c_int, c_void, CStr};
use std::ptr::{null, null_mut};
use std::sync::RwLock;

Expand Down Expand Up @@ -134,13 +134,12 @@ pub enum TSDB_OPTION {

static PARAMS: Lazy<RwLock<String>> = Lazy::new(|| RwLock::new(String::new()));

// todo
#[allow(clippy::just_underscores_and_digits)]
#[no_mangle]
pub unsafe extern "C" fn taos_options(
option: TSDB_OPTION,
arg: *const c_void,
mut varargs: VaList,
mut varargs: ...
) -> c_int {
let mut params = Vec::new();

Expand Down
4 changes: 2 additions & 2 deletions taos-ws-sys/src/native/stub.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![allow(unused_variables)]

use std::ffi::{c_char, c_int, c_ulong, c_void, VaList};
use std::ffi::{c_char, c_int, c_ulong, c_void};

use super::query::{__taos_async_fn_t, TAOS_FIELD};
use super::stmt::TAOS_FIELD_E;
Expand Down Expand Up @@ -31,7 +31,7 @@ pub unsafe extern "C" fn taos_options_connection(
taos: *mut TAOS,
option: TSDB_OPTION_CONNECTION,
arg: *const c_void,
varargs: VaList,
varargs: ...
) -> c_int {
todo!()
}
Expand Down
6 changes: 4 additions & 2 deletions taos-ws-sys/tests/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FLAGS=-I. -I../../target/debug/ -L. -L../../target/debug/ -ltaosws
DEBUG_PATH=../../target/debug
FLAGS=-I${DEBUG_PATH} -L${DEBUG_PATH} -Wl,-rpath=${DEBUG_PATH} -ltaosws

test_native:
gcc -g test_native.c ${FLAGS} -o ../../target/test_native && ../../target/test_native
gcc -g test_native.c ${FLAGS} -o ${DEBUG_PATH}/test_native
./${DEBUG_PATH}/test_native
6 changes: 2 additions & 4 deletions taos-ws-sys/tests/test_native.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
#include <assert.h>
#include "taos.h"

int main()
{
init_log();

int code = taos_options(TSDB_OPTION_LOCALE, NULL, "group.id", "10s", "enable.auto.commit", "false", NULL);
if (code != 0)
{
return 1;
}
assert(code == 0);

return 0;
}

0 comments on commit b009e87

Please sign in to comment.