more cleaning
This commit is contained in:
parent
49b9f21067
commit
9189124f2d
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,5 +1,6 @@
|
||||
dist/
|
||||
echo/echo
|
||||
nonzero/nonzero
|
||||
roll/roll
|
||||
rot13/rot13
|
||||
str/str
|
||||
|
216
Makefile
216
Makefile
@ -3,188 +3,6 @@ CC=cc
|
||||
CFLAGS=-Iinclude/ -Ilib/ -g -Wall -Wextra -Wpedantic
|
||||
RM=rm -f
|
||||
|
||||
all: libraries programs
|
||||
|
||||
cleanall: clean cleanprograms
|
||||
|
||||
clean:
|
||||
$(RM) build/*
|
||||
|
||||
cleanprograms:
|
||||
$(RM) bin/add
|
||||
$(RM) bin/calculate
|
||||
$(RM) bin/cut
|
||||
$(RM) bin/echo
|
||||
$(MAKE) -C echo clean
|
||||
$(RM) bin/eq
|
||||
$(RM) bin/false
|
||||
$(RM) bin/fdivide
|
||||
$(RM) bin/gt
|
||||
$(RM) bin/id
|
||||
$(RM) bin/lowercase
|
||||
$(RM) bin/lt
|
||||
$(RM) bin/mm
|
||||
$(RM) bin/multiply
|
||||
$(MAKE) -C nonzero clean
|
||||
$(RM) bin/pscat
|
||||
$(RM) bin/rot13
|
||||
$(MAKE) -C rot13 clean
|
||||
$(RM) bin/simexec
|
||||
$(RM) bin/sleep
|
||||
$(RM) bin/streq
|
||||
$(RM) bin/str
|
||||
$(MAKE) -C str clean
|
||||
$(RM) bin/substitute
|
||||
$(RM) bin/sysexits
|
||||
$(RM) bin/retval
|
||||
$(RM) bin/rldecode
|
||||
$(RM) bin/rlencode
|
||||
$(RM) bin/roll
|
||||
$(MAKE) -C roll clean
|
||||
$(RM) bin/tail
|
||||
$(RM) bin/true
|
||||
|
||||
libraries: libio libshell stdbool sysexits
|
||||
|
||||
libio: lib/libio.c
|
||||
$(CC) $(CFLAGS) -c -o build/libio.o lib/libio.c
|
||||
|
||||
libshell: lib/libshell.c lib/libshell.h
|
||||
$(CC) $(CFLAGS) -o lib/libshell.o -c lib/libshell.c
|
||||
|
||||
libstr: lib/libstr.c lib/libstr.h
|
||||
$(CC) $(CFLAGS) -o lib/libstr.o -c lib/libstr.c
|
||||
|
||||
stdbool: include/stdbool.h
|
||||
|
||||
sysexits_bin: src/sysexits.c
|
||||
$(CC) $(CFLAGS) -c -o build/sysexits.o src/sysexits.c
|
||||
$(CC) $(CFLAGS) -o bin/sysexits build/sysexits.o
|
||||
|
||||
sysexits: sysexits_bin
|
||||
bin/sysexits >include/sysexits.h
|
||||
|
||||
programs: echo false id lowercase nonzero pscat roll simexec sleep streq str true
|
||||
|
||||
calculate: libstr sysexits src/calculate.c
|
||||
$(CC) $(CFLAGS) -o src/calculate.o -c src/calculate.c
|
||||
$(CC) $(CFLAGS) -o bin/calculate lib/libstr.o src/calculate.o
|
||||
|
||||
.PHONY: echo
|
||||
echo: bin/$@
|
||||
|
||||
bin/echo: echo/Makefile echo/echo.c
|
||||
$(MAKE) -C echo sane
|
||||
cp echo/echo bin/echo
|
||||
|
||||
false: src/false.c
|
||||
$(CC) $(CFLAGS) -o bin/false src/false.c
|
||||
|
||||
id: stdbool sysexits src/id.c
|
||||
$(CC) $(CFLAGS) -o bin/id src/id.c
|
||||
|
||||
levenshtein: src/levenshtein.c
|
||||
$(CC) $(CFLAGS) -o bin/levenshtein src/levenshtein.c
|
||||
|
||||
lowercase: sysexits src/lowercase.c
|
||||
$(CC) $(CFLAGS) -o bin/lowercase src/lowercase.c
|
||||
|
||||
.PHONY: nonzero
|
||||
nonzero: bin/$@
|
||||
|
||||
bin/nonzero: nonzero/Makefile nonzero/nonzero.c
|
||||
$(MAKE) -C nonzero sane
|
||||
cp nonzero/nonzero bin/nonzero
|
||||
|
||||
nutshell.o: libio usefulmacros src/nutshell.c src/nutshell.h src/nutshell_builtins.c
|
||||
$(CC) $(CFLAGS) -c -o build/nutshell.o src/nutshell.c
|
||||
|
||||
nutshell: libio nutshell.o
|
||||
$(CC) $(CFLAGS) -o bin/nutshell build/libio.o build/nutshell.o
|
||||
|
||||
.PHONY: pscat
|
||||
pscat: bin/pscat
|
||||
|
||||
bin/pscat: sysexits pscat/pscat.c pscat/Makefile
|
||||
$(MAKE) -C pscat sane
|
||||
cp pscat/pscat bin/pscat
|
||||
|
||||
retval.o: libio src/retval.c sysexits
|
||||
$(CC) $(CFLAGS) -c -o build/retval.o src/retval.c
|
||||
|
||||
retval: libio retval.o
|
||||
$(CC) $(CFLAGS) -o bin/retval build/retval.o build/libio.o
|
||||
|
||||
.PHONY: roll
|
||||
roll: bin/roll
|
||||
|
||||
bin/roll: sysexits roll/roll.c roll/Makefile
|
||||
$(MAKE) -C roll sane
|
||||
cp roll/roll bin/roll
|
||||
|
||||
.PHONY: rot13
|
||||
rot13: bin/rot13
|
||||
|
||||
bin/rot13: sysexits rot13/rot13.c rot13/Makefile
|
||||
$(MAKE) -C rot13 sane
|
||||
cp rot13/rot13 bin/rot13
|
||||
|
||||
rldecode.o: sysexits src/runlength.c
|
||||
$(CC) $(CFLAGS) -Df=decode -c -o build/rldecode.o src/runlength.c
|
||||
|
||||
rlencode.o: sysexits src/runlength.c
|
||||
$(CC) $(CFLAGS) -Df=encode -c -o build/rlencode.o src/runlength.c
|
||||
|
||||
runlength: rldecode.o rlencode.o
|
||||
$(CC) $(CFLAGS) -o bin/rldecode build/rldecode.o
|
||||
$(CC) $(CFLAGS) -o bin/rlencode build/rlencode.o
|
||||
|
||||
simexec.o: libio sysexits src/simexec.c
|
||||
$(CC) $(CFLAGS) -c -o build/simexec.o src/simexec.c
|
||||
|
||||
simexec: libio simexec.o
|
||||
$(CC) $(CFLAGS) -o bin/simexec build/libio.o build/simexec.o
|
||||
|
||||
streq.o: libio sysexits src/streq.c
|
||||
$(CC) $(CFLAGS) -c -o build/streq.o src/streq.c
|
||||
|
||||
streq: libio streq.o
|
||||
$(CC) $(CFLAGS) -o bin/streq build/libio.o build/streq.o
|
||||
|
||||
.PHONY: str
|
||||
str: bin/str
|
||||
|
||||
bin/str: sysexits str/str.c str/Makefile
|
||||
$(MAKE) -C str sane
|
||||
cp str/str bin/str
|
||||
|
||||
sleep.o: libio sysexits src/sleep.c usefulmacros
|
||||
$(CC) $(CFLAGS) -c -o build/sleep.o src/sleep.c
|
||||
|
||||
sleep: libio sleep.o
|
||||
$(CC) $(CFLAGS) -o bin/sleep build/libio.o build/sleep.o
|
||||
|
||||
substitute: stdbool src/substitute.c
|
||||
$(CC) $(CFLAGS) -c -o src/substitute.o src/substitute.c
|
||||
$(CC) $(CFLAGS) -o bin/substitute src/substitute.o
|
||||
|
||||
tail.o: libio src/tail.c
|
||||
$(CC) $(CFLAGS) -c -o build/tail.o src/tail.c
|
||||
|
||||
tail: libio tail.o
|
||||
$(CC) $(CFLAGS) -o bin/tail build/libio.o build/tail.o
|
||||
|
||||
true: src/true.c
|
||||
$(CC) $(CFLAGS) -o bin/true src/true.c
|
||||
|
||||
usefulmacros: include/usefulmacros.h
|
||||
|
||||
which: libshell src/which.c
|
||||
$(CC) $(CFLAGS) -c -o src/which.o src/which.c
|
||||
$(CC) $(CFLAGS) -o bin/which lib/libshell.o src/which.o
|
||||
|
||||
# Convenience
|
||||
|
||||
PROGRAMS= \
|
||||
alsa-plugins-nice alsa-utils \
|
||||
anki audacious \
|
||||
@ -227,13 +45,16 @@ PROGRAMS= \
|
||||
zathura zathura-cb zathura-djvu \
|
||||
zathura-ps
|
||||
|
||||
.PHONY: alpine-programs
|
||||
alpine-programs:
|
||||
apk add $(PROGRAMS)
|
||||
|
||||
.PHONY: arch-doas
|
||||
arch-doas:
|
||||
cd dist/doas-sudo
|
||||
makepkg -si
|
||||
|
||||
.PHONY: arch-yay
|
||||
arch-yay:
|
||||
git clone "https://aur.archlinux.org/yay.git" || true
|
||||
cd yay
|
||||
@ -241,6 +62,7 @@ arch-yay:
|
||||
makepkg -si
|
||||
yay -V
|
||||
|
||||
.PHONY: audacious-skins
|
||||
audacious-skins:
|
||||
curl https://archive.org/download/winampskin_Sailor_Moon_Gang/Sailor_Moon_Gang.wsz -o /usr/share/audacious/Skins/Sailor_Moon_Gang.wsz
|
||||
|
||||
@ -287,14 +109,14 @@ dist/grammy/pressherald.com.png: dist/grammy
|
||||
curl -o "dist/grammy/pressherald.com.png" "https://multifiles.pressherald.com/uploads/sites/4/2014/06/apple-touch-icon-iphone-retina-display.png"
|
||||
dist/grammy/weather.com.png: dist/grammy
|
||||
curl -o "dist/grammy/weather.com.png" "https://upload.wikimedia.org/wikipedia/commons/thumb/7/77/The_Weather_Channel_logo_2005-present.svg/1200px-The_Weather_Channel_logo_2005-present.svg.png"
|
||||
|
||||
|
||||
# nmap 7.80 is the last Free nmap release
|
||||
.PHONY: nmap
|
||||
nmap:
|
||||
mkdir -p ~/src
|
||||
cd ~/src
|
||||
curl "https://nmap.org/dist/nmap-7.80.tar.bz2" | bzip2 -cd | tar -x
|
||||
./configure
|
||||
make
|
||||
mkdir -p /usr/local/src/nmap-7.80
|
||||
curl "https://nmap.org/dist/nmap-7.80.tar.bz2" | bzip2 -cd | tar x -C /usr/local/src/nmap-7.80
|
||||
cd /usr/local/src/nmap-7.80; ./configure
|
||||
$(MAKE) -C /usr/local/src/nmap-7.80
|
||||
|
||||
.PHONY: spacer
|
||||
spacer: dist/spacer.bin
|
||||
@ -307,20 +129,6 @@ dist/spacer.bin:
|
||||
# 512 * 16777216 = 8GB
|
||||
dd bs=512 count=16777216 </dev/zero >dist/spacer.bin
|
||||
|
||||
.PHONY: unscii-pkgsrc
|
||||
unscii-pkgsrc:
|
||||
cd /usr/pkgsrc/fonts/unscii
|
||||
make install clean clean-depends
|
||||
|
||||
unscii-system:
|
||||
mkdir -p /usr/share/fonts/unscii
|
||||
curl "http://viznut.fi/unscii/unscii-16-full.otf" >"/usr/share/fonts/unscii/unscii-16-full.otf"
|
||||
curl "http://viznut.fi/unscii/unscii-16-full.pcf" >"/usr/share/fonts/unscii/unscii-16-full.pcf"
|
||||
curl "http://viznut.fi/unscii/unscii-16-full.ttf" >"/usr/share/fonts/unscii/unscii-16-full.ttf"
|
||||
|
||||
unscii-user:
|
||||
mkdir -p ~/.fonts
|
||||
curl "http://viznut.fi/unscii/unscii-16-full.otf" >"~/.fonts/unscii-16-full.otf"
|
||||
curl "http://viznut.fi/unscii/unscii-16-full.pcf" >"~/.fonts/unscii-16-full.pcf"
|
||||
curl "http://viznut.fi/unscii/unscii-16-full.ttf" >"~/.fonts/unscii-16-full.ttf"
|
||||
|
||||
.PHONY: all clean cleanlibraries cleanprograms stdbool sysexits usefulmacros
|
||||
$(MAKE) -C /usr/pkgsrc/fonts/unscii install clean clean-depends
|
||||
|
30
lib/xml.h
30
lib/xml.h
@ -1,30 +0,0 @@
|
||||
/* There's already an excellent and popular XML library, libxml2, that
|
||||
* accomplishes what this does but better. Use that instead. */
|
||||
|
||||
#define XML_LEFT_BRACKET '<'
|
||||
#define XML_RIGHT_BRACKET '>'
|
||||
#define XML_FORWARD_SLASH '/'
|
||||
|
||||
struct XMLAttribute{
|
||||
char *name;
|
||||
char *content;
|
||||
}
|
||||
|
||||
struct XMLDoc{
|
||||
struct XMLNode **nodes;
|
||||
}
|
||||
|
||||
struct XMLNode{
|
||||
char *name;
|
||||
char *content;
|
||||
union{
|
||||
struct XMLDoc *doc;
|
||||
struct XMLNode *node;
|
||||
}parent;
|
||||
enum{
|
||||
XML_PARENT_IS_DOC = 0,
|
||||
XML_PARENT_IS_NODE = 1
|
||||
}parent_type;
|
||||
struct XMLAttribute **attributes;
|
||||
struct XMLNode **children;
|
||||
}
|
29
man/add.1
29
man/add.1
@ -1,29 +0,0 @@
|
||||
.TH ADD 1
|
||||
|
||||
.SH NAME
|
||||
|
||||
add \(en add integers
|
||||
|
||||
.SH DESCRIPTION
|
||||
|
||||
Add sums an arbitrary quantity of integers and prints the output.
|
||||
|
||||
.SH NOTES
|
||||
|
||||
Add may be confused with sum(1), which prints checksums of files.
|
||||
|
||||
.SH DIAGNOSTICS
|
||||
|
||||
Add will print a message to standard error and exit unsuccessfully if a non-integer argument is given.
|
||||
|
||||
.SH BUGS
|
||||
|
||||
Add does not work with decimal values.
|
||||
|
||||
.SH COPYRIGHT
|
||||
|
||||
Public domain.
|
||||
|
||||
.SH SEE ALSO
|
||||
|
||||
fdivide(1), multiply(1), stris(1), subtract(1)
|
29
man/ctypef.3
29
man/ctypef.3
@ -1,29 +0,0 @@
|
||||
.TH CTYPEF 3
|
||||
|
||||
.SH NAME
|
||||
ctypef \- ctype, guaranteed to be functions
|
||||
|
||||
.SH SYNOPSIS
|
||||
|
||||
See ctype(3).
|
||||
|
||||
.SH DESCRIPTION
|
||||
|
||||
In some ancient environments ctype.h defines macros rather than functions for its methods.
|
||||
ctypef.h replaces any macros from ctype.h with functions.
|
||||
|
||||
.SH STANDARDS
|
||||
|
||||
Redundant on standards conformant systems.
|
||||
|
||||
.SH COPYRIGHT
|
||||
|
||||
Public domain.
|
||||
|
||||
.SH CAVEATS
|
||||
|
||||
See ctype(3).
|
||||
|
||||
.SH SEE ALSO
|
||||
|
||||
ctype(3), ascii(7)
|
@ -1,25 +0,0 @@
|
||||
.TH MULTIPLY 1
|
||||
|
||||
.SH NAME
|
||||
|
||||
multiply \(en multiply integers
|
||||
|
||||
.SH DESCRIPTION
|
||||
|
||||
Multiply multiplies an arbitrary quantity of integers and prints the output.
|
||||
|
||||
.SH DIAGNOSTICS
|
||||
|
||||
Multiply will print a message to standard error and exit unsuccessfully if a non-integer argument is given.
|
||||
|
||||
.SH BUGS
|
||||
|
||||
Multiply does not work with decimal values.
|
||||
|
||||
.SH COPYRIGHT
|
||||
|
||||
Public domain.
|
||||
|
||||
.SH SEE ALSO
|
||||
|
||||
add(1), fdivide(1), stris(1), subtract(1)
|
@ -1,93 +0,0 @@
|
||||
# utilities
|
||||
|
||||
This project seeks to replicate all standard system utilities on UNIX-like system, implementing the features defined in [POSIX.1-2017](https://pubs.opengroup.org/onlinepubs/9699919799/).
|
||||
Much of this project's layout is opinionated.
|
||||
|
||||
For a user installation, place `PATH="$HOME/bin/:"$PATH` in your `$HOME/.bashrc`, `mkdir -p $HOME/bin`, and then copy the desired utilities into that binaries folder.
|
||||
(Yes, this doesn't work for all system configurations (it doesn't work for mine), but it works for nearly all configurations beginners would have; if you know what you're doing you don't have to refer to this).
|
||||
This doesn't require root permissions and you can bypass these utilities with `/bin/[desired utility]`.
|
||||
|
||||
System-wide installation of these utilities isn't recommended whatsoever.
|
||||
|
||||
## building
|
||||
|
||||
You can just read the Makefile, it's a pretty simple one.
|
||||
|
||||
`make cleanall` - cleans
|
||||
|
||||
`make programs` - builds all stable utilities
|
||||
|
||||
`make [utility]` - builds a specific utility
|
||||
|
||||
It's not necessary to `make libraries` as the Makefile knows on which libraries each program depends and will build those specific libraries when needed.
|
||||
|
||||
## included utilities
|
||||
|
||||
All not mentioned in this README have proper manual pages provided in `man/`.
|
||||
|
||||
### abs
|
||||
|
||||
Not in POSIX.
|
||||
Shellscript that returns the absolute value of an integer argument.
|
||||
Relies on *eq*(1), *lt*(1), *multiply*(1), *printf*(1), and *stris*(1).
|
||||
|
||||
### ++
|
||||
|
||||
Shellscript that sums 1 with the first argument using *add*(1).
|
||||
|
||||
### --
|
||||
|
||||
Shellscript that subtracts 1 from the first argument using *subtract*(1).
|
||||
|
||||
### subtract
|
||||
|
||||
Shellscript that subtracts the second argument from the first.
|
||||
Relies on *add*(1), *eq*(1), *multiply*(1), *printf*(1), and *stris*(1).
|
||||
|
||||
### cat
|
||||
|
||||
*cat*(1) written in POSIX shell.
|
||||
Relies on *dd*(1) and *test*(1).
|
||||
|
||||
### eq
|
||||
|
||||
Compares integer arguments and exits with 0 if they're all equal or 1 if some aren't equal.
|
||||
Equivalent to `test -eq`.
|
||||
|
||||
### fdivide
|
||||
|
||||
Not in POSIX.
|
||||
Performs **floor division** on two **integers**.
|
||||
This does not, as the name suggests, divide floating-point numbers.
|
||||
|
||||
### gt
|
||||
|
||||
Compares integer arguments and exits with 0 if the arguments are arranged in descending order.
|
||||
Exits with 1 if an argument is equal or greater to a previous argument.
|
||||
Equivalent to `test -gt`.
|
||||
|
||||
### head
|
||||
|
||||
An implementation of *head*(1) written in POSIX shell.
|
||||
Relies on *cat*(1), *printf*(1), *sed*(1), and *stris*(1).
|
||||
WIP.
|
||||
|
||||
### lt
|
||||
|
||||
Compares integer arguments and exits with 0 if the arguments are arranged in ascending order.
|
||||
Exits with 1 if an argument is equal or lesser to a previous argument.
|
||||
Equivalent to `test -lt`.
|
||||
|
||||
### man
|
||||
|
||||
Barebones implementation of *man*(1) written in POSIX shell.
|
||||
|
||||
### mod
|
||||
|
||||
Not in POSIX.
|
||||
Prints the remainder of the first argument divided by the second to stdout.
|
||||
Written in POSIX shell, relies on *eq*(1), *fdivide*(1), *multiply*(1), *printf*(1), *subtract*(1), *stris*(1).
|
||||
|
||||
### tail
|
||||
|
||||
An implementation of *tail*(1). WIP.
|
Loading…
Reference in New Issue
Block a user