Skip to content

Commit 89b66b2

Browse files
committed
netutils: Add BARE
BARE is a simple binary representation for structured application data. cbare, the BARE implementation ported by this commit, is an I/O agnostic C implementation of the BARE message encoding. Signed-off-by: Jiri Vlasak <jvlasak@elektroline.cz>
1 parent 57ced95 commit 89b66b2

5 files changed

Lines changed: 161 additions & 0 deletions

File tree

LICENSE

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,3 +2248,29 @@ AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22482248
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
22492249
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
22502250
POSSIBILITY OF SUCH DAMAGE.
2251+
2252+
2253+
netutils/bare/
2254+
==============
2255+
2256+
MIT License
2257+
2258+
Copyright (c) 2022 Frank Smit
2259+
2260+
Permission is hereby granted, free of charge, to any person obtaining a copy
2261+
of this software and associated documentation files (the "Software"), to deal
2262+
in the Software without restriction, including without limitation the rights
2263+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2264+
copies of the Software, and to permit persons to whom the Software is
2265+
furnished to do so, subject to the following conditions:
2266+
2267+
The above copyright notice and this permission notice shall be included in all
2268+
copies or substantial portions of the Software.
2269+
2270+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2271+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2272+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2273+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2274+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2275+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2276+
SOFTWARE.

netutils/bare/Kconfig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
config NETUTILS_BARE
2+
bool "Binary Application Record Encoding (BARE)"
3+
default n
4+
depends on ALLOW_MIT_COMPONENTS
5+
---help---
6+
BARE is a simple binary representation for structured
7+
application data.
8+
9+
See https://baremessages.org/
10+
11+
cbare is an MIT-licensed I/O agnostic C implementation of the
12+
BARE message encoding that is used when this option is enabled.
13+
14+
if NETUTILS_BARE
15+
16+
config NETUTILS_BARE_TEST
17+
bool "Enable baretest"
18+
default n
19+
---help---
20+
Enable baretest -- BARE test application.
21+
22+
endif

netutils/bare/Make.defs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
############################################################################
2+
# apps/netutils/bare/Make.defs
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more
7+
# contributor license agreements. See the NOTICE file distributed with
8+
# this work for additional information regarding copyright ownership. The
9+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
# "License"); you may not use this file except in compliance with the
11+
# License. You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations
19+
# under the License.
20+
#
21+
############################################################################
22+
23+
ifneq ($(CONFIG_NETUTILS_BARE),)
24+
CONFIGURED_APPS += $(APPDIR)/netutils/bare
25+
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/netutils/bare/cbare/src
26+
CXXFLAGS += ${INCDIR_PREFIX}$(APPDIR)/netutils/bare/cbare/src
27+
endif

netutils/bare/Makefile

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
############################################################################
2+
# apps/netutils/bare/Makefile
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more
7+
# contributor license agreements. See the NOTICE file distributed with
8+
# this work for additional information regarding copyright ownership. The
9+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
# "License"); you may not use this file except in compliance with the
11+
# License. You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations
19+
# under the License.
20+
#
21+
############################################################################
22+
23+
include $(APPDIR)/Make.defs
24+
25+
BARE_CBARE_DIR = cbare
26+
27+
DEPPATH += --dep-path $(BARE_CBARE_DIR)$(DELIM)src
28+
VPATH += :$(BARE_CBARE_DIR)$(DELIM)src
29+
30+
CFLAGS += -I$(BARE_CBARE_DIR)/src
31+
32+
CSRCS = $(BARE_CBARE_DIR)/src/alloc.c
33+
CSRCS += $(BARE_CBARE_DIR)/src/cbare.c
34+
CSRCS += $(BARE_CBARE_DIR)/src/die.c
35+
36+
ifneq ($(CONFIG_NETUTILS_BARE_TEST),)
37+
38+
PROGNAME = baretest
39+
PRIORITY = 100
40+
STACKSIZE = 2048
41+
MODULE = y
42+
43+
MAINSRC = $(BARE_CBARE_DIR)/test/baretest.c
44+
45+
endif
46+
47+
$(BARE_CBARE_DIR):
48+
$(Q) echo "Cloning cbare repo..."
49+
$(Q) git clone --depth=1 https://git.sr.ht/~fsx/cbare
50+
$(Q) patch -p1 --directory=cbare < cbare_porting_for_nuttx.patch
51+
$(Q) touch $(BARE_CBARE_DIR)
52+
53+
context:: $(BARE_CBARE_DIR)
54+
55+
distclean::
56+
$(call DELDIR, $(BARE_CBARE_DIR))
57+
58+
include $(APPDIR)/Application.mk
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
diff --git i/src/cbare.c w/src/cbare.c
2+
index 208639f..a3081fb 100644
3+
--- i/src/cbare.c
4+
+++ w/src/cbare.c
5+
@@ -4,7 +4,9 @@
6+
#include "cbare.h"
7+
#include "utf8.h"
8+
9+
+#ifndef UNUSED
10+
#define UNUSED(x) (void)(x)
11+
+#endif
12+
13+
enum {
14+
U8SZ = 1,
15+
diff --git i/test/baretest.c w/test/baretest.c
16+
index 1561f4c..9df740f 100644
17+
--- i/test/baretest.c
18+
+++ w/test/baretest.c
19+
@@ -10,7 +10,9 @@
20+
#include "alloc.h"
21+
#include "die.h"
22+
23+
+#ifndef UNUSED
24+
#define UNUSED(x) (void)(x)
25+
+#endif
26+
27+
#define ARRLEN(a) sizeof(a)/sizeof(a[0])
28+

0 commit comments

Comments
 (0)