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

📄 pcs_snd_bsfx1.pc

📁 unix 下用pro*c tuxedo 开发的东西
💻 PC
字号:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*	File name		: PCS_Snd_BSFX1.x	                       *				
*	Module ID		:				               *
*	Module Name	:                                                      *
*	Purpose		: Get BSFX Data from BSFXFILE 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_BSFX1/cmdef.h"
#include "/usr/bkfx/include/Pcs_Snd_BSFX1/Pcs_Snd_BSFX1.h"
#include "/usr/bkfx/include/Pcs_Snd_BSFX1/Function_define.h"

/*define the global varible which will get the sequence number*/
unsigned long lg_Key;  
char filename[MAX_LINE_LEN];

char *freememory;
FILE *FreeFileHandle;
int whichline;

void main(int argc,char* arg[])
{
	char *BSFXFileLength;
	char cOneLine[MAX_LINE_LEN+1];
	FILE *hBSFXFile;
	struct stBSFXFileRec stFileRec;
	struct stBSFXDBRec stDBRec;
	size_t FileLength;
	char Error_Msg[10];
	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);
	}
	

	hBSFXFile = fopen( arg[1], "r" );
	if( hBSFXFile == NULL )
	{
		ProcessError(LOG_ERROR,"Cannot open file: %s,The file may not exist!", arg[1]);
		movefile();
		exit(1);
	}
	
	FreeFileHandle = hBSFXFile;
	
	signal( SIGTERM, terminate);
	
	/*initial the database and the errorlog file */
	InitSndBSFX1();
	
	/*calculate the length of the file and malloc the memory */
	FileLength=myapi_GetFileSize( hBSFXFile );
	if((BSFXFileLength = (char *)malloc( FileLength +1))==NULL)
	{
		ProcessError(LOG_ERROR,"variable <BSFXFileLength> memory Allocation error - aborting.",END);
		fclose(hBSFXFile);
		movefile();
		EXEC SQL ROLLBACK RELEASE;
		exit(1);
	}
	
	freememory = BSFXFileLength;
	
	/* read the file data into the buffer */
	ReadBSFXFileData(hBSFXFile, FileLength, BSFXFileLength);
	
	/* get the sequence number from the sys.dual table */
	EXEC SQL SELECT S_FSXH.NEXTVAL INTO :lg_Key FROM SYS.DUAL;
	
	/* insert a record into  the t_fsrz and t_hz table */
	CreateSndLogAndHZRec(arg[2]);
	
	/* insert a record into  the t_fsbsfx */
	InsertBSFXRec();
	
	whichline = 0;
	while( myapi_ReadALine( cOneLine, BSFXFileLength ) ) /* read a line from the buffer */
	{
		whichline++;
		/* construct the structure of the fsbsfx and fsbsfxnr */
		if( myapi_FillFileRecord( cOneLine, &stFileRec ) )
			myapi_ConvertToDBRecord( &stFileRec, &stDBRec );
		else  
		{
			sprintf(Error_Msg, "%d", whichline);
			ProcessError(LOG_ERROR,"There are some error in line %s!", Error_Msg);
		}

		/*myapi_TestShowResult( &stFileRec, &stDBRec );	*/
		/* insert a record into the t_fsbsfxnr table */
		InsertSndBSFXNRRec( &stDBRec );
		
	}
	
	/* update the t_fsrz and t_hz table to locate the relative flag */
	UpdateSndLogRecStatus();
	
	fclose( hBSFXFile );
	free(BSFXFileLength);
	
	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 + -