|
|
#include <wchar.h>
|
|
|
#include <string.h>
|
|
|
#ifdef WIN32
|
|
|
#include <io.h>
|
|
|
#include <direct.h>
|
|
|
#else
|
|
|
#include <unistd.h>
|
|
|
#endif
|
|
|
#include "connor_itk_util.h"
|
|
|
extern "C" int POM_AM__set_application_bypass(logical bypass);
|
|
|
|
|
|
#define ARGS_LENGTH 200
|
|
|
#define ARGS_NAME_DEBUG "-debug"
|
|
|
#define DEBUG "-debug="
|
|
|
#define MAX_PRINTLINE_LENGTH 10000
|
|
|
#define MAX_PATH_LENGTH 2000
|
|
|
#define MAX_ARGUMENT_LENGTH 400
|
|
|
#define MAX_FILE_EXT_LENGTH 10
|
|
|
#define TRUE_FLAG 1
|
|
|
#define FALSE_FLAG 0
|
|
|
#define DETAILLOG 1
|
|
|
|
|
|
void ECHO(char* format, ...)
|
|
|
{
|
|
|
//if( !YFJC_OPT_DEBUG )
|
|
|
// return;
|
|
|
|
|
|
char msg[4096];
|
|
|
va_list args;
|
|
|
|
|
|
va_start(args, format);
|
|
|
vsprintf(msg, format, args);
|
|
|
va_end(args);
|
|
|
|
|
|
printf(msg);
|
|
|
TC_write_syslog(msg);
|
|
|
}
|
|
|
|
|
|
FILE* logFile = NULL;
|
|
|
|
|
|
/*=============================================================================*
|
|
|
* 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 );
|
|
|
sprintf(date_string, "%4d%02d%02d", 1900 + p->tm_year, p->tm_mon + 1, p->tm_mday);
|
|
|
//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);
|
|
|
sprintf(logFileName, "%s_%s.log", FunctionName, 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, "a");
|
|
|
|
|
|
CLEANUP:
|
|
|
//DOFREE(date_string);
|
|
|
DOFREE(session_uid);
|
|
|
}
|
|
|
|
|
|
void CreateLogFile2(char* FunctionName, char** fullname, char* fileDir)
|
|
|
{
|
|
|
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 );
|
|
|
sprintf(date_string, "%4d%02d%02d", 1900 + p->tm_year, p->tm_mon + 1, p->tm_mday);
|
|
|
//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"));
|
|
|
strcat(logFileDir, fileDir);
|
|
|
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);
|
|
|
sprintf(logFileName, "%s_%s.log", FunctionName, 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, "a");
|
|
|
|
|
|
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 WriteLog2(string value) {
|
|
|
if (logFile)
|
|
|
{
|
|
|
fprintf(logFile, "%s\n", value.c_str());
|
|
|
fflush(logFile);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
printf("*!Error!*: Log File Not Exist\n");
|
|
|
}
|
|
|
}
|
|
|
void CloseLog(void)
|
|
|
{
|
|
|
if (logFile)
|
|
|
{
|
|
|
fclose(logFile);
|
|
|
logFile = NULL;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
string getUUid()
|
|
|
{
|
|
|
GUID guid;
|
|
|
char buffer[64] = { 0 };
|
|
|
if (CoCreateGuid(&guid))
|
|
|
{
|
|
|
printf("create guid error\n");
|
|
|
return "";
|
|
|
}
|
|
|
//_snprintf(buffer, sizeof(buffer), "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", guid.Data1, guid.Data2, guid.Data3,
|
|
|
// guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]);
|
|
|
sprintf_s(buffer, sizeof(buffer),
|
|
|
"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
|
|
guid.Data1, guid.Data2, guid.Data3,
|
|
|
guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3],
|
|
|
guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]);
|
|
|
|
|
|
return buffer;
|
|
|
}
|
|
|
|
|
|
char* GbkToUtf8(const char* src_str)
|
|
|
{
|
|
|
int len = MultiByteToWideChar(CP_ACP, 0, src_str, -1, NULL, 0);
|
|
|
wchar_t* wstr = (wchar_t*)MEM_alloc((len + 1) * sizeof(wchar_t));
|
|
|
memset(wstr, 0, len + 1);
|
|
|
MultiByteToWideChar(CP_ACP, 0, src_str, -1, wstr, len);
|
|
|
len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL);
|
|
|
char* str = (char*)MEM_alloc((len + 1) * sizeof(char));
|
|
|
|
|
|
memset(str, 0, len + 1);
|
|
|
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, len, NULL, NULL);
|
|
|
return str;
|
|
|
}
|
|
|
|
|
|
char* Utf8ToGbk(const char* src_str)
|
|
|
{
|
|
|
int len = MultiByteToWideChar(CP_UTF8, 0, src_str, -1, NULL, 0);
|
|
|
wchar_t* wszGBK = (wchar_t*)MEM_alloc((len + 1) * sizeof(wchar_t));
|
|
|
memset(wszGBK, 0, len * 2 + 2);
|
|
|
MultiByteToWideChar(CP_UTF8, 0, src_str, -1, wszGBK, len);
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, wszGBK, -1, NULL, 0, NULL, NULL);
|
|
|
char* szGBK = (char*)MEM_alloc((len + 1) * sizeof(char));
|
|
|
|
|
|
memset(szGBK, 0, len + 1);
|
|
|
WideCharToMultiByte(CP_ACP, 0, wszGBK, -1, szGBK, len, NULL, NULL);
|
|
|
return szGBK;
|
|
|
}
|
|
|
|
|
|
void starTime() {
|
|
|
time_t now;
|
|
|
struct tm* p;
|
|
|
time(&now);
|
|
|
p = localtime(&now);
|
|
|
WriteLog("start time %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);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* <20>ж<EFBFBD>ij<EFBFBD><C4B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>ΪItemRevision
|
|
|
*
|
|
|
*/
|
|
|
logical checkIsItemRevision(tag_t objtag) {
|
|
|
tag_t type = NULLTAG;
|
|
|
tag_t item_type = NULLTAG;
|
|
|
logical isItems = false;
|
|
|
ITKCALL(TCTYPE_ask_object_type(objtag, &type));
|
|
|
ITKCALL(TCTYPE_find_type("ItemRevision", "", &item_type));
|
|
|
if (item_type != NULLTAG) {
|
|
|
logical isok = FALSE;
|
|
|
ITKCALL(TCTYPE_is_type_of(type, item_type, &isok));
|
|
|
if (isok) {
|
|
|
isItems = TRUE;
|
|
|
}
|
|
|
else {
|
|
|
isItems = FALSE;
|
|
|
}
|
|
|
}
|
|
|
return isItems;
|
|
|
}
|
|
|
|
|
|
int checkIsInType(tag_t objtag, string parentType) {
|
|
|
tag_t type = NULLTAG;
|
|
|
tag_t item_type = NULLTAG;
|
|
|
ITKCALL(TCTYPE_ask_object_type(objtag, &type));
|
|
|
ITKCALL(TCTYPE_find_type(parentType.c_str(), "", &item_type));
|
|
|
if (item_type != NULLTAG) {
|
|
|
logical isok = FALSE;
|
|
|
ITKCALL(TCTYPE_is_type_of(type, item_type, &isok));
|
|
|
if (isok) {
|
|
|
return 1;
|
|
|
}
|
|
|
else {
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
int getPrefStrings(const char* preference, vector<string>& pref_vec)
|
|
|
{
|
|
|
int ifail = ITK_ok, i = 0, j = 0, k = 0, num = 0;
|
|
|
char** values;
|
|
|
ITKCALL(ifail = PREF_ask_char_values(preference, &num, &values));
|
|
|
for (i = 0; i < num; i++)
|
|
|
{
|
|
|
pref_vec.push_back(values[i]);
|
|
|
}
|
|
|
DOFREE(values);
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
/*******************************************************************
|
|
|
*
|
|
|
*<2A><>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>Ϣд<CFA2>뵽<EFBFBD>м<EFBFBD><D0BC>ļ<EFBFBD>
|
|
|
*
|
|
|
*@param file_content ǩ<><C7A9><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
*@param item_id <20><><EFBFBD><EFBFBD>id
|
|
|
*@param file_name <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
*
|
|
|
*******************************************************************/
|
|
|
int Supor_create_signinfo_file(char* file_content, char* item_id, char** file_name)
|
|
|
{
|
|
|
time_t now;
|
|
|
struct tm* p;
|
|
|
FILE* filePtr = NULL;
|
|
|
char temp_dir[MAX_PATH_LENGTH];
|
|
|
char local_path[MAX_PATH] = "";
|
|
|
char date_string[MAX_PATH_LENGTH];
|
|
|
memset(temp_dir, 0, sizeof(temp_dir));
|
|
|
memset(local_path, 0, sizeof(local_path));
|
|
|
sprintf(temp_dir, "%s", getenv("TEMP"));
|
|
|
printf("\n file dir: %s\n", temp_dir);
|
|
|
time(&now);
|
|
|
p = localtime(&now);
|
|
|
if (chdir(temp_dir) != ITK_ok)
|
|
|
{
|
|
|
memset(temp_dir, 0, sizeof(temp_dir));
|
|
|
sprintf(temp_dir, "%s", getenv("TC_LOG"));
|
|
|
printf("\n TC_USER_LOG_DIR invalide, log file dir: %s\n", temp_dir);
|
|
|
if (chdir(temp_dir) != ITK_ok)
|
|
|
{
|
|
|
printf("!*ERROR*!: Failed to change dir to TC_USER_LOG_DIR\n");
|
|
|
|
|
|
}
|
|
|
}
|
|
|
memset(date_string, 0, sizeof(date_string));
|
|
|
if (item_id != NULL) {
|
|
|
sprintf(date_string, "%s_%4d%02d%02d%02d%02d%02d.dat", item_id, 1900 + p->tm_year, p->tm_mon + 1, p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sprintf(date_string, "%4d%02d%02d%02d%02d%02d.dat", 1900 + p->tm_year, p->tm_mon + 1, p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec);
|
|
|
}
|
|
|
printf("file name: %s\n", date_string);
|
|
|
filePtr = fopen(date_string, "w");
|
|
|
printf("create the temp dat file success!\n");
|
|
|
*file_name = (char*)MEM_alloc(sizeof(char) * 512);
|
|
|
sprintf(local_path, "%s\\%s", temp_dir, date_string);
|
|
|
strcpy((*file_name), local_path);
|
|
|
fprintf(filePtr, "%s", file_content);
|
|
|
//fwrite(file_content, sizeof(char), strlen(file_content), filePtr);
|
|
|
fclose(filePtr);
|
|
|
|
|
|
return ITK_ok;
|
|
|
}
|
|
|
int Connor_set_bypass(void* returnValue)
|
|
|
{
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
int Connor_close_bypass(void* returnValue)
|
|
|
{
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
int MT_add_release_status(void* return_data) {
|
|
|
int ifail = ITK_ok;
|
|
|
tag_t tags = NULLTAG;
|
|
|
char* client_string2 = NULL;
|
|
|
ITKCALL(ifail = USERARG_get_tag_argument(&tags));
|
|
|
ITKCALL(ifail = USERARG_get_string_argument(&client_string2));
|
|
|
tag_t release_stat = NULLTAG;
|
|
|
ITKCALL(ifail = RELSTAT_create_release_status(client_string2, &release_stat));
|
|
|
if (ifail == ITK_ok) {
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
ITKCALL(ifail = RELSTAT_add_release_status(release_stat, 1, &tags, true));
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
}
|
|
|
|
|
|
MEM_free(client_string2);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
// <20><><EFBFBD>ݴ<EFBFBD><DDB4>ݹ<EFBFBD><DDB9><EFBFBD><EFBFBD><EFBFBD>uid<69><64><EFBFBD>ö<EFBFBD><C3B6><EFBFBD><F3A3ACA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>uom_tag<61><67>ֵ
|
|
|
int uomTagSet(void* return_data) {
|
|
|
int ifail = ITK_ok;
|
|
|
int len = 2;
|
|
|
char **str;
|
|
|
|
|
|
char *tag_id;
|
|
|
char *sj;
|
|
|
ifail = USERARG_get_string_argument(&tag_id);
|
|
|
ifail = USERARG_get_string_argument(&sj);
|
|
|
if (ifail == ITK_ok) {
|
|
|
if (len == 2) {
|
|
|
|
|
|
tag_t tag = NULLTAG;
|
|
|
POM_string_to_tag(tag_id, &tag);
|
|
|
if (tag == NULLTAG) {
|
|
|
// û<>ҵ<EFBFBD>item
|
|
|
string returnStr = "û<EFBFBD>ҵ<EFBFBD>item";
|
|
|
*((char**)return_data) =
|
|
|
(char*)MEM_alloc((returnStr.length() + 1) * sizeof(char));
|
|
|
strcpy(*((char**)return_data), returnStr.c_str());
|
|
|
}
|
|
|
else {
|
|
|
tag_t uom;
|
|
|
UOM_find_by_symbol(sj, &uom);
|
|
|
if (uom) {
|
|
|
AOM_lock(tag);
|
|
|
AOM_set_value_tag(tag, "uom_tag", uom);
|
|
|
AOM_save(tag);
|
|
|
AOM_unlock(tag);
|
|
|
string returnStr = "<EFBFBD><EFBFBD>ֵ<EFBFBD>ɹ<EFBFBD>";
|
|
|
*((char**)return_data) =
|
|
|
(char*)MEM_alloc((returnStr.length() + 1) * sizeof(char));
|
|
|
strcpy(*((char**)return_data), returnStr.c_str());
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
// û<>ҵ<EFBFBD><D2B5><EFBFBD>Ӧ<EFBFBD><D3A6>uom
|
|
|
string returnStr = "û<EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>uom";
|
|
|
*((char**)return_data) =
|
|
|
(char*)MEM_alloc((returnStr.length() + 1) * sizeof(char));
|
|
|
strcpy(*((char**)return_data), returnStr.c_str());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>uid+<2B><>ֵ
|
|
|
string returnStr = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD>uid+<2B><>ֵ";
|
|
|
*((char**)return_data) =
|
|
|
(char*)MEM_alloc((returnStr.length() + 1) * sizeof(char));
|
|
|
strcpy(*((char**)return_data), returnStr.c_str());
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
// <20><><EFBFBD><EFBFBD>userserviceʧ<65><CAA7>
|
|
|
string returnStr = "userserviceʧ<EFBFBD><EFBFBD>";
|
|
|
*((char**)return_data) =
|
|
|
(char*)MEM_alloc((returnStr.length() + 1) * sizeof(char));
|
|
|
strcpy(*((char**)return_data), returnStr.c_str());
|
|
|
}
|
|
|
return ifail;
|
|
|
} |