123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- // Copyright 2013-2014 Fuzamei tech Ltd. All rights reserved.
- package gocctp
- /*
- #include <libcctp.h>
- #include <string.h>
- */
- import "C"
- import (
- "unsafe"
- )
- //export GoOnMdRspUserLogin
- func GoOnMdRspUserLogin(pRspUserLogin *C.CThostFtdcRspUserLoginField, pRspInfo *C.CThostFtdcRspInfoField, nRequestID int, bIsLast bool, ctx unsafe.Pointer) {
- errMsg := ""
- if unsafe.Pointer(pRspInfo) != nil {
- errNo := pRspInfo.ErrorID
- if errNo != 0 {
- errMsg = C.GoString(&pRspInfo.ErrorMsg[0])
- }
- }
- mdApi := (*MdApi)(ctx)
- mdApi.OnRspUserLogin(errMsg)
- }
- //export GoOnMdRspUserLogout
- func GoOnMdRspUserLogout(pUserLogout *C.CThostFtdcUserLogoutField, pRspInfo *C.CThostFtdcRspInfoField, nRequestID int, bIsLast bool, ctx unsafe.Pointer) {
- errMsg := ""
- if unsafe.Pointer(pRspInfo) != nil {
- errNo := pRspInfo.ErrorID
- if errNo != 0 {
- errMsg = C.GoString(&pRspInfo.ErrorMsg[0])
- }
- }
- mdApi := (*MdApi)(ctx)
- mdApi.OnRspUserLogout(errMsg)
- }
- //export GoOnMdRspError
- func GoOnMdRspError(pRspInfo *C.CThostFtdcRspInfoField, nRequestID int, bIsLast bool, ctx unsafe.Pointer) {
- errMsg := ""
- if unsafe.Pointer(pRspInfo) != nil {
- errNo := pRspInfo.ErrorID
- if errNo != 0 {
- errMsg = C.GoString(&pRspInfo.ErrorMsg[0])
- }
- }
- mdApi := (*MdApi)(ctx)
- mdApi.OnRspError(errMsg)
- }
- //export GoOnTdRspUserLogin
- func GoOnTdRspUserLogin(pRspUserLogin *C.CThostFtdcRspUserLoginField, pRspInfo *C.CThostFtdcRspInfoField, nRequestID int, bIsLast bool, ctx unsafe.Pointer) {
- errMsg := ""
- if unsafe.Pointer(pRspInfo) != nil {
- errNo := pRspInfo.ErrorID
- if errNo != 0 {
- errMsg = C.GoString(&pRspInfo.ErrorMsg[0])
- }
- }
- tdApi := (*TdApi)(ctx)
- tdApi.OnRspUserLogin(errMsg)
- }
- //export GoOnTdRspUserLogout
- func GoOnTdRspUserLogout(pUserLogout *C.CThostFtdcUserLogoutField, pRspInfo *C.CThostFtdcRspInfoField, nRequestID int, bIsLast bool, ctx unsafe.Pointer) {
- errMsg := ""
- if unsafe.Pointer(pRspInfo) != nil {
- errNo := pRspInfo.ErrorID
- if errNo != 0 {
- errMsg = C.GoString(&pRspInfo.ErrorMsg[0])
- }
- }
- tdApi := (*TdApi)(ctx)
- tdApi.OnRspUserLogout(errMsg)
- }
- //export GoOnTdRspError
- func GoOnTdRspError(pRspInfo *C.CThostFtdcRspInfoField, nRequestID int, bIsLast bool, ctx unsafe.Pointer) {
- errMsg := ""
- if unsafe.Pointer(pRspInfo) != nil {
- errNo := pRspInfo.ErrorID
- if errNo != 0 {
- errMsg = C.GoString(&pRspInfo.ErrorMsg[0])
- }
- }
- tdApi := (*TdApi)(ctx)
- tdApi.OnRspError(errMsg)
- }
- //export GoOnRtnDepthMarketData
- func GoOnRtnDepthMarketData(pDepthMarketData *C.CThostFtdcDepthMarketDataField, ctx unsafe.Pointer) {
- field := &CThostFtdcDepthMarketDataField{}
- size := unsafe.Sizeof(*field)
- C.memcpy(unsafe.Pointer(field), unsafe.Pointer(pDepthMarketData), C.size_t(size))
- mdApi := (*MdApi)(ctx)
- mdApi.OnRtnDepthMarketData(field)
- }
- //export GoOnRspQryExchange
- func GoOnRspQryExchange(pExchange *C.CThostFtdcExchangeField, pRspInfo *C.CThostFtdcRspInfoField, nRequestID int, bIsLast bool, ctx unsafe.Pointer) {
- field := &CThostFtdcExchangeField{}
- size := unsafe.Sizeof(*field)
- C.memcpy(unsafe.Pointer(field), unsafe.Pointer(pExchange), C.size_t(size))
- errMsg := ""
- if unsafe.Pointer(pRspInfo) != nil {
- errNo := pRspInfo.ErrorID
- if errNo != 0 {
- errMsg = C.GoString(&pRspInfo.ErrorMsg[0])
- }
- }
- tdApi := (*TdApi)(ctx)
- tdApi.OnRspQryExchange(field, errMsg, bIsLast)
- }
- //export GoOnRspQryInstrument
- func GoOnRspQryInstrument(pInstrument *C.CThostFtdcInstrumentField, pRspInfo *C.CThostFtdcRspInfoField, nRequestID int, bIsLast bool, ctx unsafe.Pointer) {
- field := &CThostFtdcInstrumentField{}
- size := unsafe.Sizeof(*field)
- C.memcpy(unsafe.Pointer(field), unsafe.Pointer(pInstrument), C.size_t(size))
- errMsg := ""
- if unsafe.Pointer(pRspInfo) != nil {
- errNo := pRspInfo.ErrorID
- if errNo != 0 {
- errMsg = C.GoString(&pRspInfo.ErrorMsg[0])
- }
- }
- tdApi := (*TdApi)(ctx)
- tdApi.OnRspQryInstrument(field, errMsg, bIsLast)
- }
|