add FilenameString type and macro
parent
13de41bc05
commit
07ba689835
3
HISTORY
3
HISTORY
|
|
@ -1,8 +1,9 @@
|
||||||
|
|
||||||
Version 1.49 2021-03-16
|
Version 1.49 2021-03-19
|
||||||
* add macros: FC_ABS and FC_NEGATIVE
|
* add macros: FC_ABS and FC_NEGATIVE
|
||||||
* uniq_skiplist.c: add uniq_skiplist_pair struct and init function
|
* uniq_skiplist.c: add uniq_skiplist_pair struct and init function
|
||||||
* add functions: fc_mkdirs and str_replace
|
* add functions: fc_mkdirs and str_replace
|
||||||
|
* add FilenameString type and macro
|
||||||
|
|
||||||
Version 1.48 2021-02-01
|
Version 1.48 2021-02-01
|
||||||
* fast_buffer.[hc]: add function fast_buffer_append_binary
|
* fast_buffer.[hc]: add function fast_buffer_append_binary
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
|
||||||
|
|
@ -224,6 +225,12 @@ typedef struct
|
||||||
pthread_cond_t cond;
|
pthread_cond_t cond;
|
||||||
} pthread_lock_cond_pair_t;
|
} pthread_lock_cond_pair_t;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
char buff[PATH_MAX];
|
||||||
|
string_t s;
|
||||||
|
} FilenameString;
|
||||||
|
|
||||||
typedef void (*FreeDataFunc)(void *ptr);
|
typedef void (*FreeDataFunc)(void *ptr);
|
||||||
typedef int (*CompareFunc)(void *p1, void *p2);
|
typedef int (*CompareFunc)(void *p1, void *p2);
|
||||||
typedef void* (*MallocFunc)(size_t size);
|
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_NULL_STRING(s) ((s)->str == NULL)
|
||||||
#define FC_IS_EMPTY_STRING(s) ((s)->len == 0)
|
#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)
|
#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)
|
static inline int fc_string_compare(const string_t *s1, const string_t *s2)
|
||||||
|
|
|
||||||
|
|
@ -516,34 +516,34 @@ char *bin2hex(const char *s, const int len, char *szHexBuff)
|
||||||
|
|
||||||
char *hex2bin(const char *s, char *szBinBuff, int *nDestLen)
|
char *hex2bin(const char *s, char *szBinBuff, int *nDestLen)
|
||||||
{
|
{
|
||||||
char buff[3];
|
char buff[3];
|
||||||
char *pSrc;
|
char *pSrc;
|
||||||
int nSrcLen;
|
int nSrcLen;
|
||||||
char *pDest;
|
char *pDest;
|
||||||
char *pDestEnd;
|
char *pDestEnd;
|
||||||
|
|
||||||
nSrcLen = strlen(s);
|
|
||||||
if (nSrcLen == 0)
|
|
||||||
{
|
|
||||||
*nDestLen = 0;
|
|
||||||
szBinBuff[0] = '\0';
|
|
||||||
return szBinBuff;
|
|
||||||
}
|
|
||||||
|
|
||||||
*nDestLen = nSrcLen / 2;
|
nSrcLen = strlen(s);
|
||||||
pSrc = (char *)s;
|
if (nSrcLen == 0)
|
||||||
buff[2] = '\0';
|
{
|
||||||
|
*nDestLen = 0;
|
||||||
|
szBinBuff[0] = '\0';
|
||||||
|
return szBinBuff;
|
||||||
|
}
|
||||||
|
|
||||||
pDestEnd = szBinBuff + (*nDestLen);
|
*nDestLen = nSrcLen / 2;
|
||||||
for (pDest=szBinBuff; pDest<pDestEnd; pDest++)
|
pSrc = (char *)s;
|
||||||
{
|
buff[2] = '\0';
|
||||||
buff[0] = *pSrc++;
|
|
||||||
buff[1] = *pSrc++;
|
pDestEnd = szBinBuff + (*nDestLen);
|
||||||
*pDest = (char)strtol(buff, NULL, 16);
|
for (pDest=szBinBuff; pDest<pDestEnd; pDest++)
|
||||||
}
|
{
|
||||||
|
buff[0] = *pSrc++;
|
||||||
*pDest = '\0';
|
buff[1] = *pSrc++;
|
||||||
return szBinBuff;
|
*pDest = (char)strtol(buff, NULL, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
*pDest = '\0';
|
||||||
|
return szBinBuff;
|
||||||
}
|
}
|
||||||
|
|
||||||
void printBuffHex(const char *s, const int len)
|
void printBuffHex(const char *s, const int len)
|
||||||
|
|
|
||||||
|
|
@ -546,7 +546,7 @@ int get_processes(struct fast_process_info **processes, int *count)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_sysinfo(struct fast_sysinfo*info)
|
int get_sysinfo(struct fast_sysinfo *info)
|
||||||
{
|
{
|
||||||
struct sysinfo si;
|
struct sysinfo si;
|
||||||
|
|
||||||
|
|
@ -704,7 +704,7 @@ int get_processes(struct fast_process_info **processes, int *count)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_sysinfo(struct fast_sysinfo*info)
|
int get_sysinfo(struct fast_sysinfo *info)
|
||||||
{
|
{
|
||||||
int mib[4];
|
int mib[4];
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
|
||||||
|
|
@ -160,7 +160,7 @@ int get_mounted_filesystems(struct fast_statfs *stats,
|
||||||
*/
|
*/
|
||||||
int get_processes(struct fast_process_info **processes, int *count);
|
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
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue