mirror of
https://github.com/thead-yocto-mirror/prd-utils
synced 2026-06-21 08:52:31 +02:00
Linux_SDK_V1.1.2
This commit is contained in:
41
include/prd_utils_internal.h
Normal file
41
include/prd_utils_internal.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef PRD_UTILS_INTERNAL_H
|
||||
#define PRD_UTILS_INTERNAL_H
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#define MKTAG_NEGA(e) (-(e))
|
||||
|
||||
#define LOG_COLOR_RED_YELLO_BACK "\033[1;31;43m"
|
||||
#define LOG_COLOR_RED "\033[2;31;49m"
|
||||
#define LOG_COLOR_YELLOW "\033[2;33;49m"
|
||||
#define LOG_COLOR_GREEN "\033[2;32;49m"
|
||||
#define LOG_COLOR_BLUE "\033[2;34;49m"
|
||||
#define LOG_COLOR_GRAY "\033[1;30m"
|
||||
#define LOG_COLOR_WHITE "\033[1;47;49m"
|
||||
#define LOG_COLOR_RESET "\033[0m"
|
||||
|
||||
|
||||
#define PRD_UTILS_LOG(fmt, args...) \
|
||||
do {printf("[%s():%d] ",__FUNCTION__, __LINE__); printf(fmt,##args);} while(0)
|
||||
|
||||
#define PRD_UTILS_ASSERT(expr) \
|
||||
do { \
|
||||
if (!(expr)) { \
|
||||
printf(LOG_COLOR_RED \
|
||||
"\nASSERT failed at:\n"\
|
||||
" >File name: %s\n" \
|
||||
" >Function : %s\n" \
|
||||
" >Line No. : %d\n" \
|
||||
" >Condition: %s\n" \
|
||||
LOG_COLOR_RESET, \
|
||||
__FILE__,__FUNCTION__, __LINE__, #expr);\
|
||||
exit(-1); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
|
||||
#endif /* PRD_UTILS_INTERNAL_H */
|
||||
30
include/prd_utils_kv.h
Normal file
30
include/prd_utils_kv.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef PRD_UTILS_KV_H
|
||||
#define PRD_UTILS_KV_H
|
||||
|
||||
#define PRD_UTILS_KEY_MAX_LENGTH 64
|
||||
#define PRD_UTILS_VAL_MAX_LENGTH 256
|
||||
#define PRD_UTILS_KV_MAX_COUNT 128
|
||||
|
||||
#define PRD_UTILS_KEY_NAME_ETH_ADDR "ethaddr"
|
||||
#define PRD_UTILS_KEY_NAME_SN "sn"
|
||||
|
||||
typedef enum {
|
||||
PRD_UTILS_RESULT_OK = 0,
|
||||
PRD_UTILS_RESULT_KV_INPUT_INVALID = -1,
|
||||
PRD_UTILS_RESULT_KV_IO_FAILED = -2,
|
||||
PRD_UTILS_RESULT_KV_NOT_EXIST = -3,
|
||||
} prd_utils_result_e;
|
||||
|
||||
// Notice:
|
||||
// 1. input key CAN'T including space or other non-printable charater
|
||||
// 2. input value CAN'T including any non-printable charater
|
||||
|
||||
int prd_utils_get_kv(char *key, char **value);
|
||||
int prd_utils_set_kv(char *key, char *value);
|
||||
int prd_utils_clean_kv(char *key);
|
||||
|
||||
#endif /* PRD_UTILS_KV_H */
|
||||
Reference in New Issue
Block a user