From 19d543f99def95edf7394a688615fb12fef8b5ec Mon Sep 17 00:00:00 2001 From: vx-clutch Date: Wed, 22 Apr 2026 21:44:48 -0400 Subject: [PATCH] Inital Commit --- .clang-format | 16 +++++++++ LICENSE | 15 ++++++++ Makefile | 23 ++++++++++++ README | 1 + compile_commands.json | 36 +++++++++++++++++++ doc/bugs | 4 +++ include/tcpl/tcpl.h | 11 ++++++ lib/print.c | 8 +++++ lib/print.h | 9 +++++ make.conf | 11 ++++++ man/tcpl.1 | 26 ++++++++++++++ man/tcpl.md | 25 +++++++++++++ package/tcpl-0.1.ebuild | 16 +++++++++ src/main.c | 11 ++++++ src/main.o | Bin 0 -> 1720 bytes tools/md2man | 78 ++++++++++++++++++++++++++++++++++++++++ 16 files changed, 290 insertions(+) create mode 100644 .clang-format create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README create mode 100644 compile_commands.json create mode 100644 doc/bugs create mode 100644 include/tcpl/tcpl.h create mode 100644 lib/print.c create mode 100644 lib/print.h create mode 100644 make.conf create mode 100644 man/tcpl.1 create mode 100644 man/tcpl.md create mode 100644 package/tcpl-0.1.ebuild create mode 100644 src/main.c create mode 100644 src/main.o create mode 100755 tools/md2man diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..b47e926 --- /dev/null +++ b/.clang-format @@ -0,0 +1,16 @@ +IndentWidth: 8 +TabWidth: 8 +UseTab: Always +BreakBeforeBraces: Linux +AllowShortIfStatementsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortLoopsOnASingleLine: false +ColumnLimit: 80 +IndentCaseLabels: false +PointerAlignment: Left +DerivePointerAlignment: false +SpaceAfterCStyleCast: false +AlignTrailingComments: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +SpaceBeforeParens: ControlStatements diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c2d1485 --- /dev/null +++ b/LICENSE @@ -0,0 +1,15 @@ +ISC License + +Copyright (c) 2026 fSD + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..36726b1 --- /dev/null +++ b/Makefile @@ -0,0 +1,23 @@ +-include make.conf + +BIN = tcpl + +SRC = $(wildcard src/*.c) +SRC_OBJ = $(SRC:.c=.o) + +LIB_SRC = $(wildcard lib/*.c) +LIB_OBJ = $(LIB_SRC:.c=.o) + +all: $(BIN) + +$(BIN): $(SRC_OBJ) $(LIB_OBJ) + $(LD) $(LDFLAGS) -o $@ $(SRC_OBJ) $(LIB_OBJ) + +src/%.o: src/%.c + $(CC) $(CFLAGS) -I. -Iinclude -c $< -o $@ + +lib/%.o: lib/%.c + $(CC) $(CFLAGS) -I. -Iinclude -c $< -o $@ + +clean: + rm -f $(SRC_OBJ) $(LIB_OBJ) $(BIN) diff --git a/README b/README new file mode 100644 index 0000000..df2dbc0 --- /dev/null +++ b/README @@ -0,0 +1 @@ +Read me, Read me diff --git a/compile_commands.json b/compile_commands.json new file mode 100644 index 0000000..38bc3e8 --- /dev/null +++ b/compile_commands.json @@ -0,0 +1,36 @@ +[ + { + "arguments": [ + "/usr/lib64/ccache/cc", + "-Wextra", + "-Wall", + "-Os", + "-I.", + "-Iinclude", + "-c", + "-o", + "src/main.o", + "src/main.c" + ], + "directory": "/home/owen/programming/tcpl", + "file": "/home/owen/programming/tcpl/src/main.c", + "output": "/home/owen/programming/tcpl/src/main.o" + }, + { + "arguments": [ + "/usr/lib64/ccache/cc", + "-Wextra", + "-Wall", + "-Os", + "-I.", + "-Iinclude", + "-c", + "-o", + "lib/print.o", + "lib/print.c" + ], + "directory": "/home/owen/programming/tcpl", + "file": "/home/owen/programming/tcpl/lib/print.c", + "output": "/home/owen/programming/tcpl/lib/print.o" + } +] diff --git a/doc/bugs b/doc/bugs new file mode 100644 index 0000000..ff177e3 --- /dev/null +++ b/doc/bugs @@ -0,0 +1,4 @@ +Known bugs in tcpl(21 April 2026) + + * Rare bug in x86_64 architecture prevents all users from + using this software. diff --git a/include/tcpl/tcpl.h b/include/tcpl/tcpl.h new file mode 100644 index 0000000..26a8b75 --- /dev/null +++ b/include/tcpl/tcpl.h @@ -0,0 +1,11 @@ +#ifndef TCPL_TCPL_H +#define TCPL_TCPL_H +/* + * This is a header file to be included into every source file that comprises + * this project. + * Do #include + */ + +#include + +#endif diff --git a/lib/print.c b/lib/print.c new file mode 100644 index 0000000..9d6bf32 --- /dev/null +++ b/lib/print.c @@ -0,0 +1,8 @@ +#include "print.h" +#include +#include + +int tcpl_print(char* s) +{ + return printf("%s: %s\n", arg0, s); +} diff --git a/lib/print.h b/lib/print.h new file mode 100644 index 0000000..3afb0b0 --- /dev/null +++ b/lib/print.h @@ -0,0 +1,9 @@ +#ifndef TCPL_PRINT_H +#define TCPL_PRINT_H +/* + * Define the print functions for this project + */ + +int tcpl_print(char* s); + +#endif diff --git a/make.conf b/make.conf new file mode 100644 index 0000000..7ba14cb --- /dev/null +++ b/make.conf @@ -0,0 +1,11 @@ +# tcpl version +VERSION = 0.1 + +# paths +PREFIX = /usr/local +MANPREFIX = $(PREFIX)/share/man + +CC = cc +LD = $(CC) +CFLAGS = -Wextra -Wall -Os +LDFLAGS = -s diff --git a/man/tcpl.1 b/man/tcpl.1 new file mode 100644 index 0000000..7888341 --- /dev/null +++ b/man/tcpl.1 @@ -0,0 +1,26 @@ +.TH "TCPL" 1 +.SH NAME +\fBtcpl\fR \- test c project layout. +.PP +.SH SYNOPSIS +tcpl [OPTION]... +.PP +.SH DESCRIPTION +`tcpl' greets you in various ways. +.PP +-n, --name=STRING + your name goes here +.PP +--help print this help, then exit +.PP +--version + print version number, then exit +.PP +.SH AUTHOR +Written by vxc +.PP +.SH COPYRIGHT +Copyright © 2026 vxc +This is free software; see the source for copying conditions. There is +NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. diff --git a/man/tcpl.md b/man/tcpl.md new file mode 100644 index 0000000..31a9159 --- /dev/null +++ b/man/tcpl.md @@ -0,0 +1,25 @@ +# NAME + tcpl - test c project layout. + +# SYNOPSIS + tcpl [OPTION]... + +# DESCRIPTION + `tcpl' greets you in various ways. + + -n, --name=STRING + your name goes here + + --help print this help, then exit + + --version + print version number, then exit + +# AUTHOR + Written by vxc + +# COPYRIGHT + Copyright © 2026 vxc + This is free software; see the source for copying conditions. There is + NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. diff --git a/package/tcpl-0.1.ebuild b/package/tcpl-0.1.ebuild new file mode 100644 index 0000000..c8f5179 --- /dev/null +++ b/package/tcpl-0.1.ebuild @@ -0,0 +1,16 @@ +EAPI = 8 + + DESCRIPTION = "Test C Project Layout" HOMEPAGE = + "https://fsdproject.org" SRC_URI = + "https://dl.fsdproject.org/tcpl-${PV}.tar.gz" + + LICENSE = "BSD" SLOT = "0" KEYWORDS = "~amd64" IUSE = "" + + DEPEND = "" RDEPEND = "${DEPEND}" BDEPEND = "" + + src_compile(){emake} + +src_install() +{ + dobin tcpl dodoc README +} diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..65f1a2e --- /dev/null +++ b/src/main.c @@ -0,0 +1,11 @@ +#include +#include + +extern char* arg0; + +int main(int argc, char** argv) +{ + arg0 = basename(argv[0]); + tcpl_print("Hello, World!"); + return 0; +} diff --git a/src/main.o b/src/main.o new file mode 100644 index 0000000000000000000000000000000000000000..ea1c757ad1bb05186cb75ff2404de7ca40217fd6 GIT binary patch literal 1720 zcmb_c&ubG=5S~q{tx{twB0@#BCtGNr*%TEN%1Y7ZAf*(fAVS}g6G6m*mznRIpZj(;r_WwIFE|bvacGOi$go5|3uD{Y zrcc+YM71!A;&t~RPNUWe?bY6IeS`NierjizpfuqPUwxsS?d`|z>dx-VHP?Hfs>*Y# zmFmNaSKV}1_rsQ33o>zRJX%94(HtL_4=QmY704NaGc!6le3N|;=VYIpLD^YeoL~6B z!Qk&`57Axdr={}i(tsS-kGe+%-Ps$xw|j<1BvV z4?J~)!=7qtMfLh1Y1bP;KkNnFkb<;bp{$ui^&~y)WxBq8BW&RgVgEWG$yMzog0@~Y z-4Gt!Wj-eUmhh-EZ}G11h%bt*mFgdNv!Fq$pQR(+F;*51GE%J|3rIEkeNt%*fJjey z48tf;2x2Bkv!jGmGwyanek9e4vrzG3Y_O~OPH?+-q>?mF!ZbUU^srNZo8nUblPq%` z>DntQ_i;hQ%74L_^5ZY>Ww p)L`^Kg+BTGE6nA04=F>*$9~x&^aX|gm09^6ng8q}a%AN5e*;>|g#7>j literal 0 HcmV?d00001 diff --git a/tools/md2man b/tools/md2man new file mode 100755 index 0000000..3c8950b --- /dev/null +++ b/tools/md2man @@ -0,0 +1,78 @@ +#!/bin/sh + +set -eu + +VERSION="v0.1" + +file=$1 +[ -f "$file" ] || exit 1 + +name=$(basename "$file" .md) + +awk -v name="$name" ' +BEGIN { + print ".TH \"" toupper(name) "\" 1" + in_name = 0 +} + +function esc(s) { + gsub(/\\/, "\\\\", s) + gsub(/^\./, "\\&.", s) + return s +} + +function fmt(s) { + while (match(s, /`[^`]+`/)) { + pre = substr(s, 1, RSTART-1) + mid = substr(s, RSTART+1, RLENGTH-2) + post = substr(s, RSTART+RLENGTH) + s = pre "\\fB" mid "\\fR" post + } + return esc(s) +} + +{ + sub(/\r$/, "") + + if ($0 ~ /^# /) { + section = substr($0, 3) + + if (toupper(section) == "NAME") { + print ".SH NAME" + in_name = 1 + } else { + print ".SH " toupper(esc(section)) + in_name = 0 + } + next + } + + if ($0 ~ /^$/) { + print ".PP" + next + } + + if (in_name) { + split($0, a, " - ") + if (length(a) > 1) { + print "\\fB" esc(a[1]) "\\fR \\- " esc(a[2]) + } else { + print "\\fB" esc($0) "\\fR" + } + next + } + + if ($0 ~ /^- /) { + sub(/^- /, "") + split($0, a, " ") + print ".TP" + print "\\fB" esc(a[1]) "\\fR" + if (length(a) > 1) { + print fmt(substr($0, length(a[1]) + 3)) + } + next + } + + print fmt($0) +} +' "$file"