Newsgroups: comp.sources.unix From: wirzeniu@cc.helsinki.fi (Lars Wirzenius) Subject: v28i188: liw-modules-0.4 - the LIW module set (for use with Publib), Part01/14 Message-id: <1.785201893.15507@gw.home.vix.com> Sender: unix-sources-moderator@gw.home.vix.com Approved: vixie@gw.home.vix.com Submitted-By: wirzeniu@cc.helsinki.fi (Lars Wirzenius) Posting-Number: Volume 28, Issue 188 Archive-Name: liw-modules-0.4/part01 This is a collection of "C" functions meant to be compiled inside of Publib. Each has a man page and is intended to be highly portable and generally useful. alloc: These routines do dynamic memory allocation. Those with names starting with an x are error checking front-ends of the usual functions. bitarr: These routines implement a bit array. cmp: These routines implement comparison functions for qsort(3), bsearch(3) and others with the same interface. expr: These routines evaluate mathematical expressions given as strings. files: These routines do various operations on files. The functions with names beginning with an x are error checking frontends to the corresponding functions. fname: These routines operate on UNIX/POSIX style filenames (/dir/foo.bar/file.a.b.c). hash: These routines implement a generic hashing table. iset: These routines implement a set of long integers. It is implemented as a linked list of ranges, so as to make it more efficient if there are many dense parts in the set. log: These routines implement a simple log file facility. sbuf: These routines implement a text editor's editing buffer using a simple buffer gap data structure. stack: These routines implement a generic stack. strutil: These routines implement a number of more or less useful string and memory block operatins. #!/bin/sh # This is a shell archive (produced by GNU sharutils 4.1). # To extract the files from this archive, save it to some FILE, remove # everything before the `!/bin/sh' line above, then type `sh FILE'. # # Made on 1994-11-18 19:46 EET by . # Source directory was `/home/wirzeniu/p/publib/dist'. # # Existing files will *not* be overwritten unless `-c' is specified. # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 113 -rw------- liw-modules-0.4/alloc/Makefile # 1520 -rw------- liw-modules-0.4/alloc/README # 306 -rw------- liw-modules-0.4/alloc/alloc.h # 461 -rw------- liw-modules-0.4/alloc/memdup.c # 302 -rw------- liw-modules-0.4/alloc/xfree.c # 2144 -rw------- liw-modules-0.4/alloc/xmalloc.3 # 445 -rw------- liw-modules-0.4/alloc/xmalloc.c # 440 -rw------- liw-modules-0.4/alloc/xmemdup.c # 467 -rw------- liw-modules-0.4/alloc/xrealloc.c # 443 -rw------- liw-modules-0.4/alloc/xstrdup.c # 213 -rw------- liw-modules-0.4/bitarr/Makefile # 1423 -rw------- liw-modules-0.4/bitarr/README # 670 -rw------- liw-modules-0.4/bitarr/ba_and_ba.c # 407 -rw------- liw-modules-0.4/bitarr/ba_clear.c # 403 -rw------- liw-modules-0.4/bitarr/ba_clear_all.c # 661 -rw------- liw-modules-0.4/bitarr/ba_copy.c # 433 -rw------- liw-modules-0.4/bitarr/ba_create.c # 334 -rw------- liw-modules-0.4/bitarr/ba_destroy.c # 404 -rw------- liw-modules-0.4/bitarr/ba_not.c # 741 -rw------- liw-modules-0.4/bitarr/ba_or_ba.c # 733 -rw------- liw-modules-0.4/bitarr/ba_or_not_ba.c # 416 -rw------- liw-modules-0.4/bitarr/ba_query.c # 674 -rw------- liw-modules-0.4/bitarr/ba_resize.c # 481 -rw------- liw-modules-0.4/bitarr/ba_set.c # 588 -rw------- liw-modules-0.4/bitarr/ba_xor_ba.c # 2200 -rw------- liw-modules-0.4/bitarr/bitarr.3 # 1207 -rw------- liw-modules-0.4/bitarr/bitarr.h # 58 -rw------- liw-modules-0.4/cmp/Makefile # 1487 -rw------- liw-modules-0.4/cmp/README # 2207 -rw------- liw-modules-0.4/cmp/cmp.3 # 1506 -rw------- liw-modules-0.4/cmp/cmp.c # 972 -rw------- liw-modules-0.4/cmp/cmp.h # 242 -rw------- liw-modules-0.4/expr/Makefile # 1449 -rw------- liw-modules-0.4/expr/README # 4696 -rw------- liw-modules-0.4/expr/expr.3 # 836 -rw------- liw-modules-0.4/expr/expr.h # 5899 -rw------- liw-modules-0.4/expr/expr_compile.c # 465 -rw------- liw-modules-0.4/expr/expr_eval.c # 549 -rw------- liw-modules-0.4/expr/expr_free.c # 2277 -rw------- liw-modules-0.4/expr/expr_run.c # 2424 -rw------- liw-modules-0.4/expr/test_expr.c # 115 -rw------- liw-modules-0.4/files/Makefile # 1538 -rw------- liw-modules-0.4/files/README # 491 -rw------- liw-modules-0.4/files/fassert.c # 1713 -rw------- liw-modules-0.4/files/files.3 # 886 -rw------- liw-modules-0.4/files/files.h # 1942 -rw------- liw-modules-0.4/files/getaline.c # 523 -rw------- liw-modules-0.4/files/xfclose.c # 651 -rw------- liw-modules-0.4/files/xfopen.c # 426 -rw------- liw-modules-0.4/files/xfseek.c # 455 -rw------- liw-modules-0.4/files/xgetaline.c # 332 -rw------- liw-modules-0.4/fname/Makefile # 1464 -rw------- liw-modules-0.4/fname/README # 1027 -rw------- liw-modules-0.4/fname/fname.3 # 645 -rw------- liw-modules-0.4/fname/fname.h # 411 -rw------- liw-modules-0.4/fname/fnbase.c # 492 -rw------- liw-modules-0.4/fname/fndelbeg.c # 377 -rw------- liw-modules-0.4/fname/fndelend.c # 548 -rw------- liw-modules-0.4/fname/fndelsuf.c # 493 -rw------- liw-modules-0.4/fname/fndir.c # 674 -rw------- liw-modules-0.4/fname/fnhome.c # 576 -rw------- liw-modules-0.4/fname/fnjoin.c # 358 -rw------- liw-modules-0.4/fname/fnlastsuf.c # 1463 -rw------- liw-modules-0.4/fname/fnpathfind.3 # 2172 -rw------- liw-modules-0.4/fname/fnpathfind.c # 1285 -rw------- liw-modules-0.4/fname/fnqualify.3 # 1777 -rw------- liw-modules-0.4/fname/fnqualify.c # 721 -rw------- liw-modules-0.4/fname/fnsetsuf.c # 489 -rw------- liw-modules-0.4/fname/test_fnqualify.c # 52 -rw------- liw-modules-0.4/hash/.depend # 259 -rw------- liw-modules-0.4/hash/Makefile # 1432 -rw------- liw-modules-0.4/hash/README # 2984 -rw------- liw-modules-0.4/hash/hash.3 # 900 -rw------- liw-modules-0.4/hash/hash.h # 629 -rw------- liw-modules-0.4/hash/hash_create.c # 523 -rw------- liw-modules-0.4/hash/hash_destroy.c # 1002 -rw------- liw-modules-0.4/hash/hash_install.c # 577 -rw------- liw-modules-0.4/hash/hash_iter.c # 520 -rw------- liw-modules-0.4/hash/hash_lookup.c # 758 -rw------- liw-modules-0.4/hash/hash_uninstall.c # 403 -rw------- liw-modules-0.4/iset/Makefile # 1552 -rw------- liw-modules-0.4/iset/README # 1629 -rw------- liw-modules-0.4/iset/iset.3 # 987 -rw------- liw-modules-0.4/iset/iset.h # 2367 -rw------- liw-modules-0.4/iset/iset_add.c # 477 -rw------- liw-modules-0.4/iset/iset_add_rng.c # 435 -rw------- liw-modules-0.4/iset/iset_clear.c # 523 -rw------- liw-modules-0.4/iset/iset_contains.c # 848 -rw------- liw-modules-0.4/iset/iset_copy.c # 448 -rw------- liw-modules-0.4/iset/iset_create.c # 343 -rw------- liw-modules-0.4/iset/iset_destroy.c # 499 -rw------- liw-modules-0.4/iset/iset_diff.c # 361 -rw------- liw-modules-0.4/iset/iset_is_empty.c # 601 -rw------- liw-modules-0.4/iset/iset_isect.c # 598 -rw------- liw-modules-0.4/iset/iset_nth_rng.c # 529 -rw------- liw-modules-0.4/iset/iset_range.c # 1309 -rw------- liw-modules-0.4/iset/iset_remove.c # 505 -rw------- liw-modules-0.4/iset/iset_rm_rng.c # 522 -rw------- liw-modules-0.4/iset/iset_union.c # 669 -rw------- liw-modules-0.4/iset/test_add.c # 173 -rw------- liw-modules-0.4/log/Makefile # 1433 -rw------- liw-modules-0.4/log/README # 2553 -rw------- liw-modules-0.4/log/log.3 # 2304 -rw------- liw-modules-0.4/log/log.c # 764 -rw------- liw-modules-0.4/log/log.h # 200 -rw------- liw-modules-0.4/sbuf/Makefile # 1484 -rw------- liw-modules-0.4/sbuf/README # 9542 -rw------- liw-modules-0.4/sbuf/sbuf.c # 2707 -rw------- liw-modules-0.4/sbuf/sbuf.h # 140 -rw------- liw-modules-0.4/stack/Makefile # 1426 -rw------- liw-modules-0.4/stack/README # 706 -rw------- liw-modules-0.4/stack/stack.3 # 523 -rw------- liw-modules-0.4/stack/stack.h # 1229 -rw------- liw-modules-0.4/stack/stack_copy.c # 492 -rw------- liw-modules-0.4/stack/stack_create.c # 440 -rw------- liw-modules-0.4/stack/stack_destroy.c # 311 -rw------- liw-modules-0.4/stack/stack_emptyp.c # 434 -rw------- liw-modules-0.4/stack/stack_pop.c # 1216 -rw------- liw-modules-0.4/stack/stack_push.c # 817 -rw------- liw-modules-0.4/strutil/Makefile # 1480 -rw------- liw-modules-0.4/strutil/README # 724 -rw------- liw-modules-0.4/strutil/memarrfill.3 # 464 -rw------- liw-modules-0.4/strutil/memarrfill.c # 748 -rw------- liw-modules-0.4/strutil/memdel.3 # 396 -rw------- liw-modules-0.4/strutil/memdel.c # 1010 -rw------- liw-modules-0.4/strutil/memfill.3 # 611 -rw------- liw-modules-0.4/strutil/memfill.c # 1066 -rw------- liw-modules-0.4/strutil/memins.3 # 557 -rw------- liw-modules-0.4/strutil/memins.c # 746 -rw------- liw-modules-0.4/strutil/memisort.3 # 809 -rw------- liw-modules-0.4/strutil/memisort.c # 793 -rw------- liw-modules-0.4/strutil/memmem.3 # 520 -rw------- liw-modules-0.4/strutil/memmem.c # 919 -rw------- liw-modules-0.4/strutil/memoverlap.3 # 1122 -rw------- liw-modules-0.4/strutil/memoverlap.c # 692 -rw------- liw-modules-0.4/strutil/memrchr.3 # 468 -rw------- liw-modules-0.4/strutil/memrchr.c # 803 -rw------- liw-modules-0.4/strutil/memrev.3 # 478 -rw------- liw-modules-0.4/strutil/memrev.c # 771 -rw------- liw-modules-0.4/strutil/memrmem.3 # 739 -rw------- liw-modules-0.4/strutil/memrmem.c # 1304 -rw------- liw-modules-0.4/strutil/memshuffle.3 # 564 -rw------- liw-modules-0.4/strutil/memshuffle.c # 1263 -rw------- liw-modules-0.4/strutil/memswap.3 # 703 -rw------- liw-modules-0.4/strutil/memswap.c # 1252 -rw------- liw-modules-0.4/strutil/stracat.3 # 2238 -rw------- liw-modules-0.4/strutil/stracat.c # 1072 -rw------- liw-modules-0.4/strutil/stranaxfrm.3 # 697 -rw------- liw-modules-0.4/strutil/stranaxfrm.c # 483 -rw------- liw-modules-0.4/strutil/strcenter.c # 784 -rw------- liw-modules-0.4/strutil/strchange.3 # 644 -rw------- liw-modules-0.4/strutil/strchange.c # 584 -rw------- liw-modules-0.4/strutil/strcins.3 # 367 -rw------- liw-modules-0.4/strutil/strcins.c # 1845 -rw------- liw-modules-0.4/strutil/strcstr.3 # 1434 -rw------- liw-modules-0.4/strutil/strcstr.c # 1075 -rw------- liw-modules-0.4/strutil/strdel.3 # 423 -rw------- liw-modules-0.4/strutil/strdel.c # 478 -rw------- liw-modules-0.4/strutil/strend.3 # 350 -rw------- liw-modules-0.4/strutil/strend.c # 785 -rw------- liw-modules-0.4/strutil/strendzap.3 # 545 -rw------- liw-modules-0.4/strutil/strendzap.c # 1346 -rw------- liw-modules-0.4/strutil/strgsub.3 # 892 -rw------- liw-modules-0.4/strutil/strgsub.c # 977 -rw------- liw-modules-0.4/strutil/strhash.3 # 394 -rw------- liw-modules-0.4/strutil/strhash.c # 954 -rw------- liw-modules-0.4/strutil/strinit.3 # 393 -rw------- liw-modules-0.4/strutil/strinit.c # 756 -rw------- liw-modules-0.4/strutil/strins.3 # 576 -rw------- liw-modules-0.4/strutil/strins.c # 1004 -rw------- liw-modules-0.4/strutil/strrev.3 # 1041 -rw------- liw-modules-0.4/strutil/strltrim.3 # 459 -rw------- liw-modules-0.4/strutil/strltrim.c # 1245 -rw------- liw-modules-0.4/strutil/strmaxcpy.3 # 480 -rw------- liw-modules-0.4/strutil/strmaxcpy.c # 682 -rw------- liw-modules-0.4/strutil/strmove.3 # 406 -rw------- liw-modules-0.4/strutil/strmove.c # 755 -rw------- liw-modules-0.4/strutil/strmtrim.3 # 683 -rw------- liw-modules-0.4/strutil/strmtrim.c # 746 -rw------- liw-modules-0.4/strutil/strndup.3 # 598 -rw------- liw-modules-0.4/strutil/strndup.c # 830 -rw------- liw-modules-0.4/strutil/strnins.3 # 630 -rw------- liw-modules-0.4/strutil/strnins.c # 669 -rw------- liw-modules-0.4/strutil/stroverlap.3 # 399 -rw------- liw-modules-0.4/strutil/stroverlap.c # 390 -rw------- liw-modules-0.4/strutil/strrev.c # 679 -rw------- liw-modules-0.4/strutil/strright.3 # 429 -rw------- liw-modules-0.4/strutil/strright.c # 854 -rw------- liw-modules-0.4/strutil/strrot13.3 # 527 -rw------- liw-modules-0.4/strutil/strrot13.c # 1094 -rw------- liw-modules-0.4/strutil/strrstr.3 # 616 -rw------- liw-modules-0.4/strutil/strrstr.c # 916 -rw------- liw-modules-0.4/strutil/strrtrim.3 # 439 -rw------- liw-modules-0.4/strutil/strrtrim.c # 588 -rw------- liw-modules-0.4/strutil/strset.3 # 391 -rw------- liw-modules-0.4/strutil/strset.c # 566 -rw------- liw-modules-0.4/strutil/strshuffle.3 # 391 -rw------- liw-modules-0.4/strutil/strshuffle.c # 3108 -rw------- liw-modules-0.4/strutil/strsplit.3 # 1551 -rw------- liw-modules-0.4/strutil/strsplit.c # 1170 -rw------- liw-modules-0.4/strutil/strsub.3 # 791 -rw------- liw-modules-0.4/strutil/strsub.c # 714 -rw------- liw-modules-0.4/strutil/strtabify.3 # 845 -rw------- liw-modules-0.4/strutil/strtabify.c # 895 -rw------- liw-modules-0.4/strutil/strtrexpand.3 # 963 -rw------- liw-modules-0.4/strutil/strtrexpand.c # 945 -rw------- liw-modules-0.4/strutil/strtrim.3 # 336 -rw------- liw-modules-0.4/strutil/strtrim.c # 785 -rw------- liw-modules-0.4/strutil/struncstr.3 # 1763 -rw------- liw-modules-0.4/strutil/struncstr.c # 728 -rw------- liw-modules-0.4/strutil/struntabify.3 # 580 -rw------- liw-modules-0.4/strutil/struntabify.c # 2955 -rw------- liw-modules-0.4/strutil/strutil.h # 1596 -rw------- liw-modules-0.4/strutil/strvars.3 # 1193 -rw------- liw-modules-0.4/strutil/strvars.c # 661 -rw------- liw-modules-0.4/strutil/strzap.3 # 542 -rw------- liw-modules-0.4/strutil/strzap.c # touch -am 1231235999 $$.touch >/dev/null 2>&1 if test ! -f 1231235999 && test -f $$.touch; then shar_touch=touch else shar_touch=: echo echo 'WARNING: not restoring timestamps. Consider getting and' echo "installing GNU \`touch', distributed in GNU File Utilities..." echo fi rm -f 1231235999 $$.touch # # ============= liw-modules-0.4/alloc/Makefile ============== if test ! -d 'liw-modules-0.4'; then echo 'x - creating directory liw-modules-0.4' mkdir 'liw-modules-0.4' fi if test ! -d 'liw-modules-0.4/alloc'; then echo 'x - creating directory liw-modules-0.4/alloc' mkdir 'liw-modules-0.4/alloc' fi if test -f 'liw-modules-0.4/alloc/Makefile' && test X"$1" != X"-c"; then echo 'x - skipping liw-modules-0.4/alloc/Makefile (file already exists)' else echo 'x - extracting liw-modules-0.4/alloc/Makefile (text)' sed 's/^X//' << 'SHAR_EOF' > 'liw-modules-0.4/alloc/Makefile' && objs = memdup.o xmalloc.o xrealloc.o xfree.o xstrdup.o xmemdup.o include $(srcdir)/Generic.mk X $(objs): alloc.h SHAR_EOF $shar_touch -am 1120190193 'liw-modules-0.4/alloc/Makefile' && chmod 0600 'liw-modules-0.4/alloc/Makefile' || echo 'restore of liw-modules-0.4/alloc/Makefile failed' shar_count="`wc -c < 'liw-modules-0.4/alloc/Makefile'`" test 113 -eq "$shar_count" || echo "liw-modules-0.4/alloc/Makefile: original size 113, current size $shar_count" fi # ============= liw-modules-0.4/alloc/README ============== if test -f 'liw-modules-0.4/alloc/README' && test X"$1" != X"-c"; then echo 'x - skipping liw-modules-0.4/alloc/README (file already exists)' else echo 'x - extracting liw-modules-0.4/alloc/README (text)' sed 's/^X//' << 'SHAR_EOF' > 'liw-modules-0.4/alloc/README' && README for Publib module alloc Lars Wirzenius "@(#)publib-alloc:README,v 1.2 1994/08/28 17:09:28 liw Exp" X These routines do dynamic memory allocation. Those with names starting with an x are error checking front-ends of the usual functions. X ---------------------- X Copyright (c) 1994 Lars Wirzenius. All rights reserved. X Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: X 1. Redistributions of source code must retain the above copyright X notice, this list of conditions and the following disclaimer. X 2. Redistributions in binary form must reproduce the above copyright X notice, this list of conditions and the following disclaimer in the X documentation and/or other materials provided with the distribution. X THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SHAR_EOF $shar_touch -am 0828200994 'liw-modules-0.4/alloc/README' && chmod 0600 'liw-modules-0.4/alloc/README' || echo 'restore of liw-modules-0.4/alloc/README failed' shar_count="`wc -c < 'liw-modules-0.4/alloc/README'`" test 1520 -eq "$shar_count" || echo "liw-modules-0.4/alloc/README: original size 1520, current size $shar_count" fi # ============= liw-modules-0.4/alloc/alloc.h ============== if test -f 'liw-modules-0.4/alloc/alloc.h' && test X"$1" != X"-c"; then echo 'x - skipping liw-modules-0.4/alloc/alloc.h (file already exists)' else echo 'x - extracting liw-modules-0.4/alloc/alloc.h (text)' sed 's/^X//' << 'SHAR_EOF' > 'liw-modules-0.4/alloc/alloc.h' && #ifndef __publib_alloc_h #define __publib_alloc_h X #include /* need size_t */ X void *xmalloc(size_t); void *xrealloc(void *, size_t); void xfree(void *); X char *strdup(const char *); char *xstrdup(const char *); X void *memdup(const void *, size_t); void *xmemdup(const void *, size_t); X #endif SHAR_EOF $shar_touch -am 1120190193 'liw-modules-0.4/alloc/alloc.h' && chmod 0600 'liw-modules-0.4/alloc/alloc.h' || echo 'restore of liw-modules-0.4/alloc/alloc.h failed' shar_count="`wc -c < 'liw-modules-0.4/alloc/alloc.h'`" test 306 -eq "$shar_count" || echo "liw-modules-0.4/alloc/alloc.h: original size 306, current size $shar_count" fi # ============= liw-modules-0.4/alloc/memdup.c ============== if test -f 'liw-modules-0.4/alloc/memdup.c' && test X"$1" != X"-c"; then echo 'x - skipping liw-modules-0.4/alloc/memdup.c (file already exists)' else echo 'x - extracting liw-modules-0.4/alloc/memdup.c (text)' sed 's/^X//' << 'SHAR_EOF' > 'liw-modules-0.4/alloc/memdup.c' && /* X * memdup.c -- duplicate memory block X * X * Part of publib. See man page for more information X * "@(#)publib-alloc:memdup.c,v 1.1.1.1 1993/11/20 17:01:29 liw Exp" X */ X #include #include #include "publib/alloc.h" #include "publib/errormsg.h" X void *memdup(const void *p, size_t n) { X void *q; X X assert(p != NULL); X assert(n > 0); X X q = malloc(n); X if (q == NULL) X __publib_error("malloc failed"); X else X memcpy(q, p, n); X return q; } SHAR_EOF $shar_touch -am 1120190193 'liw-modules-0.4/alloc/memdup.c' && chmod 0600 'liw-modules-0.4/alloc/memdup.c' || echo 'restore of liw-modules-0.4/alloc/memdup.c failed' shar_count="`wc -c < 'liw-modules-0.4/alloc/memdup.c'`" test 461 -eq "$shar_count" || echo "liw-modules-0.4/alloc/memdup.c: original size 461, current size $shar_count" fi # ============= liw-modules-0.4/alloc/xfree.c ============== if test -f 'liw-modules-0.4/alloc/xfree.c' && test X"$1" != X"-c"; then echo 'x - skipping liw-modules-0.4/alloc/xfree.c (file already exists)' else echo 'x - extracting liw-modules-0.4/alloc/xfree.c (text)' sed 's/^X//' << 'SHAR_EOF' > 'liw-modules-0.4/alloc/xfree.c' && /* X * xfree.c -- frontend for free (mostly for symmetricity with x*alloc) X * X * Part of publib. See man page for more information X * "@(#)publib-alloc:xfree.c,v 1.1.1.1 1993/11/20 17:01:28 liw Exp" X */ X #include #include "publib/alloc.h" X void xfree(void *p) { X if (p != NULL) X free(p); } SHAR_EOF $shar_touch -am 1120190193 'liw-modules-0.4/alloc/xfree.c' && chmod 0600 'liw-modules-0.4/alloc/xfree.c' || echo 'restore of liw-modules-0.4/alloc/xfree.c failed' shar_count="`wc -c < 'liw-modules-0.4/alloc/xfree.c'`" test 302 -eq "$shar_count" || echo "liw-modules-0.4/alloc/xfree.c: original size 302, current size $shar_count" fi # ============= liw-modules-0.4/alloc/xmalloc.3 ============== if test -f 'liw-modules-0.4/alloc/xmalloc.3' && test X"$1" != X"-c"; then echo 'x - skipping liw-modules-0.4/alloc/xmalloc.3 (file already exists)' else echo 'x - extracting liw-modules-0.4/alloc/xmalloc.3 (text)' sed 's/^X//' << 'SHAR_EOF' > 'liw-modules-0.4/alloc/xmalloc.3' && X.\" part of publib X.\" "@(#)publib-alloc:xmalloc.3,v 1.4 1994/08/28 16:55:04 liw Exp" X.\" X.TH XMALLOC 3 "C Programmer's Manual" "Publib" "C Programmer's Manual" X.SH NAME xmalloc, xrealloc, xfree, xstrdup, xmemdup, memdup \- memory allocation functions for Publib X.SH SYNOPSIS #include X.sp 1 X.nf void *\fBxmalloc\fR(size_t \fIbytes\fR); void *\fBxrealloc\fR(void *\fIptr\fR, size_t \fIbytes\fR); void \fBxfree\fR(void *\fIptr\fR); char *\fBstrdup\fR(const char *\fIstring\fR); char *\fBxstrdup\fR(const char *\fIstring\fR); void *\fBmemdup\fR(const void *\fImem\fR, size_t \fIbytes\fR); void *\fBxmemdup\fR(const void *\fImem\fR, size_t \fIbytes\fR); X.SH "DESCRIPTION" These functions are utility functions for memory allocation from the publib library. \fIxmalloc\fR, \fIxrealloc\fR, and \fIxfree\fR are error checking versions of the standard library routines \fImalloc\fR, \fIrealloc\fR, and \fIfree\fR, respectively. They are guaranteed to never return unless there was no problem: if, for example, \fIxmalloc\fR is unable to allocate the requested amount of memory, it prints an error message and terminates the program. Hence, the caller does not need to check for a NULL return value, and the code that calls these functions is simpler due to the lack of error checks. X.PP Similarly, \fIxstrdup\fR is an error checking version of the common (though not standard) \fIstrdup\fR routine, which creates a duplicate of a string by allocating memory for the copy with \fImalloc\fR. (For systems that lack \fIstrdup\fR, publib provides one in its portability module; it is always declared in .) X.PP \fImemdup\fR is similar to \fIstrdup\fR, it creates a copy of an arbitrary memory area (the arguments are a pointer to the beginning of the area, and its size) by allocating memory for the copy with \fImalloc\fR. \fIxmemdup\fR is its error checking version. X.SH NOTE \fIxmalloc\fR and \fIxrealloc\fR treat a request to allocate a block of 0 bytes as an error. \fIxrealloc\fR will allow its first argument to be NULL. X.SH "SEE ALSO" publib(3), malloc(3), strdup(3) X.SH AUTHOR Lars Wirzenius (lars.wirzenius@helsinki.fi) SHAR_EOF $shar_touch -am 0828195594 'liw-modules-0.4/alloc/xmalloc.3' && chmod 0600 'liw-modules-0.4/alloc/xmalloc.3' || echo 'restore of liw-modules-0.4/alloc/xmalloc.3 failed' shar_count="`wc -c < 'liw-modules-0.4/alloc/xmalloc.3'`" test 2144 -eq "$shar_count" || echo "liw-modules-0.4/alloc/xmalloc.3: original size 2144, current size $shar_count" fi # ============= liw-modules-0.4/alloc/xmalloc.c ============== if test -f 'liw-modules-0.4/alloc/xmalloc.c' && test X"$1" != X"-c"; then echo 'x - skipping liw-modules-0.4/alloc/xmalloc.c (file already exists)' else echo 'x - extracting liw-modules-0.4/alloc/xmalloc.c (text)' sed 's/^X//' << 'SHAR_EOF' > 'liw-modules-0.4/alloc/xmalloc.c' && /* X * xmalloc.c -- error checking malloc X * X * Part of publib. See man page for more information X * "@(#)publib-alloc:xmalloc.c,v 1.3 1994/10/06 11:07:51 liw Exp" X */ X #include #include #include "publib/alloc.h" #include "publib/errormsg.h" X void *xmalloc(size_t n) { X char *q; X X assert(n > 0); X q = malloc(n); X if (q == NULL) { X __publib_error("malloc failed"); X abort(); /* we must not return, ever */ X } X return q; } SHAR_EOF $shar_touch -am 1006130794 'liw-modules-0.4/alloc/xmalloc.c' && chmod 0600 'liw-modules-0.4/alloc/xmalloc.c' || echo 'restore of liw-modules-0.4/alloc/xmalloc.c failed' shar_count="`wc -c < 'liw-modules-0.4/alloc/xmalloc.c'`" test 445 -eq "$shar_count" || echo "liw-modules-0.4/alloc/xmalloc.c: original size 445, current size $shar_count" fi # ============= liw-modules-0.4/alloc/xmemdup.c ============== if test -f 'liw-modules-0.4/alloc/xmemdup.c' && test X"$1" != X"-c"; then echo 'x - skipping liw-modules-0.4/alloc/xmemdup.c (file already exists)' else echo 'x - extracting liw-modules-0.4/alloc/xmemdup.c (text)' sed 's/^X//' << 'SHAR_EOF' > 'liw-modules-0.4/alloc/xmemdup.c' && /* X * xmemdup.c -- error checking memdup X * X * Part of publib. See man page for more information X * "@(#)publib-alloc:xmemdup.c,v 1.1.1.1 1993/11/20 17:01:29 liw Exp" X */ X #include #include #include "publib/alloc.h" #include "publib/errormsg.h" X void *xmemdup(const void *p, size_t n) { X char *q; X X assert(p != NULL); X assert(n > 0); X q = memdup(p, n); X if (q == NULL) X __publib_error("memdup failed"); X return q; } SHAR_EOF $shar_touch -am 1120190193 'liw-modules-0.4/alloc/xmemdup.c' && chmod 0600 'liw-modules-0.4/alloc/xmemdup.c' || echo 'restore of liw-modules-0.4/alloc/xmemdup.c failed' shar_count="`wc -c < 'liw-modules-0.4/alloc/xmemdup.c'`" test 440 -eq "$shar_count" || echo "liw-modules-0.4/alloc/xmemdup.c: original size 440, current size $shar_count" fi # ============= liw-modules-0.4/alloc/xrealloc.c ============== if test -f 'liw-modules-0.4/alloc/xrealloc.c' && test X"$1" != X"-c"; then echo 'x - skipping liw-modules-0.4/alloc/xrealloc.c (file already exists)' else echo 'x - extracting liw-modules-0.4/alloc/xrealloc.c (text)' sed 's/^X//' << 'SHAR_EOF' > 'liw-modules-0.4/alloc/xrealloc.c' && /* X * xrealloc.c -- error checking realloc X * X * Part of publib. See man page for more information X * "@(#)publib-alloc:xrealloc.c,v 1.3 1994/07/16 12:06:38 liw Exp" X */ X #include #include #include "publib/alloc.h" #include "publib/errormsg.h" X void *xrealloc(void *p, size_t n) { X char *q; X X assert(n > 0); X X if (p == NULL) X q = malloc(n); X else X q = realloc(p, n); X if (q == NULL) X __publib_error("malloc or realloc failed"); X return q; } SHAR_EOF $shar_touch -am 0716150694 'liw-modules-0.4/alloc/xrealloc.c' && chmod 0600 'liw-modules-0.4/alloc/xrealloc.c' || echo 'restore of liw-modules-0.4/alloc/xrealloc.c failed' shar_count="`wc -c < 'liw-modules-0.4/alloc/xrealloc.c'`" test 467 -eq "$shar_count" || echo "liw-modules-0.4/alloc/xrealloc.c: original size 467, current size $shar_count" fi # ============= liw-modules-0.4/alloc/xstrdup.c ============== if test -f 'liw-modules-0.4/alloc/xstrdup.c' && test X"$1" != X"-c"; then echo 'x - skipping liw-modules-0.4/alloc/xstrdup.c (file already exists)' else echo 'x - extracting liw-modules-0.4/alloc/xstrdup.c (text)' sed 's/^X//' << 'SHAR_EOF' > 'liw-modules-0.4/alloc/xstrdup.c' && /* X * xstrdup.c -- error checking string duplication X * X * Part of publib. See man page for more information X * "@(#)publib-alloc:xstrdup.c,v 1.1.1.1 1993/11/20 17:01:28 liw Exp" X */ X #include #include #include #include "publib/alloc.h" #include "publib/errormsg.h" X char *xstrdup(const char *s) { X char *p; X X assert(s != NULL); X p = strdup(s); X if (p == NULL) X __publib_error("strdup failed"); X return p; } SHAR_EOF $shar_touch -am 1120190193 'liw-modules-0.4/alloc/xstrdup.c' && chmod 0600 'liw-modules-0.4/alloc/xstrdup.c' || echo 'restore of liw-modules-0.4/alloc/xstrdup.c failed' shar_count="`wc -c < 'liw-modules-0.4/alloc/xstrdup.c'`" test 443 -eq "$shar_count" || echo "liw-modules-0.4/alloc/xstrdup.c: original size 443, current size $shar_count" fi # ============= liw-modules-0.4/bitarr/Makefile ============== if test ! -d 'liw-modules-0.4/bitarr'; then echo 'x - creating directory liw-modules-0.4/bitarr' mkdir 'liw-modules-0.4/bitarr' fi if test -f 'liw-modules-0.4/bitarr/Makefile' && test X"$1" != X"-c"; then echo 'x - skipping liw-modules-0.4/bitarr/Makefile (file already exists)' else echo 'x - extracting liw-modules-0.4/bitarr/Makefile (text)' sed 's/^X//' << 'SHAR_EOF' > 'liw-modules-0.4/bitarr/Makefile' && objs = ba_and_ba.o ba_clear.o ba_clear_all.o ba_copy.o ba_create.o \ X ba_destroy.o ba_not.o ba_or_ba.o ba_or_not_ba.o ba_query.o \ X ba_resize.o ba_set.o ba_xor_ba.o include $(srcdir)/Generic.mk X $(objs): bitarr.h SHAR_EOF $shar_touch -am 1120190093 'liw-modules-0.4/bitarr/Makefile' && chmod 0600 'liw-modules-0.4/bitarr/Makefile' || echo 'restore of liw-modules-0.4/bitarr/Makefile failed' shar_count="`wc -c < 'liw-modules-0.4/bitarr/Makefile'`" test 213 -eq "$shar_count" || echo "liw-modules-0.4/bitarr/Makefile: original size 213, current size $shar_count" fi # ============= liw-modules-0.4/bitarr/README ============== if test -f 'liw-modules-0.4/bitarr/README' && test X"$1" != X"-c"; then echo 'x - skipping liw-modules-0.4/bitarr/README (file already exists)' else echo 'x - extracting liw-modules-0.4/bitarr/README (text)' sed 's/^X//' << 'SHAR_EOF' > 'liw-modules-0.4/bitarr/README' && README for Publib module bitarr Lars Wirzenius "@(#)publib-alloc:README,v 1.2 1994/08/28 17:09:42 liw Exp" X These routines implement a bit array. X ---------------------- X Copyright (c) 1994 Lars Wirzenius. All rights reserved. X Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: X 1. Redistributions of source code must retain the above copyright X notice, this list of conditions and the following disclaimer. X 2. Redistributions in binary form must reproduce the above copyright X notice, this list of conditions and the following disclaimer in the X documentation and/or other materials provided with the distribution. X THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SHAR_EOF $shar_touch -am 0828200994 'liw-modules-0.4/bitarr/README' && chmod 0600 'liw-modules-0.4/bitarr/README' || echo 'restore of liw-modules-0.4/bitarr/README failed' shar_count="`wc -c < 'liw-modules-0.4/bitarr/README'`" test 1423 -eq "$shar_count" || echo "liw-modules-0.4/bitarr/README: original size 1423, current size $shar_count" fi : || echo 'restore of liw-modules-0.4/bitarr/ba_and_ba.c failed' echo 'End of part 1, continue with part 2' exit 0