Initial commit
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
|
||||
LICENSE = "CLOSED"
|
||||
SRC_URI += " \
|
||||
file://cJSON.c \
|
||||
file://cJSON.h \
|
||||
file://lux_json_api.c \
|
||||
file://lux_json_api.h \
|
||||
file://lux_system_api.c \
|
||||
file://lux_system_api.h \
|
||||
file://cover_heat.c \
|
||||
file://cover_heat.h \
|
||||
file://lux_base.h \
|
||||
file://cover_heat.json \
|
||||
file://cover_heat_12fan.json \
|
||||
file://CMakeLists.txt "
|
||||
|
||||
S = "${WORKDIR}"
|
||||
TARGET_CC_ARCH += "${LDFLAGS}"
|
||||
DEPENDS += "systemd dbus"
|
||||
inherit pkgconfig cmake obmc-phosphor-systemd
|
||||
SYSTEMD_SERVICE:${PN} = "cover-heat.service "
|
||||
@@ -0,0 +1,19 @@
|
||||
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
|
||||
|
||||
inherit obmc-phosphor-systemd
|
||||
|
||||
SRC_URI += "file://cover-heat.service \
|
||||
file://cover-heat.sh \
|
||||
"
|
||||
|
||||
SYSTEMD_SERVICE_${PN} = "cover-heat.service"
|
||||
|
||||
do_install:append() {
|
||||
# deal with systemd unit files
|
||||
|
||||
install -d ${D}${systemd_unitdir}/system
|
||||
install -m 0755 ${WORKDIR}/cover-heat.sh ${D}${bindir}/cover-heat.sh
|
||||
install -m 0644 ${WORKDIR}/cover-heat.service ${D}${systemd_unitdir}/system
|
||||
}
|
||||
|
||||
FILES_${PN} += "${systemd_unitdir}/system/cover-heat.service"
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project(cover_heat)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(SYSTEMD REQUIRED libsystemd)
|
||||
pkg_check_modules(DBUS REQUIRED dbus-1)
|
||||
aux_source_directory(. SRC)
|
||||
add_executable(${CMAKE_PROJECT_NAME} ${SRC})
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE ${DBUS_LIBRARIES})
|
||||
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${DBUS_INCLUDE_DIRS})
|
||||
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${SYSTEMD_INCLUDE_DIRS})
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE ${SYSTEMD_LIBRARIES})
|
||||
install(TARGETS ${CMAKE_PROJECT_NAME} RUNTIME DESTINATION bin)
|
||||
install(FILES cover_heat.json DESTINATION bin)
|
||||
install(FILES cover_heat_12fan.json DESTINATION bin)
|
||||
install(FILES cover-heat.sh DESTINATION bin)
|
||||
@@ -0,0 +1,13 @@
|
||||
CFLAGS += -Wall
|
||||
OBJS = cover_heat.o cJSON.o lux_json_api.o lux_system_api.o
|
||||
EXE = cover_heat
|
||||
.c.o:
|
||||
$(CC) -c $<
|
||||
$(EXE): $(OBJS)
|
||||
$(CC) $(OBJS) -o $@
|
||||
all:$(EXE)
|
||||
clean:
|
||||
rm -f $(EXE) $(OBJS)
|
||||
install:
|
||||
cp $(EXE) $(INSTALL_DIR)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,292 @@
|
||||
/*
|
||||
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
|
||||
|
||||
pPermission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
#ifndef cJSON__h
|
||||
#define cJSON__h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32))
|
||||
#define __WINDOWS__
|
||||
#endif
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
|
||||
/* When compiling for windows, we specify a specific calling convention to avoid issues where we are being called from a project with a different default calling convention. For windows you have 3 define options:
|
||||
|
||||
CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever dllexport symbols
|
||||
CJSON_EXPORT_SYMBOLS - Define this on library build when you want to dllexport symbols (default)
|
||||
CJSON_IMPORT_SYMBOLS - Define this if you want to dllimport symbol
|
||||
|
||||
For *nix builds that support visibility attribute, you can define similar behavior by
|
||||
|
||||
setting default visibility to hidden by adding
|
||||
-fvisibility=hidden (for gcc)
|
||||
or
|
||||
-xldscope=hidden (for sun cc)
|
||||
to CFLAGS
|
||||
|
||||
then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJSON_EXPORT_SYMBOLS does
|
||||
|
||||
*/
|
||||
|
||||
#define CJSON_CDECL __cdecl
|
||||
#define CJSON_STDCALL __stdcall
|
||||
|
||||
/* export symbols by default, this is necessary for copy pasting the C and header file */
|
||||
#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS)
|
||||
#define CJSON_EXPORT_SYMBOLS
|
||||
#endif
|
||||
|
||||
#if defined(CJSON_HIDE_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) type CJSON_STDCALL
|
||||
#elif defined(CJSON_EXPORT_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) __declspec(dllexport) type CJSON_STDCALL
|
||||
#elif defined(CJSON_IMPORT_SYMBOLS)
|
||||
#define CJSON_PUBLIC(type) __declspec(dllimport) type CJSON_STDCALL
|
||||
#endif
|
||||
#else /* !__WINDOWS__ */
|
||||
#define CJSON_CDECL
|
||||
#define CJSON_STDCALL
|
||||
|
||||
#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY)
|
||||
#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type
|
||||
#else
|
||||
#define CJSON_PUBLIC(type) type
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* project version */
|
||||
#define CJSON_VERSION_MAJOR 1
|
||||
#define CJSON_VERSION_MINOR 7
|
||||
#define CJSON_VERSION_PATCH 14
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/* cJSON Types: */
|
||||
#define cJSON_Invalid (0)
|
||||
#define cJSON_False (1 << 0)
|
||||
#define cJSON_True (1 << 1)
|
||||
#define cJSON_NULL (1 << 2)
|
||||
#define cJSON_Number (1 << 3)
|
||||
#define cJSON_String (1 << 4)
|
||||
#define cJSON_Array (1 << 5)
|
||||
#define cJSON_Object (1 << 6)
|
||||
#define cJSON_Raw (1 << 7) /* raw json */
|
||||
|
||||
#define cJSON_IsReference 256
|
||||
#define cJSON_StringIsConst 512
|
||||
|
||||
/* The cJSON structure: */
|
||||
typedef struct cJSON
|
||||
{
|
||||
/* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
|
||||
struct cJSON *next;
|
||||
struct cJSON *prev;
|
||||
/* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
|
||||
struct cJSON *child;
|
||||
|
||||
/* The type of the item, as above. */
|
||||
int type;
|
||||
|
||||
/* The item's string, if type==cJSON_String and type == cJSON_Raw */
|
||||
char *valuestring;
|
||||
/* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */
|
||||
int valueint;
|
||||
/* The item's number, if type==cJSON_Number */
|
||||
double valuedouble;
|
||||
|
||||
/* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
|
||||
char *string;
|
||||
} cJSON;
|
||||
|
||||
typedef struct cJSON_Hooks
|
||||
{
|
||||
/* malloc/free are CDECL on Windows regardless of the default calling convention of the compiler, so ensure the hooks allow passing those functions directly. */
|
||||
void *(CJSON_CDECL *malloc_fn)(size_t sz);
|
||||
void (CJSON_CDECL *free_fn)(void *ptr);
|
||||
} cJSON_Hooks;
|
||||
|
||||
typedef int cJSON_bool;
|
||||
|
||||
/* Limits how deeply nested arrays/objects can be before cJSON rejects to parse them.
|
||||
* This is to prevent stack overflows. */
|
||||
#ifndef CJSON_NESTING_LIMIT
|
||||
#define CJSON_NESTING_LIMIT 1000
|
||||
#endif
|
||||
|
||||
/* returns the version of cJSON as a string */
|
||||
CJSON_PUBLIC(const char*) cJSON_Version(void);
|
||||
|
||||
/* Supply malloc, realloc and free functions to cJSON */
|
||||
CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks);
|
||||
|
||||
/* Memory Management: the caller is always responsible to free the results from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. */
|
||||
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_ParseWithLength(const char *value, size_t buffer_length);
|
||||
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
|
||||
/* If you supply a ptr in return_parse_end and parsing fails, then return_parse_end will contain a pointer to the error so will match cJSON_GetErrorPtr(). */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer_length, const char **return_parse_end, cJSON_bool require_null_terminated);
|
||||
|
||||
/* Render a cJSON entity to text for transfer/storage. */
|
||||
CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item);
|
||||
/* Render a cJSON entity to text for transfer/storage without any formatting. */
|
||||
CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item);
|
||||
/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */
|
||||
CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt);
|
||||
/* Render a cJSON entity to text using a buffer already allocated in memory with given length. Returns 1 on success and 0 on failure. */
|
||||
/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will use, so to be safe allocate 5 bytes more than you actually need */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format);
|
||||
/* Delete a cJSON entity and all subentities. */
|
||||
CJSON_PUBLIC(void) cJSON_Delete(cJSON *item);
|
||||
|
||||
/* Returns the number of items in an array (or object). */
|
||||
CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array);
|
||||
/* Retrieve item number "index" from array "array". Returns NULL if unsuccessful. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index);
|
||||
/* Get item "string" from object. Case insensitive. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string);
|
||||
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
|
||||
CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void);
|
||||
|
||||
/* Check item type and return its value */
|
||||
CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item);
|
||||
CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item);
|
||||
|
||||
/* These functions check the type of an item */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item);
|
||||
|
||||
/* These calls create a cJSON item of the appropriate type. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string);
|
||||
/* raw json */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void);
|
||||
|
||||
/* Create a string where valuestring references a string so
|
||||
* it will not be freed by cJSON_Delete */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string);
|
||||
/* Create an object/array that only references it's elements so
|
||||
* they will not be freed by cJSON_Delete */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child);
|
||||
|
||||
/* These utilities create an Array of count items.
|
||||
* The parameter count cannot be greater than the number of elements in the number array, otherwise array access will be out of bounds.*/
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count);
|
||||
|
||||
/* Append item to the specified array/object. */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item);
|
||||
/* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object.
|
||||
* WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst) is zero before
|
||||
* writing to `item->string` */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item);
|
||||
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item);
|
||||
|
||||
/* Remove/Detach items from Arrays/Objects. */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which);
|
||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string);
|
||||
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string);
|
||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string);
|
||||
CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string);
|
||||
|
||||
/* Update array items. */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem);
|
||||
|
||||
/* Duplicate a cJSON item */
|
||||
CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse);
|
||||
/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
|
||||
* need to be released. With recurse!=0, it will duplicate any children connected to the item.
|
||||
* The item->next and ->prev pointers are always zero on return from Duplicate. */
|
||||
/* Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal.
|
||||
* case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */
|
||||
CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive);
|
||||
|
||||
/* Minify a strings, remove blank characters(such as ' ', '\t', '\r', '\n') from strings.
|
||||
* The input pointer json cannot point to a read-only address area, such as a string constant,
|
||||
* but should point to a readable and writable adress area. */
|
||||
CJSON_PUBLIC(void) cJSON_Minify(char *json);
|
||||
|
||||
/* Helper functions for creating and adding items to an object at the same time.
|
||||
* They return the added item or NULL on failure. */
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name);
|
||||
CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name);
|
||||
|
||||
/* When assigning an integer value, it needs to be propagated to valuedouble too. */
|
||||
#define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number))
|
||||
/* helper for the cJSON_SetNumberValue macro */
|
||||
CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number);
|
||||
#define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number))
|
||||
/* Change the valuestring of a cJSON_String object, only takes effect when type of object is cJSON_String */
|
||||
CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring);
|
||||
|
||||
/* Macro for iterating over an array or object */
|
||||
#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
|
||||
|
||||
/* malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks */
|
||||
CJSON_PUBLIC(void *) cJSON_malloc(size_t size);
|
||||
CJSON_PUBLIC(void) cJSON_free(void *object);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
[Unit]
|
||||
Description=Oem Cover Heat Service
|
||||
Requires=xyz.openbmc_project.EntityManager.service
|
||||
After=xyz.openbmc_project.EntityManager.service
|
||||
|
||||
[Service]
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
ExecStart=/usr/bin/cover-heat.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
#start cover heat logic
|
||||
/usr/bin/cover_heat
|
||||
+2437
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,355 @@
|
||||
#ifndef DIMM_FSC_H
|
||||
#define DIMM_FSC_H
|
||||
|
||||
#define DIMM_FSC_VERSION "V0.1"
|
||||
#define FAN_TABLE_PATH "/usr/bin/cover_heat.json"
|
||||
#define COVER_MANUAL_CONTROL_FLAG "/tmp/cover_manual"
|
||||
#define COVER_MANUAL_CONTROL_VALUE "/tmp/cover_manual_value"
|
||||
|
||||
//define for thermal oem command
|
||||
#define DIMM_SETPOINT_PATH "/tmp/dimm_setpoint"
|
||||
#define COVER_SETPOINT_PATH "/tmp/cover_setpoint"
|
||||
#define COVER_STATUS_PATH "/tmp/cover_status"
|
||||
#define FSC_ENABLE_STATUS_PATH "/tmp/fsc_enable"
|
||||
|
||||
#define SETPOINT_CONSTANT "constant"
|
||||
#define SETPOINT_VARIABLE "variable"
|
||||
|
||||
#define MAX_FSC_PWM_CHANNEL 24
|
||||
#define MAX_DIMM_SLOT 24
|
||||
#define MAX_JSON_CHARACTER_SIZE 128
|
||||
#define MAX_SENSOR_NAME_LENGTH 16
|
||||
#define MAX_KEY_LENGTH 32
|
||||
#define PWM_POWER_ON_IN_SHORT_TIME 80
|
||||
#define MAX_PWM_THERMAL_DEFINE 100
|
||||
#define MIN_PWM_THERMAL_DEFINE 1
|
||||
#define MAX_OL_SENSOR 10
|
||||
#define MAX_OL_SENSOR_STEPS 50
|
||||
#define MAX_CL_SENSOR 50
|
||||
#define MAX_FAN_COUNT 20
|
||||
#define MAX_SETPOINT_CASE 10
|
||||
#define MAX_SENSOR_E_SECTION 12
|
||||
#define MAX_SENSOR_EC_SECTION 9
|
||||
#define MAX_ABNORMAL_SENSOR 50
|
||||
#define MAX_FAN_AVERAGE_COUNT 10
|
||||
#define PID_INIT_PWM 50
|
||||
#define SENSOR_REAL_VALUE_INITIAL 127 /*init sensor reading to 127, sign value */
|
||||
#define POWERON_FSC_DELAY 10
|
||||
#define INLET_SENSOR_VALUE_ABNORMAL_STATE 35 /*if inlet sensor is can't read, need use 35 do fsc control */
|
||||
|
||||
#define SENSOR_UPPER_NON_CRITICAL_PWM 80
|
||||
#define SENSOR_UPPER_CRITICAL_PWM 90
|
||||
#define SENSOR_UPPER_NON_RECOVERABLE_PWM 100
|
||||
|
||||
#define MAX_READING_CACHE 10
|
||||
#define READING_INVALID 0
|
||||
#define READING_VALID 1
|
||||
|
||||
#define FCB_I2C_BUS 7
|
||||
#define FCB_CPLD_SLAVE_ADDR 0x7c
|
||||
#define FCB_TMP468_ADDR 0x90
|
||||
|
||||
#define DIMM_HEAT_TURN_OFF 0
|
||||
#define DIMM_HEAT_TURN_ON 1
|
||||
|
||||
#define COVER_PRE_HEAT_TEMP 20
|
||||
|
||||
#define DIMM_FAN_MIN_PWM 37
|
||||
|
||||
#define PTC_PRE_HEAT_MAX_PWM 80
|
||||
#define PTC_PRE_HEAT_MIN_PWM 0
|
||||
#define PTC_PRE_HEAT_PWM 80
|
||||
#define PTC_HEAT_MAX_PWM 100
|
||||
|
||||
typedef struct
|
||||
{
|
||||
INT8U u8DIMMIndex;
|
||||
INT8U u16Reg;
|
||||
}__attribute__ ((packed))SFscFanReg;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
INT8U u8DIMMIndex;
|
||||
INT8U u16Reg;
|
||||
}__attribute__ ((packed))SFscHeatReg;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
INT8U u8DIMMIndex;
|
||||
char acDbusPath[256];
|
||||
}__attribute__ ((packed))SDIMMDbus;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
REG_FCB_CPLD_FAN_QUANTITY = 0x0006,
|
||||
REG_FCB_GET_HEAT_COVER_STATUS = 0x0037,
|
||||
REG_FCB_DIMM_INITIAL_PWM = 0x0051,
|
||||
REG_FCB_DIMM0_SET_PWM = 0x0052,
|
||||
REG_FCB_DIMM1_SET_PWM = 0x0053,
|
||||
REG_FCB_DIMM2_SET_PWM = 0x0054,
|
||||
REG_FCB_DIMM3_SET_PWM = 0x0055,
|
||||
REG_FCB_DIMM4_SET_PWM = 0x0056,
|
||||
REG_FCB_DIMM5_SET_PWM = 0x0057,
|
||||
REG_FCB_DIMM6_SET_PWM = 0x0058,
|
||||
REG_FCB_DIMM7_SET_PWM = 0x0059,
|
||||
REG_FCB_DIMM8_SET_PWM = 0x005a,
|
||||
REG_FCB_DIMM9_SET_PWM = 0x005b,
|
||||
REG_FCB_DIMM10_SET_PWM = 0x005c,
|
||||
REG_FCB_DIMM11_SET_PWM = 0x005d,
|
||||
REG_FCB_DIMM12_SET_PWM = 0x005e,
|
||||
REG_FCB_DIMM13_SET_PWM = 0x005f,
|
||||
REG_FCB_DIMM14_SET_PWM = 0x0060,
|
||||
REG_FCB_DIMM15_SET_PWM = 0x0061,
|
||||
REG_FCB_DIMM16_SET_PWM = 0x0062,
|
||||
REG_FCB_DIMM17_SET_PWM = 0x0063,
|
||||
REG_FCB_DIMM18_SET_PWM = 0x0064,
|
||||
REG_FCB_DIMM19_SET_PWM = 0x0065,
|
||||
REG_FCB_DIMM20_SET_PWM = 0x0066,
|
||||
REG_FCB_DIMM21_SET_PWM = 0x0067,
|
||||
REG_FCB_DIMM22_SET_PWM = 0x0068,
|
||||
REG_FCB_DIMM23_SET_PWM = 0x0069,
|
||||
REG_FCB_PTC_INITIAL_PWM = 0x0075,
|
||||
REG_FCB_PTC_DIMM23_SET_PWM = 0x0076,
|
||||
REG_FCB_PTC_DIMM22_SET_PWM = 0x0077,
|
||||
REG_FCB_PTC_DIMM21_SET_PWM = 0x0078,
|
||||
REG_FCB_PTC_DIMM20_SET_PWM = 0x0079,
|
||||
REG_FCB_PTC_DIMM19_SET_PWM = 0x007a,
|
||||
REG_FCB_PTC_DIMM18_SET_PWM = 0x007b,
|
||||
REG_FCB_PTC_DIMM17_SET_PWM = 0x007c,
|
||||
REG_FCB_PTC_DIMM16_SET_PWM = 0x007d,
|
||||
REG_FCB_PTC_DIMM15_SET_PWM = 0x007e,
|
||||
REG_FCB_PTC_DIMM14_SET_PWM = 0x007f,
|
||||
REG_FCB_PTC_DIMM13_SET_PWM = 0x0080,
|
||||
REG_FCB_PTC_DIMM12_SET_PWM = 0x0081,
|
||||
REG_FCB_PTC_DIMM11_SET_PWM = 0x0082,
|
||||
REG_FCB_PTC_DIMM10_SET_PWM = 0x0083,
|
||||
REG_FCB_PTC_DIMM9_SET_PWM = 0x0084,
|
||||
REG_FCB_PTC_DIMM8_SET_PWM = 0x0085,
|
||||
REG_FCB_PTC_DIMM7_SET_PWM = 0x0086,
|
||||
REG_FCB_PTC_DIMM6_SET_PWM = 0x0087,
|
||||
REG_FCB_PTC_DIMM5_SET_PWM = 0x0088,
|
||||
REG_FCB_PTC_DIMM4_SET_PWM = 0x0089,
|
||||
REG_FCB_PTC_DIMM3_SET_PWM = 0x008a,
|
||||
REG_FCB_PTC_DIMM2_SET_PWM = 0x008b,
|
||||
REG_FCB_PTC_DIMM1_SET_PWM = 0x008c,
|
||||
REG_FCB_PTC_DIMM0_SET_PWM = 0x008d,
|
||||
REG_FCB_SET_HEAT_COVER_STATUS = 0x008e,
|
||||
|
||||
|
||||
}EUbbPriCPLDReg;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
/*Power good status*/
|
||||
PS_GOOD_FAIL=0,
|
||||
PS_GOOD_OK,
|
||||
|
||||
/*Update flag */
|
||||
FSC_FAN_TABLE_NORMAL = 0,
|
||||
FSC_FAN_TABLE_UPDATE = 1,
|
||||
|
||||
/*Fan table load status flag */
|
||||
FSC_FAN_TABLE_LOAD_FAIL = 0,
|
||||
FSC_FAN_TABLE_LOAD_SUCCESS = 1,
|
||||
|
||||
/*Control mode*/
|
||||
FSC_FAN_TABLE_AUTO = 0,
|
||||
FSC_FAN_TABLE_MANUAL = 1,
|
||||
|
||||
/*Sensor present */
|
||||
FSC_SENSOR_NOT_PRESENT = 0,
|
||||
FSC_SENSOR_PRESENT = 1,
|
||||
|
||||
/*Sensor present */
|
||||
FSC_SENSOR_NORMAL = 0,
|
||||
FSC_SENSOR_ABNORMAL = 1,
|
||||
|
||||
/*Fan type */
|
||||
FSC_FAN_TYPE_SINGLE = 0,
|
||||
FSC_FAN_TYPE_TWIN = 1,
|
||||
|
||||
/*Fan status */
|
||||
FSC_FAN_NORMAL = 0,
|
||||
FSC_FAN_FAIL = 1,
|
||||
|
||||
/*Fsc work when dc off */
|
||||
FSC_WORK_DC_ON_ONLY = 0,
|
||||
FSC_WORK_DC_OFF = 1,
|
||||
|
||||
/*Fan fail handle type */
|
||||
FSC_ABNORMAL_POLICY_UNUSED = 0,
|
||||
FSC_ABNORMAL_POLICY_INCREASE = 1,
|
||||
FSC_ABNORMAL_POLICY_CONSTANT = 2,
|
||||
|
||||
/*FSC normal or abnormal */
|
||||
FSC_NORMAL = 0,
|
||||
FSC_ABNORMAL = 1,
|
||||
|
||||
/*Thermal debug */
|
||||
FSC_NO_THERMAL_DEBUG = 0,
|
||||
FSC_OPEN_THERMAL_DEBUG = 1,
|
||||
|
||||
}EFscFlag;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char acProject[MAX_KEY_LENGTH];
|
||||
char acCustomer[MAX_KEY_LENGTH];
|
||||
char acVersion[MAX_KEY_LENGTH];
|
||||
char acPlatform[MAX_KEY_LENGTH];
|
||||
}__attribute__ ((packed))SFscHeader;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
INT8U u8MaxReadingCache;
|
||||
INT16U u16Elevation;
|
||||
char acFanType[MAX_KEY_LENGTH];
|
||||
char acWorkDCOff[MAX_KEY_LENGTH];
|
||||
}__attribute__ ((packed))SFscGlobalConfig;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
INT8U u8MaxPwmNum;
|
||||
INT8U u8MaxFanNum;
|
||||
INT8U u8FanSensorNumPWMMatch[MAX_FAN_COUNT];
|
||||
INT8U u8MaxFanDuty;
|
||||
INT8U u8MinFanDuty;
|
||||
}__attribute__ ((packed))SFscFanConfig;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char acCLSensorType[MAX_KEY_LENGTH];
|
||||
char acCLSensorStatus[MAX_KEY_LENGTH];
|
||||
INT8U u8DT;
|
||||
char acSensorName[MAX_SENSOR_NAME_LENGTH + 1];
|
||||
INT8S s8VendorSpec;
|
||||
INT8S s8CustomerSpec;
|
||||
char acSetpointType[MAX_KEY_LENGTH];
|
||||
INT8S s8SetpointDefault;
|
||||
char acSetpointCase[MAX_SETPOINT_CASE][MAX_KEY_LENGTH];
|
||||
INT8S as8SetpointValue[MAX_SETPOINT_CASE];
|
||||
char acSetpointCaseUse[MAX_KEY_LENGTH];
|
||||
INT8U au8FanWeight[MAX_FSC_PWM_CHANNEL];
|
||||
INT8U u8Hysteresis;
|
||||
INT8S as8EValue[MAX_SENSOR_E_SECTION-1];
|
||||
INT8S as8ECValue[MAX_SENSOR_EC_SECTION-1];
|
||||
float afPValue[MAX_SENSOR_EC_SECTION][MAX_SENSOR_E_SECTION];
|
||||
float afIValue[MAX_SENSOR_EC_SECTION][MAX_SENSOR_E_SECTION];
|
||||
float afDValue[MAX_SENSOR_EC_SECTION][MAX_SENSOR_E_SECTION];
|
||||
|
||||
INT8U u8SensorNumber;
|
||||
INT8S s8Setpoint;
|
||||
INT8S as8RealValue[MAX_READING_CACHE];
|
||||
float fP;
|
||||
float fI;
|
||||
float fD;
|
||||
INT8U u8SensorSDRPresent; /*sensor sdr present flag, 1 - present, 0 - not present*/
|
||||
INT8U u8Present; /*sensor present flag, 1 - present, 0 - not present*/
|
||||
INT8U u8Abnormal; /*sensor health flag, 1 - abnormal, 0 - normal*/
|
||||
INT8U u8Health; /*sensor reading value status*/
|
||||
INT8U u8NoReadingTries;
|
||||
INT8U u8SensorStatus;
|
||||
/* Event Flags description */
|
||||
/* Bit 0 - Initialization Done */
|
||||
/* Bit 1 - Update in Progress */
|
||||
/* Bit 2 - reserved */
|
||||
/* Bit 3 - reserved */
|
||||
/* Bit 4 - reserved */
|
||||
/* Bit 5 - Unable to read */
|
||||
/* Bit 6 - Sensor Scanning disabled */
|
||||
/* Bit 7 - Event Message Disabled */
|
||||
|
||||
INT32U u32CalculateTick;
|
||||
INT8U u8PwmPIDCalculate;
|
||||
INT16S s16LastPwmPIDCalculate;
|
||||
float fPIncrement;
|
||||
float fIIncrement;
|
||||
float fDIncrement;
|
||||
INT8U u8PwmAfterWeighting[MAX_FSC_PWM_CHANNEL];
|
||||
INT8U u8PwmAfterWeightingCache[MAX_FSC_PWM_CHANNEL][MAX_FAN_AVERAGE_COUNT];
|
||||
INT8U u8PwmAfterHysteresis[MAX_FSC_PWM_CHANNEL];
|
||||
INT8U u8SensorNoReading;
|
||||
}__attribute__ ((packed))SFscCLSensorInfo;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
INT8U u8MaxCLSensor;
|
||||
INT8U u8TotalCLSensor;
|
||||
char acPIDAdjustMethod[MAX_KEY_LENGTH];
|
||||
INT8U u8CLSensorESection;
|
||||
INT8U u8CLSensorECSection;
|
||||
INT8U u8CLSensorSetpointMaxCase;
|
||||
SFscCLSensorInfo asFscCLSensorInfo[MAX_CL_SENSOR];
|
||||
}__attribute__ ((packed))SFscCLSensor;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
INT8U u8FanSensorNumberStart;
|
||||
char acFanFailSingle[MAX_KEY_LENGTH];
|
||||
INT8U u8FanFailTwin1;
|
||||
INT8U u8FanFailTwin2Diff;
|
||||
char acFanFailTwin2Same[MAX_KEY_LENGTH];
|
||||
|
||||
/*fan status: 0 - normal, 1 - abnormal */
|
||||
INT8U au8FanStatus[MAX_FAN_COUNT];
|
||||
INT8U au8FanFailPwm[MAX_FSC_PWM_CHANNEL];
|
||||
INT8U au8FanFailConstantPwm;
|
||||
INT8U u8FanFailHandleType;
|
||||
}__attribute__ ((packed))SFscFanFail;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char acSensorName[MAX_SENSOR_NAME_LENGTH];
|
||||
char acFailPolicy[MAX_KEY_LENGTH];
|
||||
INT8U u8FailValue;
|
||||
|
||||
INT8U u8SensorFailHandleType;
|
||||
INT8U u8SensorFailPwmOut;
|
||||
}__attribute__ ((packed))SFscSensorFailInfo;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
INT8U u8MaxAbnormalSensor;
|
||||
INT8U u8TotalAbnormalSensor;
|
||||
SFscFanFail sFscFanFail;
|
||||
SFscSensorFailInfo asFscSensorFailInfo[MAX_ABNORMAL_SENSOR];
|
||||
}__attribute__ ((packed))SFscAbnormalEvent;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
INT8U u8UpdateFlag; /*1 - update, 0 - normal */
|
||||
INT8U u8FanTableLoadStatus; /*1 - success, 0 - fail */
|
||||
INT8U u8ControlMode; /*1 - manual, 0 - auto */
|
||||
INT8U u8ThermalDebug; /*thermal debug falg, 0 - no debug, 1 - debuging */
|
||||
INT8U u8WorkDCOff; /*1 - work when dc off, 0 - no work when dc off */
|
||||
INT8U u8LoadTableTries;
|
||||
INT32U u32Tick;
|
||||
INT8U u8SKUID;
|
||||
INT8U u8MaxOLPwm;
|
||||
INT8U au8CLPwm[MAX_FSC_PWM_CHANNEL];
|
||||
INT8U au8MaxAbnormalPwm;
|
||||
INT8U au8MaxAbnormalIncreasePwm;
|
||||
char acFactorSensorName[16];
|
||||
INT8U u8FactorPwm;
|
||||
INT8U u8FscStatus; /*0 - normal fsc, 1 - abnormal fsc */
|
||||
INT8U au8PwmOut[MAX_FSC_PWM_CHANNEL];
|
||||
INT8U au8ManualPwmOut[MAX_FSC_PWM_CHANNEL];
|
||||
INT8U u8MaxCoverTemp;
|
||||
}__attribute__ ((packed))SFscRunningInfo;
|
||||
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SFscHeader sFSCHeader;
|
||||
SFscGlobalConfig sFscGlobalConfig;
|
||||
SFscFanConfig sFscFanConfig;
|
||||
SFscCLSensor sFscCLSensor;
|
||||
SFscAbnormalEvent sFscAbnormalEvent;
|
||||
SFscRunningInfo sFscRunningInfo;
|
||||
}__attribute__ ((packed))SFscInfo;
|
||||
|
||||
#endif
|
||||
+1227
File diff suppressed because it is too large
Load Diff
+1227
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,712 @@
|
||||
/***********************************************************
|
||||
* Copyright (C), 2021, LuxShare co.,
|
||||
*
|
||||
* File name : lux_base
|
||||
*
|
||||
* Description :
|
||||
* base, include base typedef, base define, base enum
|
||||
*
|
||||
* History:
|
||||
*
|
||||
* <Date> <Author> <version> <Modification>
|
||||
* 2021/03/23 xxx 0.01 First draft
|
||||
***********************************************************/
|
||||
|
||||
#ifndef __LUX_BASE_H__
|
||||
#define __LUX_BASE_H__
|
||||
|
||||
/***********************************************************
|
||||
*
|
||||
* Base Include Zone
|
||||
*
|
||||
***********************************************************/
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <fcntl.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <semaphore.h>
|
||||
#include <mqueue.h>
|
||||
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/poll.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <net/if.h>
|
||||
#include <net/route.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <dirent.h>
|
||||
|
||||
|
||||
|
||||
/***********************************************************
|
||||
*
|
||||
* Base Typedef Zone
|
||||
*
|
||||
***********************************************************/
|
||||
typedef unsigned char INT8U;
|
||||
typedef unsigned short INT16U;
|
||||
typedef unsigned int INT32U;
|
||||
typedef signed char INT8S;
|
||||
typedef short INT16S;
|
||||
typedef long INT32S;
|
||||
|
||||
/***********************************************************
|
||||
*
|
||||
* Base Define Zone
|
||||
*
|
||||
***********************************************************/
|
||||
#define SHM_KEY "/LuxShare"
|
||||
|
||||
#define NV_SETTING_FILE "/conf/bmc.setting"
|
||||
|
||||
/*Queue Name Define*/
|
||||
#define QUEUE_NAME_BLOCK0 "QueueBlock0"
|
||||
#define QUEUE_NAME_BLOCK1 "QueueBlock1"
|
||||
#define QUEUE_NAME_BLOCK2 "QueueBlock2"
|
||||
#define QUEUE_NAME_REDIS_HANDLER "RedisHandler"
|
||||
|
||||
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
|
||||
|
||||
|
||||
#define PRINT printf
|
||||
#define SHOW_RUNNING PRINT("# %s Running ......\n", __FUNCTION__)
|
||||
|
||||
|
||||
#define ERROR_PRINT PRINT("[(%s)%04d]%s():", __FILE__, __LINE__, __FUNCTION__), PRINT
|
||||
#define NORMAL_PRINT PRINT("[(%s)%04d]%s():", __FILE__, __LINE__, __FUNCTION__), PRINT
|
||||
#define WARN_PRINT PRINT("[(%s)%04d]%s():", __FILE__, __LINE__, __FUNCTION__), PRINT
|
||||
#define DEBUG_PRINT PRINT("[(%s)%04d]%s():", __FILE__, __LINE__, __FUNCTION__), PRINT
|
||||
|
||||
|
||||
#define LUX_SLEEP(Seconds, MSeconds) \
|
||||
do{\
|
||||
struct timeval TimeInterval;\
|
||||
TimeInterval.tv_sec = Seconds;\
|
||||
TimeInterval.tv_usec = MSeconds*1000;\
|
||||
select(0, NULL, NULL, NULL, &TimeInterval);\
|
||||
}while(0)
|
||||
|
||||
|
||||
/***********************************************************
|
||||
*
|
||||
* Base Enum Zone
|
||||
*
|
||||
***********************************************************/
|
||||
/*Common Code*/
|
||||
typedef enum
|
||||
{
|
||||
DISABLE_STATE=0,
|
||||
ENABLE_STATE=1,
|
||||
|
||||
INVALID_STATE=0,
|
||||
VALID_STATE=1,
|
||||
|
||||
ABSENT_STATE=0,
|
||||
PRESENT_STATE=1,
|
||||
|
||||
FALSE_STATE=0,
|
||||
TRUE_STATE=1,
|
||||
|
||||
NO_STATE=0,
|
||||
YES_STATE=1,
|
||||
CABLE_PRESENT_ONLY=2,
|
||||
|
||||
|
||||
}ECommonCode;
|
||||
|
||||
|
||||
|
||||
/*Function Return Code */
|
||||
typedef enum
|
||||
{
|
||||
FUNC_FILE_OPEN_FAIL = -1,
|
||||
FUNC_LIB_OPEN_FAIL = -1,
|
||||
FUNC_FAIL_N1 = -1,
|
||||
FUNC_OK=0,
|
||||
FUNC_FAILED,
|
||||
|
||||
}EFuncRetCode;
|
||||
|
||||
|
||||
|
||||
|
||||
/*EBits Define*/
|
||||
typedef enum
|
||||
{
|
||||
BIT0=(1<<0),
|
||||
BIT1=(1<<1),
|
||||
BIT2=(1<<2),
|
||||
BIT3=(1<<3),
|
||||
BIT4=(1<<4),
|
||||
BIT5=(1<<5),
|
||||
BIT6=(1<<6),
|
||||
BIT7=(1<<7),
|
||||
BIT8=(1<<8),
|
||||
BIT9=(1<<9),
|
||||
BIT10=(1<<10),
|
||||
BIT11=(1<<11),
|
||||
BIT12=(1<<12),
|
||||
BIT13=(1<<13),
|
||||
BIT14=(1<<14),
|
||||
BIT15=(1<<15),
|
||||
BIT16=(1<<16),
|
||||
BIT17=(1<<17),
|
||||
BIT18=(1<<18),
|
||||
BIT19=(1<<19),
|
||||
BIT20=(1<<20),
|
||||
BIT21=(1<<21),
|
||||
BIT22=(1<<22),
|
||||
BIT23=(1<<23),
|
||||
BIT24=(1<<24),
|
||||
BIT25=(1<<25),
|
||||
BIT26=(1<<26),
|
||||
BIT27=(1<<27),
|
||||
BIT28=(1<<28),
|
||||
BIT29=(1<<29),
|
||||
BIT30=(1<<30),
|
||||
BIT31=(1<<31),
|
||||
|
||||
BIT0_1=(BIT0|BIT1),
|
||||
BIT0_2=(BIT0_1|BIT2),
|
||||
BIT0_3=(BIT0_2|BIT3),
|
||||
BIT0_4=(BIT0_3|BIT4),
|
||||
BIT0_5=(BIT0_4|BIT5),
|
||||
BIT0_6=(BIT0_5|BIT6),
|
||||
BIT0_7=(BIT0_6|BIT7),
|
||||
BIT0_8=(BIT0_7|BIT8),
|
||||
BIT0_9=(BIT0_8|BIT9),
|
||||
BIT0_10=(BIT0_9|BIT10),
|
||||
BIT0_11=(BIT0_10|BIT11),
|
||||
BIT0_12=(BIT0_11|BIT12),
|
||||
BIT0_13=(BIT0_12|BIT13),
|
||||
BIT0_14=(BIT0_13|BIT14),
|
||||
BIT0_15=(BIT0_14|BIT15),
|
||||
BIT0_16=(BIT0_15|BIT16),
|
||||
BIT0_17=(BIT0_16|BIT17),
|
||||
BIT0_18=(BIT0_17|BIT18),
|
||||
BIT0_19=(BIT0_18|BIT19),
|
||||
BIT0_20=(BIT0_19|BIT20),
|
||||
BIT0_21=(BIT0_20|BIT21),
|
||||
BIT0_22=(BIT0_21|BIT22),
|
||||
BIT0_23=(BIT0_22|BIT23),
|
||||
BIT0_24=(BIT0_23|BIT24),
|
||||
BIT0_25=(BIT0_24|BIT25),
|
||||
BIT0_26=(BIT0_25|BIT26),
|
||||
BIT0_27=(BIT0_26|BIT27),
|
||||
BIT0_28=(BIT0_27|BIT28),
|
||||
BIT0_29=(BIT0_28|BIT29),
|
||||
BIT0_30=(BIT0_29|BIT30),
|
||||
BIT0_31=(BIT0_30|BIT31),
|
||||
|
||||
BIT1_2=(BIT1|BIT2),
|
||||
BIT1_3=(BIT1_2|BIT3),
|
||||
BIT1_4=(BIT1_3|BIT4),
|
||||
BIT1_5=(BIT1_4|BIT5),
|
||||
BIT1_6=(BIT1_5|BIT6),
|
||||
BIT1_7=(BIT1_6|BIT7),
|
||||
BIT1_8=(BIT1_7|BIT8),
|
||||
BIT1_9=(BIT1_8|BIT9),
|
||||
BIT1_10=(BIT1_9|BIT10),
|
||||
BIT1_11=(BIT1_10|BIT11),
|
||||
BIT1_12=(BIT1_11|BIT12),
|
||||
BIT1_13=(BIT1_12|BIT13),
|
||||
BIT1_14=(BIT1_13|BIT14),
|
||||
BIT1_15=(BIT1_14|BIT15),
|
||||
BIT1_16=(BIT1_15|BIT16),
|
||||
BIT1_17=(BIT1_16|BIT17),
|
||||
BIT1_18=(BIT1_17|BIT18),
|
||||
BIT1_19=(BIT1_18|BIT19),
|
||||
BIT1_20=(BIT1_19|BIT20),
|
||||
BIT1_21=(BIT1_20|BIT21),
|
||||
BIT1_22=(BIT1_21|BIT22),
|
||||
BIT1_23=(BIT1_22|BIT23),
|
||||
BIT1_24=(BIT1_23|BIT24),
|
||||
BIT1_25=(BIT1_24|BIT25),
|
||||
BIT1_26=(BIT1_25|BIT26),
|
||||
BIT1_27=(BIT1_26|BIT27),
|
||||
BIT1_28=(BIT1_27|BIT28),
|
||||
BIT1_29=(BIT1_28|BIT29),
|
||||
BIT1_30=(BIT1_29|BIT30),
|
||||
BIT1_31=(BIT1_30|BIT31),
|
||||
|
||||
BIT2_3=(BIT2|BIT3),
|
||||
BIT2_4=(BIT2_3|BIT4),
|
||||
BIT2_5=(BIT2_4|BIT5),
|
||||
BIT2_6=(BIT2_5|BIT6),
|
||||
BIT2_7=(BIT2_6|BIT7),
|
||||
BIT2_8=(BIT2_7|BIT8),
|
||||
BIT2_9=(BIT2_8|BIT9),
|
||||
BIT2_10=(BIT2_9|BIT10),
|
||||
BIT2_11=(BIT2_10|BIT11),
|
||||
BIT2_12=(BIT2_11|BIT12),
|
||||
BIT2_13=(BIT2_12|BIT13),
|
||||
BIT2_14=(BIT2_13|BIT14),
|
||||
BIT2_15=(BIT2_14|BIT15),
|
||||
BIT2_16=(BIT2_15|BIT16),
|
||||
BIT2_17=(BIT2_16|BIT17),
|
||||
BIT2_18=(BIT2_17|BIT18),
|
||||
BIT2_19=(BIT2_18|BIT19),
|
||||
BIT2_20=(BIT2_19|BIT20),
|
||||
BIT2_21=(BIT2_20|BIT21),
|
||||
BIT2_22=(BIT2_21|BIT22),
|
||||
BIT2_23=(BIT2_22|BIT23),
|
||||
BIT2_24=(BIT2_23|BIT24),
|
||||
BIT2_25=(BIT2_24|BIT25),
|
||||
BIT2_26=(BIT2_25|BIT26),
|
||||
BIT2_27=(BIT2_26|BIT27),
|
||||
BIT2_28=(BIT2_27|BIT28),
|
||||
BIT2_29=(BIT2_28|BIT29),
|
||||
BIT2_30=(BIT2_29|BIT30),
|
||||
BIT2_31=(BIT2_30|BIT31),
|
||||
|
||||
BIT3_4=(BIT3|BIT4),
|
||||
BIT3_5=(BIT3_4|BIT5),
|
||||
BIT3_6=(BIT3_5|BIT6),
|
||||
BIT3_7=(BIT3_6|BIT7),
|
||||
BIT3_8=(BIT3_7|BIT8),
|
||||
BIT3_9=(BIT3_8|BIT9),
|
||||
BIT3_10=(BIT3_9|BIT10),
|
||||
BIT3_11=(BIT3_10|BIT11),
|
||||
BIT3_12=(BIT3_11|BIT12),
|
||||
BIT3_13=(BIT3_12|BIT13),
|
||||
BIT3_14=(BIT3_13|BIT14),
|
||||
BIT3_15=(BIT3_14|BIT15),
|
||||
BIT3_16=(BIT3_15|BIT16),
|
||||
BIT3_17=(BIT3_16|BIT17),
|
||||
BIT3_18=(BIT3_17|BIT18),
|
||||
BIT3_19=(BIT3_18|BIT19),
|
||||
BIT3_20=(BIT3_19|BIT20),
|
||||
BIT3_21=(BIT3_20|BIT21),
|
||||
BIT3_22=(BIT3_21|BIT22),
|
||||
BIT3_23=(BIT3_22|BIT23),
|
||||
BIT3_24=(BIT3_23|BIT24),
|
||||
BIT3_25=(BIT3_24|BIT25),
|
||||
BIT3_26=(BIT3_25|BIT26),
|
||||
BIT3_27=(BIT3_26|BIT27),
|
||||
BIT3_28=(BIT3_27|BIT28),
|
||||
BIT3_29=(BIT3_28|BIT29),
|
||||
BIT3_30=(BIT3_29|BIT30),
|
||||
BIT3_31=(BIT3_30|BIT31),
|
||||
|
||||
BIT4_5=(BIT4|BIT5),
|
||||
BIT4_6=(BIT4_5|BIT6),
|
||||
BIT4_7=(BIT4_6|BIT7),
|
||||
BIT4_8=(BIT4_7|BIT8),
|
||||
BIT4_9=(BIT4_8|BIT9),
|
||||
BIT4_10=(BIT4_9|BIT10),
|
||||
BIT4_11=(BIT4_10|BIT11),
|
||||
BIT4_12=(BIT4_11|BIT12),
|
||||
BIT4_13=(BIT4_12|BIT13),
|
||||
BIT4_14=(BIT4_13|BIT14),
|
||||
BIT4_15=(BIT4_14|BIT15),
|
||||
BIT4_16=(BIT4_15|BIT16),
|
||||
BIT4_17=(BIT4_16|BIT17),
|
||||
BIT4_18=(BIT4_17|BIT18),
|
||||
BIT4_19=(BIT4_18|BIT19),
|
||||
BIT4_20=(BIT4_19|BIT20),
|
||||
BIT4_21=(BIT4_20|BIT21),
|
||||
BIT4_22=(BIT4_21|BIT22),
|
||||
BIT4_23=(BIT4_22|BIT23),
|
||||
BIT4_24=(BIT4_23|BIT24),
|
||||
BIT4_25=(BIT4_24|BIT25),
|
||||
BIT4_26=(BIT4_25|BIT26),
|
||||
BIT4_27=(BIT4_26|BIT27),
|
||||
BIT4_28=(BIT4_27|BIT28),
|
||||
BIT4_29=(BIT4_28|BIT29),
|
||||
BIT4_30=(BIT4_29|BIT30),
|
||||
BIT4_31=(BIT4_30|BIT31),
|
||||
|
||||
BIT5_6=(BIT5|BIT6),
|
||||
BIT5_7=(BIT5_6|BIT7),
|
||||
BIT5_8=(BIT5_7|BIT8),
|
||||
BIT5_9=(BIT5_8|BIT9),
|
||||
BIT5_10=(BIT5_9|BIT10),
|
||||
BIT5_11=(BIT5_10|BIT11),
|
||||
BIT5_12=(BIT5_11|BIT12),
|
||||
BIT5_13=(BIT5_12|BIT13),
|
||||
BIT5_14=(BIT5_13|BIT14),
|
||||
BIT5_15=(BIT5_14|BIT15),
|
||||
BIT5_16=(BIT5_15|BIT16),
|
||||
BIT5_17=(BIT5_16|BIT17),
|
||||
BIT5_18=(BIT5_17|BIT18),
|
||||
BIT5_19=(BIT5_18|BIT19),
|
||||
BIT5_20=(BIT5_19|BIT20),
|
||||
BIT5_21=(BIT5_20|BIT21),
|
||||
BIT5_22=(BIT5_21|BIT22),
|
||||
BIT5_23=(BIT5_22|BIT23),
|
||||
BIT5_24=(BIT5_23|BIT24),
|
||||
BIT5_25=(BIT5_24|BIT25),
|
||||
BIT5_26=(BIT5_25|BIT26),
|
||||
BIT5_27=(BIT5_26|BIT27),
|
||||
BIT5_28=(BIT5_27|BIT28),
|
||||
BIT5_29=(BIT5_28|BIT29),
|
||||
BIT5_30=(BIT5_29|BIT30),
|
||||
BIT5_31=(BIT5_30|BIT31),
|
||||
|
||||
BIT6_7=(BIT6|BIT7),
|
||||
BIT6_8=(BIT6_7|BIT8),
|
||||
BIT6_9=(BIT6_8|BIT9),
|
||||
BIT6_10=(BIT6_9|BIT10),
|
||||
BIT6_11=(BIT6_10|BIT11),
|
||||
BIT6_12=(BIT6_11|BIT12),
|
||||
BIT6_13=(BIT6_12|BIT13),
|
||||
BIT6_14=(BIT6_13|BIT14),
|
||||
BIT6_15=(BIT6_14|BIT15),
|
||||
BIT6_16=(BIT6_15|BIT16),
|
||||
BIT6_17=(BIT6_16|BIT17),
|
||||
BIT6_18=(BIT6_17|BIT18),
|
||||
BIT6_19=(BIT6_18|BIT19),
|
||||
BIT6_20=(BIT6_19|BIT20),
|
||||
BIT6_21=(BIT6_20|BIT21),
|
||||
BIT6_22=(BIT6_21|BIT22),
|
||||
BIT6_23=(BIT6_22|BIT23),
|
||||
BIT6_24=(BIT6_23|BIT24),
|
||||
BIT6_25=(BIT6_24|BIT25),
|
||||
BIT6_26=(BIT6_25|BIT26),
|
||||
BIT6_27=(BIT6_26|BIT27),
|
||||
BIT6_28=(BIT6_27|BIT28),
|
||||
BIT6_29=(BIT6_28|BIT29),
|
||||
BIT6_30=(BIT6_29|BIT30),
|
||||
BIT6_31=(BIT6_30|BIT31),
|
||||
|
||||
BIT7_8=(BIT7|BIT8),
|
||||
BIT7_9=(BIT7_8|BIT9),
|
||||
BIT7_10=(BIT7_9|BIT10),
|
||||
BIT7_11=(BIT7_10|BIT11),
|
||||
BIT7_12=(BIT7_11|BIT12),
|
||||
BIT7_13=(BIT7_12|BIT13),
|
||||
BIT7_14=(BIT7_13|BIT14),
|
||||
BIT7_15=(BIT7_14|BIT15),
|
||||
BIT7_16=(BIT7_15|BIT16),
|
||||
BIT7_17=(BIT7_16|BIT17),
|
||||
BIT7_18=(BIT7_17|BIT18),
|
||||
BIT7_19=(BIT7_18|BIT19),
|
||||
BIT7_20=(BIT7_19|BIT20),
|
||||
BIT7_21=(BIT7_20|BIT21),
|
||||
BIT7_22=(BIT7_21|BIT22),
|
||||
BIT7_23=(BIT7_22|BIT23),
|
||||
BIT7_24=(BIT7_23|BIT24),
|
||||
BIT7_25=(BIT7_24|BIT25),
|
||||
BIT7_26=(BIT7_25|BIT26),
|
||||
BIT7_27=(BIT7_26|BIT27),
|
||||
BIT7_28=(BIT7_27|BIT28),
|
||||
BIT7_29=(BIT7_28|BIT29),
|
||||
BIT7_30=(BIT7_29|BIT30),
|
||||
BIT7_31=(BIT7_30|BIT31),
|
||||
|
||||
BIT8_9=(BIT8|BIT9),
|
||||
BIT8_10=(BIT8_9|BIT10),
|
||||
BIT8_11=(BIT8_10|BIT11),
|
||||
BIT8_12=(BIT8_11|BIT12),
|
||||
BIT8_13=(BIT8_12|BIT13),
|
||||
BIT8_14=(BIT8_13|BIT14),
|
||||
BIT8_15=(BIT8_14|BIT15),
|
||||
BIT8_16=(BIT8_15|BIT16),
|
||||
BIT8_17=(BIT8_16|BIT17),
|
||||
BIT8_18=(BIT8_17|BIT18),
|
||||
BIT8_19=(BIT8_18|BIT19),
|
||||
BIT8_20=(BIT8_19|BIT20),
|
||||
BIT8_21=(BIT8_20|BIT21),
|
||||
BIT8_22=(BIT8_21|BIT22),
|
||||
BIT8_23=(BIT8_22|BIT23),
|
||||
BIT8_24=(BIT8_23|BIT24),
|
||||
BIT8_25=(BIT8_24|BIT25),
|
||||
BIT8_26=(BIT8_25|BIT26),
|
||||
BIT8_27=(BIT8_26|BIT27),
|
||||
BIT8_28=(BIT8_27|BIT28),
|
||||
BIT8_29=(BIT8_28|BIT29),
|
||||
BIT8_30=(BIT8_29|BIT30),
|
||||
BIT8_31=(BIT8_30|BIT31),
|
||||
|
||||
BIT9_10=(BIT9|BIT10),
|
||||
BIT9_11=(BIT9_10|BIT11),
|
||||
BIT9_12=(BIT9_11|BIT12),
|
||||
BIT9_13=(BIT9_12|BIT13),
|
||||
BIT9_14=(BIT9_13|BIT14),
|
||||
BIT9_15=(BIT9_14|BIT15),
|
||||
BIT9_16=(BIT9_15|BIT16),
|
||||
BIT9_17=(BIT9_16|BIT17),
|
||||
BIT9_18=(BIT9_17|BIT18),
|
||||
BIT9_19=(BIT9_18|BIT19),
|
||||
BIT9_20=(BIT9_19|BIT20),
|
||||
BIT9_21=(BIT9_20|BIT21),
|
||||
BIT9_22=(BIT9_21|BIT22),
|
||||
BIT9_23=(BIT9_22|BIT23),
|
||||
BIT9_24=(BIT9_23|BIT24),
|
||||
BIT9_25=(BIT9_24|BIT25),
|
||||
BIT9_26=(BIT9_25|BIT26),
|
||||
BIT9_27=(BIT9_26|BIT27),
|
||||
BIT9_28=(BIT9_27|BIT28),
|
||||
BIT9_29=(BIT9_28|BIT29),
|
||||
BIT9_30=(BIT9_29|BIT30),
|
||||
BIT9_31=(BIT9_30|BIT31),
|
||||
|
||||
BIT10_11=(BIT10|BIT11),
|
||||
BIT10_12=(BIT10_11|BIT12),
|
||||
BIT10_13=(BIT10_12|BIT13),
|
||||
BIT10_14=(BIT10_13|BIT14),
|
||||
BIT10_15=(BIT10_14|BIT15),
|
||||
BIT10_16=(BIT10_15|BIT16),
|
||||
BIT10_17=(BIT10_16|BIT17),
|
||||
BIT10_18=(BIT10_17|BIT18),
|
||||
BIT10_19=(BIT10_18|BIT19),
|
||||
BIT10_20=(BIT10_19|BIT20),
|
||||
BIT10_21=(BIT10_20|BIT21),
|
||||
BIT10_22=(BIT10_21|BIT22),
|
||||
BIT10_23=(BIT10_22|BIT23),
|
||||
BIT10_24=(BIT10_23|BIT24),
|
||||
BIT10_25=(BIT10_24|BIT25),
|
||||
BIT10_26=(BIT10_25|BIT26),
|
||||
BIT10_27=(BIT10_26|BIT27),
|
||||
BIT10_28=(BIT10_27|BIT28),
|
||||
BIT10_29=(BIT10_28|BIT29),
|
||||
BIT10_30=(BIT10_29|BIT30),
|
||||
BIT10_31=(BIT10_30|BIT31),
|
||||
|
||||
BIT11_12=(BIT11|BIT12),
|
||||
BIT11_13=(BIT11_12|BIT13),
|
||||
BIT11_14=(BIT11_13|BIT14),
|
||||
BIT11_15=(BIT11_14|BIT15),
|
||||
BIT11_16=(BIT11_15|BIT16),
|
||||
BIT11_17=(BIT11_16|BIT17),
|
||||
BIT11_18=(BIT11_17|BIT18),
|
||||
BIT11_19=(BIT11_18|BIT19),
|
||||
BIT11_20=(BIT11_19|BIT20),
|
||||
BIT11_21=(BIT11_20|BIT21),
|
||||
BIT11_22=(BIT11_21|BIT22),
|
||||
BIT11_23=(BIT11_22|BIT23),
|
||||
BIT11_24=(BIT11_23|BIT24),
|
||||
BIT11_25=(BIT11_24|BIT25),
|
||||
BIT11_26=(BIT11_25|BIT26),
|
||||
BIT11_27=(BIT11_26|BIT27),
|
||||
BIT11_28=(BIT11_27|BIT28),
|
||||
BIT11_29=(BIT11_28|BIT29),
|
||||
BIT11_30=(BIT11_29|BIT30),
|
||||
BIT11_31=(BIT11_30|BIT31),
|
||||
|
||||
BIT12_13=(BIT12|BIT13),
|
||||
BIT12_14=(BIT12_13|BIT14),
|
||||
BIT12_15=(BIT12_14|BIT15),
|
||||
BIT12_16=(BIT12_15|BIT16),
|
||||
BIT12_17=(BIT12_16|BIT17),
|
||||
BIT12_18=(BIT12_17|BIT18),
|
||||
BIT12_19=(BIT12_18|BIT19),
|
||||
BIT12_20=(BIT12_19|BIT20),
|
||||
BIT12_21=(BIT12_20|BIT21),
|
||||
BIT12_22=(BIT12_21|BIT22),
|
||||
BIT12_23=(BIT12_22|BIT23),
|
||||
BIT12_24=(BIT12_23|BIT24),
|
||||
BIT12_25=(BIT12_24|BIT25),
|
||||
BIT12_26=(BIT12_25|BIT26),
|
||||
BIT12_27=(BIT12_26|BIT27),
|
||||
BIT12_28=(BIT12_27|BIT28),
|
||||
BIT12_29=(BIT12_28|BIT29),
|
||||
BIT12_30=(BIT12_29|BIT30),
|
||||
BIT12_31=(BIT12_30|BIT31),
|
||||
|
||||
BIT13_14=(BIT13|BIT14),
|
||||
BIT13_15=(BIT13_14|BIT15),
|
||||
BIT13_16=(BIT13_15|BIT16),
|
||||
BIT13_17=(BIT13_16|BIT17),
|
||||
BIT13_18=(BIT13_17|BIT18),
|
||||
BIT13_19=(BIT13_18|BIT19),
|
||||
BIT13_20=(BIT13_19|BIT20),
|
||||
BIT13_21=(BIT13_20|BIT21),
|
||||
BIT13_22=(BIT13_21|BIT22),
|
||||
BIT13_23=(BIT13_22|BIT23),
|
||||
BIT13_24=(BIT13_23|BIT24),
|
||||
BIT13_25=(BIT13_24|BIT25),
|
||||
BIT13_26=(BIT13_25|BIT26),
|
||||
BIT13_27=(BIT13_26|BIT27),
|
||||
BIT13_28=(BIT13_27|BIT28),
|
||||
BIT13_29=(BIT13_28|BIT29),
|
||||
BIT13_30=(BIT13_29|BIT30),
|
||||
BIT13_31=(BIT13_30|BIT31),
|
||||
|
||||
BIT14_15=(BIT14|BIT15),
|
||||
BIT14_16=(BIT14_15|BIT16),
|
||||
BIT14_17=(BIT14_16|BIT17),
|
||||
BIT14_18=(BIT14_17|BIT18),
|
||||
BIT14_19=(BIT14_18|BIT19),
|
||||
BIT14_20=(BIT14_19|BIT20),
|
||||
BIT14_21=(BIT14_20|BIT21),
|
||||
BIT14_22=(BIT14_21|BIT22),
|
||||
BIT14_23=(BIT14_22|BIT23),
|
||||
BIT14_24=(BIT14_23|BIT24),
|
||||
BIT14_25=(BIT14_24|BIT25),
|
||||
BIT14_26=(BIT14_25|BIT26),
|
||||
BIT14_27=(BIT14_26|BIT27),
|
||||
BIT14_28=(BIT14_27|BIT28),
|
||||
BIT14_29=(BIT14_28|BIT29),
|
||||
BIT14_30=(BIT14_29|BIT30),
|
||||
BIT14_31=(BIT14_30|BIT31),
|
||||
|
||||
BIT15_16=(BIT15|BIT16),
|
||||
BIT15_17=(BIT15_16|BIT17),
|
||||
BIT15_18=(BIT15_17|BIT18),
|
||||
BIT15_19=(BIT15_18|BIT19),
|
||||
BIT15_20=(BIT15_19|BIT20),
|
||||
BIT15_21=(BIT15_20|BIT21),
|
||||
BIT15_22=(BIT15_21|BIT22),
|
||||
BIT15_23=(BIT15_22|BIT23),
|
||||
BIT15_24=(BIT15_23|BIT24),
|
||||
BIT15_25=(BIT15_24|BIT25),
|
||||
BIT15_26=(BIT15_25|BIT26),
|
||||
BIT15_27=(BIT15_26|BIT27),
|
||||
BIT15_28=(BIT15_27|BIT28),
|
||||
BIT15_29=(BIT15_28|BIT29),
|
||||
BIT15_30=(BIT15_29|BIT30),
|
||||
BIT15_31=(BIT15_30|BIT31),
|
||||
|
||||
BIT16_17=(BIT16|BIT17),
|
||||
BIT16_18=(BIT16_17|BIT18),
|
||||
BIT16_19=(BIT16_18|BIT19),
|
||||
BIT16_20=(BIT16_19|BIT20),
|
||||
BIT16_21=(BIT16_20|BIT21),
|
||||
BIT16_22=(BIT16_21|BIT22),
|
||||
BIT16_23=(BIT16_22|BIT23),
|
||||
BIT16_24=(BIT16_23|BIT24),
|
||||
BIT16_25=(BIT16_24|BIT25),
|
||||
BIT16_26=(BIT16_25|BIT26),
|
||||
BIT16_27=(BIT16_26|BIT27),
|
||||
BIT16_28=(BIT16_27|BIT28),
|
||||
BIT16_29=(BIT16_28|BIT29),
|
||||
BIT16_30=(BIT16_29|BIT30),
|
||||
BIT16_31=(BIT16_30|BIT31),
|
||||
|
||||
BIT17_18=(BIT17|BIT18),
|
||||
BIT17_19=(BIT17_18|BIT19),
|
||||
BIT17_20=(BIT17_19|BIT20),
|
||||
BIT17_21=(BIT17_20|BIT21),
|
||||
BIT17_22=(BIT17_21|BIT22),
|
||||
BIT17_23=(BIT17_22|BIT23),
|
||||
BIT17_24=(BIT17_23|BIT24),
|
||||
BIT17_25=(BIT17_24|BIT25),
|
||||
BIT17_26=(BIT17_25|BIT26),
|
||||
BIT17_27=(BIT17_26|BIT27),
|
||||
BIT17_28=(BIT17_27|BIT28),
|
||||
BIT17_29=(BIT17_28|BIT29),
|
||||
BIT17_30=(BIT17_29|BIT30),
|
||||
BIT17_31=(BIT17_30|BIT31),
|
||||
|
||||
BIT18_19=(BIT18|BIT19),
|
||||
BIT18_20=(BIT18_19|BIT20),
|
||||
BIT18_21=(BIT18_20|BIT21),
|
||||
BIT18_22=(BIT18_21|BIT22),
|
||||
BIT18_23=(BIT18_22|BIT23),
|
||||
BIT18_24=(BIT18_23|BIT24),
|
||||
BIT18_25=(BIT18_24|BIT25),
|
||||
BIT18_26=(BIT18_25|BIT26),
|
||||
BIT18_27=(BIT18_26|BIT27),
|
||||
BIT18_28=(BIT18_27|BIT28),
|
||||
BIT18_29=(BIT18_28|BIT29),
|
||||
BIT18_30=(BIT18_29|BIT30),
|
||||
BIT18_31=(BIT18_30|BIT31),
|
||||
|
||||
BIT19_20=(BIT19|BIT20),
|
||||
BIT19_21=(BIT19_20|BIT21),
|
||||
BIT19_22=(BIT19_21|BIT22),
|
||||
BIT19_23=(BIT19_22|BIT23),
|
||||
BIT19_24=(BIT19_23|BIT24),
|
||||
BIT19_25=(BIT19_24|BIT25),
|
||||
BIT19_26=(BIT19_25|BIT26),
|
||||
BIT19_27=(BIT19_26|BIT27),
|
||||
BIT19_28=(BIT19_27|BIT28),
|
||||
BIT19_29=(BIT19_28|BIT29),
|
||||
BIT19_30=(BIT19_29|BIT30),
|
||||
BIT19_31=(BIT19_30|BIT31),
|
||||
|
||||
BIT20_21=(BIT20|BIT21),
|
||||
BIT20_22=(BIT20_21|BIT22),
|
||||
BIT20_23=(BIT20_22|BIT23),
|
||||
BIT20_24=(BIT20_23|BIT24),
|
||||
BIT20_25=(BIT20_24|BIT25),
|
||||
BIT20_26=(BIT20_25|BIT26),
|
||||
BIT20_27=(BIT20_26|BIT27),
|
||||
BIT20_28=(BIT20_27|BIT28),
|
||||
BIT20_29=(BIT20_28|BIT29),
|
||||
BIT20_30=(BIT20_29|BIT30),
|
||||
BIT20_31=(BIT20_30|BIT31),
|
||||
|
||||
BIT21_22=(BIT21|BIT22),
|
||||
BIT21_23=(BIT21_22|BIT23),
|
||||
BIT21_24=(BIT21_23|BIT24),
|
||||
BIT21_25=(BIT21_24|BIT25),
|
||||
BIT21_26=(BIT21_25|BIT26),
|
||||
BIT21_27=(BIT21_26|BIT27),
|
||||
BIT21_28=(BIT21_27|BIT28),
|
||||
BIT21_29=(BIT21_28|BIT29),
|
||||
BIT21_30=(BIT21_29|BIT30),
|
||||
BIT21_31=(BIT21_30|BIT31),
|
||||
|
||||
BIT22_23=(BIT22|BIT23),
|
||||
BIT22_24=(BIT22_23|BIT24),
|
||||
BIT22_25=(BIT22_24|BIT25),
|
||||
BIT22_26=(BIT22_25|BIT26),
|
||||
BIT22_27=(BIT22_26|BIT27),
|
||||
BIT22_28=(BIT22_27|BIT28),
|
||||
BIT22_29=(BIT22_28|BIT29),
|
||||
BIT22_30=(BIT22_29|BIT30),
|
||||
BIT22_31=(BIT22_30|BIT31),
|
||||
|
||||
BIT23_24=(BIT23|BIT24),
|
||||
BIT23_25=(BIT23_24|BIT25),
|
||||
BIT23_26=(BIT23_25|BIT26),
|
||||
BIT23_27=(BIT23_26|BIT27),
|
||||
BIT23_28=(BIT23_27|BIT28),
|
||||
BIT23_29=(BIT23_28|BIT29),
|
||||
BIT23_30=(BIT23_29|BIT30),
|
||||
BIT23_31=(BIT23_30|BIT31),
|
||||
|
||||
BIT24_25=(BIT24|BIT25),
|
||||
BIT24_26=(BIT24_25|BIT26),
|
||||
BIT24_27=(BIT24_26|BIT27),
|
||||
BIT24_28=(BIT24_27|BIT28),
|
||||
BIT24_29=(BIT24_28|BIT29),
|
||||
BIT24_30=(BIT24_29|BIT30),
|
||||
BIT24_31=(BIT24_30|BIT31),
|
||||
|
||||
BIT25_26=(BIT25|BIT26),
|
||||
BIT25_27=(BIT25_26|BIT27),
|
||||
BIT25_28=(BIT25_27|BIT28),
|
||||
BIT25_29=(BIT25_28|BIT29),
|
||||
BIT25_30=(BIT25_29|BIT30),
|
||||
BIT25_31=(BIT25_30|BIT31),
|
||||
|
||||
BIT26_27=(BIT26|BIT27),
|
||||
BIT26_28=(BIT26_27|BIT28),
|
||||
BIT26_29=(BIT26_28|BIT29),
|
||||
BIT26_30=(BIT26_29|BIT30),
|
||||
BIT26_31=(BIT26_30|BIT31),
|
||||
|
||||
BIT27_28=(BIT27|BIT28),
|
||||
BIT27_29=(BIT27_28|BIT29),
|
||||
BIT27_30=(BIT27_29|BIT30),
|
||||
BIT27_31=(BIT27_30|BIT31),
|
||||
|
||||
BIT28_29=(BIT28|BIT29),
|
||||
BIT28_30=(BIT28_29|BIT30),
|
||||
BIT28_31=(BIT28_30|BIT31),
|
||||
|
||||
BIT29_30=(BIT29|BIT30),
|
||||
BIT29_31=(BIT29_30|BIT31),
|
||||
|
||||
BIT30_31=(BIT30|BIT31),
|
||||
}EBits;
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
+913
@@ -0,0 +1,913 @@
|
||||
/***********************************************************
|
||||
* Copyright (C), 2021, LuxShare co.,
|
||||
*
|
||||
* File name : lux_json_api
|
||||
*
|
||||
* Description :
|
||||
* JSON API
|
||||
*
|
||||
* History:
|
||||
*
|
||||
* <Date> <Author> <version> <Modification>
|
||||
* 2021/04/21 Laurence Zhou 0.01 First draft
|
||||
***********************************************************/
|
||||
|
||||
#include "lux_json_api.h"
|
||||
|
||||
/***********************************************************
|
||||
* Name:
|
||||
* LuxcJSONParseJsonFile
|
||||
*
|
||||
* Summary:
|
||||
* parse JSON file to get the HEAD pointer(note: remeber to call Luxcjsondelete() to free memory)
|
||||
*
|
||||
* Return Value:
|
||||
* The LuxcJSONParseJsonFile() function returns a HEAD pointer to HEAD node of the Doubly Linked List
|
||||
*
|
||||
* Parameter Input:
|
||||
* char* pcFileName -- JSON file name with Absolute path
|
||||
*
|
||||
* Parameter Output:
|
||||
* None
|
||||
*
|
||||
* Author:
|
||||
* Laurence.Zhou@luxshare-ict.com: Initial Version
|
||||
*
|
||||
***********************************************************/
|
||||
|
||||
cJSON* LuxcJSONParseJsonFile(char* pcFileName)
|
||||
{
|
||||
long lLen = 0;
|
||||
char* psBuf = NULL;
|
||||
cJSON* psRoot = NULL;
|
||||
if(NULL == pcFileName)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
FILE* fp = LuxFopen(pcFileName, "rb+");
|
||||
if (NULL == fp)
|
||||
{
|
||||
printf("open file %s failed.\n", pcFileName);
|
||||
return NULL;
|
||||
}
|
||||
LuxFseek(fp, 0, SEEK_END);
|
||||
lLen = LuxFtell(fp);
|
||||
if (0 == lLen)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
LuxFseek(fp, 0, SEEK_SET);
|
||||
psBuf = (char *)LuxMalloc(sizeof(char) * lLen);
|
||||
LuxFread(psBuf, 1, lLen, fp);
|
||||
LuxFclose(fp);
|
||||
cJSON_Minify(psBuf);
|
||||
psRoot = cJSON_Parse(psBuf);
|
||||
if (NULL == psRoot)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
LuxFree(psBuf);
|
||||
return psRoot;
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* Name:
|
||||
* LuxcJSONPrint
|
||||
*
|
||||
* Summary:
|
||||
* Render a cJSON entity to text for transfer/storage(note: remeber to call Luxcjsonfree to free memory)
|
||||
*
|
||||
* Return Value:
|
||||
* a string
|
||||
*
|
||||
* Parameter Input:
|
||||
* const cJSON* psItem -- The HEAD pointer of the CJSON entity
|
||||
*
|
||||
* Parameter Output:
|
||||
* None
|
||||
*
|
||||
* Author:
|
||||
* Laurence.Zhou@luxshare-ict.com: Initial Version
|
||||
*
|
||||
***********************************************************/
|
||||
char* LuxcJSONPrint(const cJSON* psItem)
|
||||
{
|
||||
if(NULL != psItem)
|
||||
{
|
||||
return cJSON_Print(psItem);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* Name:
|
||||
* LuxcJSONGetObjectItem
|
||||
*
|
||||
* Summary:
|
||||
* Get item "pcKey" from psObject
|
||||
*
|
||||
* Return Value:
|
||||
* Pointer to the "pcKey" cJSON node
|
||||
*
|
||||
* Parameter Input:
|
||||
* const cJSON* psItem -- The HEAD pointer of the CJSON entity
|
||||
* const char* const pcKey -- Key/Name
|
||||
*
|
||||
* Parameter Output:
|
||||
* None
|
||||
*
|
||||
* Author:
|
||||
* Laurence.Zhou@luxshare-ict.com: Initial Version
|
||||
*
|
||||
**********************************************************/
|
||||
cJSON* LuxcJSONGetObjectItem(const cJSON* const psObject, const char* const pcKey)
|
||||
{
|
||||
if(NULL == psObject)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
if(false == cJSON_HasObjectItem(psObject, pcKey))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
if(NULL == pcKey)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
cJSON* psTemp = NULL;
|
||||
psTemp = cJSON_GetObjectItem(psObject, pcKey);
|
||||
if (psTemp)
|
||||
{
|
||||
return psTemp;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* Name:
|
||||
* LuxcJSONGetObjectIntValue
|
||||
*
|
||||
* Summary:
|
||||
* Get int value
|
||||
*
|
||||
* Return Value:
|
||||
* EFuncRetCode(FUNC_FAILED or FUNC_OK)
|
||||
*
|
||||
* Parameter Input:
|
||||
* const cJSON* psItem -- The HEAD pointer of the CJSON entity
|
||||
* const char* const pcKey -- Key/Name
|
||||
* int* piValue -- Pointer that holds the int value
|
||||
*
|
||||
* Parameter Output:
|
||||
* piVAlue
|
||||
*
|
||||
* Author:
|
||||
* Laurence.Zhou@luxshare-ict.com: Initial Version
|
||||
*
|
||||
***********************************************************/
|
||||
EFuncRetCode LuxcJSONGetObjectIntValue(const cJSON* const psObject, const char* const pcKey,int* piValue )
|
||||
{
|
||||
cJSON* psItem = NULL;
|
||||
if(NULL == psObject)
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(false == cJSON_HasObjectItem(psObject, pcKey))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(NULL == piValue)
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if( NULL == (psItem = (cJSON_GetObjectItem(psObject, pcKey))))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
|
||||
*piValue = psItem->valueint;
|
||||
return FUNC_OK;
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* Name:
|
||||
* LuxcJSONGetObjectDoubleValue
|
||||
*
|
||||
* Summary:
|
||||
* Get double value
|
||||
*
|
||||
* Return Value:
|
||||
* EFuncRetCode(FUNC_FAILED or FUNC_OK)
|
||||
*
|
||||
* Parameter Input:
|
||||
* const cJSON* psItem -- The HEAD pointer of the CJSON entity
|
||||
* const char* const pcKey -- Key/Name
|
||||
* double* pdValue -- Pointer that holds the double value
|
||||
*
|
||||
* Parameter Output:
|
||||
* pdValue
|
||||
*
|
||||
* Author:
|
||||
* Laurence.Zhou@luxshare-ict.com: Initial Version
|
||||
*
|
||||
***********************************************************/
|
||||
EFuncRetCode LuxcJSONGetObjectDoubleValue(const cJSON* const psObject,const char* const pcKey, double* pdValue)
|
||||
{
|
||||
cJSON* psItem = NULL;
|
||||
if(NULL == psObject)
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(false == cJSON_HasObjectItem(psObject, pcKey))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(NULL == pdValue)
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(NULL == (psItem = (cJSON_GetObjectItem(psObject, pcKey))))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
|
||||
*pdValue = psItem->valuedouble;
|
||||
return FUNC_OK;
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* Name:
|
||||
* LuxcJSONGetObjectStringSize
|
||||
*
|
||||
* Summary:
|
||||
* Get the length of String
|
||||
*
|
||||
* Return Value:
|
||||
* length of String
|
||||
*
|
||||
* Parameter Input:
|
||||
* const cJSON* psItem -- The HEAD pointer of the CJSON entity
|
||||
* const char* const pcKey -- Key/Name
|
||||
*
|
||||
* Parameter Output:
|
||||
* None
|
||||
*
|
||||
* Author:
|
||||
* Laurence.Zhou@luxshare-ict.com: Initial Version
|
||||
*
|
||||
***********************************************************/
|
||||
EFuncRetCode LuxcJSONGetOjectStringSize(const cJSON* const psObject, const char* const pcKey, int *piSize)
|
||||
{
|
||||
cJSON* psItem = NULL;
|
||||
if(NULL == psObject)
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(false == cJSON_HasObjectItem(psObject, pcKey))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(NULL == piSize)
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
psItem = cJSON_GetObjectItem(psObject, pcKey);
|
||||
*piSize = LuxStrlen(psItem->valuestring);
|
||||
return FUNC_OK;
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* Name:
|
||||
* LuxcJSONGetObjectStringValue
|
||||
*
|
||||
* Summary:
|
||||
* Get string value
|
||||
*
|
||||
* Return Value:
|
||||
* EFuncRetCode(FUNC_FAILED or FUNC_OK)
|
||||
*
|
||||
* Parameter Input:
|
||||
* const cJSON* psItem -- The HEAD pointer of the CJSON entity
|
||||
* const char* const pcKey -- Key/Name
|
||||
* char* pcValue -- Pointer that holds the String value
|
||||
*
|
||||
* Parameter Output:
|
||||
* pcValue
|
||||
*
|
||||
* Author:
|
||||
* Laurence.Zhou@luxshare-ict.com: Initial Version
|
||||
*
|
||||
***********************************************************/
|
||||
EFuncRetCode LuxcJSONGetObjectStringValue(const cJSON* const psObject, const char* const pcKey, char* pcValue )
|
||||
{
|
||||
cJSON* psItem = NULL;
|
||||
if(NULL == psObject)
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(false == cJSON_HasObjectItem(psObject, pcKey))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(NULL == pcValue)
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(NULL == (psItem=(cJSON_GetObjectItem(psObject, pcKey))))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
LuxStrcpy(pcValue,psItem->valuestring);
|
||||
return FUNC_OK;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* Name:
|
||||
* LuxcJSONGetObjectBooleanValue
|
||||
*
|
||||
* Summary:
|
||||
* Get boolean value
|
||||
*
|
||||
* Return Value:
|
||||
* EFuncRetCode(FUNC_FAILED or FUNC_OK)
|
||||
*
|
||||
* Parameter Input:
|
||||
* const cJSON* psItem -- The HEAD pointer of the CJSON entity
|
||||
* const char* const pcKey -- Key/Name
|
||||
* cJSON_bool* pbValue -- Pointer that holds the boolean value
|
||||
*
|
||||
* Parameter Output:
|
||||
* pbValue
|
||||
*
|
||||
* Author:
|
||||
* Laurence.Zhou@luxshare-ict.com: Initial Version
|
||||
*
|
||||
***********************************************************/
|
||||
EFuncRetCode LuxcJSONGetObjectBooleanValue(const cJSON* const psObject, const char* const pcKey, cJSON_bool* pbValue)
|
||||
{
|
||||
cJSON* psItem = NULL;
|
||||
if(NULL == psObject)
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(false == cJSON_HasObjectItem(psObject, pcKey))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(NULL == pbValue)
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(NULL == (psItem = cJSON_GetObjectItem(psObject, pcKey)))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
|
||||
if(false == psItem->valueint)
|
||||
{
|
||||
*pbValue = false;
|
||||
return FUNC_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
*pbValue = true;
|
||||
return FUNC_OK;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* Name:
|
||||
* LuxcJSONGetObjectArraySize
|
||||
*
|
||||
* Summary:
|
||||
* Get the array size
|
||||
*
|
||||
* Return Value:
|
||||
* EFuncRetCode(FUNC_FAILED or FUNC_OK)
|
||||
*
|
||||
* Parameter Input:
|
||||
* const cJSON* psObject -- The HEAD pointer of the CJSON entity
|
||||
* const char* const pcKey -- Key/Name
|
||||
* int* piSize -- Pointer that holds the array size
|
||||
*
|
||||
* Parameter Output:
|
||||
* piSize
|
||||
*
|
||||
* Author:
|
||||
* Laurence.Zhou@luxshare-ict.com: Initial Version
|
||||
*
|
||||
***********************************************************/
|
||||
EFuncRetCode LuxcJSONGetObjectArraySize(const cJSON* const psObject, const char* const pcKey, int* piSize)
|
||||
{
|
||||
cJSON* psArray = NULL;
|
||||
if(NULL == psObject)
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(false == cJSON_HasObjectItem(psObject, pcKey))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(NULL == piSize)
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(NULL == (psArray = cJSON_GetObjectItem(psObject, pcKey)))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
*piSize = cJSON_GetArraySize(psArray);
|
||||
return FUNC_OK;
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* Name:
|
||||
* LuxcJSONGetObjectIntArray
|
||||
*
|
||||
* Summary:
|
||||
* Get the int array
|
||||
*
|
||||
* Return Value:
|
||||
* EFuncRetCode(FUNC_FAILED or FUNC_OK)
|
||||
*
|
||||
* Parameter Input:
|
||||
* const cJSON* psObject -- The HEAD pointer of the CJSON entity
|
||||
* const char* const pcKey -- Key/Name
|
||||
* int* piArray -- Pointer that holds the int array(if pass NULL to piArray,we can get the array size)
|
||||
* int* piSize -- Pointer that holds the array size
|
||||
*
|
||||
* Parameter Output:
|
||||
* piArray,piSize
|
||||
*
|
||||
* Author:
|
||||
* Laurence.Zhou@luxshare-ict.com: Initial Version
|
||||
*
|
||||
***********************************************************/
|
||||
EFuncRetCode LuxcJSONGetObjectIntArray(const cJSON* const psObject, const char* const pcKey, int* piArray,int* piSize)
|
||||
{
|
||||
cJSON *psArray = NULL;
|
||||
cJSON *psTemp = NULL;
|
||||
if(NULL == psObject)
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(false == cJSON_HasObjectItem(psObject, pcKey))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(NULL == piSize)
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(NULL == piArray )
|
||||
{
|
||||
if(FUNC_OK == LuxcJSONGetObjectArraySize(psObject, pcKey, piSize))
|
||||
{
|
||||
return FUNC_OK;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(FUNC_FAILED == LuxcJSONGetObjectArraySize(psObject, pcKey, piSize))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
|
||||
if(NULL == (psArray = cJSON_GetObjectItem(psObject, pcKey)))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
|
||||
for (int i = 0,j = 0; i < *piSize && j < *piSize; ++i,++j)
|
||||
{
|
||||
psTemp = cJSON_GetArrayItem(psArray, i);
|
||||
piArray[j] = psTemp->valueint;
|
||||
psTemp = NULL;
|
||||
}
|
||||
psArray = NULL;
|
||||
return FUNC_OK;
|
||||
}
|
||||
|
||||
return FUNC_OK;
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* Name:
|
||||
* LuxcJSONGetObjectDoubleArray
|
||||
*
|
||||
* Summary:
|
||||
* Get the double array
|
||||
*
|
||||
* Return Value:
|
||||
* EFuncRetCode(FUNC_FAILED or FUNC_OK)
|
||||
*
|
||||
* Parameter Input:
|
||||
* const cJSON* psObject -- The HEAD pointer of the CJSON entity
|
||||
* const char* const pcKey -- Key/Name
|
||||
* double* piArray -- Pointer that holds the double array(if pass NULL to pdArray,we can get the array size)
|
||||
* int* piSize -- Pointer that holds the array size
|
||||
*
|
||||
* Parameter Output:
|
||||
* pdArray,piSize
|
||||
*
|
||||
* Author:
|
||||
* Laurence.Zhou@luxshare-ict.com: Initial Version
|
||||
*
|
||||
***********************************************************/
|
||||
EFuncRetCode LuxcJSONGetObjectDoubleArray(const cJSON* const psObject, const char* const pcKey, double* pdArray, int* piSize )
|
||||
{
|
||||
cJSON *psArray = NULL;
|
||||
cJSON *psTemp = NULL;
|
||||
if(NULL == psObject)
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(false == cJSON_HasObjectItem(psObject, pcKey))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
|
||||
if(NULL == piSize)
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
|
||||
if(NULL == pdArray)
|
||||
{
|
||||
if(FUNC_OK == LuxcJSONGetObjectArraySize(psObject, pcKey, piSize))
|
||||
{
|
||||
return FUNC_OK;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(FUNC_FAILED == LuxcJSONGetObjectArraySize(psObject, pcKey, piSize))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
|
||||
if(NULL == (psArray = cJSON_GetObjectItem(psObject, pcKey)))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
|
||||
for (int i = 0,j = 0; i < *piSize && j < *piSize; ++i,++j)
|
||||
{
|
||||
psTemp = cJSON_GetArrayItem(psArray, i);
|
||||
pdArray[j] = psTemp->valuedouble;
|
||||
psTemp = NULL;
|
||||
}
|
||||
psArray = NULL;
|
||||
return FUNC_OK;
|
||||
}
|
||||
return FUNC_OK;
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* Name:
|
||||
* LuxcJSONGetObjectStringArray
|
||||
*
|
||||
* Summary:
|
||||
* Get the string array
|
||||
*
|
||||
* Return Value:
|
||||
* EFuncRetCode(FUNC_FAILED or FUNC_OK)
|
||||
*
|
||||
* Parameter Input:
|
||||
* const cJSON* psObject -- The HEAD pointer of the CJSON entity
|
||||
* const char* const pcKey -- Key/Name
|
||||
* char (*pcArray)[MAXSIZE] -- Pointer that holds the string array(if pass NULL to pcArray,we can get the array size)
|
||||
* int* piSize -- Pointer that holds the array size
|
||||
*
|
||||
* Parameter Output:
|
||||
* pcArray,piSize
|
||||
*
|
||||
* Author:
|
||||
* Laurence.Zhou@luxshare-ict.com: Initial Version
|
||||
*
|
||||
***********************************************************/
|
||||
EFuncRetCode LuxcJSONGetObjectStringArray(const cJSON* const psObject, const char* const pcKey, char (*pcArray)[MAXSIZE],int* piSize)
|
||||
{
|
||||
cJSON* pscJSONStringArray = NULL;
|
||||
cJSON* pscJSONStringTemp = NULL;
|
||||
if(NULL == psObject)
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(false == cJSON_HasObjectItem(psObject, pcKey))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
|
||||
if(NULL == piSize)
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(NULL == pcArray)
|
||||
{
|
||||
if(FUNC_OK == LuxcJSONGetObjectArraySize(psObject, pcKey, piSize))
|
||||
{
|
||||
return FUNC_OK;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(FUNC_FAILED == LuxcJSONGetObjectArraySize(psObject, pcKey, piSize))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
|
||||
if(NULL == (pscJSONStringArray = cJSON_GetObjectItem(psObject, pcKey)))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
|
||||
for (int i = 0; i < *piSize; ++i)
|
||||
{
|
||||
pscJSONStringTemp = cJSON_GetArrayItem(pscJSONStringArray, i);
|
||||
LuxStrcpy(pcArray[i],pscJSONStringTemp->valuestring);
|
||||
}
|
||||
return FUNC_OK;
|
||||
}
|
||||
return FUNC_OK;
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* Name:
|
||||
* LuxcJSONGetArrayRowColumnSize
|
||||
*
|
||||
* Summary:
|
||||
* Get the two-dimensional array's row and column
|
||||
*
|
||||
* Return Value:
|
||||
* EFuncRetCode(FUNC_FAILED or FUNC_OK)
|
||||
*
|
||||
* Parameter Input:
|
||||
* const cJSON* psObject -- The HEAD pointer of the CJSON entity
|
||||
* const char* const pcKey -- Key/Name
|
||||
* int* piRow -- Pointer that holds the row size
|
||||
* int* piColumn -- Pointer that holds the column size
|
||||
*
|
||||
* Parameter Output:
|
||||
* piRow,piColumn
|
||||
*
|
||||
* Author:
|
||||
* Laurence.Zhou@luxshare-ict.com: Initial Version
|
||||
*
|
||||
***********************************************************/
|
||||
EFuncRetCode LuxcJSONGetArrayRowColumnSize(const cJSON* const psObject, const char* const pcKey,int* piRow,int* piColumn)
|
||||
{
|
||||
cJSON* psArray =NULL;
|
||||
cJSON *psArray21 = NULL;
|
||||
|
||||
if(NULL == psObject)
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(false == cJSON_HasObjectItem(psObject, pcKey))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(NULL == piRow || NULL == piColumn)
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
|
||||
if(NULL == (psArray = cJSON_GetObjectItem(psObject, pcKey)))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
*piRow = cJSON_GetArraySize(psArray);
|
||||
|
||||
if(NULL == (psArray21 = cJSON_GetArrayItem(psArray, 0)))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
*piColumn = cJSON_GetArraySize(psArray21);
|
||||
return FUNC_OK;
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* Name:
|
||||
* LuxcJSONGetObjectIntArray2
|
||||
*
|
||||
* Summary:
|
||||
* Get the two-dimensional array
|
||||
*
|
||||
* Return Value:
|
||||
* EFuncRetCode(FUNC_FAILED or FUNC_OK)
|
||||
*
|
||||
* Parameter Input:
|
||||
* const cJSON* psObject -- The HEAD pointer of the CJSON entity
|
||||
* const char* const pcKey -- Key/Name
|
||||
* int (*piArray2)[MAXSIZE] -- Pointer that holds the two-dimensional arrray
|
||||
* int* piRow -- Pointer that holds the row size
|
||||
* int* piColumn -- Pointer that holds the column size
|
||||
*
|
||||
* Parameter Output:
|
||||
* piArray2,piRow,piColumn
|
||||
*
|
||||
* Author:
|
||||
* Laurence.Zhou@luxshare-ict.com: Initial Version
|
||||
*
|
||||
***********************************************************/
|
||||
EFuncRetCode LuxcJSONGetObjectIntArray2(const cJSON* const psObject, const char* const pcKey, int (*piArray2)[MAXSIZE],int* piRow, int* piColumn)
|
||||
{
|
||||
cJSON *psArray = NULL;
|
||||
cJSON *psArrayTemp = NULL;
|
||||
cJSON *psValueTemp = NULL;
|
||||
|
||||
if(NULL == psObject)
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(false == cJSON_HasObjectItem(psObject, pcKey))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(NULL == piRow || NULL == piColumn)
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
|
||||
if(NULL == piArray2)
|
||||
{
|
||||
if(FUNC_OK == LuxcJSONGetArrayRowColumnSize(psObject, pcKey, piRow, piColumn))
|
||||
{
|
||||
return FUNC_OK;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(FUNC_FAILED == LuxcJSONGetArrayRowColumnSize(psObject, pcKey, piRow, piColumn))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
|
||||
|
||||
if(NULL == (psArray = cJSON_GetObjectItem(psObject, pcKey)))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
|
||||
for (int i = 0; i < *piRow; ++i )
|
||||
{
|
||||
psArrayTemp = cJSON_GetArrayItem(psArray, i);
|
||||
for(int j = 0; j < *piColumn; ++j){
|
||||
psValueTemp = cJSON_GetArrayItem(psArrayTemp, j);
|
||||
piArray2[i][j] = psValueTemp->valueint;
|
||||
psValueTemp= NULL;
|
||||
}
|
||||
psArrayTemp = NULL;
|
||||
}
|
||||
|
||||
return FUNC_OK;
|
||||
}
|
||||
return FUNC_OK;
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* Name:
|
||||
* LuxcJSONGetObjectDoubleArray2
|
||||
*
|
||||
* Summary:
|
||||
* Get the two-dimensional array
|
||||
*
|
||||
* Return Value:
|
||||
* EFuncRetCode(FUNC_FAILED or FUNC_OK)
|
||||
*
|
||||
* Parameter Input:
|
||||
* const cJSON* psObject -- The HEAD pointer of the CJSON entity
|
||||
* const char* const pcKey -- Key/Name
|
||||
* double (*piArray2)[MAXSIZE] -- Pointer that holds the two-dimensional arrray
|
||||
* int* piRow -- Pointer that holds the row size
|
||||
* int* piColumn -- Pointer that holds the column size
|
||||
*
|
||||
* Parameter Output:
|
||||
* pdArray2,piRow,piColumn
|
||||
*
|
||||
* Author:
|
||||
* Laurence.Zhou@luxshare-ict.com: Initial Version
|
||||
*
|
||||
***********************************************************/
|
||||
EFuncRetCode LuxcJSONGetObjectDoubleArray2(const cJSON* const psObject, const char* const pcKey, double (*pdArray2)[MAXSIZE],int* piRow, int* piColumn)
|
||||
{
|
||||
cJSON *psArray = NULL;
|
||||
cJSON *psArrayTemp = NULL;
|
||||
cJSON *PsValueTemp = NULL;
|
||||
|
||||
if(NULL == psObject)
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(false == cJSON_HasObjectItem(psObject, pcKey))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(NULL == piRow || NULL == piColumn)
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
if(NULL == pdArray2)
|
||||
{
|
||||
if(FUNC_OK == LuxcJSONGetArrayRowColumnSize(psObject, pcKey, piRow, piColumn))
|
||||
{
|
||||
return FUNC_OK;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(FUNC_FAILED == LuxcJSONGetArrayRowColumnSize(psObject, pcKey, piRow, piColumn))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
|
||||
if(NULL == (psArray = cJSON_GetObjectItem(psObject, pcKey)))
|
||||
{
|
||||
return FUNC_FAILED;
|
||||
}
|
||||
for (int i = 0; i < *piRow; ++i )
|
||||
{
|
||||
psArrayTemp = cJSON_GetArrayItem(psArray, i);
|
||||
for(int j = 0; j < *piColumn; ++j)
|
||||
{
|
||||
PsValueTemp = cJSON_GetArrayItem(psArrayTemp, j);
|
||||
pdArray2[i][j] = PsValueTemp->valuedouble;
|
||||
PsValueTemp = NULL;
|
||||
}
|
||||
psArrayTemp = NULL;
|
||||
}
|
||||
return FUNC_OK;
|
||||
}
|
||||
return FUNC_OK;
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* Name:
|
||||
* LuxcJSONDelete
|
||||
*
|
||||
* Summary:
|
||||
* Delete a cJSON entity and all subentities
|
||||
*
|
||||
* Return Value:
|
||||
* EFuncRetCode(FUNC_FAILED or FUNC_OK)
|
||||
*
|
||||
* Parameter Input:
|
||||
* cJSON* psItem -- the HEAD pointer
|
||||
*
|
||||
* Parameter Output:
|
||||
* None
|
||||
*
|
||||
* Author:
|
||||
* Laurence.Zhou@luxshare-ict.com: Initial Version
|
||||
*
|
||||
***********************************************************/
|
||||
EFuncRetCode LuxcJSONDelete(cJSON* psItem)
|
||||
{
|
||||
if(NULL != psItem)
|
||||
{
|
||||
cJSON_Delete(psItem);
|
||||
}
|
||||
return FUNC_OK;
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* Name:
|
||||
* LuxcJSONFree
|
||||
*
|
||||
* Summary:
|
||||
* free object
|
||||
*
|
||||
* Return Value:
|
||||
* EFuncRetCode(FUNC_FAILED or FUNC_OK)
|
||||
*
|
||||
* Parameter Input:
|
||||
* cJSON* psItem -- the HEAD pointer
|
||||
*
|
||||
* Parameter Output:
|
||||
* None
|
||||
*
|
||||
* Author:
|
||||
* Laurence.Zhou@luxshare-ict.com: Initial Version
|
||||
*
|
||||
***********************************************************/
|
||||
EFuncRetCode LuxcJSONFree(void* psObject)
|
||||
{
|
||||
if(NULL != psObject)
|
||||
{
|
||||
cJSON_free(psObject);
|
||||
}
|
||||
return FUNC_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/***********************************************************
|
||||
* Copyright (C), 2021, LuxShare co.,
|
||||
*
|
||||
* File name : LuxcJSON
|
||||
*
|
||||
* Description :
|
||||
* JSON API
|
||||
*
|
||||
* History:
|
||||
*
|
||||
* <Date> <Author> <version> <Modification>
|
||||
* 2021/04/21 Laurence Zhou 0.01 First draft
|
||||
***********************************************************/
|
||||
|
||||
#ifndef LUX_JSON_API_H
|
||||
#define LUX_JSON_API_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "cJSON.h"
|
||||
#include "lux_system_api.h"
|
||||
|
||||
|
||||
#define MAXSIZE 128
|
||||
|
||||
#ifdef true
|
||||
#undef true
|
||||
#endif
|
||||
#define true ((cJSON_bool)1)
|
||||
#ifdef false
|
||||
#undef false
|
||||
#endif
|
||||
#define false ((cJSON_bool)0)
|
||||
|
||||
|
||||
extern cJSON* LuxcJSONParseJsonFile(char* pcFileName);
|
||||
extern char* LuxcJSONPrint(const cJSON* psItem);
|
||||
extern cJSON* LuxcJSONGetObjectItem(const cJSON* const psObject, const char* const pcKey);
|
||||
extern EFuncRetCode LuxcJSONGetObjectIntValue(const cJSON* const psObject, const char* const pcKey,int* piValue );
|
||||
extern EFuncRetCode LuxcJSONGetObjectDoubleValue(const cJSON* const psObject,const char* const pcKey, double* pdValue);
|
||||
extern EFuncRetCode LuxcJSONGetObjectStringValue(const cJSON* const psObject, const char* const pcKey, char* pcValue );
|
||||
extern EFuncRetCode LuxcJSONGetObjectBooleanValue(const cJSON* const psObject, const char* const pcKey, cJSON_bool* pbValue);
|
||||
extern EFuncRetCode LuxcJSONGetObjectArraySize(const cJSON* const psObject, const char* const pcKey, int* piSize);
|
||||
extern EFuncRetCode LuxcJSONGetObjectIntArray(const cJSON* const psObject, const char* const pcKey, int* piArray,int* piSize);
|
||||
extern EFuncRetCode LuxcJSONGetObjectDoubleArray(const cJSON* const psObject, const char* const pcKey, double* pdArray, int* piSize );
|
||||
extern EFuncRetCode LuxcJSONGetObjectStringArray(const cJSON* const psObject, const char* const pcKey, char (*pcArray)[MAXSIZE],int* piSize);
|
||||
extern EFuncRetCode LuxcJSONGetObjectIntArray2(const cJSON* const psObject, const char* const pcKey, int (*piArray2)[MAXSIZE],int* piRow, int* piColumn);
|
||||
extern EFuncRetCode LuxcJSONGetObjectDoubleArray2(const cJSON* const psObject, const char* const pcKey, double (*pdArray2)[MAXSIZE],int* piRow, int* piColumn);
|
||||
extern EFuncRetCode LuxcJSONDelete(cJSON* psItem);
|
||||
extern EFuncRetCode LuxcJSONFree(void* psObject);
|
||||
|
||||
EFuncRetCode LuxcJSONGetOjectStringSize(const cJSON* const psObject, const char* const pcKey, int *piSize);
|
||||
extern EFuncRetCode LuxcJSONGetArrayRowColumnSize(const cJSON* const psObject, const char* const pcKey, int* piRow,int* piColumn);
|
||||
|
||||
#endif /* LUX_JSON_API_H */
|
||||
+2701
File diff suppressed because it is too large
Load Diff
+123
@@ -0,0 +1,123 @@
|
||||
/***********************************************************
|
||||
* Copyright (C), 2021, LuxShare co.,
|
||||
*
|
||||
* File name : lux_system_api
|
||||
*
|
||||
* Description :
|
||||
* system or C API
|
||||
*
|
||||
* History:
|
||||
*
|
||||
* <Date> <Author> <version> <Modification>
|
||||
* 2021/03/23 chin 0.01 First draft
|
||||
* 2021/4/25 huangliang 0.02 add system calls
|
||||
***********************************************************/
|
||||
#ifndef __LUX_SYSTEM_API_H__
|
||||
#define __LUX_SYSTEM_API_H__
|
||||
#include <string.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#include "lux_base.h"
|
||||
#include <unistd.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <regex.h>
|
||||
#include <netdb.h> /* gethostbyname() */
|
||||
|
||||
#define F_OK 0
|
||||
|
||||
extern void* LuxMmap(void *addr, size_t length, int prot, int flags,int fd, off_t offset);
|
||||
extern int LuxMunmap(void *addr, size_t length);
|
||||
extern int LuxMsync(void *addr, size_t length, int flags);
|
||||
extern void* LuxMemset(void* pStr, int iValue, size_t szCount);
|
||||
extern EFuncRetCode LuxMemsetSafe(void* pDestStr, size_t szSize, int iValue, size_t szCount);
|
||||
extern void* LuxMemcpy(void* pDst, const void* pSrc, size_t szCount);
|
||||
extern EFuncRetCode LuxMemcpySafe(void* pDst, size_t szSize, const void* pSrc, size_t szCount);
|
||||
extern int LuxMemcmp(const void* pBuf1,const void* pBuf2,size_t szCount);
|
||||
extern char* LuxStrcpy(char* pcDestStr, const char* pcScrStr);
|
||||
extern char* LuxStrncpy(char* pcDestStr, const char* pcScrStr, size_t szCount);
|
||||
extern int LuxStrcmp(const char* pcStr1, const char* pcStr2);
|
||||
extern int LuxStrncmp(const char* pcStr1, const char* pcStr2, size_t szCount);
|
||||
extern size_t LuxStrlen(const char* pcStr);
|
||||
extern size_t LuxStrnlen(const char* pcStr, size_t szLen);
|
||||
extern char* LuxStrcat(char* pcDestStr, const char* pcSrcStr);
|
||||
extern char* LuxStrncat(char* pcDest, const char* pcSrc, size_t szCount);
|
||||
extern char* LuxStrstr(char* pcDestStr, const char* pcSrcStr);
|
||||
extern int LuxPrintf(const char* fmt,...);
|
||||
extern int LuxFprintf(FILE* fp, char* fmt, ...);
|
||||
extern int LuxDprintf(int fd, const char *fmt, ...);
|
||||
extern int LuxSprintf(char* pcBuf, const char* fmt, ...);
|
||||
extern int LuxSnprintf(char* pcBuf, size_t szSize, const char* fmt, ...);
|
||||
extern int LuxSscanf(const char* pcBuf, const char* fmt, ...);
|
||||
extern int LuxScanf(const char* fmt, ...);
|
||||
extern int LuxFscanf(FILE* stream, const char* fmt, ...);
|
||||
extern int LuxOpenAndCreat(const char* pcPathname,int iFlags,mode_t mode);
|
||||
extern int LuxOpen(const char* pcPathname,int iFlags);
|
||||
extern int LuxClose(int fd);
|
||||
extern ssize_t LuxRead(int fd, void* pBuf, size_t szCount);
|
||||
extern ssize_t LuxWrite(int fd, void* pBuf, size_t szCount);
|
||||
extern off_t LuxLseek(int fd, off_t offset, int iWhence);
|
||||
extern FILE* LuxFopen(const char* pcPathname, const char* pcMode);
|
||||
extern int LuxFclose(FILE* stream);
|
||||
extern size_t LuxFread(void* ptr, size_t szSize, size_t szNmemb, FILE* stream);
|
||||
extern size_t LuxFwrite(const void* ptr, size_t szSize, size_t szNmemb, FILE* stream);
|
||||
extern int LuxFseek(FILE *stream, long offset, int iWhence);
|
||||
extern long LuxFtell(FILE* stream);
|
||||
extern void LuxRewind(FILE* stream);
|
||||
extern EFuncRetCode LuxSystem(char* pcCmdStr);
|
||||
extern FILE* LuxPopen(const char* pcCmdStr, const char* pcType);
|
||||
extern int LuxPclose(FILE* stream);
|
||||
extern void* LuxDlopen(const char* pcFilename, int iFlags);
|
||||
extern int LuxDlclose(void* pDlhandle);
|
||||
extern void* LuxDlsym(void* pDlhandle, const char* pcSymbol);
|
||||
extern char* LuxDlerror(void);
|
||||
extern time_t LuxTime(time_t* timep);
|
||||
extern char* LuxCtime(const time_t* timep);
|
||||
extern char* LuxAsctime(const struct tm* tm);
|
||||
extern struct tm* LuxGmtime(const time_t* timep);
|
||||
extern struct tm* LuxLocaltime(const time_t* timep);
|
||||
extern time_t LuxMktime(struct tm* tm);
|
||||
extern void* LuxMalloc(size_t size);
|
||||
extern void* LuxCalloc(size_t nmemb, size_t size);
|
||||
extern void* LuxRealloc(void* ptr, size_t size);
|
||||
extern void LuxFree(void* ptr);
|
||||
extern void* LuxMemchr(const void* pStr, int iCharacter, size_t szCount);
|
||||
extern char* LuxStrchr(const char* pcStr, int iCharacter);
|
||||
extern char* LuxStrtok(char* pcStr, const char* pcDelim);
|
||||
extern int LuxFeof(FILE* stream);
|
||||
extern int LuxFflush(FILE* stream);
|
||||
extern int LuxRemove(const char* pcFilename);
|
||||
extern int LuxRename(const char* pcOldFilename, const char* pcNewFilename);
|
||||
extern int LuxRand(void);
|
||||
extern void LuxSrand(unsigned int iSeed);
|
||||
|
||||
extern int LuxAccess(const char* pcPathName,int mode);
|
||||
|
||||
extern int LuxClosedir(DIR* psDir);
|
||||
extern struct dirent* LuxReaddir(DIR* psDir);
|
||||
extern int LuxChdir(const char* pcPathName);
|
||||
extern int LuxRmdir(const char* pcPathname);
|
||||
extern int LuxChmod(const char* pcFilename,mode_t mode);
|
||||
extern int LuxMkdir(const char* pcPathName,mode_t mode);
|
||||
extern int LuxClockgettime (__clockid_t ClockId, struct timespec* psTimeSpec);
|
||||
extern int LuxClocksettime (__clockid_t ClockId, struct timespec* psTimeSpec);
|
||||
|
||||
extern int LuxFgetc(FILE *pstream);
|
||||
extern int LuxFputc(int chara, FILE *pstream);
|
||||
extern int LuxFerror(FILE *pstream);
|
||||
extern DIR* LuxOpendir(const char *pcdirname);
|
||||
|
||||
extern const char* LuxInetNtop(int af, const void* psrc, char* pcDst, size_t size);
|
||||
extern int LuxInetPton(int af, const char *pcSrc, void *pDst);
|
||||
extern char* LuxInetNtoa(struct in_addr in);
|
||||
extern int LuxSocket(int domain, int type, int protocol);
|
||||
extern int LuxIoctl(int fd, unsigned long request, ...);
|
||||
extern void LuxReboot(int iFlag);
|
||||
extern int LuxRegcomp(regex_t *compiled, const char *pattern, int cflags);
|
||||
extern int LuxRegexec(regex_t *compiled, char *string, size_t nmatch, regmatch_t matchptr[], int eflags);
|
||||
extern void LuxRegfree(regex_t *compiled);
|
||||
extern int LuxGetaddrinfo( const char *hostname, const char *service, const struct addrinfo *hints, struct addrinfo **result );
|
||||
extern int LuxAtoi(const char* paddr);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user