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

📄 convapi.c

📁 unix 下用pro*c tuxedo 开发的东西
💻 C
📖 第 1 页 / 共 5 页
字号:

/* Result Sets Interface */
#ifndef SQL_CRSR
#  define SQL_CRSR
  struct sql_cursor
  {
    unsigned int curocn;
    void *ptr1;
    void *ptr2;
    unsigned long magic;
  };
  typedef struct sql_cursor sql_cursor;
  typedef struct sql_cursor SQL_CURSOR;
#endif /* SQL_CRSR */

/* Thread Safety */
typedef void * sql_context;
typedef void * SQL_CONTEXT;

/* File name & Package Name */
struct sqlcxp
{
  unsigned short fillen;
           char  filnam[11];
};
static struct sqlcxp sqlfpn =
{
    10,
    "convapi.pc"
};


static unsigned long sqlctx = 74371;


static struct sqlexd {
   unsigned int   sqlvsn;
   unsigned int   arrsiz;
   unsigned int   iters;
   unsigned int   offset;
   unsigned short selerr;
   unsigned short sqlety;
   unsigned int   unused;
            short *cud;
   unsigned char  *sqlest;
            char  *stmt;
   unsigned char  **sqphsv;
   unsigned int   *sqphsl;
            short **sqpind;
   unsigned int   *sqparm;
   unsigned int   **sqparc;
   unsigned char  *sqhstv[24];
   unsigned int   sqhstl[24];
            short *sqindv[24];
   unsigned int   sqharm[24];
   unsigned int   *sqharc[24];
} sqlstm = {8,24};

/* Prototypes */
extern sqlcxt (/*_ void **, unsigned long *,
                   struct sqlexd *, struct sqlcxp * _*/);
extern sqlcx2t(/*_ void **, unsigned long *,
                   struct sqlexd *, struct sqlcxp * _*/);
extern sqlbuft(/*_ void **, char * _*/);
extern sqlgs2t(/*_ void **, char * _*/);
extern sqlorat(/*_ void **, unsigned long *, void * _*/);

/* Forms Interface */
static int IAPSUCC = 0;
static int IAPFAIL = 1403;
static int IAPFTL  = 535;
extern void sqliem(/*_ char *, int * _*/);

 static char *sq0008 = 
"select zfjbh  from t_jszfjbnr ,t_jszfjb where (((t_jszfjbnr.sjbh=:b0 and t_j\
szfjb.nf=:b1) and t_jszfjb.sjbh=t_jszfjbnr.sjbh) and t_jszfjb.jsxh=t_jszfjbnr.\
jsxh) order by t_jszfjbnr.zfjxh            ";
 static char *sq0011 = 
"select yffs ,zfjbh  from t_jszdyssj where (jsxh=:b0 and sjbh=:b1)           ";
 static char *sq0017 = 
"select zjfs ,zfjbh  from t_jspdyssj where (jsxh=:b0 and sjbh=:b1)           ";
 static char *sq0023 = 
"select *  from t_jsbkhzmlnr where (jsxh=:b0 and sjbh=:b1)           ";
 static char *sq0026 = 
"select zfjbh ,zfjmc  from t_jszfjbnr where (sjbh=:b0 and jsxh=:b1) order by \
zfjxh            ";
 static char *sq0029 = 
"select fbkjbh  from t_fbkj where jsfs in (:b0,:b1)           ";
 static char *sq0031 = 
"select zcjssj ,zh ,zzh  from t_zcjssj where jsxh=:b0 order by zh            ";
 static char *sq0037 = 
"select fbkjbh  from t_fbkj where jsfs in (:b0,:b1)           ";
 static char *sq0039 = 
"select fbkjbh  from t_fbkj where jsfs in (:b0,:b1)           ";
typedef struct { unsigned short len; unsigned char arr[1]; } VARCHAR;
typedef struct { unsigned short len; unsigned char arr[1]; } varchar;

/* cud (compilation unit data) array */
static short sqlcud0[] =
{8,4130,
2,0,0,1,0,0,32,53,0,0,0,0,1,0,
16,0,0,2,0,0,31,160,0,0,0,0,1,0,
30,0,0,3,0,0,31,163,0,0,0,0,1,0,
44,0,0,4,0,0,27,477,0,3,3,0,1,0,1,9,0,0,1,9,0,0,1,10,0,0,
70,0,0,5,0,0,31,497,0,0,0,0,1,0,
84,0,0,6,67,0,4,585,0,3,2,0,1,0,2,97,0,0,1,97,0,0,1,3,0,0,
110,0,0,7,72,0,4,602,0,3,2,0,1,0,2,3,0,0,1,3,0,0,1,97,0,0,
136,0,0,8,197,0,9,609,0,2,2,0,1,0,1,97,0,0,1,3,0,0,
158,0,0,8,0,0,13,616,0,1,0,0,1,0,2,97,0,0,
176,0,0,9,83,0,4,618,0,4,3,0,1,0,2,3,0,0,1,3,0,0,1,97,0,0,1,97,0,0,
206,0,0,8,0,0,15,624,0,0,0,0,1,0,
220,0,0,8,0,0,15,631,0,0,0,0,1,0,
234,0,0,10,72,0,4,642,0,3,2,0,1,0,2,3,0,0,1,3,0,0,1,97,0,0,
260,0,0,11,76,0,9,646,0,2,2,0,1,0,1,3,0,0,1,97,0,0,
282,0,0,11,0,0,13,652,0,2,0,0,1,0,2,3,0,0,2,97,0,0,
304,0,0,11,0,0,15,657,0,0,0,0,1,0,
318,0,0,11,0,0,15,665,0,0,0,0,1,0,
332,0,0,12,137,0,4,687,0,15,2,0,1,0,2,97,0,0,2,97,0,0,2,3,0,0,2,97,0,0,2,4,0,0,
2,3,0,0,2,4,0,0,2,3,0,0,2,4,0,0,2,97,0,0,2,97,0,0,2,3,0,0,2,3,0,0,1,3,0,0,1,97,
0,0,
406,0,0,13,50,0,4,701,0,2,1,0,1,0,2,97,0,0,1,97,0,0,
428,0,0,14,74,0,4,707,0,3,2,0,1,0,2,3,0,0,1,3,0,0,1,97,0,0,
454,0,0,15,58,0,3,710,0,4,4,0,1,0,1,97,0,0,1,1,0,0,1,3,0,0,1,97,0,0,
484,0,0,16,72,0,4,931,0,3,2,0,1,0,2,3,0,0,1,3,0,0,1,97,0,0,
510,0,0,17,76,0,9,935,0,2,2,0,1,0,1,3,0,0,1,97,0,0,
532,0,0,17,0,0,13,942,0,2,0,0,1,0,2,3,0,0,2,97,0,0,
554,0,0,17,0,0,15,947,0,0,0,0,1,0,
568,0,0,17,0,0,15,961,0,0,0,0,1,0,
582,0,0,18,164,0,4,985,0,18,2,0,1,0,2,97,0,0,2,97,0,0,2,97,0,0,2,3,0,0,2,3,0,0,
2,3,0,0,2,3,0,0,2,97,0,0,2,4,0,0,2,3,0,0,2,4,0,0,2,3,0,0,2,4,0,0,2,97,0,0,2,3,
0,0,2,3,0,0,1,3,0,0,1,97,0,0,
668,0,0,19,50,0,4,1000,0,2,1,0,1,0,2,97,0,0,1,97,0,0,
690,0,0,20,74,0,4,1005,0,3,2,0,1,0,2,3,0,0,1,3,0,0,1,97,0,0,
716,0,0,21,58,0,3,1008,0,4,4,0,1,0,1,97,0,0,1,1,0,0,1,3,0,0,1,97,0,0,
746,0,0,22,76,0,4,1242,0,7,2,0,1,0,2,97,0,0,2,97,0,0,2,5,0,0,2,97,0,0,2,3,0,0,
1,3,0,0,1,97,0,0,
788,0,0,24,74,0,4,1312,0,3,2,0,1,0,2,3,0,0,1,3,0,0,1,97,0,0,
814,0,0,23,68,0,9,1314,0,2,2,0,1,0,1,3,0,0,1,97,0,0,
836,0,0,23,0,0,13,1317,0,24,0,0,1,0,2,97,0,0,2,97,0,0,2,97,0,0,2,97,0,0,2,4,0,
0,2,4,0,0,2,4,0,0,2,4,0,0,2,4,0,0,2,97,0,0,2,97,0,0,2,97,0,0,2,97,0,0,2,97,0,0,
2,3,0,0,2,3,0,0,2,3,0,0,2,97,0,0,2,4,0,0,2,4,0,0,2,4,0,0,2,4,0,0,2,97,0,0,2,3,
0,0,
946,0,0,23,0,0,15,1414,0,0,0,0,1,0,
960,0,0,23,0,0,15,1424,0,0,0,0,1,0,
974,0,0,25,63,0,4,1456,0,3,2,0,1,0,2,3,0,0,1,3,0,0,1,97,0,0,
1000,0,0,26,93,0,9,1478,0,2,2,0,1,0,1,97,0,0,1,3,0,0,
1022,0,0,27,72,0,4,1481,0,3,2,0,1,0,2,3,0,0,1,97,0,0,1,3,0,0,
1048,0,0,26,0,0,13,1485,0,2,0,0,1,0,2,97,0,0,2,97,0,0,
1070,0,0,26,0,0,15,1502,0,0,0,0,1,0,
1084,0,0,28,62,0,4,1506,0,3,2,0,1,0,2,3,0,0,1,1,0,0,1,1,0,0,
1110,0,0,29,61,0,9,1509,0,2,2,0,1,0,1,1,0,0,1,1,0,0,
1132,0,0,29,0,0,13,1514,0,1,0,0,1,0,2,97,0,0,
1150,0,0,29,0,0,15,1529,0,0,0,0,1,0,
1164,0,0,30,78,0,4,1547,0,6,2,0,1,0,2,97,0,0,2,97,0,0,2,3,0,0,2,97,0,0,1,3,0,0,
1,97,0,0,
1202,0,0,31,76,0,9,1574,0,1,1,0,1,0,1,3,0,0,
1220,0,0,31,0,0,13,1583,0,3,0,0,1,0,2,5,0,0,2,3,0,0,2,3,0,0,
1246,0,0,31,0,0,15,1587,0,0,0,0,1,0,
1260,0,0,32,55,0,4,1596,0,2,1,0,1,0,2,3,0,0,1,3,0,0,
1282,0,0,31,0,0,15,1601,0,0,0,0,1,0,
1296,0,0,31,0,0,15,1620,0,0,0,0,1,0,
1310,0,0,33,37,0,2,1622,0,1,1,0,1,0,1,3,0,0,
1328,0,0,34,57,0,5,1630,0,3,3,0,1,0,1,1,0,0,1,3,0,0,1,97,0,0,
1354,0,0,35,0,0,29,1636,0,0,0,0,1,0,
1368,0,0,36,62,0,4,1647,0,3,2,0,1,0,2,3,0,0,1,97,0,0,1,97,0,0,
1394,0,0,37,61,0,9,1650,0,2,2,0,1,0,1,97,0,0,1,97,0,0,
1416,0,0,37,0,0,13,1655,0,1,0,0,1,0,2,97,0,0,
1434,0,0,37,0,0,15,1667,0,0,0,0,1,0,
1448,0,0,38,62,0,4,1682,0,3,2,0,1,0,2,3,0,0,1,1,0,0,1,1,0,0,
1474,0,0,39,61,0,9,1685,0,2,2,0,1,0,1,1,0,0,1,1,0,0,
1496,0,0,39,0,0,13,1690,0,1,0,0,1,0,2,97,0,0,
1514,0,0,39,0,0,15,1816,0,0,0,0,1,0,
};


#include "stdio.h"

#include "stdlib.h"

#include "sqlcpr.h"

#include <fcntl.h>

#include <signal.h>

#include "/usr/bkfx/include/myapi.h"

#include "/usr/bkfx/include/Pcs_Convert_File/convapi.h"

#include "/usr/bkfx/include/Pcs_Convert_File/Pcs_Convert_File.h"


void freect(int i)

{

	if( message!=NULL )

	free(message);

	if( messagesj!=NULL )

	free(messagesj);

	if( messagepd!=NULL )

	free(messagepd);

	if( messagepdsj!=NULL )

	free(messagepdsj);

	if( messagebkml!=NULL )

	free(messagebkml);

	if( buf!=NULL )
	free(buf);
	if( buf_sj!=NULL )
	free(buf_sj);

	if( h_zdys!=NULL )

	fclose(h_zdys);

	if( h_zdsj!=NULL )

	fclose(h_zdsj);

	if( h_pdys!=NULL )

	fclose(h_pdys);

	if( h_pdsj!=NULL )

	fclose(h_pdsj);

	if( h_gh!=NULL )

	fclose(h_gh);

	if( h_tjbb!=NULL )

	fclose(h_tjbb);

	if( h_bkml!=NULL )

	fclose(h_bkml);

	if( h_zfj!=NULL )

	fclose(h_zfj);

	if( h_yx!=NULL )

	fclose(h_yx);


	if( h_sm!=NULL )

	fclose(h_sm);

	if( h_sj!=NULL )

	fclose(h_sj);

	if( h_bag!=NULL )

	fclose(h_bag);


	/* EXEC SQL ROLLBACK WORK RELEASE; */ 

{
 struct sqlexd sqlstm;

 sqlstm.sqlvsn = 8;
 sqlstm.arrsiz = 0;
 sqlstm.iters = (unsigned int  )1;
 sqlstm.offset = (unsigned int  )2;
 sqlstm.cud = sqlcud0;
 sqlstm.sqlest = (unsigned char  *)&sqlca;
 sqlstm.sqlety = (unsigned short)0;
 sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);
}



	exit(0);
}



void ProcessError( char *LOG, char *sErrorMessage1, char *sErrorMessage2 )
{
	FILE* hErrorFile;
	char cDateTime[100],tempstr[100];
	int i,j,len,n;
	long filesize;
	char bakfile[100];
	
	tempstr[0]='\0';
	len=strlen(sErrorMessage1);
	for(i=0;i<=len;i++)
	{
		if(sErrorMessage1[i]=='%')
		{			
			n=i;
			if(len!=i+1)
			{
				for(j=0;j<200&&sErrorMessage1[i+2]!='\0';j++,i++)
				tempstr[j]=sErrorMessage1[i+2];
				tempstr[j]='\0';
			}	
			break;
		}
		if(sErrorMessage1[i]=='\0')
		{
			n=i;
			tempstr[0] = '\0';
			break;
		}
			
	}
	
	printf("\n%s",LOG);
	printf("%s",sErrorMessage1);
	printf("%s",sErrorMessage2);
	printf("%s\n",tempstr);

	sErrorMessage1[n]='\0';
	hErrorFile = fopen( ERROR_LOG_FILE, "a" );
	if( hErrorFile == NULL )
	{
		printf( "Critical! Cannot open ERROR_LOG_FILE for append or cannot create!\n");
		return;
	}
	fseek( hErrorFile, 0 ,SEEK_END );
	filesize = ftell(hErrorFile);
	if (filesize > 5242880/5)
	{
		fclose(hErrorFile );
		sprintf(bakfile, "mv %s %s.bak", ERROR_LOG_FILE, ERROR_LOG_FILE);
		system(bakfile);
		hErrorFile = fopen( ERROR_LOG_FILE, "a" );
		if( hErrorFile == NULL )
		{
			printf( "Critical! Cannot open ERROR_LOG_FILE for append or cannot create!\n");
			return;
		}
	}
	fseek( hErrorFile, 0 ,SEEK_END );
	fputs( "\n",hErrorFile);
	fputs( LOG ,hErrorFile);
	fputs( sErrorMessage1,hErrorFile );
	fputs( sErrorMessage2,hErrorFile );
	fputs( tempstr,hErrorFile );
	fputs( "\n",hErrorFile);
	fclose( hErrorFile );

	sprintf( cDateTime, "date >> %s\n", ERROR_LOG_FILE );
	system( cDateTime );
	system( "date");
}

void PutintoF(char *string )
{
	FILE *fp;
	fp=fopen("checkfile.txt","w");
	fputs(string,fp);
	fclose(fp);
}


/* write the errorlog file when the database is wrong */
void sqlerror()
{
	char tempstring[200];
	char ERR_CODE[10];
	int init_time=0;
	
	ERROR=1;
	/* EXEC SQL WHENEVER sqlerror continue; */ 

	ProcessError( LOG_ERROR, "PCS_CONVERT_FILE: ",sqlca.sqlerrm.sqlerrmc );
	strncpy(ERR_CODE,sqlca.sqlerrm.sqlerrmc,9);
	ERR_CODE[9]='\0';
	if( strcmp(ERR_CODE,"ORA-03127")==0|| strcmp(ERR_CODE,"ORA-03114")==0|| strcmp(ERR_CODE,"ORA-03123")==0|| strcmp(ERR_CODE,"ORA-01034")==0|| strcmp(ERR_CODE,"ORA-01089")==0||strcmp(ERR_CODE,"ORA-01012")==0||strcmp(ERR_CODE,"ORA-01089") ==0||strcmp( ERR_CODE, "ORA-01033") ==0 )
	{
		sleep(INIT_INTERVAL);
		init_time++;
		if (init_time == 6)
		{
			ProcessError(LOG_NORMAL, "PCS_CONVERT_FILE :Could not connect to the database, so exit now!",END);
			freect(0);
			exit(0);
		}
		InitPcsConvertFile();
		/* EXEC SQL ROLLBACK WORK; */ 

{
  struct sqlexd sqlstm;

  sqlstm.sqlvsn = 8;
  sqlstm.arrsiz = 0;
  sqlstm.iters = (unsigned int  )1;
  sqlstm.offset = (unsigned int  )16;
  sqlstm.cud = sqlcud0;
  sqlstm.sqlest = (unsigned char  *)&sqlca;
  sqlstm.sqlety = (unsigned short)0;
  sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);
}


		return;
	}
	/* EXEC SQL ROLLBACK WORK; */ 

{
 struct sqlexd sqlstm;

 sqlstm.sqlvsn = 8;
 sqlstm.arrsiz = 0;
 sqlstm.iters = (unsigned int  )1;
 sqlstm.offset = (unsigned int  )30;
 sqlstm.cud = sqlcud0;
 sqlstm.sqlest = (unsigned char  *)&sqlca;
 sqlstm.sqlety = (unsigned short)0;
 sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);
}


	return;
}	


/*Get the Time_Interval specified in the file and return it */

int GetTimeInterval(char* cType)

{

	FILE *hTimeInterval;

	char cLine[MAX_LINE_LEN+1], cCaption[100], cValue[21];

	int iInterval, i;

	char* pLine;

	

	 

	hTimeInterval = fopen( CONFIG_FILE_FOR_TIMEINTERVAL, "r" );

	if( hTimeInterval == NULL )

	{

		ProcessError(LOG_ERROR,   "GetTimeInterval: Cannot open file: ", CONFIG_FILE_FOR_TIMEINTERVAL);

		return(DEFAULT_TIMEINTERVAL);  

	}

	

	while( myapi_ReadALine( cLine, hTimeInterval ) )

	{

		if( cLine[0] == '#' ) continue;

		if( cLine[0] == NULL ) continue;

		

		pLine = cLine;

		while( (*pLine == ' ') || (*pLine == '\t') ) pLine++;

		i=0;

		while( (*pLine != ' ') && (*pLine != '\t') && (*pLine != '\0') )

		{

			cCaption[i] = *pLine;

			i++;

			pLine++;

		}

		

		cCaption[i] = '\0';

		if( strcmp( cCaption, cType ) == 0 ) /*Match*/

		{

			while( (*pLine == ' ') || (*pLine == '\t') ) pLine++;

			if( *pLine == '\0' )

			{
				fclose(hTimeInterval);
				return(DEFAULT_TIMEINTERVAL);

			}
			i=0;

			while( (*pLine != ' ') && (*pLine != '\t') && (*pLine != '\0') )

			{

				cValue[i] = *pLine;

				i++;

				pLine++;

			}

			cValue[i] = '\0';

			iInterval = atoi(cValue);

			

			if(iInterval <= 0) 		

			{

				fclose(hTimeInterval);
				return(DEFAULT_TIMEINTERVAL);

			}

			else

			{
				fclose(hTimeInterval);
				return(iInterval);

			}
		}

		else

			continue;

	}

	fclose( hTimeInterval );

	return(DEFAULT_TIMEINTERVAL);

}



/*Read a line to a string from a file, \n is excluded.

  return 1 if sucessful, 0 otherwise

  Do not close the file.*/

int myapi_ReadALine( char* cLine, FILE* hTable )

{

	char cChar;

	int i=0;

	cLine[0] = '\0';

	while( (cChar = fgetc( hTable )) != '\n' )

	{

		if( cChar == EOF ) return(0);

		cLine[i++] = cChar;

		

		

		if( i >= MAX_LINE_LEN ) i=0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -