diff options
-rw-r--r-- | .gitignore | 164 | ||||
-rw-r--r-- | COPYING | 2 | ||||
-rw-r--r-- | COPYING.3BSD | 4 | ||||
-rw-r--r-- | COPYING.GPLv3 | 4 | ||||
-rw-r--r-- | Makefile | 75 | ||||
-rw-r--r-- | basename.1 (renamed from man/basename.1) | 0 | ||||
-rw-r--r-- | basename.c (renamed from core/basename.c) | 8 | ||||
-rw-r--r-- | box-templates/box_1-23.c | 11 | ||||
-rw-r--r-- | box-templates/box_1.c | 4 | ||||
-rw-r--r-- | box-templates/box_2.c (renamed from box-templates/box_45-49.c) | 2 | ||||
-rw-r--r-- | box-templates/box_3.c (renamed from box-templates/box_70-73.c) | 5 | ||||
-rw-r--r-- | box-templates/box_4.c (renamed from box-templates/box_94-96.c) | 2 | ||||
-rw-r--r-- | box.c | 126 | ||||
-rw-r--r-- | cat.1 (renamed from man/cat.1) | 0 | ||||
-rw-r--r-- | cat.c (renamed from core/cat.c) | 12 | ||||
-rw-r--r-- | chmod.c (renamed from core/chmod.c) | 12 | ||||
-rw-r--r-- | chown.c (renamed from core/chown.c) | 12 | ||||
-rw-r--r-- | cmp.1 (renamed from man/cmp.1) | 0 | ||||
-rw-r--r-- | cmp.c (renamed from core/cmp.c) | 6 | ||||
-rw-r--r-- | common.c (renamed from common/common.c) | 0 | ||||
-rw-r--r-- | common.h (renamed from common/common.h) | 0 | ||||
-rw-r--r-- | common.mk | 24 | ||||
-rw-r--r-- | config.mk | 15 | ||||
-rw-r--r-- | core/Makefile | 18 | ||||
l--------- | core/[.c | 1 | ||||
-rw-r--r-- | date.c (renamed from core/date.c) | 6 | ||||
-rw-r--r-- | dirname.1 (renamed from man/dirname.1) | 0 | ||||
-rw-r--r-- | dirname.c (renamed from core/dirname.c) | 10 | ||||
-rw-r--r-- | echo.1 (renamed from man/echo.1) | 0 | ||||
-rw-r--r-- | echo.c (renamed from core/echo.c) | 8 | ||||
-rw-r--r-- | ed.c (renamed from core/ed.c) | 10 | ||||
-rw-r--r-- | errno.c (renamed from extras/errno.c) | 8 | ||||
-rw-r--r-- | extras/Makefile | 18 | ||||
-rw-r--r-- | false.1 (renamed from man/false.1) | 0 | ||||
-rw-r--r-- | false.c (renamed from core/false.c) | 6 | ||||
-rw-r--r-- | head.c (renamed from core/head.c) | 12 | ||||
-rw-r--r-- | link.c (renamed from core/link.c) | 12 | ||||
-rw-r--r-- | ln.c (renamed from core/ln.c) | 12 | ||||
-rw-r--r-- | ls.c (renamed from core/ls.c) | 10 | ||||
-rw-r--r-- | mkdir.c (renamed from core/mkdir.c) | 12 | ||||
-rw-r--r-- | more.c (renamed from core/more.c) | 12 | ||||
-rw-r--r-- | mv.c (renamed from core/mv.c) | 12 | ||||
-rw-r--r-- | printf.c (renamed from core/printf.c) | 12 | ||||
-rw-r--r-- | rm.c (renamed from core/rm.c) | 12 | ||||
-rw-r--r-- | sleep.1 (renamed from man/sleep.1) | 0 | ||||
-rw-r--r-- | sleep.c (renamed from core/sleep.c) | 10 | ||||
-rw-r--r-- | tail.c (renamed from core/tail.c) | 12 | ||||
-rw-r--r-- | tee.1 (renamed from man/tee.1) | 0 | ||||
-rw-r--r-- | tee.c (renamed from core/tee.c) | 6 | ||||
-rw-r--r-- | test.c (renamed from core/test.c) | 4 | ||||
-rw-r--r-- | touch.c (renamed from core/touch.c) | 6 | ||||
-rw-r--r-- | tput.c (renamed from core/tput.c) | 6 | ||||
-rw-r--r-- | true.1 (renamed from man/true.1) | 0 | ||||
-rw-r--r-- | true.c (renamed from core/true.c) | 6 | ||||
-rw-r--r-- | tty.1 (renamed from man/tty.1) | 0 | ||||
-rw-r--r-- | tty.c (renamed from core/tty.c) | 8 | ||||
-rw-r--r-- | uname.1 (renamed from man/uname.1) | 0 | ||||
-rw-r--r-- | uname.c (renamed from core/uname.c) | 12 | ||||
-rw-r--r-- | unlink.1 (renamed from man/unlink.1) | 0 | ||||
-rw-r--r-- | unlink.c (renamed from core/unlink.c) | 12 | ||||
-rw-r--r-- | wc.c (renamed from core/wc.c) | 12 | ||||
-rw-r--r-- | yes.c (renamed from extras/yes.c) | 4 |
62 files changed, 252 insertions, 525 deletions
@@ -1,166 +1,4 @@ *.o box -core/admin -core/alias -core/ar -core/asa -core/at -core/awk -core/basename -core/batch -core/bc -core/bg -core/c99 -core/cal -core/cat -core/cd -core/cflow -core/chgrp -core/chmod -core/chown -core/cksum -core/cmp -core/comm -core/command -core/compress -core/cp -core/crontab -core/csplit -core/ctags -core/cut -core/cxref -core/date -core/dd -core/delta -core/df -core/diff -core/dirname -core/du -core/echo -core/ed -core/env -core/ex -core/expand -core/expr -core/false -core/fc -core/fg -core/file -core/find -core/fold -core/fort77 -core/fuser -core/gencat -core/get -core/getconf -core/getopts -core/grep -core/hash -core/head -core/iconv -core/id -core/ipcrm -core/ipcs -core/jobs -core/join -core/kill -core/lex -core/link -core/ln -core/locale -core/localedef -core/logger -core/logname -core/lp -core/ls -core/m4 -core/mailx -core/make -core/man -core/mesg -core/mkdir -core/mkfifo -core/more -core/mv -core/newgrp -core/nice -core/nl -core/nm -core/nohup -core/od -core/paste -core/patch -core/pathchk -core/pax -core/pr -core/printf -core/prs -core/ps -core/pwd -core/qalter -core/qdel -core/qhold -core/qmove -core/qmsg -core/qrerun -core/qrls -core/qselect -core/qsig -core/qstat -core/qsub -core/read -core/renice -core/rm -core/rmdel -core/rmdir -core/sact -core/sccs -core/sed -core/sh -core/sleep -core/sort -core/split -core/strings -core/strip -core/stty -core/tabs -core/tail -core/talk -core/tee -core/test -core/time -core/touch -core/tput -core/tr -core/true -core/tsort -core/tty -core/type -core/ulimit -core/umask -core/unalias -core/uname -core/uncompress -core/unexpand -core/unget -core/uniq -core/unlink -core/uucp -core/uudecode -core/uuencode -core/uustat -core/uux -core/val -core/vi -core/wait -core/wc -core/what -core/who -core/write -core/xargs -core/yacc -core/zcat -box_tmp/* +box.c sh/sh -extras/yes -extras/errno @@ -4,7 +4,7 @@ The fases project is primarily licensed under the following two (2) licenses: 2. The GNU General Public License, version 3 or any later version (COPYING.GPLv3) The 2-Clause BSD License applies to most "core" utilities, while the GNU -General Public License applies to most "extended" utilities. Please check the +General Public License applies to most "extra" utilities. Please check the headers of each source file for an SPDX-License-Identifier. Additionally, the documentation is licensed under the FreeBSD documentation diff --git a/COPYING.3BSD b/COPYING.3BSD index 8e29a03..1fbed7a 100644 --- a/COPYING.3BSD +++ b/COPYING.3BSD @@ -1,6 +1,6 @@ # This license applies to all POSIX utilities fases provides, -# unless stated otherwise. This includes fases sh and fases core -# (core/). +# unless stated otherwise. This includes fases sh and core POSIX +# utilities. Copyright (C) 2022, 2023 Ferass EL HAFIDI Copyright (C) 2022 Leah Rowe diff --git a/COPYING.GPLv3 b/COPYING.GPLv3 index 6d74799..763ca77 100644 --- a/COPYING.GPLv3 +++ b/COPYING.GPLv3 @@ -1,8 +1,8 @@ # This license applies to all non-POSIX utilities fases provides, -# unless stated otherwise. This includes fases box and fases extra -# (extra/). +# unless stated otherwise. This includes fases box and fases extra . # This license is copyrighted by the FSF, but the code is actually # copyrighted by Ferass and other people. + GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 @@ -5,69 +5,28 @@ # Copyright (C) 2022 Leah Rowe <leah@libreboot.org> .POSIX: +.SUFFIXES: .o .c -# Commands -# ======== - -all: config clean prepbox genbox box include ./config.mk -config: - @echo "VERSION = $(VERSION)" - @echo "CFLAGS = $(CFLAGS)" - @echo "CC = $(CC)" - @echo "DESTDIR = $(DESTDIR)" - @echo "PREFIX = $(PREFIX)" - @echo "INCLUDE_EXTRA = $(INCLUDE_EXTRA)" +all: box +OBJ=$(BINS:=.o) -genbox: - cat "box-templates/box_1-23.c" > box.c - test ${INCLUDE_CORE} == n || for u in ${CORE}; do echo "int $${u%.c}_main(int, char**);" | sed "s/\[_/test_/g"; done>> box.c - test ${INCLUDE_EXTRA} == n || for u in ${EXTRA}; do echo "int $${u%.c}_main(int, char**);"; done>> box.c - cat "box-templates/box_45-49.c" >> box.c - test ${INCLUDE_CORE} == n || for u in ${CORE}; do echo " else if(!strcmp(basename(argv[0]), \"$${u%.c}\")) return $${u%.c}_main(argc, argv);" | sed "s/\[_/test_/g"; done >> box.c - test ${INCLUDE_EXTRA} == n || for u in ${EXTRA}; do echo " else if(!strcmp(argv[0], \"$${u%.c}\")) return $${u%.c}_main(argc, argv);"; done >> box.c - cat "box-templates/box_70-73.c" >> box.c - test ${INCLUDE_CORE} == n || for u in ${CORE}; do echo " printf(\"$${u%.c} \");"; done >> box.c - test ${INCLUDE_EXTRA} == n || for u in ${EXTRA}; do echo " printf(\"$${u%.c} \");"; done >> box.c - test ${INCLUDE_CORE} == n && test ${INCLUDE_EXTRA} == n && echo " printf(\"¯\\\\_(ツ)_/¯ No commands found.\");" >> box.c || true - cat "box-templates/box_94-96.c" >> box.c - echo "/* Generated on $$(date) */" >> box.c +box.c: box-templates/box_1.c box-templates/box_2.c box-templates/box_3.c box-templates/box_4.c $(BINS:=.c) + for u in ${BINS}; do printf '#define FASESBOX_INCLUDES_%s 1\n' "$${u}"; done > box.c + cat "box-templates/box_1.c" >> box.c + for u in ${BINS}; do printf 'int %s_main(int, char**);\n' "$${u}"; done >> box.c + cat "box-templates/box_2.c" >> box.c + for u in ${BINS}; do printf '\telse if (!strcmp(basename(argv[0]), "%s")) return %s_main(argc, argv);\n' "$${u}" "$${u}" ; done >> box.c + cat "box-templates/box_3.c" >> box.c + for u in ${BINS}; do printf '\t\tprintf("%s");\n' "$${u}" ; done >> box.c + cat "box-templates/box_4.c" >> box.c -prepbox: - mkdir -p box_tmp - test ${INCLUDE_CORE} == n || for f in ${CORE}; do (sed "s/^int main(/int $$(echo "$$f")_main(/" < "core/"$$f".c" | sed "s/\"..\/common/\"common/g" | sed "s/\[_/test_/g") > "box_tmp/"$$f"_box.c"; done - rm -f "box_tmp/[_box.c" - test ${INCLUDE_EXTRA} == n || for f in ${EXTRA}; do sed "s/^int main(/int $$(echo "$$f")_main(/" < "extras/"$$f".c" | sed "s/printUsage()/$$(echo "$$f")_printUsage()/g" > "box_tmp/"$$f"_box.c"; done +box: box.c $(OBJ) + $(CC) $(CFLAGS) $(BOXFLAGS) box.c $(BINS:=.o) common.c -o $@ -box: box.o - test ${INCLUDE_CORE} = n && test ${INCLUDE_EXTRA} = n && $(CC) $(CFLAGS) common/common.c box.o -o box || $(CC) $(CFLAGS) box_tmp/*.c common/common.c box.o -o box - rm -f version.h +.c.o: + $(CC) $(CFLAGS) $(BOXFLAGS) $< -c -o $@ clean: - rm -f box *.o - rm -Rf box_tmp - for f in $(CORE); do rm -f core/$$f; done - for f in $(EXTRA); do rm -f extras/$$f; done - -install: - mkdir -p $(DESTDIR)$(PREFIX)/bin - cp -r core/bin/* $(DESTDIR)$(PREFIX)/bin - -install-box: - mkdir -p $(DESTDIR)$(PREFIX)/bin - cp -r box $(DESTDIR)$(PREFIX)/bin - -links: - for u in ${CORE}; do ln -s "$(DESTDIR)$(PREFIX)/bin/box" "$(DESTDIR)$(PREFIX)/bin/$$u"; done - -remove: - rm -f $(DESTDIR)$(PREFIX)/bin/box - for u in ${CORE}; do rm -f "$(DESTDIR)$(PREFIX)/bin/$$u"; done - - -# Utilities -# ========= - -box.o: prepbox - $(CC) $(CFLAGS) -c box.c -o box.o + $(RM) box $(OBJ) diff --git a/man/basename.1 b/basename.1 index 75cdb87..75cdb87 100644 --- a/man/basename.1 +++ b/basename.1 diff --git a/core/basename.c b/basename.c index dc7e3b7..4606942 100644 --- a/core/basename.c +++ b/basename.c @@ -8,12 +8,16 @@ #include <string.h> #include <libgen.h> -#define REQ_PRINT_USAGE /* print_usage() from ../common/common.h */ +#define REQ_PRINT_USAGE /* print_usage() from common.h */ #define DESCRIPTION "Return non-directory portion of <string>." #define OPERANDS "string [suffix]" -#include "../common/common.h" +#include "common.h" +#ifdef FASESBOX +int basename_main(int argc, char *argv[]) { +#else int main(int argc, char *argv[]) { +#endif int status = 0; long unsigned int i; char *basenamestr; diff --git a/box-templates/box_1-23.c b/box-templates/box_1-23.c deleted file mode 100644 index 0331ed6..0000000 --- a/box-templates/box_1-23.c +++ /dev/null @@ -1,11 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ -/* - * Copyright (C) 2022, 2023 Ferass El Hafidi <vitali64pmemail@protonmail.com> - */ -/* START */ - -#include <string.h> -#include <unistd.h> -#include <libgen.h> -#include <stdio.h> -/* END */ diff --git a/box-templates/box_1.c b/box-templates/box_1.c new file mode 100644 index 0000000..bf3b4ed --- /dev/null +++ b/box-templates/box_1.c @@ -0,0 +1,4 @@ +#include <string.h> +#include <unistd.h> +#include <libgen.h> +#include <stdio.h> diff --git a/box-templates/box_45-49.c b/box-templates/box_2.c index 42bd0e4..56886d8 100644 --- a/box-templates/box_45-49.c +++ b/box-templates/box_2.c @@ -1,7 +1,5 @@ -/* START */ int main(int argc, char *argv[]) { if (!strcmp(basename(argv[0]),"box") && argc > 1) { argc--; argv++; } if(0); -/* END */ diff --git a/box-templates/box_70-73.c b/box-templates/box_3.c index 3124fa3..c32f473 100644 --- a/box-templates/box_70-73.c +++ b/box-templates/box_3.c @@ -1,5 +1,6 @@ -/* START */ +#ifdef FASESBOX_INCLUDES_test + else if (!strcmp(basename(argv[0]), "[")) return test_main(argc, argv); +#endif else if (!strcmp(basename(argv[0]), "box") && argc == 1) { printf("fases box.\n"); printf("Usage: box command [args] ...\n"); -/* END */ diff --git a/box-templates/box_94-96.c b/box-templates/box_4.c index ac381af..892de34 100644 --- a/box-templates/box_94-96.c +++ b/box-templates/box_4.c @@ -1,4 +1,3 @@ -/* START */ printf("\n"); } else { @@ -6,4 +5,3 @@ } return 0; } -/* END */ @@ -1,126 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ -/* - * Copyright (C) 2022, 2023 Ferass El Hafidi <vitali64pmemail@protonmail.com> - */ -/* START */ - -#include <string.h> -#include <unistd.h> -#include <libgen.h> -#include <stdio.h> -/* END */ -int test_main(int, char**); -int basename_main(int, char**); -int cat_main(int, char**); -int chmod_main(int, char**); -int chown_main(int, char**); -int cmp_main(int, char**); -int date_main(int, char**); -int dirname_main(int, char**); -int echo_main(int, char**); -int ed_main(int, char**); -int false_main(int, char**); -int head_main(int, char**); -int link_main(int, char**); -int ln_main(int, char**); -int ls_main(int, char**); -int mkdir_main(int, char**); -int more_main(int, char**); -int mv_main(int, char**); -int printf_main(int, char**); -int rm_main(int, char**); -int sleep_main(int, char**); -int tail_main(int, char**); -int tee_main(int, char**); -int test_main(int, char**); -int touch_main(int, char**); -int tput_main(int, char**); -int true_main(int, char**); -int tty_main(int, char**); -int uname_main(int, char**); -int unlink_main(int, char**); -int wc_main(int, char**); -/* START */ -int main(int argc, char *argv[]) { - if (!strcmp(basename(argv[0]),"box") && argc > 1) { - argc--; - argv++; - } if(0); -/* END */ - else if(!strcmp(basename(argv[0]), "[")) return test_main(argc, argv); - else if(!strcmp(basename(argv[0]), "basename")) return basename_main(argc, argv); - else if(!strcmp(basename(argv[0]), "cat")) return cat_main(argc, argv); - else if(!strcmp(basename(argv[0]), "chmod")) return chmod_main(argc, argv); - else if(!strcmp(basename(argv[0]), "chown")) return chown_main(argc, argv); - else if(!strcmp(basename(argv[0]), "cmp")) return cmp_main(argc, argv); - else if(!strcmp(basename(argv[0]), "date")) return date_main(argc, argv); - else if(!strcmp(basename(argv[0]), "dirname")) return dirname_main(argc, argv); - else if(!strcmp(basename(argv[0]), "echo")) return echo_main(argc, argv); - else if(!strcmp(basename(argv[0]), "ed")) return ed_main(argc, argv); - else if(!strcmp(basename(argv[0]), "false")) return false_main(argc, argv); - else if(!strcmp(basename(argv[0]), "head")) return head_main(argc, argv); - else if(!strcmp(basename(argv[0]), "link")) return link_main(argc, argv); - else if(!strcmp(basename(argv[0]), "ln")) return ln_main(argc, argv); - else if(!strcmp(basename(argv[0]), "ls")) return ls_main(argc, argv); - else if(!strcmp(basename(argv[0]), "mkdir")) return mkdir_main(argc, argv); - else if(!strcmp(basename(argv[0]), "more")) return more_main(argc, argv); - else if(!strcmp(basename(argv[0]), "mv")) return mv_main(argc, argv); - else if(!strcmp(basename(argv[0]), "printf")) return printf_main(argc, argv); - else if(!strcmp(basename(argv[0]), "rm")) return rm_main(argc, argv); - else if(!strcmp(basename(argv[0]), "sleep")) return sleep_main(argc, argv); - else if(!strcmp(basename(argv[0]), "tail")) return tail_main(argc, argv); - else if(!strcmp(basename(argv[0]), "tee")) return tee_main(argc, argv); - else if(!strcmp(basename(argv[0]), "test")) return test_main(argc, argv); - else if(!strcmp(basename(argv[0]), "touch")) return touch_main(argc, argv); - else if(!strcmp(basename(argv[0]), "tput")) return tput_main(argc, argv); - else if(!strcmp(basename(argv[0]), "true")) return true_main(argc, argv); - else if(!strcmp(basename(argv[0]), "tty")) return tty_main(argc, argv); - else if(!strcmp(basename(argv[0]), "uname")) return uname_main(argc, argv); - else if(!strcmp(basename(argv[0]), "unlink")) return unlink_main(argc, argv); - else if(!strcmp(basename(argv[0]), "wc")) return wc_main(argc, argv); -/* START */ - else if (!strcmp(basename(argv[0]), "box") && argc == 1) { - printf("fases box.\n"); - printf("Usage: box command [args] ...\n"); -/* END */ - printf("[ "); - printf("basename "); - printf("cat "); - printf("chmod "); - printf("chown "); - printf("cmp "); - printf("date "); - printf("dirname "); - printf("echo "); - printf("ed "); - printf("false "); - printf("head "); - printf("link "); - printf("ln "); - printf("ls "); - printf("mkdir "); - printf("more "); - printf("mv "); - printf("printf "); - printf("rm "); - printf("sleep "); - printf("tail "); - printf("tee "); - printf("test "); - printf("touch "); - printf("tput "); - printf("true "); - printf("tty "); - printf("uname "); - printf("unlink "); - printf("wc "); -/* START */ - printf("\n"); - } - else { - printf("box: %s: Not found or not implemented.\n", argv[0]); - } - return 0; -} -/* END */ -/* Generated on Sat Jul 27 01:23:37 PM CST 2024 */ @@ -9,16 +9,20 @@ #include <errno.h> #include <string.h> -#define REQ_PRINT_USAGE /* Require print_usage() from ../common/common.h */ -#define REQ_ERRPRINT /* Require errprint() from ../common/common.h */ +#define REQ_PRINT_USAGE /* Require print_usage() from common.h */ +#define REQ_ERRPRINT /* Require errprint() from common.h */ #define DESCRIPTION "Concatenate a file to standard output. \ If no file is specified or file is '-', read standard input." #define OPERANDS "[-u] [file] ..." -#include "../common/common.h" +#include "common.h" int cat(int flides, int unbuffered); -int main(int argc, char *const argv[]) { +#ifdef FASESBOX +int cat_main(int argc, char *argv[]) { +#else +int main(int argc, char *argv[]) { +#endif int file, argument, i = 1, unbuffered, err; char *argv0 = strdup(argv[0]); while ((argument = getopt(argc, argv, "u")) != -1) { @@ -9,13 +9,17 @@ #include <string.h> #include <errno.h> -#define REQ_PRINT_USAGE /* Require print_usage() from ../common/common.h */ -#define REQ_ERRPRINT /* Require errprint() from ../common/common.h */ +#define REQ_PRINT_USAGE /* Require print_usage() from common.h */ +#define REQ_ERRPRINT /* Require errprint() from common.h */ #define DESCRIPTION "Change file modes." #define OPERANDS "mode file" -#include "../common/common.h" +#include "common.h" -int main(int argc, char *const argv[]) { +#ifdef FASESBOX +int chmod_main(int argc, char *argv[]) { +#else +int main(int argc, char *argv[]) { +#endif int argument, i = 0; mode_t owner_modes, group_modes, other_modes; char *argv0 = strdup(argv[0]); @@ -9,13 +9,17 @@ #include <stdlib.h> #include <string.h> -#define REQ_PRINT_USAGE /* Require print_usage() from ../common/common.h */ -#define REQ_ERRPRINT /* Require errprint() from ../common/common.h */ +#define REQ_PRINT_USAGE /* Require print_usage() from common.h */ +#define REQ_ERRPRINT /* Require errprint() from common.h */ #define DESCRIPTION "Change file ownership." #define OPERANDS "owner file" -#include "../common/common.h" +#include "common.h" -int main(int argc, char *const argv[]) { +#ifdef FASESBOX +int chown_main(int argc, char *argv[]) { +#else +int main(int argc, char *argv[]) { +#endif struct passwd *user; if (argc == 1) { print_usage(argv[0], DESCRIPTION, OPERANDS, VERSION); @@ -10,12 +10,16 @@ /* Requirements in common.h */ #define REQ_PRINT_USAGE #define REQ_ERRPRINT -#include "../common/common.h" +#include "common.h" #define DESCRIPTION "Compare two files." #define OPERANDS "[-l|-s] file1 file2" +#ifdef FASESBOX +int cmp_main(int argc, char *argv[]) { +#else int main(int argc, char *argv[]) { +#endif FILE *file1, *file2; int argument, char_pos = 1, line_pos = 1, param_l, param_s, differ; char *argv0 = strdup(argv[0]); diff --git a/common/common.c b/common.c index 08328ab..08328ab 100644 --- a/common/common.c +++ b/common.c diff --git a/common/common.h b/common.h index c9e6412..c9e6412 100644 --- a/common/common.h +++ b/common.h diff --git a/common.mk b/common.mk deleted file mode 100644 index ca4f661..0000000 --- a/common.mk +++ /dev/null @@ -1,24 +0,0 @@ -# SPDX-License-Identifier: GPL-3.0-or-later -# -# Copyright (C) 2022, 2023 Ferass El Hafidi <vitali64pmemail@protonmail.com> -# Copyright (C) 2022 Leah Rowe <leah@libreboot.org> - -$(OBJ): config - -config: - @echo "VERSION = $(VERSION)" - @echo "CFLAGS = $(CFLAGS)" - @echo "CC = $(CC)" - @echo "DESTDIR = $(DESTDIR)" - @echo "PREFIX = $(PREFIX)" - @echo "INCLUDE_EXTRA = $(INCLUDE_EXTRA)" - -.o: - [ ! -e $< ] || $(CC) $(CFLAGS) $< ../common/common.c -o $@ - -.c.o: - [ ! -e $< ] || $(CC) $(CFLAGS) -c $< -o $@ - -# Cleaning -clean: - rm -f *.o version.h $(CORE) @@ -6,10 +6,13 @@ VERSION="fases v0.1r"$$(git rev-list --count HEAD)"."$$(git rev-parse --short HEAD)"" CC=cc -CFLAGS=-D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION)\" -I. -Wall -Werror -Wextra -g -pedantic -std=c99 +CFLAGS=-D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION)\" -I. -Wall -Werror -Wextra -g -pedantic -Wno-unused-parameter -std=c99 +BOXFLAGS=-DFASESBOX -CORE=\ - [\ +# Which programs do you want to build? This affects both the standalone +# programs produced if you run `make standalone', and the programs put +# into the multi-call binary if you run `make box' or simply `make'. +BINS=\ basename\ cat\ chmod\ @@ -39,13 +42,9 @@ CORE=\ tty\ uname\ unlink\ - wc -EXTRA=\ + wc\ errno\ yes -INCLUDE_EXTRA=n -INCLUDE_CORE=y - DESTDIR= PREFIX=/usr/local diff --git a/core/Makefile b/core/Makefile deleted file mode 100644 index d36a095..0000000 --- a/core/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -# SPDX-License-Identifier: GPL-3.0-or-later -# -# Copyright (C) 2022, 2023 Ferass El Hafidi <vitali64pmemail@protonmail.com> -# Copyright (C) 2022 Leah Rowe <leah@libreboot.org> - -# Special -.POSIX: -.SUFFIXES: .o .c - -# config.mk -include ../config.mk - -# Utilities -OBJ=$(CORE:=.o) -all: clean $(CORE) -$(CORE): $(@:=.o) - -include ../common.mk diff --git a/core/[.c b/core/[.c deleted file mode 120000 index aeebb26..0000000 --- a/core/[.c +++ /dev/null @@ -1 +0,0 @@ -test.c
\ No newline at end of file @@ -8,9 +8,13 @@ #include <errno.h> #define REQ_ERRPRINT -#include "../common/common.h" +#include "common.h" +#ifdef FASESBOX +int date_main(int argc, char *argv[]) { +#else int main(int argc, char *argv[]) { +#endif time_t epoch = time(NULL); struct tm* date = localtime(&epoch); char date_s[31]; diff --git a/man/dirname.1 b/dirname.1 index 8b391da..8b391da 100644 --- a/man/dirname.1 +++ b/dirname.1 diff --git a/core/dirname.c b/dirname.c index d8cf7c4..bba867c 100644 --- a/core/dirname.c +++ b/dirname.c @@ -9,13 +9,17 @@ #include <libgen.h> #include <errno.h> -#define REQ_PRINT_USAGE /* Require print_usage() from ../common/common.h */ -#define REQ_ERRPRINT /* Require errprint() from ../common/common.h */ +#define REQ_PRINT_USAGE /* Require print_usage() from common.h */ +#define REQ_ERRPRINT /* Require errprint() from common.h */ #define DESCRIPTION "Return directory portion of <string>." #define OPERANDS "string" -#include "../common/common.h" +#include "common.h" +#ifdef FASESBOX +int dirname_main(int argc, char *argv[]) { +#else int main(int argc, char *argv[]) { +#endif char *dirnamestr; if (argc != 2) { @@ -7,9 +7,13 @@ #include <errno.h> #define REQ_ERRPRINT -#include "../common/common.h" +#include "common.h" -int main(int argc, char *const argv[]) { +#ifdef FASESBOX +int echo_main(int argc, char *argv[]) { +#else +int main(int argc, char *argv[]) { +#endif int i = 1; for (i = 1; i != argc; i++) { @@ -9,16 +9,20 @@ #include <signal.h> #include <string.h> -#define REQ_PRINT_USAGE /* Require print_usage() from ../common/common.h */ -#define REQ_ERRPRINT /* Require errprint() from ../common/common.h */ +#define REQ_PRINT_USAGE /* Require print_usage() from common.h */ +#define REQ_ERRPRINT /* Require errprint() from common.h */ #define DESCRIPTION "Edit text." #define OPERANDS "[-p prompt]" -#include "../common/common.h" +#include "common.h" void print_error(const char *error, int help_mode); size_t c_append(char buffer[4096]); +#ifdef FASESBOX +int ed_main(int argc, char *argv[]) { +#else int main(int argc, char *argv[]) { +#endif int argument, i = 0, fildes = -1; char buffer[4096], *edit_pathname, *prompt_string = "", command_string[4096], *error = "", *argv0 = strdup(argv[0]); @@ -7,12 +7,16 @@ #include <stdio.h> #include <stdlib.h> -#define REQ_PRINT_USAGE /* Require print_usage() from ../common/common.h */ +#define REQ_PRINT_USAGE /* Require print_usage() from common.h */ #define DESCRIPTION "Give information about error codes." #define OPERANDS "code" -#include "../common/common.h" +#include "common.h" +#ifdef FASESBOX +int errno_main(int argc, char *argv[]) { +#else int main(int argc, char *argv[]) { +#endif long int error_code = 0; setvbuf(stdout, NULL, _IONBF, 0); if (argc == 2) { diff --git a/extras/Makefile b/extras/Makefile deleted file mode 100644 index 6348fe2..0000000 --- a/extras/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -# SPDX-License-Identifier: GPL-3.0-or-later -# -# Copyright (C) 2022, 2023 Ferass El Hafidi <vitali64pmemail@protonmail.com> -# Copyright (C) 2022 Leah Rowe <leah@libreboot.org> - -# Special -.POSIX: -.SUFFIXES: .o .c - -# config.mk -include ../config.mk - -# Utilities -OBJ=$(EXTRA:=.o) -all: clean $(EXTRA) -$(EXTRA): $(@:=.o) - -include ../common.mk @@ -2,6 +2,10 @@ /* * Copyright (C) 2022, 2023 Ferass El Hafidi <vitali64pmemail@protonmail.com> */ -int main() { +#ifdef FASESBOX +int false_main(int argc, char *argv[]) { +#else +int main(int argc, char *argv[]) { +#endif return 1; } @@ -10,13 +10,17 @@ #include <string.h> #include <stdlib.h> -#define REQ_PRINT_USAGE /* Require print_usage() from ../common/common.h */ -#define REQ_ERRPRINT /* Require errprint() from ../common/common.h */ +#define REQ_PRINT_USAGE /* Require print_usage() from common.h */ +#define REQ_ERRPRINT /* Require errprint() from common.h */ #define DESCRIPTION "Copy file to standard output until <number> lines." #define OPERANDS "[-n number] [file] ..." -#include "../common/common.h" +#include "common.h" -int main(int argc, char *const argv[]) { +#ifdef FASESBOX +int head_main(int argc, char *argv[]) { +#else +int main(int argc, char *argv[]) { +#endif int argument, i, lines = 10, lines_printed; FILE *file; char s[4096], *argv0 = strdup(argv[0]); @@ -6,13 +6,17 @@ #include <stdio.h> #include <errno.h> -#define REQ_PRINT_USAGE /* Require print_usage() from ../common/common.h */ -#define REQ_ERRPRINT /* Require errprint() from ../common/common.h */ +#define REQ_PRINT_USAGE /* Require print_usage() from common.h */ +#define REQ_ERRPRINT /* Require errprint() from common.h */ #define DESCRIPTION "Call the link() function." #define OPERANDS "source dest" -#include "../common/common.h" +#include "common.h" -int main(int argc, char *const argv[]) { +#ifdef FASESBOX +int link_main(int argc, char *argv[]) { +#else +int main(int argc, char *argv[]) { +#endif if (argc == 1) { print_usage(argv[0], DESCRIPTION, OPERANDS, VERSION); return 1; @@ -7,15 +7,19 @@ #include <errno.h> #include <string.h> -#define REQ_PRINT_USAGE /* Require print_usage() from ../common/common.h */ -#define REQ_ERRPRINT /* Require errprint() from ../common/common.h */ +#define REQ_PRINT_USAGE /* Require print_usage() from common.h */ +#define REQ_ERRPRINT /* Require errprint() from common.h */ #define DESCRIPTION "Link files." #define OPERANDS "[-fs] [-P|-L] source_file target_file" -#include "../common/common.h" +#include "common.h" int getopt(int argc, char *const argv[], const char *optstring); -int main(int argc, char *const argv[]) { +#ifdef FASESBOX +int ln_main(int argc, char *argv[]) { +#else +int main(int argc, char *argv[]) { +#endif int argument; char param[256], *buffer = NULL, *argv0 = strdup(argv[0]); @@ -17,19 +17,23 @@ #include <time.h> #include <sys/ioctl.h> -#define REQ_PRINT_USAGE /* Require print_usage() from ../common/common.h */ -#define REQ_ERRPRINT /* Require errprint() from ../common/common.h */ +#define REQ_PRINT_USAGE /* Require print_usage() from common.h */ +#define REQ_ERRPRINT /* Require errprint() from common.h */ #define DESCRIPTION "Print <directory>'s contents to standard output.\ If no directory is specified, print the current directory's contents." #define OPERANDS "[-1aACimlpgno] [directory]" -#include "../common/common.h" +#include "common.h" char *argv0; char param[256]; int ls(char *path); void printUsage(char *params); +#ifdef FASESBOX +int ls_main(int argc, char *argv[]) { +#else int main(int argc, char *argv[]) { +#endif int status = 0; int success = 0; int argument, i; @@ -8,13 +8,17 @@ #include <errno.h> #include <string.h> -#define REQ_PRINT_USAGE /* Require print_usage() from ../common/common.h */ -#define REQ_ERRPRINT /* Require errprint() from ../common/common.h */ +#define REQ_PRINT_USAGE /* Require print_usage() from common.h */ +#define REQ_ERRPRINT /* Require errprint() from common.h */ #define DESCRIPTION "Create directories." #define OPERANDS "directory ..." -#include "../common/common.h" +#include "common.h" -int main(int argc, char *const argv[]) { +#ifdef FASESBOX +int mkdir_main(int argc, char *argv[]) { +#else +int main(int argc, char *argv[]) { +#endif int success, argument, i = 0; char *argv0 = strdup(argv[0]); if (argc == 1) { @@ -10,13 +10,17 @@ #include <termios.h> #include <sys/ioctl.h> -#define REQ_PRINT_USAGE /* Require print_usage() from ../common/common.h */ -#define REQ_ERRPRINT /* Require errprint() from ../common/common.h */ +#define REQ_PRINT_USAGE /* Require print_usage() from common.h */ +#define REQ_ERRPRINT /* Require errprint() from common.h */ #define DESCRIPTION "Display files in a page-by-page basis." #define OPERANDS "file ..." -#include "../common/common.h" +#include "common.h" -int main(int argc, char *const argv[]) { +#ifdef FASESBOX +int more_main(int argc, char *argv[]) { +#else +int main(int argc, char *argv[]) { +#endif int i = 0, argument, success = 0, read_file = 1; long int /* columns, */ lines; char buffer[4096], cmd, *argv0 = strdup(argv[0]); @@ -8,13 +8,17 @@ #include <fcntl.h> #include <string.h> -#define REQ_PRINT_USAGE /* Require print_usage() from ../common/common.h */ -#define REQ_ERRPRINT /* Require errprint() from ../common/common.h */ +#define REQ_PRINT_USAGE /* Require print_usage() from common.h */ +#define REQ_ERRPRINT /* Require errprint() from common.h */ #define DESCRIPTION "Move files." #define OPERANDS "[-if] source dest" -#include "../common/common.h" +#include "common.h" -int main(int argc, char *const argv[]) { +#ifdef FASESBOX +int mv_main(int argc, char *argv[]) { +#else +int main(int argc, char *argv[]) { +#endif int argument, file; char cmd, param[256], *argv0 = strdup(argv[0]); setvbuf(stdout, NULL, _IONBF, 0); @@ -6,13 +6,17 @@ #include <stdio.h> #include <errno.h> -#define REQ_PRINT_USAGE /* Require print_usage() from ../common/common.h */ -#define REQ_ERRPRINT /* Require print_usage() from ../common/common.h */ +#define REQ_PRINT_USAGE /* Require print_usage() from common.h */ +#define REQ_ERRPRINT /* Require print_usage() from common.h */ #define DESCRIPTION "Write formatted strings to standard output." #define OPERANDS "format [string]" -#include "../common/common.h" +#include "common.h" -int main(int argc, char *const argv[]) { +#ifdef FASESBOX +int printf_main(int argc, char *argv[]) { +#else +int main(int argc, char *argv[]) { +#endif if (argc == 1) { print_usage(argv[0], DESCRIPTION, OPERANDS, VERSION); return 1; @@ -7,13 +7,17 @@ #include <errno.h> #include <string.h> -#define REQ_PRINT_USAGE /* Require print_usage() from ../common/common.h */ -#define REQ_ERRPRINT /* Require errprint() from ../common/common.h */ +#define REQ_PRINT_USAGE /* Require print_usage() from common.h */ +#define REQ_ERRPRINT /* Require errprint() from common.h */ #define DESCRIPTION "Remove files." #define OPERANDS "[-Rr] file ..." -#include "../common/common.h" +#include "common.h" -int main(int argc, char *const argv[]) { +#ifdef FASESBOX +int rm_main(int argc, char *argv[]) { +#else +int main(int argc, char *argv[]) { +#endif int argument, i = 0; char param[256], *argv0 = strdup(argv[0]); @@ -7,13 +7,17 @@ #include <unistd.h> #include <errno.h> -#define REQ_PRINT_USAGE /* Require print_usage() from ../common/common.h */ -#define REQ_ERRPRINT /* Require errprint() from ../common/common.h */ +#define REQ_PRINT_USAGE /* Require print_usage() from common.h */ +#define REQ_ERRPRINT /* Require errprint() from common.h */ #define DESCRIPTION "Suspend execution for an interval." #define OPERANDS "time" -#include "../common/common.h" +#include "common.h" +#ifdef FASESBOX +int sleep_main(int argc, char *argv[]) { +#else int main(int argc, char *argv[]) { +#endif long unsigned int seconds; if (argc == 2) { @@ -9,13 +9,17 @@ #include <string.h> #include <stdlib.h> -#define REQ_PRINT_USAGE /* Require print_usage() from ../common/common.h */ -#define REQ_ERRPRINT /* Require errprint() from ../common/common.h */ +#define REQ_PRINT_USAGE /* Require print_usage() from common.h */ +#define REQ_ERRPRINT /* Require errprint() from common.h */ #define DESCRIPTION "Copy the last part of files." #define OPERANDS "[-n number] [file] ..." -#include "../common/common.h" +#include "common.h" -int main(int argc, char *const argv[]) { +#ifdef FASESBOX +int tail_main(int argc, char *argv[]) { +#else +int main(int argc, char *argv[]) { +#endif int argument, i = 1, lines = 10, file_lines = 0; FILE *file = NULL; @@ -13,12 +13,16 @@ /* Requirements in common.h */ #define REQ_PRINT_USAGE #define REQ_ERRPRINT -#include "../common/common.h" +#include "common.h" #define DESCRIPTION "Duplicate standard input." #define OPERANDS "[-ai] [file...]" +#ifdef FASESBOX +int tee_main(int argc, char *argv[]) { +#else int main(int argc, char *argv[]) { +#endif int argument, length, i = 0, fildes[13], append_or_truncate = O_TRUNC; int ret = 0; /* Used for write errors. */ char *argv0 = strdup(argv[0]), buffer[4096]; @@ -15,7 +15,11 @@ int true = 0; int false = 1; +#ifdef FASESBOX +int test_main(int argc, char *argv[]) { +#else int main(int argc, char *argv[]) { +#endif char param[256]; struct stat file_status; @@ -16,12 +16,16 @@ /* Requirements in common.h */ #define REQ_PRINT_USAGE #define REQ_ERRPRINT -#include "../common/common.h" +#include "common.h" #define DESCRIPTION "Change file access and modification times." #define OPERANDS "[-acm] [-t [[CC]YY]MMDDhhmm[.SS]] file..." +#ifdef FASESBOX +int touch_main(int argc, char *argv[]) { +#else int main(int argc, char *argv[]) { +#endif int file, i, argument; struct timespec times[2]; struct tm time_tm = { 0 }; /* Used by strptime() */ @@ -10,12 +10,16 @@ /* Requirements in common.h */ #define REQ_PRINT_USAGE #define REQ_ERRPRINT -#include "../common/common.h" +#include "common.h" #define DESCRIPTION "Change terminal characteristics." #define OPERANDS "init|clear|reset" +#ifdef FASESBOX +int tput_main(int argc, char *argv[]) { +#else int main(int argc, char *argv[]) { +#endif int argument; char *argv0 = strdup(argv[0]); if (argc < 2) @@ -2,6 +2,10 @@ /* * Copyright (C) 2022, 2023 Ferass El Hafidi <vitali64pmemail@protonmail.com> */ -int main() { +#ifdef FASESBOX +int true_main(int argc, char *argv[]) { +#else +int main(int argc, char *argv[]) { +#endif return 0; } @@ -7,10 +7,14 @@ #include <unistd.h> #include <string.h> -#define REQ_ERRPRINT /* Require errprint() from ../common/common.h */ -#include "../common/common.h" +#define REQ_ERRPRINT /* Require errprint() from common.h */ +#include "common.h" +#ifdef FASESBOX +int tty_main(int argc, char *argv[]) { +#else int main(int argc, char *argv[]) { +#endif char *terminalname = ttyname(STDIN_FILENO); if (argc != 1) {} /* workaround... */ if (errno == ENOTTY) { @@ -8,13 +8,17 @@ #include <errno.h> #include <string.h> -#define REQ_PRINT_USAGE /* Require print_usage() from ../common/common.h */ -#define REQ_ERRPRINT /* Require errprint() from ../common/common.h */ +#define REQ_PRINT_USAGE /* Require print_usage() from common.h */ +#define REQ_ERRPRINT /* Require errprint() from common.h */ #define DESCRIPTION "Return system name." #define OPERANDS "[-amnrsv]" -#include "../common/common.h" +#include "common.h" -int main(int argc, char *const argv[]) { +#ifdef FASESBOX +int uname_main(int argc, char *argv[]) { +#else +int main(int argc, char *argv[]) { +#endif int argument; struct utsname name; char param[256]; @@ -6,13 +6,17 @@ #include <stdio.h> #include <errno.h> -#define REQ_PRINT_USAGE /* Require print_usage() from ../common/common.h */ -#define REQ_ERRPRINT /* Require errprint() from ../common/common.h */ +#define REQ_PRINT_USAGE /* Require print_usage() from common.h */ +#define REQ_ERRPRINT /* Require errprint() from common.h */ #define DESCRIPTION "Call the unlink() function." #define OPERANDS "file" -#include "../common/common.h" +#include "common.h" -int main(int argc, char *const argv[]) { +#ifdef FASESBOX +int unlink_main(int argc, char *argv[]) { +#else +int main(int argc, char *argv[]) { +#endif if (argc != 2) { print_usage(argv[0], DESCRIPTION, OPERANDS, VERSION); return 1; @@ -9,13 +9,17 @@ #include <errno.h> #include <string.h> -#define REQ_PRINT_USAGE /* Require print_usage() from ../common/common.h */ -#define REQ_ERRPRINT /* Require errprint() from ../common/common.h */ +#define REQ_PRINT_USAGE /* Require print_usage() from common.h */ +#define REQ_ERRPRINT /* Require errprint() from common.h */ #define DESCRIPTION "Word, line, and byte/character count." #define OPERANDS "[-clwm] [file...]" -#include "../common/common.h" +#include "common.h" -int main(int argc, char *const argv[]) { +#ifdef FASESBOX +int wc_main(int argc, char *argv[]) { +#else +int main(int argc, char *argv[]) { +#endif int argument, length; FILE *file; size_t len_getd = 4096; @@ -6,7 +6,11 @@ #include <string.h> #include <stdio.h> +#ifdef FASESBOX +int yes_main(int argc, char *argv[]) { +#else int main(int argc, char *argv[]) { +#endif setvbuf(stdout, NULL, _IONBF, 0); if (argc > 1) { if (!strcmp(argv[1], "--")) { |