Heng.c
上传用户:bjghjy
上传日期:2007-01-07
资源大小:379k
文件大小:50k
- #include <windows.h>
- #include <windowsx.h>
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <io.h>
- #include <sysstat.h>
- #include <fcntl.h>
- #include <time.h>
- //#include "dbf_data.h"
- #include "sv_jy.h"
- #include "jydest.h"
- #include "rsa.h"
- #define __SERVER_CCR
- #include "heng.h"
- #define MAX_PATH_LEN 128
- #define START_REC_NO 94
- //DBF_DATA CommFile;
- typedef struct tag_ANSFILE
- {
- HANDLE hf[MAX_ZQS_COUNT];
- int recnum[MAX_ZQS_COUNT];
- char path[MAX_ZQS_COUNT][MAX_PATH_LEN];
- }ANSFILE;
- ANSFILE AnsFile;
- typedef struct tag_REQFILE
- {
- HANDLE hf[MAX_ZQS_COUNT];
- int recnum[MAX_ZQS_COUNT];
- int currec[MAX_ZQS_COUNT];
- }REQFILE;
- REQFILE ReqFile;
- int ZqsCount;
- //char * CommBuffer;
- short rlen,hlen;
- char RetFilePath[80];
- BOOL fUseJy =FALSE,fTestJy=FALSE,fRsa=FALSE;
- int Thrd_SendJycx(int sd, int reqType, void *lpBuf, int);
- extern int sdJy;
- extern BOOL GetInitString(LPSTR, LPSTR, LPSTR);
- extern BOOL PutInitString(LPSTR, LPSTR, LPSTR);
- extern BOOL ErrMsg(HWND, LPSTR);
- //extern int UDP_SendBuff(LPSTR, int, LPSTR, int, LPDEST_INFO );
- #define WriteRecord WriteDatRec
- int WriteDatRec(HANDLE hd,int no,short hlen,short rlen,char *rbuff)
- {
- DWORD bytes;
- int i=0;
- SetFilePointer(hd,(long)(hlen + rlen*(START_REC_NO +no -1)),NULL,FILE_BEGIN);
- do
- {
- if(LockFile(hd,(DWORD)(hlen + rlen*(START_REC_NO +no -1)),0,rlen,0))
- break;
- else
- Sleep(RETRY_DELAY +RETRY_DELAY/2);
- }while(i<LOCK_RETRY_TIMES);
- if(i>=LOCK_RETRY_TIMES)
- return -1;
- if(WriteFile(hd,rbuff,rlen,&bytes,NULL))
- {
- if(bytes!=(DWORD)rlen)
- {
- UnlockFile(hd,(DWORD)(hlen + rlen*(START_REC_NO +no -1)),0,rlen,0);
- return -1;
- }
- }
- else
- {
- UnlockFile(hd,(DWORD)(hlen + rlen*(START_REC_NO +no -1)),0,rlen,0);
- return -1;
- }
- UnlockFile(hd,(DWORD)(hlen + rlen*(START_REC_NO +no -1)),0,rlen,0);
- return 0;
- }
- #define ReadRecord ReadDatRec
- int ReadDatRec(HANDLE hd,int no,short hlen,short rlen,char *rbuff)
- {
- DWORD bytes;
- int i=0;
- SetFilePointer(hd,(long)(hlen + rlen*(START_REC_NO+no -1)),NULL,FILE_BEGIN);
- do
- {
- if(LockFile(hd,(DWORD)(hlen + rlen*(START_REC_NO +no -1)),0,rlen,0))
- break;
- else
- Sleep(RETRY_DELAY +RETRY_DELAY/2);
- }while(i<LOCK_RETRY_TIMES);
- if(i>=LOCK_RETRY_TIMES)
- return -1;
- if(ReadFile(hd,rbuff,rlen,&bytes,NULL))
- {
- if(bytes!=(DWORD)rlen)
- {
- UnlockFile(hd,(DWORD)(hlen + rlen*(START_REC_NO +no -1)),0,rlen,0);
- return -1;
- }
- }
- else
- {
- UnlockFile(hd,(DWORD)(hlen + rlen*(START_REC_NO +no -1)),0,rlen,0);
- return -1;
- }
- UnlockFile(hd,(DWORD)(hlen + rlen*(START_REC_NO +no -1)),0,rlen,0);
- return 0;
- }
- int JyInit(void)
- {
- int i,j;
- char tmp[256], temp[256],temp1[256];
- char * prt;
- REQUEST_BUFFER ReqBuf;
- ANSWER Answer;
- DWORD bytes;
- memset(&ReqFile,0,sizeof(REQFILE));
- memset(&AnsFile,0,sizeof(ANSFILE));
- memset(&ReqBuf,0,sizeof(REQUEST_BUFFER));
- memset(&Answer,0,sizeof(ANSWER));
-
- if(GetInitString("JY", "RUN", tmp))
- {
- if(tmp[0] =='N' || tmp[0] =='n')
- {
- fUseJy =FALSE;
- return 0;
- }
- else
- fUseJy =TRUE;
- }
- if(GetInitString("JY", "TEST", tmp))
- {
- if(tmp[0] =='Y' || tmp[0] =='y')
- fTestJy =TRUE;
- else
- fTestJy =FALSE;
- }
- else fTestJy =FALSE;
-
- if(GetInitString("JY", "RSA", tmp))
- {
- if(tmp[0] =='Y' || tmp[0] =='y')
- {
- fRsa =TRUE;
- if(!ReadRsaFile(R,PK,SK))
- ErrMsg(NULL,"读RSA加密参数失败,请在系统启动后按[Init]");
- }
- }
- ZqsCount=0;
- for(i=0;i<MAX_ZQS_COUNT;i++)
- {
- wsprintf(temp,"%s%d","COMMFILE",i);
- if(!GetInitString("JY", temp, tmp))
- {
- if(ZqsCount==0)
- {
- wsprintf(temp, "不能发现配置%s:n %s",
- (LPSTR)"COMMFILE", (LPSTR)tmp);
- ErrMsg(NULL, temp);
- }
- break;
- }
- else
- {
- ZqsCount++;
- prt=strstr(tmp,";");
- if(prt==NULL)
- {
- ErrMsg(NULL,"format Reqfile;AnsFile");
- return -1;
- }
- else *prt=0;
- strcpy(temp1,tmp);
- if(access(temp1,0)!=0)
- {
- ReqFile.hf[i]=CreateFile(temp1,GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
- if(ReqFile.hf[i] ==INVALID_HANDLE_VALUE)
- {
- ErrMsg(NULL, "can not create comm file!");
- return -1;
- }
- for(j=0;j<REQUESTLEN;j++)
- {
- if(WriteFile(ReqFile.hf[i],&ReqBuf,sizeof(REQUEST_BUFFER),&bytes,NULL))
- {
- if(bytes!=sizeof(REQUEST_BUFFER))
- {
- CloseHandle(ReqFile.hf[i]);
- return -1;
- }
- }
- else
- {
- CloseHandle(ReqFile.hf[i]);
- return -1;
- }
- }
- }
- else
- {
- if(access(temp1,_S_IREAD|_S_IWRITE) <0)
- {
- wsprintf(temp, "不能存取%s:n %s",
- (LPSTR)"COMMFILE", (LPSTR)temp1);
- ErrMsg(NULL, temp);
- return -1;
- }
- ReqFile.hf[i]=CreateFile(temp1,GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
- if(ReqFile.hf[i] ==INVALID_HANDLE_VALUE)
- {
- ErrMsg(NULL, "can not create comm file!");
- return -1;
- }
- }
- //ReqFile.hf[i]=OpenDbfBase(temp1,O_RDWR);
- // if(i==0)
- // CommFile.hf=ReqFile.hf[0];
-
- //if (ReqFile.hf[i]==-1)
- //{
- // wsprintf(temp, "不能打开%s:n %s",
- // (LPSTR)"COMMFILE", (LPSTR)temp1);
- // ErrMsg(NULL, temp);
- // return -1;
- //}
- if(i==0)
- {
- // if (InitBase(CommFile.hf,&CommFile.dbfStruct,
- // &CommFile.fldStruct,&CommFile.fldCount)
- // !=SUCCEED)
- // {
- // wsprintf(temp, "不能处始化%s:n %s",
- // (LPSTR)"COMMFILE", (LPSTR)temp1);
- // ErrMsg(NULL, temp);
- // return -1;
- // }
- rlen= sizeof(REQUEST_BUFFER);
- hlen= 0;
- }
- //ReqFile.recnum[i]= REQUESTLEN;
- strcpy(temp1,++prt);
- if(access(temp1,0)!=0)
- {
- AnsFile.hf[i]=CreateFile(temp1,GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
- if(ReqFile.hf[i] ==INVALID_HANDLE_VALUE)
- {
- ErrMsg(NULL, "can not create comm ans file!");
- return -1;
- }
- for(j=0;j<ANSWERLEN;j++)
- {
- if(WriteFile(AnsFile.hf[i],&Answer,sizeof(ANSWER),&bytes,NULL))
- {
- if(bytes!=sizeof(ANSWER))
- {
- CloseHandle(ReqFile.hf[i]);
- CloseHandle(AnsFile.hf[i]);
- return -1;
- }
- }
- else
- {
- CloseHandle(AnsFile.hf[i]);
- return -1;
- }
- }
- }
- else
- {
- if(access(temp1,_S_IREAD|_S_IWRITE) <0)
- {
- wsprintf(temp, "不能存取%s:n %s",
- (LPSTR)"COMMFILE", (LPSTR)temp1);
- ErrMsg(NULL, temp);
- return -1;
- }
- AnsFile.hf[i]=CreateFile(temp1,GENERIC_READ|GENERIC_WRITE,
- FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
- if(AnsFile.hf[i] ==INVALID_HANDLE_VALUE)
- {
- ErrMsg(NULL, "can not create comm ans file!");
- return -1;
- }
- }
- //AnsFile.hf[i]=OpenDbfBase(temp1,O_RDWR);
- //if (ReqFile.hf[i]==-1)
- //{
- // wsprintf(temp, "不能打开%s:n %s",
- // (LPSTR)"COMMFILE", (LPSTR)temp1);
- // ErrMsg(NULL, temp);
- // return -1;
- //}
- prt =strrchr(temp1,'\');
- ++prt; *prt =0;
- strcpy(&AnsFile.path[i][0],temp1);
- AnsFile.recnum[i]=ANSWERLEN;
- ReqFile.recnum[i]=REQUESTLEN;
- }
- }
- return 0;
- }
- int JyExit(void)
- {
- int i;
- for(i=0;i<ZqsCount;i++)
- {
- if(ReqFile.hf[i]!=INVALID_HANDLE_VALUE)
- CloseHandle(ReqFile.hf[i]);
- if(AnsFile.hf[i]!=INVALID_HANDLE_VALUE)
- CloseHandle(AnsFile.hf[i]);
- }
- return 0;
- }
- int Jy_Zqsxx(int sd)
- {
- int len;
- BYTE SendBuff[1024];
- strcpy(SendBuff, JY_ZQSXX_HEAD);
- len =strlen(JY_ZQSXX_HEAD);
- //memcpy(&SendBuff[len],&Zqsxx,sizeof(ZQSXX));
- //len+=sizeof(Zqsxx);
-
- memcpy(&SendBuff[len],R,DATALENGTH);
- len +=DATALENGTH;
- memcpy(&SendBuff[len],PK,DATALENGTH);
- len +=DATALENGTH;
- UDP_SendBuff("RSA.R.PK", sd, SendBuff, len,NULL);
- return 0;
- }
- void ClearAns(LPJY_DEST lpJyDest)
- {
- char* buff;
- buff =GlobalAllocPtr(GHND,rlen);
- if(buff !=NULL)
- {
- memset(buff,0,rlen);
- WriteRecord(AnsFile.hf[lpJyDest->zqsid],lpJyDest->recNum,hlen,rlen,buff);
- GlobalFreePtr(buff);
- }
- }
- void ClearReq(LPJY_DEST lpJyDest)
- {
- char* buff;
- buff =GlobalAllocPtr(GHND,rlen);
- if(buff !=NULL)
- {
- memset(buff,0,rlen);
- buff[0] =0;
- WriteRecord(ReqFile.hf[lpJyDest->zqsid],lpJyDest->recNum,hlen,rlen,buff);
- GlobalFreePtr(buff);
- }
- }
- int Jy_ChkUsr(int sd, int jyNum, LPJY_ASK_CHKUSR AskChkUser)
- {
- int ret;
- LPJY_DEST lpJyDest;
- short Qsid;
- REQUEST_BUFFER ReqBuf;
- ANSWER Answer;
- if(ZqsCount ==1)
- Qsid =1;
- else
- Qsid =AskChkUser->zqsid;
- if(ReqFile.hf[Qsid -1] ==INVALID_HANDLE_VALUE)
- return ANS_SYS_ERR;
- ret =CheckJyDest(sd,REQ_CHKUSR, AskChkUser->jys,
- AskChkUser->gddm, -1, &lpJyDest);
- memset(&ReqBuf,0,rlen);
- memset(&Answer,0,sizeof(ANSWER));
- ReqBuf.command =3;
- ReqBuf.status =' 01';
- strcpy(ReqBuf.request.r_inq_account.argment,AskChkUser->gddm);
- ReqBuf.request.r_inq_account.arg_type ='2';
- ReqBuf.request.r_inq_account.password =atoi(AskChkUser->jymm);
- //StringToFld(CommBuffer,CommFile.fldStruct[fld_GDDM],AskChkUser->gddm);
- //CommBuffer[*(short*)(CommFile.fldStruct[fld_STKNO].offset)]
- // =(AskChkUser->jys ==0)?'Z':'H';
- //StringToFld(CommBuffer,CommFile.fldStruct[fld_JYMM],AskChkUser->jymm);
- //CommBuffer[*(short*)(CommFile.fldStruct[fld_ASKNO].offset)]=REQ_CHKUSR;
- //CommBuffer[*(short*)(CommFile.fldStruct[fld_STAT].offset)]=';';
- //wsprintf(temp,"%d",sd);
- //StringToFld(CommBuffer,CommFile.fldStruct[fld_ADDR],temp);
- //wsprintf(temp,"%d",jyNum);
- //StringToFld(CommBuffer,CommFile.fldStruct[fld_SERI],temp);
- if(lpJyDest==NULL)
- lpJyDest=GetFirstIdelRec();
- if(lpJyDest==NULL)
- {
- ReqFile.currec[Qsid-1]++;
- if(ReqFile.currec[Qsid-1]>ReqFile.recnum[Qsid-1])
- {
- ErrMsg(NULL, "无空闲交易表项!");
- return ANS_SYS_ERR;
- }
- lpJyDest=AddJyDest(sd, REQ_CHKUSR, AskChkUser->jys,
- ReqFile.currec[Qsid-1], AskChkUser->gddm, jyNum,Qsid-1);
- if(lpJyDest ==NULL)
- {
- ErrMsg(NULL, "不能加交易表项!");
- return ANS_SYS_ERR;
- }
- //ClearAns(lpJyDest);
- if(WriteRecord(ReqFile.hf[Qsid-1],lpJyDest->recNum,
- hlen,rlen,(char *)&ReqBuf) !=0)
- {
- ErrMsg(NULL, "不能写交换文件!");
- return ANS_SYS_ERR;
- }
- }
- else
- {
- //ClearAns(lpJyDest);
- if(WriteRecord(ReqFile.hf[Qsid-1],lpJyDest->recNum,
- hlen,rlen,(char *)&ReqBuf)!=0)
- {
- ErrMsg(NULL, "不能写交换文件1!");
- return ANS_SYS_ERR;
- }
- strcpy(lpJyDest->gddm,AskChkUser->gddm);
- ChangeJyDest(sd, lpJyDest, REQ_CHKUSR, AskChkUser->jys,
- Qsid -1,jyNum);
- }
- strcpy(lpJyDest->jymm,AskChkUser->jymm);
- if(fTestJy)
- {
- Sleep(1000);
- //CommBuffer[*(short*)(CommFile.fldStruct[fld_ASKNO].offset)]=REQ_NULL;
- //CommBuffer[*(short*)(CommFile.fldStruct[fld_ANSNO].offset)]=ANS_SUCC;
- //CommBuffer[*(short*)(CommFile.fldStruct[fld_STAT].offset)]=';';
- //wsprintf(temp,"%d",jyNum);
- //StringToFld(CommBuffer,CommFile.fldStruct[fld_SERI],temp);
- strcpy(Answer.a_inq_account.status,"000");
- Answer.a_inq_account.fund_account=atoi(AskChkUser->gddm);
- WriteRecord(AnsFile.hf[Qsid-1],lpJyDest->recNum,
- 0,sizeof(ANSWER),(char *)&Answer);
- }
- return 0;
- }
- int Jy_ChgPwd(int sd, int jyNum, LPJY_ASK_CHGPWD AskChgPwd)
- {
- LPJY_DEST lpJyDest=NULL;
- int ret;
- REQUEST_BUFFER ReqBuf;
- ANSWER Answer;
- ret =CheckJyDest(sd, REQ_CHGPWD, AskChgPwd->jys, AskChgPwd->gddm,
- AskChgPwd->userId, &lpJyDest);
- if(ret==-1)
- return ANS_SYS_ERR;
- if(ret==-2)
- return ANS_SUSP_REQ;
- if(ret==-3)
- return ANS_NO_PRIV;
- if(ReqFile.hf[lpJyDest->zqsid] ==INVALID_HANDLE_VALUE)
- return ANS_SYS_ERR;
-
- memset(&ReqBuf,0,rlen);
- memset(&Answer,0,sizeof(ANSWER));
- ReqBuf.command =2;
- ReqBuf.status =' 01';
- ReqBuf.request.r_chg_password.fund_account
- =lpJyDest->jyzh;
- ReqBuf.request.r_chg_password.password =atoi(lpJyDest->jymm);
- ReqBuf.request.r_chg_password.password_new =atoi(AskChgPwd->xmm);
- //memset(CommBuffer,' ',*(short *)CommFile.dbfStruct.rlen);
- //StringToFld(CommBuffer,CommFile.fldStruct[fld_GDDM],AskChgPwd->gddm);
- //CommBuffer[*(short*)(CommFile.fldStruct[fld_STKNO].offset)]
- // =(AskChgPwd->jys ==0)?'Z':'H';
- //StringToFld(CommBuffer,CommFile.fldStruct[fld_JYMM],AskChgPwd->xmm);
- //CommBuffer[*(short*)(CommFile.fldStruct[fld_ASKNO].offset)]=REQ_CHGPWD;
- //CommBuffer[*(short*)(CommFile.fldStruct[fld_STAT].offset)]=';';
- //wsprintf(temp,"%d",sd);
- //StringToFld(CommBuffer,CommFile.fldStruct[fld_ADDR],temp);
- //wsprintf(temp,"%d",jyNum);
- //StringToFld(CommBuffer,CommFile.fldStruct[fld_SERI],temp);
- if(WriteRecord(ReqFile.hf[lpJyDest->zqsid],lpJyDest->recNum,hlen,rlen,(char *)&ReqBuf)!=0)
- {
- ErrMsg(NULL, "不能写交换文件!");
- return ANS_SYS_ERR;
- }
- ChangeJyDest(sd, lpJyDest, REQ_CHGPWD, AskChgPwd->jys, -1, jyNum);
- if(fTestJy)
- {
- Sleep(1000);
- //CommBuffer[*(short*)(CommFile.fldStruct[fld_ASKNO].offset)]=REQ_NULL;
- //CommBuffer[*(short*)(CommFile.fldStruct[fld_ANSNO].offset)]=ANS_SUCC;
- //CommBuffer[*(short*)(CommFile.fldStruct[fld_STAT].offset)]=';';
- //wsprintf(temp,"%d",jyNum);
- //StringToFld(CommBuffer,CommFile.fldStruct[fld_SERI],temp);
- WriteRecord(AnsFile.hf[lpJyDest->zqsid],lpJyDest->recNum,
- 0,sizeof(ANSWER),(char *)&Answer);
- }
- return 0;
- }
- int Jy_BuySell(int sd, int jyNum, LPJY_ASK_BUYSELL AskBuySell)
- {
- LPJY_DEST lpJyDest;
- int ret;
- REQUEST_BUFFER ReqBuf;
- ANSWER Answer;
- ret =CheckJyDest(sd, REQ_BUYSEL, AskBuySell->jys, AskBuySell->gddm,
- AskBuySell->userId, &lpJyDest);
- if(ret==-1)
- return ANS_SYS_ERR;
- if(ret==-2)
- return ANS_SUSP_REQ;
- if(ret==-3)
- return ANS_NO_PRIV;
-
- if(ReqFile.hf[lpJyDest->zqsid] ==INVALID_HANDLE_VALUE)
- return ANS_SYS_ERR;
- memset(&ReqBuf,0,rlen);
- ReqBuf.command =5;
- ReqBuf.status =' 01';
- ReqBuf.request.r_ent_enter.exchange_type =
- (AskBuySell->jys ==0)?'2':'1';
- if(AskBuySell->jys ==0)
- strcpy(ReqBuf.request.r_ent_enter.stock_account,
- AskBuySell->gddm);
- else
- sprintf(ReqBuf.request.r_ent_enter.stock_account,
- "A%s",AskBuySell->gddm);
- ReqBuf.request.r_ent_enter.password =
- atol(lpJyDest->jymm);
- ReqBuf.request.r_ent_enter.entrust_bs =
- (AskBuySell->bs =='B')?'1':'2';
- strcpy(ReqBuf.request.r_ent_enter.stock_code,
- AskBuySell->gpdm);
- ReqBuf.request.r_ent_enter.entrust_price=
- (float)AskBuySell->wtjg/(float)100.00;
- ReqBuf.request.r_ent_enter.entrust_amount=
- AskBuySell->wtgs;
- ReqBuf.request.r_ent_enter.entrust_type='0';
- //memset(CommBuffer,' ',*(short *)CommFile.dbfStruct.rlen);
- //StringToFld(CommBuffer,CommFile.fldStruct[fld_GDDM],AskBuySell->gddm);
- //CommBuffer[*(short*)(CommFile.fldStruct[fld_STKNO].offset)]
- // =(AskBuySell->jys ==0)?'Z':'H';
- //StringToFld(CommBuffer,CommFile.fldStruct[fld_GPDM],AskBuySell->gpdm);
- //sprintf(temp,"%12ld",AskBuySell->wtgs);
- //StringToFld(CommBuffer,CommFile.fldStruct[fld_WTGS],temp);
- //sprintf(temp,"%12.2f",(double)(AskBuySell->wtjg/100.00));
- //StringToFld(CommBuffer,CommFile.fldStruct[fld_WTJG],temp);
- //if(AskBuySell->bs =='B')
- // CommBuffer[*(short*)(CommFile.fldStruct[fld_ASKNO].offset)]=REQ_BUY;
- //else if(AskBuySell->bs =='S')
- // CommBuffer[*(short*)(CommFile.fldStruct[fld_ASKNO].offset)]=REQ_SELL;
- //else
- // CommBuffer[*(short*)(CommFile.fldStruct[fld_ASKNO].offset)]='E';
- //CommBuffer[*(short*)(CommFile.fldStruct[fld_STAT].offset)]=';';
- //wsprintf(temp,"%d",sd);
- //StringToFld(CommBuffer,CommFile.fldStruct[fld_ADDR],temp);
- //wsprintf(temp,"%d",jyNum);
- //StringToFld(CommBuffer,CommFile.fldStruct[fld_SERI],temp);
- //ClearAns(lpJyDest);
- if(WriteRecord(ReqFile.hf[lpJyDest->zqsid],lpJyDest->recNum,hlen,rlen,(char *)&ReqBuf)!=0)
- {
- ErrMsg(NULL, "不能写交换文件!");
- return ANS_SYS_ERR;
- }
- if(ChangeJyDest(sd, lpJyDest, REQ_BUYSEL, AskBuySell->jys, -1, jyNum)<0)
- return ANS_SYS_ERR;
- if(fTestJy)
- {
- Sleep(1000);
- //CommBuffer[*(short*)(CommFile.fldStruct[fld_ASKNO].offset)]=REQ_NULL;
- //CommBuffer[*(short*)(CommFile.fldStruct[fld_ANSNO].offset)]=ANS_SUCC;
- //CommBuffer[*(short*)(CommFile.fldStruct[fld_STAT].offset)]=';';
- //StringToFld(CommBuffer,CommFile.fldStruct[fld_HTHM],"000068");
- //wsprintf(temp,"%d",jyNum);
- //StringToFld(CommBuffer,CommFile.fldStruct[fld_SERI],temp);
- WriteRecord(AnsFile.hf[lpJyDest->zqsid],lpJyDest->recNum,
- 0,sizeof(ANSWER),(char *)&Answer);
- }
- return 0;
- }
- int Jy_Cancel(int sd, int jyNum, LPJY_ASK_CANCEL AskCancel)
- {
- LPJY_DEST lpJyDest;
- int ret;
- REQUEST_BUFFER ReqBuf;
- ANSWER Answer;
- ret =CheckJyDest(sd, REQ_CANCEL, AskCancel->jys,
- AskCancel->gddm, AskCancel->userId, &lpJyDest);
- if(ret==-1)
- return ANS_SYS_ERR;
- if(ret==-2)
- return ANS_SUSP_REQ;
- if(ret==-3)
- return ANS_NO_PRIV;
-
- if(ReqFile.hf[lpJyDest->zqsid] ==INVALID_HANDLE_VALUE)
- return ANS_SYS_ERR;
-
- memset(&ReqBuf,0,rlen);
- memset(&Answer,0,sizeof(ANSWER));
- ReqBuf.command =6;
- ReqBuf.status =' 01';
- ReqBuf.request.r_ent_cancel.fund_account=
- lpJyDest->jyzh;
- ReqBuf.request.r_ent_cancel.password =
- atoi(lpJyDest->jymm);
- ReqBuf.request.r_ent_cancel.entrust_serial_no =
- atoi(AskCancel->Cancel[0].hthm);
- /*
- for(i=0;i<AskCancel->cancelCount;i++)
- {
- memset(CommBuffer,' ',*(short *)CommFile.dbfStruct.rlen);
- StringToFld(CommBuffer,CommFile.fldStruct[fld_GDDM],AskCancel->gddm);
- StringToFld(CommBuffer,CommFile.fldStruct[fld_HTHM],AskCancel->Cancel[i].hthm);
- CommBuffer[*(short*)(CommFile.fldStruct[fld_STKNO].offset)]
- =(AskCancel->jys ==0)?'Z':'H';
- CommBuffer[*(short*)(CommFile.fldStruct[fld_ASKNO].offset)]=REQ_CANCEL;
- CommBuffer[*(short*)(CommFile.fldStruct[fld_STAT].offset)]=';';
- wsprintf(temp,"%d",sd);
- StringToFld(CommBuffer,CommFile.fldStruct[fld_ADDR],temp);
- wsprintf(temp,"%d",jyNum);
- StringToFld(CommBuffer,CommFile.fldStruct[fld_SERI],temp);
- ClearAns(lpJyDest);
- if(WriteRecord(ReqFile.hf[lpJyDest->zqsid],lpJyDest->recNum,hlen,rlen,
- CommBuffer)!=0)
- {
- ErrMsg(NULL, "不能写交换文件!");
- return ANS_SYS_ERR;
- }
- }
- */
- if(WriteRecord(ReqFile.hf[lpJyDest->zqsid],lpJyDest->recNum,hlen,rlen,
- (char *)&ReqBuf)!=0)
- {
- ErrMsg(NULL, "不能写交换文件!");
- return ANS_SYS_ERR;
- }
- ChangeJyDest(sd, lpJyDest, REQ_CANCEL, AskCancel->jys, -1, jyNum);
- lpJyDest->recCount =1; //;AskCancel->cancelCount;
- if(fTestJy)
- {
- Sleep(1000);
- /*
- CommBuffer[*(short*)(CommFile.fldStruct[fld_ANSNO].offset)]=ANS_SUCC;
- CommBuffer[*(short*)(CommFile.fldStruct[fld_STAT].offset)]=';';
- wsprintf(temp,"%d",AskCancel->cancelCount);
- StringToFld(CommBuffer,CommFile.fldStruct[fld_JYMM],temp);
- wsprintf(temp,"%d",jyNum);
- StringToFld(CommBuffer,CommFile.fldStruct[fld_SERI],temp);
- WriteRecord(AnsFile.hf[lpJyDest->zqsid],lpJyDest->recNum,hlen,rlen,
- CommBuffer);
- wsprintf(temp,"%s%d%s",AnsFile.path[lpJyDest->zqsid],lpJyDest->recNum,".ANS");
- hFile =OpenFile(temp, &os, OF_CREATE|OF_SHARE_DENY_NONE|OF_WRITE);
- if(hFile ==HFILE_ERROR)
- return ANS_SYS_ERR;
- for(i=0;i<AskCancel->cancelCount;i++)
- {
- memset(CommBuffer,' ',*(short *)CommFile.dbfStruct.rlen);
- StringToFld(CommBuffer,CommFile.fldStruct[fld_GDDM],AskCancel->gddm);
- StringToFld(CommBuffer,CommFile.fldStruct[fld_HTHM],AskCancel->Cancel[i].hthm);
- CommBuffer[*(short*)(CommFile.fldStruct[fld_STKNO].offset)]
- =(AskCancel->jys ==0)?'Z':'H';
- CommBuffer[*(short*)(CommFile.fldStruct[fld_ASKNO].offset)]=REQ_CANCEL;
- CommBuffer[*(short*)(CommFile.fldStruct[fld_ANSNO].offset)]=ANS_SUCC;
- CommBuffer[*(short*)(CommFile.fldStruct[fld_STAT].offset)]=';';
- wsprintf(temp,"%d",sd);
- StringToFld(CommBuffer,CommFile.fldStruct[fld_ADDR],temp);
- wsprintf(temp,"%d",jyNum);
- StringToFld(CommBuffer,CommFile.fldStruct[fld_SERI],temp);
- _lwrite(hFile,&CommBuffer[1], rlen-1);
- _lwrite(hFile,"rn",2);
- }
- _lclose(hFile);
- */
- WriteRecord(AnsFile.hf[lpJyDest->zqsid],lpJyDest->recNum,
- 0,sizeof(ANSWER),(char *)&Answer);
- }
- return 0;
- }
- int Jy_Yecx(int sd, int jyNum, LPJY_ASK_YECX AskYecx)
- {
- LPJY_DEST lpJyDest;
- int ret,i=0;
- REQUEST_BUFFER ReqBuf;
- ANSWER Answer;
- ret =CheckJyDest(sd, REQ_YECX, AskYecx->jys, AskYecx->gddm,
- AskYecx->userId, &lpJyDest);
- if(ret==-1)
- return ANS_SYS_ERR;
- if(ret==-2)
- return ANS_SUSP_REQ;
- if(ret==-3)
- return ANS_NO_PRIV;
-
- if(ReqFile.hf[lpJyDest->zqsid] ==INVALID_HANDLE_VALUE)
- return ANS_SYS_ERR;
- memset(&ReqBuf,0,rlen);
- memset(&Answer,0,sizeof(ANSWER));
- ReqBuf.command =10;
- ReqBuf.status =' 01';
- ReqBuf.request.r_inq_stock.arg_type ='3';
- if(AskYecx->jys ==0)
- strcpy(ReqBuf.request.r_inq_stock.stock_account,
- AskYecx->gddm);
- else
- sprintf(ReqBuf.request.r_inq_stock.stock_account,
- "A%s",AskYecx->gddm);
- strcpy(ReqBuf.request.r_inq_stock.stock_code,"");
- ReqBuf.request.r_inq_stock.exchange_type =
- (AskYecx->jys ==0)?'2':'1';
- ReqBuf.request.r_inq_stock.inquire_mode = '1';
- //memset(CommBuffer,' ',*(short *)CommFile.dbfStruct.rlen);
- //StringToFld(CommBuffer,CommFile.fldStruct[fld_GDDM],AskYecx->gddm);
- //CommBuffer[*(short*)(CommFile.fldStruct[fld_STKNO].offset)]
- // =(AskYecx->jys ==0)?'Z':'H';
- //StringToFld(CommBuffer,CommFile.fldStruct[fld_GPDM],AskYecx->gpdm);
- //CommBuffer[*(short*)(CommFile.fldStruct[fld_ASKNO].offset)]=REQ_YECX;
- //CommBuffer[*(short*)(CommFile.fldStruct[fld_STAT].offset)]=';';
- //wsprintf(temp,"%d",sd);
- //StringToFld(CommBuffer,CommFile.fldStruct[fld_ADDR],temp);
- //wsprintf(temp,"%d",jyNum);
- //StringToFld(CommBuffer,CommFile.fldStruct[fld_SERI],temp);
- //ClearAns(lpJyDest);
- //wsprintf(temp,"%s%d%s",AnsFile.path[lpJyDest->zqsid],lpJyDest->recNum,".ANS");
- //remove(temp);
- if(WriteRecord(ReqFile.hf[lpJyDest->zqsid],lpJyDest->recNum,hlen,rlen,
- (char *)&ReqBuf)!=0)
- {
- ErrMsg(NULL, "不能写交换文件!");
- return ANS_SYS_ERR;
- }
- if(ChangeJyDest(sd, lpJyDest, REQ_YECX, AskYecx->jys, -1, jyNum) <0)
- return ANS_SYS_ERR;
- if(fTestJy)
- {
- Sleep(1000);
- /*
- wsprintf(temp,"%s%d%s",AnsFile.path[lpJyDest->zqsid],lpJyDest->recNum,".ANS");
- hFile =OpenFile(temp, &os, OF_CREATE|OF_SHARE_DENY_NONE|OF_WRITE);
- if(hFile ==HFILE_ERROR)
- return 0;
- for(i=0;i<22;i++)
- {
- memset(CommBuffer,0,sizeof(CommBuffer));
- wsprintf(temp,"%04d",i+1);
- StringToFld(CommBuffer,CommFile.fldStruct[fld_GPDM],temp);
- wsprintf(temp,"%8d",(i+1)*10);
- StringToFld(CommBuffer,CommFile.fldStruct[fld_WTGS],temp);
- wsprintf(temp,"%8d",(i+1)*20);
- StringToFld(CommBuffer,CommFile.fldStruct[fld_WTJG],temp);
- StringToFld(CommBuffer,CommFile.fldStruct[fld_DATE],"111111");
- CommBuffer[*(short*)(CommFile.fldStruct[fld_STAT].offset)]=';';
- _lwrite(hFile,&CommBuffer[1], rlen-1);
- _lwrite(hFile,"rn",2);
- }
- _lclose(hFile);
- CommBuffer[*(short*)(CommFile.fldStruct[fld_ANSNO].offset)]=ANS_SUCC;
- CommBuffer[*(short*)(CommFile.fldStruct[fld_STAT].offset)]=';';
- StringToFld(CommBuffer,CommFile.fldStruct[fld_JYMM],"22");
- StringToFld(CommBuffer,CommFile.fldStruct[fld_WTGS],"9000000.12");
- StringToFld(CommBuffer,CommFile.fldStruct[fld_WTJG],"2000000.99");
- wsprintf(temp,"%d",jyNum);
- StringToFld(CommBuffer,CommFile.fldStruct[fld_SERI],temp);
- */
- WriteRecord(AnsFile.hf[lpJyDest->zqsid],lpJyDest->recNum,
- 0,sizeof(ANSWER),(char *)&Answer);
- }
-
- return 0;
- }
- int Jy_Cjcx(int sd, int jyNum, LPJY_ASK_CJCX AskCjcx)
- {
- LPJY_DEST lpJyDest;
- int ret,i=0;
- REQUEST_BUFFER ReqBuf;
- ANSWER Answer;
- ret =CheckJyDest(sd, REQ_CJCX, AskCjcx->jys, AskCjcx->gddm, AskCjcx->userId, &lpJyDest);
- if(ret==-1)
- return ANS_SYS_ERR;
- if(ret==-2)
- return ANS_SUSP_REQ;
- if(ret==-3)
- return ANS_NO_PRIV;
-
- if(ReqFile.hf[lpJyDest->zqsid] ==INVALID_HANDLE_VALUE)
- return ANS_SYS_ERR;
- memset(&ReqBuf,0,rlen);
- memset(&Answer,0,sizeof(ANSWER));
- ReqBuf.command =9;
- ReqBuf.status =' 01';
- ReqBuf.request.r_inq_real.arg_type ='3';
- if(AskCjcx->jys ==0)
- strcpy(ReqBuf.request.r_inq_real.stock_account,
- AskCjcx->gddm);
- else
- sprintf(ReqBuf.request.r_inq_real.stock_account,
- "A%s",AskCjcx->gddm);
- ReqBuf.request.r_inq_real.exchange_type =
- (AskCjcx->jys ==0)?'2':'1';
-
- //memset(CommBuffer,' ',*(short *)CommFile.dbfStruct.rlen);
- //StringToFld(CommBuffer,CommFile.fldStruct[fld_GDDM],AskCjcx->gddm);
- //CommBuffer[*(short*)(CommFile.fldStruct[fld_STKNO].offset)]
- // =(AskCjcx->jys ==0)?'Z':'H';
- //StringToFld(CommBuffer,CommFile.fldStruct[fld_DATE],AskCjcx->cjrq);
- //StringToFld(CommBuffer,CommFile.fldStruct[fld_HTHM],AskCjcx->hthm);
- //CommBuffer[*(short*)(CommFile.fldStruct[fld_ASKNO].offset)]=REQ_CJCX;
- //CommBuffer[*(short*)(CommFile.fldStruct[fld_STAT].offset)]=';';
- //wsprintf(temp,"%d",sd);
- //StringToFld(CommBuffer,CommFile.fldStruct[fld_ADDR],temp);
- //wsprintf(temp,"%d",jyNum);
- //StringToFld(CommBuffer,CommFile.fldStruct[fld_SERI],temp);
- //ClearAns(lpJyDest);
- //wsprintf(temp,"%s%d%s",AnsFile.path[lpJyDest->zqsid],lpJyDest->recNum,".ANS");
- //remove(temp);
- if(WriteRecord(ReqFile.hf[lpJyDest->zqsid],lpJyDest->recNum,hlen,rlen,
- (char *)&ReqBuf)!=0)
- {
- ErrMsg(NULL, "不能写交换文件!");
- return ANS_SYS_ERR;
- }
- if(ChangeJyDest(sd, lpJyDest, REQ_CJCX, AskCjcx->jys, -1, jyNum) <0)
- {
- ErrMsg(NULL,"来自Jy_Cjcx:ChangeJyDest");
- return ANS_SYS_ERR;
- }
- if(fTestJy)
- {
- Sleep(1000);
- /*
- CommBuffer[*(short*)(CommFile.fldStruct[fld_ANSNO].offset)]=ANS_SUCC;
- CommBuffer[*(short*)(CommFile.fldStruct[fld_STAT].offset)]=';';
- StringToFld(CommBuffer,CommFile.fldStruct[fld_JYMM],"22");
- wsprintf(temp,"%d",jyNum);
- StringToFld(CommBuffer,CommFile.fldStruct[fld_SERI],temp);
- WriteRecord(AnsFile.hf[lpJyDest->zqsid],lpJyDest->recNum,hlen,rlen,
- CommBuffer);
- wsprintf(temp,"%s%d%s",AnsFile.path[lpJyDest->zqsid],lpJyDest->recNum,".ANS");
- hFile =OpenFile(temp, &os, OF_CREATE|OF_SHARE_DENY_NONE|OF_WRITE);
- if(hFile ==HFILE_ERROR)
- return ANS_SYS_ERR;
- for(i=0;i<22;i++)
- {
- CommBuffer[*(short*)(CommFile.fldStruct[fld_ANSNO].offset)]=i-(int)(i/2)*2==0 ?'B':'S';
- wsprintf(temp,"%04d",i+1);
- StringToFld(CommBuffer,CommFile.fldStruct[fld_GPDM],temp);
- wsprintf(temp,"%8d",(i+1)*100);
- StringToFld(CommBuffer,CommFile.fldStruct[fld_WTGS],temp);
- wsprintf(temp,"%8d",i+10);
- StringToFld(CommBuffer,CommFile.fldStruct[fld_WTJG],temp);
- wsprintf(temp,"%06d",i+100);
- StringToFld(CommBuffer,CommFile.fldStruct[fld_HTHM],temp);
- StringToFld(CommBuffer,CommFile.fldStruct[fld_DATE],"111111");
- CommBuffer[*(short*)(CommFile.fldStruct[fld_STAT].offset)]=';';
-
- _lwrite(hFile,&CommBuffer[1], rlen-1);
- _lwrite(hFile,"rn",2);
- }
- _lclose(hFile);
- */
- WriteRecord(AnsFile.hf[lpJyDest->zqsid],lpJyDest->recNum,
- 0,sizeof(ANSWER),(char *)&Answer);
- }
- return 0;
- }
- int Jy_Wtcx(int sd, int jyNum, LPJY_ASK_WTCX AskWtcx)
- {
- LPJY_DEST lpJyDest;
- int ret,i=0;
- REQUEST_BUFFER ReqBuf;
- ANSWER Answer;
- ret =CheckJyDest(sd, REQ_WTCX, AskWtcx->jys, AskWtcx->gddm,
- AskWtcx->userId, &lpJyDest);
- if(ret==-1)
- return ANS_SYS_ERR;
- if(ret==-2)
- return ANS_SUSP_REQ;
- if(ret==-3)
- return ANS_NO_PRIV;
-
- if(ReqFile.hf[lpJyDest->zqsid] ==INVALID_HANDLE_VALUE)
- return ANS_SYS_ERR;
- memset(&ReqBuf,0,rlen);
- memset(&Answer,0,sizeof(ANSWER));
- ReqBuf.command =8;
- ReqBuf.status =' 01';
- ReqBuf.request.r_inq_entrust.arg_type ='3';
- if(AskWtcx->jys ==0)
- strcpy(ReqBuf.request.r_inq_entrust.stock_account,
- AskWtcx->gddm);
- else
- sprintf(ReqBuf.request.r_inq_entrust.stock_account,
- "A%s",AskWtcx->gddm);
- ReqBuf.request.r_inq_real.exchange_type =
- (AskWtcx->jys ==0)?'2':'1';
- ReqBuf.request.r_inq_entrust.inquire_mode ='1';
- // memset(CommBuffer,' ',*(short *)CommFile.dbfStruct.rlen);
- // StringToFld(CommBuffer,CommFile.fldStruct[fld_GDDM],AskWtcx->gddm);
- // CommBuffer[*(short*)(CommFile.fldStruct[fld_STKNO].offset)]
- // =(AskWtcx->jys ==0)?'Z':'H';
- // StringToFld(CommBuffer,CommFile.fldStruct[fld_DATE],AskWtcx->wtrq);
- // StringToFld(CommBuffer,CommFile.fldStruct[fld_HTHM],AskWtcx->hthm);
- // CommBuffer[*(short*)(CommFile.fldStruct[fld_ASKNO].offset)]=REQ_WTCX;
- // CommBuffer[*(short*)(CommFile.fldStruct[fld_JYMM].offset)]=AskWtcx->cdcx;
- // CommBuffer[*(short*)(CommFile.fldStruct[fld_STAT].offset)]=';';
- // wsprintf(temp,"%d",sd);
- // StringToFld(CommBuffer,CommFile.fldStruct[fld_ADDR],temp);
- // wsprintf(temp,"%d",jyNum);
- // StringToFld(CommBuffer,CommFile.fldStruct[fld_SERI],temp);
-
- // ClearAns(lpJyDest);
- // wsprintf(temp,"%s%d%s",AnsFile.path[lpJyDest->zqsid],lpJyDest->recNum,".ANS");
- // remove(temp);
- if(WriteRecord(ReqFile.hf[lpJyDest->zqsid],lpJyDest->recNum,hlen,rlen,
- (char *)&ReqBuf)!=0)
- {
- ErrMsg(NULL, "不能写交换文件!");
- return ANS_SYS_ERR;
- }
- if(ChangeJyDest(sd, lpJyDest, REQ_WTCX, AskWtcx->jys, -1, jyNum) <0)
- return ANS_SYS_ERR;
- if(fTestJy)
- {
- Sleep(1000);
- /*
- CommBuffer[*(short*)(CommFile.fldStruct[fld_ANSNO].offset)]=ANS_SUCC;
- CommBuffer[*(short*)(CommFile.fldStruct[fld_STAT].offset)]=';';
- StringToFld(CommBuffer,CommFile.fldStruct[fld_JYMM],"22");
- wsprintf(temp,"%d",jyNum);
- StringToFld(CommBuffer,CommFile.fldStruct[fld_SERI],temp);
- WriteRecord(AnsFile.hf[lpJyDest->zqsid],lpJyDest->recNum,hlen,
- rlen,CommBuffer);
- wsprintf(temp,"%s%d%s",AnsFile.path[lpJyDest->zqsid],lpJyDest->recNum,".ANS");
- hFile =OpenFile(temp, &os, OF_CREATE|OF_SHARE_DENY_NONE|OF_WRITE);
- if(hFile ==HFILE_ERROR)
- return ANS_SYS_ERR;
- for(i=0;i<22;i++)
- {
- CommBuffer[*(short*)(CommFile.fldStruct[fld_ANSNO].offset)]=i-(int)(i/2)*2==0 ?'B':'S';
- wsprintf(temp,"%04d",i+1);
- StringToFld(CommBuffer,CommFile.fldStruct[fld_GPDM],temp);
- wsprintf(temp,"%8d",(i+1)*100);
- StringToFld(CommBuffer,CommFile.fldStruct[fld_WTGS],temp);
- wsprintf(temp,"%8d",i+10);
- StringToFld(CommBuffer,CommFile.fldStruct[fld_WTJG],temp);
- wsprintf(temp,"%06d",i+100);
- StringToFld(CommBuffer,CommFile.fldStruct[fld_HTHM],temp);
- StringToFld(CommBuffer,CommFile.fldStruct[fld_DATE],"111111");
- CommBuffer[*(short*)(CommFile.fldStruct[fld_STAT].offset)]=';';
- _lwrite(hFile,&CommBuffer[1], rlen-1);
- _lwrite(hFile,"rn",2);
- }
- _lclose(hFile);
- */
- WriteRecord(AnsFile.hf[lpJyDest->zqsid],lpJyDest->recNum,
- 0,sizeof(ANSWER),(char *)&Answer);
- }
- return 0;
- }
- int JyDest_ChkUsr(LPJY_DEST lpJyDest)
- {
- BYTE SendBuff[2048];
- int ret, len;
- JY_ANS_CHKUSR AnsUser;
- //ReadRecord(AnsFile.hf[lpJyDest->zqsid],lpJyDest->recNum,hlen,
- // rlen,CommBuffer);
- //stat=CommBuffer[*(short*)(CommFile.fldStruct[fld_STAT].offset)];
- //if(stat !=';')
- // return 0;
- REQUEST_BUFFER ReqBuf;
- ANSWER Answer;
- memset(&ReqBuf,0,rlen);
- memset(&Answer,0,sizeof(ANSWER));
- ReadRecord(ReqFile.hf[lpJyDest->zqsid],lpJyDest->recNum,
- hlen,rlen,(char *)&ReqBuf);
- if(ReqBuf.status !=' 02')
- return 0;
- if(ReadRecord(AnsFile.hf[lpJyDest->zqsid],lpJyDest->recNum,
- 0,sizeof(ANSWER),(char *)&Answer)!=0)
- ret =-1;
- else
- {
- //if(strncmp(Answer.a_inq_account.status,"000",3) ==0)
- ret =ReqBuf.error;
- if(ret>=0)
- {
- //ret =0;
- lpJyDest->jyzh =Answer.a_inq_account.fund_account;
- lpJyDest->zjye =Answer.a_inq_account.current_balance;
- lpJyDest->kyje =Answer.a_inq_account.enable_balance;
- }
- }
- //FldToString(CommBuffer,&CommFile.fldStruct[fld_SERI],temp);
- //if(lpJyDest->jyNum!=atoi(temp))
- // return 0;
- //ret=CommBuffer[*(short*)(CommFile.fldStruct[fld_ANSNO].offset)];
- //if(ret==' ')
- // return 0;
- if(ret<0)
- {
- //ret =ANS_SYS_ERR;
- switch(ret)
- {
- case -51:
- ret ='1';
- break;
- case -52:
- ret ='6';
- break;
- default:
- ret ='1';
- }
- }
- else ret =ANS_SUCC;
- strcpy(SendBuff, JY_CHKUSR_HEAD);
- len =strlen(SendBuff);
- *(short *)&SendBuff[len] =lpJyDest->jyNum;
- len +=sizeof(short);
- AnsUser.jys=lpJyDest->curJys;
- AnsUser.userId=lpJyDest->userId;
- strcpy(AnsUser.gddm,lpJyDest->gddm);
- AnsUser.flag=(char)ret;
- memcpy(&SendBuff[len],&AnsUser,sizeof(JY_ANS_CHKUSR));
- len+=sizeof(AnsUser);
- UDP_SendBuff("检查交易用户", lpJyDest->sd, SendBuff, len,NULL);
- lpJyDest->isReqEnd =TRUE;
-
- //ClearReq(lpJyDest);
- return 0;
- }
-
- int JyDest_ChgPwd(LPJY_DEST lpJyDest)
- {
- BYTE SendBuff[100];
- int ret,len;
- JY_ANS_CHGPWD AnsChgPwd;
- // ReadRecord(AnsFile.hf[lpJyDest->zqsid],lpJyDest->recNum,hlen,
- // rlen,CommBuffer);
- // stat=CommBuffer[*(short*)(CommFile.fldStruct[fld_STAT].offset)];
- // if(stat !=';')
- // return 0;
- // FldToString(CommBuffer,&CommFile.fldStruct[fld_SERI],temp);
- // if(lpJyDest->jyNum!=atoi(temp))
- // return 0;
- //
- // ret=CommBuffer[*(short*)(CommFile.fldStruct[fld_ANSNO].offset)];
- // if(ret==' ')
- // return 0;
- REQUEST_BUFFER ReqBuf;
- ANSWER Answer;
- memset(&ReqBuf,0,rlen);
- memset(&Answer,0,sizeof(ANSWER));
- ReadRecord(ReqFile.hf[lpJyDest->zqsid],lpJyDest->recNum,
- hlen,rlen,(char *)&ReqBuf);
- if(ReqBuf.status !=' 02')
- return 0;
- // if(ReadRecord(AnsFile.hf[lpJyDest->zqsid],lpJyDest->recNum,
- // 0,sizeof(ANSWER),(char *)&Answer)!=0)
- // ret =-1;
- // else
- ret =ReqBuf.error;
-
- if(ret<0)
- ret =ANS_SYS_ERR;
- else
- ret =ANS_SUCC;
- AnsChgPwd.flag =(char)ret;
- AnsChgPwd.jys =lpJyDest->curJys;
-
- strcpy(SendBuff, JY_CHGPWD_HEAD);
- len =strlen(SendBuff);
- *(short *)&SendBuff[len] =lpJyDest->jyNum;
- len +=sizeof(short);
- strcpy(AnsChgPwd.gddm, lpJyDest->gddm);
- memcpy(&SendBuff[len], &AnsChgPwd, sizeof(AnsChgPwd));
- len +=sizeof(AnsChgPwd);
- UDP_SendBuff("修改交易密码", lpJyDest->sd, SendBuff, len, NULL);
- lpJyDest->isReqEnd =TRUE;
- // ClearReq(lpJyDest);
- return 0;
- }
-
- int JyDest_BuySell(LPJY_DEST lpJyDest)
- {
- char hthm[20];
- BYTE SendBuff[100];
- int ret, len;
- JY_ANS_BUYSELL AnsBuySell;
- /*
- ReadRecord(AnsFile.hf[lpJyDest->zqsid],lpJyDest->recNum,
- hlen,rlen,CommBuffer);
- stat=CommBuffer[*(short*)(CommFile.fldStruct[fld_STAT].offset)];
- if(stat !=';')
- return 0;
-
- FldToString(CommBuffer,&CommFile.fldStruct[fld_SERI],temp);
- if(lpJyDest->jyNum!=atoi(temp))
- return 0;
- ret=CommBuffer[*(short*)(CommFile.fldStruct[fld_ANSNO].offset)];
- if(ret==' ')
- return 0;
- hthm[0] =0;
- */
- REQUEST_BUFFER ReqBuf;
- ANSWER Answer;
- memset(&ReqBuf,0,rlen);
- memset(&Answer,0,sizeof(ANSWER));
- ReadRecord(ReqFile.hf[lpJyDest->zqsid],lpJyDest->recNum,
- hlen,rlen,(char *)&ReqBuf);
- if(ReqBuf.status !=' 02')
- return 0;
- if(ReadRecord(AnsFile.hf[lpJyDest->zqsid],lpJyDest->recNum,
- 0,sizeof(ANSWER),(char *)&Answer)!=0)
- ret =-1;
- else ret =ReqBuf.error;
- if(ret<0)
- {
- ret =ANS_SYS_ERR;
- }
- else
- {
- //FldToString(CommBuffer,&CommFile.fldStruct[fld_HTHM],hthm);
- //memset(temp,' ',(short)CommFile.fldStruct[fld_HTHM].wid);
- //if(strncmp(hthm,temp,(short)CommFile.fldStruct[fld_HTHM].wid)==0)
- // return 0;
- lpJyDest->zjye =Answer.a_ent_enter.current_balance;
- lpJyDest->kyje =Answer.a_ent_enter.enable_balance;
- sprintf(hthm,"%06d",ret);
- ret =ANS_SUCC;
- }
- AnsBuySell.jys=lpJyDest->curJys;
- strcpy(AnsBuySell.gddm,lpJyDest->gddm);
- strcpy(AnsBuySell.hthm,hthm);
- AnsBuySell.bs=REQ_BUYSEL;
- AnsBuySell.flag=(char)ret;
- strcpy(SendBuff, JY_BUYSELL_HEAD);
- len =strlen(SendBuff);
- *(short *)&SendBuff[len] =lpJyDest->jyNum;
- len +=sizeof(short);
-
- memcpy(&SendBuff[len],&AnsBuySell,sizeof(AnsBuySell));
- len+=sizeof(AnsBuySell);
-
- UDP_SendBuff("买卖委托", lpJyDest->sd, SendBuff, len, NULL);
- lpJyDest->isReqEnd =TRUE;
- //ClearReq(lpJyDest);
- return 0;
- }
-
- int JyDest_Cancel(LPJY_DEST lpJyDest)
- {
- BYTE SendBuff[600];
- int ret,len,retnum;
- JY_ANS_CANCEL AnsCancel;
- /*
- ReadRecord(AnsFile.hf[lpJyDest->zqsid],lpJyDest->recNum,
- hlen,rlen,CommBuffer);
- stat=CommBuffer[*(short*)(CommFile.fldStruct[fld_STAT].offset)];
- if(stat!=';')
- return 0;
- FldToString(CommBuffer,&CommFile.fldStruct[fld_SERI],temp);
- if(lpJyDest->jyNum!=atoi(temp))
- return 0;
- ret=CommBuffer[*(short*)(CommFile.fldStruct[fld_ANSNO].offset)];
- if(ret==' ')
- return 0;
- */
- REQUEST_BUFFER ReqBuf;
- ANSWER Answer;
- memset(&ReqBuf,0,rlen);
- memset(&Answer,0,sizeof(ANSWER));
- memset(&AnsCancel,0,sizeof(JY_ANS_CANCEL));
- ReadRecord(ReqFile.hf[lpJyDest->zqsid],lpJyDest->recNum,
- hlen,rlen,(char *)&ReqBuf);
- if(ReqBuf.status !=' 02')
- return 0;
- if(ReadRecord(AnsFile.hf[lpJyDest->zqsid],lpJyDest->recNum,
- 0,sizeof(ANSWER),(char *)&Answer)!=0)
- ret =-1;
- else ret =ReqBuf.error;
- //FldToString(CommBuffer,&CommFile.fldStruct[fld_JYMM],temp);
- //memset(tmp,' ',(short)CommFile.fldStruct[fld_JYMM].wid);
- //if(ret==ANS_SUCC&&strncmp(temp,tmp,(short)CommFile.fldStruct[fld_JYMM].wid)==0)
- // return 0;
- //retnum=atoi(temp);
- retnum =1;
- if(ret<0)
- {
- AnsCancel.flag[0] =ANS_SYS_ERR;
- }
- else
- {
- // if(retnum==1)
- // {
- // ret=CommBuffer[*(short*)(CommFile.fldStruct[fld_ANSNO].offset)];
- lpJyDest->zjye =Answer.a_ent_cancel.current_balance;
- lpJyDest->kyje =Answer.a_ent_cancel.enable_balance;
- AnsCancel.flag[0] =ANS_SUCC;
- // }
- /*
- else
- {
- wsprintf(temp,"%s%d%s",AnsFile.path[lpJyDest->zqsid],lpJyDest->recNum,".ANS");
- hFile =OpenFile(temp, &os, OF_SHARE_DENY_NONE|OF_READ);
- if(hFile ==HFILE_ERROR)
- return 0;
- i=_llseek(hFile, 0L, FILE_END);
- if(i==HFILE_ERROR)
- {
- _lclose(hFile);
- return 0;
- }
- if((i-1)/(rlen+1)!=retnum)
- {
- _lclose(hFile);
- return 0;
- }
- _llseek(hFile, 0L, FILE_BEGIN);
- for(i =0; i<retnum; i++)
- {
- if((short)_lread(hFile,&CommBuffer[1],rlen -1)!=rlen -1)
- break;
- ret=CommBuffer[*(int*)(CommFile.fldStruct[fld_ANSNO].offset)];
- AnsCancel.flag[i] =ret;
- _llseek(hFile, 2L, FILE_CURRENT);
- }
- _lclose(hFile);
- remove(temp);
- }
- */
- }
- AnsCancel.jys =lpJyDest->curJys;
- strcpy(AnsCancel.gddm, lpJyDest->gddm);
-
- strcpy(SendBuff, JY_CANCEL_HEAD);
- len =strlen(SendBuff);
- *(short *)&SendBuff[len] =lpJyDest->jyNum;
- len +=sizeof(short);
- memcpy(&SendBuff[len], &AnsCancel, sizeof(AnsCancel));
- len +=sizeof(AnsCancel);
- UDP_SendBuff("撤消委托", lpJyDest->sd, SendBuff, len,NULL);
- lpJyDest->isReqEnd =TRUE;
- // ClearReq(lpJyDest);
- return 0;
- }
-
- int JyDest_Yecx(LPJY_DEST lpJyDest)
- {
- JY_ANS_YECX AnsYecx;
- int ret, i,retnum;
- // ReadRecord(AnsFile.hf[lpJyDest->zqsid],lpJyDest->recNum,
- // hlen,rlen,CommBuffer);
- // stat=CommBuffer[*(short*)(CommFile.fldStruct[fld_STAT].offset)];
- // if(stat !=';')
- // return 0;
- // FldToString(CommBuffer,&CommFile.fldStruct[fld_SERI],temp);
- // if(lpJyDest->jyNum!=atoi(temp))
- // return 0;
- // ret=CommBuffer[*(short*)(CommFile.fldStruct[fld_ANSNO].offset)];
- // if(ret==' ')
- // return 0;
- // FldToString(CommBuffer,&CommFile.fldStruct[fld_JYMM],temp);
- // memset(tmp,' ',(short)CommFile.fldStruct[fld_JYMM].wid);
- // if(ret==ANS_SUCC&&strncmp(temp,tmp,(short)CommFile.fldStruct[fld_JYMM].wid)==0)
- // return 0;
- // retnum=atoi(temp);
- // if(ret==ANS_SUCC&&retnum>0)
- // {
- // wsprintf(tmp,"%s%d%s",AnsFile.path[lpJyDest->zqsid],lpJyDest->recNum,".ANS");
- // hFile =OpenFile(tmp, &os, OF_SHARE_DENY_NONE|OF_READ);
- //
- // if(hFile ==HFILE_ERROR)
- // return 0;
- //
- // i=_llseek(hFile, 0L, FILE_END);
- // if(i==HFILE_ERROR)
- // {
- // _lclose(hFile);
- // return 0;
- // }
- // if((i)/(rlen+1)<retnum)
- // {
- // _lclose(hFile);
- // return 0;
- // }
- // _llseek(hFile, 0L, FILE_BEGIN);
- // }
- REQUEST_BUFFER ReqBuf;
- ANSWER Answer;
- memset(&ReqBuf,0,rlen);
- memset(&Answer,0,sizeof(Answer));
- ReadRecord(ReqFile.hf[lpJyDest->zqsid],lpJyDest->recNum,
- hlen,rlen,(char *)&ReqBuf);
- if(ReqBuf.status !=' 02')
- return 0;
- ReadRecord(AnsFile.hf[lpJyDest->zqsid],lpJyDest->recNum,
- 0,sizeof(ANSWER),(char *)&Answer);
- ret =ReqBuf.error;
- AnsYecx.kys=lpJyDest->kyje;
- AnsYecx.zjye=lpJyDest->zjye;
- if(ret>=0)
- {
- retnum =ret;
- ret =ANS_SUCC;
- //FldToString(CommBuffer,&CommFile.fldStruct[fld_WTJG],temp);
- //AnsYecx.kys=atof(temp);
- //FldToString(CommBuffer,&CommFile.fldStruct[fld_WTGS],temp);
- //AnsYecx.zjye=atof(temp);
- if(retnum>0)
- {
- AnsYecx.lpGptg=GlobalAllocPtr(GHND,sizeof(JY_GPTG)*retnum);
- memset(&AnsYecx.lpGptg[0],0,sizeof(JY_GPTG)*retnum);
- }
- for(i=0;i<retnum && i<ITEMS;i++)
- {
- //if((short)_lread(hFile,&CommBuffer[1],rlen -1)!=rlen -1)
- // break;
- strcpy(AnsYecx.lpGptg[i].gpdm,Answer.a_inq_stock[i].stock_code);
- sprintf(AnsYecx.lpGptg[i].kys,"%8d",
- Answer.a_inq_stock[i].enable_balance);
- sprintf(AnsYecx.lpGptg[i].gpye,"%8d",
- Answer.a_inq_stock[i].current_balance);
- /*
- FldToString(CommBuffer,&CommFile.fldStruct[fld_GPDM],
- &AnsYecx.lpGptg[i].gpdm[0]);
- FldToString(CommBuffer,&CommFile.fldStruct[fld_WTGS],
- &AnsYecx.lpGptg[i].kys[0]);
- FldToString(CommBuffer,&CommFile.fldStruct[fld_WTJG],
- &AnsYecx.lpGptg[i].gpye[0]);
- FldToString(CommBuffer,&CommFile.fldStruct[fld_DATE],
- &AnsYecx.lpGptg[i].ghrq[0]);
- _llseek(hFile, 2L, FILE_CURRENT);
- */
- }
- // if(retnum>0)
- // {
- // _lclose(hFile);
- // remove(tmp);
- // }
- AnsYecx.recnum=i;
- AnsYecx.flag=ret;
- if(AnsYecx.recnum >=0)
- {
- lpJyDest->isSending =TRUE;
- Thrd_SendJycx(REQ_YECX, lpJyDest->sd, &AnsYecx, lpJyDest->jyNum);
- if(retnum>0)
- GlobalFreePtr(AnsYecx.lpGptg);
- lpJyDest->isSending =FALSE;
- }
- }
- else
- {
- AnsYecx.recnum=0;
- AnsYecx.flag=ANS_SUCC;
- lpJyDest->isSending =TRUE;
- Thrd_SendJycx(REQ_YECX, lpJyDest->sd, &AnsYecx, lpJyDest->jyNum);
- lpJyDest->isSending =FALSE;
- // lpJyDest->isReqEnd =TRUE;
- // ClearReq(lpJyDest);
- // return ret;
- }
- lpJyDest->isReqEnd =TRUE;
- return 0;
- }
-
- int JyDest_Cjcx(LPJY_DEST lpJyDest)
- {
- JY_ANS_CJCX AnsCjcx;
- int i, ret,retnum;
- /*
- ReadRecord(AnsFile.hf[lpJyDest->zqsid],lpJyDest->recNum,
- hlen,rlen,CommBuffer);
- stat=CommBuffer[*(short*)(CommFile.fldStruct[fld_STAT].offset)];
- if(stat !=';')
- return 0;
- FldToString(CommBuffer,&CommFile.fldStruct[fld_SERI],temp);
- if(lpJyDest->jyNum!=atoi(temp))
- return 0;
- ret=CommBuffer[*(short*)(CommFile.fldStruct[fld_ANSNO].offset)];
- if(ret==' ')
- return 0;
- FldToString(CommBuffer,&CommFile.fldStruct[fld_JYMM],temp);
- memset(tmp,' ',(short)CommFile.fldStruct[fld_JYMM].wid);
- if(ret==ANS_SUCC&&strncmp(temp,tmp,(short)CommFile.fldStruct[fld_JYMM].wid)==0)
- return 0;
- retnum=atoi(temp);
- if(ret==ANS_SUCC&&retnum>0)
- {
- wsprintf(tmp,"%s%d%s",AnsFile.path[lpJyDest->zqsid],lpJyDest->recNum,".ANS");
- hFile =OpenFile(tmp, &os, OF_SHARE_DENY_NONE|OF_READ);
- if(hFile ==HFILE_ERROR)
- return 0;
- i=_llseek(hFile, 0L, FILE_END);
- if(i==HFILE_ERROR)
- {
- _lclose(hFile);
- return 0;
- }
- if((i)/(rlen+1)<retnum)
- {
- _lclose(hFile);
- return 0;
- }
- _llseek(hFile, 0L, FILE_BEGIN);
- }
- */
- REQUEST_BUFFER ReqBuf;
- ANSWER Answer;
- memset(&ReqBuf,0,rlen);
- ReadRecord(ReqFile.hf[lpJyDest->zqsid],lpJyDest->recNum,
- hlen,rlen,(char *)&ReqBuf);
- if(ReqBuf.status !=' 02')
- return 0;
- memset(&Answer,0,sizeof(Answer));
- ReadRecord(AnsFile.hf[lpJyDest->zqsid],lpJyDest->recNum,
- 0,sizeof(ANSWER),(char *)&Answer);
- ret =ReqBuf.error;
- if(ret>=0)
- {
- retnum =ret;
- ret =ANS_SUCC;
- if(retnum>0)
- {
- AnsCjcx.lpCj=GlobalAllocPtr(GHND,sizeof(JY_CJ)*retnum);
- memset(&AnsCjcx.lpCj[0],0,sizeof(JY_CJ)*retnum);
- }
- for(i=0;i<retnum && i<ITEMS;i++)
- {
- //memset(CommBuffer,0,sizeof(CommBuffer));
- //if((short)_lread(hFile,&CommBuffer[1],rlen -1)!=rlen -1)
- // break;
- //if(Answer.a_inq_real[i].real_status =='2')
- // continue;
- sprintf(AnsCjcx.lpCj[i].hthm,"%06d",
- Answer.a_inq_real[i].serial_no);
- sprintf(AnsCjcx.lpCj[i].cjsj,"%06d",
- Answer.a_inq_real[i].business_time);
- AnsCjcx.lpCj[i].mmbz=(Answer.a_inq_real[i].bs=='1')?'B':'S';
- strcpy(AnsCjcx.lpCj[i].gpdm,
- Answer.a_inq_real[i].stock_code);
- sprintf(AnsCjcx.lpCj[i].cjgs,"%8d",
- Answer.a_inq_real[i].business_amount);
- sprintf(AnsCjcx.lpCj[i].cjjg,"%6.2f",
- Answer.a_inq_real[i].business_price);
- /*
- FldToString(CommBuffer,&CommFile.fldStruct[fld_HTHM],
- &AnsCjcx.lpCj[i].hthm[0]);
- FldToString(CommBuffer,&CommFile.fldStruct[fld_DATE],
- &AnsCjcx.lpCj[i].cjsj[0]);
- AnsCjcx.lpCj[i].mmbz=
- CommBuffer[*(short*)(CommFile.fldStruct[fld_ANSNO].offset)];
- FldToString(CommBuffer,&CommFile.fldStruct[fld_GPDM],
- &AnsCjcx.lpCj[i].gpdm[0]);
- FldToString(CommBuffer,&CommFile.fldStruct[fld_WTGS],
- &AnsCjcx.lpCj[i].cjgs[0]);
- FldToString(CommBuffer,&CommFile.fldStruct[fld_WTJG],
- &AnsCjcx.lpCj[i].cjjg[0]);
- _llseek(hFile, 2L, FILE_CURRENT);
- */
- }
- AnsCjcx.recnum=i;
- AnsCjcx.flag =ret;
- if(AnsCjcx.recnum >=0)
- {
- lpJyDest->isSending =TRUE;
- Thrd_SendJycx(REQ_CJCX, lpJyDest->sd, &AnsCjcx, lpJyDest->jyNum);
- if(retnum>0)
- GlobalFreePtr(AnsCjcx.lpCj);
- lpJyDest->isSending =FALSE;
- }
- }
- else
- {
- AnsCjcx.recnum=0;
- AnsCjcx.flag =ANS_SUCC;
- lpJyDest->isSending =TRUE;
- Thrd_SendJycx(REQ_CJCX, lpJyDest->sd, &AnsCjcx, lpJyDest->jyNum);
- lpJyDest->isSending =FALSE;
- }
- lpJyDest->isReqEnd =TRUE;
- return 0;
- }
- int JyDest_Wtcx(LPJY_DEST lpJyDest)
- {
- JY_ANS_WTCX AnsWtcx;
- int ret, i,retnum;
- /*
- ReadRecord(AnsFile.hf[lpJyDest->zqsid],lpJyDest->recNum,
- hlen,rlen,CommBuffer);
- stat=CommBuffer[*(short*)(CommFile.fldStruct[fld_STAT].offset)];
- if(stat !=';')
- return 0;
- FldToString(CommBuffer,&CommFile.fldStruct[fld_SERI],temp);
- if(lpJyDest->jyNum!=atoi(temp)) return 0;
- ret=CommBuffer[*(short*)(CommFile.fldStruct[fld_ANSNO].offset)];
- if(ret==' ')
- return 0;
- FldToString(CommBuffer,&CommFile.fldStruct[fld_JYMM],temp);
- memset(tmp,' ',(short)CommFile.fldStruct[fld_JYMM].wid);
- if(ret==ANS_SUCC&&strncmp(temp,tmp,(short)CommFile.fldStruct[fld_JYMM].wid)==0)
- return 0;
- retnum=atoi(temp);
- if(ret==ANS_SUCC&&retnum>0)
- {
- wsprintf(temp,"%s%d%s",AnsFile.path[lpJyDest->zqsid],lpJyDest->recNum,".ANS");
- hFile =OpenFile(temp, &os, OF_SHARE_DENY_NONE|OF_READ);
- if(hFile ==HFILE_ERROR)
- return 0;
- i=_llseek(hFile, 0L, FILE_END);
- if(i==HFILE_ERROR)
- {
- _lclose(hFile);
- return 0;
- }
- if((i)/(rlen+1)<retnum)
- {
- _lclose(hFile);
- return 0;
- }
- _llseek(hFile, 0L, FILE_BEGIN);
- }
- */
- REQUEST_BUFFER ReqBuf;
- ANSWER Answer;
- memset(&ReqBuf,0,rlen);
- ReadRecord(ReqFile.hf[lpJyDest->zqsid],lpJyDest->recNum,
- hlen,rlen,(char *)&ReqBuf);
- if(ReqBuf.status !=' 02')
- return 0;
- memset(&Answer,0,sizeof(Answer));
- ReadRecord(AnsFile.hf[lpJyDest->zqsid],lpJyDest->recNum,
- 0,sizeof(ANSWER),(char *)&Answer);
- ret =ReqBuf.error;
- if(ret>=0)
- {
- retnum =ret;
- ret =ANS_SUCC;
- if(retnum>0)
- {
- AnsWtcx.lpWt =GlobalAllocPtr(GHND,sizeof(JY_WT)*retnum);
- memset(&AnsWtcx.lpWt[0], 0, sizeof(JY_WT)*retnum);
- }
- for(i=0;i<retnum && i<ITEMS;i++)
- {
- //if(Answer.a_inq_entrust[i].entrust_status=='4')
- // continue;
- sprintf(AnsWtcx.lpWt[i].hthm,"%06d",
- Answer.a_inq_entrust[i].entrust_serial_no);
- sprintf(AnsWtcx.lpWt[i].wtsj," : : ");
- AnsWtcx.lpWt[i].mmbz=
- (Answer.a_inq_entrust[i].entrust_bs=='1')?'B':'S';
- strcpy(AnsWtcx.lpWt[i].gpdm,
- Answer.a_inq_entrust[i].stock_code);
- sprintf(AnsWtcx.lpWt[i].wtgs,"%8d",
- Answer.a_inq_entrust[i].entrust_amount);
- sprintf(AnsWtcx.lpWt[i].wtjg,"%6.2f",
- Answer.a_inq_entrust[i].entrust_price);
- /*
- memset(CommBuffer,0,sizeof(CommBuffer));
- if((short)_lread(hFile,&CommBuffer[1],rlen -1)!=rlen -1)
- break;
- FldToString(CommBuffer,&CommFile.fldStruct[fld_HTHM],
- &AnsWtcx.lpWt[i].hthm[0]);
- FldToString(CommBuffer,&CommFile.fldStruct[fld_DATE],
- &AnsWtcx.lpWt[i].wtsj[0]);
- AnsWtcx.lpWt[i].mmbz=
- CommBuffer[*(short*)(CommFile.fldStruct[fld_ANSNO].offset)];
- FldToString(CommBuffer,&CommFile.fldStruct[fld_GPDM],
- &AnsWtcx.lpWt[i].gpdm[0]);
- FldToString(CommBuffer,&CommFile.fldStruct[fld_WTGS],
- &AnsWtcx.lpWt[i].wtgs[0]);
- FldToString(CommBuffer,&CommFile.fldStruct[fld_WTJG],
- &AnsWtcx.lpWt[i].wtjg[0]);
- _llseek(hFile, 2L, FILE_CURRENT);
- */
- }
- AnsWtcx.recnum=i;
- AnsWtcx.flag =ret;
- if(AnsWtcx.recnum >=0)
- {
- lpJyDest->isSending =TRUE;
- Thrd_SendJycx(REQ_WTCX, lpJyDest->sd, &AnsWtcx, lpJyDest->jyNum);
- if(AnsWtcx.recnum>0)
- GlobalFreePtr(AnsWtcx.lpWt);
- lpJyDest->isSending =FALSE;
- }
- }
- else
- {
- AnsWtcx.recnum=0;
- AnsWtcx.flag =ANS_SUCC;
- lpJyDest->isSending =TRUE;
- Thrd_SendJycx(REQ_WTCX, lpJyDest->sd, &AnsWtcx, lpJyDest->jyNum);
- lpJyDest->isSending =FALSE;
- }
- lpJyDest->isReqEnd =TRUE;
- return 0;
- }
- int Thrd_SendJycx(int reqType, int sd, char *lpBuf, int jyNum)
- {
- char SendBuff[2048];
- LPJY_ANS_YECX lpAnsYecx;
- LPJY_ANS_CJCX lpAnsCjcx;
- LPJY_ANS_WTCX lpAnsWtcx;
- int i, len, recCount, sendCount, sendNum;
- sendNum =0;
- sendCount =MAX_CX_SENDCOUNT;
- switch(reqType)
- {
- case REQ_YECX:
- lpAnsYecx =(LPJY_ANS_YECX)lpBuf;
- recCount =lpAnsYecx->recnum;
- for(i =0; i<=recCount/MAX_CX_SENDCOUNT; i++)
- {
- sendNum =i*MAX_CX_SENDCOUNT;
- if(sendNum+sendCount >recCount)
- sendCount =recCount-sendNum;
- strcpy(SendBuff, JY_YECX_HEAD);
- len =strlen(SendBuff);
- *(short *)&SendBuff[len] =jyNum;
- len +=sizeof(short);
- lpAnsYecx->recnum=sendCount;
- memcpy(&SendBuff[len],lpAnsYecx,sizeof(JY_ANS_YECX)-sizeof(LPJY_GPTG));
- len+=sizeof(JY_ANS_YECX)-sizeof(LPJY_GPTG);
- if(sendCount==0&&sendNum!=0)
- break;
- if(sendCount>0)
- {
- memcpy(&SendBuff[len], &lpAnsYecx->lpGptg[sendNum],
- sizeof(JY_GPTG)*sendCount);
- len +=sizeof(JY_GPTG)*sendCount;
- }
- if(UDP_SendBuff("余额查询", sd, SendBuff, len,NULL)<0)
- return -1;
- }
- break;
- case REQ_CJCX:
- lpAnsCjcx =(LPJY_ANS_CJCX)lpBuf;
- recCount =lpAnsCjcx->recnum;
- sendCount =MAX_CX_SENDCOUNT;
- for(i =0; i<=recCount/MAX_CX_SENDCOUNT; i++)
- {
- sendNum =i*MAX_CX_SENDCOUNT;
- if(sendNum+sendCount >recCount)
- sendCount =recCount-sendNum;
- strcpy(SendBuff, JY_CJCX_HEAD);
- len =strlen(SendBuff);
- *(short *)&SendBuff[len] =jyNum;
- len +=sizeof(short);
- lpAnsCjcx->recnum=sendCount;
- memcpy(&SendBuff[len],lpAnsCjcx,sizeof(JY_ANS_CJCX)-sizeof(LPJY_CJ));
- len+=sizeof(JY_ANS_CJCX)-sizeof(LPJY_CJ);
- if(sendCount==0&&sendNum!=0)
- break;
- if(sendCount>0)
- {
- memcpy(&SendBuff[len], &lpAnsCjcx->lpCj[sendNum],
- sizeof(JY_CJ)*sendCount);
- len +=sizeof(JY_CJ)*sendCount;
- }
- if(UDP_SendBuff("成交查询", sd, SendBuff, len,NULL)<0)
- return -1;
- }
- break;
- case REQ_WTCX:
- lpAnsWtcx =(LPJY_ANS_WTCX)lpBuf;
- recCount =lpAnsWtcx->recnum;
- sendCount =MAX_CX_SENDCOUNT;
- for(i =0; i<=recCount/MAX_CX_SENDCOUNT; i++)
- {
- sendNum =i*MAX_CX_SENDCOUNT;
- if(sendNum+sendCount >recCount)
- sendCount =recCount-sendNum;
- strcpy(SendBuff, JY_WTCX_HEAD);
- len =strlen(SendBuff);
- *(short *)&SendBuff[len] =jyNum;
- len +=sizeof(short);
- lpAnsWtcx->recnum=sendCount;
- memcpy(&SendBuff[len],lpAnsWtcx,sizeof(JY_ANS_WTCX)-sizeof(LPJY_WT));
- len+=sizeof(JY_ANS_WTCX)-sizeof(LPJY_WT);
- if(sendCount>0)
- {
- memcpy(&SendBuff[len], &lpAnsWtcx->lpWt[sendNum],
- sizeof(JY_WT)*sendCount);
- len +=sizeof(JY_WT)*sendCount;
- }
- if(sendCount==0&&sendNum!=0)
- break;
- if(UDP_SendBuff("委托查询", sd, SendBuff, len,NULL)<0)
- return -1;
- }
- break;
- }
- strcpy(SendBuff, JY_CXEND_HEAD);
- len =strlen(SendBuff);
- UDP_SendBuff("查询成功", sd, SendBuff, len,NULL);
- return 0;
- }
- int Jy_SendRet(int sd, char reqType, char ret, int jyNum)
- {
- int len;
- BYTE SendBuff[100];
- LPSTR lpHead;
-
- if(ret ==ANS_TIME_OUT)
- lpHead =JY_TIMEOUT_HEAD;
- else
- switch(reqType)
- {
- case REQ_CHKUSR:
- lpHead =JY_CHKUSR_HEAD;
- break;
- case REQ_CHGPWD:
- lpHead =JY_CHGPWD_HEAD;
- break;
- case REQ_BUYSEL:
- lpHead =JY_BUYSELL_HEAD;
- break;
- case REQ_CANCEL:
- lpHead =JY_CANCEL_HEAD;
- break;
- case REQ_YECX:
- lpHead =JY_YECX_HEAD;
- break;
- case REQ_CJCX:
- lpHead =JY_CJCX_HEAD;
- break;
- case REQ_WTCX:
- lpHead =JY_WTCX_HEAD;
- break;
- }
- strcpy(SendBuff, lpHead);
- len =strlen(SendBuff);
- *(short *)&SendBuff[len] =jyNum;
- len +=sizeof(short);
- SendBuff[len++] =(char)ret;
- UDP_SendBuff("发送结果", sd, SendBuff, len,NULL);
- return 0;
- }