⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stock_0214.ec

📁 证券交易系统
💻 EC
字号:
 /* * 证券交易系统,城综网帐户信息校验 打包解包模块() * 帐户种类: 储蓄卡 */#include <stdlib.h>#include <stdio.h>#include <sys/time.h>#include "../incl/lu62.h"#include "../incl/bank.h"$include sqlca;extern   SEND_NET_0214   send_net_0214;extern   RECV_NET_0214   recv_net_0214;#define  ASCII           "IBM-eucCN"      /* ASCII code page               **/#define  EBCDIC          "IBM-935"        /* EBCDIC (Host) code page       **/#define  A2E             1                /* translate ASCII to EBCDIC     **/#define  E2A             2                /* translate EBCDIC to ASCII     **/#define  HEADLEN         7extern   WORKER   *wk;extern  int cm_rc;#define  MAX_BUFFERSIZE   2048extern  int get_host_trace( char * );void GetFileName();int   end_flag;char  worker1[6],FileName[19];tohost_stock_0214(worker)char  *worker;{        int            i,sendlen,recvlen,net_err;        unsigned char  sendstr[512],recvstr[4096];        strcpy(worker1,worker);        worker1[6]='\0';        i = inq_acc_0214( sendstr, &sendlen );        if ( i < 0 ) {            WriteLog ( LOGFILE,"inq_acc_0214 err!");            return ( -1 );        }        return ( 0 );}int inq_acc_0214 ( sendstr,sendlen )int  *sendlen;unsigned char *sendstr; {        int             recvlen,net_err,retcode,loop,length, i;        char            sideinfo[9] = "CCBJZQDJ",str[100]  ;        unsigned char   recvstr[4096];        end_flag = 0;        if ( pack_host_inq_0214(sendstr, &sendlen ) )        {             WriteLog ( LOGFILE,"pack_host_inq_0214 err!");             return ( -1 );        }        retcode = LUFunction(LU_ALLOC, sideinfo, NULL, NULL);        WriteLog ( LOGFILE,"检查LU连路结束!");        if (retcode != 0)            {           strcpy ( send_net_0214.retcode, "8999" );           strcpy ( send_net_0214.errmsg,"系统错误");           WriteLog ( LOGFILE,"LU_ALLOC err:[%d]",retcode);           return(-1);        }        retcode = LUFunction(LU_SEND, &sendlen, sendstr);        WriteLog ( LOGFILE,"向9000发送数据结束!");             if (retcode != 0)        {            LUFunction(LU_FREE);            strcpy ( send_net_0214.retcode, "8999" );            strcpy ( send_net_0214.errmsg,"系统错误");            WriteLog ( LOGFILE,"LU_SEND err:[%d]",retcode);            return(-1);        }        for ( ; end_flag == 0; )        {           length = MAX_BUFFERSIZE;           retcode = LUFunction(LU_RECEIVE, &length, recvstr);           WriteLog ( LOGFILE,"接收9000返回数据结束!");                              if (retcode != 0)            {               LUFunction(LU_FREE);               strcpy ( send_net_0214.retcode, "8999" );               strcpy ( send_net_0214.errmsg,"系统错误");               WriteLog ( LOGFILE,"LU_RECEIVE err:[%d]",retcode);               return(-1);           }           if ( unpk_host_inq_0214(recvstr,length)<0 ) return (-1);         }/*        for ( ; end_flag == 0; )        {           length = MAX_BUFFERSIZE;           retcode = LUFunction(LU_RECEIVE, &length, recvstr);           WriteLog ( LOGFILE,"接收9000返回数据结束!");                              if (retcode != 0)            {               LUFunction(LU_FREE);               strcpy ( send_net_0214.retcode, "8999" );               strcpy ( send_net_0214.errmsg,"系统错误");               WriteLog ( LOGFILE,"LU_RECEIVE err:[%d]",retcode);               return(-1);           }           if ( unpk_host_inq_0214(recvstr,length)<0 ) return (-1);         }*/        /* 将该文件传送到代理集中点主机 ?????*/       sendlen = 1;       strcpy(sendstr,"1");        retcode = LUFunction(LU_SENDTRUE, &sendlen, sendstr);       WriteLog ( LOGFILE,"向9000发送确认数据结束!");            if (retcode != 0)       {           LUFunction(LU_FREE);           strcpy ( send_net_0214.retcode, "8999" );           strcpy ( send_net_0214.errmsg,"系统错误");           WriteLog ( LOGFILE,"LU_SENDTRUE err:[%d]",retcode);           return(-1);       }        LUFunction(LU_FREE);        return(0);}int pack_host_inq_0214(sendbuf, sendlen)int           *sendlen;unsigned char *sendbuf;{        int         len, i;        char        tmp[256];        char        merchant_id[10],host_ls[7];        char        worker_4[5], active[2];        char        amount[13];        char        tmp_pan2[4];        struct      head hd;        memcpy( sendbuf, headstr_duizh( hd ), 4 );         memcpy( tmp, worker1, 4);        tmp[5] = '\0';        len = Hmeg( sendbuf, 4, tmp, 0x41 );        sendbuf[ len++ ] = 0xff;                                 /*  结束标志 */        *sendlen = len;        return (0);}int   unpk_host_inq_0214(recvbuf, recvlen )short                 recvlen;unsigned char        *recvbuf;{        int     flag,i, j, result, retcode,iLen;        char    err1[10], err2[10],record[100],*temp,check[2];        char    xm[10],sfz[20],dz[16],ztbz[4],*t_req_ls,*t1;        double  dou_amount;       $char    t_req_serial[16],t_host_serial[7],t_ans_serial[7];        $char   t_trans_type[5];        $char   t_acco_type[2] ;        struct  duizh duizh_rec;        FILE    *fp;        result = 1;        /* packet format error */        if (    recvbuf[ 0 ] != 0x03 ||                recvbuf[ 1 ] != 0x00 ||                recvbuf[ 2 ] <  0x00 ||                recvbuf[ 2 ] >  0x09 &&                 recvbuf[ 2 ] != 0x0f )         {                strcpy ( send_net_0214.retcode, "8999" );                strcpy ( send_net_0214.errmsg,"系统错误");                return( -1 );        }        /* Accept by host */        if ( recvbuf[ 2 ] == 0x09 || recvbuf[ 2 ] == 0x00) {                                      if ( recvbuf[ 2 ] == 0x09 )  end_flag = 1;             GetFileName();             fp = fopen( (char *)getfname( WORKDIR, FileName), "a" );             if(fp == NULL)             {                 WriteLog(LOGFILE,"fopen file error");                 return(-1);             }             printf("WORKDIR is  [%s]\n",WORKDIR);             printf("FileName is [%s]\n",FileName);             for( i = 0; i<3 ; i++)  *recvbuf ++;             for( i = 0; i<=30 ; i++)             {                  strncpy( check, recvbuf , 1);                  check[1] = '\0';                  for (j=0;check[j]!='\0';j++)                  check[j] = 0x30 + ( 0x0f & check[j] );                  if( strncmp(check,":",1) != 0 )  break;                  *recvbuf ++;                  strncpy(duizh_rec.trans_type, recvbuf , 4);                  duizh_rec.trans_type[4] = '\0';                  for (j=0;duizh_rec.trans_type[j]!='\0';j++)                  duizh_rec.trans_type[j]                                  = 0x30 + ( 0x0f & duizh_rec.trans_type[j] );                  for ( j = 0 ; j < 4 ; j++ ) *recvbuf ++;                  strncpy( duizh_rec.acco_type,  recvbuf , 1);                  duizh_rec.acco_type[1] = '\0';                  for (j=0;duizh_rec.acco_type[j]!='\0';j++)                  duizh_rec.acco_type[j]                                  = 0x30 + ( 0x0f & duizh_rec.acco_type[j] );                  for ( j = 0 ; j < 1 ; j++ ) *recvbuf ++;                  strncpy( duizh_rec.account,    recvbuf , 19);                  duizh_rec.account[19] = '\0';                  for (j=0;duizh_rec.account[j]!='\0';j++)                  duizh_rec.account[j]                                  = 0x30 + ( 0x0f & duizh_rec.account[j] );                  for ( j = 0 ; j < 19; j++ ) *recvbuf ++;                  strncpy( duizh_rec.amount,     recvbuf , 15);                  duizh_rec.amount[15] = '\0';                  for (j=0;duizh_rec.amount[j]!='\0';j++)                  duizh_rec.amount[j]                                  = 0x30 + ( 0x0f & duizh_rec.amount[j] );                  for ( j = 0 ; j < 15; j++ ) *recvbuf ++;                  dou_amount = atof(duizh_rec.amount)/100;                  sprintf(duizh_rec.amount,"%.2f",dou_amount);                  strncpy( duizh_rec.host_ls,    recvbuf , 6);                  duizh_rec.host_ls[6] = '\0';                  for (j=0;duizh_rec.host_ls[j]!='\0';j++)                  duizh_rec.host_ls[j]                                  = 0x30 + ( 0x0f & duizh_rec.host_ls[j] );                  for ( j = 0 ; j < 6 ; j++ ) *recvbuf ++;                  strncpy( duizh_rec.worker_id,recvbuf , 6);                  duizh_rec.worker_id[6] = '\0';                  for (j=0;duizh_rec.worker_id[j]!='\0';j++)                  duizh_rec.worker_id[j]                                  = 0x30 + ( 0x0f & duizh_rec.worker_id[j] );                  for ( j = 0 ; j < 6 ; j++ ) *recvbuf ++;                  strcpy( t_host_serial, duizh_rec.host_ls);                  t_host_serial[6] = '\0';                  strcpy(duizh_rec.trans_type,"0");                  EXEC SQL SELECT   req_serial,ans_serial,trans_type,acco_type                           INTO    $t_req_serial,$t_ans_serial,                                   $t_trans_type,$t_acco_type                            FROM     t_stock_serial                           WHERE    host_serial = $t_host_serial 			   AND chong_flag[1] = "0";                  if(sqlca.sqlcode)                     continue;                  iLen = atoi(t_host_serial);                  sprintf(t_host_serial,"%d",iLen);                  fprintf(fp,"%s|%c|%s|%s|%s|%s|\n",                          t_trans_type,                           t_acco_type[0],                           duizh_rec.account,                          duizh_rec.amount,                          t_req_serial,                           t_host_serial);             }             fclose( fp );        }        /* Reject by host */        else {                result = -1;                for( i = 7, j = 0; i < 11; i++, j++ ) err1[ j ] = recvbuf[ i ];                asc( err1, 4, err2 );                result = atoi( err2 );                strcpy ( send_net_0214.retcode, "8001" );                strcpy ( send_net_0214.errmsg,"无效交易");                return(result);        }        return(0);}void GetFileName(){     struct timeval tv;     time_t clock;     struct tm *tm1;     gettimeofday(&tv,0);     clock = tv.tv_sec;     tm1 = localtime( &clock );     strftime(FileName,19,"/data/%Y%m%d.SBS",tm1);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -