publicfile-0.52 755 0 0 16000 7011746002 7651 5 ustar 00 publicfile-0.52/README 644 0 0 306 7011746002 10540 0 ustar 00 publicfile 0.52, alpha.
19991109
Copyright 1999
D. J. Bernstein
publicfile home page: http://pobox.com/~djb/publicfile.html
Installation instructions: http://pobox.com/~djb/publicfile/install.html
publicfile-0.52/TODO 644 0 0 367 7011746002 10357 0 ustar 00 upgrade to iopause
rely on tcpserver for OOBINLINE
document use of leapsecs.dat in httpd
include tools to create index.html
include tools to create ~/public
consider other protocols
consider redirection instead of silent rewriting for index.html
publicfile-0.52/CHANGES 644 0 0 2076 7011746002 10701 0 ustar 00 19991105
version: publicfile 0.50, alpha.
19991108
bug: ftpd passed contents of remote PASV IP address to byte_diff
instead of pointer. impact: normal behavior becomes very
unlikely; the other possibilities are SEGV or exit with
a bad error message. tnx Chris Johnson. fix: insert &.
bug: spsv printed first two bytes of IP address. impact: none;
spsv is just for testing. fix: use port number instead.
internal: rts now covers ftpd much more seriously.
ui: httpd now requires uppercase HEAD, GET. tnx Marc Slemko.
version: publicfile 0.51, alpha.
19991109
port: Linux sh barfs on ";" as empty separator between "then"
and "else". impact: rts aborts. fix: use ":" instead.
ui: main.c now indicates errors with exit codes.
internal: eliminated strerr from httpd, ftpd.
internal: separated httpdate.c. rewrote as a stralloc routine.
internal: revamped date handling in httpd.c.
ui: minimal support for If-Modified-Since. 9 lines of code.
internal: separated pathdecode.c.
internal: added utime; rts now covers modification times.
version: publicfile 0.52, alpha.
publicfile-0.52/VERSION 644 0 0 20 7011746002 10701 0 ustar 00 publicfile 0.52
publicfile-0.52/FILES 644 0 0 3277 7011746002 10477 0 ustar 00 README
TODO
CHANGES
VERSION
FILES
SYSDEPS
TARGETS
Makefile
conf-cc
conf-ld
conf-home
rts.sh
rts.tests
rts.exp
utime.c
configure.c
httpd.c
ftpd.c
main.c
file.h
file.c
pathdecode.h
pathdecode.c
filetype.h
filetype.c
httpdate.h
httpdate.c
percent.h
percent.c
fetch.h
fetch.c
timeoutaccept.h
timeoutaccept.c
hasdevtcp.h1
hasdevtcp.h2
choose.sh
warn-auto.sh
find-systype.sh
trycpp.c
auto-str.c
auto_home.h
install.c
instcheck.c
hier.c
alloc.c
alloc.h
alloc_re.c
byte.h
byte_chr.c
byte_copy.c
byte_cr.c
byte_diff.c
byte_rchr.c
byte_zero.c
caldate.h
caldate_fmjd.c
caltime.h
caltime_utc.c
case.h
case_diffs.c
case_lowerb.c
case_startb.c
chkshsgr.c
direntry.h1
direntry.h2
env.c
env.h
error.c
error.h
error_str.c
error_temp.c
exit.h
fmt.h
fmt_str.c
fmt_uint.c
fmt_ulong.c
fmt_xlong.c
gen_alloc.h
gen_allocdefs.h
getln.c
getln.h
getln2.c
hassgact.h1
hassgact.h2
hassgprm.h1
hassgprm.h2
hasshsgr.h1
hasshsgr.h2
ip.c
ip.h
leapsecs.dat
leapsecs.h
leapsecs_init.c
leapsecs_read.c
leapsecs_sub.c
ndelay.h
ndelay_off.c
ndelay_on.c
open.h
open_read.c
open_trunc.c
prot.c
prot.h
readwrite.h
scan.h
scan_ulong.c
select.h1
select.h2
sig.h
sig_block.c
sig_catch.c
sig_pause.c
sig_pipe.c
str.h
str_chr.c
str_diff.c
str_len.c
str_rchr.c
str_start.c
stralloc.h
stralloc_cat.c
stralloc_catb.c
stralloc_cats.c
stralloc_copy.c
stralloc_eady.c
stralloc_num.c
stralloc_opyb.c
stralloc_opys.c
stralloc_pend.c
strerr.h
strerr_die.c
strerr_sys.c
subfd.h
subfderr.c
substdi.c
substdio.c
substdio.h
substdio_copy.c
substdo.c
tai.h
tai_now.c
tai_sub.c
tai_unpack.c
timeoutconn.c
timeoutconn.h
timeoutread.c
timeoutread.h
timeoutwrite.c
timeoutwrite.h
trydrent.c
trylsock.c
trysgact.c
trysgprm.c
tryshsgr.c
trysysel.c
tryulong64.c
uint64.h1
uint64.h2
warn-shsgr
publicfile-0.52/SYSDEPS 644 0 0 131 7011746002 10731 0 ustar 00 VERSION
systype
hasshsgr.h
hassgact.h
hassgprm.h
select.h
uint64.h
direntry.h
socket.lib
publicfile-0.52/TARGETS 644 0 0 2401 7011746002 10732 0 ustar 00 load
compile
systype
hasdevtcp.h
configure.o
auto-str.o
makelib
substdio.o
substdi.o
substdo.o
substdio_copy.o
subfderr.o
substdio.a
error.o
error_str.o
error_temp.o
error.a
byte_chr.o
byte_copy.o
byte_cr.o
byte_diff.o
byte_rchr.o
byte_zero.o
str_chr.o
str_diff.o
str_len.o
str_rchr.o
str_start.o
str.a
auto-str
auto_home.c
auto_home.o
strerr_die.o
strerr_sys.o
strerr.a
open_read.o
open_trunc.o
open.a
configure
choose
uint64.h
httpd.o
main.o
pathdecode.o
file.o
filetype.o
httpdate.o
percent.o
chkshsgr.o
chkshsgr
hasshsgr.h
prot.o
select.h
timeoutread.o
timeoutwrite.o
caldate_fmjd.o
caltime_utc.o
leapsecs_init.o
leapsecs_read.o
leapsecs_sub.o
tai_now.o
tai_sub.o
tai_unpack.o
libtai.a
case_diffs.o
case_lowerb.o
case_startb.o
case.a
getln.o
getln2.o
getln.a
stralloc_cat.o
stralloc_catb.o
stralloc_cats.o
stralloc_copy.o
stralloc_eady.o
stralloc_opyb.o
stralloc_opys.o
stralloc_pend.o
stralloc_num.o
stralloc.a
alloc.o
alloc_re.o
alloc.a
hassgprm.h
sig_block.o
hassgact.h
sig_catch.o
sig_pause.o
sig_pipe.o
sig.a
env.o
env.a
fmt_str.o
fmt_uint.o
fmt_ulong.o
fmt_xlong.o
scan_ulong.o
fs.a
socket.lib
httpd
ftpd.o
direntry.h
fetch.o
ip.o
timeoutconn.o
timeoutaccept.o
ndelay_on.o
ndelay_off.o
ndelay.a
ftpd
rts
prog
install.o
hier.o
install
instcheck.o
instcheck
it
setup
check
publicfile-0.52/Makefile 644 0 0 32037 7011746002 11366 0 ustar 00 # Don't edit Makefile! Use conf-* for configuration.
SHELL=/bin/sh
default: it
alloc.a: \
makelib alloc.o alloc_re.o
./makelib alloc.a alloc.o alloc_re.o
alloc.o: \
compile alloc.c alloc.h error.h
./compile alloc.c
alloc_re.o: \
compile alloc_re.c alloc.h byte.h
./compile alloc_re.c
auto-str: \
load auto-str.o substdio.a error.a str.a
./load auto-str substdio.a error.a str.a
auto-str.o: \
compile auto-str.c substdio.h readwrite.h exit.h
./compile auto-str.c
auto_home.c: \
auto-str conf-home
./auto-str auto_home `head -1 conf-home` > auto_home.c
auto_home.o: \
compile auto_home.c
./compile auto_home.c
byte_chr.o: \
compile byte_chr.c byte.h
./compile byte_chr.c
byte_copy.o: \
compile byte_copy.c byte.h
./compile byte_copy.c
byte_cr.o: \
compile byte_cr.c byte.h
./compile byte_cr.c
byte_diff.o: \
compile byte_diff.c byte.h
./compile byte_diff.c
byte_rchr.o: \
compile byte_rchr.c byte.h
./compile byte_rchr.c
byte_zero.o: \
compile byte_zero.c byte.h
./compile byte_zero.c
caldate_fmjd.o: \
compile caldate_fmjd.c caldate.h
./compile caldate_fmjd.c
caltime_utc.o: \
compile caltime_utc.c tai.h uint64.h leapsecs.h caldate.h caltime.h \
caldate.h
./compile caltime_utc.c
case.a: \
makelib case_diffs.o case_lowerb.o case_startb.o
./makelib case.a case_diffs.o case_lowerb.o case_startb.o
case_diffs.o: \
compile case_diffs.c case.h
./compile case_diffs.c
case_lowerb.o: \
compile case_lowerb.c case.h
./compile case_lowerb.c
case_startb.o: \
compile case_startb.c case.h
./compile case_startb.c
check: \
it instcheck
./instcheck
chkshsgr: \
load chkshsgr.o
./load chkshsgr
chkshsgr.o: \
compile chkshsgr.c exit.h
./compile chkshsgr.c
choose: \
warn-auto.sh choose.sh conf-home
cat warn-auto.sh choose.sh \
| sed s}HOME}"`head -1 conf-home`"}g \
> choose
chmod 755 choose
compile: \
warn-auto.sh conf-cc
( cat warn-auto.sh; \
echo exec "`head -1 conf-cc`" '-c $${1+"$$@"}' \
) > compile
chmod 755 compile
configure: \
load configure.o auto_home.o strerr.a substdio.a error.a open.a str.a
./load configure auto_home.o strerr.a substdio.a error.a \
open.a str.a
configure.o: \
compile configure.c hasdevtcp.h strerr.h substdio.h open.h \
readwrite.h exit.h auto_home.h
./compile configure.c
direntry.h: \
choose compile trydrent.c direntry.h1 direntry.h2
./choose c trydrent direntry.h1 direntry.h2 > direntry.h
env.a: \
makelib env.o
./makelib env.a env.o
env.o: \
compile env.c str.h env.h
./compile env.c
error.a: \
makelib error.o error_str.o error_temp.o
./makelib error.a error.o error_str.o error_temp.o
error.o: \
compile error.c error.h
./compile error.c
error_str.o: \
compile error_str.c error.h
./compile error_str.c
error_temp.o: \
compile error_temp.c error.h
./compile error_temp.c
fetch.o: \
compile fetch.c substdio.h timeoutwrite.h error.h exit.h direntry.h \
fmt.h fetch.h
./compile fetch.c
file.o: \
compile file.c subfd.h substdio.h error.h file.h tai.h uint64.h \
byte.h str.h tai.h env.h
./compile file.c
filetype.o: \
compile filetype.c filetype.h stralloc.h gen_alloc.h str.h
./compile filetype.c
fmt_str.o: \
compile fmt_str.c fmt.h
./compile fmt_str.c
fmt_uint.o: \
compile fmt_uint.c fmt.h
./compile fmt_uint.c
fmt_ulong.o: \
compile fmt_ulong.c fmt.h
./compile fmt_ulong.c
fmt_xlong.o: \
compile fmt_xlong.c fmt.h
./compile fmt_xlong.c
fs.a: \
makelib fmt_str.o fmt_uint.o fmt_ulong.o fmt_xlong.o scan_ulong.o
./makelib fs.a fmt_str.o fmt_uint.o fmt_ulong.o \
fmt_xlong.o scan_ulong.o
ftpd: \
load ftpd.o main.o prot.o pathdecode.o file.o fetch.o ip.o \
timeoutread.o timeoutwrite.o timeoutconn.o timeoutaccept.o ndelay.a \
env.a sig.a substdio.a stralloc.a alloc.a error.a open.a case.a str.a \
fs.a socket.lib
./load ftpd main.o prot.o pathdecode.o file.o fetch.o ip.o \
timeoutread.o timeoutwrite.o timeoutconn.o timeoutaccept.o \
ndelay.a env.a sig.a substdio.a stralloc.a alloc.a error.a \
open.a case.a str.a fs.a `cat socket.lib`
ftpd.o: \
compile ftpd.c timeoutconn.h timeoutaccept.h timeoutread.h \
timeoutwrite.h substdio.h fetch.h pathdecode.h stralloc.h gen_alloc.h \
file.h tai.h uint64.h sig.h tai.h stralloc.h str.h error.h case.h \
byte.h env.h fmt.h scan.h ip.h
./compile ftpd.c
getln.a: \
makelib getln.o getln2.o
./makelib getln.a getln.o getln2.o
getln.o: \
compile getln.c substdio.h byte.h stralloc.h gen_alloc.h getln.h
./compile getln.c
getln2.o: \
compile getln2.c substdio.h stralloc.h gen_alloc.h byte.h getln.h
./compile getln2.c
hasdevtcp.h: \
systype hasdevtcp.h1 hasdevtcp.h2
( case "`cat systype`" in \
sunos-5.*) cat hasdevtcp.h2 ;; \
*) cat hasdevtcp.h1 ;; \
esac ) > hasdevtcp.h
hassgact.h: \
choose compile load trysgact.c hassgact.h1 hassgact.h2
./choose cl trysgact hassgact.h1 hassgact.h2 > hassgact.h
hassgprm.h: \
choose compile load trysgprm.c hassgprm.h1 hassgprm.h2
./choose cl trysgprm hassgprm.h1 hassgprm.h2 > hassgprm.h
hasshsgr.h: \
choose compile load tryshsgr.c hasshsgr.h1 hasshsgr.h2 chkshsgr \
warn-shsgr
./chkshsgr || ( cat warn-shsgr; exit 1 )
./choose clr tryshsgr hasshsgr.h1 hasshsgr.h2 > hasshsgr.h
hier.o: \
compile hier.c auto_home.h
./compile hier.c
httpd: \
load httpd.o main.o pathdecode.o file.o filetype.o httpdate.o \
percent.o prot.o timeoutread.o timeoutwrite.o libtai.a case.a getln.a \
stralloc.a alloc.a substdio.a error.a open.a sig.a env.a str.a fs.a \
socket.lib
./load httpd main.o pathdecode.o file.o filetype.o \
httpdate.o percent.o prot.o timeoutread.o timeoutwrite.o \
libtai.a case.a getln.a stralloc.a alloc.a substdio.a \
error.a open.a sig.a env.a str.a fs.a `cat socket.lib`
httpd.o: \
compile httpd.c pathdecode.h stralloc.h gen_alloc.h file.h tai.h \
uint64.h filetype.h stralloc.h percent.h stralloc.h stralloc.h sig.h \
exit.h fmt.h case.h str.h tai.h httpdate.h stralloc.h tai.h \
timeoutread.h timeoutwrite.h substdio.h error.h getln.h
./compile httpd.c
httpdate.o: \
compile httpdate.c caltime.h caldate.h httpdate.h stralloc.h \
gen_alloc.h tai.h uint64.h
./compile httpdate.c
install: \
load install.o hier.o auto_home.o strerr.a substdio.a open.a error.a \
str.a
./load install hier.o auto_home.o strerr.a substdio.a \
open.a error.a str.a
install.o: \
compile install.c substdio.h strerr.h error.h open.h readwrite.h \
exit.h
./compile install.c
instcheck: \
load instcheck.o hier.o auto_home.o strerr.a substdio.a error.a str.a
./load instcheck hier.o auto_home.o strerr.a substdio.a \
error.a str.a
instcheck.o: \
compile instcheck.c strerr.h error.h readwrite.h exit.h
./compile instcheck.c
ip.o: \
compile ip.c fmt.h scan.h ip.h
./compile ip.c
it: \
prog install instcheck
leapsecs_init.o: \
compile leapsecs_init.c leapsecs.h
./compile leapsecs_init.c
leapsecs_read.o: \
compile leapsecs_read.c tai.h uint64.h leapsecs.h
./compile leapsecs_read.c
leapsecs_sub.o: \
compile leapsecs_sub.c leapsecs.h tai.h uint64.h
./compile leapsecs_sub.c
libtai.a: \
makelib caldate_fmjd.o caltime_utc.o leapsecs_init.o leapsecs_read.o \
leapsecs_sub.o tai_now.o tai_sub.o tai_unpack.o
./makelib libtai.a caldate_fmjd.o caltime_utc.o \
leapsecs_init.o leapsecs_read.o leapsecs_sub.o tai_now.o \
tai_sub.o tai_unpack.o
load: \
warn-auto.sh conf-ld
( cat warn-auto.sh; \
echo 'main="$$1"; shift'; \
echo exec "`head -1 conf-ld`" \
'-o "$$main" "$$main".o $${1+"$$@"}' \
) > load
chmod 755 load
main.o: \
compile main.c env.h exit.h scan.h
./compile main.c
makelib: \
warn-auto.sh systype
( cat warn-auto.sh; \
echo 'main="$$1"; shift'; \
echo 'rm -f "$$main"'; \
echo 'ar cr "$$main" $${1+"$$@"}'; \
case "`cat systype`" in \
sunos-5.*) ;; \
unix_sv*) ;; \
irix64-*) ;; \
irix-*) ;; \
dgux-*) ;; \
hp-ux-*) ;; \
sco*) ;; \
*) echo 'ranlib "$$main"' ;; \
esac \
) > makelib
chmod 755 makelib
ndelay.a: \
makelib ndelay_on.o ndelay_off.o
./makelib ndelay.a ndelay_on.o ndelay_off.o
ndelay_off.o: \
compile ndelay_off.c ndelay.h
./compile ndelay_off.c
ndelay_on.o: \
compile ndelay_on.c ndelay.h
./compile ndelay_on.c
open.a: \
makelib open_read.o open_trunc.o
./makelib open.a open_read.o open_trunc.o
open_read.o: \
compile open_read.c open.h
./compile open_read.c
open_trunc.o: \
compile open_trunc.c open.h
./compile open_trunc.c
pathdecode.o: \
compile pathdecode.c pathdecode.h stralloc.h gen_alloc.h
./compile pathdecode.c
percent.o: \
compile percent.c percent.h stralloc.h gen_alloc.h
./compile percent.c
prog: \
configure httpd ftpd rts utime
prot.o: \
compile prot.c hasshsgr.h prot.h
./compile prot.c
rts: \
warn-auto.sh rts.sh conf-home
cat warn-auto.sh rts.sh \
| sed s}HOME}"`head -1 conf-home`"}g \
> rts
chmod 755 rts
scan_ulong.o: \
compile scan_ulong.c scan.h
./compile scan_ulong.c
select.h: \
choose compile trysysel.c select.h1 select.h2
./choose c trysysel select.h1 select.h2 > select.h
setup: \
it install
./install
sig.a: \
makelib sig_block.o sig_catch.o sig_pause.o sig_pipe.o
./makelib sig.a sig_block.o sig_catch.o sig_pause.o \
sig_pipe.o
sig_block.o: \
compile sig_block.c sig.h hassgprm.h
./compile sig_block.c
sig_catch.o: \
compile sig_catch.c sig.h hassgact.h
./compile sig_catch.c
sig_pause.o: \
compile sig_pause.c sig.h hassgprm.h
./compile sig_pause.c
sig_pipe.o: \
compile sig_pipe.c sig.h
./compile sig_pipe.c
socket.lib: \
trylsock.c compile load
( ( ./compile trylsock.c && \
./load trylsock -lsocket -lnsl ) >/dev/null 2>&1 \
&& echo -lsocket -lnsl || exit 0 ) > socket.lib
rm -f trylsock.o trylsock
str.a: \
makelib byte_chr.o byte_copy.o byte_cr.o byte_diff.o byte_rchr.o \
byte_zero.o str_chr.o str_diff.o str_len.o str_rchr.o str_start.o
./makelib str.a byte_chr.o byte_copy.o byte_cr.o \
byte_diff.o byte_rchr.o byte_zero.o str_chr.o str_diff.o \
str_len.o str_rchr.o str_start.o
str_chr.o: \
compile str_chr.c str.h
./compile str_chr.c
str_diff.o: \
compile str_diff.c str.h
./compile str_diff.c
str_len.o: \
compile str_len.c str.h
./compile str_len.c
str_rchr.o: \
compile str_rchr.c str.h
./compile str_rchr.c
str_start.o: \
compile str_start.c str.h
./compile str_start.c
stralloc.a: \
makelib stralloc_cat.o stralloc_catb.o stralloc_cats.o \
stralloc_copy.o stralloc_eady.o stralloc_opyb.o stralloc_opys.o \
stralloc_pend.o stralloc_num.o
./makelib stralloc.a stralloc_cat.o stralloc_catb.o \
stralloc_cats.o stralloc_copy.o stralloc_eady.o \
stralloc_opyb.o stralloc_opys.o stralloc_pend.o \
stralloc_num.o
stralloc_cat.o: \
compile stralloc_cat.c byte.h stralloc.h gen_alloc.h
./compile stralloc_cat.c
stralloc_catb.o: \
compile stralloc_catb.c stralloc.h gen_alloc.h byte.h
./compile stralloc_catb.c
stralloc_cats.o: \
compile stralloc_cats.c byte.h str.h stralloc.h gen_alloc.h
./compile stralloc_cats.c
stralloc_copy.o: \
compile stralloc_copy.c byte.h stralloc.h gen_alloc.h
./compile stralloc_copy.c
stralloc_eady.o: \
compile stralloc_eady.c alloc.h stralloc.h gen_alloc.h \
gen_allocdefs.h
./compile stralloc_eady.c
stralloc_num.o: \
compile stralloc_num.c stralloc.h gen_alloc.h
./compile stralloc_num.c
stralloc_opyb.o: \
compile stralloc_opyb.c stralloc.h gen_alloc.h byte.h
./compile stralloc_opyb.c
stralloc_opys.o: \
compile stralloc_opys.c byte.h str.h stralloc.h gen_alloc.h
./compile stralloc_opys.c
stralloc_pend.o: \
compile stralloc_pend.c alloc.h stralloc.h gen_alloc.h \
gen_allocdefs.h
./compile stralloc_pend.c
strerr.a: \
makelib strerr_die.o strerr_sys.o
./makelib strerr.a strerr_die.o strerr_sys.o
strerr_die.o: \
compile strerr_die.c substdio.h subfd.h substdio.h exit.h strerr.h
./compile strerr_die.c
strerr_sys.o: \
compile strerr_sys.c error.h strerr.h
./compile strerr_sys.c
subfderr.o: \
compile subfderr.c readwrite.h substdio.h subfd.h substdio.h
./compile subfderr.c
substdi.o: \
compile substdi.c substdio.h byte.h error.h
./compile substdi.c
substdio.a: \
makelib substdio.o substdi.o substdo.o substdio_copy.o subfderr.o
./makelib substdio.a substdio.o substdi.o substdo.o \
substdio_copy.o subfderr.o
substdio.o: \
compile substdio.c substdio.h
./compile substdio.c
substdio_copy.o: \
compile substdio_copy.c substdio.h
./compile substdio_copy.c
substdo.o: \
compile substdo.c substdio.h str.h byte.h error.h
./compile substdo.c
systype: \
find-systype.sh conf-cc conf-ld trycpp.c
( cat warn-auto.sh; \
echo CC=\'`head -1 conf-cc`\'; \
echo LD=\'`head -1 conf-ld`\'; \
cat find-systype.sh; \
) | sh > systype
tai_now.o: \
compile tai_now.c tai.h uint64.h
./compile tai_now.c
tai_sub.o: \
compile tai_sub.c tai.h uint64.h
./compile tai_sub.c
tai_unpack.o: \
compile tai_unpack.c tai.h uint64.h
./compile tai_unpack.c
timeoutaccept.o: \
compile timeoutaccept.c timeoutaccept.h ndelay.h select.h error.h \
readwrite.h
./compile timeoutaccept.c
timeoutconn.o: \
compile timeoutconn.c ndelay.h select.h error.h readwrite.h ip.h \
byte.h timeoutconn.h
./compile timeoutconn.c
timeoutread.o: \
compile timeoutread.c timeoutread.h select.h error.h readwrite.h
./compile timeoutread.c
timeoutwrite.o: \
compile timeoutwrite.c timeoutwrite.h select.h error.h readwrite.h
./compile timeoutwrite.c
uint64.h: \
choose compile load tryulong64.c uint64.h1 uint64.h2
./choose clr tryulong64 uint64.h1 uint64.h2 > uint64.h
utime: \
load utime.o fs.a
./load utime fs.a
utime.o: \
compile utime.c scan.h exit.h
./compile utime.c
publicfile-0.52/conf-cc 644 0 0 60 7011746002 11070 0 ustar 00 gcc -O2
This will be used to compile .c files.
publicfile-0.52/conf-ld 644 0 0 77 7011746002 11112 0 ustar 00 gcc -s
This will be used to link .o files into an executable.
publicfile-0.52/conf-home 644 0 0 145 7011746002 11457 0 ustar 00 /usr/local/publicfile
This is the publicfile home directory. Programs will be installed in
.../bin.
publicfile-0.52/rts.sh 644 0 0 60 7011746002 11001 0 ustar 00 env - PATH=".:$PATH" sh rts.tests 2>&1 | cat -v
publicfile-0.52/rts.tests 644 0 0 30105 7011746002 11614 0 ustar 00 # not tested:
# configure
# httpd chroot
# httpd setgid
# httpd setuid
# httpd Date: accuracy
# httpd timeout
# httpd temporary errors
# ftpd chroot
# ftpd setgid
# ftpd setuid
# ftpd timeout
# ftpd temporary errors
# ftpd PORT connection
# ftpd skips control characters, tildes, leading dots in file lists
# ftpd inode accuracy
umask 022
TCPREMOTEIP=1.2.3.4; export TCPREMOTEIP
echo '--- httpd handles HTTP/0.9 GET'
rm -rf 0
mkdir 0
echo 'Hello, world' > 0/foo
echo 'GET foo' | ./httpd; echo $?
echo '--- httpd handles %xx'
rm -rf 0
mkdir 0
echo 'Hello, world' > 0/foo
echo 'GET %66%6F%6f' | ./httpd; echo $?
echo '--- httpd handles HTTP/1.0 GET'
echo 'GET foo HTTP/1.0
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd handles HTTP/1.0 HEAD'
echo 'HEAD foo HTTP/1.0
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd handles HTTP/1.1 GET with absolute URL'
echo 'GET http://0/foo HTTP/1.1
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd handles HTTP/1.1 GET with Host'
echo 'GET foo HTTP/1.1
One: Two
Host: 0
Three: Four
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd rejects HTTP/1.1 GET without host'
echo 'GET foo HTTP/1.1
' | ./httpd 2>&1 | sed 's/^Date: .*/Date: .../'
echo '--- httpd handles HTTP/1.1 HEAD'
echo 'HEAD http://0/foo HTTP/1.1
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd handles multiple HTTP/1.1 requests'
echo 'Hi' > 0/bar
echo 'GET http://0/foo HTTP/1.1
GET http://0/bar HTTP/1.1
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd prints error message for ENOENT'
echo 'GET nonexistent HTTP/1.0
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd omits body from HEAD error message'
echo 'HEAD nonexistent HTTP/1.0
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd prints error message for ELOOP'
ln -s loop 0/loop
echo 'GET loop HTTP/1.0
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd prints error message for file not group-readable'
echo wrong > 0/unreadable
chmod 604 0/unreadable
echo 'GET unreadable HTTP/1.0
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd prints error message for file not world-readable'
chmod 640 0/unreadable
echo 'GET unreadable HTTP/1.0
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd prints error message for 101 001'
chmod 645 0/unreadable
echo 'GET unreadable HTTP/1.0
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd prints error message for directory'
mkdir 0/subdirectory
echo 'GET subdirectory HTTP/1.0
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd lowercases host names'
rm -rf 0virtual
mkdir 0virtual
echo '
Virtual' > 0virtual/index.html
echo 'GET index.html HTTP/1.0
Host: 0Virtual
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd does index.html rewriting'
echo 'GET / HTTP/1.0
Host: 0Virtual
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd rewrites dots after slashes'
mkdir 0virtual/:.
mkdir 0virtual/:./:
echo 'colons' > 0virtual/:./:/index.html
echo 'GET .././ HTTP/1.0
Host: 0Virtual
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd rejects unrecognized requests'
echo 'POST .././ HTTP/1.0
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd rejects lowercase requests'
echo 'Head / HTTP/1.0
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd rejects Expect'
echo 'GET .././ HTTP/1.0
Expect: whatever
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd converts names to file types'
( for i in 'audio=vnd:digital-winds' dvi gif gz html jpeg mpeg pdf png ps
do
touch 0/foo...$i
echo 'HEAD http://0/foo...'$i' HTTP/1.1
'
done
) | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd compresses multiple slashes in log entry'
echo 'GET /////////////////////////////////////////////////////////////////////////////////////////////////////////////foo HTTP/1.0
Host: ////////////////////0///////////////////
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd truncates log entry'
echo 'GET 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 HTTP/1.0
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd translates unusual characters in log entry'
echo 'GET 00%0001%0102%021f%1f20%2021%217f%7f80%8081%81ff%ff HTTP/1.0
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd prints Last-Modified'
echo test > 0/old
./utime 0/old 12345
echo 'GET old HTTP/1.0
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- httpd handles If-Modified-Since'
echo 'GET old HTTP/1.0
If-Modified-Since: second line takes precedence
If-MoDiFiEd-SiNcE: Thu, 01 Jan 1970 03:25:45 GMTxxx
' | ( ./httpd 2>&1; echo $? ) | sed 's/^Date: .*/Date: .../'
echo '--- ftpd rejects unrecognized requests'
echo Whatever \
| ( ./ftpd 2>&1; echo $? )
echo '--- ftpd handles USER, PASS, ACCT, QUIT'
echo 'User anonymous
Pass whatever
Acct noaccount
Quit
Whatever' \
| ( ./ftpd 2>&1; echo $? )
echo '--- ftpd handles STRU'
echo 'Stru f
Stru F
Stru x' \
| ( ./ftpd 2>&1; echo $? )
echo '--- ftpd handles MODE'
echo 'Mode s
Mode S
Mode x' \
| ( ./ftpd 2>&1; echo $? )
echo '--- ftpd handles TYPE'
echo 'Type a
Type A
Type a n
Type A N
Type i
Type I
Type l 8
Type L 8
Type x' \
| ( ./ftpd 2>&1; echo $? )
echo '--- ftpd handles SYST, HELP, NOOP'
echo 'Syst
Help
Help arg
Noop' \
| ( ./ftpd 2>&1; echo $? )
echo '--- ftpd handles CWD, CDUP, PWD'
echo 'Pwd
Pwd
Cwd foo
Pwd
Cwd bar
Pwd
Cwd /one/two
Pwd
Cdup
Pwd
Cdup
Pwd
Cdup
Pwd' \
| ( ./ftpd 2>&1; echo $? )
echo '--- ftpd rejects unusual PORT requests'
echo 'Port
Port 127,0,0,1,50,50
Port 1,2,3,5,50,50
Port 1,2,3,4,0,0
Port 1,2,3,4,0,1
Port 1,2,3,4,3,255
Port 1,2,3,4,256,0
Port 1,2,3,4,256,256' \
| ( ./ftpd 2>&1; echo $? )
echo '--- ftpd prints error message for ENOENT'
echo 'Retr nonexistent' \
| ( ./ftpd 2>&1; echo $? )
echo '--- ftpd converts dots to colons'
echo 'Retr .' \
| ( ./ftpd 2>&1; echo $? )
echo '--- ftpd handles incoming TELNET strings'
echo 'Cwd abcXydef' | tr X '\377' \
| ( ./ftpd 2>&1; echo $? )
echo '--- ftpd handles outgoing TELNET strings'
echo 'Cwd abcXXdef' | tr X '\377' \
| ( ./ftpd 2>&1; echo $? )
echo '--- ftpd handles quotes in directory name output'
echo 'Cwd ab"cd"ef
Pwd' \
| ( ./ftpd 2>&1; echo $? )
echo '--- ftpd handles PASV+LIST'
rm -f 0toftp 0fromftp
if mkfifo 0toftp && mkfifo 0fromftp
then
:
else
echo Oops, mkfifo failed. Aborting.
exit 1
fi
(
( TCPLOCALIP=127.0.0.1 TCPREMOTEIP=127.0.0.1 ./ftpd ) <0toftp >0fromftp &
(
echo Pasv
read line
case "$line" in
227*)
port=`echo "$line" | tr -d '\015' | sed 's/[^,]*,[^,]*,[^,]*,[^,]*,//' | sed 's/,/ 256*/' | sed 's/$/ +p/' | dc`
tcpclient 127.0.0.1 $port sh -c '
echo List
read line
echo "$line" >&2
case "$line" in
150*) sed 's/i[0-9][0-9]*\.[0-9]*/ixxx.xxx/g' <&6 >&2 ;;
esac
'
;;
esac
echo Quit
cat >&2
) >0toftp <0fromftp
) 2>&1
echo '--- ftpd handles SPSV+LIST'
(
( TCPLOCALIP=127.0.0.1 TCPREMOTEIP=127.0.0.1 ./ftpd ) <0toftp >0fromftp &
(
echo Spsv
read line
case "$line" in
227*)
port=`echo "$line" | tr -d '\015' | sed 's/.* //'`
tcpclient 127.0.0.1 $port sh -c '
echo List
read line
echo "$line" >&2
case "$line" in
150*) sed 's/i[0-9][0-9]*\.[0-9]*/ixxx.xxx/g' <&6 >&2 ;;
esac
'
;;
esac
echo Quit
cat >&2
) >0toftp <0fromftp
) 2>&1
echo '--- ftpd rejects third-party PASV connections'
(
( TCPLOCALIP=127.0.0.1 TCPREMOTEIP=127.0.0.2 ./ftpd ) <0toftp >0fromftp &
(
echo Spsv
read line
case "$line" in
227*)
port=`echo "$line" | tr -d '\015' | sed 's/.* //'`
tcpclient 127.0.0.1 $port sh -c '
echo List
read line
echo "$line" >&2
case "$line" in
150*) sed 's/i[0-9][0-9]*\.[0-9]*/ixxx.xxx/g' <&6 >&2 ;;
esac
'
;;
esac
echo Quit
cat >&2
) >0toftp <0fromftp
) 2>&1
echo '--- ftpd handles NLST'
(
( TCPLOCALIP=127.0.0.1 TCPREMOTEIP=127.0.0.1 ./ftpd ) <0toftp >0fromftp &
(
echo Spsv
read line
case "$line" in
227*)
port=`echo "$line" | tr -d '\015' | sed 's/.* //'`
tcpclient 127.0.0.1 $port sh -c '
echo Nlst
read line
echo "$line" >&2
case "$line" in
150*) cat <&6 >&2 ;;
esac
'
;;
esac
echo Quit
cat >&2
) >0toftp <0fromftp
) 2>&1
echo '--- ftpd handles LIST with directory argument'
(
( TCPLOCALIP=127.0.0.1 TCPREMOTEIP=127.0.0.1 ./ftpd ) <0toftp >0fromftp &
(
echo Spsv
read line
case "$line" in
227*)
port=`echo "$line" | tr -d '\015' | sed 's/.* //'`
tcpclient 127.0.0.1 $port sh -c '
echo List subdirectory
read line
echo "$line" >&2
case "$line" in
150*) sed 's/i[0-9][0-9]*\.[0-9]*/ixxx.xxx/g' <&6 >&2 ;;
esac
'
;;
esac
echo Quit
cat >&2
) >0toftp <0fromftp
) 2>&1
echo '--- ftpd handles LIST with regular file argument'
(
( TCPLOCALIP=127.0.0.1 TCPREMOTEIP=127.0.0.1 ./ftpd ) <0toftp >0fromftp &
(
echo Spsv
read line
case "$line" in
227*)
port=`echo "$line" | tr -d '\015' | sed 's/.* //'`
tcpclient 127.0.0.1 $port sh -c '
echo List foo
read line
echo "$line" >&2
case "$line" in
150*) sed 's/i[0-9][0-9]*\.[0-9]*/ixxx.xxx/g' <&6 >&2 ;;
esac
'
;;
esac
echo Quit
cat >&2
) >0toftp <0fromftp
) 2>&1
echo '--- ftpd handles LIST ENOENT'
(
( TCPLOCALIP=127.0.0.1 TCPREMOTEIP=127.0.0.1 ./ftpd ) <0toftp >0fromftp &
(
echo Spsv
read line
case "$line" in
227*)
port=`echo "$line" | tr -d '\015' | sed 's/.* //'`
tcpclient 127.0.0.1 $port sh -c '
echo List nonexistent
read line
echo "$line" >&2
'
;;
esac
echo Quit
cat >&2
) >0toftp <0fromftp
) 2>&1
echo '--- ftpd handles LIST ELOOP'
(
( TCPLOCALIP=127.0.0.1 TCPREMOTEIP=127.0.0.1 ./ftpd ) <0toftp >0fromftp &
(
echo Spsv
read line
case "$line" in
227*)
port=`echo "$line" | tr -d '\015' | sed 's/.* //'`
tcpclient 127.0.0.1 $port sh -c '
echo List loop
read line
echo "$line" >&2
'
;;
esac
echo Quit
cat >&2
) >0toftp <0fromftp
) 2>&1
echo '--- ftpd handles NLST regular file'
(
( TCPLOCALIP=127.0.0.1 TCPREMOTEIP=127.0.0.1 ./ftpd ) <0toftp >0fromftp &
(
echo Spsv
read line
case "$line" in
227*)
port=`echo "$line" | tr -d '\015' | sed 's/.* //'`
tcpclient 127.0.0.1 $port sh -c '
echo Nlst foo
read line
echo "$line" >&2
'
;;
esac
echo Quit
cat >&2
) >0toftp <0fromftp
) 2>&1
echo '--- ftpd handles RETR'
(
( TCPLOCALIP=127.0.0.1 TCPREMOTEIP=127.0.0.1 ./ftpd ) <0toftp >0fromftp &
(
echo Spsv
read line
case "$line" in
227*)
port=`echo "$line" | tr -d '\015' | sed 's/.* //'`
tcpclient 127.0.0.1 $port sh -c '
echo Retr foo
read line
echo "$line" >&2
case "$line" in
150*) cat <&6 >&2 ;;
esac
'
;;
esac
echo Quit
cat >&2
) >0toftp <0fromftp
) 2>&1
echo '--- ftpd handles RETR in TYPE I'
(
( TCPLOCALIP=127.0.0.1 TCPREMOTEIP=127.0.0.1 ./ftpd ) <0toftp >0fromftp &
(
echo Spsv
read line
case "$line" in
227*)
port=`echo "$line" | tr -d '\015' | sed 's/.* //'`
tcpclient 127.0.0.1 $port sh -c '
echo Type ix
read line
echo "$line" >&2
echo Retr foo
read line
echo "$line" >&2
case "$line" in
150*) cat <&6 >&2 ;;
esac
'
;;
esac
echo Quit
cat >&2
) >0toftp <0fromftp
) 2>&1
exit 0
publicfile-0.52/rts.exp 644 0 0 30614 7011746002 11253 0 ustar 00 --- httpd handles HTTP/0.9 GET
1.2.3.4 read ./0/foo: success
Hello, world
0
--- httpd handles %xx
1.2.3.4 read ./0/foo: success
Hello, world
0
--- httpd handles HTTP/1.0 GET
1.2.3.4 read ./0/foo: success
HTTP/1.0 200 OK^M
Server: publicfile^M
Date: ...
Content-Type: text/plain^M
Content-Length: 13^M
^M
Hello, world
0
--- httpd handles HTTP/1.0 HEAD
1.2.3.4 read ./0/foo: success
HTTP/1.0 200 OK^M
Server: publicfile^M
Date: ...
Content-Type: text/plain^M
Content-Length: 13^M
^M
0
--- httpd handles HTTP/1.1 GET with absolute URL
1.2.3.4 read ./0/foo: success
HTTP/1.1 200 OK^M
Server: publicfile^M
Date: ...
Content-Type: text/plain^M
Transfer-Encoding: chunked^M
^M
d^M
Hello, world
^M
0^M
^M
0
--- httpd handles HTTP/1.1 GET with Host
1.2.3.4 read ./0/foo: success
HTTP/1.1 200 OK^M
Server: publicfile^M
Date: ...
Content-Type: text/plain^M
Transfer-Encoding: chunked^M
^M
d^M
Hello, world
^M
0^M
^M
0
--- httpd rejects HTTP/1.1 GET without host
HTTP/1.1 400 HTTP/1.1 requests must include a host name^M
Server: publicfile^M
Date: ...
Content-Length: 70^M
Connection: close^M
Content-Type: text/html^M
^M
HTTP/1.1 requests must include a host name^M
--- httpd handles HTTP/1.1 HEAD
1.2.3.4 read ./0/foo: success
HTTP/1.1 200 OK^M
Server: publicfile^M
Date: ...
Content-Type: text/plain^M
Transfer-Encoding: chunked^M
^M
0
--- httpd handles multiple HTTP/1.1 requests
1.2.3.4 read ./0/foo: success
HTTP/1.1 200 OK^M
Server: publicfile^M
Date: ...
Content-Type: text/plain^M
Transfer-Encoding: chunked^M
^M
d^M
Hello, world
^M
0^M
^M
1.2.3.4 read ./0/bar: success
HTTP/1.1 200 OK^M
Server: publicfile^M
Date: ...
Content-Type: text/plain^M
Transfer-Encoding: chunked^M
^M
3^M
Hi
^M
0^M
^M
0
--- httpd prints error message for ENOENT
1.2.3.4 read ./0/nonexistent: open failed: file does not exist
HTTP/1.0 404 file does not exist^M
Server: publicfile^M
Date: ...
Content-Length: 47^M
Content-Type: text/html^M
^M
file does not exist^M
0
--- httpd omits body from HEAD error message
1.2.3.4 read ./0/nonexistent: open failed: file does not exist
HTTP/1.0 404 file does not exist^M
Server: publicfile^M
Date: ...
Content-Length: 47^M
Content-Type: text/html^M
^M
0
--- httpd prints error message for ELOOP
1.2.3.4 read ./0/loop: open failed: symbolic link loop
HTTP/1.0 404 symbolic link loop^M
Server: publicfile^M
Date: ...
Content-Length: 46^M
Content-Type: text/html^M
^M
symbolic link loop^M
0
--- httpd prints error message for file not group-readable
1.2.3.4 read ./0/unreadable: not ugo+r
HTTP/1.0 404 access denied^M
Server: publicfile^M
Date: ...
Content-Length: 41^M
Content-Type: text/html^M
^M
access denied^M
0
--- httpd prints error message for file not world-readable
1.2.3.4 read ./0/unreadable: not ugo+r
HTTP/1.0 404 access denied^M
Server: publicfile^M
Date: ...
Content-Length: 41^M
Content-Type: text/html^M
^M
access denied^M
0
--- httpd prints error message for 101 001
1.2.3.4 read ./0/unreadable: o+x but u-x
HTTP/1.0 404 access denied^M
Server: publicfile^M
Date: ...
Content-Length: 41^M
Content-Type: text/html^M
^M
access denied^M
0
--- httpd prints error message for directory
1.2.3.4 read ./0/subdirectory: not a regular file
HTTP/1.0 404 access denied^M
Server: publicfile^M
Date: ...
Content-Length: 41^M
Content-Type: text/html^M
^M
access denied^M
0
--- httpd lowercases host names
1.2.3.4 read ./0virtual/index.html: success
HTTP/1.0 200 OK^M
Server: publicfile^M
Date: ...
Content-Type: text/html^M
Content-Length: 34^M
^M
Virtual
0
--- httpd does index.html rewriting
1.2.3.4 read ./0virtual/index.html: success
HTTP/1.0 200 OK^M
Server: publicfile^M
Date: ...
Content-Type: text/html^M
Content-Length: 34^M
^M
Virtual
0
--- httpd rewrites dots after slashes
1.2.3.4 read ./0virtual/:./:/index.html: success
HTTP/1.0 200 OK^M
Server: publicfile^M
Date: ...
Content-Type: text/html^M
Content-Length: 33^M
^M
colons
0
--- httpd rejects unrecognized requests
HTTP/1.0 501 method not implemented^M
Server: publicfile^M
Date: ...
Content-Length: 50^M
Content-Type: text/html^M
^M
method not implemented^M
0
--- httpd rejects lowercase requests
HTTP/1.0 501 method not implemented^M
Server: publicfile^M
Date: ...
Content-Length: 50^M
Content-Type: text/html^M
^M
method not implemented^M
0
--- httpd rejects Expect
HTTP/1.0 417 I do not accept Expect^M
Server: publicfile^M
Date: ...
Content-Length: 50^M
Content-Type: text/html^M
^M
I do not accept Expect^M
0
--- httpd converts names to file types
1.2.3.4 read ./0/foo...audio=vnd:digital-winds: success
HTTP/1.1 200 OK^M
Server: publicfile^M
Date: ...
Content-Type: audio/vnd.digital-winds^M
Transfer-Encoding: chunked^M
^M
1.2.3.4 read ./0/foo...dvi: success
HTTP/1.1 200 OK^M
Server: publicfile^M
Date: ...
Content-Type: application/x-dvi^M
Transfer-Encoding: chunked^M
^M
1.2.3.4 read ./0/foo...gif: success
HTTP/1.1 200 OK^M
Server: publicfile^M
Date: ...
Content-Type: image/gif^M
Transfer-Encoding: chunked^M
^M
1.2.3.4 read ./0/foo...gz: success
HTTP/1.1 200 OK^M
Server: publicfile^M
Date: ...
Content-Type: application/x-gzip^M
Transfer-Encoding: chunked^M
^M
1.2.3.4 read ./0/foo...html: success
HTTP/1.1 200 OK^M
Server: publicfile^M
Date: ...
Content-Type: text/html^M
Transfer-Encoding: chunked^M
^M
1.2.3.4 read ./0/foo...jpeg: success
HTTP/1.1 200 OK^M
Server: publicfile^M
Date: ...
Content-Type: image/jpeg^M
Transfer-Encoding: chunked^M
^M
1.2.3.4 read ./0/foo...mpeg: success
HTTP/1.1 200 OK^M
Server: publicfile^M
Date: ...
Content-Type: video/mpeg^M
Transfer-Encoding: chunked^M
^M
1.2.3.4 read ./0/foo...pdf: success
HTTP/1.1 200 OK^M
Server: publicfile^M
Date: ...
Content-Type: application/pdf^M
Transfer-Encoding: chunked^M
^M
1.2.3.4 read ./0/foo...png: success
HTTP/1.1 200 OK^M
Server: publicfile^M
Date: ...
Content-Type: image/png^M
Transfer-Encoding: chunked^M
^M
1.2.3.4 read ./0/foo...ps: success
HTTP/1.1 200 OK^M
Server: publicfile^M
Date: ...
Content-Type: application/postscript^M
Transfer-Encoding: chunked^M
^M
0
--- httpd compresses multiple slashes in log entry
1.2.3.4 read ./0/foo: success
HTTP/1.0 200 OK^M
Server: publicfile^M
Date: ...
Content-Type: text/plain^M
Content-Length: 13^M
^M
Hello, world
0
--- httpd truncates log entry
1.2.3.4 read ./0/012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345...: open failed: file does not exist
HTTP/1.0 404 file does not exist^M
Server: publicfile^M
Date: ...
Content-Length: 47^M
Content-Type: text/html^M
^M
file does not exist^M
0
--- httpd translates unusual characters in log entry
1.2.3.4 read ./0/00?01?02?1f?20_21!7f?80?81?ff?: open failed: file does not exist
HTTP/1.0 404 file does not exist^M
Server: publicfile^M
Date: ...
Content-Length: 47^M
Content-Type: text/html^M
^M
file does not exist^M
0
--- httpd prints Last-Modified
1.2.3.4 read ./0/old: success
HTTP/1.0 200 OK^M
Server: publicfile^M
Date: ...
Last-Modified: Thu, 01 Jan 1970 03:25:45 GMT^M
Content-Type: text/plain^M
Content-Length: 5^M
^M
test
0
--- httpd handles If-Modified-Since
1.2.3.4 read ./0/old: success
HTTP/1.0 304 OK^M
Server: publicfile^M
Date: ...
Last-Modified: Thu, 01 Jan 1970 03:25:45 GMT^M
Content-Type: text/plain^M
Content-Length: 5^M
^M
0
--- ftpd rejects unrecognized requests
502 Sorry, I don't understand that command.^M
0
--- ftpd handles USER, PASS, ACCT, QUIT
230 Hi. No need to log in; I'm an anonymous ftp server.^M
202 I don't need account information; I'm an anonymous FTP server.^M
202 I don't need account information; I'm an anonymous FTP server.^M
221 Bye.^M
0
--- ftpd handles STRU
200 Thanks, I always do file structure.^M
200 Thanks, I always do file structure.^M
504 Sorry, I don't do anything except file structure.^M
0
--- ftpd handles MODE
200 Thanks, I always do stream mode.^M
200 Thanks, I always do stream mode.^M
504 Sorry, I don't do anything except stream mode.^M
0
--- ftpd handles TYPE
200 Why are you using ASCII?^M
200 Why are you using ASCII?^M
200 Why are you using ASCII?^M
200 Why are you using ASCII?^M
200 Okay, using binary.^M
200 Okay, using binary.^M
200 Okay, using binary.^M
200 Okay, using binary.^M
504 Sorry, I don't recognize that type.^M
0
--- ftpd handles SYST, HELP, NOOP
215 UNIX Type: L8^M
214 publicfile home page: http://pobox.com/~djb/publicfile.html^M
214 publicfile home page: http://pobox.com/~djb/publicfile.html^M
200 I'm here.^M
0
--- ftpd handles CWD, CDUP, PWD
257 "/" ^M
257 "/" ^M
250 "/foo" ^M
257 "/foo" ^M
250 "/foo/bar" ^M
257 "/foo/bar" ^M
250 "/one/two" ^M
257 "/one/two" ^M
200 "/one" ^M
257 "/one" ^M
200 "/" ^M
257 "/" ^M
200 "/" ^M
257 "/" ^M
0
--- ftpd rejects unusual PORT requests
501 Sorry, you need to give me six numbers separated by commas.^M
501 Sorry, I don't allow PORT relaying.^M
501 Sorry, I don't allow PORT relaying.^M
501 Sorry, I don't accept port numbers below 1024.^M
501 Sorry, I don't accept port numbers below 1024.^M
501 Sorry, I don't accept port numbers below 1024.^M
501 Sorry, I don't accept port numbers below 1024.^M
501 Sorry, I don't accept port numbers below 1024.^M
0
--- ftpd prints error message for ENOENT
1.2.3.4 read ./0/nonexistent: open failed: file does not exist
550 Sorry, I can't open that file: file does not exist.^M
0
--- ftpd converts dots to colons
1.2.3.4 read ./0/:: open failed: file does not exist
550 Sorry, I can't open that file: file does not exist.^M
0
--- ftpd handles incoming TELNET strings
250 "/abcdef" ^M
0
--- ftpd handles outgoing TELNET strings
250 "/abcM-^?M-^?def" ^M
0
--- ftpd handles quotes in directory name output
250 "/ab""cd""ef" ^M
257 "/ab""cd""ef" ^M
0
--- ftpd handles PASV+LIST
127.0.0.1 dir ./0/: success
150 Waiting for transfer connection...^M
+ixxx.xxx,r,s13, foo^M
+ixxx.xxx,r,s3, bar^M
+ixxx.xxx,r,s6, unreadable^M
+ixxx.xxx,/, subdirectory^M
+ixxx.xxx,r,s0, foo...audio=vnd:digital-winds^M
+ixxx.xxx,r,s0, foo...dvi^M
+ixxx.xxx,r,s0, foo...gif^M
+ixxx.xxx,r,s0, foo...gz^M
+ixxx.xxx,r,s0, foo...html^M
+ixxx.xxx,r,s0, foo...jpeg^M
+ixxx.xxx,r,s0, foo...mpeg^M
+ixxx.xxx,r,s0, foo...pdf^M
+ixxx.xxx,r,s0, foo...png^M
+ixxx.xxx,r,s0, foo...ps^M
+ixxx.xxx,m12345,r,s5, old^M
226 Success.^M
221 Bye.^M
--- ftpd handles SPSV+LIST
127.0.0.1 dir ./0/: success
150 Waiting for transfer connection...^M
+ixxx.xxx,r,s13, foo^M
+ixxx.xxx,r,s3, bar^M
+ixxx.xxx,r,s6, unreadable^M
+ixxx.xxx,/, subdirectory^M
+ixxx.xxx,r,s0, foo...audio=vnd:digital-winds^M
+ixxx.xxx,r,s0, foo...dvi^M
+ixxx.xxx,r,s0, foo...gif^M
+ixxx.xxx,r,s0, foo...gz^M
+ixxx.xxx,r,s0, foo...html^M
+ixxx.xxx,r,s0, foo...jpeg^M
+ixxx.xxx,r,s0, foo...mpeg^M
+ixxx.xxx,r,s0, foo...pdf^M
+ixxx.xxx,r,s0, foo...png^M
+ixxx.xxx,r,s0, foo...ps^M
+ixxx.xxx,m12345,r,s5, old^M
226 Success.^M
221 Bye.^M
--- ftpd rejects third-party PASV connections
127.0.0.2 dir ./0/: success
150 Waiting for transfer connection...^M
425 Sorry, I couldn't accept a connection: access denied.^M
221 Bye.^M
--- ftpd handles NLST
127.0.0.1 dir ./0/: success
150 Waiting for transfer connection...^M
foo^M
bar^M
loop^M
unreadable^M
subdirectory^M
foo...audio=vnd:digital-winds^M
foo...dvi^M
foo...gif^M
foo...gz^M
foo...html^M
foo...jpeg^M
foo...mpeg^M
foo...pdf^M
foo...png^M
foo...ps^M
old^M
226 Success.^M
221 Bye.^M
--- ftpd handles LIST with directory argument
127.0.0.1 dir ./0/subdirectory: success
150 Waiting for transfer connection...^M
+ixxx.xxx,/, subdirectory^M
226 Success.^M
221 Bye.^M
--- ftpd handles LIST with regular file argument
127.0.0.1 dir ./0/foo: success
150 Waiting for transfer connection...^M
+ixxx.xxx,r,s13, foo^M
226 Success.^M
221 Bye.^M
--- ftpd handles LIST ENOENT
127.0.0.1 dir ./0/nonexistent: open failed: file does not exist
550 Sorry, I can't open that file: file does not exist.^M
221 Bye.^M
--- ftpd handles LIST ELOOP
127.0.0.1 dir ./0/loop: open failed: symbolic link loop
550 Sorry, I can't open that file: symbolic link loop.^M
221 Bye.^M
--- ftpd handles NLST regular file
127.0.0.1 dir ./0/foo: success
150 Waiting for transfer connection...^M
426 Transmission failure: not a directory^M
221 Bye.^M
--- ftpd handles RETR
127.0.0.1 read ./0/foo: success
150 Warning: You're using ASCII! Waiting for transfer connection...^M
Hello, world^M
226 Success.^M
221 Bye.^M
--- ftpd handles RETR in TYPE I
200 Okay, using binary.^M
127.0.0.1 read ./0/foo: success
150 Waiting for transfer connection...^M
Hello, world
226 Success.^M
221 Bye.^M
publicfile-0.52/utime.c 644 0 0 532 7011746002 11150 0 ustar 00 #include
#include
#include "scan.h"
#include "exit.h"
char *fn;
char *ustr;
unsigned long u;
time_t ut[2];
main(int argc,char **argv)
{
fn = argv[1];
if (!fn) _exit(100);
ustr = argv[2];
if (!ustr) _exit(100);
scan_ulong(ustr,&u);
ut[0] = ut[1] = u;
if (utime(fn,ut) == -1) _exit(111);
_exit(0);
}
publicfile-0.52/configure.c 644 0 0 10057 7011746002 12051 0 ustar 00 #include
#include
#include "hasdevtcp.h"
#ifdef HASDEVTCP
#include
#endif
#include
#include "strerr.h"
#include "substdio.h"
#include "open.h"
#include "readwrite.h"
#include "exit.h"
#include "auto_home.h"
#define FATAL "configure: fatal: "
void usage(void)
{
strerr_die1x(100,"configure: usage: configure acct logacct /public hostname hostip ...");
}
char *dir;
char *fn;
char buf[1024];
int fd;
substdio ss;
void fail(void)
{
strerr_die6sys(111,FATAL,"unable to create ",dir,"/",fn,": ");
}
void makedir(char *s)
{
fn = s;
if (mkdir(fn,0700) == -1) fail();
}
void start(char *s)
{
fn = s;
fd = open_trunc(fn);
if (fd == -1) fail();
substdio_fdbuf(&ss,write,fd,buf,sizeof buf);
}
void outs(char *s)
{
if (substdio_puts(&ss,s) == -1) fail();
}
void finish(void)
{
if (substdio_flush(&ss) == -1) fail();
if (fsync(fd) == -1) fail();
close(fd);
}
void perm(int mode)
{
if (chmod(fn,mode) == -1) fail();
}
char *user;
char *loguser;
struct passwd *pw;
main(int argc,char **argv)
{
umask(022);
user = argv[1];
if (!user) usage();
loguser = argv[2];
if (!loguser) usage();
dir = argv[3];
if (!dir) usage();
if (dir[0] != '/') usage();
pw = getpwnam(loguser);
if (!pw)
strerr_die3x(111,FATAL,"unknown account ",loguser);
if (mkdir(dir,0700) == -1)
strerr_die4sys(111,FATAL,"unable to create ",dir,": ");
if (chmod(dir,02755) == -1)
strerr_die4sys(111,FATAL,"unable to set mode of ",dir,": ");
if (chdir(dir) == -1)
strerr_die4sys(111,FATAL,"unable to switch to ",dir,": ");
makedir("httpd");
perm(03700);
makedir("httpd/log");
perm(02755);
makedir("httpd/log/main");
if (chown("httpd/log/main",pw->pw_uid,pw->pw_gid) == -1)
strerr_die4sys(111,FATAL,"unable to set owner of ",dir,"/httpd/log/main: ");
perm(02755);
start("httpd/log/status");
finish();
if (chown("httpd/log/status",pw->pw_uid,pw->pw_gid) == -1)
strerr_die4sys(111,FATAL,"unable to set owner of ",dir,"/httpd/log/status: ");
perm(0644);
start("httpd/run");
outs("#!/bin/sh\nexec 2>&1\nexec");
outs(" envuidgid "); outs(user);
outs(" softlimit -o20 -d50000");
outs(" tcpserver -vDRHl0 -b50 -c100 0 80 ");
outs(auto_home); outs("/bin/httpd "); outs(dir); outs("/file\n");
finish();
perm(0755);
start("httpd/log/run");
outs("#!/bin/sh\nexec");
outs(" setuidgid "); outs(loguser);
outs(" multilog t ./main '-*' '+* * status: *' =status\n");
finish();
perm(0755);
makedir("ftpd");
perm(03700);
makedir("ftpd/log");
perm(02755);
makedir("ftpd/log/main");
if (chown("ftpd/log/main",pw->pw_uid,pw->pw_gid) == -1)
strerr_die4sys(111,FATAL,"unable to set owner of ",dir,"/ftpd/log/main: ");
perm(02755);
start("ftpd/log/status");
finish();
if (chown("ftpd/log/status",pw->pw_uid,pw->pw_gid) == -1)
strerr_die4sys(111,FATAL,"unable to set owner of ",dir,"/ftpd/log/status: ");
perm(0644);
start("ftpd/run");
outs("#!/bin/sh\nexec 2>&1\nexec");
outs(" envuidgid "); outs(user);
outs(" softlimit -o20 -d50000");
outs(" tcpserver -vDRHl0 -b20 -c40 -B'220 Features: a p .\r\n' 0 21 ");
outs(auto_home); outs("/bin/ftpd "); outs(dir); outs("/file\n");
finish();
perm(0755);
start("ftpd/log/run");
outs("#!/bin/sh\nexec");
outs(" setuidgid "); outs(loguser);
outs(" multilog t ./main '-*' '+* * status: *' =status\n");
finish();
perm(0755);
makedir("file");
perm(02755);
makedir("file/0");
perm(02755);
#ifdef HASDEVTCP
makedir("file/etc");
perm(02755);
makedir("file/dev");
perm(02755);
start("file/etc/netconfig");
outs("tcp tpi_cots_ord v inet tcp /dev/tcp -\n");
finish();
perm(0645);
umask(000);
if (mknod("file/dev/tcp",S_IFCHR | 0667,makedev(11,42)) == -1)
strerr_die4sys(111,FATAL,"unable to create device ",dir,"/file/dev/tcp: ");
umask(022);
#endif
if (chdir("file") == -1)
strerr_die4sys(111,FATAL,"unable to switch to ",dir,"/file: ");
for (argv += 4;*argv;++argv)
if (symlink("0",*argv) == -1)
strerr_die6sys(111,FATAL,"unable to create ",dir,"/file/",*argv,": ");
_exit(0);
}
publicfile-0.52/httpd.c 644 0 0 17070 7011746002 11215 0 ustar 00 #include "pathdecode.h"
#include "file.h"
#include "filetype.h"
#include "percent.h"
#include "stralloc.h"
#include "sig.h"
#include "exit.h"
#include "fmt.h"
#include "case.h"
#include "str.h"
#include "tai.h"
#include "httpdate.h"
#include "timeoutread.h"
#include "timeoutwrite.h"
#include "substdio.h"
#include "error.h"
#include "getln.h"
int safewrite(int fd,char *buf,int len)
{
int r;
r = timeoutwrite(60,fd,buf,len);
if (r <= 0) _exit(0);
return r;
}
char outbuf[1024];
substdio out = SUBSTDIO_FDBUF(safewrite,1,outbuf,sizeof outbuf);
void out_put(char *s,int len)
{
substdio_put(&out,s,len);
}
void out_puts(char *s)
{
substdio_puts(&out,s);
}
void out_flush(void)
{
substdio_flush(&out);
}
char strnum[FMT_ULONG];
stralloc protocol = {0};
int protocolnum = 0;
stralloc method = {0};
stralloc url = {0};
stralloc host = {0};
stralloc path = {0};
stralloc ims = {0};
int flagbody = 1;
char filebuf[1024];
struct tai now;
stralloc nowstr = {0};
struct tai mtime;
struct tai mtimeage;
stralloc mtimestr = {0};
void header(char *code,char *message)
{
if (protocolnum == 1)
out_puts("HTTP/1.0 ");
else
out_puts("HTTP/1.1 ");
out_puts(code);
out_puts(message);
out_puts("\r\nServer: publicfile\r\nDate:");
if (!httpdate(&nowstr,&now)) _exit(21);
out_put(nowstr.s,nowstr.len);
out_puts("\r\n");
}
void barf(char *code,char *message)
{
if (protocolnum > 0) {
tai_now(&now);
header(code,message);
out_puts("Content-Length: ");
out_put(strnum,fmt_ulong(strnum,str_len(message) + 28));
out_puts("\r\n");
if (protocolnum == 2)
out_puts("Connection: close\r\n");
out_puts("Content-Type: text/html\r\n\r\n");
}
if (flagbody) {
out_puts("");
out_puts(message);
out_puts("\r\n");
}
out_flush();
if (protocolnum >= 2) {
shutdown(1,1);
sleep(1); /* XXX */
}
_exit(0);
}
stralloc fn = {0};
stralloc contenttype = {0};
void get(void)
{
unsigned long length;
int fd;
int r;
host.len = byte_chr(host.s,host.len,':');
if (!host.len) {
if (protocolnum > 1)
barf("400 ","HTTP/1.1 requests must include a host name");
if (!stralloc_copys(&host,"0")) _exit(21);
}
case_lowerb(host.s,host.len);
percent(&path);
if (!stralloc_copys(&fn,"./")) _exit(21);
if (!stralloc_cat(&fn,&host)) _exit(21);
if (!stralloc_cats(&fn,"/")) _exit(21);
if (!stralloc_cat(&fn,&path)) _exit(21);
pathdecode(&fn);
if (!stralloc_0(&fn)) _exit(21);
fd = file_open(fn.s,&mtime,&length,1);
if (fd == -1)
barf("404 ",error_str(errno));
if (protocolnum > 0) {
tai_now(&now);
if (!httpdate(&mtimestr,&mtime)) _exit(21);
if ((ims.len < mtimestr.len) || byte_diff(mtimestr.s,mtimestr.len,ims.s))
header("200 ","OK");
else {
header("304 ","OK");
flagbody = 0;
}
if (tai_less(&mtime,&now)) {
tai_sub(&mtimeage,&now,&mtime);
if (tai_approx(&mtimeage) >= 60.0) {
out_puts("Last-Modified:");
out_put(mtimestr.s,mtimestr.len);
out_puts("\r\n");
}
}
filetype(fn.s,&contenttype);
out_put(contenttype.s,contenttype.len);
if (protocolnum >= 2)
out_puts("Transfer-Encoding: chunked\r\n");
else {
out_puts("Content-Length: ");
out_put(strnum,fmt_ulong(strnum,length)); /* XXX: could change */
out_puts("\r\n");
}
out_puts("\r\n");
}
if (protocolnum < 2) {
if (flagbody)
for (;;) {
r = read(fd,filebuf,sizeof filebuf);
if (r == -1) _exit(23);
if (r == 0) break;
out_put(filebuf,r);
}
out_flush();
_exit(0);
}
if (flagbody)
for (;;) {
r = read(fd,filebuf,sizeof filebuf);
if (r == -1) _exit(23);
if (r == 0) { out_puts("0\r\n\r\n"); out_flush(); break; }
out_put(strnum,fmt_xlong(strnum,(unsigned long) r));
out_puts("\r\n");
out_put(filebuf,r);
out_puts("\r\n");
}
close(fd);
}
stralloc field = {0};
stralloc line = {0};
int saferead(int fd,char *buf,int len)
{
int r;
out_flush();
r = timeoutread(60,fd,buf,len);
if (r <= 0) _exit(0);
return r;
}
char inbuf[512];
substdio in = SUBSTDIO_FDBUF(saferead,0,inbuf,sizeof inbuf);
void readline(void)
{
int match;
if (getln(&in,&line,&match,'\n') == -1) _exit(21);
if (!match) _exit(0);
if (line.len && (line.s[line.len - 1] == '\n')) --line.len;
if (line.len && (line.s[line.len - 1] == '\r')) --line.len;
}
void doit()
{
int i;
int spaces;
sig_pipeignore();
for (;;) {
readline();
if (!line.len) continue;
if (!stralloc_copys(&method,"")) _exit(21);
if (!stralloc_copys(&url,"")) _exit(21);
if (!stralloc_copys(&host,"")) _exit(21);
if (!stralloc_copys(&path,"")) _exit(21);
if (!stralloc_copys(&protocol,"")) _exit(21);
if (!stralloc_copys(&ims,"")) _exit(21);
protocolnum = 2;
spaces = 0;
for (i = 0;i < line.len;++i)
if (line.s[i] == ' ') {
if (!i || (line.s[i - 1] != ' ')) {
++spaces;
if (spaces >= 3) break;
}
}
else
switch(spaces) {
case 0:
if (!stralloc_append(&method,line.s + i)) _exit(21);
break;
case 1:
if (!stralloc_append(&url,line.s + i)) _exit(21);
break;
case 2:
if (!stralloc_append(&protocol,line.s + i)) _exit(21);
break;
}
if (!protocol.len)
protocolnum = 0;
else {
if (!stralloc_0(&protocol)) _exit(21);
if (case_equals(protocol.s,"http/1.0"))
protocolnum = 1; /* if client uses http/001.00, tough luck */
}
if (!stralloc_0(&method)) _exit(21);
flagbody = 1;
if (str_equal(method.s,"HEAD"))
flagbody = 0;
else if (!str_equal(method.s,"GET"))
barf("501 ","method not implemented");
if (case_startb(url.s,url.len,"http://")) {
if (!stralloc_copyb(&host,url.s + 7,url.len - 7)) _exit(21);
i = byte_chr(host.s,host.len,'/');
if (!stralloc_copyb(&path,host.s + i,host.len - i)) _exit(21);
host.len = i;
}
else
if (!stralloc_copy(&path,&url)) _exit(21);
if (!path.len || (path.s[path.len - 1] == '/'))
if (!stralloc_cats(&path,"index.html")) _exit(21);
if (protocolnum > 0) {
if (!stralloc_copys(&field,"")) _exit(21);
for (;;) {
readline();
if (!line.len || ((line.s[0] != ' ') && (line.s[0] != '\t'))) {
if (case_startb(field.s,field.len,"content-length:"))
barf("501 ","I do not accept messages");
if (case_startb(field.s,field.len,"transfer-encoding:"))
barf("501 ","I do not accept messages");
if (case_startb(field.s,field.len,"expect:"))
barf("417 ","I do not accept Expect");
if (case_startb(field.s,field.len,"if-match:"))
barf("412 ","I do not accept If-Match");
if (case_startb(field.s,field.len,"if-none-match:"))
barf("412 ","I do not accept If-None-Match");
if (case_startb(field.s,field.len,"if-unmodified-since:"))
barf("412 ","I do not accept If-Unmodified-Since");
if (case_startb(field.s,field.len,"host:"))
if (!host.len)
for (i = 5;i < field.len;++i)
if (field.s[i] != ' ')
if (field.s[i] != '\t')
if (!stralloc_append(&host,&field.s[i])) _exit(21);
if (case_startb(field.s,field.len,"if-modified-since:"))
if (!stralloc_copyb(&ims,field.s + 18,field.len - 18)) _exit(21);
field.len = 0;
}
if (!line.len) break;
if (!stralloc_cat(&field,&line)) _exit(21);
}
}
get();
}
}
publicfile-0.52/ftpd.c 644 0 0 25357 7011746002 11036 0 ustar 00 #include
#include
#include
#include
#include "timeoutconn.h"
#include "timeoutaccept.h"
#include "timeoutread.h"
#include "timeoutwrite.h"
#include "substdio.h"
#include "fetch.h"
#include "pathdecode.h"
#include "file.h"
#include "sig.h"
#include "tai.h"
#include "stralloc.h"
#include "str.h"
#include "error.h"
#include "case.h"
#include "byte.h"
#include "env.h"
#include "fmt.h"
#include "scan.h"
#include "ip.h"
int safewrite(int fd,char *buf,int len)
{
int r;
r = timeoutwrite(60,fd,buf,len);
if (r <= 0) _exit(0);
return r;
}
char outbuf[1024];
substdio out = SUBSTDIO_FDBUF(safewrite,1,outbuf,sizeof outbuf);
void out_flush(void)
{
substdio_flush(&out);
}
void out_put(char *s,int len)
{
while (len > 0) {
substdio_put(&out,s,1);
if (*s == (char) 255) substdio_put(&out,s,1);
++s;
--len;
}
}
void out_puts(char *s)
{
out_put(s,str_len(s));
}
int saferead(int fd,char *buf,int len)
{
int r;
out_flush();
r = timeoutread(60,fd,buf,len);
if (r <= 0) _exit(0);
return r;
}
char inbuf[512];
substdio in = SUBSTDIO_FDBUF(saferead,0,inbuf,sizeof inbuf);
void in_get(char *ch)
{
for (;;) {
substdio_get(&in,ch,1);
if (*ch != (char) 255) return;
substdio_get(&in,ch,1);
if (*ch == (char) 255) return;
if ((*ch == (char) 254) || (*ch == (char) 252))
substdio_get(&in,ch,1);
else if (*ch == (char) 253) {
substdio_get(&in,ch,1);
substdio_put(&out,"\377\374",2);
substdio_put(&out,ch,1);
}
else if (*ch == (char) 251) {
substdio_get(&in,ch,1);
substdio_put(&out,"\377\376",2);
substdio_put(&out,ch,1);
}
}
}
char strnum[FMT_ULONG];
struct ip_address iplocal = { {0,0,0,0} };
struct ip_address ipremote = { {0,0,0,0} };
struct sockaddr_in sa;
int fdlisten = -1; /* PASV socket; -1 if PASV not active */
unsigned int portremote = 0;
stralloc dir = {0};
stralloc fn = {0};
void startlistening(char x[6])
{
int dummy;
int opt;
if (fdlisten != -1) { close(fdlisten); fdlisten = -1; }
byte_zero(&sa,sizeof sa);
sa.sin_family = AF_INET;
byte_copy(&sa.sin_addr,4,&iplocal);
fdlisten = socket(AF_INET,SOCK_STREAM,0);
if (fdlisten == -1) _exit(22);
opt = 1;
setsockopt(fdlisten,SOL_SOCKET,SO_REUSEADDR,&opt,sizeof opt);
if (bind(fdlisten,(struct sockaddr *) &sa,sizeof sa) == -1) _exit(22);
if (listen(fdlisten,1) == -1) _exit(22);
dummy = sizeof sa;
if (getsockname(fdlisten,(struct sockaddr *) &sa,&dummy) == -1) _exit(22);
byte_copy(x,4,&sa.sin_addr);
byte_copy(x + 4,2,&sa.sin_port);
}
void spsv(void)
{
unsigned char x[6];
startlistening(x);
out_puts("227 ");
out_put(strnum,fmt_ulong(strnum,x[4] * (unsigned long) 256 + x[5]));
out_puts("\r\n");
}
void pasv(void)
{
unsigned char x[6];
startlistening(x);
out_puts("227 =");
out_put(strnum,fmt_ulong(strnum,(unsigned long) x[0]));
out_puts(",");
out_put(strnum,fmt_ulong(strnum,(unsigned long) x[1]));
out_puts(",");
out_put(strnum,fmt_ulong(strnum,(unsigned long) x[2]));
out_puts(",");
out_put(strnum,fmt_ulong(strnum,(unsigned long) x[3]));
out_puts(",");
out_put(strnum,fmt_ulong(strnum,(unsigned long) x[4]));
out_puts(",");
out_put(strnum,fmt_ulong(strnum,(unsigned long) x[5]));
out_puts("\r\n");
}
int portparse(char *arg,unsigned char x[6])
{
unsigned int i;
unsigned long u;
i = scan_ulong(arg,&u); if (!i) return 0; x[0] = u;
arg += i; if (*arg++ != ',') return 0;
i = scan_ulong(arg,&u); if (!i) return 0; x[1] = u;
arg += i; if (*arg++ != ',') return 0;
i = scan_ulong(arg,&u); if (!i) return 0; x[2] = u;
arg += i; if (*arg++ != ',') return 0;
i = scan_ulong(arg,&u); if (!i) return 0; x[3] = u;
arg += i; if (*arg++ != ',') return 0;
i = scan_ulong(arg,&u); if (!i) return 0; x[4] = u;
arg += i; if (*arg++ != ',') return 0;
i = scan_ulong(arg,&u); if (!i) return 0; x[5] = u;
return 1;
}
void port(char *arg)
{
unsigned char x[6];
if (fdlisten != -1) { close(fdlisten); fdlisten = -1; }
if (!portparse(arg,x)) {
out_puts("501 Sorry, you need to give me six numbers separated by commas.\r\n");
return;
}
if (x[4] < 4) {
out_puts("501 Sorry, I don't accept port numbers below 1024.\r\n");
return;
}
if (byte_diff(x,4,&ipremote)) {
out_puts("501 Sorry, I don't allow PORT relaying.\r\n");
return;
}
portremote = x[4] * (unsigned int) 256 + x[5];
out_puts("200 Okay.\r\n");
}
void rest(char *arg)
{
scan_ulong(arg,&fetch_rest);
out_puts("350 Okay.\r\n");
}
void get(char *arg,int how)
{
int fdfile;
int fddata;
struct tai mtime;
unsigned long length;
int dummy;
if (!stralloc_copys(&fn,"./0/")) _exit(21);
if (*arg != '/') {
if (!stralloc_cat(&fn,&dir)) _exit(21);
if (!stralloc_append(&fn,"/")) _exit(21);
}
if (!stralloc_cats(&fn,arg)) _exit(21);
pathdecode(&fn);
if (!stralloc_0(&fn)) _exit(21);
fdfile = file_open(fn.s,&mtime,&length,how == FETCH_RETR);
if (fdfile == -1) {
out_puts("550 Sorry, I can't open that file: ");
out_puts(error_str(errno));
out_puts(".\r\n");
return;
}
out_puts("150 ");
if ((how == FETCH_RETR) && fetch_ascii)
out_puts("Warning: You're using ASCII! ");
if (fdlisten == -1) {
out_puts("Making transfer connection...\r\n");
out_flush();
fddata = socket(AF_INET,SOCK_STREAM,0);
if (fddata == -1) _exit(22);
/* kernel will reject port 0 at this point */
if (timeoutconn(fddata,&ipremote,portremote,60) == -1) {
close(fddata);
close(fdfile);
out_puts("425 Sorry, I couldn't make a connection: ");
out_puts(error_str(errno));
out_puts(".\r\n");
return;
}
}
else {
out_puts("Waiting for transfer connection...\r\n");
out_flush();
fddata = timeoutaccept(fdlisten,60);
close(fdlisten); fdlisten = -1;
if (fddata != -1) {
dummy = sizeof sa;
if (getpeername(fddata,(struct sockaddr *) &sa,&dummy) == -1) {
close(fddata); fddata = -1;
}
else if (byte_diff(&sa.sin_addr,4,&ipremote)) {
errno = error_acces;
close(fddata); fddata = -1;
}
}
if (fddata == -1) {
close(fdfile);
out_puts("425 Sorry, I couldn't accept a connection: ");
out_puts(error_str(errno));
out_puts(".\r\n");
return;
}
}
dummy = 1;
setsockopt(fddata,IPPROTO_TCP,1/*TCP_NODELAY*/,&dummy,sizeof dummy);
fetch(arg,fddata,fdfile,how); /* closes fddata and fdfile */
portremote = 0;
}
void dir_moveup(void)
{
dir.len = byte_rchr(dir.s,dir.len,'/');
}
void dir_move(char *to)
{
if (*to == '/') {
if (!stralloc_copys(&dir,"")) _exit(21);
++to;
}
if (*to) {
if (!stralloc_append(&dir,"/")) _exit(21);
if (!stralloc_cats(&dir,to)) _exit(21);
}
}
void say_dir(char *code)
{
int i;
char ch;
out_puts(code);
out_puts("\"");
if (!dir.len)
out_puts("/");
else
for (i = 0;i < dir.len;++i) {
ch = dir.s[i];
if (ch == '\n') out_put("",1);
else if (ch == '"') out_put("\"\"",2);
else out_put(&ch,1);
}
out_puts("\" \r\n");
}
void request(char *cmd,char *arg)
{
if (case_equals(cmd,"spsv")) { spsv(); return; }
if (case_equals(cmd,"pasv")) { pasv(); return; }
if (case_equals(cmd,"port")) { port(arg); return; }
if (case_equals(cmd,"rest")) { rest(arg); return; }
if (case_equals(cmd,"retr")) { get(arg,FETCH_RETR); return; }
if (case_equals(cmd,"list")) { get(arg,*arg ? FETCH_LISTONE : FETCH_LIST); return; }
if (case_equals(cmd,"nlst")) { get(arg,FETCH_NLST); return; }
if (case_equals(cmd,"quit")) {
out_puts("221 Bye.\r\n");
out_flush();
_exit(0);
}
if (case_equals(cmd,"user")) {
out_puts("230 Hi. No need to log in; I'm an anonymous ftp server.\r\n");
return;
}
if (case_equals(cmd,"noop")) {
out_puts("200 I'm here.\r\n");
return;
}
if (case_equals(cmd,"pwd") || case_equals(cmd,"xpwd")) {
say_dir("257 ");
return;
}
if (case_equals(cmd,"cwd") || case_equals(cmd,"xcwd")) {
dir_move(arg);
say_dir("250 ");
return;
}
if (case_equals(cmd,"cdup") || case_equals(cmd,"xcup")) {
dir_moveup();
say_dir("200 ");
return;
}
if (case_equals(cmd,"stru")) {
if ((*arg == 'f') || (*arg == 'F')) {
out_puts("200 Thanks, I always do file structure.\r\n");
return;
}
out_puts("504 Sorry, I don't do anything except file structure.\r\n");
return;
}
if (case_equals(cmd,"mode")) {
if ((*arg == 's') || (*arg == 'S')) {
out_puts("200 Thanks, I always do stream mode.\r\n");
return;
}
out_puts("504 Sorry, I don't do anything except stream mode.\r\n");
return;
}
if (case_equals(cmd,"type")) {
if ((*arg == 'a') || (*arg == 'A')) {
fetch_ascii = 1;
out_puts("200 Why are you using ASCII?\r\n");
return;
}
if ((*arg == 'i') || (*arg == 'I') || (*arg == 'l') || (*arg == 'L')) {
fetch_ascii = 0;
out_puts("200 Okay, using binary.\r\n");
return;
}
out_puts("504 Sorry, I don't recognize that type.\r\n");
return;
}
if (case_equals(cmd,"syst")) {
out_puts("215 UNIX Type: L8\r\n");
return;
}
if (case_equals(cmd,"help")) {
out_puts("214 publicfile home page: http://pobox.com/~djb/publicfile.html\r\n");
return;
}
if (case_equals(cmd,"pass") || case_equals(cmd,"acct")) {
out_puts("202 I don't need account information; I'm an anonymous FTP server.\r\n");
return;
}
if (case_equals(cmd,"allo")) {
out_puts("202 Who cares? I don't allow file creation.\r\n");
return;
}
if (case_equals(cmd,"stor") || case_equals(cmd,"stou") || case_equals(cmd,"appe") || case_equals(cmd,"dele") || case_equals(cmd,"rnfr") || case_equals(cmd,"rnto") || case_equals(cmd,"mkd") || case_equals(cmd,"xmkd") || case_equals(cmd,"rmd") || case_equals(cmd,"xrmd")) {
out_puts("553 Sorry, I don't allow file modification.\r\n");
return;
}
out_puts("502 Sorry, I don't understand that command.\r\n");
}
stralloc line = {0};
void doit(void)
{
char *cmd;
char *arg;
char *x;
unsigned char ch;
{
int opt = 1;
setsockopt(0,SOL_SOCKET,SO_OOBINLINE,(char *) &opt,sizeof opt);
/* if it fails, bummer */
}
x = env_get("TCPLOCALIP");
if (!x) x = "0.0.0.0";
if (!ip_scan(x,&iplocal))
byte_zero(&iplocal,4);
x = env_get("TCPREMOTEIP");
if (!x) x = "0.0.0.0";
if (!ip_scan(x,&ipremote))
byte_zero(&ipremote,4);
if (!stralloc_copys(&dir,"")) _exit(21);
sig_pipeignore();
for (;;) {
if (!stralloc_copys(&line,"")) _exit(21);
for (;;) {
in_get(&ch);
if (ch == '\n') break;
if (!ch) ch = '\n';
if (!stralloc_append(&line,&ch)) _exit(21);
}
if (line.len && (line.s[line.len - 1] == '\r')) --line.len;
if (!stralloc_0(&line)) _exit(21);
cmd = line.s;
arg = cmd + str_chr(cmd,' ');
if (*arg) *arg++ = 0;
request(cmd,arg);
}
}
publicfile-0.52/main.c 644 0 0 724 7011746002 10754 0 ustar 00 #include "env.h"
#include "exit.h"
#include "scan.h"
extern void doit(void);
main(int argc,char **argv)
{
char *x;
unsigned long id;
x = argv[1];
if (x) {
if (chdir(x) == -1) _exit(20);
if (chroot(".") == -1) _exit(30);
}
x = env_get("GID");
if (x) {
scan_ulong(x,&id);
if (prot_gid((int) id) == -1) _exit(30);
}
x = env_get("UID");
if (x) {
scan_ulong(x,&id);
if (prot_uid((int) id) == -1) _exit(30);
}
doit();
}
publicfile-0.52/file.h 644 0 0 170 7011746002 10747 0 ustar 00 #ifndef FILE_H
#define FILE_H
#include "tai.h"
extern int file_open(char *,struct tai *,unsigned long *,int);
#endif
publicfile-0.52/file.c 644 0 0 3334 7011746002 10767 0 ustar 00 #include
#include
#include "subfd.h"
#include "error.h"
#include "file.h"
#include "byte.h"
#include "str.h"
#include "tai.h"
#include "env.h"
static void log(char *fn,char *result1,char *result2,int flagread)
{
int i;
char ch;
char *x;
x = env_get("TCPREMOTEIP");
if (!x) x = "0";
substdio_puts(subfderr,x);
substdio_puts(subfderr,flagread ? " read ": " dir ");
for (i = 0;i < 100;++i) {
ch = fn[i];
if (!ch) break;
if (ch < 32) ch = '?';
if (ch > 126) ch = '?';
if (ch == ' ') ch = '_';
substdio_put(subfderr,&ch,1);
}
if (i == 100)
substdio_puts(subfderr,"...");
substdio_puts(subfderr,result1);
substdio_puts(subfderr,result2);
substdio_puts(subfderr,"\n");
substdio_flush(subfderr);
}
int file_open(char *fn,struct tai *mtime,unsigned long *length,int flagread)
{
struct stat st;
int fd;
fd = open_read(fn);
if (fd == -1) {
log(fn,": open failed: ",error_str(errno),flagread);
if (error_temp(errno)) _exit(23);
return -1;
}
if (fstat(fd,&st) == -1) {
log(fn,": fstat failed: ",error_str(errno),flagread);
close(fd);
if (error_temp(errno)) _exit(23);
return -1;
}
if ((st.st_mode & 0444) != 0444) {
log(fn,": ","not ugo+r",flagread);
close(fd);
errno = error_acces;
return -1;
}
if ((st.st_mode & 0101) == 0001) {
log(fn,": ","o+x but u-x",flagread);
close(fd);
errno = error_acces;
return -1;
}
if (flagread)
if ((st.st_mode & S_IFMT) != S_IFREG) {
log(fn,": ","not a regular file",flagread);
close(fd);
errno = error_acces;
return -1;
}
log(fn,": ","success",flagread);
*length = st.st_size;
tai_unix(mtime,st.st_mtime);
return fd;
}
publicfile-0.52/pathdecode.h 644 0 0 156 7011746002 12134 0 ustar 00 #ifndef PATHDECODE_H
#define PATHDECODE_H
#include "stralloc.h"
extern void pathdecode(stralloc *);
#endif
publicfile-0.52/pathdecode.c 644 0 0 503 7011746002 12123 0 ustar 00 #include "pathdecode.h"
void pathdecode(stralloc *fn)
{
int i;
int j;
char ch;
j = 0;
for (i = 0;i < fn->len;++i) {
ch = fn->s[i];
if (ch == 0) ch = '\n';
if (j && (fn->s[j - 1] == '/')) {
if (ch == '.') ch = ':';
if (ch == '/') continue;
}
fn->s[j++] = ch;
}
fn->len = j;
}
publicfile-0.52/filetype.h 644 0 0 174 7011746002 11655 0 ustar 00 #ifndef FILETYPE_H
#define FILETYPE_H
#include "stralloc.h"
extern void filetype(char *fn,stralloc *contenttype);
#endif
publicfile-0.52/filetype.c 644 0 0 2340 7011746002 11665 0 ustar 00 #include "filetype.h"
#include "str.h"
void filetype(char *fn,stralloc *contenttype)
{
char *x;
char *result;
int i;
char ch;
if (!stralloc_copys(contenttype,"Content-Type: ")) _exit(21);
x = fn + str_rchr(fn,'.');
if (x[str_chr(x,'=')])
for (i = 0;(i < 100) && (ch = x[i]);++i) {
if ((ch != '=') && (ch != '-') && (ch != ':'))
if ((ch < 'a') || (ch > 'z'))
if ((ch < '0') || (ch > '9'))
continue;
if (ch == '=') ch = '/';
if (ch == ':') ch = '.';
if (!stralloc_append(contenttype,&ch)) _exit(21);
}
else {
result = "text/plain";
if (str_equal(x,".html")) result = "text/html";
else if (str_equal(x,".gz")) result = "application/x-gzip";
else if (str_equal(x,".dvi")) result = "application/x-dvi";
else if (str_equal(x,".ps")) result = "application/postscript";
else if (str_equal(x,".pdf")) result = "application/pdf";
else if (str_equal(x,".gif")) result = "image/gif";
else if (str_equal(x,".jpeg")) result = "image/jpeg";
else if (str_equal(x,".png")) result = "image/png";
else if (str_equal(x,".mpeg")) result = "video/mpeg";
if (!stralloc_cats(contenttype,result)) _exit(21);
}
if (!stralloc_cats(contenttype,"\r\n")) _exit(21);
}
publicfile-0.52/httpdate.h 644 0 0 205 7011746002 11644 0 ustar 00 #ifndef HTTPDATE_H
#define HTTPDATE_H
#include "stralloc.h"
#include "tai.h"
extern int httpdate(stralloc *,struct tai *);
#endif
publicfile-0.52/httpdate.c 644 0 0 2021 7011746002 11655 0 ustar 00 #include "caltime.h"
#include "httpdate.h"
static char *weekday[7] = {
" Sun, ", " Mon, ", " Tue, ", " Wed, ", " Thu, ", " Fri, ", " Sat, "
} ;
static char *month[12] = {
" Jan ", " Feb ", " Mar ", " Apr ", " May ", " Jun "
, " Jul ", " Aug ", " Sep ", " Oct ", " Nov ", " Dec "
} ;
int httpdate(stralloc *sa,struct tai *t)
{
struct caltime ct;
int i;
caltime_utc(&ct,t,&i,(int *) 0);
if (i < 0) i = 0;
if (i > 6) i = 6;
if (!stralloc_copys(sa,weekday[i])) return 0;
if (!stralloc_catuint0(sa,ct.date.day,2)) return 0;
i = ct.date.month - 1;
if (i < 0) i = 0;
if (i > 11) i = 11;
if (!stralloc_cats(sa,month[i])) return 0;
if (!stralloc_catuint0(sa,ct.date.year,0)) return 0;
if (!stralloc_cats(sa," ")) return 0;
if (!stralloc_catuint0(sa,ct.hour,2)) return 0;
if (!stralloc_cats(sa,":")) return 0;
if (!stralloc_catuint0(sa,ct.minute,2)) return 0;
if (!stralloc_cats(sa,":")) return 0;
if (!stralloc_catuint0(sa,ct.second,2)) return 0;
if (!stralloc_cats(sa," GMT")) return 0;
return 1;
}
publicfile-0.52/percent.h 644 0 0 145 7011746002 11472 0 ustar 00 #ifndef PERCENT_H
#define PERCENT_H
#include "stralloc.h"
extern void percent(stralloc *);
#endif
publicfile-0.52/percent.c 644 0 0 1066 7011746002 11510 0 ustar 00 #include "percent.h"
static unsigned char fromhex(unsigned char t)
{
unsigned char u;
u = t - 'a';
if (u < 6) return u + 10;
u = t - 'A';
if (u < 6) return u + 10;
u = t - '0';
if (u < 10) return u;
return 0;
}
void percent(stralloc *sa)
{
int i;
int j;
char ch;
i = j = 0;
for (;;) {
if (j >= sa->len) break;
ch = sa->s[j++];
if (ch == '%') {
if (j >= sa->len) break;
ch = 16 * fromhex(sa->s[j++]);
if (j >= sa->len) break;
ch += fromhex(sa->s[j++]);
}
sa->s[i++] = ch;
}
sa->len = i;
}
publicfile-0.52/fetch.h 644 0 0 341 7011746002 11121 0 ustar 00 #ifndef FETCH_H
#define FETCH_H
#define FETCH_RETR 0
#define FETCH_NLST 1
#define FETCH_LIST 2
#define FETCH_LISTONE 3
extern void fetch(char *,int,int,int);
extern int fetch_ascii;
extern unsigned long fetch_rest;
#endif
publicfile-0.52/fetch.c 644 0 0 6536 7011746002 11150 0 ustar 00 #include
#include
#include
#include "substdio.h"
#include "timeoutwrite.h"
#include "error.h"
#include "exit.h"
#include "direntry.h"
#include "fmt.h"
#include "fetch.h"
int fetch_ascii = 1;
unsigned long fetch_rest = 0;
static char inbuf[1024];
static char ssbuf[1024];
static substdio ss;
static int trouble;
static time_t now;
static struct stat st;
static char strnum[FMT_ULONG];
static int datawrite(int fd,char *buf,int len)
{
int w;
if (trouble) return -1;
if (fetch_rest) {
if (len > fetch_rest) len = fetch_rest;
fetch_rest -= len;
return len;
}
w = timeoutwrite(60,fd,buf,len);
if (w == -1) if (errno != error_intr) trouble = errno;
return w;
}
static void printstat()
{
substdio_puts(&ss,"+i");
substdio_put(&ss,strnum,fmt_ulong(strnum,(unsigned long) st.st_dev));
substdio_puts(&ss,".");
substdio_put(&ss,strnum,fmt_ulong(strnum,(unsigned long) st.st_ino));
if (st.st_mtime > 0)
if (st.st_mtime < now - 60) {
substdio_puts(&ss,",m");
substdio_put(&ss,strnum,fmt_ulong(strnum,(unsigned long) st.st_mtime));
}
if ((st.st_mode & S_IFMT) == S_IFDIR)
substdio_puts(&ss,",/");
if (((st.st_mode & S_IFMT) == S_IFREG) && ((st.st_mode & 0444) == 0444)) {
substdio_puts(&ss,",r,s");
substdio_put(&ss,strnum,fmt_ulong(strnum,(unsigned long) st.st_size));
}
substdio_puts(&ss,",\t");
}
static void list(char *fn,int flaglong)
{
int i;
if (fn[0] == '.') return;
for (i = 0;fn[i];++i) {
if ((fn[i] >= 0) && (fn[i] <= 32)) return;
if (fn[i] == '~') return;
}
if (flaglong) {
if (stat(fn,&st) == -1) {
if (error_temp(errno)) _exit(23);
return;
}
printstat(&st);
}
substdio_puts(&ss,fn);
substdio_puts(&ss,"\r\n");
}
static int doit(char *fn,int fddata,int fdfile,int how)
{
DIR *dir;
direntry *d;
int r;
int i;
substdio_fdbuf(&ss,datawrite,fddata,ssbuf,sizeof ssbuf);
switch(how) {
case FETCH_LISTONE:
if (fstat(fdfile,&st) == -1) break;
printstat(&st);
for (i = 0;fn[i];++i)
if (fn[i] == '\n')
substdio_put(&ss,"",1);
else
substdio_put(&ss,&fn[i],1);
substdio_puts(&ss,"\r\n");
break;
case FETCH_LIST:
case FETCH_NLST:
if (fchdir(fdfile) == -1) {
trouble = errno;
return;
}
dir = opendir(".");
if (!dir) _exit(23); /* XXX: could be out of memory */
while (d = readdir(dir)) /* XXX: temporary errors */
list(d->d_name,how == FETCH_LIST);
closedir(dir);
break;
default:
for (;;) {
r = read(fdfile,inbuf,sizeof inbuf);
if (r == -1) {
if (errno = error_intr) continue;
_exit(23);
}
if (r == 0)
break;
if (!fetch_ascii)
substdio_put(&ss,inbuf,r);
else
for (i = 0;i < r;++i) {
if (inbuf[i] == '\n')
substdio_put(&ss,"\r",1);
substdio_put(&ss,inbuf + i,1);
}
}
break;
}
substdio_flush(&ss);
}
void fetch(char *fn,int fddata,int fdfile,int how)
{
int fdcurrent;
time(&now);
fdcurrent = open_read(".");
if (fdcurrent == -1) _exit(23);
trouble = 0;
doit(fn,fddata,fdfile,how);
close(fddata);
close(fdfile);
if (!trouble)
out_puts("226 Success.\r\n");
else {
out_puts("426 Transmission failure: ");
out_puts(error_str(trouble));
out_puts("\r\n");
}
if (fchdir(fdcurrent) == -1) _exit(23);
close(fdcurrent);
fetch_rest = 0;
}
publicfile-0.52/timeoutaccept.h 644 0 0 134 7011746002 12676 0 ustar 00 #ifndef TIMEOUTACCEPT_H
#define TIMEOUTACCEPT_H
extern int timeoutaccept(int,int);
#endif
publicfile-0.52/timeoutaccept.c 644 0 0 1161 7011746002 12712 0 ustar 00 #include
#include
#include
#include "timeoutaccept.h"
#include "ndelay.h"
#include "select.h"
#include "error.h"
#include "readwrite.h"
int timeoutaccept(int s,int timeout)
{
struct sockaddr_in sa;
int dummy;
int fd;
fd_set rfds;
struct timeval tv;
if (ndelay_on(s) == -1) return -1;
FD_ZERO(&rfds);
FD_SET(s,&rfds);
tv.tv_sec = timeout; tv.tv_usec = 0;
if (select(s + 1,&rfds,(fd_set *) 0,(fd_set *) 0,&tv) == -1) return -1;
dummy = sizeof sa;
fd = accept(s,(struct sockaddr *) &sa,&dummy);
if (fd == -1) return -1;
ndelay_off(s);
return fd;
}
publicfile-0.52/hasdevtcp.h1 644 0 0 26 7011746002 12052 0 ustar 00 /* sysdep: -devtcp */
publicfile-0.52/hasdevtcp.h2 644 0 0 52 7011746002 12052 0 ustar 00 /* sysdep: +devtcp */
#define HASDEVTCP 1
publicfile-0.52/choose.sh 644 0 0 402 7011746002 11471 0 ustar 00
result="$4"
case "$1" in
*c*) ./compile $2.c >/dev/null 2>&1 || result="$3" ;;
esac
case "$1" in
*l*) ./load $2 >/dev/null 2>&1 || result="$3" ;;
esac
case "$1" in
*r*) ./$2 >/dev/null 2>&1 || result="$3" ;;
esac
rm -f $2.o $2
exec cat "$result"
publicfile-0.52/warn-auto.sh 644 0 0 100 7011746002 12121 0 ustar 00 #!/bin/sh
# WARNING: This file was auto-generated. Do not edit!
publicfile-0.52/find-systype.sh 644 0 0 7036 7011746002 12701 0 ustar 00 # oper-:arch-:syst-:chip-:kern-
# oper = operating system type; e.g., sunos-4.1.4
# arch = machine language; e.g., sparc
# syst = which binaries can run; e.g., sun4
# chip = chip model; e.g., micro-2-80
# kern = kernel version; e.g., sun4m
# dependence: arch --- chip
# \ \
# oper --- syst --- kern
# so, for example, syst is interpreted in light of oper, but chip is not.
# anyway, no slashes, no extra colons, no uppercase letters.
# the point of the extra -'s is to ease parsing: can add hierarchies later.
# e.g., *:i386-*:*:pentium-*:* would handle pentium-100 as well as pentium,
# and i386-486 (486s do have more instructions, you know) as well as i386.
# the idea here is to include ALL useful available information.
exec 2>/dev/null
sys="`uname -s | tr '/:[A-Z]' '..[a-z]'`"
if [ x"$sys" != x ]
then
unamer="`uname -r | tr /: ..`"
unamem="`uname -m | tr /: ..`"
unamev="`uname -v | tr /: ..`"
case "$sys" in
bsd.os)
# in bsd 4.4, uname -v does not have useful info.
# in bsd 4.4, uname -m is arch, not chip.
oper="$sys-$unamer"
arch="$unamem"
syst=""
chip="`sysctl -n hw.model`"
kern=""
;;
freebsd)
# see above about bsd 4.4
oper="$sys-$unamer"
arch="$unamem"
syst=""
chip="`sysctl -n hw.model`" # hopefully
kern=""
;;
netbsd)
# see above about bsd 4.4
oper="$sys-$unamer"
arch="$unamem"
syst=""
chip="`sysctl -n hw.model`" # hopefully
kern=""
;;
linux)
# as in bsd 4.4, uname -v does not have useful info.
oper="$sys-$unamer"
syst=""
chip="$unamem"
kern=""
case "$chip" in
i386|i486|i586|i686)
arch="i386"
;;
alpha)
arch="alpha"
;;
esac
;;
aix)
# naturally IBM has to get uname -r and uname -v backwards. dorks.
oper="$sys-$unamev-$unamer"
arch="`arch | tr /: ..`"
syst=""
chip="$unamem"
kern=""
;;
sunos)
oper="$sys-$unamer-$unamev"
arch="`(uname -p || mach) | tr /: ..`"
syst="`arch | tr /: ..`"
chip="$unamem" # this is wrong; is there any way to get the real info?
kern="`arch -k | tr /: ..`"
;;
unix_sv)
oper="$sys-$unamer-$unamev"
arch="`uname -m`"
syst=""
chip="$unamem"
kern=""
;;
*)
oper="$sys-$unamer-$unamev"
arch="`arch | tr /: ..`"
syst=""
chip="$unamem"
kern=""
;;
esac
else
$CC -c trycpp.c
$LD -o trycpp trycpp.o
case `./trycpp` in
nextstep)
oper="nextstep-`hostinfo | sed -n 's/^[ ]*NeXT Mach \([^:]*\):.*$/\1/p'`"
arch="`hostinfo | sed -n 's/^Processor type: \(.*\) (.*)$/\1/p' | tr /: ..`"
syst=""
chip="`hostinfo | sed -n 's/^Processor type: .* (\(.*\))$/\1/p' | tr ' /:' '...'`"
kern=""
;;
*)
oper="unknown"
arch=""
syst=""
chip=""
kern=""
;;
esac
rm -f trycpp.o trycpp
fi
case "$chip" in
80486)
# let's try to be consistent here. (BSD/OS)
chip=i486
;;
i486DX)
# respect the hyphen hierarchy. (FreeBSD)
chip=i486-dx
;;
i486.DX2)
# respect the hyphen hierarchy. (FreeBSD)
chip=i486-dx2
;;
Intel.586)
# no, you nitwits, there is no such chip. (NeXTStep)
chip=pentium
;;
i586)
# no, you nitwits, there is no such chip. (Linux)
chip=pentium
;;
i686)
# STOP SAYING THAT! (Linux)
chip=ppro
esac
if $CC -c x86cpuid.c
then
if $LD -o x86cpuid x86cpuid.o
then
x86cpuid="`./x86cpuid | tr /: ..`"
case "$x86cpuid" in
?*)
chip="$x86cpuid"
;;
esac
fi
fi
rm -f x86cpuid x86cpuid.o
echo "$oper-:$arch-:$syst-:$chip-:$kern-" | tr ' [A-Z]' '.[a-z]'
publicfile-0.52/trycpp.c 644 0 0 137 7011746002 11347 0 ustar 00 main()
{
#ifdef NeXT
printf("nextstep\n"); exit(0);
#endif
printf("unknown\n"); exit(0);
}
publicfile-0.52/auto-str.c 644 0 0 1345 7011746002 11626 0 ustar 00 #include "substdio.h"
#include "readwrite.h"
#include "exit.h"
char buf1[256];
substdio ss1 = SUBSTDIO_FDBUF(write,1,buf1,sizeof(buf1));
void puts(s)
char *s;
{
if (substdio_puts(&ss1,s) == -1) _exit(111);
}
main(argc,argv)
int argc;
char **argv;
{
char *name;
char *value;
unsigned char ch;
char octal[4];
name = argv[1];
if (!name) _exit(100);
value = argv[2];
if (!value) _exit(100);
puts("char ");
puts(name);
puts("[] = \"\\\n");
while (ch = *value++) {
puts("\\");
octal[3] = 0;
octal[2] = '0' + (ch & 7); ch >>= 3;
octal[1] = '0' + (ch & 7); ch >>= 3;
octal[0] = '0' + (ch & 7);
puts(octal);
}
puts("\\\n\";\n");
if (substdio_flush(&ss1) == -1) _exit(111);
_exit(0);
}
publicfile-0.52/auto_home.h 644 0 0 112 7011746002 12004 0 ustar 00 #ifndef AUTO_HOME_H
#define AUTO_HOME_H
extern char auto_home[];
#endif
publicfile-0.52/install.c 644 0 0 10016 7011746002 11531 0 ustar 00 #include "substdio.h"
#include "strerr.h"
#include "error.h"
#include "open.h"
#include "readwrite.h"
#include "exit.h"
extern void hier();
#define FATAL "install: fatal: "
int fdsourcedir = -1;
void h(home,uid,gid,mode)
char *home;
int uid;
int gid;
int mode;
{
if (mkdir(home,0700) == -1)
if (errno != error_exist)
strerr_die4sys(111,FATAL,"unable to mkdir ",home,": ");
if (chown(home,uid,gid) == -1)
strerr_die4sys(111,FATAL,"unable to chown ",home,": ");
if (chmod(home,mode) == -1)
strerr_die4sys(111,FATAL,"unable to chmod ",home,": ");
}
void d(home,subdir,uid,gid,mode)
char *home;
char *subdir;
int uid;
int gid;
int mode;
{
if (chdir(home) == -1)
strerr_die4sys(111,FATAL,"unable to switch to ",home,": ");
if (mkdir(subdir,0700) == -1)
if (errno != error_exist)
strerr_die6sys(111,FATAL,"unable to mkdir ",home,"/",subdir,": ");
if (chown(subdir,uid,gid) == -1)
strerr_die6sys(111,FATAL,"unable to chown ",home,"/",subdir,": ");
if (chmod(subdir,mode) == -1)
strerr_die6sys(111,FATAL,"unable to chmod ",home,"/",subdir,": ");
}
char inbuf[SUBSTDIO_INSIZE];
char outbuf[SUBSTDIO_OUTSIZE];
substdio ssin;
substdio ssout;
void c(home,subdir,file,uid,gid,mode)
char *home;
char *subdir;
char *file;
int uid;
int gid;
int mode;
{
int fdin;
int fdout;
if (fchdir(fdsourcedir) == -1)
strerr_die2sys(111,FATAL,"unable to switch back to source directory: ");
fdin = open_read(file);
if (fdin == -1)
strerr_die4sys(111,FATAL,"unable to read ",file,": ");
substdio_fdbuf(&ssin,read,fdin,inbuf,sizeof inbuf);
if (chdir(home) == -1)
strerr_die4sys(111,FATAL,"unable to switch to ",home,": ");
if (chdir(subdir) == -1)
strerr_die6sys(111,FATAL,"unable to switch to ",home,"/",subdir,": ");
fdout = open_trunc(file);
if (fdout == -1)
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
substdio_fdbuf(&ssout,write,fdout,outbuf,sizeof outbuf);
switch(substdio_copy(&ssout,&ssin)) {
case -2:
strerr_die4sys(111,FATAL,"unable to read ",file,": ");
case -3:
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
}
close(fdin);
if (substdio_flush(&ssout) == -1)
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
if (fsync(fdout) == -1)
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
if (close(fdout) == -1) /* NFS silliness */
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
if (chown(file,uid,gid) == -1)
strerr_die6sys(111,FATAL,"unable to chown .../",subdir,"/",file,": ");
if (chmod(file,mode) == -1)
strerr_die6sys(111,FATAL,"unable to chmod .../",subdir,"/",file,": ");
}
void z(home,subdir,file,len,uid,gid,mode)
char *home;
char *subdir;
char *file;
int len;
int uid;
int gid;
int mode;
{
int fdout;
if (chdir(home) == -1)
strerr_die4sys(111,FATAL,"unable to switch to ",home,": ");
if (chdir(subdir) == -1)
strerr_die6sys(111,FATAL,"unable to switch to ",home,"/",subdir,": ");
fdout = open_trunc(file);
if (fdout == -1)
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
substdio_fdbuf(&ssout,write,fdout,outbuf,sizeof outbuf);
while (len-- > 0)
if (substdio_put(&ssout,"",1) == -1)
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
if (substdio_flush(&ssout) == -1)
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
if (fsync(fdout) == -1)
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
if (close(fdout) == -1) /* NFS silliness */
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
if (chown(file,uid,gid) == -1)
strerr_die6sys(111,FATAL,"unable to chown .../",subdir,"/",file,": ");
if (chmod(file,mode) == -1)
strerr_die6sys(111,FATAL,"unable to chmod .../",subdir,"/",file,": ");
}
main()
{
fdsourcedir = open_read(".");
if (fdsourcedir == -1)
strerr_die2sys(111,FATAL,"unable to open current directory: ");
umask(077);
hier();
_exit(0);
}
publicfile-0.52/instcheck.c 644 0 0 4370 7011746002 12024 0 ustar 00 #include
#include
#include "strerr.h"
#include "error.h"
#include "readwrite.h"
#include "exit.h"
extern void hier();
#define FATAL "instcheck: fatal: "
#define WARNING "instcheck: warning: "
void perm(prefix1,prefix2,prefix3,file,type,uid,gid,mode)
char *prefix1;
char *prefix2;
char *prefix3;
char *file;
int type;
int uid;
int gid;
int mode;
{
struct stat st;
if (stat(file,&st) == -1) {
if (errno == error_noent)
strerr_warn6(WARNING,prefix1,prefix2,prefix3,file," does not exist",0);
else
strerr_warn4(WARNING,"unable to stat .../",file,": ",&strerr_sys);
return;
}
if ((uid != -1) && (st.st_uid != uid))
strerr_warn6(WARNING,prefix1,prefix2,prefix3,file," has wrong owner",0);
if ((gid != -1) && (st.st_gid != gid))
strerr_warn6(WARNING,prefix1,prefix2,prefix3,file," has wrong group",0);
if ((st.st_mode & 07777) != mode)
strerr_warn6(WARNING,prefix1,prefix2,prefix3,file," has wrong permissions",0);
if ((st.st_mode & S_IFMT) != type)
strerr_warn6(WARNING,prefix1,prefix2,prefix3,file," has wrong type",0);
}
void h(home,uid,gid,mode)
char *home;
int uid;
int gid;
int mode;
{
perm("","","",home,S_IFDIR,uid,gid,mode);
}
void d(home,subdir,uid,gid,mode)
char *home;
char *subdir;
int uid;
int gid;
int mode;
{
if (chdir(home) == -1)
strerr_die4sys(111,FATAL,"unable to switch to ",home,": ");
perm("",home,"/",subdir,S_IFDIR,uid,gid,mode);
}
void p(home,fifo,uid,gid,mode)
char *home;
char *fifo;
int uid;
int gid;
int mode;
{
if (chdir(home) == -1)
strerr_die4sys(111,FATAL,"unable to switch to ",home,": ");
perm("",home,"/",fifo,S_IFIFO,uid,gid,mode);
}
void c(home,subdir,file,uid,gid,mode)
char *home;
char *subdir;
char *file;
int uid;
int gid;
int mode;
{
if (chdir(home) == -1)
strerr_die4sys(111,FATAL,"unable to switch to ",home,": ");
if (chdir(subdir) == -1)
strerr_die6sys(111,FATAL,"unable to switch to ",home,"/",subdir,": ");
perm(".../",subdir,"/",file,S_IFREG,uid,gid,mode);
}
void z(home,file,len,uid,gid,mode)
char *home;
char *file;
int len;
int uid;
int gid;
int mode;
{
if (chdir(home) == -1)
strerr_die4sys(111,FATAL,"unable to switch to ",home,": ");
perm("",home,"/",file,S_IFREG,uid,gid,mode);
}
main()
{
hier();
_exit(0);
}
publicfile-0.52/hier.c 644 0 0 346 7011746002 10757 0 ustar 00 #include "auto_home.h"
void hier()
{
h(auto_home,-1,-1,02755);
d(auto_home,"bin",-1,-1,02755);
c(auto_home,"bin","configure",-1,-1,0755);
c(auto_home,"bin","httpd",-1,-1,0755);
c(auto_home,"bin","ftpd",-1,-1,0755);
}
publicfile-0.52/alloc.c 644 0 0 1501 7011746002 11134 0 ustar 00 #include "alloc.h"
#include "error.h"
extern char *malloc();
extern void free();
#define ALIGNMENT 16 /* XXX: assuming that this alignment is enough */
#define SPACE 4096 /* must be multiple of ALIGNMENT */
typedef union { char irrelevant[ALIGNMENT]; double d; } aligned;
static aligned realspace[SPACE / ALIGNMENT];
#define space ((char *) realspace)
static unsigned int avail = SPACE; /* multiple of ALIGNMENT; 0<=avail<=SPACE */
/*@null@*//*@out@*/char *alloc(n)
unsigned int n;
{
char *x;
n = ALIGNMENT + n - (n & (ALIGNMENT - 1)); /* XXX: could overflow */
if (n <= avail) { avail -= n; return space + avail; }
x = malloc(n);
if (!x) errno = error_nomem;
return x;
}
void alloc_free(x)
char *x;
{
if (x >= space)
if (x < space + SPACE)
return; /* XXX: assuming that pointers are flat */
free(x);
}
publicfile-0.52/alloc.h 644 0 0 203 7011746002 11117 0 ustar 00 #ifndef ALLOC_H
#define ALLOC_H
extern /*@null@*//*@out@*/char *alloc();
extern void alloc_free();
extern int alloc_re();
#endif
publicfile-0.52/alloc_re.c 644 0 0 326 7011746002 11606 0 ustar 00 #include "alloc.h"
#include "byte.h"
int alloc_re(x,m,n)
char **x;
unsigned int m;
unsigned int n;
{
char *y;
y = alloc(n);
if (!y) return 0;
byte_copy(y,m,*x);
alloc_free(*x);
*x = y;
return 1;
}
publicfile-0.52/byte.h 644 0 0 401 7011746002 10770 0 ustar 00 #ifndef BYTE_H
#define BYTE_H
extern unsigned int byte_chr();
extern unsigned int byte_rchr();
extern void byte_copy();
extern void byte_copyr();
extern int byte_diff();
extern void byte_zero();
#define byte_equal(s,n,t) (!byte_diff((s),(n),(t)))
#endif
publicfile-0.52/byte_chr.c 644 0 0 602 7011746002 11622 0 ustar 00 #include "byte.h"
unsigned int byte_chr(s,n,c)
char *s;
register unsigned int n;
int c;
{
register char ch;
register char *t;
ch = c;
t = s;
for (;;) {
if (!n) break; if (*t == ch) break; ++t; --n;
if (!n) break; if (*t == ch) break; ++t; --n;
if (!n) break; if (*t == ch) break; ++t; --n;
if (!n) break; if (*t == ch) break; ++t; --n;
}
return t - s;
}
publicfile-0.52/byte_copy.c 644 0 0 453 7011746002 12024 0 ustar 00 #include "byte.h"
void byte_copy(to,n,from)
register char *to;
register unsigned int n;
register char *from;
{
for (;;) {
if (!n) return; *to++ = *from++; --n;
if (!n) return; *to++ = *from++; --n;
if (!n) return; *to++ = *from++; --n;
if (!n) return; *to++ = *from++; --n;
}
}
publicfile-0.52/byte_cr.c 644 0 0 504 7011746002 11453 0 ustar 00 #include "byte.h"
void byte_copyr(to,n,from)
register char *to;
register unsigned int n;
register char *from;
{
to += n;
from += n;
for (;;) {
if (!n) return; *--to = *--from; --n;
if (!n) return; *--to = *--from; --n;
if (!n) return; *--to = *--from; --n;
if (!n) return; *--to = *--from; --n;
}
}
publicfile-0.52/byte_diff.c 644 0 0 705 7011746002 11762 0 ustar 00 #include "byte.h"
int byte_diff(s,n,t)
register char *s;
register unsigned int n;
register char *t;
{
for (;;) {
if (!n) return 0; if (*s != *t) break; ++s; ++t; --n;
if (!n) return 0; if (*s != *t) break; ++s; ++t; --n;
if (!n) return 0; if (*s != *t) break; ++s; ++t; --n;
if (!n) return 0; if (*s != *t) break; ++s; ++t; --n;
}
return ((int)(unsigned int)(unsigned char) *s)
- ((int)(unsigned int)(unsigned char) *t);
}
publicfile-0.52/byte_rchr.c 644 0 0 661 7011746002 12011 0 ustar 00 #include "byte.h"
unsigned int byte_rchr(s,n,c)
char *s;
register unsigned int n;
int c;
{
register char ch;
register char *t;
register char *u;
ch = c;
t = s;
u = 0;
for (;;) {
if (!n) break; if (*t == ch) u = t; ++t; --n;
if (!n) break; if (*t == ch) u = t; ++t; --n;
if (!n) break; if (*t == ch) u = t; ++t; --n;
if (!n) break; if (*t == ch) u = t; ++t; --n;
}
if (!u) u = t;
return u - s;
}
publicfile-0.52/byte_zero.c 644 0 0 346 7011746002 12032 0 ustar 00 #include "byte.h"
void byte_zero(s,n)
char *s;
register unsigned int n;
{
for (;;) {
if (!n) break; *s++ = 0; --n;
if (!n) break; *s++ = 0; --n;
if (!n) break; *s++ = 0; --n;
if (!n) break; *s++ = 0; --n;
}
}
publicfile-0.52/caldate.h 644 0 0 452 7011746002 11430 0 ustar 00 #ifndef CALDATE_H
#define CALDATE_H
struct caldate {
long year;
int month;
int day;
} ;
extern unsigned int caldate_fmt();
extern unsigned int caldate_scan();
extern void caldate_frommjd();
extern long caldate_mjd();
extern void caldate_normalize();
extern void caldate_easter();
#endif
publicfile-0.52/caldate_fmjd.c 644 0 0 1740 7011746002 12444 0 ustar 00 #include "caldate.h"
void caldate_frommjd(cd,day,pwday,pyday)
struct caldate *cd;
long day;
int *pwday;
int *pyday;
{
long year;
long month;
int yday;
year = day / 146097L;
day %= 146097L;
day += 678881L;
while (day >= 146097L) { day -= 146097L; ++year; }
/* year * 146097 + day - 678881 is MJD; 0 <= day < 146097 */
/* 2000-03-01, MJD 51604, is year 5, day 0 */
if (pwday) *pwday = (day + 3) % 7;
year *= 4;
if (day == 146096L) { year += 3; day = 36524L; }
else { year += day / 36524L; day %= 36524L; }
year *= 25;
year += day / 1461;
day %= 1461;
year *= 4;
yday = (day < 306);
if (day == 1460) { year += 3; day = 365; }
else { year += day / 365; day %= 365; }
yday += day;
day *= 10;
month = (day + 5) / 306;
day = (day + 5) % 306;
day /= 10;
if (month >= 10) { yday -= 306; ++year; month -= 10; }
else { yday += 59; month += 2; }
cd->year = year;
cd->month = month + 1;
cd->day = day + 1;
if (pyday) *pyday = yday;
}
publicfile-0.52/caltime.h 644 0 0 445 7011746002 11453 0 ustar 00 #ifndef CALTIME_H
#define CALTIME_H
#include "caldate.h"
struct caltime {
struct caldate date;
int hour;
int minute;
int second;
long offset;
} ;
extern void caltime_tai();
extern void caltime_utc();
extern unsigned int caltime_fmt();
extern unsigned int caltime_scan();
#endif
publicfile-0.52/caltime_utc.c 644 0 0 1115 7011746002 12334 0 ustar 00 #include "tai.h"
#include "leapsecs.h"
#include "caldate.h"
#include "caltime.h"
/* XXX: breaks tai encapsulation */
void caltime_utc(ct,t,pwday,pyday)
struct caltime *ct;
struct tai *t;
int *pwday;
int *pyday;
{
struct tai t2 = *t;
uint64 u;
int leap;
long s;
/* XXX: check for overfow? */
leap = leapsecs_sub(&t2);
u = t2.x;
u += 58486;
s = u % 86400ULL;
ct->second = (s % 60) + leap; s /= 60;
ct->minute = s % 60; s /= 60;
ct->hour = s;
u /= 86400ULL;
caldate_frommjd(&ct->date,/*XXX*/(long) (u - 53375995543064ULL),pwday,pyday);
ct->offset = 0;
}
publicfile-0.52/case.h 644 0 0 364 7011746002 10750 0 ustar 00 #ifndef CASE_H
#define CASE_H
extern void case_lowers();
extern void case_lowerb();
extern int case_diffs();
extern int case_diffb();
extern int case_starts();
extern int case_startb();
#define case_equals(s,t) (!case_diffs((s),(t)))
#endif
publicfile-0.52/case_diffs.c 644 0 0 611 7011746002 12111 0 ustar 00 #include "case.h"
int case_diffs(s,t)
register char *s;
register char *t;
{
register unsigned char x;
register unsigned char y;
for (;;) {
x = *s++ - 'A';
if (x <= 'Z' - 'A') x += 'a'; else x += 'A';
y = *t++ - 'A';
if (y <= 'Z' - 'A') y += 'a'; else y += 'A';
if (x != y) break;
if (!x) break;
}
return ((int)(unsigned int) x) - ((int)(unsigned int) y);
}
publicfile-0.52/case_lowerb.c 644 0 0 301 7011746002 12304 0 ustar 00 #include "case.h"
void case_lowerb(s,len)
char *s;
unsigned int len;
{
unsigned char x;
while (len > 0) {
--len;
x = *s - 'A';
if (x <= 'Z' - 'A') *s = x + 'a';
++s;
}
}
publicfile-0.52/case_startb.c 644 0 0 615 7011746002 12321 0 ustar 00 #include "case.h"
int case_startb(s,len,t)
register char *s;
unsigned int len;
register char *t;
{
register unsigned char x;
register unsigned char y;
for (;;) {
y = *t++ - 'A';
if (y <= 'Z' - 'A') y += 'a'; else y += 'A';
if (!y) return 1;
if (!len) return 0;
--len;
x = *s++ - 'A';
if (x <= 'Z' - 'A') x += 'a'; else x += 'A';
if (x != y) return 0;
}
}
publicfile-0.52/chkshsgr.c 644 0 0 206 7011746002 11637 0 ustar 00 #include "exit.h"
main()
{
short x[4];
x[0] = x[1] = 0;
if (getgroups(1,x) == 0) if (setgroups(1,x) == -1) _exit(1);
_exit(0);
}
publicfile-0.52/direntry.h1 644 0 0 221 7011746002 11746 0 ustar 00 #ifndef DIRENTRY_H
#define DIRENTRY_H
/* sysdep: -dirent */
#include
#include
#define direntry struct direct
#endif
publicfile-0.52/direntry.h2 644 0 0 220 7011746002 11746 0 ustar 00 #ifndef DIRENTRY_H
#define DIRENTRY_H
/* sysdep: +dirent */
#include
#include
#define direntry struct dirent
#endif
publicfile-0.52/env.c 644 0 0 441 7011746002 10614 0 ustar 00 #include "str.h"
#include "env.h"
extern /*@null@*/char *env_get(s)
char *s;
{
int i;
unsigned int len;
if (!s) return 0;
len = str_len(s);
for (i = 0;environ[i];++i)
if (str_start(environ[i],s) && (environ[i][len] == '='))
return environ[i] + len + 1;
return 0;
}
publicfile-0.52/env.h 644 0 0 137 7011746002 10623 0 ustar 00 #ifndef ENV_H
#define ENV_H
extern char **environ;
extern /*@null@*/char *env_get();
#endif
publicfile-0.52/error.c 644 0 0 1672 7011746002 11204 0 ustar 00 #include
#include "error.h"
/* warning: as coverage improves here, should update error_{str,temp} */
int error_intr =
#ifdef EINTR
EINTR;
#else
-1;
#endif
int error_nomem =
#ifdef ENOMEM
ENOMEM;
#else
-2;
#endif
int error_noent =
#ifdef ENOENT
ENOENT;
#else
-3;
#endif
int error_txtbsy =
#ifdef ETXTBSY
ETXTBSY;
#else
-4;
#endif
int error_io =
#ifdef EIO
EIO;
#else
-5;
#endif
int error_exist =
#ifdef EEXIST
EEXIST;
#else
-6;
#endif
int error_timeout =
#ifdef ETIMEDOUT
ETIMEDOUT;
#else
-7;
#endif
int error_inprogress =
#ifdef EINPROGRESS
EINPROGRESS;
#else
-8;
#endif
int error_wouldblock =
#ifdef EWOULDBLOCK
EWOULDBLOCK;
#else
-9;
#endif
int error_again =
#ifdef EAGAIN
EAGAIN;
#else
-10;
#endif
int error_pipe =
#ifdef EPIPE
EPIPE;
#else
-11;
#endif
int error_perm =
#ifdef EPERM
EPERM;
#else
-12;
#endif
int error_acces =
#ifdef EACCES
EACCES;
#else
-13;
#endif
int error_nodevice =
#ifdef ENXIO
ENXIO;
#else
-14;
#endif
publicfile-0.52/error.h 644 0 0 712 7011746002 11163 0 ustar 00 #ifndef ERROR_H
#define ERROR_H
extern int errno;
extern int error_intr;
extern int error_nomem;
extern int error_noent;
extern int error_txtbsy;
extern int error_io;
extern int error_exist;
extern int error_timeout;
extern int error_inprogress;
extern int error_wouldblock;
extern int error_again;
extern int error_pipe;
extern int error_perm;
extern int error_acces;
extern int error_nodevice;
extern char *error_str();
extern int error_temp();
#endif
publicfile-0.52/error_str.c 644 0 0 12654 7011746002 12116 0 ustar 00 #include
#include "error.h"
#define X(e,s) if (i == e) return s;
char *error_str(i)
int i;
{
X(0,"no error")
X(error_intr,"interrupted system call")
X(error_nomem,"out of memory")
X(error_noent,"file does not exist")
X(error_txtbsy,"text busy")
X(error_io,"input/output error")
X(error_exist,"file already exists")
X(error_timeout,"timed out")
X(error_inprogress,"operation in progress")
X(error_again,"temporary failure")
X(error_wouldblock,"input/output would block")
X(error_pipe,"broken pipe")
X(error_perm,"permission denied")
X(error_acces,"access denied")
X(error_nodevice,"device not configured")
#ifdef ESRCH
X(ESRCH,"no such process")
#endif
#ifdef E2BIG
X(E2BIG,"argument list too long")
#endif
#ifdef ENOEXEC
X(ENOEXEC,"exec format error")
#endif
#ifdef EBADF
X(EBADF,"file descriptor not open")
#endif
#ifdef ECHILD
X(ECHILD,"no child processes")
#endif
#ifdef EDEADLK
X(EDEADLK,"operation would cause deadlock")
#endif
#ifdef EFAULT
X(EFAULT,"bad address")
#endif
#ifdef ENOTBLK
X(ENOTBLK,"not a block device")
#endif
#ifdef EBUSY
X(EBUSY,"device busy")
#endif
#ifdef EXDEV
X(EXDEV,"cross-device link")
#endif
#ifdef ENODEV
X(ENODEV,"device does not support operation")
#endif
#ifdef ENOTDIR
X(ENOTDIR,"not a directory")
#endif
#ifdef EISDIR
X(EISDIR,"is a directory")
#endif
#ifdef EINVAL
X(EINVAL,"invalid argument")
#endif
#ifdef ENFILE
X(ENFILE,"system cannot open more files")
#endif
#ifdef EMFILE
X(EMFILE,"process cannot open more files")
#endif
#ifdef ENOTTY
X(ENOTTY,"not a tty")
#endif
#ifdef EFBIG
X(EFBIG,"file too big")
#endif
#ifdef ENOSPC
X(ENOSPC,"out of disk space")
#endif
#ifdef ESPIPE
X(ESPIPE,"unseekable descriptor")
#endif
#ifdef EROFS
X(EROFS,"read-only file system")
#endif
#ifdef EMLINK
X(EMLINK,"too many links")
#endif
#ifdef EDOM
X(EDOM,"input out of range")
#endif
#ifdef ERANGE
X(ERANGE,"output out of range")
#endif
#ifdef EALREADY
X(EALREADY,"operation already in progress")
#endif
#ifdef ENOTSOCK
X(ENOTSOCK,"not a socket")
#endif
#ifdef EDESTADDRREQ
X(EDESTADDRREQ,"destination address required")
#endif
#ifdef EMSGSIZE
X(EMSGSIZE,"message too long")
#endif
#ifdef EPROTOTYPE
X(EPROTOTYPE,"incorrect protocol type")
#endif
#ifdef ENOPROTOOPT
X(ENOPROTOOPT,"protocol not available")
#endif
#ifdef EPROTONOSUPPORT
X(EPROTONOSUPPORT,"protocol not supported")
#endif
#ifdef ESOCKTNOSUPPORT
X(ESOCKTNOSUPPORT,"socket type not supported")
#endif
#ifdef EOPNOTSUPP
X(EOPNOTSUPP,"operation not supported")
#endif
#ifdef EPFNOSUPPORT
X(EPFNOSUPPORT,"protocol family not supported")
#endif
#ifdef EAFNOSUPPORT
X(EAFNOSUPPORT,"address family not supported")
#endif
#ifdef EADDRINUSE
X(EADDRINUSE,"address already used")
#endif
#ifdef EADDRNOTAVAIL
X(EADDRNOTAVAIL,"address not available")
#endif
#ifdef ENETDOWN
X(ENETDOWN,"network down")
#endif
#ifdef ENETUNREACH
X(ENETUNREACH,"network unreachable")
#endif
#ifdef ENETRESET
X(ENETRESET,"network reset")
#endif
#ifdef ECONNABORTED
X(ECONNABORTED,"connection aborted")
#endif
#ifdef ECONNRESET
X(ECONNRESET,"connection reset")
#endif
#ifdef ENOBUFS
X(ENOBUFS,"out of buffer space")
#endif
#ifdef EISCONN
X(EISCONN,"already connected")
#endif
#ifdef ENOTCONN
X(ENOTCONN,"not connected")
#endif
#ifdef ESHUTDOWN
X(ESHUTDOWN,"socket shut down")
#endif
#ifdef ETOOMANYREFS
X(ETOOMANYREFS,"too many references")
#endif
#ifdef ECONNREFUSED
X(ECONNREFUSED,"connection refused")
#endif
#ifdef ELOOP
X(ELOOP,"symbolic link loop")
#endif
#ifdef ENAMETOOLONG
X(ENAMETOOLONG,"file name too long")
#endif
#ifdef EHOSTDOWN
X(EHOSTDOWN,"host down")
#endif
#ifdef EHOSTUNREACH
X(EHOSTUNREACH,"host unreachable")
#endif
#ifdef ENOTEMPTY
X(ENOTEMPTY,"directory not empty")
#endif
#ifdef EPROCLIM
X(EPROCLIM,"too many processes")
#endif
#ifdef EUSERS
X(EUSERS,"too many users")
#endif
#ifdef EDQUOT
X(EDQUOT,"disk quota exceeded")
#endif
#ifdef ESTALE
X(ESTALE,"stale NFS file handle")
#endif
#ifdef EREMOTE
X(EREMOTE,"too many levels of remote in path")
#endif
#ifdef EBADRPC
X(EBADRPC,"RPC structure is bad")
#endif
#ifdef ERPCMISMATCH
X(ERPCMISMATCH,"RPC version mismatch")
#endif
#ifdef EPROGUNAVAIL
X(EPROGUNAVAIL,"RPC program unavailable")
#endif
#ifdef EPROGMISMATCH
X(EPROGMISMATCH,"program version mismatch")
#endif
#ifdef EPROCUNAVAIL
X(EPROCUNAVAIL,"bad procedure for program")
#endif
#ifdef ENOLCK
X(ENOLCK,"no locks available")
#endif
#ifdef ENOSYS
X(ENOSYS,"system call not available")
#endif
#ifdef EFTYPE
X(EFTYPE,"bad file type")
#endif
#ifdef EAUTH
X(EAUTH,"authentication error")
#endif
#ifdef ENEEDAUTH
X(ENEEDAUTH,"not authenticated")
#endif
#ifdef ENOSTR
X(ENOSTR,"not a stream device")
#endif
#ifdef ETIME
X(ETIME,"timer expired")
#endif
#ifdef ENOSR
X(ENOSR,"out of stream resources")
#endif
#ifdef ENOMSG
X(ENOMSG,"no message of desired type")
#endif
#ifdef EBADMSG
X(EBADMSG,"bad message type")
#endif
#ifdef EIDRM
X(EIDRM,"identifier removed")
#endif
#ifdef ENONET
X(ENONET,"machine not on network")
#endif
#ifdef ERREMOTE
X(ERREMOTE,"object not local")
#endif
#ifdef ENOLINK
X(ENOLINK,"link severed")
#endif
#ifdef EADV
X(EADV,"advertise error")
#endif
#ifdef ESRMNT
X(ESRMNT,"srmount error")
#endif
#ifdef ECOMM
X(ECOMM,"communication error")
#endif
#ifdef EPROTO
X(EPROTO,"protocol error")
#endif
#ifdef EMULTIHOP
X(EMULTIHOP,"multihop attempted")
#endif
#ifdef EREMCHG
X(EREMCHG,"remote address changed")
#endif
return "unknown error";
}
publicfile-0.52/error_temp.c 644 0 0 1772 7011746002 12232 0 ustar 00 #include
#include "error.h"
#define X(n) if (e == n) return 1;
int error_temp(e)
int e;
{
X(error_intr)
X(error_nomem)
X(error_txtbsy)
X(error_io)
X(error_timeout)
X(error_wouldblock)
X(error_again)
#ifdef EDEADLK
X(EDEADLK)
#endif
#ifdef EBUSY
X(EBUSY)
#endif
#ifdef ENFILE
X(ENFILE)
#endif
#ifdef EMFILE
X(EMFILE)
#endif
#ifdef EFBIG
X(EFBIG)
#endif
#ifdef ENOSPC
X(ENOSPC)
#endif
#ifdef ENETDOWN
X(ENETDOWN)
#endif
#ifdef ENETUNREACH
X(ENETUNREACH)
#endif
#ifdef ENETRESET
X(ENETRESET)
#endif
#ifdef ECONNABORTED
X(ECONNABORTED)
#endif
#ifdef ECONNRESET
X(ECONNRESET)
#endif
#ifdef ENOBUFS
X(ENOBUFS)
#endif
#ifdef ETOOMANYREFS
X(ETOOMANYREFS)
#endif
#ifdef ECONNREFUSED
X(ECONNREFUSED)
#endif
#ifdef EHOSTDOWN
X(EHOSTDOWN)
#endif
#ifdef EHOSTUNREACH
X(EHOSTUNREACH)
#endif
#ifdef EPROCLIM
X(EPROCLIM)
#endif
#ifdef EUSERS
X(EUSERS)
#endif
#ifdef EDQUOT
X(EDQUOT)
#endif
#ifdef ESTALE
X(ESTALE)
#endif
#ifdef ENOLCK
X(ENOLCK)
#endif
return 0;
}
publicfile-0.52/exit.h 644 0 0 74 7011746002 10764 0 ustar 00 #ifndef EXIT_H
#define EXIT_H
extern void _exit();
#endif
publicfile-0.52/fmt.h 644 0 0 1244 7011746002 10641 0 ustar 00 #ifndef FMT_H
#define FMT_H
#define FMT_ULONG 40 /* enough space to hold 2^128 - 1 in decimal, plus \0 */
#define FMT_LEN ((char *) 0) /* convenient abbreviation */
extern unsigned int fmt_uint();
extern unsigned int fmt_uint0();
extern unsigned int fmt_xint();
extern unsigned int fmt_nbbint();
extern unsigned int fmt_ushort();
extern unsigned int fmt_xshort();
extern unsigned int fmt_nbbshort();
extern unsigned int fmt_ulong();
extern unsigned int fmt_xlong();
extern unsigned int fmt_nbblong();
extern unsigned int fmt_plusminus();
extern unsigned int fmt_minus();
extern unsigned int fmt_0x();
extern unsigned int fmt_str();
extern unsigned int fmt_strn();
#endif
publicfile-0.52/fmt_str.c 644 0 0 342 7011746002 11502 0 ustar 00 #include "fmt.h"
unsigned int fmt_str(s,t)
register char *s; register char *t;
{
register unsigned int len;
char ch;
len = 0;
if (s) { while (ch = t[len]) s[len++] = ch; }
else while (t[len]) len++;
return len;
}
publicfile-0.52/fmt_uint.c 644 0 0 226 7011746002 11652 0 ustar 00 #include "fmt.h"
unsigned int fmt_uint(s,u) register char *s; register unsigned int u;
{
register unsigned long l; l = u; return fmt_ulong(s,l);
}
publicfile-0.52/fmt_ulong.c 644 0 0 500 7011746002 12012 0 ustar 00 #include "fmt.h"
unsigned int fmt_ulong(s,u) register char *s; register unsigned long u;
{
register unsigned int len; register unsigned long q;
len = 1; q = u;
while (q > 9) { ++len; q /= 10; }
if (s) {
s += len;
do { *--s = '0' + (u % 10); u /= 10; } while(u); /* handles u == 0 */
}
return len;
}
publicfile-0.52/fmt_xlong.c 644 0 0 556 7011746002 12030 0 ustar 00 #include "fmt.h"
unsigned int fmt_xlong(s,u) register char *s; register unsigned long u;
{
register unsigned int len; register unsigned long q; register char c;
len = 1; q = u;
while (q > 15) { ++len; q /= 16; }
if (s) {
s += len;
do { c = '0' + (u & 15); if (c > '0' + 9) c += 'a' - '0' - 10;
*--s = c; u /= 16; } while(u);
}
return len;
}
publicfile-0.52/gen_alloc.h 644 0 0 255 7011746002 11757 0 ustar 00 #ifndef GEN_ALLOC_H
#define GEN_ALLOC_H
#define GEN_ALLOC_typedef(ta,type,field,len,a) \
typedef struct ta { type *field; unsigned int len; unsigned int a; } ta;
#endif
publicfile-0.52/gen_allocdefs.h 644 0 0 2262 7011746002 12641 0 ustar 00 #ifndef GEN_ALLOC_DEFS_H
#define GEN_ALLOC_DEFS_H
#define GEN_ALLOC_ready(ta,type,field,len,a,i,n,x,base,ta_ready) \
int ta_ready(x,n) register ta *x; register unsigned int n; \
{ register unsigned int i; \
if (x->field) { \
i = x->a; \
if (n > i) { \
x->a = base + n + (n >> 3); \
if (alloc_re(&x->field,i * sizeof(type),x->a * sizeof(type))) return 1; \
x->a = i; return 0; } \
return 1; } \
x->len = 0; \
return !!(x->field = (type *) alloc((x->a = n) * sizeof(type))); }
#define GEN_ALLOC_readyplus(ta,type,field,len,a,i,n,x,base,ta_rplus) \
int ta_rplus(x,n) register ta *x; register unsigned int n; \
{ register unsigned int i; \
if (x->field) { \
i = x->a; n += x->len; \
if (n > i) { \
x->a = base + n + (n >> 3); \
if (alloc_re(&x->field,i * sizeof(type),x->a * sizeof(type))) return 1; \
x->a = i; return 0; } \
return 1; } \
x->len = 0; \
return !!(x->field = (type *) alloc((x->a = n) * sizeof(type))); }
#define GEN_ALLOC_append(ta,type,field,len,a,i,n,x,base,ta_rplus,ta_append) \
int ta_append(x,i) register ta *x; register type *i; \
{ if (!ta_rplus(x,1)) return 0; x->field[x->len++] = *i; return 1; }
#endif
publicfile-0.52/getln.c 644 0 0 576 7011746002 11146 0 ustar 00 #include "substdio.h"
#include "byte.h"
#include "stralloc.h"
#include "getln.h"
int getln(ss,sa,match,sep)
register substdio *ss;
register stralloc *sa;
int *match;
int sep;
{
char *cont;
unsigned int clen;
if (getln2(ss,sa,&cont,&clen,sep) == -1) return -1;
if (!clen) { *match = 0; return 0; }
if (!stralloc_catb(sa,cont,clen)) return -1;
*match = 1;
return 0;
}
publicfile-0.52/getln.h 644 0 0 122 7011746002 11136 0 ustar 00 #ifndef GETLN_H
#define GETLN_H
extern int getln();
extern int getln2();
#endif
publicfile-0.52/getln2.c 644 0 0 1260 7011746002 11237 0 ustar 00 #include "substdio.h"
#include "stralloc.h"
#include "byte.h"
#include "getln.h"
int getln2(ss,sa,cont,clen,sep)
register substdio *ss;
register stralloc *sa;
/*@out@*/char **cont;
/*@out@*/unsigned int *clen;
int sep;
{
register char *x;
register unsigned int i;
int n;
if (!stralloc_ready(sa,0)) return -1;
sa->len = 0;
for (;;) {
n = substdio_feed(ss);
if (n < 0) return -1;
if (n == 0) { *clen = 0; return 0; }
x = substdio_PEEK(ss);
i = byte_chr(x,n,sep);
if (i < n) { substdio_SEEK(ss,*clen = i + 1); *cont = x; return 0; }
if (!stralloc_readyplus(sa,n)) return -1;
i = sa->len;
sa->len = i + substdio_get(ss,sa->s + i,n);
}
}
publicfile-0.52/hassgact.h1 644 0 0 31 7011746002 11662 0 ustar 00 /* sysdep: -sigaction */
publicfile-0.52/hassgact.h2 644 0 0 60 7011746002 11665 0 ustar 00 /* sysdep: +sigaction */
#define HASSIGACTION 1
publicfile-0.52/hassgprm.h1 644 0 0 33 7011746002 11713 0 ustar 00 /* sysdep: -sigprocmask */
publicfile-0.52/hassgprm.h2 644 0 0 64 7011746002 11720 0 ustar 00 /* sysdep: +sigprocmask */
#define HASSIGPROCMASK 1
publicfile-0.52/hasshsgr.h1 644 0 0 36 7011746002 11714 0 ustar 00 /* sysdep: -shortsetgroups */
publicfile-0.52/hasshsgr.h2 644 0 0 72 7011746002 11715 0 ustar 00 /* sysdep: +shortsetgroups */
#define HASSHORTSETGROUPS 1
publicfile-0.52/ip.c 644 0 0 2547 7011746002 10465 0 ustar 00 #include "fmt.h"
#include "scan.h"
#include "ip.h"
unsigned int ip_fmt(s,ip)
char *s;
struct ip_address *ip;
{
unsigned int len;
unsigned int i;
len = 0;
i = fmt_ulong(s,(unsigned long) ip->d[0]); len += i; if (s) s += i;
i = fmt_str(s,"."); len += i; if (s) s += i;
i = fmt_ulong(s,(unsigned long) ip->d[1]); len += i; if (s) s += i;
i = fmt_str(s,"."); len += i; if (s) s += i;
i = fmt_ulong(s,(unsigned long) ip->d[2]); len += i; if (s) s += i;
i = fmt_str(s,"."); len += i; if (s) s += i;
i = fmt_ulong(s,(unsigned long) ip->d[3]); len += i; if (s) s += i;
return len;
}
unsigned int ip_scan(s,ip)
char *s;
struct ip_address *ip;
{
unsigned int i;
unsigned int len;
unsigned long u;
len = 0;
i = scan_ulong(s,&u); if (!i) return 0; ip->d[0] = u; s += i; len += i;
if (*s != '.') return 0; ++s; ++len;
i = scan_ulong(s,&u); if (!i) return 0; ip->d[1] = u; s += i; len += i;
if (*s != '.') return 0; ++s; ++len;
i = scan_ulong(s,&u); if (!i) return 0; ip->d[2] = u; s += i; len += i;
if (*s != '.') return 0; ++s; ++len;
i = scan_ulong(s,&u); if (!i) return 0; ip->d[3] = u; s += i; len += i;
return len;
}
unsigned int ip_scanbracket(s,ip)
char *s;
struct ip_address *ip;
{
unsigned int len;
if (*s != '[') return 0;
len = ip_scan(s + 1,ip);
if (!len) return 0;
if (s[len + 1] != ']') return 0;
return len + 2;
}
publicfile-0.52/ip.h 644 0 0 304 7011746002 10437 0 ustar 00 #ifndef IP_H
#define IP_H
struct ip_address { unsigned char d[4]; } ;
extern unsigned int ip_fmt();
#define IPFMT 19
extern unsigned int ip_scan();
extern unsigned int ip_scanbracket();
#endif
publicfile-0.52/leapsecs.dat 644 0 0 260 7011746002 12150 0 ustar 00 @ ²X
@ ¤ì@ †Œ@ gS
@ H†Ž@
+@ ?@ ír‘@ Φ@ ŸÊ“@ €þ@ b1•@ %ê@ !Úå@ %ž˜@ 'Ñ@ *Põš@ ,2)@ .\œ@ 0ç$@ 3¸Hž@ 6Œ publicfile-0.52/leapsecs.h 644 0 0 237 7011746002 11633 0 ustar 00 #ifndef LEAPSECS_H
#define LEAPSECS_H
extern int leapsecs_init();
extern int leapsecs_read();
extern void leapsecs_add();
extern int leapsecs_sub();
#endif
publicfile-0.52/leapsecs_init.c 644 0 0 247 7011746002 12652 0 ustar 00 #include "leapsecs.h"
static int flaginit = 0;
int leapsecs_init()
{
if (flaginit) return 0;
if (leapsecs_read() == -1) return -1;
flaginit = 1;
return 0;
}
publicfile-0.52/leapsecs_read.c 644 0 0 1607 7011746002 12643 0 ustar 00 #include
#include
#include
#include
extern int errno;
#include "tai.h"
#include "leapsecs.h"
struct tai *leapsecs = 0;
int leapsecs_num = 0;
int leapsecs_read()
{
int fd;
struct stat st;
struct tai *t;
int n;
int i;
struct tai u;
fd = open("/etc/leapsecs.dat",O_RDONLY | O_NDELAY);
if (fd == -1) {
if (errno != ENOENT) return -1;
if (leapsecs) free(leapsecs);
leapsecs = 0;
leapsecs_num = 0;
return 0;
}
if (fstat(fd,&st) == -1) { close(fd); return -1; }
t = (struct tai *) malloc(st.st_size);
if (!t) { close(fd); return -1; }
n = read(fd,(char *) t,st.st_size);
close(fd);
if (n != st.st_size) { free(t); return -1; }
n /= sizeof(struct tai);
for (i = 0;i < n;++i) {
tai_unpack((char *) &t[i],&u);
t[i] = u;
}
if (leapsecs) free(leapsecs);
leapsecs = t;
leapsecs_num = n;
}
publicfile-0.52/leapsecs_sub.c 644 0 0 661 7011746002 12500 0 ustar 00 #include "leapsecs.h"
#include "tai.h"
/* XXX: breaks tai encapsulation */
extern struct tai *leapsecs;
extern int leapsecs_num;
int leapsecs_sub(t)
struct tai *t;
{
int i;
uint64 u;
int s;
if (leapsecs_init() == -1) return 0;
u = t->x;
s = 0;
for (i = 0;i < leapsecs_num;++i) {
if (u < leapsecs[i].x) break;
++s;
if (u == leapsecs[i].x) { t->x = u - s; return 1; }
}
t->x = u - s;
return 0;
}
publicfile-0.52/ndelay.h 644 0 0 134 7011746002 11304 0 ustar 00 #ifndef NDELAY_H
#define NDELAY_H
extern int ndelay_on();
extern int ndelay_off();
#endif
publicfile-0.52/ndelay_off.c 644 0 0 323 7011746002 12131 0 ustar 00 #include
#include
#include "ndelay.h"
#ifndef O_NONBLOCK
#define O_NONBLOCK O_NDELAY
#endif
int ndelay_off(fd)
int fd;
{
return fcntl(fd,F_SETFL,fcntl(fd,F_GETFL,0) & ~O_NONBLOCK);
}
publicfile-0.52/ndelay_on.c 644 0 0 321 7011746002 11771 0 ustar 00 #include
#include
#include "ndelay.h"
#ifndef O_NONBLOCK
#define O_NONBLOCK O_NDELAY
#endif
int ndelay_on(fd)
int fd;
{
return fcntl(fd,F_SETFL,fcntl(fd,F_GETFL,0) | O_NONBLOCK);
}
publicfile-0.52/open.h 644 0 0 243 7011746002 10772 0 ustar 00 #ifndef OPEN_H
#define OPEN_H
extern int open_read();
extern int open_excl();
extern int open_append();
extern int open_trunc();
extern int open_write();
#endif
publicfile-0.52/open_read.c 644 0 0 202 7011746002 11753 0 ustar 00 #include
#include
#include "open.h"
int open_read(fn) char *fn;
{ return open(fn,O_RDONLY | O_NDELAY); }
publicfile-0.52/open_trunc.c 644 0 0 234 7011746002 12200 0 ustar 00 #include
#include
#include "open.h"
int open_trunc(fn) char *fn;
{ return open(fn,O_WRONLY | O_NDELAY | O_TRUNC | O_CREAT,0644); }
publicfile-0.52/prot.c 644 0 0 716 7011746002 11015 0 ustar 00 #include "hasshsgr.h"
#include "prot.h"
/* XXX: there are more portability problems here waiting to leap out at me */
int prot_gid(gid) int gid;
{
#ifdef HASSHORTSETGROUPS
short x[2];
x[0] = gid; x[1] = 73; /* catch errors */
if (setgroups(1,x) == -1) return -1;
#else
if (setgroups(1,&gid) == -1) return -1;
#endif
return setgid(gid); /* _should_ be redundant, but on some systems it isn't */
}
int prot_uid(uid) int uid;
{
return setuid(uid);
}
publicfile-0.52/prot.h 644 0 0 125 7011746002 11014 0 ustar 00 #ifndef PROT_H
#define PROT_H
extern int prot_gid();
extern int prot_uid();
#endif
publicfile-0.52/readwrite.h 644 0 0 130 7011746002 12012 0 ustar 00 #ifndef READWRITE_H
#define READWRITE_H
extern int read();
extern int write();
#endif
publicfile-0.52/scan.h 644 0 0 1330 7011746002 10773 0 ustar 00 #ifndef SCAN_H
#define SCAN_H
extern unsigned int scan_uint();
extern unsigned int scan_xint();
extern unsigned int scan_nbbint();
extern unsigned int scan_ushort();
extern unsigned int scan_xshort();
extern unsigned int scan_nbbshort();
extern unsigned int scan_ulong();
extern unsigned int scan_xlong();
extern unsigned int scan_nbblong();
extern unsigned int scan_plusminus();
extern unsigned int scan_0x();
extern unsigned int scan_whitenskip();
extern unsigned int scan_nonwhitenskip();
extern unsigned int scan_charsetnskip();
extern unsigned int scan_noncharsetnskip();
extern unsigned int scan_strncmp();
extern unsigned int scan_memcmp();
extern unsigned int scan_long();
extern unsigned int scan_8long();
#endif
publicfile-0.52/scan_ulong.c 644 0 0 530 7011746002 12153 0 ustar 00 #include "scan.h"
unsigned int scan_ulong(s,u) register char *s; register unsigned long *u;
{
register unsigned int pos; register unsigned long result;
register unsigned long c;
pos = 0; result = 0;
while ((c = (unsigned long) (unsigned char) (s[pos] - '0')) < 10)
{ result = result * 10 + c; ++pos; }
*u = result; return pos;
}
publicfile-0.52/select.h1 644 0 0 207 7011746002 11371 0 ustar 00 #ifndef SELECT_H
#define SELECT_H
/* sysdep: -sysselect */
#include
#include
extern int select();
#endif
publicfile-0.52/select.h2 644 0 0 237 7011746002 11375 0 ustar 00 #ifndef SELECT_H
#define SELECT_H
/* sysdep: +sysselect */
#include
#include
#include
extern int select();
#endif
publicfile-0.52/sig.h 644 0 0 1646 7011746002 10643 0 ustar 00 #ifndef SIG_H
#define SIG_H
extern void sig_catch();
extern void sig_block();
extern void sig_unblock();
extern void sig_blocknone();
extern void sig_pause();
extern void sig_dfl();
extern void sig_miscignore();
extern void sig_bugcatch();
extern void sig_pipeignore();
extern void sig_pipedefault();
extern void sig_contblock();
extern void sig_contunblock();
extern void sig_contcatch();
extern void sig_contdefault();
extern void sig_termblock();
extern void sig_termunblock();
extern void sig_termcatch();
extern void sig_termdefault();
extern void sig_alarmblock();
extern void sig_alarmunblock();
extern void sig_alarmcatch();
extern void sig_alarmdefault();
extern void sig_childblock();
extern void sig_childunblock();
extern void sig_childcatch();
extern void sig_childdefault();
extern void sig_hangupblock();
extern void sig_hangupunblock();
extern void sig_hangupcatch();
extern void sig_hangupdefault();
#endif
publicfile-0.52/sig_block.c 644 0 0 1203 7011746002 11775 0 ustar 00 #include
#include "sig.h"
#include "hassgprm.h"
void sig_block(sig)
int sig;
{
#ifdef HASSIGPROCMASK
sigset_t ss;
sigemptyset(&ss);
sigaddset(&ss,sig);
sigprocmask(SIG_BLOCK,&ss,(sigset_t *) 0);
#else
sigblock(1 << (sig - 1));
#endif
}
void sig_unblock(sig)
int sig;
{
#ifdef HASSIGPROCMASK
sigset_t ss;
sigemptyset(&ss);
sigaddset(&ss,sig);
sigprocmask(SIG_UNBLOCK,&ss,(sigset_t *) 0);
#else
sigsetmask(sigsetmask(~0) & ~(1 << (sig - 1)));
#endif
}
void sig_blocknone()
{
#ifdef HASSIGPROCMASK
sigset_t ss;
sigemptyset(&ss);
sigprocmask(SIG_SETMASK,&ss,(sigset_t *) 0);
#else
sigsetmask(0);
#endif
}
publicfile-0.52/sig_catch.c 644 0 0 535 7011746002 11754 0 ustar 00 #include
#include "sig.h"
#include "hassgact.h"
void sig_catch(sig,f)
int sig;
void (*f)();
{
#ifdef HASSIGACTION
struct sigaction sa;
sa.sa_handler = f;
sa.sa_flags = 0;
sigemptyset(&sa.sa_mask);
sigaction(sig,&sa,(struct sigaction *) 0);
#else
signal(sig,f); /* won't work under System V, even nowadays---dorks */
#endif
}
publicfile-0.52/sig_pause.c 644 0 0 271 7011746002 12004 0 ustar 00 #include
#include "sig.h"
#include "hassgprm.h"
void sig_pause()
{
#ifdef HASSIGPROCMASK
sigset_t ss;
sigemptyset(&ss);
sigsuspend(&ss);
#else
sigpause(0);
#endif
}
publicfile-0.52/sig_pipe.c 644 0 0 223 7011746002 11621 0 ustar 00 #include
#include "sig.h"
void sig_pipeignore() { sig_catch(SIGPIPE,SIG_IGN); }
void sig_pipedefault() { sig_catch(SIGPIPE,SIG_DFL); }
publicfile-0.52/str.h 644 0 0 427 7011746002 10645 0 ustar 00 #ifndef STR_H
#define STR_H
extern unsigned int str_copy();
extern int str_diff();
extern int str_diffn();
extern unsigned int str_len();
extern unsigned int str_chr();
extern unsigned int str_rchr();
extern int str_start();
#define str_equal(s,t) (!str_diff((s),(t)))
#endif
publicfile-0.52/str_chr.c 644 0 0 536 7011746002 11475 0 ustar 00 #include "str.h"
unsigned int str_chr(s,c)
register char *s;
int c;
{
register char ch;
register char *t;
ch = c;
t = s;
for (;;) {
if (!*t) break; if (*t == ch) break; ++t;
if (!*t) break; if (*t == ch) break; ++t;
if (!*t) break; if (*t == ch) break; ++t;
if (!*t) break; if (*t == ch) break; ++t;
}
return t - s;
}
publicfile-0.52/str_diff.c 644 0 0 667 7011746002 11636 0 ustar 00 #include "str.h"
int str_diff(s,t)
register char *s;
register char *t;
{
register char x;
for (;;) {
x = *s; if (x != *t) break; if (!x) break; ++s; ++t;
x = *s; if (x != *t) break; if (!x) break; ++s; ++t;
x = *s; if (x != *t) break; if (!x) break; ++s; ++t;
x = *s; if (x != *t) break; if (!x) break; ++s; ++t;
}
return ((int)(unsigned int)(unsigned char) x)
- ((int)(unsigned int)(unsigned char) *t);
}
publicfile-0.52/str_len.c 644 0 0 357 7011746002 11500 0 ustar 00 #include "str.h"
unsigned int str_len(s)
register char *s;
{
register char *t;
t = s;
for (;;) {
if (!*t) return t - s; ++t;
if (!*t) return t - s; ++t;
if (!*t) return t - s; ++t;
if (!*t) return t - s; ++t;
}
}
publicfile-0.52/str_rchr.c 644 0 0 615 7011746002 11655 0 ustar 00 #include "str.h"
unsigned int str_rchr(s,c)
register char *s;
int c;
{
register char ch;
register char *t;
register char *u;
ch = c;
t = s;
u = 0;
for (;;) {
if (!*t) break; if (*t == ch) u = t; ++t;
if (!*t) break; if (*t == ch) u = t; ++t;
if (!*t) break; if (*t == ch) u = t; ++t;
if (!*t) break; if (*t == ch) u = t; ++t;
}
if (!u) u = t;
return u - s;
}
publicfile-0.52/str_start.c 644 0 0 526 7011746002 12055 0 ustar 00 #include "str.h"
int str_start(s,t)
register char *s;
register char *t;
{
register char x;
for (;;) {
x = *t++; if (!x) return 1; if (x != *s++) return 0;
x = *t++; if (!x) return 1; if (x != *s++) return 0;
x = *t++; if (!x) return 1; if (x != *s++) return 0;
x = *t++; if (!x) return 1; if (x != *s++) return 0;
}
}
publicfile-0.52/stralloc.h 644 0 0 1526 7011746002 11701 0 ustar 00 #ifndef STRALLOC_H
#define STRALLOC_H
#include "gen_alloc.h"
GEN_ALLOC_typedef(stralloc,char,s,len,a)
extern int stralloc_ready();
extern int stralloc_readyplus();
extern int stralloc_copy();
extern int stralloc_cat();
extern int stralloc_copys();
extern int stralloc_cats();
extern int stralloc_copyb();
extern int stralloc_catb();
extern int stralloc_append(); /* beware: this takes a pointer to 1 char */
extern int stralloc_starts();
#define stralloc_0(sa) stralloc_append(sa,"")
extern int stralloc_catulong0();
extern int stralloc_catlong0();
#define stralloc_catlong(sa,l) (stralloc_catlong0((sa),(l),0))
#define stralloc_catuint0(sa,i,n) (stralloc_catulong0((sa),(unsigned long) (i),(n)))
#define stralloc_catint0(sa,i,n) (stralloc_catlong0((sa),(long) (i),(n)))
#define stralloc_catint(sa,i) (stralloc_catlong0((sa),(long) (i),0))
#endif
publicfile-0.52/stralloc_cat.c 644 0 0 241 7011746002 12474 0 ustar 00 #include "byte.h"
#include "stralloc.h"
int stralloc_cat(sato,safrom)
stralloc *sato;
stralloc *safrom;
{
return stralloc_catb(sato,safrom->s,safrom->len);
}
publicfile-0.52/stralloc_catb.c 644 0 0 500 7011746002 12634 0 ustar 00 #include "stralloc.h"
#include "byte.h"
int stralloc_catb(sa,s,n)
stralloc *sa;
char *s;
unsigned int n;
{
if (!sa->s) return stralloc_copyb(sa,s,n);
if (!stralloc_readyplus(sa,n + 1)) return 0;
byte_copy(sa->s + sa->len,n,s);
sa->len += n;
sa->s[sa->len] = 'Z'; /* ``offensive programming'' */
return 1;
}
publicfile-0.52/stralloc_cats.c 644 0 0 226 7011746002 12662 0 ustar 00 #include "byte.h"
#include "str.h"
#include "stralloc.h"
int stralloc_cats(sa,s)
stralloc *sa;
char *s;
{
return stralloc_catb(sa,s,str_len(s));
}
publicfile-0.52/stralloc_copy.c 644 0 0 243 7011746002 12701 0 ustar 00 #include "byte.h"
#include "stralloc.h"
int stralloc_copy(sato,safrom)
stralloc *sato;
stralloc *safrom;
{
return stralloc_copyb(sato,safrom->s,safrom->len);
}
publicfile-0.52/stralloc_eady.c 644 0 0 313 7011746002 12647 0 ustar 00 #include "alloc.h"
#include "stralloc.h"
#include "gen_allocdefs.h"
GEN_ALLOC_ready(stralloc,char,s,len,a,i,n,x,30,stralloc_ready)
GEN_ALLOC_readyplus(stralloc,char,s,len,a,i,n,x,30,stralloc_readyplus)
publicfile-0.52/stralloc_num.c 644 0 0 1077 7011746002 12554 0 ustar 00 #include "stralloc.h"
int stralloc_catulong0(sa,u,n)
stralloc *sa;
unsigned long u;
unsigned int n;
{
unsigned int len;
unsigned long q;
char *s;
len = 1;
q = u;
while (q > 9) { ++len; q /= 10; }
if (len < n) len = n;
if (!stralloc_readyplus(sa,len)) return 0;
s = sa->s + sa->len;
sa->len += len;
while (len) { s[--len] = '0' + (u % 10); u /= 10; }
return 1;
}
int stralloc_catlong0(sa,l,n)
stralloc *sa;
long l;
unsigned int n;
{
if (l < 0) {
if (!stralloc_append(sa,"-")) return 0;
l = -l;
}
return stralloc_catulong0(sa,l,n);
}
publicfile-0.52/stralloc_opyb.c 644 0 0 377 7011746002 12710 0 ustar 00 #include "stralloc.h"
#include "byte.h"
int stralloc_copyb(sa,s,n)
stralloc *sa;
char *s;
unsigned int n;
{
if (!stralloc_ready(sa,n + 1)) return 0;
byte_copy(sa->s,n,s);
sa->len = n;
sa->s[n] = 'Z'; /* ``offensive programming'' */
return 1;
}
publicfile-0.52/stralloc_opys.c 644 0 0 230 7011746002 12715 0 ustar 00 #include "byte.h"
#include "str.h"
#include "stralloc.h"
int stralloc_copys(sa,s)
stralloc *sa;
char *s;
{
return stralloc_copyb(sa,s,str_len(s));
}
publicfile-0.52/stralloc_pend.c 644 0 0 231 7011746002 12652 0 ustar 00 #include "alloc.h"
#include "stralloc.h"
#include "gen_allocdefs.h"
GEN_ALLOC_append(stralloc,char,s,len,a,i,n,x,30,stralloc_readyplus,stralloc_append)
publicfile-0.52/strerr.h 644 0 0 6443 7011746002 11402 0 ustar 00 #ifndef STRERR_H
#define STRERR_H
struct strerr
{
struct strerr *who;
char *x;
char *y;
char *z;
}
;
extern struct strerr strerr_sys;
extern void strerr_sysinit();
extern char *strerr();
extern void strerr_warn();
extern void strerr_die();
#define STRERR(r,se,a) \
{ se.who = 0; se.x = a; se.y = 0; se.z = 0; return r; }
#define STRERR_SYS(r,se,a) \
{ se.who = &strerr_sys; se.x = a; se.y = 0; se.z = 0; return r; }
#define STRERR_SYS3(r,se,a,b,c) \
{ se.who = &strerr_sys; se.x = a; se.y = b; se.z = c; return r; }
#define strerr_warn6(x1,x2,x3,x4,x5,x6,se) \
strerr_warn((x1),(x2),(x3),(x4),(x5),(x6),(struct strerr *) (se))
#define strerr_warn5(x1,x2,x3,x4,x5,se) \
strerr_warn((x1),(x2),(x3),(x4),(x5),(char *) 0,(struct strerr *) (se))
#define strerr_warn4(x1,x2,x3,x4,se) \
strerr_warn((x1),(x2),(x3),(x4),(char *) 0,(char *) 0,(struct strerr *) (se))
#define strerr_warn3(x1,x2,x3,se) \
strerr_warn((x1),(x2),(x3),(char *) 0,(char *) 0,(char *) 0,(struct strerr *) (se))
#define strerr_warn2(x1,x2,se) \
strerr_warn((x1),(x2),(char *) 0,(char *) 0,(char *) 0,(char *) 0,(struct strerr *) (se))
#define strerr_warn1(x1,se) \
strerr_warn((x1),(char *) 0,(char *) 0,(char *) 0,(char *) 0,(char *) 0,(struct strerr *) (se))
#define strerr_die6(e,x1,x2,x3,x4,x5,x6,se) \
strerr_die((e),(x1),(x2),(x3),(x4),(x5),(x6),(struct strerr *) (se))
#define strerr_die5(e,x1,x2,x3,x4,x5,se) \
strerr_die((e),(x1),(x2),(x3),(x4),(x5),(char *) 0,(struct strerr *) (se))
#define strerr_die4(e,x1,x2,x3,x4,se) \
strerr_die((e),(x1),(x2),(x3),(x4),(char *) 0,(char *) 0,(struct strerr *) (se))
#define strerr_die3(e,x1,x2,x3,se) \
strerr_die((e),(x1),(x2),(x3),(char *) 0,(char *) 0,(char *) 0,(struct strerr *) (se))
#define strerr_die2(e,x1,x2,se) \
strerr_die((e),(x1),(x2),(char *) 0,(char *) 0,(char *) 0,(char *) 0,(struct strerr *) (se))
#define strerr_die1(e,x1,se) \
strerr_die((e),(x1),(char *) 0,(char *) 0,(char *) 0,(char *) 0,(char *) 0,(struct strerr *) (se))
#define strerr_die6sys(e,x1,x2,x3,x4,x5,x6) \
strerr_die((e),(x1),(x2),(x3),(x4),(x5),(x6),&strerr_sys)
#define strerr_die5sys(e,x1,x2,x3,x4,x5) \
strerr_die((e),(x1),(x2),(x3),(x4),(x5),(char *) 0,&strerr_sys)
#define strerr_die4sys(e,x1,x2,x3,x4) \
strerr_die((e),(x1),(x2),(x3),(x4),(char *) 0,(char *) 0,&strerr_sys)
#define strerr_die3sys(e,x1,x2,x3) \
strerr_die((e),(x1),(x2),(x3),(char *) 0,(char *) 0,(char *) 0,&strerr_sys)
#define strerr_die2sys(e,x1,x2) \
strerr_die((e),(x1),(x2),(char *) 0,(char *) 0,(char *) 0,(char *) 0,&strerr_sys)
#define strerr_die1sys(e,x1) \
strerr_die((e),(x1),(char *) 0,(char *) 0,(char *) 0,(char *) 0,(char *) 0,&strerr_sys)
#define strerr_die6x(e,x1,x2,x3,x4,x5,x6) \
strerr_die((e),(x1),(x2),(x3),(x4),(x5),(x6),(struct strerr *) 0)
#define strerr_die5x(e,x1,x2,x3,x4,x5) \
strerr_die((e),(x1),(x2),(x3),(x4),(x5),(char *) 0,(struct strerr *) 0)
#define strerr_die4x(e,x1,x2,x3,x4) \
strerr_die((e),(x1),(x2),(x3),(x4),(char *) 0,(char *) 0,(struct strerr *) 0)
#define strerr_die3x(e,x1,x2,x3) \
strerr_die((e),(x1),(x2),(x3),(char *) 0,(char *) 0,(char *) 0,(struct strerr *) 0)
#define strerr_die2x(e,x1,x2) \
strerr_die((e),(x1),(x2),(char *) 0,(char *) 0,(char *) 0,(char *) 0,(struct strerr *) 0)
#define strerr_die1x(e,x1) \
strerr_die((e),(x1),(char *) 0,(char *) 0,(char *) 0,(char *) 0,(char *) 0,(struct strerr *) 0)
#endif
publicfile-0.52/strerr_die.c 644 0 0 1546 7011746002 12215 0 ustar 00 #include "substdio.h"
#include "subfd.h"
#include "exit.h"
#include "strerr.h"
void strerr_warn(x1,x2,x3,x4,x5,x6,se)
char *x1; char *x2; char *x3; char *x4; char *x5; char *x6;
struct strerr *se;
{
strerr_sysinit();
if (x1) substdio_puts(subfderr,x1);
if (x2) substdio_puts(subfderr,x2);
if (x3) substdio_puts(subfderr,x3);
if (x4) substdio_puts(subfderr,x4);
if (x5) substdio_puts(subfderr,x5);
if (x6) substdio_puts(subfderr,x6);
while(se) {
if (se->x) substdio_puts(subfderr,se->x);
if (se->y) substdio_puts(subfderr,se->y);
if (se->z) substdio_puts(subfderr,se->z);
se = se->who;
}
substdio_puts(subfderr,"\n");
substdio_flush(subfderr);
}
void strerr_die(e,x1,x2,x3,x4,x5,x6,se)
int e;
char *x1; char *x2; char *x3; char *x4; char *x5; char *x6;
struct strerr *se;
{
strerr_warn(x1,x2,x3,x4,x5,x6,se);
_exit(e);
}
publicfile-0.52/strerr_sys.c 644 0 0 300 7011746002 12235 0 ustar 00 #include "error.h"
#include "strerr.h"
struct strerr strerr_sys;
void strerr_sysinit()
{
strerr_sys.who = 0;
strerr_sys.x = error_str(errno);
strerr_sys.y = "";
strerr_sys.z = "";
}
publicfile-0.52/subfd.h 644 0 0 407 7011746002 11136 0 ustar 00 #ifndef SUBFD_H
#define SUBFD_H
#include "substdio.h"
extern substdio *subfdin;
extern substdio *subfdinsmall;
extern substdio *subfdout;
extern substdio *subfdoutsmall;
extern substdio *subfderr;
extern int subfd_read();
extern int subfd_readsmall();
#endif
publicfile-0.52/subfderr.c 644 0 0 262 7011746002 11641 0 ustar 00 #include "readwrite.h"
#include "substdio.h"
#include "subfd.h"
char subfd_errbuf[256];
static substdio it = SUBSTDIO_FDBUF(write,2,subfd_errbuf,256);
substdio *subfderr = ⁢
publicfile-0.52/substdi.c 644 0 0 3117 7011746002 11524 0 ustar 00 #include "substdio.h"
#include "byte.h"
#include "error.h"
static int oneread(op,fd,buf,len)
register int (*op)();
register int fd;
register char *buf;
register int len;
{
register int r;
for (;;) {
r = op(fd,buf,len);
if (r == -1) if (errno == error_intr) continue;
return r;
}
}
static int getthis(s,buf,len)
register substdio *s;
register char *buf;
register int len;
{
register int r;
register int q;
r = s->p;
q = r - len;
if (q > 0) { r = len; s->p = q; } else s->p = 0;
byte_copy(buf,r,s->x + s->n);
s->n += r;
return r;
}
int substdio_feed(s)
register substdio *s;
{
register int r;
register int q;
if (s->p) return s->p;
q = s->n;
r = oneread(s->op,s->fd,s->x,q);
if (r <= 0) return r;
s->p = r;
q -= r;
s->n = q;
if (q > 0) /* damn, gotta shift */ byte_copyr(s->x + q,r,s->x);
return r;
}
int substdio_bget(s,buf,len)
register substdio *s;
register char *buf;
register int len;
{
register int r;
if (s->p > 0) return getthis(s,buf,len);
r = s->n; if (r <= len) return oneread(s->op,s->fd,buf,r);
r = substdio_feed(s); if (r <= 0) return r;
return getthis(s,buf,len);
}
int substdio_get(s,buf,len)
register substdio *s;
register char *buf;
register int len;
{
register int r;
if (s->p > 0) return getthis(s,buf,len);
if (s->n <= len) return oneread(s->op,s->fd,buf,len);
r = substdio_feed(s); if (r <= 0) return r;
return getthis(s,buf,len);
}
char *substdio_peek(s)
register substdio *s;
{
return s->x + s->n;
}
void substdio_seek(s,len)
register substdio *s;
register int len;
{
s->n += len;
s->p -= len;
}
publicfile-0.52/substdio.c 644 0 0 347 7011746002 11665 0 ustar 00 #include "substdio.h"
void substdio_fdbuf(s,op,fd,buf,len)
register substdio *s;
register int (*op)();
register int fd;
register char *buf;
register int len;
{
s->x = buf;
s->fd = fd;
s->op = op;
s->p = 0;
s->n = len;
}
publicfile-0.52/substdio.h 644 0 0 1714 7011746002 11711 0 ustar 00 #ifndef SUBSTDIO_H
#define SUBSTDIO_H
typedef struct substdio {
char *x;
int p;
int n;
int fd;
int (*op)();
} substdio;
#define SUBSTDIO_FDBUF(op,fd,buf,len) { (buf), 0, (len), (fd), (op) }
extern void substdio_fdbuf();
extern int substdio_flush();
extern int substdio_put();
extern int substdio_bput();
extern int substdio_putflush();
extern int substdio_puts();
extern int substdio_bputs();
extern int substdio_putsflush();
extern int substdio_get();
extern int substdio_bget();
extern int substdio_feed();
extern char *substdio_peek();
extern void substdio_seek();
#define substdio_fileno(s) ((s)->fd)
#define SUBSTDIO_INSIZE 8192
#define SUBSTDIO_OUTSIZE 8192
#define substdio_PEEK(s) ( (s)->x + (s)->n )
#define substdio_SEEK(s,len) ( ( (s)->p -= (len) ) , ( (s)->n += (len) ) )
#define substdio_BPUTC(s,c) \
( ((s)->n != (s)->p) \
? ( (s)->x[(s)->p++] = (c), 0 ) \
: substdio_bput((s),&(c),1) \
)
extern int substdio_copy();
#endif
publicfile-0.52/substdio_copy.c 644 0 0 533 7011746002 12714 0 ustar 00 #include "substdio.h"
int substdio_copy(ssout,ssin)
register substdio *ssout;
register substdio *ssin;
{
register int n;
register char *x;
for (;;) {
n = substdio_feed(ssin);
if (n < 0) return -2;
if (!n) return 0;
x = substdio_PEEK(ssin);
if (substdio_put(ssout,x,n) == -1) return -3;
substdio_SEEK(ssin,n);
}
}
publicfile-0.52/substdo.c 644 0 0 3745 7011746002 11541 0 ustar 00 #include "substdio.h"
#include "str.h"
#include "byte.h"
#include "error.h"
static int allwrite(op,fd,buf,len)
register int (*op)();
register int fd;
register char *buf;
register int len;
{
register int w;
while (len) {
w = op(fd,buf,len);
if (w == -1) {
if (errno == error_intr) continue;
return -1; /* note that some data may have been written */
}
if (w == 0) ; /* luser's fault */
buf += w;
len -= w;
}
return 0;
}
int substdio_flush(s)
register substdio *s;
{
register int p;
p = s->p;
if (!p) return 0;
s->p = 0;
return allwrite(s->op,s->fd,s->x,p);
}
int substdio_bput(s,buf,len)
register substdio *s;
register char *buf;
register int len;
{
register int n;
while (len > (n = s->n - s->p)) {
byte_copy(s->x + s->p,n,buf); s->p += n; buf += n; len -= n;
if (substdio_flush(s) == -1) return -1;
}
/* now len <= s->n - s->p */
byte_copy(s->x + s->p,len,buf);
s->p += len;
return 0;
}
int substdio_put(s,buf,len)
register substdio *s;
register char *buf;
register int len;
{
register int n;
n = s->n;
if (len > n - s->p) {
if (substdio_flush(s) == -1) return -1;
/* now s->p == 0 */
if (n < SUBSTDIO_OUTSIZE) n = SUBSTDIO_OUTSIZE;
while (len > s->n) {
if (n > len) n = len;
if (allwrite(s->op,s->fd,buf,n) == -1) return -1;
buf += n;
len -= n;
}
}
/* now len <= s->n - s->p */
byte_copy(s->x + s->p,len,buf);
s->p += len;
return 0;
}
int substdio_putflush(s,buf,len)
register substdio *s;
register char *buf;
register int len;
{
if (substdio_flush(s) == -1) return -1;
return allwrite(s->op,s->fd,buf,len);
}
int substdio_bputs(s,buf)
register substdio *s;
register char *buf;
{
return substdio_bput(s,buf,str_len(buf));
}
int substdio_puts(s,buf)
register substdio *s;
register char *buf;
{
return substdio_put(s,buf,str_len(buf));
}
int substdio_putsflush(s,buf)
register substdio *s;
register char *buf;
{
return substdio_putflush(s,buf,str_len(buf));
}
publicfile-0.52/tai.h 644 0 0 610 7011746002 10604 0 ustar 00 #ifndef TAI_H
#define TAI_H
#include "uint64.h"
struct tai {
uint64 x;
} ;
#define tai_unix(t,u) ((void) ((t)->x = 4611686018427387914ULL + (uint64) (u)))
extern void tai_now();
#define tai_approx(t) ((double) ((t)->x))
extern void tai_add();
extern void tai_sub();
#define tai_less(t,u) ((t)->x < (u)->x)
#define TAI_PACK 8
extern void tai_pack();
extern void tai_unpack();
#endif
publicfile-0.52/tai_now.c 644 0 0 147 7011746002 11467 0 ustar 00 #include
#include "tai.h"
void tai_now(t)
struct tai *t;
{
tai_unix(t,time((long *) 0));
}
publicfile-0.52/tai_sub.c 644 0 0 155 7011746002 11454 0 ustar 00 #include "tai.h"
void tai_sub(t,u,v)
struct tai *t;
struct tai *u;
struct tai *v;
{
t->x = u->x - v->x;
}
publicfile-0.52/tai_unpack.c 644 0 0 602 7011746002 12141 0 ustar 00 #include "tai.h"
void tai_unpack(s,t)
char *s;
struct tai *t;
{
uint64 x;
x = (unsigned char) s[0];
x <<= 8; x += (unsigned char) s[1];
x <<= 8; x += (unsigned char) s[2];
x <<= 8; x += (unsigned char) s[3];
x <<= 8; x += (unsigned char) s[4];
x <<= 8; x += (unsigned char) s[5];
x <<= 8; x += (unsigned char) s[6];
x <<= 8; x += (unsigned char) s[7];
t->x = x;
}
publicfile-0.52/timeoutconn.c 644 0 0 2402 7011746002 12407 0 ustar 00 #include
#include
#include
#include
#include "ndelay.h"
#include "select.h"
#include "error.h"
#include "readwrite.h"
#include "ip.h"
#include "byte.h"
#include "timeoutconn.h"
int timeoutconn(s,ip,port,timeout)
int s;
struct ip_address *ip;
unsigned int port;
int timeout;
{
char ch;
struct sockaddr_in sin;
char *x;
fd_set wfds;
struct timeval tv;
byte_zero(&sin,sizeof(sin));
byte_copy(&sin.sin_addr,4,ip);
x = (char *) &sin.sin_port;
x[1] = port; port >>= 8; x[0] = port;
sin.sin_family = AF_INET;
if (ndelay_on(s) == -1) return -1;
/* XXX: could bind s */
if (connect(s,(struct sockaddr *) &sin,sizeof(sin)) == 0) {
ndelay_off(s);
return 0;
}
if ((errno != error_inprogress) && (errno != error_wouldblock)) return -1;
FD_ZERO(&wfds);
FD_SET(s,&wfds);
tv.tv_sec = timeout; tv.tv_usec = 0;
if (select(s + 1,(fd_set *) 0,&wfds,(fd_set *) 0,&tv) == -1) return -1;
if (FD_ISSET(s,&wfds)) {
int dummy;
dummy = sizeof(sin);
if (getpeername(s,(struct sockaddr *) &sin,&dummy) == -1) {
read(s,&ch,1);
return -1;
}
ndelay_off(s);
return 0;
}
errno = error_timeout; /* note that connect attempt is continuing */
return -1;
}
publicfile-0.52/timeoutconn.h 644 0 0 117 7011746002 12375 0 ustar 00 #ifndef TIMEOUTCONN_H
#define TIMEOUTCONN_H
extern int timeoutconn();
#endif
publicfile-0.52/timeoutread.c 644 0 0 662 7011746002 12353 0 ustar 00 #include "timeoutread.h"
#include "select.h"
#include "error.h"
#include "readwrite.h"
int timeoutread(t,fd,buf,len) int t; int fd; char *buf; int len;
{
fd_set rfds;
struct timeval tv;
tv.tv_sec = t;
tv.tv_usec = 0;
FD_ZERO(&rfds);
FD_SET(fd,&rfds);
if (select(fd + 1,&rfds,(fd_set *) 0,(fd_set *) 0,&tv) == -1) return -1;
if (FD_ISSET(fd,&rfds)) return read(fd,buf,len);
errno = error_timeout;
return -1;
}
publicfile-0.52/timeoutread.h 644 0 0 117 7011746002 12353 0 ustar 00 #ifndef TIMEOUTREAD_H
#define TIMEOUTREAD_H
extern int timeoutread();
#endif
publicfile-0.52/timeoutwrite.c 644 0 0 665 7011746002 12575 0 ustar 00 #include "timeoutwrite.h"
#include "select.h"
#include "error.h"
#include "readwrite.h"
int timeoutwrite(t,fd,buf,len) int t; int fd; char *buf; int len;
{
fd_set wfds;
struct timeval tv;
tv.tv_sec = t;
tv.tv_usec = 0;
FD_ZERO(&wfds);
FD_SET(fd,&wfds);
if (select(fd + 1,(fd_set *) 0,&wfds,(fd_set *) 0,&tv) == -1) return -1;
if (FD_ISSET(fd,&wfds)) return write(fd,buf,len);
errno = error_timeout;
return -1;
}
publicfile-0.52/timeoutwrite.h 644 0 0 122 7011746002 12566 0 ustar 00 #ifndef TIMEOUTWRITE_H
#define TIMEOUTWRITE_H
extern int timeoutwrite();
#endif
publicfile-0.52/trydrent.c 644 0 0 133 7011746002 11675 0 ustar 00 #include
#include
void foo()
{
DIR *dir;
struct dirent *d;
}
publicfile-0.52/trylsock.c 644 0 0 17 7011746002 11655 0 ustar 00 main()
{
;
}
publicfile-0.52/trysgact.c 644 0 0 246 7011746002 11667 0 ustar 00 #include
main()
{
struct sigaction sa;
sa.sa_handler = 0;
sa.sa_flags = 0;
sigemptyset(&sa.sa_mask);
sigaction(0,&sa,(struct sigaction *) 0);
}
publicfile-0.52/trysgprm.c 644 0 0 216 7011746002 11713 0 ustar 00 #include
main()
{
sigset_t ss;
sigemptyset(&ss);
sigaddset(&ss,SIGCHLD);
sigprocmask(SIG_SETMASK,&ss,(sigset_t *) 0);
}
publicfile-0.52/tryshsgr.c 644 0 0 411 7011746002 11706 0 ustar 00 main()
{
short x[4];
x[0] = x[1] = 1;
if (getgroups(1,x) == 0) if (setgroups(1,x) == -1) _exit(1);
if (getgroups(1,x) == -1) _exit(1);
if (x[1] != 1) _exit(1);
x[1] = 2;
if (getgroups(1,x) == -1) _exit(1);
if (x[1] != 2) _exit(1);
_exit(0);
}
publicfile-0.52/trysysel.c 644 0 0 156 7011746002 11725 0 ustar 00 #include
#include
#include /* SVR4 silliness */
void foo()
{
;
}
publicfile-0.52/tryulong64.c 644 0 0 517 7011746002 12065 0 ustar 00 main()
{
unsigned long u;
u = 1;
u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u;
u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u;
u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u;
u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u;
if (!u) _exit(1);
_exit(0);
}
publicfile-0.52/uint64.h1 644 0 0 146 7011746002 11245 0 ustar 00 #ifndef UINT64_H
#define UINT64_H
/* sysdep: -ulong64 */
typedef unsigned long long uint64;
#endif
publicfile-0.52/uint64.h2 644 0 0 141 7011746002 11241 0 ustar 00 #ifndef UINT64_H
#define UINT64_H
/* sysdep: +ulong64 */
typedef unsigned long uint64;
#endif
publicfile-0.52/warn-shsgr 644 0 0 313 7011746002 11674 0 ustar 00 Oops. Your getgroups() returned 0, and setgroups() failed; this means
that I can't reliably do my shsgr test. Please either ``make'' as root
or ``make'' while you're in one or more supplementary groups.