#pragma once

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>

#include <stddef.h>
#include <semaphore.h>
#include <pthread.h>
#include <sys/stat.h>
// #include <regex.h>

#ifndef COLOR_RESET
#define COLOR_RESET     "\033[0m"
#endif

#ifndef COLOR_RED
#define COLOR_RED       "\033[31m"
#endif

#ifndef COLOR_WHITE
#define COLOR_WHITE     "\033[37m"
#endif



#if defined(__linux__)
#ifndef __SHORT_FILE__
#define __SHORT_FILE__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
#endif
#else
#ifndef __SHORT_FILE__
#define __SHORT_FILE__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
#endif
#endif

#ifndef LOG
#define LOG(color, level, fmt, ...) \
    do{\
        printf("%s[%s] [%s, %u] " fmt COLOR_RESET "\n", \
            color, level, __SHORT_FILE__, __LINE__, ##__VA_ARGS__); \
    }while (0)
#endif
    
#ifndef LOG_I
#define LOG_I(fmt, ...)  LOG(COLOR_WHITE, "INFO", fmt, ##__VA_ARGS__)
#endif

#ifndef LOG_E
#define LOG_E(fmt, ...)  LOG(COLOR_RED, "ERROR", fmt, ##__VA_ARGS__)
#endif

#ifndef LOCAL
#define LOCAL static
#endif

// 数据类型定义
#define DATA_TYPE_B     1
#define DATA_TYPE_S8    43
#define DATA_TYPE_U8    32
#define DATA_TYPE_S16   33
#define DATA_TYPE_U16   45
#define DATA_TYPE_S32   2
#define DATA_TYPE_U32   35
#define DATA_TYPE_L64   36
#define DATA_TYPE_UL64  37
#define DATA_TYPE_F32   38
#define DATA_TYPE_D64   39
#define DATA_TYPE_IP    100
#define DATA_TYPE_MAC   101
#define DATA_TYPE_C8    102
#define DATA_TYPE_C32   103
#define DATA_TYPE_C64   104
#define DATA_TYPE_C128  105
#define DATA_TYPE_C1    106
