prog/0041755000000000000000000000000011100056426006713 5ustar prog/skalibs-0.47/0040755000000000000000000000000011100047635010732 5ustar prog/skalibs-0.47/src/0040755000000000000000000000000010040427010011510 5ustar prog/skalibs-0.47/src/sys/0040755000000000000000000000000011100041537012332 5ustar prog/skalibs-0.47/src/sys/print-cc.sh0100644000000000000000000000011207745255041014415 0ustar cc="`head -n 1 $1`" cat warn-auto.sh exec cat </dev/null 2>&1 || result="$3" ;; esac case "$1" in *l*) ./load $2 $5 $6 $7 $8 $9 >/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" prog/skalibs-0.47/src/sys/Makefile0100644000000000000000000000103311100041503013755 0ustar it: choose compile load makelib warn-auto.sh stupid clean: EXPORT INTERNAL rm -f `cat EXPORT INTERNAL` compile: conf-cc print-cc.sh warn-auto.sh rm -f compile /bin/sh print-cc.sh conf-cc > compile chmod 555 compile load: conf-ld conf-stripbins print-ld.sh warn-auto.sh rm -f load /bin/sh print-ld.sh > load chmod 555 load makelib: conf-striplibs print-ar.sh warn-auto.sh systype rm -f makelib /bin/sh print-ar.sh > makelib chmod 555 makelib stupid: conf-sp_root conf-category conf-name conf-version conf-home touch stupid prog/skalibs-0.47/src/sys/INCLUDE0100644000000000000000000000006307745255041013355 0ustar choose warn-auto.sh print-cc.sh print-ld.sh stupid prog/skalibs-0.47/src/sys/warn-auto.sh0100644000000000000000000000010007745255041014610 0ustar #!/bin/sh # WARNING: This file was auto-generated. Do not edit! prog/skalibs-0.47/src/sys/stupid0100755000000000000000000000034611100046277013576 0ustar #!/bin/sh s=`head -n 1 conf-sp_root` h=`head -n 1 conf-home` n=`head -n 1 conf-name` v=`head -n 1 conf-version` exec sed s\|\\\$SP_ROOT\|$s\|g\;s\|\\\$PACKAGE_HOME\|$h\|g\;s\|\\\$PACKAGE_NAME\|$n\|g\;s\|\\\$PACKAGE_VERSION\|$v\|g prog/skalibs-0.47/src/libstddjb/0040755000000000000000000000000011074722341013466 5ustar prog/skalibs-0.47/src/libstddjb/Makefile0100644000000000000000000011630511051750650015130 0ustar it: command include library library.so clean: EXPORT INTERNAL rm -f `cat EXPORT INTERNAL` alloc.h: gccattributes.h touch alloc.h alloc_0.h: sysdeps.h alloc.h touch alloc_0.h intalloc.h: gen_alloc.h touch intalloc.h uintalloc.h: gen_alloc.h touch uintalloc.h uintbunch.h: gen_bunch.h uintalloc.h touch uintbunch.h diuintalloc.h: diuint.h gen_alloc.h touch diuintalloc.h diuintbunch.h: gen_bunch.h diuintalloc.h diuint.h touch diuintbunch.h uint16alloc.h: gen_alloc.h uint16.h touch uint16alloc.h uint32alloc.h: gen_alloc.h uint32.h touch uint32alloc.h uint64alloc.h: gen_alloc.h uint64.h touch uint64alloc.h uint32aalloc.h: gen_alloc.h uint32alloc.h touch uint32aalloc.h bitarray.h: uint64alloc.h gccattributes.h touch bitarray.h buffer.h: allreadwrite.h gccattributes.h touch buffer.h bufalloc.h: stralloc.h touch bufalloc.h bytestr.h: gccattributes.h touch bytestr.h caltimedate.h: gccattributes.h touch caltimedate.h env.h: stralloc.h gccattributes.h touch env.h envalloc.h: gen_alloc.h touch envalloc.h fmtscan.h: gccattributes.h uint64.h touch fmtscan.h fmtscan-internal.h: fmtscan.h touch fmtscan-internal.h iobuffer.h: buffer.h touch iobuffer.h gen_alloc.h: alloc.h touch gen_alloc.h gen_bunch.h: gen_alloc.h bitarray.h touch gen_bunch.h stralloc.h: gen_alloc.h gccattributes.h touch stralloc.h strerr.h: gccattributes.h touch strerr.h strerr2.h: strerr.h touch strerr2.h cdb.h: uint32.h gccattributes.h touch cdb.h cdb_make.h: uint32.h buffer.h diuint32alloc.h touch cdb_make.h tai.h: uint64.h gccattributes.h touch tai.h netstring.h: buffer.h stralloc.h touch netstring.h djbunix.h: stralloc.h envalloc.h gccattributes.h env.h touch djbunix.h sig.h: gccattributes.h touch sig.h socket.h: tai.h uint16.h gccattributes.h touch socket.h skamisc.h: buffer.h stralloc.h touch skamisc.h leapsecs_internal.h: tai.h touch leapsecs_internal.h stddjb.h: gccattributes.h uint16.h uint32.h uint64.h alloc.h intalloc.h uintalloc.h uint16alloc.h uint32alloc.h uint64alloc.h allreadwrite.h buffer.h iobuffer.h bytestr.h djbunix.h direntry.h error.h fmtscan.h gen_alloc.h select.h sig.h stralloc.h bufalloc.h cdb.h cdb_make.h strerr2.h tai.h iopause.h sgetopt.h netstring.h skamisc.h caltimedate.h bitarray.h gen_bunch.h uintbunch.h diuint.h diuintalloc.h diuintbunch.h environ.h shglob.h selfpipe.h syssocket.h touch stddjb.h absolutepath.o: compile absolutepath.c skamisc.h djbunix.h stralloc.h ./compile absolutepath.c absolutepath_tmp.o: compile absolutepath_tmp.c djbunix.h stralloc.h bytestr.h ./compile absolutepath_tmp.c sanitize_read.o: compile sanitize_read.c allreadwrite.h error.h ./compile sanitize_read.c allreadwrite.o: compile allreadwrite.c allreadwrite.h error.h ./compile allreadwrite.c allread.o: compile allread.c allreadwrite.h ./compile allread.c allwrite.o: compile allwrite.c allreadwrite.h ./compile allwrite.c alloc_ska.o: compile alloc_ska.c alloc.h alloc_0.h sysdeps.h ./compile alloc_ska.c alloc_0.o: compile alloc_0.c alloc_0.h alloc.h sysdeps.h ./compile alloc_0.c alloc_djb.o: compile alloc_djb.c alloc.h bytestr.h sysdeps.h ./compile alloc_djb.c basename.o: compile basename.c djbunix.h stralloc.h bytestr.h ./compile basename.c bitarray.o: compile bitarray.c bitarray.h uint64alloc.h uint64.h ./compile bitarray.c bufalloc_init.o: compile bufalloc_init.c bufalloc.h allreadwrite.h ./compile bufalloc_init.c bufalloc_clean.o: compile bufalloc_clean.c bufalloc.h bytestr.h ./compile bufalloc_clean.c bufalloc_flush.o: compile bufalloc_flush.c bufalloc.h allreadwrite.h ./compile bufalloc_flush.c bufalloc_1.o: compile bufalloc_1.c bufalloc.h allreadwrite.h ./compile bufalloc_1.c bufalloc_2.o: compile bufalloc_2.c bufalloc.h allreadwrite.h ./compile bufalloc_2.c buffer_init.o: compile buffer_init.c buffer.h allreadwrite.h ./compile buffer_init.c buffer_clean.o: compile buffer_clean.c buffer.h bytestr.h ./compile buffer_clean.c buffer_0.o: compile buffer_0.c buffer.h ./compile buffer_0.c buffer_0small.o: compile buffer_0small.c buffer.h ./compile buffer_0small.c buffer_1.o: compile buffer_1.c buffer.h ./compile buffer_1.c buffer_1small.o: compile buffer_1small.c buffer.h ./compile buffer_1small.c buffer_2.o: compile buffer_2.c buffer.h ./compile buffer_2.c buffer_bget.o: compile buffer_bget.c buffer.h ./compile buffer_bget.c buffer_feed.o: compile buffer_feed.c buffer.h ./compile buffer_feed.c buffer_fill.o: compile buffer_fill.c buffer.h ./compile buffer_fill.c buffer_flush.o: compile buffer_flush.c buffer.h allreadwrite.h ./compile buffer_flush.c buffer_get.o: compile buffer_get.c buffer.h ./compile buffer_get.c buffer_getall.o: compile buffer_getall.c buffer.h allreadwrite.h ./compile buffer_getall.c buffer_getallnf.o: compile buffer_getallnf.c buffer.h ./compile buffer_getallnf.c buffer_getnf.o: compile buffer_getnf.c buffer.h bytestr.h ./compile buffer_getnf.c buffer_peek.o: compile buffer_peek.c buffer.h ./compile buffer_peek.c buffer_put.o: compile buffer_put.c buffer.h ./compile buffer_put.c buffer_putalign.o: compile buffer_putalign.c buffer.h error.h ./compile buffer_putalign.c buffer_putall.o: compile buffer_putall.c buffer.h ./compile buffer_putall.c buffer_putallf.o: compile buffer_putallf.c buffer.h ./compile buffer_putallf.c buffer_putallnf.o: compile buffer_putallnf.c buffer.h ./compile buffer_putallnf.c buffer_putc.o: compile buffer_putc.c buffer.h ./compile buffer_putc.c buffer_putflush.o: compile buffer_putflush.c buffer.h error.h ./compile buffer_putflush.c buffer_putnf.o: compile buffer_putnf.c buffer.h bytestr.h ./compile buffer_putnf.c buffer_puts.o: compile buffer_puts.c buffer.h bytestr.h ./compile buffer_puts.c buffer_putsalign.o: compile buffer_putsalign.c buffer.h bytestr.h ./compile buffer_putsalign.c buffer_putsflush.o: compile buffer_putsflush.c buffer.h bytestr.h ./compile buffer_putsflush.c buffer_read.o: compile buffer_read.c buffer.h ./compile buffer_read.c buffer_seek.o: compile buffer_seek.c buffer.h ./compile buffer_seek.c buffer_unget.o: compile buffer_unget.c buffer.h ./compile buffer_unget.c buffer_unput.o: compile buffer_unput.c buffer.h ./compile buffer_unput.c buffer_write.o: compile buffer_write.c buffer.h ./compile buffer_write.c byte_chr.o: compile byte_chr.c bytestr.h ./compile byte_chr.c byte_copy.o: compile byte_copy.c bytestr.h ./compile byte_copy.c byte_count.o: compile byte_count.c bytestr.h ./compile byte_count.c byte_cr.o: compile byte_cr.c bytestr.h ./compile byte_cr.c byte_diff.o: compile byte_diff.c bytestr.h ./compile byte_diff.c byte_in.o: compile byte_in.c bytestr.h ./compile byte_in.c byte_rchr.o: compile byte_rchr.c bytestr.h ./compile byte_rchr.c byte_zero.o: compile byte_zero.c bytestr.h ./compile byte_zero.c caldate_fmjd.o: compile caldate_fmjd.c caltimedate.h ./compile caldate_fmjd.c caldate_fmt.o: compile caldate_fmt.c caltimedate.h ./compile caldate_fmt.c caldate_mjd.o: compile caldate_mjd.c caltimedate.h ./compile caldate_mjd.c caldate_norm.o: compile caldate_norm.c caltimedate.h ./compile caldate_norm.c caldate_scan.o: compile caldate_scan.c caltimedate.h ./compile caldate_scan.c caldate_ster.o: compile caldate_ster.c caltimedate.h ./compile caldate_ster.c caltime_fmt.o: compile caltime_fmt.c caltimedate.h ./compile caltime_fmt.c caltime_scan.o: compile caltime_scan.c caltimedate.h ./compile caltime_scan.c caltime_tai.o: compile caltime_tai.c caltimedate.h tai.h ./compile caltime_tai.c caltime_utc.o: compile caltime_utc.c caltimedate.h tai.h uint64.h ./compile caltime_utc.c leapsecs_init.o: compile leapsecs_init.c caltimedate.h ./compile leapsecs_init.c leapsecs_readf_r.o: compile leapsecs_readf_r.c tai.h caltimedate.h djbunix.h allreadwrite.h alloc.h ./compile leapsecs_readf_r.c leapsecs_read_r.o: compile leapsecs_read_r.c tai.h caltimedate.h ./compile leapsecs_read_r.c leapsecs_read.o: compile leapsecs_read.c caltimedate.h tai.h leapsecs_internal.h ./compile leapsecs_read.c leapsecs_add.o: compile leapsecs_add.c caltimedate.h tai.h leapsecs_internal.h ./compile leapsecs_add.c leapsecs_sub.o: compile leapsecs_sub.c caltimedate.h tai.h leapsecs_internal.h ./compile leapsecs_sub.c case_diffb.o: compile case_diffb.c bytestr.h ./compile case_diffb.c case_diffs.o: compile case_diffs.c bytestr.h ./compile case_diffs.c case_lowerb.o: compile case_lowerb.c bytestr.h ./compile case_lowerb.c case_lowers.o: compile case_lowers.c bytestr.h ./compile case_lowers.c case_upperb.o: compile case_upperb.c bytestr.h ./compile case_upperb.c case_uppers.o: compile case_uppers.c bytestr.h ./compile case_uppers.c cdb.o: compile cdb.c cdb.h error.h djbunix.h bytestr.h allreadwrite.h uint32.h ./compile cdb.c cdb_hash.o: compile cdb_hash.c cdb.h uint32.h ./compile cdb_hash.c cdb_make.o: compile cdb_make.c cdb_make.h cdb.h djbunix.h buffer.h uint32.h diuint32.h diuint32alloc.h ./compile cdb_make.c cdb_traverse.o: compile cdb_traverse.c cdb.h djbunix.h uint32.h ./compile cdb_traverse.c coe.o: compile coe.c djbunix.h ./compile coe.c uncoe.o: compile uncoe.c djbunix.h ./compile uncoe.c deepsleep.o: compile deepsleep.c djbunix.h iopause.h tai.h ./compile deepsleep.c dirname.o: compile dirname.c djbunix.h stralloc.h bytestr.h ./compile dirname.c diuint32.h: uint32.h touch diuint32.h diuintalloc.o: compile diuintalloc.c diuintalloc.h diuint.h gen_alloc.h ./compile diuintalloc.c diuintalloc_x.o: compile diuintalloc_x.c diuintalloc.h diuint.h gen_alloc.h ./compile diuintalloc_x.c diuintbunch.o: compile diuintbunch.c diuintbunch.h gen_bunch.h diuintalloc.h diuint.h ./compile diuintbunch.c diuint32alloc.o: compile diuint32alloc.c diuint32alloc.h diuint32.h gen_alloc.h ./compile diuint32alloc.c diuint32alloc_x.o: compile diuint32alloc_x.c diuint32alloc.h diuint32.h gen_alloc.h ./compile diuint32alloc_x.c diuint32bunch.o: compile diuint32bunch.c diuint32bunch.h gen_bunch.h diuint32alloc.h diuint32.h ./compile diuint32bunch.c doublefork.o: compile doublefork.c djbunix.h allreadwrite.h uint16.h ./compile doublefork.c dir_close.o: compile dir_close.c direntry.h ./compile dir_close.c env_get.o: compile env_get.c environ.h env.h ./compile env_get.c env_get2.o: compile env_get2.c env.h bytestr.h ./compile env_get2.c env_len.o: compile env_len.c env.h ./compile env_len.c env_addmodif.o: compile env_addmodif.c env.h stralloc.h ./compile env_addmodif.c env_string.o: compile env_string.c env.h stralloc.h ./compile env_string.c envalloc.o: compile envalloc.c envalloc.h gen_alloc.h ./compile envalloc.c envalloc_x.o: compile envalloc_x.c envalloc.h gen_alloc.h ./compile envalloc_x.c envalloc_0.o: compile envalloc_0.c envalloc.h ./compile envalloc_0.c envalloc_make.o: compile envalloc_make.c envalloc.h bytestr.h ./compile envalloc_make.c envalloc_reverse.o: compile envalloc_reverse.c envalloc.h gen_alloc.h ./compile envalloc_reverse.c envalloc_uniq.o: compile envalloc_uniq.c envalloc.h error.h bytestr.h ./compile envalloc_uniq.c envalloc_merge.o: compile envalloc_merge.c env.h envalloc.h bytestr.h ./compile envalloc_merge.c 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 fd_chdir.o: compile fd_chdir.c djbunix.h ./compile fd_chdir.c fd_copy.o: compile fd_copy.c djbunix.h ./compile fd_copy.c fd_copy2.o: compile fd_copy2.c djbunix.h ./compile fd_copy2.c fd_move.o: compile fd_move.c djbunix.h ./compile fd_move.c fd_move2.o: compile fd_move2.c djbunix.h ./compile fd_move2.c fd_close.o: compile fd_close.c djbunix.h ./compile fd_close.c fd_read.o: compile fd_read.c allreadwrite.h ./compile fd_read.c fd_write.o: compile fd_write.c allreadwrite.h ./compile fd_write.c fd_recv.o: compile fd_recv.c allreadwrite.h ./compile fd_recv.c fd_send.o: compile fd_send.c allreadwrite.h ./compile fd_send.c fifo.o: compile fifo.c djbunix.h sysdeps.h ./compile fifo.c str_fmt.o: compile str_fmt.c fmtscan.h bytestr.h ./compile str_fmt.c strn_fmt.o: compile strn_fmt.c fmtscan.h ./compile strn_fmt.c ucharn_fmt.o: compile ucharn_fmt.c fmtscan.h ./compile ucharn_fmt.c ucharn_fmt_little.o: compile ucharn_fmt_little.c fmtscan.h ./compile ucharn_fmt_little.c long_fmt.o: compile long_fmt.c fmtscan.h ./compile long_fmt.c iobuffer.o: compile iobuffer.c iobuffer.h buffer.h ./compile iobuffer.c iobuffer_init.o: compile iobuffer_init.c iobuffer.h buffer.h ./compile iobuffer_init.c iopause.o: compile iopause.c iopause.h tai.h select.h sysdeps.h ./compile iopause.c ip4_fmt.o: compile ip4_fmt.c fmtscan.h ./compile ip4_fmt.c ip4_scan.o: compile ip4_scan.c fmtscan.h ./compile ip4_scan.c lock_ex.o: compile lock_ex.c djbunix.h sysdeps.h ./compile lock_ex.c lock_exnb.o: compile lock_exnb.c djbunix.h sysdeps.h ./compile lock_exnb.c lock_sh.o: compile lock_sh.c djbunix.h sysdeps.h ./compile lock_sh.c lock_shnb.o: compile lock_shnb.c djbunix.h sysdeps.h ./compile lock_shnb.c lock_un.o: compile lock_un.c djbunix.h sysdeps.h ./compile lock_un.c ndelay_off.o: compile ndelay_off.c djbunix.h ./compile ndelay_off.c ndelay_on.o: compile ndelay_on.c djbunix.h ./compile ndelay_on.c netstring_append.o: compile netstring_append.c netstring.h stralloc.h fmtscan.h bytestr.h ./compile netstring_append.c netstring_decode.o: compile netstring_decode.c netstring.h stralloc.h fmtscan.h ./compile netstring_decode.c netstring_encode.o: compile netstring_encode.c netstring.h stralloc.h fmtscan.h ./compile netstring_encode.c netstring_get.o: compile netstring_get.c netstring.h stralloc.h buffer.h fmtscan.h bytestr.h ./compile netstring_get.c netstring_put.o: compile netstring_put.c netstring.h buffer.h fmtscan.h ./compile netstring_put.c open2.o: compile open2.c djbunix.h ./compile open2.c open3.o: compile open3.c djbunix.h ./compile open3.c open_append.o: compile open_append.c djbunix.h ./compile open_append.c open_excl.o: compile open_excl.c djbunix.h ./compile open_excl.c open_read.o: compile open_read.c djbunix.h ./compile open_read.c open_readb.o: compile open_readb.c djbunix.h ./compile open_readb.c open_trunc.o: compile open_trunc.c djbunix.h ./compile open_trunc.c open_write.o: compile open_write.c djbunix.h ./compile open_write.c openreadclose.o: compile openreadclose.c djbunix.h stralloc.h ./compile openreadclose.c openreadnclose.o: compile openreadnclose.c djbunix.h allreadwrite.h ./compile openreadnclose.c openslurpclose.o: compile openslurpclose.c djbunix.h stralloc.h ./compile openslurpclose.c pathexec_r.o: compile pathexec_r.c skamisc.h djbunix.h stralloc.h gen_alloc.h ./compile pathexec_r.c pathexec_r_tmp.o: compile pathexec_r_tmp.c djbunix.h envalloc.h stralloc.h ./compile pathexec_r_tmp.c pathexec_r_tmp_envtmp.o: compile pathexec_r_tmp_envtmp.c djbunix.h envalloc.h stralloc.h ./compile pathexec_r_tmp_envtmp.c pathexec_fromenv.o: compile pathexec_fromenv.c skamisc.h djbunix.h env.h stralloc.h ./compile pathexec_fromenv.c pathexec_run_tmp.c: stupid pathexec_run_tmp.c.stupid ./stupid < pathexec_run_tmp.c.stupid > pathexec_run_tmp.c pathexec_run_tmp.o: compile pathexec_run_tmp.c env.h djbunix.h stralloc.h ./compile pathexec_run_tmp.c pathexec_run.o: compile pathexec_run.c skamisc.h djbunix.h ./compile pathexec_run.c execvep.o: compile execvep.c skamisc.h djbunix.h ./compile execvep.c execvep_tmp.o: compile execvep_tmp.c djbunix.h stralloc.h error.h bytestr.h ./compile execvep_tmp.c pathexec0.o: compile pathexec0.c djbunix.h ./compile pathexec0.c pathexec0_tmp.o: compile pathexec0_tmp.c djbunix.h ./compile pathexec0_tmp.c pathexec0_run.o: compile pathexec0_run.c djbunix.h ./compile pathexec0_run.c pathexec0_run_tmp.o: compile pathexec0_run_tmp.c djbunix.h ./compile pathexec0_run_tmp.c pathexec.o: compile pathexec.c environ.h djbunix.h env.h ./compile pathexec.c prot.o: compile prot.c djbunix.h sysdeps.h ./compile prot.c realpath.o: compile realpath.c djbunix.h skamisc.h ./compile realpath.c realpath_tmp.o: compile realpath_tmp.c djbunix.h stralloc.h bytestr.h ./compile realpath_tmp.c rm_rf.o: compile rm_rf.c djbunix.h skamisc.h ./compile rm_rf.c rm_rf_tmp.o: compile rm_rf_tmp.c djbunix.h stralloc.h ./compile rm_rf_tmp.c rm_rf_in_tmp.o: compile rm_rf_in_tmp.c djbunix.h stralloc.h bytestr.h direntry.h ./compile rm_rf_in_tmp.c rmstar.o: compile rmstar.c djbunix.h skamisc.h ./compile rmstar.c satmp.o: satmp.c skamisc.h stralloc.h ./compile satmp.c sabasename.o: compile sabasename.c djbunix.h stralloc.h bytestr.h ./compile sabasename.c sadirname.o: compile sadirname.c djbunix.h stralloc.h bytestr.h ./compile sadirname.c sagetcwd.o: compile sagetcwd.c djbunix.h stralloc.h bytestr.h ./compile sagetcwd.c sareadlink.o: compile sareadlink.c djbunix.h stralloc.h ./compile sareadlink.c sagethostname.o: compile sagethostname.c djbunix.h stralloc.h bytestr.h ./compile sagethostname.c sauniquename.o: compile sauniquename.c skamisc.h djbunix.h tai.h stralloc.h fmtscan.h ./compile sauniquename.c fmtscan_asc.o: compile fmtscan_asc.c fmtscan.h ./compile fmtscan_asc.c fmtscan_num.o: compile fmtscan_num.c fmtscan.h ./compile fmtscan_num.c ucharn_scan.o: compile ucharn_scan.c fmtscan.h ./compile ucharn_scan.c ucharn_scan_little.o: compile ucharn_scan_little.c fmtscan.h ./compile ucharn_scan_little.c ucharn_findlen.o: compile ucharn_findlen.c fmtscan.h ./compile ucharn_findlen.c short_scan.o: compile short_scan.c fmtscan.h ./compile short_scan.c int_scan.o: compile int_scan.c fmtscan.h ./compile int_scan.c long_scan.o: compile long_scan.c fmtscan.h ./compile long_scan.c ushort_scan.o: compile ushort_scan.c fmtscan-internal.h fmtscan.h ./compile ushort_scan.c ushort0_scan.o: compile ushort0_scan.c fmtscan-internal.h fmtscan.h ./compile ushort0_scan.c uint_scan.o: compile uint_scan.c fmtscan-internal.h fmtscan.h ./compile uint_scan.c uint0_scan.o: compile uint0_scan.c fmtscan-internal.h fmtscan.h ./compile uint0_scan.c ulong_scan.o: compile ulong_scan.c fmtscan-internal.h fmtscan.h ./compile ulong_scan.c ulong0_scan.o: compile ulong0_scan.c fmtscan-internal.h fmtscan.h ./compile ulong0_scan.c seek_set.o: compile seek_set.c djbunix.h ./compile seek_set.c seek_cur.o: compile seek_cur.c djbunix.h ./compile seek_cur.c sgetopt.o: compile sgetopt.c sgetopt.h djbunix.h buffer.h ./compile sgetopt.c subgetopt.o: compile subgetopt.c sgetopt.h ./compile subgetopt.c subgetopt_here.o: compile subgetopt_here.c sgetopt.h ./compile subgetopt_here.c sig.o: compile sig.c sig.h ./compile sig.c sig_block.o: compile sig_block.c sig.h sysdeps.h ./compile sig_block.c sig_blocknone.o: compile sig_blocknone.c sig.h sysdeps.h ./compile sig_blocknone.c sig_unblock.o: compile sig_unblock.c sig.h sysdeps.h ./compile sig_unblock.c sig_pause.o: compile sig_pause.c sig.h sysdeps.h ./compile sig_pause.c sig_shield.o: compile sig_shield.c sig.h sysdeps.h ./compile sig_shield.c sig_unshield.o: compile sig_unshield.c sig.h sysdeps.h ./compile sig_unshield.c sig_stack.o: compile sig_stack.c nsig.h sig.h ./compile sig_stack.c sig_push.o: compile sig_push.c sig.h ./compile sig_push.c sig_nostack.o: compile sig_nostack.c nsig.h sig.h ./compile sig_nostack.c sig_catch.o: compile sig_catch.c sig.h ./compile sig_catch.c skasig_dfl.o: skasig_dfl.c sig.h ./compile skasig_dfl.c skasigaction.o: skasigaction.c sig.h sysdeps.h ./compile skasigaction.c selfpipe.o: selfpipe.c selfpipe.h nsig.h sig.h djbunix.h error.h uint64.h allreadwrite.h ./compile selfpipe.c skagetln.o: compile skagetln.c skamisc.h stralloc.h buffer.h bytestr.h ./compile skagetln.c skagetlnsep.o: compile skagetlnsep.c skamisc.h stralloc.h buffer.h bytestr.h ./compile skagetlnsep.c slurp.o: compile slurp.c djbunix.h stralloc.h allreadwrite.h ./compile slurp.c socket_accept.o: compile socket_accept.c socket.h bytestr.h uint16.h ./compile socket_accept.c socket_bind.o: compile socket_bind.c socket.h bytestr.h uint16.h ./compile socket_bind.c socket_bindr.o: compile socket_bindr.c socket.h uint16.h ./compile socket_bindr.c socket_tryr.o: compile socket_tryr.c socket.h ./compile socket_tryr.c socket_conn.o: compile socket_conn.c socket.h bytestr.h uint16.h ./compile socket_conn.c socket_connected.o: compile socket_connected.c socket.h allreadwrite.h ./compile socket_connected.c socket_delay.o: compile socket_delay.c socket.h ./compile socket_delay.c socket_listen.o: compile socket_listen.c socket.h ./compile socket_listen.c socket_local.o: compile socket_local.c socket.h bytestr.h uint16.h ./compile socket_local.c socket_opts.o: compile socket_opts.c socket.h ./compile socket_opts.c socket_recv.o: compile socket_recv.c socket.h bytestr.h uint16.h ./compile socket_recv.c socket_remote.o: compile socket_remote.c socket.h bytestr.h uint16.h ./compile socket_remote.c socket_send.o: compile socket_send.c socket.h bytestr.h uint16.h ./compile socket_send.c socket_tcp.o: compile socket_tcp.c socket.h djbunix.h ./compile socket_tcp.c socket_timeoutconn.o: compile socket_timeoutconn.c socket.h tai.h uint16.h ./compile socket_timeoutconn.c socket_deadlineconn.o: compile socket_deadlineconn.c socket.h iopause.h tai.h error.h uint16.h ./compile socket_deadlineconn.c socket_udp.o: compile socket_udp.c socket.h djbunix.h ./compile socket_udp.c str_chr.o: compile str_chr.c bytestr.h ./compile str_chr.c str_rchr.o: compile str_rchr.c bytestr.h ./compile str_rchr.c str_cpy.o: compile str_cpy.c bytestr.h ./compile str_cpy.c str_diff.o: compile str_diff.c bytestr.h ./compile str_diff.c str_diffb.o: compile str_diffb.c bytestr.h ./compile str_diffb.c str_diffn.o: compile str_diffn.c bytestr.h ./compile str_diffn.c str_len.o: compile str_len.c bytestr.h ./compile str_len.c str_start.o: compile str_start.c bytestr.h ./compile str_start.c str_strn.o: compile str_strn.c bytestr.h ./compile str_strn.c stralloc.o: compile stralloc.c stralloc.h gen_alloc.h ./compile stralloc.c stralloc_x.o: compile stralloc_x.c stralloc.h gen_alloc.h ./compile stralloc_x.c stralloc_cats.o: compile stralloc_cats.c stralloc.h bytestr.h ./compile stralloc_cats.c stralloc_opys.o: compile stralloc_opys.c stralloc.h bytestr.h ./compile stralloc_opys.c stralloc_sert.o: compile stralloc_sert.c stralloc.h ./compile stralloc_sert.c stralloc_ertb.o: compile stralloc_ertb.c stralloc.h bytestr.h ./compile stralloc_ertb.c stralloc_erts.o: compile stralloc_erts.c stralloc.h bytestr.h ./compile stralloc_erts.c stralloc_reverse.o: compile stralloc_reverse.c stralloc.h ./compile stralloc_reverse.c strerr_die.o: compile strerr_die.c strerr.h buffer.h ./compile strerr_die.c strerr_sys.o: compile strerr_sys.c strerr.h error.h ./compile strerr_sys.c tai_add.o: compile tai_add.c tai.h ./compile tai_add.c tai_now.o: compile tai_now.c tai.h ./compile tai_now.c tai_pack.o: compile tai_pack.c tai.h uint64.h ./compile tai_pack.c tai_pack_little.o: compile tai_pack_little.c tai.h uint64.h ./compile tai_pack_little.c tai_sub.o: compile tai_sub.c tai.h ./compile tai_sub.c tai_unpack.o: compile tai_unpack.c tai.h uint64.h ./compile tai_unpack.c tai_unpack_little.o: compile tai_unpack_little.c tai.h uint64.h ./compile tai_unpack_little.c timeval_from_tai_relative.o: compile timeval_from_tai_relative.c tai.h ./compile timeval_from_tai_relative.c tai_relative_from_timeval.o: compile tai_relative_from_timeval.c tai.h ./compile tai_relative_from_timeval.c timeval_from_tai.o: compile timeval_from_tai.c tai.h ./compile timeval_from_tai.c tai_from_timeval.o: compile tai_from_timeval.c tai.h ./compile tai_from_timeval.c timeval_from_taia_relative.o: compile timeval_from_taia_relative.c tai.h ./compile timeval_from_taia_relative.c taia_relative_from_timeval.o: compile taia_relative_from_timeval.c tai.h ./compile taia_relative_from_timeval.c timeval_from_taia.o: compile timeval_from_taia.c tai.h ./compile timeval_from_taia.c taia_from_timeval.o: compile taia_from_timeval.c tai.h ./compile taia_from_timeval.c taia_add.o: compile taia_add.c tai.h ./compile taia_add.c taia_addsec.o: compile taia_addsec.c tai.h ./compile taia_addsec.c taia_approx.o: compile taia_approx.c tai.h ./compile taia_approx.c taia_frac.o: compile taia_frac.c tai.h ./compile taia_frac.c taia_half.o: compile taia_half.c tai.h ./compile taia_half.c taia_less.o: compile taia_less.c tai.h ./compile taia_less.c taia_fmt.o: compile taia_fmt.c tai.h fmtscan.h ./compile taia_fmt.c taia_scan.o: compile taia_scan.c tai.h fmtscan.h ./compile taia_scan.c taia_now.o: compile taia_now.c tai.h ./compile taia_now.c taia_pack.o: compile taia_pack.c tai.h uint32.h ./compile taia_pack.c taia_pack_little.o: compile taia_pack_little.c tai.h uint32.h ./compile taia_pack_little.c taia_unpack.o: compile taia_unpack.c tai.h uint32.h ./compile taia_unpack.c taia_unpack_little.o: compile taia_unpack_little.c tai.h uint32.h ./compile taia_unpack_little.c taia_sub.o: compile taia_sub.c tai.h ./compile taia_sub.c taia_tai.o: compile taia_tai.c tai.h ./compile taia_tai.c taia_uint.o: compile taia_uint.c tai.h ./compile taia_uint.c taia_ulong.o: compile taia_ulong.c tai.h ./compile taia_ulong.c tain_fmt.o: compile tain_fmt.c tai.h fmtscan.h ./compile tain_fmt.c tain_scan.o: compile tain_scan.c tai.h fmtscan.h ./compile tain_scan.c tain_pack.o: compile tain_pack.c tai.h uint32.h ./compile tain_pack.c tain_pack_little.o: compile tain_pack_little.c tai.h uint32.h ./compile tain_pack_little.c tain_unpack.o: compile tain_unpack.c tai.h uint32.h ./compile tain_unpack.c tain_unpack_little.o: compile tain_unpack_little.c tai.h uint32.h ./compile tain_unpack_little.c timestamp.o: compile timestamp.c tai.h ./compile timestamp.c timestamp_fmt.o: compile timestamp_fmt.c tai.h fmtscan.h uint32.h ./compile timestamp_fmt.c timestamp_scan.o: compile timestamp_scan.c tai.h fmtscan.h uint32.h ./compile timestamp_scan.c ucspi_get.o: compile ucspi_get.c env.h skamisc.h ./compile ucspi_get.c ucspi_get_tmp.o: compile ucspi_get_tmp.c env.h stralloc.h ./compile ucspi_get_tmp.c uint16_scan.o: compile uint16_scan.c uint16.h fmtscan-internal.h ./compile uint16_scan.c uint160_scan.o: compile uint160_scan.c uint16.h fmtscan-internal.h ./compile uint160_scan.c uint16_pack.o: compile uint16_pack.c uint16.h bytestr.h ./compile uint16_pack.c uint16_pack_big.o: compile uint16_pack_big.c uint16.h bytestr.h ./compile uint16_pack_big.c uint16_unpack.o: compile uint16_unpack.c uint16.h bytestr.h ./compile uint16_unpack.c uint16_unpack_big.o: compile uint16_unpack_big.c uint16.h bytestr.h ./compile uint16_unpack_big.c uint16_reverse.o: compile uint16_reverse.c uint16.h ./compile uint16_reverse.c uint32_scan.o: compile uint32_scan.c uint32.h uint64.h fmtscan-internal.h ./compile uint32_scan.c uint320_scan.o: compile uint320_scan.c uint32.h uint64.h fmtscan-internal.h ./compile uint320_scan.c uint32_pack.o: compile uint32_pack.c uint32.h bytestr.h ./compile uint32_pack.c uint32_pack_big.o: compile uint32_pack_big.c uint32.h bytestr.h ./compile uint32_pack_big.c uint32_unpack.o: compile uint32_unpack.c uint32.h bytestr.h ./compile uint32_unpack.c uint32_unpack_big.o: compile uint32_unpack_big.c uint32.h bytestr.h ./compile uint32_unpack_big.c uint32_reverse.o: compile uint32_reverse.c uint32.h ./compile uint32_reverse.c uint64_fmt.o: compile uint64_fmt.c uint64.h fmtscan.h ./compile uint64_fmt.c uint640_fmt.o: compile uint640_fmt.c uint64.h ./compile uint640_fmt.c uint64_scan.o: compile uint64_scan.c uint64.h fmtscan.h ./compile uint64_scan.c uint640_scan.o: compile uint640_scan.c uint64.h fmtscan.h ./compile uint640_scan.c uint64_pack.o: compile uint64_pack.c uint64.h bytestr.h ./compile uint64_pack.c uint64_pack_big.o: compile uint64_pack_big.c uint64.h bytestr.h ./compile uint64_pack_big.c uint64_unpack.o: compile uint64_unpack.c uint64.h bytestr.h ./compile uint64_unpack.c uint64_unpack_big.o: compile uint64_unpack_big.c uint64.h bytestr.h ./compile uint64_unpack_big.c uint64_reverse.o: compile uint64_reverse.c uint64.h ./compile uint64_reverse.c intalloc.o: compile intalloc.c intalloc.h gen_alloc.h ./compile intalloc.c intalloc_x.o: compile intalloc_x.c intalloc.h gen_alloc.h ./compile intalloc_x.c uintalloc.o: compile uintalloc.c uintalloc.h gen_alloc.h ./compile uintalloc.c uintalloc_x.o: compile uintalloc_x.c uintalloc.h gen_alloc.h ./compile uintalloc_x.c uintbunch.o: compile uintbunch.c uintbunch.h gen_bunch.h uintalloc.h ./compile uintbunch.c uint16alloc.o: compile uint16alloc.c uint16alloc.h gen_alloc.h uint16.h ./compile uint16alloc.c uint16alloc_x.o: compile uint16alloc_x.c uint16alloc.h gen_alloc.h uint16.h ./compile uint16alloc_x.c uint32alloc.o: compile uint32alloc.c uint32alloc.h gen_alloc.h uint32.h ./compile uint32alloc.c uint32alloc_x.o: compile uint32alloc_x.c uint32alloc.h gen_alloc.h uint32.h ./compile uint32alloc_x.c uint64alloc.o: compile uint64alloc.c uint64alloc.h gen_alloc.h uint64.h ./compile uint64alloc.c uint64alloc_x.o: compile uint64alloc_x.c uint64alloc.h gen_alloc.h uint64.h ./compile uint64alloc_x.c uint32aalloc.o: compile uint32aalloc.c uint32aalloc.h gen_alloc.h uint32alloc.h ./compile uint32aalloc.c uint32aalloc_x.o: compile uint32aalloc_x.c uint32aalloc.h gen_alloc.h uint32alloc.h ./compile uint32aalloc_x.c wait_pid.o: compile wait_pid.c djbunix.h diuintalloc.h diuint.h sysdeps.h ./compile wait_pid.c wait_pid_nohang.o: compile wait_pid_nohang.c djbunix.h ./compile wait_pid_nohang.c wait_pids_nohang.o: compile wait_pids_nohang.c djbunix.h ./compile wait_pids_nohang.c wait_reap.o: compile wait_reap.c djbunix.h ./compile wait_reap.c waitn.o: compile waitn.c djbunix.h ./compile waitn.c libstddjb.a: makelib \ absolutepath.o absolutepath_tmp.o basename.o sabasename.o dirname.o sadirname.o sagetcwd.o sareadlink.o realpath.o realpath_tmp.o \ alloc_ska.o alloc_0.o alloc_djb.o \ bufalloc_init.o bufalloc_clean.o bufalloc_flush.o bufalloc_1.o bufalloc_2.o \ sanitize_read.o allreadwrite.o allread.o allwrite.o fd_read.o fd_write.o fd_recv.o fd_send.o \ buffer_0.o buffer_0small.o buffer_1.o buffer_1small.o buffer_2.o \ buffer_init.o buffer_clean.o buffer_fill.o buffer_flush.o buffer_read.o buffer_write.o \ buffer_unget.o buffer_unput.o buffer_feed.o buffer_peek.o buffer_seek.o \ buffer_bget.o buffer_get.o buffer_getall.o buffer_getallnf.o buffer_getnf.o \ buffer_put.o buffer_putalign.o buffer_putall.o buffer_putallf.o buffer_putallnf.o \ buffer_putc.o buffer_putflush.o buffer_putnf.o buffer_puts.o buffer_putsalign.o buffer_putsflush.o \ byte_chr.o byte_copy.o byte_count.o byte_cr.o byte_diff.o byte_in.o byte_rchr.o byte_zero.o \ case_diffb.o case_diffs.o case_lowerb.o case_lowers.o case_upperb.o case_uppers.o \ caldate_fmjd.o caldate_fmt.o caldate_mjd.o caldate_norm.o caldate_scan.o caldate_ster.o \ caltime_fmt.o caltime_scan.o caltime_tai.o caltime_utc.o \ leapsecs_init.o leapsecs_read.o leapsecs_read_r.o leapsecs_readf_r.o leapsecs_add.o leapsecs_sub.o \ cdb.o cdb_hash.o cdb_make.o cdb_traverse.o \ prot.o doublefork.o \ dir_close.o \ env_addmodif.o env_get.o env_get2.o env_len.o env_string.o ucspi_get.o ucspi_get_tmp.o \ envalloc.o envalloc_x.o envalloc_0.o envalloc_make.o envalloc_reverse.o envalloc_uniq.o envalloc_merge.o \ error.o error_str.o error_temp.o \ fd_copy.o fd_copy2.o fd_move.o fd_move2.o coe.o uncoe.o fd_close.o \ fd_chdir.o fifo.o \ long_fmt.o str_fmt.o strn_fmt.o fmtscan_asc.o fmtscan_num.o \ uint64_fmt.o uint640_fmt.o ucharn_fmt.o ucharn_fmt_little.o ucharn_scan.o ucharn_scan_little.o ucharn_findlen.o \ short_scan.o int_scan.o long_scan.o \ ushort_scan.o ushort0_scan.o uint_scan.o uint0_scan.o ulong_scan.o ulong0_scan.o \ satmp.o skagetln.o skagetlnsep.o \ ip4_fmt.o ip4_scan.o \ iobuffer.o iobuffer_init.o \ iopause.o deepsleep.o \ lock_ex.o lock_exnb.o lock_sh.o lock_shnb.o lock_un.o \ ndelay_off.o ndelay_on.o \ netstring_append.o netstring_decode.o netstring_encode.o netstring_get.o netstring_put.o \ open2.o open3.o open_append.o open_excl.o open_read.o open_readb.o open_trunc.o open_write.o \ pathexec_r.o pathexec_r_tmp.o pathexec_r_tmp_envtmp.o pathexec_fromenv.o pathexec.o \ pathexec_run.o pathexec_run_tmp.o execvep.o execvep_tmp.o \ pathexec0.o pathexec0_tmp.o pathexec0_run.o pathexec0_run_tmp.o \ openreadclose.o openreadnclose.o slurp.o openslurpclose.o \ rm_rf.o rm_rf_tmp.o rm_rf_in_tmp.o rmstar.o \ seek_set.o seek_cur.o \ sgetopt.o subgetopt.o subgetopt_here.o \ sig.o sig_block.o sig_blocknone.o sig_unblock.o sig_pause.o sig_shield.o sig_unshield.o \ skasig_dfl.o skasigaction.o sig_stack.o sig_push.o sig_nostack.o sig_catch.o selfpipe.o \ socket_accept.o socket_bind.o socket_bindr.o socket_tryr.o socket_conn.o socket_connected.o \ socket_delay.o socket_listen.o socket_local.o socket_opts.o \ socket_recv.o socket_remote.o socket_send.o socket_tcp.o socket_udp.o socket_timeoutconn.o socket_deadlineconn.o \ str_chr.o str_rchr.o str_cpy.o str_diff.o str_diffb.o str_diffn.o str_len.o str_start.o str_strn.o \ stralloc.o stralloc_x.o stralloc_cats.o stralloc_opys.o stralloc_sert.o stralloc_ertb.o stralloc_erts.o stralloc_reverse.o \ strerr_die.o strerr_sys.o \ tai_add.o tai_now.o tai_pack.o tai_pack_little.o tai_sub.o tai_unpack.o tai_unpack_little.o \ timeval_from_tai_relative.o tai_relative_from_timeval.o timeval_from_tai.o tai_from_timeval.o \ timeval_from_taia_relative.o taia_relative_from_timeval.o timeval_from_taia.o taia_from_timeval.o \ taia_add.o taia_addsec.o taia_approx.o taia_frac.o taia_half.o taia_less.o \ taia_now.o taia_pack.o taia_pack_little.o taia_unpack.o taia_unpack_little.o taia_sub.o taia_tai.o taia_uint.o taia_ulong.o \ taia_fmt.o taia_scan.o timestamp.o timestamp_fmt.o timestamp_scan.o \ tain_fmt.o tain_scan.o tain_pack.o tain_pack_little.o tain_unpack.o tain_unpack_little.o \ uint16_scan.o uint160_scan.o uint16_pack.o uint16_pack_big.o uint16_unpack.o uint16_unpack_big.o uint16_reverse.o \ uint32_scan.o uint320_scan.o uint32_pack.o uint32_pack_big.o uint32_unpack.o uint32_unpack_big.o uint32_reverse.o \ uint64_scan.o uint640_scan.o uint64_pack.o uint64_pack_big.o uint64_unpack.o uint64_unpack_big.o uint64_reverse.o \ intalloc.o intalloc_x.o uintalloc.o uintalloc_x.o \ uint16alloc.o uint16alloc_x.o \ uint32alloc.o uint32alloc_x.o \ uint64alloc.o uint64alloc_x.o \ uint32aalloc.o uint32aalloc_x.o \ diuintalloc.o diuintalloc_x.o diuintbunch.o \ diuint32alloc.o diuint32alloc_x.o diuint32bunch.o \ sagethostname.o sauniquename.o \ bitarray.o uintbunch.o \ wait_pid.o wait_pid_nohang.o wait_pids_nohang.o wait_reap.o waitn.o ./makelib libstddjb.a \ absolutepath.o absolutepath_tmp.o basename.o sabasename.o dirname.o sadirname.o sagetcwd.o sareadlink.o realpath.o realpath_tmp.o \ alloc_ska.o alloc_0.o alloc_djb.o \ bufalloc_init.o bufalloc_clean.o bufalloc_flush.o bufalloc_1.o bufalloc_2.o \ sanitize_read.o allreadwrite.o allread.o allwrite.o fd_read.o fd_write.o fd_recv.o fd_send.o \ buffer_0.o buffer_0small.o buffer_1.o buffer_1small.o buffer_2.o \ buffer_init.o buffer_clean.o buffer_fill.o buffer_flush.o buffer_read.o buffer_write.o \ buffer_unget.o buffer_unput.o buffer_feed.o buffer_peek.o buffer_seek.o \ buffer_bget.o buffer_get.o buffer_getall.o buffer_getallnf.o buffer_getnf.o \ buffer_put.o buffer_putalign.o buffer_putall.o buffer_putallf.o buffer_putallnf.o \ buffer_putc.o buffer_putflush.o buffer_putnf.o buffer_puts.o buffer_putsalign.o buffer_putsflush.o \ byte_chr.o byte_copy.o byte_count.o byte_cr.o byte_diff.o byte_in.o byte_rchr.o byte_zero.o \ caldate_fmjd.o caldate_fmt.o caldate_mjd.o caldate_norm.o caldate_scan.o caldate_ster.o \ caltime_fmt.o caltime_scan.o caltime_tai.o caltime_utc.o \ leapsecs_init.o leapsecs_read.o leapsecs_read_r.o leapsecs_readf_r.o leapsecs_add.o leapsecs_sub.o \ case_diffb.o case_diffs.o case_lowerb.o case_lowers.o case_upperb.o case_uppers.o \ cdb.o cdb_hash.o cdb_make.o cdb_traverse.o \ prot.o doublefork.o \ dir_close.o \ env_addmodif.o env_get.o env_get2.o env_len.o env_string.o ucspi_get.o ucspi_get_tmp.o \ envalloc.o envalloc_x.o envalloc_0.o envalloc_make.o envalloc_reverse.o envalloc_uniq.o envalloc_merge.o \ error.o error_str.o error_temp.o \ fd_copy.o fd_copy2.o fd_move.o fd_move2.o coe.o uncoe.o fd_close.o \ fd_chdir.o fifo.o \ long_fmt.o str_fmt.o strn_fmt.o fmtscan_asc.o fmtscan_num.o \ uint64_fmt.o uint640_fmt.o ucharn_fmt.o ucharn_fmt_little.o ucharn_scan.o ucharn_scan_little.o ucharn_findlen.o \ short_scan.o int_scan.o long_scan.o \ ushort_scan.o ushort0_scan.o uint_scan.o uint0_scan.o ulong_scan.o ulong0_scan.o \ satmp.o skagetln.o skagetlnsep.o \ ip4_fmt.o ip4_scan.o \ iobuffer.o iobuffer_init.o \ iopause.o deepsleep.o \ lock_ex.o lock_exnb.o lock_sh.o lock_shnb.o lock_un.o \ ndelay_off.o ndelay_on.o \ netstring_append.o netstring_decode.o netstring_encode.o netstring_get.o netstring_put.o \ open2.o open3.o open_append.o open_excl.o open_read.o open_readb.o open_trunc.o open_write.o \ pathexec_r.o pathexec_r_tmp.o pathexec_r_tmp_envtmp.o pathexec_fromenv.o pathexec.o \ pathexec_run.o pathexec_run_tmp.o execvep.o execvep_tmp.o \ pathexec0.o pathexec0_tmp.o pathexec0_run.o pathexec0_run_tmp.o \ openreadclose.o openreadnclose.o slurp.o openslurpclose.o \ rm_rf.o rm_rf_tmp.o rm_rf_in_tmp.o rmstar.o \ seek_set.o seek_cur.o \ sgetopt.o subgetopt.o subgetopt_here.o \ sig.o sig_block.o sig_blocknone.o sig_unblock.o sig_pause.o sig_shield.o sig_unshield.o \ skasig_dfl.o skasigaction.o sig_stack.o sig_push.o sig_nostack.o sig_catch.o selfpipe.o \ socket_accept.o socket_bind.o socket_bindr.o socket_tryr.o socket_conn.o socket_connected.o \ socket_delay.o socket_listen.o socket_local.o socket_opts.o \ socket_recv.o socket_remote.o socket_send.o socket_tcp.o socket_udp.o socket_timeoutconn.o socket_deadlineconn.o \ str_chr.o str_rchr.o str_cpy.o str_diff.o str_diffb.o str_diffn.o str_len.o str_start.o str_strn.o \ stralloc.o stralloc_x.o stralloc_cats.o stralloc_opys.o stralloc_sert.o stralloc_ertb.o stralloc_erts.o stralloc_reverse.o \ strerr_die.o strerr_sys.o \ tai_add.o tai_now.o tai_pack.o tai_pack_little.o tai_sub.o tai_unpack.o tai_unpack_little.o \ timeval_from_tai_relative.o tai_relative_from_timeval.o timeval_from_tai.o tai_from_timeval.o \ timeval_from_taia_relative.o taia_relative_from_timeval.o timeval_from_taia.o taia_from_timeval.o \ taia_add.o taia_addsec.o taia_approx.o taia_frac.o taia_half.o taia_less.o \ taia_now.o taia_pack.o taia_pack_little.o taia_unpack.o taia_unpack_little.o taia_sub.o taia_tai.o taia_uint.o taia_ulong.o \ taia_fmt.o taia_scan.o timestamp.o timestamp_fmt.o timestamp_scan.o \ tain_fmt.o tain_scan.o tain_pack.o tain_pack_little.o tain_unpack.o tain_unpack_little.o \ uint16_scan.o uint160_scan.o uint16_pack.o uint16_pack_big.o uint16_unpack.o uint16_unpack_big.o uint16_reverse.o \ uint32_scan.o uint320_scan.o uint32_pack.o uint32_pack_big.o uint32_unpack.o uint32_unpack_big.o uint32_reverse.o \ uint64_scan.o uint640_scan.o uint64_pack.o uint64_pack_big.o uint64_unpack.o uint64_unpack_big.o uint64_reverse.o \ intalloc.o intalloc_x.o uintalloc.o uintalloc_x.o \ uint16alloc.o uint16alloc_x.o \ uint32alloc.o uint32alloc_x.o \ uint64alloc.o uint64alloc_x.o \ uint32aalloc.o uint32aalloc_x.o \ diuintalloc.o diuintalloc_x.o diuintbunch.o \ diuint32alloc.o diuint32alloc_x.o diuint32bunch.o \ sagethostname.o sauniquename.o \ bitarray.o uintbunch.o \ wait_pid.o wait_pid_nohang.o wait_pids_nohang.o wait_reap.o waitn.o command: include: alloc.h allreadwrite.h bufalloc.h buffer.h bytestr.h cdb.h cdb_make.h env.h envalloc.h djbunix.h environ.h fmtscan.h gen_alloc.h iobuffer.h netstring.h sgetopt.h sig.h skamisc.h socket.h stddjb.h stralloc.h strerr.h strerr2.h tai.h selfpipe.h diuint.h diuint32.h diuintalloc.h diuint32alloc.h library: libstddjb.a library.so: prog/skalibs-0.47/src/libstddjb/stddjb.h0100644000000000000000000000214011100046312015066 0ustar /* Public domain. */ #ifndef STDDJB_H #define STDDJB_H #include "gccattributes.h" #include "uint16.h" #include "uint32.h" #include "uint64.h" #include "alloc.h" #include "intalloc.h" #include "uintalloc.h" #include "uint16alloc.h" #include "uint32alloc.h" #include "uint64alloc.h" #include "uint32aalloc.h" #include "allreadwrite.h" #include "buffer.h" #include "iobuffer.h" #include "bytestr.h" #include "env.h" #include "djbunix.h" #include "syssocket.h" #include "envalloc.h" #include "direntry.h" #include "error.h" #include "fmtscan.h" #include "gen_alloc.h" #include "select.h" #include "sig.h" #include "stralloc.h" #include "bufalloc.h" #include "cdb.h" #include "cdb_make.h" #include "strerr2.h" #include "tai.h" #include "iopause.h" #include "sgetopt.h" #include "netstring.h" #include "skamisc.h" #include "caltimedate.h" #include "bitarray.h" #include "gen_bunch.h" #include "uintbunch.h" #include "diuint.h" #include "diuintalloc.h" #include "diuintbunch.h" #include "diuint32.h" #include "diuint32alloc.h" #include "diuint32bunch.h" #include "environ.h" #include "shglob.h" #include "selfpipe.h" #endif prog/skalibs-0.47/src/libstddjb/INCLUDE0100644000000000000000000000070410321255074014470 0ustar alloc.h intalloc.h uintalloc.h uint16alloc.h uint32alloc.h uint64alloc.h uint32aalloc.h allreadwrite.h bitarray.h bufalloc.h buffer.h bytestr.h caltimedate.h cdb.h cdb_make.h env.h envalloc.h djbunix.h environ.h fmtscan.h gen_alloc.h gen_bunch.h iobuffer.h netstring.h sgetopt.h selfpipe.h sig.h skamisc.h socket.h stddjb.h stralloc.h strerr.h strerr2.h tai.h uintbunch.h diuint.h diuintalloc.h diuintbunch.h diuint32.h diuint32alloc.h diuint32bunch.h prog/skalibs-0.47/src/libstddjb/INTERNAL0100644000000000000000000001113210321254755014623 0ustar pathexec_run_tmp.c absolutepath.o absolutepath_tmp.o alloc_0.o alloc_djb.o alloc_ska.o allread.o allreadwrite.o allwrite.o basename.o bitarray.o bufalloc_1.o bufalloc_2.o bufalloc_clean.o bufalloc_flush.o bufalloc_init.o buffer_0.o buffer_0small.o buffer_1.o buffer_1small.o buffer_2.o buffer_bget.o buffer_clean.o buffer_feed.o buffer_fill.o buffer_flush.o buffer_get.o buffer_getall.o buffer_getallnf.o buffer_getnf.o buffer_init.o buffer_peek.o buffer_put.o buffer_putalign.o buffer_putall.o buffer_putallf.o buffer_putallnf.o buffer_putc.o buffer_putflush.o buffer_putnf.o buffer_puts.o buffer_putsalign.o buffer_putsflush.o buffer_read.o buffer_seek.o buffer_unget.o buffer_unput.o buffer_write.o byte_chr.o byte_copy.o byte_count.o byte_cr.o byte_diff.o byte_in.o byte_rchr.o byte_zero.o caldate_fmjd.o caldate_fmt.o caldate_mjd.o caldate_norm.o caldate_scan.o caldate_ster.o caltime_fmt.o caltime_scan.o caltime_tai.o caltime_utc.o case_diffb.o case_diffs.o case_lowerb.o case_lowers.o case_upperb.o case_uppers.o cdb.o cdb_hash.o cdb_make.o cdb_traverse.o coe.o deepsleep.o dir_close.o dirname.o diuintalloc.o diuintalloc_x.o diuintbunch.o diuint32alloc.o diuint32alloc_x.o diuint32bunch.o doublefork.o env_addmodif.o env_get.o env_get2.o env_len.o env_string.o envalloc.o envalloc_0.o envalloc_make.o envalloc_merge.o envalloc_reverse.o envalloc_uniq.o envalloc_x.o error.o error_str.o error_temp.o execvep.o execvep_tmp.o fd_chdir.o fd_close.o fd_copy.o fd_copy2.o fd_move.o fd_move2.o fd_read.o fd_recv.o fd_send.o fd_write.o fifo.o fmtscan_asc.o fmtscan_num.o int_scan.o intalloc.o intalloc_x.o iobuffer.o iobuffer_init.o iopause.o ip4_fmt.o ip4_scan.o leapsecs_add.o leapsecs_init.o leapsecs_read.o leapsecs_read_r.o leapsecs_readf_r.o leapsecs_sub.o lock_ex.o lock_exnb.o lock_sh.o lock_shnb.o lock_un.o long_fmt.o long_scan.o ndelay_off.o ndelay_on.o netstring_append.o netstring_decode.o netstring_encode.o netstring_get.o netstring_put.o open2.o open3.o open_append.o open_excl.o open_read.o open_readb.o open_trunc.o open_write.o openreadclose.o openreadnclose.o openslurpclose.o pathexec.o pathexec0.o pathexec0_run.o pathexec0_run_tmp.o pathexec0_tmp.o pathexec_fromenv.o pathexec_r.o pathexec_r_tmp.o pathexec_r_tmp_envtmp.o pathexec_run.o prot.o realpath.o realpath_tmp.o rm_rf.o rm_rf_in_tmp.o rm_rf_tmp.o rmstar.o sabasename.o sadirname.o sagetcwd.o sagethostname.o sanitize_read.o sareadlink.o satmp.o sauniquename.o seek_cur.o seek_set.o selfpipe.o sgetopt.o short_scan.o sig.o sig_block.o sig_blocknone.o sig_catch.o sig_nostack.o sig_pause.o sig_push.o sig_shield.o sig_stack.o sig_unblock.o sig_unshield.o skagetln.o skagetlnsep.o skasig_dfl.o skasigaction.o slurp.o socket_accept.o socket_bind.o socket_bindr.o socket_conn.o socket_connected.o socket_deadlineconn.o socket_delay.o socket_listen.o socket_local.o socket_opts.o socket_recv.o socket_remote.o socket_send.o socket_tcp.o socket_timeoutconn.o socket_tryr.o socket_udp.o str_chr.o str_cpy.o str_diff.o str_diffb.o str_diffn.o str_fmt.o str_len.o str_rchr.o str_start.o str_strn.o stralloc.o stralloc_cats.o stralloc_ertb.o stralloc_erts.o stralloc_opys.o stralloc_reverse.o stralloc_sert.o stralloc_x.o strerr_die.o strerr_sys.o strn_fmt.o subgetopt.o subgetopt_here.o tai_add.o tai_from_timeval.o tai_now.o tai_pack.o tai_pack_little.o tai_relative_from_timeval.o tai_sub.o tai_unpack.o tai_unpack_little.o taia_add.o taia_addsec.o taia_approx.o taia_fmt.o taia_frac.o taia_from_timeval.o taia_half.o taia_less.o taia_now.o taia_pack.o taia_pack_little.o taia_relative_from_timeval.o taia_scan.o taia_sub.o taia_tai.o taia_uint.o taia_ulong.o taia_unpack.o taia_unpack_little.o tain_fmt.o tain_pack.o tain_pack_little.o tain_scan.o tain_unpack.o tain_unpack_little.o timestamp.o timestamp_fmt.o timestamp_scan.o timeval_from_tai.o timeval_from_tai_relative.o timeval_from_taia.o timeval_from_taia_relative.o ucharn_findlen.o ucharn_fmt.o ucharn_fmt_little.o ucharn_scan.o ucharn_scan_little.o ucspi_get.o ucspi_get_tmp.o uint0_scan.o uint160_scan.o uint16_pack.o uint16_pack_big.o uint16_reverse.o uint16_scan.o uint16_unpack.o uint16_unpack_big.o uint16alloc.o uint16alloc_x.o uint320_scan.o uint32_pack.o uint32_pack_big.o uint32_reverse.o uint32_scan.o uint32_unpack.o uint32_unpack_big.o uint32aalloc.o uint32aalloc_x.o uint32alloc.o uint32alloc_x.o uint640_fmt.o uint640_scan.o uint64_fmt.o uint64_pack.o uint64_pack_big.o uint64_reverse.o uint64_scan.o uint64_unpack.o uint64_unpack_big.o uint64alloc.o uint64alloc_x.o uint_scan.o uintalloc.o uintalloc_x.o uintbunch.o ulong0_scan.o ulong_scan.o uncoe.o ushort0_scan.o ushort_scan.o wait_pid.o wait_pid_nohang.o wait_pids_nohang.o wait_reap.o waitn.o prog/skalibs-0.47/src/libstddjb/buffer.h0100644000000000000000000000615410007474631015114 0ustar /* Public domain. */ #ifndef BUFFER_H #define BUFFER_H /* WARNING : this implementation differs from djb's one, so a program violating the buffer encapsulation will break. This implementation safely supports asynchronous operation. All operations documented at http://cr.yp.to/lib/buffer_*.html are compatible, but buffer_getall and buffer_putall are the safe ones. */ #include "gccattributes.h" #include "allreadwrite.h" typedef struct buffer buffer, *buffer_ref ; typedef int bufferget_t (buffer_ref, char *, unsigned int) ; typedef bufferget_t *bufferget_t_ref ; typedef int bufferput_t (buffer_ref, char const *, unsigned int) ; typedef bufferput_t *bufferput_t_ref ; struct buffer { char *x ; unsigned int a ; /* total length */ unsigned int p ; /* head */ unsigned int n ; /* tail */ int fd ; iofunc_t_ref op ; } ; #define BUFFER_INIT(op, fd, buf, len) { (buf), (len), 0, 0, (fd), (op) } #define BUFFER_INSIZE 8192 #define BUFFER_OUTSIZE 8192 #define BUFFER_ERRSIZE 1024 #define BUFFER_INSIZE_SMALL 512 #define BUFFER_OUTSIZE_SMALL 512 extern void buffer_init (buffer_ref, iofunc_t_ref, int, char *, unsigned int) ; extern void buffer_clean (buffer_ref) ; extern int buffer_flush (buffer_ref) ; extern bufferput_t buffer_put ; extern bufferput_t buffer_putalign ; extern bufferput_t buffer_putflush ; extern int buffer_puts (buffer_ref, char const *) ; extern int buffer_putsalign (buffer_ref, char const *) ; extern int buffer_putsflush (buffer_ref, char const *) ; extern int buffer_PUTC (buffer_ref, char) ; extern unsigned int buffer_putnoflush (buffer_ref, char const *, unsigned int) ; extern int buffer_putall (buffer_ref, char const *, unsigned int, unsigned int *) ; extern int buffer_putallflush (buffer_ref, char const *, unsigned int, unsigned int *) ; extern bufferput_t buffer_putallnoflush ; extern int buffer_unput (buffer_ref, unsigned int) ; extern bufferget_t buffer_get ; extern bufferget_t buffer_bget ; #define buffer_GETC(b, c) buffer_get((b), (c), 1) extern int buffer_fill (buffer_ref) ; extern unsigned int buffer_getnofill (buffer_ref, char *, unsigned int) ; extern int buffer_getall (buffer_ref, char *, unsigned int, unsigned int *) ; extern bufferget_t buffer_getallnofill ; extern int buffer_unget (buffer_ref, unsigned int) ; extern int buffer_feed (buffer_ref) ; extern char *buffer_peek (buffer_ref) gccattr_pure ; extern void buffer_seek (buffer_ref, unsigned int) ; #define buffer_RPEEK(b) ((b)->x + (b)->p) #define buffer_RSEEK(b, n) ((b)->p += (n)) #define buffer_PEEK(b) buffer_RPEEK(b) #define buffer_SEEK(b, n) buffer_RSEEK(b, n) #define buffer_WPEEK(b) ((b)->x + (b)->n) #define buffer_WSEEK(b, l) ((b)->n += (l)) #define buffer_len(b) ((unsigned int)((b)->n - (b)->p)) #define buffer_available(b) ((unsigned int)((b)->a - (b)->n)) #define buffer_isempty(b) (!buffer_len(b)) #define buffer_isfull(b) (buffer_len(b) >= (b)->a) #define buffer_fd(b) ((b)->fd) extern iofunc_t buffer_unixread ; extern iofunc_t buffer_unixwrite ; extern buffer_ref buffer_0 ; extern buffer_ref buffer_0small ; extern buffer_ref buffer_1 ; extern buffer_ref buffer_1small ; extern buffer_ref buffer_2 ; #endif prog/skalibs-0.47/src/libstddjb/prot.c0100644000000000000000000000074307666446520014635 0ustar /* Public domain. */ #include #include #include #include "sysdeps.h" #include "djbunix.h" int prot_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, (const gid_t *)&gid) == -1) return -1 ; #endif return setgid(gid) ; /* _should_ be redundant, but on some systems it isn't */ } int prot_uid (int uid) { return setuid(uid) ; } prog/skalibs-0.47/src/libstddjb/strerr.h0100644000000000000000000001507507666446520015203 0ustar /* Public domain. */ #ifndef STRERR_H #define STRERR_H #include "gccattributes.h" extern void strerr_warn (char const *, char const *, char const *, char const *, char const *, char const *, char const *, char const *, char const *, char const *, char const *) ; extern void strerr_die (int, char const *, char const *, char const *, char const *, char const *, char const *, char const *, char const *, char const *, char const *, char const *) gccattr_noreturn ; extern void strerr_warnsys (char const *, char const *, char const *, char const *, char const *, char const *, char const *, char const *, char const *, char const *) ; extern void strerr_diesys (int, char const *, char const *, char const *, char const *, char const *, char const *, char const *, char const *, char const *, char const *) gccattr_noreturn ; #define strerr_warn10(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,se) \ strerr_warn((x1),(x2),(x3),(x4),(x5),(x6),(x7),(x8),(x9),(x10),(se)) #define strerr_warn9(x1,x2,x3,x4,x5,x6,x7,x8,x9,se) \ strerr_warn((x1),(x2),(x3),(x4),(x5),(x6),(x7),(x8),(x9),0,(se)) #define strerr_warn8(x1,x2,x3,x4,x5,x6,x7,x8,se) \ strerr_warn((x1),(x2),(x3),(x4),(x5),(x6),(x7),(x8),0,0,(se)) #define strerr_warn7(x1,x2,x3,x4,x5,x6,x7,se) \ strerr_warn((x1),(x2),(x3),(x4),(x5),(x6),(x7),0,0,0,(se)) #define strerr_warn6(x1,x2,x3,x4,x5,x6,se) \ strerr_warn((x1),(x2),(x3),(x4),(x5),(x6),0,0,0,0,(se)) #define strerr_warn5(x1,x2,x3,x4,x5,se) \ strerr_warn((x1),(x2),(x3),(x4),(x5),0,0,0,0,0,(se)) #define strerr_warn4(x1,x2,x3,x4,se) \ strerr_warn((x1),(x2),(x3),(x4),0,0,0,0,0,0,(se)) #define strerr_warn3(x1,x2,x3,se) \ strerr_warn((x1),(x2),(x3),0,0,0,0,0,0,0,(se)) #define strerr_warn2(x1,x2,se) \ strerr_warn((x1),(x2),0,0,0,0,0,0,0,0,(se)) #define strerr_warn1(x1,se) \ strerr_warn((x1),0,0,0,0,0,0,0,0,0,(se)) #define strerr_warn10sys(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) \ strerr_warnsys((x1),(x2),(x3),(x4),(x5),(x6),(x7),(x8),(x9),(x10)) #define strerr_warn9sys(x1,x2,x3,x4,x5,x6,x7,x8,x9) \ strerr_warnsys((x1),(x2),(x3),(x4),(x5),(x6),(x7),(x8),(x9),0) #define strerr_warn8sys(x1,x2,x3,x4,x5,x6,x7,x8) \ strerr_warnsys((x1),(x2),(x3),(x4),(x5),(x6),(x7),(x8),0,0) #define strerr_warn7sys(x1,x2,x3,x4,x5,x6,x7) \ strerr_warnsys((x1),(x2),(x3),(x4),(x5),(x6),(x7),0,0,0) #define strerr_warn6sys(x1,x2,x3,x4,x5,x6) \ strerr_warnsys((x1),(x2),(x3),(x4),(x5),(x6),0,0,0,0) #define strerr_warn5sys(x1,x2,x3,x4,x5) \ strerr_warnsys((x1),(x2),(x3),(x4),(x5),0,0,0,0,0) #define strerr_warn4sys(x1,x2,x3,x4) \ strerr_warnsys((x1),(x2),(x3),(x4),0,0,0,0,0,0) #define strerr_warn3sys(x1,x2,x3) \ strerr_warnsys((x1),(x2),(x3),0,0,0,0,0,0,0) #define strerr_warn2sys(x1,x2) \ strerr_warnsys((x1),(x2),0,0,0,0,0,0,0,0) #define strerr_warn1sys(x1) \ strerr_warnsys((x1),0,0,0,0,0,0,0,0,0) #define strerr_warn10x(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) \ strerr_warn((x1),(x2),(x3),(x4),(x5),(x6),(x7),(x8),(x9),(x10),0) #define strerr_warn9x(x1,x2,x3,x4,x5,x6,x7,x8,x9) \ strerr_warn((x1),(x2),(x3),(x4),(x5),(x6),(x7),(x8),(x9),0,0) #define strerr_warn8x(x1,x2,x3,x4,x5,x6,x7,x8) \ strerr_warn((x1),(x2),(x3),(x4),(x5),(x6),(x7),(x8),0,0,0) #define strerr_warn7x(x1,x2,x3,x4,x5,x6,x7) \ strerr_warn((x1),(x2),(x3),(x4),(x5),(x6),(x7),0,0,0,0) #define strerr_warn6x(x1,x2,x3,x4,x5,x6) \ strerr_warn((x1),(x2),(x3),(x4),(x5),(x6),0,0,0,0,0) #define strerr_warn5x(x1,x2,x3,x4,x5) \ strerr_warn((x1),(x2),(x3),(x4),(x5),0,0,0,0,0,0) #define strerr_warn4x(x1,x2,x3,x4) \ strerr_warn((x1),(x2),(x3),(x4),0,0,0,0,0,0,0) #define strerr_warn3x(x1,x2,x3) \ strerr_warn((x1),(x2),(x3),0,0,0,0,0,0,0,0) #define strerr_warn2x(x1,x2) \ strerr_warn((x1),(x2),0,0,0,0,0,0,0,0,0) #define strerr_warn1x(x1) \ strerr_warn((x1),0,0,0,0,0,0,0,0,0,0) #define strerr_die10(e,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,se) \ strerr_die(e),(x1),(x2),(x3),(x4),(x5),(x6),(x7),(x8),(x9),(x10),(se)) #define strerr_die9(e,x1,x2,x3,x4,x5,x6,x7,x8,x9,se) \ strerr_die(e),(x1),(x2),(x3),(x4),(x5),(x6),(x7),(x8),(x9),0,(se)) #define strerr_die8(e,x1,x2,x3,x4,x5,x6,x7,x8,se) \ strerr_die(e),(x1),(x2),(x3),(x4),(x5),(x6),(x7),(x8),0,0,(se)) #define strerr_die7(e,x1,x2,x3,x4,x5,x6,x7,se) \ strerr_die(e),(x1),(x2),(x3),(x4),(x5),(x6),(x7),0,0,0,(se)) #define strerr_die6(e,x1,x2,x3,x4,x5,x6,se) \ strerr_die((e),(x1),(x2),(x3),(x4),(x5),(x6),0,0,0,0,(se)) #define strerr_die5(e,x1,x2,x3,x4,x5,se) \ strerr_die((e),(x1),(x2),(x3),(x4),(x5),0,0,0,0,0,(se)) #define strerr_die4(e,x1,x2,x3,x4,se) \ strerr_die((e),(x1),(x2),(x3),(x4),0,0,0,0,0,0,(se)) #define strerr_die3(e,x1,x2,x3,se) \ strerr_die((e),(x1),(x2),(x3),0,0,0,0,0,0,0,(se)) #define strerr_die2(e,x1,x2,se) \ strerr_die((e),(x1),(x2),0,0,0,0,0,0,0,0,(se)) #define strerr_die1(e,x1,se) \ strerr_die((e),(x1),0,0,0,0,0,0,0,0,0,(se)) #define strerr_die10sys(e,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) \ strerr_diesys((e),(x1),(x2),(x3),(x4),(x5),(x6),(x7),(x8),(x9),(x10)) #define strerr_die9sys(e,x1,x2,x3,x4,x5,x6,x7,x8,x9) \ strerr_diesys((e),(x1),(x2),(x3),(x4),(x5),(x6),(x7),(x8),(x9),0) #define strerr_die8sys(e,x1,x2,x3,x4,x5,x6,x7,x8) \ strerr_diesys((e),(x1),(x2),(x3),(x4),(x5),(x6),(x7),(x8),0,0) #define strerr_die7sys(e,x1,x2,x3,x4,x5,x6,x7) \ strerr_diesys((e),(x1),(x2),(x3),(x4),(x5),(x6),(x7),0,0,0) #define strerr_die6sys(e,x1,x2,x3,x4,x5,x6) \ strerr_diesys((e),(x1),(x2),(x3),(x4),(x5),(x6),0,0,0,0) #define strerr_die5sys(e,x1,x2,x3,x4,x5) \ strerr_diesys((e),(x1),(x2),(x3),(x4),(x5),0,0,0,0,0) #define strerr_die4sys(e,x1,x2,x3,x4) \ strerr_diesys((e),(x1),(x2),(x3),(x4),0,0,0,0,0,0) #define strerr_die3sys(e,x1,x2,x3) \ strerr_diesys((e),(x1),(x2),(x3),0,0,0,0,0,0,0) #define strerr_die2sys(e,x1,x2) \ strerr_diesys((e),(x1),(x2),0,0,0,0,0,0,0,0) #define strerr_die1sys(e,x1) \ strerr_diesys((e),(x1),0,0,0,0,0,0,0,0,0) #define strerr_die10x(e,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) \ strerr_die((e),(x1),(x2),(x3),(x4),(x5),(x6),(x7),(x8),(x9),(x10),0) #define strerr_die9x(e,x1,x2,x3,x4,x5,x6,x7,x8,x9) \ strerr_die((e),(x1),(x2),(x3),(x4),(x5),(x6),(x7),(x8),(x9),0,0) #define strerr_die8x(e,x1,x2,x3,x4,x5,x6,x7,x8) \ strerr_die((e),(x1),(x2),(x3),(x4),(x5),(x6),(x7),(x8),0,0,0) #define strerr_die7x(e,x1,x2,x3,x4,x5,x6,x7) \ strerr_die((e),(x1),(x2),(x3),(x4),(x5),(x6),(x7),0,0,0,0) #define strerr_die6x(e,x1,x2,x3,x4,x5,x6) \ strerr_die((e),(x1),(x2),(x3),(x4),(x5),(x6),0,0,0,0,0) #define strerr_die5x(e,x1,x2,x3,x4,x5) \ strerr_die((e),(x1),(x2),(x3),(x4),(x5),0,0,0,0,0,0) #define strerr_die4x(e,x1,x2,x3,x4) \ strerr_die((e),(x1),(x2),(x3),(x4),0,0,0,0,0,0,0) #define strerr_die3x(e,x1,x2,x3) \ strerr_die((e),(x1),(x2),(x3),0,0,0,0,0,0,0,0) #define strerr_die2x(e,x1,x2) \ strerr_die((e),(x1),(x2),0,0,0,0,0,0,0,0,0) #define strerr_die1x(e,x1) \ strerr_die((e),(x1),0,0,0,0,0,0,0,0,0,0) #endif prog/skalibs-0.47/src/libstddjb/sig_shield.c0100644000000000000000000000100110005153143015720 0ustar /* Public domain. */ #include #include "sysdeps.h" #include "sig.h" void sig_shield () { #ifdef HASSIGPROCMASK sigset_t ss ; sigemptyset(&ss) ; sigaddset(&ss, SIGTERM) ; sigaddset(&ss, SIGQUIT) ; sigaddset(&ss, SIGABRT) ; sigaddset(&ss, SIGINT) ; sigaddset(&ss, SIGPIPE) ; sigaddset(&ss, SIGHUP) ; sigprocmask(SIG_BLOCK, &ss, 0) ; #else sigblock((1 << (SIGTERM-1)) | (1 << (SIGQUIT-1)) | (1 << (SIGABRT-1)) | (1 << (SIGINT-1)) | (1 << (SIGPIPE-1)) | (1 << (SIGHUP-1))) ; #endif } prog/skalibs-0.47/src/libstddjb/diuint.h0100644000000000000000000000025607766034333015145 0ustar /* Public domain. */ #ifndef DIUINT_H #define DIUINT_H typedef struct diuint diuint, *diuint_ref ; struct diuint { unsigned int left ; unsigned int right ; } ; #endif prog/skalibs-0.47/src/libstddjb/fifo.c0100644000000000000000000000054710004007357014553 0ustar /* Public domain. */ #include #include #include "sysdeps.h" #include "djbunix.h" #ifdef HASMKFIFO int fifo_make (char const *fn, unsigned int mode) { return mkfifo(fn, mode) ; } #else #include #include int fifo_make (char const *fn, unsigned int mode) { return mknod(fn, S_IFIFO | mode, 0) ; } #endif prog/skalibs-0.47/src/libstddjb/buffer_0.c0100644000000000000000000000030110024356022015302 0ustar /* Public domain. */ /* MT-unsafe */ #include "buffer.h" static char buf[BUFFER_INSIZE] ; static buffer b = BUFFER_INIT(&buffer_unixread, 0, buf, BUFFER_INSIZE) ; buffer_ref buffer_0 = &b ; prog/skalibs-0.47/src/libstddjb/buffer_1.c0100644000000000000000000000030410024356054015313 0ustar /* Public domain. */ /* MT-unsafe */ #include "buffer.h" static char buf[BUFFER_OUTSIZE] ; static buffer b = BUFFER_INIT(&buffer_unixwrite, 1, buf, BUFFER_OUTSIZE) ; buffer_ref buffer_1 = &b ; prog/skalibs-0.47/src/libstddjb/buffer_2.c0100644000000000000000000000030410024356065015316 0ustar /* Public domain. */ /* MT-unsafe */ #include "buffer.h" static char buf[BUFFER_ERRSIZE] ; static buffer b = BUFFER_INIT(&buffer_unixwrite, 2, buf, BUFFER_ERRSIZE) ; buffer_ref buffer_2 = &b ; prog/skalibs-0.47/src/libstddjb/buffer_get.c0100644000000000000000000000051007772637721015754 0ustar /* Public domain. */ #include "buffer.h" int buffer_get (buffer_ref b, char *buf, unsigned int len) { register int r = (int)buffer_getnofill(b, buf, len) ; if (r) return r ; if (len >= b->a) return (*b->op)(b->fd, buf, len) ; r = buffer_fill(b) ; if (r <= 0) return r ; return (int)buffer_getnofill(b, buf, len) ; } prog/skalibs-0.47/src/libstddjb/buffer_put.c0100644000000000000000000000044007772636265016011 0ustar /* Public domain. */ #include "buffer.h" int buffer_put (register buffer_ref b, char const *buf, unsigned int len) { if (len > (b->a - b->n)) { buffer_clean(b) ; if ((len > (b->a - b->n)) && (buffer_flush(b) == -1)) return -1 ; } return buffer_putalign(b, buf, len) ; } prog/skalibs-0.47/src/libstddjb/buffer_read.c0100644000000000000000000000024407772631446016112 0ustar /* Public domain. */ #include "allreadwrite.h" #include "buffer.h" int buffer_unixread (int fd, char *buf, unsigned int len) { return fd_read(fd, buf, len) ; } prog/skalibs-0.47/src/libstddjb/buffer_write.c0100644000000000000000000000024607772631427016332 0ustar /* Public domain. */ #include "allreadwrite.h" #include "buffer.h" int buffer_unixwrite (int fd, char *buf, unsigned int len) { return fd_write(fd, buf, len) ; } prog/skalibs-0.47/src/libstddjb/byte_chr.c0100644000000000000000000000114607763254165015446 0ustar /* Public domain. */ #include "bytestr.h" #ifdef USE_BASE_LIBC #include unsigned int byte_chr (char const *s, unsigned int n, int c) { register void *p = memchr(s, c, n) ; return p ? (unsigned int)((char *)p - s) : n ; } #else unsigned int byte_chr (char const *s, unsigned int n, int c) { register char ch = c ; register char const *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 ; } #endif prog/skalibs-0.47/src/libstddjb/byte_copy.c0100644000000000000000000000052607762054056015641 0ustar /* Public domain. */ #include "bytestr.h" #ifdef USE_BASE_LIBC #include void byte_copy (register char *to, register unsigned int n, register char const *from) { memmove(to, from, n) ; } #else void byte_copy (register char *to, register unsigned int n, register char const *from) { while (n--) *to++ = *from++ ; } #endif prog/skalibs-0.47/src/libstddjb/byte_cr.c0100644000000000000000000000053507666446520015277 0ustar /* Public domain. */ #include "bytestr.h" void byte_copyr (register char *to, register unsigned int n, register char const *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; } } prog/skalibs-0.47/src/libstddjb/byte_diff.c0100644000000000000000000000123107762055240015565 0ustar /* Public domain. */ #include "bytestr.h" #ifdef USE_BASE_LIBC #include int byte_diff (register char const *s, register unsigned int n, register char const *t) { return memcmp(s, t, n) ; } #else int byte_diff (register char const *s, register unsigned int n, register char const *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) ; } #endif prog/skalibs-0.47/src/libstddjb/byte_rchr.c0100644000000000000000000000036107773237732015630 0ustar /* Public domain. */ #include "bytestr.h" unsigned int byte_rchr (register char const *s, unsigned int n, int c) { register unsigned int i = n ; register char ch = c ; s += n ; while (i--) if (*--s == ch) return i ; return n ; } prog/skalibs-0.47/src/libstddjb/byte_zero.c0100644000000000000000000000044107762053413015636 0ustar /* Public domain. */ #include "bytestr.h" #ifdef USE_BASE_LIBC #include void byte_zero (void *p, register unsigned int n) { memset(p, 0, n) ; } #else void byte_zero (void *p, register unsigned int n) { register char *s = (char *)p ; while (n--) *s++ = 0 ; } #endif prog/skalibs-0.47/src/libstddjb/case_diffb.c0100644000000000000000000000055707742233410015704 0ustar /* Public domain. */ #include "bytestr.h" int case_diffb (char const *s, unsigned int len, char const *t) { register unsigned char x = 0, y = 0 ; unsigned char const d = 'a' - 'A' ; while (len-- && (x == y)) { x = *s++ ; if (('a' <= x) && (x <= 'z')) x -= d ; y = *t++ ; if (('a' <= y) && (y <= 'z')) y -= d ; } return (int)(x - y) ; } prog/skalibs-0.47/src/libstddjb/case_diffs.c0100644000000000000000000000053107742233505015722 0ustar /* Public domain. */ #include "bytestr.h" int case_diffs (char const *s, char const *t) { register unsigned char x = 1, y = 1 ; unsigned char const d = 'a' - 'A' ; while (x && (x == y)) { x = *s++ ; if (('a' <= x) && (x <= 'z')) x -= d ; y = *t++ ; if (('a' <= y) && (y <= 'z')) y -= d ; } return (int)(x - y) ; } prog/skalibs-0.47/src/libstddjb/case_lowerb.c0100644000000000000000000000034507742233653016130 0ustar /* Public domain. */ #include "bytestr.h" void case_lowerb (register char *s, unsigned int len) { register unsigned char const d = 'a' - 'A' ; while (len--) { if (('A' <= *s) && (*s <= 'Z')) *s += d ; ++s ; } } prog/skalibs-0.47/src/libstddjb/lock_exnb.c0100644000000000000000000000056010054024421015563 0ustar /* Public domain. */ #include #include #include #include #include #include "sysdeps.h" #include "djbunix.h" int lock_exnb (int fd) { register int r ; do #ifdef HASFLOCK r = flock(fd, LOCK_EX | LOCK_NB) ; #else r = lockf(fd, 2, 0) ; #endif while ((r == -1) && (errno == EINTR)) ; return r ; } prog/skalibs-0.47/src/libstddjb/uint64_pack.c0100644000000000000000000000071707666446520016001 0ustar /* Public domain. */ #include "uint64.h" #include "bytestr.h" void uint64_pack (char *s, uint64 u) { ((unsigned char *)s)[0] = T8(u) ; u >>= 8 ; ((unsigned char *)s)[1] = T8(u) ; u >>= 8 ; ((unsigned char *)s)[2] = T8(u) ; u >>= 8 ; ((unsigned char *)s)[3] = T8(u) ; u >>= 8 ; ((unsigned char *)s)[4] = T8(u) ; u >>= 8 ; ((unsigned char *)s)[5] = T8(u) ; u >>= 8 ; ((unsigned char *)s)[6] = T8(u) ; u >>= 8 ; ((unsigned char *)s)[7] = T8(u) ; } prog/skalibs-0.47/src/libstddjb/coe.c0100644000000000000000000000032710041255511014370 0ustar /* Public domain. */ #include #include "djbunix.h" int coe (int fd) { register int flags = fcntl(fd, F_GETFD, 0) ; if (flags == -1) return -1 ; return fcntl(fd, F_SETFD, flags | FD_CLOEXEC) ; } prog/skalibs-0.47/src/libstddjb/iopause.c0100644000000000000000000000411207772731727015314 0ustar /* Public domain. */ #include #include "sysdeps.h" #include "tai.h" #ifndef HASPOLL # include "select.h" #endif #include "iopause.h" int iopause (iopause_fd *x, unsigned int len, struct taia const *deadline, struct taia const *stamp) { int millisecs ; int r ; if (!deadline) millisecs = -1 ; else if (taia_less(stamp, deadline)) { double d ; struct taia t ; taia_sub(&t, deadline, stamp) ; d = taia_approx(&t) ; millisecs = d * 1000.0 + 20.0 ; } else millisecs = 0 ; { register unsigned int i = 0 ; for (; i < len ; i++) x[i].revents = 0 ; } #ifdef HASPOLL do r = poll(x, len, millisecs) ; while ((r == -1) && (errno == EINTR)) ; #else { fd_set rfds, wfds, xfds ; int nfds = 1 ; struct timeval tv ; if (millisecs >= 0) { tv.tv_sec = millisecs / 1000 ; tv.tv_usec = 1000 * (millisecs % 1000) ; } FD_ZERO(&rfds) ; FD_ZERO(&wfds) ; FD_ZERO(&xfds) ; { register unsigned int i = 0 ; for (; i < len ; i++) if (x[i].fd >= 0) { /* if (x[i].fd >= (sizeof(fd_set) << 3)) continue ; */ if (x[i].fd >= nfds) nfds = x[i].fd + 1 ; if (x[i].events & IOPAUSE_READ) FD_SET(x[i].fd, &rfds) ; if (x[i].events & IOPAUSE_WRITE) FD_SET(x[i].fd, &wfds) ; if (x[i].events & IOPAUSE_EXCEPT) FD_SET(x[i].fd, &xfds) ; } } do r = select(nfds, &rfds, &wfds, &xfds, (millisecs >= 0) ? &tv : 0) ; while ((r == -1) && (errno == EINTR)) ; if (r > 0) { register unsigned int i = 0 ; for (; i < len ; i++) if (x[i].fd >= 0) { /* if (x[i].fd >= (sizeof(fd_set) << 3)) continue ; */ if ((x[i].events & IOPAUSE_READ) && FD_ISSET(x[i].fd, &rfds)) x[i].revents |= IOPAUSE_READ ; if ((x[i].events & IOPAUSE_WRITE) && FD_ISSET(x[i].fd, &wfds)) x[i].revents |= IOPAUSE_WRITE ; if ((x[i].events & IOPAUSE_EXCEPT) && FD_ISSET(x[i].fd, &xfds)) x[i].revents |= IOPAUSE_EXCEPT ; } } } #endif return r ; } prog/skalibs-0.47/src/libstddjb/deepsleep.c0100644000000000000000000000053607772716722015621 0ustar /* Public domain. */ #include "tai.h" #include "iopause.h" #include "djbunix.h" void deepsleep (unsigned int seconds) { struct taia stamp, deadline ; taia_now(&stamp) ; taia_addsec(&deadline, &stamp, seconds) ; while (taia_less(&stamp, &deadline)) { iopause_fd x ; iopause(&x, 0, &deadline, &stamp) ; taia_now(&stamp) ; } } prog/skalibs-0.47/src/libstddjb/lock_ex.c0100644000000000000000000000054410142060424015246 0ustar /* Public domain. */ #include #include #include #include #include #include "sysdeps.h" #include "djbunix.h" int lock_ex (int fd) { register int r ; do #ifdef HASFLOCK r = flock(fd, LOCK_EX) ; #else r = lockf(fd, 1, 0) ; #endif while ((r == -1) && (errno == EINTR)) ; return r ; } prog/skalibs-0.47/src/libstddjb/ip4_scan.c0100644000000000000000000000064110003730416015321 0ustar /* Public domain. */ #include "fmtscan.h" unsigned int ip4_scan (char const *s, char *ip) { register unsigned int j = 0 ; unsigned int len = 0 ; for (; j < 4 ; j++) { unsigned int u ; register unsigned int i = uint_scan(s, &u) ; if (!i) return 0 ; ip[j] = (char)u ; s += i ; len += i ; if (j == 3) break ; if (*s != '.') return 0 ; ++s ; ++len ; } return len ; } prog/skalibs-0.47/src/libstddjb/sgetopt.c0100644000000000000000000000126310024362075015314 0ustar /* Public domain. */ /* MT-unsafe */ #include "buffer.h" #include "djbunix.h" #include "sgetopt.h" int sgetopt_r (int argc, char const *const *argv, char const *opts, struct subgetopt_t *o) { char c = (char)subgetopt_r(argc, argv, opts, o) ; if (o->err && ((c == '?') || (c == ':'))) { buffer_putsalign(buffer_2, o->prog ? o->prog : basename((char *)*argv)) ; buffer_putalign(buffer_2, ": ", 2) ; buffer_putsalign(buffer_2, ((c == '?') && argv[o->ind] && (o->ind < argc)) ? "illegal option" : "option requires an argument") ; buffer_putalign(buffer_2, " -- ", 4) ; buffer_PUTC(buffer_2, c) ; buffer_putflush(buffer_2, "\n", 1) ; } return (int)c ; } prog/skalibs-0.47/src/libstddjb/EXPORT0100644000000000000000000000001407666446520014440 0ustar libstddjb.a prog/skalibs-0.47/src/libstddjb/buffer_0small.c0100644000000000000000000000032210024356032016337 0ustar /* Public domain. */ /* MT-unsafe */ #include "buffer.h" static char buf[BUFFER_INSIZE_SMALL] ; static buffer b = BUFFER_INIT(&buffer_unixread, 0, buf, BUFFER_INSIZE_SMALL) ; buffer_ref buffer_0small = &b ; prog/skalibs-0.47/src/libstddjb/buffer_1small.c0100644000000000000000000000032510024356043016345 0ustar /* Public domain. */ /* MT-unsafe */ #include "buffer.h" static char buf[BUFFER_OUTSIZE_SMALL] ; static buffer b = BUFFER_INIT(&buffer_unixwrite, 1, buf, BUFFER_OUTSIZE_SMALL) ; buffer_ref buffer_1small = &b ; prog/skalibs-0.47/src/libstddjb/lock_un.c0100644000000000000000000000047307666446520015303 0ustar /* Public domain. (you could lock, but not unlock... UNTIL TODAY !!! -- Ska) */ #include #include #include #include #include "sysdeps.h" #include "djbunix.h" int lock_un (int fd) { #ifdef HASFLOCK return flock(fd, LOCK_UN) ; #else return lockf(fd, 0, 0) ; #endif } prog/skalibs-0.47/src/libstddjb/sig_block.c0100644000000000000000000000041610005153366015562 0ustar /* Public domain. */ #include #include "sysdeps.h" #include "sig.h" void sig_block (int sig) { #ifdef HASSIGPROCMASK sigset_t ss ; sigemptyset(&ss) ; sigaddset(&ss, sig) ; sigprocmask(SIG_BLOCK, &ss, 0) ; #else sigblock(1 << (sig - 1)) ; #endif } prog/skalibs-0.47/src/libstddjb/absolutepath.c0100644000000000000000000000031010024360633016310 0ustar /* Public domain. */ /* MT-unsafe */ #include "stralloc.h" #include "skamisc.h" #include "djbunix.h" int sarealpath (stralloc *sa, char const *path) { return sarealpath_tmp(sa, path, &satmp) ; } prog/skalibs-0.47/src/libstddjb/ip4_fmt.c0100644000000000000000000000053307666446520015210 0ustar /* Public domain. */ #include "fmtscan.h" unsigned int ip4_fmt(char *s, char const *ip) { unsigned int len = 0 ; unsigned int i, j ; for (j = 0 ; j < 4 ; j++) { i = fmt_ulong(s, (unsigned long)(unsigned char) ip[j]) ; len += i ; if (s) s += i ; if (j == 3) break ; if (s) *s++ = '.' ; ++len ; } return len; } prog/skalibs-0.47/src/libstddjb/str_cpy.c0100644000000000000000000000051407762057624015330 0ustar /* Public domain. */ #include "bytestr.h" #ifdef USE_BASE_LIBC #include unsigned int str_copy (char *s, char const *t) { strcpy(s, t) ; return strlen(t) ; } #else unsigned int str_copy (char *s, char const *t) { register unsigned int len = 0 ; while ((*s = *t)) (s++, t++, len++) ; return len ; } #endif prog/skalibs-0.47/src/libstddjb/cdb_make.c0100644000000000000000000000763411051750223015361 0ustar /* Public domain. */ #include #include #include "uint32.h" #include "diuint32.h" #include "diuint32alloc.h" #include "buffer.h" #include "djbunix.h" #include "cdb.h" #include "cdb_make.h" static void cdb_make_free (struct cdb_make *c) { int e = errno ; struct cdb_make zero = CDB_MAKE_ZERO ; diuint32alloc_free(&c->hplist) ; *c = zero ; errno = e ; } int cdb_make_start (struct cdb_make *c, int fd) { diuint32alloc zero = DIUINT32ALLOC_ZERO ; c->hplist = zero ; c->fd = fd ; c->pos = 2048 ; buffer_init(&c->b, &buffer_unixwrite, fd, c->buf, BUFFER_OUTSIZE) ; return seek_set(fd, c->pos) ; } static int posplus (struct cdb_make *c, uint32 len) { register uint32 newpos = c->pos + len ; if (newpos < len) return (errno = ENOMEM, 0) ; c->pos = newpos ; return 1 ; } static int cdb_make_addend (struct cdb_make *c, unsigned int keylen, unsigned int datalen, uint32 h) { diuint32 blah = { h, c->pos } ; if (!diuint32alloc_catb(&c->hplist, &blah, 1) || !posplus(c, 8) || !posplus(c, keylen) || !posplus(c, datalen)) { cdb_make_free(c) ; return -1 ; } return 0 ; } static int cdb_make_addbegin (struct cdb_make *c, unsigned int keylen, unsigned int datalen) { char buf[8] ; if ((keylen > 0xffffffff) || (datalen > 0xffffffff)) { errno = ENOMEM ; goto err ; } uint32_pack(buf, keylen) ; uint32_pack(buf + 4, datalen) ; if (buffer_putalign(&c->b, buf, 8) == -1) goto err ; return 0 ; err: cdb_make_free(c) ; return -1 ; } int cdb_make_add (struct cdb_make *c, char const *key, unsigned int keylen, char const *data, unsigned int datalen) { if ((cdb_make_addbegin(c, keylen, datalen) == -1) || (buffer_putalign(&c->b, key, keylen) == -1) || (buffer_putalign(&c->b, data, datalen) == -1) || (cdb_make_addend(c, keylen, datalen, cdb_hash(key, keylen)) == -1)) return -1 ; return 0 ; } int cdb_make_finish (struct cdb_make *c) { uint32 count[256] ; uint32 start[256] ; char final[2048] ; diuint32alloc split = DIUINT32ALLOC_ZERO ; unsigned int n = c->hplist.len ; register unsigned int i = 0 ; register diuint32 *hp = c->hplist.s ; for ( ; i < 256 ; i++) count[i] = 0 ; for (i = 0 ; i < n ; i++) ++count[hp[i].left & 255] ; { register uint32 u = 0 ; for (i = 0 ; i < 256 ; i++) start[i] = u += count[i] ; /* bounded by n */ } { unsigned int size = 1 ; register uint32 u ; for (i = 0 ; i < 256 ; i++) { u = count[i] << 1 ; if (u > size) size = u ; } size += n ; /* no overflow possible up to now */ u = 0xffffffffUL ; u /= sizeof (diuint32) ; if (size > u) return (errno = ENOMEM, -1) ; if (!diuint32alloc_ready(&split, size)) goto err0 ; } i = n ; while (i--) split.s[--start[hp[i].left & 255]] = hp[i] ; diuint32alloc_free(&c->hplist) ; hp = split.s + n ; for (i = 0 ; i < 256 ; ++i) { char buf[8] ; register uint32 k = count[i] ; register uint32 len = k << 1 ; /* no overflow possible */ register diuint32 *p = split.s + start[i] ; register unsigned int j = 0 ; uint32_pack(final + (i << 3), c->pos) ; uint32_pack(final + (i << 3) + 4, len) ; for ( ; j < len ; j++) hp[j].left = hp[j].right = 0 ; for (j = 0 ; j < k ; j++) { register uint32 where = (p->left >> 8) % len ; while (hp[where].right) if (++where == len) where = 0 ; hp[where] = *p++ ; } for (j = 0 ; j < len ; j++) { uint32_pack(buf, hp[j].left) ; uint32_pack(buf + 4, hp[j].right) ; if (buffer_putalign(&c->b, buf, 8) == -1) goto err ; if (!posplus(c, 8)) goto err ; } } diuint32alloc_free(&split) ; if (buffer_flush(&c->b) == -1) goto err0 ; if (seek_begin(c->fd) == -1) goto err0 ; if (buffer_putflush(&c->b, final, 2048) == -1) goto err0 ; cdb_make_free(c) ; return 0 ; err: { int e = errno ; diuint32alloc_free(&split) ; errno = e ; } err0: cdb_make_free(c) ; return -1 ; } prog/skalibs-0.47/src/libstddjb/subgetopt.c0100644000000000000000000000234607755216551015664 0ustar /* Public domain. */ #define SUBGETOPTNOSHORT #include "sgetopt.h" int subgetopt_r (int argc, char const *const *argv, char const *opts, struct subgetopt_t *o) { o->arg = 0 ; if ((o->ind >= argc) || !argv[o->ind]) return -1 ; if (o->pos && !argv[o->ind][o->pos]) { o->ind++ ; o->pos = 0 ; if ((o->ind >= argc) || !argv[o->ind]) return -1 ; } if (!o->pos) { if (argv[o->ind][0] != '-') return -1 ; else { char c ; o->pos++ ; c = argv[o->ind][1] ; if (c == '-') o->ind++ ; if (!c || (c == '-')) { o->pos = 0 ; return -1 ; } } } { char c = argv[o->ind][o->pos++] ; char const *s = opts ; char retnoarg = (*s == ':') ? (s++, ':') : '?' ; while (*s) { if (c == *s) { if (s[1] == ':') { o->arg = argv[o->ind++] + o->pos ; o->pos = 0 ; if (!*o->arg) { o->arg = argv[o->ind] ; if ((o->ind >= argc) || !o->arg) { o->problem = c ; return retnoarg ; } o->ind++ ; } } return c ; } if (*++s == ':') s++ ; } o->problem = c ; } return '?' ; } prog/skalibs-0.47/src/libstddjb/timestamp.c0100644000000000000000000000020707677444625015655 0ustar /* Public domain. */ #include "tai.h" void timestamp (char *s) { struct taia now ; taia_now(&now) ; timestamp_fmt(s, &now) ; } prog/skalibs-0.47/src/libstddjb/sig_catch.c0100644000000000000000000000032210024362237015546 0ustar /* Public domain. */ /* MT-unsafe */ #include "sig.h" int sig_catch (int sig, skasighandler_t_ref f) { struct skasigaction ssa = { f, SKASA_MASKALL | SKASA_NOCLDSTOP } ; return sig_catcha(sig, &ssa) ; } prog/skalibs-0.47/src/libstddjb/wait_pid.c0100644000000000000000000000265411051747547015450 0ustar /* Public domain. */ /* MT-unsafe if not HASWAITPID */ #include #include #include #include "sysdeps.h" #include "djbunix.h" #ifdef HASWAITPID int wait_nohang (int *wstat) { register int r ; do r = waitpid(-1, wstat, WNOHANG) ; while ((r == -1) && (errno == EINTR)) ; return r ; } int wait_pid (int *wstat, int pid) { register int r ; do r = waitpid(pid, wstat, 0) ; while ((r == -1) && (errno == EINTR)) ; return r ; } #else #include "diuint.h" #include "diuintalloc.h" static diuintalloc zombies = DIUINTALLOC_ZERO ; int wait_nohang (int *wstat) { if (!zombies.len) return wait3(wstat, WNOHANG, 0) ; *wstat = zombies.s[--zombies.len].right ; return (int)zombies.s[zombies.len].left ; } int wait_pid (int *wstat, int pid) { int r ; { register unsigned int i = 0 ; for (; i < zombies.len ; i++) { if ((unsigned int)pid == zombies.s[i].left) { *wstat = (int)zombies.s[i].right ; if (--zombies.len) zombies.s[i] = zombies.s[zombies.len] ; return pid ; } } } for (;;) { int w ; r = wait(&w) ; if (r == pid) { *wstat = w ; break ; } else if (r == -1) if (errno == EINTR) continue ; else break ; else { diuint blah = { (unsigned int)r, (unsigned int)w } ; if (!diuintalloc_catb(&zombies, &blah, 1)) return -1 ; } } return r ; } #endif prog/skalibs-0.47/src/libstddjb/sig_pause.c0100644000000000000000000000032310005153516015577 0ustar /* Public domain. */ #include #include "sysdeps.h" #include "sig.h" void sig_pause () { #ifdef HASSIGPROCMASK sigset_t ss ; sigemptyset(&ss) ; sigsuspend(&ss) ; #else sigpause(0) ; #endif } prog/skalibs-0.47/src/libstddjb/uint64_unpack.c0100644000000000000000000000072107666446520016337 0ustar /* Public domain. */ #include "uint64.h" #include "bytestr.h" void uint64_unpack (char const *s, uint64 *u) { uint64 r = T8((unsigned char)s[7]) ; r <<= 8 ; r += T8((unsigned char)s[6]) ; r <<= 8 ; r += T8((unsigned char)s[5]) ; r <<= 8 ; r += T8((unsigned char)s[4]) ; r <<= 8 ; r += T8((unsigned char)s[3]) ; r <<= 8 ; r += T8((unsigned char)s[2]) ; r <<= 8 ; r += T8((unsigned char)s[1]) ; r <<= 8 ; r += T8((unsigned char)s[0]) ; *u = r ; } prog/skalibs-0.47/src/libstddjb/skagetln.c0100644000000000000000000000127611052254120015434 0ustar /* Public domain. */ #include #include "bytestr.h" #include "buffer.h" #include "stralloc.h" #include "skamisc.h" int skagetln (buffer_ref b, stralloc *sa, int sep) { unsigned int len = sa->len ; int ok = 1 ; for (;;) { char *s = buffer_PEEK(b) ; unsigned int pos = byte_chr(s, buffer_len(b), sep) ; int r = (pos < buffer_len(b)) ; if (!stralloc_catb(sa, s, pos)) return -1 ; buffer_SEEK(b, pos) ; if (r) { if (!stralloc_catb(sa, buffer_PEEK(b), 1)) return -1 ; buffer_SEEK(b, 1) ; return ok ; } r = buffer_fill(b) ; if (r == -1) return -1 ; if (!r) return (sa->len > len) ? (errno = EPIPE, -1) : 0 ; ok = 2 ; } } prog/skalibs-0.47/src/libstddjb/alloc.h0100644000000000000000000000127210554071552014733 0ustar /* Public domain. */ #ifndef ALLOC_H #define ALLOC_H #include "gccattributes.h" typedef char aligned_char gccattr_aligned ; typedef aligned_char *aligned_char_ref, **aligned_char_ref_ref ; #ifdef USE_DJBALLOC #define alloc djb_alloc #define alloc_free djb_alloc_free #define alloc_re djb_alloc_re #define alloc_realloc djb_alloc_realloc #else #define alloc ska_alloc #define alloc_free ska_alloc_free #define alloc_re ska_alloc_re #define alloc_realloc ska_alloc_realloc #endif extern aligned_char_ref alloc (unsigned int) gccattr_malloc ; extern void alloc_free (void *) ; extern int alloc_re (void **, unsigned int, unsigned int) ; extern int alloc_realloc (void **, unsigned int) ; #endif prog/skalibs-0.47/src/libstddjb/error.c0100644000000000000000000000302507772655117015000 0ustar /* Public domain. */ #include #include "error.h" /* Warning: this file is deprecated. It will disappear in some future release. */ int error_ok = 0 ; 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 int error_proto = #ifdef EPROTO EPROTO; #else -15; #endif int error_isdir = #ifdef EISDIR EISDIR; #else -16; #endif int error_connrefused = #ifdef ECONNREFUSED ECONNREFUSED; #else -17; #endif int error_notdir = #ifdef ENOTDIR ENOTDIR; #else -18; #endif int error_badf = #ifdef EBADF EBADF; #else -19; #endif int error_notsock = #ifdef ENOTSOCK ENOTSOCK; #else -20; #endif int error_inval = #ifdef EINVAL EINVAL; #else -22; #endif int error_dom = #ifdef EDOM EDOM; #else -33; #endif int error_nobufs = #ifdef ENOBUFS ENOBUFS; #else -55; #endif prog/skalibs-0.47/src/libstddjb/error_str.c0100644000000000000000000001323707773135034015666 0ustar /* Public domain. */ #include "error.h" #ifdef USE_BASE_LIBC #include char const *error_str (register int i) { return (char const *)strerror(i) ; } #else #include #define X(e, s) case e : return s ; #define Y(e, s) if (i == e) return s ; char const *error_str (register int i) { Y(EWOULDBLOCK, "input/output would block") Y(EAGAIN, "temporary failure") Y(EINVAL, "invalid argument") switch (i) { X(0, "no error") X(EINTR, "interrupted system call") X(ENOMEM, "out of memory") X(ENOENT, "file does not exist") X(ETXTBSY, "text busy") X(EIO, "input/output error") X(EEXIST, "file already exists") X(ETIMEDOUT, "timed out") X(EINPROGRESS, "operation in progress") X(EPIPE, "broken pipe") X(EPERM, "permission denied") X(EACCES, "access denied") X(ENODEV, "device not configured") X(EPROTO, "protocol error") X(EISDIR, "is a directory") X(ECONNREFUSED, "connection refused") X(ENOTDIR, "not a directory") X(ENOTSOCK, "not a socket") X(EDOM, "input out of range") X(ENOBUFS, "out of buffer space") #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 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 ERANGE X(ERANGE, "output out of range") #endif #ifdef EALREADY X(EALREADY, "operation already in progress") #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 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 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 EMULTIHOP X(EMULTIHOP, "multihop attempted") #endif #ifdef EREMCHG X(EREMCHG, "remote address changed") #endif default : return "unknown error" ; } } #endif /* USE_BASE_LIBC */ prog/skalibs-0.47/src/libstddjb/fd_copy.c0100644000000000000000000000041607772725140015265 0ustar /* Public domain. */ #include #include #include "djbunix.h" int fd_copy (int to, int from) { register int r ; if (to == from) return (errno = EINVAL, -1) ; do r = dup2(from, to) ; while ((r == -1) && (errno == EINTR)) ; return r ; } prog/skalibs-0.47/src/libstddjb/fd_move.c0100644000000000000000000000043107772725257015267 0ustar /* Public domain. */ #include #include #include "djbunix.h" int fd_move (int to, int from) { register int r ; if (to == from) return 0 ; do r = dup2(from, to) ; while ((r == -1) && (errno == EINTR)) ; return (r == -1) ? -1 : fd_close(from) ; } prog/skalibs-0.47/src/libstddjb/netstring_append.c0100644000000000000000000000074307666446520017215 0ustar /* Public domain. */ #include "bytestr.h" #include "fmtscan.h" #include "stralloc.h" #include "netstring.h" int netstring_appendb (stralloc *sa, char const *s, unsigned int len) { char fmt[FMT_ULONG] ; unsigned int n = fmt_uint(fmt, len) ; if (!stralloc_readyplus(sa, len + n + 2)) return 0 ; fmt[n] = ':' ; byte_copy(sa->s + sa->len, n+1, fmt) ; byte_copy(sa->s + sa->len + n+1, len, s) ; sa->s[sa->len + n+1 + len] = ',' ; sa->len += n + 2 + len ; return 1 ; } prog/skalibs-0.47/src/libstddjb/uint_scan.c0100644000000000000000000000020210003730416015575 0ustar /* Public domain. */ #include #include "fmtscan.h" #include "fmtscan-internal.h" SCANU(uint, unsigned int, UINT_MAX) prog/skalibs-0.47/src/libstddjb/cdb_hash.c0100644000000000000000000000044210003245112015345 0ustar /* Public domain. */ #include "uint32.h" #include "cdb.h" uint32 cdb_hashadd (uint32 h, unsigned char c) { h += (h << 5) ; return h ^ c ; } uint32 cdb_hash (char const *buf, unsigned int len) { uint32 h = CDB_HASHSTART ; while (len--) h = cdb_hashadd(h, *buf++) ; return h ; } prog/skalibs-0.47/src/libstddjb/fmtscan.h0100644000000000000000000001664311100046312015264 0ustar /* Public domain. */ #ifndef FMTSCAN_H #define FMTSCAN_H #include "gccattributes.h" #include "uint64.h" /* fmt */ extern unsigned char fmtscan_asc (unsigned char) gccattr_const ; extern unsigned int str_fmt (char *, char const *) ; extern unsigned int strn_fmt (char *, char const *, unsigned int) ; #define IP4_FMT 20 extern unsigned int ip4_fmt (char *, char const *) ; extern unsigned int ucharn_fmt (char *, char const *, unsigned int) ; extern unsigned int ucharn_fmt_little (char *, char const *, unsigned int) ; #define USHORT_FMT UINT64_FMT #define USHORT_OFMT UINT64_OFMT #define USHORT_XFMT UINT64_XFMT #define USHORT_BFMT UINT64_BFMT #define UINT_FMT UINT64_FMT #define UINT_OFMT UINT64_OFMT #define UINT_XFMT UINT64_XFMT #define UINT_BFMT UINT64_BFMT #define ULONG_FMT UINT64_FMT #define ULONG_OFMT UINT64_OFMT #define ULONG_XFMT UINT64_XFMT #define ULONG_BFMT UINT64_BFMT #define short_fmt(s, u) long_fmt((s), (long)(short)(u)) #define int_fmt(s, u) long_fmt((s), (long)(int)(u)) extern unsigned int long_fmt (char *, long) ; #define ushort_fmt_base(s, u, b) uint64_fmt_base((s), (uint64)(unsigned short)(u), (b)) #define ushort0_fmt_base(s, u, n, b) uint640_fmt_base((s), (uint64)(unsigned short)(u), (n), (b)) #define ushort_fmt(s, u) ushort_fmt_base((s), (u), 10) #define ushort0_fmt(s, u, n) ushort0_fmt_base((s), (u), (n), 10) #define ushort_ofmt(s, u) ushort_fmt_base((s), (u), 8) #define ushort0_ofmt(s, u, n) ushort0_fmt_base((s), (u), (n), 8) #define ushort_xfmt(s, u) ushort_fmt_base((s), (u), 16) #define ushort0_xfmt(s, u, n) ushort0_fmt_base((s), (u), (n), 16) #define ushort_bfmt(s, u) ushort_fmt_base((s), (u), 2) #define ushort0_bfmt(s, u, n) ushort0_fmt_base((s), (u), (n), 2) #define uint_fmt_base(s, u, b) uint64_fmt_base((s), (uint64)(unsigned int)(u), (b)) #define uint0_fmt_base(s, u, n, b) uint640_fmt_base((s), (uint64)(unsigned int)(u), (n), (b)) #define uint_fmt(s, u) uint_fmt_base((s), (u), 10) #define uint0_fmt(s, u, n) uint0_fmt_base((s), (u), (n), 10) #define uint_ofmt(s, u) uint_fmt_base((s), (u), 8) #define uint0_ofmt(s, u, n) uint0_fmt_base((s), (u), (n), 8) #define uint_xfmt(s, u) uint_fmt_base((s), (u), 16) #define uint0_xfmt(s, u, n) uint0_fmt_base((s), (u), (n), 16) #define uint_bfmt(s, u) uint_fmt_base((s), (u), 2) #define uint0_bfmt(s, u, n) uint0_fmt_base((s), (u), (n), 2) #define ulong_fmt_base(s, u, b) uint64_fmt_base((s), (uint64)(unsigned long)(u), (b)) #define ulong0_fmt_base(s, u, n, b) uint640_fmt_base((s), (uint64)(unsigned long)(u), (n), (b)) #define ulong_fmt(s, u) ulong_fmt_base((s), (u), 10) #define ulong0_fmt(s, u, n) ulong0_fmt_base((s), (u), (n), 10) #define ulong_ofmt(s, u) ulong_fmt_base((s), (u), 8) #define ulong0_ofmt(s, u, n) ulong0_fmt_base((s), (u), (n), 8) #define ulong_xfmt(s, u) ulong_fmt_base((s), (u), 16) #define ulong0_xfmt(s, u, n) ulong0_fmt_base((s), (u), (n), 16) #define ulong_bfmt(s, u) ulong_fmt_base((s), (u), 2) #define ulong0_bfmt(s, u, n) ulong0_fmt_base((s), (u), (n), 2) /* Old compatibility. Please upgrade ! */ #define FMT_ULONG ULONG_FMT #define FMT_LEN ((char *) 0) #define fmt_str str_fmt #define fmt_strn strn_fmt #define fmt_ucharn ucharn_fmt #define fmt_short(s, u) long_fmt((s), (long)(short)(u)) #define fmt_int(s, u) long_fmt((s), (long)(int)(u)) #define fmt_long(s, u) long_fmt((s), (u)) #define fmt_ushort(s, u) ushort_fmt_base((s), (u), 10) #define oshort_fmt(s, u) ushort_fmt_base((s), (u), 8) #define fmt_oshort(s, u) ushort_fmt_base((s), (u), 8) #define xshort_fmt(s, u) ushort_fmt_base((s), (u), 16) #define fmt_xshort(s, u) ushort_fmt_base((s), (u), 16) #define fmt_uint(s, u) uint_fmt_base((s), (u), 10) #define oint_fmt(s, u) uint_fmt_base((s), (u), 8) #define fmt_oint(s, u) uint_fmt_base((s), (u), 8) #define xint_fmt(s, u) uint_fmt_base((s), (u), 16) #define fmt_xint(s, u) uint_fmt_base((s), (u), 16) #define fmt_ulong(s, u) ulong_fmt_base((s), (u), 10) #define olong_fmt(s, u) ulong_fmt_base((s), (u), 8) #define fmt_olong(s, u) ulong_fmt_base((s), (u), 8) #define xlong_fmt(s, u) ulong_fmt_base((s), (u), 16) #define fmt_xlong(s, u) ulong_fmt_base((s), (u), 16) /* scan */ extern unsigned char fmtscan_num (unsigned char, unsigned char) gccattr_const ; extern unsigned int ip4_scan (char const *, char *) ; extern unsigned int ucharn_scan (char const *, char *, unsigned int) ; extern unsigned int ucharn_scan_little (char const *, char *, unsigned int) ; extern unsigned int ucharn_findlen (char const *) gccattr_pure ; extern unsigned int short_scan (char const *, short *) ; extern unsigned int int_scan (char const *, int *) ; extern unsigned int long_scan (char const *, long *) ; extern unsigned int ushort_scan_base (char const *, unsigned short *, unsigned char) ; extern unsigned int ushort0_scan_base (char const *, unsigned short *, unsigned char) ; #define ushort_scan(s, u) ushort_scan_base((s), (u), 10) #define ushort0_scan(s, u) ushort0_scan_base((s), (u), 10) #define ushort_oscan(s, u) ushort_scan_base((s), (u), 8) #define ushort0_oscan(s, u) ushort0_scan_base((s), (u), 8) #define ushort_xscan(s, u) ushort_scan_base((s), (u), 16) #define ushort0_xscan(s, u) ushort0_scan_base((s), (u), 16) #define ushort_bscan(s, u) ushort_scan_base((s), (u), 2) #define ushort0_bscan(s, u) ushort0_scan_base((s), (u), 2) extern unsigned int uint_scan_base (char const *, unsigned int *, unsigned char) ; extern unsigned int uint0_scan_base (char const *, unsigned int *, unsigned char) ; #define uint_scan(s, u) uint_scan_base((s), (u), 10) #define uint0_scan(s, u) uint0_scan_base((s), (u), 10) #define uint_oscan(s, u) uint_scan_base((s), (u), 8) #define uint0_oscan(s, u) uint0_scan_base((s), (u), 8) #define uint_xscan(s, u) uint_scan_base((s), (u), 16) #define uint0_xscan(s, u) uint0_scan_base((s), (u), 16) #define uint_bscan(s, u) uint_scan_base((s), (u), 2) #define uint0_bscan(s, u) uint0_scan_base((s), (u), 2) extern unsigned int ulong_scan_base (char const *, unsigned long *, unsigned char) ; extern unsigned int ulong0_scan_base (char const *, unsigned long *, unsigned char) ; #define ulong_scan(s, u) ulong_scan_base((s), (u), 10) #define ulong0_scan(s, u) ulong0_scan_base((s), (u), 10) #define ulong_oscan(s, u) ulong_scan_base((s), (u), 8) #define ulong0_oscan(s, u) ulong0_scan_base((s), (u), 8) #define ulong_xscan(s, u) ulong_scan_base((s), (u), 16) #define ulong0_xscan(s, u) ulong0_scan_base((s), (u), 16) #define ulong_bscan(s, u) ulong_scan_base((s), (u), 2) #define ulong0_bscan(s, u) ulong0_scan_base((s), (u), 2) /* Old compatibility. Please upgrade ! */ #define scan_ucharn ucharn_scan #define scan_short short_scan #define scan_int int_scan #define scan_long long_scan #define scan_ushort(s, u) ushort_scan((s), (u)) #define scan_ushort0(s, u) ushort0_scan((s), (u)) #define oshort_scan(s, o) ushort_oscan((s), (o)) #define scan_oshort(s, o) ushort_oscan((s), (o)) #define xshort_scan(s, x) ushort_xscan((s), (x)) #define scan_xshort(s, x) ushort_xscan((s), (x)) #define scan_uint(s, u) uint_scan((s), (u)) #define scan_uint0(s, u) uint0_scan((s), (u)) #define oint_scan(s, o) uint_oscan((s), (o)) #define scan_oint(s, o) uint_oscan((s), (o)) #define xint_scan(s, x) uint_xscan((s), (x)) #define scan_xint(s, x) uint_xscan((s), (x)) #define scan_ulong(s, u) ulong_scan((s), (u)) #define scan_ulong0(s, u) ulong0_scan((s), (u)) #define olong_scan(s, o) ulong_oscan((s), (o)) #define scan_olong(s, o) ulong_oscan((s), (o)) #define xlong_scan(s, x) ulong_xscan((s), (x)) #define scan_xlong(s, x) ulong_xscan((s), (x)) #define scan_8long(s, o) ulong_oscan((s), (o)) #endif prog/skalibs-0.47/src/libstddjb/str_fmt.c0100644000000000000000000000024210003752766015310 0ustar /* Public domain. */ #include "bytestr.h" #include "fmtscan.h" unsigned int str_fmt (register char *d, char const *s) { return strn_fmt(d, s, str_len(s)) ; } prog/skalibs-0.47/src/libstddjb/uint32_unpack.c0100644000000000000000000000044507666446520016335 0ustar /* Public domain. */ #include "uint32.h" #include "bytestr.h" void uint32_unpack (char const *s, uint32 *u) { uint32 r = T8((unsigned char)s[3]) ; r <<= 8 ; r += T8((unsigned char)s[2]) ; r <<= 8 ; r += T8((unsigned char)s[1]) ; r <<= 8 ; r += T8((unsigned char)s[0]) ; *u = r ; } prog/skalibs-0.47/src/libstddjb/stralloc_sert.c0100644000000000000000000000027307666446520016527 0ustar /* Public domain. */ #include "stralloc.h" int stralloc_insert (stralloc *to, unsigned int offset, stralloc const *from) { return stralloc_insertb(to, offset, from->s, from->len) ; } prog/skalibs-0.47/src/libstddjb/netstring_get.c0100644000000000000000000000235107772655313016522 0ustar /* Public domain. */ #include #include "bytestr.h" #include "fmtscan.h" #include "buffer.h" #include "stralloc.h" #include "netstring.h" int netstring_get (buffer_ref b, stralloc *sa, unsigned int *unread) { unsigned int written ; int ok = 1 ; int r ; if (!sa->s || (!sa->len && !*unread)) { char *x ; unsigned int n ; unsigned int len ; for (;;) { x = buffer_PEEK(b) ; n = byte_chr(x, buffer_len(b), ':') ; /* XXX: accepts :, as a valid netstring */ if (n >= FMT_ULONG) return (errno = EINVAL, -1) ; if (n < buffer_len(b)) break ; r = buffer_fill(b) ; if (r == -1) return -1 ; if (!r) return (buffer_isempty(b) ? 0 : (errno = EPIPE, -1)) ; ok = 2 ; } if (n != scan_uint(x, &len)) return (errno = EINVAL, -1) ; if (!stralloc_ready(sa, len+1)) return -1 ; buffer_SEEK(b, n+1) ; *unread = len + 1 ; } written = sa->len ; r = buffer_getall(b, sa->s + sa->len, sa->len + *unread, &written) ; if (r <= 0) { *unread -= written - sa->len ; sa->len = written ; return r ? r : (errno = EINVAL, -1) ; } if (r == 2) ok = 2 ; sa->len += *unread ; *unread = 0 ; return (sa->s[--sa->len] == ',') ? ok : (errno = EINVAL, -1) ; } prog/skalibs-0.47/src/libstddjb/slurp.c0100644000000000000000000000100607772664452015013 0ustar /* Public domain. */ #include "allreadwrite.h" #include "stralloc.h" #include "djbunix.h" #define N 4096 int slurp (stralloc *sa, int fd) { register unsigned int salen = sa->len ; for (;;) { int r ; if (!stralloc_readyplus(sa, N)) break ; r = fd_read(fd, sa->s + sa->len, N) ; switch (r) { case -1: goto err ; case 0: stralloc_clean(sa) ; return 1 ; default: sa->len += r ; } } err: sa->len = salen ; stralloc_clean(sa) ; return 0 ; } prog/skalibs-0.47/src/libstddjb/open_readb.c0100644000000000000000000000034507773144752015746 0ustar /* Public domain. */ #include "djbunix.h" int open_readb (char const *fn) { register int fd = open_read(fn) ; if (fd == -1) return -1 ; if (ndelay_off(fd) == -1) { fd_close(fd) ; return -1 ; } return fd ; } prog/skalibs-0.47/src/libstddjb/uint32_pack.c0100644000000000000000000000042707666446520015772 0ustar /* Public domain. */ #include "uint32.h" #include "bytestr.h" void uint32_pack (char *s, uint32 u) { ((unsigned char *)s)[0] = T8(u) ; u >>= 8 ; ((unsigned char *)s)[1] = T8(u) ; u >>= 8 ; ((unsigned char *)s)[2] = T8(u) ; u >>= 8 ; ((unsigned char *)s)[3] = T8(u) ; } prog/skalibs-0.47/src/libstddjb/netstring_put.c0100644000000000000000000000155207772655203016553 0ustar /* Public domain. */ #include #include "fmtscan.h" #include "buffer.h" #include "netstring.h" int netstring_put (buffer_ref b, char const *s, unsigned int len, unsigned int *written) { char fmt[FMT_ULONG] ; unsigned int n = fmt_uint(fmt, len) ; if (*written > len + n + 2) return (errno = EINVAL, -1) ; fmt[n] = ':' ; if (*written < n + 1) { unsigned int w = *written ; int r = buffer_putall(b, fmt, n+1, &w) ; if (r == -1) return (*written = w, -1) ; *written = n+1 ; } if (*written < n+1 + len) { unsigned int w = *written - (n+1) ; int r = buffer_putall(b, s, len, &w) ; *written = w + (n+1) ; if (r == -1) return (*written = n+1 + w, -1) ; *written = n+1 + len ; } { unsigned int w = 0 ; int r = buffer_putall(b, ",", 1, &w) ; if (r == -1) return -1 ; } *written = 0 ; return 0 ; } prog/skalibs-0.47/src/libstddjb/buffer_peek.c0100644000000000000000000000016007772640722016115 0ustar /* Public domain. */ #include "buffer.h" char *buffer_peek (register buffer_ref b) { return b->x + b->p ; } prog/skalibs-0.47/src/libstddjb/bufalloc_1.c0100644000000000000000000000025110024355661015635 0ustar /* Public domain. */ /* MT-unsafe */ #include "allreadwrite.h" #include "bufalloc.h" static bufalloc b = BUFALLOC_INIT(&fd_write, 1) ; bufalloc_ref bufalloc_1 = &b ; prog/skalibs-0.47/src/libstddjb/buffer_unget.c0100644000000000000000000000032410007425161016274 0ustar /* Public domain. */ #include #include "buffer.h" int buffer_unget (register buffer_ref b, register unsigned int len) { if (b->p < len) return (errno = ENOBUFS, -1) ; b->p -= len ; return 0 ; } prog/skalibs-0.47/src/libstddjb/buffer_unput.c0100644000000000000000000000033410007426471016333 0ustar /* Public domain. */ #include #include "buffer.h" int buffer_unput (register buffer_ref b, register unsigned int len) { if (len > (b->n - b->p)) return (errno = ESPIPE, -1) ; b->n -= len ; return 0 ; } prog/skalibs-0.47/src/libstddjb/rm_rf.c0100644000000000000000000000023610024361264014732 0ustar /* Public domain. */ /* MT-unsafe */ #include "skamisc.h" #include "djbunix.h" int rm_rf (char const *filename) { return rm_rf_tmp(filename, &satmp) ; } prog/skalibs-0.47/src/libstddjb/cdb.c0100644000000000000000000000522310003253056014352 0ustar /* Public domain. */ #include #include #include #include #include #include "uint32.h" #include "allreadwrite.h" #include "bytestr.h" #include "djbunix.h" #include "error.h" #include "cdb.h" void cdb_free (struct cdb *c) { if (c->map) { munmap(c->map, c->size) ; c->map = 0 ; } } void cdb_findstart (struct cdb *c) { c->loop = 0 ; } int cdb_init (struct cdb *c, int fd) { struct stat st ; cdb_free(c) ; cdb_findstart(c) ; c->fd = fd ; if (fstat(fd, &st) == 0) { char *x = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0) ; if (x != MAP_FAILED) { c->size = st.st_size ; c->map = x ; return 0 ; } } return -1 ; } int cdb_read (struct cdb *c, char *buf, unsigned int len, uint32 pos) { if (c->map) { if ((pos > c->size) || (c->size - pos < len)) return (errno = EPROTO, -1) ; byte_copy(buf, len, c->map + pos) ; return 0 ; } else if (seek_set(c->fd, pos) == -1) return -1 ; else { register int r = allread(c->fd, buf, len) ; return (r == -1) ? -1 : ((unsigned int)r < len) ? (errno = EPROTO, -1) : 0 ; } } static int match (struct cdb *c, char const *key, unsigned int len, uint32 pos) { char buf[1024] ; while (len > 0) { register unsigned int n = 1024 ; if (n > len) n = len ; if (cdb_read(c, buf, n, pos) == -1) return -1 ; if (byte_diff(buf, n, key)) return 0 ; pos += n ; key += n ; len -= n ; } return 1 ; } int cdb_findnext (struct cdb *c, char const *key, unsigned int len) { char buf[8] ; uint32 pos ; uint32 u ; if (!c->loop) { u = cdb_hash(key, len) ; if (cdb_read(c, buf, 8, (u << 3) & 2047) == -1) return -1 ; uint32_unpack(buf + 4, &c->hslots) ; if (!c->hslots) return 0 ; uint32_unpack(buf, &c->hpos) ; c->khash = u ; u >>= 8 ; u %= c->hslots ; u <<= 3 ; c->kpos = c->hpos + u ; } while (c->loop < c->hslots) { if (cdb_read(c, buf, 8, c->kpos) == -1) return -1 ; uint32_unpack(buf + 4, &pos) ; if (!pos) return 0 ; c->loop++ ; c->kpos += 8 ; if (c->kpos == c->hpos + (c->hslots << 3)) c->kpos = c->hpos ; uint32_unpack(buf, &u) ; if (u == c->khash) { if (cdb_read(c, buf, 8, pos) == -1) return -1 ; uint32_unpack(buf, &u) ; if (u == len) switch (match(c, key, len, pos + 8)) { case -1: return -1 ; case 1: uint32_unpack(buf + 4, &c->dlen) ; c->dpos = pos + 8 + len ; return 1 ; } } } return 0 ; } int cdb_find (struct cdb *c, char const *key, unsigned int len) { cdb_findstart(c) ; return cdb_findnext(c, key, len) ; } prog/skalibs-0.47/src/libstddjb/allread.c0100644000000000000000000000024010006715532015225 0ustar /* Public domain. */ #include "allreadwrite.h" unsigned int allread (int fd, char *buf, unsigned int len) { return allreadwrite(&fd_read, fd, buf, len) ; } prog/skalibs-0.47/src/libstddjb/bufalloc_2.c0100644000000000000000000000025110024355706015636 0ustar /* Public domain. */ /* MT-unsafe */ #include "allreadwrite.h" #include "bufalloc.h" static bufalloc b = BUFALLOC_INIT(&fd_write, 2) ; bufalloc_ref bufalloc_2 = &b ; prog/skalibs-0.47/src/libstddjb/ndelay_off.c0100644000000000000000000000042710041255577015745 0ustar /* Public domain. */ #include #include #include "djbunix.h" #ifndef O_NONBLOCK #define O_NONBLOCK O_NDELAY #endif int ndelay_off (int fd) { register int got = fcntl(fd, F_GETFL) ; return (got == -1) ? -1 : fcntl(fd, F_SETFL, got & ~O_NONBLOCK) ; } prog/skalibs-0.47/src/libstddjb/ndelay_on.c0100644000000000000000000000042510041255567015604 0ustar /* Public domain. */ #include #include #include "djbunix.h" #ifndef O_NONBLOCK #define O_NONBLOCK O_NDELAY #endif int ndelay_on (int fd) { register int got = fcntl(fd, F_GETFL) ; return (got == -1) ? -1 : fcntl(fd, F_SETFL, got | O_NONBLOCK) ; } prog/skalibs-0.47/src/libstddjb/open_append.c0100644000000000000000000000030007772756734016137 0ustar /* Public domain. */ #include #include #include "djbunix.h" int open_append (char const *fn) { return open3(fn, O_WRONLY | O_NDELAY | O_APPEND | O_CREAT, 0666) ; } prog/skalibs-0.47/src/libstddjb/open_read.c0100644000000000000000000000024307772756565015613 0ustar /* Public domain. */ #include #include #include "djbunix.h" int open_read (char const *fn) { return open2(fn, O_RDONLY | O_NDELAY) ; } prog/skalibs-0.47/src/libstddjb/open_trunc.c0100644000000000000000000000027607772756635016037 0ustar /* Public domain. */ #include #include #include "djbunix.h" int open_trunc (char const *fn) { return open3(fn, O_WRONLY | O_NDELAY | O_TRUNC | O_CREAT, 0666) ; } prog/skalibs-0.47/src/libstddjb/open_write.c0100644000000000000000000000024407772756661016030 0ustar /* Public domain. */ #include #include #include "djbunix.h" int open_write (char const *fn) { return open2(fn, O_WRONLY | O_NDELAY) ; } prog/skalibs-0.47/src/libstddjb/openreadclose.c0100644000000000000000000000061610024346535016456 0ustar /* Public domain. */ #include #include "stralloc.h" #include "djbunix.h" int openreadclose (char const *fn, stralloc *sa, unsigned int bufsize) { int fd = open_readb(fn) ; if (fd == -1) return (errno == ENOENT) ? 0 : -1 ; if (!slurp(sa, fd)) { register int e = errno ; fd_close(fd) ; errno = e ; return -1 ; } fd_close(fd) ; (void)bufsize ; return 1 ; } prog/skalibs-0.47/src/libstddjb/pathexec0.c0100644000000000000000000000025410024357046015511 0ustar /* Public domain. */ /* MT-unsafe */ #include #include "djbunix.h" void pathexec0 (char const *const *argv) { if (!argv[0]) _exit(0) ; pathexec(argv) ; } prog/skalibs-0.47/src/libstddjb/str_strn.c0100644000000000000000000000063607762063441015522 0ustar /* Public domain. */ #include "bytestr.h" /* Very naive implementation, but it's small. */ unsigned int str_strn (char const *haystack, unsigned int hlen, char const *needle, unsigned int nlen) { register unsigned int i = 0 ; if (!nlen) return 0 ; if (hlen < nlen) return hlen+1 ; hlen -= nlen ; for (; i < hlen ; i++) if (!str_diffn(haystack+i, needle, nlen)) return i ; return hlen+nlen+1 ; } prog/skalibs-0.47/src/libstddjb/satmp.c0100644000000000000000000000014311051747624014757 0ustar /* Public domain. */ #include "stralloc.h" #include "skamisc.h" stralloc satmp = STRALLOC_ZERO ; prog/skalibs-0.47/src/libstddjb/ulong_scan.c0100644000000000000000000000020510003730416015745 0ustar /* Public domain. */ #include #include "fmtscan.h" #include "fmtscan-internal.h" SCANU(ulong, unsigned long, ULONG_MAX) prog/skalibs-0.47/src/libstddjb/ucharn_scan.c0100644000000000000000000000057010325103044016104 0ustar /* Public domain. */ #include "fmtscan.h" unsigned int ucharn_scan (char const *s, char *key, unsigned int n) { register unsigned int i = 0 ; for (; i < n ; i++) { unsigned char c = fmtscan_num(s[2*i], 16) ; if (c > 0xF) return 0 ; key[i] = c << 4 ; c = fmtscan_num(s[2*i+1], 16) ; if (c > 0xF) return 0 ; key[i] += c ; } return n << 1 ; } prog/skalibs-0.47/src/libstddjb/ucharn_fmt.c0100644000000000000000000000047010324523503015752 0ustar /* Public domain. */ #include "fmtscan.h" unsigned int ucharn_fmt (char *s, char const *key, unsigned int n) { register unsigned int i = 0 ; for (; i < n ; i++) { s[i<<1] = fmtscan_asc((unsigned char)key[i] >> 4) ; s[(i<<1)+1] = fmtscan_asc((unsigned char)key[i] & 0xF) ; } return n << 1 ; } prog/skalibs-0.47/src/libstddjb/uint64_fmt.c0100644000000000000000000000055711052155510015627 0ustar /* Public domain. */ #include "uint64.h" #include "fmtscan.h" unsigned int uint64_fmt_base (char *s, uint64 x, unsigned char base) { register unsigned int len = 1 ; { register uint64 q = x ; while (q > base-1) { len++ ; q /= base ; } } if (s) { s += len ; do { *--s = fmtscan_asc(x % base) ; x /= base ; } while (x) ; } return len ; } prog/skalibs-0.47/src/libstddjb/int_scan.c0100644000000000000000000000051510324523274015427 0ustar /* Public domain. */ #include "fmtscan.h" unsigned int int_scan (char const *s, int *n) { if ((*s == '-') || (*s == '+')) { unsigned int tmp ; register unsigned int r = uint_scan(s+1, &tmp) ; if (!r) return 0 ; *n = (*s == '-') ? -tmp : tmp ; return r + 1 ; } return uint_scan(s, (unsigned int *)n) ; } prog/skalibs-0.47/src/libstddjb/seek_cur.c0100644000000000000000000000023207752772121015435 0ustar /* Public domain. */ #include #include #include "djbunix.h" long seek_cur (int fd) { return (long)lseek(fd, 0, SEEK_CUR) ; } prog/skalibs-0.47/src/libstddjb/seek_set.c0100644000000000000000000000032707752772100015441 0ustar /* Public domain. */ #include #include #include "djbunix.h" #define SET 0 /* sigh */ int seek_set (int fd, long pos) { if (lseek(fd, (off_t) pos, SET) == -1) return -1 ; return 0 ; } prog/skalibs-0.47/src/libstddjb/sig.c0100644000000000000000000000060310005161304014375 0ustar /* Public domain. */ #include #include "sig.h" int sig_alarm = SIGALRM ; int sig_child = SIGCHLD ; int sig_stop = SIGSTOP ; int sig_cont = SIGCONT ; int sig_hangup = SIGHUP ; int sig_int = SIGINT ; int sig_kill = SIGKILL ; int sig_pipe = SIGPIPE ; int sig_term = SIGTERM ; int sig_usr1 = SIGUSR1 ; int sig_usr2 = SIGUSR2 ; int sig_quit = SIGQUIT ; int sig_abort = SIGABRT ; prog/skalibs-0.47/src/libstddjb/str_chr.c0100644000000000000000000000112107763261732015302 0ustar /* Public domain. */ #include "bytestr.h" #ifdef USE_BASE_LIBC #include unsigned int str_chr (register char const *s, int c) { register char *p = strchr(s, c) ; return p ? (unsigned int)(p - s) : (unsigned int)strlen(s) ; } #else unsigned int str_chr (register char const *s, int c) { register char ch = c ; register char const *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 ; } #endif prog/skalibs-0.47/src/libstddjb/str_diff.c0100644000000000000000000000116207763261664015447 0ustar /* Public domain. */ #include "bytestr.h" #ifdef USE_BASE_LIBC #include int str_diff (register char const *s, register char const *t) { return strcmp(s, t) ; } #else int str_diff (register char const *s, register char const *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) ; } #endif prog/skalibs-0.47/src/libstddjb/str_len.c0100644000000000000000000000061607762053643015313 0ustar /* Public domain. */ #include "bytestr.h" #ifdef USE_BASE_LIBC #include unsigned int str_len (char const *s) { return (unsigned int)strlen(s) ; } #else unsigned int str_len (char const *s) { register char const *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; } } #endif prog/skalibs-0.47/src/libstddjb/str_start.c0100644000000000000000000000057307666446520015677 0ustar /* Public domain. */ #include "bytestr.h" int str_start (register char const *s, register char const *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; } } prog/skalibs-0.47/src/libstddjb/alloc_ska.c0100644000000000000000000000237510554071731015570 0ustar /* Public domain. */ #include #include "sysdeps.h" #undef USE_DJBALLOC #include "alloc.h" #include "alloc_0.h" #ifdef DEBUG_ALLOC # include "fmtscan.h" # include "strerr2.h" #endif aligned_char_ref alloc (unsigned int n) { #ifdef DEBUG_ALLOC { char fmt[ULONG_FMT] ; fmt[uint_fmt(fmt, n)] = 0 ; strerr_warnw3x("alloc(", fmt, ")") ; } #endif #ifdef HASMALLOC0 return (aligned_char_ref)malloc(n) ; #else return n ? (aligned_char_ref)malloc(n) : (aligned_char_ref)alloc_0 ; #endif } void alloc_free (void *p) { #ifdef DEBUG_ALLOC strerr_warnw1x("alloc_free()") ; #endif #ifndef HASMALLOC0 if ((char *)p == alloc_0) return ; #endif free(p) ; } int alloc_realloc (void **x, unsigned int n) { #ifdef DEBUG_ALLOC { char fmt[ULONG_FMT] ; fmt[uint_fmt(fmt, n)] = 0 ; strerr_warnw3x("alloc_realloc(", fmt, ")") ; } #endif #ifdef HASMALLOC0 aligned_char_ref y = n ? (aligned_char_ref)realloc(*x, n) : (free(*x), (aligned_char_ref)malloc(0)) ; #else aligned_char_ref y = (*x == alloc_0) ? alloc(n) : n ? (aligned_char_ref)realloc(*x, n) : (free(*x), alloc_0) ; #endif if (!y) return 0 ; *x = y ; return 1 ; } int alloc_re (void **x, unsigned int dummy, unsigned int n) { (void)dummy ; return alloc_realloc(x, n) ; } prog/skalibs-0.47/src/libstddjb/alloc_0.h0100644000000000000000000000025311100046313015131 0ustar /* Public domain. */ #ifndef ALLOC_0_H #define ALLOC_0_H #include "sysdeps.h" #ifndef HASMALLOC0 #include "alloc.h" extern aligned_char_ref alloc_0 ; #endif #endif prog/skalibs-0.47/src/libstddjb/stralloc_cats.c0100644000000000000000000000024207666446520016500 0ustar /* Public domain. */ #include "bytestr.h" #include "stralloc.h" int stralloc_cats (stralloc *sa, char const *s) { return stralloc_catb(sa, s, str_len(s)) ; } prog/skalibs-0.47/src/libstddjb/uintalloc.h0100644000000000000000000000027711100030244015614 0ustar /* Public domain. */ #ifndef UINTALLOC_H #define UINTALLOC_H #include "gen_alloc.h" GEN_ALLOC_PROTOTYPES(uintalloc, unsigned int, s, len, a) #define UINTALLOC_ZERO GEN_ALLOC_ZERO #endif prog/skalibs-0.47/src/libstddjb/alloc_0.c0100644000000000000000000000041107666446520015152 0ustar /* Public domain. */ #include "sysdeps.h" #include "alloc.h" #include "alloc_0.h" #ifndef HASMALLOC0 #define ALIGNMENT 16 static union { unsigned char blah[ALIGNMENT] ; double d ; } zeroblock ; aligned_char_ref alloc_0 = (aligned_char_ref)(&zeroblock) ; #endif prog/skalibs-0.47/src/libstddjb/stralloc_opys.c0100644000000000000000000000024407666446520016542 0ustar /* Public domain. */ #include "bytestr.h" #include "stralloc.h" int stralloc_copys (stralloc *sa, char const *s) { return stralloc_copyb(sa, s, str_len(s)) ; } prog/skalibs-0.47/src/libstddjb/uint32alloc.h0100644000000000000000000000032511100046312015756 0ustar /* Public domain. */ #ifndef UINT32ALLOC_H #define UINT32ALLOC_H #include "uint32.h" #include "gen_alloc.h" GEN_ALLOC_PROTOTYPES(uint32alloc, uint32, s, len, a) #define UINT32ALLOC_ZERO GEN_ALLOC_ZERO #endif prog/skalibs-0.47/src/libstddjb/strerr_die.c0100644000000000000000000000210510024362474015770 0ustar /* Public domain. */ /* MT-unsafe */ #include #include "buffer.h" #include "strerr.h" void strerr_warn (char const *x1, char const *x2, char const *x3, char const *x4, char const *x5, char const *x6, char const *x7, char const *x8, char const *x9, char const *x10, char const *se) { if (x1) buffer_putsalign(buffer_2, x1) ; if (x2) buffer_putsalign(buffer_2, x2) ; if (x3) buffer_putsalign(buffer_2, x3) ; if (x4) buffer_putsalign(buffer_2, x4) ; if (x5) buffer_putsalign(buffer_2, x5) ; if (x6) buffer_putsalign(buffer_2, x6) ; if (x7) buffer_putsalign(buffer_2, x7) ; if (x8) buffer_putsalign(buffer_2, x8) ; if (x9) buffer_putsalign(buffer_2, x9) ; if (x10) buffer_putsalign(buffer_2, x10) ; if (se) buffer_putsalign(buffer_2, se) ; buffer_putflush(buffer_2, "\n", 1) ; } void strerr_die (int e, char const *x1, char const *x2, char const *x3, char const *x4, char const *x5, char const *x6, char const *x7, char const *x8, char const *x9, char const *x10, char const *se) { strerr_warn(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, se) ; _exit(e) ; } prog/skalibs-0.47/src/libstddjb/strerr_sys.c0100644000000000000000000000120510024362543016042 0ustar /* Public domain. */ /* MT-unsafe */ #include #include #include "error.h" #include "strerr.h" void strerr_warnsys (char const *x1, char const *x2, char const *x3, char const *x4, char const *x5, char const *x6, char const *x7, char const *x8, char const *x9, char const *x10) { strerr_warn(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, error_str(errno)) ; } void strerr_diesys (int e, char const *x1, char const *x2, char const *x3, char const *x4, char const *x5, char const *x6, char const *x7, char const *x8, char const *x9, char const *x10) { strerr_warnsys(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) ; _exit(e) ; } prog/skalibs-0.47/src/libstddjb/tai_add.c0100644000000000000000000000023307666446520015230 0ustar /* Public domain. */ #include "tai.h" void tai_add (struct tai *t, struct tai const *u, struct tai const *v) { tai_u64(t, tai_sec(u) + tai_sec(v)) ; } prog/skalibs-0.47/src/libstddjb/tai_now.c0100644000000000000000000000017707666446520015312 0ustar /* Public domain. */ #include #include "tai.h" void tai_now (struct tai *t) { tai_unix(t, time((time_t *) 0)) ; } prog/skalibs-0.47/src/libstddjb/tai_pack.c0100644000000000000000000000022007666446520015412 0ustar /* Public domain. */ #include "uint64.h" #include "tai.h" void tai_pack (char *s, struct tai const *t) { uint64_pack_big(s, tai_sec(t)) ; } prog/skalibs-0.47/src/libstddjb/tai_sub.c0100644000000000000000000000023307666446520015271 0ustar /* Public domain. */ #include "tai.h" void tai_sub (struct tai *t, struct tai const *u, struct tai const *v) { tai_u64(t, tai_sec(u) - tai_sec(v)) ; } prog/skalibs-0.47/src/libstddjb/tai.h0100644000000000000000000000701311100046312014375 0ustar /* Public domain. */ #ifndef TAI_H #define TAI_H #include #include "gccattributes.h" #include "uint64.h" struct tai { uint64 x ; } ; #define TAI_ZERO { 0 } #define TAI_MAGIC ((uint64)4611686018427387914ULL) #define tai_sec(t) ((t)->x) #define tai_u64(t, u) ((void)((t)->x = (u))) #define tai_unix(t, u) tai_u64(t, (TAI_MAGIC + (u))) #define tai_uint(t, u) tai_u64(t, (uint64)(u)) extern int tai_relative_from_timeval (struct tai *, struct timeval const *) ; extern int tai_from_timeval (struct tai *, struct timeval const *) ; extern int timeval_from_tai_relative (struct timeval *, struct tai const *) ; extern int timeval_from_tai (struct timeval *, struct tai const *) ; extern void tai_now (struct tai *) ; #define tai_approx(t) ((double)(tai_sec(t))) extern void tai_add (struct tai *, struct tai const *, struct tai const *) ; extern void tai_sub (struct tai *, struct tai const *, struct tai const *) ; #define tai_less(t,u) (tai_sec(t) < tai_sec(u)) #define TAI_PACK 8 extern void tai_pack (char *, struct tai const *) ; extern void tai_unpack (char const *, struct tai *) ; extern void tai_pack_little (char *, struct tai const *) ; extern void tai_unpack_little (char const *, struct tai *) ; struct taia { struct tai sec ; unsigned long nano ; /* 0...999999999 */ unsigned long atto ; /* 0...999999999 */ } ; #define TAIA_ZERO { TAI_ZERO, 0, 0 } extern void taia_tai (struct taia const *, struct tai *) ; #define taia_sec(a) ((a)->sec) #define taia_secp(a) (&(a)->sec) #define taia_nano(a) ((a)->nano) #define taia_atto(a) ((a)->atto) extern int taia_relative_from_timeval (struct taia *, struct timeval const *) ; extern int taia_from_timeval (struct taia *, struct timeval const *) ; extern int timeval_from_taia_relative (struct timeval *, struct taia const *) ; extern int timeval_from_taia (struct timeval *, struct taia const *) ; extern void taia_now (struct taia *) ; extern double taia_approx (struct taia const *) gccattr_pure ; extern double taia_frac (struct taia const *) gccattr_pure ; extern void taia_add (struct taia *, struct taia const *, struct taia const *) ; extern void taia_addsec (struct taia *, struct taia const *, int) ; extern void taia_sub (struct taia *, struct taia const *, struct taia const *) ; extern void taia_half (struct taia *, struct taia const *) ; extern int taia_less (struct taia const *, struct taia const *) gccattr_pure ; #define TAIA_PACK 16 extern void taia_pack (char *, struct taia const *) ; extern void taia_unpack (char const *, struct taia *) ; extern void taia_pack_little (char *, struct taia const *) ; extern void taia_unpack_little (char const *, struct taia *) ; extern unsigned int taia_fmt (char *, struct taia const *) ; extern unsigned int taia_scan (char const *, struct taia *) ; #define TAIN_PACK 12 extern void tain_pack (char *, struct taia const *) ; extern void tain_unpack (char const *, struct taia *) ; extern void tain_pack_little (char *, struct taia const *) ; extern void tain_unpack_little (char const *, struct taia *) ; extern unsigned int tain_fmt (char *, struct taia const *) ; extern unsigned int tain_scan (char const *, struct taia *) ; #define TAIA_FMTFRAC 19 extern unsigned int taia_fmtfrac (char *, struct taia const *) ; extern void taia_uint (struct taia *, unsigned int) ; extern void taia_ulong (struct taia *, unsigned long) ; #define TIMESTAMP (1 + (TAIN_PACK << 1)) extern unsigned int timestamp_fmt (char *, struct taia const *) ; extern unsigned int timestamp_scan (char const *, struct taia *) ; extern void timestamp (char *) ; #endif prog/skalibs-0.47/src/libstddjb/strerr2.h0100644000000000000000000002361407666446520015263 0ustar /* Public domain. */ #ifndef STRERR2_H #define STRERR2_H #include "strerr.h" /* requires */ extern char const *PROG ; #define strerr_warnw1x(x1) \ strerr_warn3x(PROG, ": warning: ", (x1)) #define strerr_warnw2x(x1, x2) \ strerr_warn4x(PROG, ": warning: ", (x1), (x2)) #define strerr_warnw3x(x1, x2, x3) \ strerr_warn5x(PROG, ": warning: ", (x1), (x2), (x3)) #define strerr_warnw4x(x1, x2, x3, x4) \ strerr_warn6x(PROG, ": warning: ", (x1), (x2), (x3), (x4)) #define strerr_warnw5x(x1, x2, x3, x4, x5) \ strerr_warn7x(PROG, ": warning: ", (x1), (x2), (x3), (x4), (x5)) #define strerr_warnw6x(x1, x2, x3, x4, x5, x6) \ strerr_warn8x(PROG, ": warning: ", (x1), (x2), (x3), (x4), (x5), (x6)) #define strerr_warnw7x(x1, x2, x3, x4, x5, x6, x7) \ strerr_warn9x(PROG, ": warning: ", (x1), (x2), (x3), (x4), (x5), (x6), (x7)) #define strerr_warnw8x(x1, x2, x3, x4, x5, x6, x7, x8) \ strerr_warn10x(PROG, ": warning: ", (x1), (x2), (x3), (x4), (x5), (x6), (x7), (x8)) #define strerr_warnw1sys(x1) \ strerr_warn4sys(PROG, ": warning: ", (x1), ": ") #define strerr_warnw2sys(x1, x2) \ strerr_warn5sys(PROG, ": warning: ", (x1), (x2), ": ") #define strerr_warnw3sys(x1, x2, x3) \ strerr_warn6sys(PROG, ": warning: ", (x1), (x2), (x3), ": ") #define strerr_warnw4sys(x1, x2, x3, x4) \ strerr_warn7sys(PROG, ": warning: ", (x1), (x2), (x3), (x4), ": ") #define strerr_warnw5sys(x1, x2, x3, x4, x5) \ strerr_warn8sys(PROG, ": warning: ", (x1), (x2), (x3), (x4), (x5), ": ") #define strerr_warnw6sys(x1, x2, x3, x4, x5, x6) \ strerr_warn9sys(PROG, ": warning: ", (x1), (x2), (x3), (x4), (x5), (x6), ": ") #define strerr_warnw7sys(x1, x2, x3, x4, x5, x6, x7) \ strerr_warn10sys(PROG, ": warning: ", (x1), (x2), (x3), (x4), (x5), (x6), (x7), ": ") #define strerr_diew1x(e, x1) \ strerr_die3x((e), PROG, ": warning: ", (x1)) #define strerr_diew2x(e, x1, x2) \ strerr_die4x((e), PROG, ": warning: ", (x1), (x2)) #define strerr_diew3x(e, x1, x2, x3) \ strerr_die5x((e), PROG, ": warning: ", (x1), (x2), (x3)) #define strerr_diew4x(e, x1, x2, x3, x4) \ strerr_die6x((e), PROG, ": warning: ", (x1), (x2), (x3), (x4)) #define strerr_diew5x(e, x1, x2, x3, x4, x5) \ strerr_die7x((e), PROG, ": warning: ", (x1), (x2), (x3), (x4), (x5)) #define strerr_diew6x(e, x1, x2, x3, x4, x5, x6) \ strerr_die8x((e), PROG, ": warning: ", (x1), (x2), (x3), (x4), (x5), (x6)) #define strerr_diew7x(e, x1, x2, x3, x4, x5, x6, x7) \ strerr_die9x((e), PROG, ": warning: ", (x1), (x2), (x3), (x4), (x5), (x6), (x7)) #define strerr_diew8x(e, x1, x2, x3, x4, x5, x6, x7, x8) \ strerr_die10x((e), PROG, ": warning: ", (x1), (x2), (x3), (x4), (x5), (x6), (x7), (x8)) #define strerr_diew1sys(e, x1) \ strerr_die4sys((e), PROG, ": warning: ", (x1), ": ") #define strerr_diew2sys(e, x1, x2) \ strerr_die5sys((e), PROG, ": warning: ", (x1), (x2), ": ") #define strerr_diew3sys(e, x1, x2, x3) \ strerr_die6sys((e), PROG, ": warning: ", (x1), (x2), (x3), ": ") #define strerr_diew4sys(e, x1, x2, x3, x4) \ strerr_die7sys((e), PROG, ": warning: ", (x1), (x2), (x3), (x4), ": ") #define strerr_diew5sys(e, x1, x2, x3, x4, x5) \ strerr_die8sys((e), PROG, ": warning: ", (x1), (x2), (x3), (x4), (x5), ": ") #define strerr_diew6sys(e, x1, x2, x3, x4, x5, x6) \ strerr_die9sys((e), PROG, ": warning: ", (x1), (x2), (x3), (x4), (x5), (x6), ": ") #define strerr_diew7sys(e, x1, x2, x3, x4, x5, x6, x7) \ strerr_die10sys((e), PROG, ": warning: ", (x1), (x2), (x3), (x4), (x5), (x6), (x7), ": ") #define strerr_dief1x(e, x1) \ strerr_die3x((e), PROG, ": fatal: ", (x1)) #define strerr_dief2x(e, x1, x2) \ strerr_die4x((e), PROG, ": fatal: ", (x1), (x2)) #define strerr_dief3x(e, x1, x2, x3) \ strerr_die5x((e), PROG, ": fatal: ", (x1), (x2), (x3)) #define strerr_dief4x(e, x1, x2, x3, x4) \ strerr_die6x((e), PROG, ": fatal: ", (x1), (x2), (x3), (x4)) #define strerr_dief5x(e, x1, x2, x3, x4, x5) \ strerr_die7x((e), PROG, ": fatal: ", (x1), (x2), (x3), (x4), (x5)) #define strerr_dief6x(e, x1, x2, x3, x4, x5, x6) \ strerr_die8x((e), PROG, ": fatal: ", (x1), (x2), (x3), (x4), (x5), (x6)) #define strerr_dief7x(e, x1, x2, x3, x4, x5, x6, x7) \ strerr_die9x((e), PROG, ": fatal: ", (x1), (x2), (x3), (x4), (x5), (x6), (x7)) #define strerr_dief8x(e, x1, x2, x3, x4, x5, x6, x7, x8) \ strerr_die10x((e), PROG, ": fatal: ", (x1), (x2), (x3), (x4), (x5), (x6), (x7), (x8)) #define strerr_dief1sys(e, x1) \ strerr_die4sys((e), PROG, ": fatal: ", (x1), ": ") #define strerr_dief2sys(e, x1, x2) \ strerr_die5sys((e), PROG, ": fatal: ", (x1), (x2), ": ") #define strerr_dief3sys(e, x1, x2, x3) \ strerr_die6sys((e), PROG, ": fatal: ", (x1), (x2), (x3), ": ") #define strerr_dief4sys(e, x1, x2, x3, x4) \ strerr_die7sys((e), PROG, ": fatal: ", (x1), (x2), (x3), (x4), ": ") #define strerr_dief5sys(e, x1, x2, x3, x4, x5) \ strerr_die8sys((e), PROG, ": fatal: ", (x1), (x2), (x3), (x4), (x5), ": ") #define strerr_dief6sys(e, x1, x2, x3, x4, x5, x6) \ strerr_die9sys((e), PROG, ": fatal: ", (x1), (x2), (x3), (x4), (x5), (x6), ": ") #define strerr_dief7sys(e, x1, x2, x3, x4, x5, x6, x7) \ strerr_die10sys((e), PROG, ": fatal: ", (x1), (x2), (x3), (x4), (x5), (x6), (x7), ": ") #define strerr_diefu1x(e, x1) \ strerr_die4x((e), PROG, ": fatal: ", "unable to ", (x1)) #define strerr_diefu2x(e, x1, x2) \ strerr_die5x((e), PROG, ": fatal: ", "unable to ", (x1), (x2)) #define strerr_diefu3x(e, x1, x2, x3) \ strerr_die6x((e), PROG, ": fatal: ", "unable to ", (x1), (x2), (x3)) #define strerr_diefu4x(e, x1, x2, x3, x4) \ strerr_die7x((e), PROG, ": fatal: ", "unable to ", (x1), (x2), (x3), (x4)) #define strerr_diefu5x(e, x1, x2, x3, x4, x5) \ strerr_die8x((e), PROG, ": fatal: ", "unable to ", (x1), (x2), (x3), (x4), (x5)) #define strerr_diefu6x(e, x1, x2, x3, x4, x5, x6) \ strerr_die9x((e), PROG, ": fatal: ", "unable to ", (x1), (x2), (x3), (x4), (x5), (x6)) #define strerr_diefu7x(e, x1, x2, x3, x4, x5, x6, x7) \ strerr_die10x((e), PROG, ": fatal: ", "unable to ", (x1), (x2), (x3), (x4), (x5), (x6), (x7)) #define strerr_diefu1sys(e, x1) \ strerr_die5sys((e), PROG, ": fatal: ", "unable to ", (x1), ": ") #define strerr_diefu2sys(e, x1, x2) \ strerr_die6sys((e), PROG, ": fatal: ", "unable to ", (x1), (x2), ": ") #define strerr_diefu3sys(e, x1, x2, x3) \ strerr_die7sys((e), PROG, ": fatal: ", "unable to ", (x1), (x2), (x3), ": ") #define strerr_diefu4sys(e, x1, x2, x3, x4) \ strerr_die8sys((e), PROG, ": fatal: ", "unable to ", (x1), (x2), (x3), (x4), ": ") #define strerr_diefu5sys(e, x1, x2, x3, x4, x5) \ strerr_die9sys((e), PROG, ": fatal: ", "unable to ", (x1), (x2), (x3), (x4), (x5), ": ") #define strerr_diefu6sys(e, x1, x2, x3, x4, x5, x6) \ strerr_die10sys((e), PROG, ": fatal: ", "unable to ", (x1), (x2), (x3), (x4), (x5), (x6), ": ") #define strerr_warnwu1x(x1) \ strerr_warn4x(PROG, ": warning: ", "unable to ", (x1)) #define strerr_warnwu2x(x1, x2) \ strerr_warn5x(PROG, ": warning: ", "unable to ", (x1), (x2)) #define strerr_warnwu3x(x1, x2, x3) \ strerr_warn6x(PROG, ": warning: ", "unable to ", (x1), (x2), (x3)) #define strerr_warnwu4x(x1, x2, x3, x4) \ strerr_warn7x(PROG, ": warning: ", "unable to ", (x1), (x2), (x3), (x4)) #define strerr_warnwu5x(x1, x2, x3, x4, x5) \ strerr_warn8x(PROG, ": warning: ", "unable to ", (x1), (x2), (x3), (x4), (x5)) #define strerr_warnwu6x(x1, x2, x3, x4, x5, x6) \ strerr_warn9x(PROG, ": warning: ", "unable to ", (x1), (x2), (x3), (x4), (x5), (x6)) #define strerr_warnwu7x(x1, x2, x3, x4, x5, x6, x7) \ strerr_warn10x(PROG, ": warning: ", "unable to ", (x1), (x2), (x3), (x4), (x5), (x6), (x7)) #define strerr_warnwu1sys(x1) \ strerr_warn5sys(PROG, ": warning: ", "unable to ", (x1), ": ") #define strerr_warnwu2sys(x1, x2) \ strerr_warn6sys(PROG, ": warning: ", "unable to ", (x1), (x2), ": ") #define strerr_warnwu3sys(x1, x2, x3) \ strerr_warn7sys(PROG, ": warning: ", "unable to ", (x1), (x2), (x3), ": ") #define strerr_warnwu4sys(x1, x2, x3, x4) \ strerr_warn8sys(PROG, ": warning: ", "unable to ", (x1), (x2), (x3), (x4), ": ") #define strerr_warnwu5sys(x1, x2, x3, x4, x5) \ strerr_warn9sys(PROG, ": warning: ", "unable to ", (x1), (x2), (x3), (x4), (x5), ": ") #define strerr_warnwu6sys(x1, x2, x3, x4, x5, x6) \ strerr_warn10sys(PROG, ": warning: ", "unable to ", (x1), (x2), (x3), (x4), (x5), (x6), ": ") #define strerr_diewu1x(e, x1) \ strerr_die4x((e), PROG, ": warning: ", "unable to ", (x1)) #define strerr_diewu2x(e, x1, x2) \ strerr_die5x((e), PROG, ": warning: ", "unable to ", (x1), (x2)) #define strerr_diewu3x(e, x1, x2, x3) \ strerr_die6x((e), PROG, ": warning: ", "unable to ", (x1), (x2), (x3)) #define strerr_diewu4x(e, x1, x2, x3, x4) \ strerr_die7x((e), PROG, ": warning: ", "unable to ", (x1), (x2), (x3), (x4)) #define strerr_diewu5x(e, x1, x2, x3, x4, x5) \ strerr_die8x((e), PROG, ": warning: ", "unable to ", (x1), (x2), (x3), (x4), (x5)) #define strerr_diewu6x(e, x1, x2, x3, x4, x5, x6) \ strerr_die9x((e), PROG, ": warning: ", "unable to ", (x1), (x2), (x3), (x4), (x5), (x6)) #define strerr_diewu7x(e, x1, x2, x3, x4, x5, x6, x7) \ strerr_die10x((e), PROG, ": warning: ", "unable to ", (x1), (x2), (x3), (x4), (x5), (x6), (x7)) #define strerr_diewu1sys(e, x1) \ strerr_die5sys((e), PROG, ": warning: ", "unable to ", (x1), ": ") #define strerr_diewu2sys(e, x1, x2) \ strerr_die6sys((e), PROG, ": warning: ", "unable to ", (x1), (x2), ": ") #define strerr_diewu3sys(e, x1, x2, x3) \ strerr_die7sys((e), PROG, ": warning: ", "unable to ", (x1), (x2), (x3), ": ") #define strerr_diewu4sys(e, x1, x2, x3, x4) \ strerr_die8sys((e), PROG, ": warning: ", "unable to ", (x1), (x2), (x3), (x4), ": ") #define strerr_diewu5sys(e, x1, x2, x3, x4, x5) \ strerr_die9sys((e), PROG, ": warning: ", "unable to ", (x1), (x2), (x3), (x4), (x5), ": ") #define strerr_diewu6sys(e, x1, x2, x3, x4, x5, x6) \ strerr_die10sys((e), PROG, ": warning: ", "unable to ", (x1), (x2), (x3), (x4), (x5), (x6), ": ") #define strerr_dieusage(e, u) \ strerr_die3x((e), PROG, ": usage: ", (u)) #define strerr_dienotset(e, x) \ strerr_dief2x((e), (x), " not set") #define strerr_dieinvalid(e, x) \ strerr_dief2x((e), "invalid $", (x)) #define strerr_dieexec(e, x) \ strerr_diefu2sys((e), "exec ", (x)) #endif prog/skalibs-0.47/src/libstddjb/taia_add.c0100644000000000000000000000063707666446520015401 0ustar /* Public domain. */ #include "tai.h" void taia_add (struct taia *t, struct taia const *u, struct taia const *v) { tai_add(&t->sec, &u->sec, &v->sec) ; t->nano = u->nano + v->nano ; t->atto = u->atto + v->atto ; if (t->atto > 999999999UL) { t->atto -= 1000000000UL ; ++t->nano ; } if (t->nano > 999999999UL) { t->nano -= 1000000000UL ; tai_u64(&t->sec, tai_sec(&t->sec)+1) ; } } prog/skalibs-0.47/src/libstddjb/taia_approx.c0100644000000000000000000000020407666446520016150 0ustar /* Public domain. */ #include "tai.h" double taia_approx (struct taia const *t) { return tai_approx(&t->sec) + taia_frac(t) ; } prog/skalibs-0.47/src/libstddjb/taia_frac.c0100644000000000000000000000021707666446520015556 0ustar /* Public domain. */ #include "tai.h" double taia_frac (struct taia const *t) { return (t->atto * 0.000000001 + t->nano) * 0.000000001 ; } prog/skalibs-0.47/src/libstddjb/taia_less.c0100644000000000000000000000047007666446520015612 0ustar /* Public domain. */ #include "tai.h" int taia_less (struct taia const *t, struct taia const *u) { if (tai_sec(&t->sec) < tai_sec(&u->sec)) return 1 ; if (tai_sec(&t->sec) > tai_sec(&u->sec)) return 0 ; if (t->nano < u->nano) return 1 ; if (t->nano > u->nano) return 0 ; return t->atto < u->atto ; } prog/skalibs-0.47/src/libstddjb/taia_now.c0100644000000000000000000000033307724234764015445 0ustar /* Public domain. */ #include #include #include "tai.h" void taia_now (struct taia *a) { struct timeval now ; gettimeofday(&now, 0) ; taia_from_timeval(a, &now) ; a->nano += 500 ; } prog/skalibs-0.47/src/libstddjb/taia_pack.c0100644000000000000000000000033507666446520015562 0ustar /* Public domain. */ #include "uint32.h" #include "tai.h" void taia_pack (char *s, struct taia const *t) { tai_pack(s, &t->sec) ; uint32_pack_big(s+8, (uint32)t->nano) ; uint32_pack_big(s+12, (uint32)t->atto) ; } prog/skalibs-0.47/src/libstddjb/taia_sub.c0100644000000000000000000000072607666446520015441 0ustar /* Public domain. */ #include "tai.h" void taia_sub (struct taia *t, struct taia const *u, struct taia const *v) { unsigned long unano = u->nano ; unsigned long uatto = u->atto ; tai_sub(&t->sec, &u->sec, &v->sec) ; t->nano = unano - v->nano ; t->atto = uatto - v->atto ; if (t->atto > uatto) { t->atto += 1000000000UL ; --t->nano ; } if (t->nano > unano) { t->nano += 1000000000UL ; tai_u64(&t->sec, tai_sec(&t->sec)-1) ; } } prog/skalibs-0.47/src/libstddjb/taia_uint.c0100644000000000000000000000022507666446520015621 0ustar /* Public domain. */ #include "tai.h" void taia_uint (struct taia *t, unsigned int s) { tai_uint(&t->sec, s) ; t->nano = 0 ; t->atto = 0 ; } prog/skalibs-0.47/src/libstddjb/uint16_pack.c0100644000000000000000000000027307666446520015773 0ustar /* Public domain. */ #include "uint16.h" #include "bytestr.h" void uint16_pack (char *s, uint16 u) { ((unsigned char *)s)[0] = T8(u) ; u >>= 8 ; ((unsigned char *)s)[1] = T8(u) ; } prog/skalibs-0.47/src/libstddjb/uint16_unpack.c0100644000000000000000000000031707666446520016335 0ustar /* Public domain. */ #include "uint16.h" #include "bytestr.h" void uint16_unpack (char const *s, uint16 *u) { uint16 r = T8((unsigned char)s[1]) ; r <<= 8 ; r += T8((unsigned char)s[0]) ; *u = r ; } prog/skalibs-0.47/src/libstddjb/cdb_make.h0100644000000000000000000000114111100046312015341 0ustar /* Public domain. */ #ifndef CDB_MAKE_H #define CDB_MAKE_H #include "uint32.h" #include "diuint32alloc.h" #include "buffer.h" typedef struct cdb_make cdb_make, *cdb_make_ref ; struct cdb_make { char buf[BUFFER_OUTSIZE] ; diuint32alloc hplist ; buffer b ; uint32 pos ; int fd ; } ; #define CDB_MAKE_ZERO { "", DIUINT32ALLOC_ZERO, BUFFER_INIT(&buffer_unixwrite, -1, 0, 0), 2048, -1 } extern int cdb_make_start (struct cdb_make *, int) ; extern int cdb_make_add (struct cdb_make *, char const *, unsigned int, char const *, unsigned int) ; extern int cdb_make_finish (struct cdb_make *) ; #endif prog/skalibs-0.47/src/libstddjb/str_diffn.c0100644000000000000000000000065607763251045015624 0ustar /* Public domain. */ #include "bytestr.h" #ifdef USE_BASE_LIBC #include int str_diffn (register char const *s, register char const *t, register unsigned int len) { return strncmp(s, t, len) ; } #else int str_diffn (register char const *s, register char const *t, register unsigned int len) { while (len--) { if (*s != *t) return *s - *t ; if (!*s) break ; s++ ; t++ ; } return 0 ; } #endif prog/skalibs-0.47/src/libstddjb/djbunix.h0100644000000000000000000001042711100030244015263 0ustar /* Public domain. */ #ifndef DJBUNIX_H #define DJBUNIX_H #include "gccattributes.h" #include "stralloc.h" #include "envalloc.h" #include "env.h" /* compatibility */ extern int coe (int) ; extern int uncoe (int) ; extern void deepsleep (unsigned int) gccattr_const ; extern int fd_copy (int, int) ; extern int fd_copy2 (int, int, int, int) ; extern int fd_move (int, int) ; extern int fd_move2 (int, int, int, int) ; extern int fd_close (int) ; extern int fifo_make (char const *, unsigned int) ; extern int lock_ex (int) ; extern int lock_exnb (int) ; extern int lock_sh (int) ; extern int lock_shnb (int) ; extern int lock_un (int) ; extern int ndelay_on (int) ; extern int ndelay_off (int) ; extern int open2 (char const *, unsigned int) ; extern int open3 (char const *, unsigned int, unsigned int) ; extern int open_read (char const *) ; extern int open_readb (char const *) ; extern int open_excl (char const *) ; extern int open_append (char const *) ; extern int open_trunc (char const *) ; extern int open_write (char const *) ; extern int pathexec_env (char const *, char const *) ; extern void pathexec_r (char const *const *, char const *const *, unsigned int, char const *, unsigned int) ; extern void pathexec_r_tmp (char const *const *, char const *const *, unsigned int, char const *, unsigned int, stralloc *) ; extern void pathexec_r_tmp_envtmp (char const *const *, char const *const *, unsigned int, char const *, unsigned int, stralloc *, envalloc *) ; extern void pathexec_fromenv (char const *const *, char const *const *, unsigned int) ; extern void pathexec_fromenv_tmp (char const *const *, char const *const *, unsigned int, stralloc *) ; extern void execvep (char const *, char const *const *, char const *const *, char const *) ; extern void execvep_tmp (char const *, char const *const *, char const *const *, char const *, stralloc *) ; extern void pathexec_run (char const *, char const *const *, char const *const *) ; extern void pathexec_run_tmp (char const *, char const *const *, char const *const *, stralloc *) ; extern void pathexec0_run (char const *const *, char const *const *) ; extern void pathexec0_run_tmp (char const *const *, char const *const *, stralloc *) ; extern void pathexec (char const *const *) ; extern void pathexec_tmp (char const *const *, stralloc *) ; extern void pathexec0 (char const *const *) ; extern void pathexec0_tmp (char const *const *, stralloc *) ; extern int prot_gid (int) ; extern int prot_uid (int) ; extern long seek_cur (int) ; extern int seek_set (int, long) ; extern int seek_end (int) ; extern int seek_trunc (int, long) ; #define seek_begin(fd) (seek_set((fd), 0)) extern int wait_pid (int *, int) ; extern int wait_nohang (int *) ; extern int wait_pid_nohang (int *, int) ; extern int wait_pids_nohang (int *, int const *, unsigned int) ; extern int wait_stop (void) ; extern int wait_stopnohang (void) ; #define wait_crashed(w) ((w) & 127) #define wait_exitcode(w) ((w) >> 8) #define wait_stopsig(w) ((w) >> 8) #define wait_stopped(w) (((w) & 127) == 127) #define wait_status(w) (wait_crashed(w) ? 111 : wait_exitcode(w)) extern int fd_chdir (int) ; #define absolutepath(sa, s) sarealpath(sa, s) extern char *realpath (char const *, char *) ; /* SUSv3 */ extern char *realpath_tmp (char const *, char *, stralloc *) ; extern int sarealpath (stralloc *, char const *) ; extern int sarealpath_tmp (stralloc *, char const *, stralloc *) ; extern char *basename (char *) ; /* SUSv3 */ extern int sabasename (stralloc *, char const *, unsigned int) ; extern char *dirname (char *) ; /* SUSv3 */ extern int sadirname (stralloc *, char const *, unsigned int) ; extern int sagetcwd (stralloc *) ; extern int sareadlink (stralloc *, char const *) ; extern int sagethostname (stralloc *) ; extern int doublefork (void) ; extern unsigned int wait_reap (void) ; extern int waitn (int const *, unsigned int) ; extern int slurp (stralloc *, int) ; extern int openslurpclose (stralloc *, char const *) ; extern int openreadclose (char const *, stralloc *, unsigned int) ; extern int openreadnclose (char const *, char *, unsigned int) ; extern int rm_rf (char const *) ; extern int rm_rf_tmp (char const *, stralloc *) ; extern int rm_rf_in_tmp (stralloc *, unsigned int) ; /* caution ! */ extern int rmstar (char const *) ; extern int rmstar_tmp (char const *, stralloc *) ; #endif prog/skalibs-0.47/src/libstddjb/error_temp.c0100644000000000000000000000216610040503562016004 0ustar /* Public domain. */ #include #include "error.h" int error_temp (register int e) { if (error_isagain(e)) return 1 ; switch (e) { case 0 : case EINTR : case ENOMEM : case ETXTBSY : case EIO : case ETIMEDOUT : case ENOBUFS : #ifdef EDEADLK case EDEADLK : #endif #ifdef EBUSY case EBUSY : #endif #ifdef ENFILE case ENFILE : #endif #ifdef EFBIG case EFBIG : #endif #ifdef ENOSPC case ENOSPC : #endif #ifdef ENETDOWN case ENETDOWN : #endif #ifdef ENETUNREACH case ENETUNREACH : #endif #ifdef ENETRESET case ENETRESET : #endif #ifdef ECONNABORTED case ECONNABORTED : #endif #ifdef ECONNRESET case ECONNRESET : #endif #ifdef ETOOMANYREFS case ETOOMANYREFS : #endif #ifdef ECONNREFUSED case ECONNREFUSED : #endif #ifdef EHOSTDOWN case EHOSTDOWN : #endif #ifdef EHOSTUNREACH case EHOSTUNREACH : #endif #ifdef EPROCLIM case EPROCLIM : #endif #ifdef EUSERS case EUSERS : #endif #ifdef EDQUOT case EDQUOT : #endif #ifdef ESTALE case ESTALE : #endif #ifdef ENOLCK case ENOLCK : #endif return 1 ; default : return 0 ; } } prog/skalibs-0.47/src/libstddjb/selfpipe.h0100644000000000000000000000036310005162521015434 0ustar /* Public domain. */ #ifndef SELFPIPE_H #define SELFPIPE_H extern int selfpipe_init (void) ; /* returns -1 or fd to select on */ extern int selfpipe_trap (int) ; extern int selfpipe_read (void) ; extern void selfpipe_finish (void) ; #endif prog/skalibs-0.47/src/libstddjb/case_lowers.c0100644000000000000000000000032007742233602016134 0ustar /* Public domain. */ #include "bytestr.h" void case_lowers (register char *s) { register unsigned char const d = 'a' - 'A' ; while (*s) { if (('A' <= *s) && (*s <= 'Z')) *s += d ; ++s ; } } prog/skalibs-0.47/src/libstddjb/socket_udp.c0100644000000000000000000000061310022642767015774 0ustar /* Public domain. */ #include #include #include #include #include #include "djbunix.h" #include "socket.h" int socket_udp () { int s = socket(AF_INET, SOCK_DGRAM, 0) ; if (s == -1) return -1 ; if (ndelay_on(s) == -1) { register int e = errno ; fd_close(s) ; errno = e ; return -1 ; } return s ; } prog/skalibs-0.47/src/libstddjb/iobuffer.c0100644000000000000000000000053307767206026015444 0ustar /* Public domain. */ #include "buffer.h" #include "iobuffer.h" int iobuffer_fill (iobuffer_ref b) { register int r = buffer_fill(&b->in) ; b->out.n = b->in.n ; b->out.p = b->in.p ; return r ; } int iobuffer_flush (iobuffer_ref b) { register int r = buffer_flush(&b->out) ; b->in.n = b->out.n ; b->in.p = b->out.p ; return r ; } prog/skalibs-0.47/src/libstddjb/open2.c0100644000000000000000000000036207772756000014664 0ustar /* Public domain. */ #include #include #include int open2 (char const *s, unsigned int flags) { register int r ; do r = open(s, (int)flags) ; while ((r == -1) && (errno == EINTR)) ; return r ; } prog/skalibs-0.47/src/libstddjb/openslurpclose.c0100644000000000000000000000044610321217061016700 0ustar /* Public domain. */ #include #include "stralloc.h" #include "djbunix.h" int openslurpclose (stralloc *sa, char const *fn) { int r ; int e ; int fd = open_readb(fn) ; if (fd == -1) return 0 ; r = slurp(sa, fd) ; e = errno ; fd_close(fd) ; errno = e ; return r ; } prog/skalibs-0.47/src/libstddjb/alloc_djb.c0100644000000000000000000000243710554072607015553 0ustar /* Public domain. */ /* MT-unsafe */ #include #include #include "sysdeps.h" #include "bytestr.h" #ifndef USE_DJBALLOC #define USE_DJBALLOC #endif #include "alloc.h" #define ALIGNMENT 16 typedef union { char blah[ALIGNMENT] ; double d ; } aligned ; #define SPACE 2048 /* must be multiple of ALIGNMENT */ static aligned realspace[SPACE / ALIGNMENT] ; #define space ((char *) realspace) static unsigned int avail = SPACE ; /* multiple of ALIGNMENT; 0<=avail<=SPACE */ void alloc_free (void *y) { char *x = (char *)y ; if ((x >= space) && (x < space + SPACE)) return ; /* XXX: assuming that pointers are flat (ndSka: they are) */ free(y) ; } aligned_char_ref alloc (unsigned int n) { n = ALIGNMENT + n - (n & (ALIGNMENT - 1)) ; /* XXX: could overflow */ if (n <= avail) { avail -= n ; return space + avail ; } return malloc(n) ; } int alloc_re (void **x, unsigned int m, unsigned int n) { aligned_char_ref y = alloc(n) ; if (!y) return 0 ; byte_copy(y, m, (char *)*x) ; alloc_free(*x) ; *x = y ; return 1 ; } int alloc_realloc (void **x, unsigned int n) { register char *z = *x ; if ((z >= space) && (z < space + SPACE)) return 0 ; else { aligned_char_ref y = realloc(z, n) ; if (!y) return 0 ; *x = y ; return 1 ; } } prog/skalibs-0.47/src/libstddjb/sareadlink.c0100644000000000000000000000075407773344303015763 0ustar /* Public domain. */ #include #include "stralloc.h" #include "djbunix.h" int sareadlink (stralloc *sa, char const *path) { unsigned int n = 128 ; unsigned char wasnull = !sa->s ; register int r ; for (;;) { if (!stralloc_readyplus(sa, n)) goto err ; r = readlink(path, sa->s + sa->len, n) ; if (r < 0) goto err ; if ((unsigned int)r < n) break ; n += 128 ; } sa->len += r ; return 0 ; err: if (wasnull) stralloc_free(sa) ; return -1 ; } prog/skalibs-0.47/src/libstddjb/dirname.c0100644000000000000000000000062011051750023015235 0ustar /* Public domain. */ /* MT-unsafe */ #include "bytestr.h" #include "stralloc.h" #include "djbunix.h" char *dirname (char *s) { static stralloc dirname_sa = STRALLOC_ZERO ; static char dot0[2] = "." ; char *dot = dot0 ; if (!s) return dot ; dirname_sa.len = 0 ; if (!sadirname(&dirname_sa, s, str_len(s))) return 0 ; if (!stralloc_0(&dirname_sa)) return 0 ; return dirname_sa.s ; } prog/skalibs-0.47/src/libstddjb/basename.c0100644000000000000000000000062711051747715015416 0ustar /* Public domain. */ /* MT-unsafe */ #include "bytestr.h" #include "stralloc.h" #include "djbunix.h" char *basename (char *s) { static stralloc basename_sa = STRALLOC_ZERO ; static char dot0[2] = "." ; char *dot = dot0 ; if (!s) return dot ; basename_sa.len = 0 ; if (!sabasename(&basename_sa, s, str_len(s))) return 0 ; if (!stralloc_0(&basename_sa)) return 0 ; return basename_sa.s ; } prog/skalibs-0.47/src/libstddjb/uintalloc.c0100644000000000000000000000022607772676707015651 0ustar /* Public domain. */ #undef USE_DJBALLOC #include "gen_alloc.h" #include "uintalloc.h" GEN_ALLOC_BASE_DEFS(uintalloc, unsigned int, s, len, a, 256) prog/skalibs-0.47/src/libstddjb/long_fmt.c0100644000000000000000000000026610003222710015422 0ustar /* Public domain. */ #include "fmtscan.h" unsigned int long_fmt (char *fmt, long n) { if (n >= 0) return ulong_fmt(fmt, n) ; *fmt++ = '-' ; return 1 + ulong_fmt(fmt, -n) ; } prog/skalibs-0.47/src/libstddjb/strn_fmt.c0100644000000000000000000000072010003753016015454 0ustar /* Public domain. */ #include "fmtscan.h" unsigned int strn_fmt (char *blah, register char const *s, unsigned int len) { register char *d = blah ; unsigned int i ; for (i = 0 ; i < len ; i++) if ((s[i] >= 32) && ((unsigned char)s[i] < 127)) *d++ = s[i] ; else { *d++ = '\\' ; *d++ = '0' ; *d++ = 'x' ; if ((unsigned char)s[i] < 16) *d++ = '0' ; d += uint_xfmt(d, (unsigned char)s[i]) ; } return d - blah ; } prog/skalibs-0.47/src/libstddjb/cdb.h0100644000000000000000000000274011100046312014352 0ustar /* Public domain. */ #ifndef CDB_H #define CDB_H #include "gccattributes.h" #include "uint32.h" #define CDB_HASHSTART 5381 extern uint32 cdb_hashadd (uint32, unsigned char) gccattr_const ; extern uint32 cdb_hash (char const *, unsigned int) gccattr_pure ; struct cdb { char *map ; /* 0 if no map is available */ int fd ; uint32 size ; /* initialized if map is nonzero */ uint32 loop ; /* number of hash slots searched under this key */ uint32 khash ; /* initialized if loop is nonzero */ uint32 kpos ; /* initialized if loop is nonzero */ uint32 hpos ; /* initialized if loop is nonzero */ uint32 hslots ; /* initialized if loop is nonzero */ uint32 dpos ; /* initialized if cdb_findnext() returns 1 */ uint32 dlen ; /* initialized if cdb_findnext() returns 1 */ } ; #define CDB_ZERO { 0, -1, 0, 0, 0, 0, 0, 0, 0, 0 } extern void cdb_free (struct cdb *) ; extern int cdb_init (struct cdb *, int fd) ; extern int cdb_read (struct cdb *, char *, unsigned int, uint32) ; extern void cdb_findstart (struct cdb *) ; extern int cdb_findnext (struct cdb *, char const *, unsigned int) ; extern int cdb_find (struct cdb *, char const *, unsigned int) ; #define cdb_datapos(c) ((c)->dpos) #define cdb_datalen(c) ((c)->dlen) #define cdb_keypos(c) ((c)->kpos) #define cdb_keylen(c) ((c)->dpos - (c)->kpos) extern int cdb_firstkey (struct cdb *, uint32 *) ; extern int cdb_nextkey (struct cdb *, uint32 *) ; extern int cdb_successor (struct cdb *, char const *, unsigned int) ; #endif prog/skalibs-0.47/src/libstddjb/doublefork.c0100644000000000000000000000144410324522646015771 0ustar #include #include "uint32.h" #include "allreadwrite.h" #include "djbunix.h" int doublefork () { char pack[4] ; int fd[2] ; int child ; if (pipe(fd) == -1) return -1 ; switch (child = fork()) { case -1: return -1 ; case 0: { int pid ; fd_close(fd[0]) ; switch (pid = fork()) { case -1: _exit(111) ; case 0: fd_close(fd[1]) ; return 0 ; } uint32_pack(pack, (uint32)pid) ; _exit((allwrite(fd[1], pack, 4) < 4) ? 111 : 0) ; } } fd_close(fd[1]) ; { uint32 grandchild = 0 ; int wstat ; if (allread(fd[0], pack, 4) < 4) grandchild = 1 ; fd_close(fd[0]) ; wait_pid(&wstat, child) ; if (grandchild) return -1 ; uint32_unpack(pack, &grandchild) ; return (int)grandchild ; } } prog/skalibs-0.47/src/libstddjb/wait_reap.c0100644000000000000000000000025507666446520015622 0ustar /* Public domain. */ #include "djbunix.h" unsigned int wait_reap () { register unsigned int n = 0 ; int wstat ; while (wait_nohang(&wstat) > 0) n++ ; return n ; } prog/skalibs-0.47/src/libstddjb/waitn.c0100644000000000000000000000063707762065445014775 0ustar /* Public domain. */ #include #include "djbunix.h" int waitn (int const *pids, register unsigned int n) { register unsigned int len = n ; while (len--) { int wstat ; register int pid = wait(&wstat) ; if (pid == -1) return -1 ; { register unsigned int i = 0 ; for (; i < n ; i++) if (pid == pids[i]) break ; if (i >= n) len++ ; } } return 0 ; } prog/skalibs-0.47/src/libstddjb/sig_stack.c0100644000000000000000000000144710024362333015577 0ustar /* Public domain. */ /* MT-unsafe */ #include #include #include "sig.h" #include "nsig.h" static struct skasigaction skasigstack[NSIG][SIGSTACKSIZE] ; static unsigned int sigsp[NSIG] ; /* XXX: depends on auto-init to 0 */ int sig_pusha (int sig, struct skasigaction const *ssa) { if ((sig <= 0) || (sig > NSIG)) return (errno = EINVAL, -1) ; if (sigsp[sig-1] >= SIGSTACKSIZE) return (errno = ENOBUFS, -1) ; if (skasigaction(sig, ssa, &skasigstack[sig-1][sigsp[sig-1]]) == -1) return -1 ; return ++sigsp[sig-1] ; } int sig_pop (int sig) { if ((sig <= 0) || (sig > NSIG)) return (errno = EINVAL, -1) ; if (!sigsp[sig-1]) return (errno = EFAULT, -1); if (skasigaction(sig, &skasigstack[sig-1][sigsp[sig-1]-1], 0) == -1) return -1 ; return --sigsp[sig-1] ; } prog/skalibs-0.47/src/libstddjb/buffer_fill.c0100644000000000000000000000042307772634474016130 0ustar /* Public domain. */ #include #include "buffer.h" int buffer_fill (buffer_ref b) { register int r ; buffer_clean(b) ; if (b->n == b->a) return (errno = ENOBUFS, -1) ; r = (*b->op)(b->fd, b->x + b->n, b->a - b->n) ; if (r > 0) b->n += r ; return r ; } prog/skalibs-0.47/src/libstddjb/buffer_getall.c0100644000000000000000000000135310263742501016431 0ustar /* Public domain. */ #include #include "allreadwrite.h" #include "buffer.h" int buffer_getall (buffer_ref b, char *buf, unsigned int len, unsigned int *written) { if (*written > len) return (errno = EINVAL, -1) ; *written += buffer_getnofill(b, buf + *written, len - *written) ; if (*written >= len) return (*written = 0, 1) ; if ((len - *written) >= b->a) { *written += allreadwrite((iofunc_t_ref)b->op, b->fd, buf + *written, len - *written) ; return (*written >= len) ? (*written = 0, 2) : -1 ; } while (*written < len) { register int r = sanitize_read(buffer_fill(b)) ; if (r <= 0) return r ; *written += buffer_getnofill(b, buf + *written, len - *written) ; } *written = 0 ; return 2 ; } prog/skalibs-0.47/src/libstddjb/buffer_getnf.c0100644000000000000000000000043110007446751016264 0ustar /* Public domain. */ #include "bytestr.h" #include "buffer.h" unsigned int buffer_getnofill (register buffer_ref b, char *buf, unsigned int len) { if (len > buffer_len(b)) len = buffer_len(b) ; byte_copy(buf, len, buffer_RPEEK(b)) ; buffer_RSEEK(b, len) ; return len ; } prog/skalibs-0.47/src/libstddjb/buffer_putall.c0100644000000000000000000000061710006477541016470 0ustar /* Public domain. */ #include #include "buffer.h" int buffer_putall (buffer_ref b, char const *buf, unsigned int len, unsigned int *written) { if (*written > len) return (errno = EINVAL, -1) ; for (;;) { *written += buffer_putnoflush(b, buf + *written, len - *written) ; if (*written >= len) return 0 ; buffer_flush(b) ; if (!buffer_available(b)) return -1 ; } } prog/skalibs-0.47/src/libstddjb/buffer_getallnf.c0100644000000000000000000000042607772640310016763 0ustar /* Public domain. */ #include #include "buffer.h" int buffer_getallnofill (buffer_ref b, char *buf, unsigned int len) { register unsigned int r = buffer_getnofill(b, buf, len) ; if (r == len) return 0 ; buffer_unget(b, r) ; errno = ENOBUFS ; return -1 ; } prog/skalibs-0.47/src/libstddjb/buffer_bget.c0100644000000000000000000000051207772637742016123 0ustar /* Public domain. */ #include "buffer.h" int buffer_bget (buffer_ref b, char *buf, unsigned int len) { register int r = (int)buffer_getnofill(b, buf, len) ; if (r) return r ; if (len >= b->a) return (*b->op)(b->fd, buf, b->a) ; r = buffer_fill(b) ; if (r <= 0) return r ; return (int)buffer_getnofill(b, buf, len) ; } prog/skalibs-0.47/src/libstddjb/buffer_putallnf.c0100644000000000000000000000043607772637506017032 0ustar /* Public domain. */ #include #include "buffer.h" int buffer_putallnoflush (buffer_ref b, char const *buf, unsigned int len) { register unsigned int r = buffer_putnoflush(b, buf, len) ; if (r == len) return 0 ; buffer_unput(b, r) ; errno = ENOBUFS ; return -1 ; } prog/skalibs-0.47/src/libstddjb/buffer_flush.c0100644000000000000000000000034010007444060016270 0ustar /* Public domain. */ #include "allreadwrite.h" #include "buffer.h" int buffer_flush (buffer_ref b) { b->p += allreadwrite(b->op, b->fd, b->x + b->p, b->n - b->p) ; buffer_clean(b) ; return buffer_len(b) ? -1 : 0 ; } prog/skalibs-0.47/src/libstddjb/buffer_putnf.c0100644000000000000000000000054410007447127016320 0ustar /* Public domain. */ #include "bytestr.h" #include "buffer.h" unsigned int buffer_putnoflush (buffer_ref b, char const *buf, unsigned int len) { if (len > buffer_available(b)) { buffer_clean(b) ; if (len > buffer_available(b)) len = buffer_available(b) ; } byte_copy(buffer_WPEEK(b), len, buf) ; buffer_WSEEK(b, len) ; return len ; } prog/skalibs-0.47/src/libstddjb/execvep_tmp.c0100644000000000000000000000222310024073337016143 0ustar /* Public domain. */ #include #include #include "bytestr.h" #include "stralloc.h" #include "djbunix.h" void execvep_tmp (char const *file, char const *const *argv, char const *const *envp, char const *path, stralloc *tmp) { if (!path) errno = EINVAL ; else if (file[str_chr(file, '/')]) execve(file, (char *const *)argv, (char *const *)envp) ; /* prototype stupidity */ else { unsigned int tmpbase = tmp->len ; int savederrno = 0 ; for (;;) { unsigned int split = str_chr(path, ':') ; tmp->len = tmpbase ; if (!(split ? stralloc_catb(tmp, path, split) : stralloc_catb(tmp, ".", 1)) || !stralloc_catb(tmp, "/", 1) || !stralloc_cats(tmp, file) || !stralloc_0(tmp)) break ; execve(tmp->s + tmpbase, (char *const *)argv, (char *const *)envp) ; /* sigh */ if (errno != ENOENT) { savederrno = errno ; if ((errno != EACCES) && (errno != EPERM) && (errno != EISDIR)) break ; } if (!path[split]) { if (savederrno) errno = savederrno ; break ; } path += split + 1 ; } tmp->len = tmpbase ; } } prog/skalibs-0.47/src/libstddjb/ucspi_get.c0100644000000000000000000000023410024362757015615 0ustar /* Public domain. */ /* MT-unsafe */ #include "skamisc.h" #include "env.h" char const *ucspi_get (char const *s) { return ucspi_get_tmp(s, &satmp) ; } prog/skalibs-0.47/src/libstddjb/uint16_scan.c0100644000000000000000000000014610003755102015752 0ustar /* Public domain. */ #include "uint16.h" #include "fmtscan-internal.h" SCANU(uint16, uint16, 65535) prog/skalibs-0.47/src/libstddjb/skamisc.h0100644000000000000000000000072011100030244015245 0ustar /* Public domain. */ #ifndef SKAMISC_H #define SKAMISC_H /* sucky name, eh ? */ #include "buffer.h" #include "stralloc.h" extern stralloc satmp ; extern int skagetln (buffer_ref, stralloc *, int) ; extern int skagetlnsep (buffer_ref, stralloc *, char const *, unsigned int) ; extern int sauniquename (stralloc *) ; #define skaoffsetof(n, s, field) do { s sofoftmp ; *(n) = (unsigned char *)&sofoftmp->field - (unsigned char *)&sofoftmp ; } while (0) #endif prog/skalibs-0.47/src/libstddjb/short_scan.c0100644000000000000000000000053110324523256015772 0ustar /* Public domain. */ #include "fmtscan.h" unsigned int short_scan (char const *s, short *n) { if ((*s == '-') || (*s == '+')) { unsigned short tmp ; register unsigned int r = ushort_scan(s+1, &tmp) ; if (!r) return 0 ; *n = (*s == '-') ? -tmp : tmp ; return r + 1 ; } return ushort_scan(s, (unsigned short *)n) ; } prog/skalibs-0.47/src/libstddjb/long_scan.c0100644000000000000000000000052310324523312015564 0ustar /* Public domain. */ #include "fmtscan.h" unsigned int long_scan (char const *s, long *n) { if ((*s == '-') || (*s == '+')) { unsigned long tmp ; register unsigned int r = ulong_scan(s+1, &tmp) ; if (!r) return 0 ; *n = (*s == '-') ? -tmp : tmp ; return r + 1 ; } return ulong_scan(s, (unsigned long *)n) ; } prog/skalibs-0.47/src/libstddjb/socket_timeoutconn.c0100644000000000000000000000047510023106505017540 0ustar /* Public domain. */ #include "uint16.h" #include "tai.h" #include "socket.h" int socket_timeoutconn (int s, char const *ip, uint16 port, unsigned int timeout) { struct taia deadline ; taia_now(&deadline) ; taia_addsec(&deadline, &deadline, timeout) ; return socket_deadlineconn(s, ip, port, &deadline) ; } prog/skalibs-0.47/src/libstddjb/uncoe.c0100644000000000000000000000033210041255527014736 0ustar /* Public domain. */ #include #include "djbunix.h" int uncoe (int fd) { register int flags = fcntl(fd, F_GETFD, 0) ; if (flags == -1) return -1 ; return fcntl(fd, F_SETFD, flags & ~FD_CLOEXEC) ; } prog/skalibs-0.47/src/libstddjb/openreadnclose.c0100644000000000000000000000056407773053101016637 0ustar #include #include "allreadwrite.h" #include "djbunix.h" int openreadnclose (char const *file, char *s, unsigned int n) { register int r ; int fd = open_readb(file) ; if (fd == -1) return -1 ; r = allread(fd, s, n) ; if (r == -1) { fd_close(fd) ; return -1 ; } fd_close(fd) ; if ((r > 0) && (r < (int)n)) errno = EPIPE ; return r ; } prog/skalibs-0.47/src/libstddjb/fmtscan_asc.c0100644000000000000000000000030210324523054016100 0ustar /* Public domain. */ #include "fmtscan.h" unsigned char fmtscan_asc (unsigned char c) { static char const *tab = "0123456789abcdefghijklmnopqrstuvwxyz" ; return (c >= 36) ? 0 : tab[c] ; } prog/skalibs-0.47/src/libstddjb/buffer_putalign.c0100644000000000000000000000047310324522304017001 0ustar /* Public domain. */ #include #include "error.h" #include "buffer.h" int buffer_putalign (buffer_ref b, char const *buf, unsigned int len) { unsigned int written = 0 ; register int r = buffer_putall(b, buf, len, &written) ; if ((r == -1) && !error_isagain(errno)) return -1 ; return written ; } prog/skalibs-0.47/src/libstddjb/buffer_putsalign.c0100644000000000000000000000025207666446520017203 0ustar /* Public domain. */ #include "bytestr.h" #include "buffer.h" int buffer_putsalign (buffer_ref b, char const *buf) { return buffer_putalign(b, buf, str_len(buf)) ; } prog/skalibs-0.47/src/libstddjb/buffer_putflush.c0100644000000000000000000000052707773620011017040 0ustar /* Public domain. */ #include #include "error.h" #include "buffer.h" int buffer_putflush (buffer_ref b, char const *buf, unsigned int len) { unsigned int written = 0 ; if (buffer_putall(b, buf, len, &written) == -1) return error_isagain(errno) ? (int)written : -1 ; return (buffer_flush(b) == -1) ? -1 : (int)written ; } prog/skalibs-0.47/src/libstddjb/buffer_putsflush.c0100644000000000000000000000025207666446520017232 0ustar /* Public domain. */ #include "bytestr.h" #include "buffer.h" int buffer_putsflush (buffer_ref b, char const *buf) { return buffer_putflush(b, buf, str_len(buf)) ; } prog/skalibs-0.47/src/libstddjb/buffer_puts.c0100644000000000000000000000024007666446520016165 0ustar /* Public domain. */ #include "bytestr.h" #include "buffer.h" int buffer_puts (buffer_ref b, char const *buf) { return buffer_put(b, buf, str_len(buf)) ; } prog/skalibs-0.47/src/libstddjb/buffer_clean.c0100644000000000000000000000032407772633751016261 0ustar /* Public domain. */ #include "bytestr.h" #include "buffer.h" void buffer_clean (register buffer_ref b) { if (b->p) { byte_copy(b->x, b->n - b->p, b->x + b->p) ; b->n -= b->p ; b->p = 0 ; } } prog/skalibs-0.47/src/libstddjb/buffer_putc.c0100644000000000000000000000017307772673176016161 0ustar /* Public domain. */ #include "buffer.h" int buffer_PUTC (buffer_ref b, char c) { return buffer_putalign(b, &c, 1) ; } prog/skalibs-0.47/src/libstddjb/buffer_seek.c0100644000000000000000000000020307772640734016121 0ustar /* Public domain. */ #include "buffer.h" void buffer_seek (register buffer_ref b, register unsigned int len) { b->p += len ; } prog/skalibs-0.47/src/libstddjb/buffer_feed.c0100644000000000000000000000023307772633765016106 0ustar /* Public domain. */ #include "buffer.h" int buffer_feed (register buffer_ref b) { return (b->n > b->p) ? ((int)b->n - (int)b->p) : buffer_fill(b) ; } prog/skalibs-0.47/src/libstddjb/buffer_init.c0100644000000000000000000000037007772640064016136 0ustar /* Public domain. */ #include "allreadwrite.h" #include "buffer.h" void buffer_init (register buffer_ref b, iofunc_t_ref op, int fd, char *buf, unsigned int len) { b->x = buf ; b->a = len ; b->fd = fd ; b->op = op ; b->p = b->n = 0 ; } prog/skalibs-0.47/src/libstddjb/str_diffb.c0100644000000000000000000000024607666446520015611 0ustar /* Public domain. */ #include "bytestr.h" int str_diffb (register char const *s, register unsigned int n, register char const *t) { return str_diffn(s, t, n) ; } prog/skalibs-0.47/src/libstddjb/uint32_reverse.c0100644000000000000000000000034507666446520016526 0ustar /* Public domain. */ #include "uint32.h" void uint32_reverse (char *s, unsigned int n) { while (n--) { char c = s[0] ; s[0] = s[3] ; s[3] = c ; c = s[1] ; s[1] = s[2] ; s[2] = c ; s += 4 ; } } prog/skalibs-0.47/src/libstddjb/uint64_reverse.c0100644000000000000000000000044507666446520016534 0ustar /* Public domain. */ #include "uint64.h" void uint64_reverse (char *s, unsigned int n) { while (n--) { char c = s[0] ; s[0] = s[7] ; s[7] = c ; c = s[1] ; s[1] = s[6] ; s[6] = c ; c = s[2] ; s[2] = s[5] ; s[5] = c ; c = s[3] ; s[3] = s[4] ; s[4] = c ; s += 8 ; } } prog/skalibs-0.47/src/libstddjb/uint16_reverse.c0100644000000000000000000000026507666446520016531 0ustar /* Public domain. */ #include "uint16.h" void uint16_reverse (char *s, unsigned int n) { while (n--) { char c = s[0] ; s[0] = s[1] ; s[1] = c ; s += 2 ; } } prog/skalibs-0.47/src/libstddjb/fmtscan_num.c0100644000000000000000000000055710004007716016142 0ustar /* Public domain. */ #include "fmtscan.h" unsigned char fmtscan_num (register unsigned char c, unsigned char n) { return ((c < '0') || (n > 36)) ? n : (n <= 10) ? (c - '0' <= n) ? c - '0' : n : (c - '0' <= 9) ? c - '0' : (c < 'A') ? n : (c - 'A' < n - 10) ? c - 'A' + 10 : (c < 'a') ? n : (c - 'a' < n - 10) ? c - 'a' + 10 : n ; } prog/skalibs-0.47/src/libstddjb/skasig_dfl.c0100644000000000000000000000025410005160532015725 0ustar /* Public domain. */ #include #include "sig.h" struct skasigaction const SKASIG_DFL = { SIG_DFL, 0 } ; struct skasigaction const SKASIG_IGN = { SIG_IGN, 0 } ; prog/skalibs-0.47/src/libstddjb/env_get.c0100644000000000000000000000020507763257230015265 0ustar /* Public domain. */ #include "env.h" #include "environ.h" char const *env_get (char const *s) { return env_get2(environ, s) ; } prog/skalibs-0.47/src/libstddjb/taia_ulong.c0100644000000000000000000000022007676421234015755 0ustar /* Public domain. */ #include "tai.h" void taia_ulong (struct taia *t, unsigned long s) { tai_u64(&t->sec, s) ; t->nano = t->atto = 0 ; } prog/skalibs-0.47/src/libstddjb/uint32alloc.c0100644000000000000000000000025007772677024016004 0ustar /* Public domain. */ #undef USE_DJBALLOC #include "uint32.h" #include "gen_alloc.h" #include "uint32alloc.h" GEN_ALLOC_BASE_DEFS(uint32alloc, uint32, s, len, a, 256) prog/skalibs-0.47/src/libstddjb/bufalloc_flush.c0100644000000000000000000000041210006716677016625 0ustar /* Public domain. */ #include "allreadwrite.h" #include "bufalloc.h" int bufalloc_flush (register bufalloc_ref ba) { ba->p += allreadwrite((iofunc_t_ref)ba->op, ba->fd, ba->x.s + ba->p, ba->x.len - ba->p) ; bufalloc_clean(ba) ; return ba->x.len ? -1 : 0 ; } prog/skalibs-0.47/src/libstddjb/bufalloc_init.c0100644000000000000000000000035007772635404016454 0ustar /* Public domain. */ #include "stralloc.h" #include "bufalloc.h" void bufalloc_init (bufalloc_ref ba, int (*op)(int, char const *, unsigned int), int fd) { stralloc_free(&ba->x) ; ba->op = op ; ba->fd = fd ; ba->p = 0 ; } prog/skalibs-0.47/src/libstddjb/gen_alloc.h0100644000000000000000000001125411074722241015561 0ustar /* Public domain. */ #ifndef GEN_ALLOC_H #define GEN_ALLOC_H #include "alloc.h" /* .h */ #define GEN_ALLOC_ZERO { 0, 0, 0 } #define GEN_ALLOC_typedef(ta, type, s, len, a) \ typedef struct ta { type *s ; unsigned int len ; unsigned int a ; } ta, *ta##_ref ; #define GEN_ALLOC_FPROTOTYPES(ta, type, s, len, a) \ extern int ta##_ready (ta *, unsigned int) ; \ extern int ta##_readyplus (ta *, unsigned int) ; \ extern void ta##_free (ta *) ; \ extern void ta##_clean (ta *) ; \ extern int ta##_copyb (ta *, type const *, unsigned int) ; \ extern int ta##_copy (ta *, ta const *) ; \ extern int ta##_catb (ta *, type const *, unsigned int) ; \ extern int ta##_cat (ta *, ta const *) ; \ extern int ta##_append (ta *, type const *) ; \ extern void ta##_reverse (ta *) ; \ extern void ta##_zerolen (ta *) ; \ extern void ta##_deepfree (ta *) ; \ #define GEN_ALLOC_PROTOTYPES(ta, type, s, len, a) \ GEN_ALLOC_typedef(ta, type, s, len, a) \ GEN_ALLOC_FPROTOTYPES(ta, type, s, len, a) \ /* .c */ #define GEN_ALLOC_ready(ta, type, s, len, a, base) \ int ta##_ready (register ta *x, register unsigned int n) \ { \ register unsigned int t = (base) + n + (n >> 3) ; \ if (!x->s) \ { \ type *p = (type *)alloc(t * sizeof(type)) ; \ if (!p) return 0 ; \ x->s = p ; \ x->a = t ; \ } \ else if (n > x->a) \ { \ if (!alloc_re((void **)(void *)(&x->s), x->a * sizeof(type), t * sizeof(type))) \ return 0 ; \ x->a = t ; \ } \ return 1 ; \ } \ #define GEN_ALLOC_readyplus(ta, type, s, len, a) \ int ta##_readyplus (register ta *x, register unsigned int n) \ { \ return ta##_ready(x, n + x->len) ; \ } \ #define GEN_ALLOC_free(ta, type, s, len, a) \ void ta##_free (register ta *x) \ { \ alloc_free(x->s) ; x->s = 0 ; \ x->a = x->len = 0 ; \ } \ #define GEN_ALLOC_clean(ta, type, s, len, a) \ void ta##_clean (register ta *x) \ { \ if (x->a > x->len) \ { \ alloc_realloc((void **)(void *)(&x->s), x->len * sizeof(type)) ; \ x->a = x->len ; \ } \ } \ #define GEN_ALLOC_copyb(ta, type, s, len, a) \ int ta##_copyb (register ta *sa, register type const *x, unsigned int n) \ { \ if (!ta##_ready(sa, n)) return 0 ; \ { \ unsigned int i = 0 ; \ for ( ; i < n ; i++) sa->s[i] = x[i] ; \ } \ sa->len = n ; \ return 1 ; \ } \ #define GEN_ALLOC_copy(ta, type, s, len, a) \ int ta##_copy (register ta *to, register ta const *from) \ { \ return ta##_copyb(to, from->s, from->len) ; \ } \ #define GEN_ALLOC_catb(ta, type, s, len, a) \ int ta##_catb (register ta *sa, register type const *x, unsigned int n) \ { \ if (!ta##_readyplus(sa, n)) return 0 ; \ { \ unsigned int i = 0 ; \ for ( ; i < n ; i++) sa->s[sa->len + i] = x[i] ; \ } \ sa->len += n ; \ return 1 ; \ } \ #define GEN_ALLOC_cat(ta, type, s, len, a) \ int ta##_cat (register ta *to, register ta const *from) \ { \ return ta##_catb(to, from->s, from->len) ; \ } \ #define GEN_ALLOC_append(ta, type, s, len, a) \ int ta##_append (register ta *x, register type const *i) \ { \ return ta##_catb(x, i, 1) ; \ } \ #define GEN_ALLOC_reverse(ta, type, s, len, a) \ void ta##_reverse (register ta *x) \ { \ register unsigned int i = 0 ; \ for (; i < (x->len) >> 1 ; i++) \ { \ type tmp = x->s[i] ; \ x->s[i] = x->s[x->len - 1 - i] ; \ x->s[x->len - 1 - i] = tmp ; \ } \ } \ #define GEN_ALLOC_BASE_DEFS(ta, type, s, len, a, base) \ GEN_ALLOC_ready(ta, type, s, len, a, base) \ GEN_ALLOC_readyplus(ta, type, s, len, a) \ GEN_ALLOC_free(ta, type, s, len, a) \ GEN_ALLOC_catb(ta, type, s, len, a) \ #define GEN_ALLOC_STATIC_BASE_DEFS(ta, type, s, len, a, base) \ static GEN_ALLOC_ready(ta, type, s, len, a, base) \ static GEN_ALLOC_readyplus(ta, type, s, len, a) \ static GEN_ALLOC_free(ta, type, s, len, a) \ static GEN_ALLOC_catb(ta, type, s, len, a) \ #define GEN_ALLOC_EXTENDED_DEFS(ta, type, s, len, a) \ GEN_ALLOC_clean(ta, type, s, len, a) \ GEN_ALLOC_copyb(ta, type, s, len, a) \ GEN_ALLOC_copy(ta, type, s, len, a) \ GEN_ALLOC_cat(ta, type, s, len, a) \ GEN_ALLOC_append(ta, type, s, len, a) \ GEN_ALLOC_reverse(ta, type, s, len, a) \ #define GEN_ALLOC_STATIC_EXTENDED_DEFS(ta, type, s, len, a) \ static GEN_ALLOC_clean(ta, type, s, len, a) \ static GEN_ALLOC_copyb(ta, type, s, len, a) \ static GEN_ALLOC_copy(ta, type, s, len, a) \ static GEN_ALLOC_cat(ta, type, s, len, a) \ static GEN_ALLOC_append(ta, type, s, len, a) \ static GEN_ALLOC_reverse(ta, type, s, len, a) \ #define GEN_ALLOC_DEFS(ta, type, s, len, a, base) \ GEN_ALLOC_BASE_DEFS(ta, type, s, len, a, base) \ GEN_ALLOC_EXTENDED_DEFS(ta, type, s, len, a) \ #define GEN_ALLOC_STATIC_DEFS(ta, type, s, len, a, base) \ GEN_ALLOC_STATIC_BASE_DEFS(ta, type, s, len, a, base) \ GEN_ALLOC_STATIC_EXTENDED_DEFS(ta, type, s, len, a) \ #endif prog/skalibs-0.47/src/libstddjb/bufalloc_clean.c0100644000000000000000000000036010006716545016562 0ustar /* Public domain. */ #include "bytestr.h" #include "bufalloc.h" void bufalloc_clean (register bufalloc_ref ba) { if (ba->p) { byte_copy(ba->x.s, ba->x.len - ba->p, ba->x.s + ba->p) ; ba->x.len -= ba->p ; ba->p = 0 ; } } prog/skalibs-0.47/src/libstddjb/sig.h0100644000000000000000000000310510005424373014412 0ustar /* Public domain. */ #ifndef SIG_H #define SIG_H #include "gccattributes.h" extern int sig_alarm gccattr_deprecated ; extern int sig_child gccattr_deprecated ; extern int sig_stop gccattr_deprecated ; extern int sig_cont gccattr_deprecated ; extern int sig_hangup gccattr_deprecated ; extern int sig_int gccattr_deprecated ; extern int sig_kill gccattr_deprecated ; extern int sig_pipe gccattr_deprecated ; extern int sig_term gccattr_deprecated ; extern int sig_usr1 gccattr_deprecated ; extern int sig_usr2 gccattr_deprecated ; extern int sig_quit gccattr_deprecated ; extern int sig_abort gccattr_deprecated ; typedef void skasighandler_t (int) ; typedef skasighandler_t *skasighandler_t_ref ; struct skasigaction { skasighandler_t_ref handler ; unsigned char flags ; } ; #define SKASA_MASKALL 0x01 #define SKASA_NOCLDSTOP 0x02 extern struct skasigaction const SKASIG_DFL ; extern struct skasigaction const SKASIG_IGN ; extern int skasigaction (int, struct skasigaction const *, struct skasigaction *) ; extern int sig_catcha (int, struct skasigaction const *) ; extern int sig_restore (int) ; extern int sig_catch (int, skasighandler_t_ref) ; #define sig_ignore(s) sig_catcha((s), &SKASIG_IGN) #define sig_uncatch sig_restore #define SIGSTACKSIZE 16 extern int sig_pusha (int, struct skasigaction const *) ; extern int sig_pop (int) ; extern int sig_push (int, skasighandler_t_ref) ; extern void sig_block (int) ; extern void sig_unblock (int) ; extern void sig_blocknone (void) ; extern void sig_pause (void) ; extern void sig_shield (void) ; extern void sig_unshield (void) ; #endif prog/skalibs-0.47/src/libstddjb/uint16_unpack_big.c0100644000000000000000000000032307666446520017153 0ustar /* Public domain. */ #include "uint16.h" #include "bytestr.h" void uint16_unpack_big (char const *s, uint16 *u) { uint16 r = T8((unsigned char)s[0]) ; r <<= 8 ; r += T8((unsigned char)s[1]) ; *u = r ; } prog/skalibs-0.47/src/libstddjb/nsig.h0100644000000000000000000000007310005151622014563 0ustar /* Public domain. */ #ifndef NSIG # define NSIG 64 #endif prog/skalibs-0.47/src/libstddjb/socket.h0100644000000000000000000000200611100046312015105 0ustar /* Public domain */ #ifndef SOCKET_H #define SOCKET_H #include "gccattributes.h" #include "uint16.h" #include "tai.h" extern int socket_tcp (void) ; extern int socket_udp (void) ; extern int socket_deadlineconn (int, char const *, uint16, struct taia const *) ; extern int socket_timeoutconn (int, char const *, uint16, unsigned int) ; extern int socket_connect4 (int, char const *, uint16) ; extern int socket_connected (int) gccattr_const ; extern int socket_bind4 (int, char const *, uint16) ; extern int socket_bind4_reuse (int, char const *, uint16) ; extern int socket_listen (int, int) ; extern int socket_accept4 (int, char *, uint16 *) ; extern int socket_recv4 (int, char *, int, char *, uint16 *) ; extern int socket_send4 (int, char const *, int, char const *, uint16) ; extern int socket_local4 (int, char *, uint16 *) ; extern int socket_remote4 (int, char *, uint16 *) ; extern int socket_ipoptionskill (int) ; extern int socket_tcpnodelay (int) ; extern void socket_tryreservein (int, unsigned int) ; #endif prog/skalibs-0.47/src/libstddjb/uint16_pack_big.c0100644000000000000000000000027707666446520016620 0ustar /* Public domain. */ #include "uint16.h" #include "bytestr.h" void uint16_pack_big (char *s, uint16 u) { ((unsigned char *)s)[1] = T8(u) ; u >>= 8 ; ((unsigned char *)s)[0] = T8(u) ; } prog/skalibs-0.47/src/libstddjb/uint640_fmt.c0100644000000000000000000000042210003776641015707 0ustar /* Public domain. */ #include "uint64.h" unsigned int uint640_fmt_base (char *s, uint64 x, register unsigned int n, unsigned char base) { register unsigned int len = uint64_fmt_base(0, x, base) ; while (n-- > len) *s++ = '0' ; return uint64_fmt_base(s, x, base) ; } prog/skalibs-0.47/src/libstddjb/uint32_pack_big.c0100644000000000000000000000043307666446520016610 0ustar /* Public domain. */ #include "uint32.h" #include "bytestr.h" void uint32_pack_big (char *s, uint32 u) { ((unsigned char *)s)[3] = T8(u) ; u >>= 8 ; ((unsigned char *)s)[2] = T8(u) ; u >>= 8 ; ((unsigned char *)s)[1] = T8(u) ; u >>= 8 ; ((unsigned char *)s)[0] = T8(u) ; } prog/skalibs-0.47/src/libstddjb/rmstar.c0100644000000000000000000000023610024361402015127 0ustar /* Public domain. */ /* MT-unsafe */ #include "skamisc.h" #include "djbunix.h" int rmstar (char const *dirname) { return rmstar_tmp(dirname, &satmp) ; } prog/skalibs-0.47/src/libstddjb/socket_accept.c0100644000000000000000000000106610324523751016442 0ustar /* Public domain. */ #include #include #include #include #include #include "uint16.h" #include "bytestr.h" #include "socket.h" int socket_accept4 (int s, char *ip, uint16 *port) { struct sockaddr_in sa ; socklen_t dummy = sizeof sa ; register int fd ; do fd = accept(s, (struct sockaddr *)&sa, &dummy) ; while ((fd == -1) && (errno == EINTR)) ; if (fd == -1) return -1 ; byte_copy(ip, 4, (char *)&sa.sin_addr) ; uint16_unpack_big((char *)&sa.sin_port, port) ; return fd ; } prog/skalibs-0.47/src/libstddjb/socket_bind.c0100644000000000000000000000072107772661772016137 0ustar /* Public domain. */ #include #include #include #include #include "uint16.h" #include "bytestr.h" #include "socket.h" int socket_bind4 (int s, char const *ip, uint16 port) { struct sockaddr_in sa ; byte_zero(&sa, sizeof sa) ; sa.sin_family = AF_INET ; uint16_pack_big((char *)&sa.sin_port, port) ; byte_copy((char *)&sa.sin_addr, 4, ip) ; return bind(s, (struct sockaddr *)&sa, sizeof sa) ; } prog/skalibs-0.47/src/libstddjb/socket_conn.c0100644000000000000000000000110207772711072016137 0ustar /* Public domain. */ #include #include #include #include #include #include "uint16.h" #include "bytestr.h" #include "socket.h" int socket_connect4 (int s, char const *ip, uint16 port) { struct sockaddr_in sa ; register int r ; byte_zero(&sa, sizeof sa) ; sa.sin_family = AF_INET ; uint16_pack_big((char *)&sa. sin_port,port) ; byte_copy((char *)&sa.sin_addr, 4, ip) ; r = connect(s, (struct sockaddr *)&sa, sizeof sa) ; if ((r == -1) && (errno == EINTR)) errno = EINPROGRESS ; return r ; } prog/skalibs-0.47/src/libstddjb/socket_delay.c0100644000000000000000000000041507772662145016314 0ustar /* Public domain. */ #include #include #include #include #include "socket.h" int socket_tcpnodelay (int s) { int opt = 1 ; return setsockopt(s, IPPROTO_TCP, 1, &opt, sizeof opt) ; /* 1 == TCP_NODELAY */ } prog/skalibs-0.47/src/libstddjb/socket_listen.c0100644000000000000000000000024307773121714016504 0ustar /* Public domain. */ #include #include #include "socket.h" int socket_listen (int s, int backlog) { return listen(s, backlog) ; } prog/skalibs-0.47/src/libstddjb/socket_local.c0100644000000000000000000000073110324524027016270 0ustar /* Public domain. */ #include #include #include #include #include "uint16.h" #include "bytestr.h" #include "socket.h" int socket_local4 (int s, char *ip, uint16 *port) { struct sockaddr_in sa ; socklen_t dummy = sizeof sa ; if (getsockname(s, (struct sockaddr *)&sa, &dummy) == -1) return -1 ; byte_copy(ip, 4, (char *)&sa.sin_addr) ; uint16_unpack_big((char *)&sa.sin_port, port) ; return 0 ; } prog/skalibs-0.47/src/libstddjb/socket_opts.c0100644000000000000000000000036207666446520016203 0ustar /* Public domain. */ #include #include #include #include #include "socket.h" int socket_ipoptionskill (int s) { return setsockopt(s, IPPROTO_IP, 1, 0, 0) ; /* 1 == IP_OPTIONS */ } prog/skalibs-0.47/src/libstddjb/socket_recv.c0100644000000000000000000000111610324524064016134 0ustar /* Public domain. */ #include #include #include #include #include #include "uint16.h" #include "bytestr.h" #include "socket.h" int socket_recv4 (int s, char *buf, int len, char *ip, uint16 *port) { struct sockaddr_in sa ; socklen_t dummy = sizeof sa ; register int r ; do r = recvfrom(s, buf, len, 0, (struct sockaddr *)&sa, &dummy) ; while ((r == -1) && (errno == EINTR)) ; if (r == -1) return -1 ; byte_copy(ip, 4, (char *)&sa.sin_addr) ; uint16_unpack_big((char *)&sa.sin_port, port) ; return r ; } prog/skalibs-0.47/src/libstddjb/socket_remote.c0100644000000000000000000000073210324524050016466 0ustar /* Public domain. */ #include #include #include #include #include "uint16.h" #include "bytestr.h" #include "socket.h" int socket_remote4 (int s, char *ip, uint16 *port) { struct sockaddr_in sa ; socklen_t dummy = sizeof sa ; if (getpeername(s, (struct sockaddr *)&sa, &dummy) == -1) return -1 ; byte_copy(ip, 4, (char *)&sa.sin_addr) ; uint16_unpack_big((char *)&sa.sin_port, port) ; return 0 ; } prog/skalibs-0.47/src/libstddjb/socket_send.c0100644000000000000000000000113707772672570016154 0ustar /* Public domain. */ #include #include #include #include #include #include "uint16.h" #include "bytestr.h" #include "socket.h" int socket_send4 (int s, char const *buf, int len, char const *ip, uint16 port) { struct sockaddr_in sa ; register int r ; byte_zero((char *)&sa, sizeof sa) ; sa.sin_family = AF_INET ; uint16_pack_big((char *)&sa.sin_port, port) ; byte_copy((char *)&sa.sin_addr, 4, ip) ; do r = sendto(s, buf, len, 0, (struct sockaddr *)&sa, sizeof sa) ; while ((r == -1) && (errno == EINTR)) ; return r ; } prog/skalibs-0.47/src/libstddjb/socket_tcp.c0100644000000000000000000000061410022643020015752 0ustar /* Public domain. */ #include #include #include #include #include #include "djbunix.h" #include "socket.h" int socket_tcp () { int s = socket(AF_INET, SOCK_STREAM, 0) ; if (s == -1) return -1 ; if (ndelay_on(s) == -1) { register int e = errno ; fd_close(s) ; errno = e ; return -1 ; } return s ; } prog/skalibs-0.47/src/libstddjb/dir_close.c0100644000000000000000000000041107772654406015606 0ustar /* Public domain. */ #include #include "direntry.h" int dir_close (DIR *dir) { register unsigned int done = 0 ; doit: done++ ; if (!closedir(dir)) return 0 ; if (errno == EINTR) goto doit ; return ((errno == EBADF) && (done > 1)) ? 0 : -1 ; } prog/skalibs-0.47/src/libstddjb/socket_bindr.c0100644000000000000000000000045207666446520016314 0ustar /* Public domain. */ #include #include #include "uint16.h" #include "socket.h" int socket_bind4_reuse (int s, char const *ip, uint16 port) { unsigned int opt = 1 ; setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof opt) ; return socket_bind4(s, ip, port) ; } prog/skalibs-0.47/src/libstddjb/socket_tryr.c0100644000000000000000000000043307666446520016215 0ustar /* Public domain. */ #include #include #include "socket.h" void socket_tryreservein (int s, unsigned int size) { while (size >= 1024) { if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, &size, sizeof size) == 0) return ; size -= (size >> 5) ; } } prog/skalibs-0.47/src/libstddjb/selfpipe.c0100644000000000000000000000251610325510156015437 0ustar /* Public domain. */ /* MT-unsafe */ #include #include #include "allreadwrite.h" #include "uint64.h" #include "error.h" #include "djbunix.h" #include "sig.h" #include "nsig.h" #include "selfpipe.h" static int selfpipe[2] = { -1, -1 } ; static uint64 caught ; static void selfpipe_trigger (int s) { char c = (char)s ; fd_write(selfpipe[1], &c, 1) ; } static void selfpipe_close (void) { register int e = errno ; fd_close(selfpipe[1]) ; fd_close(selfpipe[0]) ; selfpipe[0] = selfpipe[1] = -1 ; errno = e ; } int selfpipe_init (void) { if (selfpipe[0] >= 0) return (errno = EBUSY, -1) ; if (pipe(selfpipe) == -1) return -1 ; if ((ndelay_on(selfpipe[1]) == -1) || (coe(selfpipe[1]) == -1) || (ndelay_on(selfpipe[0]) == -1) || (coe(selfpipe[0]) == -1)) selfpipe_close() ; return selfpipe[0] ; } int selfpipe_trap (int sig) { struct skasigaction ssa = { &selfpipe_trigger, SKASA_NOCLDSTOP | SKASA_MASKALL } ; if (sig_catcha(sig, &ssa) == -1) return -1 ; caught |= (1 << (sig-1)) ; return 0 ; } int selfpipe_read (void) { char c ; register int r = sanitize_read((fd_read(selfpipe[0], &c, 1))) ; return (r <= 0) ? r : (int)c ; } void selfpipe_finish (void) { register unsigned int i = 1 ; for (; i <= NSIG ; caught >>= 1, i++) if (caught & 1) sig_restore(i) ; selfpipe_close() ; } prog/skalibs-0.47/src/libstddjb/socket_connected.c0100644000000000000000000000062610324524010017133 0ustar /* Public domain. */ #include #include #include #include #include "allreadwrite.h" #include "socket.h" int socket_connected (int s) { struct sockaddr_in sa ; socklen_t dummy = sizeof sa ; if (getpeername(s, (struct sockaddr *)&sa, &dummy) == -1) { char ch ; fd_read(s, &ch, 1) ; /* sets errno */ return 0 ; } return 1 ; } prog/skalibs-0.47/src/libstddjb/stralloc.h0100644000000000000000000000131011100030244015432 0ustar /* Public domain. */ #ifndef STRALLOC_H #define STRALLOC_H #include "gccattributes.h" #include "gen_alloc.h" GEN_ALLOC_PROTOTYPES(stralloc, char, s, len, a) #define STRALLOC_ZERO GEN_ALLOC_ZERO #define stralloc_shrink(sa) stralloc_clean(sa) extern int stralloc_copys (stralloc *, char const *) ; extern int stralloc_cats (stralloc *, char const *) ; extern int stralloc_starts (stralloc *, char const *) gccattr_pure ; extern int stralloc_insertb (stralloc *, unsigned int, char const *, unsigned int) ; extern int stralloc_inserts (stralloc *, unsigned int, char const *) ; extern int stralloc_insert (stralloc *, unsigned int, stralloc const *) ; #define stralloc_0(sa) stralloc_catb(sa, "", 1) #endif prog/skalibs-0.47/src/libstddjb/allreadwrite.h0100644000000000000000000000134310007473124016311 0ustar /* Public domain. */ #ifndef ALLREADWRITE_H #define ALLREADWRITE_H typedef int iofunc_t (int, char *, unsigned int) ; typedef iofunc_t *iofunc_t_ref ; typedef unsigned int alliofunc_t (int, char *, unsigned int) ; typedef alliofunc_t *alliofunc_t_ref ; extern int sanitize_read (int) ; extern unsigned int allreadwrite (iofunc_t_ref, int, char *, unsigned int) ; extern int fd_read (int, char *, unsigned int) ; extern int fd_write (int, char const *, unsigned int) ; extern int fd_recv (int, char *, unsigned int, unsigned int) ; extern int fd_send (int, char const *, unsigned int, unsigned int) ; extern unsigned int allread (int, char *, unsigned int) ; extern unsigned int allwrite (int, char const *, unsigned int) ; #endif prog/skalibs-0.47/src/libstddjb/intalloc.h0100644000000000000000000000026211100030244015421 0ustar /* Public domain. */ #ifndef INTALLOC_H #define INTALLOC_H #include "gen_alloc.h" GEN_ALLOC_PROTOTYPES(intalloc, int, s, len, a) #define INTALLOC_ZERO GEN_ALLOC_ZERO #endif prog/skalibs-0.47/src/libstddjb/iobuffer.h0100644000000000000000000000131210007474631015433 0ustar /* Public domain. */ #ifndef IOBUFFER_H #define IOBUFFER_H #include "buffer.h" typedef struct iobuffer iobuffer, *iobuffer_ref ; struct iobuffer { buffer in ; buffer out ; } ; #define IOBUFFER_INIT(fdin, fdout, buf, len) {BUFFER_INIT(&buffer_unixread, (fdin), (buf), (len)), BUFFER_INIT(&buffer_unixwrite, (fdout), (buf), (len))} extern void iobuffer_init (iobuffer_ref, int, int, char *, unsigned int) ; extern int iobuffer_fill (iobuffer_ref) ; extern int iobuffer_flush (iobuffer_ref) ; #define iobuffer_len(b) buffer_len(&(b)->in) #define iobuffer_isempty(b) buffer_isempty(&(b)->in) #define iobuffer_available(b) buffer_available(&(b)->out) #define iobuffer_isfull(b) buffer_isfull(&(b)->out) #endif prog/skalibs-0.47/src/libstddjb/intalloc.c0100644000000000000000000000021307772676643015457 0ustar /* Public domain. */ #undef USE_DJBALLOC #include "gen_alloc.h" #include "intalloc.h" GEN_ALLOC_BASE_DEFS(intalloc, int, s, len, a, 256) prog/skalibs-0.47/src/libstddjb/bufalloc.h0100644000000000000000000000154211100030244015405 0ustar /* Public domain. */ #ifndef BUFALLOC_H #define BUFALLOC_H #include "stralloc.h" typedef struct bufalloc bufalloc, *bufalloc_ref ; struct bufalloc { stralloc x ; unsigned int p ; int fd ; int (*op) (int, char const *, unsigned int) ; } ; #define BUFALLOC_ZERO { STRALLOC_ZERO, 0, -1, 0 } #define BUFALLOC_INIT(op, fd) { STRALLOC_ZERO, 0, (fd), (op) } extern void bufalloc_init (bufalloc_ref, int (*)(int, char const *, unsigned int), int) ; #define bufalloc_shrink(ba) stralloc_shrink(&(ba)->x) #define bufalloc_free(ba) stralloc_free(&(ba)->x) #define bufalloc_put(ba, s, n) stralloc_catb(&(ba)->x, (s), (n)) extern int bufalloc_flush (bufalloc_ref) ; extern void bufalloc_clean (bufalloc_ref) ; #define bufalloc_len(ba) ((ba)->x.len - (ba)->p) #define bufalloc_isempty(ba) ((ba)->x.len == (ba)->p) extern bufalloc_ref bufalloc_1, bufalloc_2 ; #endif prog/skalibs-0.47/src/libstddjb/uint64_scan.c0100644000000000000000000000065110003777255015773 0ustar /* Public domain. */ #include "uint64.h" #include "fmtscan.h" unsigned int uint64_scan_upto_base (char const *s, uint64 *u, uint64 n, unsigned char base) { uint64 result = 0 ; unsigned int pos = 0 ; for (;; pos++) { register unsigned char c = fmtscan_num(s[pos], base) ; if ((c >= base) || (result > ((n - c) / base))) break ; result = result * base + c ; } if (pos) *u = result ; return pos ; } prog/skalibs-0.47/src/libstddjb/str_rchr.c0100644000000000000000000000074307763251016015467 0ustar /* Public domain. */ #include "bytestr.h" #ifdef USE_BASE_LIBC #include unsigned int str_rchr (register char const *s, int c) { register char *p = strrchr(s, c) ; return p ? (unsigned int)(p - s) : (unsigned int)strlen(s) ; } #else unsigned int str_rchr (register char const *s, int c) { register char ch = c ; register char const *t = s ; register char const *u = 0 ; for ( ; *t ; t++) if (*t == ch) u = t ; if (!u) u = t ; return u - s ; } #endif prog/skalibs-0.47/src/libstddjb/uint16alloc.h0100644000000000000000000000032511100046312015760 0ustar /* Public domain. */ #ifndef UINT16ALLOC_H #define UINT16ALLOC_H #include "uint16.h" #include "gen_alloc.h" GEN_ALLOC_PROTOTYPES(uint16alloc, uint16, s, len, a) #define UINT16ALLOC_ZERO GEN_ALLOC_ZERO #endif prog/skalibs-0.47/src/libstddjb/byte_in.c0100644000000000000000000000044107666446520015275 0ustar /* Public domain. */ #include "bytestr.h" unsigned int byte_in (char const *s, register unsigned int n, register char const *sep, register unsigned int len) { register char const *t = s ; while (n--) { if (byte_chr(sep, len, *t) < len) break ; ++t ; } return t - s ; } prog/skalibs-0.47/src/libstddjb/sgetopt.h0100644000000000000000000000176710024362644015334 0ustar /* Public domain. */ #ifndef SGETOPT_H #define SGETOPT_H /* reentrant */ struct subgetopt_t { int ind ; int err ; int problem ; char const *arg ; unsigned int pos ; char const *prog ; } ; #define SUBGETOPT_ZERO { 1, 1, 0, 0, 0, 0 } extern int subgetopt_r (int, char const *const *, char const *, struct subgetopt_t *) ; /* non-reentrant */ extern int sgetopt_r (int, char const *const *, char const *, struct subgetopt_t *) ; extern struct subgetopt_t subgetopt_here ; #define subgetopt(argc, argv, opts) subgetopt_r((argc), (argv), (opts), &subgetopt_here) #define sgetopt(argc, argv, opts) sgetopt_r((argc), (argv), (opts), &subgetopt_here) #define sgetopt_prog() (subgetopt_here.prog = PROG) /* define SUBGETOPTNOSHORT to avoid potential name conflicts */ #ifndef SUBGETOPTNOSHORT # define getopt sgetopt # define optarg subgetopt_here.arg # define optind subgetopt_here.ind # define opterr subgetopt_here.err # define optopt subgetopt_here.problem # define opteof (-1) #endif #endif prog/skalibs-0.47/src/libstddjb/bytestr.h0100644000000000000000000000402207753472321015337 0ustar /* Public domain. */ #ifndef BYTESTR_H #define BYTESTR_H #include "gccattributes.h" /* for Alphas and other archs where char != 8bit */ #define T8(x) ((x) & 0xffU) extern unsigned int byte_chr (char const *, unsigned int, int) gccattr_pure ; extern unsigned int byte_rchr (char const *, unsigned int, int) gccattr_pure ; extern unsigned int byte_in (char const *, unsigned int, char const *, unsigned int) gccattr_pure ; extern void byte_copy (char *, unsigned int, char const *) ; extern void byte_copyr (char *, unsigned int, char const *) ; extern int byte_diff (char const *, unsigned int, char const *) gccattr_pure ; extern void byte_zero (void *, unsigned int) ; #define byte_equal(s, n, t) (!byte_diff((s), (n), (t))) extern unsigned int byte_count (char const *, unsigned int, char) gccattr_pure ; extern void case_lowers (char *) ; extern void case_lowerb (char *, unsigned int) ; extern void case_uppers (char *) ; extern void case_upperb (char *, unsigned int) ; #define case_equals(a, b) (!case_diffs((a), (b))) #define case_equalb(a, n, b) (!case_diffb((a), (n), (b))) extern int case_diffs (char const *, char const *) gccattr_pure ; extern int case_diffb (char const *, unsigned int, char const *) gccattr_pure ; extern int case_starts (char const *, char const *) gccattr_pure ; extern int case_startb (char const *, unsigned int, char const *) gccattr_pure ; extern unsigned int str_copy (char *, char const *) ; extern int str_diff (char const *, char const *) gccattr_pure ; extern int str_diffn (char const *, char const *, unsigned int) gccattr_pure ; extern int str_diffb (char const *, unsigned int, char const *) gccattr_pure ; extern unsigned int str_len (char const *) gccattr_pure ; extern unsigned int str_chr (char const *, int) gccattr_pure ; extern unsigned int str_rchr (char const *, int) gccattr_pure ; extern int str_start (char const *, char const *) gccattr_pure ; #define str_equal(s, t) (!str_diff((s), (t))) extern unsigned int str_strn (char const *, unsigned int, char const *, unsigned int) gccattr_pure ; #endif prog/skalibs-0.47/src/libstddjb/pathexec_r.c0100644000000000000000000000050710024357250015750 0ustar /* Public domain. */ /* MT-unsafe */ #include "gen_alloc.h" #include "stralloc.h" #include "djbunix.h" #include "skamisc.h" void pathexec_r (char const *const *argv, char const *const *envp, unsigned int envlen, char const *modifs, unsigned int modiflen) { pathexec_r_tmp(argv, envp, envlen, modifs, modiflen, &satmp) ; } prog/skalibs-0.47/src/libstddjb/allwrite.c0100644000000000000000000000027610006715570015457 0ustar /* Public domain. */ #include "allreadwrite.h" unsigned int allwrite (int fd, char const *buf, unsigned int len) { return allreadwrite((iofunc_t_ref)&fd_write, fd, (char *)buf, len) ; } prog/skalibs-0.47/src/libstddjb/netstring.h0100644000000000000000000000130711100030244015632 0ustar /* Public domain. */ #ifndef NETSTRING_H #define NETSTRING_H #include "buffer.h" #include "stralloc.h" extern int netstring_appendb (stralloc *, char const *, unsigned int) ; #define netstring_appends(sa, s) netstring_appendb((sa), (s), str_len(s)) #define netstring_append(to, from) netstring_appendb((to), (from)->s, (from)->len) extern int netstring_encode (stralloc *, char const *, unsigned int) ; extern int netstring_decode (stralloc *, char const *, unsigned int) ; extern int netstring_get (buffer_ref, stralloc *, unsigned int *) ; extern int netstring_put (buffer_ref, char const *, unsigned int, unsigned int *) ; #define netstring_putba(ba, s, n) netstring_appendb(&(ba)->x, (s), (n)) #endif prog/skalibs-0.47/src/libstddjb/env_len.c0100644000000000000000000000024307666446520015272 0ustar /* Public domain. */ #include "env.h" unsigned int env_len (register char const *const *e) { register unsigned int i = 0 ; while (*e++) i++ ; return i ; } prog/skalibs-0.47/src/libstddjb/sig_unblock.c0100644000000000000000000000045010005153465016123 0ustar /* Public domain. */ #include #include "sysdeps.h" #include "sig.h" void sig_unblock (int sig) { #ifdef HASSIGPROCMASK sigset_t ss ; sigemptyset(&ss) ; sigaddset(&ss, sig) ; sigprocmask(SIG_UNBLOCK, &ss, 0) ; #else sigsetmask(sigsetmask(~0) & ~(1 << (sig - 1))) ; #endif } prog/skalibs-0.47/src/libstddjb/sig_blocknone.c0100644000000000000000000000035210005153423016433 0ustar /* Public domain. */ #include #include "sysdeps.h" #include "sig.h" void sig_blocknone () { #ifdef HASSIGPROCMASK sigset_t ss ; sigemptyset(&ss) ; sigprocmask(SIG_SETMASK, &ss, 0) ; #else sigsetmask(0) ; #endif } prog/skalibs-0.47/src/libstddjb/env.h0100644000000000000000000000110711100030244014403 0ustar /* Public domain. */ #ifndef ENV_H #define ENV_H #include "gccattributes.h" #include "stralloc.h" extern unsigned int env_len (char const *const *) gccattr_pure ; extern char const *env_get (char const *) gccattr_pure ; extern char const *env_get2 (char const *const *, char const *) gccattr_pure ; extern char const *ucspi_get (char const *) gccattr_pure ; extern char const *ucspi_get_tmp (char const *, stralloc *) gccattr_pure ; extern int env_addmodif (stralloc *, char const *, char const *) ; extern int env_string (stralloc *, char const *const *, unsigned int) ; #endif prog/skalibs-0.47/src/libstddjb/sig_push.c0100644000000000000000000000032010024362263015440 0ustar /* Public domain. */ /* MT-unsafe */ #include "sig.h" int sig_push (int sig, skasighandler_t_ref f) { struct skasigaction ssa = { f, SKASA_MASKALL | SKASA_NOCLDSTOP } ; return sig_pusha(sig, &ssa) ; } prog/skalibs-0.47/src/libstddjb/iobuffer_init.c0100644000000000000000000000041407666446520016470 0ustar /* Public domain. */ #include "buffer.h" #include "iobuffer.h" void iobuffer_init (iobuffer_ref b, int fdin, int fdout, char *x, unsigned int len) { buffer_init(&b->in, &buffer_unixread, fdin, x, len) ; buffer_init(&b->out, &buffer_unixwrite, fdout, x, len) ; } prog/skalibs-0.47/src/libstddjb/taia_scan.c0100644000000000000000000000037410003730416015546 0ustar /* Public domain. */ #include "fmtscan.h" #include "tai.h" unsigned int taia_scan (char const *s, struct taia *a) { char pack[TAIA_PACK] ; register unsigned int r = scan_ucharn(s, pack, TAIA_PACK) ; if (r) taia_unpack(pack, a) ; return r ; } prog/skalibs-0.47/src/libstddjb/sig_unshield.c0100644000000000000000000000103310174163756016312 0ustar /* Public domain. */ #include #include "sysdeps.h" #include "sig.h" void sig_unshield () { #ifdef HASSIGPROCMASK sigset_t ss ; sigemptyset(&ss) ; sigaddset(&ss, SIGTERM) ; sigaddset(&ss, SIGQUIT) ; sigaddset(&ss, SIGABRT) ; sigaddset(&ss, SIGINT) ; sigaddset(&ss, SIGPIPE) ; sigaddset(&ss, SIGHUP) ; sigprocmask(SIG_UNBLOCK, &ss, 0) ; #else sigsetmask(sigsetmask(~0) & ~((1 << (SIGTERM-1)) | (1 << (SIGQUIT-1)) | (1 << (SIGABRT-1)) | (1 << (SIGINT-1)) | (1 << (SIGPIPE-1)) | (1 << (SIGHUP-1)))) ; #endif } prog/skalibs-0.47/src/libstddjb/uint64_pack_big.c0100644000000000000000000000072307666446520016617 0ustar /* Public domain. */ #include "uint64.h" #include "bytestr.h" void uint64_pack_big (char *s, uint64 u) { ((unsigned char *)s)[7] = T8(u) ; u >>= 8 ; ((unsigned char *)s)[6] = T8(u) ; u >>= 8 ; ((unsigned char *)s)[5] = T8(u) ; u >>= 8 ; ((unsigned char *)s)[4] = T8(u) ; u >>= 8 ; ((unsigned char *)s)[3] = T8(u) ; u >>= 8 ; ((unsigned char *)s)[2] = T8(u) ; u >>= 8 ; ((unsigned char *)s)[1] = T8(u) ; u >>= 8 ; ((unsigned char *)s)[0] = T8(u) ; } prog/skalibs-0.47/src/libstddjb/fd_move2.c0100644000000000000000000000153407772726461015354 0ustar /* Public domain. */ #include #include #include "djbunix.h" int fd_move2 (int to1, int from1, int to2, int from2) { register int tmp = from2 ; if (to1 == from1) return fd_move(to2, from2) ; if (to2 == from2) return fd_move(to1, from1) ; if (from1 == from2) return (to1 == to2) ? fd_move(to1, from1) : (errno = EINVAL, -1) ; if (to1 == to2) return (errno = EINVAL, -1) ; if (from2 == to1) { tmp = dup(from2) ; if (tmp == -1) return -1 ; } if (fd_copy(to1, from1) == -1) { register int e = errno ; if (from2 != tmp) fd_close(tmp) ; errno = e ; return -1 ; } if (fd_copy(to2, tmp) == -1) { register int e = errno ; fd_close(to1) ; if (from2 != tmp) fd_move(from2, tmp) ; errno = e ; return -1 ; } if (from1 != to2) fd_close(from1) ; fd_close(tmp) ; return 0 ; } prog/skalibs-0.47/src/libstddjb/tain_scan.c0100644000000000000000000000037410003730416015563 0ustar /* Public domain. */ #include "fmtscan.h" #include "tai.h" unsigned int tain_scan (char const *s, struct taia *a) { char pack[TAIN_PACK] ; register unsigned int r = scan_ucharn(s, pack, TAIN_PACK) ; if (r) tain_unpack(pack, a) ; return r ; } prog/skalibs-0.47/src/libstddjb/fd_copy2.c0100644000000000000000000000055407772725355015362 0ustar /* Public domain. */ #include #include #include "djbunix.h" int fd_copy2 (int to1, int from1, int to2, int from2) { if ((to1 == from2) || (to2 == from1)) return (errno = EINVAL, -1) ; if (fd_copy(to1, from1) == -1) return -1 ; if (fd_copy(to2, from2) == -1) { if (to1 != from1) fd_close(to1) ; return -1 ; } return 0 ; } prog/skalibs-0.47/src/libstddjb/uint0_scan.c0100644000000000000000000000020310003730416015656 0ustar /* Public domain. */ #include #include "fmtscan.h" #include "fmtscan-internal.h" SCANU0(uint, unsigned int, UINT_MAX) prog/skalibs-0.47/src/libstddjb/stralloc_erts.c0100644000000000000000000000030507666446520016523 0ustar /* Public domain. */ #include "bytestr.h" #include "stralloc.h" int stralloc_inserts (stralloc *to, unsigned int offset, char const *s) { return stralloc_insertb(to, offset, s, str_len(s)) ; } prog/skalibs-0.47/src/libstddjb/stralloc_ertb.c0100644000000000000000000000052307666446520016504 0ustar /* Public domain. */ #include "bytestr.h" #include "stralloc.h" int stralloc_insertb (stralloc *to, unsigned int offset, char const *s, unsigned int n) { if (!stralloc_readyplus(to, n)) return 0 ; byte_copyr(to->s + offset + n, to->len - offset, to->s + offset) ; to->len += n ; byte_copyr(to->s + offset, n, s) ; return 1 ; } prog/skalibs-0.47/src/libstddjb/buffer_putallf.c0100644000000000000000000000033507773473416016651 0ustar /* Public domain. */ #include "buffer.h" int buffer_putallflush (buffer_ref b, char const *buf, unsigned int len, unsigned int *written) { return (buffer_putall(b, buf, len, written) == -1) ? -1 : buffer_flush(b) ; } prog/skalibs-0.47/src/libstddjb/uint32_unpack_big.c0100644000000000000000000000045107666446520017153 0ustar /* Public domain. */ #include "uint32.h" #include "bytestr.h" void uint32_unpack_big (char const *s, uint32 *u) { uint32 r = T8((unsigned char)s[0]) ; r <<= 8 ; r += T8((unsigned char)s[1]) ; r <<= 8 ; r += T8((unsigned char)s[2]) ; r <<= 8 ; r += T8((unsigned char)s[3]) ; *u = r ; } prog/skalibs-0.47/src/libstddjb/uint64_unpack_big.c0100644000000000000000000000072507666446520017164 0ustar /* Public domain. */ #include "uint64.h" #include "bytestr.h" void uint64_unpack_big (char const *s, uint64 *u) { uint64 r = T8((unsigned char)s[0]) ; r <<= 8 ; r += T8((unsigned char)s[1]) ; r <<= 8 ; r += T8((unsigned char)s[2]) ; r <<= 8 ; r += T8((unsigned char)s[3]) ; r <<= 8 ; r += T8((unsigned char)s[4]) ; r <<= 8 ; r += T8((unsigned char)s[5]) ; r <<= 8 ; r += T8((unsigned char)s[6]) ; r <<= 8 ; r += T8((unsigned char)s[7]) ; *u = r ; } prog/skalibs-0.47/src/libstddjb/lock_sh.c0100644000000000000000000000054407772705700015266 0ustar /* Public domain. */ #include #include #include #include #include #include "sysdeps.h" #include "djbunix.h" int lock_sh (int fd) { register int r ; do #ifdef HASFLOCK r = flock(fd, LOCK_SH) ; #else r = lockf(fd, 1, 0) ; #endif while ((r == -1) && (errno == EINTR)) ; return r ; } prog/skalibs-0.47/src/libstddjb/lock_shnb.c0100644000000000000000000000044707666446520015614 0ustar /* Public domain. */ #include #include #include #include #include "sysdeps.h" #include "djbunix.h" #ifdef HASFLOCK int lock_shnb (int fd) { return flock(fd, LOCK_SH | LOCK_NB) ; } #else int lock_shnb (int fd) { return lockf(fd, 2, 0) ; } #endif prog/skalibs-0.47/src/libstddjb/environ.h0100644000000000000000000000012107666446520015324 0ustar #ifndef ENVIRON_H #define ENVIRON_H extern char const *const *environ ; #endif prog/skalibs-0.47/src/libstddjb/wait_pid_nohang.c0100644000000000000000000000034407666446520017000 0ustar /* Public domain. */ #include "djbunix.h" int wait_pid_nohang (int *wstat, int pid) { int w = 0 ; int r = 0 ; while (r != pid) { r = wait_nohang(&w) ; if (r <= 0) return r ; } *wstat = w ; return pid ; } prog/skalibs-0.47/src/libstddjb/rm_rf_tmp.c0100644000000000000000000000056410024073510015610 0ustar /* Public domain. */ #include "stralloc.h" #include "djbunix.h" int rm_rf_tmp (char const *filename, stralloc *tmp) { unsigned int tmpbase = tmp->len ; if (!stralloc_cats(tmp, filename)) return -1 ; if (!stralloc_0(tmp)) goto err ; if (rm_rf_in_tmp(tmp, tmpbase) == -1) goto err ; tmp->len = tmpbase ; return 0 ; err: tmp->len = tmpbase ; return -1 ; } prog/skalibs-0.47/src/libstddjb/uint16alloc.c0100644000000000000000000000025007772676760016014 0ustar /* Public domain. */ #undef USE_DJBALLOC #include "uint16.h" #include "gen_alloc.h" #include "uint16alloc.h" GEN_ALLOC_BASE_DEFS(uint16alloc, uint16, s, len, a, 256) prog/skalibs-0.47/src/libstddjb/uint64alloc.c0100644000000000000000000000025007772677062016013 0ustar /* Public domain. */ #undef USE_DJBALLOC #include "uint64.h" #include "gen_alloc.h" #include "uint64alloc.h" GEN_ALLOC_BASE_DEFS(uint64alloc, uint64, s, len, a, 256) prog/skalibs-0.47/src/libstddjb/open3.c0100644000000000000000000000045207772756072014676 0ustar /* Public domain. */ #include #include #include #include int open3 (char const *s, unsigned int flags, unsigned int mode) { register int r ; do r = open(s, (int)flags, (mode_t)mode) ; while ((r == -1) && (errno == EINTR)) ; return r ; } prog/skalibs-0.47/src/libstddjb/taia_tai.c0100644000000000000000000000016207666446520015417 0ustar /* Public domain. */ #include "tai.h" void taia_tai (struct taia const *ta, struct tai *t) { *t = ta->sec ; } prog/skalibs-0.47/src/libstddjb/uint64alloc.h0100644000000000000000000000032511100046312015763 0ustar /* Public domain. */ #ifndef UINT64ALLOC_H #define UINT64ALLOC_H #include "uint64.h" #include "gen_alloc.h" GEN_ALLOC_PROTOTYPES(uint64alloc, uint64, s, len, a) #define UINT64ALLOC_ZERO GEN_ALLOC_ZERO #endif prog/skalibs-0.47/src/libstddjb/taia_half.c0100644000000000000000000000043707666446520015561 0ustar /* Public domain. */ #include "tai.h" void taia_half (struct taia *t, struct taia const *u) { t->atto = u->atto>>1 ; if (u->nano & 1) t->atto += 500000000UL ; t->nano = u->nano>>1 ; if (tai_sec(&u->sec) & 1) t->nano += 500000000UL ; tai_u64(&t->sec, tai_sec(&u->sec)>>1) ; } prog/skalibs-0.47/src/libstddjb/caltimedate.h0100644000000000000000000000225607666446520016133 0ustar /* Public domain. */ #ifndef CALTIMEDATE_H #define CALTIMEDATE_H #include "gccattributes.h" #include "tai.h" struct caldate { long year ; int month ; int day ; } ; extern unsigned int caldate_fmt (char *, struct caldate const *) ; extern unsigned int caldate_scan (char const *, struct caldate *) ; extern void caldate_frommjd (struct caldate *, long, int *, int *) ; extern long caldate_mjd (struct caldate const *) gccattr_pure ; extern void caldate_normalize (struct caldate *) ; extern void caldate_easter (struct caldate *) ; struct caltime { struct caldate date ; int hour ; int minute ; int second ; long offset ; } ; extern unsigned int caltime_fmt (char *, struct caltime const *) ; extern unsigned int caltime_scan (char const *, struct caltime *) ; extern void caltime_tai (struct caltime const *, struct tai *) ; extern void caltime_utc (struct caltime *, struct tai const *, int *, int *) ; extern int leapsecs_init (void) ; extern int leapsecs_readf_r (char const *, struct tai **) ; extern int leapsecs_read_r (struct tai **) ; extern int leapsecs_read (void) ; extern void leapsecs_add (struct tai *, int) ; extern int leapsecs_sub (struct tai *) ; #endif prog/skalibs-0.47/src/libstddjb/caldate_fmjd.c0100644000000000000000000000200207666446520016234 0ustar /* Public domain. */ #include "caltimedate.h" void caldate_frommjd (struct caldate *cd, long day, int *pwday, int *pyday) { long month ; int yday ; long 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 ; } prog/skalibs-0.47/src/libstddjb/caldate_fmt.c0100644000000000000000000000112307666446520016105 0ustar /* Public domain. */ #include "caltimedate.h" unsigned int caldate_fmt (char *s, struct caldate const *cd) { long x ; int i = 0 ; x = cd->year ; if (x < 0) x = -x ; do { ++i ; x /= 10 ; } while(x) ; if (s) { x = cd->year ; if (x < 0) { x = -x ; *s++ = '-' ; } s += i ; do { *--s = '0' + (x % 10) ; x /= 10 ; } while(x) ; s += i; x = cd->month ; s[0] = '-' ; s[2] = '0' + (x % 10) ; x /= 10 ; s[1] = '0' + (x % 10) ; x = cd->day ; s[3] = '-' ; s[5] = '0' + (x % 10) ; x /= 10; s[4] = '0' + (x % 10) ; } return (cd->year < 0) + i + 6 ; } prog/skalibs-0.47/src/libstddjb/caldate_mjd.c0100644000000000000000000000147207666446520016100 0ustar /* Public domain. */ #include "caltimedate.h" long caldate_mjd (struct caldate const *cd) { unsigned long times365[4] = { 0, 365, 730, 1095 } ; unsigned long times36524[4] = { 0, 36524UL, 73048UL, 109572UL } ; unsigned long montab[12] = { 0, 31, 61, 92, 122, 153, 184, 214, 245, 275, 306, 337 } ; /* month length after february is (306 * m + 5) / 10 */ long d = cd->day - 678882L ; long m = cd->month - 1 ; long y = cd->year ; d += 146097L * (y / 400) ; y %= 400 ; if (m >= 2) m -= 2 ; else { m += 10 ; --y ; } y += (m / 12) ; m %= 12 ; if (m < 0) { m += 12 ; --y ; } d += montab[m] ; d += 146097L * (y / 400) ; y %= 400 ; if (y < 0) { y += 400 ; d -= 146097L ; } d += times365[y & 3] ; y >>= 2 ; d += 1461L * (y % 25) ; y /= 25 ; d += times36524[y & 3] ; return d ; } prog/skalibs-0.47/src/libstddjb/caldate_scan.c0100644000000000000000000000115410003730416016222 0ustar /* Public domain. */ #include "caltimedate.h" unsigned int caldate_scan (char const *s, struct caldate *cd) { int sign = 1 ; char const *t = s ; unsigned long z = 0 ; unsigned long c ; if (*t == '-') { ++t ; sign = -1 ; } while ((c = (unsigned char) (*t - '0')) <= 9) { z = z * 10 + c ; ++t ; } cd->year = z * sign ; if (*t++ != '-') return 0 ; z = 0 ; while ((c = (unsigned char) (*t - '0')) <= 9) { z = z * 10 + c ; ++t ; } cd->month = z ; if (*t++ != '-') return 0 ; z = 0 ; while ((c = (unsigned char) (*t - '0')) <= 9) { z = z * 10 + c ; ++t ; } cd->day = z ; return t - s ; } prog/skalibs-0.47/src/libstddjb/caldate_norm.c0100644000000000000000000000021707666446520016275 0ustar /* Public domain. */ #include "caltimedate.h" void caldate_normalize (struct caldate *cd) { caldate_frommjd(cd, caldate_mjd(cd), 0, 0) ; } prog/skalibs-0.47/src/libstddjb/caldate_ster.c0100644000000000000000000000072007666446520016276 0ustar /* Public domain. */ #include "caltimedate.h" void caldate_easter (struct caldate *cd) { long y = cd->year ; long c = (y / 100) + 1 ; long t = 210 - (((c * 3) / 4) % 210) ; long j = y % 19 ; long n = 57 - ((14 + j * 11 + (c * 8 + 5) / 25 + t) % 30) ; if ((n == 56) && (j > 10)) --n ; if (n == 57) --n ; n -= ((((y % 28) * 5) / 4 + t + n + 2) % 7) ; if (n < 32) { cd->month = 3 ; cd->day = n ; } else { cd->month = 4 ; cd->day = n - 31 ; } } prog/skalibs-0.47/src/libstddjb/caltime_fmt.c0100644000000000000000000000150307666446520016130 0ustar /* Public domain. */ #include "caltimedate.h" unsigned int caltime_fmt (char *s, struct caltime const *ct) { long x ; unsigned int result = caldate_fmt(s, &ct->date) ; if (s) { s += result ; x = ct->hour ; s[0] = ' ' ; s[2] = '0' + (x % 10) ; x /= 10 ; s[1] = '0' + (x % 10) ; s += 3 ; x = ct->minute ; s[0] = ':' ; s[2] = '0' + (x % 10) ; x /= 10 ; s[1] = '0' + (x % 10) ; s += 3 ; x = ct->second ; s[0] = ':' ; s[2] = '0' + (x % 10) ; x /= 10 ; s[1] = '0' + (x % 10) ; s += 3 ; s[0] = ' ' ; x = ct->offset ; if (x < 0) { s[1] = '-' ; x = -x ; } else s[1] = '+' ; s[5] = '0' + (x % 10) ; x /= 10 ; s[4] = '0' + (x % 6) ; x /= 6 ; s[3] = '0' + (x % 10) ; x /= 10 ; s[2] = '0' + (x % 10) ; } return result + 15 ; } prog/skalibs-0.47/src/libstddjb/caltime_scan.c0100644000000000000000000000216610003730416016247 0ustar /* Public domain. */ #include "caltimedate.h" unsigned int caltime_scan (char const *s, struct caltime *ct) { unsigned long z = 0 ; unsigned long c ; int sign ; char const *t = s + caldate_scan(s, &ct->date) ; while ((*t == ' ') || (*t == '\t') || (*t == 'T')) ++t ; while ((c = (unsigned char) (*t - '0')) <= 9) { z = z * 10 + c ; ++t ; } ct->hour = z ; if (*t++ != ':') return 0 ; z = 0 ; while ((c = (unsigned char) (*t - '0')) <= 9) { z = z * 10 + c ; ++t ; } ct->minute = z ; if (*t != ':') ct->second = 0 ; else { ++t ; z = 0 ; while ((c = (unsigned char) (*t - '0')) <= 9) { z = z * 10 + c ; ++t ; } ct->second = z ; } while ((*t == ' ') || (*t == '\t')) ++t ; if (*t == '+') sign = 1 ; else if (*t == '-') sign = -1 ; else return 0 ; ++t ; c = (unsigned char) (*t++ - '0') ; if (c > 9) return 0; z = c ; c = (unsigned char) (*t++ - '0') ; if (c > 9) return 0; z = z * 10 + c ; c = (unsigned char) (*t++ - '0') ; if (c > 9) return 0; z = z * 6 + c ; c = (unsigned char) (*t++ - '0') ; if (c > 9) return 0; z = z * 10 + c ; ct->offset = z * sign ; return t - s ; } prog/skalibs-0.47/src/libstddjb/caltime_tai.c0100644000000000000000000000063707666446520016126 0ustar /* Public domain. */ #include "tai.h" #include "caltimedate.h" /* XXX: breaks tai encapsulation */ void caltime_tai (struct caltime const *ct, struct tai *t) { /* XXX: check for overflow? */ long day = caldate_mjd(&ct->date) ; long s = (ct->hour * 60 + ct->minute - ct->offset) * 60 + ct->second ; t->x = day * 86400ULL + 4611686014920671114ULL + (long long) s ; leapsecs_add(t, ct->second == 60) ; } prog/skalibs-0.47/src/libstddjb/leapsecs_init.c0100644000000000000000000000034210024356157016452 0ustar /* Public domain. */ /* MT-unsafe */ #include "caltimedate.h" int leapsecs_init () { static unsigned char flaginit = 0 ; if (flaginit) return 0 ; if (leapsecs_read() == -1) return -1 ; flaginit = 1 ; return 0 ; } prog/skalibs-0.47/src/libstddjb/caltime_utc.c0100644000000000000000000000110207666446520016130 0ustar /* Public domain. */ #include "uint64.h" #include "tai.h" #include "caltimedate.h" /* XXX: breaks tai encapsulation */ void caltime_utc (struct caltime *ct, struct tai const *t, int *pwday, int *pyday) { /* XXX: check for overflow? */ struct tai t2 = *t ; int leap = leapsecs_sub(&t2) ; uint64 u = t2.x + 58486UL ; unsigned long s = u % 86400UL ; ct->second = (s % 60) + leap ; s /= 60 ; ct->minute = s % 60 ; s /= 60 ; ct->hour = s ; u /= 86400UL ; caldate_frommjd(&ct->date, /*XXX*/(long) (u - 53375995543064ULL), pwday, pyday) ; ct->offset = 0 ; } prog/skalibs-0.47/src/libstddjb/tai_unpack.c0100644000000000000000000000021707666446520015763 0ustar /* Public domain. */ #include "uint64.h" #include "tai.h" void tai_unpack (char const *s, struct tai *t) { uint64_unpack_big(s, &t->x) ; } prog/skalibs-0.47/src/libstddjb/leapsecs_read_r.c0100644000000000000000000000025407666446520016761 0ustar /* Public domain. */ #include "tai.h" #include "caltimedate.h" int leapsecs_read_r (struct tai **leapsecs) { return leapsecs_readf_r("/etc/leapsecs.dat", leapsecs) ; } prog/skalibs-0.47/src/libstddjb/leapsecs_read.c0100644000000000000000000000045510024356563016430 0ustar /* Public domain. */ /* MT-unsafe */ #include "tai.h" #include "caltimedate.h" #include "leapsecs_internal.h" struct tai *leapsecs ; unsigned int leapsecs_num ; int leapsecs_read () { int n = leapsecs_read_r(&leapsecs) ; if (n < 0) return n ; leapsecs_num = (unsigned int)n ; return 0 ; } prog/skalibs-0.47/src/libstddjb/leapsecs_readf_r.c0100644000000000000000000000177107773053263017131 0ustar /* Public domain. */ #include #include #include #include #undef USE_DJBALLOC #include "alloc.h" #include "allreadwrite.h" #include "djbunix.h" #include "tai.h" #include "caltimedate.h" int leapsecs_readf_r (char const *s, struct tai **leapsecs) { struct stat st ; struct tai *t ; int n ; int i = 0 ; int fd = open_readb(s) ; if (fd == -1) { if (errno != ENOENT) return -1 ; if (*leapsecs) alloc_free((char *)*leapsecs) ; *leapsecs = 0 ; return 0 ; } if (fstat(fd, &st) == -1) { fd_close(fd) ; return -1 ; } t = (struct tai *)alloc(st.st_size) ; if (!t) { fd_close(fd) ; return -1 ; } n = allread(fd, (char *)t, st.st_size) ; fd_close(fd) ; if (n < (int)st.st_size) { alloc_free((char *)t) ; return -1 ; } n /= sizeof(struct tai) ; for (; i < n ; i++) { struct tai u ; tai_unpack((char *)&t[i], &u) ; t[i] = u ; } if (*leapsecs) alloc_free((char *)*leapsecs) ; *leapsecs = t ; return n ; } prog/skalibs-0.47/src/libstddjb/leapsecs_add.c0100644000000000000000000000063110024356513016234 0ustar /* Public domain */ /* MT-unsafe */ #include "tai.h" #include "caltimedate.h" #include "leapsecs_internal.h" /* XXX: breaks tai encapsulation */ void leapsecs_add (struct tai *t, int hit) { unsigned int i = 0 ; uint64 u = t->x ; if (leapsecs_init() == -1) return ; for (; i < leapsecs_num ; i++) { if (u < leapsecs[i].x) break ; if (!hit || (u > leapsecs[i].x)) ++u ; } t->x = u ; } prog/skalibs-0.47/src/libstddjb/leapsecs_sub.c0100644000000000000000000000072410024356667016312 0ustar /* Public domain. */ /* MT-unsafe */ #include "tai.h" #include "caltimedate.h" #include "leapsecs_internal.h" /* XXX: breaks tai encapsulation */ int leapsecs_sub (struct tai *t) { unsigned int i = 0 ; uint64 u = t->x ; unsigned int s = 0 ; if (leapsecs_init() == -1) return 0 ; for (; 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 ; } prog/skalibs-0.47/src/libstddjb/env_addmodif.c0100644000000000000000000000056407772677631016300 0ustar /* Public domain. */ #include "stralloc.h" #include "env.h" int env_addmodif (stralloc *sa, char const *s, char const *t) { unsigned int oldlen = sa->len ; if (!s) return 1 ; if (!stralloc_cats(sa, s)) return 0 ; if ((t && (!stralloc_catb(sa, "=", 1) || !stralloc_cats(sa, t))) || !stralloc_0(sa)) { sa->len = oldlen ; return 0 ; } return 1 ; } prog/skalibs-0.47/src/libstddjb/leapsecs_internal.h0100644000000000000000000000025211100046323017313 0ustar /* Public domain. */ #ifndef LEAPSECS_INTERNAL_H #define LEAPSECS_INTERNAL_H #include "tai.h" extern struct tai *leapsecs ; extern unsigned int leapsecs_num ; #endif prog/skalibs-0.47/src/libstddjb/wait_pids_nohang.c0100644000000000000000000000057610367663430017163 0ustar /* Public domain. */ #include "djbunix.h" int wait_pids_nohang (int *wstat, int const *pids, unsigned int len) { for (;;) { int w ; register int r = wait_nohang(&w) ; if (r <= 0) return r ; { register unsigned int i = 0 ; for (; i < len ; i++) if (r == pids[i]) { *wstat = w ; return 1+i ; } } } } prog/skalibs-0.47/src/libstddjb/allreadwrite.c0100644000000000000000000000061210007443606016304 0ustar /* Public domain. */ #include #include "allreadwrite.h" unsigned int allreadwrite (iofunc_t_ref op, int fd, register char *buf, register unsigned int len) { register unsigned int written = 0 ; while (len) { register int w = (*op)(fd, buf, len) ; if (!w) errno = EPIPE ; if (w <= 0) break ; written += w ; buf += w ; len -= w ; } return written ; } prog/skalibs-0.47/src/libstddjb/netstring_decode.c0100644000000000000000000000111507774555376017175 0ustar /* Public domain. */ #include #include "fmtscan.h" #include "stralloc.h" #include "netstring.h" int netstring_decode (stralloc *sa, char const *s, unsigned int len) { unsigned int nlen ; register unsigned int pos ; if (!len) return 0 ; pos = uint_scan(s, &nlen) ; if (pos >= len) return (errno = EINVAL, -1) ; if (s[pos] != ':') return (errno = EINVAL, -1) ; s += pos+1 ; len -= pos+1 ; if (len <= nlen) return (errno = EINVAL, -1) ; if (s[nlen] != ',') return (errno = EINVAL, -1) ; if (!stralloc_catb(sa, s, nlen)) return -1 ; return pos + nlen + 2 ; } prog/skalibs-0.47/src/libstddjb/netstring_encode.c0100644000000000000000000000064407772674335017210 0ustar /* Public domain. */ #include "fmtscan.h" #include "stralloc.h" #include "netstring.h" int netstring_encode (stralloc *sa, char const *s, unsigned int len) { char fmt[FMT_ULONG] ; unsigned int pos = fmt_uint(fmt, len) ; if (!stralloc_readyplus(sa, pos + len + 2)) return 0 ; stralloc_catb(sa, fmt, pos) ; stralloc_catb(sa, ":", 1) ; stralloc_catb(sa, s, len) ; stralloc_catb(sa, ",", 1) ; return 1 ; } prog/skalibs-0.47/src/libstddjb/skagetlnsep.c0100644000000000000000000000125007772674216016166 0ustar /* Public domain. */ #include #include "bytestr.h" #include "buffer.h" #include "stralloc.h" #include "skamisc.h" int skagetlnsep (buffer_ref b, stralloc *sa, char const *sep, unsigned int len) { for (;;) { char *s = buffer_PEEK(b) ; unsigned int pos = byte_in(s, buffer_len(b), sep, len) ; int r = (pos < buffer_len(b)) ; if (!stralloc_catb(sa, s, pos)) return -1 ; buffer_SEEK(b, pos) ; if (r) { if (!stralloc_catb(sa, buffer_PEEK(b), 1)) return -1 ; buffer_SEEK(b, 1) ; return 1 ; } r = buffer_fill(b) ; if (r == -1) return -1 ; if (!r) return ((sa->s && sa->len) ? (errno = EPIPE, -1) : 0) ; } } prog/skalibs-0.47/src/libstddjb/stralloc.c0100644000000000000000000000021407772675051015466 0ustar /* Public domain. */ #undef USE_DJBALLOC #include "gen_alloc.h" #include "stralloc.h" GEN_ALLOC_BASE_DEFS(stralloc, char, s, len, a, 256) prog/skalibs-0.47/src/libstddjb/pathexec0_run.c0100644000000000000000000000033410024357064016374 0ustar /* Public domain. */ /* MT-unsafe */ #include #include "djbunix.h" void pathexec0_run (char const *const *argv, char const *const *envp) { if (!argv[0]) _exit(0) ; pathexec_run(argv[0], argv, envp) ; } prog/skalibs-0.47/src/libstddjb/envalloc.h0100644000000000000000000000071111100030244015416 0ustar /* Public domain. */ #ifndef ENVALLOC_H #define ENVALLOC_H #include "gen_alloc.h" GEN_ALLOC_PROTOTYPES(envalloc, char const *, s, len, a) #define ENVALLOC_ZERO GEN_ALLOC_ZERO extern int envalloc_make (envalloc *, unsigned int, char const *, unsigned int) ; extern int envalloc_uniq (envalloc *, char) ; extern int envalloc_merge (envalloc *, char const *const *, unsigned int, char const *, unsigned int) ; extern int envalloc_0 (envalloc *) ; #endif prog/skalibs-0.47/src/libstddjb/taia_pack_little.c0100644000000000000000000000034207666446520017135 0ustar /* Public domain. */ #include "uint32.h" #include "tai.h" void taia_pack_little (char *s, struct taia const *t) { uint32_pack(s, (uint32)t->atto) ; uint32_pack(s+4, (uint32)t->nano) ; tai_pack_little(s+8, &t->sec) ; } prog/skalibs-0.47/src/libstddjb/taia_unpack_little.c0100644000000000000000000000037507666446520017506 0ustar /* Public domain. */ #include "uint32.h" #include "tai.h" void taia_unpack_little (char const *s, struct taia *t) { uint32 x ; uint32_unpack(s, &x) ; t->atto = x ; uint32_unpack(s+4, &x) ; t->nano = x ; tai_unpack_little(s+8, &t->sec) ; } prog/skalibs-0.47/src/libstddjb/open_excl.c0100644000000000000000000000027407772756703015631 0ustar /* Public domain. */ #include #include #include "djbunix.h" int open_excl (char const *fn) { return open3(fn, O_WRONLY | O_CREAT | O_EXCL | O_NDELAY, 0666) ; } prog/skalibs-0.47/src/libstddjb/tai_pack_little.c0100644000000000000000000000022307666446520016772 0ustar /* Public domain. */ #include "uint64.h" #include "tai.h" void tai_pack_little (char *s, struct tai const *t) { uint64_pack(s, tai_sec(t)) ; } prog/skalibs-0.47/src/libstddjb/stralloc_reverse.c0100644000000000000000000000013207666446520017217 0ustar /* Public domain. */ #include "stralloc.h" GEN_ALLOC_reverse(stralloc, char, s, len, a) prog/skalibs-0.47/src/libstddjb/tai_unpack_little.c0100644000000000000000000000022207666446520017334 0ustar /* Public domain. */ #include "uint64.h" #include "tai.h" void tai_unpack_little (char const *s, struct tai *t) { uint64_unpack(s, &t->x) ; } prog/skalibs-0.47/src/libstddjb/taia_unpack.c0100644000000000000000000000037007666446520016124 0ustar /* Public domain. */ #include "uint32.h" #include "tai.h" void taia_unpack (char const *s, struct taia *t) { uint32 x ; tai_unpack(s, &t->sec) ; uint32_unpack_big(s+8, &x) ; t->nano = x ; uint32_unpack_big(s+12, &x) ; t->atto = x ; } prog/skalibs-0.47/src/libstddjb/envalloc.c0100644000000000000000000000022207772677203015446 0ustar /* Public domain. */ #undef USE_DJBALLOC #include "gen_alloc.h" #include "envalloc.h" GEN_ALLOC_BASE_DEFS(envalloc, char const *, s, len, a, 4) prog/skalibs-0.47/src/libstddjb/env_get2.c0100644000000000000000000000053307666446520015357 0ustar /* Public domain. */ #include "bytestr.h" #include "env.h" char const *env_get2 (char const *const *envp, char const *s) { unsigned int i ; unsigned int len ; if (!s) return 0 ; len = str_len(s) ; for (i = 0 ; envp[i] ; ++i) if (str_start(envp[i], s) && (envp[i][len] == '=')) return envp[i] + len + 1 ; return 0 ; } prog/skalibs-0.47/src/libstddjb/pathexec.c0100644000000000000000000000030510024360021015411 0ustar /* Public domain. */ /* MT-unsafe */ #include "env.h" #include "djbunix.h" #include "environ.h" void pathexec (char const *const *argv) { pathexec_fromenv(argv, environ, env_len(environ)) ; } prog/skalibs-0.47/src/libstddjb/pathexec_fromenv.c0100644000000000000000000000066711051750122017166 0ustar /* Public domain. */ /* MT-unsafe */ #include "stralloc.h" #include "env.h" #include "djbunix.h" #include "skamisc.h" static stralloc plus = STRALLOC_ZERO ; int pathexec_env (char const *s, char const *t) /* historic, bad name */ { return env_addmodif(&plus, s, t) ; } void pathexec_fromenv (char const *const *argv, char const *const *envp, unsigned int envlen) { pathexec_r_tmp(argv, envp, envlen, plus.s, plus.len, &satmp) ; } prog/skalibs-0.47/src/libstddjb/envalloc_make.c0100644000000000000000000000054307666446520016447 0ustar #include "bytestr.h" #include "envalloc.h" int envalloc_make (envalloc *v, unsigned int argc, char const *s, unsigned int len) { register unsigned int pos = 0 ; if (!envalloc_ready(v, argc+1)) return 0 ; for (v->len = 0 ; v->len < argc ; v->len++) { v->s[v->len] = s + pos ; pos += str_len(s + pos) + 1 ; } (void)len ; return 1 ; } prog/skalibs-0.47/src/libstddjb/envalloc_uniq.c0100644000000000000000000000104107772643016016475 0ustar /* Public domain. */ #include #include "bytestr.h" #include "envalloc.h" int envalloc_uniq (envalloc *v, char delim) { unsigned int m = 0 ; register unsigned int i = 0 ; for (; i < v->len ; i++) { register unsigned int j = i+1 ; char const *s = v->s[i] ; unsigned int n = str_chr(s, delim) ; if (delim && !s[n]) return (errno = EINVAL, -1) ; for (; j < v->len ; j++) { if (!str_diffn(s, v->s[j], n)) { v->s[j] = v->s[--v->len] ; m++ ; } } } return (int)m ; } prog/skalibs-0.47/src/libstddjb/envalloc_0.c0100644000000000000000000000020707772674010015661 0ustar /* Public domain. */ #include "envalloc.h" int envalloc_0 (envalloc *v) { char const *z = 0 ; return envalloc_catb(v, &z, 1) ; } prog/skalibs-0.47/src/libstddjb/env_string.c0100644000000000000000000000055407672001742016015 0ustar /* Public domain. */ #include "stralloc.h" #include "env.h" int env_string (stralloc *sa, char const *const *envp, unsigned int envlen) { unsigned int salen = sa->len ; register unsigned int i = 0 ; for (; i < envlen ; i++) { if (!stralloc_cats(sa, envp[i]) || !stralloc_0(sa)) { sa->len = salen ; return 0 ; } } return 1 ; } prog/skalibs-0.47/src/libstddjb/uint32aalloc.c0100644000000000000000000000054307772677152016154 0ustar /* Public domain. */ #include "uint32alloc.h" #include "uint32aalloc.h" GEN_ALLOC_BASE_DEFS(uint32aalloc, uint32alloc, s, len, a, 8) void uint32aalloc_zerolen (uint32aalloc *z) { while (z->len--) uint32alloc_free(z->s + z->len) ; z->len = 0 ; } void uint32aalloc_deepfree (uint32aalloc *z) { uint32aalloc_zerolen(z) ; uint32aalloc_free(z) ; } prog/skalibs-0.47/src/libstddjb/byte_count.c0100644000000000000000000000033707666446520016023 0ustar /* Public domain. */ #include "bytestr.h" unsigned int byte_count (register char const *s, register unsigned int len, register char b) { register unsigned int n = 0 ; while (len--) if (*s++ == b) n++ ; return n ; } prog/skalibs-0.47/src/libstddjb/envalloc_reverse.c0100644000000000000000000000017107666446520017202 0ustar /* Public domain. */ #include "gen_alloc.h" #include "envalloc.h" GEN_ALLOC_reverse(envalloc, char const *, s, len, a) prog/skalibs-0.47/src/libstddjb/execvep.c0100644000000000000000000000035210024361025015256 0ustar /* Public domain. */ /* MT-unsafe */ #include "skamisc.h" #include "djbunix.h" void execvep (char const *file, char const *const *argv, char const *const *envp, char const *path) { execvep_tmp(file, argv, envp, path, &satmp) ; } prog/skalibs-0.47/src/libstddjb/envalloc_merge.c0100644000000000000000000000154710024075675016625 0ustar /* Public domain. */ #include "bytestr.h" #include "envalloc.h" int envalloc_merge (envalloc *v, char const *const *envp, unsigned int envlen, char const *modifs, unsigned int modiflen) { unsigned int vbase = v->len ; unsigned int j = 0 ; register unsigned int i = 0 ; if (!envalloc_readyplus(v, envlen + 1 + byte_count(modifs, modiflen, '\0'))) return 0 ; envalloc_catb(v, envp, envlen) ; for (; i < modiflen ; i++) { if (!modifs[i]) { register unsigned int t = vbase ; unsigned int split = str_chr(modifs + j, '=') ; for (; t < v->len ; t++) { if (!byte_diff(modifs + j, split, v->s[t]) && (v->s[t][split] == '=')) { v->s[t] = v->s[--v->len] ; break ; } } if (modifs[j + split]) v->s[v->len++] = modifs + j ; j = i + 1 ; } } return 1 ; } prog/skalibs-0.47/src/libstddjb/uint32aalloc.h0100644000000000000000000000031411100046357016126 0ustar /* Public domain. */ #ifndef UINT32AALLOC_H #define UINT32AALLOC_H #include "uint32alloc.h" GEN_ALLOC_PROTOTYPES(uint32aalloc, uint32alloc, s, len, a) #define UINT32AALLOC_ZERO GEN_ALLOC_ZERO #endif prog/skalibs-0.47/src/libstddjb/taia_fmt.c0100644000000000000000000000032107677442470015427 0ustar /* Public domain. */ #include "fmtscan.h" #include "tai.h" unsigned int taia_fmt (char *s, struct taia const *a) { char pack[TAIA_PACK] ; taia_pack(pack, a) ; return fmt_ucharn(s, pack, TAIA_PACK) ; } prog/skalibs-0.47/src/libstddjb/tain_pack.c0100644000000000000000000000026207700243670015564 0ustar /* Public domain. */ #include "uint32.h" #include "tai.h" void tain_pack (char *s, struct taia const *t) { tai_pack(s, &t->sec) ; uint32_pack_big(s+8, (uint32)t->nano) ; } prog/skalibs-0.47/src/libstddjb/timestamp_scan.c0100644000000000000000000000032110003730416016623 0ustar /* Public domain. */ #include "tai.h" unsigned int timestamp_scan (char const *s, struct taia *a) { register unsigned int r ; if (*s != '@') return 0 ; r = tain_scan(s+1, a) ; return r ? r+1 : 0 ; } prog/skalibs-0.47/src/libstddjb/uint160_scan.c0100644000000000000000000000014710003755163016042 0ustar /* Public domain. */ #include "uint16.h" #include "fmtscan-internal.h" SCANU0(uint16, uint16, 65535) prog/skalibs-0.47/src/libstddjb/timestamp_fmt.c0100644000000000000000000000022407700244716016504 0ustar /* Public domain. */ #include "tai.h" unsigned int timestamp_fmt (char *s, struct taia const *a) { *s = '@' ; return 1 + tain_fmt(s+1, a) ; } prog/skalibs-0.47/src/libstddjb/fmtscan-internal.h0100644000000000000000000000121611100046332017066 0ustar /* Public domain. */ #ifndef FMTSCAN_INTERNAL_H #define FMTSCAN_INTERNAL_H #include "uint64.h" #define SCANU(abbr, type, n) \ unsigned int abbr##_scan_base (char const *s, type *u, unsigned char base) \ { \ uint64 result ; \ register unsigned int pos = uint64_scan_upto_base(s, &result, n, base) ; \ if (pos) *u = (type)result ; \ return pos ; \ } \ #define SCANU0(abbr, type, n) \ unsigned int abbr##0_scan_base (register char const *s, register type *u, unsigned char base) \ { \ uint64 result ; \ register unsigned int pos = uint640_scan_upto_base(s, &result, n, base) ; \ if (pos) *u = (type)result ; \ return pos ; \ } \ #endif prog/skalibs-0.47/src/libstddjb/tain_unpack.c0100644000000000000000000000033007700244062016117 0ustar /* Public domain. */ #include "uint32.h" #include "tai.h" void tain_unpack (char const *s, struct taia *t) { uint32 x ; tai_unpack(s, &t->sec) ; uint32_unpack_big(s+8, &x) ; t->nano = x ; t->atto = 0 ; } prog/skalibs-0.47/src/libstddjb/ulong0_scan.c0100644000000000000000000000020610003730416016026 0ustar /* Public domain. */ #include #include "fmtscan.h" #include "fmtscan-internal.h" SCANU0(ulong, unsigned long, ULONG_MAX) prog/skalibs-0.47/src/libstddjb/tain_fmt.c0100644000000000000000000000032107773457637015454 0ustar /* Public domain. */ #include "fmtscan.h" #include "tai.h" unsigned int tain_fmt (char *s, struct taia const *a) { char pack[TAIN_PACK] ; tain_pack(pack, a) ; return ucharn_fmt(s, pack, TAIN_PACK) ; } prog/skalibs-0.47/src/libstddjb/realpath.c0100644000000000000000000000025610024360573015431 0ustar /* Public domain. */ /* MT-unsafe */ #include "skamisc.h" #include "djbunix.h" char *realpath (char const *name, char *buf) { return realpath_tmp(name, buf, &satmp) ; } prog/skalibs-0.47/src/libstddjb/timeval_from_tai.c0100644000000000000000000000045707772655711017176 0ustar /* Public domain. */ #include #include #include #include "tai.h" int timeval_from_tai (struct timeval *tv, struct tai const *t) { time_t x = tai_sec(t) - TAI_MAGIC ; if (x < 0) return (errno = EINVAL, 0) ; tv->tv_sec = x ; tv->tv_usec = 0 ; return 1 ; } prog/skalibs-0.47/src/libstddjb/uint32_scan.c0100644000000000000000000000021210003755221015744 0ustar /* Public domain. */ #include "uint32.h" #include "uint64.h" #include "fmtscan-internal.h" SCANU(uint32, uint32, ((uint64)1 << 32) - 1) prog/skalibs-0.47/src/libstddjb/tain_unpack_little.c0100644000000000000000000000034207700244046017501 0ustar /* Public domain. */ #include "uint32.h" #include "tai.h" void tain_unpack_little (char const *s, struct taia *t) { uint32 x ; t->atto = 0 ; uint32_unpack(s, &x) ; t->nano = x ; tai_unpack_little(s+4, &t->sec) ; } prog/skalibs-0.47/src/libstddjb/tai_from_timeval.c0100644000000000000000000000025207724236440017156 0ustar /* Public domain. */ #include #include "tai.h" int tai_from_timeval (struct tai *t, struct timeval const *tv) { tai_unix(t, tv->tv_sec) ; return 1 ; } prog/skalibs-0.47/src/libstddjb/tain_pack_little.c0100644000000000000000000000027407700244125017140 0ustar /* Public domain. */ #include "uint32.h" #include "tai.h" void tain_pack_little (char *s, struct taia const *t) { uint32_pack(s, (uint32)t->nano) ; tai_pack_little(s+4, &t->sec) ; } prog/skalibs-0.47/src/libstddjb/timeval_from_tai_relative.c0100644000000000000000000000045407772655746021076 0ustar /* Public domain. */ #include #include #include #include "tai.h" int timeval_from_tai_relative (struct timeval *tv, struct tai const *t) { time_t x = tai_sec(t) ; if (x < 0) return (errno = EINVAL, 0) ; tv->tv_sec = x ; tv->tv_usec = 0 ; return 1 ; } prog/skalibs-0.47/src/libstddjb/tai_relative_from_timeval.c0100644000000000000000000000042007772655551021061 0ustar /* Public domain. */ #include #include #include "tai.h" int tai_relative_from_timeval (struct tai *t, struct timeval const *tv) { if ((tv->tv_sec < 0) || (tv->tv_usec < 0)) return (errno = EINVAL, 0) ; tai_uint(t, tv->tv_sec) ; return 1 ; } prog/skalibs-0.47/src/libstddjb/taia_relative_from_timeval.c0100644000000000000000000000051607772655655021235 0ustar /* Public domain. */ #include #include #include "tai.h" int taia_relative_from_timeval (struct taia *a, struct timeval const *tv) { if ((tv->tv_sec < 0) || (tv->tv_usec < 0)) return (errno = EINVAL, 0) ; tai_uint(taia_secp(a), tv->tv_sec) ; a->nano = 1000 * tv->tv_usec ; a->atto = 0 ; return 1 ; } prog/skalibs-0.47/src/libstddjb/timeval_from_taia.c0100644000000000000000000000050507772655762017337 0ustar /* Public domain. */ #include #include #include "tai.h" int timeval_from_taia (struct timeval *tv, struct taia const *a) { struct timeval tmp ; if (!timeval_from_tai(&tmp, taia_secp(a))) return (errno = EINVAL, 0) ; tv->tv_sec = tmp.tv_sec ; tv->tv_usec = a->nano / 1000 ; return 1 ; } prog/skalibs-0.47/src/libstddjb/taia_from_timeval.c0100644000000000000000000000045707772655614017341 0ustar /* Public domain. */ #include #include #include "tai.h" int taia_from_timeval (struct taia *a, struct timeval const *tv) { if (tv->tv_usec < 0) return (errno = EINVAL, 0) ; tai_unix(taia_secp(a), tv->tv_sec) ; a->nano = 1000 * tv->tv_usec ; a->atto = 0 ; return 1 ; } prog/skalibs-0.47/src/libstddjb/cdb_traverse.c0100644000000000000000000000165010003252012016254 0ustar /* Public domain. */ #include "uint32.h" #include "cdb.h" int cdb_nextkey (struct cdb *c, uint32 *kpos) { char buf[8] ; uint32 eod, klen ; if (cdb_read(c, buf, 4, 0)) return -1 ; uint32_unpack(buf, &eod) ; if (eod < 8 || eod - 8 < *kpos) return 0 ; c->kpos = *kpos + 8 ; if (c->kpos < *kpos) return -1 ; /* wraparound */ cdb_findstart(c) ; c->hslots = 1 ; if (cdb_read(c, buf, 8, *kpos) == -1) return -1 ; uint32_unpack(buf, &klen) ; uint32_unpack(buf + 4, &c->dlen) ; c->dpos = c->kpos + klen ; *kpos += 8 + klen + c->dlen ; return 1 ; } int cdb_firstkey (struct cdb *c, uint32 *kpos) { *kpos = 2048 ; return cdb_nextkey(c, kpos) ; } int cdb_successor (struct cdb *c, char const *key, unsigned int klen) { int r ; uint32 kpos ; if (key) { r = cdb_find(c, key, klen) ; if (r < 1) return r ; kpos = c->dpos + c->dlen ; } else kpos = 2048 ; return cdb_nextkey(c, &kpos) ; } prog/skalibs-0.47/src/libstddjb/timeval_from_taia_relative.c0100644000000000000000000000052707772655775021242 0ustar /* Public domain. */ #include #include #include "tai.h" int timeval_from_taia_relative (struct timeval *tv, struct taia const *a) { struct timeval tmp ; if (!timeval_from_tai_relative(&tmp, taia_secp(a))) return (errno = EINVAL, 0) ; tv->tv_sec = tmp.tv_sec ; tv->tv_usec = a->nano / 1000 ; return 1 ; } prog/skalibs-0.47/src/libstddjb/sig_nostack.c0100644000000000000000000000115410024362225016127 0ustar /* Public domain. */ /* MT-unsafe */ #include #include #include "sig.h" #include "nsig.h" static struct skasigaction oldactions[NSIG] ; int sig_catcha (int sig, struct skasigaction const *ssa) { if ((sig <= 0) || (sig > NSIG)) return (errno = EINVAL, -1) ; return skasigaction(sig, ssa, oldactions + (sig-1)) ; } int sig_restore (int sig) { if ((sig <= 0) || (sig > NSIG)) return (errno = EINVAL, -1) ; if (!oldactions[sig-1].handler) oldactions[sig-1] = SKASIG_DFL ; if (skasigaction(sig, oldactions + (sig-1), 0) == -1) return -1 ; oldactions[sig-1] = SKASIG_DFL ; return 0 ; } prog/skalibs-0.47/src/libstddjb/uint320_scan.c0100644000000000000000000000021310003755204016026 0ustar /* Public domain. */ #include "uint32.h" #include "uint64.h" #include "fmtscan-internal.h" SCANU0(uint32, uint32, ((uint64)1 << 32) - 1) prog/skalibs-0.47/src/libstddjb/bitarray.c0100644000000000000000000000453710030513160015441 0ustar /* Public domain. */ #include "uint64.h" #include "uint64alloc.h" #include "bitarray.h" #define div64(n) ((n) ? 1 + (((n) - 1) >> 6) : 0) void bitarray_clearsetn (register bitarray *x, register unsigned int a, register unsigned int b, register unsigned char h) { if (!b) return ; b += a ; if ((a >> 6) == ((b-1) >> 6)) { register uint64 mask = ((1 << (a & 63)) - 1) ^ ((a << (b & 63)) - 1) ; if (h) x->x.s[a>>6] |= mask ; else x->x.s[a>>6] &= ~mask ; } else { register uint64 mask = ~((1 << (a & 63)) - 1) ; register unsigned int i = (a>>6) + 1 ; if (h) x->x.s[a>>6] |= mask ; else x->x.s[a>>6] &= ~mask ; mask = h ? ~((uint64)0) : (uint64)0 ; for (; i < (b>>6) - 1 ; i++) x->x.s[i] = mask ; mask = (1 << (b & 63)) - 1 ; if (h) x->x.s[b>>6] |= mask ; else x->x.s[b>>6] &= ~mask ; } } void bitarray_free (register bitarray *b) { uint64alloc_free(&b->x) ; } int bitarray_ready (register bitarray *b, register unsigned int n) { register unsigned int old = b->x.a << 6 ; if (n < old) return 1 ; if (!uint64alloc_ready(&b->x, div64(n))) return 0 ; bitarray_clearn(b, old, (b->x.a << 6) - old) ; return 1 ; } int bitarray_readyplus (register bitarray *b, register unsigned int n) { return bitarray_ready(b, n + (b->x.a << 6)) ; } int bitarray_peek (register bitarray const *b, register unsigned int n) { return (b->x.s[n>>6] & ((uint64)1 << (n & 63))) ? 1 : 0 ; } void bitarray_clear (register bitarray *b, register unsigned int n) { b->x.s[n>>6] &= ~((uint64)1 << (n & 63)) ; } void bitarray_set (register bitarray *b, register unsigned int n) { b->x.s[n>>6] |= (uint64)1 << (n & 63) ; } int bitarray_testandpoke (register bitarray *b, register unsigned int n, register unsigned char h) { register uint64 mask = (uint64)1 << (n & 63) ; register uint64 z = b->x.s[n>>6] ; b->x.s[n>>6] = h ? z | mask : z & ~mask ; return (z & mask) ? 1 : 0 ; } unsigned int bitarray_firstclear (register bitarray const *b) { register uint64 z = ~(uint64)0 ; register unsigned int i = 0 ; for (; i < b->x.a ; i++) if (b->x.s[i] != z) break ; if (i >= b->x.a) return i << 6 ; z = b->x.s[i] ; i <<= 6 ; { register unsigned int j = 64 ; while (j >>= 1) { register uint64 k = ((uint64)1 << j) - 1 ; if ((z & k) == k) { i += j ; z >>= j ; } } } return i ; } prog/skalibs-0.47/src/libstddjb/sadirname.c0100644000000000000000000000077307773240201015602 0ustar /* Public domain. */ #include "bytestr.h" #include "stralloc.h" #include "djbunix.h" int sadirname (stralloc *sa, char const *s, unsigned int len) { if (!len) return stralloc_catb(sa, ".", 1) ; while (len && (s[len-1] == '/')) len-- ; if (!len) return stralloc_catb(sa, "/", 1) ; { register unsigned int i = byte_rchr(s, len, '/') ; return (i == len) ? stralloc_catb(sa, ".", 1) : (i == 0) ? stralloc_catb(sa, "/", 1) : stralloc_catb(sa, s, i) ; } } prog/skalibs-0.47/src/libstddjb/uint640_scan.c0100644000000000000000000000061210003777347016052 0ustar /* Public domain. */ #include #include "uint64.h" #include "fmtscan.h" unsigned int uint640_scan_upto_base (char const *s, uint64 *u, uint64 n, unsigned char base) { register unsigned int pos = uint64_scan_upto_base(s, u, n, base) ; if (!pos) return (errno = EINVAL, 0) ; if (!s[pos]) return pos ; errno = (fmtscan_num(s[pos], base) < base) ? EDOM : EINVAL ; return 0 ; } prog/skalibs-0.47/src/libstddjb/taia_addsec.c0100644000000000000000000000053407742573473016073 0ustar /* Public domain. */ #include "tai.h" extern void taia_addsec (struct taia *b, struct taia const *a, int c) { b->atto = a->atto ; b->nano = a->nano ; if (c >= 0) { struct tai t ; tai_u64(&t, c) ; tai_add(&b->sec, &a->sec, &t) ; } else { struct tai t ; tai_u64(&t, -c) ; tai_sub(&b->sec, &a->sec, &t) ; } } prog/skalibs-0.47/src/libstddjb/ushort_scan.c0100644000000000000000000000020710003752316016152 0ustar /* Public domain. */ #include #include "fmtscan.h" #include "fmtscan-internal.h" SCANU(ushort, unsigned short, USHRT_MAX) prog/skalibs-0.47/src/libstddjb/skasigaction.c0100644000000000000000000000211710174164662016315 0ustar /* Public domain. */ #include #include "sysdeps.h" #include "sig.h" #ifdef HASSIGACTION int skasigaction (int sig, struct skasigaction const *new, struct skasigaction *old) { struct sigaction sanew, saold ; if (((new->flags & SKASA_MASKALL) ? sigfillset(&sanew.sa_mask) : sigemptyset(&sanew.sa_mask)) == -1) return -1 ; sanew.sa_handler = new->handler ; sanew.sa_flags = (new->flags & SKASA_NOCLDSTOP) ? SA_NOCLDSTOP : 0 ; if (sigaction(sig, &sanew, &saold) == -1) return -1 ; if (old) { register int r = sigismember(&saold.sa_mask, (sig == SIGTERM) ? SIGPIPE : SIGTERM) ; if (r == -1) return -1 ; old->flags = 0 ; if (r) old->flags |= SKASA_MASKALL ; if (saold.sa_flags & SA_NOCLDSTOP) old->flags |= SKASA_NOCLDSTOP ; old->handler = saold.sa_handler ; } return 0 ; } #else int skasigaction (int sig, struct skasigaction const *new, struct skasigaction *old) { skasighandler_t_ref haold = signal(sig, new->handler) ; if (haold == SIG_ERR) return -1 ; if (old) { old->handler = haold ; old->flags = 0 ; } return 0 ; } #endif prog/skalibs-0.47/src/libstddjb/case_upperb.c0100644000000000000000000000034507742561104016126 0ustar /* Public domain. */ #include "bytestr.h" void case_upperb (register char *s, unsigned int len) { register unsigned char const d = 'a' - 'A' ; while (len--) { if (('a' <= *s) && (*s <= 'z')) *s -= d ; ++s ; } } prog/skalibs-0.47/src/libstddjb/fd_close.c0100644000000000000000000000041407772671614015424 0ustar /* Public domain. */ #include #include #include "djbunix.h" int fd_close (int fd) { register unsigned int i = 0 ; doit: if (!close(fd)) return 0 ; i++ ; if (errno == EINTR) goto doit ; return ((errno == EBADF) && (i > 1)) ? 0 : -1 ; } prog/skalibs-0.47/src/libstddjb/case_uppers.c0100644000000000000000000000032007742561167016151 0ustar /* Public domain. */ #include "bytestr.h" void case_uppers (register char *s) { register unsigned char const d = 'a' - 'A' ; while (*s) { if (('a' <= *s) && (*s <= 'z')) *s -= d ; ++s ; } } prog/skalibs-0.47/src/libstddjb/pathexec_run.c0100644000000000000000000000033410024361110016277 0ustar /* Public domain. */ /* MT-unsafe */ #include "skamisc.h" #include "djbunix.h" void pathexec_run (char const *file, char const *const *argv, char const *const *envp) { pathexec_run_tmp(file, argv, envp, &satmp) ; } prog/skalibs-0.47/src/libstddjb/subgetopt_here.c0100644000000000000000000000016210024362617016645 0ustar /* Public domain. */ /* MT-unsafe */ #include "sgetopt.h" struct subgetopt_t subgetopt_here = SUBGETOPT_ZERO ; prog/skalibs-0.47/src/libstddjb/fd_read.c0100644000000000000000000000036607772671643015242 0ustar /* Public domain. */ #include #include #include "allreadwrite.h" int fd_read (int fd, char *buf, unsigned int len) { register int r ; do r = read(fd, buf, len) ; while ((r == -1) && (errno == EINTR)) ; return r ; } prog/skalibs-0.47/src/libstddjb/fd_recv.c0100644000000000000000000000046107773121724015251 0ustar /* Public domain. */ #include #include #include #include "allreadwrite.h" int fd_recv (int fd, char *buf, unsigned int len, unsigned int flags) { register int r ; do r = recv(fd, buf, len, (int)flags) ; while ((r == -1) && (errno == EINTR)) ; return r ; } prog/skalibs-0.47/src/libstddjb/fd_write.c0100644000000000000000000000037607772671667015470 0ustar /* Public domain. */ #include #include #include "allreadwrite.h" int fd_write (int fd, char const *buf, unsigned int len) { register int r ; do r = write(fd, buf, len) ; while ((r == -1) && (errno == EINTR)) ; return r ; } prog/skalibs-0.47/src/libstddjb/stralloc_x.c0100644000000000000000000000021307772675040016012 0ustar /* Public domain. */ #undef USE_DJBALLOC #include "gen_alloc.h" #include "stralloc.h" GEN_ALLOC_EXTENDED_DEFS(stralloc, char, s, len, a) prog/skalibs-0.47/src/libstddjb/fd_send.c0100644000000000000000000000046707773121736015254 0ustar /* Public domain. */ #include #include #include #include "allreadwrite.h" int fd_send (int fd, char const *buf, unsigned int len, unsigned int flags) { register int r ; do r = send(fd, buf, len, (int)flags) ; while ((r == -1) && (errno == EINTR)) ; return r ; } prog/skalibs-0.47/src/libstddjb/intalloc_x.c0100644000000000000000000000021207772676660016004 0ustar /* Public domain. */ #undef USE_DJBALLOC #include "gen_alloc.h" #include "intalloc.h" GEN_ALLOC_EXTENDED_DEFS(intalloc, int, s, len, a) prog/skalibs-0.47/src/libstddjb/envalloc_x.c0100644000000000000000000000022307772676146016003 0ustar /* Public domain. */ #undef USE_DJBALLOC #include "gen_alloc.h" #include "envalloc.h" GEN_ALLOC_EXTENDED_DEFS(envalloc, char const *, s, len, a) prog/skalibs-0.47/src/libstddjb/gen_bunch.h0100644000000000000000000000573011100046312015554 0ustar /* Public domain. */ #ifndef GEN_BUNCH_H #define GEN_BUNCH_H #include "gen_alloc.h" #include "bitarray.h" /* user */ #define GEN_BUNCH_ZERO { GEN_ALLOC_ZERO, BITARRAY_ZERO, 0 } #define gen_bunch_p(sb, i) ((i) ? ((sb)->x.s+((i)-1)) : 0) /* .h */ #define GEN_BUNCH_typedef(tbunch, talloc) \ typedef struct tbunch { talloc x ; bitarray used ; unsigned int n ; } tbunch, *tbunch##_ref ; #define GEN_BUNCH_FPROTOTYPES(tbunch, talloc, type) \ extern void tbunch##_free (tbunch *) ; \ extern int tbunch##_ready (tbunch *, unsigned int) ; \ extern int tbunch##_readyplus (tbunch *, unsigned int) ; \ extern int tbunch##_delete (tbunch *, unsigned int) ; \ extern unsigned int tbunch##_new (tbunch *) ; \ #define GEN_BUNCH_PROTOTYPES(tbunch, talloc, type) \ GEN_BUNCH_typedef(tbunch, talloc) \ GEN_BUNCH_FPROTOTYPES(tbunch, talloc, type) \ /* .c */ #define GEN_BUNCH_free(tbunch, talloc) \ void tbunch##_free (tbunch *sb) \ { \ bitarray_free(&sb->used) ; \ talloc##_free(&sb->x) ; \ sb->n = 0 ; \ } \ #define GEN_BUNCH_ready(tbunch, talloc) \ int tbunch##_ready (tbunch *sb, unsigned int n) \ { \ unsigned char wasnull = !sb->x.s ; \ if (!talloc##_ready(&sb->x, n)) return 0 ; \ if (!bitarray_ready(&sb->used, n)) \ { \ if (wasnull) talloc##_free(&sb->x) ; \ return 0 ; \ } \ return 1 ; \ } \ #define GEN_BUNCH_readyplus(tbunch, talloc) \ int tbunch##_readyplus (tbunch *sb, unsigned int n) \ { \ return tbunch##_ready(sb, n + sb->n) ; \ } \ #define GEN_BUNCH_delete(tbunch) \ int tbunch##_delete (tbunch *sb, unsigned int i) \ { \ if (!i-- || !bitarray_testandclear(&sb->used, i)) return 0 ; \ sb->n-- ; \ if (i+1 == sb->x.len) \ while (sb->x.len && !bitarray_isset(&sb->used, sb->x.len - 1)) \ sb->x.len-- ; \ return 1 ; \ } \ #define GEN_BUNCH_new(tbunch, talloc, type, base, minfree) \ unsigned int tbunch##_new (tbunch *sb) \ { \ register unsigned int i = sb->x.len ; \ if (i < sb->x.a) \ { \ if (!bitarray_ready(&sb->used, i)) return 0 ; \ sb->x.len++ ; \ } \ else if ((sb->n + (minfree) + (i >> 5)) < i) \ i = bitarray_firstclear(&sb->used) ; \ if (i >= sb->x.len) \ { \ unsigned char wasnull = !sb->x.s ; \ if (!talloc##_readyplus(&sb->x, (base))) return 0 ; \ if (!bitarray_ready(&sb->used, sb->x.a)) \ { \ if (wasnull) talloc##_free(&sb->x) ; \ return 0 ; \ } \ i = sb->x.len++ ; \ } \ bitarray_set(&sb->used, i) ; \ sb->n++ ; \ return i+1 ; \ } \ #define GEN_BUNCH_DEFS(tbunch, talloc, type, base, minfree) \ GEN_BUNCH_free(tbunch, talloc) \ GEN_BUNCH_ready(tbunch, talloc) \ GEN_BUNCH_readyplus(tbunch, talloc) \ GEN_BUNCH_delete(tbunch) \ GEN_BUNCH_new(tbunch, talloc, type, base, minfree) \ #define GEN_BUNCH_STATIC_DEFS(tbunch, talloc, type, base, minfree) \ static GEN_BUNCH_free(tbunch, talloc) \ static GEN_BUNCH_ready(tbunch, talloc) \ static GEN_BUNCH_readyplus(tbunch, talloc) \ static GEN_BUNCH_delete(tbunch) \ static GEN_BUNCH_new(tbunch, talloc, type, base, minfree) \ #endif prog/skalibs-0.47/src/libstddjb/uintalloc_x.c0100644000000000000000000000022507772676730016173 0ustar /* Public domain. */ #undef USE_DJBALLOC #include "gen_alloc.h" #include "uintalloc.h" GEN_ALLOC_EXTENDED_DEFS(uintalloc, unsigned int, s, len, a) prog/skalibs-0.47/src/libstddjb/bitarray.h0100644000000000000000000000220011100046312015426 0ustar /* Public domain. */ #ifndef BITARRAY_H #define BITARRAY_H #include "gccattributes.h" #include "uint64alloc.h" typedef struct bitarray { uint64alloc x ; } bitarray, *bitarray_ref ; #define BITARRAY_ZERO { UINT64ALLOC_ZERO } extern int bitarray_ready (bitarray *, unsigned int) ; extern int bitarray_readyplus (bitarray *, unsigned int) ; extern void bitarray_free (bitarray *) ; extern void bitarray_clearsetn (bitarray *, unsigned int, unsigned int, unsigned char) ; #define bitarray_clearn(x, start, len) bitarray_clearsetn(x, start, len, 0) #define bitarray_setn(x, start, len) bitarray_clearsetn(x, start, len, 1) extern int bitarray_peek (bitarray const *, unsigned int) gccattr_pure ; #define bitarray_isset(b, n) bitarray_peek(b, n) extern void bitarray_clear (bitarray *, unsigned int) ; extern void bitarray_set (bitarray *, unsigned int) ; extern int bitarray_testandpoke (bitarray *, unsigned int, unsigned char) ; #define bitarray_testandclear(b, n) bitarray_testandpoke(b, n, 0) #define bitarray_testandset(b, n) bitarray_testandpoke(b, n, 1) extern unsigned int bitarray_firstclear (bitarray const *) gccattr_pure ; #endif prog/skalibs-0.47/src/libstddjb/uintbunch.h0100644000000000000000000000032611100046312015617 0ustar /* Public domain. */ #ifndef UINTBUNCH_H #define UINTBUNCH_H #include "uintalloc.h" #include "gen_bunch.h" GEN_BUNCH_PROTOTYPES(uintbunch, uintalloc, unsigned int) #define UINTBUNCH_ZERO GEN_BUNCH_ZERO #endif prog/skalibs-0.47/src/libstddjb/uint16alloc_x.c0100644000000000000000000000024707772676773016355 0ustar /* Public domain. */ #undef USE_DJBALLOC #include "uint16.h" #include "gen_alloc.h" #include "uint16alloc.h" GEN_ALLOC_EXTENDED_DEFS(uint16alloc, uint16, s, len, a) prog/skalibs-0.47/src/libstddjb/uintbunch.c0100644000000000000000000000021707772713750015644 0ustar /* Public domain. */ #include "uintalloc.h" #include "gen_bunch.h" #include "uintbunch.h" GEN_BUNCH_DEFS(uintbunch, uintalloc, uint, 64, 16) prog/skalibs-0.47/src/libstddjb/diuintalloc.c0100644000000000000000000000022307766021205016137 0ustar /* Public domain. */ #include "gen_alloc.h" #include "diuint.h" #include "diuintalloc.h" GEN_ALLOC_BASE_DEFS(diuintalloc, diuint, s, len, a, 64) prog/skalibs-0.47/src/libstddjb/uint32alloc_x.c0100644000000000000000000000024707772677037016345 0ustar /* Public domain. */ #undef USE_DJBALLOC #include "uint32.h" #include "gen_alloc.h" #include "uint32alloc.h" GEN_ALLOC_EXTENDED_DEFS(uint32alloc, uint32, s, len, a) prog/skalibs-0.47/src/libstddjb/diuintalloc.h0100644000000000000000000000032511100030244016123 0ustar /* Public domain. */ #ifndef DIUINTALLOC_H #define DIUINTALLOC_H #include "gen_alloc.h" #include "diuint.h" GEN_ALLOC_PROTOTYPES(diuintalloc, diuint, s, len, a) #define DIUINTALLOC_ZERO GEN_ALLOC_ZERO #endif prog/skalibs-0.47/src/libstddjb/diuintbunch.c0100644000000000000000000000025507766021346016157 0ustar /* Public domain. */ #include "diuint.h" #include "diuintalloc.h" #include "gen_bunch.h" #include "diuintbunch.h" GEN_BUNCH_DEFS(diuintbunch, diuintalloc, diuint, 64, 16) prog/skalibs-0.47/src/libstddjb/uint64alloc_x.c0100644000000000000000000000024707772677074016353 0ustar /* Public domain. */ #undef USE_DJBALLOC #include "uint64.h" #include "gen_alloc.h" #include "uint64alloc.h" GEN_ALLOC_EXTENDED_DEFS(uint64alloc, uint64, s, len, a) prog/skalibs-0.47/src/libstddjb/diuintbunch.h0100644000000000000000000000036011100046312016132 0ustar /* Public domain. */ #ifndef DIUINTBUNCH_H #define DIUINTBUNCH_H #include "diuint.h" #include "diuintalloc.h" #include "gen_bunch.h" GEN_BUNCH_PROTOTYPES(diuintbunch, diuintalloc, diuint) #define DIUINTBUNCH_ZERO GEN_BUNCH_ZERO #endif prog/skalibs-0.47/src/libstddjb/diuintalloc_x.c0100644000000000000000000000022307772716315016500 0ustar /* Public domain. */ #include "gen_alloc.h" #include "diuint.h" #include "diuintalloc.h" GEN_ALLOC_EXTENDED_DEFS(diuintalloc, diuint, s, len, a) prog/skalibs-0.47/src/libstddjb/uint32aalloc_x.c0100644000000000000000000000021007772677172016474 0ustar /* Public domain. */ #include "uint32alloc.h" #include "uint32aalloc.h" GEN_ALLOC_EXTENDED_DEFS(uint32aalloc, uint32alloc, s, len, a) prog/skalibs-0.47/src/libstddjb/sagetcwd.c0100644000000000000000000000075007773236464015453 0ustar /* Public domain. */ #include #include #include "bytestr.h" #include "stralloc.h" #include "djbunix.h" int sagetcwd (stralloc *sa) { unsigned int n = 128 ; unsigned char wasnull = !sa->s ; for (;;) { if (!stralloc_readyplus(sa, n)) goto err ; if (getcwd(sa->s + sa->len, n)) break ; if (errno != ERANGE) goto err ; n += 128 ; } sa->len += str_len(sa->s + sa->len) ; return 0 ; err: if (wasnull) stralloc_free(sa) ; return -1 ; } prog/skalibs-0.47/src/libstddjb/sabasename.c0100644000000000000000000000066007773221605015740 0ustar /* Public domain. */ #include "bytestr.h" #include "stralloc.h" #include "djbunix.h" int sabasename (stralloc *sa, char const *s, unsigned int len) { if (!len) return stralloc_catb(sa, ".", 1) ; while (len && (s[len-1] == '/')) len-- ; if (!len) return stralloc_catb(sa, "/", 1) ; { register unsigned int i = byte_rchr(s, len, '/') ; i = (i == len) ? 0 : i+1 ; return stralloc_catb(sa, s + i, len - i) ; } } prog/skalibs-0.47/src/libstddjb/rm_rf_in_tmp.c0100644000000000000000000000435610317346156016317 0ustar /* Public domain. */ #include #include #include #include "bytestr.h" #include "stralloc.h" #include "direntry.h" #include "djbunix.h" static int rmstarindir (DIR *dir, stralloc *tmp, unsigned int ipos) /* WARNING: closes dir */ { unsigned int tmpbase = tmp->len ; for (;;) { register direntry *d ; errno = 0 ; d = readdir(dir) ; if (!d) break ; if (d->d_name[0] == '.') if (((d->d_name[1] == '.') && (d->d_name[2] == 0)) || (d->d_name[1] == 0)) continue ; if (!stralloc_cats(tmp, d->d_name) || !stralloc_0(tmp)) goto closeanderr ; } if (errno) goto closeanderr ; dir_close(dir) ; { unsigned int tmpstop = tmp->len ; unsigned int fnbase = str_len(tmp->s + ipos) ; unsigned int i = tmpbase ; if (!stralloc_readyplus(tmp, fnbase+1)) goto err ; stralloc_catb(tmp, tmp->s + ipos, fnbase) ; stralloc_catb(tmp, "/", 1) ; fnbase = tmp->len ; for (; i < tmpstop ; i += tmp->len - fnbase) { register unsigned int n = str_len(tmp->s + i) ; tmp->len = fnbase ; if (!stralloc_readyplus(tmp, n+1)) goto err ; stralloc_catb(tmp, tmp->s + i, n+1) ; if (rm_rf_in_tmp(tmp, tmpstop) == -1) goto err ; } } tmp->len = tmpbase ; return 0 ; closeanderr: { register int e = errno ; dir_close(dir) ; errno = e ; } err: tmp->len = tmpbase ; return -1 ; } int rm_rf_in_tmp (stralloc *tmp, unsigned int ipos) { if (unlink(tmp->s + ipos) == 0) return 0 ; if (errno == ENOENT) return 0 ; if ((errno != EISDIR) && (errno != EPERM)) return -1 ; { register unsigned char h = (errno == EPERM) ; register DIR *dir = opendir(tmp->s + ipos) ; if (!dir) { if (h && (errno == ENOTDIR)) errno = EPERM ; return -1 ; } if (rmstarindir(dir, tmp, ipos) == -1) return -1 ; } return rmdir(tmp->s + ipos) ; } int rmstar_tmp (char const *dirname, stralloc *tmp) { unsigned int tmpbase = tmp->len ; if (!stralloc_cats(tmp, dirname)) return -1 ; if (!stralloc_0(tmp)) goto err ; { register DIR *dir = opendir(dirname) ; if (!dir) goto err ; if (rmstarindir(dir, tmp, tmpbase) == -1) goto err ; } tmp->len = tmpbase ; return 0 ; err: tmp->len = tmpbase ; return -1 ; } prog/skalibs-0.47/src/libstddjb/fd_chdir.c0100644000000000000000000000031707773226232015403 0ustar /* Public domain. */ #include #include #include "djbunix.h" int fd_chdir (int d) { register int r ; do r = fchdir(d) ; while ((r == -1) && (errno == EINTR)) ; return r ; } prog/skalibs-0.47/src/libstddjb/sagethostname.c0100644000000000000000000000077107773337453016517 0ustar /* Public domain. */ #include #include "bytestr.h" #include "stralloc.h" int sagethostname (stralloc *sa) { unsigned int n = 128 ; unsigned char wasnull = !sa->s ; for (;;) { if (!stralloc_readyplus(sa, n)) goto err ; sa->s[sa->len + n - 2] = 0 ; if (gethostname(sa->s + sa->len, n) == -1) goto err ; if (!sa->s[sa->len + n - 2]) break ; n += 128 ; } sa->len += str_len(sa->s + sa->len) ; return 0 ; err: if (wasnull) stralloc_free(sa) ; return -1 ; } prog/skalibs-0.47/src/libstddjb/sauniquename.c0100644000000000000000000000122110321116405016306 0ustar /* Public domain. */ #include #include "fmtscan.h" #include "tai.h" #include "stralloc.h" #include "djbunix.h" #include "skamisc.h" int sauniquename (stralloc *sa) { unsigned int base = sa->len ; unsigned char wasnull = !sa->s ; if (!stralloc_readyplus(sa, TIMESTAMP + UINT_FMT + 131)) return -1 ; sa->s[base] = ':' ; timestamp(sa->s + base + 1) ; sa->s[base + 1 + TIMESTAMP] = ':' ; sa->len = base + 2 + TIMESTAMP ; sa->len += uint_fmt(sa->s + sa->len, getpid()) ; sa->s[sa->len++] = ':' ; if (sagethostname(sa) == -1) goto err ; return 0 ; err: if (wasnull) stralloc_free(sa) ; else sa->len = base ; return -1 ; } prog/skalibs-0.47/src/libstddjb/ucharn_findlen.c0100644000000000000000000000026610022322403016575 0ustar /* Public domain. */ #include "fmtscan.h" unsigned int ucharn_findlen (char const *s) { register unsigned int i = 0 ; while (fmtscan_num(s[i], 16) <= 0xF) i++ ; return i ; } prog/skalibs-0.47/src/libstddjb/ushort0_scan.c0100644000000000000000000000021010003730416016221 0ustar /* Public domain. */ #include #include "fmtscan.h" #include "fmtscan-internal.h" SCANU0(ushort, unsigned short, USHRT_MAX) prog/skalibs-0.47/src/libstddjb/sanitize_read.c0100644000000000000000000000042010010474417016441 0ustar /* Public domain. */ #include #include "allreadwrite.h" #include "error.h" int sanitize_read (int r) { switch (r) { case -1 : return error_isagain(errno) ? (errno = 0, 0) : -1 ; case 0 : return (errno = EPIPE, -1) ; default : return r ; } } prog/skalibs-0.47/src/libstddjb/realpath_tmp.c0100644000000000000000000000110010031056104016264 0ustar /* Public domain. */ #include #include #include "bytestr.h" #include "stralloc.h" #include "djbunix.h" #ifndef PATH_MAX # define PATH_MAX 4095 #endif char *realpath_tmp (char const *name, char *buf, stralloc *tmp) { unsigned int tmpbase = tmp->len ; if (sarealpath(tmp, name) == -1) return (char *)0 ; if (tmp->len - tmpbase > PATH_MAX) { tmp->len = tmpbase ; return (errno = ENAMETOOLONG, (char *)0) ; } byte_copy(buf, tmp->len - tmpbase, tmp->s + tmpbase) ; buf[tmp->len - tmpbase] = 0 ; tmp->len = tmpbase ; return buf ; } prog/skalibs-0.47/src/libstddjb/socket_deadlineconn.c0100644000000000000000000000142010023106374017612 0ustar /* Public domain. */ #include #include "uint16.h" #include "error.h" #include "tai.h" #include "iopause.h" #include "socket.h" int socket_deadlineconn (int s, char const *ip, uint16 port, struct taia const *deadline) { if (socket_connect4(s, ip, port) == -1) { iopause_fd x = { s, IOPAUSE_WRITE | IOPAUSE_EXCEPT, 0 } ; if (!error_isagain(errno) && !error_isalready(errno)) return -1 ; for (;;) { struct taia stamp ; taia_now(&stamp) ; switch (iopause(&x, 1, deadline, &stamp)) { case -1 : return -1 ; case 0 : return (errno = ETIMEDOUT, 0) ; } if (x.revents & IOPAUSE_EXCEPT) return -1 ; if (x.revents & IOPAUSE_WRITE) break ; } if (!socket_connected(s)) return -1 ; } return 1 ; } prog/skalibs-0.47/src/libstddjb/absolutepath_tmp.c0100644000000000000000000000301411051642460017176 0ustar /* Public domain. */ #include #include #include "bytestr.h" #include "stralloc.h" #include "djbunix.h" #define SKALIBS_SYMLOOP_MAX 48 int sarealpath_tmp (stralloc *sa, char const *path, stralloc *tmp) { unsigned int tmpbase = tmp->len ; unsigned int base = sa->len ; unsigned int loop = SKALIBS_SYMLOOP_MAX ; int fdhere ; unsigned char wasnull = !sa->s ; if (!path) return (errno = EINVAL, -1) ; if (!stralloc_cats(sa, path)) return -1 ; fdhere = open_read(".") ; if (fdhere == -1) { if (wasnull) stralloc_free(sa) ; else sa->len = base ; return -1 ; } do { tmp->len = tmpbase ; if (!loop--) { errno = ELOOP ; goto err ; } if (!sadirname(tmp, sa->s + base, sa->len - base) || !stralloc_0(tmp) || (chdir(tmp->s + tmpbase) == -1)) goto err ; tmp->len = tmpbase ; if (!sabasename(tmp, sa->s + base, sa->len - base) || !stralloc_0(tmp)) goto err ; sa->len = base ; } while (sareadlink(sa, tmp->s + tmpbase) >= 0) ; if ((errno != EINVAL) || (sagetcwd(sa) == -1) || ((sa->len > base + 1) && !stralloc_catb(sa, "/", 1)) || ((tmp->len > tmpbase) && (tmp->s[tmpbase] != '/') && !stralloc_catb(sa, tmp->s + tmpbase, tmp->len - tmpbase))) goto err ; tmp->len = tmpbase ; fd_chdir(fdhere) ; fd_close(fdhere) ; return 0 ; err: { register int e = errno ; tmp->len = tmpbase ; fd_chdir(fdhere) ; fd_close(fdhere) ; if (wasnull) stralloc_free(sa) ; else sa->len = base ; errno = e ; } return -1 ; } prog/skalibs-0.47/src/libstddjb/ucspi_get_tmp.c0100644000000000000000000000077010024101524016461 0ustar /* Public domain. */ #include #include "stralloc.h" #include "env.h" char const *ucspi_get_tmp (char const *s, stralloc *tmp) { unsigned int tmpbase = tmp->len ; char const *x = env_get("PROTO") ; if (!x) return (errno = EINVAL, (char const *)0) ; if (!stralloc_cats(tmp, x)) return 0 ; if (!stralloc_cats(tmp, s) || !stralloc_0(tmp)) { tmp->len = tmpbase ; return 0 ; } x = env_get(tmp->s + tmpbase) ; tmp->len = tmpbase ; if (!x) errno = EINVAL ; return x ; } prog/skalibs-0.47/src/libstddjb/pathexec_run_tmp.c.stupid0100644000000000000000000000050710024074653020505 0ustar /* Public domain. */ #include "env.h" #include "stralloc.h" #include "djbunix.h" void pathexec_run_tmp (char const *file, char const *const *argv, char const *const *envp, stralloc *tmp) { register char const *path = env_get("PATH") ; if (!path) path = "$SP_ROOT/command" ; execvep_tmp(file, argv, envp, path, tmp) ; } prog/skalibs-0.47/src/libstddjb/pathexec_r_tmp.c0100644000000000000000000000056011051702450016624 0ustar /* Public domain. */ #include "stralloc.h" #include "envalloc.h" #include "djbunix.h" void pathexec_r_tmp (char const *const *argv, char const *const *envp, unsigned int envlen, char const *modifs, unsigned int modiflen, stralloc *tmp) { envalloc v = ENVALLOC_ZERO ; pathexec_r_tmp_envtmp(argv, envp, envlen, modifs, modiflen, tmp, &v) ; envalloc_free(&v) ; } prog/skalibs-0.47/src/libstddjb/pathexec_r_tmp_envtmp.c0100644000000000000000000000067410024101656020223 0ustar /* Public domain. */ #include "stralloc.h" #include "envalloc.h" #include "djbunix.h" void pathexec_r_tmp_envtmp (char const *const *argv, char const *const *envp, unsigned int envlen, char const *modifs, unsigned int modiflen, stralloc *tmp, envalloc *v) { unsigned int vbase = v->len ; if (envalloc_merge(v, envp, envlen, modifs, modiflen) && envalloc_0(v)) pathexec_run_tmp(argv[0], argv, v->s + vbase, tmp) ; v->len = vbase ; } prog/skalibs-0.47/src/libstddjb/pathexec0_tmp.c0100644000000000000000000000031510024100611016347 0ustar /* Public domain. */ #include #include "stralloc.h" #include "djbunix.h" void pathexec0_tmp (char const *const *argv, stralloc *tmp) { if (!argv[0]) _exit(0) ; pathexec_tmp(argv, tmp) ; } prog/skalibs-0.47/src/libstddjb/pathexec0_run_tmp.c0100644000000000000000000000037510024100734017247 0ustar /* Public domain. */ #include #include "stralloc.h" #include "djbunix.h" void pathexec0_run_tmp (char const *const *argv, char const *const *envp, stralloc *tmp) { if (!argv[0]) _exit(0) ; pathexec_run_tmp(argv[0], argv, envp, tmp) ; } prog/skalibs-0.47/src/libstddjb/ucharn_scan_little.c0100644000000000000000000000060310324523563017471 0ustar /* Public domain. */ #include "fmtscan.h" unsigned int ucharn_scan_little (char const *s, char *key, unsigned int n) { register unsigned int i = 0 ; for (; i < n ; i++) { unsigned char c = fmtscan_num(s[(i<<1)+1], 16) ; if (c > 0xF) return 0 ; key[i] = c << 4 ; c = fmtscan_num(s[i<<1], 16) ; if (c > 0xF) return 0 ; key[i] += c ; } return n << 1 ; } prog/skalibs-0.47/src/libstddjb/diuint32alloc.h0100644000000000000000000000034111051003376016301 0ustar /* Public domain. */ #ifndef DIUINT32ALLOC_H #define DIUINT32ALLOC_H #include "gen_alloc.h" #include "diuint32.h" GEN_ALLOC_PROTOTYPES(diuint32alloc, diuint32, s, len, a) #define DIUINT32ALLOC_ZERO GEN_ALLOC_ZERO #endif prog/skalibs-0.47/src/libstddjb/ucharn_fmt_little.c0100644000000000000000000000047710324523467017347 0ustar /* Public domain. */ #include "fmtscan.h" unsigned int ucharn_fmt_little (char *s, char const *key, unsigned int n) { register unsigned int i = 0 ; for (; i < n ; i++) { s[i<<1] = fmtscan_asc((unsigned char)key[i] & 0xF) ; s[(i<<1)+1] = fmtscan_asc((unsigned char)key[i] >> 4) ; } return n << 1 ; } prog/skalibs-0.47/src/libstddjb/diuint32.h0100644000000000000000000000030311100046312015254 0ustar /* Public domain. */ #ifndef DIUINT32_H #define DIUINT32_H #include "uint32.h" typedef struct diuint32 diuint32, *diuint32_ref ; struct diuint32 { uint32 left ; uint32 right ; } ; #endif prog/skalibs-0.47/src/libstddjb/diuint32bunch.h0100644000000000000000000000032510321254652016314 0ustar /* Public domain. */ #ifndef DIUINT32BUNCH_H #define DIUINT32BUNCH_H #include "diuint32.h" #include "diuint32alloc.h" #include "gen_bunch.h" GEN_BUNCH_PROTOTYPES(diuint32bunch, diuint32alloc, diuint32) #endif prog/skalibs-0.47/src/libstddjb/diuint32alloc.c0100644000000000000000000000023310321254456016302 0ustar /* Public domain. */ #include "gen_alloc.h" #include "diuint32.h" #include "diuint32alloc.h" GEN_ALLOC_BASE_DEFS(diuint32alloc, diuint32, s, len, a, 64) prog/skalibs-0.47/src/libstddjb/diuint32bunch.c0100644000000000000000000000027110321255026016303 0ustar /* Public domain. */ #include "diuint32.h" #include "diuint32alloc.h" #include "gen_bunch.h" #include "diuint32bunch.h" GEN_BUNCH_DEFS(diuint32bunch, diuint32alloc, diuint32, 64, 16) prog/skalibs-0.47/src/libstddjb/diuint32alloc_x.c0100644000000000000000000000023310321254540016623 0ustar /* Public domain. */ #include "gen_alloc.h" #include "diuint32.h" #include "diuint32alloc.h" GEN_ALLOC_EXTENDED_DEFS(diuint32alloc, diuint32, s, len, a) prog/skalibs-0.47/src/libdns/0040755000000000000000000000000011051021611012763 5ustar prog/skalibs-0.47/src/libdns/EXPORT0100644000000000000000000000001107663560170013742 0ustar libdns.a prog/skalibs-0.47/src/libdns/INCLUDE0100644000000000000000000000004207663560170014010 0ustar dns.h dns_helper.h dns_transmit.h prog/skalibs-0.47/src/libdns/INTERNAL0100644000000000000000000000104110177543744014143 0ustar dns_dfd.o dns_domain_copy.o dns_domain_free.o dns_domain_length.o dns_domain_suffix.o dns_domain_suffixpos.o dns_dtda.o dns_ip4.o dns_ip4b.o dns_ip_p.o dns_ipq.o dns_ipq_rules.o dns_ipq_rulesb.o dns_ipqb.o dns_ipqb_r_tmp.o dns_mx.o dns_mx_p.o dns_name.o dns_name_p.o dns_nd.o dns_packet_copy.o dns_packet_getname.o dns_packet_skipname.o dns_rcip.o dns_rcip_info_here.o dns_rcipit.o dns_rcrw.o dns_rcrw_info_free.o dns_rcrw_info_here.o dns_rcrwit.o dns_rcrwit_tmp.o dns_resolve.o dns_resolve_r.o dns_sortip.o dns_transmit.o dns_txt.o dns_txt_p.o prog/skalibs-0.47/src/libdns/Makefile0100644000000000000000000001170410177544202014441 0ustar it: command include library library.so clean: EXPORT INTERNAL rm -f `cat EXPORT INTERNAL` dns.h: dns_helper.h dns_transmit.h touch dns.h dns_helper.h: gccattributes.h bytestr.h stralloc.h touch dns_helper.h dns_transmit.h: stralloc.h gen_alloc.h tai.h iopause.h touch dns_transmit.h dns_dfd.o: compile dns_dfd.c dns_helper.h error.h alloc.h bytestr.h ./compile dns_dfd.c dns_domain_copy.o: compile dns_domain_copy.c dns_helper.h alloc.h bytestr.h ./compile dns_domain_copy.c dns_domain_free.o: compile dns_domain_free.c dns_helper.h alloc.h ./compile dns_domain_free.c dns_domain_length.o: compile dns_domain_length.c dns_helper.h ./compile dns_domain_length.c dns_domain_suffix.o: compile dns_domain_suffix.c dns_helper.h ./compile dns_domain_suffix.c dns_domain_suffixpos.o: compile dns_domain_suffixpos.c dns_helper.h ./compile dns_domain_suffixpos.c dns_dtda.o: compile dns_dtda.c dns_helper.h stralloc.h ./compile dns_dtda.c dns_ip4.o: compile dns_ip4.c dns.h stralloc.h ./compile dns_ip4.c dns_ip4b.o: compile dns_ip4b.c dns.h stralloc.h ./compile dns_ip4b.c dns_ip_p.o: compile dns_ip_p.c dns_helper.h stralloc.h bytestr.h uint16.h ./compile dns_ip_p.c dns_ipq.o: compile dns_ipq.c dns_transmit.h stralloc.h ./compile dns_ipq.c dns_ipqb.o: compile dns_ipqb.c dns_transmit.h skamisc.h stralloc.h ./compile dns_ipqb.c dns_ipqb_r_tmp.o: compile dns_ipqb_r_tmp.c dns_transmit.h stralloc.h ./compile dns_ipqb_r_tmp.c dns_ipq_rules.o: compile dns_ipq_rules.c dns_transmit.h stralloc.h bytestr.h ./compile dns_ipq_rules.c dns_ipq_rulesb.o: compile dns_ipq_rulesb.c dns_transmit.h stralloc.h ./compile dns_ipq_rulesb.c dns_mx.o: compile dns_mx.c dns.h stralloc.h ./compile dns_mx.c dns_mx_p.o: compile dns_mx_p.c dns_helper.h stralloc.h bytestr.h uint16.h ./compile dns_mx_p.c dns_name.o: compile dns_name.c dns.h stralloc.h ./compile dns_name.c dns_name_p.o: compile dns_name_p.c dns_helper.h stralloc.h bytestr.h uint16.h ./compile dns_name_p.c dns_nd.o: compile dns_nd.c dns_helper.h fmtscan.h bytestr.h ./compile dns_nd.c dns_packet_copy.o: compile dns_packet_copy.c dns_helper.h error.h bytestr.h ./compile dns_packet_copy.c dns_packet_getname.o: compile dns_packet_getname.c dns_helper.h error.h ./compile dns_packet_getname.c dns_packet_skipname.o: compile dns_packet_skipname.c dns_helper.h error.h ./compile dns_packet_skipname.c dns_rcip.o: compile dns_rcip.c dns_transmit.h bytestr.h ./compile dns_rcip.c dns_rcipit.o: compile dns_rcipit.c dns_transmit.h djbunix.h tai.h fmtscan.h bytestr.h ./compile dns_rcipit.c dns_rcip_info_here.o: compile dns_rcip_info_here.c dns_transmit.h ./compile dns_rcip_info_here.c dns_rcrw_info_here.o: compile dns_rcrw_info_here.c dns_transmit.h ./compile dns_rcrw_info_here.c dns_rcrw_info_free.o: compile dns_rcrw_info_free.c dns_transmit.h stralloc.h tai.h ./compile dns_rcrw_info_free.c dns_rcrw.o: compile dns_rcrw.c dns_transmit.h skamisc.h stralloc.h ./compile dns_rcrw.c dns_rcrwit.o: compile dns_rcrwit.c dns_transmit.h skamisc.h ./compile dns_rcrwit.c dns_rcrwit_tmp.o: compile dns_rcrwit_tmp.c dns_transmit.h djbunix.h env.h tai.h stralloc.h bytestr.h ./compile dns_rcrwit_tmp.c dns_resolve.o: compile dns_resolve.c dns_transmit.h ./compile dns_resolve.c dns_resolve_r.o: compile dns_resolve_r.c dns_transmit.h iopause.h tai.h ./compile dns_resolve_r.c dns_sortip.o: compile dns_sortip.c dns_helper.h random.h bytestr.h ./compile dns_sortip.c dns_transmit.o: compile dns_transmit.c dns.h socket.h random.h iopause.h tai.h error.h bytestr.h alloc.h allreadwrite.h uint16.h ./compile dns_transmit.c dns_txt.o: compile dns_txt.c dns.h stralloc.h ./compile dns_txt.c dns_txt_p.o: compile dns_txt_p.c dns_helper.h stralloc.h bytestr.h uint16.h ./compile dns_txt_p.c libdns.a: makelib dns_dfd.o dns_domain_copy.o \ dns_domain_free.o dns_domain_length.o dns_domain_suffix.o \ dns_domain_suffixpos.o dns_dtda.o dns_ip4.o dns_ip4b.o dns_ip_p.o \ dns_ipq.o dns_ipqb.o dns_ipqb_r_tmp.o dns_ipq_rules.o dns_ipq_rulesb.o \ dns_mx.o dns_mx_p.o dns_name.o dns_name_p.o dns_nd.o \ dns_packet_copy.o dns_packet_getname.o dns_packet_skipname.o \ dns_rcip.o dns_rcipit.o dns_rcip_info_here.o \ dns_rcrw_info_here.o dns_rcrw_info_free.o dns_rcrw.o dns_rcrwit.o dns_rcrwit_tmp.o \ dns_resolve.o dns_resolve_r.o dns_sortip.o dns_transmit.o \ dns_txt.o dns_txt_p.o ./makelib libdns.a \ dns_dfd.o dns_domain_copy.o \ dns_domain_free.o dns_domain_length.o dns_domain_suffix.o \ dns_domain_suffixpos.o dns_dtda.o dns_ip4.o dns_ip4b.o dns_ip_p.o \ dns_ipq.o dns_ipqb.o dns_ipqb_r_tmp.o dns_ipq_rules.o dns_ipq_rulesb.o \ dns_mx.o dns_mx_p.o dns_name.o dns_name_p.o dns_nd.o \ dns_packet_copy.o dns_packet_getname.o dns_packet_skipname.o \ dns_rcip.o dns_rcipit.o dns_rcip_info_here.o \ dns_rcrw_info_here.o dns_rcrw_info_free.o dns_rcrw.o dns_rcrwit.o dns_rcrwit_tmp.o \ dns_resolve.o dns_resolve_r.o dns_sortip.o dns_transmit.o \ dns_txt.o dns_txt_p.o command: include: dns.h dns_helper.h dns_transmit.h library: libdns.a library.so: prog/skalibs-0.47/src/libdns/dns_dfd.c0100644000000000000000000000275107773125141014555 0ustar /* Public domain. */ #include #include "error.h" #include "bytestr.h" #undef USE_DJBALLOC #include "alloc.h" #include "dns_helper.h" int dns_domain_fromdot (char **out, char const *buf, unsigned int n) { char label[63] ; unsigned int labellen = 0 ; /* <= sizeof label */ char name[255] ; unsigned int namelen = 0 ; /* <= sizeof name */ char ch ; char *x ; errno = EPROTO ; for (;;) { if (!n) break; ch = *buf++; --n; if (ch == '.') { if (labellen) { if (namelen + labellen + 1 > sizeof name) return 0; name[namelen++] = labellen; byte_copy(name + namelen,labellen,label); namelen += labellen; labellen = 0; } continue; } if (ch == '\\') { if (!n) break; ch = *buf++; --n; if ((ch >= '0') && (ch <= '7')) { ch -= '0'; if (n && (*buf >= '0') && (*buf <= '7')) { ch <<= 3; ch += *buf - '0'; ++buf; --n; if (n && (*buf >= '0') && (*buf <= '7')) { ch <<= 3; ch += *buf - '0'; ++buf; --n; } } } } if (labellen >= sizeof label) return 0; label[labellen++] = ch; } if (labellen) { if (namelen + labellen + 1 > sizeof name) return 0; name[namelen++] = labellen; byte_copy(name + namelen,labellen,label); namelen += labellen; labellen = 0; } if (namelen + 1 > sizeof name) return 0; name[namelen++] = 0; x = alloc(namelen); if (!x) return 0; byte_copy(x,namelen,name); if (*out) alloc_free(*out); *out = x; errno = 0 ; return 1; } prog/skalibs-0.47/src/libdns/dns_ip_p.c0100644000000000000000000000170310004503456014731 0ustar /* Public domain. */ #include "uint16.h" #include "bytestr.h" #include "stralloc.h" #include "dns_helper.h" int dns_ip4_packet(stralloc *out,char const *buf,unsigned int len) { unsigned int pos; char header[12]; uint16 numanswers; uint16 datalen; out->len = 0 ; pos = dns_packet_copy(buf,len,0,header,12); if (!pos) return -1; uint16_unpack_big(header + 6,&numanswers); pos = dns_packet_skipname(buf,len,pos); if (!pos) return -1; pos += 4; while (numanswers--) { pos = dns_packet_skipname(buf,len,pos); if (!pos) return -1; pos = dns_packet_copy(buf,len,pos,header,10); if (!pos) return -1; uint16_unpack_big(header + 8,&datalen); if (byte_equal(header,2,DNS_T_A)) if (byte_equal(header + 2,2,DNS_C_IN)) if (datalen == 4) { if (!dns_packet_copy(buf,len,pos,header,4)) return -1; if (!stralloc_catb(out,header,4)) return -1; } pos += datalen; } dns_sortip(out->s, out->len) ; return 0; } prog/skalibs-0.47/src/libdns/dns_dtda.c0100644000000000000000000000144007772700054014727 0ustar /* Public domain. */ #include "stralloc.h" #include "dns_helper.h" int dns_domain_todot_cat (stralloc *out, char const *d) { char ch; char ch2; unsigned char ch3; char buf[4]; if (!*d) return stralloc_catb(out, ".", 1) ; for (;;) { ch = *d++; while (ch--) { ch2 = *d++; if ((ch2 >= 'A') && (ch2 <= 'Z')) ch2 += 32; if (((ch2 >= 'a') && (ch2 <= 'z')) || ((ch2 >= '0') && (ch2 <= '9')) || (ch2 == '-') || (ch2 == '_')) { if (!stralloc_catb(out, &ch2, 1)) return 0; } else { ch3 = ch2; buf[3] = '0' + (ch3 & 7); ch3 >>= 3; buf[2] = '0' + (ch3 & 7); ch3 >>= 3; buf[1] = '0' + (ch3 & 7); buf[0] = '\\'; if (!stralloc_catb(out,buf,4)) return 0; } } if (!*d) return 1; if (!stralloc_catb(out, ".", 1)) return 0; } } prog/skalibs-0.47/src/libdns/dns_ipq.c0100644000000000000000000000033310031405757014576 0ustar /* Public domain. */ /* MT-unsafe */ #include "stralloc.h" #include "dns_transmit.h" int dns_ip4_qualify (stralloc *out, stralloc *fqdn, stralloc const *in) { return dns_ip4_qualifyb(out, fqdn, in->s, in->len) ; } prog/skalibs-0.47/src/libdns/dns_mx.c0100644000000000000000000000073210035312135014423 0ustar /* Public domain. */ /* MT-unsafe */ #include "stralloc.h" #include "dns.h" int dns_mx (stralloc *out, stralloc const *fqdn) { char *q = 0 ; register int r ; if (!dns_domain_fromdot(&q, fqdn->s, fqdn->len)) goto err ; if (dns_resolve(q, DNS_T_MX) == -1) goto err ; r = dns_mx_packet(out, dns_resolve_tx.packet, dns_resolve_tx.packetlen) ; dns_transmit_free(&dns_resolve_tx) ; dns_domain_free(&q) ; return r ; err: dns_domain_free(&q) ; return -1 ; } prog/skalibs-0.47/src/libdns/dns_name.c0100644000000000000000000000061310035312164014717 0ustar /* Public domain. */ /* MT-unsafe */ #include "stralloc.h" #include "dns.h" int dns_name4 (stralloc *out, char const *ip) { char name[DNS_NAME4_DOMAIN] ; register int r ; dns_name4_domain(name, ip) ; if (dns_resolve(name, DNS_T_PTR) == -1) return -1 ; r = dns_name_packet(out, dns_resolve_tx.packet, dns_resolve_tx.packetlen) ; dns_transmit_free(&dns_resolve_tx) ; return r ; } prog/skalibs-0.47/src/libdns/dns_nd.c0100644000000000000000000000125510035414737014414 0ustar /* Public domain. */ #include "bytestr.h" #include "fmtscan.h" #include "dns_helper.h" void dns_name4_domain (char *name, char const *ip) { unsigned int namelen = 0 ; unsigned int i = uint_fmt(name + 1, (unsigned int)(unsigned char)ip[3]) ; name[namelen++] = i ; namelen += i ; i = uint_fmt(name + namelen + 1, (unsigned int)(unsigned char)ip[2]) ; name[namelen++] = i ; namelen += i ; i = uint_fmt(name + namelen + 1, (unsigned int)(unsigned char)ip[1]) ; name[namelen++] = i ; namelen += i ; i = uint_fmt(name + namelen + 1, (unsigned int)(unsigned char)ip[0]) ; name[namelen++] = i ; namelen += i ; byte_copy(name + namelen, 14, "\7in-addr\4arpa") ; } prog/skalibs-0.47/src/libdns/dns_sortip.c0100644000000000000000000000076010040426747015333 0ustar /* Public domain. */ /* MT-unsafe */ #include "bytestr.h" #include "random.h" #include "dns_helper.h" /* XXX: sort servers by configurable notion of closeness? */ /* XXX: pay attention to competence of each server? */ void dns_sortip (char *s, unsigned int n) { n >>= 2 ; while (n > 1) { char tmp[4] ; register unsigned int i = badrandom_int(n--) ; byte_copy(tmp, 4, s + (i << 2)) ; byte_copy(s + (i << 2), 4, s + (n << 2)) ; byte_copy(s + (n << 2), 4, tmp) ; } } prog/skalibs-0.47/src/libdns/dns_rcipit.c0100644000000000000000000000316011051021440015262 0ustar /* Public domain. */ #include #include "bytestr.h" #include "fmtscan.h" #include "tai.h" #include "djbunix.h" #include "dns_transmit.h" static int init (char *ip) { unsigned int iplen = 0 ; char const *x = env_get("DNSCACHEIP") ; if (x) while (iplen <= 60) { if (*x == '.') ++x ; else { unsigned int i = ip4_scan(x, ip + iplen) ; if (!i) break ; x += i ; iplen += 4 ; } } if (!iplen) { char tmp[257] ; int n = openreadnclose("/etc/resolv.conf", tmp, 256) ; if (n == -1) { if (errno != ENOENT) return 0 ; else n = 0 ; } if (n) { unsigned int i = 0, j = 0 ; errno = 0 ; tmp[n++] = '\n' ; for (; (int)j < n ; j++) if (tmp[j] == '\n') { if (byte_equal("nameserver ", 11, tmp + i) || byte_equal("nameserver\t", 11, tmp + i)) { i += 10 ; while ((tmp[i] == ' ') || (tmp[i] == '\t')) ++i ; if (iplen <= 60) if (ip4_scan(tmp + i, ip + iplen)) { if (byte_equal(ip + iplen, 4, "\0\0\0")) byte_copy(ip + iplen, 4, "\177\0\0\1") ; iplen += 4 ; } } i = j + 1 ; } } } if (!iplen) { byte_copy(ip, 4, "\177\0\0\1") ; iplen = 4 ; } byte_zero(ip + iplen, 64 - iplen) ; return 1 ; } int dns_resolvconfipit (struct dns_rcip_info *dr) { struct taia now ; taia_now(&now) ; if (!dr->uses-- || taia_less(&dr->deadline, &now)) { if (!init(dr->ip)) return 0 ; taia_addsec(&dr->deadline, &now, 600) ; dr->uses = 10000 ; } return 1 ; } prog/skalibs-0.47/src/libdns/dns_rcrw.c0100644000000000000000000000050610035271217014760 0ustar /* Public domain. */ /* MT-unsafe */ #include "stralloc.h" #include "dns_transmit.h" int dns_resolvconfrewrite (stralloc *out) { if (!dns_resolvconfrewriteit(&dns_rcrw_info_here)) return -1 ; out->len = 0 ; if (!stralloc_catb(out, dns_rcrw_info_here.rules.s, dns_rcrw_info_here.rules.len)) return -1 ; return 0 ; } prog/skalibs-0.47/src/libdns/dns_resolve.c0100644000000000000000000000037410177544107015475 0ustar /* Public domain. */ /* MT-unsafe */ #include "dns_transmit.h" struct dns_transmit dns_resolve_tx = DNS_TRANSMIT_ZERO ; int dns_resolve (char const *q, char const *qtype) { return dns_resolve_r(q, qtype, &dns_resolve_tx, &dns_rcip_info_here) ; } prog/skalibs-0.47/src/libdns/dns_txt_p.c0100644000000000000000000000224107772700343015152 0ustar /* Public domain. */ #include "uint16.h" #include "bytestr.h" #include "stralloc.h" #include "dns_helper.h" int dns_txt_packet (stralloc *out, char const *buf, unsigned int len) { unsigned int pos; char header[12]; uint16 numanswers; uint16 datalen; char ch; unsigned int txtlen; int i; if (!stralloc_ready(out, 8)) return -1 ; out->len = 0 ; pos = dns_packet_copy(buf,len,0,header,12); if (!pos) return -1; uint16_unpack_big(header + 6,&numanswers); pos = dns_packet_skipname(buf,len,pos); if (!pos) return -1; pos += 4; while (numanswers--) { pos = dns_packet_skipname(buf,len,pos); if (!pos) return -1; pos = dns_packet_copy(buf,len,pos,header,10); if (!pos) return -1; uint16_unpack_big(header + 8,&datalen); if (byte_equal(header,2,DNS_T_TXT)) if (byte_equal(header + 2,2,DNS_C_IN)) { if (pos + datalen > len) return -1; txtlen = 0; for (i = 0;i < datalen;++i) { ch = buf[pos + i]; if (!txtlen) txtlen = (unsigned char) ch; else { --txtlen; if (ch < 32) ch = '?'; if (ch > 126) ch = '?'; if (!stralloc_catb(out, &ch, 1)) return -1 ; } } } pos += datalen ; } return 0 ; } prog/skalibs-0.47/src/libdns/dns_transmit.c0100644000000000000000000002114010325071655015647 0ustar /* Public domain. */ #include #include #include #include "uint16.h" #undef USE_DJBALLOC #include "allreadwrite.h" #include "alloc.h" #include "bytestr.h" #include "error.h" #include "tai.h" #include "iopause.h" #include "djbunix.h" #include "random.h" #include "socket.h" #include "dns.h" static int serverwantstcp (char const *buf, unsigned int len) { char out[12] ; if (!dns_packet_copy(buf, len, 0, out, 12)) return 1 ; if (out[2] & 2) return 1 ; return 0 ; } static int serverfailed (char const *buf, unsigned int len) { char out[12] ; unsigned int rcode ; if (!dns_packet_copy(buf, len, 0, out, 12)) return 1 ; rcode = out[3] ; rcode &= 15 ; if (rcode && (rcode != 3)) return (errno = EAGAIN, 1) ; return 0 ; } static int irrelevant (struct dns_transmit const *d, char const *buf, unsigned int len) { char out[12] ; char *dn = 0 ; unsigned int pos = dns_packet_copy(buf, len, 0, out, 12) ; if (!pos) return 1 ; if (byte_diff(out, 2, d->query + 2)) return 1 ; if (out[4] != 0) return 1 ; if (out[5] != 1) return 1 ; pos = dns_packet_getname(buf, len, pos, &dn) ; if (!pos) return 1; if (!dns_domain_equal(dn, d->query + 14)) { alloc_free(dn) ; return 1 ; } alloc_free(dn) ; pos = dns_packet_copy(buf, len, pos, out, 4) ; if (!pos) return 1 ; if (byte_diff(out, 2, d->qtype)) return 1 ; if (byte_diff(out + 2, 2, DNS_C_IN)) return 1 ; return 0 ; } static void packetfree (struct dns_transmit *d) { if (!d->packet) return ; alloc_free(d->packet) ; d->packet = 0 ; } static void queryfree (struct dns_transmit *d) { if (!d->query) return ; alloc_free(d->query) ; d->query = 0 ; } static void socketfree (struct dns_transmit *d) { if (!d->s1) return ; fd_close(d->s1 - 1) ; d->s1 = 0 ; } void dns_transmit_free (struct dns_transmit *d) { queryfree(d) ; socketfree(d) ; packetfree(d) ; } static int randombind (struct dns_transmit *d) { register unsigned int j = 0 ; for (; j < 10 ; j++) if (socket_bind4(d->s1 - 1, d->localip, 1025 + badrandom_int(64510)) == 0) return 0 ; if (socket_bind4(d->s1 - 1, d->localip, 0) == 0) return 0 ; return -1 ; } static int const timeouts[4] = { 1, 3, 11, 45 } ; static int thisudp (struct dns_transmit *d) { socketfree(d) ; while (d->udploop < 4) { for (; d->curserver < 16 ; ++d->curserver) { char const *ip = d->servers + 4 * d->curserver ; if (byte_diff(ip, 4, "\0\0\0")) { d->query[2] = badrandom_char() ; d->query[3] = badrandom_char() ; d->s1 = 1 + socket_udp() ; if (!d->s1 || (randombind(d) == -1)) { dns_transmit_free(d) ; return -1 ; } if (socket_connect4(d->s1 - 1, ip, 53) == 0) if (fd_send(d->s1 - 1, d->query + 2, d->querylen - 2, 0) == (int)d->querylen - 2) { struct taia now ; taia_now(&now) ; taia_uint(&d->deadline, timeouts[d->udploop]) ; taia_add(&d->deadline, &d->deadline, &now) ; d->tcpstate = 0 ; return 0 ; } socketfree(d) ; } } ++d->udploop ; d->curserver = 0 ; } dns_transmit_free(d) ; return -1 ; } static int firstudp (struct dns_transmit *d) { d->curserver = 0 ; return thisudp(d) ; } static int nextudp (struct dns_transmit *d) { ++d->curserver ; return thisudp(d) ; } static int thistcp (struct dns_transmit *d) { socketfree(d) ; packetfree(d) ; for (; d->curserver < 16 ; ++d->curserver) { char const *ip = d->servers + 4 * d->curserver ; if (byte_diff(ip,4,"\0\0\0")) { struct taia now ; d->query[2] = badrandom_char() ; d->query[3] = badrandom_char() ; d->s1 = 1 + socket_tcp() ; if (!d->s1 || (randombind(d) == -1)) { dns_transmit_free(d) ; return -1 ; } taia_now(&now) ; taia_uint(&d->deadline,10) ; taia_add(&d->deadline, &d->deadline, &now) ; if (socket_connect4(d->s1 - 1, ip, 53) == 0) { d->tcpstate = 2 ; return 0 ; } if (error_isalready(errno) || error_isagain(errno)) { d->tcpstate = 1 ; return 0 ; } socketfree(d) ; } } dns_transmit_free(d) ; return -1 ; } static int firsttcp (struct dns_transmit *d) { d->curserver = 0 ; return thistcp(d) ; } static int nexttcp (struct dns_transmit *d) { ++d->curserver ; return thistcp(d) ; } int dns_transmit_start (struct dns_transmit *d, char const servers[64], int flagrecursive, char const *q, char const qtype[2], char const localip[4]) { unsigned int len ; dns_transmit_free(d) ; errno = EIO ; len = dns_domain_length(q) ; d->querylen = len + 18 ; d->query = alloc(d->querylen) ; if (!d->query) return -1 ; uint16_pack_big(d->query, len + 16) ; byte_copy(d->query + 2, 12, flagrecursive ? "\0\0\1\0\0\1\0\0\0\0\0" : "\0\0\0\0\0\1\0\0\0\0\0\0gcc-bug-workaround") ; byte_copy(d->query + 14, len, q) ; byte_copy(d->query + 14 + len, 2, qtype) ; byte_copy(d->query + 16 + len, 2, DNS_C_IN) ; byte_copy(d->qtype, 2, qtype) ; d->servers = servers ; byte_copy(d->localip, 4, localip) ; d->udploop = flagrecursive ? 1 : 0 ; if (len + 16 > 512) return firsttcp(d) ; return firstudp(d) ; } void dns_transmit_io (struct dns_transmit *d, iopause_fd *x, struct taia *deadline) { x->fd = d->s1 - 1 ; switch (d->tcpstate) { case 0: case 3: case 4: case 5: x->events = IOPAUSE_READ ; break ; case 1: case 2: x->events = IOPAUSE_WRITE ; break ; } if (taia_less(&d->deadline,deadline)) *deadline = d->deadline ; } int dns_transmit_get (struct dns_transmit *d, iopause_fd const *x, struct taia const *when) { char udpbuf[513] ; unsigned char ch ; int r ; int fd = d->s1 - 1 ; errno = EIO ; if (!x->revents) { if (taia_less(when, &d->deadline)) return 0 ; errno = ETIMEDOUT ; if (d->tcpstate == 0) return nextudp(d) ; return nexttcp(d) ; } if (d->tcpstate == 0) { /* have attempted to send UDP query to each server udploop times have sent query to curserver on UDP socket s */ r = fd_recv(fd, udpbuf, sizeof udpbuf, 0) ; if (r <= 0) { if (errno == ECONNREFUSED) if (d->udploop == 2) return 0 ; return nextudp(d) ; } if (r + 1 > (int)sizeof udpbuf) return 0 ; if (irrelevant(d, udpbuf, r)) return 0 ; if (serverwantstcp(udpbuf, r)) return firsttcp(d) ; if (serverfailed(udpbuf, r)) { if (d->udploop == 2) return 0 ; return nextudp(d) ; } socketfree(d) ; d->packetlen = r ; d->packet = alloc(d->packetlen) ; if (!d->packet) { dns_transmit_free(d) ; return -1 ; } byte_copy(d->packet, d->packetlen, udpbuf) ; queryfree(d) ; return 1 ; } if (d->tcpstate == 1) { /* have sent connection attempt to curserver on TCP socket s pos not defined */ if (!socket_connected(fd)) return nexttcp(d) ; d->pos = 0 ; d->tcpstate = 2 ; return 0 ; } if (d->tcpstate == 2) { /* have connection to curserver on TCP socket s have sent pos bytes of query */ r = fd_write(fd, d->query + d->pos, d->querylen - d->pos) ; if (r <= 0) return nexttcp(d) ; d->pos += r ; if (d->pos == d->querylen) { struct taia now ; taia_now(&now) ; taia_addsec(&d->deadline, &now, 10) ; d->tcpstate = 3 ; } return 0 ; } if (d->tcpstate == 3) { /* have sent entire query to curserver on TCP socket s pos not defined */ r = fd_read(fd, (char *)&ch, 1) ; if (r <= 0) return nexttcp(d) ; d->packetlen = ch ; d->tcpstate = 4 ; return 0 ; } if (d->tcpstate == 4) { /* have sent entire query to curserver on TCP socket s pos not defined have received one byte of packet length into packetlen */ r = fd_read(fd, (char *)&ch, 1) ; if (r <= 0) return nexttcp(d) ; d->packetlen <<= 8 ; d->packetlen += ch ; d->tcpstate = 5 ; d->pos = 0 ; d->packet = alloc(d->packetlen) ; if (!d->packet) { dns_transmit_free(d) ; return -1 ; } return 0 ; } if (d->tcpstate == 5) { /* have sent entire query to curserver on TCP socket s have received entire packet length into packetlen packet is allocated have received pos bytes of packet */ r = fd_read(fd, d->packet + d->pos, d->packetlen - d->pos) ; if (r <= 0) return nexttcp(d) ; d->pos += r ; if (d->pos < d->packetlen) return 0 ; socketfree(d) ; if (irrelevant(d,d->packet, d->packetlen)) return nexttcp(d) ; if (serverwantstcp(d->packet, d->packetlen)) return nexttcp(d) ; if (serverfailed(d->packet, d->packetlen)) return nexttcp(d) ; queryfree(d) ; return 1 ; } return 0 ; } prog/skalibs-0.47/src/libdns/dns_name_p.c0100644000000000000000000000200407772702520015247 0ustar /* Public domain. */ #include "uint16.h" #include "bytestr.h" #include "stralloc.h" #include "dns_helper.h" int dns_name_packet(stralloc *out,char const *buf,unsigned int len) { char *q = 0; unsigned int pos; char header[12]; uint16 numanswers; uint16 datalen; out->len = 0 ; pos = dns_packet_copy(buf,len,0,header,12); if (!pos) return -1; uint16_unpack_big(header + 6,&numanswers); pos = dns_packet_skipname(buf,len,pos); if (!pos) return -1; pos += 4; while (numanswers--) { pos = dns_packet_skipname(buf,len,pos); if (!pos) goto err ; pos = dns_packet_copy(buf,len,pos,header,10); if (!pos) goto err ; uint16_unpack_big(header + 8,&datalen); if (byte_equal(header,2,DNS_T_PTR)) if (byte_equal(header + 2,2,DNS_C_IN)) { if (!dns_packet_getname(buf,len,pos,&q)) goto err ; if (!dns_domain_todot_cat(out,q)) goto err ; dns_domain_free(&q) ; return 0; } pos += datalen; } dns_domain_free(&q) ; return 0; err: dns_domain_free(&q) ; return -1 ; } prog/skalibs-0.47/src/libdns/dns_txt.c0100644000000000000000000000073010035311116014612 0ustar /* Public domain. */ /* MT-unsafe */ #include "stralloc.h" #include "dns.h" int dns_txt (stralloc *out, stralloc const *fqdn) { char *q = 0 ; register int r ; if (!dns_domain_fromdot(&q, fqdn->s, fqdn->len)) return -1 ; if (dns_resolve(q, DNS_T_TXT) == -1) { dns_domain_free(&q) ; return -1 ; } r = dns_txt_packet(out, dns_resolve_tx.packet, dns_resolve_tx.packetlen) ; dns_transmit_free(&dns_resolve_tx); dns_domain_free(&q) ; return r ; } prog/skalibs-0.47/src/libdns/dns_domain_copy.c0100644000000000000000000000051607663560170016321 0ustar /* Public domain. */ #include "bytestr.h" #undef USE_DJBALLOC #include "alloc.h" #include "dns_helper.h" int dns_domain_copy (char **out, char const *in) { unsigned int len = dns_domain_length(in) ; char *x = alloc(len) ; if (!x) return 0 ; byte_copy(x, len, in) ; if (*out) alloc_free(*out) ; *out = x ; return 1 ; } prog/skalibs-0.47/src/libdns/dns_domain_length.c0100644000000000000000000000031607663560170016626 0ustar /* Public domain. */ #include "dns_helper.h" unsigned int dns_domain_length (char const *dn) { char const *x = dn ; unsigned char c ; while ((c = *x++)) x += (unsigned int) c ; return x - dn ; } prog/skalibs-0.47/src/libdns/dns.h0100644000000000000000000000015511100046374013726 0ustar /* Public domain. */ #ifndef DNS_H #define DNS_H #include "dns_helper.h" #include "dns_transmit.h" #endif prog/skalibs-0.47/src/libdns/dns_ipqb.c0100644000000000000000000000043710035305247014742 0ustar /* Public domain. */ /* MT-unsafe */ #include "stralloc.h" #include "skamisc.h" #include "dns_transmit.h" int dns_ip4_qualifyb (stralloc *out, stralloc *fqdn, char const *in, unsigned int inlen) { return dns_ip4_qualifyb_r_tmp(out, fqdn, in, inlen, &dns_rcrw_info_here, &satmp) ; } prog/skalibs-0.47/src/libdns/dns_domain_free.c0100644000000000000000000000026607663560170016272 0ustar /* Public domain. */ #undef USE_DJBALLOC #include "alloc.h" #include "dns_helper.h" void dns_domain_free (char **out) { if (*out) { alloc_free(*out) ; *out = 0 ; } } prog/skalibs-0.47/src/libdns/dns_domain_suffix.c0100644000000000000000000000040107663560170016644 0ustar /* Public domain. */ #include "dns_helper.h" int dns_domain_suffix (char const *big, char const *little) { for (;;) { unsigned char c ; if (dns_domain_equal(big, little)) return 1 ; c = *big++ ; if (!c) return 0 ; big += c ; } } prog/skalibs-0.47/src/libdns/dns_domain_suffixpos.c0100644000000000000000000000046007663560170017373 0ustar /* Public domain. */ #include "dns_helper.h" unsigned int dns_domain_suffixpos(char const *big, char const *little) { char const *orig = big ; for (;;) { unsigned char c ; if (dns_domain_equal(big, little)) return big - orig ; c = *big++ ; if (!c) return 0 ; big += c ; } } prog/skalibs-0.47/src/libdns/dns_ipq_rules.c0100644000000000000000000000040310024114367016002 0ustar /* Public domain. */ #include "stralloc.h" #include "dns_transmit.h" int dns_ip4_qualify_rules (stralloc *out, stralloc *fqdn, stralloc const *in, stralloc const *rules) { return dns_ip4_qualify_rulesb(out, fqdn, in->s, in->len, rules->s, rules->len) ; } prog/skalibs-0.47/src/libdns/dns_mx_p.c0100644000000000000000000000226207772702375014771 0ustar /* Public domain. */ #include "uint16.h" #include "bytestr.h" #include "stralloc.h" #include "dns_helper.h" int dns_mx_packet (stralloc *out, char const *buf, unsigned int len) { char *q = 0 ; unsigned int pos ; char header[12] ; char pref[2] ; uint16 numanswers ; uint16 datalen ; out->len = 0 ; pos = dns_packet_copy(buf, len, 0, header, 12) ; if (!pos) return -1 ; uint16_unpack_big(header + 6, &numanswers) ; pos = dns_packet_skipname(buf, len, pos) ; if (!pos) return -1 ; pos += 4 ; while (numanswers--) { pos = dns_packet_skipname(buf, len, pos) ; if (!pos) goto err ; pos = dns_packet_copy(buf, len, pos, header, 10) ; if (!pos) goto err ; uint16_unpack_big(header + 8, &datalen) ; if (byte_equal(header, 2, DNS_T_MX)) if (byte_equal(header + 2, 2, DNS_C_IN)) { if (!dns_packet_copy(buf, len, pos, pref, 2)) goto err ; if (!dns_packet_getname(buf, len, pos + 2, &q)) goto err ; if (!stralloc_catb(out, pref, 2)) goto err ; if (!dns_domain_todot_cat(out, q)) goto err ; if (!stralloc_0(out)) goto err ; } pos += datalen ; } dns_domain_free(&q) ; return 0 ; err: dns_domain_free(&q) ; return -1 ; } prog/skalibs-0.47/src/libdns/dns_transmit.h0100644000000000000000000000565111100046374015655 0ustar /* Public domain. */ #ifndef DNS_TRANSMIT_H #define DNS_TRANSMIT_H #include "tai.h" #include "iopause.h" #include "gen_alloc.h" #include "stralloc.h" /* DNS packet transmission, async primitives */ struct dns_transmit { char *query ; /* 0, or dynamically allocated */ unsigned int querylen ; char *packet ; /* 0, or dynamically allocated */ unsigned int packetlen ; int s1 ; /* 0, or 1 + an open file descriptor */ int tcpstate ; unsigned int udploop ; unsigned int curserver ; struct taia deadline ; unsigned int pos ; char const *servers ; char localip[4] ; char qtype[2] ; } ; #define DNS_TRANSMIT_ZERO {0, 0, 0, 0, 0, 0, 0, 0, TAIA_ZERO, 0, 0, "\0\0\0", "\0"} extern int dns_transmit_start (struct dns_transmit *, char const *, int, char const *, char const *, char const *) ; extern void dns_transmit_free (struct dns_transmit *) ; extern void dns_transmit_io (struct dns_transmit *, iopause_fd *, struct taia *) ; extern int dns_transmit_get (struct dns_transmit *, iopause_fd const *, struct taia const *) ; /* DNS resolution, sync primitives */ struct dns_rcip_info { unsigned int uses ; struct taia deadline ; char ip[64] ; } ; #define DNS_RCIP_INFO_ZERO { 0, TAIA_ZERO, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" } extern struct dns_rcip_info dns_rcip_info_here ; extern int dns_resolvconfip (char *) ; extern int dns_resolvconfipit (struct dns_rcip_info *) ; extern struct dns_transmit dns_resolve_tx ; extern int dns_resolve (char const *, char const *) ; extern int dns_resolve_r (char const *, char const *, struct dns_transmit *, struct dns_rcip_info *) ; extern int dns_ip4 (stralloc *, stralloc const *) ; extern int dns_ip4b (stralloc *, char const *, unsigned int) ; extern int dns_name4 (stralloc *, char const *) ; extern int dns_txt (stralloc *, stralloc const *) ; extern int dns_mx (stralloc *, stralloc const *) ; /* Rewriting rules and resolution with qualification */ struct dns_rcrw_info { unsigned int uses ; struct taia deadline ; stralloc rules ; } ; #define DNS_RCRW_INFO_ZERO { 0, TAIA_ZERO, GEN_ALLOC_ZERO } extern struct dns_rcrw_info dns_rcrw_info_here ; extern void dns_rcrw_info_free (struct dns_rcrw_info *) ; extern int dns_resolvconfrewrite (stralloc *) ; extern int dns_resolvconfrewriteit (struct dns_rcrw_info *) ; extern int dns_resolvconfrewriteit_tmp (struct dns_rcrw_info *, stralloc *) ; extern int dns_ip4_qualify (stralloc *, stralloc *, stralloc const *) ; extern int dns_ip4_qualifyb (stralloc *, stralloc *, char const *, unsigned int) ; extern int dns_ip4_qualifyb_r_tmp (stralloc *, stralloc *, char const *, unsigned int, struct dns_rcrw_info *, stralloc *) ; extern int dns_ip4_qualify_rules (stralloc *, stralloc *, stralloc const *, stralloc const *) ; extern int dns_ip4_qualify_rulesb (stralloc *, stralloc *, char const *, unsigned int, char const *, unsigned int) ; #endif prog/skalibs-0.47/src/libdns/dns_packet_copy.c0100644000000000000000000000053007773125203016311 0ustar /* Public domain. */ #include #include "bytestr.h" #include "error.h" #include "dns_helper.h" unsigned int dns_packet_copy (char const *buf, unsigned int len, unsigned int pos, char *out, unsigned int outlen) { if ((pos + outlen) > len) return (errno = EPROTO, 0) ; byte_copy(out, outlen, buf + pos) ; return pos + outlen ; } prog/skalibs-0.47/src/libdns/dns_packet_getname.c0100644000000000000000000000214207773125255016767 0ustar /* Public domain. */ #include #include "error.h" #include "dns_helper.h" unsigned int dns_packet_getname(char const *buf,unsigned int len,unsigned int pos,char **d) { unsigned int loop = 0; unsigned int state = 0; unsigned int firstcompress = 0; unsigned int where; unsigned char ch; char name[255]; unsigned int namelen = 0; for (;;) { if (pos >= len) goto PROTO; ch = buf[pos++]; if (++loop >= 1000) goto PROTO; if (state) { if (namelen + 1 > sizeof name) goto PROTO; name[namelen++] = ch; --state; } else { while (ch >= 192) { where = ch; where -= 192; where <<= 8; if (pos >= len) goto PROTO; ch = buf[pos++]; if (!firstcompress) firstcompress = pos; pos = where + ch; if (pos >= len) goto PROTO; ch = buf[pos++]; if (++loop >= 1000) goto PROTO; } if (ch >= 64) goto PROTO; if (namelen + 1 > sizeof name) goto PROTO; name[namelen++] = ch; if (!ch) break; state = ch; } } if (!dns_domain_copy(d, name)) return 0 ; return firstcompress ? firstcompress : pos ; PROTO: errno = EPROTO ; return 0 ; } prog/skalibs-0.47/src/libdns/dns_packet_skipname.c0100644000000000000000000000063507773125361017161 0ustar /* Public domain. */ #include #include "error.h" #include "dns_helper.h" unsigned int dns_packet_skipname (char const *buf, unsigned int len, unsigned int pos) { for (;;) { register unsigned char ch ; if (pos >= len) break ; ch = buf[pos++] ; if (ch >= 192) return pos + 1 ; if (ch >= 64) break ; if (!ch) return pos ; pos += ch ; } errno = EPROTO ; return 0 ; } prog/skalibs-0.47/src/libdns/dns_resolve_r.c0100644000000000000000000000127210177543715016020 0ustar /* Public domain. */ #include "tai.h" #include "iopause.h" #include "dns_transmit.h" int dns_resolve_r (char const *q, char const *qtype, struct dns_transmit *dt, struct dns_rcip_info *dr) { int r = 0 ; if (!dns_resolvconfipit(dr)) return -1 ; if (dns_transmit_start(dt, dr->ip, 1, q, qtype, "\0\0\0") == -1) return -1 ; while (!r) { struct taia deadline, stamp ; iopause_fd x[1] ; taia_now(&stamp) ; taia_addsec(&deadline, &stamp, 120) ; dns_transmit_io(dt, x, &deadline) ; if (iopause(x, 1, &deadline, &stamp) == -1) goto err ; r = dns_transmit_get(dt, x, &stamp) ; } if (r < 0) goto err ; return 0 ; err: dns_transmit_free(dt) ; return -1 ; } prog/skalibs-0.47/src/libdns/dns_helper.h0100644000000000000000000000340311100030414015250 0ustar /* Public domain. */ #ifndef DNS_HELPER_H #define DNS_HELPER_H #include "gccattributes.h" #include "bytestr.h" #include "stralloc.h" #define DNS_C_IN "\0\1" #define DNS_C_ANY "\0\377" #define DNS_T_A "\0\1" #define DNS_T_NS "\0\2" #define DNS_T_CNAME "\0\5" #define DNS_T_SOA "\0\6" #define DNS_T_PTR "\0\14" #define DNS_T_HINFO "\0\15" #define DNS_T_MX "\0\17" #define DNS_T_TXT "\0\20" #define DNS_T_RP "\0\21" #define DNS_T_SIG "\0\30" #define DNS_T_KEY "\0\31" #define DNS_T_AAAA "\0\34" #define DNS_T_SRV "\0\41" #define DNS_T_AXFR "\0\374" #define DNS_T_ANY "\0\377" extern void dns_sortip (char *, unsigned int) ; extern void dns_domain_free (char **) ; extern int dns_domain_copy (char **, char const *) ; extern unsigned int dns_domain_length (char const *) gccattr_pure ; #define dns_domain_equal(a, b) (!case_diffs((a), (b))) extern int dns_domain_suffix (char const *, char const *) gccattr_pure ; extern unsigned int dns_domain_suffixpos (char const *, char const *) gccattr_pure ; extern int dns_domain_fromdot (char **, char const *, unsigned int) ; extern int dns_domain_todot_cat (stralloc *, char const *) ; extern unsigned int dns_packet_copy (char const *, unsigned int, unsigned int, char *, unsigned int) ; extern unsigned int dns_packet_getname (char const *, unsigned int, unsigned int, char **) ; extern unsigned int dns_packet_skipname (char const *, unsigned int, unsigned int) gccattr_pure ; extern int dns_ip4_packet (stralloc *, char const *, unsigned int) ; extern int dns_name_packet (stralloc *, char const *, unsigned int) ; extern void dns_name4_domain (char *, char const *) ; #define DNS_NAME4_DOMAIN 31 extern int dns_txt_packet (stralloc *, char const *, unsigned int) ; extern int dns_mx_packet (stralloc *, char const *, unsigned int) ; #endif prog/skalibs-0.47/src/libdns/dns_rcrwit_tmp.c0100644000000000000000000000732110035266500016176 0ustar /* Public domain. */ #include #include "bytestr.h" #include "stralloc.h" #include "tai.h" #include "env.h" #include "djbunix.h" #include "dns_transmit.h" static int init (stralloc *rules, stralloc *tmp) { unsigned int tmpbase = tmp->len ; char const *x ; int r ; rules->len = 0 ; x = env_get("DNSREWRITEFILE") ; if (!x) x = "/etc/dnsrewrite" ; r = openreadclose(x, tmp, 64) ; if (r == -1) return 0 ; if (r) { unsigned int i = 0, j = 0 ; if (!stralloc_catb(tmp, "\n", 1)) goto err ; for (; j < tmp->len - tmpbase ; j++) if (tmp->s[tmpbase + j] == '\n') { if (!stralloc_catb(rules, tmp->s + tmpbase + i, j - i)) goto err ; while (rules->len) { if (rules->s[rules->len - 1] != ' ') if (rules->s[rules->len - 1] != '\t') if (rules->s[rules->len - 1] != '\r') break ; --rules->len ; } if (!stralloc_0(rules)) goto err ; i = j + 1 ; } tmp->len = tmpbase ; return 1 ; } x = env_get("LOCALDOMAIN") ; if (x) { unsigned int i = 0, j = 0 ; tmp->len = tmpbase ; rules->len = 0 ; if (!stralloc_cats(tmp, x)) goto err ; if (!stralloc_catb(tmp, " ", 1)) goto err ; if (!stralloc_catb(rules, "?:", 2)) goto err ; for (; j < tmp->len - tmpbase ; j++) if (tmp->s[tmpbase + j] == ' ') { if (!stralloc_catb(rules, "+.", 2)) goto err ; if (!stralloc_catb(rules, tmp->s + tmpbase + i, j - i)) goto err ; i = j + 1 ; } if (!stralloc_0(rules)) goto err ; if (!stralloc_catb(rules, "*.:", 3)) goto err ; if (!stralloc_0(rules)) goto err ; tmp->len = tmpbase ; return 1 ; } r = openreadclose("/etc/resolv.conf", tmp, 64) ; if (r == -1) goto err ; if (r) { unsigned int i = 0, j = 0 ; if (!stralloc_catb(tmp, "\n", 1)) goto err ; for ( ; j < tmp->len - tmpbase ; j++) if (tmp->s[tmpbase + j] == '\n') { if (byte_equal("search ", 7, tmp->s + tmpbase + i) || byte_equal("search\t", 7, tmp->s + tmpbase + i) || byte_equal("domain ", 7, tmp->s + tmpbase + i) || byte_equal("domain\t", 7, tmp->s + tmpbase + i)) { rules->len = 0 ; if (!stralloc_catb(rules, "?:", 2)) goto err ; i += 7 ; while (i < j) { unsigned int k = byte_chr(tmp->s + tmpbase + i, j - i, ' ') ; k = byte_chr(tmp->s + tmpbase + i, k, '\t') ; if (!k) { ++i ; continue ; } if (!stralloc_catb(rules, "+.", 2)) goto err ; if (!stralloc_catb(rules, tmp->s + tmpbase + i, k)) goto err ; i += k ; } if (!stralloc_0(rules)) goto err ; if (!stralloc_catb(rules, "*.:", 3)) goto err ; if (!stralloc_0(rules)) goto err ; tmp->len = tmpbase ; return 1 ; } i = j + 1 ; } tmp->len = tmpbase ; } if (sagethostname(tmp) == -1) goto err ; r = byte_chr(tmp->s + tmpbase, tmp->len - tmpbase, '.') ; if ((unsigned int)r < tmp->len - tmpbase) { rules->len = 0 ; if (!stralloc_catb(rules, "?:", 2)) goto err ; if (!stralloc_catb(rules, tmp->s + tmpbase + r, tmp->len - tmpbase - r)) goto err ; if (!stralloc_0(rules)) goto err ; } if (!stralloc_catb(rules, "*.:", 3)) goto err ; if (!stralloc_0(rules)) goto err ; tmp->len = tmpbase ; return 1 ; err: tmp->len = tmpbase ; rules->len = 0 ; return 0 ; } int dns_resolvconfrewriteit_tmp (struct dns_rcrw_info *dr, stralloc *tmp) { struct taia now ; taia_now(&now) ; if (!dr->uses-- || taia_less(&dr->deadline, &now)) { if (!init(&dr->rules, tmp)) return 0 ; taia_addsec(&dr->deadline, &now, 600) ; dr->uses = 10000 ; } return 1 ; } prog/skalibs-0.47/src/libdns/dns_ip4b.c0100644000000000000000000000211310035312066014633 0ustar /* Public domain. */ /* MT-unsafe */ #include "stralloc.h" #include "dns.h" int dns_ip4b (stralloc *out, char const *fqdn, unsigned int fqdnlen) { char *q = 0 ; unsigned int i = 0 ; char code = 0 ; if (!stralloc_ready(out, 8)) return -1 ; out->len = 0 ; for (; i <= fqdnlen ; i++) { char ch ; if (i < fqdnlen) ch = fqdn[i] ; else ch = '.' ; if ((ch == '[') || (ch == ']')) continue ; if (ch == '.') { if (!stralloc_catb(out, &code, 1)) goto err ; code = 0 ; continue ; } if ((ch >= '0') && (ch <= '9')) { code *= 10 ; code += ch - '0' ; continue ; } if (!dns_domain_fromdot(&q, fqdn, fqdnlen)) return -1 ; if (dns_resolve(q, DNS_T_A) == -1) goto err ; if (dns_ip4_packet(out, dns_resolve_tx.packet, dns_resolve_tx.packetlen) == -1) { dns_transmit_free(&dns_resolve_tx) ; goto err ; } dns_transmit_free(&dns_resolve_tx) ; dns_domain_free(&q) ; return 0 ; } out->len &= ~3 ; dns_domain_free(&q) ; return 0 ; err: dns_domain_free(&q) ; return -1 ; } prog/skalibs-0.47/src/libdns/dns_rcip.c0100644000000000000000000000035710035312263014741 0ustar /* Public domain. */ /* MT-unsafe */ #include "bytestr.h" #include "dns_transmit.h" int dns_resolvconfip (char *s) { if (!dns_resolvconfipit(&dns_rcip_info_here)) return -1 ; byte_copy(s, 64, dns_rcip_info_here.ip) ; return 0 ; } prog/skalibs-0.47/src/libdns/dns_ipq_rulesb.c0100644000000000000000000000372210024116221016142 0ustar /* Public domain. */ #include "bytestr.h" #include "stralloc.h" #include "dns_transmit.h" static int doit (stralloc *work, unsigned int workbase, char const *rule) { unsigned int colon ; unsigned int prefixlen ; char ch = *rule++ ; if ((ch != '?') && (ch != '=') && (ch != '*') && (ch != '-')) return 1 ; colon = str_chr(rule, ':') ; if (!rule[colon]) return 1 ; if (work->len - workbase < colon) return 1 ; prefixlen = work->len - workbase - colon ; if ((ch == '=') && prefixlen) return 1 ; if (case_diffb(rule, colon, work->s + workbase + prefixlen)) return 1 ; if (ch == '?') { if (byte_chr(work->s + workbase, prefixlen, '.') < prefixlen) return 1 ; if (byte_chr(work->s + workbase, prefixlen, '[') < prefixlen) return 1 ; if (byte_chr(work->s + workbase, prefixlen, ']') < prefixlen) return 1 ; } work->len = workbase + prefixlen ; if (ch == '-') work->len = workbase ; return stralloc_cats(work, rule + colon + 1) ; } int dns_ip4_qualify_rulesb (stralloc *out, stralloc *fqdn, char const *in, unsigned int inlen, char const *rules, unsigned int ruleslen) { unsigned int fqdnbase = fqdn->len ; unsigned int outbase = out->len ; unsigned int i = 0, j = 0 ; unsigned int plus ; unsigned int fqdnlen ; if (!stralloc_catb(fqdn, in, inlen)) return -1 ; for (; j < ruleslen ; j++) if (!rules[j]) { if (!doit(fqdn, fqdnbase, rules + i)) return -1 ; i = j + 1 ; } fqdnlen = fqdn->len - fqdnbase ; plus = byte_chr(fqdn->s + fqdnbase, fqdnlen, '+') ; if (plus >= fqdnlen) return dns_ip4b(out, fqdn->s + fqdnbase, fqdnlen) ; i = plus + 1 ; for (;;) { j = byte_chr(fqdn->s + fqdnbase + i, fqdnlen - i, '+') ; byte_copy(fqdn->s + fqdnbase + plus, j, fqdn->s + fqdnbase + i) ; fqdn->len = fqdnbase + plus + j ; if (dns_ip4b(out, fqdn->s + fqdnbase, fqdn->len - fqdnbase) == -1) return -1 ; if (out->len > outbase) return 0 ; i += j ; if (i >= fqdnlen) return 0 ; ++i ; } } prog/skalibs-0.47/src/libdns/dns_ip4.c0100644000000000000000000000026210035414220014467 0ustar /* Public domain. */ /* MT-unsafe */ #include "stralloc.h" #include "dns.h" int dns_ip4 (stralloc *out, stralloc const *fqdn) { return dns_ip4b(out, fqdn->s, fqdn->len) ; } prog/skalibs-0.47/src/libdns/dns_rcrwit.c0100644000000000000000000000026410035270245015316 0ustar /* Public domain. */ #include "skamisc.h" #include "dns_transmit.h" int dns_resolvconfrewriteit (struct dns_rcrw_info *dr) { return dns_resolvconfrewriteit_tmp(dr, &satmp) ; } prog/skalibs-0.47/src/libdns/dns_rcrw_info_free.c0100644000000000000000000000036310142731517017000 0ustar /* Public domain. */ #include "tai.h" #include "stralloc.h" #include "dns_transmit.h" void dns_rcrw_info_free (struct dns_rcrw_info *d) { struct taia zero = TAIA_ZERO ; d->uses = 0 ; d->deadline = zero ; stralloc_free(&d->rules) ; } prog/skalibs-0.47/src/libdns/dns_ipqb_r_tmp.c0100644000000000000000000000054010035277553016146 0ustar /* Public domain. */ #include "stralloc.h" #include "dns_transmit.h" int dns_ip4_qualifyb_r_tmp (stralloc *out, stralloc *fqdn, char const *in, unsigned int inlen, struct dns_rcrw_info *dr, stralloc *tmp) { if (!dns_resolvconfrewriteit_tmp(dr, tmp)) return -1 ; return dns_ip4_qualify_rulesb(out, fqdn, in, inlen, dr->rules.s, dr->rules.len) ; } prog/skalibs-0.47/src/libdns/dns_rcrw_info_here.c0100644000000000000000000000020110031414567016771 0ustar /* Public domain. */ /* MT-unsafe */ #include "dns_transmit.h" struct dns_rcrw_info dns_rcrw_info_here = DNS_RCRW_INFO_ZERO ; prog/skalibs-0.47/src/libdns/dns_rcip_info_here.c0100644000000000000000000000020110035264147016752 0ustar /* Public domain. */ /* MT-unsafe */ #include "dns_transmit.h" struct dns_rcip_info dns_rcip_info_here = DNS_RCIP_INFO_ZERO ; prog/skalibs-0.47/src/libwebipc/0040755000000000000000000000000011063565152013470 5ustar prog/skalibs-0.47/src/libwebipc/getpeereid.c0100644000000000000000000000131211063565077015751 0ustar /* Public domain. */ #include "sysdeps.h" #ifdef HASGETPEEREID /* syscall exists - do nothing */ #else #include "getpeereid.h" #ifdef HASSO_PEERCRED /* implementation with SO_PEERCRED */ #include #include #include int getpeereid (int s, int *u, int *g) { struct ucred blah = { 0, 0, 0 } ; unsigned int len = sizeof(blah) ; if (getsockopt(s, SOL_SOCKET, SO_PEERCRED, &blah, &len) == -1) return -1 ; *u = blah.uid ; *g = blah.gid ; return 0 ; } #else /* nonexistent getpeereid : stub implementation */ #include int getpeereid (int s, int *uid, int *gid) { (void)s ; *uid = *gid = -1 ; errno = ENOSYS ; return -1 ; } #endif #endif prog/skalibs-0.47/src/libwebipc/getpeereid.h0100644000000000000000000000016507663560170015763 0ustar /* Public domain. */ #ifndef GETPEEREID_H #define GETPEEREID_H extern int getpeereid (int, int *, int *) ; #endif prog/skalibs-0.47/src/libwebipc/Makefile0100644000000000000000000000222307773124764015141 0ustar it: command include library library.so clean: EXPORT INTERNAL rm -f `cat EXPORT INTERNAL` getpeereid.o: compile getpeereid.c getpeereid.h sysdeps.h ./compile getpeereid.c ipc_accept.o: compile ipc_accept.c webipc.h bytestr.h ./compile ipc_accept.c ipc_bind.o: compile ipc_bind.c webipc.h pflocal.h error.h bytestr.h ./compile ipc_bind.c ipc_conn.o: compile ipc_conn.c webipc.h pflocal.h djbunix.h error.h bytestr.h ./compile ipc_conn.c ipc_eid.o: compile ipc_eid.c webipc.h getpeereid.h ./compile ipc_eid.c ipc_listen.o: compile ipc_listen.c webipc.h ./compile ipc_listen.c ipc_local.o: compile ipc_local.c webipc.h bytestr.h ./compile ipc_local.c ipc_stream.o: compile ipc_stream.c webipc.h pflocal.h djbunix.h ./compile ipc_stream.c ipc_dgram.o: compile ipc_dgram.c webipc.h pflocal.h djbunix.h ./compile ipc_dgram.c libwebipc.a: makelib getpeereid.o ipc_accept.o ipc_bind.o \ ipc_conn.o ipc_listen.o ipc_local.o ipc_eid.o ipc_stream.o ipc_dgram.o ./makelib libwebipc.a getpeereid.o ipc_accept.o ipc_bind.o \ ipc_conn.o ipc_listen.o ipc_local.o ipc_eid.o ipc_stream.o ipc_dgram.o command: include: webipc.h library: libwebipc.a library.so: prog/skalibs-0.47/src/libwebipc/INTERNAL0100644000000000000000000000015407740230117014621 0ustar getpeereid.o ipc_accept.o ipc_bind.o ipc_conn.o ipc_eid.o ipc_listen.o ipc_local.o ipc_stream.o ipc_dgram.o prog/skalibs-0.47/src/libwebipc/ipc_accept.c0100644000000000000000000000133310324525116015716 0ustar /* Public domain. */ #include #include #include #include #include #include "bytestr.h" #include "webipc.h" int ipc_accept (int s, char *p, unsigned int l, int *trunc) { struct sockaddr_un sa ; socklen_t dummy = sizeof sa ; register int fd ; byte_zero((char*)&sa, (unsigned int)dummy) ; do fd = accept(s, (struct sockaddr *)&sa, &dummy) ; while ((fd == -1) && (errno == EINTR)) ; if (fd == -1) return -1 ; if (p) { dummy = byte_chr(sa.sun_path, dummy, 0) ; *trunc = 1 ; if (!l) return fd ; if (l < (dummy + 1)) dummy = l - 1 ; else *trunc = 0 ; byte_copy(p, dummy, sa.sun_path) ; p[dummy] = 0 ; } return fd ; } prog/skalibs-0.47/src/libwebipc/ipc_bind.c0100644000000000000000000000147407773124777015427 0ustar /* Public domain. */ #include #include #include #include #include #include #include "bytestr.h" #include "error.h" #include "pflocal.h" #include "webipc.h" static int ipc_bindit (int s, char const *p, int del) { struct sockaddr_un sa ; unsigned int l = str_len(p) ; if (l > IPCPATH_MAX) return (errno = EPROTO, -1) ; byte_zero((char *) &sa, sizeof sa) ; sa.sun_family = PF_LOCAL ; byte_copy(sa.sun_path, l, p) ; if (del) unlink(sa.sun_path) ; return bind(s, (struct sockaddr *) &sa, sizeof sa) ; } int ipc_bind (int s, char const *p) { return ipc_bindit(s, p, 0) ; } int ipc_bind_reuse (int s, char const *p) { unsigned int opt = 1 ; setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof opt) ; return ipc_bindit(s, p, 1) ; } prog/skalibs-0.47/src/libwebipc/ipc_conn.c0100644000000000000000000000122710021151144015404 0ustar /* Public domain. */ #include #include #include #include #include #include #include "bytestr.h" #include "error.h" #include "djbunix.h" #include "pflocal.h" #include "webipc.h" int ipc_connect (int s, char const *p) { struct sockaddr_un sa ; unsigned int l = str_len(p) ; if (l > IPCPATH_MAX) return (errno = EPROTO, -1) ; byte_zero((char *) &sa, sizeof sa) ; sa.sun_family = PF_LOCAL ; byte_copy(sa.sun_path, l, p) ; if (connect(s, (struct sockaddr *)&sa, sizeof sa) == -1) { if (errno == EINTR) errno = EINPROGRESS ; return -1 ; } return ndelay_off(s) ; } prog/skalibs-0.47/src/libwebipc/ipc_eid.c0100644000000000000000000000035007663560170015231 0ustar /* Public domain. */ #include "getpeereid.h" #include "webipc.h" int ipc_eid (int s, int *u, int *g) { int dummyu, dummyg ; if (getpeereid(s, &dummyu, &dummyg) == -1) return -1 ; *u = dummyu ; *g = dummyg ; return 0 ; } prog/skalibs-0.47/src/libwebipc/ipc_listen.c0100644000000000000000000000031307772661461015773 0ustar /* Public domain. */ #include #include #include #include #include "webipc.h" int ipc_listen (int s, int backlog) { return listen(s, backlog) ; } prog/skalibs-0.47/src/libwebipc/ipc_local.c0100644000000000000000000000111710324525141015547 0ustar /* Public domain. */ #include #include #include #include #include "bytestr.h" #include "webipc.h" int ipc_local (int s, char *p, unsigned int l, int *trunc) { struct sockaddr_un sa ; socklen_t dummy = sizeof sa ; byte_zero((char *)&sa, sizeof sa) ; if (getsockname(s, (struct sockaddr *)&sa, &dummy) == -1) return -1 ; dummy = byte_chr(sa.sun_path, dummy, 0) ; *trunc = 1 ; if (!l) return 0 ; if (l < (dummy + 1)) dummy = l - 1 ; else *trunc = 0 ; byte_copy(p, dummy, sa.sun_path) ; p[dummy] = 0 ; return 0 ; } prog/skalibs-0.47/src/libwebipc/ipc_stream.c0100644000000000000000000000054607772661055015777 0ustar /* Public domain. */ #include #include #include #include #include #include "djbunix.h" #include "pflocal.h" #include "webipc.h" int ipc_stream () { int s = socket(PF_LOCAL, SOCK_STREAM, 0) ; if (s == -1) return -1 ; if (ndelay_on(s) == -1) { fd_close(s) ; return -1 ; } return s ; } prog/skalibs-0.47/src/libwebipc/EXPORT0100644000000000000000000000001407663560170014432 0ustar libwebipc.a prog/skalibs-0.47/src/libwebipc/INCLUDE0100644000000000000000000000001107663560170014471 0ustar webipc.h prog/skalibs-0.47/src/libwebipc/pflocal.h0100644000000000000000000000016407663560170015265 0ustar /* Public domain. */ #ifndef PFLOCAL_H #define PFLOCAL_H #ifndef PF_LOCAL #define PF_LOCAL PF_UNIX #endif #endif prog/skalibs-0.47/src/libwebipc/webipc.h0100644000000000000000000000074210324525215015105 0ustar /* Public domain. */ #ifndef WEBIPC_H #define WEBIPC_H #define IPCPATH_MAX 99 extern int ipc_stream (void) ; extern int ipc_datagram (void) ; extern int ipc_connect (int, char const *) ; extern int ipc_bind (int, char const *) ; extern int ipc_bind_reuse (int, char const *) ; extern int ipc_listen (int, int) ; extern int ipc_accept (int, char *, unsigned int, int *) ; extern int ipc_eid (int, int *, int *) ; extern int ipc_local (int, char *, unsigned int, int *) ; #endif prog/skalibs-0.47/src/libwebipc/ipc_dgram.c0100644000000000000000000000054707772661033015573 0ustar /* Public domain. */ #include #include #include #include #include #include "djbunix.h" #include "pflocal.h" #include "webipc.h" int ipc_datagram () { int s = socket(PF_LOCAL, SOCK_DGRAM, 0) ; if (s == -1) return -1 ; if (ndelay_on(s) == -1) { fd_close(s) ; return -1 ; } return s ; } prog/skalibs-0.47/src/librandom/0040755000000000000000000000000010443205242013467 5ustar prog/skalibs-0.47/src/librandom/dns_random.c0100644000000000000000000000053510040423551015755 0ustar /* Public domain. */ /* MT-unsafe */ #include "surf.h" #include "random-internal.h" #include "random.h" unsigned int dns_random (unsigned int n) { unsigned int i = n ; unsigned int m ; if (!n) return 0 ; m = random_mask2(n-1) ; while (i >= n) { surf(&surf_here, (char *)&i, sizeof(unsigned int)) ; i &= m ; } return i ; } prog/skalibs-0.47/src/librandom/INCLUDE0100644000000000000000000000004610040426517014475 0ustar surf.h unirandom.h rrandom.h random.h prog/skalibs-0.47/src/librandom/Makefile0100644000000000000000000001466110040500712015125 0ustar it: command include library library.so clean: EXPORT INTERNAL rm -f `cat EXPORT INTERNAL` random-internal.h: rrandom.h unirandom.h surf.h gccattributes.h touch random-internal.h surf.h: uint32.h touch surf.h surf_sinit.o: compile surf_sinit.c surf.h uint32.h ./compile surf_sinit.c surf.o: compile surf.c surf.h uint32.h bytestr.h ./compile surf.c surf_makeseed.o: compile surf_makeseed.c surf.h sha1.h tai.h uint32.h ./compile surf_makeseed.c surf_init.o: compile surf_init.c surf.h ./compile surf_init.c surf_autoinit.o: compile surf_autoinit.c surf.h ./compile surf_autoinit.c unisurf.h: unirandom.h touch unisurf.h unisurf.o: compile unisurf.c unisurf.h unirandom.h surf.h ./compile unisurf.c unisurf_init.o: compile unisurf_init.c unisurf.h unirandom.h random-internal.h surf.h ./compile unisurf_init.c randomegd_open.o: compile randomegd_open.c randomegd.h webipc.h djbunix.h ./compile randomegd_open.c randomegd_readb.o: compile randomegd_readb.c randomegd.h allreadwrite.h ./compile randomegd_readb.c randomegd_readnb.o: compile randomegd_readnb.c randomegd.h allreadwrite.h ./compile randomegd_readnb.c unirandomegd.h: unirandom.h touch unirandomegd.h unirandomegd.o: compile unirandomegd.c unirandomegd.h unirandom.h randomegd.h djbunix.h ./compile unirandomegd.c unihasegd.o: compile unihasegd.c unirandom.h random-internal.h unirandomegd.h sysdeps.h ./compile unihasegd.c unirandomdev.h: unirandom.h touch unirandomdev.h unirandomdev.o: compile unirandomdev.c unirandomdev.h unirandom.h djbunix.h allreadwrite.h ./compile unirandomdev.c unidevrandom.o: compile unidevrandom.c unirandom.h random-internal.h unirandomdev.h sysdeps.h ./compile unidevrandom.c unidevurandom.o: compile unidevurandom.c unirandom.h random-internal.h unirandomdev.h sysdeps.h ./compile unidevurandom.c unirandom.h: surf.h touch unirandom.h unirandom_register.o: compile unirandom_register.c random-internal.h unirandom.h ./compile unirandom_register.c unirandom_init.o: compile unirandom_init.c unirandom.h ./compile unirandom_init.c unirandom_readb.o: compile unirandom_readb.c unirandom.h ./compile unirandom_readb.c unirandom_readnb.o: compile unirandom_readnb.c unirandom.h ./compile unirandom_readnb.c unirandom_finish.o: compile unirandom_finish.c unirandom.h ./compile unirandom_finish.c rrandom.h: unirandom.h touch rrandom.h rrandom_add.o: compile rrandom_add.c rrandom.h unirandom.h ./compile rrandom_add.c rrandom_finish.o: compile rrandom_finish.c rrandom.h unirandom.h ./compile rrandom_finish.c rrandom_name.o: compile rrandom_name.c rrandom.h unirandom.h ./compile rrandom_name.c rrandom_read.o: compile rrandom_read.c rrandom.h unirandom.h error.h allreadwrite.h ./compile rrandom_read.c rrandom_readint.o: compile rrandom_readint.c rrandom.h unirandom.h random-internal.h ./compile rrandom_readint.c random_mask2.o: compile random_mask2.c random-internal.h ./compile random_mask2.c surf_here.o: compile surf_here.c random-internal.h surf.h ./compile surf_here.c badrandom_here.o: compile badrandom_here.c random-internal.h unirandomdev.h unirandomegd.h unisurf.h sysdeps.h ./compile badrandom_here.c goodrandom_here.o: compile goodrandom_here.c random-internal.h unirandomdev.h unirandomegd.h unisurf.h sysdeps.h ./compile goodrandom_here.c dns_random_init.o: compile dns_random_init.c random.h random-internal.h surf.h tai.h bytestr.h uint32.h ./compile dns_random_init.c dns_random.o: compile dns_random.c random.h random-internal.h surf.h ./compile dns_random.c dns_random_string.o: compile dns_random_string.c random.h random-internal.h surf.h ./compile dns_random_string.c badrandom_init.o: compile badrandom_init.c random.h ./compile badrandom_init.c badrandom_finish.o: compile badrandom_finish.c random.h random-internal.h rrandom.h ./compile badrandom_finish.c badrandom_string.o: compile badrandom_string.c random.h random-internal.h rrandom.h ./compile badrandom_string.c badrandom_int.o: compile badrandom_int.c random.h random-internal.h rrandom.h ./compile badrandom_int.c badrandom_char.o: compile badrandom_char.c random.h random-internal.h ./compile badrandom_char.c goodrandom_init.o: compile goodrandom_init.c random.h ./compile goodrandom_init.c goodrandom_finish.o: compile goodrandom_finish.c random.h random-internal.h random.h rrandom.h ./compile goodrandom_finish.c goodrandom_string.o: compile goodrandom_string.c random.h random-internal.h rrandom.h ./compile goodrandom_string.c goodrandom_int.o: compile goodrandom_int.c random.h random-internal.h rrandom.h ./compile goodrandom_int.c goodrandom_char.o: compile goodrandom_char.c random.h random-internal.h ./compile goodrandom_char.c random_name.o: compile random_name.c random.h random-internal.h ./compile random_name.c random_sauniquename.o: compile random_sauniquename.c random.h skamisc.h stralloc.h ./compile random_sauniquename.c librandom.a: makelib \ surf_sinit.o surf.o surf_makeseed.o surf_init.o surf_autoinit.o \ randomegd_open.o randomegd_readb.o randomegd_readnb.o \ unisurf.o unisurf_init.o \ unirandomegd.o unihasegd.o \ unirandomdev.o unidevrandom.o unidevurandom.o \ unirandom_register.o unirandom_init.o unirandom_finish.o unirandom_readb.o unirandom_readnb.o \ rrandom_add.o rrandom_finish.o rrandom_read.o rrandom_readint.o rrandom_name.o \ random_mask2.o surf_here.o badrandom_here.o goodrandom_here.o \ dns_random.o dns_random_init.o dns_random_string.o \ badrandom_init.o badrandom_finish.o badrandom_string.o badrandom_int.o badrandom_char.o \ goodrandom_init.o goodrandom_finish.o goodrandom_string.o goodrandom_int.o goodrandom_char.o \ random_name.o random_sauniquename.o ./makelib librandom.a \ surf_sinit.o surf.o surf_makeseed.o surf_init.o surf_autoinit.o \ randomegd_open.o randomegd_readb.o randomegd_readnb.o \ unisurf.o unisurf_init.o \ unirandomegd.o unihasegd.o \ unirandomdev.o unidevrandom.o unidevurandom.o \ unirandom_register.o unirandom_init.o unirandom_finish.o unirandom_readb.o unirandom_readnb.o \ rrandom_add.o rrandom_finish.o rrandom_read.o rrandom_readint.o rrandom_name.o \ random_mask2.o surf_here.o badrandom_here.o goodrandom_here.o \ dns_random.o dns_random_init.o dns_random_string.o \ badrandom_init.o badrandom_finish.o badrandom_string.o badrandom_int.o badrandom_char.o \ goodrandom_init.o goodrandom_finish.o goodrandom_string.o goodrandom_int.o goodrandom_char.o \ random_name.o random_sauniquename.o command: include: surf.h unirandom.h rrandom.h random.h library: librandom.a library.so: prog/skalibs-0.47/src/librandom/INTERNAL0100644000000000000000000000131710040477527014637 0ustar badrandom_char.o badrandom_finish.o badrandom_here.o badrandom_init.o badrandom_int.o badrandom_string.o dns_random.o dns_random_init.o dns_random_string.o goodrandom_char.o goodrandom_finish.o goodrandom_here.o goodrandom_init.o goodrandom_int.o goodrandom_string.o random_mask2.o random_name.o random_sauniquename.o randomegd_open.o randomegd_readb.o randomegd_readnb.o rrandom_add.o rrandom_finish.o rrandom_name.o rrandom_read.o rrandom_readint.o surf.o surf_autoinit.o surf_here.o surf_init.o surf_makeseed.o surf_sinit.o unidevrandom.o unidevurandom.o unihasegd.o unirandom_finish.o unirandom_init.o unirandom_readb.o unirandom_readnb.o unirandom_register.o unirandomdev.o unirandomegd.o unisurf.o unisurf_init.o prog/skalibs-0.47/src/librandom/EXPORT0100644000000000000000000000001410024623203014417 0ustar librandom.a prog/skalibs-0.47/src/librandom/goodrandom_int.c0100644000000000000000000000034110040434057016632 0ustar /* Public domain. */ /* MT-unsafe */ #include "rrandom.h" #include "random-internal.h" #include "random.h" unsigned int goodrandom_int (unsigned int n) { return rrandom_readint(&goodrandom_here, n, &unirandom_readb) ; } prog/skalibs-0.47/src/librandom/goodrandom_string.c0100644000000000000000000000032310040422134017337 0ustar /* Public domain. */ /* MT-unsafe */ #include "rrandom.h" #include "random-internal.h" #include "random.h" int goodrandom_string (char *s, unsigned int n) { return rrandom_readb(&goodrandom_here, s, n) ; } prog/skalibs-0.47/src/librandom/badrandom_int.c0100644000000000000000000000034010040434036016424 0ustar /* Public domain. */ /* MT-unsafe */ #include "rrandom.h" #include "random-internal.h" #include "random.h" unsigned int badrandom_int (unsigned int n) { return rrandom_readint(&badrandom_here, n, &unirandom_readnb) ; } prog/skalibs-0.47/src/librandom/random.h0100644000000000000000000000205710040422646015123 0ustar /* Public domain. */ /* MT-unsafe functions only. Use rrandom for MT-safety. */ #ifndef RANDOM_H #define RANDOM_H #include "stralloc.h" #include "rrandom.h" extern int badrandom_init (void) ; extern unsigned char badrandom_char (void) ; extern unsigned int badrandom_int (unsigned int) ; extern int badrandom_string (char *, unsigned int) ; extern void badrandom_finish (void) ; extern int goodrandom_init (void) ; extern unsigned char goodrandom_char (void) ; extern unsigned int goodrandom_int (unsigned int) ; extern int goodrandom_string (char *, unsigned int) ; extern void goodrandom_finish (void) ; extern void dns_random_init (char const *) ; /* 128 chars */ extern void dns_random_string (char *, unsigned int) ; extern unsigned dns_random (unsigned int) ; #define random_init badrandom_init #define random_char badrandom_char #define random_int badrandom_int #define random_string badrandom_string #define random_finish badrandom_finish extern int random_name (char *, unsigned int) ; extern int random_sauniquename (stralloc *, unsigned int) ; #endif prog/skalibs-0.47/src/librandom/badrandom_string.c0100644000000000000000000000032210040421127017135 0ustar /* Public domain. */ /* MT-unsafe */ #include "rrandom.h" #include "random-internal.h" #include "random.h" int badrandom_string (char *s, unsigned int n) { return rrandom_readnb(&badrandom_here, s, n) ; } prog/skalibs-0.47/src/librandom/badrandom_char.c0100644000000000000000000000030610324525617016564 0ustar /* Public domain. */ /* MT-unsafe */ #include "random-internal.h" #include "random.h" unsigned char badrandom_char (void) { unsigned char x ; badrandom_string((char *)&x, 1) ; return x ; } prog/skalibs-0.47/src/librandom/goodrandom_char.c0100644000000000000000000000031010324525640016755 0ustar /* Public domain. */ /* MT-unsafe */ #include "random-internal.h" #include "random.h" unsigned char goodrandom_char (void) { unsigned char x ; goodrandom_string((char *)&x, 1) ; return x ; } prog/skalibs-0.47/src/librandom/badrandom_init.c0100644000000000000000000000014710040421564016604 0ustar /* Public domain. */ /* MT-unsafe */ #include "random.h" int badrandom_init (void) { return 1 ; } prog/skalibs-0.47/src/librandom/randomegd_readnb.c0100644000000000000000000000126610324526015017112 0ustar /* Public domain. */ #include "allreadwrite.h" #include "randomegd.h" unsigned int randomegd_readnb (int s, char *x, unsigned int n) { unsigned int w = 0 ; while ((n - w) >= 255) { char c[2] = { 0x01, 0xFF } ; register unsigned char wtmp ; if (allwrite(s, c, 2) < 2) return w ; if (sanitize_read(fd_read(s, c+1, 1)) < 1) return w ; wtmp = allread(s, x + w, c[1]) ; w += wtmp ; if ((wtmp < c[1]) || ((unsigned char)c[1] < 0xFF)) return w ; } if (w < n) { char c[2] = "\001" ; c[1] = n - w ; if (allwrite(s, c, 2) < 2) return w ; if (sanitize_read(fd_read(s, c+1, 1)) < 1) return w ; w += allread(s, x + w, c[1]) ; } return w ; } prog/skalibs-0.47/src/librandom/randomegd_open.c0100644000000000000000000000051410030102103016571 0ustar /* Public domain. */ #include #include "djbunix.h" #include "webipc.h" #include "randomegd.h" int randomegd_open (char const *path) { int s = ipc_stream() ; if (s < 0) return -1 ; if (ipc_connect(s, path) == -1) { register int e = errno ; fd_close(s) ; errno = e ; return -1 ; } return s ; } prog/skalibs-0.47/src/librandom/rrandom_read.c0100644000000000000000000000103010040433655016263 0ustar /* Public domain. */ #include #include "allreadwrite.h" #include "error.h" #include "unirandom.h" #include "rrandom.h" unsigned int rrandom_read (rrandom_ref z, char *s, unsigned int n, unsigned int (*f) (unirandom_ref, char *, unsigned int)) { unsigned int i = 0 ; for (; i < 3 ; i++) { int r ; if (!z->tries[i].ok) continue ; r = sanitize_read((*f)(&z->tries[i].it, s, n)) ; if (r > 0) return r ; z->tries[i].ok = error_temp(errno) ? z->tries[i].ok - 1 : 0 ; } return (errno = ENOENT, 0) ; } prog/skalibs-0.47/src/librandom/random_mask2.c0100644000000000000000000000032310024623203016177 0ustar /* Public domain. */ #include "random-internal.h" unsigned int random_mask2 (register unsigned int n) { for (;;) { register unsigned int m = n | (n >> 1) ; if (m == n) return n ; n = m ; } } prog/skalibs-0.47/src/librandom/goodrandom_finish.c0100644000000000000000000000026510040434201017314 0ustar /* Public domain. */ /* MT-unsafe */ #include "random-internal.h" #include "rrandom.h" #include "random.h" void goodrandom_finish (void) { rrandom_finish(&goodrandom_here) ; } prog/skalibs-0.47/src/librandom/randomegd_readb.c0100644000000000000000000000107710324525512016735 0ustar /* Public domain. */ #include "allreadwrite.h" #include "randomegd.h" unsigned int randomegd_readb (int s, char *x, unsigned int n) { unsigned int w = 0 ; unsigned int i = 0 ; for (; i < (n / 255) ; i++) { char const c[2] = { 0x02, 0xFF } ; register unsigned char wtmp ; if (allwrite(s, c, 2) < 2) return w ; wtmp = allread(s, x + w, 255) ; w += wtmp ; if (wtmp < 255) return w ; } if (w < n) { char c[2] = "\002" ; c[1] = n - w ; if (allwrite(s, c, 2) < 2) return w ; w += allread(s, x + w, c[1]) ; } return w ; } prog/skalibs-0.47/src/librandom/rrandom_name.c0100644000000000000000000000067410443205233016301 0ustar /* Public domain. */ #include "unirandom.h" #include "rrandom.h" unsigned int rrandom_name (rrandom_ref z, char *s, unsigned int n, unsigned char nb) { static char const *oklist = "ABCDEFGHIJKLMNOPQRSTUVWXYZghijklmnopqrstuvwxyz-_0123456789abcdef" ; register unsigned int r = rrandom_read(z, s, n, nb ? &unirandom_readnb : &unirandom_readb) ; register unsigned int i = 0 ; for (; i < r ; i++) s[i] = oklist[s[i] & 63] ; return r ; } prog/skalibs-0.47/src/librandom/badrandom_here.c0100644000000000000000000000150410040433200016550 0ustar /* Public domain. */ /* MT-unsafe */ #include "sysdeps.h" #include "unisurf.h" #include "random-internal.h" #ifdef HASEGD # include "unirandomegd.h" # ifdef HASDEVURANDOM # include "unirandomdev.h" rrandom badrandom_here = { { { UNIRANDOM_REGISTER_DEVURANDOM(), 3 }, { UNIRANDOM_REGISTER_HASEGD(), 3 }, { UNIRANDOM_REGISTER_SURF(), 3 } }, 3 } ; # else rrandom badrandom_here = { { { UNIRANDOM_REGISTER_HASEGD(), 3 }, { UNIRANDOM_REGISTER_SURF(), 3 }, { UNIRANDOM_ZERO, 3 } }, 2 } ; # endif #else # ifdef HASDEVURANDOM # include "unirandomdev.h" rrandom badrandom_here = { { { UNIRANDOM_REGISTER_DEVURANDOM(), 3 }, { UNIRANDOM_REGISTER_SURF(), 3 }, { UNIRANDOM_ZERO, 3 } }, 2 } ; # else rrandom badrandom_here = { { { UNIRANDOM_REGISTER_SURF(), 3 }, { UNIRANDOM_ZERO, 3 }, { UNIRANDOM_ZERO, 3 } }, 1 } ; # endif #endif prog/skalibs-0.47/src/librandom/goodrandom_init.c0100644000000000000000000000015010040421737017002 0ustar /* Public domain. */ /* MT-unsafe */ #include "random.h" int goodrandom_init (void) { return 1 ; } prog/skalibs-0.47/src/librandom/badrandom_finish.c0100644000000000000000000000026310040421545017117 0ustar /* Public domain. */ /* MT-unsafe */ #include "rrandom.h" #include "random-internal.h" #include "random.h" void badrandom_finish (void) { rrandom_finish(&badrandom_here) ; } prog/skalibs-0.47/src/librandom/random_name.c0100644000000000000000000000036210040500232016077 0ustar /* Public domain. */ /* MT-unsafe */ #include "random-internal.h" #include "random.h" int random_name (char *s, unsigned int n) { register unsigned int r = rrandom_name(&badrandom_here, s, n, 1) ; if (r < n) return -1 ; return n ; } prog/skalibs-0.47/src/librandom/surf_sinit.c0100644000000000000000000000054310040430273016014 0ustar /* Public domain. */ #include "uint32.h" #include "surf.h" void surf_sinit (SURFSchedule_ref ctx, char const *s) { SURFSchedule zero = SURFSCHEDULE_ZERO ; register unsigned int i = 4 ; *ctx = zero ; for (; i < 12 ; i++) uint32_unpack(s + (i<<2) - 16, ctx->in + i) ; for (i = 0 ; i < 32 ; i++) uint32_unpack(s + 32 + (i<<2), ctx->seed + i) ; } prog/skalibs-0.47/src/librandom/random_sauniquename.c0100644000000000000000000000103410040416071017656 0ustar /* Public domain. */ /* MT-unsafe */ #include "stralloc.h" #include "skamisc.h" #include "random.h" int random_sauniquename (stralloc *sa, unsigned int n) { unsigned int base = sa->len ; unsigned char wasnull = !sa->s ; register int r ; if (sauniquename(sa) == -1) return -1 ; if (!stralloc_readyplus(sa, n+1)) goto err ; stralloc_catb(sa, ":", 1) ; r = random_name(sa->s + sa->len, n) ; if (r == -1) goto err ; sa->len += r ; return r ; err: if (wasnull) stralloc_free(sa) ; else sa->len = base ; return -1 ; } prog/skalibs-0.47/src/librandom/random-internal.h0100644000000000000000000000110311100046370016716 0ustar /* Public domain. */ #ifndef RANDOM_INTERNAL_H #define RANDOM_INTERNAL_H #include "gccattributes.h" #include "surf.h" #include "unirandom.h" #include "rrandom.h" extern void unirandom_register (unirandom_ref, int (*) (union unirandominfo *), int (*) (union unirandominfo *), unsigned int (*) (union unirandominfo *, char *, unsigned int), unsigned int (*) (union unirandominfo *, char *, unsigned int)) ; extern unsigned int random_mask2 (unsigned int) gccattr_const ; extern SURFSchedule surf_here ; extern rrandom goodrandom_here ; extern rrandom badrandom_here ; #endif prog/skalibs-0.47/src/librandom/surf.c0100644000000000000000000000252410324524575014625 0ustar /* Public domain. */ #include "uint32.h" #include "bytestr.h" #include "surf.h" #define ROTATE(x, b) (((x) << (b)) | ((x) >> (32 - (b)))) #define MUSH(i, b) x = t[i] += (((x ^ ctx->seed[i]) + sum) ^ ROTATE(x, b)) static void surfit (SURFSchedule_ref ctx) { uint32 t[12] ; uint32 z[8] ; uint32 x ; uint32 sum = 0 ; unsigned int i = 0, loop = 0 ; ; if (!++ctx->in[0] && !++ctx->in[1] && !++ctx->in[2]) ++ctx->in[3] ; for (; i < 12 ; i++) t[i] = ctx->in[i] ^ ctx->seed[12+i] ; for (i = 0 ; i < 8 ; i++) z[i] = ctx->seed[24+i] ; x = t[11] ; for (; loop < 2 ; loop++) { for (i = 0 ; i < 16 ; i++) { sum += 0x9e3779b9 ; MUSH(0, 5) ; MUSH(1, 7) ; MUSH(2, 9) ; MUSH(3, 13) ; MUSH(4, 5) ; MUSH(5, 7) ; MUSH(6, 9) ; MUSH(7, 13) ; MUSH(8, 5) ; MUSH(9, 7) ; MUSH(10, 9) ; MUSH(11, 13) ; } for (i = 0 ; i < 8 ; i++) z[i] ^= t[i+4] ; } for (i = 0 ; i < 8 ; i++) uint32_pack(ctx->out + (i<<2), z[i]) ; } void surf (SURFSchedule_ref ctx, char *s, unsigned int n) { { register unsigned int i = 32 - ctx->pos ; if (n < i) i = n ; byte_copy(s, i, ctx->out + ctx->pos) ; s += i ; n -= i ; ctx->pos += i ; } while (n > 32) { surfit(ctx) ; byte_copy(s, 32, ctx->out) ; s += 32 ; n -= 32 ; } if (!n) return ; surfit(ctx) ; byte_copy(s, n, ctx->out) ; ctx->pos = n ; } prog/skalibs-0.47/src/librandom/surf.h0100644000000000000000000000156711100046366014626 0ustar /* Public domain. */ #ifndef SKALIBS_SURF_H #define SKALIBS_SURF_H #include "uint32.h" typedef struct SURFSchedule SURFSchedule, *SURFSchedule_ref, **SURFSchedule_ref_ref ; struct SURFSchedule { uint32 seed[32] ; uint32 in[12] ; char out[32] ; unsigned char pos ; } ; #define SURFSCHEDULE_ZERO { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 32 } extern void surf_sinit (SURFSchedule_ref, char const *) ; /* 160 chars */ extern void surf (SURFSchedule_ref, char *, unsigned int) ; /* The following functions need libstdcrypto.a */ extern void surf_makeseed (char *) ; /* fills 160 chars */ extern void surf_init (SURFSchedule_ref) ; extern void surf_autoinit (SURFSchedule_ref, char *, unsigned int) ; #endif prog/skalibs-0.47/src/librandom/surf_init.c0100644000000000000000000000021710324525404015635 0ustar /* Public domain. */ #include "surf.h" void surf_init (SURFSchedule_ref ctx) { char s[160] ; surf_makeseed(s) ; surf_sinit(ctx, s) ; } prog/skalibs-0.47/src/librandom/rrandom.h0100644000000000000000000000211511100046366015277 0ustar /* Public domain. */ #ifndef RRANDOM_H #define RRANDOM_H #include "unirandom.h" typedef struct rrandominfo rrandominfo, *rrandominfo_ref, **rrandominfo_ref_ref ; struct rrandominfo { unirandom it ; unsigned int ok ; } ; #define RRANDOMINFO_ZERO { UNIRANDOM_ZERO, 3 } typedef struct rrandom rrandom, *rrandom_ref, **rrandom_ref_ref ; struct rrandom { rrandominfo tries[3] ; unsigned int n ; } ; #define RRANDOM_ZERO { { RRANDOMINFO_ZERO, RRANDOMINFO_ZERO, RRANDOMINFO_ZERO }, 0 } extern int rrandom_add (rrandom_ref, int (*) (unirandom_ref)) ; extern int rrandom_finish (rrandom_ref) ; extern unsigned int rrandom_read (rrandom_ref, char *, unsigned int, unsigned int (*) (unirandom_ref, char *, unsigned int)) ; extern unsigned int rrandom_readint (rrandom_ref, unsigned int, unsigned int (*) (unirandom_ref, char *, unsigned int)) ; #define rrandom_readb(z, s, n) rrandom_read((z), (s), (n), &unirandom_readb) #define rrandom_readnb(z, s, n) rrandom_read((z), (s), (n), &unirandom_readnb) extern unsigned int rrandom_name (rrandom_ref, char *, unsigned int, unsigned char) ; #endif prog/skalibs-0.47/src/librandom/unisurf.h0100644000000000000000000000071711100046367015337 0ustar /* Public domain. */ #ifndef UNISURF_H #define UNISURF_H #include "unirandom.h" extern int unisurf_sinit (union unirandominfo *, char const *) ; extern unsigned int unisurf_read (union unirandominfo *, char *, unsigned int) ; extern int unisurf_finish (union unirandominfo *) ; extern int unisurf_init (union unirandominfo *) ; #define UNIRANDOM_REGISTER_SURF() { &unisurf_read, &unisurf_read, &unisurf_init, &unisurf_finish, UNIRANDOMINFO_ZERO, 0 } #endif prog/skalibs-0.47/src/librandom/unirandom.h0100644000000000000000000000231211100046366015630 0ustar /* Public domain. */ #ifndef UNIRANDOM_H #define UNIRANDOM_H #include "surf.h" struct randomfd { int fd ; unsigned char nb : 1 ; } ; #define RANDOMFD_ZERO { -1, 0 } union unirandominfo { SURFSchedule surf_ctx ; struct randomfd file ; } ; #define UNIRANDOMINFO_ZERO { SURFSCHEDULE_ZERO } typedef struct unirandom unirandom, *unirandom_ref, **unirandom_ref_ref ; struct unirandom { unsigned int (*readb) (union unirandominfo *, char *, unsigned int) ; unsigned int (*readnb) (union unirandominfo *, char *, unsigned int) ; int (*init) (union unirandominfo *) ; int (*finish) (union unirandominfo *) ; union unirandominfo data ; unsigned char initted : 1 ; } ; #define UNIRANDOM_ZERO { 0, 0, 0, 0, UNIRANDOMINFO_ZERO, 0 } extern int unirandom_register_devrandom (unirandom_ref) ; extern int unirandom_register_devurandom (unirandom_ref) ; extern int unirandom_register_hasegd (unirandom_ref) ; extern int unirandom_register_surf (unirandom_ref) ; extern int unirandom_init (unirandom_ref) ; extern unsigned int unirandom_readb (unirandom_ref, char *, unsigned int) ; extern unsigned int unirandom_readnb (unirandom_ref, char *, unsigned int) ; extern int unirandom_finish (unirandom_ref) ; #endif prog/skalibs-0.47/src/librandom/surf_here.c0100644000000000000000000000020410040423721015603 0ustar /* Public domain. */ /* MT-unsafe */ #include "surf.h" #include "random-internal.h" SURFSchedule surf_here = SURFSCHEDULE_ZERO ; prog/skalibs-0.47/src/librandom/unirandomegd.c0100644000000000000000000000143710040527450016312 0ustar /* Public domain. */ #include #include "djbunix.h" #include "randomegd.h" #include "unirandom.h" #include "unirandomegd.h" int unirandomegd_sinit (union unirandominfo *u, char const *path) { int s = randomegd_open(path) ; if (s == -1) return 0 ; if (coe(s) == -1) { register int e = errno ; fd_close(s) ; errno = e ; return 0 ; } u->file.fd = s ; u->file.nb = 0 ; return 1 ; } int unirandomegd_finish (union unirandominfo *u) { if (fd_close(u->file.fd) == -1) return 0 ; return 1 ; } unsigned int unirandomegd_readb (union unirandominfo *u, char *s, unsigned int n) { return randomegd_readb(u->file.fd, s, n) ; } unsigned int unirandomegd_readnb (union unirandominfo *u, char *s, unsigned int n) { return randomegd_readnb(u->file.fd, s, n) ; } prog/skalibs-0.47/src/librandom/surf_makeseed.c0100644000000000000000000000126010324526614016453 0ustar /* Public domain. */ #include #include "uint32.h" #include "tai.h" #include "sha1.h" #include "surf.h" void surf_makeseed (char *s) { SHA1Schedule bak = SHA1_INIT() ; { struct taia now ; char tmp[20 + TAIN_PACK] ; uint32 x = getpid() ; uint32_pack(tmp, x) ; x = getppid() ; uint32_pack(tmp + 4, x) ; taia_now(&now) ; tain_pack(tmp + 8, &now) ; sha1_update(&bak, tmp, 8 + TAIN_PACK) ; sha1_final(&bak, tmp) ; sha1_init(&bak) ; sha1_update(&bak, tmp, 20) ; } { char i = 0 ; for (; i < 8 ; i++) { SHA1Schedule ctx = bak ; sha1_update(&ctx, &i, 1) ; sha1_final(&ctx, s + 20*i) ; } } } prog/skalibs-0.47/src/librandom/unihasegd.c0100644000000000000000000000115210040431667015603 0ustar /* Public domain. */ #include "sysdeps.h" #include "unirandomegd.h" #include "unirandom.h" #ifdef HASEGD #include "random-internal.h" int unihasegd_init (union unirandominfo *u) { return unirandomegd_sinit(u, HASEGD) ; } int unirandom_register_hasegd (unirandom *u) { unirandom_register(u, &unihasegd_init, &unirandomegd_finish, &unirandomegd_readb, &unirandomegd_readnb) ; return 1 ; } #else #include int unihasegd_init (union unirandominfo *u) { (void)u ; return (errno = ENOSYS, 0) ; } int unirandom_register_hasegd (unirandom *u) { (void)u ; return (errno = ENOSYS, 0) ; } #endif prog/skalibs-0.47/src/librandom/unisurf.c0100644000000000000000000000060510040431433015320 0ustar /* Public domain. */ #include "surf.h" #include "unirandom.h" #include "unisurf.h" int unisurf_sinit (union unirandominfo *u, char const *s) { surf_sinit(&u->surf_ctx, s) ; return 1 ; } int unisurf_finish (union unirandominfo *u) { (void)u ; return 1 ; } unsigned int unisurf_read (union unirandominfo *u, char *s, unsigned int n) { surf(&u->surf_ctx, s, n) ; return n ; } prog/skalibs-0.47/src/librandom/unirandomdev.c0100644000000000000000000000172110040527426016330 0ustar /* Public domain. */ #include #include "allreadwrite.h" #include "djbunix.h" #include "unirandom.h" #include "unirandomdev.h" int unirandomdev_sinit (union unirandominfo *u, char const *file) { int fd = open_read(file) ; if (fd == -1) return 0 ; if (coe(fd) == -1) { register int e = errno ; fd_close(fd) ; errno = e ; return 0 ; } u->file.fd = fd ; u->file.nb = 1 ; return 1 ; } int unirandomdev_finish (union unirandominfo *u) { if (fd_close(u->file.fd) == -1) return 0 ; return 1 ; } unsigned int unirandomdev_readb (union unirandominfo *u, char *s, unsigned int n) { if (u->file.nb) { if (ndelay_off(u->file.fd) == -1) return 0 ; u->file.nb = 0 ; } return allread(u->file.fd, s, n) ; } unsigned int unirandomdev_readnb (union unirandominfo *u, char *s, unsigned int n) { if (!u->file.nb) { if (ndelay_on(u->file.fd) == -1) return 0 ; u->file.nb = 1 ; } return allread(u->file.fd, s, n) ; } prog/skalibs-0.47/src/librandom/randomegd.h0100644000000000000000000000037110030102322015561 0ustar /* Public domain. */ #ifndef RANDOMEGD_H #define RANDOMEGD_H extern int randomegd_open (char const *) ; extern unsigned int randomegd_readb (int, char *, unsigned int) ; extern unsigned int randomegd_readnb (int, char *, unsigned int) ; #endif prog/skalibs-0.47/src/librandom/unirandom_init.c0100644000000000000000000000031710037504421016650 0ustar /* Public domain. */ #include #include "unirandom.h" int unirandom_init (unirandom_ref u) { if (u->initted) return 1 ; if (!(*u->init)(&u->data)) return 0 ; u->initted = 1 ; return 1 ; } prog/skalibs-0.47/src/librandom/unirandomdev.h0100644000000000000000000000146211100046370016327 0ustar /* Public domain. */ #ifndef UNIRANDOMDEV_H #define UNIRANDOMDEV_H #include "unirandom.h" extern int unirandomdev_sinit (union unirandominfo *, char const *) ; extern unsigned int unirandomdev_readb (union unirandominfo *, char *, unsigned int) ; extern unsigned int unirandomdev_readnb (union unirandominfo *, char *, unsigned int) ; extern int unirandomdev_finish (union unirandominfo *) ; extern int unidevrandom_init (union unirandominfo *) ; extern int unidevurandom_init (union unirandominfo *) ; #define UNIRANDOM_REGISTER_DEVRANDOM() { &unirandomdev_readb, &unirandomdev_readnb, &unidevrandom_init, &unirandomdev_finish, UNIRANDOMINFO_ZERO, 0 } #define UNIRANDOM_REGISTER_DEVURANDOM() { &unirandomdev_readb, &unirandomdev_readnb, &unidevurandom_init, &unirandomdev_finish, UNIRANDOMINFO_ZERO, 0 } #endif prog/skalibs-0.47/src/librandom/unirandom_finish.c0100644000000000000000000000032410037471224017167 0ustar /* Public domain. */ #include #include "unirandom.h" int unirandom_finish (unirandom_ref u) { if (!u->initted) return 1 ; if (!(*u->finish)(&u->data)) return 0 ; u->initted = 0 ; return 1 ; } prog/skalibs-0.47/src/librandom/unirandom_readb.c0100644000000000000000000000035010040433504016754 0ustar /* Public domain. */ #include #include "unirandom.h" unsigned int unirandom_readb (unirandom_ref u, char *s, unsigned int n) { if (!u->initted && !unirandom_init(u)) return 0 ; return (*u->readb)(&u->data, s, n) ; } prog/skalibs-0.47/src/librandom/surf_autoinit.c0100644000000000000000000000033110040431274016517 0ustar /* Public domain. */ #include "surf.h" void surf_autoinit (SURFSchedule_ref ctx, char *s, unsigned int n) { if (!ctx->in[0] && !ctx->in[1] && !ctx->in[2] && !ctx->in[3]) surf_init(ctx) ; surf(ctx, s, n) ; } prog/skalibs-0.47/src/librandom/unisurf_init.c0100644000000000000000000000053610040431522016345 0ustar /* Public domain. */ #include "surf.h" #include "random-internal.h" #include "unirandom.h" #include "unisurf.h" int unisurf_init (union unirandominfo *u) { surf_init(&u->surf_ctx) ; return 1 ; } int unirandom_register_surf (unirandom *u) { unirandom_register(u, &unisurf_init, &unisurf_finish, &unisurf_read, &unisurf_read) ; return 1 ; } prog/skalibs-0.47/src/librandom/rrandom_readint.c0100644000000000000000000000066010040433752017004 0ustar /* Public domain. */ #include "unirandom.h" #include "random-internal.h" #include "rrandom.h" unsigned int rrandom_readint (rrandom_ref z, unsigned int n, unsigned int (*f) (unirandom_ref, char *, unsigned int)) { unsigned int i = n ; unsigned int m = random_mask2(n-1) ; while (i >= n) { if (rrandom_read(z, (char *)&i, sizeof(unsigned int), f) < (int)sizeof(unsigned int)) return 0 ; i &= m ; } return i ; } prog/skalibs-0.47/src/librandom/unidevrandom.c0100644000000000000000000000120610040424704016321 0ustar /* Public domain. */ #include "sysdeps.h" #include "unirandomdev.h" #include "unirandom.h" #ifdef HASDEVRANDOM #include "random-internal.h" int unidevrandom_init (union unirandominfo *u) { return unirandomdev_sinit(u, "/dev/random") ; } int unirandom_register_devrandom (unirandom *u) { unirandom_register(u, &unidevrandom_init, &unirandomdev_finish, &unirandomdev_readb, &unirandomdev_readnb) ; return 1 ; } #else #include int unidevrandom_init (union unirandominfo *u) { (void)u ; return (errno = ENOSYS, 0) ; } int unirandom_register_devrandom (unirandom *u) { (void)u ; return (errno = ENOSYS, 0) ; } #endif prog/skalibs-0.47/src/librandom/unidevurandom.c0100644000000000000000000000121510040424716016511 0ustar /* Public domain. */ #include "sysdeps.h" #include "unirandomdev.h" #include "unirandom.h" #ifdef HASDEVURANDOM #include "random-internal.h" int unidevurandom_init (union unirandominfo *u) { return unirandomdev_sinit(u, "/dev/urandom") ; } int unirandom_register_devurandom (unirandom *u) { unirandom_register(u, &unidevurandom_init, &unirandomdev_finish, &unirandomdev_readb, &unirandomdev_readnb) ; return 1 ; } #else #include int unidevurandom_init (union unirandominfo *u) { (void)u ; return (errno = ENOSYS, 0) ; } int unirandom_register_devurandom (unirandom *u) { (void)u ; return (errno = ENOSYS, 0) ; } #endif prog/skalibs-0.47/src/librandom/unirandom_register.c0100644000000000000000000000077610040425541017541 0ustar /* Public domain. */ #include #include "unirandom.h" #include "random-internal.h" void unirandom_register (unirandom_ref u, int (*init) (union unirandominfo *), int (*finish) (union unirandominfo *), unsigned int (*readb) (union unirandominfo *, char *, unsigned int), unsigned int (*readnb) (union unirandominfo *, char *, unsigned int)) { unirandom zero = UNIRANDOM_ZERO ; *u = zero ; u->init = init ; u->finish = finish ; u->readb = readb ; u->readnb = readnb ; u->initted = 0 ; } prog/skalibs-0.47/src/librandom/unirandomegd.h0100644000000000000000000000113111100046370016301 0ustar /* Public domain. */ #ifndef UNIRANDOMEGD_H #define UNIRANDOMEGD_H #include "unirandom.h" extern int unirandomegd_sinit (union unirandominfo *, char const *) ; extern unsigned int unirandomegd_readb (union unirandominfo *, char *, unsigned int) ; extern unsigned int unirandomegd_readnb (union unirandominfo *, char *, unsigned int) ; extern int unirandomegd_finish (union unirandominfo *) ; extern int unihasegd_init (union unirandominfo *) ; #define UNIRANDOM_REGISTER_HASEGD() { &unirandomegd_readb, &unirandomegd_readnb, &unihasegd_init, &unirandomegd_finish, UNIRANDOMINFO_ZERO, 0 } #endif prog/skalibs-0.47/src/librandom/dns_random_string.c0100644000000000000000000000027310040424053017340 0ustar /* Public domain. */ /* MT-unsafe */ #include "surf.h" #include "random-internal.h" #include "random.h" void dns_random_string (char *s, unsigned int n) { surf(&surf_here, s, n) ; } prog/skalibs-0.47/src/librandom/goodrandom_here.c0100644000000000000000000000150410040433167016766 0ustar /* Public domain. */ /* MT-unsafe */ #include "sysdeps.h" #include "unisurf.h" #include "random-internal.h" #ifdef HASEGD # include "unirandomegd.h" # ifdef HASDEVRANDOM # include "unirandomdev.h" rrandom goodrandom_here = { { { UNIRANDOM_REGISTER_DEVRANDOM(), 3 }, { UNIRANDOM_REGISTER_HASEGD(), 3 }, { UNIRANDOM_REGISTER_SURF(), 3 } }, 3 } ; # else rrandom goodrandom_here = { { { UNIRANDOM_REGISTER_HASEGD(), 3 }, { UNIRANDOM_REGISTER_SURF(), 3 }, { UNIRANDOM_ZERO, 3 } }, 2 } ; # endif #else # ifdef HASDEVRANDOM # include "unirandomdev.h" rrandom goodrandom_here = { { { UNIRANDOM_REGISTER_DEVRANDOM(), 3 }, { UNIRANDOM_REGISTER_SURF(), 3 }, { UNIRANDOM_ZERO, 3 } }, 2 } ; # else rrandom goodrandom_here = { { { UNIRANDOM_REGISTER_SURF(), 3 }, { UNIRANDOM_ZERO, 3 }, { UNIRANDOM_ZERO, 3 } }, 1 } ; # endif #endif prog/skalibs-0.47/src/librandom/unirandom_readnb.c0100644000000000000000000000035210040433477017145 0ustar /* Public domain. */ #include #include "unirandom.h" unsigned int unirandom_readnb (unirandom_ref u, char *s, unsigned int n) { if (!u->initted && !unirandom_init(u)) return 0 ; return (*u->readnb)(&u->data, s, n) ; } prog/skalibs-0.47/src/librandom/dns_random_init.c0100644000000000000000000000100310040433273016771 0ustar /* Public domain. */ /* MT-unsafe */ #include #include "uint32.h" #include "bytestr.h" #include "tai.h" #include "surf.h" #include "random-internal.h" #include "random.h" void dns_random_init (char const *data) /* 128 chars */ { char tmp[160] ; struct taia t ; byte_copy(tmp, 128, data) ; taia_now(&t) ; taia_pack(tmp + 128, &t) ; uint32_pack(tmp + 144, getpid()) ; uint32_pack(tmp + 148, getppid()) ; /* more space in tmp+152 and tmp+156 if needed */ surf_sinit(&surf_here, tmp) ; } prog/skalibs-0.47/src/librandom/rrandom_finish.c0100644000000000000000000000041310040426124016625 0ustar /* Public domain. */ #include "unirandom.h" #include "rrandom.h" int rrandom_finish (rrandom_ref z) { rrandom zero = RRANDOM_ZERO ; unsigned int i = z->n ; int e = 1 ; while (i--) e &= unirandom_finish(&z->tries[i].it) ; if (e) *z = zero ; return e ; } prog/skalibs-0.47/src/librandom/rrandom_add.c0100644000000000000000000000042610037510646016112 0ustar /* Public domain. */ #include #include "unirandom.h" #include "rrandom.h" int rrandom_add (rrandom_ref z, int (*f) (unirandom_ref)) { if (z->n >= 3) return (errno = EBUSY, 0) ; if (!(*f)(&z->tries[z->n].it)) return 0 ; z->tries[z->n++].ok = 3 ; return 1 ; } prog/skalibs-0.47/src/libstdcrypto/0040755000000000000000000000000010324527101014241 5ustar prog/skalibs-0.47/src/libstdcrypto/Makefile0100644000000000000000000000303207663560170015713 0ustar it: command include library library.so clean: EXPORT INTERNAL rm -f `cat EXPORT INTERNAL` stdcrypto.h: rc4.h sha1.h md5.h touch stdcrypto.h rc4.o: compile rc4.c rc4.h bytestr.h ./compile rc4.c rc4_init.o: compile rc4_init.c rc4.h bytestr.h ./compile rc4_init.c md5.h: uint32.h touch md5.h md5_init.o: compile md5_init.c md5.h uint32.h ./compile md5_init.c md5_transform.o: compile md5_transform.c md5_internal.h md5.h uint32.h ./compile md5_transform.c md5_update.o: compile md5_update.c md5_internal.h md5.h bytestr.h uint32.h ./compile md5_update.c md5_final.o: compile md5_final.c md5_internal.h md5.h uint32.h ./compile md5_final.c sha1.h: uint32.h touch sha1.h sha1_init.o: compile sha1_init.c sha1.h ./compile sha1_init.c sha1_transform.o: compile sha1_transform.c sha1_internal.h sha1.h uint32.h ./compile sha1_transform.c sha1_feed.o: compile sha1_feed.c sha1_internal.h sha1.h uint32.h bytestr.h ./compile sha1_feed.c sha1_update.o: compile sha1_update.c sha1_internal.h sha1.h ./compile sha1_update.c sha1_final.o: compile sha1_final.c sha1_internal.h sha1.h uint32.h ./compile sha1_final.c libstdcrypto.a: makelib \ rc4.o rc4_init.o \ md5_init.o md5_transform.o md5_update.o md5_final.o \ sha1_init.o sha1_transform.o sha1_feed.o sha1_update.o sha1_final.o ./makelib libstdcrypto.a \ rc4.o rc4_init.o \ md5_init.o md5_transform.o md5_update.o md5_final.o \ sha1_init.o sha1_transform.o sha1_feed.o sha1_update.o sha1_final.o command: include: rc4.h md5.h sha1.h stdcrypto.h library: libstdcrypto.a library.so: prog/skalibs-0.47/src/libstdcrypto/EXPORT0100644000000000000000000000001707663560170015217 0ustar libstdcrypto.a prog/skalibs-0.47/src/libstdcrypto/INCLUDE0100644000000000000000000000003707663560170015263 0ustar rc4.h md5.h sha1.h stdcrypto.h prog/skalibs-0.47/src/libstdcrypto/INTERNAL0100644000000000000000000000021107663560170015406 0ustar md5_init.o md5_transform.o md5_update.o md5_final.o rc4.o rc4_init.o sha1_init.o sha1_transform.o sha1_feed.o sha1_update.o sha1_final.o prog/skalibs-0.47/src/libstdcrypto/md5_update.c0100644000000000000000000000153110324527077016445 0ustar /* Public domain. */ #include "uint32.h" #include "bytestr.h" #include "md5.h" #include "md5_internal.h" void md5_update (MD5Schedule_ref ctx, char const *s, unsigned int len) { register uint32 t = ctx->bits[0] ; if ((ctx->bits[0] = t + (len << 3)) < t) ctx->bits[1]++ ; ctx->bits[1] += len >> 29 ; t = (t >> 3) & 0x3f ; if (t) { unsigned char *p = ctx->in + t ; t = 64 - t ; if (len < t) { byte_copy((char *)p, len, s) ; return ; } byte_copy((char *)p, t, s) ; uint32_little_endian(ctx->in, 16) ; md5_transform(ctx->buf, (uint32 *)ctx->in) ; s += t ; len -= t ; } while (len >= 64) { byte_copy((char *)ctx->in, 64, s) ; uint32_little_endian(ctx->in, 16) ; md5_transform(ctx->buf, (uint32 *)ctx->in) ; s += 64 ; len -= 64 ; } byte_copy((char *)ctx->in, len, s) ; } prog/skalibs-0.47/src/libstdcrypto/md5_init.c0100644000000000000000000000036607663560170016136 0ustar /* Public domain. */ #include "md5.h" void md5_init (MD5Schedule_ref ctx) { ctx->buf[0] = 0x67452301UL ; ctx->buf[1] = 0xefcdab89UL ; ctx->buf[2] = 0x98badcfeUL ; ctx->buf[3] = 0x10325476UL ; ctx->bits[0] = 0 ; ctx->bits[1] = 0 ; } prog/skalibs-0.47/src/libstdcrypto/md5.h0100644000000000000000000000115611100046364015077 0ustar /* Public domain. */ #ifndef MD5_H #define MD5_H #include "uint32.h" typedef struct MD5Schedule MD5Schedule, *MD5Schedule_ref ; struct MD5Schedule { uint32 buf[4] ; uint32 bits[2] ; unsigned char in[64] ; } ; #define MD5_INIT() { {0x67452301UL, 0xefcdab89UL, 0x98badcfeUL, 0x10325476UL}, {0, 0}, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" } extern void md5_init (MD5Schedule_ref) ; extern void md5_update (MD5Schedule_ref, char const *, unsigned int) ; extern void md5_final (MD5Schedule_ref, char * /* 16 chars */) ; #endif prog/skalibs-0.47/src/libstdcrypto/md5_transform.c0100644000000000000000000000750707663560170017212 0ustar /* Public domain. */ #include "uint32.h" #include "md5_internal.h" /* #define F1(x, y, z) (x & y | ~x & z) */ #define F1(x, y, z) (z ^ (x & (y ^ z))) #define F2(x, y, z) F1(z, x, y) #define F3(x, y, z) (x ^ y ^ z) #define F4(x, y, z) (y ^ (x | ~z)) #define MD5STEP(f, w, x, y, z, data, s) \ ( w += f(x, y, z) + data, w = w<>(32-s), w += x ) void md5_transform (uint32 *buf /* 4 uint32s */, uint32 const *in /* 16 uint32s */) { register uint32 a = buf[0], b = buf[1], c = buf[2], d = buf[3] ; MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7) ; MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12) ; MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17) ; MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22) ; MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7) ; MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12) ; MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17) ; MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22) ; MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7) ; MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12) ; MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17) ; MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22) ; MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7) ; MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12) ; MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17) ; MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22) ; MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5) ; MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9) ; MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14) ; MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20) ; MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5) ; MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9) ; MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14) ; MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20) ; MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5) ; MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9) ; MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14) ; MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20) ; MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5) ; MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9) ; MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14) ; MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20) ; MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4) ; MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11) ; MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16) ; MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23) ; MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4) ; MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11) ; MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16) ; MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23) ; MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4) ; MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11) ; MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16) ; MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23) ; MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4) ; MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11) ; MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16) ; MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23) ; MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6) ; MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10) ; MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15) ; MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21) ; MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6) ; MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10) ; MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15) ; MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21) ; MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6) ; MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10) ; MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15) ; MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21) ; MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6) ; MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10) ; MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15) ; MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21) ; buf[0] += a ; buf[1] += b ; buf[2] += c ; buf[3] += d ; } prog/skalibs-0.47/src/libstdcrypto/md5_final.c0100644000000000000000000000142507667005037016261 0ustar /* Public domain. */ #include "uint32.h" #include "bytestr.h" #include "md5.h" #include "md5_internal.h" void md5_final (MD5Schedule_ref ctx, char *digest /* 16 chars */) { register unsigned int count = (ctx->bits[0] >> 3) & 0x3F ; register unsigned char *p = ctx->in + count ; *p++ = 0x80; count = 63 - count ; if (count < 8) { byte_zero(p, count) ; uint32_little_endian(ctx->in, 16) ; md5_transform(ctx->buf, (uint32 *)ctx->in) ; byte_zero(ctx->in, 56) ; } else byte_zero(p, count - 8) ; uint32_little_endian(ctx->in, 14) ; ((uint32 *)ctx->in)[14] = ctx->bits[0] ; ((uint32 *)ctx->in)[15] = ctx->bits[1] ; md5_transform(ctx->buf, (uint32 *)ctx->in) ; uint32_little_endian((char *)ctx->buf, 4) ; byte_copy(digest, 16, (char *)ctx->buf) ; } prog/skalibs-0.47/src/libstdcrypto/rc4.c0100644000000000000000000000074110324526325015103 0ustar /* Public domain. */ /* Thanks to Thomas Pornin */ #include "bytestr.h" #include "rc4.h" void rc4 (RC4Schedule_ref r, char const *in, char *out, unsigned int n) { register unsigned int i = 0 ; for (; i < n ; i++) { register unsigned char t ; r->x = T8(r->x + 1) ; t = r->tab[r->x] ; r->y = T8(r->y + t) ; r->tab[r->x] = r->tab[r->y] ; r->tab[r->y] = t ; out[i] = (unsigned char)in[i] ^ T8(r->tab[r->x] + r->tab[r->y]) ; } } prog/skalibs-0.47/src/libstdcrypto/rc4.h0100644000000000000000000000055310324526147015113 0ustar /* Public domain. */ #ifndef RC4_H #define RC4_H #define RC4_THROWAWAY 128 typedef struct RC4Schedule RC4Schedule, *RC4Schedule_ref ; struct RC4Schedule { unsigned char tab[256] ; unsigned char x, y ; } ; extern void rc4_init (RC4Schedule_ref, char const *, unsigned int) ; extern void rc4 (RC4Schedule_ref, char const *, char *, unsigned int) ; #endif prog/skalibs-0.47/src/libstdcrypto/md5_internal.h0100644000000000000000000000031307663560170017004 0ustar /* Public domain. */ #ifndef MD5_INTERNAL_H #define MD5_INTERNAL_H #include "uint32.h" #include "md5.h" extern void md5_transform (uint32 * /* 4 uint32s */, uint32 const * /* 16 uint32s */) ; #endif prog/skalibs-0.47/src/libstdcrypto/rc4_init.c0100644000000000000000000000111310324526240016114 0ustar /* Public domain. */ /* Thanks to Thomas Pornin */ #include "bytestr.h" #include "rc4.h" void rc4_init (RC4Schedule_ref r, char const *key, unsigned int ksize) { register unsigned int i = 0, j = 0 ; register unsigned char c = 0; r->x = r->y = 0 ; for (; i < 256 ; i++) r->tab[i] = i ; for (i = 0 ; i < 256 ; i++) { unsigned char t = r->tab[i] ; c = T8(c + (unsigned char)key[j] + t) ; r->tab[i] = r->tab[c] ; r->tab[c] = t ; if (++j == ksize) j = 0 ; } { char tmp[RC4_THROWAWAY] ; rc4(r, tmp, tmp, RC4_THROWAWAY) ; } } prog/skalibs-0.47/src/libstdcrypto/sha1.h0100644000000000000000000000111111100046364015235 0ustar /* Public domain. */ #ifndef SHA1_H #define SHA1_H #include "uint32.h" typedef struct SHA1Schedule SHA1Schedule, *SHA1Schedule_ref ; struct SHA1Schedule { uint32 buf[5] ; uint32 bits[2] ; uint32 in[16] ; unsigned char b ; } ; #define SHA1_INIT() { {0x67452301UL, 0xefcdab89UL, 0x98badcfeUL, 0x10325476UL, 0xc3d2e1f0UL}, {0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0 } extern void sha1_init (SHA1Schedule_ref) ; extern void sha1_update (SHA1Schedule_ref, char const *, unsigned int) ; extern void sha1_final (SHA1Schedule_ref, char * /* 20 chars */) ; #endif prog/skalibs-0.47/src/libstdcrypto/sha1_internal.h0100644000000000000000000000041107663560170017152 0ustar /* Public domain. */ #ifndef SHA1_INTERNAL_H #define SHA1_INTERNAL_H #include "uint32.h" #include "sha1.h" extern void sha1_feed (SHA1Schedule_ref, unsigned char) ; extern void sha1_transform (uint32 * /* 5 uint32s */, uint32 const * /* 16 uint32s */) ; #endif prog/skalibs-0.47/src/libstdcrypto/sha1_transform.c0100644000000000000000000000206707667004711017353 0ustar /* Public domain. */ #include "uint32.h" #include "sha1_internal.h" #define F1(x, y, z) ((x & y) | ((~x) & z)) #define F2(x, y, z) (x ^ y ^ z) #define F3(x, y, z) ((x & y) | (x & z) | (y & z)) #define F4(x, y, z) (x ^ y ^ z) #define SHA1STEP(f, data) \ { \ register uint32 tmp = e + f(b, c, d) + data + ((a<<5) | (a>>27)); \ e = d ; \ d = c ; \ c = (b<<30) | (b>>2) ; \ b = a ; \ a = tmp ; \ } void sha1_transform (uint32 *buf, uint32 const *in) { register uint32 a = buf[0], b = buf[1], c = buf[2], d = buf[3], e = buf[4] ; uint32 w[80] ; register unsigned int i = 0 ; for (; i < 16 ; i++) w[i] = in[i] ; for (; i < 80 ; i++) { w[i] = w[i-3] ^ w[i-8] ^ w[i-14] ^ w[i-16] ; w[i] = (w[i]<<1) | (w[i]>>31) ; } for (i = 0 ; i < 20 ; i++) SHA1STEP(F1, w[i] + 0x5a827999UL) ; for (; i < 40 ; i++) SHA1STEP(F2, w[i] + 0x6ed9eba1UL) ; for (; i < 60 ; i++) SHA1STEP(F3, w[i] + 0x8f1bbcdcUL) ; for (; i < 80 ; i++) SHA1STEP(F4, w[i] + 0xca62c1d6UL) ; buf[0] += a ; buf[1] += b ; buf[2] += c ; buf[3] += d ; buf[4] += e ; } prog/skalibs-0.47/src/libstdcrypto/sha1_init.c0100644000000000000000000000055107667004654016305 0ustar /* Public domain. */ #include "sha1.h" void sha1_init (SHA1Schedule_ref ctx) { register unsigned int i = 0 ; ctx->buf[0] = 0x67452301UL ; ctx->buf[1] = 0xefcdab89UL ; ctx->buf[2] = 0x98badcfeUL ; ctx->buf[3] = 0x10325476UL ; ctx->buf[4] = 0xc3d2e1f0UL ; ctx->bits[0] = ctx->bits[1] = 0 ; for (; i < 16 ; i++) ctx->in[i] = 0 ; ctx->b = 0 ; } prog/skalibs-0.47/src/libstdcrypto/sha1_final.c0100644000000000000000000000070010324526413016411 0ustar /* Public domain. */ #include "uint32.h" #include "sha1.h" #include "sha1_internal.h" void sha1_final (SHA1Schedule_ref ctx, char *digest) { char pack[8] ; register unsigned int i = 0 ; uint32_pack_big(pack, ctx->bits[1]) ; uint32_pack_big(pack+4, ctx->bits[0]) ; sha1_feed(ctx, 0x80) ; while (ctx->b != 56) sha1_feed(ctx, 0) ; sha1_update(ctx, pack, 8) ; for (; i < 5 ; i++) uint32_pack_big(digest + (i<<2), ctx->buf[i]) ; } prog/skalibs-0.47/src/libstdcrypto/sha1_feed.c0100644000000000000000000000100307667004614016232 0ustar /* Public domain. */ #include "uint32.h" #include "bytestr.h" #include "sha1.h" #include "sha1_internal.h" void sha1_feed (SHA1Schedule_ref ctx, unsigned char inb) { register uint32 tmp ; ctx->in[ctx->b>>2] <<= 8 ; ctx->in[ctx->b>>2] |= T8(inb) ; if (++ctx->b >= 64) { register unsigned int i = 0 ; sha1_transform(ctx->buf, ctx->in) ; ctx->b = 0 ; for (i = 0 ; i < 16 ; i++) ctx->in[i] = 0 ; } tmp = ctx->bits[0] ; ctx->bits[0] += 8 ; if (tmp > ctx->bits[0]) ctx->bits[1]++ ; } prog/skalibs-0.47/src/libstdcrypto/sha1_update.c0100644000000000000000000000036307667004700016615 0ustar /* Public domain. */ #include "sha1.h" #include "sha1_internal.h" void sha1_update (SHA1Schedule_ref ctx, char const *buf, unsigned int len) { register unsigned int i = 0 ; for (; i < len ; i++) sha1_feed(ctx, (unsigned char)buf[i]) ; } prog/skalibs-0.47/src/libstdcrypto/stdcrypto.h0100644000000000000000000000017311100046364016443 0ustar /* Public domain. */ #ifndef STDCRYPTO_H #define STDCRYPTO_H #include "rc4.h" #include "md5.h" #include "sha1.h" #endif prog/skalibs-0.47/src/headers/0040755000000000000000000000000010136147472013144 5ustar prog/skalibs-0.47/src/headers/Makefile0100644000000000000000000000745510022111774014602 0ustar it: command include library library.so clean: EXPORT INTERNAL rm -f `cat EXPORT INTERNAL` skalibs-version.h: stupid skalibs-version.h.stupid ./stupid < skalibs-version.h.stupid > skalibs-version.h uint16.h: sysdeps uint64.h uint16-header uint16-footer uint16-stdinth uint16-inttypesh uint16-default uint16-lendian uint16-bendian rm -f uint16.h ( \ cat uint16-header ; \ if grep +stdinth sysdeps >/dev/null ; then cat uint16-stdinth ; \ elif grep +inttypesh sysdeps >/dev/null ; then cat uint16-inttypesh ; \ else cat uint16-default ; \ fi ; \ if grep +little_endian sysdeps >/dev/null ; then cat uint16-lendian ; \ elif grep +big_endian sysdeps >/dev/null ; then cat uint16-bendian ; \ else echo "Error ! Unsupported endianness" 1>&2 ; ./crash ; \ fi ; \ cat uint16-footer \ ) > uint16.h uint32.h: sysdeps uint64.h uint32-header uint32-footer uint32-stdinth uint32-inttypesh uint32-ulong32 uint32-noulong32 uint32-lendian uint32-bendian rm -f uint32.h ( \ cat uint32-header ; \ if grep +stdinth sysdeps >/dev/null ; then cat uint32-stdinth ; \ elif grep +inttypesh sysdeps >/dev/null ; then cat uint32-inttypesh ; \ elif grep +ulong32 sysdeps >/dev/null ; then cat uint32-ulong32 ; \ else cat uint32-noulong32 ; \ fi ; \ if grep +little_endian sysdeps >/dev/null ; then cat uint32-lendian ; \ elif grep +big_endian sysdeps >/dev/null ; then cat uint32-bendian ; \ else echo "Error ! Unsupported endianness" 1>&2 ; ./crash ; \ fi ; \ cat uint32-footer \ ) > uint32.h uint64.h: sysdeps uint64-header uint64-footer uint64-ulong64 uint64-noulong64 uint64-lendian uint64-bendian rm -f uint64.h ( \ cat uint64-header ; \ if grep +ulong64 sysdeps >/dev/null ; then cat uint64-ulong64 ; \ else cat uint64-noulong64 ; \ fi ; \ if grep +little_endian sysdeps >/dev/null ; then cat uint64-lendian ; \ elif grep +big_endian sysdeps >/dev/null ; then cat uint64-bendian ; \ else echo "Error ! Unsupported endianness" 1>&2 ; ./crash ; \ fi ; \ cat uint64-footer \ ) > uint64.h direntry.h: sysdeps direntry.h1 direntry.h2 direntry-header direntry-footer rm -f direntry.h ( \ cat direntry-header ; \ if grep +dirent sysdeps >/dev/null ; then cat direntry.h2 ; \ else cat direntry.h1 ; \ fi ; \ cat direntry-footer \ ) > direntry.h error.h: systype sysdeps error-addrinuse error-already error-proto error-header error-footer rm -f error.h ( \ cat error-header ; \ if cut -d- -f1 systype | grep bsd >/dev/null ; then cat error-addrinuse ; \ else cat error-already ; \ fi ; \ if grep +eproto sysdeps >/dev/null ; then true ; \ else cat error-proto ; \ fi ; \ cat error-footer \ ) > error.h select.h: sysdeps select.h1 select.h2 rm -f select.h ( \ if grep +sysselect sysdeps >/dev/null ; then cat select.h2 ; \ else cat select.h1 ; \ fi \ ) > select.h iopause.h: sysdeps iopause.h1 iopause.h2 iopause.h3 iopause.h4 rm -f iopause.h ( \ if grep +poll sysdeps >/dev/null ; then \ if grep +pollh sysdeps >/dev/null ; then cat iopause.h2 ; \ elif grep +syspollh sysdeps >/dev/null ; then cat iopause.h3 ; \ else cat iopause.h4 ; \ fi \ else cat iopause.h1 ; \ fi \ ) > iopause.h shglob.h: sysdeps shglob.h1 shglob.h2 rm -f shglob.h ( \ if grep +posixglob sysdeps >/dev/null ; then cat shglob.h2 ; \ else cat shglob.h1 ; \ fi \ ) > shglob.h syssocket.h: sysdeps syssocket.h1 syssocket.h2 syssocket-header syssocket-footer rm -f syssocket.h ( \ cat syssocket-header ; \ if grep +oksyssocket sysdeps >/dev/null ; then cat syssocket.h2 ; \ else cat syssocket.h1 ; \ fi ; \ cat syssocket-footer \ ) > syssocket.h command: include: gccattributes.h skalibs-version.h uint16.h uint32.h uint64.h direntry.h error.h select.h iopause.h shglob.h syssocket.h library: library.so: prog/skalibs-0.47/src/headers/INCLUDE0100644000000000000000000000002007663560170014144 0ustar gccattributes.h prog/skalibs-0.47/src/headers/INTERNAL0100644000000000000000000000000007663560170014273 0ustar prog/skalibs-0.47/src/headers/EXPORT0100644000000000000000000000015010022111561014061 0ustar uint16.h uint32.h uint64.h direntry.h error.h select.h iopause.h shglob.h skalibs-version.h syssocket.h prog/skalibs-0.47/src/headers/uint32-inttypesh0100644000000000000000000000006107724247372016243 0ustar #include typedef uint32_t uint32 ; prog/skalibs-0.47/src/headers/error-addrinuse0100644000000000000000000000015707773703540016203 0ustar /* BSD sucks */ #define error_isalready(e) (((e) == EALREADY) || ((e) == EINPROGRESS) || ((e) == EADDRINUSE)) prog/skalibs-0.47/src/headers/uint16-footer0100644000000000000000000000276010004032474015500 0ustar extern void uint16_pack (char *, uint16) ; extern void uint16_pack_big (char *, uint16) ; extern void uint16_unpack (char const *, uint16 *) ; extern void uint16_unpack_big (char const *, uint16 *) ; extern void uint16_reverse (char *, unsigned int) ; #define UINT16_FMT 6 #define UINT16_OFMT 7 #define UINT16_XFMT 5 #define UINT16_BFMT 17 #define uint16_fmt(s, u) uint64_fmt((s), (uint64)(uint16)(u)) #define uint160_fmt(s, u, n) uint64_fmt((s), (uint64)(uint16)(u), (n)) #define uint16_ofmt(s, o) uint64_ofmt((s), (uint64)(uint16)(o)) #define uint160_ofmt(s, o, n) uint64_ofmt((s), (uint64)(uint16)(o), (n)) #define uint16_xfmt(s, x) uint64_xfmt((s), (uint64)(uint16)(x)) #define uint160_xfmt(s, x, n) uint64_xfmt((s), (uint64)(uint16)(x), (n)) #define uint16_bfmt(s, x) uint64_bfmt((s), (uint64)(uint16)(x)) #define uint160_bfmt(s, x, n) uint64_bfmt((s), (uint64)(uint16)(x), (n)) extern unsigned int uint16_scan_base (char const *, uint16 *, unsigned char) ; extern unsigned int uint160_scan_base (char const *, uint16 *, unsigned char) ; #define uint16_scan(s, u) uint16_scan_base((s), (u), 10) #define uint160_scan(s, u) uint160_scan_base((s), (u), 10) #define uint16_oscan(s, u) uint16_scan_base((s), (u), 8) #define uint160_oscan(s, u) uint160_scan_base((s), (u), 8) #define uint16_xscan(s, u) uint16_scan_base((s), (u), 16) #define uint160_xscan(s, u) uint160_scan_base((s), (u), 16) #define uint16_bscan(s, u) uint16_scan_base((s), (u), 2) #define uint160_bscan(s, u) uint160_scan_base((s), (u), 2) #endif prog/skalibs-0.47/src/headers/uint32-header0100644000000000000000000000011610003223747015425 0ustar /* Public domain. */ #ifndef UINT32_H #define UINT32_H #include "uint64.h" prog/skalibs-0.47/src/headers/uint32-footer0100644000000000000000000000276510003761373015511 0ustar extern void uint32_pack (char *, uint32) ; extern void uint32_pack_big (char *, uint32) ; extern void uint32_unpack (char const *, uint32 *) ; extern void uint32_unpack_big (char const *, uint32 *) ; extern void uint32_reverse (char *, unsigned int) ; #define UINT32_FMT 11 #define UINT32_OFMT 13 #define UINT32_XFMT 9 #define UINT32_BFMT 33 #define uint32_fmt(s, u) uint64_fmt((s), (uint64)(uint32)(u)) #define uint320_fmt(s, u, n) uint640_fmt((s), (uint64)(uint32)(u), (n)) #define uint32_ofmt(s, o) uint64_ofmt((s), (uint64)(uint32)(o)) #define uint320_ofmt(s, o, n) uint640_ofmt((s), (uint64)(uint32)(o), (n)) #define uint32_xfmt(s, x) uint64_xfmt((s), (uint64)(uint32)(x)) #define uint320_xfmt(s, x, n) uint640_xfmt((s), (uint64)(uint32)(x), (n)) #define uint32_bfmt(s, x) uint64_bfmt((s), (uint64)(uint32)(x)) #define uint320_bfmt(s, x, n) uint640_bfmt((s), (uint64)(uint32)(x), (n)) extern unsigned int uint32_scan_base (char const *, uint32 *, unsigned char) ; extern unsigned int uint320_scan_base (char const *, uint32 *, unsigned char) ; #define uint32_scan(s, u) uint32_scan_base((s), (u), 10) #define uint320_scan(s, u) uint320_scan_base((s), (u), 10) #define uint32_oscan(s, u) uint32_scan_base((s), (u), 8) #define uint320_oscan(s, u) uint320_scan_base((s), (u), 8) #define uint32_xscan(s, u) uint32_scan_base((s), (u), 16) #define uint320_xscan(s, u) uint320_scan_base((s), (u), 16) #define uint32_bscan(s, u) uint32_scan_base((s), (u), 2) #define uint320_bscan(s, u) uint320_scan_base((s), (u), 2) #endif prog/skalibs-0.47/src/headers/uint16-header0100644000000000000000000000011610003224170015416 0ustar /* Public domain. */ #ifndef UINT16_H #define UINT16_H #include "uint64.h" prog/skalibs-0.47/src/headers/syssocket.h10100644000000000000000000000005710022110570015403 0ustar #include #include prog/skalibs-0.47/src/headers/direntry.h10100644000000000000000000000011307772654245015243 0ustar #include #include #define direntry struct direct prog/skalibs-0.47/src/headers/uint16-bendian0100644000000000000000000000013507724242337015614 0ustar #define uint16_little_endian(s, n) uint16_reverse((s), (n)) #define uint16_big_endian(s, n) prog/skalibs-0.47/src/headers/select.h10100644000000000000000000000020207663560170014651 0ustar /* Public domain. */ #ifndef SELECT_H #define SELECT_H #include #include #include #endif prog/skalibs-0.47/src/headers/select.h20100644000000000000000000000023207773101512014646 0ustar /* Public domain. */ #ifndef SELECT_H #define SELECT_H #include #include #include #include #endif prog/skalibs-0.47/src/headers/iopause.h10100644000000000000000000000063210136147470015037 0ustar /* Public domain. */ #ifndef IOPAUSE_H #define IOPAUSE_H #include "tai.h" typedef struct iopause_fd iopause_fd, *iopause_fd_ref ; struct iopause_fd { int fd ; unsigned short events ; unsigned short revents ; } ; #define IOPAUSE_READ 0x0011 #define IOPAUSE_WRITE 0x0004 #define IOPAUSE_EXCEPT 0x0038 extern int iopause (iopause_fd *, unsigned int, struct taia const *, struct taia const *) ; #endif prog/skalibs-0.47/src/headers/direntry.h20100644000000000000000000000011207772654251015240 0ustar #include #include #define direntry struct dirent prog/skalibs-0.47/src/headers/error-header0100644000000000000000000000247007773701552015456 0ustar /* Public domain. */ #ifndef ERROR_H #define ERROR_H #include #include "gccattributes.h" extern int error_ok gccattr_deprecated ; extern int error_intr gccattr_deprecated ; extern int error_nomem gccattr_deprecated ; extern int error_noent gccattr_deprecated ; extern int error_txtbsy gccattr_deprecated ; extern int error_io gccattr_deprecated ; extern int error_exist gccattr_deprecated ; extern int error_timeout gccattr_deprecated ; extern int error_inprogress gccattr_deprecated ; extern int error_wouldblock gccattr_deprecated ; extern int error_again gccattr_deprecated ; extern int error_pipe gccattr_deprecated ; extern int error_perm gccattr_deprecated ; extern int error_acces gccattr_deprecated ; extern int error_nodevice gccattr_deprecated ; extern int error_proto gccattr_deprecated ; extern int error_isdir gccattr_deprecated ; extern int error_connrefused gccattr_deprecated ; extern int error_notdir gccattr_deprecated ; extern int error_badf gccattr_deprecated ; extern int error_notsock gccattr_deprecated ; extern int error_inval gccattr_deprecated ; extern int error_dom gccattr_deprecated ; extern int error_nobufs gccattr_deprecated ; extern char const *error_str (int) gccattr_const ; extern int error_temp (int) gccattr_const ; #define error_isagain(e) (((e) == EAGAIN) || ((e) == EWOULDBLOCK)) prog/skalibs-0.47/src/headers/iopause.h20100644000000000000000000000060610136147173015041 0ustar /* Public domain. */ #ifndef IOPAUSE_H #define IOPAUSE_H #include #include #include "tai.h" typedef struct pollfd iopause_fd, *iopause_fd_ref ; #define IOPAUSE_READ (POLLIN|POLLHUP) #define IOPAUSE_WRITE POLLOUT #define IOPAUSE_EXCEPT (POLLERR|POLLHUP|POLLNVAL) extern int iopause (iopause_fd *, unsigned int, struct taia const *, struct taia const *) ; #endif prog/skalibs-0.47/src/headers/iopause.h30100644000000000000000000000061210136147232015033 0ustar /* Public domain. */ #ifndef IOPAUSE_H #define IOPAUSE_H #include #include #include "tai.h" typedef struct pollfd iopause_fd, *iopause_fd_ref ; #define IOPAUSE_READ (POLLIN|POLLHUP) #define IOPAUSE_WRITE POLLOUT #define IOPAUSE_EXCEPT (POLLERR|POLLHUP|POLLNVAL) extern int iopause (iopause_fd *, unsigned int, struct taia const *, struct taia const *) ; #endif prog/skalibs-0.47/src/headers/iopause.h40100644000000000000000000000056410136147155015046 0ustar /* Public domain. */ #ifndef IOPAUSE_H #define IOPAUSE_H #include #include "tai.h" typedef struct pollfd iopause_fd, *iopause_fd_ref ; #define IOPAUSE_READ (POLLIN|POLLHUP) #define IOPAUSE_WRITE POLLOUT #define IOPAUSE_EXCEPT (POLLERR|POLLHUP|POLLNVAL) extern int iopause (iopause_fd *, unsigned int, struct taia const *, struct taia const *) ; #endif prog/skalibs-0.47/src/headers/shglob.h20100644000000000000000000000026507663560170014662 0ustar /* Public domain. */ #ifndef SHGLOB_H #define SHGLOB_H #include #define shglob(pattern, flags, errfunc, pglob) glob((pattern), (int)(flags), (errfunc), (pglob)) #endif prog/skalibs-0.47/src/headers/error-footer0100644000000000000000000000001007773701576015516 0ustar #endif prog/skalibs-0.47/src/headers/shglob.h10100644000000000000000000000046107663560170014657 0ustar /* Public domain. */ #ifndef SHGLOB_H #define SHGLOB_H #include #define GLOB_NOMATCH (-3) #define GLOB_NOESCAPE GLOB_QUOTE #define shglob(pattern, flags, errfunc, pglob) glob((pattern), (int)(((flags) & GLOB_QUOTE) ? (flags) & ~GLOB_QUOTE : (flags) | GLOB_QUOTE), (errfunc), (pglob)) #endif prog/skalibs-0.47/src/headers/gccattributes.h0100644000000000000000000000277507663560170016175 0ustar /* Public domain. */ #ifndef GCCATTRIBUTES_H #define GCCATTRIBUTES_H #ifdef __GNUC__ #define gccattr_noreturn __attribute__((__noreturn__)) #define gccattr_noinline __attribute__((__noinline__)) #define gccattr_inline __attribute__((__always_inline__)) #define gccattr_const __attribute__((__const__)) #define gccattr_unused __attribute__((__unused__)) #define gccattr_used __attribute__((__used__)) #define gccattr_weak __attribute__((__weak__)) #define gccattr_aligned __attribute__((__aligned__)) # if (__GNUC__ >= 3) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 96)) #define gccattr_malloc __attribute__((__malloc__)) #define gccattr_pure __attribute__((__pure__)) # else #define gccattr_malloc #define gccattr_pure # endif # if (__GNUC__ >= 3) #define gccattr_deprecated __attribute__((__deprecated__)) # else #define gccattr_deprecated # endif #else #define gccattr_noreturn #define gccattr_noinline #define gccattr_inline #define gccattr_const #define gccattr_unused #define gccattr_used #define gccattr_weak #define gccattr_aligned #define gccattr_malloc #define gccattr_pure #define gccattr_deprecated #endif #ifdef GCCATTR_COMPAT_0_22 #define _a_noreturn gccattr_noreturn #define _a_noinline gccattr_noinline #define _a_inline gccattr_inline #define _a_const gccattr_const #define _a_unused gccattr_unused #define _a_used gccattr_used #define _a_weak gccattr_weak #define _a_aligned gccattr_aligned #define _a_malloc gccattr_malloc #define _a_pure gccattr_pure #define _a_deprecated gccattr_deprecated #endif #endif prog/skalibs-0.47/src/headers/uint64-footer0100644000000000000000000000342110004025530015471 0ustar extern void uint64_pack (char *, uint64) ; extern void uint64_pack_big (char *, uint64) ; extern void uint64_unpack (char const *, uint64 *) ; extern void uint64_unpack_big (char const *, uint64 *) ; extern void uint64_reverse (char *, unsigned int) ; #define UINT64_FMT 21 #define UINT64_OFMT 25 #define UINT64_XFMT 17 #define UINT64_BFMT 65 extern unsigned int uint64_fmt_base (char *, uint64, unsigned char) ; extern unsigned int uint640_fmt_base (char *, uint64, unsigned int, unsigned char) ; #define uint64_fmt(s, u) uint64_fmt_base((s), (u), 10) #define uint640_fmt(s, u, n) uint640_fmt_base((s), (u), (n), 10) #define uint64_ofmt(s, u) uint64_fmt_base((s), (u), 8) #define uint640_ofmt(s, u, n) uint640_fmt_base((s), (u), (n), 8) #define uint64_xfmt(s, u) uint64_fmt_base((s), (u), 16) #define uint640_xfmt(s, u, n) uint640_fmt_base((s), (u), (n), 16) #define uint64_bfmt(s, u) uint64_fmt_base((s), (u), 2) #define uint640_bfmt(s, u, n) uint640_fmt_base((s), (u), (n), 2) extern unsigned int uint64_scan_upto_base (char const *, uint64 *, uint64, unsigned char) ; extern unsigned int uint640_scan_upto_base (char const *, uint64 *, uint64, unsigned char) ; #define uint64_scan_base(s, u, b) uint64_scan_upto_base((s), (u), ~(uint64)0, (b)) #define uint640_scan_base(s, u, b) uint640_scan_upto_base((s), (u), ~(uint64)0, (b)) #define uint64_scan(s, u) uint64_scan_base((s), (u), 10) #define uint640_scan(s, u) uint640_scan_base((s), (u), 10) #define uint64_oscan(s, u) uint64_scan_base((s), (u), 8) #define uint640_oscan(s, u) uint640_scan_base((s), (u), 8) #define uint64_xscan(s, u) uint64_scan_base((s), (u), 16) #define uint640_xscan(s, u) uint640_scan_base((s), (u), 16) #define uint64_bscan(s, u) uint64_scan_base((s), (u), 2) #define uint640_bscan(s, u) uint640_scan_base((s), (u), 2) #endif prog/skalibs-0.47/src/headers/direntry-footer0100644000000000000000000000005007772654350016225 0ustar extern int dir_close (DIR *) ; #endif prog/skalibs-0.47/src/headers/direntry-header0100644000000000000000000000007507772654234016167 0ustar /* Public domain. */ #ifndef DIRENTRY_H #define DIRENTRY_H prog/skalibs-0.47/src/headers/error-proto0100644000000000000000000000010207773704500015353 0ustar /* Did I ever tell you that BSD sucks ? */ #define EPROTO EINVAL prog/skalibs-0.47/src/headers/syssocket-header0100644000000000000000000000007710022112072016323 0ustar /* Public domain. */ #ifndef SYSSOCKET_H #define SYSSOCKET_H prog/skalibs-0.47/src/headers/uint64-header0100644000000000000000000000007107721706566015454 0ustar /* Public domain. */ #ifndef UINT64_H #define UINT64_H prog/skalibs-0.47/src/headers/uint16-inttypesh0100644000000000000000000000006107724242425016237 0ustar #include typedef uint16_t uint16 ; prog/skalibs-0.47/src/headers/uint64-ulong640100644000000000000000000000004007724240075015505 0ustar typedef unsigned long uint64 ; prog/skalibs-0.47/src/headers/uint16-lendian0100644000000000000000000000013507724242362015624 0ustar #define uint16_little_endian(s, n) #define uint16_big_endian(s, n) uint16_reverse((s), (n)) prog/skalibs-0.47/src/headers/uint16-stdinth0100644000000000000000000000005707724242465015676 0ustar #include typedef uint16_t uint16 ; prog/skalibs-0.47/src/headers/uint64-lendian0100644000000000000000000000013507724240067015627 0ustar #define uint64_little_endian(s, n) #define uint64_big_endian(s, n) uint64_reverse((s), (n)) prog/skalibs-0.47/src/headers/uint64-noulong640100644000000000000000000000004507724240102016036 0ustar typedef unsigned long long uint64 ; prog/skalibs-0.47/src/headers/uint64-bendian0100644000000000000000000000013507724240134015610 0ustar #define uint64_little_endian(s, n) uint64_reverse((s), (n)) #define uint64_big_endian(s, n) prog/skalibs-0.47/src/headers/error-already0100644000000000000000000000010707773702700015636 0ustar #define error_isalready(e) (((e) == EALREADY) || ((e) == EINPROGRESS)) prog/skalibs-0.47/src/headers/uint16-default0100644000000000000000000000004107724242670015634 0ustar typedef unsigned short uint16 ; prog/skalibs-0.47/src/headers/uint32-lendian0100644000000000000000000000013507724247273015630 0ustar #define uint32_little_endian(s, n) #define uint32_big_endian(s, n) uint32_reverse((s), (n)) prog/skalibs-0.47/src/headers/uint32-ulong320100644000000000000000000000004007724247240015474 0ustar typedef unsigned long uint32 ; prog/skalibs-0.47/src/headers/uint32-noulong320100644000000000000000000000003707724247177016050 0ustar typedef unsigned int uint32 ; prog/skalibs-0.47/src/headers/uint32-bendian0100644000000000000000000000013507724247330015610 0ustar #define uint32_little_endian(s, n) uint32_reverse((s), (n)) #define uint32_big_endian(s, n) prog/skalibs-0.47/src/headers/syssocket.h20100644000000000000000000000003010022110611015367 0ustar #include prog/skalibs-0.47/src/headers/uint32-stdinth0100644000000000000000000000005707724247421015671 0ustar #include typedef uint32_t uint32 ; prog/skalibs-0.47/src/headers/skalibs-version.h.stupid0100644000000000000000000000017710005430427017727 0ustar /* Public domain. */ #ifndef SKALIBS_VERSION_H #define SKALIBS_VERSION_H #define SKALIBS_VERSION "$PACKAGE_VERSION" #endif prog/skalibs-0.47/src/headers/syssocket-footer0100644000000000000000000000001010022112053016353 0ustar #endif prog/skalibs-0.47/src/libbiguint/0040755000000000000000000000000010324527361013657 5ustar prog/skalibs-0.47/src/libbiguint/Makefile0100644000000000000000000000457407663560170015335 0ustar it: command include library library.so clean: EXPORT INTERNAL rm -f `cat EXPORT INTERNAL` biguint.h: uint32.h gccattributes.h touch biguint.h bu_addc.o: compile bu_addc.c biguint.h uint32.h uint64.h ./compile bu_addc.c bu_addmod.o: compile bu_addmod.c biguint.h uint32.h ./compile bu_addmod.c bu_cmp.o: compile bu_cmp.c biguint.h uint32.h ./compile bu_cmp.c bu_copy.o: compile bu_copy.c biguint.h uint32.h ./compile bu_copy.c bu_div.o: compile bu_div.c biguint.h uint32.h ./compile bu_div.c bu_div_unsafe.o: compile bu_div_unsafe.c biguint.h uint32.h ./compile bu_div_unsafe.c bu_invmod.o: compile bu_invmod.c biguint.h uint32.h ./compile bu_invmod.c bu_divmod.o: compile bu_divmod.c biguint.h uint32.h ./compile bu_divmod.c bu_len.o: compile bu_len.c biguint.h uint32.h ./compile bu_len.c bu_mod.o: compile bu_mod.c biguint.h uint32.h ./compile bu_mod.c bu_mul.o: compile bu_mul.c biguint.h uint32.h uint64.h ./compile bu_mul.c bu_pack.o: compile bu_pack.c biguint.h uint32.h ./compile bu_pack.c bu_pack_big.o: compile bu_pack_big.c biguint.h uint32.h ./compile bu_pack_big.c bu_slbc.o: compile bu_slbc.c biguint.h uint32.h ./compile bu_slbc.c bu_srbc.o: compile bu_srbc.c biguint.h uint32.h ./compile bu_srbc.c bu_subc.o: compile bu_subc.c biguint.h uint32.h uint64.h ./compile bu_subc.c bu_submod.o: compile bu_submod.c biguint.h uint32.h ./compile bu_submod.c bu_unpack.o: compile bu_unpack.c biguint.h uint32.h ./compile bu_unpack.c bu_unpack_big.o: compile bu_unpack_big.c biguint.h uint32.h ./compile bu_unpack_big.c bu_zero.o: compile bu_zero.c biguint.h uint32.h ./compile bu_zero.c bu_fmt.o: compile bu_fmt.c biguint.h uint32.h fmtscan.h bytestr.h ./compile bu_fmt.c bu_scan.o: compile bu_scan.c biguint.h uint32.h fmtscan.h bytestr.h ./compile bu_scan.c libbiguint.a: makelib \ bu_addc.o bu_addmod.o bu_cmp.o bu_copy.o bu_div.o bu_div_unsafe.o \ bu_invmod.o bu_divmod.o bu_len.o bu_mod.o bu_mul.o bu_pack.o \ bu_pack_big.o bu_slbc.o bu_srbc.o bu_subc.o bu_submod.o \ bu_unpack.o bu_unpack_big.o bu_zero.o bu_fmt.o bu_scan.o ./makelib libbiguint.a \ bu_addc.o bu_addmod.o bu_cmp.o bu_copy.o bu_div.o bu_div_unsafe.o \ bu_invmod.o bu_divmod.o bu_len.o bu_mod.o bu_mul.o bu_pack.o \ bu_pack_big.o bu_slbc.o bu_srbc.o bu_subc.o bu_submod.o \ bu_unpack.o bu_unpack_big.o bu_zero.o bu_fmt.o bu_scan.o command: include: biguint.h library: libbiguint.a library.so: prog/skalibs-0.47/src/libbiguint/INCLUDE0100644000000000000000000000001207663560170014662 0ustar biguint.h prog/skalibs-0.47/src/libbiguint/EXPORT0100644000000000000000000000001507663560170014623 0ustar libbiguint.a prog/skalibs-0.47/src/libbiguint/INTERNAL0100644000000000000000000000036007663560170015021 0ustar bu_addc.o bu_addmod.o bu_cmp.o bu_copy.o bu_div.o bu_divmod.o bu_div_unsafe.o bu_fmt.o bu_invmod.o bu_len.o bu_mod.o bu_mul.o bu_pack.o bu_pack_big.o bu_scan.o bu_slbc.o bu_srbc.o bu_subc.o bu_submod.o bu_unpack.o bu_unpack_big.o bu_zero.o prog/skalibs-0.47/src/libbiguint/biguint.h0100644000000000000000000000362011100046402015450 0ustar /* Public domain. */ #ifndef BIGUINT_H #define BIGUINT_H #include "gccattributes.h" #include "uint32.h" #define BIGUINT_MAXLIMBS 64 #define FMT_BIGUINT ((BIGUINT_MAXLIMBS<<3) + 1) extern void bu_pack (char *, uint32 const *, unsigned int) ; extern void bu_unpack (char const *, uint32 *, unsigned int) ; extern void bu_pack_big (char *, uint32 const *, unsigned int) ; extern void bu_unpack_big (char const *, uint32 *, unsigned int) ; extern unsigned int bu_fmt (char *, uint32 const *, unsigned int) ; extern void bu_zero (uint32 *, unsigned int) ; extern void bu_copy (uint32 *, uint32 const *, unsigned int) ; extern unsigned int bu_len (uint32 const *, unsigned int) gccattr_pure ; extern int bu_cmp (uint32 const *, uint32 const *, unsigned int) gccattr_pure ; #define bu_add(c, a, b, n) bu_addc(c, a, b, n, 0) extern unsigned char bu_addc (uint32 *, uint32 const *, uint32 const *, unsigned int, unsigned char) ; #define bu_sub(c, a, b, n) bu_subc(c, a, b, n, 0) extern unsigned char bu_subc (uint32 *, uint32 const *, uint32 const *, unsigned int, unsigned char) ; extern void bu_mul (uint32 *, uint32 const *, unsigned int, uint32 const *, unsigned int) ; extern void bu_div (uint32 const *, uint32 const *, uint32 *, uint32 *, unsigned int) ; extern void bu_div_unsafe (uint32 const *, uint32 const *, uint32 *, uint32 *, unsigned int) ; #define bu_slb(a, n) bu_slbc(a, n, 0) extern unsigned char bu_slbc (uint32 *, unsigned int, unsigned char) ; #define bu_srb(a, n) bu_srbc(a, n, 0) extern unsigned char bu_srbc (uint32 *, unsigned int, unsigned char) ; extern void bu_addmod (uint32 *, uint32 const *, uint32 const *, uint32 const *, unsigned int) ; extern void bu_submod (uint32 *, uint32 const *, uint32 const *, uint32 const *, unsigned int) ; extern int bu_invmod (uint32 *, uint32 const *, unsigned int) ; extern int bu_divmod (uint32 *, uint32 const *, uint32 const *, uint32 const *, unsigned int) ; #endif prog/skalibs-0.47/src/libbiguint/bu_len.c0100644000000000000000000000027607663560170015300 0ustar /* Public domain. */ #include "uint32.h" #include "biguint.h" unsigned int bu_len (register uint32 const *a, register unsigned int n) { while (n--) if (a[n]) return n+1 ; return 0 ; } prog/skalibs-0.47/src/libbiguint/bu_mul.c0100644000000000000000000000125107663560170015311 0ustar /* Public domain. */ #include "uint32.h" #include "uint64.h" #include "biguint.h" void bu_mul (uint32 *x, uint32 const *a, unsigned int an, uint32 const *b, unsigned int bn) { uint32 c[BIGUINT_MAXLIMBS] ; unsigned int alen = bu_len(a, an) ; unsigned int blen = bu_len(b, bn) ; register unsigned int i = 0 ; bu_zero(c, an+bn) ; for (; i < alen ; i++) { register unsigned int j = 0 ; register uint32 carry = 0 ; for (; j < blen ; j++) { register uint64 t = a[i] ; t *= b[j] ; t += c[i+j] ; t += carry ; c[i+j] = (uint32)t ; carry = (uint32)(t >> 32) ; } c[i + blen] = carry ; } bu_copy(x, c, an+bn) ; } prog/skalibs-0.47/src/libbiguint/bu_div.c0100644000000000000000000000070110324527357015273 0ustar /* Public domain. */ #include "uint32.h" #include "biguint.h" void bu_div (uint32 const *a, uint32 const *b, uint32 *q, uint32 *r, unsigned int n) { register unsigned int blen = bu_len(b, n) ; if (!blen) { q[0] = 1/0 ; return ; } else if ((blen == 1) && (b[0] == 1)) { bu_copy(q, a, n) ; bu_zero(r, n) ; } else if (bu_cmp(a, b, n) < 0) { bu_zero(q, n) ; bu_copy(r, a, n) ; } else bu_div_unsafe(a, b, q, r, n) ; } prog/skalibs-0.47/src/libbiguint/bu_cmp.c0100644000000000000000000000040107663560170015267 0ustar /* Public domain. */ #include "uint32.h" #include "biguint.h" int bu_cmp (register uint32 const *a, register uint32 const *b, register unsigned int n) { while (n--) { if (a[n] < b[n]) return -1 ; if (a[n] > b[n]) return 1 ; } return 0 ; } prog/skalibs-0.47/src/libbiguint/bu_srbc.c0100644000000000000000000000047507663560170015454 0ustar /* Public domain. */ #include "uint32.h" #include "biguint.h" unsigned char bu_srbc (register uint32 *a, register unsigned int n, register unsigned char carry) { while (n--) { register unsigned char c = a[n] & 1 ; a[n] = (a[n] >> 1) | (carry ? 0x80000000UL : 0) ; carry = c ; } return carry ; } prog/skalibs-0.47/src/libbiguint/bu_fmt.c0100644000000000000000000000056010016647104015271 0ustar /* Public domain. */ #include "uint32.h" #include "bytestr.h" #include "biguint.h" unsigned int bu_fmt (char *s, uint32 const *x, unsigned int n) { unsigned int len = 0 ; while (n--) { char fmt[8] ; unsigned int i = uint32_xfmt(fmt, x[n]) ; byte_copy(s+len, 8-i, "00000000") ; byte_copy(s+len+8-i, i, fmt) ; len += 8 ; } return len ; } prog/skalibs-0.47/src/libbiguint/bu_mod.c0100644000000000000000000000032107663560170015270 0ustar /* Public domain. */ #include "uint32.h" #include "biguint.h" void bu_mod (register uint32 *a, register uint32 const *b, register unsigned int n) { uint32 q[BIGUINT_MAXLIMBS] ; bu_div(a, b, q, a, n) ; } prog/skalibs-0.47/src/libbiguint/bu_unpack_big.c0100644000000000000000000000034707663560170016623 0ustar /* Public domain. */ #include "uint32.h" #include "biguint.h" void bu_unpack_big (char const *s, uint32 *a, unsigned int n) { register unsigned int i = 0 ; for (; i < n ; i++) uint32_unpack_big(s + (i<<2), a + n - 1 - i) ; } prog/skalibs-0.47/src/libbiguint/bu_addc.c0100644000000000000000000000112607663560170015410 0ustar /* Public domain. */ #include "uint32.h" #include "uint64.h" #include "biguint.h" static inline unsigned char uint32_addc (register uint32 *c, register uint32 a, register uint32 b, register unsigned char carry) { register uint64 t = a ; t += b ; if (carry) t++ ; *c = (uint32)t ; return (t > 0xffffffffUL) ; } unsigned char bu_addc (register uint32 *c, register uint32 const *a, register uint32 const *b, register unsigned int n, register unsigned char carry) { register unsigned int i = 0 ; for (; i < n ; i++) carry = uint32_addc(c+i, a[i], b[i], carry) ; return carry ; } prog/skalibs-0.47/src/libbiguint/bu_div_unsafe.c0100644000000000000000000000175310016646325016637 0ustar /* Public domain. */ #include "uint32.h" #include "biguint.h" void bu_div_unsafe (uint32 const *a, uint32 const *b, uint32 *q, uint32 *r, unsigned int n) { uint32 btmp[BIGUINT_MAXLIMBS] ; unsigned int alen = bu_len(a, n) ; unsigned int blen = bu_len(b, n) ; unsigned int i = alen - blen ; unsigned char bshift = 0 ; bu_copy(r, a, n) ; bu_zero(btmp, i) ; bu_copy(btmp + i, b, blen) ; bu_zero(btmp + alen, BIGUINT_MAXLIMBS - alen) ; while (!(btmp[alen-1] & 0x80000000UL)) { bu_slb(btmp, alen) ; bshift++ ; } i++ ; while (i--) { unsigned int j = 0 ; q[i] = 0 ; for (; j < 32 ; j++) { q[i] <<= 1 ; if (bu_cmp(r, btmp, blen + i) >= 0) { bu_sub(r, r, btmp, blen + i) ; q[i] |= 1 ; } bu_srb(btmp, blen + i) ; } } while (bshift--) { bu_slb(q, alen - blen + 1) ; if (bu_cmp(r, btmp, blen) >= 0) { bu_sub(r, r, btmp, blen) ; q[0] |= 1 ; } bu_srb(btmp, blen) ; } } prog/skalibs-0.47/src/libbiguint/bu_subc.c0100644000000000000000000000115710016646751015451 0ustar /* Public domain. */ #include "uint32.h" #include "uint64.h" #include "biguint.h" static inline unsigned char uint32_subc (register uint32 *c, register uint32 a, register uint32 b, register unsigned char carry) { register uint64 t = 1 ; t <<= 32 ; t += a ; t -= b ; if (carry) t-- ; *c = (uint32)t ; return (t <= 0xffffffffUL) ; } unsigned char bu_subc (register uint32 *c, register uint32 const *a, register uint32 const *b, register unsigned int n, register unsigned char carry) { register unsigned int i = 0 ; for (; i < n ; i++) carry = uint32_subc(c+i, a[i], b[i], carry) ; return carry ; } prog/skalibs-0.47/src/libbiguint/bu_pack.c0100644000000000000000000000026307663560170015434 0ustar /* Public domain. */ #include "uint32.h" #include "biguint.h" void bu_pack (char *s, uint32 const *a, register unsigned int n) { while (n--) uint32_pack(s + (n<<2), a[n]) ; } prog/skalibs-0.47/src/libbiguint/bu_unpack.c0100644000000000000000000000027007663560170015775 0ustar /* Public domain. */ #include "uint32.h" #include "biguint.h" void bu_unpack (char const *s, uint32 *a, register unsigned int n) { while (n--) uint32_unpack(s + (n<<2), a + n) ; } prog/skalibs-0.47/src/libbiguint/bu_addmod.c0100644000000000000000000000035207663560170015745 0ustar /* Public domain. */ #include "uint32.h" #include "biguint.h" void bu_addmod (uint32 *c, uint32 const *a, uint32 const *b, uint32 const *m, unsigned int n) { bu_add(c, a, b, n) ; if (bu_cmp(c, m, n) >= 0) bu_sub(c, c, m, n) ; } prog/skalibs-0.47/src/libbiguint/bu_divmod.c0100644000000000000000000000214010321120714015751 0ustar /* Public domain. */ #include "uint32.h" #include "biguint.h" /* q = y/x mod m. m and x must be relatively prime. Otherwise, infinite loop. Original idea: see http://research.sun.com/techrep/2001/abstract-95.html */ int bu_divmod (uint32 *q, uint32 const *y, uint32 const *x, uint32 const *m, unsigned int n) { uint32 aa[BIGUINT_MAXLIMBS] ; uint32 bb[BIGUINT_MAXLIMBS] ; uint32 uu[BIGUINT_MAXLIMBS] ; uint32 vv[BIGUINT_MAXLIMBS] ; /* fixed */ register uint32 *a = aa, *b = bb, *u = uu, *v = vv ; /* may move around */ /* init: a=x, b=m, u=y, v=0 */ bu_copy(a, x, n) ; bu_copy(b, m, n) ; bu_copy(u, y, n) ; bu_zero(v, n) ; /*** XXX: this iterates like hell, should probably be optimized more */ for (;;) { while (!(a[0] & 1)) { bu_srb(a, n) ; if (u[0] & 1) bu_add(u, u, m, n) ; bu_srb(u, n) ; } if ((a[0] == 1) && (bu_len(a, n) == 1)) break ; if (bu_cmp(a, b, n) < 0) { register uint32 *t = a ; a = b ; b = t ; t = u ; u = v ; v = t ; } bu_add(a, a, b, n) ; bu_add(u, u, v, n) ; } bu_copy(q, u, n) ; return 1 ; } prog/skalibs-0.47/src/libbiguint/bu_copy.c0100644000000000000000000000026507663560170015472 0ustar /* Public domain. */ #include "uint32.h" #include "biguint.h" void bu_copy (register uint32 *b, register uint32 const *a, register unsigned int n) { while (n--) b[n] = a[n] ; } prog/skalibs-0.47/src/libbiguint/bu_zero.c0100644000000000000000000000023007663560170015467 0ustar /* Public domain. */ #include "uint32.h" #include "biguint.h" void bu_zero (register uint32 *z, register unsigned int n) { while (n--) z[n] = 0 ; } prog/skalibs-0.47/src/libbiguint/bu_invmod.c0100644000000000000000000000041507742574460016016 0ustar /* Public domain. */ #include "uint32.h" #include "biguint.h" /* x^-1 mod m. m must be prime. */ int bu_invmod (uint32 *x, uint32 const *m, unsigned int n) { uint32 one[BIGUINT_MAXLIMBS] ; bu_zero(one, n) ; one[0] = 1 ; return bu_divmod(x, one, x, m, n) ; } prog/skalibs-0.47/src/libbiguint/bu_scan.c0100644000000000000000000000112310022411453015414 0ustar /* Public domain. */ #include "uint32.h" #include "bytestr.h" #include "fmtscan.h" #include "biguint.h" unsigned int bu_scan (char const *s, uint32 *x, unsigned int *n) { char fmt[9] = "\0\0\0\0\0\0\0\0" ; unsigned int i = 0 ; unsigned int len = ucharn_findlen(s) ; if (!len) return 0 ; if (len > BIGUINT_MAXLIMBS << 3) len = BIGUINT_MAXLIMBS << 3 ; *n = len >> 3 ; if (len & 7) { byte_copy(fmt, len & 7, s) ; uint32_xscan(fmt, x + *n) ; } for (; i < *n ; i++) { byte_copy(fmt, 8, s + len - 8 - (i << 3)) ; uint32_xscan(fmt, x + i) ; } return len ; } prog/skalibs-0.47/src/libbiguint/bu_submod.c0100644000000000000000000000042307663560170016005 0ustar /* Public domain. */ #include "uint32.h" #include "biguint.h" void bu_submod (uint32 *c, uint32 const *a, uint32 const *b, uint32 const *m, unsigned int n) { if (bu_cmp(a, b, n) < 0) { bu_add(c, a, m, n) ; bu_sub(c, c, b, n) ; } else bu_sub(c, a, b, n) ; } prog/skalibs-0.47/src/libbiguint/bu_slbc.c0100644000000000000000000000054507663560170015444 0ustar /* Public domain. */ #include "uint32.h" #include "biguint.h" unsigned char bu_slbc (register uint32 *a, register unsigned int n, register unsigned char carry) { register unsigned int i = 0 ; for (; i < n ; i++) { register unsigned char c = (a[i] & 0x80000000UL) ? 1 : 0 ; a[i] = (a[i] << 1) | carry ; carry = c ; } return carry ; } prog/skalibs-0.47/src/libbiguint/bu_pack_big.c0100644000000000000000000000033607663560170016256 0ustar /* Public domain. */ #include "uint32.h" #include "biguint.h" void bu_pack_big (char *s, uint32 const *a, unsigned int n) { register unsigned int i = 0 ; for (; i < n ; i++) uint32_pack_big(s + (i<<2), a[n-1-i]) ; } prog/skalibs-0.47/src/libttymodes/0040755000000000000000000000000007772665326014107 5ustar prog/skalibs-0.47/src/libttymodes/EXPORT0100644000000000000000000000001607663560170015033 0ustar libttymodes.a prog/skalibs-0.47/src/libttymodes/INCLUDE0100644000000000000000000000001307663560170015072 0ustar ttymodes.h prog/skalibs-0.47/src/libttymodes/INTERNAL0100644000000000000000000000034607663560170015234 0ustar ttymodes_packt.o ttymodes_packw.o ttymodes_pack.o ttymodes_unpackt.o ttymodes_unpackw.o ttymodes_unpack.o ttymodes_gett.o ttymodes_getw.o ttymodes_get.o ttymodes_sett.o ttymodes_sett_nohang.o ttymodes_setw.o ttymodes_set_nohang.o prog/skalibs-0.47/src/libttymodes/Makefile0100644000000000000000000000505407772665321015543 0ustar it: command include library library.so clean: EXPORT INTERNAL rm -f `cat EXPORT INTERNAL` ttymodes_packt.o: compile ttymodes_packt.c ttymodes.h uint32.h uint64.h ./compile ttymodes_packt.c ttymodes_packw.o: compile ttymodes_packw.c ttymodes.h uint16.h ./compile ttymodes_packw.c ttymodes_pack.o: compile ttymodes_pack.c ttymodes.h ./compile ttymodes_pack.c ttymodes_unpackt.o: compile ttymodes_unpackt.c ttymodes.h uint32.h uint64.h ./compile ttymodes_unpackt.c ttymodes_unpackw.o: compile ttymodes_unpackw.c ttymodes.h uint16.h ./compile ttymodes_unpackw.c ttymodes_unpack.o: compile ttymodes_unpack.c ttymodes.h ./compile ttymodes_unpack.c ttymodes_gett.o: compile ttymodes_gett.c ttymodes.h ./compile ttymodes_gett.c ttymodes_getw.o: compile ttymodes_getw.c ttymodes.h sysdeps.h ./compile ttymodes_getw.c ttymodes_get.o: compile ttymodes_get.c ttymodes.h ./compile ttymodes_get.c ttymodes_sett.o: compile ttymodes_sett.c ttymodes.h ./compile ttymodes_sett.c ttymodes_sett_nohang.o: compile ttymodes_sett_nohang.c ttymodes.h ./compile ttymodes_sett_nohang.c ttymodes_setw.o: compile ttymodes_setw.c ttymodes.h sysdeps.h ./compile ttymodes_setw.c ttymodes_set.o: compile ttymodes_set.c ttymodes.h ./compile ttymodes_set.c ttymodes_set_nohang.o: compile ttymodes_set_nohang.c ttymodes.h ./compile ttymodes_set_nohang.c ttymodes_raw.o: compile ttymodes_raw.c ttymodes.h ./compile ttymodes_raw.c ttymodes_sane.o: compile ttymodes_sane.c ttymodes.h bytestr.h ./compile ttymodes_sane.c ttymodes_remote.o: compile ttymodes_remote.c ttymodes.h sysdeps.h ./compile ttymodes_remote.c ttymodes_echo_off.o: compile ttymodes_echo_off.c ttymodes.h ./compile ttymodes_echo_off.c ttymodes_echo_on.o: compile ttymodes_echo_on.c ttymodes.h ./compile ttymodes_echo_on.c libttymodes.a: makelib \ ttymodes_packt.o ttymodes_packw.o ttymodes_pack.o \ ttymodes_unpackt.o ttymodes_unpackw.o ttymodes_unpack.o \ ttymodes_gett.o ttymodes_getw.o ttymodes_get.o \ ttymodes_sett.o ttymodes_sett_nohang.o ttymodes_setw.o ttymodes_set.o ttymodes_set_nohang.o \ ttymodes_raw.o ttymodes_sane.o ttymodes_remote.o ttymodes_echo_off.o ttymodes_echo_on.o ./makelib libttymodes.a \ ttymodes_packt.o ttymodes_packw.o ttymodes_pack.o \ ttymodes_unpackt.o ttymodes_unpackw.o ttymodes_unpack.o \ ttymodes_gett.o ttymodes_getw.o ttymodes_get.o \ ttymodes_sett.o ttymodes_sett_nohang.o ttymodes_setw.o ttymodes_set.o ttymodes_set_nohang.o \ ttymodes_raw.o ttymodes_sane.o ttymodes_remote.o ttymodes_echo_off.o ttymodes_echo_on.o command: include: ttymodes.h library: libttymodes.a library.so: prog/skalibs-0.47/src/libttymodes/ttymodes_gett.c0100644000000000000000000000036207772665264017145 0ustar /* Public domain */ #include #include #include "ttymodes.h" int ttymodes_gett (int fd, ttymodes_ref t) { register int r ; do r = tcgetattr(fd, &t->ti) ; while ((r == -1) && (errno == EINTR)) ; return r ; } prog/skalibs-0.47/src/libttymodes/ttymodes_setw.c0100644000000000000000000000055407772665244017165 0ustar /* Public domain. */ #include #include "sysdeps.h" #ifdef HASSTREAMS #include #endif #include #include #include #include "ttymodes.h" int ttymodes_setw (int fd, ttymodes const *t) { register int r ; do r = ioctl(fd, TIOCSWINSZ, &t->ws) ; while ((r == -1) && (errno == EINTR)) ; return r ; } prog/skalibs-0.47/src/libttymodes/ttymodes.h0100644000000000000000000000247007663560170016116 0ustar /* Public domain. */ #ifndef TTYMODES_H #define TTYMODES_H #include #include #define TERMIOS_PACK (36+8*NCCS) #define WINSIZE_PACK 8 #define TTYMODES_PACK (TERMIOS_PACK+WINSIZE_PACK) typedef struct ttymodes ttymodes, *ttymodes_ref ; struct ttymodes { struct winsize ws ; struct termios ti ; } ; extern void ttymodes_packw (char *, ttymodes const *) ; extern void ttymodes_packt (char *, ttymodes const *) ; extern void ttymodes_pack (char *, ttymodes const *) ; extern void ttymodes_unpackw (char const *, ttymodes_ref) ; extern unsigned int ttymodes_unpackt (char const *, ttymodes_ref) ; extern unsigned int ttymodes_unpack (char const *, ttymodes_ref) ; extern int ttymodes_gett (int, ttymodes_ref) ; extern int ttymodes_getw (int, ttymodes_ref) ; extern int ttymodes_get (int, ttymodes_ref) ; extern int ttymodes_sett (int, ttymodes const *) ; extern int ttymodes_sett_nohang (int, ttymodes const *) ; extern int ttymodes_setw (int, ttymodes const *) ; extern int ttymodes_set (int, ttymodes const *) ; extern int ttymodes_set_nohang (int, ttymodes const *) ; extern void ttymodes_raw (ttymodes_ref) ; extern void ttymodes_sane (ttymodes_ref) ; extern int ttymodes_remote (int, ttymodes_ref) ; extern void ttymodes_echo_off (ttymodes_ref) ; extern void ttymodes_echo_on (ttymodes_ref) ; #endif prog/skalibs-0.47/src/libttymodes/ttymodes_getw.c0100644000000000000000000000055107772665254017147 0ustar /* Public domain. */ #include #include "sysdeps.h" #ifdef HASSTREAMS #include #endif #include #include #include #include "ttymodes.h" int ttymodes_getw (int fd, ttymodes_ref t) { register int r ; do r = ioctl(fd, TIOCGWINSZ, &t->ws) ; while ((r == -1) && (errno == EINTR)) ; return r ; } prog/skalibs-0.47/src/libttymodes/ttymodes_pack.c0100644000000000000000000000024207663560170017102 0ustar /* Public domain. */ #include "ttymodes.h" void ttymodes_pack (char *s, ttymodes const *t) { ttymodes_packw(s, t) ; ttymodes_packt(s + WINSIZE_PACK, t) ; } prog/skalibs-0.47/src/libttymodes/ttymodes_get.c0100644000000000000000000000025107663560170016743 0ustar /* Public domain. */ #include "ttymodes.h" int ttymodes_get (int fd, ttymodes_ref t) { if (ttymodes_gett(fd, t) == -1) return -1 ; return ttymodes_getw(fd, t) ; } prog/skalibs-0.47/src/libttymodes/ttymodes_packw.c0100644000000000000000000000050107663560170017267 0ustar /* Public domain. */ #include "uint16.h" #include "ttymodes.h" void ttymodes_packw (char *s, ttymodes const *t) { uint16_pack(s, (uint16)t->ws.ws_row) ; s += 2 ; uint16_pack(s, (uint16)t->ws.ws_col) ; s += 2 ; uint16_pack(s, (uint16)t->ws.ws_xpixel) ; s += 2 ; uint16_pack(s, (uint16)t->ws.ws_ypixel) ; } prog/skalibs-0.47/src/libttymodes/ttymodes_unpackw.c0100644000000000000000000000054707663560170017644 0ustar /* Public domain. */ #include "uint16.h" #include "ttymodes.h" void ttymodes_unpackw (char const *s, ttymodes_ref t) { uint16 u ; uint16_unpack(s, &u) ; t->ws.ws_row = u ; s += 2 ; uint16_unpack(s, &u) ; t->ws.ws_col = u ; s += 2 ; uint16_unpack(s, &u) ; t->ws.ws_xpixel = u ; s += 2 ; uint16_unpack(s, &u) ; t->ws.ws_ypixel = u ; } prog/skalibs-0.47/src/libttymodes/ttymodes_raw.c0100644000000000000000000000075607663560170016767 0ustar /* Public domain. */ #include #include #include "ttymodes.h" void ttymodes_raw (ttymodes_ref t) { t->ti.c_iflag &= ~(BRKINT | IGNBRK | IGNPAR | PARMRK) ; t->ti.c_iflag &= ~(ISTRIP | IXON | IXOFF | ICRNL | INLCR | IGNCR | IMAXBEL) ; t->ti.c_oflag &= ~OPOST ; t->ti.c_lflag &= ~(ECHO | ECHONL) ; t->ti.c_lflag &= ~(ICANON | ISIG | IEXTEN) ; t->ti.c_cflag &= ~(CSIZE | PARENB) ; t->ti.c_cflag |= CS8 ; t->ti.c_cc[VMIN] = 1 ; t->ti.c_cc[VTIME] = 0 ; } prog/skalibs-0.47/src/libttymodes/ttymodes_unpack.c0100644000000000000000000000036507663560170017453 0ustar /* Public domain. */ #include "ttymodes.h" unsigned int ttymodes_unpack (char const *s, ttymodes_ref t) { unsigned int n = ttymodes_unpackt(s + WINSIZE_PACK, t) ; if (!n) return 0 ; ttymodes_unpackw(s, t) ; return WINSIZE_PACK + n ; } prog/skalibs-0.47/src/libttymodes/ttymodes_unpackt.c0100644000000000000000000000125007663560170017631 0ustar /* Public domain. */ #include #include "uint32.h" #include "uint64.h" #include "ttymodes.h" unsigned int ttymodes_unpackt (char const *s, ttymodes_ref t) { uint32 nccs ; uint64 blah ; unsigned int i ; uint32_unpack(s, &nccs) ; if (nccs > NCCS) return 0 ; s += 4 ; uint64_unpack(s, &blah) ; t->ti.c_iflag = blah ; s += 8 ; uint64_unpack(s, &blah) ; t->ti.c_oflag = blah ; s += 8 ; uint64_unpack(s, &blah) ; t->ti.c_cflag = blah ; s += 8 ; uint64_unpack(s, &blah) ; t->ti.c_lflag = blah ; s += 8 ; for (i = 0 ; i < NCCS ; i++) { uint64_unpack(s, &blah) ; t->ti.c_cc[i] = blah ; s += 8 ; } return 36 + 8*nccs ; } prog/skalibs-0.47/src/libttymodes/ttymodes_echo_off.c0100644000000000000000000000024407663560170017736 0ustar /* Public domain. */ #include #include "ttymodes.h" void ttymodes_echo_off (ttymodes_ref t) { t->ti.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL) ; } prog/skalibs-0.47/src/libttymodes/ttymodes_packt.c0100644000000000000000000000101207663560170017262 0ustar /* Public domain. */ #include #include "uint32.h" #include "uint64.h" #include "ttymodes.h" void ttymodes_packt (char *s, ttymodes const *t) { unsigned int i ; uint32_pack(s, (uint32)NCCS) ; s += 4 ; uint64_pack(s, (uint64)t->ti.c_iflag) ; s += 8 ; uint64_pack(s, (uint64)t->ti.c_oflag) ; s += 8 ; uint64_pack(s, (uint64)t->ti.c_cflag) ; s += 8 ; uint64_pack(s, (uint64)t->ti.c_lflag) ; s += 8 ; for (i = 0 ; i < NCCS ; i++) { uint64_pack(s, t->ti.c_cc[i]) ; s += 8 ; } } prog/skalibs-0.47/src/libttymodes/ttymodes_set.c0100644000000000000000000000025407663560170016762 0ustar /* Public domain. */ #include "ttymodes.h" int ttymodes_set (int fd, ttymodes const *t) { if (ttymodes_sett(fd, t) == -1) return -1 ; return ttymodes_setw(fd, t) ; } prog/skalibs-0.47/src/libttymodes/ttymodes_sett.c0100644000000000000000000000030007663560170017136 0ustar /* Public domain. */ #include #include "ttymodes.h" int ttymodes_sett (int fd, ttymodes const *t) { if (ttymodes_sett_nohang(fd, t) == -1) return -1 ; return tcdrain(fd) ; } prog/skalibs-0.47/src/libttymodes/ttymodes_sane.c0100644000000000000000000000227007663560170017115 0ustar /* Public domain. */ #include #include #include #include "bytestr.h" #include "ttymodes.h" void ttymodes_sane (ttymodes_ref t) { unsigned int i ; byte_zero((char *)t, sizeof(ttymodes)) ; for (i = 0; i < sizeof(t->ti.c_cc) / sizeof(*t->ti.c_cc) ; i++) t->ti.c_cc[i] = _POSIX_VDISABLE ; t->ti.c_iflag = BRKINT | IGNBRK | ICRNL | IXON | IMAXBEL ; t->ti.c_oflag = OPOST | ONLCR ; t->ti.c_lflag = ISIG | ICANON | IEXTEN | ECHO | ECHOE | ECHOKE | ECHOCTL ; t->ti.c_cflag = CS8 | CREAD | HUPCL ; cfsetispeed(&t->ti, B38400) ; cfsetospeed(&t->ti, B38400) ; t->ti.c_cc[VMIN] = 1 ; t->ti.c_cc[VTIME] = 0 ; t->ti.c_cc[VINTR] = 3 ; t->ti.c_cc[VQUIT] = 28 ; t->ti.c_cc[VERASE] = 127 ; t->ti.c_cc[VKILL] = 21 ; t->ti.c_cc[VEOF] = 4 ; t->ti.c_cc[VSTART] = 17 ; t->ti.c_cc[VSTOP] = 19 ; #ifdef VSUSP t->ti.c_cc[VSUSP] = 26 ; #endif #ifdef VDSUSP t->ti.c_cc[VDSUSP] = 25 ; #endif #ifdef VREPRINT t->ti.c_cc[VREPRINT] = 18 ; #endif #ifdef VDISCARD t->ti.c_cc[VDISCARD] = 15 ; #endif #ifdef VWERASE t->ti.c_cc[VWERASE] = 23 ; #endif #ifdef VLNEXT t->ti.c_cc[VLNEXT] = 22 ; #endif #ifdef VSTATUS t->ti.c_cc[VSTATUS] = 20 ; #endif } prog/skalibs-0.47/src/libttymodes/ttymodes_remote.c0100644000000000000000000000060007663560170017455 0ustar /* Public domain. */ #include #include "sysdeps.h" #ifdef HASSTREAMS #include #endif #include #include #include "ttymodes.h" int ttymodes_remote (int fd, ttymodes_ref t) { #ifdef HASTIOCREMOTE { int on = 1 ; if (ioctl(fd, TIOCREMOTE, &on) == -1) return -1 ; } #else (void)fd ; #endif ttymodes_raw(t) ; return 0 ; } prog/skalibs-0.47/src/libttymodes/ttymodes_echo_on.c0100644000000000000000000000022707663560170017601 0ustar /* Public domain. */ #include #include "ttymodes.h" void ttymodes_echo_on (ttymodes_ref t) { t->ti.c_lflag |= ECHO | ECHOE | ECHOK ; } prog/skalibs-0.47/src/libttymodes/ttymodes_sett_nohang.c0100644000000000000000000000042607772665224020510 0ustar /* Public domain. */ #include #include #include "ttymodes.h" int ttymodes_sett_nohang (int fd, ttymodes const *t) { register int r ; do r = tcsetattr(fd, TCSADRAIN, (struct termios *)&t->ti) ; while ((r == -1) && (errno == EINTR)) ; return r ; } prog/skalibs-0.47/src/libttymodes/ttymodes_set_nohang.c0100644000000000000000000000027207663560170020314 0ustar /* Public domain. */ #include "ttymodes.h" int ttymodes_set_nohang (int fd, ttymodes const *t) { if (ttymodes_sett_nohang(fd, t) == -1) return -1 ; return ttymodes_setw(fd, t) ; } prog/skalibs-0.47/src/sysdeps/0040755000000000000000000000000011051023410013201 5ustar prog/skalibs-0.47/src/sysdeps/haseproto.h10100644000000000000000000000004707773705123015465 0ustar #undef HASEPROTO /* sysdep: -eproto */ prog/skalibs-0.47/src/sysdeps/hasdevur.h10100644000000000000000000000005707673715512015305 0ustar #undef HASDEVURANDOM /* sysdep: -devurandom */ prog/skalibs-0.47/src/sysdeps/EXPORT0100644000000000000000000000004607673722253014174 0ustar sysdeps sysdeps.h socket.lib util.lib prog/skalibs-0.47/src/sysdeps/Makefile0100644000000000000000000001701710447502272014664 0ustar it: sysdeps.h sysdeps socket.lib util.lib clean: EXPORT INTERNAL rm -f `cat EXPORT INTERNAL` chkshsgr.o: chkshsgr.c compile ./compile chkshsgr.c chkshsgr: chkshsgr.o load ./load chkshsgr sysdeps: compile load systype sysdeps.h socket.lib util.lib rm -f sysdeps cat systype compile load socket.lib util.lib >> sysdeps grep -h sysdep: sysdeps.h >> sysdeps sysdeps.h: hasdevtcp.h hasdevptc.h hasdevptmx.h hasdevr.h hasdevur.h \ hasdirent.h haseproto.h hasflock.h hasgetpt.h \ hasgpeid.h hasmalloc0.h hasmkffo.h hasnpbg1.h \ haspollh.h hassyspollh.h haspoll.h hassgact.h hassgprm.h \ hasshsgr.h hassysel.h hasrevoke.h haswaitp.h hasulong32.h hasulong64.h \ hasutilh.h haslibutilh.h hasptyh.h hasunixh.h has_getpty.h hasopenpty.h \ hasstreams.h haslendian.h hasbendian.h hasegd.h hastiocr.h hasposixglob.h \ hasstdinth.h hasinttypesh.h hasoksyssocket.h @echo '/* Public domain. */' > sysdeps.h @echo >> sysdeps.h @echo '#ifndef SYSDEPS_H' >> sysdeps.h @echo '#define SYSDEPS_H' >> sysdeps.h @echo >> sysdeps.h cat hasdevtcp.h hasdevptc.h hasdevptmx.h hasdevr.h hasdevur.h \ hasdirent.h haseproto.h hasflock.h hasgetpt.h \ hasgpeid.h hasmalloc0.h hasmkffo.h hasnpbg1.h \ haspollh.h hassyspollh.h haspoll.h hassgact.h hassgprm.h \ hasshsgr.h hassysel.h hasrevoke.h haswaitp.h hasulong32.h hasulong64.h \ hasutilh.h haslibutilh.h hasptyh.h has_getpty.h hasopenpty.h hasunixh.h \ hasstreams.h haslendian.h hasbendian.h hasegd.h hastiocr.h hasposixglob.h \ hasstdinth.h hasinttypesh.h hasoksyssocket.h >> sysdeps.h @echo >> sysdeps.h @echo '#endif' >> sysdeps.h socket.lib: compile load trylsock.c echo > socket.lib ./compile trylsock.c && ( ./load trylsock 2>/dev/null || ( ./load trylsock -lsocket -lnsl 2>/dev/null && echo -lsocket -lnsl > socket.lib ) ) || true rm -f trylsock.o trylsock util.lib: compile load trylutil.c echo > util.lib ./compile trylutil.c && ( ./load trylutil 2>/dev/null || ( ./load trylutil -lutil 2>/dev/null && echo -lutil > util.lib ) ) || true rm -f trylutil.o trylutil hasdevtcp.h: systype hasdevtcp.h1 hasdevtcp.h2 ( case "`cat systype`" in \ sunos-5.*) cat hasdevtcp.h2 ;; \ *) cat hasdevtcp.h1 ;; \ esac ) > hasdevtcp.h hasdevptc.h: choose compile load trydevptc.c hasdevptc.h1 hasdevptc.h2 ./choose clr trydevptc hasdevptc.h1 hasdevptc.h2 > hasdevptc.h hasdevptmx.h: choose compile load trydevptmx.c hasdevptmx.h1 hasdevptmx.h2 ./choose clr trydevptmx hasdevptmx.h1 hasdevptmx.h2 > hasdevptmx.h hasdevr.h: choose compile load trydevr.c hasdevr.h1 hasdevr.h2 warn-trydevr @cat < warn-trydevr ./choose clr trydevr hasdevr.h1 hasdevr.h2 > hasdevr.h hasdevur.h: choose compile load trydevur.c hasdevur.h1 hasdevur.h2 ./choose clr trydevur hasdevur.h1 hasdevur.h2 > hasdevur.h hasdirent.h: choose compile hasdirent.h1 hasdirent.h2 trydrent.c ./choose c trydrent hasdirent.h1 hasdirent.h2 > hasdirent.h haseproto.h: choose compile haseproto.h1 haseproto.h2 tryeproto.c ./choose c tryeproto haseproto.h1 haseproto.h2 > haseproto.h hasflock.h: choose compile hasflock.h1 hasflock.h2 load tryflock.c ./choose cl tryflock hasflock.h1 hasflock.h2 > hasflock.h hasgetpt.h: choose compile hasgetpt.h1 hasgetpt.h2 load trygetpt.c ./choose cl trygetpt hasgetpt.h1 hasgetpt.h2 > hasgetpt.h hasgpeid.h: choose compile load hasgpeid.h0 hasgpeid.h1 hasgpeid.h2 \ trysopc.c trygpeid.c ./choose cl trygpeid hasgpeid.h0 hasgpeid.h1 > hasgpeid.tmp ./choose c trysopc hasgpeid.tmp hasgpeid.h2 > hasgpeid.h rm -f hasgpeid.tmp hasmalloc0.h: choose compile load hasmalloc0.h1 hasmalloc0.h2 trymalloc0.c ./choose clr trymalloc0 hasmalloc0.h1 hasmalloc0.h2 > hasmalloc0.h hasmkffo.h: choose compile hasmkffo.h1 hasmkffo.h2 load trymkffo.c ./choose cl trymkffo hasmkffo.h1 hasmkffo.h2 > hasmkffo.h hasnpbg1.h: choose compile hasnpbg1.h1 hasnpbg1.h2 load trynpbg1.c hasmkffo.h hassysel.h ./choose clr trynpbg1 hasnpbg1.h1 hasnpbg1.h2 > hasnpbg1.h haspollh.h: choose compile haspollh.h1 haspollh.h2 trypollh.c ./choose c trypollh haspollh.h1 haspollh.h2 > haspollh.h hassyspollh.h: choose compile hassyspollh.h1 hassyspollh.h2 trysyspollh.c ./choose c trysyspollh hassyspollh.h1 hassyspollh.h2 > hassyspollh.h haspoll.h: choose compile haspoll.h1 haspoll.h2 load trypoll.c haspollh.h hassyspollh.h ./choose clr trypoll haspoll.h1 haspoll.h2 > haspoll.h hassgact.h: choose compile hassgact.h1 hassgact.h2 load trysgact.c ./choose cl trysgact hassgact.h1 hassgact.h2 > hassgact.h hassgprm.h: choose compile hassgprm.h1 hassgprm.h2 load trysgprm.c ./choose cl trysgprm hassgprm.h1 hassgprm.h2 > hassgprm.h hasshsgr.h: chkshsgr choose compile hasshsgr.h1 hasshsgr.h2 load tryshsgr.c warn-shsgr ./chkshsgr || ( cat warn-shsgr; exit 1 ) ./choose clr tryshsgr hasshsgr.h1 hasshsgr.h2 > hasshsgr.h hassysel.h: choose compile hassysel.h1 hassysel.h2 trysysel.c ./choose c trysysel hassysel.h1 hassysel.h2 > hassysel.h hasrevoke.h: choose compile hasrevoke.h1 hasrevoke.h2 load tryrevoke.c ./choose cl tryrevoke hasrevoke.h1 hasrevoke.h2 > hasrevoke.h haswaitp.h: choose compile haswaitp.h1 haswaitp.h2 load trywaitp.c ./choose cl trywaitp haswaitp.h1 haswaitp.h2 > haswaitp.h hasulong32.h: choose compile load tryulong32.c hasulong32.h1 hasulong32.h2 ./choose clr tryulong32 hasulong32.h1 hasulong32.h2 > hasulong32.h hasulong64.h: choose compile load tryulong64.c hasulong64.h1 hasulong64.h2 ./choose clr tryulong64 hasulong64.h1 hasulong64.h2 > hasulong64.h hasutilh.h: choose compile tryutilh.c hasutilh.h1 hasutilh.h2 ./choose c tryutilh hasutilh.h1 hasutilh.h2 > hasutilh.h haslibutilh.h: choose compile trylibutilh.c haslibutilh.h1 haslibutilh.h2 ./choose c trylibutilh haslibutilh.h1 haslibutilh.h2 > haslibutilh.h hasptyh.h: choose compile tryptyh.c hasptyh.h1 hasptyh.h2 ./choose c tryptyh hasptyh.h1 hasptyh.h2 > hasptyh.h hasunixh.h: choose compile tryunixh.c hasunixh.h1 hasunixh.h2 ./choose c tryunixh hasunixh.h1 hasunixh.h2 > hasunixh.h has_getpty.h: choose compile load try_getpty.c has_getpty.h1 has_getpty.h2 ./choose cl try_getpty has_getpty.h1 has_getpty.h2 > has_getpty.h hasopenpty.h: choose compile load tryopenpty.c hasopenpty.h1 hasopenpty.h2 hasutilh.h haslibutilh.h hasptyh.h util.lib ./choose cl tryopenpty hasopenpty.h1 hasopenpty.h2 `cat util.lib` > hasopenpty.h hasstreams.h: choose compile trystreams.c hasstreams.h1 hasstreams.h2 ./choose c trystreams hasstreams.h1 hasstreams.h2 > hasstreams.h haslendian.h: choose compile load trylendian.c haslendian.h1 haslendian.h2 hasulong32.h hasulong64.h ./choose clr trylendian haslendian.h1 haslendian.h2 > haslendian.h hasbendian.h: choose compile load trybendian.c hasbendian.h1 hasbendian.h2 hasulong32.h hasulong64.h ./choose clr trybendian hasbendian.h1 hasbendian.h2 > hasbendian.h hasegd.h: conf-egd hasegd.h1 hasegd.h2 rm -f egd.h if test "x`head -n 1 conf-egd`" = "x" ; then cp hasegd.h1 hasegd.h ; \ else sed "s|EGD_IPCPATH|`head -1 conf-egd`|" hasegd.h2 > hasegd.h ; \ fi hastiocr.h: choose compile trytiocr.c hastiocr.h1 hastiocr.h2 ./choose c trytiocr hastiocr.h1 hastiocr.h2 > hastiocr.h hasposixglob.h: choose compile tryposixglob.c hasposixglob.h1 hasposixglob.h2 ./choose c tryposixglob hasposixglob.h1 hasposixglob.h2 > hasposixglob.h hasstdinth.h: choose compile hasstdinth.h1 hasstdinth.h2 trystdinth.c ./choose c trystdinth hasstdinth.h1 hasstdinth.h2 > hasstdinth.h hasinttypesh.h: choose compile hasinttypesh.h1 hasinttypesh.h2 tryinttypesh.c ./choose c tryinttypesh hasinttypesh.h1 hasinttypesh.h2 > hasinttypesh.h hasoksyssocket.h: choose compile hasoksyssocket.h1 hasoksyssocket.h2 tryoksyssocket.c ./choose c tryoksyssocket hasoksyssocket.h1 hasoksyssocket.h2 > hasoksyssocket.h prog/skalibs-0.47/src/sysdeps/haseproto.h20100644000000000000000000000005007773705143015462 0ustar #define HASEPROTO /* sysdep: +eproto */ prog/skalibs-0.47/src/sysdeps/tryeproto.c0100644000000000000000000000011507773713126015440 0ustar #include static int dummy ; #ifndef EPROTO syntax error ! #endif prog/skalibs-0.47/src/sysdeps/INTERNAL0100644000000000000000000000070310022111323014333 0ustar chkshsgr chkshsgr.o hasdevtcp.h hasdevptc.h hasdevptmx.h hasdevr.h hasdevur.h hasdirent.h haseproto.h hasflock.h hasgetpt.h hasgpeid.h hasmalloc0.h hasmkffo.h hasnpbg1.h haspollh.h hassyspollh.h haspoll.h hassgact.h hassgprm.h hasshsgr.h hassysel.h haswaitp.h hasutilh.h haslibutilh.h hasptyh.h hasunixh.h has_getpty.h hasopenpty.h hasstreams.h haslendian.h hasbendian.h hasegd.h hastiocr.h hasposixglob.h hasstdinth.h hasinttypesh.h hasoksyssocket.h prog/skalibs-0.47/src/sysdeps/trydevr.c0100644000000000000000000000217010447271327015065 0ustar /* Public domain. */ #include #include #include #include static int fd_read (int fd, char *buf, unsigned int len) { register int r ; do r = read(fd, buf, len) ; while ((r == -1) && (errno == EINTR)) ; return r ; } static unsigned int allread (int fd, register char *buf, register unsigned int len) { register unsigned int written = 0 ; while (len) { register int w = fd_read(fd, buf, len) ; if (!w) errno = EPIPE ; if (w <= 0) break ; written += w ; buf += w ; len -= w ; } return written ; } static int byte_diff (char *s, unsigned int n, char *t) { for (;;) { if (!n) return 0 ; if (*s != *t) break ; ++s ; ++t ; --n ; } return ((int)(unsigned int)(unsigned char) *s) - ((int)(unsigned int)(unsigned char) *t); } int main () { char a[64] ; char b[64] ; int fd = open("/dev/random", O_RDONLY) ; if ((fd == -1) || (allread(fd, a, 64) < 64) ) return 111 ; close(fd) ; fd = open("/dev/random", O_RDONLY) ; if ((fd == -1) || (allread(fd, b, 64) < 64) ) return 111 ; close(fd) ; return !byte_diff(a, 64, b) ; } prog/skalibs-0.47/src/sysdeps/trydrent.c0100644000000000000000000000016107673715512015245 0ustar /* Public domain. */ #include #include void foo() { DIR *dir; struct dirent *d; } prog/skalibs-0.47/src/sysdeps/tryflock.c0100644000000000000000000000023507673715512015231 0ustar /* Public domain. */ #include #include #include int main (void) { return flock (0, LOCK_EX | LOCK_UN | LOCK_NB) ; } prog/skalibs-0.47/src/sysdeps/trymkffo.c0100644000000000000000000000016107673715512015233 0ustar /* Public domain. */ #include #include void main() { mkfifo("temp-trymkffo",0); } prog/skalibs-0.47/src/sysdeps/trypoll.c0100644000000000000000000000074207673715512015104 0ustar /* Public domain. */ #include #include #include "haspollh.h" #include "hassyspollh.h" #ifdef HASPOLLH #include #else #ifdef HASSYSPOLLH #include #endif #endif int main() { struct pollfd x; x.fd = open("trypoll.c",O_RDONLY); if (x.fd == -1) _exit(111); x.events = POLLIN; if (poll(&x,1,10) == -1) _exit(1); if (x.revents != POLLIN) _exit(1); /* XXX: try to detect and avoid poll() imitation libraries */ _exit(0); } prog/skalibs-0.47/src/sysdeps/trysgact.c0100644000000000000000000000027607673715512015241 0ustar /* Public domain. */ #include int main (void) { struct sigaction sa ; sa.sa_handler = 0 ; sa.sa_flags = 0 ; sigemptyset(&sa.sa_mask) ; return sigaction(0, &sa, 0) ; } prog/skalibs-0.47/src/sysdeps/trysgprm.c0100644000000000000000000000025407673715512015264 0ustar /* Public domain. */ #include int main (void) { sigset_t ss ; sigemptyset(&ss) ; sigaddset(&ss, SIGCHLD) ; return sigprocmask(SIG_SETMASK, &ss, 0) ; } prog/skalibs-0.47/src/sysdeps/tryshsgr.c0100644000000000000000000000044307673715512015262 0ustar /* Public domain. */ int 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); } prog/skalibs-0.47/src/sysdeps/INCLUDE0100644000000000000000000000000007673715546014233 0ustar prog/skalibs-0.47/src/sysdeps/trysysel.c0100644000000000000000000000022607673715512015272 0ustar /* Public domain. */ #include #include #include #include /* SVR4 silliness */ void foo() { ; } prog/skalibs-0.47/src/sysdeps/tryulong32.c0100644000000000000000000000053707673715512015431 0ustar int main () { unsigned long 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 ; return !!u ; } prog/skalibs-0.47/src/sysdeps/tryulong64.c0100644000000000000000000000053607673715512015435 0ustar int main () { unsigned long 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 ; return !u ; } prog/skalibs-0.47/src/sysdeps/trywaitp.c0100644000000000000000000000016407673715512015260 0ustar /* Public domain. */ #include #include int main (void) { return waitpid(0, 0, 0) ; } prog/skalibs-0.47/src/sysdeps/hasdevtcp.h10100644000000000000000000000004707673715512015444 0ustar #undef HASDEVTCP /* sysdep: -devtcp */ prog/skalibs-0.47/src/sysdeps/hasdevtcp.h20100644000000000000000000000005007673715512015437 0ustar #define HASDEVTCP /* sysdep: +devtcp */ prog/skalibs-0.47/src/sysdeps/hasflock.h10100644000000000000000000000004507673715512015253 0ustar #undef HASFLOCK /* sysdep: -flock */ prog/skalibs-0.47/src/sysdeps/hasflock.h20100644000000000000000000000004607673715512015255 0ustar #define HASFLOCK /* sysdep: +flock */ prog/skalibs-0.47/src/sysdeps/hasmkffo.h10100644000000000000000000000004707673715512015261 0ustar #undef HASMKFIFO /* sysdep: -mkfifo */ prog/skalibs-0.47/src/sysdeps/hasmkffo.h20100644000000000000000000000005007673715512015254 0ustar #define HASMKFIFO /* sysdep: +mkfifo */ prog/skalibs-0.47/src/sysdeps/hassgact.h10100644000000000000000000000005507673715512015257 0ustar #undef HASSIGACTION /* sysdep: -sigaction */ prog/skalibs-0.47/src/sysdeps/hassgact.h20100644000000000000000000000005607673715512015261 0ustar #define HASSIGACTION /* sysdep: +sigaction */ prog/skalibs-0.47/src/sysdeps/hassgprm.h10100644000000000000000000000006107673715512015303 0ustar #undef HASSIGPROCMASK /* sysdep: -sigprocmask */ prog/skalibs-0.47/src/sysdeps/hassgprm.h20100644000000000000000000000006207673715512015305 0ustar #define HASSIGPROCMASK /* sysdep: +sigprocmask */ prog/skalibs-0.47/src/sysdeps/hasshsgr.h10100644000000000000000000000006707673715512015307 0ustar #undef HASSHORTSETGROUPS /* sysdep: -shortsetgroups */ prog/skalibs-0.47/src/sysdeps/hasshsgr.h20100644000000000000000000000007007673715512015302 0ustar #define HASSHORTSETGROUPS /* sysdep: +shortsetgroups */ prog/skalibs-0.47/src/sysdeps/haswaitp.h10100644000000000000000000000005107673715512015276 0ustar #undef HASWAITPID /* sysdep: -waitpid */ prog/skalibs-0.47/src/sysdeps/haswaitp.h20100644000000000000000000000005207673715512015300 0ustar #define HASWAITPID /* sysdep: +waitpid */ prog/skalibs-0.47/src/sysdeps/hasdirent.h10100644000000000000000000000004707673715512015444 0ustar #undef HASDIRENT /* sysdep: -dirent */ prog/skalibs-0.47/src/sysdeps/hasdevur.h20100644000000000000000000000006007673715512015300 0ustar #define HASDEVURANDOM /* sysdep: +devurandom */ prog/skalibs-0.47/src/sysdeps/hasdirent.h20100644000000000000000000000005007673715512015437 0ustar #define HASDIRENT /* sysdep: +dirent */ prog/skalibs-0.47/src/sysdeps/hasulong64.h10100644000000000000000000000005107673715512015450 0ustar #undef HASULONG64 /* sysdep: -ulong64 */ prog/skalibs-0.47/src/sysdeps/hasgpeid.h00100644000000000000000000000014007673715512015240 0ustar #undef HASGETPEEREID /* sysdep: -getpeereid */ #undef HASSO_PEERCRED /* sysdep: -SO_PEERCRED */ prog/skalibs-0.47/src/sysdeps/trydevur.c0100644000000000000000000000121407673715512015256 0ustar /* Public domain. */ #include #include #include static int byte_diff (char *s, unsigned int n, char *t) { for (;;) { if (!n) return 0 ; if (*s != *t) break ; ++s ; ++t ; --n ; } return ((int)(unsigned int)(unsigned char) *s) - ((int)(unsigned int)(unsigned char) *t); } int main () { char a[64] ; char b[64] ; int fd ; fd = open("/dev/urandom", O_RDONLY) ; if ((fd == -1) || (read(fd, a, 64) < 64) ) return 111 ; close(fd) ; fd = open("/dev/urandom", O_RDONLY) ; if ((fd == -1) || (read(fd, b, 64) < 64) ) return 111 ; close(fd) ; return (!byte_diff(a, 64, b)) ; } prog/skalibs-0.47/src/sysdeps/warn-shsgr0100644000000000000000000000031307673715512015243 0ustar 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. prog/skalibs-0.47/src/sysdeps/chkshsgr.c0100644000000000000000000000031707673715512015211 0ustar /* Public domain. */ #include #include #include int main() { short x[4]; x[0] = x[1] = 0; if (getgroups(1,x) == 0) if (setgroups(1,x) == -1) _exit(1); _exit(0); } prog/skalibs-0.47/src/sysdeps/trymalloc0.c0100644000000000000000000000006707673715512015465 0ustar #include int main() { return !malloc(0) ; } prog/skalibs-0.47/src/sysdeps/trysopc.c0100644000000000000000000000036207673715512015100 0ustar #include #include #include #include int main (void) { int s ; struct ucred dummy = {0} ; int len = sizeof(dummy) ; return getsockopt(s, SOL_SOCKET, SO_PEERCRED, &dummy, &len) ; } prog/skalibs-0.47/src/sysdeps/hasgpeid.h10100644000000000000000000000014107673715512015242 0ustar #define HASGETPEEREID /* sysdep: +getpeereid */ #undef HASSO_PEERCRED /* sysdep: -SO_PEERCRED */ prog/skalibs-0.47/src/sysdeps/hasgpeid.h20100644000000000000000000000014107673715512015243 0ustar #undef HASGETPEEREID /* sysdep: -getpeereid */ #define HASSO_PEERCRED /* sysdep: +SO_PEERCRED */ prog/skalibs-0.47/src/sysdeps/hassysel.h10100644000000000000000000000005507673715512015315 0ustar #undef HASSYSSELECT /* sysdep: -sysselect */ prog/skalibs-0.47/src/sysdeps/trygpeid.c0100644000000000000000000000024207673715512015221 0ustar #include #include #include int main() { int uid_t; int gid_t; int so; return getpeereid(so,&uid_t,&gid_t); } prog/skalibs-0.47/src/sysdeps/hassysel.h20100644000000000000000000000005607673715512015317 0ustar #define HASSYSSELECT /* sysdep: +sysselect */ prog/skalibs-0.47/src/sysdeps/haspoll.h10100644000000000000000000000004307673715512015121 0ustar #undef HASPOLL /* sysdep: -poll */ prog/skalibs-0.47/src/sysdeps/haspoll.h20100644000000000000000000000004407673715512015123 0ustar #define HASPOLL /* sysdep: +poll */ prog/skalibs-0.47/src/sysdeps/hasmalloc0.h10100644000000000000000000000005107673715512015501 0ustar #undef HASMALLOC0 /* sysdep: -malloc0 */ prog/skalibs-0.47/src/sysdeps/hasmalloc0.h20100644000000000000000000000005207673715512015503 0ustar #define HASMALLOC0 /* sysdep: +malloc0 */ prog/skalibs-0.47/src/sysdeps/trylsock.c0100644000000000000000000000014110023403206015213 0ustar #include #include int main () { shutdown(0, 0) ; return 0 ; } prog/skalibs-0.47/src/sysdeps/hasulong32.h10100644000000000000000000000005107673715512015443 0ustar #undef HASULONG32 /* sysdep: -ulong32 */ prog/skalibs-0.47/src/sysdeps/hasulong32.h20100644000000000000000000000005207673715512015445 0ustar #define HASULONG32 /* sysdep: +ulong32 */ prog/skalibs-0.47/src/sysdeps/hasulong64.h20100644000000000000000000000005207673715512015452 0ustar #define HASULONG64 /* sysdep: +ulong64 */ prog/skalibs-0.47/src/sysdeps/hasnpbg1.h10100644000000000000000000000004507673715512015164 0ustar #undef HASNPBG1 /* sysdep: -npbg1 */ prog/skalibs-0.47/src/sysdeps/trynpbg1.c0100644000000000000000000000144707673715512015150 0ustar #include #include #include #include #include "hasmkffo.h" #include "hassysel.h" #ifdef HASSYSSELECT #include #else #include #endif static int fifo_make (char const *fn, int mode) { #ifdef HASMKFIFO return mkfifo(fn, mode) ; #else return mknod(fn, S_IFIFO | mode, 0) ; #endif } #define FN "temp-trynpbg1.fifo" int main() { int flagbug = 0 ; struct timeval instant ; fd_set rfds ; if (fifo_make(FN, 0600) != -1) { close(0) ; if (open(FN, O_RDONLY|O_NONBLOCK) == 0) { FD_ZERO(&rfds) ; FD_SET(0, &rfds) ; instant.tv_sec = instant.tv_usec = 0 ; if (select(1, &rfds, (fd_set *) 0, (fd_set *) 0, &instant) > 0) flagbug = 1 ; } unlink(FN) ; } return !flagbug ; } prog/skalibs-0.47/src/sysdeps/hasnpbg1.h20100644000000000000000000000004607673715512015166 0ustar #define HASNPBG1 /* sysdep: +npbg1 */ prog/skalibs-0.47/src/sysdeps/tryoksyssocket.c0100644000000000000000000000010310022111104016447 0ustar #include int main (void) { shutdown(0, SHUT_RD) ; } prog/skalibs-0.47/src/sysdeps/hasoksyssocket.h20100644000000000000000000000006210022111246016506 0ustar #define HASOKSYSSOCKET /* sysdep: +oksyssocket */ prog/skalibs-0.47/src/sysdeps/hasdevr.h10100644000000000000000000000005507673715512015116 0ustar #undef HASDEVRANDOM /* sysdep: -devrandom */ prog/skalibs-0.47/src/sysdeps/hasdevr.h20100644000000000000000000000005607673715512015120 0ustar #define HASDEVRANDOM /* sysdep: +devrandom */ prog/skalibs-0.47/src/sysdeps/trygetpt.c0100644000000000000000000000006407673715512015256 0ustar #include int main() { return getpt() ; } prog/skalibs-0.47/src/sysdeps/hasgetpt.h10100644000000000000000000000004507673715512015300 0ustar #undef HASGETPT /* sysdep: -getpt */ prog/skalibs-0.47/src/sysdeps/trydevptc.c0100644000000000000000000000020207673715512015412 0ustar #include #include int main () { struct stat st ; return (stat("/dev/ptc", &st) == -1) ? 1 : 0 ; } prog/skalibs-0.47/src/sysdeps/hasgetpt.h20100644000000000000000000000004607673715512015302 0ustar #define HASGETPT /* sysdep: +getpt */ prog/skalibs-0.47/src/sysdeps/hasdevptc.h10100644000000000000000000000004707673715512015444 0ustar #undef HASDEVPTC /* sysdep: -devptc */ prog/skalibs-0.47/src/sysdeps/hasdevptmx.h10100644000000000000000000000005107673715512015641 0ustar #undef HASDEVPTMX /* sysdep: -devptmx */ prog/skalibs-0.47/src/sysdeps/hasdevptc.h20100644000000000000000000000005007673715512015437 0ustar #define HASDEVPTC /* sysdep: +devptc */ prog/skalibs-0.47/src/sysdeps/hasdevptmx.h20100644000000000000000000000005207673715512015643 0ustar #define HASDEVPTMX /* sysdep: +devptmx */ prog/skalibs-0.47/src/sysdeps/trydevptmx.c0100644000000000000000000000020307673715512015615 0ustar #include #include int main () { struct stat st ; return (stat("/dev/ptmx", &st) == -1) ? 1 : 0 ; } prog/skalibs-0.47/src/sysdeps/hasrevoke.h10100644000000000000000000000004707673715512015452 0ustar #undef HASREVOKE /* sysdep: -revoke */ prog/skalibs-0.47/src/sysdeps/hasrevoke.h20100644000000000000000000000005007673715512015445 0ustar #define HASREVOKE /* sysdep: +revoke */ prog/skalibs-0.47/src/sysdeps/tryrevoke.c0100644000000000000000000000007107673715512015424 0ustar #include int main () { return revoke("/") ; } prog/skalibs-0.47/src/sysdeps/hasptyh.h10100644000000000000000000000004307673715512015137 0ustar #undef HASPTYH /* sysdep: -ptyh */ prog/skalibs-0.47/src/sysdeps/hasptyh.h20100644000000000000000000000004407673715512015141 0ustar #define HASPTYH /* sysdep: +ptyh */ prog/skalibs-0.47/src/sysdeps/tryptyh.c0100644000000000000000000000010010023407273015067 0ustar #include #include static char dummy = 0 ; prog/skalibs-0.47/src/sysdeps/tryutilh.c0100644000000000000000000000010110023407315015226 0ustar #include #include static char dummy = 0 ; prog/skalibs-0.47/src/sysdeps/trylibutilh.c0100644000000000000000000000010407673715512015742 0ustar #include #include static char dummy = 0 ; prog/skalibs-0.47/src/sysdeps/tryopenpty.c0100644000000000000000000000045607673715512015636 0ustar #include #include "hasptyh.h" #ifdef HASPTYH #include #endif #include "hasutilh.h" #ifdef HASUTILH #include #endif #include "haslibutilh.h" #ifdef HASLIBUTILH #include #endif int main () { int fd[2] ; openpty(&fd[0], &fd[1], 0, 0, 0) ; return 0 ; } prog/skalibs-0.47/src/sysdeps/hasutilh.h10100644000000000000000000000004507673715512015302 0ustar #undef HASUTILH /* sysdep: -utilh */ prog/skalibs-0.47/src/sysdeps/hasutilh.h20100644000000000000000000000004607673715512015304 0ustar #define HASUTILH /* sysdep: +utilh */ prog/skalibs-0.47/src/sysdeps/haslibutilh.h20100644000000000000000000000005407673715512015772 0ustar #define HASLIBUTILH /* sysdep: +libutilh */ prog/skalibs-0.47/src/sysdeps/haslibutilh.h10100644000000000000000000000005307673715512015770 0ustar #undef HASLIBUTILH /* sysdep: -libutilh */ prog/skalibs-0.47/src/sysdeps/try_getpty.c0100644000000000000000000000025407673715512015607 0ustar #include #include #include #include int main () { int fd ; char *name = _getpty(&fd, O_RDWR, 0600, 0) ; return 0 ; } prog/skalibs-0.47/src/sysdeps/has_getpty.h10100644000000000000000000000005107673715512015625 0ustar #undef HAS_GETPTY /* sysdep: -_getpty */ prog/skalibs-0.47/src/sysdeps/has_getpty.h20100644000000000000000000000005207673715512015627 0ustar #define HAS_GETPTY /* sysdep: +_getpty */ prog/skalibs-0.47/src/sysdeps/hasopenpty.h10100644000000000000000000000005107673715512015650 0ustar #undef HASOPENPTY /* sysdep: -openpty */ prog/skalibs-0.47/src/sysdeps/hasopenpty.h20100644000000000000000000000005207673715512015652 0ustar #define HASOPENPTY /* sysdep: +openpty */ prog/skalibs-0.47/src/sysdeps/hasstreams.h10100644000000000000000000000005107673715512015630 0ustar #undef HASSTREAMS /* sysdep: -streams */ prog/skalibs-0.47/src/sysdeps/hasstreams.h20100644000000000000000000000005207673715512015632 0ustar #define HASSTREAMS /* sysdep: +streams */ prog/skalibs-0.47/src/sysdeps/trystreams.c0100644000000000000000000000013610543466275015610 0ustar #include #include int main() { struct strioctl foo ; return 0 ; } prog/skalibs-0.47/src/sysdeps/trylutil.c0100644000000000000000000000045607673715512015271 0ustar #include #include "hasptyh.h" #ifdef HASPTYH #include #endif #include "hasutilh.h" #ifdef HASUTILH #include #endif #include "haslibutilh.h" #ifdef HASLIBUTILH #include #endif int main () { int fd[2] ; openpty(&fd[0], &fd[1], 0, 0, 0) ; return 0 ; } prog/skalibs-0.47/src/sysdeps/tryunixh.c0100644000000000000000000000010110023407306015234 0ustar #include #include static char dummy = 0 ; prog/skalibs-0.47/src/sysdeps/hasunixh.h10100644000000000000000000000004507673715512015310 0ustar #undef HASUNIXH /* sysdep: -unixh */ prog/skalibs-0.47/src/sysdeps/hasunixh.h20100644000000000000000000000004607673715512015312 0ustar #define HASUNIXH /* sysdep: +unixh */ prog/skalibs-0.47/src/sysdeps/trypollh.c0100644000000000000000000000010110023407263015221 0ustar #include #include static char dummy = 0 ; prog/skalibs-0.47/src/sysdeps/haslendian.h10100644000000000000000000000006507673715512015571 0ustar #undef HASLITTLE_ENDIAN /* sysdep: -little_endian */ prog/skalibs-0.47/src/sysdeps/trybendian.c0100644000000000000000000000137307673715512015537 0ustar #include "hasulong32.h" #include "hasulong64.h" int main () { #ifdef HASULONG32 unsigned long i = 0xdeadbeef ; if ((((unsigned char *)(&i))[0] == 0xde) && (((unsigned char *)(&i))[1] == 0xad) && (((unsigned char *)(&i))[2] == 0xbe) && (((unsigned char *)(&i))[3] == 0xef)) return 0 ; #else #ifdef HASULONG64 unsigned long i = 0x12345678deadbeefUL ; if ((((unsigned char *)(&i))[0] == 0x12) && (((unsigned char *)(&i))[1] == 0x34) && (((unsigned char *)(&i))[2] == 0x56) && (((unsigned char *)(&i))[3] == 0x78) && (((unsigned char *)(&i))[4] == 0xde) && (((unsigned char *)(&i))[5] == 0xad) && (((unsigned char *)(&i))[6] == 0xbe) && (((unsigned char *)(&i))[7] == 0xef)) return 0 ; #endif #endif return 1 ; } prog/skalibs-0.47/src/sysdeps/haslendian.h20100644000000000000000000000006607673715512015573 0ustar #define HASLITTLE_ENDIAN /* sysdep: +little_endian */ prog/skalibs-0.47/src/sysdeps/trylendian.c0100644000000000000000000000137307673715512015551 0ustar #include "hasulong32.h" #include "hasulong64.h" int main () { #ifdef HASULONG32 unsigned long i = 0xdeadbeef ; if ((((unsigned char *)(&i))[0] == 0xef) && (((unsigned char *)(&i))[1] == 0xbe) && (((unsigned char *)(&i))[2] == 0xad) && (((unsigned char *)(&i))[3] == 0xde)) return 0 ; #else #ifdef HASULONG64 unsigned long i = 0x12345678deadbeefUL ; if ((((unsigned char *)(&i))[0] == 0xef) && (((unsigned char *)(&i))[1] == 0xbe) && (((unsigned char *)(&i))[2] == 0xad) && (((unsigned char *)(&i))[3] == 0xde) && (((unsigned char *)(&i))[4] == 0x78) && (((unsigned char *)(&i))[5] == 0x56) && (((unsigned char *)(&i))[6] == 0x34) && (((unsigned char *)(&i))[7] == 0x12)) return 0 ; #endif #endif return 1 ; } prog/skalibs-0.47/src/sysdeps/hasbendian.h10100644000000000000000000000005707673715512015560 0ustar #undef HASBIG_ENDIAN /* sysdep: -big_endian */ prog/skalibs-0.47/src/sysdeps/hasbendian.h20100644000000000000000000000006007673715512015553 0ustar #define HASBIG_ENDIAN /* sysdep: +big_endian */ prog/skalibs-0.47/src/sysdeps/haspollh.h10100644000000000000000000000004507673715512015273 0ustar #undef HASPOLLH /* sysdep: -pollh */ prog/skalibs-0.47/src/sysdeps/haspollh.h20100644000000000000000000000004607673715512015275 0ustar #define HASPOLLH /* sysdep: +pollh */ prog/skalibs-0.47/src/sysdeps/hassyspollh.h10100644000000000000000000000005307673715512016031 0ustar #undef HASSYSPOLLH /* sysdep: -syspollh */ prog/skalibs-0.47/src/sysdeps/hassyspollh.h20100644000000000000000000000005407673715512016033 0ustar #define HASSYSPOLLH /* sysdep: +syspollh */ prog/skalibs-0.47/src/sysdeps/hasegd.h10100644000000000000000000000004107673715512014710 0ustar #undef HASEGD /* sysdep: -egd */ prog/skalibs-0.47/src/sysdeps/trysyspollh.c0100644000000000000000000000010510023407301015755 0ustar #include #include static char dummy = 0 ; prog/skalibs-0.47/src/sysdeps/trytiocr.c0100644000000000000000000000013007673715512015245 0ustar /* Public domain. */ #include #include int r = TIOCREMOTE ; prog/skalibs-0.47/src/sysdeps/hasegd.h20100644000000000000000000000006007673715512014712 0ustar #define HASEGD "EGD_IPCPATH" /* sysdep: +egd */ prog/skalibs-0.47/src/sysdeps/hastiocr.h10100644000000000000000000000005707673715512015300 0ustar #undef HASTIOCREMOTE /* sysdep: -tiocremote */ prog/skalibs-0.47/src/sysdeps/hastiocr.h20100644000000000000000000000006007673715512015273 0ustar #define HASTIOCREMOTE /* sysdep: +tiocremote */ prog/skalibs-0.47/src/sysdeps/tryposixglob.c0100644000000000000000000000014107673715512016135 0ustar /* Public domain. */ #include static int dummy[2] = { GLOB_NOMATCH, GLOB_NOESCAPE } ; prog/skalibs-0.47/src/sysdeps/trystdinth.c0100644000000000000000000000005407673715512015607 0ustar #include static char dummy = 0 ; prog/skalibs-0.47/src/sysdeps/hasposixglob.h10100644000000000000000000000005507673715512016164 0ustar #undef HASPOSIXGLOB /* sysdep: -posixglob */ prog/skalibs-0.47/src/sysdeps/hasposixglob.h20100644000000000000000000000005607673715512016166 0ustar #define HASPOSIXGLOB /* sysdep: +posixglob */ prog/skalibs-0.47/src/sysdeps/hasstdinth.h10100644000000000000000000000005107673715512015627 0ustar #undef HASSTDINTH /* sysdep: -stdinth */ prog/skalibs-0.47/src/sysdeps/hasinttypesh.h20100644000000000000000000000005607673715512016207 0ustar #define HASINTTYPESH /* sysdep: +inttypesh */ prog/skalibs-0.47/src/sysdeps/hasinttypesh.h10100644000000000000000000000005507673715512016205 0ustar #undef HASINTTYPESH /* sysdep: -inttypesh */ prog/skalibs-0.47/src/sysdeps/hasstdinth.h20100644000000000000000000000005207673715512015631 0ustar #define HASSTDINTH /* sysdep: +stdinth */ prog/skalibs-0.47/src/sysdeps/tryinttypesh.c0100644000000000000000000000005607673715512016163 0ustar #include static char dummy = 0 ; prog/skalibs-0.47/src/sysdeps/hasoksyssocket.h10100644000000000000000000000006110022111300016473 0ustar #undef HASOKSYSSOCKET /* sysdep: -oksyssocket */ prog/skalibs-0.47/src/sysdeps/warn-trydevr0100644000000000000000000000064211051023351015573 0ustar -- If your system has the /dev/random device, the compilation might hang for -- several minutes on the next "choose" line. This is normal and depends on -- the amount of hardware entropy in the computer. -- To generate hardware entropy and allow the compilation process to resume, -- you can move the mouse around, or start other processes in parallel. -- You can also just wait for entropy to increase naturally. prog/skalibs-0.47/src/systype/0040755000000000000000000000000007674257016013262 5ustar prog/skalibs-0.47/src/systype/trycpp.c0100644000000000000000000000017107673721133014736 0ustar /* Public domain. */ int main() { #ifdef NeXT printf("nextstep\n"); exit(0); #endif printf("unknown\n"); exit(0); } prog/skalibs-0.47/src/systype/find-systype.sh0100644000000000000000000000640611100046276016236 0ustar # 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|freebsd|netbsd|openbsd) # 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`" # 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 ./bootcompile trycpp.c ./bootload trycpp 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 ./bootcompile x86cpuid.c then if ./bootload x86cpuid 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]' prog/skalibs-0.47/src/systype/Makefile0100644000000000000000000000072407674257012014716 0ustar it: systype clean: EXPORT INTERNAL rm -f `cat EXPORT INTERNAL` systype: find-systype.sh trycpp.c x86cpuid.c /bin/sh find-systype.sh > systype find-systype.sh: bootcompile bootload touch find-systype.sh bootcompile: conf-cc print-cc.sh warn-auto.sh rm -f bootcompile /bin/sh print-cc.sh conf-cc > bootcompile chmod 555 bootcompile bootload: conf-ld conf-stripbins print-ld.sh warn-auto.sh rm -f bootload /bin/sh print-ld.sh > bootload chmod 555 bootload prog/skalibs-0.47/src/systype/x86cpuid.c0100644000000000000000000000121307673720053015065 0ustar /* Public domain. */ #include void nope() { exit(1); } int main() { unsigned long x[4]; unsigned long y[4]; int i; int j; char c; signal(SIGILL,nope); x[0] = 0; x[1] = 0; x[2] = 0; x[3] = 0; asm volatile(".byte 15;.byte 162" : "=a"(x[0]),"=b"(x[1]),"=c"(x[3]),"=d"(x[2]) : "0"(0) ); if (!x[0]) return 0; asm volatile(".byte 15;.byte 162" : "=a"(y[0]),"=b"(y[1]),"=c"(y[2]),"=d"(y[3]) : "0"(1) ); for (i = 1;i < 4;++i) for (j = 0;j < 4;++j) { c = x[i] >> (8 * j); if (c < 32) c = 32; if (c > 126) c = 126; putchar(c); } printf("-%08x-%08x\n",y[0],y[3]); return 0; } prog/skalibs-0.47/src/systype/EXPORT0100644000000000000000000000001007673721073014210 0ustar systype prog/skalibs-0.47/src/systype/INTERNAL0100644000000000000000000000002507674245344014414 0ustar bootcompile bootload prog/skalibs-0.47/src/systype/INCLUDE0100644000000000000000000000000007673720053014246 0ustar prog/skalibs-0.47/src/libdatastruct/0040755000000000000000000000000007772716365014415 5ustar prog/skalibs-0.47/src/libdatastruct/EXPORT0100644000000000000000000000002007755272716015344 0ustar libdatastruct.a prog/skalibs-0.47/src/libdatastruct/INCLUDE0100644000000000000000000000010707772716167015416 0ustar datastruct.h avlnode.h avlnodealloc.h avlnodebunch.h list1.h avltree.h prog/skalibs-0.47/src/libdatastruct/INTERNAL0100644000000000000000000000027507772716364015554 0ustar avlnodealloc.o avlnodealloc_x.o avlnodebunch.o list1.o list1_delete.o list1_insert.o list1_iter.o list1_search.o avltree.o avltree_height.o avltree_insdel.o avltree_iter.o avltree_search.o prog/skalibs-0.47/src/libdatastruct/Makefile0100644000000000000000000000417707772716161016055 0ustar it: command include library library.so clean: EXPORT INTERNAL rm -f `cat EXPORT INTERNAL` datastruct.h: avltree.h list1.h avlnodebunch.h avlnodealloc.h avlnode.h touch datastruct.h list1.h: diuintbunch.h gccattributes.h touch list1.h avlnodealloc.h: avlnode.h gen_alloc.h touch avlnodealloc.h avlnodebunch.h: gen_bunch.h avlnodealloc.h avlnode.h touch avlnodebunch.h avltree.h: avlnodebunch.h gccattributes.h touch avltree.h avlnodealloc.o: compile avlnodealloc.c avlnodealloc.h avlnode.h gen_alloc.h ./compile avlnodealloc.c avlnodealloc_x.o: compile avlnodealloc_x.c avlnodealloc.h avlnode.h gen_alloc.h ./compile avlnodealloc_x.c avlnodebunch.o: compile avlnodebunch.c avlnodebunch.h gen_bunch.h avlnodealloc.h avlnode.h ./compile avlnodebunch.c list1.o: compile list1.c list1.h diuintbunch.h ./compile list1.c list1_delete.o: compile list1_delete.c list1.h diuintbunch.h ./compile list1_delete.c list1_insert.o: compile list1_insert.c list1.h diuintbunch.h ./compile list1_insert.c list1_iter.o: compile list1_iter.c list1.h ./compile list1_iter.c list1_search.o: compile list1_search.c list1.h ./compile list1_search.c avltree.o: compile avltree.c avltree.h avlnodebunch.h ./compile avltree.c avltree_height.o: compile avltree_insdel.c avltree.h avlnode.h ./compile avltree_height.c avltree_insdel.o: compile avltree_insdel.c avltree.h avlnodebunch.h avlnode.h ./compile avltree_insdel.c avltree_iter.o: compile avltree_iter.c avltree.h ./compile avltree_iter.c avltree_search.o: compile avltree_search.c avltree.h avlnode.h ./compile avltree_search.c libdatastruct.a: makelib \ avlnodealloc.o avlnodealloc_x.o avlnodebunch.o \ list1.o list1_delete.o list1_insert.o list1_iter.o list1_search.o \ avltree.o avltree_height.o avltree_insdel.o avltree_iter.o avltree_search.o ./makelib libdatastruct.a \ avlnodealloc.o avlnodealloc_x.o avlnodebunch.o \ list1.o list1_delete.o list1_insert.o list1_iter.o list1_search.o \ avltree.o avltree_height.o avltree_insdel.o avltree_iter.o avltree_search.o command: include: datastruct.h avlnode.h avlnodealloc.h avlnodebunch.h list1.h avltree.h library: libdatastruct.a library.so: prog/skalibs-0.47/src/libdatastruct/avlnodealloc_x.c0100644000000000000000000000022707772716353017546 0ustar /* Public domain. */ #include "gen_alloc.h" #include "avlnode.h" #include "avlnodealloc.h" GEN_ALLOC_EXTENDED_DEFS(avlnodealloc, avlnode, s, len, a) prog/skalibs-0.47/src/libdatastruct/avltree.h0100644000000000000000000000204011100046405016164 0ustar /* Public domain. */ #ifndef AVLTREE_H #define AVLTREE_H #include "gccattributes.h" #include "avlnodebunch.h" #define AVLTREE_ZERO { GEN_BUNCH_ZERO, 0 } #define avltree_i(t, i) ((i) ? ((t)->x.x.s[i].data) : 0) #define avltree_len(t) ((t)->x.n - 1) #define avltree_root(t) ((t)->x.x.s[0].left) #define avltree_setroot(t, r) ((t)->x.x.s[0].left = (r)) typedef struct avltree avltree, *avltree_ref ; struct avltree { avlnodebunch x ; int (*cmp)(unsigned int, unsigned int) ; } ; extern void avltree_free (avltree_ref) ; extern int avltree_init (avltree_ref, int (*)(unsigned int, unsigned int)) ; extern unsigned int avltree_search (avltree const *, unsigned int) gccattr_pure ; extern unsigned int avltree_insert (avltree_ref, unsigned int) ; extern unsigned int avltree_delete (avltree_ref, unsigned int) ; extern unsigned int avltree_deletenode (avltree_ref, unsigned int) ; extern unsigned int avltree_height (avltree const *) gccattr_pure ; extern int avltree_iter (avltree_ref, int (*)(unsigned int, unsigned int, void *), void *) ; #endif prog/skalibs-0.47/src/libdatastruct/datastruct.h0100644000000000000000000000027211100046405016705 0ustar /* Public domain. */ #ifndef DATASTRUCT_H #define DATASTRUCT_H #include "avlnode.h" #include "avlnodealloc.h" #include "avlnodebunch.h" #include "list1.h" #include "avltree.h" #endif prog/skalibs-0.47/src/libdatastruct/avlnode.h0100644000000000000000000000034607766030206016200 0ustar /* Public domain. */ #ifndef AVLNODE_H #define AVLNODE_H typedef struct avlnode avlnode, *avlnode_ref ; struct avlnode { unsigned int data ; unsigned int left ; unsigned int right ; signed char balance : 2 ; } ; #endif prog/skalibs-0.47/src/libdatastruct/avlnodealloc.h0100644000000000000000000000026111100030430017157 0ustar /* Public domain. */ #ifndef AVLNODEALLOC_H #define AVLNODEALLOC_H #include "gen_alloc.h" #include "avlnode.h" GEN_ALLOC_PROTOTYPES(avlnodealloc, avlnode, s, len, a) #endif prog/skalibs-0.47/src/libdatastruct/list1.c0100644000000000000000000000053507766034730015605 0ustar /* Public domain. */ #include "diuintbunch.h" #include "list1.h" void list1_free (list1_ref t) { t->cmp = 0 ; diuintbunch_free(&t->x) ; } int list1_init (list1_ref t, int (*f)(unsigned int, unsigned int)) { list1_free(t) ; if (!diuintbunch_new(&t->x)) return 0 ; t->cmp = f ; t->x.x.s[0].left = t->x.x.s[0].right = 0 ; return 1 ; } prog/skalibs-0.47/src/libdatastruct/avlnodealloc.c0100644000000000000000000000022707766030466017214 0ustar /* Public domain. */ #include "gen_alloc.h" #include "avlnode.h" #include "avlnodealloc.h" GEN_ALLOC_BASE_DEFS(avlnodealloc, avlnode, s, len, a, 64) prog/skalibs-0.47/src/libdatastruct/avlnodebunch.c0100644000000000000000000000026407766030563017220 0ustar /* Public domain. */ #include "avlnode.h" #include "avlnodealloc.h" #include "gen_bunch.h" #include "avlnodebunch.h" GEN_BUNCH_DEFS(avlnodebunch, avlnodealloc, avlnode, 256, 16) prog/skalibs-0.47/src/libdatastruct/avlnodebunch.h0100644000000000000000000000031611100046405017176 0ustar /* Public domain. */ #ifndef AVLNODEBUNCH_H #define AVLNODEBUNCH_H #include "avlnode.h" #include "avlnodealloc.h" #include "gen_bunch.h" GEN_BUNCH_PROTOTYPES(avlnodebunch, avlnodealloc, avlnode) #endif prog/skalibs-0.47/src/libdatastruct/avltree.c0100644000000000000000000000053207767221400016201 0ustar /* Public domain. */ #include "avlnodebunch.h" #include "avltree.h" void avltree_free (avltree_ref t) { t->cmp = 0 ; avlnodebunch_free(&t->x) ; } int avltree_init (avltree_ref t, int (*f) (unsigned int, unsigned int)) { avltree_free(t) ; if (!avlnodebunch_new(&t->x)) return 0 ; t->cmp = f ; avltree_setroot(t, 0) ; return 1 ; } prog/skalibs-0.47/src/libdatastruct/avltree_iter.c0100644000000000000000000000120107767221161017222 0ustar /* Public domain. */ #include "avltree.h" struct avltree_iter_s { avlnode_ref s ; int (*f) (unsigned int, unsigned int, void *) ; void *p ; } ; static int avltree_iter_rec (struct avltree_iter_s const *blah, unsigned int r, unsigned int h) { return r ? (!avltree_iter_rec(blah, blah->s[r].left, h+1) || !blah->f(blah->s[r].data, h, blah->p) || !avltree_iter_rec(blah, blah->s[r].right, h+1)) ? 0 : 1 : 1 ; } int avltree_iter (avltree_ref t, int (*f)(unsigned int, unsigned int, void *), void *p) { struct avltree_iter_s blah = { t->x.x.s, f, p } ; return avltree_iter_rec(&blah, avltree_root(t), 0) ; } prog/skalibs-0.47/src/libdatastruct/avltree_height.c0100644000000000000000000000105207766035075017541 0ustar /* Public domain. */ #include "avlnode.h" #include "avltree.h" static unsigned int avltree_height_rec (avlnode const *s, register unsigned int r) { if (!r) return 0 ; if (s[r].balance) return 1 + avltree_height_rec(s, (s[r].balance < 0) ? s[r].left : s[r].right) ; { unsigned int h1 = avltree_height_rec(s, s[r].left) ; register unsigned int h2 = avltree_height_rec(s, s[r].right) ; return 1 + ((h1 > h2) ? h1 : h2) ; } } unsigned int avltree_height (avltree const *t) { return avltree_height_rec (t->x.x.s, avltree_root(t)) ; } prog/skalibs-0.47/src/libdatastruct/list1.h0100644000000000000000000000200011100046405015552 0ustar /* Public domain. */ #ifndef LIST1_H #define LIST1_H #include "gccattributes.h" #include "diuintbunch.h" #define LIST1_ZERO { GEN_BUNCH_ZERO, 0 } #define list1_i(t, i) ((i) ? ((t)->x.x.s[i].right) : 0) #define list1_len(t) ((t)->x.n - 1) #define list1_head(t) ((t)->x.x.s[0].left) #define list1_sethead(t, r) ((t)->x.x.s[0].left = (r)) typedef struct list1 list1, *list1_ref ; struct list1 { diuintbunch x ; int (*cmp)(unsigned int, unsigned int) ; } ; extern void list1_free (list1_ref) ; extern int list1_init (list1_ref, int (*)(unsigned int, unsigned int)) ; extern unsigned int list1_search (list1 const *, unsigned int) gccattr_pure ; extern unsigned int list1_push (list1_ref, unsigned int) ; extern unsigned int list1_insert (list1_ref, unsigned int) ; extern unsigned int list1_deletenext (list1_ref, unsigned int) ; extern unsigned int list1_pop (list1_ref) ; extern unsigned int list1_delete (list1_ref, unsigned int) ; extern int list1_iter (list1_ref, int (*)(unsigned int, void *), void *) ; #endif prog/skalibs-0.47/src/libdatastruct/list1_delete.c0100644000000000000000000000136407766034744017135 0ustar /* Public domain. */ #include "diuintbunch.h" #include "list1.h" unsigned int list1_deletenext (list1_ref t, unsigned int i) { register unsigned int k ; register unsigned int j = t->x.x.s[i].left ; if (!j) return 0 ; k = t->x.x.s[j].right ; t->x.x.s[i].left = t->x.x.s[j].left ; diuintbunch_delete(&t->x, j+1) ; return k ; } unsigned int list1_pop (list1_ref t) { return list1_deletenext(t, 0) ; } unsigned int list1_delete (list1_ref t, unsigned int k) { register unsigned int i = 0 ; for (;;) { register int h ; register unsigned int j = t->x.x.s[i].left ; if (!j) return 0 ; h = (*t->cmp)(k, t->x.x.s[j].right) ; if (!h) break ; if (h < 0) return 0 ; i = j ; } return list1_deletenext(t, i) ; } prog/skalibs-0.47/src/libdatastruct/list1_search.c0100644000000000000000000000050407766034534017130 0ustar /* Public domain. */ #include "list1.h" unsigned int list1_search (register list1 const *t, register unsigned int k) { register unsigned int i = t->x.x.s[0].left ; for (;; i = t->x.x.s[i].left) { register int h = (*t->cmp)(k, t->x.x.s[i].right) ; if (!h) return i ; if (h < 0) break ; } return 0 ; } prog/skalibs-0.47/src/libdatastruct/avltree_insdel.c0100644000000000000000000001105707770631157017553 0ustar /* Public domain. */ #include "avlnode.h" #include "avlnodebunch.h" #include "avltree.h" static unsigned int avlnode_rotate_r (avlnode_ref s, unsigned int i) { register unsigned int j = s[i].left ; s[i].left = s[j].right ; s[j].right = i ; if (s[j].balance < 0) s[i].balance = s[j].balance = 0 ; else s[j].balance = 1 ; return j ; } static unsigned int avlnode_rotate_l (avlnode_ref s, unsigned int i) { register unsigned int j = s[i].right ; s[i].right = s[j].left ; s[j].left = i ; if (s[j].balance > 0) s[i].balance = s[j].balance = 0 ; else s[j].balance = -1 ; return j ; } static unsigned int avlnode_rotate_lr (avlnode_ref s, unsigned int i) { register unsigned int j = s[i].left ; register unsigned int k = s[j].right ; s[i].left = s[k].right ; s[j].right = s[k].left ; s[k].left = j ; s[k].right = i ; s[i].balance = (s[k].balance < 0) ? 1 : 0 ; s[j].balance = (s[k].balance > 0) ? -1 : 0 ; s[k].balance = 0 ; return k ; } static unsigned int avlnode_rotate_rl (avlnode_ref s, unsigned int i) { register unsigned int j = s[i].right ; register unsigned int k = s[j].left ; s[i].right = s[k].left ; s[j].left = s[k].right ; s[k].right = j ; s[k].left = i ; s[i].balance = (s[k].balance > 0) ? -1 : 0 ; s[j].balance = (s[k].balance < 0) ? 1 : 0 ; s[k].balance = 0 ; return k ; } #define MAXDEPTH 256 /* should be more than enough */ unsigned int avltree_insert (avltree_ref t, unsigned int k) { unsigned int i = avlnodebunch_new(&t->x) ; if (!i--) return 0 ; { unsigned int stack[MAXDEPTH] ; signed char spin[MAXDEPTH] ; unsigned char done = 0 ; register unsigned int r = avltree_root(t) ; register unsigned int sp = 0 ; register avlnode_ref s = t->x.x.s ; s[i].data = k ; s[i].left = s[i].right = 0 ; s[i].balance = 0 ; while (r) { stack[sp] = r ; if ((*t->cmp)(k, s[r].data) <= 0) { spin[sp] = -1 ; r = s[r].left ; } else { spin[sp] = 1 ; r = s[r].right ; } sp++ ; } r = i ; while (sp--) { if (spin[sp] < 0) s[stack[sp]].left = r ; else s[stack[sp]].right = r ; if (done) return i ; switch (spin[sp] * s[stack[sp]].balance) { case -1 : s[stack[sp]].balance = 0 ; return i ; case 0 : s[stack[sp]].balance = spin[sp] ; r = stack[sp] ; break ; case 1 : { r = (spin[sp] < 0) ? (s[r].balance < 0) ? avlnode_rotate_r(s, stack[sp]) : avlnode_rotate_lr(s, stack[sp]) : (s[r].balance < 0) ? avlnode_rotate_rl(s, stack[sp]) : avlnode_rotate_l(s, stack[sp]) ; done = 1 ; break ; } } } avltree_setroot(t, r) ; } return i ; } unsigned int avltree_delete (avltree_ref t, unsigned int k) { unsigned int stack[MAXDEPTH] ; signed char spin[MAXDEPTH] ; register unsigned int r = avltree_root(t) ; register unsigned int sp = 0 ; register avlnode_ref s = t->x.x.s ; unsigned char done = 0 ; for (;;) { register int h ; if (!r) return 0 ; h = (*t->cmp)(k, s[r].data) ; if (!h) break ; stack[sp] = r ; if (h < 0) { spin[sp] = -1 ; r = s[r].left ; } else { spin[sp] = 1 ; r = s[r].right ; } sp++ ; } k = r ; if (s[r].left) { stack[sp] = r ; spin[sp++] = -1 ; r = s[r].left ; } while (r) { stack[sp] = r ; spin[sp++] = 1 ; r = s[r].right ; } r = stack[--sp] ; s[k].data = s[r].data ; k = r ; r = s[r].left ; avlnodebunch_delete(&t->x, k+1) ; while (sp--) { if (spin[sp] < 0) s[stack[sp]].left = r ; else s[stack[sp]].right = r ; if (done) return 1 ; switch (spin[sp] * s[stack[sp]].balance) { case 0 : s[stack[sp]].balance = -spin[sp] ; return 1 ; case 1 : s[stack[sp]].balance = 0 ; r = stack[sp] ; break ; case -1 : { switch ((spin[sp] < 0) ? -s[s[stack[sp]].right].balance : s[s[stack[sp]].left].balance) { case 0 : done = 1 ; case -1 : r = (spin[sp] < 0) ? avlnode_rotate_l(s, stack[sp]) : avlnode_rotate_r(s, stack[sp]) ; break ; case 1 : r = (spin[sp] < 0) ? avlnode_rotate_rl(s, stack[sp]) : avlnode_rotate_lr(s, stack[sp]) ; break ; } } } } avltree_setroot(t, r) ; return k ; } unsigned int avltree_deletenode (avltree_ref t, unsigned int i) { return avltree_delete(t, avltree_i(t, i)) ; } prog/skalibs-0.47/src/libdatastruct/list1_insert.c0100644000000000000000000000134507766034761017175 0ustar /* Public domain. */ #include "diuintbunch.h" #include "list1.h" static unsigned int list1_insertthere (register list1_ref t, register unsigned int j, register unsigned int k) { register diuint_ref s = t->x.x.s ; register unsigned int i = diuintbunch_new(&t->x) ; if (!i--) return 0 ; s[i].right = k ; s[i].left = s[j].left ; s[j].left = i ; return i ; } unsigned int list1_push (list1_ref t, unsigned int k) { return list1_insertthere(t, 0, k) ; } unsigned int list1_insert (list1_ref t, unsigned int k) { register unsigned int j = 0 ; for (;;) { register unsigned int i = t->x.x.s[j].left ; if (!i || ((*t->cmp)(k, t->x.x.s[i].right) <= 0)) break ; j = i ; } return list1_insertthere(t, j, k) ; } prog/skalibs-0.47/src/libdatastruct/avltree_search.c0100644000000000000000000000057707767221307017545 0ustar /* Public domain. */ #include "avlnode.h" #include "avltree.h" unsigned int avltree_search (register avltree const *t, register unsigned int k) { register unsigned int r = avltree_root(t) ; register avlnode const *s = t->x.x.s ; while (r) { register int h = (*t->cmp)(k, s[r].data) ; if (!h) return r ; r = (h < 0) ? s[r].left : s[r].right ; } return 0 ; } prog/skalibs-0.47/src/libdatastruct/list1_iter.c0100644000000000000000000000037707766034534016636 0ustar /* Public domain. */ #include "list1.h" int list1_iter (list1_ref t, int (*f)(unsigned int, void *), void *p) { register unsigned int i = t->x.x.s[0].left ; for (; i ; i = t->x.x.s[i].left) if (!(*f)(t->x.x.s[i].right, p)) return 0 ; return 1 ; } prog/skalibs-0.47/package/0040755000000000000000000000000011100047251012317 5ustar prog/skalibs-0.47/package/name0100644000000000000000000000001007674233176013176 0ustar skalibs prog/skalibs-0.47/package/sharing0100644000000000000000000000024407674233176013722 0ustar command:syst compile:syst conf-compile:syst doc:dist include:syst library:syst library.so:syst man:dist package:dist precompiled-sysdeps:dist service:host src:dist prog/skalibs-0.47/package/upgrade0100755000000000000000000000066111100037675013705 0ustar #!/bin/sh -e # Public domain. umask 022 test -d package || { echo 'Wrong working directory.'; exit 100; } test -d src || { echo 'Wrong working directory.'; exit 100; } test -d conf-compile || { echo 'Wrong working directory.'; exit 100; } name=`cat compile/export/conf-name` version=`cat compile/export/conf-version` echo "Creating symlink $name -> $name-$version..." rm -f "$name" ln -s "$name-$version" "$name" mv -f "$name" .. prog/skalibs-0.47/package/compile0100755000000000000000000000047107674233176013724 0ustar #!/bin/sh -e # Public domain. umask 022 test -d package || { echo 'Wrong working directory.'; exit 100; } test -d src || { echo 'Wrong working directory.'; exit 100; } test -d conf-compile || { echo 'Wrong working directory.'; exit 100; } package/prepare package/configure package/make exec package/makeinstall prog/skalibs-0.47/package/install0100755000000000000000000000046111077707654013740 0ustar #!/bin/sh -e # Public domain. umask 022 test -d package || { echo 'Wrong working directory.'; exit 100; } test -d src || { echo 'Wrong working directory.'; exit 100; } test -d conf-compile || { echo 'Wrong working directory.'; exit 100; } package/compile package/export package/upgrade exec package/run prog/skalibs-0.47/package/README0100644000000000000000000000040411051022523013172 0ustar skalibs-0.47 (C) 2002-2008 Laurent Bercot skalibs homepage: http://www.skarnet.org/software/skalibs/ See http://www.skarnet.org/software/skalibs/install.html for installation instructions. This software is in the public domain. prog/skalibs-0.47/package/versions0100644000000000000000000000027611051022474014121 0ustar 0.10 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.20 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.30 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.40 0.41 0.42 0.43 0.44 0.45 0.46 0.47 prog/skalibs-0.47/package/version0100644000000000000000000000000511051022501013713 0ustar 0.47 prog/skalibs-0.47/package/run0100755000000000000000000000036007674233176013075 0ustar #!/bin/sh -e # Public domain. umask 022 test -d package || { echo 'Wrong working directory.'; exit 100; } test -d src || { echo 'Wrong working directory.'; exit 100; } test -d conf-compile || { echo 'Wrong working directory.'; exit 100; } prog/skalibs-0.47/package/compat0100755000000000000000000000135611100037354013535 0ustar #!/bin/sh -e # Public domain. umask 022 test -d package || { echo 'Wrong working directory.'; exit 100; } test -d src || { echo 'Wrong working directory.'; exit 100; } test -d conf-compile || { echo 'Wrong working directory.'; exit 100; } spr=`cat compile/export/conf-sp_root` exportit() { dir="$1" dest="$2" test -f "package/$dir.compat" && { echo "Making links from $dest to $spr/$dir..." mkdir -p "$dest" for i in `cat "package/$dir.compat"` do rm -f "$dest/$i"'{new}' ln -s "$spr/$dir/$i" "$dest/$i"'{new}' mv -f "$dest/$i"'{new}' "$dest/$i" done } || true } exportit command /usr/local/bin exportit include /usr/local/include exportit library /usr/local/lib exportit library.so /usr/local/lib prog/skalibs-0.47/package/distclean0100755000000000000000000000044507674233176014243 0ustar #!/bin/sh -e # Public domain. umask 022 test -d package || { echo 'Wrong working directory.'; exit 100; } test -d src || { echo 'Wrong working directory.'; exit 100; } test -d conf-compile || { echo 'Wrong working directory.'; exit 100; } exec rm -rf compile command include library sysdeps prog/skalibs-0.47/package/compilesub0100755000000000000000000000105007674233176014430 0ustar #!/bin/sh -e # Public domain. umask 022 test -d package || { echo 'Wrong working directory.'; exit 100; } test -d src || { echo 'Wrong working directory.'; exit 100; } test -d conf-compile || { echo 'Wrong working directory.'; exit 100; } s="$1" test -n "$s" || ( echo usage: compilesub subsys ; exit 100 ) echo Making subsystem "$s"... cd "compile/$s" for i in `ls ../export` ; do test -r "$i" || ln -s "../export/$i" . done make for i in `cat EXPORT` ; do rm -f "../export/$i" ln -s "../$s/$i" ../export done echo Subsystem "$s" done. echo prog/skalibs-0.47/package/subsystems0100644000000000000000000000013711100046227014463 0ustar headers libstddjb libwebipc libstdcrypto librandom libdns libbiguint libdatastruct libttymodes prog/skalibs-0.47/package/distribution0100644000000000000000000000006407674233176015006 0ustar Every part of this package is in the public domain. prog/skalibs-0.47/package/CHANGES0100644000000000000000000002614111100056334013315 0ustar 20020916 version: 0.10 20020930 bug: invalid IOBUFFER_INIT in iobuffer.h fix: obvious. bug: skamisc.h didn't include fmtscan.h (for FMT_ULONG) fix: obvious. version: 0.11 20021002 code: added new fmt_ and scan_ functions internal: removed ndelay_off() from slurp.c internal: fixed allreadwrite.h update version: 0.12 20021014 portability: added test portability: added pflocal.h to libwebipc internal: -W warning cleanups internal: added cdb_init test internal: removed useless libdns statics code: added libstdcrypto version: 0.13 20021021 internal: modified slurp and allreadwrite for error reporting 20021022 code: added EGD support to librandom code: added libbiguint ui: merged sha1, rc4, md5 into libstdcrypto.a. internal: fixed syspollh.h sysdep typo doc: reflected change 20021101 doc: added libbiguint version: 0.14 20021102 bug: libwebipc: ipc_accept didn't zero sa.sunpath. fix: obvious. 20021118 bug: libdns: forgot to include dns_resolve_r in objects fix: obvious. 20021122 code: added lock_sh and lock_shnb, fd_copy2 and fd_move2 internal: changed bu_invmod negativity test 20021130 ui: added environ.h 20021201 doc: fixed & -> & 20021205 code: added wait_pid_nohang code: split up alloc, made USE_DJBALLOC useful 20021206 code: added iobuffer_available version: 0.15 20021212 code: added taia_tai, taia_frac, and caltimedate version: 0.16 20021214 bug: wrong choose dependencies in sys fix: obvious. code: added hastiocr code: added libttymodes 20021218 doc: minimal libttymodes doc bug: one read is not enough in trydevr.c fix: replace read by allread portability: on OpenBSD, headers are not self-contained. Dorks. workaround: explicitly include . Yuck. code: defensively add dummies to try* code: added ENOSYS to dummy getpeereid portability: added T8 macro to bytestr.h, used it version: 0.17 20030111 bug: did not define alloc_0 properly in alloc_0.c and alloc_internal.h fix: replace #ifdef by #ifndef version: 0.18 20030117 ui: added up to 10 args to strerr_* internal: removed struct strerr ui: added strerr2.h 20030207 ui: updated sig.h portability: added "|| true" to packaging scripts 20030218 ui: changed byte_(r)chr prototype to add const code: added netstring_encode and netstring_decode 20030219 code: added byte_in, skagetlnsep 20030226 code: added pathexec0, pathexec0_run bug: leapsecs_read declared static structures fix: obvious. version: 0.19 bug: wrong endianness for tai*_*pack fix: make them big-endian, create tai*_*pack_little 20030302 ui: added int sig_kill version: 0.20 20030312 ui: added const to wait_pids_nohang prototype 20030316 doc: documented PROG variable 20030317 portability: partial glob() support on FreeBSD-4.6. Dorks. workaround: added posixglob sysdep and shglob header 20030320 bug: bad bu_invmod() fix: used Sheueling Chang Shantz algorithm. Fixes minssl. :) ui: added bu_divmod() 20030325 doc: updated libbiguint.html internal: optimized bu_divmod() version: 0.21 20030329 internal: joined alloc, stralloc ui: changed GEN_ALLOC prototypes code: added intalloc, uint*alloc code: added error_inval 20030402 internal: fixed stddjb.h dependencies 20030406 ui: added gccattributes.h to headers internal: added gccattributes support to all subsystems 20030407 version: 0.22 code: added str_rchr 20030408 ui: moved (in gccattributes) _a_* to gccattr_* internal: added explicit unsigned char * casts to pack functions internal: simplified reverse functions 20030409 version: 0.23 20030413 ui: exported ttymodes 20030507 ui: moved to bug: wrong ttymodes prototypes fix: obvious 20030514 code: added open_excl doc: added links to djb's doc packaging: added conf-compile (man, was that hard) version: 0.24 portability: doesn't exist everywhere. Sigh. fix: add inttypes.h test and a default definition 20030515 code: rewrote librandom to spare open()/close() 20030523 code: added envalloc, rewrote pathexec, added reentrant functions ui: removed drop_* 20030524 doc: reflected changes internal: changed const foo to foo const portability: tested src/sys/try*.c 20030531 internal: made env(alloc) maximally reentrant code: added gen_alloc reverse ui: added env.h 20030603 version: 0.25 20030611 portability: head -1 -> head -n 1 20030615 code: added uint32aalloc 20030617 packaging: clearly separated conf-compile files 20030618 packaging: added support for cross-compilation doc: documented it version: 0.26 20030619 ui: moved sysdeps.h to sysdeps/ packaging: added conf-striplibs and conf-stripbins portability: changed subshell construct from () to {} doc: added dank-cross-notes.html doc: fixed inaccuracies in doc/* version: 0.27 20030629 fixed taia_ulong.c comment ui: added taia_get_* macros, timestamp_* functions 20030701 code: added tain functions internal: rewrote timestamp functions to use tain internal: removed unused taia_nano.c 20030708 version: 0.28 20030713 ui: added tai_secp() 20030716 bug: GEN_ALLOC_clean() didn't update x->a fix: obvious internal: reduced stralloc base to 256 20030727 version: 0.29 20030730 bug: forgot to include tain_* functions in libstddjb.a fix: obvious 20030804 version: 0.30 20030819 bug: str_diffn tested !s, not !*s fix: obvious 20030831 code: add tai(a) to/from timeval conversion functions internal: rewrote uint16/32/64 header building code: added uint16/32/64 fmtscan functions bug: with malloc0, ska_alloc_realloc freed when realloc'ed to 0 fix: work around realloc() like alloc_0 does version: 0.31 20030902 bug: wrong str_diffn (I'm good at being ridiculous these days) fix: obvious version: 0.32 20031006 code: added ipc_dgram 20031012 bug: wrong case_* tests fix: revert to djb's tests (found & suggested by Paul Jarc). code: added taia_addsec 20031013 code: added case_upper[bs], case_equalb 20031018 version: 0.33 20031105 packaging: added sp_root support, added early failure for import 20031107 ui: added error_nobufs code: rewrote rmstar() => suitable for SUSv3 rm 20031109 code: added str_strn.c code: simplified libdns 20031114 ui: simplified sgetopt interface code: rewrote sgetopt/subgetopt, with SUSv3 and reentrant versions 20031129 internal: reorganized gen_alloc to handle smarter deps code: added libdatastruct 20031202 internal: added USE_BASE_LIBC macro for optimized libcs 20031203 code: finished gen_avltree internal: added DEBUG_ALLOC macro for profiling 20031205 portability: fixed rm_rf (grr FreeBSD) 20031207 code: more libdatastruct fixes 20031209 version: 0.34 20031215 ui: changed libdatastruct API code: rewrote libdatastruct ui: changed dirname to match SUS code: added sadirname internal: restored old thanks file :-( 20031225 internal: minor code cleanups doc: updated version: 0.35 20031226 code: added EINTR workarounds for reliability internal: added optional strerror() dependency code: separated stralloc.c and stralloc_x.c internal: major cleanups 20031227 code: rewrote sadirname, added sabasename and friends ui: made basename() SUSv3-compliant code: finally got a working realpath 20031230 internal: too many changes. 20040101 version: 0.36 20040120 bug: allreadwrite couldn't report EAGAIN fix: obvious internal: moved all fmt functions to uint64 code: added uncoe.c, changed coe.c code: added cdb_traverse version: 0.37 20040122 bug: ushort_fmt and al. macros didn't truncate properly fix: add casts code: completely rewrote fmtscan to eliminate code duplication ui: added new fmtscan APIs and ready-to-use functions version: 0.38 20040124 bug: extraneous semicolons in uint16 macros. Ook ! fix: obvious bug: lock_exnb.c didn't export lock_exnb(). Ook ! fix: obvious bug: since 0.34, wrong dns_domain_equal() macro. Ook ! Ook ! Oook ! fix: !case_diffs() instead of case_diffs() version: 0.39 20040125 internal: rewrote signal management 20040126 ui: added selfpipe 20040203 ui: changed allreadwrite interface internal: moved buffer to new allreadwrite API internal: moved random_readint and friends to new allreadwrite API ui: added buffer_fd (without a cast, only to annoy Paul :-þ) 20040205 version: 0.40 20040306 portability: added oksyssocket sysdep. (BSD strikes again !) bug: bu_scan didn't work with new scan API fix: added ucharn_findlen, rewrote bu_scan bug: socket_timeoutconn returned 0 if error after writability fix: change to -1 ui: added missing consts in webipc.h prototypes 20040308 ui: added socket_deadlineconn 20040309 bug: lots of try* didn't compile on Solaris 7 impact: invalid sysdeps for Solaris 7 :( fix: remove as many system headers as possible. Use . 20040311 ui: added explicit-temporary-storage prototypes ui: added reentrant prototypes internal: rewrote a lot around it ui: deleted readclose doc: tagged MT-unsafe object files in source 20040327 bug: absolutepath_tmp didn't detect symloops. Ook ! fix: add a manual loop count (ugh) version: 0.41 20040328 bug: bad dns_ipq() emulation fix: more MT-safe / MT-unsafe wrapping in libdns 20040409 internal: finished (hopefully) libdns rewriting version: 0.42 20040418 code: brand new librandom ui: EMFILE is now permanent (suggested by Paul Jarc) bug: unirandomegd and unirandomdev didn't coe fix: obvious. bug: taia_tai.o wasn't in the makelib list. fix: obvious. version: 0.43 20040517 doc: EGD support has been tested, woohoo bug: (theoretically) possible memleak in gen_bunch fix: add wasnull safeguards bug: '=' instead of '==' in lock_exnb and lock_ex. Ook ! fix: obvious 20041022 portability: Linux sometimes gives POLLHUP w/o POLLIN on close fix: make IOPAUSE_READ = POLLIN|POLLHUP. Yuck. 20041103 version: 0.44 20050201 bug: syntax error in sig_unshield.c if not HASSIGPROCMASK fix: obvious bug: syntax error in wait_pid.c if not HASWAITPID fix: widen "r" scope internal: simplified libdns version: 0.45 20051013 bug: huge memleak in cdb_make (hello, djb?? oO) fix: entirely rewrote cdb_make, using diuint32allocs ui: deleted cdb_make_addbegin and cdb_make_addend entry points internal: various optimizations and readability cleanups 20060131 bug: wait_pids_nohang() returned 0 ambiguously fix: return 1+i instead of i. Changes the ui. 20060625 build: added trydevr warning 20061224 build: trystreams.c failed on a dietlibc+glibc installation. fix: add #include 20070119 ui: changed alloc_re and alloc_realloc prototypes 20070125 version: 0.46 20080814 bug: possible crash in dns_rcipit fix: force n=0 ui: added various _ZERO macros for gen_alloc-based types 20080817 build: corrected typo in warn-trydevr internal: various dependency cleanups 20080818 ui: added return code of 2 to skagetln when buffer_fill is called 20081013 internal: improved first alloc in gen_alloc.h 20081022 portability: strip -x is broken on some Solaris platforms workaround: empty default conf-compile/conf-striplibs packaging: redesigned install/upgrade/compat 20081023 doc: wrote selfpipe.html build: compile libstdcrypto before librandom, duh. build: also modified package/prepare for conf-compile/ security packaging: removed writability on read-only dirs version: 0.47 prog/skalibs-0.47/package/prepare0100755000000000000000000000377011100046132013704 0ustar #!/bin/sh -e # Public domain. umask 022 test -d package || { echo 'Wrong working directory.'; exit 100; } test -d src || { echo 'Wrong working directory.'; exit 100; } test -d conf-compile || { echo 'Wrong working directory.'; exit 100; } mkdir -p compile/export echo 'Linking ./src into ./compile...' for i in `ls src` ; do if test -d "src/$i" ; then mkdir -p "compile/$i" for j in `ls src/$i` ; do test -r "compile/$i/$j" || ln -s "../../src/$i/$j" "compile/$i/$j" done else test -r "compile/$i" || ln -s "../src/$i" "compile/$i" fi done echo echo 'Importing ./conf-compile files into the build tree...' echo '(Remove the compile/ subdirectory if conf-compile/ has been modified since the last build.)' for i in `ls -1 conf-compile | grep conf-` ; do test -r "compile/export/$i" || head -n 1 < "conf-compile/$i" > "compile/export/$i" done test -r compile/export/conf-category || cat package/category > compile/export/conf-category test -r compile/export/conf-name || cat package/name > compile/export/conf-name test -r compile/export/conf-version || cat package/version > compile/export/conf-version test -r compile/export/conf-sp_root || echo > compile/export/conf-sp_root test -r compile/export/conf-home || echo `cat compile/export/conf-sp_root`/package/`cat compile/export/conf-category`/`cat compile/export/conf-name` > compile/export/conf-home echo test -r conf-compile/import && { echo 'Importing external files...' spr=`cat compile/export/conf-sp_root` for i in `sed "s|\\$SP_ROOT|$spr|" < conf-compile/import` ; do if test -d "$i" ; then for j in `ls "$i"` ; do rm -f "compile/export/$j" echo "Importing $i/$j" ln -s "$i/$j" "compile/export/$j" done else echo "Wrong import directory: $i" exit 100 fi done echo } || true echo 'Linking include files...' for i in sys `cat package/subsystems` ; do for j in `cat "src/$i/INCLUDE"` ; do test -r "compile/export/$j" || ln -s "../$i/$j" "compile/export/$j" done done echo prog/skalibs-0.47/package/make0100755000000000000000000000046707674233176013216 0ustar #!/bin/sh -e # Public domain. umask 022 test -d package || { echo 'Wrong working directory.'; exit 100; } test -d src || { echo 'Wrong working directory.'; exit 100; } test -d conf-compile || { echo 'Wrong working directory.'; exit 100; } for i in `cat package/subsystems` ; do package/compilesub "$i" ; done prog/skalibs-0.47/package/makeinstall0100755000000000000000000000360707674233176014604 0ustar #!/bin/sh -e # Public domain. umask 022 test -d package || { echo 'Wrong working directory.'; exit 100; } test -d src || { echo 'Wrong working directory.'; exit 100; } test -d conf-compile || { echo 'Wrong working directory.'; exit 100; } test -r package/command && { mkdir -p command echo 'Copying commands into ./command...' cat package/command | while read a b ; do chmod "$b" "compile/export/$a" rm -f "command/$a"'{new}' cp -p "compile/export/$a" "command/$a"'{new}' mv -f "command/$a"'{new}' "command/$a" done } || true test -r package/library && { mkdir -p library echo 'Copying libraries into ./library...' for i in `cat package/library` ; do rm -f "library/$i"'{new}' cp -p "compile/export/$i" "library/$i"'{new}' mv -f "library/$i"'{new}' "library/$i" done } || true test -r package/library.so && { mkdir -p library.so echo 'Copying shared libraries into ./library.so...' for i in `cat package/library.so` ; do rm -f "library.so/$i"'{new}' cp -p "compile/export/$i" "library.so/$i"'{new}' mv -f "library.so/$i"'{new}' "library.so/$i" done } || true test -r package/include && { mkdir -p include echo 'Copying header files into ./include...' for i in `cat package/include` ; do rm -f "include/$i"'{new}' cp -p "compile/export/$i" "include/$i"'{new}' mv -f "include/$i"'{new}' "include/$i" done } || true test -r package/man && { mkdir -p man echo 'Copying manual pages into ./man...' for i in `cat package/man` ; do rm -f "man/$i"'{new}' cp -p "compile/export/$i" "man/$i"'{new}' mv -f "man/$i"'{new}' "man/$i" done } || true test -r package/sysdeps && { mkdir -p sysdeps echo 'Copying sysdeps files into ./sysdeps...' for i in `cat package/sysdeps` ; do rm -f "sysdeps/$i"'{new}' cp -p "compile/export/$i" "sysdeps/$i"'{new}' mv -f "sysdeps/$i"'{new}' "sysdeps/$i" done } || true echo prog/skalibs-0.47/package/include0100644000000000000000000000141010321255131013660 0ustar gccattributes.h skalibs-version.h uint16.h uint32.h uint64.h direntry.h select.h iopause.h shglob.h syssocket.h alloc.h intalloc.h uintalloc.h uintbunch.h uint16alloc.h uint32alloc.h uint64alloc.h uint32aalloc.h allreadwrite.h env.h envalloc.h bufalloc.h buffer.h bytestr.h caltimedate.h cdb.h cdb_make.h djbunix.h environ.h error.h fmtscan.h gen_alloc.h iobuffer.h netstring.h sgetopt.h sig.h selfpipe.h skamisc.h socket.h stddjb.h stralloc.h strerr.h strerr2.h tai.h webipc.h rc4.h md5.h sha1.h stdcrypto.h surf.h unirandom.h rrandom.h random.h dns.h dns_helper.h dns_transmit.h biguint.h datastruct.h bitarray.h gen_bunch.h diuint.h diuintalloc.h diuintbunch.h diuint32.h diuint32alloc.h diuint32bunch.h avlnode.h avlnodealloc.h avlnodebunch.h list1.h avltree.h ttymodes.h prog/skalibs-0.47/package/category0100644000000000000000000000000507674233176014077 0ustar prog prog/skalibs-0.47/package/library0100644000000000000000000000014707755311562013731 0ustar libstddjb.a libwebipc.a librandom.a libdns.a libstdcrypto.a libbiguint.a libdatastruct.a libttymodes.a prog/skalibs-0.47/package/sysdeps0100644000000000000000000000005607674254243013760 0ustar sysdeps.h sysdeps systype socket.lib util.lib prog/skalibs-0.47/package/THANKS0100644000000000000000000000114411100031043013217 0ustar Dan J. Bernstein - original code - Unix software design mentor William E. Baxter - libwebipc Jean Marot - bugfixes Paul Jarc - bugfixes, suggestions Nicolas George - bugfixes Taj Khattra - bug-reports - documentation fixes Dan Kegel - cross-compilation portability advice - doc contribution Stefan Karrmann - add-ons Matthew R. Dempsky - bugfixes David A. Madore - portability tests prog/skalibs-0.47/package/crosscompile0100755000000000000000000000075007674233176014776 0ustar #!/bin/sh -e # Public domain. umask 022 test -d package || { echo 'Wrong working directory.'; exit 100; } test -d src || { echo 'Wrong working directory.'; exit 100; } test -d conf-compile || { echo 'Wrong working directory.'; exit 100; } test -n "$1" || ( echo "crosscompile: usage: crosscompile sysdepdir" ; exit 100 ) test -d "$1" || ( echo "crosscompile: usage: crosscompile sysdepdir" ; exit 100 ) package/prepare package/crossconfigure "$1" package/make exec package/makeinstall prog/skalibs-0.47/package/configure0100755000000000000000000000050307674233176014251 0ustar #!/bin/sh -e # Public domain. umask 022 test -d package || { echo 'Wrong working directory.'; exit 100; } test -d src || { echo 'Wrong working directory.'; exit 100; } test -d conf-compile || { echo 'Wrong working directory.'; exit 100; } package/compilesub systype package/compilesub sys exec package/compilesub sysdeps prog/skalibs-0.47/package/crossconfigure0100755000000000000000000000126307674233176015327 0ustar #!/bin/sh -e # Public domain. umask 022 test -d package || { echo 'Wrong working directory.'; exit 100; } test -d src || { echo 'Wrong working directory.'; exit 100; } test -d conf-compile || { echo 'Wrong working directory.'; exit 100; } test -n "$1" || ( echo "crossconfigure: usage: crossconfigure sysdepdir" ; exit 100 ) test -d "$1" || ( echo "crossconfigure: usage: crossconfigure sysdepdir" ; exit 100 ) echo "Importing precompiled sysdeps files from $1..." for i in `cat src/systype/EXPORT` `cat src/sysdeps/EXPORT` ; do test -f "$1/$i" || ( echo "no $i file in $1" ; exit 100 ) rm -f "compile/export/$i" cp -f "$1/$i" compile/export/ done echo exec package/compilesub sys prog/skalibs-0.47/package/export0100755000000000000000000000145711100047242013572 0ustar #!/bin/sh -e # Public domain. umask 022 test -d package || { echo 'Wrong working directory.'; exit 100; } test -d src || { echo 'Wrong working directory.'; exit 100; } test -d conf-compile || { echo 'Wrong working directory.'; exit 100; } spr=`cat compile/export/conf-sp_root` category=`cat compile/export/conf-category` name=`cat compile/export/conf-name` exportit() { dir="$1" test -f "package/$dir.exported" && { echo "Making links in $spr/$dir..." mkdir -p "$spr/$dir" for i in `cat "package/$dir.exported"` do rm -f "$spr/$dir/$i"'{new}' ln -s "../package/$category/$name/$dir/$i" "$spr/$dir/$i"'{new}' mv -f "$spr/$dir/$i"'{new}' "$spr/$dir/$i" done } || true } exportit command exportit library exportit library.so exportit include exportit man exportit doc prog/skalibs-0.47/doc/0040755000000000000000000000000011100035071011466 5ustar prog/skalibs-0.47/doc/index.html0100644000000000000000000000554607765176440013526 0ustar skalibs

Software
www.skarnet.org

skalibs

What is it ?

skalibs is a package centralizing the public-domain C development files I use for building other software: it contains essentially general-purpose libraries. You will need to install skalibs if you plan to build skarnet.org software. The point is that you won't have to download and compile big libraries everytime you need to build a package: do it only once.

skalibs can also be used as a sound basic start for C development. There are a lot of general-purpose libraries out there; but if your main goal is to produce small and secure C code, you will like skalibs.

skalibs contains exclusively public-domain code. So you can redistribute it as you want, and it does not prevent you from distributing any of your executables.


Reference

Header files

Libraries


Related resources

prog/skalibs-0.47/doc/install.html0100644000000000000000000000735611100034775014044 0ustar How to install skalibs

skalibs
Software
www.skarnet.org

How to install skalibs

Like any other piece of software (and information generally), skalibs comes with NO WARRANTY.

Requirements

System

  • A Unix-like system

Build-time

  • A standard C development environment

Run-time

No dependencies.

Installation

skalibs follows the slashpackage convention.

  • Create a /package directory:
         mkdir -p /package
         chmod 1755 /package
         cd /package
    
  • Download the latest version of skalibs, skalibs-0.47.tar.gz, into /package.
  • Unpack the skalibs package:
         tar -zxpvf skalibs-0.47.tar.gz
         # if you do not have GNU tar, check with your gunzip and tar manual pages.
         rm skalibs-0.47.tar.gz
         cd prog/skalibs-0.47
    
  • If you're trying to build skalibs in a cross-compilation environment, then read that page.

    The following instructions assume that you are installing skalibs as a native standalone package.
  • If you want to use another compiler and linker than the default, edit conf-compile/conf-cc and conf-compile/conf-ld as needed. Edit conf-compile/conf-stripbins if you need to change the way the binaries are stripped. (Since skalibs does not export any executables, this has no real influence.) Edit conf-compile/conf-striplibs if you need to change the way the libraries are stripped.
  • If you want EGD support, edit conf-compile/conf-egd so that the first line contains the full path to your EGD socket.
  • If for some reason your slashpackage installation is in $prefix/package, for instance if you're not root, then unpack the skalibs package into $prefix/package and tell it about your prefix:
         echo $prefix > conf-compile/conf-sp_root
    
    The build system will then install the software into a slashpackage tree residing in $prefix.
    Note that this is not recommended, because it makes you lose the ability to hardcode paths into your scripts, which is the main benefit of a slashpackage installation.
  • Then compile and set up skalibs:
         package/install
    
    The libraries will be available under /package/prog/skalibs/library/ and the header files under /package/prog/skalibs/include/. System-dependent files that other packages may use to automatically configure for your system can be found under /package/prog/skalibs/sysdeps/.
  • To report success :
    	 cat package/name package/version sysdeps/sysdeps sysdeps/sysdeps.h | mail ska-sysdeps@skarnet.org
    
  • You can then delete the compile subdirectory to save disk space.
prog/skalibs-0.47/doc/librandom.html0100644000000000000000000001112410040440774014333 0ustar skalibs: the random library interface

skalibs
Software
www.skarnet.org

The random library interface

librandom is a small library designed to provide an interface to some reasonable-quality pseudorandom number generation. Some libcs have a bad random() implementation; librandom is designed to use system pseudorandom number generation when it's provided via /dev/random and /dev/urandom, and to use a good default PRNG otherwise.

Starting with skalibs-0.14, librandom supports EGD. If you have built skalibs with the right conf-egd, then the librandom primitives will try and connect to an EGD service to get random bytes if there is no kernel-based entropy generator such as /dev/random. If the EGD connection fails, a SURF PRNG is used.

Compiling

  • Add /package/prog/skalibs/include to your header directory list
  • Use #include "random.h"

Linking

  • Define a global variable PROG of type char const * that contains the name of your executable.
  • Link against /package/prog/skalibs/library/librandom.a, /package/prog/skalibs/library/libstdcrypto.a and /package/prog/skalibs/library/libstddjb.a.
  • If you're using EGD, you will need to link against /package/prog/skalibs/library/librandom.a, /package/prog/skalibs/library/libstdcrypto.a, /package/prog/skalibs/library/libwebipc.a and /package/prog/skalibs/library/libstddjb.a, and add the switches specified by /package/prog/skalibs/sysdeps/socket.lib to your compiler command line for linking.

Programming

You should refer to the random.h header for the exact function prototypes.

High quality, cryptographically strong random data

  unsigned char c ;
  unsigned int max ;
  unsigned int n ;
  unsigned int b ;
  char data[at least b] ;
  int r ;

  goodrandom_init() ;
  c = goodrandom_char() ;
  n = goodrandom_int(max) ;
  r = goodrandom_string(data, b) ;
  goodrandom_finish() ;

goodrandom_init() becomes optional with skalibs-0.43. It is recommended that you let the library perform cleanups after you have used it, by calling goodrandom_finish().

  • goodrandom_char() returns a random character
  • goodrandom_int(max) returns a random integer between 0 and max-1
  • goodrandom_string(data, b) puts b random bytes in data, which must be preallocated. It returns b if it succeeds, or a non-negative integer lesser than b if it fails for any reason.

If you have neither /dev/random nor EGD, a software PRNG is used. This PRNG is based on the SURF function, which is unpredictable enough for most uses.

Lower quality random data

It works basically the same, by replacing goodrandom_* with badrandom_*. It uses /dev/urandom on systems that support it; on systems that do not, but support EGD, non-blocking calls to EGD are made ; if that is not enough, or EGD is not supported, the SURF generator is used.

The point of badrandom is to get random bytes instantly, even at the expense of quality; whereas goodrandom always returns high-quality random bytes, but may block if entropy is insufficient. In practice, in spite of its name, badrandom will return quite unpredictable pseudo-random data, so goodrandom should be used only when paranoia is the rule and blocking is an option.

prog/skalibs-0.47/doc/libstddjb.html0100644000000000000000000001073311100026556014326 0ustar skalibs: the stddjb library interface

skalibs
Software
www.skarnet.org

The stddjb library interface

libstddjb is a general-purpose C library wrapping some system calls, hiding some Unix portability problems, providing some basic low-level buffering functions and string handling, and generally offering a nice API to Unix programming - in many ways nicer and safer than the "standard" Unix APIs like stdio.h.

It is mostly based on some excellent code written and placed into the public domain by D. J. Bernstein.

Compiling

  • Add /package/prog/skalibs/include to your header directory list
  • Use #include "stddjb.h"

Linking

  • Define a global variable PROG of type char const * that contains the name of your executable.
  • Link against /package/prog/skalibs/library/libstddjb.a.

Programming

There are way too many functions to document them extensively. Feel free to look at the stddjb.h file and the included .h files, and to browse the source code; it should be easy enough to read.

Some documentation is available on DJB's site:

Some documentation is available here:

Please note that the documentation is not exhaustive: I have often added functions to the documented set. Sometimes the implementation is quite different from DJB's, and the documented functions are not the most useful ones: buffer is in that case. The only accurate source of information is the header and source files in src/libstddjb/. However, outright incompatibilities are noted in the present file.

  • The #include directives mentioned in DJB's documentation are not valid with skalibs. Only use "stddjb.h" or the relevant sub-files of stddjb.h.
  • If the PATH environment variable is empty, the pathexec functions default to /command, not to /usr/bin:/bin.
  • strallocs, like every gen_alloc, must be initialized to GEN_ALLOC_ZERO, not to {0}. The gen_alloc macros also have a different prototype.
  • The getln and getln2 functions are considered obsolete. Use skagetln instead.

Every skarnet.org package uses libstddjb, which is the basis for safe C/Unix programming. The source code of skadns can be used as a libstddjb usage example.

prog/skalibs-0.47/doc/libwebipc.html0100644000000000000000000000414707720422453014340 0ustar skalibs: the webipc library interface

skalibs
Software
www.skarnet.org

The webipc library interface

libwebipc is a small library designed to simplify Unix domain sockets programming. It is based on code written and placed into the public domain by William E. Baxter for the ucspi-ipc package.

Compiling

  • Add /package/prog/skalibs/include to your header directory list
  • Use #include "webipc.h"

Linking

  • Define a global variable PROG of type char const * that contains the name of your executable.
  • Link against /package/prog/skalibs/library/libwebipc.a and /package/prog/skalibs/library/libstddjb.a.
  • On some systems (for instance Solaris) you will need to link your executables against the libsocket and libnsl libraries too. The /package/prog/skalibs/sysdeps/socket.lib should contain the necessary switches to add to your compiler command line for linking.

Programming

Feel free to look at the webipc.h file, and to browse the source code; it should be easy enough to read, and the library is quite small.

prog/skalibs-0.47/doc/libbiguint.html0100644000000000000000000002210507720424506014523 0ustar skalibs: the biguint library interface

skalibs
Software
www.skarnet.org

The biguint library interface

biguint is set of simple primitives performing arithmetical operations on (unsigned) integers of arbitrary length. It is nowhere near as powerful or efficient as specialized, assembly language-optimized libraries such as GMP, but it has the advantages of smallness and simplicity. biguint was developed for use in minssl; now that it provides every function that minssl needs, no feature will most probably be added.

Compiling

  • Add /package/prog/skalibs/include to your header directory list
  • Use #include "uint32.h" and #include "biguint.h"

Linking

  • Define a global variable PROG of type char const * that contains the name of your executable.
  • Link against /package/prog/skalibs/library/libbiguint.a and /package/prog/skalibs/library/libstddjb.a.

Programming

You should refer to the biguint.h header for the exact function prototypes.

Definitions

  • A biguint x is a pointer to an array u of uint32, together with an unsigned integer n called its length.
    x = (2^32)^0 * u[0] + (2^32)^1 * u[1] + ... + (2^32)^(n-1) * u[n-1].
    n must be lesser than BIGUINT_MAXLIMBS, which is currently 64.
  • Every u[i] is called a limb.
  • The greatest integer i lesser than n for which u[i] is non-zero is called the order of x. The order of zero is 0.

Basic operations

Creating a biguint

Just declare uint32 x[BIGUINT_MAXLIMBS] ; . In the following, we will refer to a biguint as a uint32 *; remember that it must be pre-allocated.

Setting it to zero

uint32 *x ;
unsigned int n ;

 bu_zero(x, n) ;

bu_zero() sets the first n limbs of x to zero.

Copying a biguint

uint32 const *x ;
uint32 *y ;
unsigned int n ;

 bu_copy(y, x, n) ;

bu_copy() will copy the first n limbs from x to y.

Calculating the order

uint32 const *x ;
unsigned int n ;
unsigned int r ;

 r = bu_len(x, n) ;

bu_len() outputs the order of x of length n. 0 <= r <= n.

Comparing two biguints

uint32 const *a ;
uint32 const *b ;
unsigned int n ;
int r ;

 r = bu_cmp(a, b, n) ;

bu_cmp() returns -1 if a < b, 1 if a > b, and 0 if a = b. a and b must have the same length n.

I/O operations

Writing a biguint as an array of bytes

char *s ;
uint32 const *x ;
unsigned int n ;

 bu_pack(s, x, n) ;
 bu_pack_big(s, x, n) ;

bu_pack() writes 4*n bytes to s. The bytes are a little-endian representation of x.
bu_pack_big() is the same, with a big-endian representation.

Reading a biguint from an array of bytes

char const *s ;
uint32 *x ;
unsigned int n ;

 bu_unpack(s, x, n) ;
 bu_unpack_big(s, x, n) ;

bu_unpack() reads 4*n little-endian bytes from s and builds the corresponding biguint x.
bu_unpack_big() is the same, but the bytes are interpreted as big-endian.

Formatting a biguint for readable output

char *s ;
uint32 const *x ;
unsigned int n ;

 bu_fmt(s, x, n) ;

bu_fmt() writes x in s as a standard big-endian hexadecimal number. x is considered of length n, so 8*n bytes will be written to s, even if it x starts with zeros.

Reading a biguint from readable format

char const *s ;
uint32 *x ;
unsigned int n ;
unsigned int r ;

 r = bu_scan(s, x, &n) ;

bu_scan() is the inverse of bu_fmt(): some bytes are read from s, and they build a biguint x of computed length n. The reading stops at the first byte encountered that is not in the 0-9, A-F or a-f range. bu_scan() returns the number of bytes read.

Arithmetic operations

Addition

uint32 const *a ;
uint32 const *b ;
uint32 *c ;
unsigned int n ;
unsigned char carrybefore ;
unsigned char carryafter ;

 carryafter = bu_addc(c, a, b, n, carrybefore) ;
 carryafter = bu_subc(c, a, b, n, carrybefore) ;

bu_addc() adds a and b, and puts the result into c. a and b must have the same length, n; after the addition, c has length n. carrybefore must be 0 or 1; if it is 1, then b+1 is used instead of b. If c doesn't fit in n limbs, then the n least significant limbs are kept, and bu_addc() returns 1. Else it returns 0.
bu_subc() is the same, with substraction. If c should be negative, then c is really (2^32)^n - c and bu_subc() returns 1.
bu_add(c, a, b, n) is a macro for bu_addc(c, a, b, n, 0).
bu_sub(c, a, b, n) is a macro for bu_subc(c, a, b, n, 0).

Multiplication

uint32 const *a ;
uint32 const *b ;
uint32 *c ;
unsigned int an, bn ;

 bu_mul(c, a, an, b, bn) ;

bu_mul() computes c=a*b. a's length is an; b's length is bn; c's length will be an+bn.

Division

uint32 const *a ;
uint32 const *b ;
uint32 *q ;
uint32 *r ;
unsigned int n ;

 bu_div(a, b, q, r, n) ;
 bu_mod(a, b, n) ;

bu_div() computes q, the quotient, and r, the remainder, of a divided by b. If b is zero, a SIGFPE is raised: this is intentional.
bu_mod() computes only the remainder, and stores it into a.

Left-shifts and right-shifts

uint32 *x ;
unsigned int n ;
unsigned char carryafter ;
unsigned char carrybefore ;

 carryafter = bu_slbc(x, n, carrybefore) ;
 carryafter = bu_srbc(x, n, carrybefore) ;

bu_slbc() computes x <<= 1. The least significant bit of x is then set to carrybefore. bu_slbc() returns the previous value of x's most significant bit.
bu_srbc() computes x >>= 1. The most significant bit of x is then set to carrybefore. bu_slbc() returns the previous value of x's least significant bit.
bu_slb(x, n) and bu_srb(x, n) are macros for respectively bu_slbc(x, n, 0) and bu_srbc(x, n, 0).

Modular operations

uint32 const *a ;
uint32 const *b ;
uint32 *c ;
uint32 const *m ;
unsigned int n ;

 bu_addmod(c, a, b, m, n) ;
 bu_submod(c, a, b, m, n) ;
 bu_divmod(c, a, b, m, n) ;
 bu_invmod(c, m, n) ;

bu_addmod() computes c = (a+b) mod m.
bu_submod() computes c = (a-b) mod m.
a, b and m must have the same length n. a and b must already be numbers modulo m.

bu_divmod() computes a divided by b modulo m and stores it into c.
bu_invmod() computes the inverse of c modulo m and stores it into c.
The divisor and m must be relatively prime, else those functions loop forever.
The algorithm for modular division and inversion is due to
Sheueling Chang Shantz.

prog/skalibs-0.47/doc/libdns.html0100644000000000000000000000522007720423354013645 0ustar skalibs: the dns library interface

skalibs
Software
www.skarnet.org

The dns library interface

libdns is the DNS client library from djbdns. It has been placed into the public domain by D. J. Bernstein.

Compiling

  • Add /package/prog/skalibs/include to your header directory list
  • Use #include "dns.h"

Linking

  • Define a global variable PROG of type char const * that contains the name of your executable.
  • Link against /package/prog/skalibs/library/libdns.a, /package/prog/skalibs/library/librandom.a and /package/prog/skalibs/library/libstddjb.a.
  • If you're using EGD, you should link against /package/prog/skalibs/library/libdns.a, /package/prog/skalibs/library/librandom.a, /package/prog/skalibs/library/libwebipc.a and /package/prog/skalibs/library/libstddjb.a; and add the switches specified by /package/prog/skalibs/sysdeps/socket.lib to your compiler command line for linking.

Programming

libdns implements the following functions, documented by Dan Bernstein:

The dns_random functions have been included in librandom as a default pseudo-random number generator for systems that lack /dev/urandom and EGD. You should call badrandom_init() before performing DNS queries.

prog/skalibs-0.47/doc/libstdcrypto.html0100644000000000000000000000640007720423166015116 0ustar skalibs: the stdcrypto library interface

skalibs
Software
www.skarnet.org

The stdcrypto library interface

stdcrypto is a small collection of standard, public-domain cryptographic primitives. Currently, the following operations are provided:

  • rc4
  • md5
  • sha1

Compiling

  • Add /package/prog/skalibs/include to your header directory list
  • Use #include "stdcrypto.h"

Linking

  • Define a global variable PROG of type char const * that contains the name of your executable.
  • Link against /package/prog/skalibs/library/libstdcrypto.a and /package/prog/skalibs/library/libstddjb.a.

Programming

You should refer to the stdcrypto.h header and included headers for the exact function prototypes.

RC4

  RC4Schedule ctx ;
  unsigned char const *key ;
  unsigned int keylen ;
  unsigned char const *in ;
  unsigned char *out ;
  unsigned int len ;

  rc4_init(&ctx, key, keylen) ;
  rc4(&ctx, in, out, len) ;
  • rc4_init() initializes a RC4Schedule structure with a key key, of length keylen. It then computes and throws away the first RC4_THROWAWAY bytes, usually 100
  • rc4() encrypts len bytes of in with the RC4 flow, and stores the results into out

MD5

  MD5Schedule ctx ;
  char const *message ;
  unsigned int messagelen ;
  char digest[16] ;

  md5_init(&ctx) ;
  md5_update(&ctx, message, messagelen) ;
  md5_final(&ctx, digest) ;
  • md5_init() prepares a MD5Schedule structure for computation
  • md5_update() adds message to the message to be digested
  • md5_final() computes the digest

SHA1

  SHA1Schedule ctx ;
  char const *message ;
  unsigned int messagelen ;
  unsigned char digest[20] ;

  sha1_init(&ctx) ;
  sha1_update(&ctx, message, messagelen) ;
  sha1_final(&ctx, digest) ;
  • sha1_init() prepares a SHA1Schedule structure for computation
  • sha1_update() adds message to the message to be digested
  • sha1_final() computes the digest
prog/skalibs-0.47/doc/libttymodes.html0100644000000000000000000000312007720422342014722 0ustar skalibs: the ttymodes library interface

skalibs
Software
www.skarnet.org

The ttymodes library interface

libttymodes is a small library designed to encapsulate some basic terminal manipulation.

Compiling

  • Add /package/prog/skalibs/include to your header directory list
  • Use #include "ttymodes.h"

Linking

  • Define a global variable PROG of type char const * that contains the name of your executable.
  • Link against /package/prog/skalibs/library/libttymodes.a and /package/prog/skalibs/library/libstddjb.a.

Programming

Look at ttymodes.h for the function prototypes; that header file should be self-explanatory.

prog/skalibs-0.47/doc/upgrade.html0100644000000000000000000001426211100017334014007 0ustar How to upgrade skalibs

skalibs
Software
www.skarnet.org

Upgrade incompatibilities: notes for developers

from 0.46 to 0.47

No API incompatibilities.

The installer has changed (links in /usr/local aren't performed automatically anymore) but it shouldn't impact this package: there are no /usr/local links for skalibs anyway.

from 0.45 to 0.46

  • The low-level entry points cdb_make_addbegin() and cdb_make_addend() have been removed. Please use cdb_make_add() instead and do not mess around with hash values. :-)
  • The alloc_re() and alloc_realloc() prototypes have changed: now they use void ** instead of char **. This shouldn't break anything.

from 0.44 to 0.45

No API incompatibilities.

from 0.43 to 0.44

  • IOPAUSE_READ has been changed to POLLIN | POLLHUP on systems with poll(). If something breaks, please report it.

from 0.42 to 0.43

  • Internal librandom structures have been completely rewritten.
  • Applications linked against librandom.a and using the standard goodrandom/badrandom interface must also be linked against libstdcrypto.a. There is no need to use goodrandom_init() or badrandom_init() anymore.

from 0.41 to 0.42

  • The dns_resolve_r() interface has been removed. Internal libdns structures have been heavily modified.

from 0.40 to 0.41

  • The readclose() interface has been removed.

from 0.39 to 0.40

The allreadwrite interface has been changed: allread, allwrite and other looping functions now return an unsigned int, which is the number of processed bytes. If this number is lesser than the number requested, errno will describe what happened. EPIPE on a reading operation means EOF.

The default signal mask when entering a signal handler has been changed from empty to full, but this is saner. If you were relying on the old behaviour, your code was buggy.

from 0.38 to 0.39

No API incompatibilities.

from 0.37 to 0.38

Less functions and more macros in fmtscan.h.

from 0.36 to 0.37

All the *_fmt functions have been replaced by macros. Programs using &uint_fmt, for instance, will not work anymore; the only remaining unsigned format function is uint64_fmt - and its octal and hexadecimal counterparts. Please do not assume that a function defined in fmtscan.h will remain a function; more functions are likely to be replaced by macros in future versions of skalibs.

from 0.35 to 0.36

No API incompatibilities.

from 0.34 to 0.35

  • The dirname() prototype has been changed, to be SUSv3-compliant. A new function, sadirname(), has been added; you should rewrite your programs using the old dirname() so that they use sadirname() instead.
  • The libdatastruct has been rewritten. gen_list1 and gen_avltree do not exist anymore. You should rewrite your programs so that they use the new list1 and avltree APIs instead. To do this, store your objects into a gen_bunch and store only the (unsigned int) indices into the data structure.

from 0.33 to 0.34

No API incompatibilities.

from 0.32 to 0.33

No API incompatibilities.

from 0.31 to 0.32

No API incompatibilities.

from 0.30 to 0.31

No API incompatibilities. The available namespace has been reduced because of name changes in the fmtscan functions; but the "old" names are still working.

from 0.29 to 0.30

No API incompatibilities.

from 0.28 to 0.29

No API incompatibilities.

from 0.27 to 0.28

No API incompatibilities.

from 0.26 to 0.27

No API incompatibilities. Only the packaging has changed.

from 0.25 to 0.26

No API incompatibilities. The internal build order has changed, but you shouldn't be relying on it anyway.

from 0.24 to 0.25

  • The *.h sysdeps have been renamed with the dot removed, for consistency.
  • On some BSD and Solaris systems, sysdeps may have changed. This is a good thing: your system's capabilities should be guessed more accurately now.
  • The drop_uidgid and drop_root functions have been removed. The strerr2.h macros make direct chroot and prot_[ug]id calls easier.

from 0.23 to 0.24

  • A conf-compile directory has been created, and administrators are invited to modify only the files contained in that directory (which are symlinks). The preconfiguration interface is subject to heavy change.

from 0.22 to 0.23

  • The preferred gccattributes interface has been changed. See src/headers/gccattributes.h.

from pre-0.22 to 0.22

  • The GEN_ALLOC interface has been changed. See src/libstddjb/gen_alloc.h.
prog/skalibs-0.47/doc/gccattributes.html0100644000000000000000000000260710323524676015245 0ustar skalibs: the gccattributes header

skalibs
Software
www.skarnet.org

The gccattributes.h header

gccattributes.h is a set of wrappers around gcc attributes (duh). It defines macros that are always valid, and that have no effect if the compiler is not gcc or the used version of gcc does not support the wanted attribute.

For instance:

 extern unsigned int str_len (char const *) gccattr_pure ;

defines the str_len function as pure if it is supported.

The file src/headers/gccattributes.h is the only reliable reference.

prog/skalibs-0.47/doc/crosscompile.html0100644000000000000000000001730407720421514015076 0ustar How to cross-compile skalibs

skalibs
Software
www.skarnet.org

How to cross-compile skalibs

There are three issues in the world of cross-compilation:

  • support for parallel builds: the source directory must be read-only and each build process must have its own build tree.
  • support for compiler options: to specify the target architecture, the header and library files that should be used, etc.
  • build-time tests performed on the build architecture are invalid if the target architecture is different.

Starting with release 0.26, skalibs tries to address those issues.

Support for parallel builds

Let's assume that:

  • You untarred the skalibs-$VERSION.tar.gz archive into $BUILDROOT.
  • You made a symlink $BUILDROOT/prog/skalibs -> skalibs-$VERSION. (This is not really necessary, but it allows you to access the skalibs source tree as $BUILDROOT/prog/skalibs no matter the version number.)
You now have 5 subdirectories in the $BUILDROOT/prog/skalibs directory:
  • conf-compile. This is where you will write compilation options.
  • doc. The skalibs documentation you are currently reading. Not used in the build process.
  • package. Build system scripts and general package information. You should not modify anything there unless you know exactly what you are doing.
  • src. The source tree.
  • precompiled-sysdeps. Some sets of precompiled sysdeps; more on that below.

None of those directories are written into by the skalibs build system. Instead, the build scripts create the following directories:

  • compile. This is where all the compilation takes place. Every source file will be symlinked there, and object files will be created there.
  • include. This is where the target header files will reside after the compilation.
  • library. This is where the target library files will reside after the compilation.
  • sysdeps. This is where the target system-specific information will reside after build-time autodetection or manual importing. More on that below.

To prepare for a build in a separate place - say, in $ARCHROOT/skalibs - that will not modify the directory where the sources have been unpacked, so that parallel builds can occur, you should then take the following steps:

  • mkdir $ARCHROOT/skalibs
  • symlink the $BUILDROOT/prog/skalibs/package and $BUILDROOT/prog/skalibs/src directory into $ARCHROOT/skalibs
  • mkdir $ARCHROOT/skalibs/conf-compile

You now have your own arch-specific $ARCHROOT/skalibs tree; it's time to fill it with arch-specific options.

Support for build-time options

The first line of conf-compile/conf-cc must be the command line used to compile a .c file into a .o file: for instance, gcc -c.
If you're using a "GNU configure"-type system with $CC and $CFLAGS, the following line should be enough:

  echo ${CC} ${CFLAGS} > conf-compile/conf-cc

Similarly, the first line of conf-compile/conf-ld must be the command line used to link .o and .a files into an executable: for instance, gcc -s.
With a "GNU configure"-type system, the following line should do the trick:

  echo ${CC} ${LDFLAGS} > conf-compile/conf-ld

Now, there is another file: conf-compile/conf-egd. If you're going to perform build-time autodetection, you need to provide it now:

  echo path-to-the-target-EGD-socket > conf-compile/conf-egd

or, if you won't be using EGD, just

  echo > conf-compile/conf-egd

But you probably do not need to do that, because you will be providing your own sysdeps.

Starting with 0.27: there are two other files, conf-stripbins and conf-striplibs. Since skalibs does not provide any executables, and since you are cross-compiling, avoid trouble and do not strip anything:

  echo > conf-compile/conf-stripbins
  echo > conf-compile/conf-striplibs

Bypassing the build-time tests

The "normal" skalibs build procedure, package/compile, performs the following steps:

  1. finding the target's (i.e. here the build arch's) systype
  2. building correct compilation scripts from the systype and the information you gave in conf-compile
  3. making some build-time tests to gather sysdeps, i.e. arch-specific information, used in the sources to work around possible portability problems
  4. compiling the portable sources.

In a cross-compilation environment, the steps 1 and 3 are clearly invalid: the autodetected systype and sysdeps will be the build architecture's, not the target architecture's. There is only one way to cross-compile portable code without resorting to build-time autodetection: you must provide by hand the sysdeps for your target architecture.

The easiest way to get the "right" sysdeps for a target achitecture is to natively compile skalibs on that target, and steal the produced sysdeps files. The skalibs package comes with a small set of predefined sysdeps files that I got that way; your target may be more or less accurately represented by one of the subdirectories of precompiled-sysdeps.

The most powerful way to get the sysdeps would be to have a program such as GNU autoconf automatically generate them at build-time. I won't convert skalibs to autoconf, but contributions such as autoconf-to-sysdeps scripts are welcome.

Dan Kegel has kindly provided some step-by-step notes on making sysdeps files for your target architecture.


So, one way or the other, you have filled up conf-compile, and you have a predefined set of sysdeps in $SYSDEPSDIR, for instance $BUILDROOT/prog/skalibs/precompiled-sysdeps/i686-openbsd-3.2.
Instead of performing package/install for a native installation, or package/compile for a native compilation without the install phase, you just perform

  package/crosscompile ${SYSDEPSDIR}

The set of sysdeps in $SYSDEPSDIR will be imported into the build tree, and the portable sources will be compiled. The header files will be produced in the include directory, and the library files in the library directory. That's it.


Credits

Dan Kegel brought up the need for a clean cross-compilation system.

prog/skalibs-0.47/doc/dank-cross-notes.html0100644000000000000000000000771607720421603015573 0ustar How to cross-compile skalibs: Dan Kegel's hints for making sysdeps

skalibs
Software
www.skarnet.org

Dan Kegel's hints on making sysdeps files for skalibs cross-compilation

Here is what he said (edited for typos) from his experience. I commented some points.

    If your target is an embedded system with a shell and normal Unix
    utilities, but no make and no compiler, you may still be able to run
    parts of the configuration scripts on the target system, and combine
    their output with one of the preconfigured sysdeps that is a close match.

    You should read and understand the configuration scripts.  One
    way to get a handle on them is to add 'set -x' to the top of
    all the scripts in skalibs

(In the package directory.)

    then configure on your workstation,
    save the log, and look through it (or use it as a reference).
    This will show you the sequence in which the scripts are run,
    and expose steps that might not have been obvious by inspection.

    The file sysdeps is created by src/sysdeps/Makefile like this:
         cat systype compile load socket.lib util.lib > sysdeps
         grep -h sysdep: sysdeps.h >> sysdeps

    That first file, systype, is generated by src/systype/find-systype.sh,
    which can be transferred by itself to the target and run standalone on
    non-x86 systems.

This is not completely true: in some cases, find-systype.sh depends on bootcompile and bootload, which are generated exactly as compile and load are. Nevertheless, the information is not really vital, so you may perform as suggested without losing too much accuracy.

    The second file, compile, is generated by src/sys/Makefile,
    it contains the first line of your conf-cc followed by -c "$1"
    (followed by a call to strip on some operating systems, but that can
    be omitted).

Update: starting with 0.27, object files are not stripped. conf-stripbins and conf-striplibs are used in building the load and makelib respectively, to strip executables or libraries at link time / archive time; but you can safely have blank conf-stripbins and conf-striplibs files, and ignore stripping completely.

    The third file, load, is generated by src/sys/print-ld.sh, which
    can safely be run on the development system; it doesn't need to be
    transferred. It reads your conf-ld file, and generates the line
    skalibs actually uses to link programs.

    The fourth and fifth files, socket.lib and util.lib, can be left empty
    or unchanged until you notice your programs need -lutil or something
    like that to link :-)

    The last file, sysdeps.h, you should probably copy from a preconfigured
    sysdeps directory, and edit by hand.  Obvious entries to change might
    be HASLITTLE_ENDIAN and HASBIG_ENDIAN.

    Once you've done all that, concatenate them to form sysdeps as
    src/sysdeps/Makefile would have done.

Thank you for writing documentation in my place, Dan. :-)

prog/skalibs-0.47/doc/libdatastruct.html0100644000000000000000000000427107772461456015260 0ustar skalibs: the datastruct library interface

skalibs
Software
www.skarnet.org

The datastruct library interface

libdatastruct implements generic data structures like chained lists and AVL trees, in a memory-efficient way.

Compiling

  • Add /package/prog/skalibs/include to your header directory list
  • Use #include "datastruct.h"

Linking

  • Define a global variable PROG of type char const * that contains the name of your executable.
  • Link against /package/prog/skalibs/library/libdatastruct.a and /package/prog/skalibs/library/libstddjb.a.

Programming

  • bitarray allows handling of large bit arrays.
  • gen_bunch provides a generic framework for handling large sets of objects of the same type in a memory-efficient way. It is built over gen_alloc and bitarray.
  • list1 offers an interface to simple lists containing unsigned ints.
  • avltree offers an interface to AVL trees containing unsigned ints.
  • By combining for instance avltree with gen_bunch you can get generic, memory-efficient AVL trees.

Look at the header and source files for details. The function prototypes should be self-explanatory.

prog/skalibs-0.47/doc/selfpipe.html0100644000000000000000000001520511100035066014167 0ustar skalibs: the selfpipe library interface

libstddjb
skalibs
Software
www.skarnet.org

The selfpipe library interface

It's a part of libstddjb. The functions are defined in the selfpipe.h header.

What does it do ?

Signal handlers suck.

They do. I don't care how experienced you are with C/Unix programming, they do. You can be Ken Thompson, if you use signal handlers as a regular part of your C programming model, you are going to screw up, and write buggy code.

Unix is tricky enough with interruptions. Most of libstddjb's wrappers are there to protect system calls from EINTR. (And no, the SA_RESTART option in sigaction() isn't protection enough.) But signal handlers are more than just pesky interruptions: they can totally change the execution flow. They mess up the logic of linear and structured code, they introduce non-determinism; you always have to think "and what if I get interrupted here and the flow goes into a handler...". This is annoying.

Moreover, signal handler code is very limited in what it can do. It can't use any non-reentrant function! If you call an non-reentrant function, and by chance you were precisely in that non-reentrant function code when you got interrupted by a signal... you lose. That means, no malloc(). No bufferized IO. No globals. The list goes on and on.
If you're going to catch signals, you'll want to handle them outside the signal handler. You actually want to spend the least possible time inside a signal handler - just enough to notify your main execution flow that there's a signal to take care of.

And, of course, signal handlers don't mix with event loops, which is a classic source of headaches for programmers and led to the birth of abominations such as pselect. So much for the "everything is a file" concept that Unix was built on.

A signal should be an event like any other. There should be a unified interface - receiving a signal should make some fd readable or something.

And that's exactly what the "self-pipe trick", invented by djb, does.

As long as you're in some kind of event loop, the self-pipe trick allows you to forget about signal handlers... forever. It works this way:

  1. Create a pipe p. Make both ends close-on-exec and nonblocking.
  2. Write a tiny signal handler for all the signals you want to catch. This signal handler should just write one byte into p[1], and do nothing more; ideally, the written byte identifies the signal.
  3. In your event loop, add p[0] to the list of fds you're watching for readability.

When you get a signal, a byte will be written to the self-pipe, and your execution flow will resume. When you next go through the event loop, p[0] will be readable; you'll then be able to read a byte from it, identify the signal, and handle it - in your unrestricted main environment.

The selfpipe library does it all for you - you don't even have to write the signal handlers yourself. You can forget their existence and recover some peace of mind. Of course, you still need to protect your system calls against EINTR: the self-pipe trick doesn't prevent signals from happening.

How do I use it ?

int fd = selfpipe_init() ;

selfpipe_init() sets up a selfpipe. You must use that function first.
If fd is -1, then an error occurred. Else fd is a non-blocking descriptor that can be used in your event loop. It will be selected for readability when you've caught a signal.

int r = selfpipe_trap(SIGTERM) ;

selfpipe_trap() catches a signal and sends it to the selfpipe. Uncaught signals won't trigger the selfpipe. r is 0 if the operation succeeded, and -1 if it failed. If it succeeded, you can forget about the trapped signal entirely.
In our example, if r is 0, then a SIGTERM will instantly trigger readability on fd.

int c = selfpipe_read() ;

Call selfpipe_read() when your fd is readable. That's where you write your real signal handler: in the body of your event loop, in a "normal" context.
c is -1 if an error occurred - in which case chances are it's a serious one and your system has become very unstable. c is 0 if there are no more pending signals. If c is positive, it is the number of the signal that was caught.

selfpipe_finish() ;

Call selfpipe_finish() when you're done using the selfpipe. Signal handlers will be restored to their previous value.

Any limitations ?

Some, as always.

  • The selfpipe library uses a global pipe; so, it's not safe for multithreading. I'm not sure how multithreaded programs handle signals; I personally don't like multithreading and never use it, so I'm not knowledgeable about it. Anyway, if your program is multithreaded, chances are you don't have an asynchronous event loop, so the self-pipe trick has less benefits for you.
  • The self-pipe can be filled if some application sends more than PIPE_BUF signals before you have time to selfpipe_read(). On most Unix systems, PIPE_BUF is 4096, so it's a very acceptable margin. Unless your code is waiting where it should not be, only malicious applications will fill the self-pipe - and malicious applications could just send you a SIGKILL and be done with you, so this is not a concern. Protect yourself from malicious applications with clever use of uids.
prog/skalibs-0.47/conf-compile/0040755000000000000000000000000011077702244013314 5ustar prog/skalibs-0.47/conf-compile/conf-cc0100644000000000000000000000035210554052614014542 0ustar gcc -O2 -W -Wall -fomit-frame-pointer -pipe -DUSE_BASE_LIBC This will be used to compile .c files that are not meant to be part of a shared library (but may be used to make an executable that may be linked against a shared library). prog/skalibs-0.47/conf-compile/conf-egd0100644000000000000000000000020507663560170014721 0ustar If you want librandom to support the EGD daemon, the first line of this file must be the full path to the EGD unix-domain socket. prog/skalibs-0.47/conf-compile/conf-ld0100644000000000000000000000007710554052627014564 0ustar gcc -s This will be used to link .o files into an executable. prog/skalibs-0.47/conf-compile/conf-stripbins0100644000000000000000000000025311072732654016177 0ustar strip This will be used to strip executables. If you have a GNU strip, you can use: strip -R .note -R .comment -R .note.GNU-stack Otherwise, use "strip", or leave blank. prog/skalibs-0.47/conf-compile/conf-striplibs0100644000000000000000000000031611077702243016171 0ustar This will be used to strip library files (.a) If you have a BSD strip, you can use: strip -x If you have a GNU strip, you can use: strip -x -R .note -R .comment -R .note.GNU-stack Otherwise, leave blank. prog/skalibs-0.47/precompiled-sysdeps/0040755000000000000000000000000010022224047014721 5ustar prog/skalibs-0.47/precompiled-sysdeps/i686-freebsd-5.0-release/0040755000000000000000000000000010022317144020744 5ustar prog/skalibs-0.47/precompiled-sysdeps/i686-freebsd-5.0-release/sysdeps0100644000000000000000000000233110022317111022347 0ustar freebsd-5.0-release-:i386-:-:ppro-:- #!/bin/sh # WARNING: This file was auto-generated. Do not edit! exec gcc -O2 -W -Wall -fomit-frame-pointer -pipe -c "$1" #!/bin/sh # WARNING: This file was auto-generated. Do not edit! main="$1"; shift ; exec gcc -s -static -o "$main" "$main".o ${1+"$@"} -lutil /* sysdep: -devtcp */ /* sysdep: -devptc */ /* sysdep: -devptmx */ /* sysdep: +devrandom */ /* sysdep: +devurandom */ /* sysdep: +dirent */ /* sysdep: -eproto */ /* sysdep: +flock */ /* sysdep: -getpt */ /* sysdep: +getpeereid */ /* sysdep: -SO_PEERCRED */ /* sysdep: +malloc0 */ /* sysdep: +mkfifo */ /* sysdep: -npbg1 */ /* sysdep: +pollh */ /* sysdep: +syspollh */ /* sysdep: +poll */ /* sysdep: +sigaction */ /* sysdep: +sigprocmask */ /* sysdep: -shortsetgroups */ /* sysdep: +sysselect */ /* sysdep: +revoke */ /* sysdep: +waitpid */ /* sysdep: +ulong32 */ /* sysdep: -ulong64 */ /* sysdep: -utilh */ /* sysdep: +libutilh */ /* sysdep: -ptyh */ /* sysdep: -_getpty */ /* sysdep: +openpty */ /* sysdep: -unixh */ /* sysdep: -streams */ /* sysdep: +little_endian */ /* sysdep: -big_endian */ /* sysdep: -egd */ /* sysdep: +tiocremote */ /* sysdep: +posixglob */ /* sysdep: +stdinth */ /* sysdep: +inttypesh */ /* sysdep: -oksyssocket */ prog/skalibs-0.47/precompiled-sysdeps/i686-freebsd-5.0-release/systype0100644000000000000000000000004507674056534022431 0ustar freebsd-5.0-release-:i386-:-:ppro-:- prog/skalibs-0.47/precompiled-sysdeps/i686-freebsd-5.0-release/socket.lib0100644000000000000000000000000107674056370022734 0ustar prog/skalibs-0.47/precompiled-sysdeps/i686-freebsd-5.0-release/util.lib0100644000000000000000000000000707674056371022430 0ustar -lutil prog/skalibs-0.47/precompiled-sysdeps/i686-freebsd-5.0-release/sysdeps.h0100644000000000000000000000335410022317140022605 0ustar /* Public domain. */ #ifndef SYSDEPS_H #define SYSDEPS_H #undef HASDEVTCP /* sysdep: -devtcp */ #undef HASDEVPTC /* sysdep: -devptc */ #undef HASDEVPTMX /* sysdep: -devptmx */ #define HASDEVRANDOM /* sysdep: +devrandom */ #define HASDEVURANDOM /* sysdep: +devurandom */ #define HASDIRENT /* sysdep: +dirent */ #undef HASDIRENT /* sysdep: -eproto */ #define HASFLOCK /* sysdep: +flock */ #undef HASGETPT /* sysdep: -getpt */ #define HASGETPEEREID /* sysdep: +getpeereid */ #undef HASSO_PEERCRED /* sysdep: -SO_PEERCRED */ #define HASMALLOC0 /* sysdep: +malloc0 */ #define HASMKFIFO /* sysdep: +mkfifo */ #undef HASNPBG1 /* sysdep: -npbg1 */ #define HASPOLLH /* sysdep: +pollh */ #define HASSYSPOLLH /* sysdep: +syspollh */ #define HASPOLL /* sysdep: +poll */ #define HASSIGACTION /* sysdep: +sigaction */ #define HASSIGPROCMASK /* sysdep: +sigprocmask */ #undef HASSHORTSETGROUPS /* sysdep: -shortsetgroups */ #define HASSYSSELECT /* sysdep: +sysselect */ #define HASREVOKE /* sysdep: +revoke */ #define HASWAITPID /* sysdep: +waitpid */ #define HASULONG32 /* sysdep: +ulong32 */ #undef HASULONG64 /* sysdep: -ulong64 */ #undef HASUTILH /* sysdep: -utilh */ #define HASLIBUTILH /* sysdep: +libutilh */ #undef HASPTYH /* sysdep: -ptyh */ #undef HAS_GETPTY /* sysdep: -_getpty */ #define HASOPENPTY /* sysdep: +openpty */ #undef HASUNIXH /* sysdep: -unixh */ #undef HASSTREAMS /* sysdep: -streams */ #define HASLITTLE_ENDIAN /* sysdep: +little_endian */ #undef HASBIG_ENDIAN /* sysdep: -big_endian */ #undef HASEGD /* sysdep: -egd */ #define HASTIOCREMOTE /* sysdep: +tiocremote */ #define HASPOSIXGLOB /* sysdep: +posixglob */ #define HASSTDINTH /* sysdep: +stdinth */ #define HASINTTYPESH /* sysdep: +inttypesh */ #undef HASOKSYSSOCKET /* sysdep: -oksyssocket */ #endif prog/skalibs-0.47/precompiled-sysdeps/i686-openbsd-3.2/0040755000000000000000000000000010022317471017351 5ustar prog/skalibs-0.47/precompiled-sysdeps/i686-openbsd-3.2/sysdeps0100644000000000000000000000232110022317432020756 0ustar openbsd-3.2-:i386-:-:ppro-:- #!/bin/sh # WARNING: This file was auto-generated. Do not edit! exec gcc -O2 -W -Wall -fomit-frame-pointer -pipe -c "$1" #!/bin/sh # WARNING: This file was auto-generated. Do not edit! main="$1"; shift ; exec gcc -s -static -o "$main" "$main".o ${1+"$@"} -lutil /* sysdep: -devtcp */ /* sysdep: -devptc */ /* sysdep: -devptmx */ /* sysdep: -devrandom */ /* sysdep: +devurandom */ /* sysdep: +dirent */ /* sysdep: -eproto */ /* sysdep: +flock */ /* sysdep: -getpt */ /* sysdep: +getpeereid */ /* sysdep: -SO_PEERCRED */ /* sysdep: +malloc0 */ /* sysdep: +mkfifo */ /* sysdep: -npbg1 */ /* sysdep: +pollh */ /* sysdep: +syspollh */ /* sysdep: +poll */ /* sysdep: +sigaction */ /* sysdep: +sigprocmask */ /* sysdep: -shortsetgroups */ /* sysdep: +sysselect */ /* sysdep: +revoke */ /* sysdep: +waitpid */ /* sysdep: +ulong32 */ /* sysdep: -ulong64 */ /* sysdep: +utilh */ /* sysdep: -libutilh */ /* sysdep: -ptyh */ /* sysdep: -_getpty */ /* sysdep: +openpty */ /* sysdep: -unixh */ /* sysdep: -streams */ /* sysdep: +little_endian */ /* sysdep: -big_endian */ /* sysdep: -egd */ /* sysdep: +tiocremote */ /* sysdep: +posixglob */ /* sysdep: -stdinth */ /* sysdep: +inttypesh */ /* sysdep: -oksyssocket */ prog/skalibs-0.47/precompiled-sysdeps/i686-openbsd-3.2/systype0100644000000000000000000000003507674055364021032 0ustar openbsd-3.2-:i386-:-:ppro-:- prog/skalibs-0.47/precompiled-sysdeps/i686-openbsd-3.2/socket.lib0100644000000000000000000000000107674054537021341 0ustar prog/skalibs-0.47/precompiled-sysdeps/i686-openbsd-3.2/util.lib0100644000000000000000000000000707674054540021026 0ustar -lutil prog/skalibs-0.47/precompiled-sysdeps/i686-openbsd-3.2/sysdeps.h0100644000000000000000000000335210022317464021216 0ustar /* Public domain. */ #ifndef SYSDEPS_H #define SYSDEPS_H #undef HASDEVTCP /* sysdep: -devtcp */ #undef HASDEVPTC /* sysdep: -devptc */ #undef HASDEVPTMX /* sysdep: -devptmx */ #undef HASDEVRANDOM /* sysdep: -devrandom */ #define HASDEVURANDOM /* sysdep: +devurandom */ #define HASDIRENT /* sysdep: +dirent */ #undef HASDIRENT /* sysdep: -eproto */ #define HASFLOCK /* sysdep: +flock */ #undef HASGETPT /* sysdep: -getpt */ #define HASGETPEEREID /* sysdep: +getpeereid */ #undef HASSO_PEERCRED /* sysdep: -SO_PEERCRED */ #define HASMALLOC0 /* sysdep: +malloc0 */ #define HASMKFIFO /* sysdep: +mkfifo */ #undef HASNPBG1 /* sysdep: -npbg1 */ #define HASPOLLH /* sysdep: +pollh */ #define HASSYSPOLLH /* sysdep: +syspollh */ #define HASPOLL /* sysdep: +poll */ #define HASSIGACTION /* sysdep: +sigaction */ #define HASSIGPROCMASK /* sysdep: +sigprocmask */ #undef HASSHORTSETGROUPS /* sysdep: -shortsetgroups */ #define HASSYSSELECT /* sysdep: +sysselect */ #define HASREVOKE /* sysdep: +revoke */ #define HASWAITPID /* sysdep: +waitpid */ #define HASULONG32 /* sysdep: +ulong32 */ #undef HASULONG64 /* sysdep: -ulong64 */ #define HASUTILH /* sysdep: +utilh */ #undef HASLIBUTILH /* sysdep: -libutilh */ #undef HASPTYH /* sysdep: -ptyh */ #undef HAS_GETPTY /* sysdep: -_getpty */ #define HASOPENPTY /* sysdep: +openpty */ #undef HASUNIXH /* sysdep: -unixh */ #undef HASSTREAMS /* sysdep: -streams */ #define HASLITTLE_ENDIAN /* sysdep: +little_endian */ #undef HASBIG_ENDIAN /* sysdep: -big_endian */ #undef HASEGD /* sysdep: -egd */ #define HASTIOCREMOTE /* sysdep: +tiocremote */ #define HASPOSIXGLOB /* sysdep: +posixglob */ #undef HASSTDINTH /* sysdep: -stdinth */ #define HASINTTYPESH /* sysdep: +inttypesh */ #undef HASOKSYSSOCKET /* sysdep: -oksyssocket */ #endif prog/skalibs-0.47/precompiled-sysdeps/sparc5-solaris-8/0040755000000000000000000000000010022317724017742 5ustar prog/skalibs-0.47/precompiled-sysdeps/sparc5-solaris-8/sysdeps0100644000000000000000000000233410022317670021356 0ustar sunos-5.8-generic-:sparc-:sun4-:sun4m-:sun4m- #!/bin/sh # WARNING: This file was auto-generated. Do not edit! exec gcc -O2 -W -Wall -fomit-frame-pointer -pipe -c "$1" #!/bin/sh # WARNING: This file was auto-generated. Do not edit! main="$1"; shift ; exec gcc -s -static -o "$main" "$main".o ${1+"$@"} /* sysdep: +devtcp */ /* sysdep: -devptc */ /* sysdep: +devptmx */ /* sysdep: -devrandom */ /* sysdep: -devurandom */ /* sysdep: +dirent */ /* sysdep: +eproto */ /* sysdep: -flock */ /* sysdep: -getpt */ /* sysdep: -getpeereid */ /* sysdep: -SO_PEERCRED */ /* sysdep: +malloc0 */ /* sysdep: +mkfifo */ /* sysdep: -npbg1 */ /* sysdep: -pollh */ /* sysdep: -syspollh */ /* sysdep: -poll */ /* sysdep: +sigaction */ /* sysdep: +sigprocmask */ /* sysdep: -shortsetgroups */ /* sysdep: +sysselect */ /* sysdep: -revoke */ /* sysdep: +waitpid */ /* sysdep: +ulong32 */ /* sysdep: -ulong64 */ /* sysdep: -utilh */ /* sysdep: -libutilh */ /* sysdep: -ptyh */ /* sysdep: -_getpty */ /* sysdep: -openpty */ /* sysdep: -unixh */ /* sysdep: +streams */ /* sysdep: -little_endian */ /* sysdep: +big_endian */ /* sysdep: -egd */ /* sysdep: +tiocremote */ /* sysdep: +posixglob */ /* sysdep: -stdinth */ /* sysdep: +inttypesh */ /* sysdep: +oksyssocket */ prog/skalibs-0.47/precompiled-sysdeps/sparc5-solaris-8/systype0100644000000000000000000000005607674072305021417 0ustar sunos-5.8-generic-:sparc-:sun4-:sun4m-:sun4m- prog/skalibs-0.47/precompiled-sysdeps/sparc5-solaris-8/socket.lib0100644000000000000000000000000107674072203021717 0ustar prog/skalibs-0.47/precompiled-sysdeps/sparc5-solaris-8/util.lib0100644000000000000000000000000107674072203021404 0ustar prog/skalibs-0.47/precompiled-sysdeps/sparc5-solaris-8/sysdeps.h0100644000000000000000000000334610022317717021612 0ustar /* Public domain. */ #ifndef SYSDEPS_H #define SYSDEPS_H #define HASDEVTCP /* sysdep: +devtcp */ #undef HASDEVPTC /* sysdep: -devptc */ #define HASDEVPTMX /* sysdep: +devptmx */ #undef HASDEVRANDOM /* sysdep: -devrandom */ #undef HASDEVURANDOM /* sysdep: -devurandom */ #define HASDIRENT /* sysdep: +dirent */ #define HASEPROTO /* sysdep: +eproto */ #undef HASFLOCK /* sysdep: -flock */ #undef HASGETPT /* sysdep: -getpt */ #undef HASGETPEEREID /* sysdep: -getpeereid */ #undef HASSO_PEERCRED /* sysdep: -SO_PEERCRED */ #define HASMALLOC0 /* sysdep: +malloc0 */ #define HASMKFIFO /* sysdep: +mkfifo */ #undef HASNPBG1 /* sysdep: -npbg1 */ #undef HASPOLLH /* sysdep: -pollh */ #undef HASSYSPOLLH /* sysdep: -syspollh */ #undef HASPOLL /* sysdep: -poll */ #define HASSIGACTION /* sysdep: +sigaction */ #define HASSIGPROCMASK /* sysdep: +sigprocmask */ #undef HASSHORTSETGROUPS /* sysdep: -shortsetgroups */ #define HASSYSSELECT /* sysdep: +sysselect */ #undef HASREVOKE /* sysdep: -revoke */ #define HASWAITPID /* sysdep: +waitpid */ #define HASULONG32 /* sysdep: +ulong32 */ #undef HASULONG64 /* sysdep: -ulong64 */ #undef HASUTILH /* sysdep: -utilh */ #undef HASLIBUTILH /* sysdep: -libutilh */ #undef HASPTYH /* sysdep: -ptyh */ #undef HAS_GETPTY /* sysdep: -_getpty */ #undef HASOPENPTY /* sysdep: -openpty */ #undef HASUNIXH /* sysdep: -unixh */ #define HASSTREAMS /* sysdep: +streams */ #undef HASLITTLE_ENDIAN /* sysdep: -little_endian */ #define HASBIG_ENDIAN /* sysdep: +big_endian */ #undef HASEGD /* sysdep: -egd */ #define HASTIOCREMOTE /* sysdep: +tiocremote */ #define HASPOSIXGLOB /* sysdep: +posixglob */ #undef HASSTDINTH /* sysdep: -stdinth */ #define HASINTTYPESH /* sysdep: +inttypesh */ #define HASOKSYSSOCKET /* sysdep: +oksyssocket */ #endif prog/skalibs-0.47/precompiled-sysdeps/i686-linux-2.4-glibc-2.2.5/0040755000000000000000000000000010022317404020573 5ustar prog/skalibs-0.47/precompiled-sysdeps/i686-linux-2.4-glibc-2.2.5/sysdeps0100644000000000000000000000240710022317347022216 0ustar linux-2.4-:i386-:-:ppro-:- #!/bin/sh # WARNING: This file was auto-generated. Do not edit! gcc -O2 -W -Wall -fomit-frame-pointer -pipe -c "$1" && exec strip -x -R .comment -R .note `echo "$1" | sed 's/\.c/.o/g'` #!/bin/sh # WARNING: This file was auto-generated. Do not edit! main="$1"; shift ; exec gcc -s -o "$main" "$main".o ${1+"$@"} -lutil /* sysdep: -devtcp */ /* sysdep: -devptc */ /* sysdep: +devptmx */ /* sysdep: +devrandom */ /* sysdep: +devurandom */ /* sysdep: +dirent */ /* sysdep: +eproto */ /* sysdep: +flock */ /* sysdep: +getpt */ /* sysdep: -getpeereid */ /* sysdep: +SO_PEERCRED */ /* sysdep: +malloc0 */ /* sysdep: +mkfifo */ /* sysdep: -npbg1 */ /* sysdep: +pollh */ /* sysdep: +syspollh */ /* sysdep: +poll */ /* sysdep: +sigaction */ /* sysdep: +sigprocmask */ /* sysdep: -shortsetgroups */ /* sysdep: +sysselect */ /* sysdep: +revoke */ /* sysdep: +waitpid */ /* sysdep: +ulong32 */ /* sysdep: -ulong64 */ /* sysdep: -utilh */ /* sysdep: -libutilh */ /* sysdep: +ptyh */ /* sysdep: -_getpty */ /* sysdep: +openpty */ /* sysdep: -unixh */ /* sysdep: +streams */ /* sysdep: +little_endian */ /* sysdep: -big_endian */ /* sysdep: -egd */ /* sysdep: -tiocremote */ /* sysdep: +posixglob */ /* sysdep: +stdinth */ /* sysdep: +inttypesh */ /* sysdep: +oksyssocket */ prog/skalibs-0.47/precompiled-sysdeps/i686-linux-2.4-glibc-2.2.5/systype0100644000000000000000000000003307674055201022244 0ustar linux-2.4-:i386-:-:ppro-:- prog/skalibs-0.47/precompiled-sysdeps/i686-linux-2.4-glibc-2.2.5/socket.lib0100644000000000000000000000000107674052652022563 0ustar prog/skalibs-0.47/precompiled-sysdeps/i686-linux-2.4-glibc-2.2.5/util.lib0100644000000000000000000000000707674052654022260 0ustar -lutil prog/skalibs-0.47/precompiled-sysdeps/i686-linux-2.4-glibc-2.2.5/sysdeps.h0100644000000000000000000000336010022317372022441 0ustar /* Public domain. */ #ifndef SYSDEPS_H #define SYSDEPS_H #undef HASDEVTCP /* sysdep: -devtcp */ #undef HASDEVPTC /* sysdep: -devptc */ #define HASDEVPTMX /* sysdep: +devptmx */ #define HASDEVRANDOM /* sysdep: +devrandom */ #define HASDEVURANDOM /* sysdep: +devurandom */ #define HASDIRENT /* sysdep: +dirent */ #define HASEPROTO /* sysdep: +eproto */ #define HASFLOCK /* sysdep: +flock */ #define HASGETPT /* sysdep: +getpt */ #undef HASGETPEEREID /* sysdep: -getpeereid */ #define HASSO_PEERCRED /* sysdep: +SO_PEERCRED */ #define HASMALLOC0 /* sysdep: +malloc0 */ #define HASMKFIFO /* sysdep: +mkfifo */ #undef HASNPBG1 /* sysdep: -npbg1 */ #define HASPOLLH /* sysdep: +pollh */ #define HASSYSPOLLH /* sysdep: +syspollh */ #define HASPOLL /* sysdep: +poll */ #define HASSIGACTION /* sysdep: +sigaction */ #define HASSIGPROCMASK /* sysdep: +sigprocmask */ #undef HASSHORTSETGROUPS /* sysdep: -shortsetgroups */ #define HASSYSSELECT /* sysdep: +sysselect */ #define HASREVOKE /* sysdep: +revoke */ #define HASWAITPID /* sysdep: +waitpid */ #define HASULONG32 /* sysdep: +ulong32 */ #undef HASULONG64 /* sysdep: -ulong64 */ #undef HASUTILH /* sysdep: -utilh */ #undef HASLIBUTILH /* sysdep: -libutilh */ #define HASPTYH /* sysdep: +ptyh */ #undef HAS_GETPTY /* sysdep: -_getpty */ #define HASOPENPTY /* sysdep: +openpty */ #undef HASUNIXH /* sysdep: -unixh */ #define HASSTREAMS /* sysdep: +streams */ #define HASLITTLE_ENDIAN /* sysdep: +little_endian */ #undef HASBIG_ENDIAN /* sysdep: -big_endian */ #undef HASEGD /* sysdep: -egd */ #undef HASTIOCREMOTE /* sysdep: -tiocremote */ #define HASPOSIXGLOB /* sysdep: +posixglob */ #define HASSTDINTH /* sysdep: +stdinth */ #define HASINTTYPESH /* sysdep: +inttypesh */ #define HASOKSYSSOCKET /* sysdep: +oksyssocket */ #endif prog/skalibs-0.47/precompiled-sysdeps/i686-linux-2.4-dietlibc-0.22/0040755000000000000000000000000010022317314021207 5ustar prog/skalibs-0.47/precompiled-sysdeps/i686-linux-2.4-dietlibc-0.22/socket.lib0100644000000000000000000000000107674050236023173 0ustar prog/skalibs-0.47/precompiled-sysdeps/i686-linux-2.4-dietlibc-0.22/sysdeps0100644000000000000000000000236110022317204022621 0ustar linux-2.4-:i386-:-:ppro-:- #!/bin/sh # WARNING: This file was auto-generated. Do not edit! diet gcc -nostdinc -Os -c "$1" && exec strip -x -R .comment -R .note `echo "$1" | sed 's/\.c/.o/g'` #!/bin/sh # WARNING: This file was auto-generated. Do not edit! main="$1"; shift ; exec dietg cc -s -o "$main" "$main".o ${1+"$@"} /* sysdep: -devtcp */ /* sysdep: -devptc */ /* sysdep: +devptmx */ /* sysdep: +devrandom */ /* sysdep: +devurandom */ /* sysdep: +dirent */ /* sysdep: +eproto */ /* sysdep: +flock */ /* sysdep: -getpt */ /* sysdep: -getpeereid */ /* sysdep: +SO_PEERCRED */ /* sysdep: -malloc0 */ /* sysdep: +mkfifo */ /* sysdep: -npbg1 */ /* sysdep: +pollh */ /* sysdep: +syspollh */ /* sysdep: +poll */ /* sysdep: +sigaction */ /* sysdep: +sigprocmask */ /* sysdep: +shortsetgroups */ /* sysdep: +sysselect */ /* sysdep: -revoke */ /* sysdep: +waitpid */ /* sysdep: +ulong32 */ /* sysdep: -ulong64 */ /* sysdep: -utilh */ /* sysdep: -libutilh */ /* sysdep: +ptyh */ /* sysdep: -_getpty */ /* sysdep: +openpty */ /* sysdep: -unixh */ /* sysdep: -streams */ /* sysdep: +little_endian */ /* sysdep: -big_endian */ /* sysdep: -egd */ /* sysdep: -tiocremote */ /* sysdep: +posixglob */ /* sysdep: +stdinth */ /* sysdep: +inttypesh */ /* sysdep: +oksyssocket */ prog/skalibs-0.47/precompiled-sysdeps/i686-linux-2.4-dietlibc-0.22/systype0100644000000000000000000000003307674055131022662 0ustar linux-2.4-:i386-:-:ppro-:- prog/skalibs-0.47/precompiled-sysdeps/i686-linux-2.4-dietlibc-0.22/util.lib0100644000000000000000000000000107674050236022660 0ustar prog/skalibs-0.47/precompiled-sysdeps/i686-linux-2.4-dietlibc-0.22/sysdeps.h0100644000000000000000000000335510022317235023057 0ustar /* Public domain. */ #ifndef SYSDEPS_H #define SYSDEPS_H #undef HASDEVTCP /* sysdep: -devtcp */ #undef HASDEVPTC /* sysdep: -devptc */ #define HASDEVPTMX /* sysdep: +devptmx */ #define HASDEVRANDOM /* sysdep: +devrandom */ #define HASDEVURANDOM /* sysdep: +devurandom */ #define HASDIRENT /* sysdep: +dirent */ #define HASEPROTO /* sysdep: +eproto */ #define HASFLOCK /* sysdep: +flock */ #undef HASGETPT /* sysdep: -getpt */ #undef HASGETPEEREID /* sysdep: -getpeereid */ #define HASSO_PEERCRED /* sysdep: +SO_PEERCRED */ #undef HASMALLOC0 /* sysdep: -malloc0 */ #define HASMKFIFO /* sysdep: +mkfifo */ #undef HASNPBG1 /* sysdep: -npbg1 */ #define HASPOLLH /* sysdep: +pollh */ #define HASSYSPOLLH /* sysdep: +syspollh */ #define HASPOLL /* sysdep: +poll */ #define HASSIGACTION /* sysdep: +sigaction */ #define HASSIGPROCMASK /* sysdep: +sigprocmask */ #define HASSHORTSETGROUPS /* sysdep: +shortsetgroups */ #define HASSYSSELECT /* sysdep: +sysselect */ #undef HASREVOKE /* sysdep: -revoke */ #define HASWAITPID /* sysdep: +waitpid */ #define HASULONG32 /* sysdep: +ulong32 */ #undef HASULONG64 /* sysdep: -ulong64 */ #undef HASUTILH /* sysdep: -utilh */ #undef HASLIBUTILH /* sysdep: -libutilh */ #define HASPTYH /* sysdep: +ptyh */ #undef HAS_GETPTY /* sysdep: -_getpty */ #define HASOPENPTY /* sysdep: +openpty */ #undef HASUNIXH /* sysdep: -unixh */ #undef HASSTREAMS /* sysdep: -streams */ #define HASLITTLE_ENDIAN /* sysdep: +little_endian */ #undef HASBIG_ENDIAN /* sysdep: -big_endian */ #undef HASEGD /* sysdep: -egd */ #undef HASTIOCREMOTE /* sysdep: -tiocremote */ #define HASPOSIXGLOB /* sysdep: +posixglob */ #define HASSTDINTH /* sysdep: +stdinth */ #define HASINTTYPESH /* sysdep: +inttypesh */ #define HASOKSYSSOCKET /* sysdep: +oksyssocket */ #endif prog/skalibs-0.47/precompiled-sysdeps/ultrasparc-solaris-7/0040755000000000000000000000000010022320053020711 5ustar prog/skalibs-0.47/precompiled-sysdeps/ultrasparc-solaris-7/sysdeps0100644000000000000000000000233410022320022022321 0ustar sunos-5.7-generic-:sparc-:sun4-:sun4u-:sun4u- #!/bin/sh # WARNING: This file was auto-generated. Do not edit! exec gcc -O2 -W -Wall -fomit-frame-pointer -pipe -c "$1" #!/bin/sh # WARNING: This file was auto-generated. Do not edit! main="$1"; shift ; exec gcc -s -static -o "$main" "$main".o ${1+"$@"} /* sysdep: +devtcp */ /* sysdep: -devptc */ /* sysdep: +devptmx */ /* sysdep: -devrandom */ /* sysdep: -devurandom */ /* sysdep: +dirent */ /* sysdep: +eproto */ /* sysdep: -flock */ /* sysdep: -getpt */ /* sysdep: -getpeereid */ /* sysdep: -SO_PEERCRED */ /* sysdep: +malloc0 */ /* sysdep: +mkfifo */ /* sysdep: -npbg1 */ /* sysdep: -pollh */ /* sysdep: -syspollh */ /* sysdep: -poll */ /* sysdep: +sigaction */ /* sysdep: +sigprocmask */ /* sysdep: -shortsetgroups */ /* sysdep: +sysselect */ /* sysdep: -revoke */ /* sysdep: +waitpid */ /* sysdep: +ulong32 */ /* sysdep: -ulong64 */ /* sysdep: -utilh */ /* sysdep: -libutilh */ /* sysdep: -ptyh */ /* sysdep: -_getpty */ /* sysdep: -openpty */ /* sysdep: -unixh */ /* sysdep: +streams */ /* sysdep: -little_endian */ /* sysdep: +big_endian */ /* sysdep: -egd */ /* sysdep: +tiocremote */ /* sysdep: +posixglob */ /* sysdep: -stdinth */ /* sysdep: +inttypesh */ /* sysdep: +oksyssocket */ prog/skalibs-0.47/precompiled-sysdeps/ultrasparc-solaris-7/systype0100644000000000000000000000005607674072036022402 0ustar sunos-5.7-generic-:sparc-:sun4-:sun4u-:sun4u- prog/skalibs-0.47/precompiled-sysdeps/ultrasparc-solaris-7/socket.lib0100644000000000000000000000000107674071755022714 0ustar prog/skalibs-0.47/precompiled-sysdeps/ultrasparc-solaris-7/util.lib0100644000000000000000000000000107674071755022401 0ustar prog/skalibs-0.47/precompiled-sysdeps/ultrasparc-solaris-7/sysdeps.h0100644000000000000000000000334610022320050022554 0ustar /* Public domain. */ #ifndef SYSDEPS_H #define SYSDEPS_H #define HASDEVTCP /* sysdep: +devtcp */ #undef HASDEVPTC /* sysdep: -devptc */ #define HASDEVPTMX /* sysdep: +devptmx */ #undef HASDEVRANDOM /* sysdep: -devrandom */ #undef HASDEVURANDOM /* sysdep: -devurandom */ #define HASDIRENT /* sysdep: +dirent */ #define HASEPROTO /* sysdep: +eproto */ #undef HASFLOCK /* sysdep: -flock */ #undef HASGETPT /* sysdep: -getpt */ #undef HASGETPEEREID /* sysdep: -getpeereid */ #undef HASSO_PEERCRED /* sysdep: -SO_PEERCRED */ #define HASMALLOC0 /* sysdep: +malloc0 */ #define HASMKFIFO /* sysdep: +mkfifo */ #undef HASNPBG1 /* sysdep: -npbg1 */ #undef HASPOLLH /* sysdep: -pollh */ #undef HASSYSPOLLH /* sysdep: -syspollh */ #undef HASPOLL /* sysdep: -poll */ #define HASSIGACTION /* sysdep: +sigaction */ #define HASSIGPROCMASK /* sysdep: +sigprocmask */ #undef HASSHORTSETGROUPS /* sysdep: -shortsetgroups */ #define HASSYSSELECT /* sysdep: +sysselect */ #undef HASREVOKE /* sysdep: -revoke */ #define HASWAITPID /* sysdep: +waitpid */ #define HASULONG32 /* sysdep: +ulong32 */ #undef HASULONG64 /* sysdep: -ulong64 */ #undef HASUTILH /* sysdep: -utilh */ #undef HASLIBUTILH /* sysdep: -libutilh */ #undef HASPTYH /* sysdep: -ptyh */ #undef HAS_GETPTY /* sysdep: -_getpty */ #undef HASOPENPTY /* sysdep: -openpty */ #undef HASUNIXH /* sysdep: -unixh */ #define HASSTREAMS /* sysdep: +streams */ #undef HASLITTLE_ENDIAN /* sysdep: -little_endian */ #define HASBIG_ENDIAN /* sysdep: +big_endian */ #undef HASEGD /* sysdep: -egd */ #define HASTIOCREMOTE /* sysdep: +tiocremote */ #define HASPOSIXGLOB /* sysdep: +posixglob */ #undef HASSTDINTH /* sysdep: -stdinth */ #define HASINTTYPESH /* sysdep: +inttypesh */ #define HASOKSYSSOCKET /* sysdep: +oksyssocket */ #endif prog/skalibs-0.47/precompiled-sysdeps/ultrasparc-solaris-8/0040755000000000000000000000000010022320000020702 5ustar prog/skalibs-0.47/precompiled-sysdeps/ultrasparc-solaris-8/sysdeps0100644000000000000000000000233410022317750022340 0ustar sunos-5.8-generic-:sparc-:sun4-:sun4u-:sun4u- #!/bin/sh # WARNING: This file was auto-generated. Do not edit! exec gcc -O2 -W -Wall -fomit-frame-pointer -pipe -c "$1" #!/bin/sh # WARNING: This file was auto-generated. Do not edit! main="$1"; shift ; exec gcc -s -static -o "$main" "$main".o ${1+"$@"} /* sysdep: +devtcp */ /* sysdep: -devptc */ /* sysdep: +devptmx */ /* sysdep: +devrandom */ /* sysdep: +devurandom */ /* sysdep: +dirent */ /* sysdep: +eproto */ /* sysdep: -flock */ /* sysdep: -getpt */ /* sysdep: -getpeereid */ /* sysdep: -SO_PEERCRED */ /* sysdep: +malloc0 */ /* sysdep: +mkfifo */ /* sysdep: -npbg1 */ /* sysdep: -pollh */ /* sysdep: -syspollh */ /* sysdep: -poll */ /* sysdep: +sigaction */ /* sysdep: +sigprocmask */ /* sysdep: -shortsetgroups */ /* sysdep: +sysselect */ /* sysdep: -revoke */ /* sysdep: +waitpid */ /* sysdep: +ulong32 */ /* sysdep: -ulong64 */ /* sysdep: -utilh */ /* sysdep: -libutilh */ /* sysdep: -ptyh */ /* sysdep: -_getpty */ /* sysdep: -openpty */ /* sysdep: -unixh */ /* sysdep: +streams */ /* sysdep: -little_endian */ /* sysdep: +big_endian */ /* sysdep: -egd */ /* sysdep: +tiocremote */ /* sysdep: +posixglob */ /* sysdep: -stdinth */ /* sysdep: +inttypesh */ /* sysdep: +oksyssocket */ prog/skalibs-0.47/precompiled-sysdeps/ultrasparc-solaris-8/systype0100644000000000000000000000005607674060003022372 0ustar sunos-5.8-generic-:sparc-:sun4-:sun4u-:sun4u- prog/skalibs-0.47/precompiled-sysdeps/ultrasparc-solaris-8/socket.lib0100644000000000000000000000000107674057730022712 0ustar prog/skalibs-0.47/precompiled-sysdeps/ultrasparc-solaris-8/util.lib0100644000000000000000000000000107674057730022377 0ustar prog/skalibs-0.47/precompiled-sysdeps/ultrasparc-solaris-8/sysdeps.h0100644000000000000000000000335010022317775022574 0ustar /* Public domain. */ #ifndef SYSDEPS_H #define SYSDEPS_H #define HASDEVTCP /* sysdep: +devtcp */ #undef HASDEVPTC /* sysdep: -devptc */ #define HASDEVPTMX /* sysdep: +devptmx */ #define HASDEVRANDOM /* sysdep: +devrandom */ #define HASDEVURANDOM /* sysdep: +devurandom */ #define HASDIRENT /* sysdep: +dirent */ #define HASEPROTO /* sysdep: +eproto */ #undef HASFLOCK /* sysdep: -flock */ #undef HASGETPT /* sysdep: -getpt */ #undef HASGETPEEREID /* sysdep: -getpeereid */ #undef HASSO_PEERCRED /* sysdep: -SO_PEERCRED */ #define HASMALLOC0 /* sysdep: +malloc0 */ #define HASMKFIFO /* sysdep: +mkfifo */ #undef HASNPBG1 /* sysdep: -npbg1 */ #undef HASPOLLH /* sysdep: -pollh */ #undef HASSYSPOLLH /* sysdep: -syspollh */ #undef HASPOLL /* sysdep: -poll */ #define HASSIGACTION /* sysdep: +sigaction */ #define HASSIGPROCMASK /* sysdep: +sigprocmask */ #undef HASSHORTSETGROUPS /* sysdep: -shortsetgroups */ #define HASSYSSELECT /* sysdep: +sysselect */ #undef HASREVOKE /* sysdep: -revoke */ #define HASWAITPID /* sysdep: +waitpid */ #define HASULONG32 /* sysdep: +ulong32 */ #undef HASULONG64 /* sysdep: -ulong64 */ #undef HASUTILH /* sysdep: -utilh */ #undef HASLIBUTILH /* sysdep: -libutilh */ #undef HASPTYH /* sysdep: -ptyh */ #undef HAS_GETPTY /* sysdep: -_getpty */ #undef HASOPENPTY /* sysdep: -openpty */ #undef HASUNIXH /* sysdep: -unixh */ #define HASSTREAMS /* sysdep: +streams */ #undef HASLITTLE_ENDIAN /* sysdep: -little_endian */ #define HASBIG_ENDIAN /* sysdep: +big_endian */ #undef HASEGD /* sysdep: -egd */ #define HASTIOCREMOTE /* sysdep: +tiocremote */ #define HASPOSIXGLOB /* sysdep: +posixglob */ #undef HASSTDINTH /* sysdep: -stdinth */ #define HASINTTYPESH /* sysdep: +inttypesh */ #define HASOKSYSSOCKET /* sysdep: +oksyssocket */ #endif