|
|
@ -37,8 +37,8 @@ int iGetPid()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
/****************************************************************
|
|
|
|
** Description : 检查文件/目录是否存在
|
|
|
|
** Description : <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>/Ŀ¼<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
** param in : pszName -- 要检查的文件/目录,FileName / PathName
|
|
|
|
** param in : pszName -- Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>/Ŀ¼,FileName / PathName
|
|
|
|
** :
|
|
|
|
** :
|
|
|
|
** param out : None
|
|
|
|
** param out : None
|
|
|
|
** return code : 0 -- exist
|
|
|
|
** return code : 0 -- exist
|
|
|
@ -98,8 +98,8 @@ char* getDirName(char* path, char *dirname)
|
|
|
|
return dirname;
|
|
|
|
return dirname;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/****************************************************************
|
|
|
|
/****************************************************************
|
|
|
|
** Description : 创建目录
|
|
|
|
** Description : <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼
|
|
|
|
** param in : pNmae -- 要创建的目录名称
|
|
|
|
** param in : pNmae -- Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
** :
|
|
|
|
** :
|
|
|
|
** param out : None
|
|
|
|
** param out : None
|
|
|
|
** return code : <0 -- failed
|
|
|
|
** return code : <0 -- failed
|
|
|
@ -122,12 +122,12 @@ int iBuildDirent(const char *pName)
|
|
|
|
return iRet;
|
|
|
|
return iRet;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 移动文件到指定目录(备份文件)
|
|
|
|
// <EFBFBD>ƶ<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>Ŀ¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
bool bMoveFile(char *filename, char *pBakPath)
|
|
|
|
bool bMoveFile(char *filename, char *pBakPath)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char *p = NULL, *s = NULL, *t = NULL;
|
|
|
|
char *p = NULL, *s = NULL, *t = NULL;
|
|
|
|
char szCmd[1024] = { 0 };
|
|
|
|
char szCmd[1024] = { 0 };
|
|
|
|
// 文件名格式:sersorID_time.jpg 或 ../img/sersorid_time.jpg
|
|
|
|
// <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>sersorID_time.jpg <20><> ../img/sersorid_time.jpg
|
|
|
|
if (filename && pBakPath)
|
|
|
|
if (filename && pBakPath)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (iDirOrFileExist(pBakPath))
|
|
|
|
if (iDirOrFileExist(pBakPath))
|
|
|
@ -145,8 +145,8 @@ bool bMoveFile(char *filename, char *pBakPath)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/****************************************************************
|
|
|
|
/****************************************************************
|
|
|
|
** Description : 获取文件大小
|
|
|
|
** Description : <EFBFBD><EFBFBD>ȡ<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>С
|
|
|
|
** param in : pNmae -- 文件名称
|
|
|
|
** param in : pNmae -- <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
** :
|
|
|
|
** :
|
|
|
|
** param out : None
|
|
|
|
** param out : None
|
|
|
|
** return code : <0 -- failed
|
|
|
|
** return code : <0 -- failed
|
|
|
@ -163,8 +163,8 @@ int get_file_size(const char *path)
|
|
|
|
return filesize;
|
|
|
|
return filesize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/****************************************************************
|
|
|
|
/****************************************************************
|
|
|
|
** Description : 获取文件创建时间
|
|
|
|
** Description : <EFBFBD><EFBFBD>ȡ<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
|
|
|
|
** param in : pNmae -- 文件名称
|
|
|
|
** param in : pNmae -- <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
** :
|
|
|
|
** :
|
|
|
|
** param out : pCreateTime -- YYYY-MM-DD HH24:MI:SS
|
|
|
|
** param out : pCreateTime -- YYYY-MM-DD HH24:MI:SS
|
|
|
|
** return code : <=0 -- failed
|
|
|
|
** return code : <=0 -- failed
|
|
|
@ -188,22 +188,22 @@ int getFileCreateTime(const char *path, char *pCreateTime)
|
|
|
|
return (int)statbuff.st_size ;
|
|
|
|
return (int)statbuff.st_size ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/****************************************************************
|
|
|
|
/****************************************************************
|
|
|
|
** Description : 从文件全路径中截取文件父目录、文件名及文件扩展名称
|
|
|
|
** Description : <EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ȫ·<EFBFBD><EFBFBD><EFBFBD>н<EFBFBD>ȡ<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>Ŀ¼<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
** param in : pFullPath -- 路径名称
|
|
|
|
** param in : pFullPath -- ·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
** :
|
|
|
|
** :
|
|
|
|
** param out : pFilename -- 文件名
|
|
|
|
** param out : pFilename -- <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
** :pExt -- 扩展名
|
|
|
|
** <EFBFBD><EFBFBD>pExt -- <EFBFBD><EFBFBD>չ<EFBFBD><EFBFBD>
|
|
|
|
** return code : <0 -- failed
|
|
|
|
** return code : <0 -- failed
|
|
|
|
****************************************************************/
|
|
|
|
****************************************************************/
|
|
|
|
bool bSplitFilenameByFullPath(char *pFullPath, char *pPrantPath, char *pFilename, char *pExt)
|
|
|
|
bool bSplitFilenameByFullPath(char *pFullPath, char *pPrantPath, char *pFilename, char *pExt)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char *p, *s;
|
|
|
|
char *p, *s;
|
|
|
|
// 文件名格式:sersorID_time.jpg 或 ../img/sersorid_time.jpg
|
|
|
|
// <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>sersorID_time.jpg <20><> ../img/sersorid_time.jpg
|
|
|
|
if (pFullPath && strlen(pFullPath) > 1) {
|
|
|
|
if (pFullPath && strlen(pFullPath) > 1) {
|
|
|
|
p = pFullPath + strlen((const char*)pFullPath);
|
|
|
|
p = pFullPath + strlen((const char*)pFullPath);
|
|
|
|
|
|
|
|
|
|
|
|
while (*p != '\\' && *p != '/' && p != pFullPath) p--;
|
|
|
|
while (*p != '\\' && *p != '/' && p != pFullPath) p--;
|
|
|
|
strncpy(pPrantPath, pFullPath, p - pFullPath + 1); // 父目录名称
|
|
|
|
strncpy(pPrantPath, pFullPath, p - pFullPath + 1); // <EFBFBD><EFBFBD>Ŀ¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
s = p + 1;
|
|
|
|
s = p + 1;
|
|
|
|
while (*s != '.') s++;
|
|
|
|
while (*s != '.') s++;
|
|
|
|
if (*s != '.') strcpy(pFilename, p + 1);
|
|
|
|
if (*s != '.') strcpy(pFilename, p + 1);
|
|
|
@ -217,22 +217,22 @@ bool bSplitFilenameByFullPath(char *pFullPath, char *pPrantPath, char *pFilename
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
/****************************************************************
|
|
|
|
** Description : 从文件全路径中截取文件父目录、文件名
|
|
|
|
** Description : <EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ȫ·<EFBFBD><EFBFBD><EFBFBD>н<EFBFBD>ȡ<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>Ŀ¼<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
** param in : pFullPath -- 路径名称
|
|
|
|
** param in : pFullPath -- ·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
** :
|
|
|
|
** :
|
|
|
|
** param out : pFilename -- 文件名
|
|
|
|
** param out : pFilename -- <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
** :pExt -- 扩展名
|
|
|
|
** <EFBFBD><EFBFBD>pExt -- <EFBFBD><EFBFBD>չ<EFBFBD><EFBFBD>
|
|
|
|
** return code : <0 -- failed
|
|
|
|
** return code : <0 -- failed
|
|
|
|
****************************************************************/
|
|
|
|
****************************************************************/
|
|
|
|
bool bSplitFilenameByPath(char *pFullPath, char *pPrantPath, char *pFilename)
|
|
|
|
bool bSplitFilenameByPath(char *pFullPath, char *pPrantPath, char *pFilename)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char *p, *s;
|
|
|
|
char *p, *s;
|
|
|
|
// 文件名格式:sersorID_time.jpg 或 ../img/sersorid_time.jpg
|
|
|
|
// <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>sersorID_time.jpg <20><> ../img/sersorid_time.jpg
|
|
|
|
if (pFullPath && strlen(pFullPath) > 1) {
|
|
|
|
if (pFullPath && strlen(pFullPath) > 1) {
|
|
|
|
p = pFullPath + strlen((const char*)pFullPath);
|
|
|
|
p = pFullPath + strlen((const char*)pFullPath);
|
|
|
|
|
|
|
|
|
|
|
|
while (*p != '\\' && *p != '/' && p != pFullPath) p--;
|
|
|
|
while (*p != '\\' && *p != '/' && p != pFullPath) p--;
|
|
|
|
strncpy(pPrantPath, pFullPath, p - pFullPath + 1); // 父目录名称
|
|
|
|
strncpy(pPrantPath, pFullPath, p - pFullPath + 1); // <EFBFBD><EFBFBD>Ŀ¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
pPrantPath[p - pFullPath + 1] = 0x00;
|
|
|
|
pPrantPath[p - pFullPath + 1] = 0x00;
|
|
|
|
|
|
|
|
|
|
|
|
s = p + 1;
|
|
|
|
s = p + 1;
|
|
|
@ -243,7 +243,7 @@ bool bSplitFilenameByPath(char *pFullPath, char *pPrantPath, char *pFilename)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/***********************************************************************
|
|
|
|
/***********************************************************************
|
|
|
|
** Description : 前导字符串
|
|
|
|
** Description : ǰ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
** param in : pstr -- source string end=0x00
|
|
|
|
** param in : pstr -- source string end=0x00
|
|
|
|
** : node -- split char
|
|
|
|
** : node -- split char
|
|
|
|
** : no -- index filed
|
|
|
|
** : no -- index filed
|
|
|
@ -255,18 +255,18 @@ int iGetFileBeforString(char *pinstr, int pstrlen, char *poutstr)
|
|
|
|
{ //0312B12000042A383000022_001_01_20190906123640.dat
|
|
|
|
{ //0312B12000042A383000022_001_01_20190906123640.dat
|
|
|
|
|
|
|
|
|
|
|
|
char *p = NULL, *s = pinstr;
|
|
|
|
char *p = NULL, *s = pinstr;
|
|
|
|
// 文件名称的时间之前最小长度0312B12000042A383000022_001_01_
|
|
|
|
// <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD>ʱ<EFBFBD><EFBFBD>֮ǰ<EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD>0312B12000042A383000022_001_01_
|
|
|
|
if (pinstr && pstrlen > 1) {
|
|
|
|
if (pinstr && pstrlen > 1) {
|
|
|
|
p = pinstr + strlen((const char*)pinstr);
|
|
|
|
p = pinstr + strlen((const char*)pinstr);
|
|
|
|
while (*p != '_' && p != pinstr) p--;
|
|
|
|
while (*p != '_' && p != pinstr) p--;
|
|
|
|
strncpy(poutstr, pinstr, p - pinstr + 1); // 父目录名称
|
|
|
|
strncpy(poutstr, pinstr, p - pinstr + 1); // <EFBFBD><EFBFBD>Ŀ¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
poutstr[p - pinstr + 1] = 0x00;
|
|
|
|
poutstr[p - pinstr + 1] = 0x00;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (p - pinstr + 1);
|
|
|
|
return (p - pinstr + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
/***********************************************************************
|
|
|
|
** Description : 获取主机时间
|
|
|
|
** Description : <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
|
|
|
|
** param in : None
|
|
|
|
** param in : None
|
|
|
|
** param out : pszTime -- string time(yyyymmddhhmmss)
|
|
|
|
** param out : pszTime -- string time(yyyymmddhhmmss)
|
|
|
|
** return code : None
|
|
|
|
** return code : None
|
|
|
@ -293,7 +293,7 @@ void vGetHostTimeOnMillsecond(char *pszTime)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/***********************************************************************
|
|
|
|
/***********************************************************************
|
|
|
|
** Description : 获取主机时间
|
|
|
|
** Description : <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
|
|
|
|
** param in : None
|
|
|
|
** param in : None
|
|
|
|
** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss+xxxx)
|
|
|
|
** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss+xxxx)
|
|
|
|
** return code : None
|
|
|
|
** return code : None
|
|
|
@ -321,7 +321,7 @@ time_t vGetHostTimeFmtOnMillsecond(char *pszTime)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
/***********************************************************************
|
|
|
|
** Description : 获取主机时间
|
|
|
|
** Description : <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
|
|
|
|
** param in : None
|
|
|
|
** param in : None
|
|
|
|
** param out : pszTime -- string time(yyyymmddhhmmss)
|
|
|
|
** param out : pszTime -- string time(yyyymmddhhmmss)
|
|
|
|
** return code : None
|
|
|
|
** return code : None
|
|
|
@ -339,8 +339,8 @@ void vGetHostTime (char *pszTime)
|
|
|
|
return ;
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/***********************************************************************
|
|
|
|
/***********************************************************************
|
|
|
|
** Description : 将int时间转为已经消失的时间格式串
|
|
|
|
** Description : <EFBFBD><EFBFBD>intʱ<EFBFBD><EFBFBD>תΪ<EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>
|
|
|
|
** param in : c -- 时间差(s)
|
|
|
|
** param in : c -- ʱ<EFBFBD><EFBFBD><EFBFBD>(s)
|
|
|
|
** param out : pszTime -- string time(DD(day) hh:mm:ss)
|
|
|
|
** param out : pszTime -- string time(DD(day) hh:mm:ss)
|
|
|
|
** return code : None
|
|
|
|
** return code : None
|
|
|
|
***********************************************************************/
|
|
|
|
***********************************************************************/
|
|
|
@ -354,10 +354,10 @@ void diffTimes(unsigned int c, char *pszTime)
|
|
|
|
sprintf(pszTime, "%02d(day) %02d:%02d:%02d",day, hour, min, sec);
|
|
|
|
sprintf(pszTime, "%02d(day) %02d:%02d:%02d",day, hour, min, sec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/***********************************************************************
|
|
|
|
/***********************************************************************
|
|
|
|
** Description : 计算与当前时间之差
|
|
|
|
** Description : <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뵱ǰʱ<EFBFBD><EFBFBD>֮<EFBFBD><EFBFBD>
|
|
|
|
** param in : bcd_t -- BCD编码(YYMMDDHHMISS)
|
|
|
|
** param in : bcd_t -- BCD<EFBFBD><EFBFBD><EFBFBD><EFBFBD>(YYMMDDHHMISS)
|
|
|
|
** param out : none
|
|
|
|
** param out : none
|
|
|
|
** return code : 差值
|
|
|
|
** return code : <EFBFBD><EFBFBD>ֵ
|
|
|
|
***********************************************************************/
|
|
|
|
***********************************************************************/
|
|
|
|
int getCurrTimeDiff(unsigned char *bcd_t)
|
|
|
|
int getCurrTimeDiff(unsigned char *bcd_t)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -368,7 +368,7 @@ int getCurrTimeDiff(unsigned char *bcd_t)
|
|
|
|
return int(time(NULL)- strTime2int((char*)szTime));
|
|
|
|
return int(time(NULL)- strTime2int((char*)szTime));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/***********************************************************************
|
|
|
|
/***********************************************************************
|
|
|
|
** Description : 获取主机时间
|
|
|
|
** Description : <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
|
|
|
|
** param in : None
|
|
|
|
** param in : None
|
|
|
|
** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss)
|
|
|
|
** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss)
|
|
|
|
** return code : None
|
|
|
|
** return code : None
|
|
|
@ -386,7 +386,7 @@ time_t vGetHostTimeFmt (char *pszTime)
|
|
|
|
return t;
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/***********************************************************************
|
|
|
|
/***********************************************************************
|
|
|
|
** Description : 获取主机时间
|
|
|
|
** Description : <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
|
|
|
|
** param in : None
|
|
|
|
** param in : None
|
|
|
|
** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss)
|
|
|
|
** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss)
|
|
|
|
** return code : None
|
|
|
|
** return code : None
|
|
|
@ -405,7 +405,7 @@ time_t vGetHostTimeFmtBeforBay(char *pszTime, int beforbay)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
/***********************************************************************
|
|
|
|
** Description : 获取当天的起始和结束时间
|
|
|
|
** Description : <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>ͽ<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
|
|
|
|
** param in : None
|
|
|
|
** param in : None
|
|
|
|
** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss)
|
|
|
|
** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss)
|
|
|
|
** return code : None
|
|
|
|
** return code : None
|
|
|
@ -425,7 +425,7 @@ time_t vGeOneDayTimeFmt(char *pSTime, char *pETime)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
/***********************************************************************
|
|
|
|
** Description : 获取主机时间
|
|
|
|
** Description : <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
|
|
|
|
** param in : None
|
|
|
|
** param in : None
|
|
|
|
** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss)
|
|
|
|
** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss)
|
|
|
|
** return code : None
|
|
|
|
** return code : None
|
|
|
@ -438,7 +438,7 @@ unsigned int uiTime (void)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
/***********************************************************************
|
|
|
|
** Description : 转换time_t的时间
|
|
|
|
** Description : ת<EFBFBD><EFBFBD>time_t<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
|
|
|
|
** param in : t
|
|
|
|
** param in : t
|
|
|
|
** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss)
|
|
|
|
** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss)
|
|
|
|
** return code : None
|
|
|
|
** return code : None
|
|
|
@ -452,8 +452,8 @@ void vTranHostTimeFmt (time_t t, char *pszTime)
|
|
|
|
tms.tm_hour, tms.tm_min, tms.tm_sec);
|
|
|
|
tms.tm_hour, tms.tm_min, tms.tm_sec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*****************************************************************
|
|
|
|
/*****************************************************************
|
|
|
|
** Description: 时间串转整数
|
|
|
|
** Description: ʱ<EFBFBD>䴮ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
** param in : pszTime -- 时间串(yyyy-mm-dd 24hh:mm:ss)
|
|
|
|
** param in : pszTime -- ʱ<EFBFBD>䴮(yyyy-mm-dd 24hh:mm:ss)
|
|
|
|
** param out : None
|
|
|
|
** param out : None
|
|
|
|
** return code: uintTime
|
|
|
|
** return code: uintTime
|
|
|
|
*****************************************************************/
|
|
|
|
*****************************************************************/
|
|
|
@ -481,7 +481,7 @@ time_t strTimeFmt2int(char *pszTime)
|
|
|
|
return t1;
|
|
|
|
return t1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/***********************************************************************
|
|
|
|
/***********************************************************************
|
|
|
|
** Description : 获取当前时间点到之前360小时的时间段
|
|
|
|
** Description : <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰʱ<EFBFBD><EFBFBD>㵽֮ǰ360Сʱ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
** param in : t
|
|
|
|
** param in : t
|
|
|
|
** param out : pSTime -- string time(yyyymmddhh24mmss)
|
|
|
|
** param out : pSTime -- string time(yyyymmddhh24mmss)
|
|
|
|
** param out : pETime -- string time(yyyymmddhh24mmss)
|
|
|
|
** param out : pETime -- string time(yyyymmddhh24mmss)
|
|
|
@ -499,15 +499,15 @@ void getCurrentBefor360Hour(char *pstime, char *petime)
|
|
|
|
tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
|
|
|
|
tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
|
|
|
|
tm.tm_hour, tm.tm_min, tm.tm_sec);
|
|
|
|
tm.tm_hour, tm.tm_min, tm.tm_sec);
|
|
|
|
|
|
|
|
|
|
|
|
curTime = curTime - (360 * 60 * 60); // 360小时之前的时间
|
|
|
|
curTime = curTime - (360 * 60 * 60); // 360Сʱ֮ǰ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
|
|
|
|
memcpy(&tm, localtime((const time_t *)&curTime), sizeof(struct tm));
|
|
|
|
memcpy(&tm, localtime((const time_t *)&curTime), sizeof(struct tm));
|
|
|
|
sprintf(pstime, "%04d%02d%02d%02d%02d%02d",
|
|
|
|
sprintf(pstime, "%04d%02d%02d%02d%02d%02d",
|
|
|
|
tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
|
|
|
|
tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
|
|
|
|
tm.tm_hour, tm.tm_min, tm.tm_sec);
|
|
|
|
tm.tm_hour, tm.tm_min, tm.tm_sec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*****************************************************************
|
|
|
|
/*****************************************************************
|
|
|
|
** Description: 时间串转整数
|
|
|
|
** Description: ʱ<EFBFBD>䴮ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
** param in : pszTime -- 时间串(yyyymmddhhmmss)
|
|
|
|
** param in : pszTime -- ʱ<EFBFBD>䴮(yyyymmddhhmmss)
|
|
|
|
** param out : None
|
|
|
|
** param out : None
|
|
|
|
** return code: uintTime
|
|
|
|
** return code: uintTime
|
|
|
|
*****************************************************************/
|
|
|
|
*****************************************************************/
|
|
|
@ -535,20 +535,20 @@ time_t strTime2int(char *pszTime)
|
|
|
|
return t1 ;
|
|
|
|
return t1 ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#if 0
|
|
|
|
#if 0
|
|
|
|
// 日月年(dmyy), 年的表示是先将年转换为2位十六进制数
|
|
|
|
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(dmyy), <20><>ı<EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>Ƚ<EFBFBD><C8BD><EFBFBD>ת<EFBFBD><D7AA>Ϊ2λʮ<CEBB><CAAE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
void setPostionDate(unsigned char *pDate, unsigned char *pTime)
|
|
|
|
void setPostionDate(unsigned char *pDate, unsigned char *pTime)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
unsigned char szDate[5]={0};
|
|
|
|
unsigned char szDate[5]={0};
|
|
|
|
unsigned short usNo = 0;
|
|
|
|
unsigned short usNo = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 20130109
|
|
|
|
// 20130109
|
|
|
|
memcpy(szDate, pDate+6, 2); // 日
|
|
|
|
memcpy(szDate, pDate+6, 2); // <EFBFBD><EFBFBD>
|
|
|
|
memcpy(szDate+2, pDate+4, 2); // 月
|
|
|
|
memcpy(szDate+2, pDate+4, 2); // <EFBFBD><EFBFBD>
|
|
|
|
asc_to_bcd(szDate, 4, pTime);
|
|
|
|
asc_to_bcd(szDate, 4, pTime);
|
|
|
|
|
|
|
|
|
|
|
|
memcpy(szDate, pDate, 4);
|
|
|
|
memcpy(szDate, pDate, 4);
|
|
|
|
usNo = htons(atoi((char*)szDate));
|
|
|
|
usNo = htons(atoi((char*)szDate));
|
|
|
|
memcpy(pTime+2, &usNo, sizeof(short)); // 年
|
|
|
|
memcpy(pTime+2, &usNo, sizeof(short)); // <EFBFBD><EFBFBD>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// pDate = HH24MMSS
|
|
|
|
// pDate = HH24MMSS
|
|
|
|
void setPostionTime(unsigned char *pDate, unsigned char *pTime)
|
|
|
|
void setPostionTime(unsigned char *pDate, unsigned char *pTime)
|
|
|
@ -558,22 +558,22 @@ void setPostionTime(unsigned char *pDate, unsigned char *pTime)
|
|
|
|
memcpy(pTime, szTmp, 3);
|
|
|
|
memcpy(pTime, szTmp, 3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
// 日月年(dmyy), 年的表示是先将年转换为2位十六进制数
|
|
|
|
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(dmyy), <20><>ı<EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>Ƚ<EFBFBD><C8BD><EFBFBD>ת<EFBFBD><D7AA>Ϊ2λʮ<CEBB><CAAE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
void setPostionDate(unsigned char *pDate, unsigned char *pTime)
|
|
|
|
void setPostionDate(unsigned char *pDate, unsigned char *pTime)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char szDate[5]={0};
|
|
|
|
char szDate[5]={0};
|
|
|
|
unsigned short usNo = 0;
|
|
|
|
unsigned short usNo = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 20130109
|
|
|
|
// 20130109
|
|
|
|
memcpy(szDate, pDate+6, 2); // 日
|
|
|
|
memcpy(szDate, pDate+6, 2); // <EFBFBD><EFBFBD>
|
|
|
|
pTime[0] = (char)atoi(szDate);
|
|
|
|
pTime[0] = (char)atoi(szDate);
|
|
|
|
|
|
|
|
|
|
|
|
memcpy(szDate, pDate+4, 2); // 月
|
|
|
|
memcpy(szDate, pDate+4, 2); // <EFBFBD><EFBFBD>
|
|
|
|
pTime[1] = (char)atoi(szDate);
|
|
|
|
pTime[1] = (char)atoi(szDate);
|
|
|
|
|
|
|
|
|
|
|
|
memcpy(szDate, pDate, 4);
|
|
|
|
memcpy(szDate, pDate, 4);
|
|
|
|
usNo = htons(atoi((char*)szDate));
|
|
|
|
usNo = htons(atoi((char*)szDate));
|
|
|
|
memcpy(pTime+2, &usNo, sizeof(short)); // 年
|
|
|
|
memcpy(pTime+2, &usNo, sizeof(short)); // <EFBFBD><EFBFBD>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// pDate = HH24MMSS
|
|
|
|
// pDate = HH24MMSS
|
|
|
@ -584,10 +584,10 @@ void setPostionTime(unsigned char *pDate, unsigned char *pTime)
|
|
|
|
memcpy(szTmp, pDate, 2); // ʱ
|
|
|
|
memcpy(szTmp, pDate, 2); // ʱ
|
|
|
|
pTime[0] = (char)atoi(szTmp);
|
|
|
|
pTime[0] = (char)atoi(szTmp);
|
|
|
|
|
|
|
|
|
|
|
|
memcpy(szTmp, pDate+2, 2); // 分
|
|
|
|
memcpy(szTmp, pDate+2, 2); // <EFBFBD><EFBFBD>
|
|
|
|
pTime[1] = (char)atoi(szTmp);
|
|
|
|
pTime[1] = (char)atoi(szTmp);
|
|
|
|
|
|
|
|
|
|
|
|
memcpy(szTmp, pDate+4, 2); // 秒
|
|
|
|
memcpy(szTmp, pDate+4, 2); // <EFBFBD><EFBFBD>
|
|
|
|
pTime[2] = (char)atoi(szTmp);
|
|
|
|
pTime[2] = (char)atoi(szTmp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
@ -633,7 +633,7 @@ void getGnssTime(unsigned char *p_time)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
/***********************************************************************
|
|
|
|
** Description : 获取主机UTC时间
|
|
|
|
** Description : <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>UTCʱ<EFBFBD><EFBFBD>
|
|
|
|
** param in : None
|
|
|
|
** param in : None
|
|
|
|
** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss)
|
|
|
|
** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss)
|
|
|
|
** return code : None
|
|
|
|
** return code : None
|
|
|
@ -651,7 +651,7 @@ void getUTCFmtTime (char *pszTime)
|
|
|
|
return ;
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/***********************************************************************
|
|
|
|
/***********************************************************************
|
|
|
|
** Description : 获取主机UTC时间
|
|
|
|
** Description : <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>UTCʱ<EFBFBD><EFBFBD>
|
|
|
|
** param in : None
|
|
|
|
** param in : None
|
|
|
|
** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss)
|
|
|
|
** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss)
|
|
|
|
** return code : None
|
|
|
|
** return code : None
|
|
|
@ -667,7 +667,7 @@ time_t getUTCLongTime (void)
|
|
|
|
return t1 ;
|
|
|
|
return t1 ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/***********************************************************************
|
|
|
|
/***********************************************************************
|
|
|
|
** Description : 将UTC时间转为格式串
|
|
|
|
** Description : <EFBFBD><EFBFBD>UTCʱ<EFBFBD><EFBFBD>תΪ<EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>
|
|
|
|
** param in : None
|
|
|
|
** param in : None
|
|
|
|
** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss)
|
|
|
|
** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss)
|
|
|
|
** return code : None
|
|
|
|
** return code : None
|
|
|
@ -684,7 +684,7 @@ void UTC2FmtTime (time_t utc, char *pszTime)
|
|
|
|
return ;
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/***********************************************************************
|
|
|
|
/***********************************************************************
|
|
|
|
** Description : UTC时间转为本地时间
|
|
|
|
** Description : UTCʱ<EFBFBD><EFBFBD>תΪ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
|
|
|
|
** param in : None
|
|
|
|
** param in : None
|
|
|
|
** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss)
|
|
|
|
** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss)
|
|
|
|
** return code : None
|
|
|
|
** return code : None
|
|
|
@ -699,7 +699,7 @@ void UTC2LocalTime (time_t utc, char *pszTime)
|
|
|
|
tm.tm_hour, tm.tm_min, tm.tm_sec);
|
|
|
|
tm.tm_hour, tm.tm_min, tm.tm_sec);
|
|
|
|
return ;
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 本地时间转UTC时间, pTime: YYMMDDHH24MISS
|
|
|
|
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>תUTCʱ<EFBFBD><EFBFBD>, pTime: YYMMDDHH24MISS
|
|
|
|
time_t local2Utc(unsigned char *pTime, int iLen)
|
|
|
|
time_t local2Utc(unsigned char *pTime, int iLen)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
unsigned char szTime[20] = {0};
|
|
|
|
unsigned char szTime[20] = {0};
|
|
|
@ -715,7 +715,7 @@ time_t local2Utc(unsigned char *pTime, int iLen)
|
|
|
|
return t1 ;
|
|
|
|
return t1 ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 本地时间转UTC整型时间
|
|
|
|
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>תUTC<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
|
|
|
|
time_t local2UtcTime(time_t localTime)
|
|
|
|
time_t local2UtcTime(time_t localTime)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct tm tm = {0};
|
|
|
|
struct tm tm = {0};
|
|
|
@ -725,7 +725,7 @@ time_t local2UtcTime(time_t localTime)
|
|
|
|
return t;
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 根据BCD编码时间转报警ID
|
|
|
|
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>BCD<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID
|
|
|
|
// param_in: pTime -- YYMMDDHHMISS, \x13\x10\12\x09\x14\x11
|
|
|
|
// param_in: pTime -- YYMMDDHHMISS, \x13\x10\12\x09\x14\x11
|
|
|
|
unsigned int getWarnID(unsigned char *pTime, int iLen, unsigned int id)
|
|
|
|
unsigned int getWarnID(unsigned char *pTime, int iLen, unsigned int id)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -741,7 +741,7 @@ unsigned int getWarnID(unsigned char *pTime, int iLen, unsigned int id)
|
|
|
|
return (utc & 0xFFFFFFFF);
|
|
|
|
return (utc & 0xFFFFFFFF);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/***********************************************************************
|
|
|
|
/***********************************************************************
|
|
|
|
** Description : 获取源串中的第no个域,数字串,eg: 1923.122.3.4
|
|
|
|
** Description : <EFBFBD><EFBFBD>ȡԴ<EFBFBD><EFBFBD><EFBFBD>еĵ<EFBFBD>no<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>,eg: 1923.122.3.4
|
|
|
|
** param in : pstr -- source string end=0x00
|
|
|
|
** param in : pstr -- source string end=0x00
|
|
|
|
** : node -- split char
|
|
|
|
** : node -- split char
|
|
|
|
** : no -- index filed
|
|
|
|
** : no -- index filed
|
|
|
@ -771,7 +771,7 @@ int iSplitNumberFiled(char *pstr, char node, int no)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 去除版本号首部字符,保留数字版本号
|
|
|
|
// ȥ<EFBFBD><EFBFBD><EFBFBD>汾<EFBFBD><EFBFBD><EFBFBD>ײ<EFBFBD><EFBFBD>ַ<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ְ汾<D6B0><E6B1BE>
|
|
|
|
// eg: Ver1.2.34 ==> 1.2.34
|
|
|
|
// eg: Ver1.2.34 ==> 1.2.34
|
|
|
|
int iTrimVersionHeadChar(char *strver)
|
|
|
|
int iTrimVersionHeadChar(char *strver)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -788,7 +788,7 @@ int iTrimVersionHeadChar(char *strver)
|
|
|
|
return strlen(strver);
|
|
|
|
return strlen(strver);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/***********************************************************************
|
|
|
|
/***********************************************************************
|
|
|
|
** Description : 获取源串中的第no个域, 字符串
|
|
|
|
** Description : <EFBFBD><EFBFBD>ȡԴ<EFBFBD><EFBFBD><EFBFBD>еĵ<EFBFBD>no<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
** param in : pstr -- source string end=0x00
|
|
|
|
** param in : pstr -- source string end=0x00
|
|
|
|
** : node -- split char
|
|
|
|
** : node -- split char
|
|
|
|
** : no -- index filed
|
|
|
|
** : no -- index filed
|
|
|
@ -819,8 +819,8 @@ int iSplitStringFiled(char *pstr, char node, char no, char *pFiled)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
/***********************************************************************
|
|
|
|
** Description : getDateFromTime 从时间字符串获取Date信息
|
|
|
|
** Description : getDateFromTime <EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡDate<EFBFBD><EFBFBD>Ϣ
|
|
|
|
** param in : p_time -- 时间字符串
|
|
|
|
** param in : p_time -- ʱ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
***********************************************************************/
|
|
|
|
***********************************************************************/
|
|
|
|
void getDateFromTime(char* p_time,char* p_date)
|
|
|
|
void getDateFromTime(char* p_time,char* p_date)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -893,7 +893,7 @@ void LRTrim(unsigned char *str)
|
|
|
|
RigthTrim(str) ;
|
|
|
|
RigthTrim(str) ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**************************************************************
|
|
|
|
/**************************************************************
|
|
|
|
** Description: trim char string middle space,仅保留一个空格
|
|
|
|
** Description: trim char string middle space,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ո<EFBFBD>
|
|
|
|
** param in :
|
|
|
|
** param in :
|
|
|
|
** : *str -- sources string
|
|
|
|
** : *str -- sources string
|
|
|
|
** param out :
|
|
|
|
** param out :
|
|
|
@ -920,7 +920,7 @@ void MiddleTrim(unsigned char *str)
|
|
|
|
*last = '\0';
|
|
|
|
*last = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**************************************************************
|
|
|
|
/**************************************************************
|
|
|
|
** Description: trim char string middle space,仅保留一个空格
|
|
|
|
** Description: trim char string middle space,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ո<EFBFBD>
|
|
|
|
** param in :
|
|
|
|
** param in :
|
|
|
|
** : *str -- sources string
|
|
|
|
** : *str -- sources string
|
|
|
|
** param out :
|
|
|
|
** param out :
|
|
|
@ -948,7 +948,7 @@ void strMiddleTrim(unsigned char *str)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**************************************************************
|
|
|
|
/**************************************************************
|
|
|
|
** Description: check string all char is digit(number '0'--'9')
|
|
|
|
** Description: check string all char is digit(number '0'--'9')
|
|
|
|
** param in : 是否为纯数字的字符串
|
|
|
|
** param in : <EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
** : *str -- sources string
|
|
|
|
** : *str -- sources string
|
|
|
|
** param out :
|
|
|
|
** param out :
|
|
|
|
** : *str -- trim string
|
|
|
|
** : *str -- trim string
|
|
|
@ -1130,7 +1130,7 @@ Param in :
|
|
|
|
Param out :
|
|
|
|
Param out :
|
|
|
|
pusTo : object strings.
|
|
|
|
pusTo : object strings.
|
|
|
|
Return Code : none
|
|
|
|
Return Code : none
|
|
|
|
Note : 本函数入参为网络字节序列
|
|
|
|
Note : <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
*************************************************************************/
|
|
|
|
*************************************************************************/
|
|
|
|
unsigned int int64To32(utint64 u64)
|
|
|
|
unsigned int int64To32(utint64 u64)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1158,7 +1158,7 @@ void LocalTime2Bcd(char *pLocalTime, char *pBcd)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
/*************************************************************************
|
|
|
|
Function : 检查字符串结束符
|
|
|
|
Function : <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
Param in :
|
|
|
|
Param in :
|
|
|
|
psz : source string
|
|
|
|
psz : source string
|
|
|
|
length : input string length, max 128(Byte)
|
|
|
|
length : input string length, max 128(Byte)
|
|
|
@ -1202,7 +1202,7 @@ int getHexString(unsigned char *str, int length, unsigned char *pstr)
|
|
|
|
return (length * 2);
|
|
|
|
return (length * 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*************************************************************************
|
|
|
|
/*************************************************************************
|
|
|
|
Function : 32位整数转二进制字符串
|
|
|
|
Function : 32λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
Param in :
|
|
|
|
Param in :
|
|
|
|
num : source uint
|
|
|
|
num : source uint
|
|
|
|
Param out :
|
|
|
|
Param out :
|
|
|
@ -1217,12 +1217,12 @@ void uint32_binstr(unsigned int num, char* pBin)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pBin[(sizeof(int)*8-1)-i] = (char)(((num >> i) & 1) + '0');
|
|
|
|
pBin[(sizeof(int)*8-1)-i] = (char)(((num >> i) & 1) + '0');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pBin[(sizeof(int)*8)] = 0x00; // 结束符
|
|
|
|
pBin[(sizeof(int)*8)] = 0x00; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
/*************************************************************************
|
|
|
|
Function : 64位整数转二进制字符串
|
|
|
|
Function : 64λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
Param in :
|
|
|
|
Param in :
|
|
|
|
num : source uint
|
|
|
|
num : source uint
|
|
|
|
Param out :
|
|
|
|
Param out :
|
|
|
@ -1237,11 +1237,11 @@ void uint64_binstr(utint64 num, char* pBin)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pBin[(sizeof(utint64)*8-1)-i] = (char)(((num >> i) & 1) + '0');
|
|
|
|
pBin[(sizeof(utint64)*8-1)-i] = (char)(((num >> i) & 1) + '0');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pBin[(sizeof(utint64)*8)] = 0x00; // 结束符
|
|
|
|
pBin[(sizeof(utint64)*8)] = 0x00; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*************************************************************************
|
|
|
|
/*************************************************************************
|
|
|
|
Function : 二进制字符串转32位整数
|
|
|
|
Function : <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>ת32λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
Param in :
|
|
|
|
Param in :
|
|
|
|
pBin : source bin string(eg. 1010101001111), need '\0' end.
|
|
|
|
pBin : source bin string(eg. 1010101001111), need '\0' end.
|
|
|
|
Param out :
|
|
|
|
Param out :
|
|
|
@ -1263,32 +1263,32 @@ unsigned int binstr_uint32(char *pBin)
|
|
|
|
return n;
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//从低位到高位,取n的第m位,m=1...32
|
|
|
|
//<EFBFBD>ӵ<EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ,ȡn<C8A1>ĵ<EFBFBD>mλ,m=1...32
|
|
|
|
int getBit(int n, int m)
|
|
|
|
int getBit(int n, int m)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (m == 0) return (n >> (1 - 1)) & 1;
|
|
|
|
if (m == 0) return (n >> (1 - 1)) & 1;
|
|
|
|
return (n >> (m - 1)) & 1;
|
|
|
|
return (n >> (m - 1)) & 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//从低位到高位.将n的第m位置1, m=1...32
|
|
|
|
//<EFBFBD>ӵ<EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ.<2E><>n<EFBFBD>ĵ<EFBFBD>mλ<6D><CEBB>1, m=1...32
|
|
|
|
int setBitToOne(int n, int m)
|
|
|
|
int setBitToOne(int n, int m)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (m == 0) return n | (1 << (1 - 1));
|
|
|
|
if (m == 0) return n | (1 << (1 - 1));
|
|
|
|
return n | (1 << (m - 1));
|
|
|
|
return n | (1 << (m - 1));
|
|
|
|
/*将1左移m-1位找到第m位,得到000...1...000
|
|
|
|
/*<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD>m-1λ<31>ҵ<EFBFBD><D2B5><EFBFBD>mλ<6D><CEBB><EFBFBD>õ<EFBFBD>000...1...000
|
|
|
|
n在和这个数做或运算*/
|
|
|
|
n<EFBFBD>ں<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//从低位到高位, 将n的第m位置0,m=1...32
|
|
|
|
//<EFBFBD>ӵ<EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ, <20><>n<EFBFBD>ĵ<EFBFBD>mλ<6D><CEBB>0,m=1...32
|
|
|
|
int setBitToZero(int n, int m)
|
|
|
|
int setBitToZero(int n, int m)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (m == 0) return n & ~(1 << (1 - 1));
|
|
|
|
if (m == 0) return n & ~(1 << (1 - 1));
|
|
|
|
return n & ~(1 << (m - 1));
|
|
|
|
return n & ~(1 << (m - 1));
|
|
|
|
/* 将1左移m-1位找到第m位,取反后变成111...0...1111
|
|
|
|
/* <EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD>m-1λ<31>ҵ<EFBFBD><D2B5><EFBFBD>mλ<6D><CEBB>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>111...0...1111
|
|
|
|
n再和这个数做与运算*/
|
|
|
|
n<EFBFBD>ٺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
/*************************************************************************
|
|
|
|
Function : 字符串反转
|
|
|
|
Function : <EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת
|
|
|
|
Param in :
|
|
|
|
Param in :
|
|
|
|
str : source string(eg. 1010101001111), need '\0' end.
|
|
|
|
str : source string(eg. 1010101001111), need '\0' end.
|
|
|
|
len : source length
|
|
|
|
len : source length
|
|
|
@ -1305,7 +1305,7 @@ char* strSwap(char* str,int len)
|
|
|
|
return (strSwap( str+1, len-2)-1);
|
|
|
|
return (strSwap( str+1, len-2)-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*************************************************************************
|
|
|
|
/*************************************************************************
|
|
|
|
Function : 二进制字符串转64位整数
|
|
|
|
Function : <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>ת64λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
Param in :
|
|
|
|
Param in :
|
|
|
|
pBin : source bin string(eg. 1010101001111), need '\0' end.
|
|
|
|
pBin : source bin string(eg. 1010101001111), need '\0' end.
|
|
|
|
Param out :
|
|
|
|
Param out :
|
|
|
@ -1328,7 +1328,7 @@ utint64 binstr_uint64(char *pBin)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
/*************************************************************************
|
|
|
|
Function : 将Linux文件路径转为Windows的路径格式, 仅测试用
|
|
|
|
Function : <EFBFBD><EFBFBD>Linux<EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD>תΪWindows<EFBFBD><EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
Param in :
|
|
|
|
Param in :
|
|
|
|
pszPath: source path
|
|
|
|
pszPath: source path
|
|
|
|
Param out :
|
|
|
|
Param out :
|
|
|
@ -1350,7 +1350,7 @@ void Unix2WindowPath(char *pszPath)
|
|
|
|
p[i] = 0x00;
|
|
|
|
p[i] = 0x00;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*************************************************************************
|
|
|
|
/*************************************************************************
|
|
|
|
Function : 将Windows文件路径转为Linux的路径格式, 仅测试用
|
|
|
|
Function : <EFBFBD><EFBFBD>Windows<EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD>תΪLinux<EFBFBD><EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
Param in : pszPath -- source path
|
|
|
|
Param in : pszPath -- source path
|
|
|
|
Param out :
|
|
|
|
Param out :
|
|
|
|
: pszPath
|
|
|
|
: pszPath
|
|
|
@ -1390,7 +1390,7 @@ int stringncasecmp(const char *ps1, const char *ps2, int length)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
/*************************************************************************
|
|
|
|
Function : 获取uuid
|
|
|
|
Function : <EFBFBD><EFBFBD>ȡuuid
|
|
|
|
Param in :
|
|
|
|
Param in :
|
|
|
|
Param out :
|
|
|
|
Param out :
|
|
|
|
: pszPath
|
|
|
|
: pszPath
|
|
|
@ -1426,7 +1426,7 @@ int getuuid(char *str, int inlen )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
/*************************************************************************
|
|
|
|
Function : 获取1-100内的随机数
|
|
|
|
Function : <EFBFBD><EFBFBD>ȡ1-100<EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
Param in :
|
|
|
|
Param in :
|
|
|
|
Param out :
|
|
|
|
Param out :
|
|
|
|
Return Code : none
|
|
|
|
Return Code : none
|
|
|
@ -1438,7 +1438,7 @@ double getRandByTime()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
/*************************************************************************
|
|
|
|
Function : 字符串转小写
|
|
|
|
Function : <EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>תСд
|
|
|
|
Param in :
|
|
|
|
Param in :
|
|
|
|
Param out :
|
|
|
|
Param out :
|
|
|
|
: pszPath
|
|
|
|
: pszPath
|
|
|
@ -1452,14 +1452,14 @@ char *str2lower(char *s)
|
|
|
|
for (int i = 0; i < len; i++)
|
|
|
|
for (int i = 0; i < len; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (s[i] >= 'A' && s[i] <= 'Z'){
|
|
|
|
if (s[i] >= 'A' && s[i] <= 'Z'){
|
|
|
|
s[i] += 32;//+32转换为小写
|
|
|
|
s[i] += 32;//+32ת<EFBFBD><EFBFBD>ΪСд
|
|
|
|
//s[i]=s[i]-'A'+'a';
|
|
|
|
//s[i]=s[i]-'A'+'a';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return p;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*************************************************************************
|
|
|
|
/*************************************************************************
|
|
|
|
Function : 获取1-100内的随机数
|
|
|
|
Function : <EFBFBD><EFBFBD>ȡ1-100<EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
Param in :
|
|
|
|
Param in :
|
|
|
|
Param out :
|
|
|
|
Param out :
|
|
|
|
: pszPath
|
|
|
|
: pszPath
|
|
|
@ -1473,7 +1473,7 @@ char *str2upper(char *s)
|
|
|
|
for (int i = 0; i < len; i++)
|
|
|
|
for (int i = 0; i < len; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (s[i] >= 'a' && s[i] <= 'z'){
|
|
|
|
if (s[i] >= 'a' && s[i] <= 'z'){
|
|
|
|
s[i] -= 32;//+32转换为小写
|
|
|
|
s[i] -= 32;//+32ת<EFBFBD><EFBFBD>ΪСд
|
|
|
|
//s[i]=s[i]-'a'+'A';
|
|
|
|
//s[i]=s[i]-'a'+'A';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|