From 561753df419bf21bcd98c4d2a0c836be8c58647b Mon Sep 17 00:00:00 2001 From: vx-clutch Date: Sat, 8 Nov 2025 18:36:38 -0500 Subject: [PATCH] reset --- .clang-format | 108 ---------------- .clangd | 7 - .gitmodules | 3 - .usermap | 1 - AUTHORS | 11 -- COPYING | 28 ---- INSTALL | 54 -------- Makefile | 69 ---------- README | 29 ----- README-dev | 112 ---------------- README-release | 32 ----- THANKS | 15 --- TODO | 8 -- bootstrap | 44 ------- build-aux/compile | 63 --------- build-aux/generate-artifacts | 38 ------ config.h | 10 -- configure | 159 ----------------------- doc/Makefile | 22 ---- doc/version.texi | 2 - doc/yait.texi | 240 ----------------------------------- gcklib | 1 - lib/err.c | 214 ------------------------------- lib/err.h | 71 ----------- lib/flag.c | 125 ------------------ lib/flag.h | 44 ------- lib/fs.c | 211 ------------------------------ lib/fs.h | 55 -------- lib/proginfo.c | 82 ------------ lib/proginfo.h | 50 -------- lib/say.c | 105 --------------- lib/say.h | 50 -------- lib/textc.c | 80 ------------ lib/textc.h | 49 ------- lib/xmem.c | 65 ---------- lib/xmem.h | 47 ------- man/yait.x | 4 - scripts/manual/make | 35 ----- src/flat.c | 42 ------ src/flat.h | 8 -- src/license.h | 82 ------------ src/shell.c | 62 --------- src/shell.h | 7 - src/version.c | 8 -- src/version.h | 13 -- src/yait.c | 235 ---------------------------------- t/INSTALL.x | 55 -------- t/Makefile.x | 64 ---------- t/README-dev.x | 113 ----------------- t/README-release.x | 33 ----- t/README.x | 30 ----- t/flat_Makefile.x | 31 ----- t/main.x | 50 -------- t/shell.x | 39 ------ t/t | 154 ---------------------- template.h | 68 ---------- tools/Cleanup | 55 -------- tools/format | 43 ------- tools/update-gcklib | 36 ------ yait.1 | 43 ------- 60 files changed, 3614 deletions(-) delete mode 100644 .clang-format delete mode 100644 .clangd delete mode 100644 .gitmodules delete mode 100644 .usermap delete mode 100644 AUTHORS delete mode 100644 COPYING delete mode 100644 INSTALL delete mode 100644 Makefile delete mode 100644 README delete mode 100644 README-dev delete mode 100644 README-release delete mode 100644 THANKS delete mode 100644 TODO delete mode 100755 bootstrap delete mode 100755 build-aux/compile delete mode 100755 build-aux/generate-artifacts delete mode 100644 config.h delete mode 100755 configure delete mode 100644 doc/Makefile delete mode 100644 doc/version.texi delete mode 100644 doc/yait.texi delete mode 160000 gcklib delete mode 100644 lib/err.c delete mode 100644 lib/err.h delete mode 100644 lib/flag.c delete mode 100644 lib/flag.h delete mode 100644 lib/fs.c delete mode 100644 lib/fs.h delete mode 100644 lib/proginfo.c delete mode 100644 lib/proginfo.h delete mode 100644 lib/say.c delete mode 100644 lib/say.h delete mode 100644 lib/textc.c delete mode 100644 lib/textc.h delete mode 100644 lib/xmem.c delete mode 100644 lib/xmem.h delete mode 100644 man/yait.x delete mode 100755 scripts/manual/make delete mode 100644 src/flat.c delete mode 100644 src/flat.h delete mode 100644 src/license.h delete mode 100644 src/shell.c delete mode 100644 src/shell.h delete mode 100644 src/version.c delete mode 100644 src/version.h delete mode 100644 src/yait.c delete mode 100644 t/INSTALL.x delete mode 100644 t/Makefile.x delete mode 100644 t/README-dev.x delete mode 100644 t/README-release.x delete mode 100644 t/README.x delete mode 100644 t/flat_Makefile.x delete mode 100644 t/main.x delete mode 100644 t/shell.x delete mode 100755 t/t delete mode 100644 template.h delete mode 100755 tools/Cleanup delete mode 100755 tools/format delete mode 100755 tools/update-gcklib delete mode 100644 yait.1 diff --git a/.clang-format b/.clang-format deleted file mode 100644 index ed93a28..0000000 --- a/.clang-format +++ /dev/null @@ -1,108 +0,0 @@ ---- -AccessModifierOffset: -4 -AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: false -AlignEscapedNewlines: Left -AlignOperands: true -AlignTrailingComments: false -AllowAllParametersOfDeclarationOnNextLine: false -AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: None -AllowShortIfStatementsOnASingleLine: false -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: false -BinPackArguments: true -BinPackParameters: true -BraceWrapping: - AfterClass: false - AfterControlStatement: false - AfterEnum: false - AfterFunction: true - AfterNamespace: true - AfterObjCDeclaration: false - AfterStruct: false - AfterUnion: false - AfterExternBlock: false - BeforeCatch: false - BeforeElse: false - IndentBraces: false - SplitEmptyFunction: true - SplitEmptyRecord: true - SplitEmptyNamespace: true -BreakBeforeBinaryOperators: None -BreakBeforeBraces: Custom -BreakBeforeInheritanceComma: false -BreakBeforeTernaryOperators: false -BreakConstructorInitializersBeforeComma: false -BreakConstructorInitializers: BeforeComma -BreakAfterJavaFieldAnnotations: false -BreakStringLiterals: false -ColumnLimit: 80 -CommentPragmas: '^ IWYU pragma:' -CompactNamespaces: false -ConstructorInitializerAllOnOneLineOrOnePerLine: false -ConstructorInitializerIndentWidth: 8 -ContinuationIndentWidth: 8 -Cpp11BracedListStyle: false -DerivePointerAlignment: false -DisableFormat: false -ExperimentalAutoDetectBinPacking: false -FixNamespaceComments: false - -IncludeBlocks: Preserve -IncludeCategories: - - Regex: '.*' - Priority: 1 -IncludeIsMainRegex: '(Test)?$' -IndentCaseLabels: false -IndentGotoLabels: false -IndentPPDirectives: None -IndentWidth: 8 -IndentWrappedFunctionNames: false -JavaScriptQuotes: Leave -JavaScriptWrapImports: true -KeepEmptyLinesAtTheStartOfBlocks: false -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: None -ObjCBinPackProtocolList: Auto -ObjCBlockIndentWidth: 8 -ObjCSpaceAfterProperty: true -ObjCSpaceBeforeProtocolList: true - -PenaltyBreakAssignment: 10 -PenaltyBreakBeforeFirstCallParameter: 30 -PenaltyBreakComment: 10 -PenaltyBreakFirstLessLess: 0 -PenaltyBreakString: 10 -PenaltyExcessCharacter: 100 -PenaltyReturnTypeOnItsOwnLine: 60 - -PointerAlignment: Right -ReflowComments: false -SortIncludes: false -SortUsingDeclarations: false -SpaceAfterCStyleCast: false -SpaceAfterTemplateKeyword: true -SpaceBeforeAssignmentOperators: true -SpaceBeforeCtorInitializerColon: true -SpaceBeforeInheritanceColon: true -SpaceBeforeParens: ControlStatementsExceptForEachMacros -SpaceBeforeRangeBasedForLoopColon: true -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: false -SpacesInContainerLiterals: false -SpacesInCStyleCastParentheses: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -Standard: Cpp03 -TabWidth: 8 -UseTab: Always -... diff --git a/.clangd b/.clangd deleted file mode 100644 index 6624551..0000000 --- a/.clangd +++ /dev/null @@ -1,7 +0,0 @@ -CompileFlags: - Add: [-x, c, -std=c2x] - -Diagnostics: - ClangTidy: - Add: [clang-diagnostic-*] - Remove: [] diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index c2ba7a4..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "gcklib"] - path = gcklib - url = https://github.com/gck-org/gcklib diff --git a/.usermap b/.usermap deleted file mode 100644 index 987f326..0000000 --- a/.usermap +++ /dev/null @@ -1 +0,0 @@ -vx-clutch diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index 5c9c5eb..0000000 --- a/AUTHORS +++ /dev/null @@ -1,11 +0,0 @@ -Authors of GCK yait. - - Copyright (C) 2025 GCK. - - Copying and distribution of this file, with or without modification, - are permitted in any medium without royalty provided the copyright - notice and this notice are preserved. - -Also see the THANKS files. - -vx-clutch diff --git a/COPYING b/COPYING deleted file mode 100644 index 1c5cedf..0000000 --- a/COPYING +++ /dev/null @@ -1,28 +0,0 @@ -BSD 3-Clause License - -Copyright (c) 2025, GCK - -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 of the copyright holder 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 HOLDER 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. diff --git a/INSTALL b/INSTALL deleted file mode 100644 index 1c447a3..0000000 --- a/INSTALL +++ /dev/null @@ -1,54 +0,0 @@ -Installation Instructions -************************* - -Copyright (C) 2025 GCK. - - Copying and distribution of this file, with or without modification, -are permitted in any medium without royalty provided the copyright -notice and this notice are preserved. This file is offered as-is, -without warranty of any kind. - -Basic Installation -================== - - Briefly, the shell command `./configure && make && make install` should -configure, build, and install this package. The following more-detailed -instruction are generic; see the `README` file for instructions specific to -this package. - - The `configure` shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values within a `Makefile` to build for that POSIX system as -defined by `config.mak` which was generated by `configure`. - -Compilers and Options -===================== - - Some systems require unusal options for compilation or linking that -the `configure` script does not know about. If you run into an issue -run `./configure --help` to figure out what you can do to fix the -behavoir. - -Installation Names -================== - - By default, `make install` installs the package's command under -`/usr/local/bin`. You can specify an installation prefix other than `/usr/local/` -by giving `configure` the option `--prefix=PREFIX` to `configure`, the package uses -PREFIX as the prefix for installation programs and libraries. -Documentation and other data files still use the regular prefix. - -`configure` Invokation -====================== - - `configure` recongizes the following options to control its operations. - - `--help` - Prints a summary of all the options to `configure`, and exits. - `--prefix=PREFIX` - Sets the installation prefix. - `CFLAGS` - Sets the flags used during compilation. - -`configure` also accepts some other options. Run `configure --help` for more -details diff --git a/Makefile b/Makefile deleted file mode 100644 index cd4a4d9..0000000 --- a/Makefile +++ /dev/null @@ -1,69 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -PACKAGE := yait - -SRCS := $(wildcard src/*.c) $(wildcard lib/*.c) -OBJS := $(patsubst %.c,build/obj/%.o,$(SRCS)) - -BIN := bin/$(PACKAGE) - -COMMIT := $(shell git rev-list --count --all) -FLAGS := -I. --std=c2x -pedantic -Ibuild/include - -VERSION := $(shell git describe --tags --always --dirty) -TARBALL := $(PACKAGE)-$(VERSION).tar.gz -RELEASE_FILES := doc src lib COPYING AUTHORS README $(PACKAGE).1 INSTALL Makefile configure config.h - --include config.mak - -ifeq ($(wildcard config.mak),) -all: - @echo "File config.mak not found, run configure" - @exit 1 -else - -all: $(BIN) - -bin: - @mkdir -p bin - -build/obj: - @mkdir -p build/obj/src - @mkdir -p build/obj/lib - -build/obj/%.o: %.c config.mak | build/obj - @printf " CC %s\n" $(notdir $@) - @$(CC) $(FLAGS) $(CFLAGS) -c $< -o $@ - -$(BIN): $(OBJS) | bin - @printf " LINK %s\n" "$(notdir $@)" - @$(CC) $(FLAGS) $(CFLAGS) $^ -o $@ - - -install: $(BIN) - cp $(BIN) $(PREFIX) - -endif - -doc: - @$(MAKE) -C doc all - -uninstall: - @$(RM) $(PREFIX)$(PACKAGE) - -clean: - @echo " CLEAN" - @$(RM) -r bin - @$(RM) -r build - @$(MAKE) -C doc clean --no-print-directory - -distclean: clean - @$(RM) config.mak config.status - @$(RM) $(TARBALL) - -release: distclean all - tar -czf $(TARBALL) $(RELEASE_FILES) - -test: - @$(BIN) --version > /dev/null 2>&1 && echo "intact" || echo "defective" - -.PHONY: all clean distclean install uninstall doc diff --git a/README b/README deleted file mode 100644 index c9378fc..0000000 --- a/README +++ /dev/null @@ -1,29 +0,0 @@ -This is the README file for the GCK yait distribution. -yait is an optionated C project generator - - Copyright (C) 2025 GCK. - - Copying and distribution of this file, with or without modification, - are permitted in any medium without royalty provided the copyright - notice and this notice are preserved. - -See the files ./INSTALL* for building and installation instructions. - -Bug reports: - Please include enough information for the maintainers to reproduce the - problem. Generally speaking, that means: -- the contents of any input files necessary to reproduce the bug - and command line invocations of the program(s) involved (crucial!). -- a description of the problem and any samples of the erroneous output. -- the version number of the program(s) involved (use --version). -- hardware, operating system, and compiler versions (uname -a). -- unusual options you gave to configure, if any (see config.mak). -- anything else that you think would be helpful. - -See README-dev for information on the development environment -- any -interested parties are welcome. If you're a programmer and wish to -contribute, this should get you started. If you're not a programmer, -your help in writing test cases, checking documentation against the -implementation, etc., would still be very much appreciated. - -GCK yait is free software. See the file COPYING for copying conditions. diff --git a/README-dev b/README-dev deleted file mode 100644 index 00ecf96..0000000 --- a/README-dev +++ /dev/null @@ -1,112 +0,0 @@ -This README.dev file describes the development environment. - - Copyright (C) 2025 GCK. - - Copying and distribution of this file, with or without modification, - are permitted in any medium without royalty provided the copyright - notice and this notice are preserved. - -Notice ------- - -This documentation is standard across all GCK package and is not specified per -package; however, this is the defacto standard for most packages. The only -place where this commonly differs is in non-binary or library packages. - - -Build system ------------- - -This distribution uses a GNU autotools-like build system. This is made up of a -configure script, and a Makefile. The configure script detects a C23 compiler -on the system and sets any program flags: debug, release, custom. The Makefile -builds the binary based on the output [config.mak] of the configure script. - - -Building --------- - -To build this distribution you first must run the configure script. This -outputs a config.mak file that will be used in the Make step. Then run make; -this builds the objects into build/ and the binary into bin/. - - -Configuration -------------- - -The configuration script is used to generate a build intermediate step called -the config.mak. This file is used by the Makefile to figure out C compiler to -use, what CFLAGS and LDFLAGS to use, and where to install the binary if -requested. By default these values are gcc, the release flag set, and -/usr/local/. The configuration script supports the following flags that control -CFLAGS: --enable-debug and CFLAGS="". By default, the script uses flags for a release -build. Debug is for in-development programming and is the strictest when it -comes to warnings and other compiler output. CFLAGS="" is for custom flag -definition. For the development environment is it recommended to use the ---debug flag. Some examples of how you can run the configure script: - -For default behavior: - - ./configure - -For debug use: - - ./configure --enable-debug - -For help text: - - ./configure --help - -The help text is a more useage specific and up-to-date reference for -the configure script. - - -Makefile --------- - -The GNU Makefile is used to build the final executable, clean up build -artifacts, and install the program. It checks for the config.mak which is -generated by the configure script. For a regular build, once you have the -configure script with desired flags, run: - - make - -This builds the executable to bin/ and build objects to build/ - - -Suggested enviroment setup --------------------------- -It is suggested that you run do the following things to prepare you environment -for development. This is not a strict enforcement, but due to the project -structure it is a good starting point. - - git pull - ./tools/Cleanup - ./configure --debug - ./build-aux/generate-artifacts - make test - -This is to ensure that you have the most up-to-date source code, and that there -are no major problems with the source control version. - -The git pull is used to sync with the repository and prevent conflicts. The -cleanup is to ensure their are no lingering build artifacts. The configure with -debug enabled is for strict build flags and -ggdb. Bear is used to generated -compile_commands.json for the clang suite of tooling. Finally, run the program -to ensure the chain works. - - -Pre-commit checks ------------------ - -Before you commit to source control ensure that done the following: - - * Run the cleanup scripts - - ./tools/Cleanup - - * Ensure that all changes were atomic - - * If you compted a TODO list item check it off. - - * Based on complexity, test the feature accordingly. diff --git a/README-release b/README-release deleted file mode 100644 index 8cc6f7a..0000000 --- a/README-release +++ /dev/null @@ -1,32 +0,0 @@ -Here are most of the steps before you make a release. - -* Start from a clean, up-to-date git driectory on "master": - - make -k distclean || { ./configure && make distclean; } - git checkout master - git pull origin master - -* Ensure that the latest stable versions of make, sh, etc. -are in your path. See the prerequisites list in README-dev -for a compile list of tools. - -* Ensure that you have no uncommitted diffs. This should produce -no output: - - git diff - -* Ensure that you've pushed all changes that belong in the release: - - git push origin master - -* Pre-release testing: ensure that the following command succeeds: - - make check syntax-check distcheck - -Once all the builds and tests have passed, - -* Run the following to create release tarballs. - - make release - -* Upload the tarball to the relavent distribtuion platform. diff --git a/THANKS b/THANKS deleted file mode 100644 index e501341..0000000 --- a/THANKS +++ /dev/null @@ -1,15 +0,0 @@ -Additional contributors to GCK yait. - - Copyright (C) 2025 GCK. - - Copying and distribution of this file, with or without modification, - are permitted in any medium without royalty provided the copyright - notice and this notice are preserved. - -Thanks to: - - GNU hello for layout ideas. - - The Linux Kernel for the code formatting guidelines. - -See also the AUTHORS file. diff --git a/TODO b/TODO deleted file mode 100644 index 85fe182..0000000 --- a/TODO +++ /dev/null @@ -1,8 +0,0 @@ -GCK yait --- TODO - -Todo: - - * fix 't' so that it handles names correctly and special in-file characters - * write all templates sources - -end of file TODO diff --git a/bootstrap b/bootstrap deleted file mode 100755 index 2709639..0000000 --- a/bootstrap +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: BSD-3-Clause -me=$0 -scriptversion="1.0.0" - -version="$me $scriptversion - -Copyright (C) 2025 GCK. -This is free software; you are free to change and redistribute it. -There is NO WARRANTY, to the extent permitted by law." - -usage="\ -Usage: $me [OPTION]... -Prepares the build enviroment - -Options: - - --help print this help and exit - --version output version information" - -while [ $# -gt 0 ]; do - case $1 in - --help) echo "$usage"; exit 0 ;; - --version) echo "$version"; exit 0 ;; - -*) - echo "$0: Unknown option '$1'." >&2 - echo "$0: Try '--help' for more information." >&2 - exit 1 ;; - esac - shift -done - - -echo "$0: Bootstrapping from checked-out $(basename "$(git rev-parse --show-toplevel)") sources" - -if [ ! -f .gitmodules ]; then - echo "$0: No .gitmodules file found. Skipping submodule initialization." - exit 0 -fi - -git config -f .gitmodules --get-regexp path | while read -r key path; do - echo "$0: initializing submodule '$path'..." - git submodule update --init --recursive "$path" -done diff --git a/build-aux/compile b/build-aux/compile deleted file mode 100755 index 35c743b..0000000 --- a/build-aux/compile +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: BSD-3-Clause -me=$0 -scriptversion="1.0.0" - -version="$me $scriptversion - -Copyright (C) 2025 GCK. -This is free software; you are free to change and redistribute it. -There is NO WARRANTY, to the extent permitted by law." - -usage="\ -Usage: $me [OPTION]... -Compile wrapper for GCK distributions - -Options: - -R force re-compile everything - - --help print this help and exit - --version output version information - -Automatically passes arugments to 'configure'" - -rebuild= - -while test $# -gt 0; do - case $1 in - --help) echo "$usage"; exit 0;; - --version) echo "$version"; exit 0;; - -R) rebuild=true ;; - -*) - echo "$0: Unknown option '$1'." >&2 - echo "$0: Try '--help' for more information." >&2 - exit 1;; - esac - shift -done - -if [ -f ./config.mak ] && [ -z "$rebuild" ]; then - echo "$0: reusing old 'config.mak'" -else -if [ ! -x ./configure ]; then - echo "$0: 'configure' not found or not executable" >&2 - exit 1 -fi - -echo "$0: configuring $(basename "$(git rev-parse --show-toplevel)")" -./configure "$@" -if [ $? -ne 0 ]; then - echo "error: configure failed" >&2 - exit 1 -fi - -fi - -echo "$0: starting build" -make -j"$(nproc)" -if [ $? -ne 0 ]; then - echo "error: build failed" >&2 - exit 1 -fi - -echo "$0: finish" diff --git a/build-aux/generate-artifacts b/build-aux/generate-artifacts deleted file mode 100755 index 0fb14d7..0000000 --- a/build-aux/generate-artifacts +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: BSD-3-Clause -me=$0 -scriptversion="1.0.0" - -version="$me $scriptversion - -Copyright (C) 2025 GCK. -This is free software; you are free to change and redistribute it. -There is NO WARRANTY, to the extent permitted by law." - -usage="\ -Usage: $me [OPTION]... -Generates artifacts - -Options: - - --help print this help and exit - --version output version information" - -while test $# -gt 0; do - case $1 in - --help) echo "$usage"; exit 0;; - --version) echo "$version"; exit 0;; - -*) - echo "$0: Unknown option '$1'." >&2 - echo "$0: Try '--help' for more information." >&2 - exit 1;; - esac - shift -done - -if [ ! -e "config.mak" ]; then - ./configure -fi - -mkdir -p build -bear --output build/compile_commands.json -- make -B -j"$(nproc)" diff --git a/config.h b/config.h deleted file mode 100644 index 45bc1d0..0000000 --- a/config.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef CONFIG_H -#define CONFIG_H - -/* Program information */ -#define PROGRAM "yait" -#define AUTHORS "GCK" -#define VERSION "beta" -#define YEAR 2025 - -#endif diff --git a/configure b/configure deleted file mode 100755 index 574ce01..0000000 --- a/configure +++ /dev/null @@ -1,159 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: BSD-3-Clause -me=$0 -scriptversion="1.0.0" - -version="$me $scriptversion - -Copyright (C) 2025 GCK. -This is free software; you are free to change and redistribute it. -There is NO WARRANTY, to the extent permitted by law." - -usage="\ -Usage: $me [OPTION]... -Prepares the build system for GCK distributions - -Options: - --release enable release flags - --enable-debug enable debugging options - --prefix PREFIX set installation prefix - - --help print this help and exit - --version output version information - -Environment variables: - - CC C compiler command - CFLAGS C compiler flags - -Use these variables to override the choices made by 'configure'." - -release=false -debug=false -prefix=/usr/local -CFLAGS=-pedantic -CC= -args_old=$@ - -while [ $# -gt 0 ]; do - case $1 in - --help) echo "$usage"; exit 0 ;; - --version) echo "$version"; exit 0 ;; - --release) release=true ;; - --enable-debug) debug=true ;; - --prefix) shift; prefix=${1:?missing prefix argument} ;; - --strict) CFLAGS+="-Werror" ;; - CC=*) CC=${1#*=} ;; - CFLAGS=*) CFLAGS=${1#*=} ;; - -*) - echo "$0: Unknown option '$1'." >&2 - echo "$0: Try '--help' for more information." >&2 - exit 1 ;; - esac - shift -done - -if [ "$release" = true ] && [ "$debug" = true ]; then - echo "$0: Can't set both '--release' and '--debug'." >&2 - echo "$0: Try '--help' for more information." >&2 - exit 1 -fi - -cmdexists() { command -v "$1" >/dev/null 2>&1 ; } -trycc() { [ -z "$CC" ] && cmdexists "$1" && CC=$1 ; } - -if [ -z "$CC" ]; then - printf "checking for C compiler... " - trycc gcc - trycc clang - trycc cc - if [ -z "$CC" ]; then - echo "none found" - exit 1 - fi - printf "%s\n" "$CC" -fi - -printf "checking for git... " -if cmdexists git; then - echo "yes" -else - echo "no" - exit 1 -fi - -printf "checking whether C compiler works... " -tmpcdir="$(mktemp -d)" -tmpc="$tmpcdir/test.c" -echo "typedef int x;" > "$tmpc" -if output=$($CC $CFLAGS -c -o /dev/null "$tmpc" 2>&1); then - printf "yes\n" -else - printf "no; %s\n" "$output" - rm -rf "$tmpcdir" - exit 1 -fi -rm -rf "$tmpcdir" - -if [ "$release" = true ]; then - CFLAGS="$CFLAGS -O3 -pipe -DNDEBUG -march=native -flto -s -fdata-sections -ffunction-sections -Wl,--gc-sections" -elif [ "$debug" = true ]; then - CFLAGS="$CFLAGS -O0 -ggdb -Wall -Wextra -Wpedantic -fno-omit-frame-pointer -DDEBUG" -fi - -echo "creating config.status" -cat < config.status -#!/bin/sh -# DO NOT MODIFY. THIS IS A AUTOGENERATED SCRIPT FROM 'configure' -# -# COMPILATION (Linux - POSIX): -# ./config.status -# -# -# LICENSE: BSD-3-Clause -# -# Copyright (c) 2025 GCK -# -# 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 of the copyright holder 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 HOLDER 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. -# - -printf "config.status: recreating config.mak... " -{ - printf "PREFIX=%s\\n" "$prefix" - printf "CFLAGS=%s\\n" "$CFLAGS" - printf "CC=%s\\n" "$CC" -} > config.status -printf "done\n" -EOF -chmod u+x config.status - -printf "configure: creating config.mak... " -{ - printf "PREFIX=%s\n" "$prefix" - printf "CFLAGS=%s\n" "$CFLAGS" - printf "CC=%s\n" "$CC" -} > config.mak -printf "done\n" diff --git a/doc/Makefile b/doc/Makefile deleted file mode 100644 index 3655a1c..0000000 --- a/doc/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -hello.info: hello.texi version.texi - @makeinfo --no-split hello.texi -o hello.info - -hello.html: hello.texi version.texi - @makeinfo --no-split --html hello.texi - -hello.pdf: hello.texi version.texi - @makeinfo --pdf hello.texi - -hello.txt: hello.texi version.texi - @makeinfo --plaintext hello.texi -o hello.txt - -clean: - @rm -f *.aux *.cp *.cps *.fn *.fns *.ky *.kys *.log *.pg *.pgs *.toc *.tp *.tps *.vr *.vrs - @rm -f hello.info hello.dvi hello.pdf hello.html hello.txt - -install: hello.info - @install -d $(DESTDIR)$(infodir) - @install -m 644 hello.info $(DESTDIR)$(infodir)/ - @install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/hello.info - -.PHONY: all clean install diff --git a/doc/version.texi b/doc/version.texi deleted file mode 100644 index a43cb6a..0000000 --- a/doc/version.texi +++ /dev/null @@ -1,2 +0,0 @@ -@set UPDATED 2025-01-01 -@set VERSION 1.0 \ No newline at end of file diff --git a/doc/yait.texi b/doc/yait.texi deleted file mode 100644 index d76620e..0000000 --- a/doc/yait.texi +++ /dev/null @@ -1,240 +0,0 @@ -\input texinfo @c -*-texinfo-*- -@c %**start of header -@setfilename hello.info -@include version.texi -@settitle GCK Hello @value{VERSION} - -@c Define a new index for options. -@defcodeindex op -@c Combine everything into one index (arbitrarily chosen to be the -@c concept index). -@syncodeindex op cp -@c %**end of header - -@copying -This manual is for GCK Hello (version @value{VERSION}, @value{UPDATED}), -which greets you nicely. - -Copyright @copyright{} 2025 GCK. - -@quotation -Copying and distribution of this file, with or without modification, -are permitted in any medium without royalty provided the copyright -notice and this notice are preserved. -@end quotation -@end copying - -@titlepage -@title GCK Hello -@subtitle for version @value{VERSION}, @value{UPDATED} -@page -@vskip 0pt plus 1filll -@insertcopying -@end titlepage - -@contents - - -@ifnottex -@node Top -@top GCK Hello - -This manual is for GCK Hello (version @value{VERSION}, @value{UPDATED}), -which greets you nicely. -@end ifnottex - -@menu -* Overview:: General purpose and information. -* Sample output:: Sample output from @command{hello}. -* Invoking hello:: How to run @command{hello}. -* Reporting bugs:: Sending bug reports and feature suggestions. -* Concept index:: Index of concepts. -@end menu - - -@node Overview -@chapter Overview - -@cindex greetings -@cindex overview - -The GCK @command{hello} program produces a simple, friendly greeting. -It serves as a minimal example of a C program with proper GNU-style -structure and build system. - -@cindex example program -@cindex template -This program is designed as a template and example for other projects. -It demonstrates basic C programming practices, proper project structure, -and standard GNU conventions. - -@cindex features -GCK Hello has the following features: - -@itemize @bullet -@item Simple and friendly greeting -@item Support for command-line arguments -@item Standard GNU-style help and version options -@item Clean, readable C source code -@item Proper project structure with build system -@end itemize - -@cindex implementation -GCK Hello is implemented in C and follows standard POSIX conventions. -The program accepts command-line arguments and greets each one individually, -or prints a default greeting if no arguments are provided. - -@cindex license -This program is distributed under the BSD 3-Clause License, allowing -free use, modification, and distribution with minimal restrictions. - - -@node Sample output -@chapter Sample output - -@cindex sample output -@cindex examples - -Here are some examples of running GCK Hello. - -This is the output of the command @samp{hello}: - -@example -Hello, World! -@end example - -This is the output of the command @samp{hello Alice}: - -@example -Hello, Alice! -@end example - -This is the output of the command @samp{hello Alice Bob}: - -@example -Hello, Alice! -Hello, Bob! -@end example - -This is the output of the command @samp{hello --help}: - -@example -Usage: hello [OPTION]... -Greets you nicely. - - --help display this help and exit - --version display version information and exit -@end example - - -@node Invoking hello -@chapter Invoking @command{hello} - -@cindex invoking -@cindex options -@cindex usage -@cindex help - -The format for running the @command{hello} program is: - -@example -hello [@var{option}]... [@var{name}]... -@end example - -With no arguments, @command{hello} prints the greeting @samp{Hello, World!}. - -If one or more @var{name} arguments are provided, @command{hello} greets -each name individually with @samp{Hello, @var{name}!}. - -@command{hello} supports the following options: - -@table @option -@item --help -@opindex --help -Print an informative help message on standard output and exit -successfully. - -@item --version -@opindex --version -Print the version number and licensing information of Hello on -standard output and then exit successfully. -@end table - - -@node Reporting bugs -@chapter Reporting bugs - -@cindex bug reporting -@cindex problems -@cindex reporting bugs - -To report bugs, suggest enhancements or otherwise discuss GCK Hello, -please send electronic mail to the project maintainers. - -@cindex checklist for bug reports -For bug reports, please include enough information for the maintainers -to reproduce the problem. Generally speaking, that means: - -@itemize @bullet -@item The version numbers of Hello (which you can find by running - @w{@samp{hello --version}}) and any other program(s) or - manual(s) involved. -@item Hardware and operating system names and versions. -@item The contents of any input files necessary to reproduce the bug. -@item The expected behavior and/or output. -@item A description of the problem and samples of any erroneous output. -@item Options you gave to @command{configure} other than specifying - installation directories. -@item Anything else that you think would be helpful. -@end itemize - -When in doubt whether something is needed or not, include it. It's -better to include too much than to leave out something important. - -@cindex patches, contributing -Patches are welcome; if possible, please make them with @samp{@w{diff --c}} and include @file{ChangeLog} entries. Please follow the existing -coding style. - - -@node BSD License -@appendix BSD License - -This program is distributed under the BSD 3-Clause License: - -@quotation -Copyright (c) 2025, GCK - -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 of the copyright holder 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 HOLDER 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. -@end quotation - - -@node Concept index -@unnumbered Concept index - -@printindex cp - -@bye diff --git a/gcklib b/gcklib deleted file mode 160000 index b325e80..0000000 --- a/gcklib +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b325e8005adf513a329a2c62f78835b4db31f6e2 diff --git a/lib/err.c b/lib/err.c deleted file mode 100644 index 7bfca35..0000000 --- a/lib/err.c +++ /dev/null @@ -1,214 +0,0 @@ -/* - * gcklib.err - Contains color printing functions - * - * CONFIGURATION - * #define NOCOLOR - * Force no color when printing - * - * - * LICENSE: BSD-3-Clause - * - * Copyright (c) 2025 GCK - * - * 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 of the copyright holder 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 HOLDER 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 -#include -#include -#include -#include - -#include "err.h" - -#define RESET "\x1B[0m" -#define ERROR "\x1B[1;91m" -#define WARN "\x1B[1;95m" -#define NOTE "\x1B[1;94m" -#define HINT "\x1B[38;5;166m" - -static bool err_support_color(void) -{ -#ifdef NOCOLOR - return false; -#else - static int cached = -1; - if (cached != -1) - return cached; - const char *term, *colorterm, *force, *nocolor; - term = getenv("TERM"); - colorterm = getenv("COLORTERM"); - force = getenv("FORCE_COLOR"); - nocolor = getenv("NO_COLOR"); - if (nocolor && *nocolor && (!force || !*force)) { - cached = 0; - return false; - } - if (force && *force && strcmp(force, "0") != 0) { - cached = 1; - return true; - } - // if (!isatty(fileno(stdout))) { - // cached = 0; - // return false; - // } - if (colorterm && *colorterm) { - cached = 1; - return true; - } - if (!term || !*term) { - cached = 0; - return false; - } - if (strstr(term, "color") || strstr(term, "xterm") || - strstr(term, "screen") || strstr(term, "vt100") || - strstr(term, "rxvt") || strstr(term, "ansi") || - strstr(term, "linux") || strstr(term, "konsole") || - strstr(term, "vte") || strstr(term, "kitty") || - strstr(term, "wezterm") || strstr(term, "gnome")) { - cached = 1; - return true; - } - cached = 0; - return false; -#endif -} - -void errorf(const char *format, ...) -{ - va_list args; - va_start(args, format); - - if (err_support_color()) { - fprintf(stderr, "%serror%s: ", ERROR, RESET); - } else { - fputs("error: ", stderr); - } - - vfprintf(stderr, format, args); - fputc('\n', stderr); - - va_end(args); -} -void fatalf(const char *format, ...) -{ - va_list args; - va_start(args, format); - - if (err_support_color()) { - fprintf(stderr, "%sfatal error%s: ", ERROR, RESET); - } else { - fputs("fatal error: ", stderr); - } - - vfprintf(stderr, format, args); - fputc('\n', stderr); - - va_end(args); - - fputs("program terminated.\n", stderr); - exit(EXIT_FAILURE); -} -void warnf(const char *format, ...) -{ - va_list args; - va_start(args, format); - - if (err_support_color()) { - fprintf(stderr, "%swarning%s: ", WARN, RESET); - } else { - fputs("warning: ", stderr); - } - - vfprintf(stderr, format, args); - fputc('\n', stderr); - - va_end(args); -} -void notef(const char *format, ...) -{ - va_list args; - va_start(args, format); - - if (err_support_color()) { - fprintf(stderr, "%snote%s: ", NOTE, RESET); - } else { - fputs("note: ", stderr); - } - - vfprintf(stderr, format, args); - fputc('\n', stderr); - - va_end(args); -} -void hintf(const char *format, ...) -{ - va_list args; - va_start(args, format); - - if (err_support_color()) { - fprintf(stderr, "%shint: ", HINT); - } else { - fputs("hint: ", stderr); - } - - vfprintf(stderr, format, args); - - if (err_support_color()) { - fprintf(stderr, "%s\n", RESET); - } else { - fputc('\n', stderr); - } - - va_end(args); -} - -void errorfa(int code) -{ - errorf(strerror(code)); -} - -void fatalfa(int code) -{ - fatalf(strerror(code)); -} - -void notefa(int code) -{ - notef(strerror(code)); -} - -void warnfa(int code) -{ - warnf(strerror(code)); -} - -void hintfa(int code) -{ - hintf(strerror(code)); -} - -/* end of file err.c */ diff --git a/lib/err.h b/lib/err.h deleted file mode 100644 index 920f4a4..0000000 --- a/lib/err.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * gcklib.err - Contains color printing functions - * - * CONFIGURATION - * #define NOCOLOR - * Force no color when printing - * #define SHOW_TRACE - * Add debug traces to error printing - * - * - * LICENSE: BSD-3-Clause - * - * Copyright (c) 2025 GCK - * - * 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 of the copyright holder 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 HOLDER 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. - */ - -#ifndef ERR_H -#define ERR_H - -void errorf(const char *format, ...); -_Noreturn void fatalf(const char *format, ...); -void notef(const char *format, ...); -void warnf(const char *format, ...); -void hintf(const char *format, ...); - -void errorfa(int code); -_Noreturn void fatalfa(int code); -void notefa(int code); -void warnfa(int code); -void hintfa(int code); - -#if defined(SHOW_TRACE) -#define errorf(fmt, ...) \ - do { \ - errorf("%s:%s:%d: " fmt, __FILE__, __func__, \ - __LINE__ __VA_OPT__(, ) __VA_ARGS__); \ - } while (0) -#define fatalf(fmt, ...) \ - do { \ - fatalf("%s:%s:%d: " fmt, __FILE__, __func__, \ - __LINE__ __VA_OPT__(, ) __VA_ARGS__); \ - } while (0) -#endif - -#endif - -/* end of file err.h */ diff --git a/lib/flag.c b/lib/flag.c deleted file mode 100644 index 6475f6b..0000000 --- a/lib/flag.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * gcklib.flag - Contains command-line flag parsing functions - * - * - * LICENSE: BSD-3-Clause - * - * Copyright (c) 2025 GCK - * - * 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 of the copyright holder 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 HOLDER 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 -#include -#include -#include - -#include "flag.h" - -static char *nextchar; - -int getopt_long(int argc, char *const argv[], const char *optstring, - const struct option *longopts, int *longindex) -{ - if (nextchar == NULL || *nextchar == '\0') { - if (optind >= argc) - return -1; - if (argv[optind][0] != '-' || argv[optind][1] == '\0') - return -1; - if (argv[optind][1] == '-' && argv[optind][2] == '\0') { - optind++; - return -1; - } - if (argv[optind][1] == '-') { - const char *arg = argv[optind] + 2; - char *eq = strchr(arg, '='); - size_t len = eq ? (size_t)(eq - arg) : strlen(arg); - for (int i = 0; longopts[i].name; i++) { - if (strncmp(arg, longopts[i].name, len) == 0 && - strlen(longopts[i].name) == len) { - if (longindex) - *longindex = i; - if (longopts[i].has_arg == - required_argument) { - if (eq) - optarg = (char *)eq + 1; - else if (optind + 1 < argc) - optarg = argv[++optind]; - else - return '?'; - } else if (longopts[i].has_arg == - optional_argument) - optarg = eq ? (char *)eq + 1 : - NULL; - else - optarg = NULL; - optind++; - if (longopts[i].flag) { - *longopts[i].flag = - longopts[i].val; - return 0; - } - return longopts[i].val; - } - } - optind++; - return '?'; - } - nextchar = argv[optind] + 1; - } - char c = *nextchar++; - const char *pos = strchr(optstring, c); - if (!pos) { - optopt = c; - if (*nextchar == '\0') - optind++; - return '?'; - } - if (pos[1] == ':') { - if (*nextchar != '\0') { - optarg = nextchar; - optind++; - nextchar = NULL; - } else if (optind + 1 < argc) { - optarg = argv[++optind]; - optind++; - nextchar = NULL; - } else { - optopt = c; - return '?'; - } - } else { - optarg = NULL; - if (*nextchar == '\0') { - optind++; - nextchar = NULL; - } - } - return c; -} - -/* end of file flag.c */ diff --git a/lib/flag.h b/lib/flag.h deleted file mode 100644 index 6576ab9..0000000 --- a/lib/flag.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * gcklib.flag - Contains command-line flag parsing functions - * - * - * LICENSE: BSD-3-Clause - * - * Copyright (c) 2025 GCK - * - * 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 of the copyright holder 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 HOLDER 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. - */ - -#ifndef FLAG_H -#define FLAG_H - -int getopt_long(int argc, char *const argv[], const char *optstring, - const struct option *longopts, int *longindex); - -#endif - -/* end of file flag.h */ diff --git a/lib/fs.c b/lib/fs.c deleted file mode 100644 index 70d027d..0000000 --- a/lib/fs.c +++ /dev/null @@ -1,211 +0,0 @@ -/* - * gcklib.fs - Contains file system related iterations - * - * CONFIGURATION - * #define FS_ERROR_ON - * Error instead of fatal on failure - * #define FS_FATAL_OFF - * Disable auto fatal on failure - * - * - * LICENSE: BSD-3-Clause - * - * Copyright (c) 2025 GCK - * - * 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 of the copyright holder 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 HOLDER 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 -#include -#include -#include -#include -#include -#include - -#include "fs.h" - -#include "err.h" -#include "xmem.h" - -#if defined(FS_ERROR_ON) -#define RETURN(code) \ - errorfa(code); \ - return code -#elif defined(FS_FATAL_OFF) -#define RETURN(code) return code -#else -#define RETURN(code) fatalfa(code) -#endif - -char *fs_read(const char *path) -{ - FILE *fptr = fopen(path, "r"); - if (!fptr) { -#if defined(FS_ERROR_ON) - errorfa(errno); -#elif defined(FS_FATAL_ON) - fatalfa(errno); -#endif - return NULL; - } - - size_t cap = 1024; - size_t len = 0; - char *buf = xmalloc(cap); - - int c; - while ((c = fgetc(fptr)) != EOF) { - if (len + 1 >= cap) { - cap *= 2; - char *tmp = realloc(buf, cap); - if (!tmp) { - free(buf); - fclose(fptr); - return NULL; - } - buf = tmp; - } - buf[len++] = (char)c; - } - buf[len] = '\0'; - - fclose(fptr); - return buf; -} - -bool fs_exists(const char *path) -{ - FILE *fptr; - bool exists; - - fptr = fopen(path, "r"); - if (fptr) { - exists = true; - } else { - exists = false; - } - - fclose(fptr); - return exists; -} - -int fs_append(const char *path, const char *format, ...) -{ - FILE *fp = fopen(path, "a"); - if (!fp) - RETURN(errno); - - va_list ap; - va_start(ap, format); - int ret = vfprintf(fp, format, ap); - va_end(ap); - - if (ret < 0) { - fclose(fp); - RETURN(errno); - } - - if (fclose(fp) != 0) - RETURN(errno); - - return ret; -} - -int fs_del(const char *path) -{ - RETURN(remove(path)); -} - -int fs_new(const char *path) -{ - size_t len; - int fd; - - if (path == NULL) { - errno = EINVAL; - RETURN(-1); - } - - len = strlen(path); - if (len == 0) { - errno = EINVAL; - RETURN(-1); - } - - if (path[len - 1] == '/') { - if (mkdir(path, 0777) == -1) - RETURN(-1); - } else { - fd = open(path, O_CREAT | O_EXCL | O_WRONLY, 0666); - if (fd == -1) - RETURN(-1); - close(fd); - } - - return 0; -} - -int fs_write(const char *path, const char *format, ...) -{ - FILE *fptr = fopen(path, "w"); - if (!fptr) - RETURN(-1); - - va_list ap; - va_start(ap, format); - int ret = vfprintf(fptr, format, ap); - va_end(ap); - - if (ret < 0) { - fclose(fptr); - RETURN(-1); - } - - if (fclose(fptr) != 0) - RETURN(-1); - - return ret; -} - -FILE *fs_temp() -{ - FILE *fptr = tmpfile(); - - if (!fptr) { -#if defined(FS_ERROR_ON) - errorf("tmp failed"); -#elif defined(FS_FATAL_ON) - fatalf("tmp failed"); -#endif - return NULL; - } - - return fptr; -} - -/* end of file fs.c */ diff --git a/lib/fs.h b/lib/fs.h deleted file mode 100644 index b149a41..0000000 --- a/lib/fs.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * gcklib.fs - Contains file system related iterations - * - * - * LICENSE: BSD-3-Clause - * - * Copyright (c) 2025 GCK - * - * 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 of the copyright holder 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 HOLDER 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. - */ - -#ifndef fs_H -#define fs_H - -#include -#include - -char *fs_read(const char *path); - -bool fs_exists(const char *path); - -int fs_append(const char *path, const char *format, ...); -int fs_del(const char *path); -int fs_new(const char *path); -int fs_write(const char *path, const char *format, ...); - -FILE *fs_temp(); - -#endif - -/* end of file fs.h */ diff --git a/lib/proginfo.c b/lib/proginfo.c deleted file mode 100644 index d07e000..0000000 --- a/lib/proginfo.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * gcklib.proginfo - Program information functions, macros, and variables - * - * - * LICENSE: BSD-3-Clause - * - * Copyright (c) 2025 GCK - * - * 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 of the copyright holder 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 HOLDER 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 -#include -#include -#include -#include - -#include "proginfo.h" - -/* TODO(vx-clutch): default this to argv[0] */ -const char *prog_name = ""; - -void set_prog_name(char *name) -{ - prog_name = prog_name ? basename(name) : ""; -} - -void emit_try_help() -{ - printf("Try '%s --help' for more information\n", prog_name); -} - -// void emit_version() -// { -// printf("\ -// %s %s %d\n\ -// Copyright (C) %d GCK.\n\ -// This is free software: you are free to change and redistribute it.\n\ -// There is NO WARRNTY, to the extent permitted by law.\n\ -// ", -// prog_name, VERSION, COMMIT, YEAR); -// } - -int parse_standard_options(int argc, char **argv, void (*print_help)(), - void (*print_version)()) -{ - for (int i = 0; i < argc; ++i) { - if (!strcmp(argv[i], "--help")) { - print_help(); - exit(EXIT_SUCCESS); - } else if (!strcmp(argv[i], "--version")) { - print_version(); - exit(EXIT_SUCCESS); - } - } - return 0; -} - -/* end of file proginfo.c */ diff --git a/lib/proginfo.h b/lib/proginfo.h deleted file mode 100644 index 371990f..0000000 --- a/lib/proginfo.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * gcklib.proginfo - Program information functions, macros, and variables - * - * - * LICENSE: BSD-3-Clause - * - * Copyright (c) 2025 GCK - * - * 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 of the copyright holder 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 HOLDER 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. - */ - -#ifndef proginfo_H -#define proginfo_H - -extern const char *prog_name; - -void set_prog_name(char *name); - -void emit_try_help(); -void emit_version(); - -int parse_standard_options(int argc, char **argv, void (*print_help)(), - void (*print_version)()); - -#endif - -/* end of file proginfo.h */ diff --git a/lib/say.c b/lib/say.c deleted file mode 100644 index f5d3139..0000000 --- a/lib/say.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - * gcklib.say - Provides printing and some string utilies - * - * - * LICENSE: BSD-3-Clause - * - * Copyright (c) 2025 GCK - * - * 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 of the copyright holder 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 HOLDER 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 "say.h" - -#include -#include -#include -#include -#include -#include - -#include "xmem.h" - -void alert() -{ - fputs("\a", stderr); - fflush(stderr); - return; -} - -int vasprintf(char **result, const char *fmt, va_list ap) -{ - int total_width = strlen(fmt) + 1; - *result = (char *)xmalloc(total_width); - return vsprintf(*result, fmt, ap); -} - -int asprintf(char **buf, const char *fmt, ...) -{ - int status; - va_list ap; - va_start(ap, fmt); - status = vasprintf(buf, fmt, ap); - va_end(ap); - return status; -} - -int say(const char *restrict format, ...) -{ - struct winsize w; - if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) == -1) { - va_list args; - va_start(args, format); - int ret = vprintf(format, args); - va_end(args); - putchar('\n'); - fflush(stdout); - return ret; - } - - printf("\0337"); // save cursor (ESC 7) - printf("\033[%d;1H", w.ws_row); // move to last row - printf("\033[2K"); // clear entire line - - va_list args; - va_start(args, format); - int ret = vprintf(format, args); // print formatted message - va_end(args); - - fflush(stdout); // ensure it's visible immediately - printf("\0338"); // restore cursor (ESC 8) - fflush(stdout); - - return ret; -} - -_Noreturn void die(const char *msg) -{ - fputs(msg, stderr); - exit(EXIT_FAILURE); -} - -/* end of file say.c */ diff --git a/lib/say.h b/lib/say.h deleted file mode 100644 index 9907b6d..0000000 --- a/lib/say.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * gcklib.say - Provides printing and some string utilies - * - * - * LICENSE: BSD-3-Clause - * - * Copyright (c) 2025 GCK - * - * 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 of the copyright holder 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 HOLDER 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. - */ - -#ifndef SAY_H -#define SAY_H - -#include - -int asprintf(char **buf, const char *fmt, ...); -int vasprintf(char **buf, const char *fmt, va_list ap); -int say(const char *restrict format, ...); - -void alert(); - -_Noreturn void die(const char *msg); - -#endif - -/* end of file say.h */ diff --git a/lib/textc.c b/lib/textc.c deleted file mode 100644 index a4cc53c..0000000 --- a/lib/textc.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * gcklib.textc - Text control - * - * - * LICENSE: BSD-3-Clause - * - * Copyright (c) 2025 GCK - * - * 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 of the copyright holder 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 HOLDER 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 "xmem.h" -#include -#include - -#include "textc.h" - -char *str_dup(char *s) -{ - char *new = xmalloc(strlen(s) + 1); - strcpy(new, s); - return new; -} - -char *tostrupr(char *s) -{ - char *new = str_dup(s); - for (int i = 0; new[i] != '\0'; ++i) - new[i] = toupper((unsigned char)new[i]); - return new; -} - -char *tostrlwr(char *s) -{ - char *new = str_dup(s); - for (int i = 0; new[i] != '\0'; ++i) - new[i] = tolower((unsigned char)new[i]); - return new; -} - -char *textc_trim(char *s) -{ - return NULL; -} - -char *textc_pad_left(int count, char *s, char pad) -{ - char *buffer = xmalloc(strlen(s) + 1); - - free(buffer); - buffer = "NOT IMPLEMENTED"; - - return buffer; -} - -/* end of file textc.c */ diff --git a/lib/textc.h b/lib/textc.h deleted file mode 100644 index 4ef80d9..0000000 --- a/lib/textc.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * gcklib.textc - Text control - * - * - * LICENSE: BSD-3-Clause - * - * Copyright (c) 2025 GCK - * - * 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 of the copyright holder 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 HOLDER 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. - */ - -#ifndef TEXTC_H -#define TEXTC_H - -char *str_dup(char *s); -char *tostrupr(char *s); -char *tostrlwr(char *s); - -char *textc_trim(char *s); -char *textc_pad_left(int count, char *s, char pad); -char *textc_pad_right(int count, char *s, char pad); - -#endif - -/* end of file textc.h */ diff --git a/lib/xmem.c b/lib/xmem.c deleted file mode 100644 index 214201e..0000000 --- a/lib/xmem.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * gcklib.xmem - Xplosive memory - * - * - * LICENSE: BSD-3-Clause - * - * Copyright (c) 2025 GCK - * - * 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 of the copyright holder 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 HOLDER 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 -#include - -#include "err.h" - -#include "xmem.h" - -void *ensure_nonnull(void *ptr) -{ - if (ptr == NULL) - fatalf("memory exhausted"); - return ptr; -} - -void *xmalloc(size_t size) -{ - return ensure_nonnull(malloc(size)); -} - -void *xrealloc(void *ptr, size_t size) -{ - return ensure_nonnull(realloc(ptr, size)); -} - -void *xcalloc(size_t nmemb, size_t size) -{ - return ensure_nonnull(calloc(nmemb, size)); -} - -/* end of file xmem.c */ diff --git a/lib/xmem.h b/lib/xmem.h deleted file mode 100644 index bda7785..0000000 --- a/lib/xmem.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * gcklib.xmem - Xplosive memory - * - * - * LICENSE: BSD-3-Clause - * - * Copyright (c) 2025 GCK - * - * 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 of the copyright holder 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 HOLDER 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. - */ - -#ifndef xmem_H -#define xmem_H - -#include - -void *xmalloc(size_t size); -void *xrealloc(void *ptr, size_t size); -void *xcalloc(size_t nmemb, size_t size); - -#endif - -/* end of file xmem.h */ diff --git a/man/yait.x b/man/yait.x deleted file mode 100644 index aa6ddb3..0000000 --- a/man/yait.x +++ /dev/null @@ -1,4 +0,0 @@ -[NAME] -yait - An opinionated C project generator -[ADDITIONAL INFORMATION] -.UR https://github.com/gck-org/yait diff --git a/scripts/manual/make b/scripts/manual/make deleted file mode 100755 index 19e136a..0000000 --- a/scripts/manual/make +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: BSD-3-Clause -me=$0 -scriptversion="1.0.0" - -version="$me $scriptversion - -Copyright (C) 2025 GCK. -This is free software; you are free to change and redistribute it. -There is NO WARRANTY, to the extent permitted by law." - -usage="\ -Usage: $me [OPTION]... -Builds man page - -Options: - - --help print this help and exit - --version output version information" - -package=yait - -while test $# -gt 0; do - case $1 in - --help) echo "$usage"; exit 0;; - --version) echo "$version"; exit 0;; - -*) - echo "$0: Unknown option '$1'." >&2 - echo "$0: Try '--help' for more information.'$1'." >&2 - exit 1;; - esac - shift -done - -help2man --include=man/$package.x ./bin/$package > $package.1 diff --git a/src/flat.c b/src/flat.c deleted file mode 100644 index 04bb9d2..0000000 --- a/src/flat.c +++ /dev/null @@ -1,42 +0,0 @@ -// SPDX-License-Identifer: BSD-3-Clause -/* - * A uemacs derided and inspired layout and format for smaller projects; - * such as, a small test, or CLI. - */ -#include -#include - -#include -#include "flat.h" - -int generate_flat(char *package, char *author, int year, char *license, - char *desc) -{ - char *main; - asprintf(&main, "%s.c", package); - fs_write("Makefile", templ_FLAT_MAKEFILE, package); - fs_write(main, "%s", license); - fs_write("version.h", "\ -#ifndef VERSION_H_\n\ -#define VERSION_H_\n\ -\n\ -#define PROGRAM_NAME \"%s\"\n\ -#define PROGRAM_NAME_LONG \"%s/%s\"\n\ -\n\ -#define VERSION \"1.0.0\"\n\ -\n\ -/* Print the version string. */\n\ -void version();\n\ -\n\ -#endif", - package, package, author); - fs_write("version.c", "\ -#include \n\ -#include \"version.h\"\n\ -\n\ -void version()\n\ -{\n\ - printf(\"%%s version %%s\\n\", PROGRAM_NAME_LONG, VERSION);\n\ -}"); - return 0; -} diff --git a/src/flat.h b/src/flat.h deleted file mode 100644 index 35ab1fe..0000000 --- a/src/flat.h +++ /dev/null @@ -1,8 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -#ifndef FLAT_H_ -#define FLAT_H_ - -int generate_flat(char *package, char *author, int year, char *license, - char *desc); - -#endif diff --git a/src/license.h b/src/license.h deleted file mode 100644 index 78f896b..0000000 --- a/src/license.h +++ /dev/null @@ -1,82 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -#ifndef LICENCES_H_ -#define LICENCES_H_ - -const char *fBSD = "\ -BSD 3-Clause License\n\ -\n\ -Copyright (c) %d, %s\n\ -\n\ -Redistribution and use in source and binary forms, with or without\n\ -modification, are permitted provided that the following conditions are met:\n\ -\n\ -1. Redistributions of source code must retain the above copyright notice, this\n\ - list of conditions and the following disclaimer.\n\ -\n\ -2. Redistributions in binary form must reproduce the above copyright notice,\n\ - this list of conditions and the following disclaimer in the documentation\n\ - and/or other materials provided with the distribution.\n\ -\n\ -3. Neither the name of the copyright holder nor the names of its\n\ - contributors may be used to endorse or promote products derived from\n\ - this software without specific prior written permission.\n\ -\n\ -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \" AS IS \"\n\ -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n\ -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n\ -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n\ -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n\ -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n\ -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n\ -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n\ -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n\ -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\ -"; - -const char *fGPL = "\ - SPDX-License-Identifier: GPL-3.0-or-later\n\ -\n\ -This program is free software: you can redistribute it and/or modify it\n\ -under the terms of the GNU General Public License as published by the\n\ -Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n\ -\n\ -For details, see ."; - -const char *fMIT = "\ -Copyright %d %s\n\ -\n\ -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:\n\ -\n\ -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\ -\n\ -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.\n\ -"; - -const char *fUNL = "\ -This is free and unencumbered software released into the public domain.\n\ -\n\ -Anyone is free to copy, modify, publish, use, compile, sell, or\n\ -distribute this software, either in source code form or as a compiled\n\ -binary, for any purpose, commercial or non-commercial, and by any\n\ -means.\n\ -\n\ -In jurisdictions that recognize copyright laws, the author or authors\n\ -of this software dedicate any and all copyright interest in the\n\ -software to the public domain. We make this dedication for the benefit\n\ -of the public at large and to the detriment of our heirs and\n\ -successors. We intend this dedication to be an overt act of\n\ -relinquishment in perpetuity of all present and future rights to this\n\ -software under copyright law.\n\ -\n\ -THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n\ -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n\ -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n\ -IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\n\ -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\n\ -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n\ -OTHER DEALINGS IN THE SOFTWARE.\n\ -\n\ -For more information, please refer to \ -"; - -#endif diff --git a/src/shell.c b/src/shell.c deleted file mode 100644 index d6d4375..0000000 --- a/src/shell.c +++ /dev/null @@ -1,62 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -#include -#include -#include -#include - -int write_shell(char *package, char *license, int year, char *author, char *m) -{ - fs_write(package, "\ -#!/bin/sh\n\ -# SPDX-License-Identifier: %s\n\ -#\n\ -# %s\n\ -\n\ -me=$0\n\ -scriptversion=\"1.0.0\"\n\ -\n\ -version=\"$me $scriptversion\n\ -\n\ -Copyright (C) %d %s\n\ -This is free software; you are free to change and redistribute it.\n\ -There is NO WARRANTY, to the textent permitted by law.\"\n\ -\n\ -usage=\"\\\n\ -Usage: $me [OPTION]...\n\ -%s\n\ -\n\ -Options:\n\ -\n\ - --help print this help and exit\n\ - --version output version information\"\n\ -\n\ -while [ $# -gt 0 ]; do\n\ - case $1 in\n\ - --help) echo \"$usage\"; exit 0;;\n\ - --version) echo \"$version\"; exit 0;;\n\ - -*)\n\ - echo \"$0: Unknwon option '$1'.\" >&2\n\ - echo \"$0: Try '--help' for more information.\" >&2\n\ - exit 1 ;;\n\ - esac\n\ - shift\n\ -done\n\ -\n\ -echo \"$0: done.\"\n\ -\n\ -# End: %s\ -", - license, m, year, author, m, package); - struct stat st; - - if (stat(package, &st) != 0) { - fatalfa(errno); - } - - mode_t mode = st.st_mode | S_IXUSR; - - if (chmod(package, mode) != 0) { - fatalfa(errno); - } - return 0; -} diff --git a/src/shell.h b/src/shell.h deleted file mode 100644 index fa9f9ac..0000000 --- a/src/shell.h +++ /dev/null @@ -1,7 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -#ifndef SHELL_H_ -#define SHELL_H_ - -int write_shell(char *package, char *license, int year, char *author, char *m); - -#endif diff --git a/src/version.c b/src/version.c deleted file mode 100644 index d3855b7..0000000 --- a/src/version.c +++ /dev/null @@ -1,8 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -#include -#include "version.h" - -void version() -{ - printf("%s version %s\n", PROGRAM_NAME_LONG, VERSION); -} diff --git a/src/version.h b/src/version.h deleted file mode 100644 index f3a8364..0000000 --- a/src/version.h +++ /dev/null @@ -1,13 +0,0 @@ -// SPDX-License-Identifer: BSD-3-Clause -#ifndef VERSION_H_ -#define VERSION_H_ - -#define PROGRAM_NAME "yait" -#define PROGRAM_NAME_LONG "yait/GCK" - -#define VERSION "beta" - -/* Print the version string. */ -void version(); - -#endif diff --git a/src/yait.c b/src/yait.c deleted file mode 100644 index d86f257..0000000 --- a/src/yait.c +++ /dev/null @@ -1,235 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -/* - * Copyright (C) 2025, GCK. - * Written by vx-clutch (vx-clutch) - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "flat.h" -#include "license.h" -#include "shell.h" -#include "version.h" -#include - -#ifndef GOOD -#define GOOD 0 -#endif - -typedef enum { MIT, GPL, BSD, UNL } license_t; - -static const struct option longopts[] = { - { "author", required_argument, 0, 'a' }, - { "license", required_argument, 0, 'l' }, - { "flat", no_argument, 0, 'f' }, - { 0, 0, 0, 0 } -}; - -static int exit_status; - -static void print_help(); - -static char *get_name() -{ - int fds[2]; - if (pipe(fds) == -1) - goto sysuser; - - pid_t pid = fork(); - if (pid == -1) { - close(fds[0]); - close(fds[1]); - goto sysuser; - } - - if (pid == 0) { - dup2(fds[1], STDOUT_FILENO); - close(fds[0]); - close(fds[1]); - execlp("git", "git", "config", "--get", "user.name", - (char *)NULL); - _exit(127); - } - - close(fds[1]); - char buf[256]; - ssize_t n = read(fds[0], buf, sizeof buf - 1); - close(fds[0]); - int status; - waitpid(pid, &status, 0); - if (n > 0 && WIFEXITED(status) && WEXITSTATUS(status) == 0) { - buf[n] = 0; - buf[strcspn(buf, "\n")] = 0; - return str_dup(buf); - } - -sysuser: { - char *name = getlogin(); - if (name) - return str_dup(name); - struct passwd *pw = getpwuid(getuid()); - if (pw && pw->pw_name) - return str_dup(pw->pw_name); -} - return str_dup("author"); -} - -static int get_year() -{ - time_t now = time(NULL); - struct tm *t = localtime(&now); - - return t->tm_year + 1900; -} - -int main(int argc, char **argv) -{ - int optc; - int lose = 0; - char *m = str_dup("[DESCRIPTION]"), /* description flag */ - *package; - bool S = false; /* shell flag */ - bool f = false; /* flat flag */ - char *author = get_name(); - exit_status = GOOD; - int year = get_year(); - license_t license = BSD; - char *license_str = "BSD-3-Clause"; - set_prog_name(argv[0]); - - parse_standard_options(argc, argv, print_help, version); - - while ((optc = getopt_long(argc, argv, "a:l:m:EqfS", longopts, NULL)) != - -1) - switch (optc) { - case 'a': - if (optarg) { - if (author) - free(author); - author = str_dup(optarg); - } - break; - case 'm': - if (optarg) { - if (m) - free(m); - m = str_dup(optarg); - } - break; - case 'l': - if (!strcmp(optarg, "list")) { - puts("BSD\nGPL\nMIT\nUNL"); - exit(EXIT_SUCCESS); - } - if (!strcmp(optarg, "GPL")) { - license = GPL; - license_str = "GPL-3.0-only"; - } else if (!strcmp(optarg, "MIT")) { - license = MIT; - license_str = "MIT"; - } else if (!strcmp(optarg, "BSD")) { - license = BSD; - license_str = "BSD-3-Clause"; - } else if (!strcmp(optarg, "UNL")) { - license = UNL; - license_str = "Unlicense"; - } else { - puts("BSD\nGPL\nMIT\nUNL"); - exit(EXIT_FAILURE); - } - break; - case 'S': - S = true; - break; - case 'f': - f = true; - break; - default: - lose = 1; - } - if (lose) { - emit_try_help(); - } - - if (optind >= argc) { - fatalf("no input name"); - } - - if (optind + 1 < argc) { - errorf("extra operand: %s", argv[optind + 1]); - emit_try_help(); - } - - package = str_dup(argv[optind]); - - if (S) - return write_shell(package, license_str, year, author, m); - - char *project_dir; - asprintf(&project_dir, "%s/", package); - - fs_new(project_dir); - if (chdir(project_dir)) - fatalfa(errno); - - switch (license) { - case MIT: - fs_write("COPYING", fMIT, year, author); - break; - case GPL: - fs_write("COPYING", fGPL); - break; - case BSD: - fs_write("COPYING", fBSD, year, author); - break; - case UNL: - default: - fs_write("COPYING", fUNL); - } - - fs_write("README", templ_README, author, package, package, m, year, - package, author, package); - - if (f) - exit_status = - generate_flat(package, author, year, license_str, m); - // else - // exit_status = - // generate_regular(package, author, year, license_str, m); - - return exit_status; -} - -static void print_help() -{ - printf("Usage: %s [OPTION]... [project-name]...\n", PROGRAM); - fputs("\ -Generates an opinionated C project.\n", - stdout); - puts(""); - fputs("\ - --help display this help and exit\n\ - --version display version information and exit\n", - stdout); - puts(""); - fputs("\ - -m DESC Set the program description (default \"Does a thing\")\n\ - --author NAME Set the program author (default git username|system username)\n\ - --license LICENSE Set the program license (default BSD)\n", - stdout); - exit(exit_status); -} diff --git a/t/INSTALL.x b/t/INSTALL.x deleted file mode 100644 index 4a69adc..0000000 --- a/t/INSTALL.x +++ /dev/null @@ -1,55 +0,0 @@ -Format_Index: y, a -Installation Instructions -************************* - -Copyright (C) %d %s - - Copying and distribution of this file, with or without modification, -are permitted in any medium without royalty provided the copyright -notice and this notice are preserved. This file is offered as-is, -without warranty of any kind. - -Basic Installation -================== - - Briefly, the shell command `./configure && make && make install` should -configure, build, and install this package. The following more-detailed -instruction are generic; see the `README` file for instructions specific to -this package. - - The `configure` shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values within a `Makefile` to build for that POSIX system as -defined by `config.mak` which was generated by `configure`. - -Compilers and Options -===================== - - Some systems require unusal options for compilation or linking that -the `configure` script does not know about. If you run into an issue -run `./configure --help` to figure out what you can do to fix the -behavoir. - -Installation Names -================== - - By default, `make install` installs the package's command under -`/usr/local/bin`. You can specify an installation prefix other than `/usr/local/` -by giving `configure` the option `--prefix=PREFIX` to `configure`, the package uses -PREFIX as the prefix for installation programs and libraries. -Documentation and other data files still use the regular prefix. - -`configure` Invokation -====================== - - `configure` recongizes the following options to control its operations. - - `--help` - Prints a summary of all the options to `configure`, and exits. - `--prefix=PREFIX` - Sets the installation prefix. - `CFLAGS` - Sets the flags used during compilation. - -`configure` also accepts some other options. Run `configure --help` for more -details diff --git a/t/Makefile.x b/t/Makefile.x deleted file mode 100644 index 55fd924..0000000 --- a/t/Makefile.x +++ /dev/null @@ -1,64 +0,0 @@ -Format_Index: p -# SPDX-License-Identifier: BSD-3-Clause -PACKAGE := %s - -SRCS := $(wildcard src/*.c) $(wildcard lib/*.c) -OBJS := $(patsubst src/%.c,build/obj/%.o,$(SRCS)) - -BIN := bin/$(PACKAGE) - -COMMIT := $(shell git rev-list --count --all) -FLAGS := -I. -DCOMMIT=$(COMMIT) --std=c2x -pedantic -Ibuild/include - -VERSION := $(shell git describe --tags --always --dirty) -TARBALL := $(PACKAGE)-$(VERSION).tar.gz -RELEASE_FILES := doc src lib COPYING AUTHORS README $(PACKAGE).1 INSTALL Makefile configure config.h - --include config.mak - -ifeq ($(wildcard config.mak),) -all: - @echo "File config.mak not found, run configure" - @exit 1 -else - -all: build $(BIN) doc - -build: - mkdir -p bin - mkdir -p build/obj - -build/obj/%.o: src/%.c config.mak - $(CC) $(FLAGS) $(CFLAGS) -c $< -o $@ - -$(BIN): $(OBJS) - $(CC) $(FLAGS) $(CFLAGS) $^ -o $@ - -endif - -install: $(BIN) - cp $(BIN) $(PREFIX) - -doc: - $(MAKE) -C doc all - -uninstall: - $(RM) $(PREFIX)$(PACKAGE) - -clean: - $(RM) -r bin - $(RM) -r build - $(MAKE) -C doc clean - -distclean: clean - $(RM) config.mak config.status - $(RM) $(TARBALL) - $(MAKE) -C doc clean - -release: clean all - tar -czf $(TARBALL) $(RELEASE_FILES) - -test: - @$(BIN) --version > /dev/null 2>&1 && echo "intact"|| echo "defective" - -.PHONY: all clean distclean install uninstall build release doc diff --git a/t/README-dev.x b/t/README-dev.x deleted file mode 100644 index 7476f18..0000000 --- a/t/README-dev.x +++ /dev/null @@ -1,113 +0,0 @@ -Format_Index: y, a -This README.dev file describes the development environment. - - Copyright (C) %d %s. - - Copying and distribution of this file, with or without modification, - are permitted in any medium without royalty provided the copyright - notice and this notice are preserved. - -Notice ------- - -This documentation is standard across all GCK package and is not specified per -package; however, this is the defacto standard for most packages. The only -place where this commonly differs is in non-binary or library packages. - - -Build system ------------- - -This distribution uses a GNU autotools-like build system. This is made up of a -configure script, and a Makefile. The configure script detects a C23 compiler -on the system and sets any program flags: debug, release, custom. The Makefile -builds the binary based on the output [config.mak] of the configure script. - - -Building --------- - -To build this distribution you first must run the configure script. This -outputs a config.mak file that will be used in the Make step. Then run make; -this builds the objects into build/ and the binary into bin/. - - -Configuration -------------- - -The configuration script is used to generate a build intermediate step called -the config.mak. This file is used by the Makefile to figure out C compiler to -use, what CFLAGS and LDFLAGS to use, and where to install the binary if -requested. By default these values are gcc, the release flag set, and -/usr/local/. The configuration script supports the following flags that control -CFLAGS: --enable-debug and CFLAGS="". By default, the script uses flags for a release -build. Debug is for in-development programming and is the strictest when it -comes to warnings and other compiler output. CFLAGS="" is for custom flag -definition. For the development environment is it recommended to use the ---debug flag. Some examples of how you can run the configure script: - -For default behavior: - - ./configure - -For debug use: - - ./configure --enable-debug - -For help text: - - ./configure --help - -The help text is a more useage specific and up-to-date reference for -the configure script. - - -Makefile --------- - -The GNU Makefile is used to build the final executable, clean up build -artifacts, and install the program. It checks for the config.mak which is -generated by the configure script. For a regular build, once you have the -configure script with desired flags, run: - - make - -This builds the executable to bin/ and build objects to build/ - - -Suggested enviroment setup --------------------------- -It is suggested that you run do the following things to prepare you environment -for development. This is not a strict enforcement, but due to the project -structure it is a good starting point. - - git pull - ./tools/Cleanup - ./configure --enable-debug - ./build-aux/generate-artifacts - make test - -This is to ensure that you have the most up-to-date source code, and that there -are no major problems with the source control version. - -The git pull is used to sync with the repository and prevent conflicts. The -cleanup is to ensure their are no lingering build artifacts. The configure with -debug enabled is for strict build flags and -ggdb. Bear is used to generated -compile_commands.json for the clang suite of tooling. Finally, run the program -to ensure the chain works. - - -Pre-commit checks ------------------ - -Before you commit to source control ensure that done the following: - - * Run the cleanup scripts - - ./tools/Cleanup - - * Ensure that all changes were atomic - - * If you compted a TODO list item check it off. - - * Based on complexity, test the feature accordingly. diff --git a/t/README-release.x b/t/README-release.x deleted file mode 100644 index b33476f..0000000 --- a/t/README-release.x +++ /dev/null @@ -1,33 +0,0 @@ -Format_Index: -Here are most of the steps before you make a release. - -* Start from a clean, up-to-date git driectory on "master": - - make -k distclean || { ./configure && make distclean; } - git checkout master - git pull origin master - -* Ensure that the latest stable versions of make, sh, etc. -are in your path. See the prerequisites list in README-dev -for a compile list of tools. - -* Ensure that you have no uncommitted diffs. This should produce -no output: - - git diff - -* Ensure that you've pushed all changes that belong in the release: - - git push origin master - -* Pre-release testing: ensure that the following command succeeds: - - make check syntax-check distcheck - -Once all the builds and tests have passed, - -* Run the following to create release tarballs. - - make release - -* Upload the tarball to the relavent distribtuion platform. diff --git a/t/README.x b/t/README.x deleted file mode 100644 index d19a068..0000000 --- a/t/README.x +++ /dev/null @@ -1,30 +0,0 @@ -Format_Index: a, p, p, d, y, p, a, p -This is the README file for the %s %s distribution. -%s %s - - Copyright (C) %d %s. - - Copying and distribution of this file, with or without modification, - are permitted in any medium without royalty provided the copyright - notice and this notice are preserved. - -See the files ./INSTALL* for building and installation instructions. - -Bug reports: - Please include enough information for the maintainers to reproduce the - problem. Generally speaking, that means: -- the contents of any input files necessary to reproduce the bug - and command line invocations of the program(s) involved (crucial!). -- a description of the problem and any samples of the erroneous output. -- the version number of the program(s) involved (use --version). -- hardware, operating system, and compiler versions (uname -a). -- unusual options you gave to configure, if any (see config.mak). -- anything else that you think would be helpful. - -See README-dev for information on the development environment -- any -interested parties are welcome. If you're a programmer and wish to -contribute, this should get you started. If you're not a programmer, -your help in writing test cases, checking documentation against the -implementation, etc., would still be very much appreciated. - -%s %s is free software. See the file COPYING for copying conditions. diff --git a/t/flat_Makefile.x b/t/flat_Makefile.x deleted file mode 100644 index 891791a..0000000 --- a/t/flat_Makefile.x +++ /dev/null @@ -1,31 +0,0 @@ -Format_Index: p -PROGRAM = %s -CC = gcc -CFLAGS = -O2 -Wall -Wstrict-prototypes -g -DEFINES = -LIBS = - -SRC = $(wildcard *.c) -OBJ = $(SRC:.c=.o) - -V = -ifeq ($(strip $(V)),) -E = @echo -Q = @ -else -E = @\# -Q = -endif -export E Q - -$(PROGRAM): $(OBJ) - $(E) " LINK " $@ - $(Q) $(CC) $(CFLAGS) $(DEFINES) -o $@ $^ $(LIBS) - -%.o: %.c - $(E) " CC " $@ - $(Q) $(CC) $(CFLAGS) $(DEFINES) -c $< - -clean: - $(E) " CLEAN" - $(Q) rm -f $(PROGRAM) $(OBJ) diff --git a/t/main.x b/t/main.x deleted file mode 100644 index 627c827..0000000 --- a/t/main.x +++ /dev/null @@ -1,50 +0,0 @@ -Format_Index: l, y, a, d, a -// SPDX-License-Identifier: %s -/* - * Copyright (C) %d, %s. - * Written by YOU (you@example.com) - */ - #include - - static int exit_status; - - static void print_help(); - static void print_version(); - - int main(int argc, char **argv) - { - exit_status = EXIT_SUCCESS; - - return exit_status; - } - -static void print_help() -{ - printf("Usage: %%s [OPTION]...\n", PROGRAM); - fputs("\ -%s.\n", - stdout); - puts(""); - fputs("\ - --help display this help and exit\n\ - --version display version information and exit\n", - stdout); - /* - puts(""); - fputs("\ - --foo Enable the foo directive\n", - stdout); - */ - exit(exit_status); -} - -static void print_version() -{ - printf("%%s %%s %%d\n", prog_name, VERSION, COMMIT); - - printf("Copyright (C) %%d %s.\n", YEAR); - - puts("This is free software: you are free to change and redistribute it."); - puts("There is NO WARRANTY, to the extent permitted by law."); - exit(exit_status); -} diff --git a/t/shell.x b/t/shell.x deleted file mode 100644 index 0ef6ab5..0000000 --- a/t/shell.x +++ /dev/null @@ -1,39 +0,0 @@ -Format_Index: l,d,y,a,d,p -#!/bin/sh -# SPDX-License-Identifier: %s -# -# %s - -me=$0 -scriptversion="1.0.0" - -version="$me $scriptversion - -Copyright (C) %d %s -This is free software; you are free to change and redistribute it. -There is NO WARRANTY, to the textent permitted by law." - -usage="\ -Usage: $me [OPTION]... -%s - -Options: - - --help print this help and exit - --version output version information" - -while [ $# -gt 0 ]; do - case $1 in - --help) echo "$usage"; exit 0;; - --version) echo "$version"; exit 0;; - -*) - echo "$0: Unknown option '$1'." >&2 - echo "$0: Try '--help' for more information." >&2 - exit 1 ;; - esac - shift -done - -echo "$0: done." - -# End: %s diff --git a/t/t b/t/t deleted file mode 100755 index c5264a3..0000000 --- a/t/t +++ /dev/null @@ -1,154 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: BSD-3-Clause -me=$0 -scriptversion="1.0.1" - -version="$me $scriptversion - -Copyright (C) 2025 GCK. -This is free software; you are free to change and redistribute it. -There is NO WARRANTY, to the extent permitted by law." - -usage="\ -Usage: $me [OPTION]... -Generate template headers - -Options: - - --help print this help and exit - --version output version information" - -while test $# -gt 0; do - case $1 in - --help) echo "$usage"; exit 0;; - --version) echo "$version"; exit 0;; - -*) - echo "$0: Unknown option '$1'." >&2 - echo "$0: Try '--help' for more information." >&2 - exit 1;; - esac - shift -done - -x_files=$(find . -maxdepth 1 -name "*.x" -type f | sort) - -if test -z "$x_files"; then - echo "$0: No .x files found in current directory." >&2 - exit 1 -fi - -output_file="../template.h" -mkdir -p ../build/include/ - -first_template=true - -{ - echo "/* DO NOT MODIFY THIS FILE! It was generated by t $scriptversion. */" - echo "#ifndef TEMPLATE_H" - echo "#define TEMPLATE_H" - - for input_file in $x_files; do - base_name=$(basename "$input_file" .x) - template_name=$(echo "$base_name" | tr '[:lower:]' '[:upper:]') - - tmp_format=$(mktemp) - tmp_template=$(mktemp) - tmp_params=$(mktemp) - - format_index=$(head -n 1 "$input_file") - if ! echo "$format_index" | grep -q "^Format_Index:"; then - echo "$0: '$input_file': Missing Format_Index line." >&2 - rm -f "$tmp_format" "$tmp_template" "$tmp_params" - continue - fi - - if test "$first_template" = false; then - echo "" - fi - first_template=false - - tmp_specs=$(mktemp) - - echo "$format_index" | sed 's/Format_Index://' | tr ',' '\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' > "$tmp_params" - - tail -n +2 "$input_file" | sed '/^$/d' > "$tmp_template" - - param_names="" - while IFS= read -r param; do - param_names="$param_names $param" - done < "$tmp_params" - - while IFS= read -r line; do - echo "$line" | grep -o '%[sdifgxXoucpeEaAn]' >> "$tmp_specs" - done < "$tmp_template" - - echo "/*" - - param_idx=1 - for param in $param_names; do - format_type="" - spec=$(sed -n "${param_idx}p" "$tmp_specs") - case "$spec" in - %s|%S) format_type="(s)" ;; - %d|%i|%u|%x|%X|%o) format_type="(d)" ;; - %f|%g|%e|%E|%a|%A) format_type="(f)" ;; - %c) format_type="(c)" ;; - %p) format_type="(p)" ;; - %n) format_type="(n)" ;; - *) format_type="(?)" ;; - esac - - case "$param" in - a) param="author" ;; - y) param="year" ;; - l) param="license" ;; - d) param="description" ;; - p) param="package" ;; - esac - - printf " * %-13s%s\n" "$param" "$format_type" - param_idx=$((param_idx + 1)) - done - - echo " */" - echo "static const char templ_${template_name}[] = \"\\" - - line_count=0 - total_lines=$(wc -l < "$tmp_template") - while IFS= read -r line; do - line_count=$((line_count + 1)) - escaped_line=$(echo "$line" | sed \ - -e 's/\\\\/__BSLASH__/g' \ - -e 's/\\"/__BQUOTE__/g' \ - -e 's/\\n/__NEWLINE__/g' \ - -e 's/\\t/__TAB__/g' \ - -e 's/\\r/__RETURN__/g' \ - -e 's/\\a/__ALERT__/g' \ - -e 's/\\b/__BACKSPACE__/g' \ - -e 's/\\f/__FORMFEED__/g' \ - -e 's/\\v/__VTAB__/g' \ - -e 's/\\0/__NULL__/g' \ - -e 's/\\/\\\\/g' \ - -e 's/"/\\"/g' \ - -e 's/__BSLASH__/\\\\/g' \ - -e 's/__BQUOTE__/\\"/g' \ - -e 's/__NEWLINE__/\\n/g' \ - -e 's/__TAB__/\\t/g' \ - -e 's/__RETURN__/\\r/g' \ - -e 's/__ALERT__/\\a/g' \ - -e 's/__BACKSPACE__/\\b/g' \ - -e 's/__FORMFEED__/\\f/g' \ - -e 's/__VTAB__/\\v/g' \ - -e 's/__NULL__/\\0/g') - if test $line_count -lt $total_lines; then - printf '%s\\n\\\n' "$escaped_line" - else - printf '%s";\n' "$escaped_line" - fi - done < "$tmp_template" - - rm -f "$tmp_format" "$tmp_template" "$tmp_params" "$tmp_specs" - done - - echo "#endif" -} > "$output_file" diff --git a/template.h b/template.h deleted file mode 100644 index 4799e6d..0000000 --- a/template.h +++ /dev/null @@ -1,68 +0,0 @@ -/* DO NOT MODIFY THIS FILE! It was generated by t 1.0.1. */ -#ifndef TEMPLATE_H -#define TEMPLATE_H -/* - * package (s) - */ -static const char templ_FLAT_MAKEFILE[] = "\ -PROGRAM = %s\n\ -CC = gcc\n\ -CFLAGS = -O2 -Wall -Wstrict-prototypes -g\n\ -DEFINES =\n\ -LIBS =\n\ -SRC = $(wildcard *.c)\n\ -OBJ = $(SRC:.c=.o)\n\ -V =\n\ -ifeq ($(strip $(V)),)\n\ -E = @echo\n\ -Q = @\n\ -else\n\ -E = @\\#\n\ -Q =\n\ -endif\n\ -export E Q\n\ -$(PROGRAM): $(OBJ)\n\ - $(E) \" LINK \" $@\n\ - $(Q) $(CC) $(CFLAGS) $(DEFINES) -o $@ $^ $(LIBS)\n\ -%.o: %.c\n\ - $(E) \" CC \" $@\n\ - $(Q) $(CC) $(CFLAGS) $(DEFINES) -c $<\n\ -clean:\n\ - $(E) \" CLEAN\"\n\ - $(Q) rm -f $(PROGRAM) $(OBJ)"; - -/* - * author (s) - * package (s) - * package (s) - * description (s) - * year (d) - * package (s) - * author (s) - * package (s) - */ -static const char templ_README[] = "\ -This is the README file for the %s %s distribution.\n\ -%s %s\n\ - Copyright (C) %d %s.\n\ - Copying and distribution of this file, with or without modification,\n\ - are permitted in any medium without royalty provided the copyright\n\ - notice and this notice are preserved.\n\ -See the files ./INSTALL* for building and installation instructions.\n\ -Bug reports:\n\ - Please include enough information for the maintainers to reproduce the\n\ - problem. Generally speaking, that means:\n\ -- the contents of any input files necessary to reproduce the bug\n\ - and command line invocations of the program(s) involved (crucial!).\n\ -- a description of the problem and any samples of the erroneous output.\n\ -- the version number of the program(s) involved (use --version).\n\ -- hardware, operating system, and compiler versions (uname -a).\n\ -- unusual options you gave to configure, if any (see config.mak).\n\ -- anything else that you think would be helpful.\n\ -See README-dev for information on the development environment -- any\n\ -interested parties are welcome. If you're a programmer and wish to\n\ -contribute, this should get you started. If you're not a programmer,\n\ -your help in writing test cases, checking documentation against the\n\ -implementation, etc., would still be very much appreciated.\n\ -%s %s is free software. See the file COPYING for copying conditions."; -#endif diff --git a/tools/Cleanup b/tools/Cleanup deleted file mode 100755 index e4185ca..0000000 --- a/tools/Cleanup +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: BSD-3-Clause -me=$0 -scriptversion="1.0.0" - -version="$me $scriptversion - -Copyright (C) 2025 GCK. -This is free software; you are free to change and redistribute it. -There is NO WARRANTY, to the extent permitted by law." - -usage="\ -Usage: $me [OPTION]... -Standard GCK cleanup - -Options: - -q, --quiet silence output - - --help print this help and exit - --version output version information" - -QUIET= - -while test $# -gt 0; do - case $1 in - --help) echo "$usage"; exit 0;; - --version) echo "$version"; exit 0;; - --quiet|-q) QUIET="--quiet";; - -*) - echo "$0: Unknown option '$1'." >&2 - echo "$0: Try '--help' for more information.'$1'." >&2 - exit 1;; - esac - shift -done - -fatal() { - echo "fatal: $*" >&2 - exit 1 -} - -run() { - "$@" || fatal "could not run: $*" -} - -[ -d "./git" ] && fatal "must be run from parent directory" - -run sh ./tools/format $QUIET -run rm -rf .cache -run rm -f compile_commands.json -run make distclean - -if [ -z "$QUIET" ]; then - echo "done." -fi diff --git a/tools/format b/tools/format deleted file mode 100755 index 853f5d8..0000000 --- a/tools/format +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: BSD-3-Clause -me=$0 -scriptversion="1.0.0" - -version="$me $scriptversion - -Copyright (C) 2025 GCK. -This is free software; you are free to change and redistribute it. -There is NO WARRANTY, to the extent permitted by law." - -usage="\ -Usage: $me [OPTION]... -Format C source code - -Options: - -q, -quiet silence output - - --help print this help and exit - --version output version information" - -QUIET= - -while test $# -gt 0; do - case $1 in - --help) echo "$usage"; exit 0;; - --version) echo "$version"; exit 0;; - --quiet|-q) QUIET=true;; - -*) - echo "$0: Unknown option '$1'." >&2 - echo "$0: Try '--help' for more information.'$1'." >&2 - exit 1;; - esac - shift -done - -if [ -z "$QUIET" ]; then -find . -type f -name '*.c' ! -path './lib/*' ! -path './gcklib/*' -exec clang-format -i --verbose {} + -find . -type f -name '*.h' ! -path './lib/*' ! -path './gcklib/*' -exec clang-format -i --verbose {} + -else -find . -type f -name '*.c' ! -path './lib/*' ! -path './gcklib/*' -exec clang-format -i {} + -find . -type f -name '*.h' ! -path './lib/*' ! -path './gcklib/*' -exec clang-format -i {} + -fi diff --git a/tools/update-gcklib b/tools/update-gcklib deleted file mode 100755 index 1a8a031..0000000 --- a/tools/update-gcklib +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: BSD-3-Clause -me=$0 -scriptversion="1.0.0" - -version="$me $scriptversion - -Copyright (C) 2025 GCK. -This is free software; you are free to change and redistribute it. -There is NO WARRANTY, to the extent permitted by law." - -usage="\ -Usage: $me [OPTION]... -Update gcklib - -Options: - - --current get current gcklib commit - - --help print this help and exit - --version output version information" - -while test $# -gt 0; do - case $1 in - --help) echo "$usage"; exit 0;; - --version) echo "$version"; exit 0;; - --current) git submodule status gcklib;; - -*) - echo "$0: Unknown option '$1'." >&2 - echo "$0: Try '--help' for more information.'$1'." >&2 - exit 1;; - esac - shift -done - -git submodule update --remote --rebase -- gcklib diff --git a/yait.1 b/yait.1 deleted file mode 100644 index 0d8aa5a..0000000 --- a/yait.1 +++ /dev/null @@ -1,43 +0,0 @@ -.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.2. -.TH YAIT "1" "November 2025" "yait beta 212" "User Commands" -.SH NAME -yait - An opinionated C project generator -.SH SYNOPSIS -.B yait -[\fI\,OPTION\/\fR]... [\fI\,project-name\/\fR]... -.SH DESCRIPTION -Generates an opinionated C project. -.TP -\fB\-\-help\fR -display this help and exit -.TP -\fB\-\-version\fR -display version information and exit -.TP -\fB\-m\fR DESC -Set the program description (default "Does a thing") -.TP -\fB\-\-author\fR NAME -Set the program author (default git username|system username) -.TP -\fB\-\-license\fR LICENSE -Set the program license (default BSD) -.SH "ADDITIONAL INFORMATION" -.UR https://github.com/gck-org/yait -.SH COPYRIGHT -Copyright \(co 2025 GCK. -.br -This is free software: you are free to change and redistribute it. -There is NO WARRNTY, to the extent permitted by law. -.SH "SEE ALSO" -The full documentation for -.B yait -is maintained as a Texinfo manual. If the -.B info -and -.B yait -programs are properly installed at your site, the command -.IP -.B info yait -.PP -should give you access to the complete manual.