📄 pcs_rcv_bkhzml.pc
字号:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* File name : PCS_RCV_BKHZML *
* Module ID : *
* Module Name : *
* Purpose : Get BKHZML Data from MQ And Insert into DB *
* Author : Mr. laishihong *
* Date Created : 1999,07,14 *
* Version : Version 1.0 *
* Environment : Digital UNIX *
* Portability : UNIX Platform *
* Warnings : *
* References : *
* Calling Syntax : *
* Parameters : None *
* Returns : void *
* Calling Function : *
* Called Functions : When system startup *
* Datastores and usages : * *
* (a) Input *
* (b) OutPut *
* Report : None *
* Screens : None *
* Messages Files : None *
* Change Log : *
* Date *
* Author *
* Reason For Change *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
#include "stdio.h"
#include <stdlib.h>
#include <sqlcpr.h>
#include <signal.h>
#include "/usr/bkfx/include/Pcs_Rcv_BKHZML/cmdef.h"
#include "/usr/bkfx/include/Pcs_Rcv_BKHZML/Pcs_Rcv_BKHZML.h"
#include "/usr/bkfx/include/Pcs_Rcv_BKHZML/Function_define.h"
char *freememory;
void main()
{
char *BKML_Buf_Msg;
int rec_count;
int retcode;
/* define the time used in the searching of the middleware */
int iTInterval;
char *buf;
long buf_length;
char data_type[32];
ProcessError(LOG_NORMAL,"The application is beginning!", END);
signal( SIGTERM, terminate );
/*Get the sleep time interval*/
iTInterval = GetTimeInterval("PCS_RCV_BKHZML");
while(1)
{
retcode = MQBKInit("ML");
if ( retcode < 0 )
{
ProcessError(LOG_ERROR,"Calling Funtion MQBKInit() Failed!",END);
sleep(iTInterval);
}
else
break;
}
Init();
while (1)
{
/*calculate the length of the file and malloc the memory */
if((buf = (char *)malloc( MAX_FILE_SIZE ))==NULL)
{
ProcessError(LOG_ERROR,"variable <buf> memory Allocation error - aborting.",END);
MQBKClear();
EXEC SQL ROLLBACK RELEASE;
exit(1);
}
freememory = buf;
retcode = MQBKReceiveSyn_Wait( &buf_length, buf, data_type );
/*printf("buf=%sand length=%ld\n",buf,buf_length);*/
if ( retcode < 0 )
{
#ifdef DEBUG
ProcessError(LOG_NORMAL,"Maybe there is no data in the middleware!",END);
MQBKClear();
EXEC SQL ROLLBACK RELEASE;
if(freememory != NULL)
free(freememory);
exit(-1);
#endif
if(freememory != NULL)
free(freememory);
sleep(iTInterval);
}
else
{
if((BKML_Buf_Msg = (char *)malloc( buf_length + 1 ))==NULL )
{
ProcessError(LOG_ERROR,"variable <BKML_Buf_Msg> memory Allocation error - aborting.",END);
MQBKClear();
if(freememory != NULL)
free(freememory);
EXEC SQL ROLLBACK RELEASE;
exit(1);
}
strcpy(BKML_Buf_Msg, buf);
if(freememory != NULL)
free(freememory);
freememory = BKML_Buf_Msg;
/* calculate the record count */
rec_count = (buf_length - MSGHEADER_LEN)/THE_RECORD_LEN;
/* come into being the record and write into database */
Read_Msg_to_Database(BKML_Buf_Msg, rec_count);
if (freememory != NULL)
free(freememory);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -