#include #include #include #include "hlog.h" #include "util.h" const char *get_filename(char *path) { CHECK_NULL_RETURN("path", path); char *s1 = strrchr(path, '/'); char *s2 = strrchr(path, '\\'); if (s1 && s2) { path = (s1 > s2) ? s1 + 1 : s2 + 1; } else if (s1) path = s1 + 1; else if (s2) path = s2 + 1; return path; } uint8_t file_exist(const char* path) { return !access(path, F_OK); } uint8_t isIP(const char*ip){ int32_t a,b,c,d; char str[128]; return sscanf(ip,"%d.%d.%d.%d",&a,&b,&c,&d) == 4 || sscanf(ip,"%[^:]|%[^:]|%[^:]|%[^:]|%[^:]|%[^:]|%s",str,str,str,str,str,str,str) == 7; }