Mod aaa-12 增加对象管理配置管理接口
RCA: SOL: 修改人:huangxin 检视人:huangxin
This commit is contained in:
parent
24f01ce548
commit
dc1a278ce7
|
@ -1,19 +1,37 @@
|
||||||
cmake_minimum_required(VERSION 3.10)
|
cmake_minimum_required(VERSION 3.10)
|
||||||
project(drivers) # 工程名字,随你怎么叫都行
|
project(drivers) # 工程名字,随你怎么叫都行
|
||||||
|
|
||||||
|
set(PLAT_CFG_DIR "./Platform/user/configm/config-server")
|
||||||
#include(kernel_config.cmake) # 一堆的 add_definitions(xxx),就不细说了
|
#include(kernel_config.cmake) # 一堆的 add_definitions(xxx),就不细说了
|
||||||
|
|
||||||
#add_definitions(-D__KERNEL__=1)
|
#add_definitions(-D__KERNEL__=1)
|
||||||
|
|
||||||
|
add_definitions(-D_GNU_SOURCE=1)
|
||||||
|
add_definitions(-D__USE_XOPEN=1)
|
||||||
|
add_definitions(-DOBJECT_DEMO=1)
|
||||||
|
|
||||||
aux_source_directory(./Product/user/object_manager DIR_SRCS)
|
aux_source_directory(./Product/user/object_manager DIR_SRCS)
|
||||||
aux_source_directory(./libs/src/lighttpd-1.4.51/src DIR_SRCS)
|
aux_source_directory(./libs/src/lighttpd-1.4.51/src DIR_SRCS)
|
||||||
|
aux_source_directory(${PLAT_CFG_DIR} DIR_SRCS)
|
||||||
|
aux_source_directory(${PLAT_CFG_DIR}/object_manager DIR_SRCS)
|
||||||
|
aux_source_directory(${PLAT_CFG_DIR}/web_config DIR_SRCS)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
set(MY_ANDROID_ROOT_DIR "./kernel/linux-4.14.83") # 定义一个变量,方便后面使用
|
set(MY_ANDROID_ROOT_DIR "./kernel/linux-4.14.83") # 定义一个变量,方便后面使用
|
||||||
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -nostdinc") # C 编译器设置
|
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -nostdinc") # C 编译器设置
|
||||||
|
|
||||||
add_executable(drivers ${DIR_SRCS}) # dummy target,没有这个的话external libraries就是空的,
|
add_executable(drivers ${DIR_SRCS} Platform/user/configm/config-server/object_manager/object_manager.h Platform/user/configm/config-server/object_manager/object_manager.c) # dummy target,没有这个的话external libraries就是空的,
|
||||||
# 弄一个main.c糊弄糊弄Clion
|
# 弄一个main.c糊弄糊弄Clion
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
./Common
|
||||||
|
${PLAT_CFG_DIR}/include
|
||||||
|
./Platform/common/configm/include
|
||||||
|
./Platform/common
|
||||||
|
./Product/common
|
||||||
|
)
|
||||||
|
|
||||||
#include_directories(
|
#include_directories(
|
||||||
# "${MY_ANDROID_ROOT_DIR}/kernel/include"
|
# "${MY_ANDROID_ROOT_DIR}/kernel/include"
|
||||||
# "${MY_ANDROID_ROOT_DIR}/kernel/arch/arm/include"
|
# "${MY_ANDROID_ROOT_DIR}/kernel/arch/arm/include"
|
||||||
|
|
|
@ -12,6 +12,22 @@
|
||||||
/***********************操作类型定义结束 ********************/
|
/***********************操作类型定义结束 ********************/
|
||||||
|
|
||||||
/*************************** 模块定义 ************************/
|
/*************************** 模块定义 ************************/
|
||||||
|
typedef enum{
|
||||||
|
NETCONFIG_MODULE = 0x00000001, ///< NET CONFIG
|
||||||
|
USER_MANAGER_CONFIG_MODULE = 0x00000002, ///< USER MANAGER CONFIG
|
||||||
|
LOCALAUTH_CONFIG_MODULE = 0x00000003, ///< PORTAL SERVER CONFIG
|
||||||
|
LOG_CONFIG_MODULE = 0x00000004, ///<
|
||||||
|
VLAN_CONFIG_MODULE = 0x00000005, ///< vlan config
|
||||||
|
DHCP_CONFIG_MODULE = 0x00000007, ///< DHCP CONFIG
|
||||||
|
LTE_CONFIG_MODULE = 0x00000008, ///< 4G config
|
||||||
|
NAT_CONFIG_MODULE = 0x00000009, ///< nat config
|
||||||
|
STATIC_ROUTING_CONFIG_MODULE = 0x00000009, ///< static routing
|
||||||
|
OBJECT_MANAGER_CONFIG_MODULE = 0x0000000A, ///< Object manager config id
|
||||||
|
|
||||||
|
CONFIG_ID_MAX,
|
||||||
|
} CONFIG_ID_TYPE;
|
||||||
|
|
||||||
|
#if 0
|
||||||
/* NET CONFIG */
|
/* NET CONFIG */
|
||||||
#define NETCONFIG_MODULE 0x00000001
|
#define NETCONFIG_MODULE 0x00000001
|
||||||
|
|
||||||
|
@ -37,7 +53,7 @@
|
||||||
|
|
||||||
/*4G config*/
|
/*4G config*/
|
||||||
#define LTE_CONFIG_MODULE 0x00000007
|
#define LTE_CONFIG_MODULE 0x00000007
|
||||||
|
#endif
|
||||||
|
|
||||||
/************************* 模块定义结束 **********************/
|
/************************* 模块定义结束 **********************/
|
||||||
|
|
||||||
|
@ -80,6 +96,10 @@
|
||||||
#define GET_ALL_ROUTING_INFO (uint64)((uint64)STATIC_ROUTING_CONFIG_MODULE<<32|2)
|
#define GET_ALL_ROUTING_INFO (uint64)((uint64)STATIC_ROUTING_CONFIG_MODULE<<32|2)
|
||||||
|
|
||||||
#define LTE_CONFIG (uint64)((uint64)LTE_CONFIG_MODULE<<32|1)
|
#define LTE_CONFIG (uint64)((uint64)LTE_CONFIG_MODULE<<32|1)
|
||||||
|
|
||||||
|
#define OBJECT_CONFIG (uint64)((uint64)OBJECT_MANAGER_CONFIG_MODULE<<32|1)
|
||||||
|
#define OBJECT_GETALL_CONFIG (uint64)((uint64)OBJECT_MANAGER_CONFIG_MODULE<<32|2)
|
||||||
|
|
||||||
/************************ config id定义 end**********************/
|
/************************ config id定义 end**********************/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -28,7 +28,8 @@ VPATH = ../user/configm/config-server \
|
||||||
../user/configm/config-server/web_config \
|
../user/configm/config-server/web_config \
|
||||||
../user/configm/config-server/dhcp_config \
|
../user/configm/config-server/dhcp_config \
|
||||||
../user/configm/config-server/user_manager_config \
|
../user/configm/config-server/user_manager_config \
|
||||||
../user/configm/config-server/log_config
|
../user/configm/config-server/log_config \
|
||||||
|
../user/configm/config-server/object_manager
|
||||||
|
|
||||||
# source code
|
# source code
|
||||||
|
|
||||||
|
@ -71,7 +72,10 @@ COMMON_SRCS = configserver.c \
|
||||||
dhcp_shared_network_config.c \
|
dhcp_shared_network_config.c \
|
||||||
dhcp_subnet_config.c\
|
dhcp_subnet_config.c\
|
||||||
static_routing_config/static_routing_config.c \
|
static_routing_config/static_routing_config.c \
|
||||||
LTE_config/LTE_config.c
|
LTE_config/LTE_config.c \
|
||||||
|
object_manager.c \
|
||||||
|
log.c \
|
||||||
|
hexdump.c
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,7 +88,8 @@ COMMOM_CFLAGS = -I../user/configm/config-server/include \
|
||||||
-I../../Common -I../common/redismq -I../common/database \
|
-I../../Common -I../common/redismq -I../common/database \
|
||||||
-I../common/configm -I../common/rpc -I../common/rpc/hashtable \
|
-I../common/configm -I../common/rpc -I../common/rpc/hashtable \
|
||||||
-I../common/ulog -I../user/configm/config-server/netconfig/ \
|
-I../common/ulog -I../user/configm/config-server/netconfig/ \
|
||||||
-I../user/configm/config-server/netconfig/bridge/include
|
-I../user/configm/config-server/netconfig/bridge/include \
|
||||||
|
-I../common -I../../Producd/common
|
||||||
|
|
||||||
# gcc CFLAGS
|
# gcc CFLAGS
|
||||||
PLAT_ARM64_CFLAGS := $(COMMOM_CFLAGS)
|
PLAT_ARM64_CFLAGS := $(COMMOM_CFLAGS)
|
||||||
|
|
|
@ -35,7 +35,7 @@ PLAT_LINUX_SRCS = $(COMMON_SRCS)
|
||||||
PLAT_ARM64_SRCS = $(COMMON_SRCS)
|
PLAT_ARM64_SRCS = $(COMMON_SRCS)
|
||||||
|
|
||||||
# gcc CFLAGS
|
# gcc CFLAGS
|
||||||
PLAT_ARM64_CFLAGS := -I../user/configm/config-server/include -I../../Common -I../common/configm -I../common/rpc -I../common/rpc/hashtable
|
PLAT_ARM64_CFLAGS := -I../user/configm/config-server/include -I../../Common -I../common/configm -I../common -I../common/rpc -I../common/rpc/hashtable
|
||||||
PLAT_LINUX_CFLAGS := $(PLAT_ARM64_CFLAGS)
|
PLAT_LINUX_CFLAGS := $(PLAT_ARM64_CFLAGS)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "dhcp_lib.h"
|
#include "dhcp_lib.h"
|
||||||
#include "static_routing.h"
|
#include "static_routing.h"
|
||||||
#include "LTE_config.h"
|
#include "LTE_config.h"
|
||||||
|
#include "../object_manager/object_manager.h"
|
||||||
|
|
||||||
#define RET_CODE_LEN 16
|
#define RET_CODE_LEN 16
|
||||||
#define RET_MSG_LEN 128
|
#define RET_MSG_LEN 128
|
||||||
|
@ -42,6 +43,10 @@
|
||||||
{ \
|
{ \
|
||||||
LTE_CONFIG_MODULE, \
|
LTE_CONFIG_MODULE, \
|
||||||
LTE_config_init \
|
LTE_config_init \
|
||||||
|
}, \
|
||||||
|
{ \
|
||||||
|
OBJECT_MANAGER_CONFIG_MODULE, \
|
||||||
|
object_config_init \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,6 +314,24 @@
|
||||||
LTE_config_proc, \
|
LTE_config_proc, \
|
||||||
NULL, \
|
NULL, \
|
||||||
LTE_config_get_all \
|
LTE_config_get_all \
|
||||||
|
}, \
|
||||||
|
{ \
|
||||||
|
OBJECT_CONFIG, \
|
||||||
|
CONFIG_FROM_WEB, \
|
||||||
|
FALSE, \
|
||||||
|
object_config_chk, \
|
||||||
|
object_config_proc, \
|
||||||
|
NULL, \
|
||||||
|
NULL, \
|
||||||
|
}, \
|
||||||
|
{ \
|
||||||
|
OBJECT_GETALL_CONFIG, \
|
||||||
|
CONFIG_FROM_WEB, \
|
||||||
|
FALSE, \
|
||||||
|
object_config_chk, \
|
||||||
|
NULL, \
|
||||||
|
object_config_get, \
|
||||||
|
object_config_get_all, \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,326 @@
|
||||||
|
#ifndef __KERNEL__
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <uthash/utstring.h>
|
||||||
|
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
|
static const char hex_asc[] = "0123456789abcdef";
|
||||||
|
|
||||||
|
#define hex_asc_lo(x) hex_asc[((x) & 0x0f)]
|
||||||
|
#define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4]
|
||||||
|
|
||||||
|
char* IHW_bin2hex(char *p, const unsigned char *cp, int count)
|
||||||
|
{
|
||||||
|
while (count) {
|
||||||
|
unsigned char c = *cp++;
|
||||||
|
/* put lowercase hex digits */
|
||||||
|
*p++ = 0x20 | hex_asc[c >> 4];
|
||||||
|
*p++ = 0x20 | hex_asc[c & 0xf];
|
||||||
|
count--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hex_to_bin - convert a hex digit to its real value
|
||||||
|
* @ch: ascii character represents hex digit
|
||||||
|
*
|
||||||
|
* hex_to_bin() converts one hex digit to its actual value or -1 in case of bad
|
||||||
|
* input.
|
||||||
|
*/
|
||||||
|
int hex_to_bin(char ch)
|
||||||
|
{
|
||||||
|
if((ch >= '0') && (ch <= '9'))
|
||||||
|
{
|
||||||
|
return ch - '0';
|
||||||
|
}
|
||||||
|
|
||||||
|
ch = tolower(ch);
|
||||||
|
|
||||||
|
if((ch >= 'a') && (ch <= 'f'))
|
||||||
|
{
|
||||||
|
return ch - 'a' + 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hex_dump_to_buffer - convert a blob of data to "hex ASCII" in memory
|
||||||
|
* @buf: data blob to dump
|
||||||
|
* @len: number of bytes in the @buf
|
||||||
|
* @rowsize: number of bytes to print per line; must be 16 or 32
|
||||||
|
* @groupsize: number of bytes to print at a time (1, 2, 4, 8; default = 1)
|
||||||
|
* @linebuf: where to put the converted data
|
||||||
|
* @linebuflen: total size of @linebuf, including space for terminating NUL
|
||||||
|
* @ascii: include ASCII after the hex output
|
||||||
|
*
|
||||||
|
* hex_dump_to_buffer() works on one "line" of output at a time, i.e.,
|
||||||
|
* 16 or 32 bytes of input data converted to hex + ASCII output.
|
||||||
|
*
|
||||||
|
* Given a buffer of u8 data, hex_dump_to_buffer() converts the input data
|
||||||
|
* to a hex + ASCII dump at the supplied memory location.
|
||||||
|
* The converted output is always NUL-terminated.
|
||||||
|
*
|
||||||
|
* E.g.:
|
||||||
|
* hex_dump_to_buffer(frame->data, frame->len, 16, 1,
|
||||||
|
* linebuf, sizeof(linebuf), true);
|
||||||
|
*
|
||||||
|
* example output buffer:
|
||||||
|
* 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f @ABCDEFGHIJKLMNO
|
||||||
|
*/
|
||||||
|
void hex_dump_to_buffer(const void* buf, int len, int rowsize,
|
||||||
|
int groupsize, char* linebuf, size_t linebuflen,
|
||||||
|
int ascii)
|
||||||
|
{
|
||||||
|
const unsigned char* ptr = (const unsigned char *)buf;
|
||||||
|
unsigned char ch;
|
||||||
|
int j, lx = 0;
|
||||||
|
int ascii_column;
|
||||||
|
|
||||||
|
if(rowsize != 16 && rowsize != 32)
|
||||||
|
{
|
||||||
|
rowsize = 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!len)
|
||||||
|
{
|
||||||
|
goto nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(len > rowsize) /* limit to one line at a time */
|
||||||
|
{
|
||||||
|
len = rowsize;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((len % groupsize) != 0) /* no mixed size output */
|
||||||
|
{
|
||||||
|
groupsize = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(groupsize)
|
||||||
|
{
|
||||||
|
case 8:
|
||||||
|
{
|
||||||
|
const unsigned long long* ptr8 = (const unsigned long long *)buf;
|
||||||
|
int ngroups = len / groupsize;
|
||||||
|
|
||||||
|
for(j = 0; j < ngroups; j++)
|
||||||
|
lx += snprintf(linebuf + lx, linebuflen - lx,
|
||||||
|
"%s%16.16llx", j ? " " : "",
|
||||||
|
(unsigned long long) * (ptr8 + j));
|
||||||
|
|
||||||
|
ascii_column = 17 * ngroups + 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
{
|
||||||
|
const unsigned int* ptr4 = (const unsigned int *)buf;
|
||||||
|
int ngroups = len / groupsize;
|
||||||
|
|
||||||
|
for(j = 0; j < ngroups; j++)
|
||||||
|
lx += snprintf(linebuf + lx, linebuflen - lx,
|
||||||
|
"%s%8.8x", j ? " " : "", *(ptr4 + j));
|
||||||
|
|
||||||
|
ascii_column = 9 * ngroups + 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
const unsigned short* ptr2 = (const unsigned short *)buf;
|
||||||
|
int ngroups = len / groupsize;
|
||||||
|
|
||||||
|
for(j = 0; j < ngroups; j++)
|
||||||
|
lx += snprintf(linebuf + lx, linebuflen - lx,
|
||||||
|
"%s%4.4x", j ? " " : "", *(ptr2 + j));
|
||||||
|
|
||||||
|
ascii_column = 5 * ngroups + 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
for(j = 0; (j < len) && (lx + 3) <= linebuflen; j++)
|
||||||
|
{
|
||||||
|
ch = ptr[j];
|
||||||
|
linebuf[lx++] = hex_asc_hi(ch);
|
||||||
|
linebuf[lx++] = hex_asc_lo(ch);
|
||||||
|
linebuf[lx++] = ' ';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(j)
|
||||||
|
{
|
||||||
|
lx--;
|
||||||
|
}
|
||||||
|
|
||||||
|
ascii_column = 3 * rowsize + 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!ascii)
|
||||||
|
{
|
||||||
|
goto nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(lx < (linebuflen - 1) && lx < (ascii_column - 1))
|
||||||
|
{
|
||||||
|
linebuf[lx++] = ' ';
|
||||||
|
}
|
||||||
|
|
||||||
|
for(j = 0; (j < len) && (lx + 2) < linebuflen; j++)
|
||||||
|
{
|
||||||
|
ch = ptr[j];
|
||||||
|
linebuf[lx++] = (isascii(ch) && isprint(ch)) ? ch : '.';
|
||||||
|
}
|
||||||
|
|
||||||
|
nil:
|
||||||
|
linebuf[lx++] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* print_hex_dump - print a text hex dump to syslog for a binary blob of data
|
||||||
|
* @level: kernel log level (e.g. KERN_DEBUG)
|
||||||
|
* @prefix_str: string to prefix each line with;
|
||||||
|
* caller supplies trailing spaces for alignment if desired
|
||||||
|
* @prefix_type: controls whether prefix of an offset, address, or none
|
||||||
|
* is printed (%DUMP_PREFIX_OFFSET, %DUMP_PREFIX_ADDRESS, %DUMP_PREFIX_NONE)
|
||||||
|
* @rowsize: number of bytes to print per line; must be 16 or 32
|
||||||
|
* @groupsize: number of bytes to print at a time (1, 2, 4, 8; default = 1)
|
||||||
|
* @buf: data blob to dump
|
||||||
|
* @len: number of bytes in the @buf
|
||||||
|
* @ascii: include ASCII after the hex output
|
||||||
|
*
|
||||||
|
* Given a buffer of u8 data, print_hex_dump() prints a hex + ASCII dump
|
||||||
|
* to the kernel log at the specified kernel log level, with an optional
|
||||||
|
* leading prefix.
|
||||||
|
*
|
||||||
|
* print_hex_dump() works on one "line" of output at a time, i.e.,
|
||||||
|
* 16 or 32 bytes of input data converted to hex + ASCII output.
|
||||||
|
* print_hex_dump() iterates over the entire input @buf, breaking it into
|
||||||
|
* "line size" chunks to format and print.
|
||||||
|
*
|
||||||
|
* E.g.:
|
||||||
|
* print_hex_dump(KERN_DEBUG, "raw data: ", DUMP_PREFIX_ADDRESS,
|
||||||
|
* 16, 1, frame->data, frame->len, true);
|
||||||
|
*
|
||||||
|
* Example output using %DUMP_PREFIX_OFFSET and 1-byte mode:
|
||||||
|
* 0009ab42: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f @ABCDEFGHIJKLMNO
|
||||||
|
* Example output using %DUMP_PREFIX_ADDRESS and 4-byte mode:
|
||||||
|
* ffffffff88089af0: 73727170 77767574 7b7a7978 7f7e7d7c pqrstuvwxyz{|}~.
|
||||||
|
*/
|
||||||
|
void print_hex_dump(const char* prefix_str, int prefix_type,
|
||||||
|
int rowsize, int groupsize,
|
||||||
|
const void* buf, int len, int ascii)
|
||||||
|
{
|
||||||
|
const unsigned char* ptr = (const unsigned char *)buf;
|
||||||
|
int i, remaining = len;
|
||||||
|
unsigned char linebuf[32 * 3 + 2 + 32 + 1];
|
||||||
|
|
||||||
|
if(rowsize != 16 && rowsize != 32)
|
||||||
|
{
|
||||||
|
rowsize = 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i = 0; i < len; i += rowsize)
|
||||||
|
{
|
||||||
|
int linelen = MIN(remaining, rowsize);
|
||||||
|
remaining -= rowsize;
|
||||||
|
|
||||||
|
hex_dump_to_buffer(ptr + i, linelen, rowsize, groupsize,
|
||||||
|
(char *)linebuf, sizeof(linebuf), ascii);
|
||||||
|
|
||||||
|
switch(prefix_type)
|
||||||
|
{
|
||||||
|
case DUMP_PREFIX_ADDRESS:
|
||||||
|
print("%s%p: %s\n",
|
||||||
|
prefix_str, ptr + i, linebuf);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DUMP_PREFIX_OFFSET:
|
||||||
|
print("%s%.8x: %s\n", prefix_str, i, linebuf);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
print("%s%.8x: %s\n", prefix_str, i, linebuf);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print("%s", "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* print_hex_dump_bytes - shorthand form of print_hex_dump() with default params
|
||||||
|
* @prefix_str: string to prefix each line with;
|
||||||
|
* caller supplies trailing spaces for alignment if desired
|
||||||
|
* @prefix_type: controls whether prefix of an offset, address, or none
|
||||||
|
* is printed (%DUMP_PREFIX_OFFSET, %DUMP_PREFIX_ADDRESS, %DUMP_PREFIX_NONE)
|
||||||
|
* @buf: data blob to dump
|
||||||
|
* @len: number of bytes in the @buf
|
||||||
|
*
|
||||||
|
* Calls print_hex_dump(), with log level of KERN_DEBUG,
|
||||||
|
* rowsize of 16, groupsize of 1, and ASCII output included.
|
||||||
|
*/
|
||||||
|
void print_hex_dump_bytes(const char* prefix_str, int prefix_type,
|
||||||
|
const void* buf, int len)
|
||||||
|
{
|
||||||
|
print_hex_dump(prefix_str, prefix_type, 16, 1,
|
||||||
|
buf, len, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* format_hex_buf(const char* prefix_str, int prefix_type,
|
||||||
|
int rowsize, int groupsize,
|
||||||
|
const void* buf, int len, int ascii)
|
||||||
|
{
|
||||||
|
UT_string* pLogStr = NULL;
|
||||||
|
const char* pFormatStr;
|
||||||
|
const unsigned char* ptr = (const unsigned char *)buf;
|
||||||
|
int i, remaining = len;
|
||||||
|
unsigned char linebuf[32 * 3 + 2 + 32 + 1];
|
||||||
|
|
||||||
|
if(rowsize != 16 && rowsize != 32)
|
||||||
|
{
|
||||||
|
rowsize = 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
utstring_new(pLogStr);
|
||||||
|
|
||||||
|
for(i = 0; i < len; i += rowsize)
|
||||||
|
{
|
||||||
|
int linelen = MIN(remaining, rowsize);
|
||||||
|
remaining -= rowsize;
|
||||||
|
|
||||||
|
hex_dump_to_buffer(ptr + i, linelen, rowsize, groupsize,
|
||||||
|
(char *)linebuf, sizeof(linebuf), ascii);
|
||||||
|
|
||||||
|
switch(prefix_type)
|
||||||
|
{
|
||||||
|
case DUMP_PREFIX_ADDRESS:
|
||||||
|
utstring_printf(pLogStr, "%s%p: %s\n",
|
||||||
|
prefix_str, ptr + i, linebuf);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DUMP_PREFIX_OFFSET:
|
||||||
|
utstring_printf(pLogStr, "%s%.8x: %s\n",
|
||||||
|
prefix_str, i, linebuf);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
utstring_printf(pLogStr, "%s%.8x: %s\n",
|
||||||
|
prefix_str, i, linebuf);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pFormatStr = strdup(utstring_body(pLogStr));
|
||||||
|
utstring_free(pLogStr);
|
||||||
|
|
||||||
|
return pFormatStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,441 @@
|
||||||
|
/** @file log.c
|
||||||
|
@brief 系统日志接口文件
|
||||||
|
@version 1.0.0
|
||||||
|
*/
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <uthash/utlist.h>
|
||||||
|
#include <uthash/utstring.h>
|
||||||
|
|
||||||
|
#include "log.h"
|
||||||
|
#include "../../../../Product/common/common.h"
|
||||||
|
|
||||||
|
#define SHOW_CONSOLE_RED ("\033[31;48m\033[1m%s\033[0m%c")
|
||||||
|
#define SHOW_CONSOLE_YELLOW ("\033[33;48m\033[1m%s\033[0m%c")
|
||||||
|
#define SHOW_CONSOLE_GREEN ("\033[32;48m\033[1m%s\033[0m%c")
|
||||||
|
#define SHOW_CONSOLE_BLUE ("\033[34;48m\033[1m%s\033[0m%c")
|
||||||
|
|
||||||
|
#define LOG_FILE_BASEDIR (".")
|
||||||
|
|
||||||
|
#define MAX_LOG_FILE_SIZE (1024 * 1024)
|
||||||
|
#define MAX_PATH (256)
|
||||||
|
|
||||||
|
typedef struct LOG_ITEM
|
||||||
|
{
|
||||||
|
LOG_LEVEL level;
|
||||||
|
int isPrinted;
|
||||||
|
int isAddTags;
|
||||||
|
struct timeval timestamp;
|
||||||
|
char *pLogContent;
|
||||||
|
struct LOG_ITEM *next, *prev;
|
||||||
|
}*PLOG_ITEM;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
pid_t pid;
|
||||||
|
char exeName[MAX_PATH];
|
||||||
|
char logFilePath[MAX_PATH];
|
||||||
|
FILE *pLogFile;
|
||||||
|
} LOG_PROCESS_INFO, *PLOG_PROCESS_INFO;
|
||||||
|
|
||||||
|
static int g_bEnableLog = TRUE; // 是否启用 Log 功能
|
||||||
|
static int g_bEnLogToFile = TRUE;
|
||||||
|
static char g_strLogTag[32]; // Log 标志
|
||||||
|
static unsigned int g_LogRdPos = 0;
|
||||||
|
static pthread_t g_logThreadId;
|
||||||
|
static LOG_PROCESS_INFO g_LogProcessInfo;
|
||||||
|
static pthread_mutex_t g_logLock;
|
||||||
|
static PLOG_ITEM g_pLogItemList = NULL;
|
||||||
|
|
||||||
|
static int g_iMinLevel = LOG_Fatal | LOG_Error | LOG_Warn | LOG_Debug | LOG_Info | LOG_Step;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Log 调试等级转字符串
|
||||||
|
* @param level 调试等级
|
||||||
|
* @return 调试等级对应的字符串
|
||||||
|
*/
|
||||||
|
const char* LogLevelToStr(LOG_LEVEL level)
|
||||||
|
{
|
||||||
|
switch(level)
|
||||||
|
{
|
||||||
|
case LOG_Test:
|
||||||
|
return "T";
|
||||||
|
|
||||||
|
case LOG_Info:
|
||||||
|
return "I";
|
||||||
|
|
||||||
|
case LOG_Call:
|
||||||
|
return "C";
|
||||||
|
|
||||||
|
case LOG_Debug:
|
||||||
|
return "D";
|
||||||
|
|
||||||
|
case LOG_Warn:
|
||||||
|
return "W";
|
||||||
|
|
||||||
|
case LOG_Error:
|
||||||
|
return "E";
|
||||||
|
|
||||||
|
case LOG_Fatal:
|
||||||
|
return "F";
|
||||||
|
|
||||||
|
case LOG_Step:
|
||||||
|
return "S";
|
||||||
|
|
||||||
|
case LOG_Devp:
|
||||||
|
return "V";
|
||||||
|
|
||||||
|
case LOG_Unknown:
|
||||||
|
return "U";
|
||||||
|
|
||||||
|
case LOG_All:
|
||||||
|
return "A";
|
||||||
|
|
||||||
|
default:
|
||||||
|
return "?";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __logColorOutput(const char* pColFmt, UT_string* pLog)
|
||||||
|
{
|
||||||
|
if(pLog == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pColFmt == NULL)
|
||||||
|
{
|
||||||
|
print("%s", utstring_body(pLog));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(utstring_find(pLog, -1, "\n", 1) == utstring_len(pLog) - 1)
|
||||||
|
{
|
||||||
|
char* pLogArray = utstring_body(pLog);
|
||||||
|
pLogArray[utstring_len(pLog) - 1] = 0;
|
||||||
|
|
||||||
|
print(pColFmt, pLogArray, '\n');
|
||||||
|
|
||||||
|
strcat(pLogArray, "\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print(pColFmt, utstring_body(pLog), '\0');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void* __logOutputThread(void *p)
|
||||||
|
{
|
||||||
|
(void)p;
|
||||||
|
while(TRUE)
|
||||||
|
{
|
||||||
|
int isWriteLog = FALSE;
|
||||||
|
PLOG_ITEM pItem = NULL, pTmp = NULL;
|
||||||
|
|
||||||
|
pthread_mutex_lock(&g_logLock);
|
||||||
|
|
||||||
|
LL_FOREACH_SAFE(g_pLogItemList, pItem, pTmp)
|
||||||
|
{
|
||||||
|
UT_string *pLogStr;
|
||||||
|
struct tm lTime;
|
||||||
|
int logFileSize = 0;
|
||||||
|
|
||||||
|
if(++g_LogRdPos % 100 == 0)
|
||||||
|
{
|
||||||
|
GET_FILE_SIZE(g_LogProcessInfo.logFilePath, logFileSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
localtime_r(&(pItem->timestamp.tv_sec), &lTime);
|
||||||
|
|
||||||
|
utstring_new(pLogStr);
|
||||||
|
|
||||||
|
if(pItem->isAddTags)
|
||||||
|
{
|
||||||
|
utstring_printf(pLogStr, "[%04d-%02d-%02d %02d:%02d:%02d.%03ld] [%s] %s",
|
||||||
|
lTime.tm_year + 1900, lTime.tm_mon + 1, lTime.tm_mday,
|
||||||
|
lTime.tm_hour, lTime.tm_min, lTime.tm_sec, pItem->timestamp.tv_usec / 1000,
|
||||||
|
LogLevelToStr(pItem->level), pItem->pLogContent);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
utstring_printf(pLogStr, "%s", pItem->pLogContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pItem->isPrinted == FALSE)
|
||||||
|
{
|
||||||
|
if(pItem->level & LOG_Error
|
||||||
|
|| pItem->level & LOG_Fatal)
|
||||||
|
{
|
||||||
|
__logColorOutput(SHOW_CONSOLE_RED, pLogStr);
|
||||||
|
}
|
||||||
|
else if(pItem->level & LOG_Warn
|
||||||
|
|| pItem->level & LOG_Unknown)
|
||||||
|
{
|
||||||
|
__logColorOutput(SHOW_CONSOLE_YELLOW, pLogStr);
|
||||||
|
}
|
||||||
|
else if(pItem->level & LOG_Test
|
||||||
|
|| pItem->level & LOG_Call)
|
||||||
|
{
|
||||||
|
__logColorOutput(SHOW_CONSOLE_BLUE, pLogStr);
|
||||||
|
}
|
||||||
|
else if(pItem->level & LOG_Devp)
|
||||||
|
{
|
||||||
|
__logColorOutput(SHOW_CONSOLE_GREEN, pLogStr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print("%s", utstring_body(pLogStr));
|
||||||
|
}
|
||||||
|
|
||||||
|
pItem->isPrinted = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(g_LogProcessInfo.pLogFile != NULL && g_bEnLogToFile)
|
||||||
|
{
|
||||||
|
if(logFileSize >= MAX_LOG_FILE_SIZE)
|
||||||
|
{
|
||||||
|
fflush(g_LogProcessInfo.pLogFile);
|
||||||
|
fclose(g_LogProcessInfo.pLogFile);
|
||||||
|
|
||||||
|
g_LogProcessInfo.pLogFile = fopen(g_LogProcessInfo.logFilePath, "w+");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(g_LogProcessInfo.pLogFile)
|
||||||
|
{
|
||||||
|
fwrite(utstring_body(pLogStr), 1, utstring_len(pLogStr), g_LogProcessInfo.pLogFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
isWriteLog = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
LL_DELETE(g_pLogItemList, pItem);
|
||||||
|
|
||||||
|
utstring_free(pLogStr);
|
||||||
|
free(pItem->pLogContent);
|
||||||
|
free(pItem);
|
||||||
|
|
||||||
|
if(g_LogRdPos % 100 == 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&g_logLock);
|
||||||
|
|
||||||
|
usleep(1000);
|
||||||
|
if(g_LogProcessInfo.pLogFile != NULL && isWriteLog)
|
||||||
|
{
|
||||||
|
fflush(g_LogProcessInfo.pLogFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 设置调试等级
|
||||||
|
* @param level 调试等级
|
||||||
|
* @param iEnable 1 打开调试等级, 0 关闭调试等级
|
||||||
|
*/
|
||||||
|
void IHW_EnableLogLevel(LOG_LEVEL level, int iEnable)
|
||||||
|
{
|
||||||
|
if(iEnable > 0)
|
||||||
|
{
|
||||||
|
g_iMinLevel |= level;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_iMinLevel &= ~(level);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 初始化系统日志功能
|
||||||
|
* @param pLogTag 系统日志标志
|
||||||
|
* @param pPath 系统日志保存路径
|
||||||
|
* @param bEnable 打开/关闭调试信息
|
||||||
|
*/
|
||||||
|
void IHW_InitLOG(const char* pLogTag, const char* pPath, int bEnable)
|
||||||
|
{
|
||||||
|
char strPath[MAX_PATH * 2];
|
||||||
|
(void)pPath;
|
||||||
|
|
||||||
|
pthread_mutex_init(&g_logLock, 0);
|
||||||
|
|
||||||
|
g_LogRdPos = 0;
|
||||||
|
memset(g_strLogTag, 0, 32);
|
||||||
|
|
||||||
|
memset(&g_LogProcessInfo, 0, sizeof(LOG_PROCESS_INFO));
|
||||||
|
|
||||||
|
if(pLogTag == NULL)
|
||||||
|
{
|
||||||
|
strcpy(g_strLogTag, "");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strncpy(g_strLogTag, pLogTag, 31);
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
{
|
||||||
|
char *pExeName = strrchr(strPath, '/');
|
||||||
|
|
||||||
|
if(pExeName == NULL)
|
||||||
|
{
|
||||||
|
strncpy(g_LogProcessInfo.exeName, strPath, MAX_PATH - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strncpy(g_LogProcessInfo.exeName, pExeName + 1, MAX_PATH - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(g_LogProcessInfo.logFilePath, 0, MAX_PATH);
|
||||||
|
sprintf(g_LogProcessInfo.logFilePath, "%s/%s_%d.log", LOG_FILE_BASEDIR, g_LogProcessInfo.exeName, g_LogProcessInfo.pid);
|
||||||
|
|
||||||
|
memset(strPath, 0, MAX_PATH);
|
||||||
|
//sprintf(strPath, "rm -f %s/%s_*.log > /dev/zero", LOG_FILE_BASEDIR, g_LogProcessInfo.exeName);
|
||||||
|
//ret = system(strPath);
|
||||||
|
|
||||||
|
//g_LogProcessInfo.pLogFile = fopen(g_LogProcessInfo.logFilePath, "w+");
|
||||||
|
|
||||||
|
g_bEnableLog = bEnable;
|
||||||
|
|
||||||
|
IHW_RunLogService();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IHW_RunLogService(void)
|
||||||
|
{
|
||||||
|
pthread_create(&g_logThreadId, NULL, __logOutputThread, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __logTo(LOG_LEVEL level, int isAddTag, char* pMsg, int isPrint)
|
||||||
|
{
|
||||||
|
PLOG_ITEM pLogItem;
|
||||||
|
|
||||||
|
pLogItem = (PLOG_ITEM)malloc(sizeof(struct LOG_ITEM));
|
||||||
|
|
||||||
|
if(pLogItem == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pLogItem->pLogContent = strdup(pMsg);
|
||||||
|
pLogItem->isPrinted = isPrint ? FALSE : TRUE;
|
||||||
|
pLogItem->level = level;
|
||||||
|
pLogItem->isAddTags = isAddTag ? TRUE : FALSE;
|
||||||
|
gettimeofday(&(pLogItem->timestamp), NULL);
|
||||||
|
|
||||||
|
pthread_mutex_lock(&g_logLock);
|
||||||
|
LL_APPEND(g_pLogItemList, pLogItem);
|
||||||
|
pthread_mutex_unlock(&g_logLock);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IHW_LogStrWithoutPrint(int level, char* pMsg)
|
||||||
|
{
|
||||||
|
__logTo(level, TRUE, pMsg, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IHW_LogRawString(int level, char* pMsg)
|
||||||
|
{
|
||||||
|
__logTo(level, TRUE, pMsg, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 输出调试信息
|
||||||
|
* @param cFlag 调试信息开关
|
||||||
|
* @param pMsg 调试信息内容
|
||||||
|
*/
|
||||||
|
void IHW_LOG_UNTAG(LOG_LEVEL level, const char* pMsg, ...)
|
||||||
|
{
|
||||||
|
va_list arg_ptr;
|
||||||
|
UT_string *pLogContent;
|
||||||
|
|
||||||
|
if(!g_bEnableLog)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查调试等级
|
||||||
|
if(!(g_iMinLevel & level))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
utstring_new(pLogContent);
|
||||||
|
va_start(arg_ptr, pMsg);
|
||||||
|
utstring_printf_va(pLogContent, pMsg, arg_ptr);
|
||||||
|
va_end(arg_ptr);
|
||||||
|
|
||||||
|
__logTo(level, FALSE, utstring_body(pLogContent), TRUE);
|
||||||
|
|
||||||
|
utstring_free(pLogContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 输出调试信息
|
||||||
|
* @param cFlag 调试信息开关
|
||||||
|
* @param pMsg 调试信息内容
|
||||||
|
*/
|
||||||
|
void IHW_LOG(LOG_LEVEL level, const char* pMsg, ...)
|
||||||
|
{
|
||||||
|
UT_string* pLogContent = NULL;
|
||||||
|
va_list arg_ptr;
|
||||||
|
|
||||||
|
if(!g_bEnableLog)
|
||||||
|
{
|
||||||
|
fprintf(stdout, "skip2\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查调试等级
|
||||||
|
if(!(g_iMinLevel & level))
|
||||||
|
{
|
||||||
|
fprintf(stdout, "skip1\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
utstring_new(pLogContent);
|
||||||
|
va_start(arg_ptr, pMsg);
|
||||||
|
utstring_printf_va(pLogContent, pMsg, arg_ptr);
|
||||||
|
va_end(arg_ptr);
|
||||||
|
|
||||||
|
__logTo(level, TRUE, utstring_body(pLogContent), TRUE);
|
||||||
|
|
||||||
|
utstring_free(pLogContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* LogLeveToString(LOG_LEVEL 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";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "Unknown";
|
||||||
|
}
|
|
@ -0,0 +1,208 @@
|
||||||
|
/** @file log.h
|
||||||
|
@brief
|
||||||
|
@details
|
||||||
|
@version 1.0.0
|
||||||
|
*/
|
||||||
|
#ifndef LOG_H_
|
||||||
|
#define LOG_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __KERNEL__
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
#else
|
||||||
|
#include <linux/string.h>
|
||||||
|
#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 TIMEZONE_EAST_8H (8 * 3600)
|
||||||
|
|
||||||
|
#ifndef __KERNEL__
|
||||||
|
#define DUMP_PREFIX_ADDRESS (1)
|
||||||
|
#define DUMP_PREFIX_OFFSET (2)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define print(format, ...) fprintf(stdout, format, __VA_ARGS__)
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
CMD_LOG_ENABLE = 0,
|
||||||
|
CMD_LOG_FILE = 1,
|
||||||
|
CMD_LOG_MAIL = 2,
|
||||||
|
CMD_LOG_LEVEL = 3,
|
||||||
|
CMD_LOG_NETWORK = 4,
|
||||||
|
CMD_LOG_SERVER = 5
|
||||||
|
} LOG_CFG_CMD;
|
||||||
|
|
||||||
|
/** @enum _LOG_LEVEL_
|
||||||
|
* LOG等级枚举变量
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
LOG_Fatal = (1 << 0),
|
||||||
|
LOG_Error = (1 << 1),
|
||||||
|
LOG_Warn = (1 << 2),
|
||||||
|
LOG_Debug = (1 << 3),
|
||||||
|
LOG_Info = (1 << 4),
|
||||||
|
LOG_Test = (1 << 5),
|
||||||
|
LOG_Call = (1 << 6),
|
||||||
|
LOG_Devp = (1 << 7),
|
||||||
|
LOG_Step = (1 << 8),
|
||||||
|
LOG_Unknown = (1 << 9),
|
||||||
|
LOG_All = (0xFFFFFFFF),
|
||||||
|
LOG_Close = 0x0,
|
||||||
|
} LOG_LEVEL;
|
||||||
|
/** @var typedef _LOG_LEVEL_ LOG_LEVEL
|
||||||
|
* @brief 错误值枚举类型
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef DISABLE_LOG
|
||||||
|
#define LOG_BUF(level, buf, len)
|
||||||
|
#define LOG_EX(level, format, args...)
|
||||||
|
#define LOG_EX2(level, format, args...)
|
||||||
|
#define LOG_TAG_EX(tag, level, format, args...)
|
||||||
|
#define DEBUG_CODE_LINE()
|
||||||
|
#define DEBUG_FUNCTION_BEGIN()
|
||||||
|
#define DEBUG_FUNCTION_END()
|
||||||
|
#else
|
||||||
|
#define LOG_BUF(level, buf, len) do { \
|
||||||
|
const char* pFmtBuf = format_hex_buf("", DUMP_PREFIX_ADDRESS, 16, 1, buf, len, 1); \
|
||||||
|
IHW_LOG(level, "[%s] - %s(%04d): %s[0-%d]:\n%s", basename_v2(__FILE__), __FUNCTION__, __LINE__, \
|
||||||
|
#buf, len, pFmtBuf); \
|
||||||
|
free((void*)pFmtBuf); \
|
||||||
|
} while(0);
|
||||||
|
/*! \def LOG_EX
|
||||||
|
\brief 系统日志调试宏标识
|
||||||
|
*/
|
||||||
|
#define LOG_EX(level, format, args...) (IHW_LOG(level, "[%s] - %s(%04d):" format , basename_v2(__FILE__), __FUNCTION__, __LINE__, ##args))
|
||||||
|
|
||||||
|
/*! \def LOG_TAG_EX
|
||||||
|
\brief 系统日志调试宏标识
|
||||||
|
*/
|
||||||
|
#define LOG_TAG_EX(tag, level, format, args...) (IHW_LOG(level, "{%s} [%s] %s(%04d):" format , tag, basename_v2(__FILE__), __FUNCTION__, __LINE__, ##args))
|
||||||
|
|
||||||
|
#define LOG_EX2(level, format, args...) (IHW_LOG_UNTAG(level, format , ##args))
|
||||||
|
|
||||||
|
/*! @def APP_BUILD_INFO
|
||||||
|
@brief 应用程序编译信息
|
||||||
|
*/
|
||||||
|
#define APP_BUILD_INFO(appname, appver) (IHW_LOG(LOG_Info, "%s Ver:%s (Build: %s %s GCC Ver:%s) With %d(bits) OS\n", \
|
||||||
|
appname, appver, __DATE__, __TIME__, __VERSION__, sizeof(int*) * 8))
|
||||||
|
|
||||||
|
|
||||||
|
/*! @def DEBUG_CODE_LINE
|
||||||
|
@brief 输出当前函数名,行号
|
||||||
|
*/
|
||||||
|
#define DEBUG_CODE_LINE() (LOG_EX(LOG_Info, "\n"))
|
||||||
|
|
||||||
|
/*! @def DEBUG_FUNCTION_BEGIN
|
||||||
|
@brief 函数入口标志
|
||||||
|
*/
|
||||||
|
#define DEBUG_FUNCTION_BEGIN() (LOG_EX(LOG_Call, "+++++\n"))
|
||||||
|
|
||||||
|
/*! @def DEBUG_FUNCTION_END
|
||||||
|
@brief 函数出口标志
|
||||||
|
*/
|
||||||
|
#define DEBUG_FUNCTION_END() (LOG_EX(LOG_Call, "-----\n"))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 输出调试信息
|
||||||
|
* @param level 调试信息开关
|
||||||
|
* @param pMsg 调试信息内容
|
||||||
|
*/
|
||||||
|
void IHW_LOG(LOG_LEVEL level, const char* pMsg, ...);
|
||||||
|
void IHW_LOG_UNTAG(LOG_LEVEL level, const char* pMsg, ...);
|
||||||
|
|
||||||
|
void IHW_LogStrWithoutPrint(int level, char* pMsg);
|
||||||
|
void IHW_LogRawString(int level, char* pMsg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 设置调试等级
|
||||||
|
* @param level 调试等级
|
||||||
|
* @param iEnable 1 打开调试等级, 0 关闭调试等级
|
||||||
|
*/
|
||||||
|
void IHW_EnableLogLevel(LOG_LEVEL level, int iEnable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 初始化系统日志功能
|
||||||
|
* @param pLogTag 系统日志标志
|
||||||
|
* @param pPath 系统日志保存路径
|
||||||
|
* @param bEnable 打开/关闭调试信息
|
||||||
|
*/
|
||||||
|
void IHW_InitLOG(const char* pLogTag, const char* pPath, int bEnable);
|
||||||
|
|
||||||
|
void IHW_RunLogService(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 判断文件、路径是否存在
|
||||||
|
* @param pPath - 文件路径
|
||||||
|
* @return int 存在返回 1, 否则返回 0;
|
||||||
|
*/
|
||||||
|
int IHW_IsFileExist(const char* pPath);
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
const char* tail = strrchr(path, '/');
|
||||||
|
return tail ? tail + 1 : path;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int dirname_v2(const char* path, char* dir)
|
||||||
|
{
|
||||||
|
const char* tail = strrchr(path, '/');
|
||||||
|
|
||||||
|
if(tail)
|
||||||
|
{
|
||||||
|
memcpy(dir, path, tail - path);
|
||||||
|
dir[tail - path] = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strcpy(dir, "./");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const char* LogLeveToString(LOG_LEVEL lv);
|
||||||
|
|
||||||
|
const char* format_hex_buf(const char* prefix_str, int prefix_type,
|
||||||
|
int rowsize, int groupsize,
|
||||||
|
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);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif //LOG_H_
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
//
|
||||||
|
// Created by xajhu on 2019/10/10 0010.
|
||||||
|
//
|
||||||
|
#include "object_manager.h"
|
||||||
|
#include "configm.h"
|
||||||
|
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
|
ret_code object_config_init()
|
||||||
|
{
|
||||||
|
IHW_InitLOG("obj", NULL, TRUE);
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret_code object_config_chk(uint source, uint *config_type,
|
||||||
|
pointer input, int *input_len,
|
||||||
|
pointer output, int *output_len)
|
||||||
|
{
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret_code object_config_proc(uint source, uint config_type,
|
||||||
|
pointer input, int input_len,
|
||||||
|
pointer output, int *output_len)
|
||||||
|
{
|
||||||
|
LOG_EX(LOG_Debug, "[%016X]:type = %u, %s\n", source, config_type, (const char*)input);
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret_code object_config_get(uint source,
|
||||||
|
pointer input, int input_len,
|
||||||
|
pointer output, int *output_len)
|
||||||
|
{
|
||||||
|
LOG_EX(LOG_Debug, "[%016X]: %s\n", source, (const char*)input);
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret_code object_config_get_all(uint source,
|
||||||
|
pointer output, int *output_len)
|
||||||
|
{
|
||||||
|
LOG_EX(LOG_Debug, "[%016X]: \n", source);
|
||||||
|
return RET_OK;
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
//
|
||||||
|
// Created by xajhu on 2019/10/10 0010.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef DRIVERS_OBJECT_MANAGER_H
|
||||||
|
#define DRIVERS_OBJECT_MANAGER_H
|
||||||
|
#include "rpc/rpc_common.h"
|
||||||
|
|
||||||
|
ret_code object_config_init();
|
||||||
|
|
||||||
|
ret_code object_config_chk(uint source, uint *config_type,
|
||||||
|
pointer input, int *input_len,
|
||||||
|
pointer output, int *output_len);
|
||||||
|
ret_code object_config_proc(uint source, uint config_type,
|
||||||
|
pointer input, int input_len,
|
||||||
|
pointer output, int *output_len);
|
||||||
|
ret_code object_config_get(uint source,
|
||||||
|
pointer input, int input_len,
|
||||||
|
pointer output, int *output_len);
|
||||||
|
ret_code object_config_get_all(uint source,
|
||||||
|
pointer output, int *output_len);
|
||||||
|
#endif //DRIVERS_OBJECT_MANAGER_H
|
|
@ -35,13 +35,16 @@ PLAT_LINUX_SRCS := $(subst $(SRC_DIR)/, , $(wildcard $(SRC_DIR)/*.c))
|
||||||
PLAT_ARM64_SRCS := $(PLAT_LINUX_SRCS)
|
PLAT_ARM64_SRCS := $(PLAT_LINUX_SRCS)
|
||||||
|
|
||||||
# gcc CFLAGS
|
# gcc CFLAGS
|
||||||
COMMON_CFLAGS := -I../../Common
|
COMMON_CFLAGS := -I../../Common -I../../Platform/common -I../../Product/common -DOBJECT_DEMO=1
|
||||||
PLAT_LINUX_CFLAGS += $(COMMON_CFLAGS)
|
PLAT_LINUX_CFLAGS += $(COMMON_CFLAGS)
|
||||||
PLAT_ARM64_CFLAGS += $(COMMON_CFLAGS) -D_GNU_SOURCE -D__USE_XOPEN
|
PLAT_ARM64_CFLAGS += $(COMMON_CFLAGS) -D_GNU_SOURCE -D__USE_XOPEN
|
||||||
|
|
||||||
|
PLAT_ARM64_LDFLAGS := -L ../../Platform/build/debug
|
||||||
|
PLAT_LINUX_LDFLAGS := $(PLAT_ARM64_LDFLAGS)
|
||||||
|
|
||||||
COMMON_LIBS := -lcjson -lpthread -lpcre
|
COMMON_LIBS := -lcjson -lpthread -lpcre
|
||||||
PLAT_LINUX_LIBS := $(COMMON_LIBS)
|
PLAT_ARM64_LIBS := -lopenrpc-$(ARM64_OBJ_TARGET) -lconfigmapi-$(ARM64_OBJ_TARGET) $(COMMON_LIBS)
|
||||||
PLAT_ARM64_LIBS := $(COMMON_LIBS)
|
PLAT_LINUX_LIBS := -lopenrpc-$(LINUX_OBJ_TARGET) -lconfigmapi-$(LINUX_OBJ_TARGET) $(COMMON_LIBS)
|
||||||
|
|
||||||
# this line must be at below of thus, because of...
|
# this line must be at below of thus, because of...
|
||||||
include ../../Common/common.Makefile
|
include ../../Common/common.Makefile
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#if 1
|
#if OBJECT_DEMO
|
||||||
#define RET_OK 0
|
#define RET_OK 0
|
||||||
#define RET_ERR 1
|
#define RET_ERR 1
|
||||||
#define RET_UNKNOWN 2
|
#define RET_UNKNOWN 2
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <cjson/cJSON.h>
|
#include <cjson/cJSON.h>
|
||||||
|
@ -865,8 +863,7 @@ static int __obj_search_decode(const char *pJsonS, void **pStruct)
|
||||||
{
|
{
|
||||||
cJSON *pRoot, *pVal;
|
cJSON *pRoot, *pVal;
|
||||||
PIFACE_SEARCH_OBJ pData;
|
PIFACE_SEARCH_OBJ pData;
|
||||||
int arraySize;
|
|
||||||
int i;
|
|
||||||
*pStruct = malloc(sizeof(IFACE_SEARCH_OBJ));
|
*pStruct = malloc(sizeof(IFACE_SEARCH_OBJ));
|
||||||
|
|
||||||
if(*pStruct == NULL) {
|
if(*pStruct == NULL) {
|
||||||
|
@ -908,55 +905,55 @@ static int __obj_search_decode(const char *pJsonS, void **pStruct)
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __obj_search_encode(const char *pJsonS, void **pStruct)
|
static const char *__obj_search_encode(void *pData)
|
||||||
{
|
{
|
||||||
cJSON *pRoot, *pVal;
|
const char *pJsonS;
|
||||||
PIFACE_SEARCH_LIST pData;
|
PIFC_RET_MSG p = (PIFC_RET_MSG)pData;
|
||||||
*pStruct = malloc(sizeof(IFACE_SEARCH_LIST));
|
cJSON *pRoot = cJSON_CreateObject();
|
||||||
|
|
||||||
if(*pStruct == NULL) {
|
if(!p) {
|
||||||
return -RET_NOMEM;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pData = (PIFACE_SEARCH_LIST) * pStruct;
|
cJSON_AddNumberToObject(pRoot, "retCode", p->ret_code);
|
||||||
pRoot = cJSON_Parse(pJsonS);
|
|
||||||
|
|
||||||
if(!pRoot) {
|
if(p->mesg) {
|
||||||
return -RET_SYSERR;
|
cJSON_AddStringToObject(pRoot, "mesg", p->mesg);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(pData, 0, sizeof(IFACE_SEARCH_LIST));
|
if(p->n_items > 0) {
|
||||||
pVal = cJSON_GetObjectItem(pRoot, "type");
|
cJSON *pArray = cJSON_AddArrayToObject(pRoot, "data");
|
||||||
|
|
||||||
if(cJSON_IsNumber(pVal)) {
|
if(pArray) {
|
||||||
pData->type = pVal->valueint;
|
int i;
|
||||||
|
|
||||||
|
for(i = 0; i < p->n_items; i++) {
|
||||||
|
cJSON *pItem = cJSON_CreateObject();
|
||||||
|
|
||||||
|
if(!pItem) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
pVal = cJSON_GetObjectItem(pRoot, "start");
|
cJSON_AddStringToObject(pItem, "name", p->data[i].name);
|
||||||
|
cJSON_AddNumberToObject(pItem, "retCode", p->data[i].ret_code);
|
||||||
|
|
||||||
if(cJSON_IsNumber(pVal)) {
|
if(p->data[i].mesg) {
|
||||||
pData->start = pVal->valueint;
|
cJSON_AddStringToObject(pItem, "mesg", p->data[i].mesg);
|
||||||
}
|
}
|
||||||
|
|
||||||
pVal = cJSON_GetObjectItem(pRoot, "end");
|
cJSON_AddItemToArray(pArray, pItem);
|
||||||
|
}
|
||||||
if(cJSON_IsNumber(pVal)) {
|
}
|
||||||
pData->end = pVal->valueint;
|
|
||||||
}
|
|
||||||
|
|
||||||
pVal = cJSON_GetObjectItem(pRoot, "session");
|
|
||||||
|
|
||||||
if(cJSON_IsString(pVal)) {
|
|
||||||
strncpy(pData->session, pVal->valuestring, MAX_SESSION - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pJsonS = cJSON_Print(pRoot);
|
||||||
cJSON_Delete(pRoot);
|
cJSON_Delete(pRoot);
|
||||||
return RET_OK;
|
return pJsonS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static JSON_ENGINE g_jSonEngine[] = {
|
static JSON_ENGINE g_jSonEngine[] = {
|
||||||
{JE_INTERFACE, __interface_encode, __interface_decode, NULL},
|
{JE_INTERFACE, __interface_encode, __interface_decode, NULL},
|
||||||
{OBJ_CMD_ADD, __obj_add_encode, __obj_add_decode, NULL},
|
{JE_OBJ_ADD, __obj_add_encode, __obj_add_decode, NULL},
|
||||||
{JE_OBJ_DEL, __obj_del_encode, __obj_del_decode, NULL},
|
{JE_OBJ_DEL, __obj_del_encode, __obj_del_decode, NULL},
|
||||||
{JE_OBJ_MOD, __obj_mod_encode, __obj_mod_decode, NULL},
|
{JE_OBJ_MOD, __obj_mod_encode, __obj_mod_decode, NULL},
|
||||||
{JE_OBJ_QUERYLIST, __obj_query_list_encode, __obj_query_list_decode, NULL},
|
{JE_OBJ_QUERYLIST, __obj_query_list_encode, __obj_query_list_decode, NULL},
|
||||||
|
|
|
@ -82,7 +82,7 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[MAX_NAME_LEN];
|
char name[MAX_NAME_LEN];
|
||||||
char *mesg;
|
char *mesg;
|
||||||
char* desc[MAX_DESC];
|
char desc[MAX_DESC];
|
||||||
int prio;
|
int prio;
|
||||||
int ret_code;
|
int ret_code;
|
||||||
POBJECT_K pObjK;
|
POBJECT_K pObjK;
|
||||||
|
|
|
@ -6,17 +6,14 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <uthash/utlist.h>
|
#include <uthash/utlist.h>
|
||||||
#include <uthash/utstring.h>
|
#include <uthash/utstring.h>
|
||||||
#include <uthash/utringbuffer.h>
|
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "../../common/common.h"
|
#include "../../common/common.h"
|
||||||
|
@ -28,9 +25,7 @@
|
||||||
|
|
||||||
#define LOG_FILE_BASEDIR (".")
|
#define LOG_FILE_BASEDIR (".")
|
||||||
|
|
||||||
#define MAX_LOG_ITEM (1000)
|
|
||||||
#define MAX_LOG_FILE_SIZE (1024 * 1024)
|
#define MAX_LOG_FILE_SIZE (1024 * 1024)
|
||||||
#define LOG_PRE_SIZE (512)
|
|
||||||
#define MAX_PATH (256)
|
#define MAX_PATH (256)
|
||||||
|
|
||||||
typedef struct LOG_ITEM
|
typedef struct LOG_ITEM
|
||||||
|
@ -107,8 +102,6 @@ const char* LogLevelToStr(LOG_LEVEL level)
|
||||||
default:
|
default:
|
||||||
return "?";
|
return "?";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "U";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __logColorOutput(const char* pColFmt, UT_string* pLog)
|
static void __logColorOutput(const char* pColFmt, UT_string* pLog)
|
||||||
|
@ -142,6 +135,7 @@ static void __logColorOutput(const char* pColFmt, UT_string* pLog)
|
||||||
|
|
||||||
static void* __logOutputThread(void *p)
|
static void* __logOutputThread(void *p)
|
||||||
{
|
{
|
||||||
|
(void)p;
|
||||||
while(TRUE)
|
while(TRUE)
|
||||||
{
|
{
|
||||||
int isWriteLog = FALSE;
|
int isWriteLog = FALSE;
|
||||||
|
@ -243,9 +237,6 @@ static void* __logOutputThread(void *p)
|
||||||
fflush(g_LogProcessInfo.pLogFile);
|
fflush(g_LogProcessInfo.pLogFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_detach(pthread_self());
|
|
||||||
return (NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -274,6 +265,7 @@ void IHW_EnableLogLevel(LOG_LEVEL level, int iEnable)
|
||||||
void IHW_InitLOG(const char* pLogTag, const char* pPath, int bEnable)
|
void IHW_InitLOG(const char* pLogTag, const char* pPath, int bEnable)
|
||||||
{
|
{
|
||||||
char strPath[MAX_PATH * 2];
|
char strPath[MAX_PATH * 2];
|
||||||
|
(void)pPath;
|
||||||
|
|
||||||
pthread_mutex_init(&g_logLock, 0);
|
pthread_mutex_init(&g_logLock, 0);
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <fcntl.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <regex.h>
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <uthash/uthash.h>
|
#include <uthash/uthash.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <configm/configmapi.h>
|
||||||
|
|
||||||
#include "compile.h"
|
#include "compile.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "object_manager.h"
|
#include "object_manager.h"
|
||||||
#include "json_interface.h"
|
#include "json_interface.h"
|
||||||
#include "regex_table.h"
|
#include "regex_table.h"
|
||||||
|
#include "rpc/rpc.h"
|
||||||
|
#include "ret_errno.h"
|
||||||
|
|
||||||
#define MAX_OBJ (300)
|
#define MAX_OBJ (300)
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ static PCMHI_OBJECT g_pObject = NULL;
|
||||||
static OBJECT_K g_objItem[MAX_OBJ];
|
static OBJECT_K g_objItem[MAX_OBJ];
|
||||||
static pthread_mutex_t g_obj_lock = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t g_obj_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
static void random_string(unsigned char *buf, int size)
|
static void create_session(unsigned char *buf, int size)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
const char *asc_char = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
const char *asc_char = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||||
|
@ -44,7 +44,7 @@ static void random_string(unsigned char *buf, int size)
|
||||||
buf[i] = asc_char[rand() % max];
|
buf[i] = asc_char[rand() % max];
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_EX(LOG_Debug, "random string(%d): %s\n", strlen(buf), (char *)buf);
|
LOG_EX(LOG_Debug, "random string(%d): %s\n", strlen((const char *) buf), (char *) buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int split_params(char *pInput, char **pFirst, char **pSecond,
|
static int split_params(char *pInput, char **pFirst, char **pSecond,
|
||||||
|
@ -165,8 +165,6 @@ static void dump_object(void)
|
||||||
|
|
||||||
int object_split_page(char *pSession, int type, char *outSession)
|
int object_split_page(char *pSession, int type, char *outSession)
|
||||||
{
|
{
|
||||||
PSPLIT_PAGE p;
|
|
||||||
|
|
||||||
if (pSession == NULL || strlen(pSession) == 0) {
|
if (pSession == NULL || strlen(pSession) == 0) {
|
||||||
PCMHI_OBJECT pObj, pTmp;
|
PCMHI_OBJECT pObj, pTmp;
|
||||||
int sess_type = OBJ_TYPE_MAX;
|
int sess_type = OBJ_TYPE_MAX;
|
||||||
|
@ -178,7 +176,7 @@ int object_split_page(char *pSession, int type, char *outSession)
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(pNew, 0, sizeof(SPLIT_PAGE));
|
memset(pNew, 0, sizeof(SPLIT_PAGE));
|
||||||
random_string(pNew->session, MAX_SESSION - 1);
|
create_session((unsigned char *) pNew->session, MAX_SESSION - 1);
|
||||||
|
|
||||||
if (outSession) {
|
if (outSession) {
|
||||||
strcpy(outSession, pNew->session);
|
strcpy(outSession, pNew->session);
|
||||||
|
@ -217,11 +215,11 @@ int object_split_page(char *pSession, int type, char *outSession)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
int get_page_items(char *pSession, int type, int start, int end)
|
int get_page_items(char *pSession, int type, int start, int end)
|
||||||
{
|
{
|
||||||
int ret = RET_OK;
|
int ret = RET_OK;
|
||||||
PSPLIT_PAGE p;
|
PSPLIT_PAGE p;
|
||||||
char **pStr;
|
|
||||||
int i, iCount = 0;
|
int i, iCount = 0;
|
||||||
char session[MAX_SESSION];
|
char session[MAX_SESSION];
|
||||||
|
|
||||||
|
@ -244,10 +242,13 @@ int get_page_items(char *pSession, int type, int start, int end)
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = start; i < end && iCount < MAX_PAGE_ITEMS && iCount < utarray_len(p->name_list); i++) {
|
for(i = start; i < end && iCount < MAX_PAGE_ITEMS && iCount < utarray_len(p->name_list); i++) {
|
||||||
pStr = (char **)utarray_eltptr(p->name_list, i);
|
char ** pStr = (char **)utarray_eltptr(p->name_list, i);
|
||||||
LOG_EX(LOG_Debug, "%s[%03d]: %s\n", p->session, iCount++, *pStr);
|
LOG_EX(LOG_Debug, "%s[%03d]: %s\n", p->session, iCount++, *pStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int object_add(PCMHI_OBJECT pObj, POBJECT_K pObjK)
|
int object_add(PCMHI_OBJECT pObj, POBJECT_K pObjK)
|
||||||
{
|
{
|
||||||
|
@ -307,17 +308,9 @@ int object_add(PCMHI_OBJECT pObj, POBJECT_K pObjK)
|
||||||
return -RET_INPUTERR;
|
return -RET_INPUTERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
//first = strtoul(pStart, NULL, 10);
|
|
||||||
last = strtoul(pEnd, NULL, 10);
|
last = strtoul(pEnd, NULL, 10);
|
||||||
|
|
||||||
if(pSvr->pro_type <= PORT_UDP) {
|
|
||||||
//pSvr->min_port = htonl(first) & 0xFFFF;
|
|
||||||
pSvr->max_port = last;
|
pSvr->max_port = last;
|
||||||
} else {
|
|
||||||
//ICMP , min_port --> type, max_port --> code
|
|
||||||
//pSvr->min_port = first;
|
|
||||||
pSvr->max_port = last;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -446,7 +439,7 @@ int object_add(PCMHI_OBJECT pObj, POBJECT_K pObjK)
|
||||||
int object_del(const char *pName)
|
int object_del(const char *pName)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
PCMHI_OBJECT p, pTmp;
|
PCMHI_OBJECT p;
|
||||||
|
|
||||||
if (!pName || strlen(pName) == 0) {
|
if (!pName || strlen(pName) == 0) {
|
||||||
return -RET_INPUTERR;
|
return -RET_INPUTERR;
|
||||||
|
@ -479,21 +472,21 @@ int object_del(const char *pName)
|
||||||
switch (g_objItem[p->obj_index].type / 10) {
|
switch (g_objItem[p->obj_index].type / 10) {
|
||||||
case OBJ_TYPE_SERVER:
|
case OBJ_TYPE_SERVER:
|
||||||
if (pSvr->str_val) {
|
if (pSvr->str_val) {
|
||||||
free(pSvr->str_val);
|
free((void *) pSvr->str_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OBJ_TYPE_ADDR:
|
case OBJ_TYPE_ADDR:
|
||||||
if (pAddr->str_val) {
|
if (pAddr->str_val) {
|
||||||
free(pAddr->str_val);
|
free((void *) pAddr->str_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OBJ_TYPE_DATETIME:
|
case OBJ_TYPE_DATETIME:
|
||||||
if (pDt->str_val) {
|
if (pDt->str_val) {
|
||||||
free(pDt->str_val);
|
free((void *) pDt->str_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -536,21 +529,21 @@ int object_mod(PCMHI_OBJECT pObj, POBJECT_K pObjK)
|
||||||
switch (g_objItem[p->obj_index].type / 10) {
|
switch (g_objItem[p->obj_index].type / 10) {
|
||||||
case OBJ_TYPE_SERVER:
|
case OBJ_TYPE_SERVER:
|
||||||
if (pSvr->str_val) {
|
if (pSvr->str_val) {
|
||||||
free(pSvr->str_val);
|
free((void *) pSvr->str_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OBJ_TYPE_ADDR:
|
case OBJ_TYPE_ADDR:
|
||||||
if (pAddr->str_val) {
|
if (pAddr->str_val) {
|
||||||
free(pAddr->str_val);
|
free((void *) pAddr->str_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OBJ_TYPE_DATETIME:
|
case OBJ_TYPE_DATETIME:
|
||||||
if (pDt->str_val) {
|
if (pDt->str_val) {
|
||||||
free(pDt->str_val);
|
free((void *) pDt->str_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -590,14 +583,7 @@ int object_mod(PCMHI_OBJECT pObj, POBJECT_K pObjK)
|
||||||
//first = strtoul(pStart, NULL, 10);
|
//first = strtoul(pStart, NULL, 10);
|
||||||
last = strtoul(pEnd, NULL, 10);
|
last = strtoul(pEnd, NULL, 10);
|
||||||
|
|
||||||
if(pSvr->pro_type <= PORT_UDP) {
|
|
||||||
//pSvr->min_port = htonl(first) & 0xFFFF;
|
|
||||||
pSvr->max_port = last;
|
pSvr->max_port = last;
|
||||||
} else {
|
|
||||||
//ICMP , min_port --> type, max_port --> code
|
|
||||||
//pSvr->min_port = first;
|
|
||||||
pSvr->max_port = last;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -1243,6 +1229,7 @@ static void test_str_time(char *pVal)
|
||||||
LOG_EX(LOG_Debug, "asctime: %s / %d\n", buf, mktime(&tm));
|
LOG_EX(LOG_Debug, "asctime: %s / %d\n", buf, mktime(&tm));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
static void test_random_string(char *pVal)
|
static void test_random_string(char *pVal)
|
||||||
{
|
{
|
||||||
int first;
|
int first;
|
||||||
|
@ -1263,20 +1250,22 @@ static void test_random_string(char *pVal)
|
||||||
free(pBuf);
|
free(pBuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void test_page_object(char *pVal)
|
static void test_page_object(char *pVal)
|
||||||
{
|
{
|
||||||
int i, ret;
|
int i, ret;
|
||||||
char **pStr;
|
|
||||||
PSPLIT_PAGE pPage;
|
PSPLIT_PAGE pPage;
|
||||||
PCMHI_OBJECT pObj;
|
PCMHI_OBJECT pObj;
|
||||||
const char *pRetJson;
|
const char *pRetJson;
|
||||||
IFC_RET_PAGE_MSG retCtx;
|
IFC_RET_PAGE_MSG retCtx;
|
||||||
char session[MAX_SESSION];
|
|
||||||
int iCount = 0;
|
int iCount = 0;
|
||||||
PIFACE_QUERY_LIST pQuery = NULL;
|
PIFACE_QUERY_LIST pQuery = NULL;
|
||||||
PJSON_INTERFACE p = NULL;
|
PJSON_INTERFACE p = NULL;
|
||||||
const char *pJson = read_json_file(QUERY_LIST_JS_FILE);
|
const char *pJson = read_json_file(QUERY_LIST_JS_FILE);
|
||||||
|
|
||||||
|
(void) pVal;
|
||||||
|
|
||||||
ret = Json2Struct(pJson, &p, JE_INTERFACE, FALSE);
|
ret = Json2Struct(pJson, &p, JE_INTERFACE, FALSE);
|
||||||
memset(&retCtx, 0, sizeof(IFC_RET_PAGE_MSG));
|
memset(&retCtx, 0, sizeof(IFC_RET_PAGE_MSG));
|
||||||
|
|
||||||
|
@ -1349,9 +1338,7 @@ static void test_page_object(char *pVal)
|
||||||
if (ret != RET_OK) {
|
if (ret != RET_OK) {
|
||||||
LOG_EX(LOG_Error, "object_split_page error: %d\n", ret);
|
LOG_EX(LOG_Error, "object_split_page error: %d\n", ret);
|
||||||
|
|
||||||
if(pQuery) {
|
|
||||||
free(pQuery);
|
free(pQuery);
|
||||||
}
|
|
||||||
|
|
||||||
if (p->msgContent) {
|
if (p->msgContent) {
|
||||||
free((void *) p->msgContent);
|
free((void *) p->msgContent);
|
||||||
|
@ -1380,9 +1367,7 @@ static void test_page_object(char *pVal)
|
||||||
if (pPage == NULL) {
|
if (pPage == NULL) {
|
||||||
LOG_EX(LOG_Debug, "Can't found session: %s\n", pQuery->session);
|
LOG_EX(LOG_Debug, "Can't found session: %s\n", pQuery->session);
|
||||||
|
|
||||||
if(pQuery) {
|
|
||||||
free(pQuery);
|
free(pQuery);
|
||||||
}
|
|
||||||
|
|
||||||
if (p->msgContent) {
|
if (p->msgContent) {
|
||||||
free((void *) p->msgContent);
|
free((void *) p->msgContent);
|
||||||
|
@ -1426,7 +1411,7 @@ static void test_page_object(char *pVal)
|
||||||
pPage->last_time = time(NULL);
|
pPage->last_time = time(NULL);
|
||||||
|
|
||||||
for (i = retCtx.start; i < pQuery->end && iCount < MAX_PAGE_ITEMS && iCount < retCtx.tolItems; i++) {
|
for (i = retCtx.start; i < pQuery->end && iCount < MAX_PAGE_ITEMS && iCount < retCtx.tolItems; i++) {
|
||||||
pStr = (char **)utarray_eltptr(pPage->name_list, i);
|
char **pStr = (char **) utarray_eltptr(pPage->name_list, i);
|
||||||
pthread_mutex_lock(&g_obj_lock);
|
pthread_mutex_lock(&g_obj_lock);
|
||||||
HASH_FIND_STR(g_pObject, *pStr, pObj);
|
HASH_FIND_STR(g_pObject, *pStr, pObj);
|
||||||
pthread_mutex_unlock(&g_obj_lock);
|
pthread_mutex_unlock(&g_obj_lock);
|
||||||
|
@ -1453,18 +1438,6 @@ static void test_page_object(char *pVal)
|
||||||
LOG_EX(LOG_Debug, "Respons:\n%s\n", pRetJson);
|
LOG_EX(LOG_Debug, "Respons:\n%s\n", pRetJson);
|
||||||
free((void *) pRetJson);
|
free((void *) pRetJson);
|
||||||
|
|
||||||
/* char **pStr;
|
|
||||||
int iCount = 0;
|
|
||||||
PSPLIT_PAGE p, pTmp;
|
|
||||||
test_add_object();
|
|
||||||
get_page_items("", 1, 30, 100); */
|
|
||||||
/* object_split_page("", 1);
|
|
||||||
HASH_ITER(hh, g_pSplitPage, p, pTmp) {
|
|
||||||
while((pStr = (char **)utarray_next(p->name_list, pStr))) {
|
|
||||||
LOG_EX(LOG_Debug, "%s[%03d]: %s\n", p->session, iCount++, *pStr);
|
|
||||||
}
|
|
||||||
} */
|
|
||||||
|
|
||||||
if (p->msgContent) {
|
if (p->msgContent) {
|
||||||
free((void *) p->msgContent);
|
free((void *) p->msgContent);
|
||||||
}
|
}
|
||||||
|
@ -1605,10 +1578,8 @@ static void test_detail_object(void)
|
||||||
|
|
||||||
static void test_search_object(char *pVal)
|
static void test_search_object(char *pVal)
|
||||||
{
|
{
|
||||||
int i, ret, size;
|
int i, ret;
|
||||||
PCMHI_OBJECT pObj, pTmp;
|
PCMHI_OBJECT pObj, pTmp;
|
||||||
char **pStr;
|
|
||||||
PSPLIT_PAGE pPage;
|
|
||||||
char regex_str[MAX_REGEX_LEN];
|
char regex_str[MAX_REGEX_LEN];
|
||||||
IFC_RET_PAGE_MSG retCtx;
|
IFC_RET_PAGE_MSG retCtx;
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
@ -1618,6 +1589,9 @@ static void test_search_object(char *pVal)
|
||||||
int sess_type = OBJ_TYPE_MAX;
|
int sess_type = OBJ_TYPE_MAX;
|
||||||
PSPLIT_PAGE pNew = (PSPLIT_PAGE) malloc(sizeof(SPLIT_PAGE));
|
PSPLIT_PAGE pNew = (PSPLIT_PAGE) malloc(sizeof(SPLIT_PAGE));
|
||||||
const char *pJson = read_json_file(SEARCH_JS_FILE);
|
const char *pJson = read_json_file(SEARCH_JS_FILE);
|
||||||
|
|
||||||
|
(void) pVal;
|
||||||
|
|
||||||
ret = Json2Struct(pJson, &p, JE_INTERFACE, FALSE);
|
ret = Json2Struct(pJson, &p, JE_INTERFACE, FALSE);
|
||||||
memset(&retCtx, 0, sizeof(IFC_RET_PAGE_MSG));
|
memset(&retCtx, 0, sizeof(IFC_RET_PAGE_MSG));
|
||||||
|
|
||||||
|
@ -1749,7 +1723,7 @@ static void test_search_object(char *pVal)
|
||||||
pthread_mutex_unlock(&g_obj_lock);
|
pthread_mutex_unlock(&g_obj_lock);
|
||||||
|
|
||||||
if (retCtx.tolItems > MAX_PAGE_ITEMS) {
|
if (retCtx.tolItems > MAX_PAGE_ITEMS) {
|
||||||
random_string(pNew->session, MAX_SESSION - 1);
|
create_session((unsigned char *) pNew->session, MAX_SESSION - 1);
|
||||||
HASH_ADD_STR(g_pSplitPage, session, pNew);
|
HASH_ADD_STR(g_pSplitPage, session, pNew);
|
||||||
retCtx.session = pNew->session;
|
retCtx.session = pNew->session;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1794,6 +1768,23 @@ static void test_search_object(char *pVal)
|
||||||
free((void *) pJson);
|
free((void *) pJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_configm_object(char* pVal)
|
||||||
|
{
|
||||||
|
char* output = NULL;
|
||||||
|
int output_len;
|
||||||
|
int cmd = strtoul(pVal, 0, 10);
|
||||||
|
const char *pJson = read_json_file(SEARCH_JS_FILE);
|
||||||
|
|
||||||
|
web_config_exec_sync(cmd, OBJECT_CONFIG,
|
||||||
|
(void*)pJson, strlen(pJson) + 1, &output, &output_len);
|
||||||
|
|
||||||
|
if(output) {
|
||||||
|
free(output);
|
||||||
|
}
|
||||||
|
|
||||||
|
free((void*)pJson);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 应用程序主函数
|
* @brief 应用程序主函数
|
||||||
* @param argc 输入参数个数
|
* @param argc 输入参数个数
|
||||||
|
@ -1815,6 +1806,7 @@ int main(int argc, char **argv)
|
||||||
{"page_split", optional_argument, NULL, 'f'},
|
{"page_split", optional_argument, NULL, 'f'},
|
||||||
{"detail", optional_argument, NULL, 'g'},
|
{"detail", optional_argument, NULL, 'g'},
|
||||||
{"search", optional_argument, NULL, 'i'},
|
{"search", optional_argument, NULL, 'i'},
|
||||||
|
{"config", optional_argument, NULL, 'j'},
|
||||||
{NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
IHW_InitLOG("obj", NULL, TRUE);
|
IHW_InitLOG("obj", NULL, TRUE);
|
||||||
|
@ -1828,7 +1820,7 @@ int main(int argc, char **argv)
|
||||||
LOG_EX(LOG_Debug, "SVR_OBJECT = %u bytes\n", sizeof(SVR_OBJECT) * MAX_OBJ_CONTENT);
|
LOG_EX(LOG_Debug, "SVR_OBJECT = %u bytes\n", sizeof(SVR_OBJECT) * MAX_OBJ_CONTENT);
|
||||||
LOG_EX(LOG_Debug, "ADDR_OBJECT = %u bytes\n", sizeof(ADDR_OBJECT) * MAX_OBJ_CONTENT);
|
LOG_EX(LOG_Debug, "ADDR_OBJECT = %u bytes\n", sizeof(ADDR_OBJECT) * MAX_OBJ_CONTENT);
|
||||||
|
|
||||||
while((c = getopt_long(argc, argv, "ab:c:d:e:f::i::ghv", long_opts, &optidx)) != -1) {
|
while ((c = getopt_long(argc, argv, "ab:c:d:e:f::i::j::ghv", long_opts, &optidx)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'v':
|
case 'v':
|
||||||
LOG_EX(LOG_Info, "User demo version: %s(%s)\n", sGATE_GIT_TAGS, sGATE_GIT_VERS);
|
LOG_EX(LOG_Info, "User demo version: %s(%s)\n", sGATE_GIT_TAGS, sGATE_GIT_VERS);
|
||||||
|
@ -1846,8 +1838,8 @@ int main(int argc, char **argv)
|
||||||
//TODO 添加其它必要处理参数过程
|
//TODO 添加其它必要处理参数过程
|
||||||
case 'a':
|
case 'a':
|
||||||
test_add_object();
|
test_add_object();
|
||||||
//test_del_object();
|
test_del_object();
|
||||||
//test_mod_object();
|
test_mod_object();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'b':
|
case 'b':
|
||||||
|
@ -1880,6 +1872,11 @@ int main(int argc, char **argv)
|
||||||
test_add_object();
|
test_add_object();
|
||||||
test_search_object(optarg);
|
test_search_object(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case 'j':
|
||||||
|
test_configm_object(optarg);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue