all: update to match GCK standard
This commit is contained in:
108
.clang-format
108
.clang-format
@@ -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
|
|
||||||
...
|
|
||||||
7
.clangd
7
.clangd
@@ -1,7 +0,0 @@
|
|||||||
CompileFlags:
|
|
||||||
Add: [-x, c, -std=c23, -Ilib, -I.]
|
|
||||||
|
|
||||||
Diagnostics:
|
|
||||||
ClangTidy:
|
|
||||||
Add: [clang-diagnostic-*]
|
|
||||||
Remove: []
|
|
||||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +0,0 @@
|
|||||||
[submodule "gcklib"]
|
|
||||||
path = gcklib
|
|
||||||
url = https://github.com/gck-org/gcklib
|
|
||||||
51
Makefile
51
Makefile
@@ -1,3 +1,37 @@
|
|||||||
|
#
|
||||||
|
# Makefile for yait (requires GNU make)
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
PACKAGE := yait
|
PACKAGE := yait
|
||||||
|
|
||||||
SRCS := $(wildcard src/*.c) $(wildcard lib/*.c)
|
SRCS := $(wildcard src/*.c) $(wildcard lib/*.c)
|
||||||
@@ -6,11 +40,11 @@ OBJS := $(patsubst src/%.c,build/obj/%.o,$(SRCS))
|
|||||||
BIN := bin/$(PACKAGE)
|
BIN := bin/$(PACKAGE)
|
||||||
|
|
||||||
COMMIT := $(shell git rev-list --count --all)
|
COMMIT := $(shell git rev-list --count --all)
|
||||||
FLAGS := -I. -DCOMMIT=$(COMMIT) -DSHOW_TRACE --std=c23
|
FLAGS := -I. -DCOMMIT=$(COMMIT) --std=c2x -pedantic
|
||||||
|
|
||||||
VERSION := $(shell git describe --tags --always --dirty)
|
VERSION := $(shell git describe --tags --always --dirty)
|
||||||
TARBALL := $(PACKAGE)-$(VERSION).tar.gz
|
TARBALL := $(PACKAGE)-$(VERSION).tar.gz
|
||||||
RELEASE_FILES := doc src lib COPYING AUTHORS README yait.1 INSTALL Makefile configure config.h
|
RELEASE_FILES := doc src lib COPYING AUTHORS README hello.1 INSTALL Makefile configure config.h
|
||||||
|
|
||||||
-include config.mak
|
-include config.mak
|
||||||
|
|
||||||
@@ -20,7 +54,7 @@ all:
|
|||||||
@exit 1
|
@exit 1
|
||||||
else
|
else
|
||||||
|
|
||||||
all: build $(BIN)
|
all: build $(BIN) doc
|
||||||
|
|
||||||
build:
|
build:
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
@@ -37,18 +71,23 @@ endif
|
|||||||
install: $(BIN)
|
install: $(BIN)
|
||||||
cp $(BIN) $(PREFIX)
|
cp $(BIN) $(PREFIX)
|
||||||
|
|
||||||
|
doc:
|
||||||
|
$(MAKE) -C doc all
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
$(RM) $(PREFIX)$(PACKAGE)
|
$(RM) $(PREFIX)$(PACKAGE)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) $(BIN)
|
$(RM) -r bin
|
||||||
$(RM) -r build
|
$(RM) -r build
|
||||||
|
$(MAKE) -C doc clean
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
$(RM) config.mak
|
$(RM) config.mak config.status
|
||||||
$(RM) $(TARBALL)
|
$(RM) $(TARBALL)
|
||||||
|
$(MAKE) -C doc clean
|
||||||
|
|
||||||
release: clean all
|
release: clean all
|
||||||
tar -czf $(TARBALL) $(RELEASE_FILES)
|
tar -czf $(TARBALL) $(RELEASE_FILES)
|
||||||
|
|
||||||
.PHONY: all clean distclean install uninstall build release
|
.PHONY: all clean distclean install uninstall build release doc
|
||||||
|
|||||||
2
README
2
README
@@ -1,5 +1,5 @@
|
|||||||
This is the README file for the GCK yait distribution.
|
This is the README file for the GCK yait distribution.
|
||||||
yait generates a optioned C project.
|
yait is an optionated C project generator
|
||||||
|
|
||||||
Copyright (C) 2025 GCK.
|
Copyright (C) 2025 GCK.
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,14 @@ This README.dev file describes the development environment.
|
|||||||
are permitted in any medium without royalty provided the copyright
|
are permitted in any medium without royalty provided the copyright
|
||||||
notice and this notice are preserved.
|
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 package. The only place
|
||||||
|
where this commonly differs is in non-binary or library packages.
|
||||||
|
|
||||||
|
|
||||||
Build system
|
Build system
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
|||||||
2
THANKS
2
THANKS
@@ -8,8 +8,6 @@ Additional contributors to GCK yait.
|
|||||||
|
|
||||||
Thanks to:
|
Thanks to:
|
||||||
|
|
||||||
GNU & UNIX for command design ideas.
|
|
||||||
|
|
||||||
GNU hello for layout ideas.
|
GNU hello for layout ideas.
|
||||||
|
|
||||||
The Linux Kernel for the code formatting guidelines.
|
The Linux Kernel for the code formatting guidelines.
|
||||||
|
|||||||
8
TODO
8
TODO
@@ -1,10 +1,8 @@
|
|||||||
GCK yait - TODO
|
GCK yait --- TODO
|
||||||
|
|
||||||
Todo:
|
Todo:
|
||||||
|
|
||||||
* Fix package.c generation
|
* update copyright every January 1st
|
||||||
* Add git integration: git init, add the gcklib submodule, ./gcklib-tool --import proginfo
|
* pre-commit scripts
|
||||||
* -p: specify path
|
|
||||||
* sanitize input (gcklib feature)
|
|
||||||
|
|
||||||
end of file TODO
|
end of file TODO
|
||||||
|
|||||||
84
bootstrap
Executable file
84
bootstrap
Executable file
@@ -0,0 +1,84 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# gck.bootstrap - Prepares the build enviroment
|
||||||
|
# FEATURES:
|
||||||
|
# - Initializes submodules
|
||||||
|
#
|
||||||
|
# COMPILATION (Linux - POSIX):
|
||||||
|
# ./bootstrap
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
me=$0
|
||||||
|
scriptversion="1.0.0"
|
||||||
|
|
||||||
|
version="make $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
|
||||||
|
|
||||||
|
# End: bootstrap
|
||||||
101
build-aux/compile
Executable file
101
build-aux/compile
Executable file
@@ -0,0 +1,101 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# gck.compile - Compile wrapper for GCK distributions
|
||||||
|
#
|
||||||
|
# COMPILATION (Linux - POSIX):
|
||||||
|
# ./compile
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
me=$0
|
||||||
|
scriptversion="1.0.0"
|
||||||
|
|
||||||
|
version="make $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"
|
||||||
|
|
||||||
|
# End: compile
|
||||||
75
build-aux/generate-artifacts
Executable file
75
build-aux/generate-artifacts
Executable file
@@ -0,0 +1,75 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# gck.generate-artifacts - Generate compile_commands.json
|
||||||
|
#
|
||||||
|
# FEATURES:
|
||||||
|
# - Generate compile_commands.json
|
||||||
|
#
|
||||||
|
# COMPILATION (Linux - POSIX):
|
||||||
|
# ./generate-artifacts
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
me=$0
|
||||||
|
scriptversion="1.0.0"
|
||||||
|
|
||||||
|
version="make $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
|
||||||
|
|
||||||
|
mkdir -p build
|
||||||
|
bear --output build/compile_commands.json -- make -B -j"$(nproc)"
|
||||||
|
|
||||||
|
# End: generate-artifacts
|
||||||
2
config.h
2
config.h
@@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
/* Program information */
|
/* Program information */
|
||||||
#define PROGRAM "yait"
|
#define PROGRAM "yait"
|
||||||
#define LICENSE_LINE \
|
|
||||||
"License BSD-3-Clause: BSD-3-Clause <https://opensource.org/license/bsd-3-clause>"
|
|
||||||
#define AUTHORS "GCK"
|
#define AUTHORS "GCK"
|
||||||
#define VERSION "beta"
|
#define VERSION "beta"
|
||||||
#define YEAR 2025
|
#define YEAR 2025
|
||||||
|
|||||||
244
configure
vendored
244
configure
vendored
@@ -1,90 +1,200 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# gck.configure - Prepares the build system for GCK distributions
|
||||||
|
# FEATURES:
|
||||||
|
# - Generate config.mak
|
||||||
|
# - Sets C Flags
|
||||||
|
#
|
||||||
|
# COMPILATION (Linux - POSIX):
|
||||||
|
# ./configure
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
usage() {
|
me=$0
|
||||||
cat <<EOF
|
scriptversion="1.0.1"
|
||||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
|
||||||
|
|
||||||
To assign environment variables (e.g., CC, CFLAGS...), specify them as
|
version="make $scriptversion
|
||||||
VAR=VALUE.
|
|
||||||
|
|
||||||
CC C compiler command [detected]
|
Copyright (C) 2025 GCK.
|
||||||
CFLAGS C compiler flags [-g, ...]
|
|
||||||
LDFLAGS C linker flags
|
|
||||||
|
|
||||||
--prefix=<path> Set the install path
|
This is free software; you are free to change and redistribute it.
|
||||||
--debug Flags for debug build, overrides CFLAGS
|
There is NO WARRANTY, to the extent permitted by law."
|
||||||
|
|
||||||
EOF
|
usage="\
|
||||||
exit 0
|
Usage: $me [OPTION]...
|
||||||
}
|
Prepares the build system for GCK distributions
|
||||||
|
|
||||||
cmdexists() { type "$1" >/dev/null 2>&1 ; }
|
Options:
|
||||||
trycc() { [ -z "$CC" ] && cmdexists "$1" && CC=$1 ; }
|
--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
|
prefix=/usr/local
|
||||||
CFLAGS="-std=c23"
|
CFLAGS=-pedantic
|
||||||
LDFLAGS=
|
|
||||||
CC=
|
CC=
|
||||||
|
args_old=$@
|
||||||
|
|
||||||
printf "checking for C compiler... "
|
while [ $# -gt 0 ]; do
|
||||||
trycc gcc
|
case $1 in
|
||||||
trycc clang
|
--help) echo "$usage"; exit 0 ;;
|
||||||
trycc cc
|
--version) echo "$version"; exit 0 ;;
|
||||||
trycc icx
|
--release) release=true ;;
|
||||||
printf "%s\n" "$CC"
|
--enable-debug) debug=true ;;
|
||||||
|
--prefix) shift; prefix=${1:?missing prefix argument} ;;
|
||||||
DEBUG=false
|
--strict) CFLAGS+="-Werror" ;;
|
||||||
for arg; do
|
CC=*) CC=${1#*=} ;;
|
||||||
case "$arg" in
|
CFLAGS=*) CFLAGS=${1#*=} ;;
|
||||||
--help|-h) usage ;;
|
-*)
|
||||||
--prefix=*) prefix=${arg#*=} ;;
|
echo "$0: Unknown option '$1'." >&2
|
||||||
--debug) DEBUG=true ;;
|
echo "$0: Try '--help' for more information." >&2
|
||||||
CFLAGS=*) CFLAGS=${arg#*=} ;;
|
exit 1 ;;
|
||||||
LDFLAGS=*) LDFLAGS=${arg#*=} ;;
|
esac
|
||||||
CC=*) CC=${arg#*=} ;;
|
shift
|
||||||
*) printf "Unrecognized option %s\n" "$arg" ;;
|
|
||||||
esac
|
|
||||||
done
|
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... "
|
printf "checking whether C compiler works... "
|
||||||
tmpc="$(mktemp -d)/test.c"
|
tmpcdir="$(mktemp -d)"
|
||||||
|
tmpc="$tmpcdir/test.c"
|
||||||
echo "typedef int x;" > "$tmpc"
|
echo "typedef int x;" > "$tmpc"
|
||||||
if output=$($CC $CFLAGS -c -o /dev/null "$tmpc" 2>&1); then
|
if output=$($CC $CFLAGS -c -o /dev/null "$tmpc" 2>&1); then
|
||||||
printf "yes\n"
|
printf "yes\n"
|
||||||
else
|
else
|
||||||
printf "no; %s\n" "$output"
|
printf "no; %s\n" "$output"
|
||||||
exit 1
|
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
|
fi
|
||||||
|
|
||||||
GDEBUGCFLAGS="-std=c23 -O0 -g3 -Wall -Wextra -Wpedantic -Werror -Wshadow -Wdouble-promotion -Wformat=2 -Wnull-dereference -Wconversion -Wsign-conversion -Wcast-qual -Wcast-align=strict -Wpointer-arith -Wstrict-overflow=5 -Wstrict-aliasing=2 -Wundef -Wunreachable-code -Wswitch-enum -fanalyzer -fsanitize=undefined,address -fstack-protector-strong -D_FORTIFY_SOURCE=3"
|
echo "creating config.status"
|
||||||
CDEBUGCFLAGS="-std=gnu2x -O0 -g3 -Wall -Wextra -Wpedantic -Werror -Wshadow -Wdouble-promotion -Wformat=2 -Wnull-dereference -Wconversion -Wsign-conversion -Wcast-qual -Wcast-align=strict -Wpointer-arith -Wstrict-overflow=5 -Wstrict-aliasing=2 -Wundef -Wunreachable-code -Wswitch-enum -fanalyzer -fsanitize=undefined,address -fstack-protector-strong -D_FORTIFY_SOURCE=3"
|
cat <<EOF > 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.
|
||||||
|
#
|
||||||
|
|
||||||
if [ -z "$DEBUG" ]; then
|
printf "config.status: recreating config.mak... "
|
||||||
case "$CC" in
|
|
||||||
gcc) CFLAGS="$GDEBUGFLAGS";;
|
|
||||||
clang) CFLAGS="$CDEBUGFLAGS";;
|
|
||||||
*) ;;
|
|
||||||
esac
|
|
||||||
else
|
|
||||||
case "$CC" in
|
|
||||||
gcc) ;;
|
|
||||||
clang) ;;
|
|
||||||
*) ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$OSTYPE" in
|
|
||||||
cygwin|msys)
|
|
||||||
echo "enabling windows specific flags"
|
|
||||||
CFLAGS="-v $CFLAGS"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
printf "creating config.mak... "
|
|
||||||
{
|
{
|
||||||
printf "PREFIX=%s\n" "$prefix"
|
printf "PREFIX=%s\\n" "$prefix"
|
||||||
printf "CFLAGS=%s\n" "$CFLAGS"
|
printf "CFLAGS=%s\\n" "$CFLAGS"
|
||||||
printf "LDFLAGS=%s\n" "$LDFLAGS"
|
printf "CC=%s\\n" "$CC"
|
||||||
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
|
} > config.mak
|
||||||
printf "done\n"
|
printf "done\n"
|
||||||
|
|
||||||
|
# End: configure
|
||||||
|
|||||||
22
doc/Makefile
Normal file
22
doc/Makefile
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
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
|
||||||
@@ -1,4 +1,2 @@
|
|||||||
@set UPDATED 12 September 2025
|
@set UPDATED 2025-01-01
|
||||||
@set UPDATED-MONTH September 2025
|
@set VERSION 1.0
|
||||||
@set EDITION beta
|
|
||||||
@set VERSION beta
|
|
||||||
248
doc/yait.texi
248
doc/yait.texi
@@ -1,8 +1,8 @@
|
|||||||
\input texinfo @c -*-texinfo-*-
|
\input texinfo @c -*-texinfo-*-
|
||||||
@c %**start of header
|
@c %**start of header
|
||||||
@setfilename yait.info
|
@setfilename hello.info
|
||||||
@include version.texi
|
@include version.texi
|
||||||
@settitle GCK yait @value{VERSION}
|
@settitle GCK Hello @value{VERSION}
|
||||||
|
|
||||||
@c Define a new index for options.
|
@c Define a new index for options.
|
||||||
@defcodeindex op
|
@defcodeindex op
|
||||||
@@ -12,8 +12,8 @@
|
|||||||
@c %**end of header
|
@c %**end of header
|
||||||
|
|
||||||
@copying
|
@copying
|
||||||
This manual is for GCK yait (version @value{VERSION}, @value{UPDATED}),
|
This manual is for GCK Hello (version @value{VERSION}, @value{UPDATED}),
|
||||||
which generates an optionated C project.
|
which greets you nicely.
|
||||||
|
|
||||||
Copyright @copyright{} 2025 GCK.
|
Copyright @copyright{} 2025 GCK.
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ notice and this notice are preserved.
|
|||||||
@end copying
|
@end copying
|
||||||
|
|
||||||
@titlepage
|
@titlepage
|
||||||
@title GCK yait
|
@title GCK Hello
|
||||||
@subtitle for version @value{VERSION}, @value{UPDATED}
|
@subtitle for version @value{VERSION}, @value{UPDATED}
|
||||||
@page
|
@page
|
||||||
@vskip 0pt plus 1filll
|
@vskip 0pt plus 1filll
|
||||||
@@ -37,16 +37,16 @@ notice and this notice are preserved.
|
|||||||
|
|
||||||
@ifnottex
|
@ifnottex
|
||||||
@node Top
|
@node Top
|
||||||
@top GNU Hello
|
@top GCK Hello
|
||||||
|
|
||||||
This manual is for GCK yait (version @value{VERSION}, @value{UPDATED}),
|
This manual is for GCK Hello (version @value{VERSION}, @value{UPDATED}),
|
||||||
which generates an optionated C project.
|
which greets you nicely.
|
||||||
@end ifnottex
|
@end ifnottex
|
||||||
|
|
||||||
@menu
|
@menu
|
||||||
* Overview:: General purpose and information.
|
* Overview:: General purpose and information.
|
||||||
* Sample output:: Sample output from @command{yait}.
|
* Sample output:: Sample output from @command{hello}.
|
||||||
* Invoking hello:: How to run @command{yait}.
|
* Invoking hello:: How to run @command{hello}.
|
||||||
* Reporting bugs:: Sending bug reports and feature suggestions.
|
* Reporting bugs:: Sending bug reports and feature suggestions.
|
||||||
* Concept index:: Index of concepts.
|
* Concept index:: Index of concepts.
|
||||||
@end menu
|
@end menu
|
||||||
@@ -58,113 +58,35 @@ which generates an optionated C project.
|
|||||||
@cindex greetings
|
@cindex greetings
|
||||||
@cindex overview
|
@cindex overview
|
||||||
|
|
||||||
The GNU @command{hello} program
|
The GCK @command{hello} program produces a simple, friendly greeting.
|
||||||
(@url{http://www.gnu.org/software/hello/}) produces a familiar,
|
It serves as a minimal example of a C program with proper GNU-style
|
||||||
friendly greeting. It allows nonprogrammers to use a classic computer
|
structure and build system.
|
||||||
science tool which would otherwise be unavailable to them. Because it
|
|
||||||
is protected by the GNU General Public License, users are free (in
|
|
||||||
perpetuity) to share and change it.
|
|
||||||
|
|
||||||
@cindex joke, not
|
@cindex example program
|
||||||
Not to spoil the joke, but of course the practical purpose of GNU
|
@cindex template
|
||||||
Hello is to serve as a minimal example of a GNU package. So, although
|
This program is designed as a template and example for other projects.
|
||||||
most manuals don't need to discuss the implementation of the programs
|
It demonstrates basic C programming practices, proper project structure,
|
||||||
they document, that is part of the goal here.
|
and standard GNU conventions.
|
||||||
|
|
||||||
@cindex GNU coding standards
|
@cindex features
|
||||||
@cindex GNU maintainer standards
|
GCK Hello has the following features:
|
||||||
@cindex standards, GNU coding
|
|
||||||
@cindex standards, GNU maintainer
|
|
||||||
First, GNU Hello follows the GNU coding standards
|
|
||||||
(@pxref{Top,,Preface,standards,GNU Coding Standards}) and GNU
|
|
||||||
maintainer standards (@pxref{Top,,Preface,maintain, Information for
|
|
||||||
GNU Maintainers}). These are the basic documents which all GNU
|
|
||||||
packages should adhere to.
|
|
||||||
|
|
||||||
The Hello package also implements recommended development practices
|
|
||||||
not embodied in the standards, using other GNU packages and features:
|
|
||||||
|
|
||||||
@itemize @bullet
|
@itemize @bullet
|
||||||
@item
|
@item Simple and friendly greeting
|
||||||
@cindex Automake
|
@item Support for command-line arguments
|
||||||
@cindex Autoconf
|
@item Standard GNU-style help and version options
|
||||||
It uses Automake (@pxref{Top,,Introduction,automake,GNU Automake}) and
|
@item Clean, readable C source code
|
||||||
hence also Autoconf (@pxref{Top,,Introduction,autoconf,GNU Autoconf})
|
@item Proper project structure with build system
|
||||||
for configuration.
|
|
||||||
|
|
||||||
@item
|
|
||||||
@cindex Gnulib
|
|
||||||
@cindex @command{srclist-update} script
|
|
||||||
@cindex @file{README-dev} source file
|
|
||||||
It uses Gnulib (@pxref{Top,,Introduction,gnulib,GNU Gnulib}) to enhance
|
|
||||||
portability and avoid duplication of common sources. Both
|
|
||||||
@code{gnulib-tool} and @code{srclist-update} are used, for purposes of
|
|
||||||
example. See the @file{README-dev} file in the distribution.
|
|
||||||
|
|
||||||
@item
|
|
||||||
@cindex Gettext
|
|
||||||
GNU Gettext (@pxref{Top,,Introduction,gettext,GNU Gettext}) is used
|
|
||||||
for internationalization support. Hello's greeting has been translated
|
|
||||||
into many languages.
|
|
||||||
|
|
||||||
@item
|
|
||||||
@opindex --help
|
|
||||||
Internally, Hello uses the GNU @code{getopt_long} function
|
|
||||||
(@pxref{Getopt Long Options,,,libc,GNU C Library}) to parse options,
|
|
||||||
thus supporting GNU-style long options such as @option{--help}.
|
|
||||||
|
|
||||||
@item
|
|
||||||
@cindex Help2man
|
|
||||||
The Hello Man page is generated with GNU @code{help2man}
|
|
||||||
(@pxref{Top,,Overview,help2man,GNU @code{help2man}}) from the
|
|
||||||
@option{--help} output. This relieves the maintainers from the burden
|
|
||||||
of updating separate man documentation, yet provides a reasonable
|
|
||||||
overview for man devotees.
|
|
||||||
|
|
||||||
@item
|
|
||||||
@cindex Texinfo
|
|
||||||
Finally, Texinfo (@pxref{Top,,Introduction,texinfo,Texinfo}) is the
|
|
||||||
documentation format for this manual. It supports output in Info,
|
|
||||||
HTML, PDF, DVI, plain text, XML, and other formats.
|
|
||||||
|
|
||||||
@end itemize
|
@end itemize
|
||||||
|
|
||||||
GNU Hello is implemented in C@. The GNU Gettext distribution contains
|
@cindex implementation
|
||||||
``hello world'' examples in many other programming languages; see the
|
GCK Hello is implemented in C and follows standard POSIX conventions.
|
||||||
Gettext home page at @url{http://www.gnu.org/software/gettext/}.
|
The program accepts command-line arguments and greets each one individually,
|
||||||
|
or prints a default greeting if no arguments are provided.
|
||||||
|
|
||||||
@cindex @file{Makefile.am} targets
|
@cindex license
|
||||||
The top-level @file{Makefile.am} in Hello also contains a few special
|
This program is distributed under the BSD 3-Clause License, allowing
|
||||||
targets for other projects to adapt as desired:
|
free use, modification, and distribution with minimal restrictions.
|
||||||
|
|
||||||
@table @code
|
|
||||||
@item diff
|
|
||||||
Make a diff from the previous release, assuming the current tarball is
|
|
||||||
in the current tarball.
|
|
||||||
|
|
||||||
@item po-check
|
|
||||||
Verify that all source files using @code{_()} are included for
|
|
||||||
translation in @file{po/POTFILES.in}, so translators will have all the
|
|
||||||
messages.
|
|
||||||
|
|
||||||
@item wwwdoc
|
|
||||||
Sample procedure for updating the manual on the GNU web site, in this
|
|
||||||
case @url{http://www.gnu.org/software/hello/manual/}.
|
|
||||||
@end table
|
|
||||||
|
|
||||||
@cindex authors
|
|
||||||
@cindex Haertel, Mike
|
|
||||||
@cindex MacKenzie, David
|
|
||||||
@cindex Brittenson, Jan
|
|
||||||
@cindex Hannum, Charles
|
|
||||||
@cindex McGrath, Roland
|
|
||||||
@cindex Friedman, Noah
|
|
||||||
@cindex Eichwalder, Karl
|
|
||||||
@cindex King, The
|
|
||||||
@cindex Berry, Karl
|
|
||||||
GNU Hello was written by Mike Haertel, David MacKenzie, Jan
|
|
||||||
Brittenson, Charles Hannum, Roland McGrath, Noah Friedman, Karl
|
|
||||||
Eichwalder, Karl Berry, and @w{The King}.
|
|
||||||
|
|
||||||
|
|
||||||
@node Sample output
|
@node Sample output
|
||||||
@@ -173,24 +95,35 @@ Eichwalder, Karl Berry, and @w{The King}.
|
|||||||
@cindex sample output
|
@cindex sample output
|
||||||
@cindex examples
|
@cindex examples
|
||||||
|
|
||||||
Here are some examples of running GNU Hello.
|
Here are some examples of running GCK Hello.
|
||||||
|
|
||||||
This is the output of the command @samp{hello}:
|
This is the output of the command @samp{hello}:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
Hello, world!
|
Hello, World!
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
This is the output of the command @samp{hello --traditional}:
|
This is the output of the command @samp{hello Alice}:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
hello, world
|
Hello, Alice!
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
This is the output of the command @samp{hello --greeting=hi}:
|
This is the output of the command @samp{hello Alice Bob}:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
hi
|
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
|
@end example
|
||||||
|
|
||||||
|
|
||||||
@@ -205,57 +138,28 @@ hi
|
|||||||
The format for running the @command{hello} program is:
|
The format for running the @command{hello} program is:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
hello @var{option} @dots{}
|
hello [@var{option}]... [@var{name}]...
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
With no options, @command{hello} prints the greeting @samp{Hello,
|
With no arguments, @command{hello} prints the greeting @samp{Hello, World!}.
|
||||||
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:
|
@command{hello} supports the following options:
|
||||||
|
|
||||||
@table @option
|
@table @option
|
||||||
@item --greeting=@var{text}
|
|
||||||
@itemx -g @var{text}
|
|
||||||
@opindex --greeting
|
|
||||||
@opindex -g
|
|
||||||
Output @var{text} instead of the default greeting.
|
|
||||||
|
|
||||||
@item --help
|
@item --help
|
||||||
@itemx -h
|
|
||||||
@opindex --help
|
@opindex --help
|
||||||
@opindex -h
|
|
||||||
Print an informative help message on standard output and exit
|
Print an informative help message on standard output and exit
|
||||||
successfully.
|
successfully.
|
||||||
|
|
||||||
@cindex environment variables, help for
|
|
||||||
@c This comment prevents `make syntax-check' from diagnosing a doubled word "for\nFor"
|
|
||||||
For the @option{--help} output of GNU programs, it's strongly
|
|
||||||
encouraged to include a brief (one or two sentences) description of
|
|
||||||
what the program does, as well as the synopsis of how to run the
|
|
||||||
program. Any environment variables which affect execution should also
|
|
||||||
be mentioned (Hello doesn't have any).
|
|
||||||
|
|
||||||
@item --traditional
|
|
||||||
@itemx -t
|
|
||||||
@opindex --traditional
|
|
||||||
@opindex -t
|
|
||||||
@cindex traditional
|
|
||||||
@cindex modern
|
|
||||||
Output the traditional greeting message @samp{hello, world}.
|
|
||||||
|
|
||||||
@item --version
|
@item --version
|
||||||
@itemx -v
|
|
||||||
@opindex --version
|
@opindex --version
|
||||||
@opindex -v
|
|
||||||
Print the version number and licensing information of Hello on
|
Print the version number and licensing information of Hello on
|
||||||
standard output and then exit successfully.
|
standard output and then exit successfully.
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
If more than one of the greeting options (@option{-g},
|
|
||||||
@option{-t}, and their long-named equivalents) is specified, whichever
|
|
||||||
comes last takes precedence.
|
|
||||||
|
|
||||||
|
|
||||||
@node Reporting bugs
|
@node Reporting bugs
|
||||||
@chapter Reporting bugs
|
@chapter Reporting bugs
|
||||||
@@ -264,8 +168,8 @@ comes last takes precedence.
|
|||||||
@cindex problems
|
@cindex problems
|
||||||
@cindex reporting bugs
|
@cindex reporting bugs
|
||||||
|
|
||||||
To report bugs, suggest enhancements or otherwise discuss GNU Hello,
|
To report bugs, suggest enhancements or otherwise discuss GCK Hello,
|
||||||
please send electronic mail to @email{bug-hello@@gnu.org}.
|
please send electronic mail to the project maintainers.
|
||||||
|
|
||||||
@cindex checklist for bug reports
|
@cindex checklist for bug reports
|
||||||
For bug reports, please include enough information for the maintainers
|
For bug reports, please include enough information for the maintainers
|
||||||
@@ -289,15 +193,43 @@ better to include too much than to leave out something important.
|
|||||||
|
|
||||||
@cindex patches, contributing
|
@cindex patches, contributing
|
||||||
Patches are welcome; if possible, please make them with @samp{@w{diff
|
Patches are welcome; if possible, please make them with @samp{@w{diff
|
||||||
-c}} (@pxref{Top,, Overview, diff, Comparing and Merging Files}) and
|
-c}} and include @file{ChangeLog} entries. Please follow the existing
|
||||||
include @file{ChangeLog} entries (@pxref{Change Log,,, emacs, The GNU
|
coding style.
|
||||||
Emacs Manual}). Please follow the existing coding style.
|
|
||||||
|
|
||||||
|
|
||||||
@node GNU Free Documentation License
|
@node BSD License
|
||||||
@appendix GNU Free Documentation License
|
@appendix BSD License
|
||||||
|
|
||||||
@include fdl.texi
|
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
|
@node Concept index
|
||||||
|
|||||||
263
lib/err.c
263
lib/err.c
@@ -12,28 +12,29 @@
|
|||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* 3. Neither the name of the copyright holder nor the names of its
|
* 3. Neither the name of the copyright holder nor the names of its
|
||||||
* contributors may be used to endorse or promote products derived from
|
* contributors may be used to endorse or promote products derived from
|
||||||
* this software without specific prior written permission.
|
* this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -50,165 +51,143 @@
|
|||||||
#define NOTE "\x1B[1;94m"
|
#define NOTE "\x1B[1;94m"
|
||||||
#define HINT "\x1B[38;5;166m"
|
#define HINT "\x1B[38;5;166m"
|
||||||
|
|
||||||
static bool err_support_color(void)
|
static bool err_support_color(void) {
|
||||||
{
|
|
||||||
#ifdef NOCOLOR
|
#ifdef NOCOLOR
|
||||||
return false;
|
return false;
|
||||||
#else
|
#else
|
||||||
static int cached = -1;
|
static int cached = -1;
|
||||||
if (cached != -1)
|
if (cached != -1)
|
||||||
return cached;
|
return cached;
|
||||||
const char *term, *colorterm, *force, *nocolor;
|
const char *term, *colorterm, *force, *nocolor;
|
||||||
term = getenv("TERM");
|
term = getenv("TERM");
|
||||||
colorterm = getenv("COLORTERM");
|
colorterm = getenv("COLORTERM");
|
||||||
force = getenv("FORCE_COLOR");
|
force = getenv("FORCE_COLOR");
|
||||||
nocolor = getenv("NO_COLOR");
|
nocolor = getenv("NO_COLOR");
|
||||||
if (nocolor && *nocolor && (!force || !*force)) {
|
if (nocolor && *nocolor && (!force || !*force)) {
|
||||||
cached = 0;
|
cached = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (force && *force && strcmp(force, "0") != 0) {
|
if (force && *force && strcmp(force, "0") != 0) {
|
||||||
cached = 1;
|
cached = 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// if (!isatty(fileno(stdout))) {
|
// if (!isatty(fileno(stdout))) {
|
||||||
// cached = 0;
|
// cached = 0;
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
if (colorterm && *colorterm) {
|
if (colorterm && *colorterm) {
|
||||||
cached = 1;
|
cached = 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!term || !*term) {
|
if (!term || !*term) {
|
||||||
cached = 0;
|
cached = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (strstr(term, "color") || strstr(term, "xterm") ||
|
if (strstr(term, "color") || strstr(term, "xterm") ||
|
||||||
strstr(term, "screen") || strstr(term, "vt100") ||
|
strstr(term, "screen") || strstr(term, "vt100") || strstr(term, "rxvt") ||
|
||||||
strstr(term, "rxvt") || strstr(term, "ansi") ||
|
strstr(term, "ansi") || strstr(term, "linux") ||
|
||||||
strstr(term, "linux") || strstr(term, "konsole") ||
|
strstr(term, "konsole") || strstr(term, "vte") || strstr(term, "kitty") ||
|
||||||
strstr(term, "vte") || strstr(term, "kitty") ||
|
strstr(term, "wezterm") || strstr(term, "gnome")) {
|
||||||
strstr(term, "wezterm") || strstr(term, "gnome")) {
|
cached = 1;
|
||||||
cached = 1;
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
cached = 0;
|
||||||
cached = 0;
|
return false;
|
||||||
return false;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void errorf(const char *format, ...)
|
void errorf(const char *format, ...) {
|
||||||
{
|
va_list args;
|
||||||
va_list args;
|
va_start(args, format);
|
||||||
va_start(args, format);
|
|
||||||
|
|
||||||
if (err_support_color()) {
|
if (err_support_color()) {
|
||||||
fprintf(stderr, "%serror%s: ", ERROR, RESET);
|
fprintf(stderr, "%serror%s: ", ERROR, RESET);
|
||||||
} else {
|
} else {
|
||||||
fputs("error: ", stderr);
|
fputs("error: ", stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
vfprintf(stderr, format, args);
|
vfprintf(stderr, format, args);
|
||||||
fputc('\n', stderr);
|
fputc('\n', stderr);
|
||||||
|
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
void fatalf(const char *format, ...)
|
void fatalf(const char *format, ...) {
|
||||||
{
|
va_list args;
|
||||||
va_list args;
|
va_start(args, format);
|
||||||
va_start(args, format);
|
|
||||||
|
|
||||||
if (err_support_color()) {
|
if (err_support_color()) {
|
||||||
fprintf(stderr, "%sfatal error%s: ", ERROR, RESET);
|
fprintf(stderr, "%sfatal error%s: ", ERROR, RESET);
|
||||||
} else {
|
} else {
|
||||||
fputs("fatal error: ", stderr);
|
fputs("fatal error: ", stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
vfprintf(stderr, format, args);
|
vfprintf(stderr, format, args);
|
||||||
fputc('\n', stderr);
|
fputc('\n', stderr);
|
||||||
|
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
fputs("program terminated.\n", stderr);
|
fputs("program terminated.\n", stderr);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
void warnf(const char *format, ...)
|
void warnf(const char *format, ...) {
|
||||||
{
|
va_list args;
|
||||||
va_list args;
|
va_start(args, format);
|
||||||
va_start(args, format);
|
|
||||||
|
|
||||||
if (err_support_color()) {
|
if (err_support_color()) {
|
||||||
fprintf(stderr, "%swarning%s: ", WARN, RESET);
|
fprintf(stderr, "%swarning%s: ", WARN, RESET);
|
||||||
} else {
|
} else {
|
||||||
fputs("warning: ", stderr);
|
fputs("warning: ", stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
vfprintf(stderr, format, args);
|
vfprintf(stderr, format, args);
|
||||||
fputc('\n', stderr);
|
fputc('\n', stderr);
|
||||||
|
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
void notef(const char *format, ...)
|
void notef(const char *format, ...) {
|
||||||
{
|
va_list args;
|
||||||
va_list args;
|
va_start(args, format);
|
||||||
va_start(args, format);
|
|
||||||
|
|
||||||
if (err_support_color()) {
|
if (err_support_color()) {
|
||||||
fprintf(stderr, "%snote%s: ", NOTE, RESET);
|
fprintf(stderr, "%snote%s: ", NOTE, RESET);
|
||||||
} else {
|
} else {
|
||||||
fputs("note: ", stderr);
|
fputs("note: ", stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
vfprintf(stderr, format, args);
|
vfprintf(stderr, format, args);
|
||||||
fputc('\n', stderr);
|
fputc('\n', stderr);
|
||||||
|
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
void hintf(const char *format, ...)
|
void hintf(const char *format, ...) {
|
||||||
{
|
va_list args;
|
||||||
va_list args;
|
va_start(args, format);
|
||||||
va_start(args, format);
|
|
||||||
|
|
||||||
if (err_support_color()) {
|
if (err_support_color()) {
|
||||||
fprintf(stderr, "%shint: ", HINT);
|
fprintf(stderr, "%shint: ", HINT);
|
||||||
} else {
|
} else {
|
||||||
fputs("hint: ", stderr);
|
fputs("hint: ", stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
vfprintf(stderr, format, args);
|
vfprintf(stderr, format, args);
|
||||||
|
|
||||||
if (err_support_color()) {
|
if (err_support_color()) {
|
||||||
fprintf(stderr, "%s\n", RESET);
|
fprintf(stderr, "%s\n", RESET);
|
||||||
} else {
|
} else {
|
||||||
fputc('\n', stderr);
|
fputc('\n', stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void errorfa(int code)
|
void errorfa(int code) { errorf(strerror(code)); }
|
||||||
{
|
|
||||||
errorf(strerror(code));
|
|
||||||
}
|
|
||||||
|
|
||||||
void fatalfa(int code)
|
void fatalfa(int code) { fatalf(strerror(code)); }
|
||||||
{
|
|
||||||
fatalf(strerror(code));
|
|
||||||
}
|
|
||||||
|
|
||||||
void notefa(int code)
|
void notefa(int code) { notef(strerror(code)); }
|
||||||
{
|
|
||||||
notef(strerror(code));
|
|
||||||
}
|
|
||||||
|
|
||||||
void warnfa(int code)
|
void warnfa(int code) { warnf(strerror(code)); }
|
||||||
{
|
|
||||||
warnf(strerror(code));
|
|
||||||
}
|
|
||||||
|
|
||||||
void hintfa(int code)
|
void hintfa(int code) { hintf(strerror(code)); }
|
||||||
{
|
|
||||||
hintf(strerror(code));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* end of file err.c */
|
/* end of file err.c */
|
||||||
|
|||||||
49
lib/err.h
49
lib/err.h
@@ -14,28 +14,29 @@
|
|||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* 3. Neither the name of the copyright holder nor the names of its
|
* 3. Neither the name of the copyright holder nor the names of its
|
||||||
* contributors may be used to endorse or promote products derived from
|
* contributors may be used to endorse or promote products derived from
|
||||||
* this software without specific prior written permission.
|
* this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef ERR_H
|
#ifndef ERR_H
|
||||||
@@ -54,16 +55,16 @@ void warnfa(int code);
|
|||||||
void hintfa(int code);
|
void hintfa(int code);
|
||||||
|
|
||||||
#if defined(SHOW_TRACE)
|
#if defined(SHOW_TRACE)
|
||||||
#define errorf(fmt, ...) \
|
#define errorf(fmt, ...) \
|
||||||
do { \
|
do { \
|
||||||
errorf("%s:%s:%d: " fmt, __FILE__, __func__, \
|
errorf("%s:%s:%d: " fmt, __FILE__, __func__, \
|
||||||
__LINE__ __VA_OPT__(, ) __VA_ARGS__); \
|
__LINE__ __VA_OPT__(, ) __VA_ARGS__); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define fatalf(fmt, ...) \
|
#define fatalf(fmt, ...) \
|
||||||
do { \
|
do { \
|
||||||
fatalf("%s:%s:%d: " fmt, __FILE__, __func__, \
|
fatalf("%s:%s:%d: " fmt, __FILE__, __func__, \
|
||||||
__LINE__ __VA_OPT__(, ) __VA_ARGS__); \
|
__LINE__ __VA_OPT__(, ) __VA_ARGS__); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
178
lib/flag.c
178
lib/flag.c
@@ -8,28 +8,29 @@
|
|||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* 3. Neither the name of the copyright holder nor the names of its
|
* 3. Neither the name of the copyright holder nor the names of its
|
||||||
* contributors may be used to endorse or promote products derived from
|
* contributors may be used to endorse or promote products derived from
|
||||||
* this software without specific prior written permission.
|
* this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
@@ -42,83 +43,78 @@
|
|||||||
static char *nextchar;
|
static char *nextchar;
|
||||||
|
|
||||||
int getopt_long(int argc, char *const argv[], const char *optstring,
|
int getopt_long(int argc, char *const argv[], const char *optstring,
|
||||||
const struct option *longopts, int *longindex)
|
const struct option *longopts, int *longindex) {
|
||||||
{
|
if (nextchar == NULL || *nextchar == '\0') {
|
||||||
if (nextchar == NULL || *nextchar == '\0') {
|
if (optind >= argc)
|
||||||
if (optind >= argc)
|
return -1;
|
||||||
return -1;
|
if (argv[optind][0] != '-' || argv[optind][1] == '\0')
|
||||||
if (argv[optind][0] != '-' || argv[optind][1] == '\0')
|
return -1;
|
||||||
return -1;
|
if (argv[optind][1] == '-' && argv[optind][2] == '\0') {
|
||||||
if (argv[optind][1] == '-' && argv[optind][2] == '\0') {
|
optind++;
|
||||||
optind++;
|
return -1;
|
||||||
return -1;
|
}
|
||||||
}
|
if (argv[optind][1] == '-') {
|
||||||
if (argv[optind][1] == '-') {
|
const char *arg = argv[optind] + 2;
|
||||||
const char *arg = argv[optind] + 2;
|
char *eq = strchr(arg, '=');
|
||||||
char *eq = strchr(arg, '=');
|
size_t len = eq ? (size_t)(eq - arg) : strlen(arg);
|
||||||
size_t len = eq ? (size_t)(eq - arg) : strlen(arg);
|
for (int i = 0; longopts[i].name; i++) {
|
||||||
for (int i = 0; longopts[i].name; i++) {
|
if (strncmp(arg, longopts[i].name, len) == 0 &&
|
||||||
if (strncmp(arg, longopts[i].name, len) == 0 &&
|
strlen(longopts[i].name) == len) {
|
||||||
strlen(longopts[i].name) == len) {
|
if (longindex)
|
||||||
if (longindex)
|
*longindex = i;
|
||||||
*longindex = i;
|
if (longopts[i].has_arg == required_argument) {
|
||||||
if (longopts[i].has_arg ==
|
if (eq)
|
||||||
required_argument) {
|
optarg = (char *)eq + 1;
|
||||||
if (eq)
|
else if (optind + 1 < argc)
|
||||||
optarg = (char *)eq + 1;
|
optarg = argv[++optind];
|
||||||
else if (optind + 1 < argc)
|
else
|
||||||
optarg = argv[++optind];
|
return '?';
|
||||||
else
|
} else if (longopts[i].has_arg == optional_argument)
|
||||||
return '?';
|
optarg = eq ? (char *)eq + 1 : NULL;
|
||||||
} else if (longopts[i].has_arg ==
|
else
|
||||||
optional_argument)
|
optarg = NULL;
|
||||||
optarg = eq ? (char *)eq + 1 :
|
optind++;
|
||||||
NULL;
|
if (longopts[i].flag) {
|
||||||
else
|
*longopts[i].flag = longopts[i].val;
|
||||||
optarg = NULL;
|
return 0;
|
||||||
optind++;
|
}
|
||||||
if (longopts[i].flag) {
|
return longopts[i].val;
|
||||||
*longopts[i].flag =
|
}
|
||||||
longopts[i].val;
|
}
|
||||||
return 0;
|
optind++;
|
||||||
}
|
return '?';
|
||||||
return longopts[i].val;
|
}
|
||||||
}
|
nextchar = argv[optind] + 1;
|
||||||
}
|
}
|
||||||
optind++;
|
char c = *nextchar++;
|
||||||
return '?';
|
const char *pos = strchr(optstring, c);
|
||||||
}
|
if (!pos) {
|
||||||
nextchar = argv[optind] + 1;
|
optopt = c;
|
||||||
}
|
if (*nextchar == '\0')
|
||||||
char c = *nextchar++;
|
optind++;
|
||||||
const char *pos = strchr(optstring, c);
|
return '?';
|
||||||
if (!pos) {
|
}
|
||||||
optopt = c;
|
if (pos[1] == ':') {
|
||||||
if (*nextchar == '\0')
|
if (*nextchar != '\0') {
|
||||||
optind++;
|
optarg = nextchar;
|
||||||
return '?';
|
optind++;
|
||||||
}
|
nextchar = NULL;
|
||||||
if (pos[1] == ':') {
|
} else if (optind + 1 < argc) {
|
||||||
if (*nextchar != '\0') {
|
optarg = argv[++optind];
|
||||||
optarg = nextchar;
|
optind++;
|
||||||
optind++;
|
nextchar = NULL;
|
||||||
nextchar = NULL;
|
} else {
|
||||||
} else if (optind + 1 < argc) {
|
optopt = c;
|
||||||
optarg = argv[++optind];
|
return '?';
|
||||||
optind++;
|
}
|
||||||
nextchar = NULL;
|
} else {
|
||||||
} else {
|
optarg = NULL;
|
||||||
optopt = c;
|
if (*nextchar == '\0') {
|
||||||
return '?';
|
optind++;
|
||||||
}
|
nextchar = NULL;
|
||||||
} else {
|
}
|
||||||
optarg = NULL;
|
}
|
||||||
if (*nextchar == '\0') {
|
return c;
|
||||||
optind++;
|
|
||||||
nextchar = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* end of file flag.c */
|
/* end of file flag.c */
|
||||||
|
|||||||
31
lib/flag.h
31
lib/flag.h
@@ -8,35 +8,36 @@
|
|||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* 3. Neither the name of the copyright holder nor the names of its
|
* 3. Neither the name of the copyright holder nor the names of its
|
||||||
* contributors may be used to endorse or promote products derived from
|
* contributors may be used to endorse or promote products derived from
|
||||||
* this software without specific prior written permission.
|
* this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef FLAG_H
|
#ifndef FLAG_H
|
||||||
#define FLAG_H
|
#define FLAG_H
|
||||||
|
|
||||||
int getopt_long(int argc, char *const argv[], const char *optstring,
|
int getopt_long(int argc, char *const argv[], const char *optstring,
|
||||||
const struct option *longopts, int *longindex);
|
const struct option *longopts, int *longindex);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
252
lib/fs.c
252
lib/fs.c
@@ -14,28 +14,29 @@
|
|||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* 3. Neither the name of the copyright holder nor the names of its
|
* 3. Neither the name of the copyright holder nor the names of its
|
||||||
* contributors may be used to endorse or promote products derived from
|
* contributors may be used to endorse or promote products derived from
|
||||||
* this software without specific prior written permission.
|
* this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@@ -52,159 +53,150 @@
|
|||||||
#include "xmem.h"
|
#include "xmem.h"
|
||||||
|
|
||||||
#if defined(FS_ERROR_ON)
|
#if defined(FS_ERROR_ON)
|
||||||
#define RETURN(code) \
|
#define RETURN(code) \
|
||||||
errorfa(code); \
|
errorfa(code); \
|
||||||
return code
|
return code
|
||||||
#elif defined(FS_FATAL_OFF)
|
#elif defined(FS_FATAL_OFF)
|
||||||
#define RETURN(code) return code
|
#define RETURN(code) return code
|
||||||
#else
|
#else
|
||||||
#define RETURN(code) fatalfa(code)
|
#define RETURN(code) fatalfa(code)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char *fs_read(const char *path)
|
char *fs_read(const char *path) {
|
||||||
{
|
FILE *fptr = fopen(path, "r");
|
||||||
FILE *fptr = fopen(path, "r");
|
if (!fptr) {
|
||||||
if (!fptr) {
|
|
||||||
#if defined(FS_ERROR_ON)
|
#if defined(FS_ERROR_ON)
|
||||||
errorfa(errno);
|
errorfa(errno);
|
||||||
#elif defined(FS_FATAL_ON)
|
#elif defined(FS_FATAL_ON)
|
||||||
fatalfa(errno);
|
fatalfa(errno);
|
||||||
#endif
|
#endif
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t cap = 1024;
|
size_t cap = 1024;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
char *buf = xmalloc(cap);
|
char *buf = xmalloc(cap);
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
while ((c = fgetc(fptr)) != EOF) {
|
while ((c = fgetc(fptr)) != EOF) {
|
||||||
if (len + 1 >= cap) {
|
if (len + 1 >= cap) {
|
||||||
cap *= 2;
|
cap *= 2;
|
||||||
char *tmp = realloc(buf, cap);
|
char *tmp = realloc(buf, cap);
|
||||||
if (!tmp) {
|
if (!tmp) {
|
||||||
free(buf);
|
free(buf);
|
||||||
fclose(fptr);
|
fclose(fptr);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
buf = tmp;
|
buf = tmp;
|
||||||
}
|
}
|
||||||
buf[len++] = (char)c;
|
buf[len++] = (char)c;
|
||||||
}
|
}
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
|
|
||||||
fclose(fptr);
|
fclose(fptr);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fs_exists(const char *path)
|
bool fs_exists(const char *path) {
|
||||||
{
|
FILE *fptr;
|
||||||
FILE *fptr;
|
bool exists;
|
||||||
bool exists;
|
|
||||||
|
|
||||||
fptr = fopen(path, "r");
|
fptr = fopen(path, "r");
|
||||||
if (fptr) {
|
if (fptr) {
|
||||||
exists = true;
|
exists = true;
|
||||||
} else {
|
} else {
|
||||||
exists = false;
|
exists = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fptr);
|
fclose(fptr);
|
||||||
return exists;
|
return exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fs_append(const char *path, const char *format, ...)
|
int fs_append(const char *path, const char *format, ...) {
|
||||||
{
|
FILE *fp = fopen(path, "a");
|
||||||
FILE *fp = fopen(path, "a");
|
if (!fp)
|
||||||
if (!fp)
|
RETURN(errno);
|
||||||
RETURN(errno);
|
|
||||||
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
int ret = vfprintf(fp, format, ap);
|
int ret = vfprintf(fp, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
RETURN(errno);
|
RETURN(errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fclose(fp) != 0)
|
if (fclose(fp) != 0)
|
||||||
RETURN(errno);
|
RETURN(errno);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fs_del(const char *path)
|
int fs_del(const char *path) { RETURN(remove(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_new(const char *path)
|
int fs_write(const char *path, const char *format, ...) {
|
||||||
{
|
FILE *fptr = fopen(path, "w");
|
||||||
size_t len;
|
if (!fptr)
|
||||||
int fd;
|
RETURN(-1);
|
||||||
|
|
||||||
if (path == NULL) {
|
va_list ap;
|
||||||
errno = EINVAL;
|
va_start(ap, format);
|
||||||
RETURN(-1);
|
int ret = vfprintf(fptr, format, ap);
|
||||||
}
|
va_end(ap);
|
||||||
|
|
||||||
len = strlen(path);
|
if (ret < 0) {
|
||||||
if (len == 0) {
|
fclose(fptr);
|
||||||
errno = EINVAL;
|
RETURN(-1);
|
||||||
RETURN(-1);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (path[len - 1] == '/') {
|
if (fclose(fptr) != 0)
|
||||||
if (mkdir(path, 0777) == -1)
|
RETURN(-1);
|
||||||
RETURN(-1);
|
|
||||||
} else {
|
|
||||||
fd = open(path, O_CREAT | O_EXCL | O_WRONLY, 0666);
|
|
||||||
if (fd == -1)
|
|
||||||
RETURN(-1);
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fs_write(const char *path, const char *format, ...)
|
FILE *fs_temp() {
|
||||||
{
|
FILE *fptr = tmpfile();
|
||||||
FILE *fptr = fopen(path, "w");
|
|
||||||
if (!fptr)
|
|
||||||
RETURN(-1);
|
|
||||||
|
|
||||||
va_list ap;
|
if (!fptr) {
|
||||||
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)
|
#if defined(FS_ERROR_ON)
|
||||||
errorf("tmp failed");
|
errorf("tmp failed");
|
||||||
#elif defined(FS_FATAL_ON)
|
#elif defined(FS_FATAL_ON)
|
||||||
fatalf("tmp failed");
|
fatalf("tmp failed");
|
||||||
#endif
|
#endif
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fptr;
|
return fptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* end of file fs.c */
|
/* end of file fs.c */
|
||||||
|
|||||||
29
lib/fs.h
29
lib/fs.h
@@ -8,28 +8,29 @@
|
|||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* 3. Neither the name of the copyright holder nor the names of its
|
* 3. Neither the name of the copyright holder nor the names of its
|
||||||
* contributors may be used to endorse or promote products derived from
|
* contributors may be used to endorse or promote products derived from
|
||||||
* this software without specific prior written permission.
|
* this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef fs_H
|
#ifndef fs_H
|
||||||
|
|||||||
@@ -8,75 +8,70 @@
|
|||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* 3. Neither the name of the copyright holder nor the names of its
|
* 3. Neither the name of the copyright holder nor the names of its
|
||||||
* contributors may be used to endorse or promote products derived from
|
* contributors may be used to endorse or promote products derived from
|
||||||
* this software without specific prior written permission.
|
* this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
#include <libgen.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <libgen.h>
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
#include "proginfo.h"
|
#include "proginfo.h"
|
||||||
|
|
||||||
/* TODO(vx-clutch): default this to argv[0] */
|
/* TODO(vx-clutch): default this to argv[0] */
|
||||||
const char *prog_name = "";
|
const char *prog_name = "";
|
||||||
|
|
||||||
void set_prog_name(char *name)
|
void set_prog_name(char *name) { prog_name = prog_name ? basename(name) : ""; }
|
||||||
{
|
|
||||||
prog_name = prog_name ? basename(name) : "";
|
void emit_try_help() {
|
||||||
|
printf("Try '%s --help' for more information\n", prog_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void emit_try_help()
|
void emit_version() {
|
||||||
{
|
printf("\
|
||||||
printf("Try '%s --help' for more information\n", prog_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void emit_version()
|
|
||||||
{
|
|
||||||
printf("\
|
|
||||||
%s %s %d\n\
|
%s %s %d\n\
|
||||||
Copyright (C) %d GCK.\n\
|
Copyright (C) %d GCK.\n\
|
||||||
This is free software: you are free to change and redistribute it.\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\
|
There is NO WARRNTY, to the extent permitted by law.\n\
|
||||||
",
|
",
|
||||||
prog_name, VERSION, COMMIT, YEAR);
|
prog_name, VERSION, COMMIT, YEAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
int parse_standard_options(int argc, char **argv, void (*print_help)(),
|
int parse_standard_options(int argc, char **argv, void (*print_help)(),
|
||||||
void (*print_version)())
|
void (*print_version)()) {
|
||||||
{
|
for (int i = 0; i < argc; ++i) {
|
||||||
for (int i = 0; i < argc; ++i) {
|
if (!strcmp(argv[i], "--help")) {
|
||||||
if (!strcmp(argv[i], "--help")) {
|
print_help();
|
||||||
print_help();
|
exit(EXIT_SUCCESS);
|
||||||
exit(EXIT_SUCCESS);
|
} else if (!strcmp(argv[i], "--version")) {
|
||||||
} else if (!strcmp(argv[i], "--version")) {
|
emit_version();
|
||||||
emit_version();
|
exit(EXIT_SUCCESS);
|
||||||
exit(EXIT_SUCCESS);
|
}
|
||||||
}
|
}
|
||||||
}
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* end of file proginfo.c */
|
/* end of file proginfo.c */
|
||||||
|
|||||||
@@ -8,28 +8,29 @@
|
|||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* 3. Neither the name of the copyright holder nor the names of its
|
* 3. Neither the name of the copyright holder nor the names of its
|
||||||
* contributors may be used to endorse or promote products derived from
|
* contributors may be used to endorse or promote products derived from
|
||||||
* this software without specific prior written permission.
|
* this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef proginfo_H
|
#ifndef proginfo_H
|
||||||
@@ -43,7 +44,7 @@ void emit_try_help();
|
|||||||
void emit_version();
|
void emit_version();
|
||||||
|
|
||||||
int parse_standard_options(int argc, char **argv, void (*print_help)(),
|
int parse_standard_options(int argc, char **argv, void (*print_help)(),
|
||||||
void (*print_version)());
|
void (*print_version)());
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
122
lib/say.c
122
lib/say.c
@@ -8,98 +8,94 @@
|
|||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* 3. Neither the name of the copyright holder nor the names of its
|
* 3. Neither the name of the copyright holder nor the names of its
|
||||||
* contributors may be used to endorse or promote products derived from
|
* contributors may be used to endorse or promote products derived from
|
||||||
* this software without specific prior written permission.
|
* this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "say.h"
|
#include "say.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "xmem.h"
|
#include "xmem.h"
|
||||||
|
|
||||||
void alert()
|
void alert() {
|
||||||
{
|
fputs("\a", stderr);
|
||||||
fputs("\a", stderr);
|
fflush(stderr);
|
||||||
fflush(stderr);
|
return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int vasprintf(char **result, const char *fmt, va_list ap)
|
int vasprintf(char **result, const char *fmt, va_list ap) {
|
||||||
{
|
int total_width = strlen(fmt) + 1;
|
||||||
int total_width = strlen(fmt) + 1;
|
*result = (char *)xmalloc(total_width);
|
||||||
*result = (char *)xmalloc(total_width);
|
return vsprintf(*result, fmt, ap);
|
||||||
return vsprintf(*result, fmt, ap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int asprintf(char **buf, const char *fmt, ...)
|
int asprintf(char **buf, const char *fmt, ...) {
|
||||||
{
|
int status;
|
||||||
int status;
|
va_list ap;
|
||||||
va_list ap;
|
va_start(ap, fmt);
|
||||||
va_start(ap, fmt);
|
status = vasprintf(buf, fmt, ap);
|
||||||
status = vasprintf(buf, fmt, ap);
|
va_end(ap);
|
||||||
va_end(ap);
|
return status;
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int say(const char *restrict format, ...)
|
int say(const char *restrict format, ...) {
|
||||||
{
|
struct winsize w;
|
||||||
struct winsize w;
|
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) == -1) {
|
||||||
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) == -1) {
|
va_list args;
|
||||||
va_list args;
|
va_start(args, format);
|
||||||
va_start(args, format);
|
int ret = vprintf(format, args);
|
||||||
int ret = vprintf(format, args);
|
va_end(args);
|
||||||
va_end(args);
|
putchar('\n');
|
||||||
putchar('\n');
|
fflush(stdout);
|
||||||
fflush(stdout);
|
return ret;
|
||||||
return ret;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
printf("\0337"); // save cursor (ESC 7)
|
printf("\0337"); // save cursor (ESC 7)
|
||||||
printf("\033[%d;1H", w.ws_row); // move to last row
|
printf("\033[%d;1H", w.ws_row); // move to last row
|
||||||
printf("\033[2K"); // clear entire line
|
printf("\033[2K"); // clear entire line
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
int ret = vprintf(format, args); // print formatted message
|
int ret = vprintf(format, args); // print formatted message
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
fflush(stdout); // ensure it's visible immediately
|
fflush(stdout); // ensure it's visible immediately
|
||||||
printf("\0338"); // restore cursor (ESC 8)
|
printf("\0338"); // restore cursor (ESC 8)
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
_Noreturn void die(const char *msg)
|
_Noreturn void die(const char *msg) {
|
||||||
{
|
fputs(msg, stderr);
|
||||||
fputs(msg, stderr);
|
exit(EXIT_FAILURE);
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* end of file say.c */
|
/* end of file say.c */
|
||||||
|
|||||||
29
lib/say.h
29
lib/say.h
@@ -8,28 +8,29 @@
|
|||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* 3. Neither the name of the copyright holder nor the names of its
|
* 3. Neither the name of the copyright holder nor the names of its
|
||||||
* contributors may be used to endorse or promote products derived from
|
* contributors may be used to endorse or promote products derived from
|
||||||
* this software without specific prior written permission.
|
* this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SAY_H
|
#ifndef SAY_H
|
||||||
|
|||||||
80
lib/textc.c
80
lib/textc.c
@@ -8,72 +8,66 @@
|
|||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* 3. Neither the name of the copyright holder nor the names of its
|
* 3. Neither the name of the copyright holder nor the names of its
|
||||||
* contributors may be used to endorse or promote products derived from
|
* contributors may be used to endorse or promote products derived from
|
||||||
* this software without specific prior written permission.
|
* this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include "xmem.h"
|
#include "xmem.h"
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "textc.h"
|
#include "textc.h"
|
||||||
|
|
||||||
char *str_dup(char *s)
|
char *str_dup(char *s) {
|
||||||
{
|
char *new = xmalloc(strlen(s) + 1);
|
||||||
char *new = xmalloc(strlen(s) + 1);
|
strcpy(new, s);
|
||||||
strcpy(new, s);
|
return new;
|
||||||
return new;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *tostrupr(char *s)
|
char *tostrupr(char *s) {
|
||||||
{
|
char *new = str_dup(s);
|
||||||
char *new = str_dup(s);
|
for (int i = 0; new[i] != '\0'; ++i)
|
||||||
for (int i = 0; new[i] != '\0'; ++i)
|
new[i] = toupper((unsigned char)new[i]);
|
||||||
new[i] = toupper((unsigned char)new[i]);
|
return new;
|
||||||
return new;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *tostrlwr(char *s)
|
char *tostrlwr(char *s) {
|
||||||
{
|
char *new = str_dup(s);
|
||||||
char *new = str_dup(s);
|
for (int i = 0; new[i] != '\0'; ++i)
|
||||||
for (int i = 0; new[i] != '\0'; ++i)
|
new[i] = tolower((unsigned char)new[i]);
|
||||||
new[i] = tolower((unsigned char)new[i]);
|
return new;
|
||||||
return new;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *textc_trim(char *s)
|
char *textc_trim(char *s) { return NULL; }
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *textc_pad_left(int count, char *s, char pad)
|
char *textc_pad_left(int count, char *s, char pad) {
|
||||||
{
|
char *buffer = xmalloc(strlen(s) + 1);
|
||||||
char *buffer = xmalloc(strlen(s) + 1);
|
|
||||||
|
|
||||||
free(buffer);
|
free(buffer);
|
||||||
buffer = "NOT IMPLEMENTED";
|
buffer = "NOT IMPLEMENTED";
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* end of file textc.c */
|
/* end of file textc.c */
|
||||||
|
|||||||
29
lib/textc.h
29
lib/textc.h
@@ -8,28 +8,29 @@
|
|||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* 3. Neither the name of the copyright holder nor the names of its
|
* 3. Neither the name of the copyright holder nor the names of its
|
||||||
* contributors may be used to endorse or promote products derived from
|
* contributors may be used to endorse or promote products derived from
|
||||||
* this software without specific prior written permission.
|
* this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TEXTC_H
|
#ifndef TEXTC_H
|
||||||
|
|||||||
55
lib/xmem.c
55
lib/xmem.c
@@ -8,28 +8,29 @@
|
|||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* 3. Neither the name of the copyright holder nor the names of its
|
* 3. Neither the name of the copyright holder nor the names of its
|
||||||
* contributors may be used to endorse or promote products derived from
|
* contributors may be used to endorse or promote products derived from
|
||||||
* this software without specific prior written permission.
|
* this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -39,26 +40,20 @@
|
|||||||
|
|
||||||
#include "xmem.h"
|
#include "xmem.h"
|
||||||
|
|
||||||
void *ensure_nonnull(void *ptr)
|
void *ensure_nonnull(void *ptr) {
|
||||||
{
|
if (ptr == NULL)
|
||||||
if (ptr == NULL)
|
fatalf("memory exhausted");
|
||||||
fatalf("memory exhausted");
|
return ptr;
|
||||||
return ptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *xmalloc(size_t size)
|
void *xmalloc(size_t size) { return ensure_nonnull(malloc(size)); }
|
||||||
{
|
|
||||||
return ensure_nonnull(malloc(size));
|
void *xrealloc(void *ptr, size_t size) {
|
||||||
|
return ensure_nonnull(realloc(ptr, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
void *xrealloc(void *ptr, size_t size)
|
void *xcalloc(size_t nmemb, size_t size) {
|
||||||
{
|
return ensure_nonnull(calloc(nmemb, 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 */
|
/* end of file xmem.c */
|
||||||
|
|||||||
29
lib/xmem.h
29
lib/xmem.h
@@ -8,28 +8,29 @@
|
|||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* 3. Neither the name of the copyright holder nor the names of its
|
* 3. Neither the name of the copyright holder nor the names of its
|
||||||
* contributors may be used to endorse or promote products derived from
|
* contributors may be used to endorse or promote products derived from
|
||||||
* this software without specific prior written permission.
|
* this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef xmem_H
|
#ifndef xmem_H
|
||||||
|
|||||||
@@ -1,2 +1,4 @@
|
|||||||
[NAME]
|
[NAME]
|
||||||
yait - an optionated C project generator
|
yait - An opinionated C project generator
|
||||||
|
[ADDITIONAL INFORMATION]
|
||||||
|
.UR https://github.com/gck-org/yait
|
||||||
|
|||||||
76
scripts/manual/make
Executable file
76
scripts/manual/make
Executable file
@@ -0,0 +1,76 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# gck.make - Generate manual page
|
||||||
|
#
|
||||||
|
# FEATURES:
|
||||||
|
# - Generate manual page
|
||||||
|
#
|
||||||
|
# COMPILATION (Linux - POSIX):
|
||||||
|
# ./make
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
me=$0
|
||||||
|
scriptversion="1.0.0"
|
||||||
|
|
||||||
|
version="make $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
|
||||||
|
|
||||||
|
# End: make
|
||||||
@@ -8,28 +8,29 @@
|
|||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* 3. Neither the name of the copyright holder nor the names of its
|
* 3. Neither the name of the copyright holder nor the names of its
|
||||||
* contributors may be used to endorse or promote products derived from
|
* contributors may be used to endorse or promote products derived from
|
||||||
* this software without specific prior written permission.
|
* this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LICENCES_H
|
#ifndef LICENCES_H
|
||||||
|
|||||||
485
src/yait.c
485
src/yait.c
@@ -19,196 +19,191 @@
|
|||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* 3. Neither the name of the copyright holder nor the names of its
|
* 3. Neither the name of the copyright holder nor the names of its
|
||||||
* contributors may be used to endorse or promote products derived from
|
* contributors may be used to endorse or promote products derived from
|
||||||
* this software without specific prior written permission.
|
* this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <sys/wait.h>
|
||||||
#include <stdbool.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "licence.h"
|
|
||||||
#include "../lib/err.h"
|
#include "../lib/err.h"
|
||||||
#include "../lib/fs.h"
|
#include "../lib/fs.h"
|
||||||
#include "../lib/proginfo.h"
|
#include "../lib/proginfo.h"
|
||||||
#include "../lib/textc.h"
|
|
||||||
#include "../lib/say.h"
|
#include "../lib/say.h"
|
||||||
|
#include "../lib/textc.h"
|
||||||
|
#include "licence.h"
|
||||||
|
|
||||||
typedef enum { MIT, GPL, BSD, UNL } licence_t;
|
typedef enum { MIT, GPL, BSD, UNL } licence_t;
|
||||||
|
|
||||||
static const struct option longopts[] = {
|
static const struct option longopts[] = {{"author", required_argument, 0, 'a'},
|
||||||
{ "author", required_argument, 0, 'a' },
|
{"licence", required_argument, 0, 'l'},
|
||||||
{ "licence", required_argument, 0, 'l' },
|
{"quiet", no_argument, 0, 'q'},
|
||||||
{ "quiet", no_argument, 0, 'q' },
|
{"force", no_argument, 0, 'f'},
|
||||||
{ "force", no_argument, 0, 'f' },
|
{0, 0, 0, 0}};
|
||||||
{ 0, 0, 0, 0 }
|
|
||||||
};
|
|
||||||
|
|
||||||
static int exit_status;
|
static int exit_status;
|
||||||
|
|
||||||
static void print_help();
|
static void print_help();
|
||||||
static void print_version();
|
static void print_version();
|
||||||
|
|
||||||
static char *get_name()
|
static char *get_name() {
|
||||||
{
|
int fds[2];
|
||||||
int fds[2];
|
if (pipe(fds) == -1)
|
||||||
if (pipe(fds) == -1)
|
goto sysuser;
|
||||||
goto sysuser;
|
|
||||||
|
|
||||||
pid_t pid = fork();
|
pid_t pid = fork();
|
||||||
if (pid == -1) {
|
if (pid == -1) {
|
||||||
close(fds[0]);
|
close(fds[0]);
|
||||||
close(fds[1]);
|
close(fds[1]);
|
||||||
goto sysuser;
|
goto sysuser;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
dup2(fds[1], STDOUT_FILENO);
|
dup2(fds[1], STDOUT_FILENO);
|
||||||
close(fds[0]);
|
close(fds[0]);
|
||||||
close(fds[1]);
|
close(fds[1]);
|
||||||
execlp("git", "git", "config", "--get", "user.name",
|
execlp("git", "git", "config", "--get", "user.name", (char *)NULL);
|
||||||
(char *)NULL);
|
_exit(127);
|
||||||
_exit(127);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
close(fds[1]);
|
close(fds[1]);
|
||||||
char buf[256];
|
char buf[256];
|
||||||
ssize_t n = read(fds[0], buf, sizeof buf - 1);
|
ssize_t n = read(fds[0], buf, sizeof buf - 1);
|
||||||
close(fds[0]);
|
close(fds[0]);
|
||||||
int status;
|
int status;
|
||||||
waitpid(pid, &status, 0);
|
waitpid(pid, &status, 0);
|
||||||
if (n > 0 && WIFEXITED(status) && WEXITSTATUS(status) == 0) {
|
if (n > 0 && WIFEXITED(status) && WEXITSTATUS(status) == 0) {
|
||||||
buf[n] = 0;
|
buf[n] = 0;
|
||||||
buf[strcspn(buf, "\n")] = 0;
|
buf[strcspn(buf, "\n")] = 0;
|
||||||
return str_dup(buf);
|
return str_dup(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
sysuser: {
|
sysuser: {
|
||||||
char *name = getlogin();
|
char *name = getlogin();
|
||||||
if (name)
|
if (name)
|
||||||
return str_dup(name);
|
return str_dup(name);
|
||||||
struct passwd *pw = getpwuid(getuid());
|
struct passwd *pw = getpwuid(getuid());
|
||||||
if (pw && pw->pw_name)
|
if (pw && pw->pw_name)
|
||||||
return str_dup(pw->pw_name);
|
return str_dup(pw->pw_name);
|
||||||
}
|
}
|
||||||
return str_dup("author");
|
return str_dup("author");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_year()
|
static int get_year() {
|
||||||
{
|
time_t now = time(NULL);
|
||||||
time_t now = time(NULL);
|
struct tm *t = localtime(&now);
|
||||||
struct tm *t = localtime(&now);
|
|
||||||
|
|
||||||
// The tm_year member stores years since 1900, so add 1900 to get the actual year
|
// The tm_year member stores years since 1900, so add 1900 to get the actual
|
||||||
return t->tm_year + 1900;
|
// year
|
||||||
|
return t->tm_year + 1900;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv) {
|
||||||
{
|
int optc;
|
||||||
int optc;
|
int lose = 0;
|
||||||
int lose = 0;
|
char *package;
|
||||||
char *package;
|
bool quiet = false;
|
||||||
bool quiet = false;
|
bool force = false;
|
||||||
bool force = false;
|
bool editor = false;
|
||||||
bool editor = false;
|
bool shell = false;
|
||||||
bool shell = false;
|
char *author = get_name();
|
||||||
char *author = get_name();
|
exit_status = EXIT_SUCCESS;
|
||||||
exit_status = EXIT_SUCCESS;
|
int year = get_year();
|
||||||
int year = get_year();
|
licence_t licence = BSD;
|
||||||
licence_t licence = BSD;
|
set_prog_name(argv[0]);
|
||||||
set_prog_name(argv[0]);
|
|
||||||
|
|
||||||
parse_standard_options(argc, argv, print_help, print_version);
|
parse_standard_options(argc, argv, print_help, print_version);
|
||||||
|
|
||||||
while ((optc = getopt_long(argc, argv, "a:l:EqfS", longopts, NULL)) !=
|
while ((optc = getopt_long(argc, argv, "a:l:EqfS", longopts, NULL)) != -1)
|
||||||
-1)
|
switch (optc) {
|
||||||
switch (optc) {
|
case 'a':
|
||||||
case 'a':
|
if (optarg) {
|
||||||
if (optarg) {
|
if (author)
|
||||||
if (author)
|
free(author);
|
||||||
free(author);
|
author = str_dup(optarg);
|
||||||
author = str_dup(optarg);
|
}
|
||||||
}
|
break;
|
||||||
break;
|
case 'l':
|
||||||
case 'l':
|
if (!strcmp(optarg, "list")) {
|
||||||
if (!strcmp(optarg, "list")) {
|
puts("BSD\nGPL\nMIT\nUNL");
|
||||||
puts("BSD\nGPL\nMIT\nUNL");
|
exit(EXIT_SUCCESS);
|
||||||
exit(EXIT_SUCCESS);
|
}
|
||||||
}
|
if (!strcmp(optarg, "GPL"))
|
||||||
if (!strcmp(optarg, "GPL"))
|
licence = GPL;
|
||||||
licence = GPL;
|
else if (!strcmp(optarg, "MIT"))
|
||||||
else if (!strcmp(optarg, "MIT"))
|
licence = MIT;
|
||||||
licence = MIT;
|
else if (!strcmp(optarg, "BSD"))
|
||||||
else if (!strcmp(optarg, "BSD"))
|
licence = BSD;
|
||||||
licence = BSD;
|
else if (!strcmp(optarg, "UNL"))
|
||||||
else if (!strcmp(optarg, "UNL"))
|
licence = UNL;
|
||||||
licence = UNL;
|
else {
|
||||||
else {
|
puts("BSD\nGPL\nMIT\nUNL");
|
||||||
puts("BSD\nGPL\nMIT\nUNL");
|
exit(EXIT_FAILURE);
|
||||||
exit(EXIT_FAILURE);
|
}
|
||||||
}
|
break;
|
||||||
break;
|
case 'E':
|
||||||
case 'E':
|
editor = true;
|
||||||
editor = true;
|
break;
|
||||||
break;
|
case 'q':
|
||||||
case 'q':
|
quiet = true;
|
||||||
quiet = true;
|
break;
|
||||||
break;
|
case 'f':
|
||||||
case 'f':
|
force = true;
|
||||||
force = true;
|
break;
|
||||||
break;
|
case 'S':
|
||||||
case 'S':
|
shell = true;
|
||||||
shell = true;
|
break;
|
||||||
break;
|
default:
|
||||||
default:
|
lose = 1;
|
||||||
lose = 1;
|
}
|
||||||
}
|
if (lose) {
|
||||||
if (lose) {
|
emit_try_help();
|
||||||
emit_try_help();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (optind >= argc) {
|
if (optind >= argc) {
|
||||||
fatalf("no input name");
|
fatalf("no input name");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optind + 1 < argc) {
|
if (optind + 1 < argc) {
|
||||||
errorf("extra operand: %s", argv[optind + 1]);
|
errorf("extra operand: %s", argv[optind + 1]);
|
||||||
emit_try_help();
|
emit_try_help();
|
||||||
}
|
}
|
||||||
|
|
||||||
package = str_dup(argv[optind]);
|
package = str_dup(argv[optind]);
|
||||||
|
|
||||||
if (shell) {
|
if (shell) {
|
||||||
fs_write(package, "\
|
fs_write(package, "\
|
||||||
#!/bin/sh\n\
|
#!/bin/sh\n\
|
||||||
\n\
|
\n\
|
||||||
# Usage: $0 [options]...\n\
|
# Usage: $0 [options]...\n\
|
||||||
@@ -253,45 +248,45 @@ while [ $# -gt 0 ]; do\n\
|
|||||||
shift\n\
|
shift\n\
|
||||||
done\n\
|
done\n\
|
||||||
",
|
",
|
||||||
year, author);
|
year, author);
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
if (stat(package, &st) != 0) {
|
if (stat(package, &st) != 0) {
|
||||||
fatalfa(errno);
|
fatalfa(errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
mode_t mode = st.st_mode | S_IXUSR;
|
mode_t mode = st.st_mode | S_IXUSR;
|
||||||
|
|
||||||
if (chmod(package, mode) != 0) {
|
if (chmod(package, mode) != 0) {
|
||||||
fatalfa(errno);
|
fatalfa(errno);
|
||||||
}
|
}
|
||||||
return exit_status;
|
return exit_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// size_t len = strlen(package);
|
// size_t len = strlen(package);
|
||||||
// char *pdir = xmalloc(len + 2);
|
// char *pdir = xmalloc(len + 2);
|
||||||
// memcpy(pdir, package, len);
|
// memcpy(pdir, package, len);
|
||||||
// pdir[len] = '/';
|
// pdir[len] = '/';
|
||||||
// pdir[len + 1] = '\0';
|
// pdir[len + 1] = '\0';
|
||||||
char *pdir;
|
char *pdir;
|
||||||
asprintf(&pdir, "%s/", package);
|
asprintf(&pdir, "%s/", package);
|
||||||
|
|
||||||
fs_new(pdir);
|
fs_new(pdir);
|
||||||
if (chdir(pdir))
|
if (chdir(pdir))
|
||||||
fatalfa(errno);
|
fatalfa(errno);
|
||||||
|
|
||||||
fs_write("doc/version.texi", "\
|
fs_write("doc/version.texi", "\
|
||||||
@set UPDATED %s\
|
@set UPDATED %s\
|
||||||
@set UPDATED-MONTH %s\
|
@set UPDATED-MONTH %s\
|
||||||
@set EDITION 1\
|
@set EDITION 1\
|
||||||
@set VERSION alpha\
|
@set VERSION alpha\
|
||||||
",
|
",
|
||||||
"1 January 1970", "January 2025");
|
"1 January 1970", "January 2025");
|
||||||
|
|
||||||
char *texi_buffer;
|
char *texi_buffer;
|
||||||
// snprintf(path_buffer, sizeof(path_buffer), "doc/%s.texi", package);
|
// snprintf(path_buffer, sizeof(path_buffer), "doc/%s.texi", package);
|
||||||
asprintf(&texi_buffer, "doc/%s.texi", package);
|
asprintf(&texi_buffer, "doc/%s.texi", package);
|
||||||
fs_write(texi_buffer, "\
|
fs_write(texi_buffer, "\
|
||||||
\\input texinfo @c -*-texinfo-*-\n\
|
\\input texinfo @c -*-texinfo-*-\n\
|
||||||
@c %**start of header\n\
|
@c %**start of header\n\
|
||||||
@setfilename foo.info\n\
|
@setfilename foo.info\n\
|
||||||
@@ -460,15 +455,15 @@ a @file{ChangeLog} entry.\n\
|
|||||||
\n\
|
\n\
|
||||||
@bye\
|
@bye\
|
||||||
",
|
",
|
||||||
author, author, author, author, author, author, author, author,
|
author, author, author, author, author, author, author, author,
|
||||||
author, author, author, author, author, author);
|
author, author, author, author, author, author);
|
||||||
free(texi_buffer);
|
free(texi_buffer);
|
||||||
|
|
||||||
// TODO(vx-clutch): Why dosn't this write the source?
|
// TODO(vx-clutch): Why dosn't this write the source?
|
||||||
// snprintf(path_buffer, sizeof(path_buffer), "src/%s.c", package);
|
// snprintf(path_buffer, sizeof(path_buffer), "src/%s.c", package);
|
||||||
char *src_path;
|
char *src_path;
|
||||||
asprintf(&src_path, "src/%s.c", package);
|
asprintf(&src_path, "src/%s.c", package);
|
||||||
fs_write(src_path, "\
|
fs_write(src_path, "\
|
||||||
/* Copyright (C) %s\n\
|
/* Copyright (C) %s\n\
|
||||||
*\n\
|
*\n\
|
||||||
* This file is part of %s\n\
|
* This file is part of %s\n\
|
||||||
@@ -529,10 +524,10 @@ void print_version()\n\
|
|||||||
exit(exit_status);\n\
|
exit(exit_status);\n\
|
||||||
}\
|
}\
|
||||||
",
|
",
|
||||||
author, package, package, package, author);
|
author, package, package, package, author);
|
||||||
free(src_path);
|
free(src_path);
|
||||||
|
|
||||||
fs_write("tools/Cleanup", "\
|
fs_write("tools/Cleanup", "\
|
||||||
#!/bin/sh\n\
|
#!/bin/sh\n\
|
||||||
# Usage: ./Cleanup\n\
|
# Usage: ./Cleanup\n\
|
||||||
\n\
|
\n\
|
||||||
@@ -554,7 +549,7 @@ run make distclean\n\
|
|||||||
\n\
|
\n\
|
||||||
echo \"done.\"\
|
echo \"done.\"\
|
||||||
");
|
");
|
||||||
fs_write("tools/format", "\
|
fs_write("tools/format", "\
|
||||||
#!/bin/sh\n\
|
#!/bin/sh\n\
|
||||||
\n\
|
\n\
|
||||||
# Usage ./format\n\
|
# Usage ./format\n\
|
||||||
@@ -563,7 +558,7 @@ find . -name \"*.c\" -exec clang-format -i --verbose {} \\;\n\
|
|||||||
find . -name \"*.h\" -exec clang-format -i --verbose {} \\;\
|
find . -name \"*.h\" -exec clang-format -i --verbose {} \\;\
|
||||||
");
|
");
|
||||||
|
|
||||||
fs_write(".clang-format", "\
|
fs_write(".clang-format", "\
|
||||||
---\n\
|
---\n\
|
||||||
AccessModifierOffset: -4\n\
|
AccessModifierOffset: -4\n\
|
||||||
AlignAfterOpenBracket: Align\n\
|
AlignAfterOpenBracket: Align\n\
|
||||||
@@ -674,7 +669,7 @@ UseTab: Always\n\
|
|||||||
...\
|
...\
|
||||||
");
|
");
|
||||||
|
|
||||||
fs_write(".clangd", "\
|
fs_write(".clangd", "\
|
||||||
CompileFlags:\n\
|
CompileFlags:\n\
|
||||||
Add: [-x, c, -std=c23, -Ilib, -I.]\n\
|
Add: [-x, c, -std=c23, -Ilib, -I.]\n\
|
||||||
\n\
|
\n\
|
||||||
@@ -684,7 +679,7 @@ Diagnostics:\n\
|
|||||||
Remove: []\
|
Remove: []\
|
||||||
");
|
");
|
||||||
|
|
||||||
fs_write("README", "\
|
fs_write("README", "\
|
||||||
This is the README for the GCK %s distribution.\n\
|
This is the README for the GCK %s distribution.\n\
|
||||||
%s does a thing.\n\
|
%s does a thing.\n\
|
||||||
\n\
|
\n\
|
||||||
@@ -715,9 +710,9 @@ implementation, etc., would still be very much appreciated.\n\
|
|||||||
\n\
|
\n\
|
||||||
GCK %s is free software. See the file COPYING for copying conditions.\n\
|
GCK %s is free software. See the file COPYING for copying conditions.\n\
|
||||||
\n",
|
\n",
|
||||||
package, package, year, package);
|
package, package, year, package);
|
||||||
|
|
||||||
fs_write("INSTALL", "\
|
fs_write("INSTALL", "\
|
||||||
Installation Instructions\n\
|
Installation Instructions\n\
|
||||||
*************************\n\
|
*************************\n\
|
||||||
\n\
|
\n\
|
||||||
@@ -773,9 +768,9 @@ Documentation and other data files still use the regular prefix.\n\
|
|||||||
`configure` also accepts some other options. Run `configure --help` for more\n\
|
`configure` also accepts some other options. Run `configure --help` for more\n\
|
||||||
details\n\
|
details\n\
|
||||||
",
|
",
|
||||||
year);
|
year);
|
||||||
|
|
||||||
fs_write("AUTHORS", "\
|
fs_write("AUTHORS", "\
|
||||||
Authors of %s %s.\n\
|
Authors of %s %s.\n\
|
||||||
\n\
|
\n\
|
||||||
Copyright (C) %d %s.\n\
|
Copyright (C) %d %s.\n\
|
||||||
@@ -788,9 +783,9 @@ Also see the THANKS files.\n\
|
|||||||
\n\
|
\n\
|
||||||
%s\n\
|
%s\n\
|
||||||
",
|
",
|
||||||
author, package, year, package, author);
|
author, package, year, package, author);
|
||||||
|
|
||||||
fs_write("THANKS", "\
|
fs_write("THANKS", "\
|
||||||
Additional contributors to %s %s.\n\
|
Additional contributors to %s %s.\n\
|
||||||
\n\
|
\n\
|
||||||
Copyright (C) %d %s.\n\
|
Copyright (C) %d %s.\n\
|
||||||
@@ -805,9 +800,9 @@ Thanks to:\n\
|
|||||||
\n\
|
\n\
|
||||||
See also the AUTHORS file.\n\
|
See also the AUTHORS file.\n\
|
||||||
",
|
",
|
||||||
author, package, year, author);
|
author, package, year, author);
|
||||||
|
|
||||||
fs_write("config.h", "\
|
fs_write("config.h", "\
|
||||||
#ifndef CONFIG_H\n\
|
#ifndef CONFIG_H\n\
|
||||||
#define CONFIG_H\n\
|
#define CONFIG_H\n\
|
||||||
\n\
|
\n\
|
||||||
@@ -819,9 +814,9 @@ See also the AUTHORS file.\n\
|
|||||||
\n\
|
\n\
|
||||||
#endif\
|
#endif\
|
||||||
",
|
",
|
||||||
package, author, year);
|
package, author, year);
|
||||||
|
|
||||||
fs_write("configure", "\
|
fs_write("configure", "\
|
||||||
#!/bin/sh\n\
|
#!/bin/sh\n\
|
||||||
\n\
|
\n\
|
||||||
usage() {\n\
|
usage() {\n\
|
||||||
@@ -914,7 +909,7 @@ printf \"CC=%%s\n\" \"$CC\"\n\
|
|||||||
printf \"done\n\"\
|
printf \"done\n\"\
|
||||||
");
|
");
|
||||||
|
|
||||||
fs_write("Makefile", "\
|
fs_write("Makefile", "\
|
||||||
PACKAGE := %s\n\
|
PACKAGE := %s\n\
|
||||||
\n\
|
\n\
|
||||||
SRCS := $(wildcard src/*.c) $(wildcard lib/*.c)\n\
|
SRCS := $(wildcard src/*.c) $(wildcard lib/*.c)\n\
|
||||||
@@ -970,9 +965,9 @@ release: clean all\n\
|
|||||||
\n\
|
\n\
|
||||||
.PHONY: all clean distclean install uninstall build release\
|
.PHONY: all clean distclean install uninstall build release\
|
||||||
",
|
",
|
||||||
package);
|
package);
|
||||||
|
|
||||||
fs_write("TODO", "\
|
fs_write("TODO", "\
|
||||||
%s %s- TODO\n\
|
%s %s- TODO\n\
|
||||||
\n\
|
\n\
|
||||||
Todo:\n\
|
Todo:\n\
|
||||||
@@ -981,77 +976,75 @@ Todo:\n\
|
|||||||
\n\
|
\n\
|
||||||
end of file TODO\
|
end of file TODO\
|
||||||
",
|
",
|
||||||
author, package, package);
|
author, package, package);
|
||||||
|
|
||||||
switch (licence) {
|
switch (licence) {
|
||||||
case BSD:
|
case BSD:
|
||||||
fs_write("COPYING", fBSD, year, author);
|
fs_write("COPYING", fBSD, year, author);
|
||||||
break;
|
break;
|
||||||
case MIT:
|
case MIT:
|
||||||
fs_write("COPYING", fMIT, year, author);
|
fs_write("COPYING", fMIT, year, author);
|
||||||
break;
|
break;
|
||||||
case GPL:
|
case GPL:
|
||||||
fs_write("COPYING", fGPL);
|
fs_write("COPYING", fGPL);
|
||||||
break;
|
break;
|
||||||
case UNL:
|
case UNL:
|
||||||
fs_write("COPYING", fUNL);
|
fs_write("COPYING", fUNL);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fatalf("illegal state");
|
fatalf("illegal state");
|
||||||
}
|
}
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
if (stat("configure", &st) != 0) {
|
if (stat("configure", &st) != 0) {
|
||||||
fatalfa(errno);
|
fatalfa(errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
mode_t mode = st.st_mode | S_IXUSR;
|
mode_t mode = st.st_mode | S_IXUSR;
|
||||||
|
|
||||||
if (chmod("configure", mode) != 0) {
|
if (chmod("configure", mode) != 0) {
|
||||||
fatalfa(errno);
|
fatalfa(errno);
|
||||||
}
|
}
|
||||||
if (chmod("tools/format", mode) != 0) {
|
if (chmod("tools/format", mode) != 0) {
|
||||||
fatalfa(errno);
|
fatalfa(errno);
|
||||||
}
|
}
|
||||||
if (chmod("tools/Cleanup", mode) != 0) {
|
if (chmod("tools/Cleanup", mode) != 0) {
|
||||||
fatalfa(errno);
|
fatalfa(errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
return exit_status;
|
return exit_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_help()
|
static void print_help() {
|
||||||
{
|
printf("Usage: %s [OPTION]... [project-name]...\n", PROGRAM);
|
||||||
printf("Usage: %s [OPTION]... [project-name]...\n", PROGRAM);
|
fputs("\
|
||||||
fputs("\
|
|
||||||
Generates an opinionated C project.\n",
|
Generates an opinionated C project.\n",
|
||||||
stdout);
|
stdout);
|
||||||
puts("");
|
puts("");
|
||||||
fputs("\
|
fputs("\
|
||||||
--help display this help and exit\n\
|
--help display this help and exit\n\
|
||||||
--version display version information and exit\n",
|
--version display version information and exit\n",
|
||||||
stdout);
|
stdout);
|
||||||
puts("");
|
puts("");
|
||||||
fputs("\
|
fputs("\
|
||||||
-E Open $EDITOR after project creation\n\
|
-E Open $EDITOR after project creation\n\
|
||||||
-q, --quiet Only print required messages\n\
|
-q, --quiet Only print required messages\n\
|
||||||
-f, --force Overwrite existing files\n\
|
-f, --force Overwrite existing files\n\
|
||||||
--author=NAME Set the program author (default git username|system username)\n\
|
--author=NAME Set the program author (default git username|system username)\n\
|
||||||
--licence=LICENCE Set the program licence (default BSD)\n",
|
--licence=LICENCE Set the program licence (default BSD)\n",
|
||||||
stdout);
|
stdout);
|
||||||
exit(exit_status);
|
exit(exit_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_version()
|
static void print_version() {
|
||||||
{
|
printf("%s %s %d\n", prog_name, VERSION, COMMIT);
|
||||||
printf("%s %s %d\n", prog_name, VERSION, COMMIT);
|
|
||||||
|
|
||||||
printf("Copyright (C) %d GCK.\n", YEAR);
|
printf("Copyright (C) %d GCK.\n", YEAR);
|
||||||
|
|
||||||
puts("This is free software: you are free to change and redistribute it.");
|
puts("This is free software: you are free to change and redistribute it.");
|
||||||
puts("There is NO WARRANTY, to the extent permitted by law.");
|
puts("There is NO WARRANTY, to the extent permitted by law.");
|
||||||
exit(exit_status);
|
exit(exit_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* end of file yait.c */
|
/* end of file yait.c */
|
||||||
|
|||||||
@@ -1,5 +1,75 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Usage: ./Cleanup
|
# gck.Cleanup - Cleanup the distribution
|
||||||
|
#
|
||||||
|
# FEATURES:
|
||||||
|
# - Run makefile cleans
|
||||||
|
# - Run formats
|
||||||
|
# - Cleanup artifacts
|
||||||
|
#
|
||||||
|
# COMPILATION (Linux - POSIX):
|
||||||
|
# ./Cleanup
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
me=$0
|
||||||
|
scriptversion="1.0.0"
|
||||||
|
|
||||||
|
version="make $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:
|
||||||
|
|
||||||
|
--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.'$1'." >&2
|
||||||
|
exit 1;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
fatal() {
|
fatal() {
|
||||||
echo "fatal: $*" >&2
|
echo "fatal: $*" >&2
|
||||||
@@ -18,3 +88,5 @@ run rm -f compile_commands.json
|
|||||||
run make distclean
|
run make distclean
|
||||||
|
|
||||||
echo "done."
|
echo "done."
|
||||||
|
|
||||||
|
# End: Cleanup
|
||||||
|
|||||||
71
tools/format
71
tools/format
@@ -1,6 +1,75 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# gck.format - Format C source code
|
||||||
|
#
|
||||||
|
# FEATURES:
|
||||||
|
# - Uses clang-format to force C code
|
||||||
|
#
|
||||||
|
# COMPILATION (Linux - POSIX):
|
||||||
|
# ./format
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
# Usage ./format
|
me=$0
|
||||||
|
scriptversion="1.0.0"
|
||||||
|
|
||||||
|
version="make $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:
|
||||||
|
|
||||||
|
--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.'$1'." >&2
|
||||||
|
exit 1;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
find . -name "*.c" -exec clang-format -i --verbose {} \;
|
find . -name "*.c" -exec clang-format -i --verbose {} \;
|
||||||
find . -name "*.h" -exec clang-format -i --verbose {} \;
|
find . -name "*.h" -exec clang-format -i --verbose {} \;
|
||||||
|
|
||||||
|
# End: format
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
mkdir -p build
|
|
||||||
bear --output build/compile_commands.json -- make
|
|
||||||
@@ -1,3 +1,77 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# gck.update-gcklib - Update gcklib submodule
|
||||||
|
#
|
||||||
|
# FEATURES:
|
||||||
|
# - Updates gcklib
|
||||||
|
#
|
||||||
|
# COMPILATION (Linux - POSIX):
|
||||||
|
# ./update-gcklib
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
git submodule update --remote --rebase
|
me=$0
|
||||||
|
scriptversion="1.0.0"
|
||||||
|
|
||||||
|
version="make $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
|
||||||
|
|
||||||
|
# End: update-gcklib
|
||||||
|
|||||||
66
yait.1
66
yait.1
@@ -1,66 +0,0 @@
|
|||||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.2.
|
|
||||||
.TH YAIT "1" "September 2025" "yait beta 156" "User Commands"
|
|
||||||
.SH NAME
|
|
||||||
yait \- manual page for yait beta 156
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.B yait
|
|
||||||
[\fI\,OPTION\/\fR]... [\fI\,project-name\/\fR]
|
|
||||||
.SH DESCRIPTION
|
|
||||||
Generates an optionated C project.
|
|
||||||
.TP
|
|
||||||
\fB\-\-help\fR
|
|
||||||
display this help and exit
|
|
||||||
.TP
|
|
||||||
\fB\-\-version\fR
|
|
||||||
display version information and eixt
|
|
||||||
.TP
|
|
||||||
\fB\-\-git\fR
|
|
||||||
Initialize git repository (default)
|
|
||||||
.TP
|
|
||||||
\fB\-\-no\-git\fR
|
|
||||||
Do not initialize git repository
|
|
||||||
.TP
|
|
||||||
\fB\-\-lib\fR
|
|
||||||
Make this a library
|
|
||||||
.TP
|
|
||||||
\fB\-l\fR <licence>
|
|
||||||
Set licence. This list can be found by passing 'list'
|
|
||||||
.TP
|
|
||||||
\fB\-E\fR
|
|
||||||
Open $EDITOR after project creation
|
|
||||||
.TP
|
|
||||||
\fB\-\-autotools\fR
|
|
||||||
Use the autotools build system
|
|
||||||
.TP
|
|
||||||
\fB\-\-cmake\fR
|
|
||||||
Use the cmake build system
|
|
||||||
.TP
|
|
||||||
\fB\-\-make\fR
|
|
||||||
Use the GNU make build system (default)
|
|
||||||
.TP
|
|
||||||
\fB\-\-bare\fR
|
|
||||||
Minimal C project structure
|
|
||||||
.TP
|
|
||||||
\fB\-\-flat\fR
|
|
||||||
All files in project root.
|
|
||||||
.TP
|
|
||||||
\fB\-\-extras=\fR<arg1>,<arg2>
|
|
||||||
Extra build options, Pass list to list out options.
|
|
||||||
.SH COPYRIGHT
|
|
||||||
Copyright \(co 2025 GCK.
|
|
||||||
License BSD\-3\-Clause: BSD\-3\-Clause <https://opensource.org/license/bsd\-3\-clause>
|
|
||||||
.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.
|
|
||||||
Reference in New Issue
Block a user