commit
a8a1bf7814
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"CurrentProjectSetting": "无配置"
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ExpandedNodes": [
|
||||||
|
"",
|
||||||
|
"\\jf_erp_check_project",
|
||||||
|
"\\jf_itk"
|
||||||
|
],
|
||||||
|
"SelectedNode": "\\jf_itk\\yb_send_to_erp.cpp",
|
||||||
|
"PreviewInSolutionExplorer": false
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,290 @@
|
|||||||
|
/**
|
||||||
|
* @file common_itk_util.cpp
|
||||||
|
* @brief itk warpper utility function
|
||||||
|
* @author James
|
||||||
|
* @history
|
||||||
|
* ===================================================================================
|
||||||
|
* Date Name Description of Change
|
||||||
|
* 18-July-2008 James
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma warning (disable: 4996)
|
||||||
|
#pragma warning (disable: 4819)
|
||||||
|
|
||||||
|
#include <epm/epm.h>
|
||||||
|
#include <epm/epm_toolkit_tc_utils.h>
|
||||||
|
#include <ict/ict_userservice.h>
|
||||||
|
#include <tccore/item.h>
|
||||||
|
#include <ae/ae.h>
|
||||||
|
#include <tc/folder.h>
|
||||||
|
#include <tccore/aom.h>
|
||||||
|
#include <sa/sa.h>
|
||||||
|
#include <tccore/aom_prop.h>
|
||||||
|
#include <property/prop_errors.h>
|
||||||
|
#include <tccore/workspaceobject.h>
|
||||||
|
#include <tc/preferences.h>
|
||||||
|
#include <tccore/imantype.h>
|
||||||
|
#include <tccore//grm.h>
|
||||||
|
#include <tccore/grmtype.h>
|
||||||
|
#include <sa/am.h>
|
||||||
|
#include <cfm/cfm.h>
|
||||||
|
#include <bom/bom.h>
|
||||||
|
#include <tccore/uom.h>
|
||||||
|
#include <ps/ps.h>
|
||||||
|
#include <epm/signoff.h>
|
||||||
|
#include <fclasses/tc_date.h>
|
||||||
|
//#include <tccore/imantype.h>
|
||||||
|
//#include <textsrv/textserver.h>
|
||||||
|
//#include <user_exits/epm_toolkit_utils.h>
|
||||||
|
//#include <ss/ss_errors.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
//#include <io.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <time.h>
|
||||||
|
//#include <direct.h>
|
||||||
|
//#include <unistd.h>
|
||||||
|
#include "error_handling.h"
|
||||||
|
#include "common_itk_util.h"
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#include <io.h>
|
||||||
|
#include <direct.h>
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define ARGS_LENGTH 200
|
||||||
|
#define ARGS_NAME_DEBUG "-debug"
|
||||||
|
#define DEBUG "-debug="
|
||||||
|
#define MAX_PRINTLINE_LENGTH 2000
|
||||||
|
#define MAX_PATH_LENGTH 2000
|
||||||
|
#define MAX_ARGUMENT_LENGTH 400
|
||||||
|
#define MAX_PARAMNAME_LENGTH 50
|
||||||
|
#define MAX_FILE_EXT_LENGTH 10
|
||||||
|
#define TRUE_FLAG 1
|
||||||
|
#define FALSE_FLAG 0
|
||||||
|
#define DETAILLOG 1
|
||||||
|
|
||||||
|
extern "C" int AM__set_application_bypass(logical bypass);
|
||||||
|
|
||||||
|
void ECHO(char *format, ...)
|
||||||
|
{
|
||||||
|
//if( !YFJC_OPT_DEBUG )
|
||||||
|
// return;
|
||||||
|
|
||||||
|
char msg[1024];
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start( args, format );
|
||||||
|
vsprintf( msg, format, args );
|
||||||
|
va_end( args );
|
||||||
|
|
||||||
|
printf( msg );
|
||||||
|
TC_write_syslog( msg );
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE* logFile = NULL;
|
||||||
|
|
||||||
|
void set_bypass(logical bypass)
|
||||||
|
{
|
||||||
|
AM__set_application_bypass(bypass);
|
||||||
|
}
|
||||||
|
/*=============================================================================*
|
||||||
|
* FUNCTION: current_time
|
||||||
|
* PURPOSE : get the current datetime
|
||||||
|
* INPUT:
|
||||||
|
* date_t* date_tag // current date time tag
|
||||||
|
*
|
||||||
|
* RETURN:
|
||||||
|
* void
|
||||||
|
*============================================================================*/
|
||||||
|
void current_time( date_t * date_tag )
|
||||||
|
{
|
||||||
|
time_t ltime;
|
||||||
|
struct tm *today ;
|
||||||
|
|
||||||
|
// Set time zone from TZ environment variable. If TZ is not set,
|
||||||
|
// the operating system is queried to obtain the default value
|
||||||
|
// for the variable.
|
||||||
|
//
|
||||||
|
//_tzset();
|
||||||
|
|
||||||
|
// Get UNIX-style time and display as number and string.
|
||||||
|
time( <ime );
|
||||||
|
|
||||||
|
today = localtime( <ime );
|
||||||
|
date_tag->year = today->tm_year + 1900 ;
|
||||||
|
date_tag->month = today->tm_mon ;
|
||||||
|
date_tag->day = today->tm_mday ;
|
||||||
|
date_tag->hour = today->tm_hour ;
|
||||||
|
date_tag->minute = today->tm_min ;
|
||||||
|
date_tag->second = today->tm_sec ;
|
||||||
|
}
|
||||||
|
/*=============================================================================*
|
||||||
|
* FUNCTION: CreateLogFile
|
||||||
|
* PURPOSE : create log file
|
||||||
|
* INPUT:
|
||||||
|
* char* FunctionName // the funtion which need to create log file
|
||||||
|
* FILE** logFile // out: the log file pointer
|
||||||
|
*
|
||||||
|
* RETURN:
|
||||||
|
* void
|
||||||
|
*============================================================================*/
|
||||||
|
void CreateLogFile(char* FunctionName, char **fullname)
|
||||||
|
{
|
||||||
|
int i=0, ifail = ITK_ok;
|
||||||
|
//date_t status_now;
|
||||||
|
//char* date_string = NULL;
|
||||||
|
char date_string[MAX_PATH_LENGTH];
|
||||||
|
char logFileDir[MAX_PATH_LENGTH];
|
||||||
|
char logFileName[MAX_PATH_LENGTH];
|
||||||
|
|
||||||
|
char* session_uid = NULL;
|
||||||
|
tag_t session_tag = NULLTAG;
|
||||||
|
time_t now;
|
||||||
|
struct tm *p;
|
||||||
|
|
||||||
|
time(&now);
|
||||||
|
|
||||||
|
logFile = NULL;
|
||||||
|
//current_time(&status_now);
|
||||||
|
p=localtime(&now);
|
||||||
|
|
||||||
|
memset(date_string, 0, sizeof(date_string));
|
||||||
|
sprintf(date_string,"%4d%02d%02d%02d%02d%02d",1900+p->tm_year,p->tm_mon+1 ,p->tm_mday ,p->tm_hour,p->tm_min ,p->tm_sec );
|
||||||
|
//if( DATE_date_to_string( status_now, "%Y%m%d%H%M%S", &date_string) != ITK_ok )
|
||||||
|
//ifail = ITK_date_to_string (status_now, &date_string );
|
||||||
|
//if (ifail)
|
||||||
|
//{
|
||||||
|
// printf("!*ERROR*!: Failed to get current date time\n");
|
||||||
|
// goto CLEANUP;
|
||||||
|
//}
|
||||||
|
|
||||||
|
memset(logFileDir, 0, sizeof(logFileDir));
|
||||||
|
memset(logFileName, 0, sizeof(logFileName));
|
||||||
|
//get log dir
|
||||||
|
sprintf(logFileDir, "%s", getenv("TEMP"));
|
||||||
|
printf("\n log file dir: %s\n", logFileDir);
|
||||||
|
//try to change dir to TC_USER_LOG_DIR
|
||||||
|
if(chdir(logFileDir)!=ITK_ok)
|
||||||
|
{
|
||||||
|
//not set TC_USER_LOG_DIR
|
||||||
|
//log in to default TC_LOG
|
||||||
|
memset(logFileDir, 0, sizeof(logFileDir));
|
||||||
|
sprintf(logFileDir, "%s", getenv("TC_LOG"));
|
||||||
|
printf("\n TC_USER_LOG_DIR invalide, log file dir: %s\n", logFileDir);
|
||||||
|
if(chdir(logFileDir)!=ITK_ok)
|
||||||
|
{
|
||||||
|
//still can not change to log dir
|
||||||
|
printf("!*ERROR*!: Failed to change dir to TC_USER_LOG_DIR\n");
|
||||||
|
goto CLEANUP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//get session_uid to make sure the log file name unique
|
||||||
|
POM_ask_session(&session_tag);
|
||||||
|
ITK__convert_tag_to_uid(session_tag, &session_uid);
|
||||||
|
|
||||||
|
|
||||||
|
//get logFileName
|
||||||
|
sprintf(logFileName, "%s_%s_%s.log", FunctionName, session_uid, date_string);
|
||||||
|
printf("log file name: %s\n", logFileName);
|
||||||
|
|
||||||
|
*fullname = (char *)MEM_alloc(sizeof(char)*512);
|
||||||
|
sprintf(*fullname,"%s\\%s",logFileDir,logFileName);
|
||||||
|
|
||||||
|
//for(i = 0; _access((char *)logFileName, 4) == 0; i++)
|
||||||
|
/*{
|
||||||
|
memset(logFileName, 0, sizeof(logFileName));
|
||||||
|
sprintf(logFileName, "%s_%s_%s_%d.log", FunctionName, session_uid, date_string, i);
|
||||||
|
}
|
||||||
|
printf("final log file name: %s\n", logFileName);*/
|
||||||
|
|
||||||
|
//create log file
|
||||||
|
logFile = fopen(logFileName, "w");
|
||||||
|
|
||||||
|
CLEANUP:
|
||||||
|
//DOFREE(date_string);
|
||||||
|
DOFREE(session_uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*=============================================================================*
|
||||||
|
* FUNCTION: WriteLog
|
||||||
|
* PURPOSE : write log, if debug log File not null, write log message to log File
|
||||||
|
* INPUT:
|
||||||
|
* const char* format // debug message string
|
||||||
|
*
|
||||||
|
* RETURN:
|
||||||
|
* void
|
||||||
|
*============================================================================*/
|
||||||
|
void WriteLog(const char* format, ...)
|
||||||
|
{
|
||||||
|
va_list arg;
|
||||||
|
char tmp[MAX_PRINTLINE_LENGTH];
|
||||||
|
|
||||||
|
if(logFile)
|
||||||
|
{
|
||||||
|
//get the message
|
||||||
|
memset(tmp, 0, sizeof(tmp));
|
||||||
|
va_start(arg, format);
|
||||||
|
vsprintf(tmp, format, arg);
|
||||||
|
va_end(arg);
|
||||||
|
|
||||||
|
//----------print to command window for trace--------//
|
||||||
|
printf("%s\n", tmp);
|
||||||
|
|
||||||
|
//print message to log file
|
||||||
|
fprintf(logFile, "%s\n", tmp);
|
||||||
|
fflush(logFile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("*!Error!*: Log File Not Exist\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CloseLog(void)
|
||||||
|
{
|
||||||
|
if(logFile)
|
||||||
|
{
|
||||||
|
fclose(logFile);
|
||||||
|
logFile = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//void getTypeinfo(char *type)
|
||||||
|
//{
|
||||||
|
// int ulen = 0,i=0,tempcount=0,asd=0;
|
||||||
|
//
|
||||||
|
// char temp[128]="";
|
||||||
|
// ulen = strlen(type);
|
||||||
|
// asd = ulen-1;
|
||||||
|
// for(i=0;i < ulen;i++)
|
||||||
|
// {
|
||||||
|
// if(type[i] == ';')
|
||||||
|
// {
|
||||||
|
// temp[tempcount] = '\0';
|
||||||
|
// strcpy(excludetypes[typecount].type,temp);
|
||||||
|
// strcpy(temp,"");
|
||||||
|
// tempcount = 0;
|
||||||
|
// typecount = typecount + 1;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
//
|
||||||
|
// temp[tempcount] = type[i];
|
||||||
|
// tempcount = tempcount + 1;
|
||||||
|
// if(i==asd)
|
||||||
|
// {
|
||||||
|
// temp[tempcount] = '\0';
|
||||||
|
// strcpy(excludetypes[typecount].type,temp);
|
||||||
|
// typecount = typecount + 1;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//}
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
/**
|
||||||
|
* @file common_itk_util.h
|
||||||
|
* @brief itk warpper utility function
|
||||||
|
* @author James
|
||||||
|
* @history
|
||||||
|
* ===================================================================================
|
||||||
|
* Date Name Description of Change
|
||||||
|
* 09-July-2008 James
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMMON_ITK_UTIL
|
||||||
|
#define COMMON_ITK_UTIL
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DOFREE(obj) \
|
||||||
|
{ \
|
||||||
|
if(obj) \
|
||||||
|
{ \
|
||||||
|
MEM_free(obj); \
|
||||||
|
obj = NULL; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
void ECHO(char *format, ...);
|
||||||
|
void CreateLogFile(char* FunctionName, char **fullname);
|
||||||
|
void WriteLog(const char* format, ...);
|
||||||
|
void CloseLog(void);
|
||||||
|
void set_bypass(logical bypass);
|
||||||
|
//int FindDatasetReferenceExt( tag_t datasettype, const char *datasettype_ref, char ext[10] );
|
||||||
|
//int CompareDate( date_t date1, date_t date2 );
|
||||||
|
//int GetRandomTempFile( char tempFile[256] );
|
||||||
|
//logical IsItemRevisionType( char object_type[WSO_name_size_c + 1] );
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -0,0 +1,160 @@
|
|||||||
|
/*!
|
||||||
|
* @addtogroup common
|
||||||
|
* \file error_handling.h
|
||||||
|
* \brief 错误处理函数
|
||||||
|
* \date 2008/6/10
|
||||||
|
* \author Ray Li
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SIMPLE_ERR_H_INCLUDED
|
||||||
|
#define SIMPLE_ERR_H_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
|
#include <itk/mem.h>
|
||||||
|
#include <tc/iman.h>
|
||||||
|
#include <tc/emh.h>
|
||||||
|
#include <pom/pom/pom_errors.h>
|
||||||
|
#include <tc/emh_const.h>
|
||||||
|
#include <tc/tc.h>
|
||||||
|
#include <pom/pom/pom.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#define BUFSIZE 512
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
//#define HANDLER_ARGUMENT_ERROR EMH_USER_error_base + 1
|
||||||
|
//#define WORKFLOW_NODE_IS_NOT_VALID EMH_USER_error_base + 2
|
||||||
|
//#define HANDLER_PLACED_INVALID EMH_USER_error_base + 3
|
||||||
|
//
|
||||||
|
////user errors define
|
||||||
|
////<error id="100">在站点文件中缺少 %1$ 配置,或该配置中无数据项</error>
|
||||||
|
//#define ERROR_PREFERENCE_NOT_FOUND (EMH_USER_error_base + 100)
|
||||||
|
|
||||||
|
|
||||||
|
#define DOFREE(obj) \
|
||||||
|
{ \
|
||||||
|
if(obj) \
|
||||||
|
{ \
|
||||||
|
MEM_free(obj); \
|
||||||
|
obj = NULL; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//#define ECHO(X) printf X;
|
||||||
|
#define SYS_LOG(X) IMAN_write_syslog X;
|
||||||
|
#define LOG_ECHO(X) printf X; IMAN_write_syslog X;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \def CALL(x)
|
||||||
|
* 打印错误信息
|
||||||
|
*/
|
||||||
|
#define CALL(x) { \
|
||||||
|
int stat; \
|
||||||
|
char *err_string; \
|
||||||
|
if( (stat = (x)) != ITK_ok) \
|
||||||
|
{ \
|
||||||
|
EMH_ask_error_text (stat, &err_string); \
|
||||||
|
LOG_ECHO( ("ERROR: %d ERROR MSG: %s.\n",stat, err_string) ) \
|
||||||
|
LOG_ECHO( ("Function: %s FILE: %s LINE: %d\n", #x, __FILE__, __LINE__ ) ) \
|
||||||
|
MEM_free (err_string); \
|
||||||
|
return (stat); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \def DO(x)
|
||||||
|
* 打印错误信息
|
||||||
|
*/
|
||||||
|
#define DO(x) { \
|
||||||
|
int stat; \
|
||||||
|
char *err_string; \
|
||||||
|
if( (stat = (x)) != POM_ok) \
|
||||||
|
{ \
|
||||||
|
EMH_ask_error_text (stat, &err_string); \
|
||||||
|
printf ("ERROR: %d ERROR MSG: %s.\n", stat, err_string); \
|
||||||
|
printf ("Function: %s FILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \
|
||||||
|
MEM_free (err_string); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \def CALLRNULL(x)
|
||||||
|
* 打印错误信息
|
||||||
|
*/
|
||||||
|
#define CALLRNULL(x) { \
|
||||||
|
int stat; \
|
||||||
|
char *err_string; \
|
||||||
|
if( (stat = (x)) != ITK_ok) \
|
||||||
|
{ \
|
||||||
|
EMH_ask_error_text (stat, &err_string); \
|
||||||
|
printf ("ERROR: %d ERROR MSG: %s.\n", stat, err_string); \
|
||||||
|
printf ("Function: %s FILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \
|
||||||
|
MEM_free (err_string); \
|
||||||
|
return ((char *)NULL); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \def CALL2(x)
|
||||||
|
* 打印错误信息
|
||||||
|
*/
|
||||||
|
#define CALL2(x) { \
|
||||||
|
int stat, n_ifails, *serverities, *ifails, err_count; \
|
||||||
|
char *err_string, **texts; \
|
||||||
|
if( (stat = (x)) != ITK_ok) \
|
||||||
|
{ \
|
||||||
|
printf ("Function: %s FILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \
|
||||||
|
EMH_ask_errors( &n_ifails, (const int**)(&serverities), (const int**)(&ifails), (const char***)(&texts) );\
|
||||||
|
for( err_count=0; err_count<n_ifails; err_count++ ) \
|
||||||
|
{ \
|
||||||
|
printf( "ERROR: %d ERROR MSG: %s.\n", ifails[i], texts[i] ); \
|
||||||
|
} \
|
||||||
|
MEM_free( serverities ); \
|
||||||
|
MEM_free( ifails ); \
|
||||||
|
MEM_free( texts ); \
|
||||||
|
return (stat); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
|
||||||
|
#define CHECK_FILE(x,ret) { \
|
||||||
|
FILE *stream = NULL; \
|
||||||
|
if( (stream = fopen(x,"rb")) == NULL ) { \
|
||||||
|
printf( "%s doesn't exists, please check!\n", x ); \
|
||||||
|
IMAN_write_syslog( "%s doesn't exists, please check!\n", x) ; \
|
||||||
|
ret = -1; \
|
||||||
|
} \
|
||||||
|
else { \
|
||||||
|
fclose(stream); \
|
||||||
|
stream = NULL; \
|
||||||
|
ret = 0; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
|
||||||
|
|
||||||
|
#define CHECK_FILE_NOT_EXISTS(x,ret) { \
|
||||||
|
FILE *stream = NULL; \
|
||||||
|
if( (stream = fopen(x,"rb")) != NULL ) { \
|
||||||
|
fclose(stream); \
|
||||||
|
stream = NULL; \
|
||||||
|
printf( "%s exists, please check!\n", x ); \
|
||||||
|
IMAN_write_syslog( "%s exists, please check!\n", x) ; \
|
||||||
|
ret = -1; \
|
||||||
|
} \
|
||||||
|
else { \
|
||||||
|
ret = 0; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -0,0 +1 @@
|
|||||||
|
# include "jf3_main.h"
|
||||||
@ -0,0 +1,57 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="源文件">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="头文件">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="资源文件">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="common">
|
||||||
|
<UniqueIdentifier>{65de63f5-1c56-4dd5-8613-cf9edb74ee2c}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="jf3_main.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="common_itk_util.c">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="ocilib.cxx">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="string_helper.cpp">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="string_utils.cxx">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="jf3_main.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="common_itk_util.h">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="ocilib.h">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="string_helper.h">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="string_utils.h">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="error_handling.h">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
</Project>
|
||||||
@ -0,0 +1,98 @@
|
|||||||
|
/*=====================================================================================================================
|
||||||
|
Copyright(c) 2012 ORIGIN.
|
||||||
|
Unpublished - All rights reserved
|
||||||
|
=======================================================================================================================
|
||||||
|
File description:
|
||||||
|
|
||||||
|
Filename: ocilib.h
|
||||||
|
Module : OCI
|
||||||
|
|
||||||
|
This Header file of OCI library Package.
|
||||||
|
|
||||||
|
=======================================================================================================================
|
||||||
|
Date Name Description of Change
|
||||||
|
1-Feb-2015 Ray Initialize creation
|
||||||
|
$HISTORY$
|
||||||
|
=====================================================================================================================*/
|
||||||
|
#include <oci.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <memory.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
//#include <limits.h>
|
||||||
|
|
||||||
|
#define OCI_FAIL 1
|
||||||
|
#define OCI_OK 0
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
/**
|
||||||
|
* 连接数据库.
|
||||||
|
* @param username - <I> 用户名
|
||||||
|
* @param password - <I> 密码
|
||||||
|
* @param dbname - <I> 数据库SID
|
||||||
|
* @return - OCI_OK or error code
|
||||||
|
*
|
||||||
|
* ORACLE 数据库的连接与封装函数
|
||||||
|
*/
|
||||||
|
extern int ConnServer(char *username,char *password,char *dbname);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不带输入参数的执行SQL语句.
|
||||||
|
* @param SQL - <I> SQL语句
|
||||||
|
* @return - OCI_OK or error code
|
||||||
|
*
|
||||||
|
* ORACLE 数据库的连接与封装函数
|
||||||
|
*/
|
||||||
|
extern int ExecuteSQLNoInputParam(char *SQL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 带输入参数的执行SQL语句.
|
||||||
|
* @param SQL - <I> SQL语句
|
||||||
|
* @param inputValueCount - <I> 输入参数数量
|
||||||
|
* @param inputValue - <I> 输入参数值
|
||||||
|
* @return - OCI_OK or error code
|
||||||
|
*
|
||||||
|
* ORACLE 数据库的连接与封装函数
|
||||||
|
*/
|
||||||
|
extern int ExecuteSQL(char *SQL,int inputValueCount,char **inputValue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不带输入参数的查询SQL语句.
|
||||||
|
* @param SQL - <I> SQL语句
|
||||||
|
* @param outputColumn - <O> 输出表的列的数量
|
||||||
|
* @param outputValueCount - <O> 输出表的行的数量
|
||||||
|
* @param outputValue - <O> 输出表内容
|
||||||
|
* @return - OCI_OK or error code
|
||||||
|
*
|
||||||
|
* ORACLE 数据库的连接与封装函数
|
||||||
|
*/
|
||||||
|
extern int QuerySQLNoInputParam(char *SQL, int * outputColumn, int * outputValueCount, char **** outputValue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 带输入参数的查询SQL语句.
|
||||||
|
* @param SQL - <I> SQL语句
|
||||||
|
* @param inputValueCount - <I> 输入参数数量
|
||||||
|
* @param inputValue - <I> 输入参数值
|
||||||
|
* @param outputColumn - <O> 输出表的列的数量
|
||||||
|
* @param outputValueCount - <O> 输出表的行的数量
|
||||||
|
* @param outputValue - <O> 输出表内容
|
||||||
|
* @return - OCI_OK or error code
|
||||||
|
*
|
||||||
|
* ORACLE 数据库的连接与封装函数
|
||||||
|
*/
|
||||||
|
extern int QuerySQL(char *SQL, int inputValueCount, char ** inputValue, int * outputColumn, int * outputValueCount, char **** outputValue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 断开数据库连接.
|
||||||
|
*
|
||||||
|
* ORACLE 数据库的连接与封装函数
|
||||||
|
*/
|
||||||
|
extern void DisConnServer();
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@ -0,0 +1,146 @@
|
|||||||
|
/**
|
||||||
|
* @file string_helper.cpp
|
||||||
|
* @brief string utility functions' implemention
|
||||||
|
* @author James
|
||||||
|
* @history
|
||||||
|
* ===================================================================================
|
||||||
|
* Date Name Description of Change
|
||||||
|
* 09-July-2008 James
|
||||||
|
* 14-Jau-2009 James modify Split functions, add trim blank characters
|
||||||
|
*/
|
||||||
|
#pragma warning(disable:4996)
|
||||||
|
//
|
||||||
|
//#include <stdio.h>
|
||||||
|
//#include <iostream>
|
||||||
|
//#include <windows.h>
|
||||||
|
#include "string_helper.h"
|
||||||
|
|
||||||
|
string TrimString( string strArg )
|
||||||
|
{
|
||||||
|
size_t index1 = 0;
|
||||||
|
index1 = strArg.find_first_not_of( ' ');
|
||||||
|
if( index1 != string::npos )
|
||||||
|
strArg.erase( strArg.begin(), strArg.begin()+index1 );
|
||||||
|
index1 = strArg.find_last_not_of( ' ');
|
||||||
|
if( index1 != string::npos )
|
||||||
|
strArg.erase( strArg.begin() + index1 + 1 );
|
||||||
|
return strArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Split( string strArg, char spliter, vector<string> &ans )
|
||||||
|
{
|
||||||
|
ans.clear();
|
||||||
|
size_t index0 = 0;
|
||||||
|
string one_arg;
|
||||||
|
if ( strArg.find_first_not_of(' ') == string::npos )
|
||||||
|
strArg = "";
|
||||||
|
while( strArg.size()>0 )
|
||||||
|
{
|
||||||
|
index0 = strArg.find_first_of( spliter );
|
||||||
|
if( index0 != string::npos )
|
||||||
|
{
|
||||||
|
one_arg = strArg.substr( 0,index0 );
|
||||||
|
strArg = strArg.substr( index0 + 1 );
|
||||||
|
ans.push_back( one_arg );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ans.push_back( strArg );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Split( string strArg, string spliter, vector<string> &ans )
|
||||||
|
{
|
||||||
|
|
||||||
|
ans.clear();
|
||||||
|
|
||||||
|
size_t index0;
|
||||||
|
string one_arg;
|
||||||
|
|
||||||
|
if ( strArg.find_first_not_of(" ") == string::npos )
|
||||||
|
strArg = "";
|
||||||
|
|
||||||
|
|
||||||
|
while( strArg.size()>0 )
|
||||||
|
{
|
||||||
|
|
||||||
|
index0 = strArg.find(spliter);
|
||||||
|
|
||||||
|
if( index0 != string::npos )
|
||||||
|
{
|
||||||
|
|
||||||
|
one_arg = strArg.substr( 0, index0 );
|
||||||
|
strArg = strArg.substr( index0 + spliter.size() );
|
||||||
|
|
||||||
|
ans.push_back( one_arg );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
ans.push_back( strArg );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RemoveLiner( string &in, string &out )
|
||||||
|
{
|
||||||
|
char buf[BUFSIZ] = "";
|
||||||
|
for( int i=0; i<(int)in.size(); i++ )
|
||||||
|
{
|
||||||
|
if( in[i] == '\n')
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
sprintf( buf,"%s%c", buf, in[i] );
|
||||||
|
}
|
||||||
|
out.assign(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
////Converting a WChar string to a Ansi string
|
||||||
|
//std::string WChar2Ansi(LPCWSTR pwszSrc)
|
||||||
|
//{
|
||||||
|
// int nLen = WideCharToMultiByte(CP_ACP, 0, pwszSrc, -1, NULL, 0, NULL, NULL);
|
||||||
|
//
|
||||||
|
// if (nLen<= 0) return std::string("");
|
||||||
|
//
|
||||||
|
// char* pszDst = new char[nLen];
|
||||||
|
// if (NULL == pszDst) return std::string("");
|
||||||
|
//
|
||||||
|
// WideCharToMultiByte(CP_ACP, 0, pwszSrc, -1, pszDst, nLen, NULL, NULL);
|
||||||
|
// pszDst[nLen -1] = 0;
|
||||||
|
//
|
||||||
|
// std::string strTemp(pszDst);
|
||||||
|
// delete [] pszDst;
|
||||||
|
//
|
||||||
|
// return strTemp;
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//string ws2s(wstring& inputws){ return WChar2Ansi(inputws.c_str()); }
|
||||||
|
//
|
||||||
|
////Converting a Ansi string to WChar string
|
||||||
|
//std::wstring Ansi2WChar(LPCSTR pszSrc, int nLen)
|
||||||
|
//{
|
||||||
|
// int nSize = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pszSrc, nLen, 0, 0);
|
||||||
|
// if(nSize <= 0) return NULL;
|
||||||
|
//
|
||||||
|
// WCHAR *pwszDst = new WCHAR[nSize+1];
|
||||||
|
// if( NULL == pwszDst) return NULL;
|
||||||
|
//
|
||||||
|
// MultiByteToWideChar(CP_ACP, 0,(LPCSTR)pszSrc, nLen, pwszDst, nSize);
|
||||||
|
// pwszDst[nSize] = 0;
|
||||||
|
//
|
||||||
|
// if( pwszDst[0] == 0xFEFF) // skip Oxfeff
|
||||||
|
// for(int i = 0; i < nSize; i ++)
|
||||||
|
// pwszDst[i] = pwszDst[i+1];
|
||||||
|
//
|
||||||
|
// wstring wcharString(pwszDst);
|
||||||
|
// delete pwszDst;
|
||||||
|
//
|
||||||
|
// return wcharString;
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//std::wstring s2ws(const string& s){ return Ansi2WChar(s.c_str(),s.size());}
|
||||||
|
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* @file string_helper.h
|
||||||
|
* @brief string utilities to help dealing with string
|
||||||
|
* @author James
|
||||||
|
* @history
|
||||||
|
* ===================================================================================
|
||||||
|
* Date Name Description of Change
|
||||||
|
* 09-July-2008 James
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef STRING_HELPER
|
||||||
|
#define STRING_HELPER
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
string TrimString( string strArg );
|
||||||
|
void Split( string strArg, char spliter, vector<string> &ans );
|
||||||
|
void Split( string strArg, string spliter, vector<string> &ans );
|
||||||
|
void RemoveLiner( string &in, string &out );
|
||||||
|
//string ws2s(wstring& inputws);
|
||||||
|
//wstring s2ws(const string& s);
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -0,0 +1,253 @@
|
|||||||
|
/*==================================================================================================================
|
||||||
|
Copyright(c) 2012 ORIGIN.
|
||||||
|
Unpublished - All rights reserved
|
||||||
|
====================================================================================================================
|
||||||
|
File description:
|
||||||
|
Filename: string_utils.c
|
||||||
|
Module : Common module.
|
||||||
|
|
||||||
|
This file includes some operations of the string.
|
||||||
|
|
||||||
|
====================================================================================================================
|
||||||
|
Date Name Description of Change
|
||||||
|
3-Feb-2015 Ray li Initialize creation
|
||||||
|
$HISTORY$
|
||||||
|
===================================================================================================================*/
|
||||||
|
#ifndef _cplusplus
|
||||||
|
#ifndef _CRT_SECURE_NO_DEPRECATE
|
||||||
|
#define _CRT_SECURE_NO_DEPRECATE
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <fclasses/tc_string.h>
|
||||||
|
#include <tc/tc_util.h>
|
||||||
|
#include <itk/mem.h>
|
||||||
|
#include <tccore/workspaceobject.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include "string_utils.h"
|
||||||
|
|
||||||
|
//void Split( string strArg, string spliter, vector<string> &ans )
|
||||||
|
//{
|
||||||
|
// ans.clear();
|
||||||
|
// size_t index0;
|
||||||
|
// string one_arg;
|
||||||
|
// if ( strArg.find_first_not_of(' ') == string::npos )
|
||||||
|
// strArg = "";
|
||||||
|
// while( strArg.size()>0 )
|
||||||
|
// {
|
||||||
|
// index0 = strArg.find(spliter);
|
||||||
|
// if( index0 != string::npos )
|
||||||
|
// {
|
||||||
|
// one_arg = strArg.substr( 0, index0 );
|
||||||
|
// strArg = strArg.substr( index0 + spliter.size() );
|
||||||
|
// ans.push_back( one_arg );
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// ans.push_back( strArg );
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
char* GSTR_clone( char **dst, const char *src )
|
||||||
|
{
|
||||||
|
char *retVal = NULL;
|
||||||
|
int srcLen = 0;
|
||||||
|
|
||||||
|
*dst = NULL;
|
||||||
|
if (src == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
srcLen = (int)tc_strlen( src ) + 1;
|
||||||
|
*dst = (char*)MEM_alloc( srcLen * sizeof(char) );
|
||||||
|
retVal = tc_strncpy( *dst, src, srcLen );
|
||||||
|
(*dst)[srcLen - 1] = '\0';
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* GSTR_copy( char *dst, const char *src, int dstSize )
|
||||||
|
{
|
||||||
|
char *retVal = tc_strncpy( dst, src, dstSize );
|
||||||
|
dst[dstSize - 1] = '\0';
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* GSTR_int_to_string( char **dst, int value )
|
||||||
|
{
|
||||||
|
char strVal[128 + 1];
|
||||||
|
|
||||||
|
*dst = NULL;
|
||||||
|
memset( strVal, 0, sizeof(strVal)/sizeof(char) );
|
||||||
|
sprintf( strVal, "%d", value );
|
||||||
|
|
||||||
|
return GSTR_clone( dst, strVal );
|
||||||
|
}
|
||||||
|
|
||||||
|
void GSTR_format_int_to_string( char *dst, int digitNum, int value )
|
||||||
|
{
|
||||||
|
char sNum[WSO_desc_size_c + 1];
|
||||||
|
sprintf( sNum, "%%0%dd", digitNum );
|
||||||
|
sprintf( dst, sNum, value );
|
||||||
|
}
|
||||||
|
|
||||||
|
void GSTR_format_string( const char *dst, int m, const char *fill_char, char **out )
|
||||||
|
{
|
||||||
|
char sNum[WSO_name_size_c + 1] = {0};
|
||||||
|
char sNew[WSO_name_size_c + 1] = {0};
|
||||||
|
sprintf( sNum, "%%%d.%ds", m, m );
|
||||||
|
sprintf( sNew, sNum, dst );
|
||||||
|
STRNG_replace_str( sNew, " ", fill_char, out );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char* GSTR_string_append( const char *s1, const char *s2 )
|
||||||
|
{
|
||||||
|
char *s = NULL;
|
||||||
|
if (s1 == NULL || s2 == NULL)
|
||||||
|
{
|
||||||
|
GSTR_clone(&s, s1 == NULL ? (s2 == NULL ? "" : s2) : s1 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int size = (int)tc_strlen(s1) + (int)tc_strlen(s2) + 1;
|
||||||
|
s = (char *)MEM_alloc( size );
|
||||||
|
tc_strcpy( s, s1 );
|
||||||
|
tc_strcat( s, s2 );
|
||||||
|
s[size - 1] = '\0';
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
logical GSTR_is_float(const char *str)
|
||||||
|
{
|
||||||
|
logical isfloat = true;
|
||||||
|
char *pStr = (char *)str;
|
||||||
|
logical hasPositive = false;
|
||||||
|
logical hasMinus = false;
|
||||||
|
logical hasDot = false;
|
||||||
|
|
||||||
|
if (str == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
while (*pStr != '\0' && isfloat == true)
|
||||||
|
{
|
||||||
|
if ( (*pStr >= '0' && *pStr <= '9'))
|
||||||
|
{
|
||||||
|
//continue;
|
||||||
|
}
|
||||||
|
else if ( *pStr == '+' )
|
||||||
|
{
|
||||||
|
isfloat = (hasPositive ? false : (hasPositive = true));
|
||||||
|
}
|
||||||
|
else if ( *pStr == '-' )
|
||||||
|
{
|
||||||
|
isfloat = (hasMinus ? false : (hasMinus = true));
|
||||||
|
}
|
||||||
|
else if ( *pStr == '.' )
|
||||||
|
{
|
||||||
|
isfloat = (hasDot ? false : (hasDot = true));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
isfloat = false;
|
||||||
|
|
||||||
|
pStr ++;
|
||||||
|
}
|
||||||
|
return isfloat;
|
||||||
|
}
|
||||||
|
|
||||||
|
logical GSTR_is_number(const char *str)
|
||||||
|
{
|
||||||
|
logical is_number = true;
|
||||||
|
char *pStr = (char *)str;
|
||||||
|
if (str == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
while (*pStr != '\0')
|
||||||
|
{
|
||||||
|
if ( !( (*pStr >= '0' && *pStr <= '9') || *pStr == '-' ) )
|
||||||
|
{
|
||||||
|
is_number = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pStr ++;
|
||||||
|
}
|
||||||
|
return is_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
logical GSTR_is_ascii(char ch)
|
||||||
|
{
|
||||||
|
return ((unsigned int)ch) < 128;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GSTR_trim_l( char *str, char s )
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
char *pointer = str, *poffset = NULL;
|
||||||
|
if (str == NULL || str[0] == '\0')
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
while ( *pointer != '\0' )
|
||||||
|
{
|
||||||
|
if ( *pointer != s )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
pointer++;
|
||||||
|
}
|
||||||
|
if (count == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
poffset = str + count;
|
||||||
|
pointer = str;
|
||||||
|
while ( *poffset != '\0' )
|
||||||
|
{
|
||||||
|
*pointer = *poffset;
|
||||||
|
pointer ++;
|
||||||
|
poffset ++;
|
||||||
|
}
|
||||||
|
*pointer = '\0';
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GSTR_trim_r( char *str, char s )
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
char *pointer = NULL;
|
||||||
|
if (str == NULL || str[0] == '\0')
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
pointer = str + ((int) strlen(str) - 1);
|
||||||
|
|
||||||
|
while ( pointer != str )
|
||||||
|
{
|
||||||
|
if ( *pointer != s )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pointer = '\0';
|
||||||
|
|
||||||
|
count++;
|
||||||
|
pointer--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GSTR_trim_float( char *floatValue )
|
||||||
|
{
|
||||||
|
if ( !IS_EMPTY(floatValue) && tc_strstr(floatValue, ".") != NULL )
|
||||||
|
{
|
||||||
|
int len = 0;
|
||||||
|
GSTR_trim_r(floatValue, '0');
|
||||||
|
len = (int)tc_strlen(floatValue);
|
||||||
|
if (floatValue[ len - 1 ] == '.')
|
||||||
|
floatValue[ len - 1 ] = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,125 @@
|
|||||||
|
/*=====================================================================================================================
|
||||||
|
Copyright(c) 2005 ORIGIN PLM Software Corp. All rights reserved.
|
||||||
|
Unpublished - All rights reserved
|
||||||
|
=======================================================================================================================
|
||||||
|
File description:
|
||||||
|
Filename: string_utils.h
|
||||||
|
Module : Common module.
|
||||||
|
|
||||||
|
This file includes some operations of the string.
|
||||||
|
|
||||||
|
=======================================================================================================================
|
||||||
|
Date Name Description of Change
|
||||||
|
14-Jul-2009 Ray Li Initialize creation
|
||||||
|
$HISTORY$
|
||||||
|
=====================================================================================================================*/
|
||||||
|
#ifndef STRING_UTILS_H
|
||||||
|
#define STRING_UTILS_H
|
||||||
|
#include <string>
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
using namespace std;
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// @{{ String assister
|
||||||
|
#define IS_NULL(S) ((S)==NULL)
|
||||||
|
#define IS_EMPTY(S) (((S)==NULL) || !(*(S)))
|
||||||
|
// @}}
|
||||||
|
void Split( string strArg, string spliter, vector<string> &ans );
|
||||||
|
/**
|
||||||
|
* Clones the string.
|
||||||
|
* @param dst - <OF> the output string.
|
||||||
|
* @param src - <I> the string to be cloned.
|
||||||
|
* @return - the destinatin string pointer.
|
||||||
|
*/
|
||||||
|
extern char* GSTR_clone( char **dst, const char *src );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy safely the string with null end.
|
||||||
|
* @param dst - <O> the output string.
|
||||||
|
* @param src - <I> the string to be cloned.
|
||||||
|
* @param dstSize - <I> the size of output string.
|
||||||
|
* @return - the destinatin string pointer.
|
||||||
|
*/
|
||||||
|
extern char *GSTR_copy( char *dst, const char *src, int dstSize );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts int to string.
|
||||||
|
* @param dst - <OF> the output string.
|
||||||
|
* @param value - <I> the int to be cloned.
|
||||||
|
* @return - the destinatin string pointer.
|
||||||
|
*/
|
||||||
|
extern char* GSTR_int_to_string( char **dst, int value );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats the int/string value as string.
|
||||||
|
* @param dst - <O> the destination string.
|
||||||
|
* @param digitNum - <I> the digit number of the value.
|
||||||
|
* @param value - <I> the value to be converted.
|
||||||
|
* @return - N/A.
|
||||||
|
*/
|
||||||
|
extern void GSTR_format_int_to_string( char *dst, int digitNum, int value );
|
||||||
|
extern void GSTR_format_string( const char *dst, int m, const char *fill_char, char **out );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appends the strings( never null returned )
|
||||||
|
* @param s1 - <I> string 1
|
||||||
|
* @param s2 - <I> string 2
|
||||||
|
* @return - <OF> new string
|
||||||
|
*/
|
||||||
|
extern char* GSTR_string_append( const char *s1, const char *s2 );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the string is float type
|
||||||
|
* @param str - <I> The string
|
||||||
|
*
|
||||||
|
* NOTE: it's only check whether each word is in "+-.0123456789", not care the float with "E" or the float rule,
|
||||||
|
* like "00-1.+01", it will return true.
|
||||||
|
* @return - return true if it is one.
|
||||||
|
*/
|
||||||
|
extern logical GSTR_is_float(const char *str);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether all char of the string are number
|
||||||
|
* @param str - <I> The string
|
||||||
|
*
|
||||||
|
* NOTE: it's only check whether each word is in "0123456789"
|
||||||
|
* @return - return true if it is one.
|
||||||
|
*/
|
||||||
|
extern logical GSTR_is_number(const char *str);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is ascii char
|
||||||
|
* @param ch - <I> ascii char
|
||||||
|
* @return - return true if it is.
|
||||||
|
*/
|
||||||
|
extern logical GSTR_is_ascii(char ch);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trims the string's prefix.
|
||||||
|
* @param str - <I> The string
|
||||||
|
* @param s - <I> The char
|
||||||
|
*
|
||||||
|
* @return - count.
|
||||||
|
*/
|
||||||
|
extern int GSTR_trim_l( char *str, char s );
|
||||||
|
extern int GSTR_trim_r( char *str, char s );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the zero.
|
||||||
|
* For Example:
|
||||||
|
* floatValue="50.00" -> = "50"
|
||||||
|
* floatValue="50.0100" -> = "50.01"
|
||||||
|
* @return - count.
|
||||||
|
*/
|
||||||
|
extern void GSTR_trim_float( char *floatValue );
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif //STRING_UTILS_H
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
|
||||||
|
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
|
||||||
|
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||||
|
<security>
|
||||||
|
<requestedPrivileges>
|
||||||
|
<requestedExecutionLevel level='asInvoker' uiAccess='false' />
|
||||||
|
</requestedPrivileges>
|
||||||
|
</security>
|
||||||
|
</trustInfo>
|
||||||
|
</assembly>
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,291 @@
|
|||||||
|
/**
|
||||||
|
* @file common_itk_util.cpp
|
||||||
|
* @brief itk warpper utility function
|
||||||
|
* @author James
|
||||||
|
* @history
|
||||||
|
* ===================================================================================
|
||||||
|
* Date Name Description of Change
|
||||||
|
* 18-July-2008 James
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma warning (disable: 4996)
|
||||||
|
#pragma warning (disable: 4819)
|
||||||
|
|
||||||
|
#include <epm/epm.h>
|
||||||
|
#include <epm/epm_toolkit_tc_utils.h>
|
||||||
|
#include <ict/ict_userservice.h>
|
||||||
|
#include <tccore/item.h>
|
||||||
|
#include <ae/ae.h>
|
||||||
|
#include <tc/folder.h>
|
||||||
|
#include <tccore/aom.h>
|
||||||
|
#include <sa/sa.h>
|
||||||
|
#include <tccore/aom_prop.h>
|
||||||
|
#include <property/prop_errors.h>
|
||||||
|
#include <tccore/workspaceobject.h>
|
||||||
|
#include <tc/preferences.h>
|
||||||
|
#include <tccore/imantype.h>
|
||||||
|
#include <tccore//grm.h>
|
||||||
|
#include <tccore/grmtype.h>
|
||||||
|
#include <sa/am.h>
|
||||||
|
#include <cfm/cfm.h>
|
||||||
|
#include <bom/bom.h>
|
||||||
|
#include <tccore/uom.h>
|
||||||
|
#include <ps/ps.h>
|
||||||
|
#include <epm/signoff.h>
|
||||||
|
#include <fclasses/tc_date.h>
|
||||||
|
//#include <tccore/imantype.h>
|
||||||
|
//#include <textsrv/textserver.h>
|
||||||
|
//#include <user_exits/epm_toolkit_utils.h>
|
||||||
|
//#include <ss/ss_errors.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
//#include <io.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <time.h>
|
||||||
|
//#include <direct.h>
|
||||||
|
//#include <unistd.h>
|
||||||
|
#include "error_handling.h"
|
||||||
|
#include "common_itk_util.h"
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#include <io.h>
|
||||||
|
#include <direct.h>
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define ARGS_LENGTH 200
|
||||||
|
#define ARGS_NAME_DEBUG "-debug"
|
||||||
|
#define DEBUG "-debug="
|
||||||
|
#define MAX_PRINTLINE_LENGTH 2000
|
||||||
|
#define MAX_PATH_LENGTH 2000
|
||||||
|
#define MAX_ARGUMENT_LENGTH 400
|
||||||
|
#define MAX_PARAMNAME_LENGTH 50
|
||||||
|
#define MAX_FILE_EXT_LENGTH 10
|
||||||
|
#define TRUE_FLAG 1
|
||||||
|
#define FALSE_FLAG 0
|
||||||
|
#define DETAILLOG 1
|
||||||
|
|
||||||
|
int AM__set_application_bypass(logical bypass);
|
||||||
|
|
||||||
|
void ECHO(char *format, ...)
|
||||||
|
{
|
||||||
|
//if( !YFJC_OPT_DEBUG )
|
||||||
|
// return;
|
||||||
|
|
||||||
|
char msg[1024];
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start( args, format );
|
||||||
|
vsprintf( msg, format, args );
|
||||||
|
va_end( args );
|
||||||
|
|
||||||
|
printf( msg );
|
||||||
|
TC_write_syslog( msg );
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE* logFile = NULL;
|
||||||
|
|
||||||
|
void set_bypass(logical bypass)
|
||||||
|
{
|
||||||
|
AM__set_application_bypass(bypass);
|
||||||
|
}
|
||||||
|
/*=============================================================================*
|
||||||
|
* FUNCTION: current_time
|
||||||
|
* PURPOSE : get the current datetime
|
||||||
|
* INPUT:
|
||||||
|
* date_t* date_tag // current date time tag
|
||||||
|
*
|
||||||
|
* RETURN:
|
||||||
|
* void
|
||||||
|
*============================================================================*/
|
||||||
|
void current_time( date_t * date_tag )
|
||||||
|
{
|
||||||
|
time_t ltime;
|
||||||
|
struct tm *today ;
|
||||||
|
|
||||||
|
// Set time zone from TZ environment variable. If TZ is not set,
|
||||||
|
// the operating system is queried to obtain the default value
|
||||||
|
// for the variable.
|
||||||
|
//
|
||||||
|
//_tzset();
|
||||||
|
|
||||||
|
// Get UNIX-style time and display as number and string.
|
||||||
|
time( <ime );
|
||||||
|
|
||||||
|
today = localtime( <ime );
|
||||||
|
date_tag->year = today->tm_year + 1900 ;
|
||||||
|
date_tag->month = today->tm_mon ;
|
||||||
|
date_tag->day = today->tm_mday ;
|
||||||
|
date_tag->hour = today->tm_hour ;
|
||||||
|
date_tag->minute = today->tm_min ;
|
||||||
|
date_tag->second = today->tm_sec ;
|
||||||
|
}
|
||||||
|
/*=============================================================================*
|
||||||
|
* FUNCTION: CreateLogFile
|
||||||
|
* PURPOSE : create log file
|
||||||
|
* INPUT:
|
||||||
|
* char* FunctionName // the funtion which need to create log file
|
||||||
|
* FILE** logFile // out: the log file pointer
|
||||||
|
*
|
||||||
|
* RETURN:
|
||||||
|
* void
|
||||||
|
*============================================================================*/
|
||||||
|
void CreateLogFile(char* FunctionName, char **fullname)
|
||||||
|
{
|
||||||
|
int i=0, ifail = ITK_ok;
|
||||||
|
//date_t status_now;
|
||||||
|
//char* date_string = NULL;
|
||||||
|
char date_string[MAX_PATH_LENGTH];
|
||||||
|
char logFileDir[MAX_PATH_LENGTH];
|
||||||
|
char logFileName[MAX_PATH_LENGTH];
|
||||||
|
|
||||||
|
char* session_uid = NULL;
|
||||||
|
tag_t session_tag = NULLTAG;
|
||||||
|
time_t now;
|
||||||
|
struct tm *p;
|
||||||
|
|
||||||
|
time(&now);
|
||||||
|
|
||||||
|
logFile = NULL;
|
||||||
|
//current_time(&status_now);
|
||||||
|
p=localtime(&now);
|
||||||
|
|
||||||
|
memset(date_string, 0, sizeof(date_string));
|
||||||
|
sprintf(date_string,"%4d%02d%02d%02d%02d%02d",1900+p->tm_year,p->tm_mon+1 ,p->tm_mday ,p->tm_hour,p->tm_min ,p->tm_sec );
|
||||||
|
//if( DATE_date_to_string( status_now, "%Y%m%d%H%M%S", &date_string) != ITK_ok )
|
||||||
|
//ifail = ITK_date_to_string (status_now, &date_string );
|
||||||
|
//if (ifail)
|
||||||
|
//{
|
||||||
|
// printf("!*ERROR*!: Failed to get current date time\n");
|
||||||
|
// goto CLEANUP;
|
||||||
|
//}
|
||||||
|
|
||||||
|
memset(logFileDir, 0, sizeof(logFileDir));
|
||||||
|
memset(logFileName, 0, sizeof(logFileName));
|
||||||
|
//get log dir
|
||||||
|
sprintf(logFileDir, "%s", getenv("TEMP"));
|
||||||
|
printf("\n log file dir: %s\n", logFileDir);
|
||||||
|
//try to change dir to TC_USER_LOG_DIR
|
||||||
|
if(chdir(logFileDir)!=ITK_ok)
|
||||||
|
{
|
||||||
|
//not set TC_USER_LOG_DIR
|
||||||
|
//log in to default TC_LOG
|
||||||
|
memset(logFileDir, 0, sizeof(logFileDir));
|
||||||
|
sprintf(logFileDir, "%s", getenv("TC_LOG"));
|
||||||
|
printf("\n TC_USER_LOG_DIR invalide, log file dir: %s\n", logFileDir);
|
||||||
|
if(chdir(logFileDir)!=ITK_ok)
|
||||||
|
{
|
||||||
|
//still can not change to log dir
|
||||||
|
printf("!*ERROR*!: Failed to change dir to TC_USER_LOG_DIR\n");
|
||||||
|
goto CLEANUP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//get session_uid to make sure the log file name unique
|
||||||
|
POM_ask_session(&session_tag);
|
||||||
|
ITK__convert_tag_to_uid(session_tag, &session_uid);
|
||||||
|
|
||||||
|
|
||||||
|
//get logFileName
|
||||||
|
sprintf(logFileName, "%s_%s_%s.log", FunctionName, session_uid, date_string);
|
||||||
|
printf("log file name: %s\n", logFileName);
|
||||||
|
|
||||||
|
*fullname = (char *)MEM_alloc(sizeof(char)*512);
|
||||||
|
sprintf(*fullname,"%s\\%s",logFileDir,logFileName);
|
||||||
|
|
||||||
|
//for(i = 0; _access((char *)logFileName, 4) == 0; i++)
|
||||||
|
/*{
|
||||||
|
memset(logFileName, 0, sizeof(logFileName));
|
||||||
|
sprintf(logFileName, "%s_%s_%s_%d.log", FunctionName, session_uid, date_string, i);
|
||||||
|
}
|
||||||
|
printf("final log file name: %s\n", logFileName);*/
|
||||||
|
|
||||||
|
//create log file
|
||||||
|
logFile = fopen(logFileName, "w");
|
||||||
|
|
||||||
|
CLEANUP:
|
||||||
|
//DOFREE(date_string);
|
||||||
|
DOFREE(session_uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*=============================================================================*
|
||||||
|
* FUNCTION: WriteLog
|
||||||
|
* PURPOSE : write log, if debug log File not null, write log message to log File
|
||||||
|
* INPUT:
|
||||||
|
* const char* format // debug message string
|
||||||
|
*
|
||||||
|
* RETURN:
|
||||||
|
* void
|
||||||
|
*============================================================================*/
|
||||||
|
void WriteLog(const char* format, ...)
|
||||||
|
{
|
||||||
|
va_list arg;
|
||||||
|
char tmp[MAX_PRINTLINE_LENGTH];
|
||||||
|
|
||||||
|
if(logFile)
|
||||||
|
{
|
||||||
|
//get the message
|
||||||
|
memset(tmp, 0, sizeof(tmp));
|
||||||
|
va_start(arg, format);
|
||||||
|
vsprintf(tmp, format, arg);
|
||||||
|
va_end(arg);
|
||||||
|
|
||||||
|
//----------print to command window for trace--------//
|
||||||
|
printf("%s\n", tmp);
|
||||||
|
|
||||||
|
//print message to log file
|
||||||
|
fprintf(logFile, "%s\n", tmp);
|
||||||
|
fflush(logFile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("*!Error!*: Log File Not Exist\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CloseLog(void)
|
||||||
|
{
|
||||||
|
if(logFile)
|
||||||
|
{
|
||||||
|
fclose(logFile);
|
||||||
|
logFile = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//void getTypeinfo(char *type)
|
||||||
|
//{
|
||||||
|
// int ulen = 0,i=0,tempcount=0,asd=0;
|
||||||
|
//
|
||||||
|
// char temp[128]="";
|
||||||
|
// ulen = strlen(type);
|
||||||
|
// asd = ulen-1;
|
||||||
|
// for(i=0;i < ulen;i++)
|
||||||
|
// {
|
||||||
|
// if(type[i] == ';')
|
||||||
|
// {
|
||||||
|
// temp[tempcount] = '\0';
|
||||||
|
// strcpy(excludetypes[typecount].type,temp);
|
||||||
|
// strcpy(temp,"");
|
||||||
|
// tempcount = 0;
|
||||||
|
// typecount = typecount + 1;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
//
|
||||||
|
// temp[tempcount] = type[i];
|
||||||
|
// tempcount = tempcount + 1;
|
||||||
|
// if(i==asd)
|
||||||
|
// {
|
||||||
|
// temp[tempcount] = '\0';
|
||||||
|
// strcpy(excludetypes[typecount].type,temp);
|
||||||
|
// typecount = typecount + 1;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//}
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
/**
|
||||||
|
* @file common_itk_util.h
|
||||||
|
* @brief itk warpper utility function
|
||||||
|
* @author James
|
||||||
|
* @history
|
||||||
|
* ===================================================================================
|
||||||
|
* Date Name Description of Change
|
||||||
|
* 09-July-2008 James
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMMON_ITK_UTIL
|
||||||
|
#define COMMON_ITK_UTIL
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DOFREE(obj) \
|
||||||
|
{ \
|
||||||
|
if(obj) \
|
||||||
|
{ \
|
||||||
|
MEM_free(obj); \
|
||||||
|
obj = NULL; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
void ECHO(char *format, ...);
|
||||||
|
void CreateLogFile(char* FunctionName, char **fullname);
|
||||||
|
void WriteLog(const char* format, ...);
|
||||||
|
void CloseLog(void);
|
||||||
|
void set_bypass(logical bypass);
|
||||||
|
//int FindDatasetReferenceExt( tag_t datasettype, const char *datasettype_ref, char ext[10] );
|
||||||
|
//int CompareDate( date_t date1, date_t date2 );
|
||||||
|
//int GetRandomTempFile( char tempFile[256] );
|
||||||
|
//logical IsItemRevisionType( char object_type[WSO_name_size_c + 1] );
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -0,0 +1,160 @@
|
|||||||
|
/*!
|
||||||
|
* @addtogroup common
|
||||||
|
* \file error_handling.h
|
||||||
|
* \brief 错误处理函数
|
||||||
|
* \date 2008/6/10
|
||||||
|
* \author Ray Li
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SIMPLE_ERR_H_INCLUDED
|
||||||
|
#define SIMPLE_ERR_H_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
|
#include <itk/mem.h>
|
||||||
|
#include <tc/iman.h>
|
||||||
|
#include <tc/emh.h>
|
||||||
|
#include <pom/pom/pom_errors.h>
|
||||||
|
#include <tc/emh_const.h>
|
||||||
|
#include <tc/tc.h>
|
||||||
|
#include <pom/pom/pom.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#define BUFSIZE 512
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
//#define HANDLER_ARGUMENT_ERROR EMH_USER_error_base + 1
|
||||||
|
//#define WORKFLOW_NODE_IS_NOT_VALID EMH_USER_error_base + 2
|
||||||
|
//#define HANDLER_PLACED_INVALID EMH_USER_error_base + 3
|
||||||
|
//
|
||||||
|
////user errors define
|
||||||
|
////<error id="100">在站点文件中缺少 %1$ 配置,或该配置中无数据项</error>
|
||||||
|
//#define ERROR_PREFERENCE_NOT_FOUND (EMH_USER_error_base + 100)
|
||||||
|
|
||||||
|
|
||||||
|
#define DOFREE(obj) \
|
||||||
|
{ \
|
||||||
|
if(obj) \
|
||||||
|
{ \
|
||||||
|
MEM_free(obj); \
|
||||||
|
obj = NULL; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//#define ECHO(X) printf X;
|
||||||
|
#define SYS_LOG(X) IMAN_write_syslog X;
|
||||||
|
#define LOG_ECHO(X) printf X; IMAN_write_syslog X;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \def CALL(x)
|
||||||
|
* 打印错误信息
|
||||||
|
*/
|
||||||
|
#define CALL(x) { \
|
||||||
|
int stat; \
|
||||||
|
char *err_string; \
|
||||||
|
if( (stat = (x)) != ITK_ok) \
|
||||||
|
{ \
|
||||||
|
EMH_ask_error_text (stat, &err_string); \
|
||||||
|
LOG_ECHO( ("ERROR: %d ERROR MSG: %s.\n",stat, err_string) ) \
|
||||||
|
LOG_ECHO( ("Function: %s FILE: %s LINE: %d\n", #x, __FILE__, __LINE__ ) ) \
|
||||||
|
MEM_free (err_string); \
|
||||||
|
return (stat); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \def DO(x)
|
||||||
|
* 打印错误信息
|
||||||
|
*/
|
||||||
|
#define DO(x) { \
|
||||||
|
int stat; \
|
||||||
|
char *err_string; \
|
||||||
|
if( (stat = (x)) != POM_ok) \
|
||||||
|
{ \
|
||||||
|
EMH_ask_error_text (stat, &err_string); \
|
||||||
|
printf ("ERROR: %d ERROR MSG: %s.\n", stat, err_string); \
|
||||||
|
printf ("Function: %s FILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \
|
||||||
|
MEM_free (err_string); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \def CALLRNULL(x)
|
||||||
|
* 打印错误信息
|
||||||
|
*/
|
||||||
|
#define CALLRNULL(x) { \
|
||||||
|
int stat; \
|
||||||
|
char *err_string; \
|
||||||
|
if( (stat = (x)) != ITK_ok) \
|
||||||
|
{ \
|
||||||
|
EMH_ask_error_text (stat, &err_string); \
|
||||||
|
printf ("ERROR: %d ERROR MSG: %s.\n", stat, err_string); \
|
||||||
|
printf ("Function: %s FILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \
|
||||||
|
MEM_free (err_string); \
|
||||||
|
return ((char *)NULL); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \def CALL2(x)
|
||||||
|
* 打印错误信息
|
||||||
|
*/
|
||||||
|
#define CALL2(x) { \
|
||||||
|
int stat, n_ifails, *serverities, *ifails, err_count; \
|
||||||
|
char *err_string, **texts; \
|
||||||
|
if( (stat = (x)) != ITK_ok) \
|
||||||
|
{ \
|
||||||
|
printf ("Function: %s FILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \
|
||||||
|
EMH_ask_errors( &n_ifails, (const int**)(&serverities), (const int**)(&ifails), (const char***)(&texts) );\
|
||||||
|
for( err_count=0; err_count<n_ifails; err_count++ ) \
|
||||||
|
{ \
|
||||||
|
printf( "ERROR: %d ERROR MSG: %s.\n", ifails[i], texts[i] ); \
|
||||||
|
} \
|
||||||
|
MEM_free( serverities ); \
|
||||||
|
MEM_free( ifails ); \
|
||||||
|
MEM_free( texts ); \
|
||||||
|
return (stat); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
|
||||||
|
#define CHECK_FILE(x,ret) { \
|
||||||
|
FILE *stream = NULL; \
|
||||||
|
if( (stream = fopen(x,"rb")) == NULL ) { \
|
||||||
|
printf( "%s doesn't exists, please check!\n", x ); \
|
||||||
|
IMAN_write_syslog( "%s doesn't exists, please check!\n", x) ; \
|
||||||
|
ret = -1; \
|
||||||
|
} \
|
||||||
|
else { \
|
||||||
|
fclose(stream); \
|
||||||
|
stream = NULL; \
|
||||||
|
ret = 0; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
|
||||||
|
|
||||||
|
#define CHECK_FILE_NOT_EXISTS(x,ret) { \
|
||||||
|
FILE *stream = NULL; \
|
||||||
|
if( (stream = fopen(x,"rb")) != NULL ) { \
|
||||||
|
fclose(stream); \
|
||||||
|
stream = NULL; \
|
||||||
|
printf( "%s exists, please check!\n", x ); \
|
||||||
|
IMAN_write_syslog( "%s exists, please check!\n", x) ; \
|
||||||
|
ret = -1; \
|
||||||
|
} \
|
||||||
|
else { \
|
||||||
|
ret = 0; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
# include "common_itk_util.h"
|
||||||
|
# include "error_handling.h"
|
||||||
|
# include "ocilib.h"
|
||||||
|
# include "string_helper.h"
|
||||||
|
# include "string_utils.h"
|
||||||
|
|
||||||
|
|
||||||
|
int ITK_user_main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
printf("1111\n");
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,57 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="源文件">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="头文件">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="资源文件">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="common">
|
||||||
|
<UniqueIdentifier>{695e5212-e914-4315-a83f-087109122c06}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="common_itk_util.c">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="string_helper.cpp">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="ocilib.cxx">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="string_utils.cxx">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="jf_erp_project.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="common_itk_util.h">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="error_handling.h">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="ocilib.h">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="string_helper.h">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="string_utils.h">
|
||||||
|
<Filter>common</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="jf_erp_project.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
</Project>
|
||||||
@ -0,0 +1,98 @@
|
|||||||
|
/*=====================================================================================================================
|
||||||
|
Copyright(c) 2012 ORIGIN.
|
||||||
|
Unpublished - All rights reserved
|
||||||
|
=======================================================================================================================
|
||||||
|
File description:
|
||||||
|
|
||||||
|
Filename: ocilib.h
|
||||||
|
Module : OCI
|
||||||
|
|
||||||
|
This Header file of OCI library Package.
|
||||||
|
|
||||||
|
=======================================================================================================================
|
||||||
|
Date Name Description of Change
|
||||||
|
1-Feb-2015 Ray Initialize creation
|
||||||
|
$HISTORY$
|
||||||
|
=====================================================================================================================*/
|
||||||
|
#include <oci.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <memory.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
//#include <limits.h>
|
||||||
|
|
||||||
|
#define OCI_FAIL 1
|
||||||
|
#define OCI_OK 0
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
/**
|
||||||
|
* 连接数据库.
|
||||||
|
* @param username - <I> 用户名
|
||||||
|
* @param password - <I> 密码
|
||||||
|
* @param dbname - <I> 数据库SID
|
||||||
|
* @return - OCI_OK or error code
|
||||||
|
*
|
||||||
|
* ORACLE 数据库的连接与封装函数
|
||||||
|
*/
|
||||||
|
extern int ConnServer(char *username,char *password,char *dbname);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不带输入参数的执行SQL语句.
|
||||||
|
* @param SQL - <I> SQL语句
|
||||||
|
* @return - OCI_OK or error code
|
||||||
|
*
|
||||||
|
* ORACLE 数据库的连接与封装函数
|
||||||
|
*/
|
||||||
|
extern int ExecuteSQLNoInputParam(char *SQL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 带输入参数的执行SQL语句.
|
||||||
|
* @param SQL - <I> SQL语句
|
||||||
|
* @param inputValueCount - <I> 输入参数数量
|
||||||
|
* @param inputValue - <I> 输入参数值
|
||||||
|
* @return - OCI_OK or error code
|
||||||
|
*
|
||||||
|
* ORACLE 数据库的连接与封装函数
|
||||||
|
*/
|
||||||
|
extern int ExecuteSQL(char *SQL,int inputValueCount,char **inputValue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不带输入参数的查询SQL语句.
|
||||||
|
* @param SQL - <I> SQL语句
|
||||||
|
* @param outputColumn - <O> 输出表的列的数量
|
||||||
|
* @param outputValueCount - <O> 输出表的行的数量
|
||||||
|
* @param outputValue - <O> 输出表内容
|
||||||
|
* @return - OCI_OK or error code
|
||||||
|
*
|
||||||
|
* ORACLE 数据库的连接与封装函数
|
||||||
|
*/
|
||||||
|
extern int QuerySQLNoInputParam(char *SQL, int * outputColumn, int * outputValueCount, char **** outputValue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 带输入参数的查询SQL语句.
|
||||||
|
* @param SQL - <I> SQL语句
|
||||||
|
* @param inputValueCount - <I> 输入参数数量
|
||||||
|
* @param inputValue - <I> 输入参数值
|
||||||
|
* @param outputColumn - <O> 输出表的列的数量
|
||||||
|
* @param outputValueCount - <O> 输出表的行的数量
|
||||||
|
* @param outputValue - <O> 输出表内容
|
||||||
|
* @return - OCI_OK or error code
|
||||||
|
*
|
||||||
|
* ORACLE 数据库的连接与封装函数
|
||||||
|
*/
|
||||||
|
extern int QuerySQL(char *SQL, int inputValueCount, char ** inputValue, int * outputColumn, int * outputValueCount, char **** outputValue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 断开数据库连接.
|
||||||
|
*
|
||||||
|
* ORACLE 数据库的连接与封装函数
|
||||||
|
*/
|
||||||
|
extern void DisConnServer();
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@ -0,0 +1,146 @@
|
|||||||
|
/**
|
||||||
|
* @file string_helper.cpp
|
||||||
|
* @brief string utility functions' implemention
|
||||||
|
* @author James
|
||||||
|
* @history
|
||||||
|
* ===================================================================================
|
||||||
|
* Date Name Description of Change
|
||||||
|
* 09-July-2008 James
|
||||||
|
* 14-Jau-2009 James modify Split functions, add trim blank characters
|
||||||
|
*/
|
||||||
|
#pragma warning(disable:4996)
|
||||||
|
//
|
||||||
|
//#include <stdio.h>
|
||||||
|
//#include <iostream>
|
||||||
|
//#include <windows.h>
|
||||||
|
#include "string_helper.h"
|
||||||
|
|
||||||
|
string TrimString( string strArg )
|
||||||
|
{
|
||||||
|
size_t index1 = 0;
|
||||||
|
index1 = strArg.find_first_not_of( ' ');
|
||||||
|
if( index1 != string::npos )
|
||||||
|
strArg.erase( strArg.begin(), strArg.begin()+index1 );
|
||||||
|
index1 = strArg.find_last_not_of( ' ');
|
||||||
|
if( index1 != string::npos )
|
||||||
|
strArg.erase( strArg.begin() + index1 + 1 );
|
||||||
|
return strArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Split( string strArg, char spliter, vector<string> &ans )
|
||||||
|
{
|
||||||
|
ans.clear();
|
||||||
|
size_t index0 = 0;
|
||||||
|
string one_arg;
|
||||||
|
if ( strArg.find_first_not_of(' ') == string::npos )
|
||||||
|
strArg = "";
|
||||||
|
while( strArg.size()>0 )
|
||||||
|
{
|
||||||
|
index0 = strArg.find_first_of( spliter );
|
||||||
|
if( index0 != string::npos )
|
||||||
|
{
|
||||||
|
one_arg = strArg.substr( 0,index0 );
|
||||||
|
strArg = strArg.substr( index0 + 1 );
|
||||||
|
ans.push_back( one_arg );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ans.push_back( strArg );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Split( string strArg, string spliter, vector<string> &ans )
|
||||||
|
{
|
||||||
|
|
||||||
|
ans.clear();
|
||||||
|
|
||||||
|
size_t index0;
|
||||||
|
string one_arg;
|
||||||
|
|
||||||
|
if ( strArg.find_first_not_of(" ") == string::npos )
|
||||||
|
strArg = "";
|
||||||
|
|
||||||
|
|
||||||
|
while( strArg.size()>0 )
|
||||||
|
{
|
||||||
|
|
||||||
|
index0 = strArg.find(spliter);
|
||||||
|
|
||||||
|
if( index0 != string::npos )
|
||||||
|
{
|
||||||
|
|
||||||
|
one_arg = strArg.substr( 0, index0 );
|
||||||
|
strArg = strArg.substr( index0 + spliter.size() );
|
||||||
|
|
||||||
|
ans.push_back( one_arg );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
ans.push_back( strArg );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RemoveLiner( string &in, string &out )
|
||||||
|
{
|
||||||
|
char buf[BUFSIZ] = "";
|
||||||
|
for( int i=0; i<(int)in.size(); i++ )
|
||||||
|
{
|
||||||
|
if( in[i] == '\n')
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
sprintf( buf,"%s%c", buf, in[i] );
|
||||||
|
}
|
||||||
|
out.assign(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
////Converting a WChar string to a Ansi string
|
||||||
|
//std::string WChar2Ansi(LPCWSTR pwszSrc)
|
||||||
|
//{
|
||||||
|
// int nLen = WideCharToMultiByte(CP_ACP, 0, pwszSrc, -1, NULL, 0, NULL, NULL);
|
||||||
|
//
|
||||||
|
// if (nLen<= 0) return std::string("");
|
||||||
|
//
|
||||||
|
// char* pszDst = new char[nLen];
|
||||||
|
// if (NULL == pszDst) return std::string("");
|
||||||
|
//
|
||||||
|
// WideCharToMultiByte(CP_ACP, 0, pwszSrc, -1, pszDst, nLen, NULL, NULL);
|
||||||
|
// pszDst[nLen -1] = 0;
|
||||||
|
//
|
||||||
|
// std::string strTemp(pszDst);
|
||||||
|
// delete [] pszDst;
|
||||||
|
//
|
||||||
|
// return strTemp;
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//string ws2s(wstring& inputws){ return WChar2Ansi(inputws.c_str()); }
|
||||||
|
//
|
||||||
|
////Converting a Ansi string to WChar string
|
||||||
|
//std::wstring Ansi2WChar(LPCSTR pszSrc, int nLen)
|
||||||
|
//{
|
||||||
|
// int nSize = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pszSrc, nLen, 0, 0);
|
||||||
|
// if(nSize <= 0) return NULL;
|
||||||
|
//
|
||||||
|
// WCHAR *pwszDst = new WCHAR[nSize+1];
|
||||||
|
// if( NULL == pwszDst) return NULL;
|
||||||
|
//
|
||||||
|
// MultiByteToWideChar(CP_ACP, 0,(LPCSTR)pszSrc, nLen, pwszDst, nSize);
|
||||||
|
// pwszDst[nSize] = 0;
|
||||||
|
//
|
||||||
|
// if( pwszDst[0] == 0xFEFF) // skip Oxfeff
|
||||||
|
// for(int i = 0; i < nSize; i ++)
|
||||||
|
// pwszDst[i] = pwszDst[i+1];
|
||||||
|
//
|
||||||
|
// wstring wcharString(pwszDst);
|
||||||
|
// delete pwszDst;
|
||||||
|
//
|
||||||
|
// return wcharString;
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//std::wstring s2ws(const string& s){ return Ansi2WChar(s.c_str(),s.size());}
|
||||||
|
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* @file string_helper.h
|
||||||
|
* @brief string utilities to help dealing with string
|
||||||
|
* @author James
|
||||||
|
* @history
|
||||||
|
* ===================================================================================
|
||||||
|
* Date Name Description of Change
|
||||||
|
* 09-July-2008 James
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef STRING_HELPER
|
||||||
|
#define STRING_HELPER
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
string TrimString( string strArg );
|
||||||
|
void Split( string strArg, char spliter, vector<string> &ans );
|
||||||
|
void Split( string strArg, string spliter, vector<string> &ans );
|
||||||
|
void RemoveLiner( string &in, string &out );
|
||||||
|
//string ws2s(wstring& inputws);
|
||||||
|
//wstring s2ws(const string& s);
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -0,0 +1,253 @@
|
|||||||
|
/*==================================================================================================================
|
||||||
|
Copyright(c) 2012 ORIGIN.
|
||||||
|
Unpublished - All rights reserved
|
||||||
|
====================================================================================================================
|
||||||
|
File description:
|
||||||
|
Filename: string_utils.c
|
||||||
|
Module : Common module.
|
||||||
|
|
||||||
|
This file includes some operations of the string.
|
||||||
|
|
||||||
|
====================================================================================================================
|
||||||
|
Date Name Description of Change
|
||||||
|
3-Feb-2015 Ray li Initialize creation
|
||||||
|
$HISTORY$
|
||||||
|
===================================================================================================================*/
|
||||||
|
#ifndef _cplusplus
|
||||||
|
#ifndef _CRT_SECURE_NO_DEPRECATE
|
||||||
|
#define _CRT_SECURE_NO_DEPRECATE
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <fclasses/tc_string.h>
|
||||||
|
#include <tc/tc_util.h>
|
||||||
|
#include <itk/mem.h>
|
||||||
|
#include <tccore/workspaceobject.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include "string_utils.h"
|
||||||
|
|
||||||
|
//void Split( string strArg, string spliter, vector<string> &ans )
|
||||||
|
//{
|
||||||
|
// ans.clear();
|
||||||
|
// size_t index0;
|
||||||
|
// string one_arg;
|
||||||
|
// if ( strArg.find_first_not_of(' ') == string::npos )
|
||||||
|
// strArg = "";
|
||||||
|
// while( strArg.size()>0 )
|
||||||
|
// {
|
||||||
|
// index0 = strArg.find(spliter);
|
||||||
|
// if( index0 != string::npos )
|
||||||
|
// {
|
||||||
|
// one_arg = strArg.substr( 0, index0 );
|
||||||
|
// strArg = strArg.substr( index0 + spliter.size() );
|
||||||
|
// ans.push_back( one_arg );
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// ans.push_back( strArg );
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
char* GSTR_clone( char **dst, const char *src )
|
||||||
|
{
|
||||||
|
char *retVal = NULL;
|
||||||
|
int srcLen = 0;
|
||||||
|
|
||||||
|
*dst = NULL;
|
||||||
|
if (src == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
srcLen = (int)tc_strlen( src ) + 1;
|
||||||
|
*dst = (char*)MEM_alloc( srcLen * sizeof(char) );
|
||||||
|
retVal = tc_strncpy( *dst, src, srcLen );
|
||||||
|
(*dst)[srcLen - 1] = '\0';
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* GSTR_copy( char *dst, const char *src, int dstSize )
|
||||||
|
{
|
||||||
|
char *retVal = tc_strncpy( dst, src, dstSize );
|
||||||
|
dst[dstSize - 1] = '\0';
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* GSTR_int_to_string( char **dst, int value )
|
||||||
|
{
|
||||||
|
char strVal[128 + 1];
|
||||||
|
|
||||||
|
*dst = NULL;
|
||||||
|
memset( strVal, 0, sizeof(strVal)/sizeof(char) );
|
||||||
|
sprintf( strVal, "%d", value );
|
||||||
|
|
||||||
|
return GSTR_clone( dst, strVal );
|
||||||
|
}
|
||||||
|
|
||||||
|
void GSTR_format_int_to_string( char *dst, int digitNum, int value )
|
||||||
|
{
|
||||||
|
char sNum[WSO_desc_size_c + 1];
|
||||||
|
sprintf( sNum, "%%0%dd", digitNum );
|
||||||
|
sprintf( dst, sNum, value );
|
||||||
|
}
|
||||||
|
|
||||||
|
void GSTR_format_string( const char *dst, int m, const char *fill_char, char **out )
|
||||||
|
{
|
||||||
|
char sNum[WSO_name_size_c + 1] = {0};
|
||||||
|
char sNew[WSO_name_size_c + 1] = {0};
|
||||||
|
sprintf( sNum, "%%%d.%ds", m, m );
|
||||||
|
sprintf( sNew, sNum, dst );
|
||||||
|
STRNG_replace_str( sNew, " ", fill_char, out );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char* GSTR_string_append( const char *s1, const char *s2 )
|
||||||
|
{
|
||||||
|
char *s = NULL;
|
||||||
|
if (s1 == NULL || s2 == NULL)
|
||||||
|
{
|
||||||
|
GSTR_clone(&s, s1 == NULL ? (s2 == NULL ? "" : s2) : s1 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int size = (int)tc_strlen(s1) + (int)tc_strlen(s2) + 1;
|
||||||
|
s = (char *)MEM_alloc( size );
|
||||||
|
tc_strcpy( s, s1 );
|
||||||
|
tc_strcat( s, s2 );
|
||||||
|
s[size - 1] = '\0';
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
logical GSTR_is_float(const char *str)
|
||||||
|
{
|
||||||
|
logical isfloat = true;
|
||||||
|
char *pStr = (char *)str;
|
||||||
|
logical hasPositive = false;
|
||||||
|
logical hasMinus = false;
|
||||||
|
logical hasDot = false;
|
||||||
|
|
||||||
|
if (str == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
while (*pStr != '\0' && isfloat == true)
|
||||||
|
{
|
||||||
|
if ( (*pStr >= '0' && *pStr <= '9'))
|
||||||
|
{
|
||||||
|
//continue;
|
||||||
|
}
|
||||||
|
else if ( *pStr == '+' )
|
||||||
|
{
|
||||||
|
isfloat = (hasPositive ? false : (hasPositive = true));
|
||||||
|
}
|
||||||
|
else if ( *pStr == '-' )
|
||||||
|
{
|
||||||
|
isfloat = (hasMinus ? false : (hasMinus = true));
|
||||||
|
}
|
||||||
|
else if ( *pStr == '.' )
|
||||||
|
{
|
||||||
|
isfloat = (hasDot ? false : (hasDot = true));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
isfloat = false;
|
||||||
|
|
||||||
|
pStr ++;
|
||||||
|
}
|
||||||
|
return isfloat;
|
||||||
|
}
|
||||||
|
|
||||||
|
logical GSTR_is_number(const char *str)
|
||||||
|
{
|
||||||
|
logical is_number = true;
|
||||||
|
char *pStr = (char *)str;
|
||||||
|
if (str == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
while (*pStr != '\0')
|
||||||
|
{
|
||||||
|
if ( !( (*pStr >= '0' && *pStr <= '9') || *pStr == '-' ) )
|
||||||
|
{
|
||||||
|
is_number = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pStr ++;
|
||||||
|
}
|
||||||
|
return is_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
logical GSTR_is_ascii(char ch)
|
||||||
|
{
|
||||||
|
return ((unsigned int)ch) < 128;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GSTR_trim_l( char *str, char s )
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
char *pointer = str, *poffset = NULL;
|
||||||
|
if (str == NULL || str[0] == '\0')
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
while ( *pointer != '\0' )
|
||||||
|
{
|
||||||
|
if ( *pointer != s )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
pointer++;
|
||||||
|
}
|
||||||
|
if (count == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
poffset = str + count;
|
||||||
|
pointer = str;
|
||||||
|
while ( *poffset != '\0' )
|
||||||
|
{
|
||||||
|
*pointer = *poffset;
|
||||||
|
pointer ++;
|
||||||
|
poffset ++;
|
||||||
|
}
|
||||||
|
*pointer = '\0';
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GSTR_trim_r( char *str, char s )
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
char *pointer = NULL;
|
||||||
|
if (str == NULL || str[0] == '\0')
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
pointer = str + ((int) strlen(str) - 1);
|
||||||
|
|
||||||
|
while ( pointer != str )
|
||||||
|
{
|
||||||
|
if ( *pointer != s )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pointer = '\0';
|
||||||
|
|
||||||
|
count++;
|
||||||
|
pointer--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GSTR_trim_float( char *floatValue )
|
||||||
|
{
|
||||||
|
if ( !IS_EMPTY(floatValue) && tc_strstr(floatValue, ".") != NULL )
|
||||||
|
{
|
||||||
|
int len = 0;
|
||||||
|
GSTR_trim_r(floatValue, '0');
|
||||||
|
len = (int)tc_strlen(floatValue);
|
||||||
|
if (floatValue[ len - 1 ] == '.')
|
||||||
|
floatValue[ len - 1 ] = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,125 @@
|
|||||||
|
/*=====================================================================================================================
|
||||||
|
Copyright(c) 2005 ORIGIN PLM Software Corp. All rights reserved.
|
||||||
|
Unpublished - All rights reserved
|
||||||
|
=======================================================================================================================
|
||||||
|
File description:
|
||||||
|
Filename: string_utils.h
|
||||||
|
Module : Common module.
|
||||||
|
|
||||||
|
This file includes some operations of the string.
|
||||||
|
|
||||||
|
=======================================================================================================================
|
||||||
|
Date Name Description of Change
|
||||||
|
14-Jul-2009 Ray Li Initialize creation
|
||||||
|
$HISTORY$
|
||||||
|
=====================================================================================================================*/
|
||||||
|
#ifndef STRING_UTILS_H
|
||||||
|
#define STRING_UTILS_H
|
||||||
|
#include <string>
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
using namespace std;
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// @{{ String assister
|
||||||
|
#define IS_NULL(S) ((S)==NULL)
|
||||||
|
#define IS_EMPTY(S) (((S)==NULL) || !(*(S)))
|
||||||
|
// @}}
|
||||||
|
void Split( string strArg, string spliter, vector<string> &ans );
|
||||||
|
/**
|
||||||
|
* Clones the string.
|
||||||
|
* @param dst - <OF> the output string.
|
||||||
|
* @param src - <I> the string to be cloned.
|
||||||
|
* @return - the destinatin string pointer.
|
||||||
|
*/
|
||||||
|
extern char* GSTR_clone( char **dst, const char *src );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy safely the string with null end.
|
||||||
|
* @param dst - <O> the output string.
|
||||||
|
* @param src - <I> the string to be cloned.
|
||||||
|
* @param dstSize - <I> the size of output string.
|
||||||
|
* @return - the destinatin string pointer.
|
||||||
|
*/
|
||||||
|
extern char *GSTR_copy( char *dst, const char *src, int dstSize );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts int to string.
|
||||||
|
* @param dst - <OF> the output string.
|
||||||
|
* @param value - <I> the int to be cloned.
|
||||||
|
* @return - the destinatin string pointer.
|
||||||
|
*/
|
||||||
|
extern char* GSTR_int_to_string( char **dst, int value );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats the int/string value as string.
|
||||||
|
* @param dst - <O> the destination string.
|
||||||
|
* @param digitNum - <I> the digit number of the value.
|
||||||
|
* @param value - <I> the value to be converted.
|
||||||
|
* @return - N/A.
|
||||||
|
*/
|
||||||
|
extern void GSTR_format_int_to_string( char *dst, int digitNum, int value );
|
||||||
|
extern void GSTR_format_string( const char *dst, int m, const char *fill_char, char **out );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appends the strings( never null returned )
|
||||||
|
* @param s1 - <I> string 1
|
||||||
|
* @param s2 - <I> string 2
|
||||||
|
* @return - <OF> new string
|
||||||
|
*/
|
||||||
|
extern char* GSTR_string_append( const char *s1, const char *s2 );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the string is float type
|
||||||
|
* @param str - <I> The string
|
||||||
|
*
|
||||||
|
* NOTE: it's only check whether each word is in "+-.0123456789", not care the float with "E" or the float rule,
|
||||||
|
* like "00-1.+01", it will return true.
|
||||||
|
* @return - return true if it is one.
|
||||||
|
*/
|
||||||
|
extern logical GSTR_is_float(const char *str);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether all char of the string are number
|
||||||
|
* @param str - <I> The string
|
||||||
|
*
|
||||||
|
* NOTE: it's only check whether each word is in "0123456789"
|
||||||
|
* @return - return true if it is one.
|
||||||
|
*/
|
||||||
|
extern logical GSTR_is_number(const char *str);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is ascii char
|
||||||
|
* @param ch - <I> ascii char
|
||||||
|
* @return - return true if it is.
|
||||||
|
*/
|
||||||
|
extern logical GSTR_is_ascii(char ch);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trims the string's prefix.
|
||||||
|
* @param str - <I> The string
|
||||||
|
* @param s - <I> The char
|
||||||
|
*
|
||||||
|
* @return - count.
|
||||||
|
*/
|
||||||
|
extern int GSTR_trim_l( char *str, char s );
|
||||||
|
extern int GSTR_trim_r( char *str, char s );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the zero.
|
||||||
|
* For Example:
|
||||||
|
* floatValue="50.00" -> = "50"
|
||||||
|
* floatValue="50.0100" -> = "50.01"
|
||||||
|
* @return - count.
|
||||||
|
*/
|
||||||
|
extern void GSTR_trim_float( char *floatValue );
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif //STRING_UTILS_H
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue