ztp/include/common.h

50 lines
1.2 KiB
C

//
// Created by xajhu on 2019/11/18 0018.
//
#ifndef ZTP_COMMON_H
#define ZTP_COMMON_H
#ifndef UNUSED
#define UNUSED(x) ((void)(x))
#endif
#ifndef MAX_PATH
#define MAX_PATH (256)
#endif
#ifndef TRUE
#define TRUE (1)
#endif
#ifndef FALSE
#define FALSE (0)
#endif
#ifndef MAX
/** @def MAX
@brief 取最大值
*/
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef MIN
/** @def MIN
@brief 取最小值
*/
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif
#define GET_FILE_SIZE(path, size) \
do { \
struct stat st; \
memset(&st, 0, sizeof(struct stat)); \
if (stat(path, &st) != 0) { \
(size) = -1; \
} else { \
(size) = st.st_size; \
} \
} while (0)
#endif //ZTP_COMMON_H