initial commit

This commit is contained in:
2025-08-05 15:53:44 +08:00
commit 09dc02ae52
553 changed files with 137665 additions and 0 deletions

38
common/utils/util.c Executable file
View File

@@ -0,0 +1,38 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#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;
}