--- /dev/null
+SortIncludes: false
--- /dev/null
+---
+Checks: "*,
+ -abseil-*,
+ -llvm*,
+ -google*,
+ -modernize-use-trailing-return-type,
+ -readability-else-after-return,
+ -readability-static-accessed-through-instance,
+ -readability-avoid-const-params-in-decls,
+ -misc-unused-parameters,
+ -bugprone-easily-swappable-parameters,
+ -cert-err33-c,
+ -readability-identifier-length,
+ -altera-unroll-loops,
+ -cppcoreguidelines-avoid-non-const-global-variables,
+ -altera-struct-pack-align,
+ -cppcoreguidelines-avoid-magic-numbers,
+ -readability-magic-numbers,
+ -cert-err34-c,
+ -readability-function-cognitive-complexity,
+ -altera-id-dependent-backward-branch,
+ -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
+ -misc-no-recursion,
+ -concurrency-mt-unsafe
+"
+WarningsAsErrors: ''
+HeaderFilterRegex: ''
+FormatStyle: None
+
--- /dev/null
+* text=auto
--- /dev/null
+# Build directory
+bin/
+obj/
+
+ Prerequisites
+*.d
+
+# Object files
+*.o
+*.ko
+*.obj
+*.elf
+
+# Linker output
+*.ilk
+*.map
+*.exp
+
+# Precompiled Headers
+*.gch
+*.pch
+
+# Libraries
+*.lib
+*.a
+*.la
+*.lo
+
+# Shared objects (inc. Windows DLLs)
+*.dll
+*.so
+*.so.*
+*.dylib
+
+# Executables
+*.exe
+*.out
+*.app
+*.i*86
+*.x86_64
+*.hex
+
+# Debug files
+*.dSYM/
+*.su
+*.idb
+*.pdb
+vgcore.*
+
+# Kernel Module Compile Results
+*.mod*
+*.cmd
+.tmp_versions/
+modules.order
+Module.symvers
+Mkfile.old
+dkms.conf
+
+compile_commands.json
+.cache/
+.clang_complete
+.clangd
+
--- /dev/null
+Copyright 2020 Lukas Krickl (lukas@krickl.dev)
+
+Permission 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.
--- /dev/null
+# ulas
+
+## Table of content
+
+- [Installation](#Installation)
+- [Usage](#Usage)
+- [License](#License)
+- [Contributing](#Contributing)
+- [TODO](#TODO)
+
+## Installation
+
+To build this program you will require a recent C compiler, make, `libargtable2` and `libcmocka` for unit tests.
+
+```sh
+premake gmake # to build gnu make file
+make # to compile all targets
+```
+
+## Usage
+
+1) Rename `ulas` to the project's name in all files and folders
+
+## License
+
+This program is distributed under the terms of the MIT License.
+
+## Contributing
+
--- /dev/null
+.\" Manpage for ulas.
+.\" Contact lukas@krickl.dev to correct errors or typos.
+
+.TH man 8 "21 August 2023" "0.0.1" "ulas manual"
+
+.SH NAME
+ ulas
+.SH SYNOPSIS
+ ulas [-v] [--help] [--version]
+.SH DESCRIPTION
+ ulas
+
+ --help
+ display this help and exit
+ --version
+ display version info and exit
+ -v, --verbose
+ verbose output
+
+.SH EXAMPLES
+
+.SH SEE ALSO
+
+.SH BUGS
+
+.SH AUTHOR
+ Lukas Krickl (lukas@krickl.dev)
+
+.SH COPYRIGHT
+ Copyright 2023 Lukas Krickl (lukas@krickl.dev)
--- /dev/null
+#ifndef ULASH__
+#define ULASH__
+
+#include <stdbool.h>
+
+struct ulas_config {
+ char **argv;
+ int argc;
+
+ bool verbose;
+};
+
+int ulas_main(struct ulas_config *cfg);
+
+#endif
--- /dev/null
+NAME=ulas
+IDIR=./include
+SDIR=./src
+CC=gcc
+DBGCFLAGS=-g -fsanitize=address
+DBGLDFLAGS=-fsanitize=address
+CFLAGS=-I$(IDIR) -Wall -pedantic $(DBGCFLAGS) -std=gnu99
+LIBS=
+TEST_LIBS=
+LDFLAGS=$(DBGLDFLAGS) $(LIBS)
+
+ODIR=obj
+TEST_ODIR=obj/test
+BDIR=bin
+BNAME=$(NAME)
+MAIN=main.o
+TEST_MAIN=test.o
+TEST_BNAME=testulas
+
+BIN_INSTALL_DIR=/usr/local/bin
+MAN_INSTALL_DIR=/usr/local/man
+
+_OBJ = $(MAIN) ulas.o
+OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
+
+all: bin test
+
+$(ODIR)/%.o: src/%.c
+ mkdir -p $(@D)
+ $(CC) -c -o $@ $< $(CFLAGS) $(LDFLAGS)
+
+bin: $(OBJ)
+ mkdir -p $(BDIR)
+ $(CC) -o $(BDIR)/$(BNAME) $^ $(CFLAGS) $(LDFLAGS)
+
+test:
+ echo "building tests"
+ make bin MAIN=$(TEST_MAIN) BNAME=$(TEST_BNAME) ODIR=$(TEST_ODIR) LIBS=$(TEST_LIBS)
+
+.PHONY: clean
+
+clean:
+ rm -f ./$(ODIR)/*.o
+ rm -f ./$(TEST_ODIR)/*.o
+ rm -f ./$(BDIR)/$(BNAME)
+ rm -f ./$(BDIR)/$(TEST_BNAME)
+
+.PHONY: install
+
+install:
+ cp ./$(BDIR)/$(BNAME) $(BIN_INSTALL_DIR)
+ cp ./doc/$(BNAME).man $(MAN_INSTALL_DIR)
--- /dev/null
+#!/bin/sh
+
+# generate clang build commands
+bear -- make SHELL="sh -x -e" --always-make
--- /dev/null
+#!/bin/bash
+
+# rename to project specific values
+NAME="ulas"
+CONST="ULAS"
+STRUCT="ulas"
+FN="ulas"
+
+# will be replaced
+ULAS_NAME="ulas"
+ULAS_STRUCT="ulas"
+ULAS_CONST="ULAS"
+ULAS_FN="ulas"
+
+function replace() {
+ echo "Replacing $1 with $2"
+ find ./ -type f -name '*.c' -exec sed -i "s/$1/$2/g" {} \;
+ find ./ -type f -name '*.h' -exec sed -i "s/$1/$2/g" {} \;
+ find ./ -type f -name '*.md' -exec sed -i "s/$1/$2/g" {} \;
+ find ./ -type f -name 'makefile' -exec sed -i "s/$1/$2/g" {} \;
+ find ./ -type f -name '*.sh' -exec sed -i "s/$1/$2/g" {} \;
+ find ./doc/ -type f -name '*' -exec sed -i "s/$1/$2/g" {} \;
+}
+
+replace $ULAS_NAME $NAME
+replace $ULAS_CONST $CONST
+replace $ULAS_STRUCT $STRUCT
+replace $ULAS_FN $FN
+
+mv "include/$ULAS_NAME.h" "include/$NAME.h"
+mv "src/$ULAS_NAME.c" "src/$NAME.c"
+mv "doc/$ULAS_NAME.man" "doc/$NAME.man"
--- /dev/null
+#!/bin/sh
+
+make && ./bin/ulas "$@"
+
--- /dev/null
+#!/bin/bash
+
+make && ./bin/testulas
+
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "ulas.h"
+#include <unistd.h>
+
+#define ULAS_NAME "ulas"
+#define ULAS_VER "0.0.1"
+
+void ulas_help(void) {
+ printf("%s\n", ULAS_NAME);
+ printf("Usage %s [-h] [-V] [-v]\n\n", ULAS_NAME);
+ printf("\t-h\tdisplay this help and exit\n");
+ printf("\t-V\tdisplay version info and exit\n");
+ printf("\t-v\tverbose output\n");
+}
+
+void ulas_version(void) { printf("%s version %s\n", ULAS_NAME, ULAS_VER); }
+
+void ulas_getopt(int argc, char **argv, struct ulas_config *cfg) {
+ int c = 0;
+ while ((c = getopt(argc, argv, "hvV")) != -1) {
+ switch (c) {
+ case 'h':
+ ulas_help();
+ exit(0);
+ break;
+ case 'V':
+ ulas_version();
+ exit(0);
+ break;
+ case 'v':
+ cfg->verbose = true;
+ break;
+ case '?':
+ break;
+ default:
+ printf("%s: invalid option '%c'\nTry '%s -h' for more information.\n",
+ ULAS_NAME, c, ULAS_NAME);
+ exit(-1);
+ break;
+ }
+ }
+
+ cfg->argc = argc - optind;
+ cfg->argv = argv + optind;
+}
+
+int main(int argc, char **argv) {
+ // map args to cfg here
+ struct ulas_config cfg;
+ memset(&cfg, 0, sizeof(cfg));
+
+ ulas_getopt(argc, argv, &cfg);
+
+ int res = ulas_main(&cfg);
+
+ return res;
+}
--- /dev/null
+#include <stdio.h>
+
+void null_test_success(void) {
+ puts("[null test]");
+ puts("[null test ok]");
+}
+
+int main(int arc, char **argv) {
+ null_test_success();
+
+ return 0;
+}
--- /dev/null
+#include "ulas.h"
+
+int ulas_main(struct ulas_config *cfg) {
+ return 0;
+}