// // Created by xajhu on 2021/7/2 0002. // #ifndef DAEMON_AGENT_MISC_MISC_H #define DAEMON_AGENT_MISC_MISC_H #ifdef __cplusplus extern "C" { #endif #define _STR(s) #s #define STR(s) _STR(s) #ifndef ARRAY_SIZE //#ifdef __cplusplus #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) //#else //#define ARRAY_SIZE_TYPE_CHECK(a) (sizeof(typeof(int[1 - 2 * !!__builtin_types_compatible_p(typeof(a), typeof(&a[0]))]))) //#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]) + ARRAY_SIZE_TYPE_CHECK(a) * 0) //#endif #endif #ifndef UNUSED #define UNUSED(x) UNUSED_##x __attribute__((__unused__)) #endif #ifndef MAX_PATH #define MAX_PATH (512) #endif #ifndef TRUE #define TRUE (1) #endif #ifndef FALSE #define FALSE (0) #endif int file_exists(const char *pPath); const char *basename_v2(const char *path); int dirname_v2(const char *path, char *dir); unsigned long long get_partition_free_size(const char *pPartPath); int copy_file(const char *pSrc, const char *pDest); char *bin2hex(char *p, const unsigned char *cp, unsigned int count); int shell_with_output(const char *pCmd, char **pResult); #ifdef __cplusplus } #endif #endif//DAEMON_AGENT_MISC_MISC_H