commit 62214fdbedd35c931c12346672bd21d77d0c333a
Author: finwo <finwo@pm.me>
Date: Wed, 26 Aug 2026 20:57:46 +0200
Project init
Diffstat:
11 files changed, 347 insertions(+), 0 deletions(-)
diff --git a/.dep b/.dep
@@ -0,0 +1 @@
+finwo/buf https://git.finwo.net/lib/buf.c/archives/heads/main.tar.gz
diff --git a/.dep.export b/.dep.export
@@ -0,0 +1 @@
+include/finwo/cnfparse.h src/cnfparse.h
diff --git a/.editorconfig b/.editorconfig
@@ -0,0 +1,13 @@
+# 2d0e4a3f-ac19-430c-bf1b-46c68651ce21
+root = true
+
+[*]
+end_of_line = lf
+insert_final_newline = true
+charset = utf-8
+indent_size = 2
+indent_style = space
+trim_trailing_whitespace = true
+
+[Makefile*]
+indent_style = tab
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1,3 @@
+*.o
+/lib/
+/cnfparse_test
diff --git a/LICENSE.md b/LICENSE.md
@@ -0,0 +1,34 @@
+Copyright (c) 2026 finwo
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to use, copy,
+modify, and distribute the Software, subject to the following conditions:
+
+ 1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form, or any public offering of the Software
+ (including hosted or managed services), must reproduce the above copyright
+ notice, this list of conditions, and the following disclaimer in the
+ documentation and/or other materials provided.
+
+ 3. Any redistribution or public offering of the Software must clearly attribute
+ the Software to the original copyright holder, reference this License, and
+ include a link to the official project repository or website.
+
+ 4. The Software may not be renamed, rebranded, or marketed in a manner that
+ implies it is an independent or proprietary product. Derivative works must
+ clearly state that they are based on the Software.
+
+ 5. Modifications to copies of the Software must carry prominent notices stating
+ that changes were made, the nature of the modifications, and the date of the
+ modifications.
+
+Any violation of these conditions terminates the permissions granted herein.
+
+THIS 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 COPYRIGHT
+HOLDER OR CONTRIBUTORS 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.
diff --git a/Makefile b/Makefile
@@ -0,0 +1,34 @@
+BIN?=cnfparse_test
+
+LIBS:=
+SRC:=
+INCLUDES:=
+INCLUDES+=-I src
+
+LDFLAGS:=
+CFLAGS?=-Wall -s -O2
+
+include lib/.dep/config.mk
+
+SRC+=src/cnfparse.c
+SRC+=test/main.c
+
+OBJ:=$(SRC:.c=.o)
+OBJ:=$(OBJ:.cc=.o)
+
+CFLAGS+=$(INCLUDES)
+
+LDFLAGS+=$(CFLAGS)
+
+.PHONY: default
+default: $(BIN)
+
+.c.o:
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+$(BIN): $(OBJ)
+ $(CC) $(LDFLAGS) $(OBJ) -o $@
+
+.PHONY: clean
+clean:
+ rm -rf $(OBJ)
diff --git a/export.mk b/export.mk
@@ -0,0 +1 @@
+SRC+={{module.dirname}}/src/cnfparse.c
diff --git a/src/cnfparse.c b/src/cnfparse.c
@@ -0,0 +1,7 @@
+#include "finwo/buf.h"
+
+#include "cnfparse.h"
+
+
+
+
diff --git a/src/cnfparse.h b/src/cnfparse.h
@@ -0,0 +1,6 @@
+#ifndef __FINWO_CNFPARSE_H__
+#define __FINWO_CNFPARSE_H__
+
+
+
+#endif // __FINWO_CNFPARSE_H__
diff --git a/test/assert.h b/test/assert.h
@@ -0,0 +1,242 @@
+/// assert.h
+/// ========
+///
+/// Single-file unit-testing library for C
+///
+/// Features
+/// --------
+///
+/// - Single header file, no other library dependencies
+/// - Simple ANSI C. The library should work with virtually every C(++) compiler on
+/// virtually any playform
+/// - Reporting of assertion failures, including the expression and location of the
+/// failure
+/// - Stops test on first failed assertion
+/// - ANSI color output for maximum visibility
+/// - Easily embeddable in applications for runtime tests or separate testing
+/// applications
+///
+/// Todo
+/// ----
+///
+/// - Disable assertions on definition, to allow production build without source modifications
+///
+/// Example Usage
+/// -------------
+///
+/// ```C
+/// #include "finwo/assert.h"
+/// #include "mylib.h"
+///
+/// void test_sheep() {
+/// ASSERT("Sheep are cool", are_sheep_cool());
+/// ASSERT_EQUALS(4, sheep.legs);
+/// }
+///
+/// void test_cheese() {
+/// ASSERT("Cheese is tangy", cheese.tanginess > 0);
+/// ASSERT_STRING_EQUALS("Wensleydale", cheese.name);
+/// }
+///
+/// int main() {
+/// RUN(test_sheep);
+/// RUN(test_cheese);
+/// return TEST_REPORT();
+/// }
+/// ```
+///
+/// To run the tests, compile the tests as a binary and run it.
+
+#ifndef __TINYTEST_INCLUDED_H__
+#define __TINYTEST_INCLUDED_H__
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+///
+/// Helper function for string comparison to avoid NULL warnings
+///
+static inline int _string_equals(const char *a, const char *b) {
+ if (a == NULL && b == NULL) return 1;
+ if (a == NULL || b == NULL) return 0;
+ return strcmp(a, b) == 0;
+}
+
+///
+/// API
+/// ---
+///
+
+///
+/// ### Macros
+///
+
+
+/// <details>
+/// <summary>ASSERT(msg, expression)</summary>
+///
+/// Perform an assertion
+///<C
+#define ASSERT(msg, expression) if (!tap_assert(__FILE__, __LINE__, (msg), (#expression), (expression) ? 1 : 0)) return
+///>
+/// </details>
+
+
+/// <details>
+/// <summary>ASSERT_EQUALS(expected, actual)</summary>
+///
+/// Perform an equal assertion
+///<C
+/* Convenient assertion methods */
+/* TODO: Generate readable error messages for assert_equals or assert_str_equals */
+#define ASSERT_EQUALS(expected, actual) ASSERT((#actual), (expected) == (actual))
+///>
+/// </details>
+
+/// <details>
+/// <summary>ASSERT_STRING_EQUALS(expected, actual)</summary>
+///
+/// Perform an equal string assertion
+///<
+#define ASSERT_STRING_EQUALS(expected, actual) ASSERT((#actual), _string_equals((expected),(actual)))
+///>
+/// </details>
+
+/// <details>
+/// <summary>RUN(fn)</summary>
+///
+/// Run a test suite/function containing assertions
+///<C
+#define RUN(test_function) tap_execute((#test_function), (test_function))
+///>
+/// </details>
+
+/// <details>
+/// <summary>TEST_REPORT()</summary>
+///
+/// Report on the tests that have been run
+///<C
+#define TEST_REPORT() tap_report()
+///>
+/// </details>
+
+///
+/// Extras
+/// ------
+///
+/// ### Disable color
+///
+/// If you want to disable color during the assertions, because you want to
+/// interpret the output for example (it is "tap" format after all), you can
+/// define `NO_COLOR` during compilation to disable color output.
+///
+/// ```sh
+/// cc -D NO_COLOR source.c -o test
+/// ```
+///
+/// ### Silent assertions
+///
+/// You can also fully disable output for assertions by defining the
+/// `ASSERT_SILENT` macro. This will fully disable the printf performed after
+/// the assertion is performed.
+///
+/// ```sh
+/// cc -D ASSERT_SILENT source.c -o test
+/// ```
+///
+/// ### Silent reporting
+///
+/// If you do not want the report to be displayed at the end, you can define the
+/// `REPORT_SILENT` macro. This will disable the printf during reporting and
+/// only keep the return code.
+///
+/// ```sh
+/// cc -D REPORT_SILENT source.c -o test
+/// ```
+///
+
+#ifdef NO_COLOR
+#define TAP_COLOR_CODE ""
+#define TAP_COLOR_RED ""
+#define TAP_COLOR_GREEN ""
+#define TAP_COLOR_RESET ""
+#else
+#define TAP_COLOR_CODE "\x1B"
+#define TAP_COLOR_RED "[1;31m"
+#define TAP_COLOR_GREEN "[1;32m"
+#define TAP_COLOR_RESET "[0m"
+#endif
+
+int tap_asserts = 0;
+int tap_passes = 0;
+int tap_fails = 0;
+const char *tap_current_name = NULL;
+
+void tap_execute(const char* name, void (*test_function)()) {
+ tap_current_name = name;
+ printf("# %s\n", name);
+ test_function();
+}
+
+int tap_assert(const char* file, int line, const char* msg, const char* expression, int pass) {
+ tap_asserts++;
+
+ if (pass) {
+ tap_passes++;
+#ifndef ASSERT_SILENT
+ printf("%s%sok%s%s %d - %s\n",
+ TAP_COLOR_CODE, TAP_COLOR_GREEN,
+ TAP_COLOR_CODE, TAP_COLOR_RESET,
+ tap_asserts,
+ msg
+ );
+#endif
+ } else {
+ tap_fails++;
+#ifndef ASSERT_SILENT
+ printf(
+ "%s%snot ok%s%s %d - %s\n"
+ " On %s:%d, in test %s()\n"
+ " %s\n"
+ ,
+ TAP_COLOR_CODE, TAP_COLOR_RED,
+ TAP_COLOR_CODE, TAP_COLOR_RESET,
+ tap_asserts, msg,
+ file, line, tap_current_name,
+ expression
+ );
+ }
+#endif
+ return pass;
+}
+
+int tap_report(void) {
+#ifndef REPORT_SILENT
+ printf(
+ "1..%d\n"
+ "# tests %d\n"
+ "# pass %d\n"
+ "# fail %d\n",
+ tap_asserts,
+ tap_asserts,
+ tap_passes,
+ tap_fails
+ );
+#endif
+ return tap_fails ? 2 : 0;
+}
+
+#endif // __TINYTEST_INCLUDED_H__
+
+///
+/// Credits
+/// -------
+///
+/// This library was heavily based on the [tinytest][tinytest] library by
+/// [Joe Walnes][joewalnes]. A license reference to his library could not be
+/// found, which is why this reference is in this file. Should I be contacted
+/// about licensing issues, I'll investigate further.
+///
+/// [joewalnes]: https://github.com/joewalnes
+/// [tinytest]: https://github.com/joewalnes/tinytest
diff --git a/test/main.c b/test/main.c
@@ -0,0 +1,5 @@
+#include "cnfparse.h"
+
+int main(int argc, char *argv[]) {
+ return 42;
+}