📄 pcs_snd_tjbb1.pc
字号:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* File name : PCS_Snd_TJBB1.x *
* Module ID : *
* Module Name : *
* Purpose : Get TJBB Data from TJBBFILE 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 : *
* Change No. *
* Date *
* Author *
* Reason For Change *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
#include "stdio.h"
#include <stdlib.h>
#include <sqlcpr.h>
#include <signal.h>
#include "/usr/bkfx/include/Pcs_Snd_TJBB1/cmdef.h"
#include "/usr/bkfx/include/Pcs_Snd_TJBB1/Pcs_Snd_TJBB1.h"
#include "/usr/bkfx/include/Pcs_Snd_TJBB1/Function_define.h"
char *freememory;
FILE *FreeFileHandle;
char filename[MAX_LINE_LEN];
void main(int argc,char* arg[])
{
char *TJBBFileLength;
char cOneLine[MAX_LINE_LEN+1];
FILE *hTJBBFile;
struct stTJBBInfo stTJBBRec;
size_t FileLength;
char cCommand[100];
ProcessError(LOG_NORMAL,"The application is beginning!", END);
strcpy(filename, arg[1]);
if( argc < 3 )
{
ProcessError(LOG_ERROR,"Three arguments expected!",END);
movefile();
exit(1);
}
hTJBBFile = fopen( arg[1], "r" );
if( hTJBBFile == NULL )
{
ProcessError(LOG_ERROR,"Cannot open file %s,The file may not exist!", arg[1]);
movefile();
exit(1);
}
FreeFileHandle = hTJBBFile;
signal ( SIGTERM, terminate);
/*initial the database and the errorlog file */
InitSndTJBB1();
/* get the relative information from the file name */
myapi_GetInfoFromFileName( &stTJBBRec, arg[1] );
/*calculate the length of the file and malloc the memory */
FileLength=myapi_GetFileSize( hTJBBFile );
if((TJBBFileLength = (char *)malloc( FileLength +1))==NULL)
{
ProcessError(LOG_ERROR,"variable <TJBBFileLength> memory Allocation error - aborting.",END);
fclose(hTJBBFile);
movefile();
EXEC SQL ROLLBACK RELEASE;
exit(1);
}
freememory = TJBBFileLength;
/* read the file data into the buffer */
ReadTJBBFileData(hTJBBFile, FileLength, TJBBFileLength);
TJBBFileLength[FileLength] = '\0';
/* get the sequence number from the sys.dual table */
EXEC SQL SELECT S_FSXH.NEXTVAL INTO :stTJBBRec.lg_Key FROM SYS.DUAL;
/* insert a record into the t_fsrz and t_hz table */
CreateSndLogAndHZRec(stTJBBRec.lg_Key, arg[2]);
/* construct the structure of the tjbb */
if( myapi_FillFileRecord( TJBBFileLength, &stTJBBRec ) )
InsertSndTJBBRec( &stTJBBRec );
else
ProcessError(LOG_ERROR, "There is a illegal line in file: %s.", arg[1] );
EXEC SQL COMMIT WORK;
/* update the t_fsrz and t_hz table to locate the relative flag */
UpdateSndLogRecStatus(stTJBBRec.lg_Key);
fclose( hTJBBFile );
free(TJBBFileLength);
sprintf( cCommand, "rm -f %s", filename );
system( cCommand );
ProcessError(LOG_NORMAL,"The application ended!", END);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -