apps/fsutils/inih: New package. inih (INI Not Invented Here) is a simple .INI file parser written in C. https://github.com/benhoyt/inih
This commit is contained in:
parent
0b8e12b8cf
commit
4ab6042a31
3
fsutils/inih/.gitignore
vendored
Normal file
3
fsutils/inih/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
/inih-*
|
||||||
|
/*.tar.gz
|
||||||
|
/Make.dep
|
54
fsutils/inih/Kconfig
Normal file
54
fsutils/inih/Kconfig
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#
|
||||||
|
# For a description of the syntax of this configuration file,
|
||||||
|
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||||
|
#
|
||||||
|
|
||||||
|
menuconfig FSUTILS_INIH
|
||||||
|
bool "inih ini file parser"
|
||||||
|
default n
|
||||||
|
---help---
|
||||||
|
inih (INI Not Invented Here) is a simple .INI file parser written in C.
|
||||||
|
https://github.com/benhoyt/inih
|
||||||
|
|
||||||
|
Library is licensed under the New BSD license. See LICENSE.txt file in
|
||||||
|
the downloaded code for license details
|
||||||
|
|
||||||
|
if FSUTILS_INIH
|
||||||
|
|
||||||
|
config INIH_MULTI_LINE_ENTRIES
|
||||||
|
bool "Enable multiline entries"
|
||||||
|
default n
|
||||||
|
---help---
|
||||||
|
This makes inih to support multi-line entries in the style of Python's
|
||||||
|
ConfigParser.
|
||||||
|
|
||||||
|
config INIH_USE_MALLOC
|
||||||
|
bool "Enable use of malloc()"
|
||||||
|
default n
|
||||||
|
---help---
|
||||||
|
If you enable this, inih will be using malloc() and realloc() to
|
||||||
|
allocate needed memory for line-by-line file parsing.
|
||||||
|
|
||||||
|
If you disable this, inih will be using only stack allocated memory
|
||||||
|
for parsing file.
|
||||||
|
|
||||||
|
if INIH_USE_MALLOC
|
||||||
|
|
||||||
|
config INIH_INITIAL_ALLOC
|
||||||
|
int "Initial allocation size"
|
||||||
|
default 128
|
||||||
|
---help---
|
||||||
|
inih will allocate this ammount of memory and will double it when
|
||||||
|
line is bigger than currently allocated memory.
|
||||||
|
|
||||||
|
endif # INIH_USE_MALLOC
|
||||||
|
|
||||||
|
config INIH_MAX_LINE
|
||||||
|
int "Maximum line size"
|
||||||
|
default 80
|
||||||
|
range 4 4096
|
||||||
|
---help---
|
||||||
|
Maximum size of a single line. It doesn't matter if you have malloc()
|
||||||
|
enabled or not, you can't exceed this value.
|
||||||
|
|
||||||
|
endif # FSUTILS_INIH
|
38
fsutils/inih/Make.defs
Normal file
38
fsutils/inih/Make.defs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
############################################################################
|
||||||
|
# apps/fsutils/inih/Make.defs
|
||||||
|
#
|
||||||
|
# Copyright (C) 2019 Michał Łyszczek. All rights reserved.
|
||||||
|
# Author: Michał Łyszczek <michal.lyszczek@bofc.pl>
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
#
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in
|
||||||
|
# the documentation and/or other materials provided with the
|
||||||
|
# distribution.
|
||||||
|
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
# used to endorse or promote products derived from this software
|
||||||
|
# without specific prior written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_FSUTILS_INIH),y)
|
||||||
|
CONFIGURED_APPS += fsutils/inih
|
||||||
|
endif
|
108
fsutils/inih/Makefile
Normal file
108
fsutils/inih/Makefile
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
############################################################################
|
||||||
|
# apps/fsutils/inih/Makefile
|
||||||
|
#
|
||||||
|
# Copyright (C) 2019 Michał Łyszczek. All rights reserved.
|
||||||
|
# Author: Michał Łyszczek <michal.lyszczek@bofc.pl>
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
#
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in
|
||||||
|
# the documentation and/or other materials provided with the
|
||||||
|
# distribution.
|
||||||
|
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
# used to endorse or promote products derived from this software
|
||||||
|
# without specific prior written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
-include $(TOPDIR)/Make.defs
|
||||||
|
|
||||||
|
WGET = wget
|
||||||
|
CP = cp -R
|
||||||
|
UNPACK = tar -xzf
|
||||||
|
PACKEXT = .tar.gz
|
||||||
|
NXTOOLSDIR = $(APPDIR)/tools
|
||||||
|
|
||||||
|
INIH_GITHUB_NAME = benhoyt/inih
|
||||||
|
INIH_VERSION = r42
|
||||||
|
INIH_SRC_SHA256 = 53ac3591be39a004ddc7874d0a57e7b9bc92be14192808bbef510c5c533cb1d8
|
||||||
|
INIH_EXT = tar.gz
|
||||||
|
INIH_SOURCES = inih-$(INIH_VERSION)
|
||||||
|
INIH_TARBALL = $(INIH_VERSION).$(INIH_EXT)
|
||||||
|
INIH_URL = https://github.com/$(INIH_GITHUB_NAME)/archive
|
||||||
|
|
||||||
|
CSRCS = $(INIH_SOURCES)/ini.c
|
||||||
|
|
||||||
|
# inih configuration from Kconfig
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_INIH_MULTI_LINE_ENTRIES),y)
|
||||||
|
CFLAGS += -DINI_ALLOW_MULTILINE=1
|
||||||
|
else
|
||||||
|
CFLAGS += -DINI_ALLOW_MULTILINE=0
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_INIH_USE_MALLOC),y)
|
||||||
|
CFLAGS += -DINI_USE_STACK=0
|
||||||
|
CFLAGS += -DINI_ALLOW_REALLOC=1
|
||||||
|
CFLAGS += -DINI_INITIAL_ALLOC=$(CONFIG_INIH_INITIAL_ALLOC)
|
||||||
|
else
|
||||||
|
CFLAGS += -DINI_USE_STACK=1
|
||||||
|
CFLAGS += -DINI_ALLOW_REALLOC=0
|
||||||
|
endif
|
||||||
|
|
||||||
|
CFLAGS += -DINI_MAX_LINE=$(CONFIG_INIH_MAX_LINE)
|
||||||
|
|
||||||
|
# compile-time configuration of inih
|
||||||
|
|
||||||
|
CFLAGS += -DINI_ALLOW_BOM=0
|
||||||
|
CFLAGS += -DINI_ALLOW_INLINE_COMMENTS=1
|
||||||
|
CFLAGS += -DINI_STOP_ON_FIRST_ERROR=0
|
||||||
|
CFLAGS += -DINI_HANDLER_LINENO=1
|
||||||
|
|
||||||
|
# building of inih
|
||||||
|
|
||||||
|
$(INIH_TARBALL):
|
||||||
|
@echo "Downloading: $@"
|
||||||
|
$(Q) $(WGET) -O $@ $(INIH_URL)/$@
|
||||||
|
${Q} $(NXTOOLSDIR)/check-hash.sh sha256 $(INIH_SRC_SHA256) $@
|
||||||
|
$(Q) touch $@
|
||||||
|
|
||||||
|
$(INIH_SOURCES): $(INIH_TARBALL)
|
||||||
|
@echo "Unpacking $< -> $@"
|
||||||
|
$(Q) $(call DELDIR, $@)
|
||||||
|
$(Q) $(UNPACK) $<
|
||||||
|
$(Q) touch $@
|
||||||
|
|
||||||
|
create_includes:
|
||||||
|
$(Q) $(CP) $(INIH_SOURCES)/ini.h $(APPDIR)/include/fsutils
|
||||||
|
|
||||||
|
context:: $(INIH_SOURCES)
|
||||||
|
$(Q) $(MAKE) create_includes
|
||||||
|
|
||||||
|
clean::
|
||||||
|
$(Q) $(call DELFILE, $(APPDIR)/include/fsutils/ini.h)
|
||||||
|
$(Q) $(foreach COBJ, $(COBJS), $(call DELFILE, $(COBJ)))
|
||||||
|
|
||||||
|
distclean::
|
||||||
|
$(Q) $(call DELDIR, $(INIH_SOURCES))
|
||||||
|
$(Q) $(call DELDIR, $(INIH_TARBALL))
|
||||||
|
|
||||||
|
include $(APPDIR)/Application.mk
|
Loading…
x
Reference in New Issue
Block a user