// // 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 #define VERIFY_STRING(s) (((s) != NULL) && (strlen(s) > 0)) #define SAFETY_STR_STRING(s) ((s) == NULL ? "NULL" : (s)) #define MAX_IP_V4_STR (16) #define MAX_MAC_ADDR_STR (18) #define DEBUG_CODE_LINE() LOG_MSG(debug, "\n") const char *get_cur_process_dir(); const char *get_cur_process_name(); 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); int str_to_mac(const char *str, unsigned char mac[6]); int get_nic_info(const char *pName, unsigned int *pIp, unsigned int *pNetmask, unsigned int *pGateway, unsigned char *pMac); int str_to_ipaddr(const char *pIp, unsigned int *ipAddr); unsigned long long get_current_time_ms(); #ifdef __cplusplus } #endif #endif //DAEMON_AGENT_MISC_MISC_H