use std::os::raw::{c_char, c_int, c_void};
#[repr(C)]
pub struct CtpLogConfig {
pub enable_debug: c_int, pub log_file_path: *const c_char, pub max_file_size_mb: c_int, pub max_backup_files: c_int, }
#[repr(C)]
pub struct MdSpiCallbacks {
pub user_data: *mut c_void,
pub on_front_connected: Option<extern "C" fn(*mut c_void)>,
pub on_front_disconnected: Option<extern "C" fn(*mut c_void, c_int)>,
pub on_heart_beat_warning: Option<extern "C" fn(*mut c_void, c_int)>,
pub on_rsp_user_login:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_user_logout:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_error: Option<extern "C" fn(*mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_sub_market_data:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_unsub_market_data:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rtn_depth_market_data: Option<extern "C" fn(*mut c_void, *mut c_void)>,
pub on_rtn_for_quote_rsp: Option<extern "C" fn(*mut c_void, *mut c_void)>,
}
#[repr(C)]
pub struct TraderSpiCallbacks {
pub user_data: *mut c_void,
pub on_front_connected: Option<extern "C" fn(*mut c_void)>,
pub on_front_disconnected: Option<extern "C" fn(*mut c_void, c_int)>,
pub on_heart_beat_warning: Option<extern "C" fn(*mut c_void, c_int)>,
pub on_rsp_authenticate:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_user_login:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_user_logout:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_error: Option<extern "C" fn(*mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_order_insert:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_order_action:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rtn_order: Option<extern "C" fn(*mut c_void, *mut c_void)>,
pub on_rtn_trade: Option<extern "C" fn(*mut c_void, *mut c_void)>,
pub on_rsp_qry_trading_account:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_qry_investor_position:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_err_rtn_order_insert: Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void)>,
pub on_err_rtn_order_action: Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void)>,
pub on_rsp_qry_order:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_qry_trade:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_qry_instrument:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_qry_instrument_margin_rate:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_qry_instrument_commission_rate:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_qry_exchange:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_qry_product:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_settlement_info_confirm:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_parked_order_insert:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_parked_order_action:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_exec_order_insert:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_exec_order_action:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_for_quote_insert:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_quote_insert:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_quote_action:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_batch_order_action:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_remove_parked_order:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_remove_parked_order_action:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_qry_max_order_volume:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_qry_depth_market_data:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_qry_settlement_info:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_qry_transfer_bank:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_qry_investor_position_detail:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
pub on_rsp_qry_notice:
Option<extern "C" fn(*mut c_void, *mut c_void, *mut c_void, c_int, c_int)>,
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CreateMdSpiBridge(callbacks: *const MdSpiCallbacks) -> *mut c_void;
pub fn DestroyMdSpiBridge(spi_bridge: *mut c_void);
pub fn CreateTraderSpiBridge(callbacks: *const TraderSpiCallbacks) -> *mut c_void;
pub fn DestroyTraderSpiBridge(spi_bridge: *mut c_void);
pub fn CTP_InitializeDebugLogging(config: *const CtpLogConfig);
pub fn CTP_CleanupDebugLogging();
}
pub mod md_api {
use super::*;
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcMdApi_CreateFtdcMdApi(
flow_path: *const c_char,
is_using_udp: bool,
is_multicast: bool,
is_production_mode: bool,
) -> *mut c_void;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcMdApi_GetApiVersion() -> *const c_char;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcMdApi_Release(api: *mut c_void);
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcMdApi_Init(api: *mut c_void);
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcMdApi_Join(api: *mut c_void) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcMdApi_GetTradingDay(api: *mut c_void) -> *const c_char;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcMdApi_RegisterFront(api: *mut c_void, front_address: *const c_char);
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcMdApi_RegisterNameServer(api: *mut c_void, ns_address: *const c_char);
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcMdApi_RegisterFensUserInfo(api: *mut c_void, user_info: *const c_void);
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcMdApi_RegisterSpi(api: *mut c_void, spi: *mut c_void);
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcMdApi_ReqUserLogin(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcMdApi_ReqUserLogout(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcMdApi_SubscribeMarketData(
api: *mut c_void,
instrument_ids: *const *const c_char,
count: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcMdApi_UnSubscribeMarketData(
api: *mut c_void,
instrument_ids: *const *const c_char,
count: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcMdApi_SubscribeForQuoteRsp(
api: *mut c_void,
instrument_ids: *const *const c_char,
count: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcMdApi_UnSubscribeForQuoteRsp(
api: *mut c_void,
instrument_ids: *const *const c_char,
count: c_int,
) -> c_int;
}
}
pub mod trader_api {
use super::*;
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_CreateFtdcTraderApi(
flow_path: *const c_char,
is_production_mode: bool,
) -> *mut c_void;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_GetApiVersion() -> *const c_char;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_Release(api: *mut c_void);
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_Init(api: *mut c_void);
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_Join(api: *mut c_void) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_GetTradingDay(api: *mut c_void) -> *const c_char;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_RegisterFront(api: *mut c_void, front_address: *const c_char);
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_RegisterNameServer(api: *mut c_void, ns_address: *const c_char);
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_RegisterFensUserInfo(api: *mut c_void, user_info: *const c_void);
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_RegisterSpi(api: *mut c_void, spi: *mut c_void);
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_GetFrontInfo(api: *mut c_void, front_info: *mut c_void);
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_RegisterWechatUserSystemInfo(
api: *mut c_void,
user_system_info: *mut c_void,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_SubmitWechatUserSystemInfo(
api: *mut c_void,
user_system_info: *mut c_void,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqAuthenticate(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_RegisterUserSystemInfo(
api: *mut c_void,
user_info: *const c_void,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_SubmitUserSystemInfo(
api: *mut c_void,
user_info: *const c_void,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqUserLogin(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqUserLogout(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqQryTradingAccount(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqQryInvestorPosition(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqOrderInsert(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqOrderAction(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqQryOrder(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqQryTrade(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqQryInstrument(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqQryInstrumentMarginRate(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqQryInstrumentCommissionRate(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqQryExchange(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqQryProduct(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqSettlementInfoConfirm(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqParkedOrderInsert(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqParkedOrderAction(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqExecOrderInsert(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqExecOrderAction(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqForQuoteInsert(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqQuoteInsert(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqQuoteAction(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqBatchOrderAction(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqRemoveParkedOrder(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqRemoveParkedOrderAction(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqQryMaxOrderVolume(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqQryDepthMarketData(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqQrySettlementInfo(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqQryTransferBank(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqQryInvestorPositionDetail(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
#[link(name = "ctp_wrapper")]
extern "C" {
pub fn CThostFtdcTraderApi_ReqQryNotice(
api: *mut c_void,
req: *const c_void,
request_id: c_int,
) -> c_int;
}
}
pub mod callbacks {
use super::*;
pub type OnFrontConnectedCallback = extern "C" fn();
pub type OnFrontDisconnectedCallback = extern "C" fn(reason: c_int);
pub type OnHeartBeatWarningCallback = extern "C" fn(time_lapse: c_int);
pub type OnRspUserLoginCallback = extern "C" fn(
user_login: *const c_void,
rsp_info: *const c_void,
request_id: c_int,
is_last: bool,
);
pub type OnRspUserLogoutCallback = extern "C" fn(
user_logout: *const c_void,
rsp_info: *const c_void,
request_id: c_int,
is_last: bool,
);
pub type OnRtnDepthMarketDataCallback = extern "C" fn(depth_market_data: *const c_void);
pub type OnRspSubMarketDataCallback = extern "C" fn(
specific_instrument: *const c_void,
rsp_info: *const c_void,
request_id: c_int,
is_last: bool,
);
pub type OnRspUnSubMarketDataCallback = extern "C" fn(
specific_instrument: *const c_void,
rsp_info: *const c_void,
request_id: c_int,
is_last: bool,
);
pub type OnRspAuthenticateCallback = extern "C" fn(
rsp_authenticate: *const c_void,
rsp_info: *const c_void,
request_id: c_int,
is_last: bool,
);
pub type OnRspErrorCallback =
extern "C" fn(rsp_info: *const c_void, request_id: c_int, is_last: bool);
}
#[cfg(test)]
mod tests {
use std::ptr;
#[test]
fn test_ffi_declarations_compile() {
let _api_ptr: *mut std::os::raw::c_void = ptr::null_mut();
assert!(true, "FFI声明编译成功");
}
}