📄 pcs_fbkj_wjjs.c
字号:
/* 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[17];
};
static struct sqlcxp sqlfpn =
{
16,
"Pcs_Fbkj_Wjjs.pc"
};
static unsigned long sqlctx = 5078867;
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[4];
unsigned int sqhstl[4];
short *sqindv[4];
unsigned int sqharm[4];
unsigned int *sqharc[4];
} sqlstm = {8,4};
/* 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 *sq0010 =
"select fbkjbh from t_fbkj where (jsfs=:b0 or jsfs=: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,31,152,0,0,0,0,1,0,
16,0,0,2,0,0,27,264,0,3,3,0,1,0,1,9,0,0,1,9,0,0,1,10,0,0,
42,0,0,3,42,0,2,284,0,1,1,0,1,0,1,97,0,0,
60,0,0,4,42,0,2,303,0,1,1,0,1,0,1,97,0,0,
78,0,0,5,60,0,4,311,0,2,1,0,1,0,2,3,0,0,1,97,0,0,
100,0,0,6,49,0,5,314,0,2,2,0,1,0,1,97,0,0,1,97,0,0,
122,0,0,7,50,0,5,315,0,2,2,0,1,0,1,97,0,0,1,97,0,0,
144,0,0,8,48,0,3,319,0,4,4,0,1,0,1,97,0,0,1,97,0,0,1,97,0,0,1,97,0,0,
174,0,0,9,42,0,2,322,0,1,1,0,1,0,1,97,0,0,
192,0,0,11,67,0,4,339,0,3,2,0,1,0,2,3,0,0,1,1,0,0,1,1,0,0,
218,0,0,10,66,0,9,341,0,2,2,0,1,0,1,1,0,0,1,1,0,0,
240,0,0,10,0,0,13,344,0,1,0,0,1,0,2,97,0,0,
258,0,0,12,0,0,31,349,0,0,0,0,1,0,
272,0,0,10,0,0,15,354,0,0,0,0,1,0,
286,0,0,13,0,0,29,355,0,0,0,0,1,0,
300,0,0,14,0,0,32,361,0,0,0,0,1,0,
};
#include "stdio.h"
#include "stdlib.h"
#include "sqlcpr.h"
#include <fcntl.h>
#include <signal.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/types.h>
#include "/usr/bkfx/include/myapi.h"
#include "/usr/bkfx/include/Pcs_Convert_File/Pcs_Convert_File.h"
FILE *h_fbkj_wjjs,*h_temp_jsfile;
/* Read a string from Pstring to Cstring */
/* m,n define the first point and the last point */
int myapi_ReadString(char *Pstring,char *Cstring,int m,int n)
{
int i,j;
Cstring[0]='\0'; /*First make the target string as a null string*/
if( (strlen(Pstring)<n) || (m>n) || (m<0) )
{
return(0);/*Some error when use this function */
}
for(i=m,j=0;i<=n;i++,j++)
{
Cstring[j]=Pstring[i];
}
Cstring[n-m+1]='\0';
return(1);
}
/*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;
cLine[i] = '\0';
}
return(1);
}
/*
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_ReadALinefromF( char *cALine,FILE *hTable )
{
char cChar='\0';
int i=0;
cALine[0] = '\0';
while( (cChar = fgetc( hTable )) != '\n' )
{
if( cChar == EOF ) return(0);
cALine[i++] = cChar;
if( i >= MAX_LINE_LEN ) i=0;
cALine[i] = '\0'; /* define the end of a string */
}
return(1);
}
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 sqlerror()
{
ERROR=1;
/* EXEC SQL WHENEVER sqlerror continue; */
ProcessError( LOG_ERROR, "PCS_FBKJ_WJJS: ",sqlca.sqlerrm.sqlerrmc );
/* EXEC SQL ROLLBACK WORK; */
{
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);
}
return;
}
void trim(char *CAline)
{
int i,j;
char temp_string[100];
i=strlen(CAline);
while(i>0) /*delete the end ' ' or '\n' */
{
if(CAline[i-1]==' '||CAline[i-1]=='\n')
CAline[i-1]='\0';
else
break;
i--;
}
i=0;j=0;
while( CAline[i]!='\0' ) /*delete the head ' ' or '\n' */
{
if(CAline[i]==' '||CAline[i]=='\n')
i++;
else
{
for (j=0;CAline[i]!='\0';i++,j++)
CAline[j]=CAline[i];
break;
}
}
CAline[j]='\0';
}
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);
}
int InitPcsFbkjWjjs()
{
/* EXEC SQL BEGIN DECLARE SECTION; */
/* VARCHAR username[20]; */
struct { unsigned short len; unsigned char arr[20]; } username;
/* VARCHAR password[20]; */
struct { unsigned short len; unsigned char arr[20]; } password;
/* EXEC SQL END DECLARE SECTION; */
strcpy(username.arr,"pcsdba");
username.len=strlen(username.arr);
strcpy(password.arr,"dba");
password.len=strlen(password.arr);
/* EXEC SQL WHENEVER SQLERROR DO sqlerror(); */
/* EXEC SQL CONNECT :username IDENTIFIED BY :password; */
{
struct sqlexd sqlstm;
sqlstm.sqlvsn = 8;
sqlstm.arrsiz = 3;
sqlstm.iters = (unsigned int )10;
sqlstm.offset = (unsigned int )16;
sqlstm.cud = sqlcud0;
sqlstm.sqlest = (unsigned char *)&sqlca;
sqlstm.sqlety = (unsigned short)0;
sqlstm.sqhstv[0] = (unsigned char *)&username;
sqlstm.sqhstl[0] = (unsigned int )22;
sqlstm.sqindv[0] = ( short *)0;
sqlstm.sqharm[0] = (unsigned int )0;
sqlstm.sqhstv[1] = (unsigned char *)&password;
sqlstm.sqhstl[1] = (unsigned int )22;
sqlstm.sqindv[1] = ( short *)0;
sqlstm.sqharm[1] = (unsigned int )0;
sqlstm.sqphsv = sqlstm.sqhstv;
sqlstm.sqphsl = sqlstm.sqhstl;
sqlstm.sqpind = sqlstm.sqindv;
sqlstm.sqparm = sqlstm.sqharm;
sqlstm.sqparc = sqlstm.sqharc;
sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn);
if (sqlca.sqlcode < 0) sqlerror();
}
if( ERROR!=0 )
{
ERROR=0;
return(-1);
}
return(0);
}
int check_fbkj_wjjs(char *dddddd)
{
char sys_ls_str[200];
char tmp_fname_str[100];
char file_len[20],file_date[20];
int sign_flag,count_i;
sprintf(sys_ls_str,"%s%s/jsfile",FBKJ_PATH,dddddd);
h_temp_jsfile=fopen(sys_ls_str,"r");
if( h_temp_jsfile==NULL )
{
/* EXEC SQL DELETE FROM T_FBKJ_WJJS WHERE FBKJBH=:dddddd; */
{
struct sqlexd sqlstm;
sqlstm.sqlvsn = 8;
sqlstm.arrsiz = 3;
sqlstm.stmt = "delete from T_FBKJ_WJJS where FBKJBH=:b0";
sqlstm.iters = (unsigned int )1;
sqlstm.offset = (unsigned int )42;
sqlstm.cud = sqlcud0;
sqlstm.sqlest = (unsigned char *)&sqlca;
sqlstm.sqlety = (unsigned short)0;
sqlstm.sqhstv[0] = (unsigned char *)dddddd;
sqlstm.sqhstl[0] = (unsigned int )0;
sqlstm.sqindv[0] = ( short *)0;
sqlstm.sqharm[0] = (unsigned int )0;
sqlstm.sqphsv = sqlstm.sqhstv;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -