add FilenameString type and macro

storage_pool
YuQing 2021-03-19 09:17:11 +08:00
parent 13de41bc05
commit 07ba689835
5 changed files with 45 additions and 30 deletions

View File

@ -1,8 +1,9 @@
Version 1.49 2021-03-16
Version 1.49 2021-03-19
* add macros: FC_ABS and FC_NEGATIVE
* uniq_skiplist.c: add uniq_skiplist_pair struct and init function
* add functions: fc_mkdirs and str_replace
* add FilenameString type and macro
Version 1.48 2021-02-01
* fast_buffer.[hc]: add function fast_buffer_append_binary

View File

@ -21,6 +21,7 @@
#include <pthread.h>
#include <string.h>
#include <errno.h>
#include <limits.h>
#ifdef WIN32
@ -224,6 +225,12 @@ typedef struct
pthread_cond_t cond;
} pthread_lock_cond_pair_t;
typedef struct
{
char buff[PATH_MAX];
string_t s;
} FilenameString;
typedef void (*FreeDataFunc)(void *ptr);
typedef int (*CompareFunc)(void *p1, void *p2);
typedef void* (*MallocFunc)(size_t size);
@ -283,6 +290,13 @@ typedef void* (*MallocFunc)(size_t size);
#define FC_IS_NULL_STRING(s) ((s)->str == NULL)
#define FC_IS_EMPTY_STRING(s) ((s)->len == 0)
#define FC_INIT_FILENAME_STRING(filename) \
FC_SET_STRING_EX((filename).s, (filename).buff, 0)
#define FC_FILENAME_STRING_OBJ(filename) ((filename).s)
#define FC_FILENAME_STRING_PTR(filename) ((filename).buff)
#define FC_FILENAME_BUFFER_SIZE(filename) sizeof((filename).buff)
#define fc_compare_string(s1, s2) fc_string_compare(s1, s2)
static inline int fc_string_compare(const string_t *s1, const string_t *s2)

View File

@ -516,34 +516,34 @@ char *bin2hex(const char *s, const int len, char *szHexBuff)
char *hex2bin(const char *s, char *szBinBuff, int *nDestLen)
{
char buff[3];
char *pSrc;
int nSrcLen;
char *pDest;
char *pDestEnd;
char buff[3];
char *pSrc;
int nSrcLen;
char *pDest;
char *pDestEnd;
nSrcLen = strlen(s);
if (nSrcLen == 0)
{
*nDestLen = 0;
szBinBuff[0] = '\0';
return szBinBuff;
}
nSrcLen = strlen(s);
if (nSrcLen == 0)
{
*nDestLen = 0;
szBinBuff[0] = '\0';
return szBinBuff;
}
*nDestLen = nSrcLen / 2;
pSrc = (char *)s;
buff[2] = '\0';
*nDestLen = nSrcLen / 2;
pSrc = (char *)s;
buff[2] = '\0';
pDestEnd = szBinBuff + (*nDestLen);
for (pDest=szBinBuff; pDest<pDestEnd; pDest++)
{
buff[0] = *pSrc++;
buff[1] = *pSrc++;
*pDest = (char)strtol(buff, NULL, 16);
}
pDestEnd = szBinBuff + (*nDestLen);
for (pDest=szBinBuff; pDest<pDestEnd; pDest++)
{
buff[0] = *pSrc++;
buff[1] = *pSrc++;
*pDest = (char)strtol(buff, NULL, 16);
}
*pDest = '\0';
return szBinBuff;
*pDest = '\0';
return szBinBuff;
}
void printBuffHex(const char *s, const int len)

View File

@ -546,7 +546,7 @@ int get_processes(struct fast_process_info **processes, int *count)
return result;
}
int get_sysinfo(struct fast_sysinfo*info)
int get_sysinfo(struct fast_sysinfo *info)
{
struct sysinfo si;
@ -704,7 +704,7 @@ int get_processes(struct fast_process_info **processes, int *count)
return 0;
}
int get_sysinfo(struct fast_sysinfo*info)
int get_sysinfo(struct fast_sysinfo *info)
{
int mib[4];
size_t size;

View File

@ -160,7 +160,7 @@ int get_mounted_filesystems(struct fast_statfs *stats,
*/
int get_processes(struct fast_process_info **processes, int *count);
int get_sysinfo(struct fast_sysinfo*info);
int get_sysinfo(struct fast_sysinfo *info);
#endif
#ifdef __cplusplus