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

📄 caatm.cpre

📁 商业银行前置系统
💻 CPRE
字号:
/* * This is a part of the Application Preconsole * - Channel Access - ATM. * 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: * 2001-08-05 TianLei       - create implementation file */#include <sybtesql.h>#include "ap.h"EXEC SQL INCLUDE sqlca;EXEC SQL INCLUDE "atm.h";/* * Types and structures defined in this file */typedef struct tagMSGSIZESTRU{    PCSTR pszMsgId;    UINT nMsgSize;} MSGSIZESTRU;typedef MSGSIZESTRU *        PMSGSIZESTRU;typedef const MSGSIZESTRU    CMSGSIZESTRU;typedef const MSGSIZESTRU *  PCMSGSIZESTRU;/* * Variables declared in this file */MSGSIZESTRU msgsizestru[] = {    {"ARQK", sizeof(RQKSTRU)},    {"ACWD", sizeof(CWDSTRU)},    {"ATFR", sizeof(TFRSTRU)},    {"AINQ", sizeof(INQSTRU)},    {"ACWC", sizeof(CWCSTRU)},    {"APIN", sizeof(PINSTRU)},    {"AAEX", sizeof(AEXSTRU)},    {"AOEX", sizeof(OEXSTRU)},    {"AMSR", sizeof(MSRSTRU)},    {"ARQF", sizeof(RQFSTRU)},    {"ARFM", sizeof(RFMSTRU)},    {"ADEP", sizeof(DEPSTRU)},    {"ADPC", sizeof(DPCSTRU)},    {NULL  , 0              }};RESULT GetMsgSize(PCSTR pszMsgId, PUINT pnMsgSize){    UINT n = 0;        while (msgsizestru[n].pszMsgId != NULL)    {       if (strcmp(pszMsgId, msgsizestru[n].pszMsgId) == 0)       {           *pnMsgSize = msgsizestru[n].nMsgSize;           return NORMAL;       }       n++;    }    return INVALID;}#define ASSURE(b) \    { \        if (!VERIFY(b)) \        { \            close(nSock); \            return EXCEPTION; \        } \    }#define ASSURE_NORMAL(r) \    { \        RESULT rTemp = (r); \        if (!VERIFY_NORMAL(rTemp)) \        { \            close(nSock); \            return rTemp; \        } \    }BOOL bShutdown = FALSE;RESULT main(UINT nArgCnt, PSTR pszArgVal[]){    COMMAREASTRU commareastru;    pid_t _pid_tChild;        char szData[SIZE_MSG_ATM + 1];     char szPort[LEN_PORT + 1];     char szAddr[LEN_ADDR + 1];      char cMsg[AP_SIZE_COMMAREA];              UINT nListenSock;    UINT nSock, i;    UINT nSize, nMsgSize;            bufclr(szData);    bufclr(szPort);    bufclr(szAddr);    DETECT(nArgCnt == 2);    DETECT(strlen(pszArgVal[1]) == 4);    DETECT(memcmp(pszArgVal[1], "AP", 2) == 0);    PrintLog(stdout, "caatm: service is starting...");    ASSERT_NORMAL(InitServer());    /*     * 建立配置XML 结构,并获取TCP 套接字的配置信息。     */         PrintLog(stdout, "caatm: get config parameters...");    ASSERT_NORMAL(AP_DEMAND_CFG(PATH_PORT, szPort));        /*     * 建立监听套接字。     */         PrintLog(stdout, "caatm: create listen socket...");    ASSERT_NORMAL(CreateSock(&nListenSock, atoi(szPort), 16));    PrintLog(stdout, "caatm: service is activated.");    while (!bShutdown)    {        if (!VERIFY_NORMAL(AcceptSock(&nSock, nListenSock)))            continue;        /*         * 复制进程, 父进程继续监听TCP 套接字,子进程处理交易。         */        VERIFY((_pid_tChild = fork()) >= 0);        if (_pid_tChild > 0)        {            close(nSock);            continue;        }                    break;    }    close(nListenSock);              ASSURE_NORMAL(LocateRemoteAddr(nSock, szAddr))       nSize = SIZE_MSGID;        ASSURE_NORMAL(ReadFileExt(nSock, szData, &nSize, 10));        ASSURE_NORMAL(GetMsgSize(szData, &nMsgSize));        nMsgSize -= SIZE_MSGID;    ASSURE_NORMAL(ReadFileExt(nSock, szData + 4, &nMsgSize, 30));    bufclr(commareastru.szAddr);    bufclr(commareastru.szMsgLen);    bufclr(commareastru.cMsg);        strcpy(commareastru.szAddr, szAddr);    memcpy(commareastru.cMsg, szData, nMsgSize + SIZE_MSGID);    sprintf(commareastru.szMsgLen, "%06d", nMsgSize + SIZE_MSGID);        /*     * CallCics 调用CAATM处理交易     */    ASSURE_NORMAL(CallCics(pszArgVal[1], "APUSER", "APUSER", "CAATM",                           "CPMI", &commareastru, sizeof(COMMAREASTRU)));    ASSURE_NORMAL(WriteFileExt(nSock, commareastru.cMsg,                               atol(commareastru.szMsgLen), 20));    close(nSock);    return NORMAL;}/* End of this file */

⌨️ 快捷键说明

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