home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-01-09 | 42.2 KB | 1,336 lines |
- Newsgroups: comp.sources.misc
- From: lm@rmit.edu.au (Luke Mewburn)
- Subject: v41i079: casu - comms. & status utils, v3.3, Part04/04
- Message-ID: <1994Jan10.025706.4171@sparky.sterling.com>
- X-Md4-Signature: bafe48d7982ee05f591c12909d9f5741
- Sender: kent@sparky.sterling.com (Kent Landfield)
- Organization: Sterling Software
- Date: Mon, 10 Jan 1994 02:57:06 GMT
- Approved: kent@sparky.sterling.com
-
- Submitted-by: lm@rmit.edu.au (Luke Mewburn)
- Posting-number: Volume 41, Issue 79
- Archive-name: casu/part04
- Environment: UNIX, ANSI-C
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # Contents: casu-3.3/INSTALL casu-3.3/NEWS casu-3.3/README
- # casu-3.3/__TODO__ casu-3.3/bsearch.c casu-3.3/configure.in
- # casu-3.3/eg.friends casu-3.3/eg.torc casu-3.3/getutent.c
- # casu-3.3/main.c casu-3.3/qsort.c casu-3.3/tags casu-3.3/various.c
- # Wrapped by kent@sparky on Sun Jan 9 20:46:39 1994
- PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 4 (of 4)."'
- if test -f 'casu-3.3/INSTALL' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'casu-3.3/INSTALL'\"
- else
- echo shar: Extracting \"'casu-3.3/INSTALL'\" \(5776 characters\)
- sed "s/^X//" >'casu-3.3/INSTALL' <<'END_OF_FILE'
- XThis is a generic INSTALL file for utilities distributions.
- XIf this package does not come with, e.g., installable documentation or
- Xdata files, please ignore the references to them below.
- X
- XTo compile this package:
- X
- X1. Configure the package for your system. In the directory that this
- Xfile is in, type `./configure'. If you're using `csh' on an old
- Xversion of System V, you might need to type `sh configure' instead to
- Xprevent `csh' from trying to execute `configure' itself.
- X
- XThe `configure' shell script attempts to guess correct values for
- Xvarious system-dependent variables used during compilation, and
- Xcreates the Makefile(s) (one in each subdirectory of the source
- Xdirectory). In some packages it creates a C header file containing
- Xsystem-dependent definitions. It also creates a file `config.status'
- Xthat you can run in the future to recreate the current configuration.
- X
- XRunning `configure' takes a minute or two. While it is running, it
- Xprints some messages that tell what it is doing. If you don't want to
- Xsee the messages, run `configure' with its standard output redirected
- Xto `/dev/null'; for example, `./configure >/dev/null'.
- X
- XTo compile the package in a different directory from the one
- Xcontaining the source code, you must use a version of `make' that
- Xsupports the VPATH variable, such as GNU `make'. `cd' to the directory
- Xwhere you want the object files and executables to go and run
- X`configure'. `configure' automatically checks for the source code in
- Xthe directory that `configure' is in and in `..'. If for some reason
- X`configure' is not in the source code directory that you are
- Xconfiguring, then it will report that it can't find the source code.
- XIn that case, run `configure' with the option `--srcdir=DIR', where
- XDIR is the directory that contains the source code.
- X
- XBy default, `make install' will install the package's files in
- X/usr/local/bin, /usr/local/lib, /usr/local/man, etc. You can specify an
- Xinstallation prefix other than /usr/local by giving `configure' the option
- X`--prefix=PATH'. Alternately, you can do so by consistently giving a value
- Xfor the `prefix' variable when you run `make', e.g.,
- X make prefix=/usr/gnu
- X make prefix=/usr/gnu install
- X
- XYou can specify separate installation prefixes for
- Xarchitecture-specific files and architecture-independent files. If
- Xyou give `configure' the option `--exec-prefix=PATH' or set the
- X`make' variable `exec_prefix' to PATH, the package will use PATH as
- Xthe prefix for installing programs and libraries. Data files and
- Xdocumentation will still use the regular prefix. Normally, all files
- Xare installed using the regular prefix.
- X
- XAnother `configure' option is useful mainly in `Makefile' rules for
- Xupdating `config.status' and `Makefile'. The `--no-create' option
- Xfigures out the configuration for your system and records it in
- X`config.status', without actually configuring the package (creating
- X`Makefile's and perhaps a configuration header file). Later, you can
- Xrun `./config.status' to actually configure the package. You can also
- Xgive `config.status' the `--recheck' option, which makes it re-run
- X`configure' with the same arguments you used before. This option is
- Xuseful if you change `configure'.
- X
- XSome packages pay attention to `--with-PACKAGE' options to `configure',
- Xwhere PACKAGE is something like `gnu-libc' or `x' (for the X Window System).
- XThe README should mention any --with- options that the package recognizes.
- X
- X`configure' ignores any other arguments that you give it.
- X
- XIf your system requires unusual options for compilation or linking
- Xthat `configure' doesn't know about, you can give `configure' initial
- Xvalues for some variables by setting them in the environment. In
- XBourne-compatible shells, you can do that on the command line like
- Xthis:
- X CC='gcc -traditional' DEFS=-D_POSIX_SOURCE ./configure
- X
- XThe `make' variables that you might want to override with environment
- Xvariables when running `configure' are:
- X
- X(For these variables, any value given in the environment overrides the
- Xvalue that `configure' would choose:)
- XCC C compiler program.
- X Default is `cc', or `gcc' if `gcc' is in your PATH.
- XINSTALL Program to use to install files.
- X Default is `install' if you have it, `cp' otherwise.
- X
- X(For these variables, any value given in the environment is added to
- Xthe value that `configure' chooses:)
- XDEFS Configuration options, in the form `-Dfoo -Dbar ...'
- X Do not use this variable in packages that create a
- X configuration header file.
- XLIBS Libraries to link with, in the form `-lfoo -lbar ...'
- X
- XIf you need to do unusual things to compile the package, we encourage
- Xyou to figure out how `configure' could check whether to do them, and
- Xmail diffs or instructions to the address given in the README so we
- Xcan include them in the next release.
- X
- X2. Type `make' to compile the package. If you want, you can override
- Xthe `make' variables CFLAGS and LDFLAGS like this:
- X
- X make CFLAGS=-O2 LDFLAGS=-s
- X
- X3. If the package comes with self-tests and you want to run them,
- Xtype `make check'. If you're not sure whether there are any, try it;
- Xif `make' responds with something like
- X make: *** No way to make target `check'. Stop.
- Xthen the package does not come with self-tests.
- X
- X4. Type `make install' to install programs, data files, and
- Xdocumentation.
- X
- X5. You can remove the program binaries and object files from the
- Xsource directory by typing `make clean'. To also remove the
- XMakefile(s), the header file containing system-dependent definitions
- X(if the package uses one), and `config.status' (all the files that
- X`configure' created), type `make distclean'.
- X
- XThe file `configure.in' is used as a template to create `configure' by
- Xa program called `autoconf'. You will only need it if you want to
- Xregenerate `configure' using a newer version of `autoconf'.
- END_OF_FILE
- if test 5776 -ne `wc -c <'casu-3.3/INSTALL'`; then
- echo shar: \"'casu-3.3/INSTALL'\" unpacked with wrong size!
- fi
- # end of 'casu-3.3/INSTALL'
- fi
- if test -f 'casu-3.3/NEWS' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'casu-3.3/NEWS'\"
- else
- echo shar: Extracting \"'casu-3.3/NEWS'\" \(1506 characters\)
- sed "s/^X//" >'casu-3.3/NEWS' <<'END_OF_FILE'
- XUser visible changes in CaSU.
- X
- XCurrent version: 3.3.1
- XSee the file ChangeLog for details of all changes.
- X
- XMajor changes from 3.3 to 3.3.1:
- X* improved installation instructions and manual page installation
- X
- XMajor changes from 3.2.2 to 3.3:
- X* flon: support for machines that run YP/NIS and use a different
- X getpwent() added.
- X* flon: added %b (hostname in brackets) to output format
- X* to: new .torc files will always have the user's group.
- X* flon: ``you're not technically logged on'' reworded.
- X
- XMajor changes from 3.2.1 to 3.2.2:
- X* to: all user `configurable' values for messages & autoreplies,
- X such as the name, message, and autoreplies, are filtered for
- X `illegal' characters (which are replaced with `?' as decribed below.)
- X* to: added the concept of a `dot tty'. So, `to .' remembers which tty
- X you sent a message to.
- X* to: added `-E user', which removes an exclude entry.
- X* to: ignore excess `exclude user' entries.
- X* fixed up man pages for the Solaris 2 man program's autoformatter
- X
- XMajor changes from 3.2 to 3.2.1
- X* to: interactively read in message if non specified on the command line.
- X* to: sane limits on message size, and changing of all non-ASCII
- X (including control codes) to `?'.
- X* to: addition of an `exclude' class, and an appropriate auto-reply to
- X prevent certain users from contacting you.
- X* flon: setting of default %h width back to 16.
- X* flon: When run as who, use a variant width to print the host field
- X (to prevent an unnecessary padding of spaces on the right hand margin.)
- END_OF_FILE
- if test 1506 -ne `wc -c <'casu-3.3/NEWS'`; then
- echo shar: \"'casu-3.3/NEWS'\" unpacked with wrong size!
- fi
- # end of 'casu-3.3/NEWS'
- fi
- if test -f 'casu-3.3/README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'casu-3.3/README'\"
- else
- echo shar: Extracting \"'casu-3.3/README'\" \(2542 characters\)
- sed "s/^X//" >'casu-3.3/README' <<'END_OF_FILE'
- XCaSU -- communications & status utilities.
- X
- X
- XIntro:
- X------
- X
- XCaSU is a collection of programs for communicating with, and showing
- Xthe status of, other users (especially your friends). The package
- Xcurrently consists of:
- X flon -- lists your friends who are logged on
- X to -- sends a short message to another user
- X
- X
- X_flon_ uses the `$HOME/.friends' file to instruct it on which users to
- Xselectively display. The file eg.friends contains sample information.
- XThe $FLON environment variable is also used by _flon_. Refer to the
- Xmanual (source form is `FLON.rof') for more details.
- X
- X_to_ uses the `$HOME/.torc' file to store various parameters. The
- Xvarious settings in this text file can either be directly edited,
- Xor set via command line options. The eg.torc file contains a sample.
- XRefer to the manual (source form is `TO.rof') for more details.
- X
- X
- XQuick Installation Notes:
- X-------------------------
- XFrom your favourite shell, run:
- X sh ./configure
- X make
- X make install
- X make install.man
- X
- X
- XSome people may wish to install the manual pages formatted. If this
- Xis the case, type:
- X make install.catman
- X
- XBy default, _flon_ will install a hardlink to itself with the name of
- X`who' (to use _flon_ as who). If you don't want this behaviour, modify
- Xthe Makefile and clear the `who_prog =' variable.
- X
- X_to_ may need to be installed by the system administrator if your system
- Xlimits who can access a user's tty. During configuration, if a message
- Xsuch as:
- X checking mesg y permissions
- X - `to' is setgid to group 5
- Xappears, then this is the case.
- X
- X
- XCaSU 3.3.1 has successfully been ported (in that the author has personally
- Xtested the auto-configured scripts) to the following architectures:
- X A/UX 3.0, NetBSD 0.0, Solaris 2, SunOS 4.1.3, Umax 2.4
- XFlon and To (at various stages of their development) have also been
- Xported to the following architectures: (and theoretically should still
- Xwork without problems)
- X 386BSD 0.1, AIX, Dynix, Irix 4, Linux, SCO Unix, SVR4 (non-Solaris)
- X
- X
- XFuture enhancements:
- X--------------------
- X- addition of a calendar program
- X- enhance package to become the rcaid (remote communications and
- X interactive diary) currently being designed by myself and
- X Andrew Vanderstock, which contains the following subsystems:
- X - remote to (``rto'')
- X - remote flon (``rlon'')
- X - remote calendar (``rcal'')
- X - remote pin-board (``rpin'')
- X
- X
- XBug reports, fixes, suggestions, and enhancements would be gratefully
- Xaccepted by the author, who may be contacted via email at:
- X <lm@rmit.edu.au>
- X
- XLuke Mewburn, 931223.
- END_OF_FILE
- if test 2542 -ne `wc -c <'casu-3.3/README'`; then
- echo shar: \"'casu-3.3/README'\" unpacked with wrong size!
- fi
- # end of 'casu-3.3/README'
- fi
- if test -f 'casu-3.3/__TODO__' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'casu-3.3/__TODO__'\"
- else
- echo shar: Extracting \"'casu-3.3/__TODO__'\" \(134 characters\)
- sed "s/^X//" >'casu-3.3/__TODO__' <<'END_OF_FILE'
- X- hunt and perform genocide upon the remaining bugs (there must be a few.)
- X
- X- ultrix barfs on chmod in sys/stat.h & getpwuid in pwd.h
- END_OF_FILE
- if test 134 -ne `wc -c <'casu-3.3/__TODO__'`; then
- echo shar: \"'casu-3.3/__TODO__'\" unpacked with wrong size!
- fi
- # end of 'casu-3.3/__TODO__'
- fi
- if test -f 'casu-3.3/bsearch.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'casu-3.3/bsearch.c'\"
- else
- echo shar: Extracting \"'casu-3.3/bsearch.c'\" \(3415 characters\)
- sed "s/^X//" >'casu-3.3/bsearch.c' <<'END_OF_FILE'
- X/*
- X * Copyright (c) 1990 Regents of the University of California.
- X * All rights reserved.
- X *
- X * Redistribution and use in source and binary forms, with or without
- X * modification, are permitted provided that the following conditions
- X * 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 * 3. All advertising materials mentioning features or use of this software
- X * must display the following acknowledgement:
- X * This product includes software developed by the University of
- X * California, Berkeley and its contributors.
- X * 4. Neither the name of the University nor the names of its contributors
- X * may be used to endorse or promote products derived from this software
- X * without specific prior written permission.
- X *
- X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- X * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- X * SUCH DAMAGE.
- X */
- X
- X#if defined(LIBC_SCCS) && !defined(lint)
- Xstatic char sccsid[] = "@(#)bsearch.c 5.4 (Berkeley) 2/23/91";
- X#endif /* LIBC_SCCS and not lint */
- X
- X#include "casu.h" /* Luke Mewburn: 930608 */
- X#if 0
- X#include <stddef.h> /* size_t */
- X#include <stdlib.h>
- X#endif
- X
- X
- X/*
- X * Perform a binary search.
- X *
- X * The code below is a bit sneaky. After a comparison fails, we
- X * divide the work in half by moving either left or right. If lim
- X * is odd, moving left simply involves halving lim: e.g., when lim
- X * is 5 we look at item 2, so we change lim to 2 so that we will
- X * look at items 0 & 1. If lim is even, the same applies. If lim
- X * is odd, moving right again involes halving lim, this time moving
- X * the base up one item past p: e.g., when lim is 5 we change base
- X * to item 3 and make lim 2 so that we will look at items 3 and 4.
- X * If lim is even, however, we have to shrink it by one before
- X * halving: e.g., when lim is 4, we still looked at item 2, so we
- X * have to make lim 3, then halve, obtaining 1, so that we will only
- X * look at item 3.
- X */
- Xvoid *
- Xnbsearch(key, base0, nmemb, size, compar)
- X register const void *key;
- X const void *base0;
- X size_t nmemb;
- X register size_t size;
- X register int (*compar) __PROT((const void *, const void *));
- X{
- X register const char *base = base0;
- X register int lim, cmp;
- X register const void *p;
- X
- X for (lim = nmemb; lim != 0; lim >>= 1) {
- X p = base + (lim >> 1) * size;
- X cmp = (*compar)(key, p);
- X if (cmp == 0)
- X return ((void *)p);
- X if (cmp > 0) { /* key > p: move right */
- X base = (char *)p + size;
- X lim--;
- X } /* else move left */
- X }
- X return (NULL);
- X}
- END_OF_FILE
- if test 3415 -ne `wc -c <'casu-3.3/bsearch.c'`; then
- echo shar: \"'casu-3.3/bsearch.c'\" unpacked with wrong size!
- fi
- # end of 'casu-3.3/bsearch.c'
- fi
- if test -f 'casu-3.3/configure.in' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'casu-3.3/configure.in'\"
- else
- echo shar: Extracting \"'casu-3.3/configure.in'\" \(3425 characters\)
- sed "s/^X//" >'casu-3.3/configure.in' <<'END_OF_FILE'
- Xdnl
- Xdnl Process this file with autoconf to produce a configure script.
- Xdnl
- Xdnl Part of the CaSU package, v3.3.1
- Xdnl Written by Luke Mewburn <lm@rmit.edu.au>, 931223
- Xdnl
- Xdnl
- Xdnl
- Xdnl Initialize & check for programs
- Xdnl
- XAC_INIT(casu.h)
- XPROGS="flon to"
- XAC_SUBST(PROGS)dnl
- XAC_PROG_CC
- XAC_PROG_CPP
- XAC_PROG_INSTALL
- XAC_LN_S
- XAC_PROGRAM_CHECK(ROFF, nroff, [nroff -man], cat)
- XAC_PROGRAM_CHECK(TBL, tbl, tbl, cat)
- XAC_PROGRAM_CHECK(YPWHICH, ypwhich, ypwhich, false)
- X
- Xdnl
- Xdnl Check for UNIX variants
- Xdnl
- XAC_AIX
- XAC_DYNIX_SEQ
- XAC_MINIX
- XAC_ISC_POSIX
- X
- Xdnl
- Xdnl Check for typedefs & ANSI
- Xdnl
- XAC_STDC_HEADERS
- XAC_HAVE_HEADERS(stdlib.h,paths.h,unistd.h)
- XAC_UID_T
- XAC_MODE_T
- XAC_SIZE_T
- X
- Xdnl
- Xdnl Compiler characteristics
- Xdnl
- XAC_CROSS_CHECK
- XAC_CONST
- X
- Xdnl
- Xdnl Check for various UNIX services & variants
- Xdnl
- XAC_HEADER_CHECK(netdb.h,
- X AC_HEADER_EGREP(MAXHOSTNAMELEN, netdb.h, AC_DEFINE(NEED_NETDB_H)))
- X
- Xecho "checking mesg y permissions"
- XAC_TEST_PROGRAM([
- X #include <sys/types.h>
- X #include <sys/stat.h>
- X #include <stdio.h>
- X main() {
- X struct stat sb; char *x; int om, m; FILE *fp;
- X if (!(x = ttyname(0))) exit(1);
- X if (stat(x, &sb)) exit(1);
- X om = sb.st_mode;
- X if (chmod(x, om & ~077)) exit(1);
- X m = system("mesg y");
- X if (m == -1 || m == 127) exit(1);
- X if (stat(x, &sb)) exit(1);
- X m = sb.st_mode;
- X if (chmod(x, om)) exit(1);
- X if (!(m & 002)) {
- X if (!(fp=fopen("conftest_grp", "w")))
- X exit(1);
- X fprintf(fp, "%d\n", sb.st_gid);
- X fclose(fp);
- X }
- X exit(0);
- X }
- X],[
- X if test -f conftest_grp; then
- X echo "- 'to' is setgid to group `cat conftest_grp`"
- X AC_DEFINE(TTY_RESTRICTED)
- X TO_GRP=`cat conftest_grp`
- X else
- X echo "- anyone can write to tty"
- X fi
- X],
- X echo "- can't determine - assume anyone can write to tty"
- X)
- XAC_SUBST(TO_GRP)dnl
- X
- Xecho "checking for YP/NIS"
- Xif $YPWHICH >/dev/null 2>&1; then
- X echo "- running YP, using system getpwent"
- X usegetpw=1
- Xelse
- X echo "checking for getpwent db caches"
- X if test -f /etc/passwd.dir || test -f /etc/pwd.db; then
- X echo "- they're there, using system getpwent"
- X usegetpw=1
- X else
- X echo "- unavailable, using own getpwent"
- X fi
- Xfi
- Xif test -n "$usegetpw"; then
- X AC_DEFINE(USE_GETPWENT)
- Xfi
- X
- XAC_HEADER_CHECK(utmpx.h,
- X AC_DEFINE(HAVE_UTMPX_H)
- X AC_DEFINE(HAVE_UT_TYPE)
- X AC_DEFINE(HAVE_UT_HOST)
- X,
- X echo "checking for struct utmp.ut_type"
- X AC_HEADER_EGREP(ut_type, utmp.h, AC_DEFINE(HAVE_UT_TYPE))
- X echo "checking for struct umtp.ut_host"
- X AC_HEADER_EGREP(ut_host, utmp.h, AC_DEFINE(HAVE_UT_HOST))
- X)
- X
- XAC_HAVE_LIBRARY(nsl, [LIBS="$LIBS -lnsl"])
- XAC_HAVE_LIBRARY(socket, [LIBS="$LIBS -lsocket"])
- XAC_HAVE_FUNCS(strerror)
- XAC_REPLACE_FUNCS(getutent)
- X
- Xecho "checking malloc declaration"
- XAC_PROGRAM_EGREP([malloc( | |\()],[
- X#if HAVE_STDLIB_H
- X# include <stdlib.h>
- X#endif
- X],AC_DEFINE(MALLOC_DECL))
- X
- Xecho "checking open declaration"
- XAC_PROGRAM_EGREP([open( | |\()],[
- X#include <fcntl.h>
- X],AC_DEFINE(OPEN_DECL))
- X
- Xecho "checking read declaration"
- XAC_PROGRAM_EGREP([read( | |\()],[
- X#if HAVE_UNISTD_H
- X# include <unistd.h>
- X#endif
- X],AC_DEFINE(READ_DECL))
- X
- XAC_FUNC_CHECK(gethostname,[
- X AC_DEFINE(HAVE_GETHOSTNAME)
- X have_ghn=1
- X],[
- X AC_HAVE_HEADERS(sys/utsname.h)
- X AC_HAVE_FUNCS(uname)
- X])
- Xif test -n "$have_ghn"; then
- X echo "checking gethostname declaration"
- X AC_PROGRAM_EGREP([gethostname( | |\()],[
- X #include <sys/types.h>
- X #if HAVE_UNISTD_H
- X # include <unistd.h>
- X #endif
- X ],AC_DEFINE(GETHOSTNAME_DECL))
- Xfi
- X
- XAC_OUTPUT(Makefile)
- END_OF_FILE
- if test 3425 -ne `wc -c <'casu-3.3/configure.in'`; then
- echo shar: \"'casu-3.3/configure.in'\" unpacked with wrong size!
- fi
- # end of 'casu-3.3/configure.in'
- fi
- if test -f 'casu-3.3/eg.friends' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'casu-3.3/eg.friends'\"
- else
- echo shar: Extracting \"'casu-3.3/eg.friends'\" \(135 characters\)
- sed "s/^X//" >'casu-3.3/eg.friends' <<'END_OF_FILE'
- Xrxkajv OzFuzzy
- Xs902113 Zak, programmer of flon
- X
- Xzrmitcs RMIT computer society
- Xbob Joe Bob Briggs
- X
- X
- Xroot Da Boss
- Xnroot Da boss again.
- END_OF_FILE
- if test 135 -ne `wc -c <'casu-3.3/eg.friends'`; then
- echo shar: \"'casu-3.3/eg.friends'\" unpacked with wrong size!
- fi
- # end of 'casu-3.3/eg.friends'
- fi
- if test -f 'casu-3.3/eg.torc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'casu-3.3/eg.torc'\"
- else
- echo shar: Extracting \"'casu-3.3/eg.torc'\" \(187 characters\)
- sed "s/^X//" >'casu-3.3/eg.torc' <<'END_OF_FILE'
- X. lm
- X: ttyp0
- XP Zak
- XY You rang?
- XI I'm idle - beep me
- XN Can't you see I'm busy? Mail me...
- XG I'm not here at the moment, mail me at: lm@rmit.edu.au
- Xa cyric s902117
- Xa tau s861298
- Xa god root
- END_OF_FILE
- if test 187 -ne `wc -c <'casu-3.3/eg.torc'`; then
- echo shar: \"'casu-3.3/eg.torc'\" unpacked with wrong size!
- fi
- # end of 'casu-3.3/eg.torc'
- fi
- if test -f 'casu-3.3/getutent.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'casu-3.3/getutent.c'\"
- else
- echo shar: Extracting \"'casu-3.3/getutent.c'\" \(1292 characters\)
- sed "s/^X//" >'casu-3.3/getutent.c' <<'END_OF_FILE'
- X/*
- X * CaSU - communications & status utilities.
- X * Copyright (C) 1992, 1993 Luke Mewburn <lm@rmit.edu.au>
- X * incorporating:
- X * flon - lists your friends who are logged on.
- X * to - send a short message to a friend
- X *
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License as published by
- X * the Free Software Foundation; either version 2 of the License, or
- X * (at your option) any later version.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X *
- X */
- X
- X#include "casu.h"
- X
- Xstatic int fd = -1;
- X
- X/*
- X * getutent - support for boxes that need it
- X */
- Xutmp_s *
- Xgetutent()
- X{
- X static utmp_s buf;
- X
- X if (fd == -1)
- X {
- X fd = open(PATH_UTMP, O_RDONLY, 0);
- X if (fd == -1)
- X return NULL;
- X }
- X if (read(fd, &buf, sizeof(buf)) <= 0)
- X return NULL;
- X return &buf;
- X}
- X
- Xvoid
- Xendutent()
- X{
- X close(fd);
- X}
- END_OF_FILE
- if test 1292 -ne `wc -c <'casu-3.3/getutent.c'`; then
- echo shar: \"'casu-3.3/getutent.c'\" unpacked with wrong size!
- fi
- # end of 'casu-3.3/getutent.c'
- fi
- if test -f 'casu-3.3/main.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'casu-3.3/main.c'\"
- else
- echo shar: Extracting \"'casu-3.3/main.c'\" \(2837 characters\)
- sed "s/^X//" >'casu-3.3/main.c' <<'END_OF_FILE'
- X/*
- X * CaSU - communications & status utilities.
- X * Copyright (C) 1992, 1993 Luke Mewburn <lm@rmit.edu.au>
- X * incorporating:
- X * flon - lists your friends who are logged on.
- X * to - send a short message to a friend
- X *
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License as published by
- X * the Free Software Foundation; either version 2 of the License, or
- X * (at your option) any later version.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X *
- X */
- X
- X#define _MAIN_
- X#include "casu.h"
- X
- X#ifdef M_SYSV
- X utmp_s Kludge;
- X#endif /* for SCO */
- X
- X
- X/*
- X * flon main
- X */
- X
- Xvoid
- Xflon_main(argc, argv)
- X int argc;
- X char *argv[];
- X{
- X char *ffile_path=NULL, *format_str=NULL;
- X char *yes_str=NULL, *no_str=NULL;
- X int origargc = argc;
- X
- X add_envopt(&argc, &argv, STRflon);
- X parse_options(origargc, argc, argv, &ffile_path, &format_str,
- X &yes_str, &no_str);
- X parse_format(format_str);
- X get_utmp(1); /* need it sorted/filtered */
- X if (flags & NEED_FFILE)
- X get_friends(ffile_path);
- X#if !USE_GETPWENT
- X if ((flags & (NEED_PASSWD | BEST_NAME)) && (flags & ALL_ON))
- X get_passwd(_PATH_PASSWD);
- X#endif /* !USE_GETPWENT */
- X print_output(yes_str, no_str);
- X} /* flon_main */
- X
- X
- X/*
- X * who main
- X */
- X
- Xvoid
- Xwho_main(argc, argv)
- X int argc;
- X char *argv[];
- X{
- X if (argc > 2)
- X {
- X if ( (strcmp(argv[1], "am")) ||
- X (argv[2][1] != '\0') ||
- X ( (argv[2][0] != 'i') &&
- X (argv[2][0] != 'I')) ||
- X (argc > 3) )
- X {
- X fprintf(stderr, "Usage: %s [ file ]\n %s am { i , I }\n",
- X argv[0], argv[0]);
- X exit(1);
- X }
- X get_utmp(1); /* needed for who_am_I() - filter it */
- X who_am_I();
- X return;
- X }
- X if (argc == 2)
- X utmp_file=argv[1]; /* emulate who <file> */
- X
- X flags = NO_HEADER + NO_TAILER + ALL_ON;
- X /* no head or tail, & list all */
- X get_utmp(0); /* don't filter utmp file */
- X parse_format(WHO_FORMAT);
- X
- X print_output(" ", "*");
- X} /* who_main */
- X
- X
- X/*
- X * main
- X */
- X
- Xint
- Xmain(argc, argv)
- X int argc;
- X char *argv[];
- X{
- X char *p;
- X if (argv[0] == NULL)
- X exit(1);
- X
- X min_idle = MINIDLE;
- X max_idle = MAXIDLE;
- X utmp_file = PATH_UTMP;
- X
- X progname = argv[0];
- X if ((p = strrchr(progname, '/')) != NULL)
- X progname = ++p;
- X if (strcmp(progname, WHO_PROG) == 0)
- X who_main(argc, argv);
- X else
- X flon_main(argc, argv);
- X exit(0);
- X return 0; /* shut the compiler up */
- X} /* main */
- END_OF_FILE
- if test 2837 -ne `wc -c <'casu-3.3/main.c'`; then
- echo shar: \"'casu-3.3/main.c'\" unpacked with wrong size!
- fi
- # end of 'casu-3.3/main.c'
- fi
- if test -f 'casu-3.3/qsort.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'casu-3.3/qsort.c'\"
- else
- echo shar: Extracting \"'casu-3.3/qsort.c'\" \(8218 characters\)
- sed "s/^X//" >'casu-3.3/qsort.c' <<'END_OF_FILE'
- X/*-
- X * Copyright (c) 1980, 1983, 1990 The Regents of the University of California.
- X * All rights reserved.
- X *
- X * Redistribution and use in source and binary forms, with or without
- X * modification, are permitted provided that the following conditions
- X * 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 * 3. All advertising materials mentioning features or use of this software
- X * must display the following acknowledgement:
- X * This product includes software developed by the University of
- X * California, Berkeley and its contributors.
- X * 4. Neither the name of the University nor the names of its contributors
- X * may be used to endorse or promote products derived from this software
- X * without specific prior written permission.
- X *
- X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- X * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- X * SUCH DAMAGE.
- X */
- X
- X#if defined(LIBC_SCCS) && !defined(lint)
- Xstatic char sccsid[] = "@(#)qsort.c 5.9 (Berkeley) 2/23/91";
- X#endif /* LIBC_SCCS and not lint */
- X
- X#include "casu.h" /* Luke, 930608 */
- X#if 0
- X#include <sys/types.h>
- X#include <stdlib.h>
- X#endif
- X
- Xstatic void insertion_sort __PROT((char *bot, int nmemb, register int size,
- X int (*compar)()));
- Xstatic void quick_sort __PROT((char *bot, int nmemb, register int size,
- X int (*compar)()));
- X
- X/*
- X * MTHRESH is the smallest partition for which we compare for a median
- X * value instead of using the middle value.
- X */
- X#define MTHRESH 6
- X
- X/*
- X * THRESH is the minimum number of entries in a partition for continued
- X * partitioning.
- X */
- X#define THRESH 4
- X
- Xvoid
- Xnqsort(bot, nmemb, size, compar)
- X void *bot;
- X size_t nmemb, size;
- X int (*compar) __PROT((const void *, const void *));
- X{
- X if (nmemb <= 1)
- X return;
- X
- X if (nmemb >= THRESH)
- X quick_sort(bot, nmemb, size, compar);
- X else
- X insertion_sort(bot, nmemb, size, compar);
- X}
- X
- X/*
- X * Swap two areas of size number of bytes. Although qsort(3) permits random
- X * blocks of memory to be sorted, sorting pointers is almost certainly the
- X * common case (and, were it not, could easily be made so). Regardless, it
- X * isn't worth optimizing; the SWAP's get sped up by the cache, and pointer
- X * arithmetic gets lost in the time required for comparison function calls.
- X */
- X#define SWAP(a, b) { \
- X cnt = size; \
- X do { \
- X ch = *a; \
- X *a++ = *b; \
- X *b++ = ch; \
- X } while (--cnt); \
- X}
- X
- X/*
- X * Knuth, Vol. 3, page 116, Algorithm Q, step b, argues that a single pass
- X * of straight insertion sort after partitioning is complete is better than
- X * sorting each small partition as it is created. This isn't correct in this
- X * implementation because comparisons require at least one (and often two)
- X * function calls and are likely to be the dominating expense of the sort.
- X * Doing a final insertion sort does more comparisons than are necessary
- X * because it compares the "edges" and medians of the partitions which are
- X * known to be already sorted.
- X *
- X * This is also the reasoning behind selecting a small THRESH value (see
- X * Knuth, page 122, equation 26), since the quicksort algorithm does less
- X * comparisons than the insertion sort.
- X */
- X#define SORT(bot, n) { \
- X if (n > 1) \
- X if (n == 2) { \
- X t1 = bot + size; \
- X if (compar(t1, bot) < 0) \
- X SWAP(t1, bot); \
- X } else \
- X insertion_sort(bot, n, size, compar); \
- X}
- X
- Xstatic void
- Xquick_sort(bot, nmemb, size, compar)
- X register char *bot;
- X register int size;
- X int nmemb, (*compar)();
- X{
- X register int cnt;
- X register unsigned char ch;
- X register char *top, *mid, *t1, *t2;
- X register int n1, n2;
- X char *bsv;
- X
- X /* bot and nmemb must already be set. */
- Xpartition:
- X
- X /* find mid and top elements */
- X mid = bot + size * (nmemb >> 1);
- X top = bot + (nmemb - 1) * size;
- X
- X /*
- X * Find the median of the first, last and middle element (see Knuth,
- X * Vol. 3, page 123, Eq. 28). This test order gets the equalities
- X * right.
- X */
- X if (nmemb >= MTHRESH) {
- X n1 = compar(bot, mid);
- X n2 = compar(mid, top);
- X if (n1 < 0 && n2 > 0)
- X t1 = compar(bot, top) < 0 ? top : bot;
- X else if (n1 > 0 && n2 < 0)
- X t1 = compar(bot, top) > 0 ? top : bot;
- X else
- X t1 = mid;
- X
- X /* if mid element not selected, swap selection there */
- X if (t1 != mid) {
- X SWAP(t1, mid);
- X mid -= size;
- X }
- X }
- X
- X /* Standard quicksort, Knuth, Vol. 3, page 116, Algorithm Q. */
- X#define didswap n1
- X#define newbot t1
- X#define replace t2
- X didswap = 0;
- X for (bsv = bot;;) {
- X for (; bot < mid && compar(bot, mid) <= 0; bot += size);
- X while (top > mid) {
- X if (compar(mid, top) <= 0) {
- X top -= size;
- X continue;
- X }
- X newbot = bot + size; /* value of bot after swap */
- X if (bot == mid) /* top <-> mid, mid == top */
- X replace = mid = top;
- X else { /* bot <-> top */
- X replace = top;
- X top -= size;
- X }
- X goto swap;
- X }
- X if (bot == mid)
- X break;
- X
- X /* bot <-> mid, mid == bot */
- X replace = mid;
- X newbot = mid = bot; /* value of bot after swap */
- X top -= size;
- X
- Xswap: SWAP(bot, replace);
- X bot = newbot;
- X didswap = 1;
- X }
- X
- X /*
- X * Quicksort behaves badly in the presence of data which is already
- X * sorted (see Knuth, Vol. 3, page 119) going from O N lg N to O N^2.
- X * To avoid this worst case behavior, if a re-partitioning occurs
- X * without swapping any elements, it is not further partitioned and
- X * is insert sorted. This wins big with almost sorted data sets and
- X * only loses if the data set is very strangely partitioned. A fix
- X * for those data sets would be to return prematurely if the insertion
- X * sort routine is forced to make an excessive number of swaps, and
- X * continue the partitioning.
- X */
- X if (!didswap) {
- X insertion_sort(bsv, nmemb, size, compar);
- X return;
- X }
- X
- X /*
- X * Re-partition or sort as necessary. Note that the mid element
- X * itself is correctly positioned and can be ignored.
- X */
- X#define nlower n1
- X#define nupper n2
- X bot = bsv;
- X nlower = (mid - bot) / size; /* size of lower partition */
- X mid += size;
- X nupper = nmemb - nlower - 1; /* size of upper partition */
- X
- X /*
- X * If must call recursively, do it on the smaller partition; this
- X * bounds the stack to lg N entries.
- X */
- X if (nlower > nupper) {
- X if (nupper >= THRESH)
- X quick_sort(mid, nupper, size, compar);
- X else {
- X SORT(mid, nupper);
- X if (nlower < THRESH) {
- X SORT(bot, nlower);
- X return;
- X }
- X }
- X nmemb = nlower;
- X } else {
- X if (nlower >= THRESH)
- X quick_sort(bot, nlower, size, compar);
- X else {
- X SORT(bot, nlower);
- X if (nupper < THRESH) {
- X SORT(mid, nupper);
- X return;
- X }
- X }
- X bot = mid;
- X nmemb = nupper;
- X }
- X goto partition;
- X /* NOTREACHED */
- X}
- X
- Xstatic void
- Xinsertion_sort(bot, nmemb, size, compar)
- X char *bot;
- X register int size;
- X int nmemb, (*compar)();
- X{
- X register int cnt;
- X register unsigned char ch;
- X register char *s1, *s2, *t1, *t2, *top;
- X
- X /*
- X * A simple insertion sort (see Knuth, Vol. 3, page 81, Algorithm
- X * S). Insertion sort has the same worst case as most simple sorts
- X * (O N^2). It gets used here because it is (O N) in the case of
- X * sorted data.
- X */
- X top = bot + nmemb * size;
- X for (t1 = bot + size; t1 < top;) {
- X for (t2 = t1; (t2 -= size) >= bot && compar(t1, t2) < 0;);
- X if (t1 != (t2 += size)) {
- X /* Bubble bytes up through each element. */
- X for (cnt = size; cnt--; ++t1) {
- X ch = *t1;
- X for (s1 = s2 = t1; (s2 -= size) >= t2; s1 = s2)
- X *s1 = *s2;
- X *s1 = ch;
- X }
- X } else
- X t1 += size;
- X }
- X}
- END_OF_FILE
- if test 8218 -ne `wc -c <'casu-3.3/qsort.c'`; then
- echo shar: \"'casu-3.3/qsort.c'\" unpacked with wrong size!
- fi
- # end of 'casu-3.3/qsort.c'
- fi
- if test -f 'casu-3.3/tags' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'casu-3.3/tags'\"
- else
- echo shar: Extracting \"'casu-3.3/tags'\" \(1842 characters\)
- sed "s/^X//" >'casu-3.3/tags' <<'END_OF_FILE'
- XMmain main.c /^main(argc, argv)$/
- XMto to.c /^main(margc, margv)$/
- XSORT qsort.c /^#define SORT(bot, n) { \\$/
- XSWAP qsort.c /^#define SWAP(a, b) { \\$/
- Xadd_alist_ent to.c /^add_alist_ent(alias, userid, them)$/
- Xadd_envopt init.c /^void add_envopt(argcp, argvp, name)$/
- Xcompare_friends fileio.c /^compare_friends(entry1, entry2)$/
- Xcompare_users fileio.c /^compare_users(entry1, entry2)$/
- Xcompare_utmp fileio.c /^compare_utmp(entry1, entry2)$/
- Xconstruct_message to.c /^construct_message(me)$/
- Xconvert_realname various.c /^convert_realname(tfb, name, uid)$/
- Xdump_status to.c /^dump_status(me)$/
- Xendutent getutent.c /^endutent()$/
- Xerrexit various.c /^errexit(m1, m2)$/
- Xerrmesg various.c /^errmesg(m1, m2)$/
- Xfilter_buf to.c /^filter_buf(buf)$/
- Xflon_main main.c /^flon_main(argc, argv)$/
- Xget_friends fileio.c /^get_friends(frfile)$/
- Xget_passwd fileio.c /^get_passwd(pwfile)$/
- Xget_pwent to.c /^get_pwent(nam)$/
- Xget_username various.c /^get_username()$/
- Xget_utmp fileio.c /^get_utmp(sort_required)$/
- Xgetutent getutent.c /^getutent()$/
- Xinsertion_sort qsort.c /^insertion_sort(bot, nmemb, size, compar)$/
- Xload_rcfile to.c /^load_rcfile(them, nam)$/
- Xlookup_user to.c /^lookup_user(me, them)$/
- Xnbsearch bsearch.c /^nbsearch(key, base0, nmemb, size, compar)$/
- Xnqsort qsort.c /^nqsort(bot, nmemb, size, compar)$/
- Xparse_format init.c /^parse_format(format)$/
- Xparse_options init.c /^parse_options(origargc, myArgc, myArgv, frfile, fo/
- Xprint_output print.c /^print_output(yes_str, no_str)$/
- Xprocess_options to.c /^process_options(me, you)$/
- Xquick_sort qsort.c /^quick_sort(bot, nmemb, size, compar)$/
- Xremove_alist_ent to.c /^remove_alist_ent(user, them, rm_type)$/
- Xsend_message to.c /^send_message(me, you)$/
- Xstrnc0py various.c /^strnc0py(s1, s2, n)$/
- Xupdate_torc to.c /^update_torc(me)$/
- Xwho_am_I print.c /^who_am_I()$/
- Xwho_main main.c /^who_main(argc, argv)$/
- END_OF_FILE
- if test 1842 -ne `wc -c <'casu-3.3/tags'`; then
- echo shar: \"'casu-3.3/tags'\" unpacked with wrong size!
- fi
- # end of 'casu-3.3/tags'
- fi
- if test -f 'casu-3.3/various.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'casu-3.3/various.c'\"
- else
- echo shar: Extracting \"'casu-3.3/various.c'\" \(3719 characters\)
- sed "s/^X//" >'casu-3.3/various.c' <<'END_OF_FILE'
- X/*
- X * CaSU - communications & status utilities.
- X * Copyright (C) 1992, 1993 Luke Mewburn <lm@rmit.edu.au>
- X * incorporating:
- X * flon - lists your friends who are logged on.
- X * to - send a short message to a friend
- X *
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License as published by
- X * the Free Software Foundation; either version 2 of the License, or
- X * (at your option) any later version.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X *
- X */
- X
- X#include "casu.h"
- X
- X/*
- X * errmesg
- X * print a message to stderr, in a consistant format.
- X * output is of the form:
- X * progname: 'm2' - m1.\n # m2 is ! NULL
- X * progname: m1.\n # m2 is NULL
- X */
- Xvoid
- Xerrmesg(m1, m2)
- X char *m1, *m2;
- X{
- X fprintf(stderr, "%s: ", progname);
- X if (m2)
- X fprintf(stderr, "'%s' - ", m2);
- X fprintf(stderr, "%s.\n", m1);
- X} /* errmesg */
- X
- X
- X/*
- X * errexit
- X *
- X * use errmesg to print a message and exit the program.
- X */
- Xvoid
- Xerrexit(m1, m2)
- X char *m1, *m2;
- X{
- X errmesg(m1, m2);
- X exit(1);
- X} /* errexit */
- X
- X
- X/*
- X * strnc0py
- X *
- X * as strncpy, but always put in the \0 (assume array is siz+1 long)
- X */
- Xchar *
- Xstrnc0py(s1, s2, n)
- X char *s1, *s2;
- X size_t n;
- X{
- X s1[n] = '\0';
- X return strncpy(s1, s2, n);
- X} /* strnc0py */
- X
- X
- X/*
- X * get_username
- X *
- X * find out the username of the user...
- X */
- Xchar *
- Xget_username()
- X{
- X struct passwd *pwbufr;
- X char *myname;
- X int my_uid;
- X static char namebuf[UT_NAMESIZE+1];
- X
- X myname=getlogin();
- X if (myname == NULL) /* attempt to get name another way */
- X {
- X my_uid = (int) getuid();
- X if (pw_list != NULL)
- X {
- X int lp;
- X for (lp = 0; lp < pw_count; lp++)
- X if (pw_list[lp].uid == my_uid)
- X break;
- X if (lp != pw_count)
- X myname = pw_list[lp].username;
- X }
- X else /* don't use inbuilt passwd file - USE_GETPWENT does this too */
- X {
- X if ((pwbufr = getpwuid(my_uid)) != NULL)
- X myname = pwbufr->pw_name;
- X }
- X }
- X if (myname == NULL)
- X myname = "";
- X strnc0py(namebuf, myname, UT_NAMESIZE);
- X return (namebuf);
- X} /* get_username */
- X
- X
- X/*
- X * convert_realname
- X *
- X * converts the GCOS field at tfb to a full name, replacing
- X * occurances of `&' with name. If uid matches the last request,
- X * it will return the last converted entry (cache!). It returns
- X * a pointer to an internal static buffer
- X */
- Xchar *
- Xconvert_realname(tfb, name, uid)
- X char *tfb, *name;
- X int uid;
- X{
- X static char realnam[BUFSIZ + 1];
- X static int last_uid = -1;
- X
- X char *namep, *final;
- X int len, namelen;
- X
- X if (last_uid == uid)
- X return realnam;
- X final = strchr(tfb, ',');
- X if (final != NULL)
- X *final = '\0';
- X if (strchr(tfb, '&') == NULL)
- X return tfb;
- X final = tfb;
- X namelen = strlen(name) - 1;
- X for (namep=tfb, len=1; *namep && len < BUFSIZ ; namep++, len++)
- X {
- X if (*namep=='&')
- X {
- X if (len + namelen >= BUFSIZ)
- X break; /* safety net for copy below */
- X len += namelen;
- X }
- X }
- X final = namep;
- X for (namep=tfb, len=0; namep < final ; namep++, len++)
- X {
- X if (*namep=='&')
- X {
- X strcpy(&realnam[len], name);
- X if (islower(realnam[len]))
- X realnam[len] = toupper(realnam[len]);
- X len += namelen;
- X }
- X else
- X realnam[len] = *namep;
- X }
- X realnam[len]='\0';
- X last_uid = uid;
- X return realnam;
- X} /* convert_realname */
- END_OF_FILE
- if test 3719 -ne `wc -c <'casu-3.3/various.c'`; then
- echo shar: \"'casu-3.3/various.c'\" unpacked with wrong size!
- fi
- # end of 'casu-3.3/various.c'
- fi
- echo shar: End of archive 4 \(of 4\).
- cp /dev/null ark4isdone
- MISSING=""
- for I in 1 2 3 4 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 4 archives.
- rm -f ark[1-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
-