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

📄 spdsi.cpre

📁 商业银行前置系统
💻 CPRE
字号:
/* * This is a part of the Application Preconsole * - Service Provide - DSI. * Copyright (C) 2000-2000 ABC.SDC. * All rights reserved. * * This source code is only intended as a supplement to the * Application Preconsole Reference and related * electronic documentation provided with the library. * See these sources for detailed information regarding the * Application Preconsole product.  * * Update record: * 2002-2-4   HLW  - Communication of DSI *                   cics program */ #include <sybtesql.h> #include "ap.h"EXEC SQL INCLUDE sqlca;EXEC SQL INCLUDE "dsi.h";/* * Constant macros defined in this file *//* * Message constant macros */#define MSG_INIT "MSG_INIT"/* * Second constant macros */#define SEC_TIMEOUT 50/* * Dsi calling function */RESULT SendMsg(PVOID pMsg, UINT nSize){    UINT nSock;    char szSize[4 + 1];    char szPort[LEN_PORT + 1];        ASSERT_NORMAL(AP_DEMAND_CFG(PATH_SERVICEPORT, szPort));    ASSERT_NORMAL(ConnectSock(&nSock, atol(szPort), "127.0.0.1"));    sprintf(szSize, "%04d", nSize);    if (!VERIFY_NORMAL(WriteFile(nSock, szSize, 4)) ||        !VERIFY_NORMAL(WriteFile(nSock, pMsg, nSize)))    {        close(nSock);        return EXCEPTION;    }    close(nSock);    return NORMAL;}RESULT CallDsi(PISO8583STRU piso8583stru){        char cMsg[SIZE_MSG_ISO8583];    UINT nSize;    char szDelayId[8 + 1];    char szTsqName[8 + 1];    char szTraceNo[SIZE_TRACENO + 1];    short sSize;    unsigned long lRespCode;    bufclr(szDelayId);    bufclr(szTsqName);    bufclr(szTraceNo);        nSize = SIZE_TRACENO;    GetBitInIso8583(piso8583stru, BIT_TRACENO, szTraceNo, &nSize);        strcpy(szDelayId, "DD");    strncat(szDelayId, szTraceNo, SIZE_TRACENO);        strcpy(szTsqName, "QD");    strncat(szTsqName, szTraceNo, SIZE_TRACENO);        bufclr(cMsg);    nSize = sizeof(cMsg);    ASSERT_NORMAL(ExportIso8583(piso8583stru, cMsg, &nSize));    /*     * 向DSC 发送请求报文。如果发送成功,而此后发生异常,都必须返回     * UNKNOWN 。     */    ASSERT_NORMAL(SendMsg(cMsg, nSize));    strcpy(cMsg, MSG_INIT);    EXEC CICS ADDRESS EIB(dfheiptr);    EXEC CICS WRITEQ TS QUEUE(szTsqName) FROM(cMsg) LENGTH(strlen(cMsg))               RESP(lRespCode);    if (!VERIFY(lRespCode == DFHRESP(NORMAL)))        return UNKNOWN;        /*     * 等待接收DSC 应答报文。     */    EXEC CICS DELAY FOR SECONDS(SEC_TIMEOUT) REQID(szDelayId)              RESP(lRespCode);    if (!VERIFY(lRespCode == DFHRESP(NORMAL)) && lRespCode != DFHRESP(EXPIRED))    {        EXEC CICS DELETEQ TS QUEUE(szTsqName);        return UNKNOWN;    }    /*     * 读TSQ 中的应答报文。     */        sSize = sizeof(cMsg);    bufclr(cMsg);    EXEC CICS READQ TS QUEUE(szTsqName) INTO(cMsg) ITEM(1) LENGTH(sSize)              RESP(lRespCode);    if (!VERIFY(lRespCode == DFHRESP(NORMAL)))    {        EXEC CICS DELETEQ TS QUEUE(szTsqName);        return UNKNOWN;    }    EXEC CICS DELETEQ TS QUEUE(szTsqName);    /*     * 如果TSQ 中报文发生变化,则解析应答报文。     */    if (strncmp(cMsg, MSG_INIT, strlen(MSG_INIT)) == 0)        return UNKNOWN;    if (!VERIFY_NORMAL(ImportIso8583(piso8583stru, cMsg, sSize)))        return UNKNOWN;       return NORMAL;}/*  * main function */  void main(){    char *pcCommArea;    UINT nSize;    RESULT rTemp;    ISO8583STRU iso8583stru;                         EXEC CICS ADDRESS EIB(dfheiptr);    EXEC CICS ADDRESS COMMAREA(pcCommArea);        if (!VERIFY_NULL(pcCommArea) ||        !VERIFY((nSize = dfheiptr->eibcalen) == SIZE_MSG_ISO8583))        EXEC CICS RETURN;    memset(&iso8583stru, 0, sizeof(ISO8583STRU));        if (!VERIFY_NORMAL(CreateIso8583(&iso8583stru, ifistruDsi)) ||        !VERIFY_NORMAL(ImportIso8583(&iso8583stru, pcCommArea, nSize)))    {        strcpy(pcCommArea, "EC0996");        DeleteIso8583(&iso8583stru);        EXEC CICS RETURN;                }            if (!VERIFY((rTemp = CallDsi(&iso8583stru)) != UNKNOWN))        strcpy(pcCommArea, "EC0999");    else if (!VERIFY_NORMAL(rTemp))        strcpy(pcCommArea, "EC0996");        else        ExportIso8583(&iso8583stru, pcCommArea, &nSize);        DeleteIso8583(&iso8583stru);    EXEC CICS RETURN;            }    /* End of this file */

⌨️ 快捷键说明

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