diff --git a/.gitignore b/.gitignore index 01b3b42..3959543 100644 --- a/.gitignore +++ b/.gitignore @@ -1,23 +1,5 @@ -bin/echo -bin/false -bin/id -bin/lowercase -bin/nonzero -bin/nutshell -bin/pscat -bin/retval -bin/rldecode -bin/rlencode -bin/roll -bin/rot13 -bin/simexec -bin/sleep -bin/str -bin/streq -bin/sysexits -build/* -include/sysexits.h -lib/*.o +dist/ +echo/echo roll/roll rot13/rot13 -src/*.o +str/str diff --git a/arraylen.h b/arraylen.h new file mode 100644 index 0000000..6a8251d --- /dev/null +++ b/arraylen.h @@ -0,0 +1,3 @@ +#ifndef ARRAYLEN +# define ARRAYLEN(a) sizeof(a) / sizeof *(a) +#endif diff --git a/banned/banned.h b/banned/banned.h index 3e280f6..aef7991 100644 --- a/banned/banned.h +++ b/banned/banned.h @@ -4,6 +4,11 @@ # define Use_of_this_function_is_not_permitted(a) invalid_token # define BAN(a) Use_of_this_function_is_not_permitted(a) +# undef fscanf +# define fscanf(...) BAN(fscanf) +# undef scanf +# define scanf(...) BAN(scanf) + # undef strcat # define strcat(a,b) BAN(strcat) diff --git a/bin/head b/bin/head deleted file mode 100755 index 84b6540..0000000 --- a/bin/head +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/sh - -length=10 # default length - -# core [input] [output] [length] -core() { - sed $3q <"$1" >"$2" -} - -usage() { - printf "Usage: %b [-h] [-n number]\n" "$1" - exit 1 -} - -argc=$# -argv0="$0" -output="/dev/stdout" - -while getopts 'hn:' c; do - case $c in - (h) usage "$0";; - (n) - stris uint "$OPTARG" \ - && length=$OPTARG \ - || usage "$argv0" - ;; - (:) - printf "%b: \"-$OPTARG\" requires an argument (number)\n" "$argv0" >/dev/stderr - exit 1;; - (?) - stris uint $OPTOPT >/dev/null \ - && printf "%b: This program doesn't support -[number] arguments as they're not POSIX\n" "$argv0" >/dev/stderr \ - || usage "$argv0" - exit 1;; - esac -done - -if eq $OPTIND $(add $argc 1); then # no file specified, assume stdin - core /dev/stdin "$output" $length - exit 0 -fi - -shift $OPTIND -temp0="$0" - -while true; do - ! [ -e "$0" ] \ - && printf "%b: %b: File does not exist\n" "$argv0" "$0" >/dev/stderr \ - && exit 1 - - [ -n "$1" ] && ! streq "$0" "$temp0" \ - && printf "\n" >"$output" - [ -n "$1" ] \ - && printf "==> %b <==\n" "$0" >"$output" - - core "$0" "$output" $length - - [ -n "$1" ] && shift 1 || break -done - -exit 0 diff --git a/bin/man b/bin/man deleted file mode 100755 index 3f7b62d..0000000 --- a/bin/man +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/sh - -argv0="$0" - -die() { printf "$*" >/dev/stderr && exit 1; } - -# A lot of these break convention when recording errors because this tries to -# imitate other implementations. -[ -n "$1" ] || die "What manual page do you want?\nFor example, try 'man man'.\n" - -[ -n "$LANG" ] || LANG="C" - -[ -n "$MANPATH" ] || MANPATH="/usr/share/man" -[ -d "$MANPATH" ] || die "$0: \$MANPATH: $MANPATH: Does not exist\n" -[ -n "$MANSECTIONS" ] \ - && default_mansections="$MANSECTIONS" \ - || default_mansections="1nl830254967" -[ -d "$MANPATH"/"$LANG" ] \ - && MANDIR="$MANPATH/$LANG" \ - || MANDIR="$MANPATH" - -if [ -z "$PAGER" ]; then - for prog in $(printf " -less -more -cat -dd - "); do - if which "$prog" >/dev/null 2>&1; then - PAGER="$prog" - break - fi - done -fi - -man() { - eq $# 2 || die "$argv0: man() called with $# arguments. Expected 2. This is a programmer error\n" - MANSECTIONS="$1" - NAME="$2" - - # the way manpages are laid out SUCKS - # so, yeah, each man section is one character. which means it's totally - # bueno to just iterate over the string like this. but $MANDIR/man1 can - # have both man.1.gz AND man.1p.gz. ARGH!!!! - for SECTION in $(printf "$MANSECTIONS" | sed 's/\(.\)/\1\n/g'); do - PAGE="$(find "$MANDIR/man$SECTION" -type f 2>/dev/null | grep "\/$NAME\.\|\/$NAME$" | sed q)" - [ -z "$PAGE" ] || break - done - - ! [ -n "$PAGE" ] \ - && printf "No manual entry for $NAME\n" \ - && return 1 - - case "$(file -bir --no-buffer "$PAGE")" in - ("text/"*) - COMMAND="cat" ;; - ("application/gzip"*) - COMMAND="zcat" ;; - (*) - die "$argv0: $PAGE: Unknown file type.\n" ;; - esac - - $COMMAND "$PAGE" | nroff -man | $PAGER -} - -# this seems to be what the popular man does -# so like `man foo -k bar` will show the manpages for foo, -k, and bar -# expected behavior imo would be manpage for foo, then gist for bar -# but let's not break things -if streq "$1" "-k"; then # -k - printf "Not yet implemented\n" && exit 1 -else # not -k - while gt $# 0; do - if eq $(fdivide $# 2) 0 && gt 1 $# || ! stris int "$1"; then - MANSECTIONS="$default_mansections" - NAME="$1" - SHIFTING=1 - elif gt 1 $(fdivide $# 2); then - MANSECTIONS="$1" - NAME="$2" - SHIFTING=2 - else exit 0 # no more args - fi - man "$MANSECTIONS" "$NAME" - shift $SHIFTING - done -fi diff --git a/dotfiles/.nethackrc b/dotfiles/.nethackrc new file mode 100644 index 0000000..027d83a --- /dev/null +++ b/dotfiles/.nethackrc @@ -0,0 +1 @@ +OPTIONS=!autopickup diff --git a/include/stdbool.h b/include/stdbool.h deleted file mode 100644 index 13acf04..0000000 --- a/include/stdbool.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef _STDBOOL_H -# define _STDBOOL_H -# define bool _Bool -# define false 0 -# define true 1 -# define __bool_true_false_are_defined 1 -/* "dirtbag boolean" - * - ideally the compiler would keep all the booleans in [x] number of unsigned - * [type]s so it could squeeze eight booleans out of one byte. - * alas, the simplest thing tends to be best, and it's nice to not waste 20 - * cycles (figure made up) on applying a bitmask to an int to read a bool */ -# define _Bool unsigned char -#endif /* ifndef _STDBOOL_H */ diff --git a/include/usefulmacros.h b/include/usefulmacros.h deleted file mode 100644 index 1efa9d1..0000000 --- a/include/usefulmacros.h +++ /dev/null @@ -1,9 +0,0 @@ -/* #include - * - Needed for NULL in NOARGVZERO - * #include - * - Needed for EX_OSERR in NOARGVZERO - * #include - * - Needed for write(2) in NOARGVZERO */ - -#define ARRAYLEN(a) sizeof((a)) / sizeof(*(a)) -#define NOARGVZERO(a) if(*(a) == NULL) { write(2, "argv[0] is NULL; OS error, exiting...\n", 38); return EX_OSERR; } diff --git a/irc/irc.c b/irc/irc.c new file mode 100644 index 0000000..e104bc6 --- /dev/null +++ b/irc/irc.c @@ -0,0 +1,16 @@ +#include +#include + +/* RFC 1459 1.2 + * 9 characters + nul terminator */ +static int nickname[9 + 1]; + +/* RFC 1459 1.3 + * 200 characters + nul terminator */ +static int channel[200 + 1]; + +/* RFC 1459 1.3 + * channel names cannot contain these characters */ +static int channel_restricted[] = { 0x07, ' ', ',', '\0' }; + + diff --git a/irc/irc.h b/irc/irc.h new file mode 100644 index 0000000..5d44e6a --- /dev/null +++ b/irc/irc.h @@ -0,0 +1,4 @@ +#ifndef _IRC_H +# define _IRC_H + +#endif /* ifndef _IRC_H */