diff --git a/.gitignore b/.gitignore index 7d8a08c75..eb8af1dde 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ /archive/2019/ /archive/2020/ /bugs.html +/bin /faq.html iocccsize mkentry diff --git a/bin/extract_winner_handles.sh b/bin/extract_winner_handles.sh deleted file mode 100755 index ee344667e..000000000 --- a/bin/extract_winner_handles.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -grep -o '' winners.html |sed -e 's,//g' - diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 000000000..ac5aa064f --- /dev/null +++ b/src/Makefile @@ -0,0 +1,131 @@ +#!/usr/bin/env make +# +# src - all source for bin tools +# +# Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved. +# +# Permission to use, copy, modify, and distribute this software and +# its documentation for any purpose and without fee is hereby granted, +# provided that the above copyright, this permission notice and text +# this comment, and the disclaimer below appear in all of the following: +# +# supporting documentation +# source copies +# source works derived from this source +# binaries derived from this source or from derived source +# +# LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO +# EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, 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. +# +# chongo (Landon Curt Noll, http://www.isthe.com/chongo/index.html) /\oo/\ +# +# Share and enjoy! :-) + +############# +# utilities # +############# + +CC= cc +CHMOD= chmod +CP= cp +INSTALL= install +RM= rm +SHELL= bash + +#CFLAGS= -O3 -g3 --pedantic -Wall -Werror +CFLAGS= -O3 -g3 --pedantic -Wall + +###################### +# target information # +###################### + +TARGETS= sgit winner_name + +###################################### +# all - default rule - must be first # +###################################### + +all: ${TARGETS} + @for dir in ${TARGETS}; do \ + if [[ ! -d $$dir ]]; then \ + echo "$0: FATAL: not a sub-directory: $$dir" 1>&2; \ + exit 1; \ + fi; \ + if [[ ! -f $$dir/Makefile ]]; then \ + echo "$0: FATAL: not a file: $$dir/Makefile" 1>&2; \ + exit 2; \ + fi; \ + echo "make -C \"$$dir\" $@"; \ + make -C "$$dir" $@; \ + done + +################################################# +# .PHONY list of rules that do not create files # +################################################# + +.PHONY: all configure clean clobber install + +################################### +# standard Makefile utility rules # +################################### + +configure: + @for dir in ${TARGETS}; do \ + if [[ ! -d $$dir ]]; then \ + echo "$0: FATAL: not a sub-directory: $$dir" 1>&2; \ + exit 1; \ + fi; \ + if [[ ! -f $$dir/Makefile ]]; then \ + echo "$0: FATAL: not a file: $$dir/Makefile" 1>&2; \ + exit 2; \ + fi; \ + echo "make -C \"$$dir\" $@"; \ + make -C "$$dir" $@; \ + done + +clean: + @for dir in ${TARGETS}; do \ + if [[ ! -d $$dir ]]; then \ + echo "$0: FATAL: not a sub-directory: $$dir" 1>&2; \ + exit 1; \ + fi; \ + if [[ ! -f $$dir/Makefile ]]; then \ + echo "$0: FATAL: not a file: $$dir/Makefile" 1>&2; \ + exit 2; \ + fi; \ + echo "make -C \"$$dir\" $@"; \ + make -C "$$dir" $@; \ + done + +clobber: clean + @for dir in ${TARGETS}; do \ + if [[ ! -d $$dir ]]; then \ + echo "$0: FATAL: not a sub-directory: $$dir" 1>&2; \ + exit 1; \ + fi; \ + if [[ ! -f $$dir/Makefile ]]; then \ + echo "$0: FATAL: not a file: $$dir/Makefile" 1>&2; \ + exit 2; \ + fi; \ + echo "make -C \"$$dir\" $@"; \ + make -C "$$dir" $@; \ + done + +install: all + @for dir in ${TARGETS}; do \ + if [[ ! -d $$dir ]]; then \ + echo "$0: FATAL: not a sub-directory: $$dir" 1>&2; \ + exit 1; \ + fi; \ + if [[ ! -f $$dir/Makefile ]]; then \ + echo "$0: FATAL: not a file: $$dir/Makefile" 1>&2; \ + exit 2; \ + fi; \ + echo "make -C \"$$dir\" $@"; \ + make -C "$$dir" $@; \ + done diff --git a/src/sgit/.gitignore b/src/sgit/.gitignore new file mode 100644 index 000000000..67af07208 --- /dev/null +++ b/src/sgit/.gitignore @@ -0,0 +1 @@ +sgit diff --git a/src/sgit/Makefile b/src/sgit/Makefile new file mode 100644 index 000000000..951901a25 --- /dev/null +++ b/src/sgit/Makefile @@ -0,0 +1,82 @@ +#!/usr/bin/env make +# +# sgit - run sed on all files under git control +# +# Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved. +# +# Permission to use, copy, modify, and distribute this software and +# its documentation for any purpose and without fee is hereby granted, +# provided that the above copyright, this permission notice and text +# this comment, and the disclaimer below appear in all of the following: +# +# supporting documentation +# source copies +# source works derived from this source +# binaries derived from this source or from derived source +# +# LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO +# EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, 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. +# +# chongo (Landon Curt Noll, http://www.isthe.com/chongo/index.html) /\oo/\ +# +# Share and enjoy! :-) + +############# +# utilities # +############# + +CC= cc +CHMOD= chmod +CP= cp +INSTALL= install +RM= rm +SHELL= bash + +#CFLAGS= -O3 -g3 --pedantic -Wall -Werror +CFLAGS= -O3 -g3 --pedantic -Wall + +###################### +# target information # +###################### + +DESTDIR= ../../bin + +TARGETS= sgit + +###################################### +# all - default rule - must be first # +###################################### + +all: ${TARGETS} + +winner_name: winner_name.sh + ${RM} -f -v $@ + ${CP} -f -v $? $@ + ${CHMOD} +x $@ + +################################################# +# .PHONY list of rules that do not create files # +################################################# + +.PHONY: all configure clean clobber install + +################################### +# standard Makefile utility rules # +################################### + +configure: + @: + +clean: + @: + +clobber: clean + rm -f ${TARGETS} + +install: all + ${INSTALL} -m 0555 ${TARGETS} ${DESTDIR} diff --git a/bin/sgit.README.md b/src/sgit/sgit.README.md similarity index 100% rename from bin/sgit.README.md rename to src/sgit/sgit.README.md diff --git a/bin/sgit b/src/sgit/sgit.sh similarity index 98% rename from bin/sgit rename to src/sgit/sgit.sh index f865948b0..50932219e 100755 --- a/bin/sgit +++ b/src/sgit/sgit.sh @@ -1,7 +1,6 @@ #!/usr/bin/env bash # -# sgit - run sed (by default with -i) on all files (or one or more globs) under -# git control +# sgit - run sed on all files under git control # # This script allows one to run sed under git control without having to come up # with a list of files first and then passing those to the command. diff --git a/src/winner_name/.gitignore b/src/winner_name/.gitignore new file mode 100644 index 000000000..9c6ede522 --- /dev/null +++ b/src/winner_name/.gitignore @@ -0,0 +1 @@ +winner_name diff --git a/src/winner_name/Makefile b/src/winner_name/Makefile new file mode 100644 index 000000000..6176b1fb5 --- /dev/null +++ b/src/winner_name/Makefile @@ -0,0 +1,82 @@ +#!/usr/bin/env make +# +# winner_name - extract NAME handles from winners.html +# +# Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved. +# +# Permission to use, copy, modify, and distribute this software and +# its documentation for any purpose and without fee is hereby granted, +# provided that the above copyright, this permission notice and text +# this comment, and the disclaimer below appear in all of the following: +# +# supporting documentation +# source copies +# source works derived from this source +# binaries derived from this source or from derived source +# +# LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO +# EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, 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. +# +# chongo (Landon Curt Noll, http://www.isthe.com/chongo/index.html) /\oo/\ +# +# Share and enjoy! :-) + +############# +# utilities # +############# + +CC= cc +CHMOD= chmod +CP= cp +INSTALL= install +RM= rm +SHELL= bash + +#CFLAGS= -O3 -g3 --pedantic -Wall -Werror +CFLAGS= -O3 -g3 --pedantic -Wall + +###################### +# target information # +###################### + +DESTDIR= ../../bin + +TARGETS= winner_name + +###################################### +# all - default rule - must be first # +###################################### + +all: ${TARGETS} + +winner_name: winner_name.sh + ${RM} -f -v $@ + ${CP} -f -v $? $@ + ${CHMOD} +x $@ + +################################################# +# .PHONY list of rules that do not create files # +################################################# + +.PHONY: all configure clean clobber install + +################################### +# standard Makefile utility rules # +################################### + +configure: + @: + +clean: + @: + +clobber: clean + rm -f ${TARGETS} + +install: all + ${INSTALL} -m 0555 ${TARGETS} ${DESTDIR} diff --git a/src/winner_name/winner_name.sh b/src/winner_name/winner_name.sh new file mode 100755 index 000000000..62e1b1334 --- /dev/null +++ b/src/winner_name/winner_name.sh @@ -0,0 +1,147 @@ +#!/usr/bin/env bash +# +# winner_name - extract NAME tags from winners.html +# +# Print NAME tags from a winners.html. By default print just the winner_id renamed NAME tags. +# +# Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved. +# +# Permission to use, copy, modify, and distribute this software and +# its documentation for any purpose and without fee is hereby granted, +# provided that the above copyright, this permission notice and text +# this comment, and the disclaimer below appear in all of the following: +# +# supporting documentation +# source copies +# source works derived from this source +# binaries derived from this source or from derived source +# +# LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO +# EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, 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. +# +# chongo (Landon Curt Noll, http://www.isthe.com/chongo/index.html) /\oo/\ +# +# Share and enjoy! :-) + +# setup +# +export VERSION="1.0 2023-05-15" +NAME=$(basename "$0") +export NAME +# +export A_FLAG= +export V_FLAG=0 +export WINNERS_HTML="./winners.html" + +# usage +# +export USAGE="usage: $0 [-h] [-v level] [-V] [-a] [winners.html] + + -h print help message and exit + -v level set verbosity level (def level: $V_FLAG) + -V print version string and exit + -a print all NAME tags (def: print just winner_id NAMEs) + + winners.html path of winners.html (def: ./winners.html) + +Exit codes: + 0 all OK + 1 winners.html does not exist, not a file, not readable + 2 -h and help string printed or -V and version string printed + 3 command line error + >= 10 internal error + +$NAME version: $VERSION" + +# parse command line +# +while getopts :hv:Va flag; do + case "$flag" in + h) echo "$USAGE" + exit 2 + ;; + v) V_FLAG="$OPTARG" + ;; + V) echo "$VERSION" + exit 2 + ;; + a) A_FLAG="true" + ;; + \?) echo "$0: ERROR: invalid option: -$OPTARG" 1>&2 + echo 1>&2 + echo "$USAGE" 1>&2 + exit 3 + ;; + :) echo "$0: ERROR: option -$OPTARG requires an argument" 1>&2 + echo 1>&2 + echo "$USAGE" 1>&2 + exit 3 + ;; + *) echo "$0: ERROR: unexpected value from getopts: $flag" 1>&2 + echo 1>&2 + echo "$USAGE" 1>&2 + exit 3 + ;; + esac +done +if [[ $V_FLAG -ge 1 ]]; then + echo "$0: debug[1]: debug level: $V_FLAG" 1>&2 +fi +# +# remove the options +# +shift $(( OPTIND - 1 )); +# +# verify arg count +# +if [[ $# -gt 1 ]]; then + echo "$0: ERROR: expected 0 or 1 args, found: $#" 1>&2 + echo "$USAGE" 1>&2 + exit 3 +fi +# +# parse args +# +if [[ $# -gt 0 ]]; then + export WINNERS_HTML="$1" +fi + +# firewall WINNERS_HTML just be a readable file +# +if [[ ! -e $WINNERS_HTML ]]; then + echo "$0: ERROR: winners.html does not exist: $WINNERS_HTML" 1>&2 + exit 1 +fi +if [[ ! -f $WINNERS_HTML ]]; then + echo "$0: ERROR: winners.html not a file: $WINNERS_HTML" 1>&2 + exit 1 +fi +if [[ ! -r $WINNERS_HTML ]]; then + echo "$0: ERROR: winners.html not a readable file: $WINNERS_HTML" 1>&2 + exit 1 +fi + +# case: print only winner_id NAME tags +# +if [[ -z $A_FLAG ]]; then + + grep -o -i '