Return dummy u8 in c ffi
This commit is contained in:
parent
27e65f2bed
commit
cc17413e9c
23
binding.h
23
binding.h
|
@ -13,17 +13,17 @@ typedef char bool;
|
||||||
#endif
|
#endif
|
||||||
typedef void *DartPostCObjectFnType;
|
typedef void *DartPostCObjectFnType;
|
||||||
|
|
||||||
typedef struct CResult {
|
|
||||||
char value;
|
|
||||||
char *error;
|
|
||||||
} CResult;
|
|
||||||
|
|
||||||
#define QR_DATA_SIZE 256
|
#define QR_DATA_SIZE 256
|
||||||
|
|
||||||
#define MAX_ATTEMPTS 10
|
#define MAX_ATTEMPTS 10
|
||||||
|
|
||||||
#define N 200000
|
#define N 200000
|
||||||
|
|
||||||
|
typedef struct CResult_u8 {
|
||||||
|
uint8_t value;
|
||||||
|
char *error;
|
||||||
|
} CResult_u8;
|
||||||
|
|
||||||
typedef struct CResult_u32 {
|
typedef struct CResult_u32 {
|
||||||
uint32_t value;
|
uint32_t value;
|
||||||
char *error;
|
char *error;
|
||||||
|
@ -34,11 +34,6 @@ typedef struct CResult_____c_char {
|
||||||
char *error;
|
char *error;
|
||||||
} CResult_____c_char;
|
} CResult_____c_char;
|
||||||
|
|
||||||
typedef struct CResult_u8 {
|
|
||||||
uint8_t value;
|
|
||||||
char *error;
|
|
||||||
} CResult_u8;
|
|
||||||
|
|
||||||
typedef struct CResult_u64 {
|
typedef struct CResult_u64 {
|
||||||
uint64_t value;
|
uint64_t value;
|
||||||
char *error;
|
char *error;
|
||||||
|
@ -50,11 +45,11 @@ void dart_post_cobject(DartPostCObjectFnType ptr);
|
||||||
|
|
||||||
void deallocate_str(char *s);
|
void deallocate_str(char *s);
|
||||||
|
|
||||||
CResult init_wallet(uint8_t coin, char *db_path);
|
struct CResult_u8 init_wallet(uint8_t coin, char *db_path);
|
||||||
|
|
||||||
CResult migrate_db(uint8_t coin, char *db_path);
|
struct CResult_u8 migrate_db(uint8_t coin, char *db_path);
|
||||||
|
|
||||||
CResult migrate_data_db(uint8_t coin);
|
struct CResult_u8 migrate_data_db(uint8_t coin);
|
||||||
|
|
||||||
void set_active(uint8_t active);
|
void set_active(uint8_t active);
|
||||||
|
|
||||||
|
@ -74,7 +69,7 @@ struct CResult_u32 new_account(uint8_t coin, char *name, char *data, int32_t ind
|
||||||
|
|
||||||
void new_sub_account(char *name, int32_t index, uint32_t count);
|
void new_sub_account(char *name, int32_t index, uint32_t count);
|
||||||
|
|
||||||
CResult convert_to_watchonly(uint8_t coin, uint32_t id_account);
|
struct CResult_u8 convert_to_watchonly(uint8_t coin, uint32_t id_account);
|
||||||
|
|
||||||
struct CResult_____c_char get_backup(uint8_t coin, uint32_t id_account);
|
struct CResult_____c_char get_backup(uint8_t coin, uint32_t id_account);
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,3 @@ typedef char bool;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
typedef void *DartPostCObjectFnType;
|
typedef void *DartPostCObjectFnType;
|
||||||
|
|
||||||
typedef struct CResult {
|
|
||||||
char value;
|
|
||||||
char *error;
|
|
||||||
} CResult;
|
|
||||||
|
|
|
@ -90,24 +90,24 @@ pub struct CResult<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn init_wallet(coin: u8, db_path: *mut c_char) -> CResult<()> {
|
pub unsafe extern "C" fn init_wallet(coin: u8, db_path: *mut c_char) -> CResult<u8> {
|
||||||
try_init_logger();
|
try_init_logger();
|
||||||
from_c_str!(db_path);
|
from_c_str!(db_path);
|
||||||
to_cresult(init_coin(coin, &db_path))
|
to_cresult(init_coin(coin, &db_path).and_then(|()| Ok(0u8)))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn migrate_db(coin: u8, db_path: *mut c_char) -> CResult<()> {
|
pub unsafe extern "C" fn migrate_db(coin: u8, db_path: *mut c_char) -> CResult<u8> {
|
||||||
try_init_logger();
|
try_init_logger();
|
||||||
from_c_str!(db_path);
|
from_c_str!(db_path);
|
||||||
to_cresult(crate::coinconfig::migrate_db(coin, &db_path))
|
to_cresult(crate::coinconfig::migrate_db(coin, &db_path).and_then(|()| Ok(0u8)))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
pub async unsafe extern "C" fn migrate_data_db(coin: u8) -> CResult<()> {
|
pub async unsafe extern "C" fn migrate_data_db(coin: u8) -> CResult<u8> {
|
||||||
try_init_logger();
|
try_init_logger();
|
||||||
to_cresult(crate::coinconfig::migrate_data(coin).await)
|
to_cresult(crate::coinconfig::migrate_data(coin).await.and_then(|()| Ok(0u8)))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
@ -197,9 +197,9 @@ pub unsafe extern "C" fn new_sub_account(name: *mut c_char, index: i32, count: u
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn convert_to_watchonly(coin: u8, id_account: u32) -> CResult<()> {
|
pub unsafe extern "C" fn convert_to_watchonly(coin: u8, id_account: u32) -> CResult<u8> {
|
||||||
let res = crate::api::account::convert_to_watchonly(coin, id_account);
|
let res = crate::api::account::convert_to_watchonly(coin, id_account);
|
||||||
to_cresult(res)
|
to_cresult(res.and_then(|()| Ok(0u8)))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|
Loading…
Reference in New Issue