Mod aaa-12 重新格式化代码,更新工程配置
RCA: SOL: 修改人:huangxin 检视人:huangxin
This commit is contained in:
parent
5e05e5771c
commit
8c278cbc64
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" native2AsciiForPropertiesFiles="true" defaultCharsetForPropertiesFiles="UTF-8">
|
||||
<file url="file://$PROJECT_DIR$/ztp_main.c" charset="UTF-8" />
|
||||
<file url="PROJECT" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
|
@ -108,7 +108,9 @@ static int __get_dev_port_config(config_t *pCfg, DEV_PORT_CONFIG pPortCfg[], int
|
|||
if(config_setting_lookup_string(pSubVal, "backup_dns", (const char **)&pString) == CONFIG_TRUE) {
|
||||
strcpy(pPortCfg[i].wan_conf.static_config.backup_dns, pString);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case PPPOE_TYPE:
|
||||
pSubVal = config_setting_get_member(pVal, "pppoe");
|
||||
|
||||
|
@ -123,9 +125,12 @@ static int __get_dev_port_config(config_t *pCfg, DEV_PORT_CONFIG pPortCfg[], int
|
|||
if(config_setting_lookup_string(pSubVal, "password", (const char **)&pString) == CONFIG_TRUE) {
|
||||
strcpy(pPortCfg[i].wan_conf.pppoe_config.password, pString);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case DHCP_TYPE:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -276,7 +281,9 @@ static void *__cfg_file_monitor(void *p)
|
|||
if(select(fd + 1, &fds, NULL, NULL, NULL) > 0) {
|
||||
ssize_t len;
|
||||
unsigned int index = 0;
|
||||
|
||||
while(((len = read(fd, &buf, MAX_PATH)) < 0) && (errno == EINTR)); //没有读取到事件。
|
||||
|
||||
while(index < len) {
|
||||
event = (struct inotify_event *)(buf + index);
|
||||
//LOG_EX(LOG_Info, "event->mask: 0x%08x\n", event->mask);
|
||||
|
@ -296,6 +303,7 @@ static void *__cfg_file_monitor(void *p)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//获取事件。
|
||||
index += sizeof(struct inotify_event) + event->len; //移动index指向下一个事件。
|
||||
}
|
||||
|
|
|
@ -12,14 +12,14 @@ typedef enum {
|
|||
} JSON_ENGINE_TYPE;
|
||||
|
||||
typedef struct {
|
||||
char* pESN;
|
||||
char *pESN;
|
||||
} AUTH_ZTH_REQ, *PAUTH_ZTH_REQ;
|
||||
|
||||
typedef struct {
|
||||
char* status;
|
||||
char *status;
|
||||
unsigned int iptype;
|
||||
unsigned int ip;
|
||||
char* code;
|
||||
char *code;
|
||||
} AUTH_ZTH_RSP, *PAUTH_ZTH_RSP;
|
||||
|
||||
|
||||
|
|
|
@ -31,8 +31,7 @@ extern "C" {
|
|||
/** @enum _LOG_LEVEL_
|
||||
* LOG等级枚举变量
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
LOG_Fatal = (1u << 0u),
|
||||
LOG_Error = (1u << 1u),
|
||||
LOG_Warn = (1u << 2u),
|
||||
|
@ -63,7 +62,7 @@ typedef enum
|
|||
const char* pFmtBuf = format_hex_buf(prefix, DUMP_PREFIX_NONE, 16, 1, buf, len, 1); \
|
||||
IHW_LOG(level, "[%s] - %s(%04d): %s", basename_v2(__FILE__), __FUNCTION__, __LINE__, pFmtBuf); \
|
||||
free((void*)pFmtBuf); \
|
||||
} while(0);
|
||||
} while(0);
|
||||
/*! \def LOG_EX
|
||||
\brief 系统日志调试宏标识
|
||||
*/
|
||||
|
@ -103,11 +102,11 @@ typedef enum
|
|||
* @param level 调试信息开关
|
||||
* @param pMsg 调试信息内容
|
||||
*/
|
||||
void IHW_LOG(unsigned int level, const char* pMsg, ...);
|
||||
void IHW_LOG_UNTAG(unsigned int level, const char* pMsg, ...);
|
||||
void IHW_LOG(unsigned int level, const char *pMsg, ...);
|
||||
void IHW_LOG_UNTAG(unsigned int level, const char *pMsg, ...);
|
||||
|
||||
void IHW_LogStrWithoutPrint(unsigned int level, char* pMsg);
|
||||
void IHW_LogRawString(unsigned int level, char* pMsg);
|
||||
void IHW_LogStrWithoutPrint(unsigned int level, char *pMsg);
|
||||
void IHW_LogRawString(unsigned int level, char *pMsg);
|
||||
|
||||
/**
|
||||
* @brief 设置调试等级
|
||||
|
@ -122,7 +121,7 @@ void IHW_EnableLogLevel(unsigned int level, int iEnable);
|
|||
* @param pPath 系统日志保存路径
|
||||
* @param bEnable 打开/关闭调试信息
|
||||
*/
|
||||
void IHW_InitLOG(const char* pLogTag, const char* pPath, int bEnable);
|
||||
void IHW_InitLOG(const char *pLogTag, const char *pPath, int bEnable);
|
||||
|
||||
void IHW_RunLogService(void);
|
||||
|
||||
|
@ -131,28 +130,25 @@ void IHW_RunLogService(void);
|
|||
* @param pPath - 文件路径
|
||||
* @return int 存在返回 1, 否则返回 0;
|
||||
*/
|
||||
int IHW_IsFileExist(const char* pPath);
|
||||
int IHW_IsFileExist(const char *pPath);
|
||||
|
||||
char* IHW_bin2hex(char *p, const unsigned char *cp, int count);
|
||||
char *IHW_bin2hex(char *p, const unsigned char *cp, int count);
|
||||
|
||||
/* Return the last part of a pathname */
|
||||
static inline const char* basename_v2(const char* path)
|
||||
static inline const char *basename_v2(const char *path)
|
||||
{
|
||||
const char* tail = strrchr(path, '/');
|
||||
const char *tail = strrchr(path, '/');
|
||||
return tail ? tail + 1 : path;
|
||||
}
|
||||
|
||||
static inline int dirname_v2(const char* path, char* dir)
|
||||
static inline int dirname_v2(const char *path, char *dir)
|
||||
{
|
||||
const char* tail = strrchr(path, '/');
|
||||
const char *tail = strrchr(path, '/');
|
||||
|
||||
if(tail)
|
||||
{
|
||||
if(tail) {
|
||||
memcpy(dir, path, tail - path);
|
||||
dir[tail - path] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
strcpy(dir, "./");
|
||||
}
|
||||
|
||||
|
@ -161,14 +157,14 @@ static inline int dirname_v2(const char* path, char* dir)
|
|||
#endif
|
||||
|
||||
void IHW_WaitFinishLogout(void);
|
||||
const char* LogLeveToString(unsigned int lv);
|
||||
const char *LogLeveToString(unsigned int lv);
|
||||
|
||||
const char* format_hex_buf(const char* prefix_str, int prefix_type,
|
||||
const char *format_hex_buf(const char *prefix_str, int prefix_type,
|
||||
int rowsize, int groupsize,
|
||||
const void* buf, int len, int ascii);
|
||||
const void *buf, int len, int ascii);
|
||||
#ifndef __KERNEL__
|
||||
void print_hex_dump_bytes(const char* prefix_str, int prefix_type,
|
||||
const void* buf, int len);
|
||||
void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
|
||||
const void *buf, int len);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
#ifndef ZTP_CLIENT_RESTFUL_H
|
||||
#define ZTP_CLIENT_RESTFUL_H
|
||||
|
||||
typedef void (*OnHttpResponse)(void* pData, unsigned int size, const char* pReqUrl,
|
||||
const char* pDlPath, const char* pTaskUuid, int iFinished, void* pUserData);
|
||||
typedef void (*OnHttpResponse)(void *pData, unsigned int size, const char *pReqUrl,
|
||||
const char *pDlPath, const char *pTaskUuid, int iFinished, void *pUserData);
|
||||
|
||||
int http_post_request(const char *pURL, const char* pPost, OnHttpResponse onRespCb);
|
||||
int http_post_request(const char *pURL, const char *pPost, OnHttpResponse onRespCb);
|
||||
#endif //ZTP_CLIENT_RESTFUL_H
|
||||
|
|
|
@ -81,13 +81,13 @@ typedef struct {
|
|||
int total_ports;
|
||||
} DEVICE_CONFIG, *PDEVICE_CONFIG;
|
||||
|
||||
int init_configure(const char* pPath);
|
||||
int init_configure(const char *pPath);
|
||||
|
||||
int cfg_get_bool_value(config_t* pCfg, const char* pTags, int defValue);
|
||||
int cfg_get_int_value(config_t* pCfg, const char* pTags, int defValue);
|
||||
char* cfg_get_string_value(config_t* pCfg, const char* pTags, char* pDefValue);
|
||||
double cfg_get_float_value(config_t* pCfg, const char* pTags, double defValue);
|
||||
int cfg_get_array_int_value(config_t* pCfg, const char *pTags, int* pArray, int* pMaxItem);
|
||||
int cfg_get_bool_value(config_t *pCfg, const char *pTags, int defValue);
|
||||
int cfg_get_int_value(config_t *pCfg, const char *pTags, int defValue);
|
||||
char *cfg_get_string_value(config_t *pCfg, const char *pTags, char *pDefValue);
|
||||
double cfg_get_float_value(config_t *pCfg, const char *pTags, double defValue);
|
||||
int cfg_get_array_int_value(config_t *pCfg, const char *pTags, int *pArray, int *pMaxItem);
|
||||
|
||||
int load_dev_config(const char* devId);
|
||||
int load_dev_config(const char *devId);
|
||||
#endif //ZTP_CLIENT_ZTP_CONFIG_H
|
||||
|
|
|
@ -89,7 +89,7 @@ static int __ztp_auth_decode(const char *pJsonS, void **pStruct)
|
|||
|
||||
static JSON_ENGINE g_jSonEngine[] = {
|
||||
{JE_AUTH_ZTP, __ztp_auth_encode, __ztp_auth_decode, NULL},
|
||||
{JSON_ENGINE_MAX,NULL, NULL, NULL}
|
||||
{JSON_ENGINE_MAX, NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -15,9 +15,9 @@ static const char hex_asc[] = "0123456789abcdef";
|
|||
#define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4]
|
||||
|
||||
#if 0
|
||||
char* IHW_bin2hex(char *p, const unsigned char *cp, int count)
|
||||
char *IHW_bin2hex(char *p, const unsigned char *cp, int count)
|
||||
{
|
||||
while (count) {
|
||||
while(count) {
|
||||
unsigned char c = *cp++;
|
||||
/* put lowercase hex digits */
|
||||
*p++ = 0x20 | hex_asc[c >> 4];
|
||||
|
@ -37,15 +37,13 @@ char* IHW_bin2hex(char *p, const unsigned char *cp, int count)
|
|||
*/
|
||||
int hex_to_bin(char ch)
|
||||
{
|
||||
if((ch >= '0') && (ch <= '9'))
|
||||
{
|
||||
if((ch >= '0') && (ch <= '9')) {
|
||||
return ch - '0';
|
||||
}
|
||||
|
||||
ch = tolower(ch);
|
||||
|
||||
if((ch >= 'a') && (ch <= 'f'))
|
||||
{
|
||||
if((ch >= 'a') && (ch <= 'f')) {
|
||||
return ch - 'a' + 10;
|
||||
}
|
||||
|
||||
|
@ -94,13 +92,11 @@ void hex_dump_to_buffer(const void *buf, int len, int rowsize,
|
|||
goto nil;
|
||||
}
|
||||
|
||||
if(len > rowsize) /* limit to one line at a time */
|
||||
{
|
||||
if(len > rowsize) { /* limit to one line at a time */
|
||||
len = rowsize;
|
||||
}
|
||||
|
||||
if((len % groupsize) != 0) /* no mixed size output */
|
||||
{
|
||||
if((len % groupsize) != 0) { /* no mixed size output */
|
||||
groupsize = 1;
|
||||
}
|
||||
|
||||
|
@ -112,7 +108,7 @@ void hex_dump_to_buffer(const void *buf, int len, int rowsize,
|
|||
for(j = 0; j < ngroups; j++)
|
||||
lx += snprintf(linebuf + lx, linebuflen - lx,
|
||||
"%s%16.16llx", j ? " " : "",
|
||||
(long long)*(ptr8 + j));
|
||||
(long long) * (ptr8 + j));
|
||||
|
||||
ascii_column = 17 * ngroups + 2;
|
||||
break;
|
||||
|
@ -171,7 +167,7 @@ void hex_dump_to_buffer(const void *buf, int len, int rowsize,
|
|||
linebuf[lx++] = (char)((isascii(ch) && isprint(ch)) ? ch : '.');
|
||||
}
|
||||
|
||||
nil:
|
||||
nil:
|
||||
linebuf[lx] = '\0';
|
||||
}
|
||||
|
||||
|
|
14
log/log.c
14
log/log.c
|
@ -126,6 +126,7 @@ static void __logColorOutput(const char *pColFmt, UT_string *pLog)
|
|||
static void *__logOutputThread(void *p)
|
||||
{
|
||||
UNUSED(p);
|
||||
|
||||
while(g_bEnableLog) {
|
||||
int isWriteLog = FALSE;
|
||||
PLOG_ITEM pItem = NULL, pTmp = NULL;
|
||||
|
@ -202,6 +203,7 @@ static void *__logOutputThread(void *p)
|
|||
pthread_mutex_unlock(&g_logLock);
|
||||
|
||||
usleep(1000);
|
||||
|
||||
if(g_LogProcessInfo.pLogFile != NULL && isWriteLog) {
|
||||
fflush(g_LogProcessInfo.pLogFile);
|
||||
}
|
||||
|
@ -253,6 +255,7 @@ void IHW_InitLOG(const char *pLogTag, const char *pPath, int bEnable)
|
|||
memset(strPath, 0, MAX_PATH * 2);
|
||||
|
||||
g_LogProcessInfo.pid = getpid();
|
||||
|
||||
if(readlink("/proc/self/exe", strPath, MAX_PATH) == -1) {
|
||||
strcpy(g_LogProcessInfo.exeName, pLogTag);
|
||||
} else {
|
||||
|
@ -399,26 +402,37 @@ const char *LogLeveToString(unsigned int lv)
|
|||
switch(lv) {
|
||||
case LOG_Fatal:
|
||||
return "LOG_Fatal";
|
||||
|
||||
case LOG_Error:
|
||||
return "LOG_Error";
|
||||
|
||||
case LOG_Warn:
|
||||
return "LOG_Warn";
|
||||
|
||||
case LOG_Debug:
|
||||
return "LOG_Debug";
|
||||
|
||||
case LOG_Info:
|
||||
return "LOG_Info";
|
||||
|
||||
case LOG_Test:
|
||||
return "LOG_Test";
|
||||
|
||||
case LOG_Call:
|
||||
return "LOG_Call";
|
||||
|
||||
case LOG_Devp:
|
||||
return "LOG_Devp";
|
||||
|
||||
case LOG_Step:
|
||||
return "LOG_Step";
|
||||
|
||||
case LOG_Unknown:
|
||||
return "LOG_Unknown";
|
||||
|
||||
case LOG_All:
|
||||
return "LOG_All";
|
||||
|
||||
case LOG_Close:
|
||||
return "LOG_Close";
|
||||
|
||||
|
|
|
@ -52,9 +52,11 @@ int main(int argc, char **argv)
|
|||
load_dev_config(ZTP_ESN);
|
||||
|
||||
#ifdef MONITOR_ZTP_CFG_FILE
|
||||
while(ret == ERR_OK){
|
||||
|
||||
while(ret == ERR_OK) {
|
||||
usleep(1000);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
IHW_WaitFinishLogout();
|
||||
|
|
Loading…
Reference in New Issue