📄 pcs_snd_snml.pc
字号:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* File name : PCS_Snd_SNML.x *
* Module ID : *
* Module Name : *
* Purpose : Get SNML Data from SNMLFILE 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_SNML/cmdef.h"
#include "/usr/bkfx/include/Pcs_Snd_SNML/Pcs_Snd_SNML.h"
#include "/usr/bkfx/include/Pcs_Snd_SNML/Function_define.h"
char cRec_Year_Flag[YEAR_FLAG+1];
char *freememory;
FILE *FreeFileHandle;
char filename[MAX_LINE_LEN];
int whichline;
void main(int argc,char* arg[])
{
char *SNMLFileLength;
char cOneLine[MAX_LINE_LEN+1];
FILE *hSNMLFile;
struct stSNMLFileRec stFileRec;
size_t FileLength;
char nf[5];
char Error_Msg[10];
char cCommand[100];
ProcessError(LOG_NORMAL,"The application is beginning!", END);
strcpy(filename, arg[1]);
if( argc < 2 )
{
ProcessError(LOG_ERROR,"Two arguments expected!",END);
movefile();
exit(1);
}
hSNMLFile = fopen( arg[1], "r" );
if( hSNMLFile == NULL )
{
ProcessError(LOG_ERROR,"Cannot open file %s,The file may not exist!", arg[1]);
movefile();
exit(0);
}
FreeFileHandle = hSNMLFile;
signal (SIGTERM, terminate);
/*initial the database and the errorlog file */
InitSndSNML1();
/* get the Year Flag from the file name */
myapi_GetRecYearFlagFromFileName( cRec_Year_Flag, arg[1] );
EXEC SQL SELECT TO_CHAR(SYSDATE, 'YYYY') INTO :nf FROM SYS.DUAL;
if (cRec_Year_Flag[0] =='0')
{
if ((atoi(nf))%2 == 1)
stFileRec.yxnf = atoi(nf) + 1;
else
stFileRec.yxnf = atoi(nf);
}
else if (cRec_Year_Flag[0] =='1')
{
if ((atoi(nf))%2 == 0)
stFileRec.yxnf = atoi(nf) + 1;
else
stFileRec.yxnf = atoi(nf);
}
else
{
ProcessError(LOG_ERROR,"The file name must be incorrect,it should be 'SNML.0' or 'SNML.1', please retry after modified!",END);
fclose(hSNMLFile);
EXEC SQL ROLLBACK RELEASE;
movefile();
exit(1);
}
/*calculate the length of the file and malloc the memory */
FileLength=myapi_GetFileSize( hSNMLFile );
if((SNMLFileLength = (char *)malloc( FileLength +1))==NULL)
{
ProcessError(LOG_ERROR,"variable <SNMLFileLength> memory Allocation error - aborting.",END);
fclose(hSNMLFile);
EXEC SQL ROLLBACK RELEASE;
movefile();
exit(1);
}
freememory = SNMLFileLength;
/* read the file data into the buffer */
ReadSNMLFileData(hSNMLFile, FileLength, SNMLFileLength);
whichline=0;
while( myapi_ReadALine( cOneLine, SNMLFileLength ) ) /* read a line from the buffer */
{
whichline++;
/* construct the structure of the SNML */
if( !(myapi_FillFileRecord( cOneLine, &stFileRec )) )
{
sprintf(Error_Msg, "%d", whichline);
ProcessError(LOG_ERROR,"There are some error in line %s!", Error_Msg);
}
/* insert a record into the t_fsSNMLnr table */
InsertSNMLRec( &stFileRec);
InsertSNMLFBRec(&stFileRec );
}
EXEC SQL COMMIT RELEASE;
fclose( hSNMLFile );
free(SNMLFileLength);
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 + -