📄 cadsi.cpre
字号:
/* * This is a part of the Application Preconsole * Channel Access - 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: * 2001-08-12 Cheng WeiHong - create implementation file for * transaction entrance * 2001-09-25 R.Cao - simplify logic */ #include <sybtesql.h>#include "ap.h"EXEC SQL INCLUDE sqlca;EXEC SQL INCLUDE "dsi.h";EXEC SQL INCLUDE "dsiext.h";RESULT main(){ COMMAREASTRU commareastru; char szOutMsgKey[LEN_MSGKEY + 1]; char szInMsgKey[LEN_MSGKEY + 1]; UINT nOutMsg; UINT nInMsg; char cMsg[SIZE_MSG_ISO8583]; UINT nSize; UINT nType; UINT nReqSeqNo; EXEC SQL BEGIN DECLARE SECTION; char szSeqNo[AP_LEN_SEQNO + 1]; char szMinSeqNo[AP_LEN_SEQNO + 1], szMaxSeqNo[AP_LEN_SEQNO + 1]; EXEC SQL END DECLARE SECTION; TIMESTRU timestru; pid_t _pid_tChild; /* * 初始化服务程序,建立配置XML 结构,并获取消息队列的配置信息。 */ PrintLog(stdout, "cadsi: service is starting..."); ASSERT_NORMAL(InitServer()); PrintLog(stdout, "cadsi: get config parameters..."); ASSERT_NORMAL(AP_DEMAND_CFG(PATH_OUTMSGKEY, szOutMsgKey)); ASSERT_NORMAL(AP_DEMAND_CFG(PATH_INMSGKEY, szInMsgKey)); /* * 打开消息队列。 */ ASSERT((nOutMsg = msgget(atoi(szOutMsgKey), IPC_CREAT | 0666)) > 0); ASSERT((nInMsg = msgget(atoi(szInMsgKey), IPC_CREAT | 0666)) > 0); PrintLog(stdout, "cadsi: connect database..."); ASSERT_NORMAL(ApConnectDatabase()); EXEC SQL SET CHAINED OFF; PrintLog(stdout, "cadsi: initialize sequence number."); timestru = GetTime(); sprintf(szMinSeqNo, "00%02d%02d000000", timestru.nMon, timestru.nDay); sprintf(szMaxSeqNo, "00%02d%02d999999", timestru.nMon, timestru.nDay); EXEC SQL SELECT ISNULL(MAX(reqseqno), :szMinSeqNo) INTO :szSeqNo FROM dsij WHERE reqseqno >= :szMinSeqNo AND reqseqno <= :szMaxSeqNo; ASSERT(VERIFY_SQL_NORMAL()); EXEC SQL DISCONNECT CURRENT; nReqSeqNo = atoi(szSeqNo + 6); while (TRUE) { nSize = sizeof(cMsg); nType = TYPE_MSG_REQ; bufclr(cMsg); if (!VERIFY_NORMAL(ReadMsg(nInMsg, cMsg, &nSize, &nType))) continue; /* * 复制进程, 父进程继续监视队列,子进程进行报文处理。 */ if (nReqSeqNo >= 1E6) nReqSeqNo = 0; nReqSeqNo++; VERIFY((_pid_tChild = fork()) >= 0); if (_pid_tChild > 0) continue; break; } /* * 填充DSI的通讯结构体 */ timestru = GetTime(); sprintf(commareastru.szReqSeqNo, "00%02d%02d%06d", timestru.nMon, timestru.nDay, nReqSeqNo); commareastru.nSize = nSize; memcpy(commareastru.cMsg, cMsg, nSize); /* * CallCics 调用 CADSI 处理交易 */ VERIFY_NORMAL(CallCics("AP00", "APUSER", "APUSER", "CADSI", "CPMI", &commareastru, sizeof(COMMAREASTRU))); nType = TYPE_MSG_RESP; ASSERT_NORMAL(WriteMsg(nOutMsg, commareastru.cMsg, commareastru.nSize, nType)); return NORMAL;}/* End of this file */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -