Add preview of 1984-2019
The 2020 winners are hinted it, but the source code is not there,
nor are the hints. Someone could look into the HTML and
see what was commented out, but that is not a problem because
WHO won is known and the name of their AWARD is known already.
Moreover a number of the winners have talked about what their
entirs do, so the commented out spoiler text is not a bit problem.
One will find HTML commented out with:
<!-- XXX remove when 2020 is ready
2020 links here
XXX remove when 2020 is ready -->
The "XXX remove when 2020 is ready" string is found at the
start and end comment blocks. Again, soneone could read
what was commented out, but that is OK since most of that
information is known or can be known. The following files
have such HTML comment blocks in them.
./winners.html
./years-spoiler.html
./years.html
In addition, ./all/summary.txt was modified to not
include the 2020 entries for the momemt.
The 2020 winner code AND write-ups are NOT part of this set.
p.s. The all/all.tar.bz2 does not contain the 2020 source code (yet?).
This commit is contained in:
1 parent
28efc67f5d
commit
c0663537cb
1683 files changed
+220064
No files matched your search
@@ -0,0 +1,596 @@
|
||||
|
||||
#!/usr/bin/env make
|
||||
#
|
||||
# 2019 makefile
|
||||
#
|
||||
# This work by Landon Curt Noll, Simon Cooper, and Leonid A. Broukhis
|
||||
# is licensed under:
|
||||
#
|
||||
# Creative Commons Attribution-ShareAlike 3.0 Unported License.
|
||||
#
|
||||
# See: http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
#############################
|
||||
# shell used by this Makefile
|
||||
#############################
|
||||
#
|
||||
SHELL= /bin/bash
|
||||
|
||||
#######################
|
||||
# common tool locations
|
||||
#######################
|
||||
#
|
||||
A2P= a2p
|
||||
AR= ar
|
||||
ASA= asa
|
||||
AT= at
|
||||
ATQ= atq
|
||||
ATRM= atrm
|
||||
AWK= awk
|
||||
BANNER= banner
|
||||
BASE64= base64
|
||||
BASENAME= basename
|
||||
BATCH= batch
|
||||
BC= bc
|
||||
BINHEX= binhex
|
||||
BISON= bison
|
||||
BUNZIP2= bunzip2
|
||||
BZCAT= bzcat
|
||||
BZCMP= bzcmp
|
||||
BZDIFF= bzdiff
|
||||
BZEGREP= bzegrep
|
||||
BZFGREP= bzfgrep
|
||||
BZGREP= bzgrep
|
||||
BZIP2= bzip2
|
||||
BZLESS= bzless
|
||||
BZMORE= bzmore
|
||||
C2PH= c2ph
|
||||
C89= c89
|
||||
C99= c99
|
||||
CAL= cal
|
||||
CALC= calc
|
||||
CAT= cat
|
||||
CD= cd
|
||||
CHFLAGS= chflags
|
||||
CHGRP= chgrp
|
||||
CHMOD= chmod
|
||||
CKSUM= cksum
|
||||
CLANG= clang
|
||||
CLANG_PLUSPLUS= clang++
|
||||
CLEAR= clear
|
||||
CMP= cmp
|
||||
COL= col
|
||||
COLLDEF= colldef
|
||||
COLRM= colrm
|
||||
COLUMN= column
|
||||
COMPRESS= compress
|
||||
CP= cp
|
||||
CPIO= cpio
|
||||
CPP= cpp
|
||||
CRC32= crc32
|
||||
CSH= csh
|
||||
CSPLIT= csplit
|
||||
CURL= curl
|
||||
CUT= cut
|
||||
C_PLUSPLUS= c++
|
||||
C_PLUSPLUS_FILT= c++filt
|
||||
DATE= date
|
||||
DC= dc
|
||||
DD= dd
|
||||
DF= df
|
||||
DIFF3= diff3
|
||||
DIFF= diff
|
||||
DIG= dig
|
||||
DIRNAME= dirname
|
||||
ED= ed
|
||||
EGREP= egrep
|
||||
ENV= env
|
||||
EQN= eqn
|
||||
ETAGS= etags
|
||||
EXPECT= expect
|
||||
EXPR= expr
|
||||
FALSE= false
|
||||
FGREP= fgrep
|
||||
FILE= file
|
||||
FIND2PERL= find2perl
|
||||
FIND= find
|
||||
FLEX= flex
|
||||
FLEX_PLUSPLUS= flex++
|
||||
FMT= fmt
|
||||
FOLD= fold
|
||||
FS_USAGE= fs_usage
|
||||
FUNZIP= funzip
|
||||
FUSER= fuser
|
||||
GCC= gcc
|
||||
GDIFFMK= gdiffmk
|
||||
GENCAT= gencat
|
||||
GENSTRINGS= genstrings
|
||||
GETOPT= getopt
|
||||
GETOPTS= getopts
|
||||
GNUMAKE= gnumake
|
||||
GREP= grep
|
||||
GROFF= groff
|
||||
GROFFER= groffer
|
||||
GROG= grog
|
||||
GROPS= grops
|
||||
GROTTY= grotty
|
||||
GUNZIP= gunzip
|
||||
GVIM= gvim
|
||||
GZCAT= gzcat
|
||||
GZEXE= gzexe
|
||||
GZIP_PROG= gzip
|
||||
G_PLUSPLUS= g++
|
||||
H2PH= h2ph
|
||||
H2XS= h2xs
|
||||
HASH= hash
|
||||
HEAD= head
|
||||
HOSTNAME_PROG= hostname
|
||||
ICONV= iconv
|
||||
ID= id
|
||||
INDENT= indent
|
||||
INFO= info
|
||||
JOT= jot
|
||||
KILL= kill
|
||||
KSH= ksh
|
||||
LAST= last
|
||||
LD= ld
|
||||
LESSECHO= lessecho
|
||||
LEX= len
|
||||
LINK= link
|
||||
LN= ln
|
||||
LS= ls
|
||||
M4= m4
|
||||
MAKE= make
|
||||
MAN= man
|
||||
MKDIR= mkdir
|
||||
MKFIFo= mkfifo
|
||||
MKTEMP= mktemp
|
||||
MV= mv
|
||||
NANO= nano
|
||||
NASM= nasm
|
||||
NEQN= neqn
|
||||
NICE= nice
|
||||
NL= nl
|
||||
NM= nm
|
||||
NOHUP= nohup
|
||||
NROFF= nroff
|
||||
NSLOOKUP= nslookup
|
||||
OD= od
|
||||
OPENSSL= openssl
|
||||
PASTE= paste
|
||||
PATCH= patch
|
||||
PATHCHK= pathchk
|
||||
PAX= pax
|
||||
PERL= perl
|
||||
PICO= pico
|
||||
PR= pr
|
||||
PRINTENV= printenv
|
||||
PS= ps
|
||||
PTAR= ptar
|
||||
PTARDIFF= ptardiff
|
||||
PTARGREP= ptargrep
|
||||
PWD= pwd
|
||||
PYDOC= pydoc
|
||||
PYTHON= python
|
||||
PYTHONW= pythonw
|
||||
READLINK= readlink
|
||||
RENICE= renice
|
||||
RESET= reset
|
||||
REV= rev
|
||||
RI= ri
|
||||
RM= rm
|
||||
RMDIR= rmdir
|
||||
RSYNC= rsync
|
||||
RUBY= ruby
|
||||
RVIM= rvim
|
||||
SAY= say
|
||||
SCP= scp
|
||||
SCREEN= screen
|
||||
SCRIPT= script
|
||||
SDIFF= sdiff
|
||||
SED= sed
|
||||
SEQ= seq
|
||||
SFTP= sftp
|
||||
SH= sh
|
||||
SHA1= sha1
|
||||
SHA= sha
|
||||
SHAR= shar
|
||||
SHASUM5_18= shasum5.18
|
||||
SHASUM= shasum
|
||||
SIZE= size
|
||||
SLEEP= sleep
|
||||
SORT= sort
|
||||
SSH= ssh
|
||||
STAT= stat
|
||||
STRIP= strip
|
||||
STTY= stty
|
||||
SUM= sum
|
||||
SYNC= sync
|
||||
TABS= tabs
|
||||
TAIL= tail
|
||||
TAR= tar
|
||||
TEE= tee
|
||||
TEST= test
|
||||
TFTP= tftp
|
||||
TIDY= tidy
|
||||
TIME= time
|
||||
TOP= top
|
||||
TOUCH= touch
|
||||
TPUT= tout
|
||||
TPUT= tput
|
||||
TR= tr
|
||||
TROFF= troff
|
||||
TRUE= true
|
||||
TSET= tset
|
||||
TSORT= tsort
|
||||
UL= ul
|
||||
UNAME= uname
|
||||
UNCOMPRESS= uncompress
|
||||
UNEXPAND= unexpand
|
||||
UNIFDEF= unifdef
|
||||
UNIFDEFALL= unifdefall
|
||||
UNIQ= uniq
|
||||
UNITS= units
|
||||
UNLINK= unlink
|
||||
UNZIP= unzip
|
||||
UNZIPSFX= unzipsfx
|
||||
UPTIME= uptime
|
||||
UUDECODE= uudecode
|
||||
UUENCODE= uuencode
|
||||
UUIDGEN= uuidgen
|
||||
VI= vi
|
||||
VIEW= view
|
||||
VIM= vim
|
||||
VIMDIFF= vimdiff
|
||||
W= w
|
||||
WAIT4PATH= wait4path
|
||||
WAIT= wait
|
||||
WC= wc
|
||||
WHAT= what
|
||||
WHATIS= whatis
|
||||
WHICH= which
|
||||
WHO= who
|
||||
WHOAMI= whoami
|
||||
WHOIS= whois
|
||||
WRTIE= write
|
||||
XAR= xar
|
||||
XARGS= xargs
|
||||
XATTR= xattr
|
||||
XXD= xxd
|
||||
YACC= yacc
|
||||
YES= yes
|
||||
ZCAT= zcat
|
||||
ZCMP= zcmp
|
||||
ZDIFF= zdiff
|
||||
ZEGREP= zegrep
|
||||
ZFGREP= zfgrep
|
||||
ZFORCE= zforce
|
||||
ZGREP= zgrep
|
||||
ZIP= zip
|
||||
ZIPCLOAK= zipcloak
|
||||
ZIPGREp= zipgrep
|
||||
ZIPINFo= zipinfo
|
||||
ZIPNOTE= zipnote
|
||||
ZIPSPLIT= zipsplit
|
||||
ZLESS= zless
|
||||
ZMORE= zmore
|
||||
ZNEW= znew
|
||||
ZPRINT= zprint
|
||||
ZSH= zsh
|
||||
|
||||
# Set X11_LIBDIR to the directory where the X11 library resides
|
||||
#
|
||||
#X11_LIBDIR= /usr/X11R6/lib
|
||||
#X11_LIBDIR= /usr/X11/lib
|
||||
X11_LIBDIR= /opt/X11/lib
|
||||
|
||||
# Set X11_INCLUDEDIR to the directory where the X11 include files reside
|
||||
#
|
||||
#X11_INCDIR= /usr/X11R6/include
|
||||
#X11_INCDIR= /usr/X11/include
|
||||
X11_INCDIR= /opt/X11/include
|
||||
|
||||
# Compiler warnings
|
||||
#
|
||||
#CWARN=
|
||||
#CWARN= -Wall
|
||||
#CWARN= -Wall -Wextra
|
||||
CWARN= -Wall -Wextra -pedantic ${CSILENCE}
|
||||
#CWARN= -Wall -Wextra -Weverything
|
||||
#CWARN= -Wall -Wextra -Weverything -pedantic
|
||||
#CWARN= -Wall -Wextra -Weverything -pedantic ${CSILENCE}
|
||||
|
||||
# Silence warnings that ${CWARN} would normally complain about
|
||||
#
|
||||
#CSILENCE=
|
||||
#CSILENCE= -Wno-implicit-int
|
||||
CSILENCE=-Wno-incompatible-pointer-types -Wno-return-type -Wno-format-security \
|
||||
-Wno-bitwise-op-parentheses -Wno-logical-op-parentheses -Wno-parentheses \
|
||||
-Wno-dangling-else -Wno-implicit-int -Wno-unused-value -Wno-pedantic \
|
||||
-Wno-misleading-indentation -Wno-sequence-point -Wno-unknown-warning-option
|
||||
|
||||
# compiler standard
|
||||
#
|
||||
#CSTD=
|
||||
#CSTD= -ansi
|
||||
CSTD= -std=c11
|
||||
|
||||
# compiler bit architecture
|
||||
#
|
||||
# Some entries require 32-bitness:
|
||||
# ARCH= -m32
|
||||
#
|
||||
# Some entries require 64-bitness:
|
||||
# ARCH= -m64
|
||||
#
|
||||
# By default we assume nothing:
|
||||
#
|
||||
ARCH=
|
||||
|
||||
# defines that are needed to compile
|
||||
#
|
||||
CDEFINE=
|
||||
#CDEFINE= -DIOCCC=26
|
||||
|
||||
# include files that are needed to compile
|
||||
#
|
||||
CINCLUDE=
|
||||
#CINCLUDE= -include stdlib.h
|
||||
#CINCLUDE= -include stdio.h
|
||||
#CINCLUDE= -include stdlib.h -include stdio.h
|
||||
#CINCLUDE= -I ${X11_INCDIR}
|
||||
|
||||
# optimization
|
||||
#
|
||||
# Most compiles will safely use -O2. Some can use only -O1 or -O.
|
||||
# A few compilers have broken optimizers or this entry make break
|
||||
# under those buggy optimizers and thus you may not want anything.
|
||||
# Reasonable compilers will allow for -O3.
|
||||
#
|
||||
OPT=
|
||||
#OPT= -O
|
||||
#OPT= -O1
|
||||
#OPT= -O2
|
||||
#OPT= -O3
|
||||
|
||||
# default flags for ANSI C compilation
|
||||
#
|
||||
CFLAGS= ${CSTD} ${CWARN} ${ARCH} ${CDEFINE} ${CINCLUDE} ${OPT}
|
||||
|
||||
# Libraries needed to build
|
||||
#
|
||||
LIBS=
|
||||
#LIBS= -L ${X11_LIBDIR}
|
||||
|
||||
# ANSI compiler
|
||||
#
|
||||
# Set CC to the name of your ANSI compiler.
|
||||
#
|
||||
# Some entries seem to need gcc. If you have gcc, set
|
||||
# both CC and MAY_NEED_GCC to gcc.
|
||||
#
|
||||
# If you do not have gcc, set CC to the name of your ANSI compiler, and
|
||||
# set MAY_NEED_GCC to either ${CC} (and hope for the best) or to just :
|
||||
# to disable such programs.
|
||||
#
|
||||
CC= cc
|
||||
#CC=clang
|
||||
MAY_NEED_GCC= gcc
|
||||
|
||||
|
||||
##############################
|
||||
# Special flags for this entry
|
||||
##############################
|
||||
#
|
||||
OBJ= prog.o
|
||||
DATA=
|
||||
TARGET= prog
|
||||
#
|
||||
ALT_OBJ= prog.orig.o
|
||||
ALT_TARGET= default.orig prog.orig
|
||||
|
||||
LINES= 24
|
||||
COLUMNS= 80
|
||||
|
||||
OS_SET= Linux FreeBSD Darwin
|
||||
|
||||
#################
|
||||
# build the entry
|
||||
#################
|
||||
#
|
||||
all: ${TARGET} ${DATA}
|
||||
@${TRUE}
|
||||
|
||||
prog:
|
||||
$(MAKE) `${UNAME}`
|
||||
|
||||
check-os: check-os.sh
|
||||
${SHELL} ./check-os.sh ${LINES} ${COLUMNS}
|
||||
|
||||
error-stty:
|
||||
@echo "No stty command here. Please manually specify size in the Makefile." >&2 ; false
|
||||
|
||||
has-stty:
|
||||
which stty >/dev/null || $(MAKE) error-stty
|
||||
|
||||
fullscreen: has-stty
|
||||
$(MAKE) prog \
|
||||
LINES=`stty size | sed -s 's/ .*$$//'` \
|
||||
COLUMNS=`stty size | sed -s 's/^.* //'`
|
||||
|
||||
Darwin: prog.c
|
||||
@${RM} -f $@
|
||||
${CC} ${CFLAGS} -Dg=392 \
|
||||
-Ds=46 \
|
||||
-DV=${LINES} \
|
||||
-DW=${COLUMNS} \
|
||||
$< -o prog ${LIBS}
|
||||
${LN} prog $@
|
||||
|
||||
FreeBSD: prog.c
|
||||
@${RM} -f $@
|
||||
${CC} ${CFLAGS} -Dg=392 \
|
||||
-Ds=46 \
|
||||
-DV=${LINES} \
|
||||
-DW=${COLUMNS} \
|
||||
$< -o prog ${LIBS}
|
||||
${LN} prog $@
|
||||
|
||||
Linux: prog.c
|
||||
@${RM} -f $@
|
||||
${CC} ${CFLAGS} -Dg=11 \
|
||||
-Ds=0 \
|
||||
-DV=${LINES} \
|
||||
-DW=${COLUMNS} \
|
||||
$< -o prog ${LIBS}
|
||||
${LN} prog $@
|
||||
|
||||
# alternative executable
|
||||
#
|
||||
alt: ${ALT_TARGET}
|
||||
@${TRUE}
|
||||
|
||||
prog.orig:
|
||||
$(MAKE) `${UNAME}`.orig
|
||||
|
||||
FreeBSD.orig: prog.orig.c
|
||||
@${RM} -f $@
|
||||
${CC} ${CFLAGS} -Dg=392 \
|
||||
-Ds=46 \
|
||||
-DV=${LINES} \
|
||||
-DW=${COLUMNS} \
|
||||
$< -o prog.orig ${LIBS}
|
||||
${LN} prog.orig $@
|
||||
|
||||
Linux.orig: prog.orig.c
|
||||
@${RM} -f $@
|
||||
${CC} ${CFLAGS} -Dg=11 \
|
||||
-Ds=0 \
|
||||
-DV=${LINES} \
|
||||
-DW=${COLUMNS} \
|
||||
$< -o prog.orig ${LIBS}
|
||||
${LN} prog.orig $@
|
||||
|
||||
# data files
|
||||
#
|
||||
data: ${DATA}
|
||||
@${TRUE}
|
||||
|
||||
|
||||
###############
|
||||
# utility rules
|
||||
###############
|
||||
#
|
||||
everything: all alt
|
||||
|
||||
clean:
|
||||
${RM} -f ${OBJ} ${ALT_OBJ}
|
||||
|
||||
clobber: clean
|
||||
${RM} -f ${TARGET} ${ALT_TARGET}
|
||||
${RM} -f ${OS_SET}
|
||||
@-if [ -e sandwich ]; then \
|
||||
${RM} -f sandwich; \
|
||||
echo 'ate sandwich'; \
|
||||
fi
|
||||
|
||||
nuke: clobber
|
||||
@${TRUE}
|
||||
|
||||
dist_clean: nuke
|
||||
@${TRUE}
|
||||
|
||||
install:
|
||||
@echo "Surely you are performing, Dr. May!"
|
||||
@${TRUE}
|
||||
|
||||
# backwards compatibility
|
||||
#
|
||||
build: all
|
||||
@${TRUE}
|
||||
|
||||
|
||||
##################
|
||||
# 133t hacker rulz
|
||||
##################
|
||||
#
|
||||
love:
|
||||
@echo 'not war?'
|
||||
@${TRUE}
|
||||
|
||||
haste:
|
||||
$(MAKE) waste
|
||||
@${TRUE}
|
||||
|
||||
waste:
|
||||
@echo 'haste'
|
||||
@${TRUE}
|
||||
|
||||
make:
|
||||
@echo 'Attend a maker faire'
|
||||
@${TRUE}
|
||||
|
||||
easter_egg:
|
||||
@echo you expected to often mis-understand this $${RANDOM} magic
|
||||
@echo chongo '<was here>' "/\\oo/\\"
|
||||
@echo Eggy
|
||||
|
||||
fabricate fashion form frame manufacture produce: make
|
||||
@${TRUE}
|
||||
|
||||
sandwich:
|
||||
@if [ `id -u` -eq 0 ]; then \
|
||||
echo 'Okay.'; \
|
||||
echo $${RANDOM}`date +%s`$${RANDOM} > $@; \
|
||||
else \
|
||||
echo 'What? Make it yourself.'; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
# Understand the history of the Homebrew Computer Club
|
||||
# as well as the West Coast Computer Faire and
|
||||
# you might be confused different. :-)
|
||||
#
|
||||
supernova: nuke
|
||||
@-if [ -r .code_anal ]; then \
|
||||
${RM} -f .code_anal_v6; \
|
||||
else \
|
||||
echo "planet deniers, like some members of the IAU, are so cute when they try to defend their logic"; \
|
||||
fi
|
||||
@echo A $@ helps ${MAKE} the elements that help form planets
|
||||
@${TRUE}
|
||||
|
||||
deep_magic:
|
||||
@-if [ -r .code_anal ]; then \
|
||||
ccode_analysis --deep_magic fc6b6af226b7cc598de3d48fc20ed0bd54f7b4f7f0f651a32b9cf8345b2a3b3f --FNV1a_hash_512_bit "prog"; \
|
||||
else \
|
||||
echo "Wrong! Do it again!"; \
|
||||
sleep 2; \
|
||||
echo "Wrong! Do it again!"; \
|
||||
sleep 2; \
|
||||
echo "Wrong! Do it again!"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
|
||||
magic: deep_magic
|
||||
@-if [ -r .code_anal ]; then \
|
||||
ccode_analysis --level 391581 --mode 216193 --FNV1a_hash_512_bit "prog"; \
|
||||
else \
|
||||
echo "If you don't eat yer meat, you can't have any pudding!"; \
|
||||
echo "How can you have any pudding if you don't eat yer meat?!"; \
|
||||
fi
|
||||
@${TRUE}
|
||||
|
||||
# The IOCCC resident astronomer states
|
||||
#
|
||||
charon: supernova
|
||||
@echo $@ is a dwarf planet
|
||||
@echo dwarf is a type of planet
|
||||
@echo therefore IAU, $@ is a planet
|
||||
|
||||
pluto: supernova
|
||||
${MAKE} charon
|
||||
@echo $@ is a dwarf planet
|
||||
@echo dwarf is a type of planet
|
||||
@echo therefore, $@ is a planet
|
||||
@echo get used to having lots of planets because a $< can ${MAKE} a lot of them
|
||||
@@ -0,0 +1,33 @@
|
||||
|
||||
LINES=24
|
||||
COLUMNS=80
|
||||
CC=gcc
|
||||
|
||||
CSILENCE=-Wno-incompatible-pointer-types -Wno-return-type -Wno-format-security \
|
||||
-Wno-bitwise-op-parentheses -Wno-logical-op-parentheses \
|
||||
-Wno-dangling-else -Wno-implicit-int -Wno-unused-value
|
||||
|
||||
CFLAGS=$(CSILENCE)
|
||||
|
||||
default:
|
||||
$(MAKE) `uname`
|
||||
|
||||
check-os:
|
||||
sh check-os.sh $(LINES) $(COLUMNS)
|
||||
|
||||
FreeBSD:
|
||||
RAW_MODE=392 \
|
||||
IPC_MODE=46 \
|
||||
$(MAKE) binary
|
||||
|
||||
Linux:
|
||||
RAW_MODE=11 \
|
||||
IPC_MODE=0 \
|
||||
$(MAKE) binary
|
||||
|
||||
binary:
|
||||
$(CC) $(CFLAGS) -Dg=$$RAW_MODE \
|
||||
-Ds=$$IPC_MODE \
|
||||
-DV=$(LINES) \
|
||||
-DW=$(COLUMNS) \
|
||||
-o prog prog.c
|
||||
@@ -0,0 +1,77 @@
|
||||
#!/bin/sh
|
||||
|
||||
PROGNAME="$0"
|
||||
LINES="$1"
|
||||
COLUMNS="$2"
|
||||
|
||||
if [ "$2" = "" ]
|
||||
then
|
||||
echo "Usage: $0 <LINES> <COLUMNS>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
OS=$(uname)
|
||||
|
||||
MAGIC_VALUE_LINUX=$(((COLUMNS*28+12)*LINES+36))
|
||||
|
||||
linux_min_vals() {
|
||||
cat << EOF
|
||||
net.core.wmem_max $MAGIC_VALUE_LINUX
|
||||
net.core.wmem_default $MAGIC_VALUE_LINUX
|
||||
EOF
|
||||
}
|
||||
|
||||
MAGIC_VALUE_FREEBSD=16777216
|
||||
|
||||
freebsd_min_vals() {
|
||||
cat << EOF
|
||||
net.local.dgram.recvspace $MAGIC_VALUE_FREEBSD
|
||||
net.local.dgram.maxdgram $MAGIC_VALUE_FREEBSD
|
||||
net.local.seqpacket.recvspace $MAGIC_VALUE_FREEBSD
|
||||
net.local.seqpacket.maxseqpacket $MAGIC_VALUE_FREEBSD
|
||||
kern.ipc.maxsockbuf $((4*MAGIC_VALUE_FREEBSD))
|
||||
EOF
|
||||
}
|
||||
|
||||
list_fixup_commands() {
|
||||
while read param min_value
|
||||
do
|
||||
cur_val=$(sysctl -n $param)
|
||||
if [ "$cur_val" -lt "$min_value" ]
|
||||
then
|
||||
echo "$PROGNAME -- $ sudo sysctl $param=$min_value"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
echo
|
||||
echo "$PROGNAME -- Detected OS: $OS"
|
||||
|
||||
case "$OS" in
|
||||
"Linux")
|
||||
fixup_commands="$(linux_min_vals | list_fixup_commands)"
|
||||
;;
|
||||
"FreeBSD")
|
||||
fixup_commands="$(freebsd_min_vals | list_fixup_commands)"
|
||||
;;
|
||||
*)
|
||||
echo "$PROGNAME -- Sorry, the program has not been designed or tested for your OS!"
|
||||
exit 1 # failed, unknown OS
|
||||
esac
|
||||
|
||||
if [ -z "$fixup_commands" ]
|
||||
then
|
||||
echo "$PROGNAME -- Checking IPC parameters... OK!"
|
||||
echo
|
||||
exit # script was successful
|
||||
else
|
||||
cat << EOF
|
||||
$PROGNAME -- Checking IPC parameters... FAILED!
|
||||
|
||||
$PROGNAME -- Program compiled as ${COLUMNS}x${LINES} needs higher default IPC parameters.
|
||||
$PROGNAME -- Please run:
|
||||
$fixup_commands
|
||||
|
||||
EOF
|
||||
exit 2 # failed, OS needs higher IPC parameter values.
|
||||
fi
|
||||
@@ -0,0 +1,204 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta name="GENERATOR" content="mkd2html 2.2.0">
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset=utf-8"> <link rel="stylesheet"
|
||||
type="text/css"
|
||||
href="../hint.css">
|
||||
<title>Best collaborative graphics</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Best collaborative graphics</h1>
|
||||
|
||||
<p>Etienne Duble<br>
|
||||
<a href="https://lig-membres.imag.fr/duble">https://lig-membres.imag.fr/duble</a><br>
|
||||
Twitter: @etienne_duble</p>
|
||||
|
||||
<h2>Judges' comments:</h2>
|
||||
|
||||
<h3>To use:</h3>
|
||||
|
||||
<pre><code>make
|
||||
</code></pre>
|
||||
|
||||
<h3>Try:</h3>
|
||||
|
||||
<pre><code>./prog /tmp/drawing
|
||||
|
||||
(open another window / terminal)
|
||||
|
||||
./prog /tmp/drawing
|
||||
|
||||
(open more terminals....)
|
||||
|
||||
./prog /tmp/drawing
|
||||
</code></pre>
|
||||
|
||||
<h3>Selected Judges Remarks:</h3>
|
||||
|
||||
<p>After starting the program, use the cursor keys, then try some modes, like “p”
|
||||
or “l” (they toggle).</p>
|
||||
|
||||
<h2>Author’s comments:</h2>
|
||||
|
||||
<h3>Introduction</h3>
|
||||
|
||||
<p>This program is a <strong>graphics editor</strong>, running on the terminal.</p>
|
||||
|
||||
<p>It provides <strong>collaborative</strong> features: one can join the drawing session
|
||||
of someone else by just opening the same file!</p>
|
||||
|
||||
<h3>Getting started</h3>
|
||||
|
||||
<p>The program can run on Linux, FreeBSD, Mac OS X, and in most terminals.
|
||||
See section ‘Limits, Portability’ for more info.</p>
|
||||
|
||||
<p>To build, type <code>make</code> (assuming gcc) or <code>make CC=clang</code>.</p>
|
||||
|
||||
<p>Then you can start the program. It expects a file path as its first argument:</p>
|
||||
|
||||
<pre><code>$ ./prog /tmp/drawing
|
||||
</code></pre>
|
||||
|
||||
<p>(If not started this way, <code>prog</code> will refuse to start.)</p>
|
||||
|
||||
<p>If the file does not exist, you will start with a blank drawing.</p>
|
||||
|
||||
<p>If someone else (or another <em>instance of yourself</em>, maybe??) is already
|
||||
editing this file, you will join the session!</p>
|
||||
|
||||
<h3>Edition features</h3>
|
||||
|
||||
<ul>
|
||||
<li><strong>arrow keys</strong>: move cursor.</li>
|
||||
<li><strong>p</strong> key: enter <em>pen</em> mode (type <strong>p</strong> again to return to the default <em>move</em> mode).</li>
|
||||
<li><strong>l</strong> key: enter <em>line</em> mode (type <strong>l</strong> again to validate the line and return to the <em>move</em> mode).</li>
|
||||
<li><strong>c</strong> key: cycle through a small set of different <em>colors</em>.</li>
|
||||
<li><strong>q</strong> key: quit the editor. The drawing is automatically saved.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<p>The mode and current color is indicated at the bottom left corner of
|
||||
the editor.</p>
|
||||
|
||||
<h3>Bonus features</h3>
|
||||
|
||||
<ul>
|
||||
<li>If you just want to display the content of a drawing file, you do not
|
||||
need to start the editor. Just <strong>execute the drawing file</strong>: <code>./<the-file></code>.
|
||||
(This will fail if someone is still editing the file, though.)</li>
|
||||
<li><code>ls --color <drawing-files...></code> will probably select different colors
|
||||
to indicate whether a drawing file is being edited or not. :-)</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>Obfuscation</h3>
|
||||
|
||||
<p>You will probably have a hard time analyzing this entry, because:</p>
|
||||
|
||||
<ul>
|
||||
<li>Analyzing a system made of several communicating programs is known to
|
||||
be a complex task. (And if you think that observing a single-user drawing
|
||||
session will be a good starting point, read on.)</li>
|
||||
<li>Code coverage of single vs multi-user sessions is more or less the same. :-)</li>
|
||||
<li>Code coverage when using <em>move</em>, <em>pen</em> or <em>line</em> modes is almost the same.
|
||||
(so, is there a Bresenham algorithm somewhere??)</li>
|
||||
<li>Some OS resource values and stdlib call results are inferred.</li>
|
||||
<li>Whenever possible, variable names are reused.</li>
|
||||
<li>You might start analyzing escape code sequences right now, but warming up
|
||||
your brain is actually recommended. Start with a simple question such as:
|
||||
<em>in inverse video mode, will a space char show the foreground color or
|
||||
background color?</em></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>A few more things</h3>
|
||||
|
||||
<p>Did you notice the <code>enum</code> declaration? Could it be just an <code>int</code> or <code>const int</code>
|
||||
variable, instead? (spoiler: http://c-faq.com/ansi/constasconst.html)</p>
|
||||
|
||||
<p>If your keyboard has no arrow keys, you can probably find alternate keys by
|
||||
reading the source code.</p>
|
||||
|
||||
<h3>Limits, Portability</h3>
|
||||
|
||||
<p>I tested the program on several Linux systems, on FreeBSD 12, and on
|
||||
Mac OS X (mojave).</p>
|
||||
|
||||
<p>On Linux, the program uses an OS-specific detail to hide communication
|
||||
artefacts, and avoids the need to remove them on exit.
|
||||
Since this is Linux-specific, it was not possible on FreeBSD or Mac OS.
|
||||
Its behavior is a little more <em>dirty</em> there.</p>
|
||||
|
||||
<p>The program should work on most terminals that support 8-bit colors,
|
||||
inverse video mode, and movement escape codes, e.g. <code>xterm</code>, <code>gnome-terminal</code>,
|
||||
<code>terminator</code>, etc.</p>
|
||||
|
||||
<p>Note: the drawing files <code>prog</code> generates are probably even more portable than
|
||||
<code>prog</code> itself!</p>
|
||||
|
||||
<h3>Drawing area size</h3>
|
||||
|
||||
<p><em>The drawing area size is set at compilation time</em>.</p>
|
||||
|
||||
<p>The default size is the one of my xterm (see top of Makefile).
|
||||
You may set it to the full size of your terminal window by typing:</p>
|
||||
|
||||
<pre><code>$ make fullscreen
|
||||
</code></pre>
|
||||
|
||||
<p>IMPORTANT NOTES:</p>
|
||||
|
||||
<ul>
|
||||
<li><strong>The program compiled with a given size will fail to reload a drawing file
|
||||
with a different size!</strong></li>
|
||||
<li>No scrolling is implemented (sorry but that would be too much for rule2!),
|
||||
so any peer reaching the session should have a terminal with the same
|
||||
size or larger.</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>prog.c vs prog.orig.c</h3>
|
||||
|
||||
<p>The file <code>prog.orig.c</code> is the one I submitted.</p>
|
||||
|
||||
<p>Judges proposed a small update: the program was using macro <code>FD_SET</code> inside an
|
||||
expression, which breaks compilation on Mac OS X. Wrapping this macro into a
|
||||
function was enough to fix this compilation issue.</p>
|
||||
|
||||
<p>However, that was not enough to make the program work on Mac OS X. If you analyse
|
||||
the program you will see that it heavily relies on OS resources. And, for this
|
||||
first version of the program, you even needed to increase default <code>sysctl</code>
|
||||
parameters to make it work on FreeBSD (this was the purpose of file <code>check-os.sh</code>).
|
||||
I tried hard to tune Mac OS X the same, but failed.</p>
|
||||
|
||||
<p>The simple fact Judges proposed this update meant they wish it could work on Mac.
|
||||
And if judges wish something, it <strong>has to</strong> be done. ;)
|
||||
So I refactored a little more the program to reduce OS resources consumption.
|
||||
Or maybe not reduce consumption, but consume them differently…
|
||||
And I obtained <code>prog.c</code>. With this version, no need to touch <code>sysctl</code> parameters,
|
||||
and it works on Mac OS X too!
|
||||
I must confess it was challenging to remain below the size limit with this little
|
||||
change.</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<!--
|
||||
(c) Copyright 1984-2019, [Leo Broukhis, Simon Cooper, Landon Curt Noll][judges] - All rights reserved
|
||||
This work is licensed under a [Creative Commons Attribution-ShareAlike 3.0 Unported License][cc].
|
||||
|
||||
[judges]: http://www.ioccc.org/judges.html
|
||||
[cc]: http://creativecommons.org/licenses/by-sa/3.0/
|
||||
-->
|
||||
|
||||
<TABLE><TR>
|
||||
<TD><a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="/png/by-sa-3.0-88x31.png" /></a></TD>
|
||||
<TD><P>© Copyright 1984-2019,
|
||||
<A HREF="/judges.html">Leo Broukhis, Simon Cooper, Landon Curt Noll</A>
|
||||
- All rights reserved<BR>
|
||||
This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.</P></TD>
|
||||
<TD> <!--<a href="https://validator.w3.org/check?uri=referer"><img src="https://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>--></TD>
|
||||
</TR></TABLE>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,165 @@
|
||||
# Best collaborative graphics
|
||||
|
||||
Etienne Duble
|
||||
<https://lig-membres.imag.fr/duble>
|
||||
Twitter: @etienne_duble
|
||||
|
||||
|
||||
## Judges' comments:
|
||||
### To use:
|
||||
|
||||
make
|
||||
|
||||
### Try:
|
||||
|
||||
./prog /tmp/drawing
|
||||
|
||||
(open another window / terminal)
|
||||
|
||||
./prog /tmp/drawing
|
||||
|
||||
(open more terminals....)
|
||||
|
||||
./prog /tmp/drawing
|
||||
|
||||
### Selected Judges Remarks:
|
||||
|
||||
After starting the program, use the cursor keys, then try some modes, like "p"
|
||||
or "l" (they toggle).
|
||||
|
||||
## Author's comments:
|
||||
### Introduction
|
||||
|
||||
This program is a **graphics editor**, running on the terminal.
|
||||
|
||||
It provides **collaborative** features: one can join the drawing session
|
||||
of someone else by just opening the same file!
|
||||
|
||||
### Getting started
|
||||
|
||||
The program can run on Linux, FreeBSD, Mac OS X, and in most terminals.
|
||||
See section 'Limits, Portability' for more info.
|
||||
|
||||
To build, type `make` (assuming gcc) or `make CC=clang`.
|
||||
|
||||
Then you can start the program. It expects a file path as its first argument:
|
||||
|
||||
$ ./prog /tmp/drawing
|
||||
|
||||
(If not started this way, `prog` will refuse to start.)
|
||||
|
||||
If the file does not exist, you will start with a blank drawing.
|
||||
|
||||
If someone else (or another *instance of yourself*, maybe??) is already
|
||||
editing this file, you will join the session!
|
||||
|
||||
### Edition features
|
||||
|
||||
* **arrow keys**: move cursor.
|
||||
* **p** key: enter *pen* mode (type **p** again to return to the default *move* mode).
|
||||
* **l** key: enter *line* mode (type **l** again to validate the line and return to the *move* mode).
|
||||
* **c** key: cycle through a small set of different *colors*.
|
||||
* **q** key: quit the editor. The drawing is automatically saved.
|
||||
|
||||
The mode and current color is indicated at the bottom left corner of
|
||||
the editor.
|
||||
|
||||
### Bonus features
|
||||
|
||||
* If you just want to display the content of a drawing file, you do not
|
||||
need to start the editor. Just **execute the drawing file**: `./<the-file>`.
|
||||
(This will fail if someone is still editing the file, though.)
|
||||
* `ls --color <drawing-files...>` will probably select different colors
|
||||
to indicate whether a drawing file is being edited or not. :-)
|
||||
|
||||
### Obfuscation
|
||||
|
||||
You will probably have a hard time analyzing this entry, because:
|
||||
|
||||
* Analyzing a system made of several communicating programs is known to
|
||||
be a complex task. (And if you think that observing a single-user drawing
|
||||
session will be a good starting point, read on.)
|
||||
* Code coverage of single vs multi-user sessions is more or less the same. :-)
|
||||
* Code coverage when using *move*, *pen* or *line* modes is almost the same.
|
||||
(so, is there a Bresenham algorithm somewhere??)
|
||||
* Some OS resource values and stdlib call results are inferred.
|
||||
* Whenever possible, variable names are reused.
|
||||
* You might start analyzing escape code sequences right now, but warming up
|
||||
your brain is actually recommended. Start with a simple question such as:
|
||||
*in inverse video mode, will a space char show the foreground color or
|
||||
background color?*
|
||||
|
||||
### A few more things
|
||||
|
||||
Did you notice the `enum` declaration? Could it be just an `int` or `const int`
|
||||
variable, instead? (spoiler: http://c-faq.com/ansi/constasconst.html)
|
||||
|
||||
If your keyboard has no arrow keys, you can probably find alternate keys by
|
||||
reading the source code.
|
||||
|
||||
### Limits, Portability
|
||||
|
||||
I tested the program on several Linux systems, on FreeBSD 12, and on
|
||||
Mac OS X (mojave).
|
||||
|
||||
On Linux, the program uses an OS-specific detail to hide communication
|
||||
artefacts, and avoids the need to remove them on exit.
|
||||
Since this is Linux-specific, it was not possible on FreeBSD or Mac OS.
|
||||
Its behavior is a little more *dirty* there.
|
||||
|
||||
The program should work on most terminals that support 8-bit colors,
|
||||
inverse video mode, and movement escape codes, e.g. `xterm`, `gnome-terminal`,
|
||||
`terminator`, etc.
|
||||
|
||||
Note: the drawing files `prog` generates are probably even more portable than
|
||||
`prog` itself!
|
||||
|
||||
### Drawing area size
|
||||
|
||||
*The drawing area size is set at compilation time*.
|
||||
|
||||
The default size is the one of my xterm (see top of Makefile).
|
||||
You may set it to the full size of your terminal window by typing:
|
||||
|
||||
$ make fullscreen
|
||||
|
||||
IMPORTANT NOTES:
|
||||
|
||||
* **The program compiled with a given size will fail to reload a drawing file
|
||||
with a different size!**
|
||||
* No scrolling is implemented (sorry but that would be too much for rule2!),
|
||||
so any peer reaching the session should have a terminal with the same
|
||||
size or larger.
|
||||
|
||||
### prog.c vs prog.orig.c
|
||||
|
||||
The file `prog.orig.c` is the one I submitted.
|
||||
|
||||
Judges proposed a small update: the program was using macro `FD_SET` inside an
|
||||
expression, which breaks compilation on Mac OS X. Wrapping this macro into a
|
||||
function was enough to fix this compilation issue.
|
||||
|
||||
However, that was not enough to make the program work on Mac OS X. If you analyse
|
||||
the program you will see that it heavily relies on OS resources. And, for this
|
||||
first version of the program, you even needed to increase default `sysctl`
|
||||
parameters to make it work on FreeBSD (this was the purpose of file `check-os.sh`).
|
||||
I tried hard to tune Mac OS X the same, but failed.
|
||||
|
||||
The simple fact Judges proposed this update meant they wish it could work on Mac.
|
||||
And if judges wish something, it **has to** be done. ;)
|
||||
So I refactored a little more the program to reduce OS resources consumption.
|
||||
Or maybe not reduce consumption, but consume them differently...
|
||||
And I obtained `prog.c`. With this version, no need to touch `sysctl` parameters,
|
||||
and it works on Mac OS X too!
|
||||
I must confess it was challenging to remain below the size limit with this little
|
||||
change.
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
<!--
|
||||
(c) Copyright 1984-2019, [Leo Broukhis, Simon Cooper, Landon Curt Noll][judges] - All rights reserved
|
||||
This work is licensed under a [Creative Commons Attribution-ShareAlike 3.0 Unported License][cc].
|
||||
|
||||
[judges]: http://www.ioccc.org/judges.html
|
||||
[cc]: http://creativecommons.org/licenses/by-sa/3.0/
|
||||
-->
|
||||
@@ -0,0 +1,63 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/un.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/time.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
int a,b,c,d,e,f,h,i,j,k,l,m,n;fd_set p[1],q;struct{int A,B,C,D,E, F
|
||||
,G,H,I,J,L,K;}w ,x;r(int r){return b=r,FD_ISSET(r,p);}enum{u=V*( 11 *W
|
||||
+5)+16};t( int t){FD_SET(t,&q);}struct sockaddr_un A, B,*D,C={ .
|
||||
sun_family=1}; char v[u];unsigned int E=sizeof(B),F= sizeof( x
|
||||
);char*I="\e" "[0m\e[2J\e[0;0H",*K,*L=&C.sun_path, *M,*J =
|
||||
"\e[0;30;40" "m \0\e[0m\n\0#!/bin/cat\n\e[1A",N; O(){ n=
|
||||
0;while(++n< 9)*(n+L)=rand()%13+65;t(b=socket(1 ,2 ,0
|
||||
));n=bind(b, b==4?&B:&C,E);}struct timeval y,z ;H (
|
||||
){recvfrom(b ,&w,F,0,&A,&E),a=w.A;}Q(){close ( 4)
|
||||
;fopen(K,"r" ) &&(read(4,v,u),close(4),unlink (K )
|
||||
),O();b=3;}P ( int P){strcat(v,J+P);}G(int G ){ x.
|
||||
A=G;D=G<5?0: G ^8?&B:&A;return sendto(b,G^3 ? &
|
||||
x:&w,F,0,D,! ! D*E);}struct termios o;main ( int
|
||||
F,char**D){n = 0;for(P(18);n++<V;P(12))// ! b+12
|
||||
for(b=0;b++< W ;)P(0);if(F==2)for(K=D[1 ], t(0),
|
||||
srand(getpid ( )),strcpy(L,K),B=C,*L=s , x.J=44,
|
||||
O(),Q(),G(6);F ++-4;)for(tcsetattr(1, 0, (//IOCCC
|
||||
tcgetattr(1,&o ),o.c_lflag^=g,&o));F -4 ;) {//2019
|
||||
gettimeofday(& y,0);n=y.tv_usec;m|| ( m =(3<<19
|
||||
)+n);z.tv_usec =(m-n)%999999;b=3; *p =q ;select
|
||||
(5,p,0,0,&z)|| (x.E^=1,G(9),m=0) ; r( 0)&&(b=
|
||||
3,read(0,&N,1) ,N%=65,34^N||(x. D= x. D%6+1),
|
||||
N^47&&N^43||(x .J=N==x.J?x.E=0 , G(10 ),44:N)
|
||||
,N<4&&(x.E=0,G (9),x.F+=N==2& (x .F-=N ==3&&x.
|
||||
F)!=W-3,x.G+=N ==1&(x.G-=! N && x.G)!=V -3,x.E=
|
||||
1),x.J^43&&(x. H=x.F,x.I=x . G),G(9), 48^N||(
|
||||
x.E=0,G(9),G(7 )));if(r(4 )) if(H(),a^6 )if(a^5
|
||||
)while(++b<=c) G(3);else x .K=v[w.L],b =w.B,G(
|
||||
4);else/*O()*/ connect( (O (),x.C=b),&A ,E),b>c
|
||||
&&(c=b),G(1) ; if(r(3) ) if(H(),a^2){ a ||G(6),
|
||||
a^1||(x.B=w.C, x.D||(x. D=x.B%6+1),x. L ||G(5))
|
||||
,a^4||(v[x.L++] =w.K, x. L<u?G(5):printf ( "%s%.*"
|
||||
"s\r \e[97mmod" "e:" , I,u-6,v));if(a==7) if(x.B^
|
||||
5||close(w.B),w.B==x.B ){if(x.B==5)for(/**/ unlink(
|
||||
K),write(creat(K,511 ),v,u),b=5;++b<=c;)if (G(2)+1
|
||||
)for(H();++b<=c;)G( 0);printf(I);break;}if (a>8)//
|
||||
for(d=w.F,e=w.G,f =w.H,h=w.I,a=w.E,i=d<f?1 :-1,j=(
|
||||
f-d)*i,k=e<h?1:- 1,l=(h-e)*k,n=(j>l?j:-l)/ 2;M=34+
|
||||
(v+(e+1)*(5+W * 11 )+d*11)
|
||||
,47^w.J&&43^w . J|w.A ^
|
||||
10||(*M=w.D+ 48 ),*(M-3
|
||||
)=w.D*(w.D +48!=*M)+48,*(M-6)=w.E*7+48,*(M+2)=a?42:32 ,
|
||||
printf("" "\e[%d;%dH%.11s\e[%d;%dH\e[0;4%dm%c%s%s",e+2,
|
||||
d+2,M-8 ,V,8,x.D,x.J+65,I+8,J),f^d|e^h;)(b=n)>-j&&(n-=l
|
||||
,d+=i) ,b<l&&(n+=j,e+=k),a=0;fflush(stdout);}else//d+=i
|
||||
0+ Q(
|
||||
) ,
|
||||
G (6
|
||||
), G(
|
||||
8) ;
|
||||
}}
|
||||
@@ -0,0 +1,63 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/un.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/time.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
struct sockaddr_un u,v={.sun_family=1},*w=&v,x;struct timeval b,c ;
|
||||
fd_set r,t[ 1]; enum{z=V*(11*W+5)+15};struct{int A,B,C,D,E,F,G,H ,I ;
|
||||
char J,K[z];}A ,B;y(int y){return FD_ISSET(y,t);} int d,e,f,h, i,
|
||||
j,k,l,m,n,o,p, q;unsigned int I=sizeof(x),J=sizeof(B );char* E
|
||||
=B.K,*D="\e[" "0;30;40m \0\e[0m\n\0#!/bin/cat\n\e" "[1A" ,
|
||||
*C="\e[0m\e" "[2J\e[0;0H",*F,*G=&v.sun_path,H;K( int K)
|
||||
{strcat(E,D+ K);}struct termios a;N(){p=0;while ( ++
|
||||
p<9)*(p+ G)= rand()%13+65;p=bind(d=socket(1,2, 0) ,
|
||||
w,I);FD_SET( d,&r);}O(){close(4);fopen(F,"r" ) &&
|
||||
(read(4,B.K, z ),close(4),unlink(F)),w=&x;N() ;d =
|
||||
3;}L(int L){ B .A=L;return sendto(d,&B,J,0,w ,I *!
|
||||
!w);}M(int M ) {return recvfrom(M,&A,J,0,&u , &
|
||||
I);}main(int P ,char**Q){for(p=0,K(18);p++ <V ;K(
|
||||
12))for(d=0; d ++<W;)K(0);if(P==2) for(F= Q [1],
|
||||
srand(getpid ( )),FD_SET(0,&r),strcpy(G ,F ),x=v
|
||||
,*G=s,B.J=44 , N(),O(),L(0);P++-4;)for ( (float)
|
||||
tcsetattr(1,0, ((int)tcgetattr(1,& a) ,a .c_lflag
|
||||
^=g,&a));P-4;) {gettimeofday(& b,0); p= b. tv_usec
|
||||
;q||(q=(3<<19) +p);c.tv_usec=0+(q-p ) % 999999;
|
||||
d=3;w=&x;*t=r; select(5,t,0,0,&c) || (B .E^=1,L
|
||||
(7),q=0);y( 0) &&(!read(0,&H,1), H %= 65,H^34
|
||||
||(B.D=B.D%6+1 ),H^47&&H^43||(B .J =H ==B.J?B
|
||||
.E=0,L(8),44:H ),H<4&&(B.E=0,L ( 7),B .F+=H==
|
||||
2&(B.F-=H==3&& B.F)!=W-3,B. G += H==1& (B.G-=!
|
||||
H&&B.G)!=V-3,B .E=1),B.J^ 43 && (B.H=B. F,B.I=B
|
||||
.G),L( 7),H^48 ||(B.E=0,L( 7 ),L(2))) ;if(y(4
|
||||
))if(M(4),p=4, A.A)while( ++ p<=e)send( p,&A,J,
|
||||
0);else w= &v, connect(( N (),B.C=d),& u,I),d>
|
||||
e&&(e=d),w=0,L (4);if(y (3 ))if(M(3),A. A^5){A.
|
||||
A^1||L(+0),A.A ^4||(B. B ||printf("%s%" ".*s\r"
|
||||
" \e[97mmode:" ,C,z-5,A .K),B.B=A.C,B.D ||(B.D=
|
||||
B.B%6+1),strcpy (B.K, A. K));if(A.A==2)if( B.B^5||
|
||||
close(A.B),A. B ==B. B ){if(6==1+B.B)for( unlink(
|
||||
F),write(creat(F,511), B.K,z),d=5,w=0;++d<= e;)if(L
|
||||
(5)+1)for(M(d);++d<= e;)L(1);(int)printf(C );break
|
||||
;}if(A.A>6)for(h=A. F,i=A.G,j=A.H,k=A.I,f= A.E,l=h
|
||||
<j?1:-1,m=(j-h)*l ,n=i<k?1:-1,o=(k-i)*n,p= (m>o?m:
|
||||
-o)/2;E=34+(B.K+ (i+1)*(5+W*11)+h*11),47^A .J&&43^
|
||||
A.J|8^A.A||(*E= 48 +A.D),*
|
||||
(E-3)=A.D*(A. D +48!=*E
|
||||
)+48,*(E-6)= A. E*7+48,
|
||||
*(E+2)=f ? 42:32,printf("\e[%d;%dH%.11s\e[%d;%dH\e[0;4"
|
||||
"%dm%c%s" "%s",2+i,h+2,E-8,V,8,B.D,B.J+65,C+8,D),j^h|i^
|
||||
k;)(d=p )>-m&&(p-=o,h+=l),d<o&&(p+=m,i+=n),f=0;fflush (
|
||||
stdout );}else&v+111,(unsigned int)O(),/* IOCCC 2019 */
|
||||
+L (0
|
||||
) ,
|
||||
w =&
|
||||
u, L(
|
||||
6) ;
|
||||
}}
|
||||
Reference in new issue
Block a user