mirror of
https://github.com/LuckfoxTECH/luckfox-pico.git
synced 2026-01-18 03:28:19 +01:00
* project/app : Add uvc_app_tiny application Signed-off-by: luckfox-eng29 <eng29@luckfox.com> * project/cfg/BoardConfig_IPC/overlay : Add Ubuntu system support for Rockit and RKNN libraries Signed-off-by: luckfox-eng29 <eng29@luckfox.com> * sysdrv/source/kernel/drivers/of : Add support for dynamic device tree Signed-off-by: eng29 <eng29@luckfox.com> * sysdrv/source/kernel/drivers/usb/serial : Add CH343 driver support Signed-off-by: eng29 <eng29@luckfox.com> * sysdrv/source/kernel/drivers/staging : Disable partial logging of fbtft Signed-off-by: eng29 <eng29@luckfox.com> * sysdrv/source/kernel/drivers/pinctrl/pinctrl-rockchip.h : Fix pinctrl configuration failure issue Signed-off-by: eng29 <eng29@luckfox.com> * sysdrv/source/kernel/include/dt-bindings/soc/rockchip,boot-mode.h : Add support for the reboot U-Boot command in the BusyBox system Signed-off-by: eng29 <eng29@luckfox.com> * sysdrv/source/kernel/drivers/video : Add logo display support for LF40-480480-ARK and LF40-720720-ARK Signed-off-by: eng29 <eng29@luckfox.com> * sysdrv/source/kernel/arch/arm/boot/dts : Add device tree files for the Luckfox RV1103/RV1106 series boards Signed-off-by: eng29 <eng29@luckfox.com> * sysdrv/source/kernel/arch/arm/configs : Add device tree files for the Luckfox RV1103/RV1106 series boards Signed-off-by: eng29 <eng29@luckfox.com> * sysdrv/source/uboot/u-boot/drivers/mmc/mmc.c : Fix the issue where some Micro SD cards fail to boot Signed-off-by: eng29 <eng29@luckfox.com> * sysdrv/source/uboot/u-boot/common/image-fit.c : Add U-Boot support for luckfox-config Signed-off-by: eng29 <eng29@luckfox.com> * sysdrv/source/uboot/rkbin/bin/rv11 : Add firmware with a serial baud rate of 115200 and back up the original firmware Signed-off-by: eng29 <eng29@luckfox.com> * sysdrv/source/uboot/u-boot/arch/arm/dts : Add device tree files for the Luckfox RV1103/RV1106 series boards Signed-off-by: eng29 <eng29@luckfox.com> * sysdrv/source/uboot/u-boot/configs : Add defconfig files for the Luckfox RV1103/RV1106 series boards Signed-off-by: eng29 <eng29@luckfox.com> * sysdrv/source/uboot/u-boot : Add support for the reboot U-Boot command in the BusyBox system Signed-off-by: eng29 <eng29@luckfox.com> * sysdrv/source/kernel/drivers/media/i2c : Add MIS5001 driver support Signed-off-by: eng29 <eng29@luckfox.com> * sysdrv/source/kernel/arch/arm : Add default support for MIS5001 on Luckfox RV1106 series boards Signed-off-by: eng29 <eng29@luckfox.com> * sysdrv/tools/board : Delete irrelevant overwrite files and patch files Signed-off-by: eng29 <eng29@luckfox.com> * sysdrv/drv_ko/insmod_ko.sh : Register mis5001 driver during boot process Signed-off-by: luckfox-eng29 <eng29@luckfox.com> * media/isp/release_camera_engine_rkaiq_rv1106_arm-rockchip830-linux-uclibcgnueabihf/isp_iqfiles : Add mis5001 iqfile Signed-off-by: luckfox-eng29 <eng29@luckfox.com> * project/app/rkipc/rkipc/src/rv1106_ipc : Add rkipc application support for mis5001 sensor Signed-off-by: eng29 <eng29@luckfox.com> * project/cfg/BoardConfig_IPC : Enable default retrieval of mis5001 iqfile and include ROCKIT and RKNN libraries of RV1106 series board Signed-off-by: luckfox-eng29 <eng29@luckfox.com> * project/build.sh : Remove operations related to applying and deleting patches Signed-off-by: eng29 <eng29@luckfox.com> * project/build.sh : Modify build system menu description; Apply lightweight system processing only during Buildroot and BusyBox system compilation Signed-off-by: eng29 <eng29@luckfox.com> * sysdrv/tools/board/buildroot/luckfox_pico_w_defconfig : Add pppd and pgrep for 4G module Signed-off-by: luckfox-eng29 <eng29@luckfox.com> * sysdrv/tools/board/kernel/rv1106-luckfox-pico-ultra-ipc.dtsi : Add uart4m1 support for lastest luckfox-config tool Signed-off-by: eng29 <eng29@luckfox.com> --------- Signed-off-by: luckfox-eng29 <eng29@luckfox.com> Signed-off-by: eng29 <eng29@luckfox.com>
171 lines
6.5 KiB
C
171 lines
6.5 KiB
C
|
|
/*-------------------------------------------------------------------------*/
|
|
/**
|
|
@file dictionary.h
|
|
@author N. Devillard
|
|
@brief Implements a dictionary for string variables.
|
|
|
|
This module implements a simple dictionary object, i.e. a list
|
|
of string/string associations. This object is useful to store e.g.
|
|
informations retrieved from a configuration file (ini files).
|
|
*/
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
#ifndef _DICTIONARY_H_
|
|
#define _DICTIONARY_H_
|
|
|
|
/*---------------------------------------------------------------------------
|
|
Includes
|
|
---------------------------------------------------------------------------*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*---------------------------------------------------------------------------
|
|
New types
|
|
---------------------------------------------------------------------------*/
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
/**
|
|
@brief Dictionary object
|
|
|
|
This object contains a list of string/string associations. Each
|
|
association is identified by a unique string key. Looking up values
|
|
in the dictionary is speeded up by the use of a (hopefully collision-free)
|
|
hash function.
|
|
*/
|
|
/*-------------------------------------------------------------------------*/
|
|
typedef struct _dictionary_ {
|
|
int n; /** Number of entries in dictionary */
|
|
ssize_t size; /** Storage size */
|
|
char **val; /** List of string values */
|
|
char **key; /** List of string keys */
|
|
unsigned *hash; /** List of hash values for keys */
|
|
} dictionary;
|
|
|
|
/*---------------------------------------------------------------------------
|
|
Function prototypes
|
|
---------------------------------------------------------------------------*/
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
/**
|
|
@brief Compute the hash key for a string.
|
|
@param key Character string to use for key.
|
|
@return 1 unsigned int on at least 32 bits.
|
|
|
|
This hash function has been taken from an Article in Dr Dobbs Journal.
|
|
This is normally a collision-free function, distributing keys evenly.
|
|
The key is stored anyway in the struct so that collision can be avoided
|
|
by comparing the key itself in last resort.
|
|
*/
|
|
/*--------------------------------------------------------------------------*/
|
|
unsigned dictionary_hash(const char *key);
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
/**
|
|
@brief Create a new dictionary object.
|
|
@param size Optional initial size of the dictionary.
|
|
@return 1 newly allocated dictionary object.
|
|
|
|
This function allocates a new dictionary object of given size and returns
|
|
it. If you do not know in advance (roughly) the number of entries in the
|
|
dictionary, give size=0.
|
|
*/
|
|
/*--------------------------------------------------------------------------*/
|
|
dictionary *dictionary_new(size_t size);
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
/**
|
|
@brief Delete a dictionary object
|
|
@param d dictionary object to deallocate.
|
|
@return void
|
|
|
|
Deallocate a dictionary object and all memory associated to it.
|
|
*/
|
|
/*--------------------------------------------------------------------------*/
|
|
void dictionary_del(dictionary *vd);
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
/**
|
|
@brief Get a value from a dictionary.
|
|
@param d dictionary object to search.
|
|
@param key Key to look for in the dictionary.
|
|
@param def Default value to return if key not found.
|
|
@return 1 pointer to internally allocated character string.
|
|
|
|
This function locates a key in a dictionary and returns a pointer to its
|
|
value, or the passed 'def' pointer if no such key can be found in
|
|
dictionary. The returned character pointer points to data internal to the
|
|
dictionary object, you should not try to free it or modify it.
|
|
*/
|
|
/*--------------------------------------------------------------------------*/
|
|
const char *dictionary_get(const dictionary *d, const char *key,
|
|
const char *def);
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
/**
|
|
@brief Set a value in a dictionary.
|
|
@param d dictionary object to modify.
|
|
@param key Key to modify or add.
|
|
@param val Value to add.
|
|
@return int 0 if Ok, anything else otherwise
|
|
|
|
If the given key is found in the dictionary, the associated value is
|
|
replaced by the provided one. If the key cannot be found in the
|
|
dictionary, it is added to it.
|
|
|
|
It is Ok to provide a NULL value for val, but NULL values for the dictionary
|
|
or the key are considered as errors: the function will return immediately
|
|
in such a case.
|
|
|
|
Notice that if you dictionary_set a variable to NULL, a call to
|
|
dictionary_get will return a NULL value: the variable will be found, and
|
|
its value (NULL) is returned. In other words, setting the variable
|
|
content to NULL is equivalent to deleting the variable from the
|
|
dictionary. It is not possible (in this implementation) to have a key in
|
|
the dictionary without value.
|
|
|
|
This function returns non-zero in case of failure.
|
|
*/
|
|
/*--------------------------------------------------------------------------*/
|
|
int dictionary_set(dictionary *vd, const char *key, const char *val);
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
/**
|
|
@brief Delete a key in a dictionary
|
|
@param d dictionary object to modify.
|
|
@param key Key to remove.
|
|
@return void
|
|
|
|
This function deletes a key in a dictionary. Nothing is done if the
|
|
key cannot be found.
|
|
*/
|
|
/*--------------------------------------------------------------------------*/
|
|
void dictionary_unset(dictionary *d, const char *key);
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
/**
|
|
@brief Dump a dictionary to an opened file pointer.
|
|
@param d Dictionary to dump
|
|
@param f Opened file pointer.
|
|
@return void
|
|
|
|
Dumps a dictionary onto an opened file pointer. Key pairs are printed out
|
|
as @c [Key]=[Value], one per line. It is Ok to provide stdout or stderr as
|
|
output file pointers.
|
|
*/
|
|
/*--------------------------------------------------------------------------*/
|
|
void dictionary_dump(const dictionary *d, FILE *out);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|