home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume41 / casu / part04 < prev    next >
Encoding:
Text File  |  1994-01-09  |  42.2 KB  |  1,336 lines

  1. Newsgroups: comp.sources.misc
  2. From: lm@rmit.edu.au (Luke Mewburn)
  3. Subject: v41i079:  casu - comms. & status utils, v3.3, Part04/04
  4. Message-ID: <1994Jan10.025706.4171@sparky.sterling.com>
  5. X-Md4-Signature: bafe48d7982ee05f591c12909d9f5741
  6. Sender: kent@sparky.sterling.com (Kent Landfield)
  7. Organization: Sterling Software
  8. Date: Mon, 10 Jan 1994 02:57:06 GMT
  9. Approved: kent@sparky.sterling.com
  10.  
  11. Submitted-by: lm@rmit.edu.au (Luke Mewburn)
  12. Posting-number: Volume 41, Issue 79
  13. Archive-name: casu/part04
  14. Environment: UNIX, ANSI-C
  15.  
  16. #! /bin/sh
  17. # This is a shell archive.  Remove anything before this line, then feed it
  18. # into a shell via "sh file" or similar.  To overwrite existing files,
  19. # type "sh file -c".
  20. # Contents:  casu-3.3/INSTALL casu-3.3/NEWS casu-3.3/README
  21. #   casu-3.3/__TODO__ casu-3.3/bsearch.c casu-3.3/configure.in
  22. #   casu-3.3/eg.friends casu-3.3/eg.torc casu-3.3/getutent.c
  23. #   casu-3.3/main.c casu-3.3/qsort.c casu-3.3/tags casu-3.3/various.c
  24. # Wrapped by kent@sparky on Sun Jan  9 20:46:39 1994
  25. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
  26. echo If this archive is complete, you will see the following message:
  27. echo '          "shar: End of archive 4 (of 4)."'
  28. if test -f 'casu-3.3/INSTALL' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'casu-3.3/INSTALL'\"
  30. else
  31.   echo shar: Extracting \"'casu-3.3/INSTALL'\" \(5776 characters\)
  32.   sed "s/^X//" >'casu-3.3/INSTALL' <<'END_OF_FILE'
  33. XThis is a generic INSTALL file for utilities distributions.
  34. XIf this package does not come with, e.g., installable documentation or
  35. Xdata files, please ignore the references to them below.
  36. X
  37. XTo compile this package:
  38. X
  39. X1.  Configure the package for your system.  In the directory that this
  40. Xfile is in, type `./configure'.  If you're using `csh' on an old
  41. Xversion of System V, you might need to type `sh configure' instead to
  42. Xprevent `csh' from trying to execute `configure' itself.
  43. X
  44. XThe `configure' shell script attempts to guess correct values for
  45. Xvarious system-dependent variables used during compilation, and
  46. Xcreates the Makefile(s) (one in each subdirectory of the source
  47. Xdirectory).  In some packages it creates a C header file containing
  48. Xsystem-dependent definitions.  It also creates a file `config.status'
  49. Xthat you can run in the future to recreate the current configuration.
  50. X
  51. XRunning `configure' takes a minute or two.  While it is running, it
  52. Xprints some messages that tell what it is doing.  If you don't want to
  53. Xsee the messages, run `configure' with its standard output redirected
  54. Xto `/dev/null'; for example, `./configure >/dev/null'.
  55. X
  56. XTo compile the package in a different directory from the one
  57. Xcontaining the source code, you must use a version of `make' that
  58. Xsupports the VPATH variable, such as GNU `make'.  `cd' to the directory
  59. Xwhere you want the object files and executables to go and run
  60. X`configure'.  `configure' automatically checks for the source code in
  61. Xthe directory that `configure' is in and in `..'.  If for some reason
  62. X`configure' is not in the source code directory that you are
  63. Xconfiguring, then it will report that it can't find the source code.
  64. XIn that case, run `configure' with the option `--srcdir=DIR', where
  65. XDIR is the directory that contains the source code.
  66. X
  67. XBy default, `make install' will install the package's files in
  68. X/usr/local/bin, /usr/local/lib, /usr/local/man, etc.  You can specify an
  69. Xinstallation prefix other than /usr/local by giving `configure' the option
  70. X`--prefix=PATH'.  Alternately, you can do so by consistently giving a value
  71. Xfor the `prefix' variable when you run `make', e.g.,
  72. X    make prefix=/usr/gnu
  73. X    make prefix=/usr/gnu install
  74. X
  75. XYou can specify separate installation prefixes for
  76. Xarchitecture-specific files and architecture-independent files.  If
  77. Xyou give `configure' the option `--exec-prefix=PATH' or set the
  78. X`make' variable `exec_prefix' to PATH, the package will use PATH as
  79. Xthe prefix for installing programs and libraries.  Data files and
  80. Xdocumentation will still use the regular prefix.  Normally, all files
  81. Xare installed using the regular prefix.
  82. X
  83. XAnother `configure' option is useful mainly in `Makefile' rules for
  84. Xupdating `config.status' and `Makefile'.  The `--no-create' option
  85. Xfigures out the configuration for your system and records it in
  86. X`config.status', without actually configuring the package (creating
  87. X`Makefile's and perhaps a configuration header file).  Later, you can
  88. Xrun `./config.status' to actually configure the package.  You can also
  89. Xgive `config.status' the `--recheck' option, which makes it re-run
  90. X`configure' with the same arguments you used before.  This option is
  91. Xuseful if you change `configure'.
  92. X
  93. XSome packages pay attention to `--with-PACKAGE' options to `configure',
  94. Xwhere PACKAGE is something like `gnu-libc' or `x' (for the X Window System).
  95. XThe README should mention any --with- options that the package recognizes.
  96. X
  97. X`configure' ignores any other arguments that you give it.
  98. X
  99. XIf your system requires unusual options for compilation or linking
  100. Xthat `configure' doesn't know about, you can give `configure' initial
  101. Xvalues for some variables by setting them in the environment.  In
  102. XBourne-compatible shells, you can do that on the command line like
  103. Xthis:
  104. X    CC='gcc -traditional' DEFS=-D_POSIX_SOURCE ./configure
  105. X
  106. XThe `make' variables that you might want to override with environment
  107. Xvariables when running `configure' are:
  108. X
  109. X(For these variables, any value given in the environment overrides the
  110. Xvalue that `configure' would choose:)
  111. XCC        C compiler program.
  112. X        Default is `cc', or `gcc' if `gcc' is in your PATH.
  113. XINSTALL        Program to use to install files.
  114. X        Default is `install' if you have it, `cp' otherwise.
  115. X
  116. X(For these variables, any value given in the environment is added to
  117. Xthe value that `configure' chooses:)
  118. XDEFS        Configuration options, in the form `-Dfoo -Dbar ...'
  119. X        Do not use this variable in packages that create a
  120. X        configuration header file.
  121. XLIBS        Libraries to link with, in the form `-lfoo -lbar ...'
  122. X
  123. XIf you need to do unusual things to compile the package, we encourage
  124. Xyou to figure out how `configure' could check whether to do them, and
  125. Xmail diffs or instructions to the address given in the README so we
  126. Xcan include them in the next release.
  127. X
  128. X2.  Type `make' to compile the package.  If you want, you can override
  129. Xthe `make' variables CFLAGS and LDFLAGS like this:
  130. X
  131. X    make CFLAGS=-O2 LDFLAGS=-s
  132. X
  133. X3.  If the package comes with self-tests and you want to run them,
  134. Xtype `make check'.  If you're not sure whether there are any, try it;
  135. Xif `make' responds with something like
  136. X    make: *** No way to make target `check'.  Stop.
  137. Xthen the package does not come with self-tests.
  138. X
  139. X4.  Type `make install' to install programs, data files, and
  140. Xdocumentation.
  141. X
  142. X5.  You can remove the program binaries and object files from the
  143. Xsource directory by typing `make clean'.  To also remove the
  144. XMakefile(s), the header file containing system-dependent definitions
  145. X(if the package uses one), and `config.status' (all the files that
  146. X`configure' created), type `make distclean'.
  147. X
  148. XThe file `configure.in' is used as a template to create `configure' by
  149. Xa program called `autoconf'.  You will only need it if you want to
  150. Xregenerate `configure' using a newer version of `autoconf'.
  151. END_OF_FILE
  152.   if test 5776 -ne `wc -c <'casu-3.3/INSTALL'`; then
  153.     echo shar: \"'casu-3.3/INSTALL'\" unpacked with wrong size!
  154.   fi
  155.   # end of 'casu-3.3/INSTALL'
  156. fi
  157. if test -f 'casu-3.3/NEWS' -a "${1}" != "-c" ; then 
  158.   echo shar: Will not clobber existing file \"'casu-3.3/NEWS'\"
  159. else
  160.   echo shar: Extracting \"'casu-3.3/NEWS'\" \(1506 characters\)
  161.   sed "s/^X//" >'casu-3.3/NEWS' <<'END_OF_FILE'
  162. XUser visible changes in CaSU.
  163. X
  164. XCurrent version: 3.3.1
  165. XSee the file ChangeLog for details of all changes.
  166. X
  167. XMajor changes from 3.3 to 3.3.1:
  168. X* improved installation instructions and manual page installation
  169. X
  170. XMajor changes from 3.2.2 to 3.3:
  171. X* flon: support for machines that run YP/NIS and use a different
  172. X  getpwent() added.
  173. X* flon: added %b (hostname in brackets) to output format
  174. X* to: new .torc files will always have the user's group.
  175. X* flon: ``you're not technically logged on'' reworded.
  176. X
  177. XMajor changes from 3.2.1 to 3.2.2:
  178. X* to: all user `configurable' values for messages & autoreplies,
  179. X  such as the name, message, and autoreplies, are filtered for
  180. X  `illegal' characters (which are replaced with `?' as decribed below.)
  181. X* to: added the concept of a `dot tty'. So, `to .' remembers which tty
  182. X  you sent a message to.
  183. X* to: added `-E user', which removes an exclude entry.
  184. X* to: ignore excess `exclude user' entries.
  185. X* fixed up man pages for the Solaris 2 man program's autoformatter
  186. X
  187. XMajor changes from 3.2 to 3.2.1
  188. X* to: interactively read in message if non specified on the command line.
  189. X* to: sane limits on message size, and changing of all non-ASCII
  190. X  (including control codes) to `?'.
  191. X* to: addition of an `exclude' class, and an appropriate auto-reply to
  192. X  prevent certain users from contacting you.
  193. X* flon: setting of default %h width back to 16.
  194. X* flon: When run as who, use a variant width to print the host field
  195. X  (to prevent an unnecessary padding of spaces on the right hand margin.)
  196. END_OF_FILE
  197.   if test 1506 -ne `wc -c <'casu-3.3/NEWS'`; then
  198.     echo shar: \"'casu-3.3/NEWS'\" unpacked with wrong size!
  199.   fi
  200.   # end of 'casu-3.3/NEWS'
  201. fi
  202. if test -f 'casu-3.3/README' -a "${1}" != "-c" ; then 
  203.   echo shar: Will not clobber existing file \"'casu-3.3/README'\"
  204. else
  205.   echo shar: Extracting \"'casu-3.3/README'\" \(2542 characters\)
  206.   sed "s/^X//" >'casu-3.3/README' <<'END_OF_FILE'
  207. XCaSU -- communications & status utilities.
  208. X
  209. X
  210. XIntro:
  211. X------
  212. X
  213. XCaSU is a collection of programs for communicating with, and showing
  214. Xthe status of, other users (especially your friends). The package
  215. Xcurrently consists of:
  216. X    flon --    lists your friends who are logged on
  217. X    to --    sends a short message to another user
  218. X
  219. X
  220. X_flon_ uses the `$HOME/.friends' file to instruct it on which users to
  221. Xselectively display.  The file eg.friends contains sample information.
  222. XThe $FLON environment variable is also used by _flon_.  Refer to the
  223. Xmanual (source form is `FLON.rof') for more details.
  224. X
  225. X_to_ uses the `$HOME/.torc' file to store various parameters.  The
  226. Xvarious settings in this text file can either be directly edited,
  227. Xor set via command line options.  The eg.torc file contains a sample. 
  228. XRefer to the manual (source form is `TO.rof') for more details.
  229. X
  230. X
  231. XQuick Installation Notes:
  232. X-------------------------
  233. XFrom your favourite shell, run:
  234. X    sh ./configure
  235. X    make
  236. X    make install
  237. X    make install.man
  238. X
  239. X
  240. XSome people may wish to install the manual pages formatted. If this
  241. Xis the case, type:
  242. X    make install.catman
  243. X
  244. XBy default, _flon_ will install a hardlink to itself with the name of
  245. X`who' (to use _flon_ as who). If you don't want this behaviour, modify
  246. Xthe Makefile and clear the `who_prog =' variable.
  247. X
  248. X_to_ may need to be installed by the system administrator if your system
  249. Xlimits who can access a user's tty. During configuration, if a message
  250. Xsuch as:
  251. X    checking mesg y permissions
  252. X    - `to' is setgid to group 5
  253. Xappears, then this is the case.
  254. X
  255. X
  256. XCaSU 3.3.1 has successfully been ported (in that the author has personally
  257. Xtested the auto-configured scripts) to the following architectures:
  258. X    A/UX 3.0, NetBSD 0.0, Solaris 2, SunOS 4.1.3, Umax 2.4
  259. XFlon and To (at various stages of their development) have also been
  260. Xported to the following architectures: (and theoretically should still
  261. Xwork without problems)
  262. X    386BSD 0.1, AIX, Dynix, Irix 4, Linux, SCO Unix, SVR4 (non-Solaris)
  263. X
  264. X
  265. XFuture enhancements:
  266. X--------------------
  267. X- addition of a calendar program
  268. X- enhance package to become the rcaid (remote communications and
  269. X  interactive diary) currently being designed by myself and
  270. X  Andrew Vanderstock, which contains the following subsystems:
  271. X    - remote to (``rto'')
  272. X    - remote flon (``rlon'')
  273. X    - remote calendar (``rcal'')
  274. X    - remote pin-board (``rpin'')
  275. X
  276. X
  277. XBug reports, fixes, suggestions, and enhancements would be gratefully
  278. Xaccepted by the author, who may be contacted via email at:
  279. X    <lm@rmit.edu.au>
  280. X
  281. XLuke Mewburn, 931223.
  282. END_OF_FILE
  283.   if test 2542 -ne `wc -c <'casu-3.3/README'`; then
  284.     echo shar: \"'casu-3.3/README'\" unpacked with wrong size!
  285.   fi
  286.   # end of 'casu-3.3/README'
  287. fi
  288. if test -f 'casu-3.3/__TODO__' -a "${1}" != "-c" ; then 
  289.   echo shar: Will not clobber existing file \"'casu-3.3/__TODO__'\"
  290. else
  291.   echo shar: Extracting \"'casu-3.3/__TODO__'\" \(134 characters\)
  292.   sed "s/^X//" >'casu-3.3/__TODO__' <<'END_OF_FILE'
  293. X- hunt and perform genocide upon the remaining bugs (there must be a few.)
  294. X
  295. X- ultrix barfs on chmod in sys/stat.h & getpwuid in pwd.h
  296. END_OF_FILE
  297.   if test 134 -ne `wc -c <'casu-3.3/__TODO__'`; then
  298.     echo shar: \"'casu-3.3/__TODO__'\" unpacked with wrong size!
  299.   fi
  300.   # end of 'casu-3.3/__TODO__'
  301. fi
  302. if test -f 'casu-3.3/bsearch.c' -a "${1}" != "-c" ; then 
  303.   echo shar: Will not clobber existing file \"'casu-3.3/bsearch.c'\"
  304. else
  305.   echo shar: Extracting \"'casu-3.3/bsearch.c'\" \(3415 characters\)
  306.   sed "s/^X//" >'casu-3.3/bsearch.c' <<'END_OF_FILE'
  307. X/*
  308. X * Copyright (c) 1990 Regents of the University of California.
  309. X * All rights reserved.
  310. X *
  311. X * Redistribution and use in source and binary forms, with or without
  312. X * modification, are permitted provided that the following conditions
  313. X * are met:
  314. X * 1. Redistributions of source code must retain the above copyright
  315. X *    notice, this list of conditions and the following disclaimer.
  316. X * 2. Redistributions in binary form must reproduce the above copyright
  317. X *    notice, this list of conditions and the following disclaimer in the
  318. X *    documentation and/or other materials provided with the distribution.
  319. X * 3. All advertising materials mentioning features or use of this software
  320. X *    must display the following acknowledgement:
  321. X *    This product includes software developed by the University of
  322. X *    California, Berkeley and its contributors.
  323. X * 4. Neither the name of the University nor the names of its contributors
  324. X *    may be used to endorse or promote products derived from this software
  325. X *    without specific prior written permission.
  326. X *
  327. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  328. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  329. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  330. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  331. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  332. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  333. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  334. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  335. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  336. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  337. X * SUCH DAMAGE.
  338. X */
  339. X
  340. X#if defined(LIBC_SCCS) && !defined(lint)
  341. Xstatic char sccsid[] = "@(#)bsearch.c    5.4 (Berkeley) 2/23/91";
  342. X#endif /* LIBC_SCCS and not lint */
  343. X
  344. X#include "casu.h"        /* Luke Mewburn: 930608 */
  345. X#if 0
  346. X#include <stddef.h>        /* size_t */
  347. X#include <stdlib.h>
  348. X#endif
  349. X
  350. X
  351. X/*
  352. X * Perform a binary search.
  353. X *
  354. X * The code below is a bit sneaky.  After a comparison fails, we
  355. X * divide the work in half by moving either left or right. If lim
  356. X * is odd, moving left simply involves halving lim: e.g., when lim
  357. X * is 5 we look at item 2, so we change lim to 2 so that we will
  358. X * look at items 0 & 1.  If lim is even, the same applies.  If lim
  359. X * is odd, moving right again involes halving lim, this time moving
  360. X * the base up one item past p: e.g., when lim is 5 we change base
  361. X * to item 3 and make lim 2 so that we will look at items 3 and 4.
  362. X * If lim is even, however, we have to shrink it by one before
  363. X * halving: e.g., when lim is 4, we still looked at item 2, so we
  364. X * have to make lim 3, then halve, obtaining 1, so that we will only
  365. X * look at item 3.
  366. X */
  367. Xvoid *
  368. Xnbsearch(key, base0, nmemb, size, compar)
  369. X    register const void *key;
  370. X    const void *base0;
  371. X    size_t nmemb;
  372. X    register size_t size;
  373. X    register int (*compar) __PROT((const void *, const void *));
  374. X{
  375. X    register const char *base = base0;
  376. X    register int lim, cmp;
  377. X    register const void *p;
  378. X
  379. X    for (lim = nmemb; lim != 0; lim >>= 1) {
  380. X        p = base + (lim >> 1) * size;
  381. X        cmp = (*compar)(key, p);
  382. X        if (cmp == 0)
  383. X            return ((void *)p);
  384. X        if (cmp > 0) {    /* key > p: move right */
  385. X            base = (char *)p + size;
  386. X            lim--;
  387. X        } /* else move left */
  388. X    }
  389. X    return (NULL);
  390. X}
  391. END_OF_FILE
  392.   if test 3415 -ne `wc -c <'casu-3.3/bsearch.c'`; then
  393.     echo shar: \"'casu-3.3/bsearch.c'\" unpacked with wrong size!
  394.   fi
  395.   # end of 'casu-3.3/bsearch.c'
  396. fi
  397. if test -f 'casu-3.3/configure.in' -a "${1}" != "-c" ; then 
  398.   echo shar: Will not clobber existing file \"'casu-3.3/configure.in'\"
  399. else
  400.   echo shar: Extracting \"'casu-3.3/configure.in'\" \(3425 characters\)
  401.   sed "s/^X//" >'casu-3.3/configure.in' <<'END_OF_FILE'
  402. Xdnl
  403. Xdnl Process this file with autoconf to produce a configure script.
  404. Xdnl
  405. Xdnl Part of the CaSU package, v3.3.1
  406. Xdnl Written by Luke Mewburn <lm@rmit.edu.au>, 931223
  407. Xdnl
  408. Xdnl
  409. Xdnl
  410. Xdnl    Initialize & check for programs
  411. Xdnl
  412. XAC_INIT(casu.h)
  413. XPROGS="flon to"
  414. XAC_SUBST(PROGS)dnl
  415. XAC_PROG_CC
  416. XAC_PROG_CPP
  417. XAC_PROG_INSTALL
  418. XAC_LN_S
  419. XAC_PROGRAM_CHECK(ROFF, nroff, [nroff -man], cat)
  420. XAC_PROGRAM_CHECK(TBL, tbl, tbl,    cat)
  421. XAC_PROGRAM_CHECK(YPWHICH, ypwhich, ypwhich, false)
  422. X
  423. Xdnl
  424. Xdnl    Check for UNIX variants
  425. Xdnl
  426. XAC_AIX
  427. XAC_DYNIX_SEQ
  428. XAC_MINIX
  429. XAC_ISC_POSIX
  430. X
  431. Xdnl
  432. Xdnl    Check for typedefs & ANSI
  433. Xdnl
  434. XAC_STDC_HEADERS
  435. XAC_HAVE_HEADERS(stdlib.h,paths.h,unistd.h)
  436. XAC_UID_T
  437. XAC_MODE_T
  438. XAC_SIZE_T
  439. X
  440. Xdnl
  441. Xdnl    Compiler characteristics
  442. Xdnl
  443. XAC_CROSS_CHECK
  444. XAC_CONST
  445. X
  446. Xdnl
  447. Xdnl    Check for various UNIX services & variants
  448. Xdnl
  449. XAC_HEADER_CHECK(netdb.h,
  450. X    AC_HEADER_EGREP(MAXHOSTNAMELEN, netdb.h, AC_DEFINE(NEED_NETDB_H)))
  451. X
  452. Xecho "checking mesg y permissions"
  453. XAC_TEST_PROGRAM([
  454. X    #include <sys/types.h>
  455. X    #include <sys/stat.h>
  456. X    #include <stdio.h>
  457. X    main() {
  458. X    struct stat sb; char *x; int om, m; FILE *fp;
  459. X    if (!(x = ttyname(0))) exit(1);
  460. X    if (stat(x, &sb)) exit(1);
  461. X    om = sb.st_mode;
  462. X    if (chmod(x, om & ~077)) exit(1);
  463. X    m = system("mesg y");
  464. X    if (m == -1 || m == 127) exit(1);
  465. X    if (stat(x, &sb)) exit(1);
  466. X    m = sb.st_mode;
  467. X    if (chmod(x, om)) exit(1);
  468. X    if (!(m & 002)) {
  469. X        if (!(fp=fopen("conftest_grp", "w")))
  470. X        exit(1);
  471. X        fprintf(fp, "%d\n", sb.st_gid);
  472. X        fclose(fp);
  473. X    }
  474. X    exit(0);
  475. X    }
  476. X],[
  477. X    if test -f conftest_grp; then
  478. X    echo "- 'to' is setgid to group `cat conftest_grp`"
  479. X    AC_DEFINE(TTY_RESTRICTED)
  480. X    TO_GRP=`cat conftest_grp`
  481. X    else
  482. X    echo "- anyone can write to tty"
  483. X    fi
  484. X],
  485. X    echo "- can't determine - assume anyone can write to tty"
  486. X)
  487. XAC_SUBST(TO_GRP)dnl
  488. X    
  489. Xecho "checking for YP/NIS"
  490. Xif $YPWHICH >/dev/null 2>&1; then
  491. X    echo "- running YP, using system getpwent"
  492. X    usegetpw=1
  493. Xelse
  494. X    echo "checking for getpwent db caches"
  495. X    if test -f /etc/passwd.dir || test -f /etc/pwd.db; then
  496. X    echo "- they're there, using system getpwent"
  497. X    usegetpw=1
  498. X    else
  499. X    echo "- unavailable, using own getpwent"
  500. X    fi
  501. Xfi
  502. Xif test -n "$usegetpw"; then
  503. X    AC_DEFINE(USE_GETPWENT)
  504. Xfi
  505. X
  506. XAC_HEADER_CHECK(utmpx.h,
  507. X    AC_DEFINE(HAVE_UTMPX_H)
  508. X    AC_DEFINE(HAVE_UT_TYPE)
  509. X    AC_DEFINE(HAVE_UT_HOST)
  510. X,
  511. X    echo "checking for struct utmp.ut_type"
  512. X    AC_HEADER_EGREP(ut_type, utmp.h, AC_DEFINE(HAVE_UT_TYPE))
  513. X    echo "checking for struct umtp.ut_host"
  514. X    AC_HEADER_EGREP(ut_host, utmp.h, AC_DEFINE(HAVE_UT_HOST))
  515. X)
  516. X
  517. XAC_HAVE_LIBRARY(nsl, [LIBS="$LIBS -lnsl"])
  518. XAC_HAVE_LIBRARY(socket, [LIBS="$LIBS -lsocket"])
  519. XAC_HAVE_FUNCS(strerror)
  520. XAC_REPLACE_FUNCS(getutent)
  521. X
  522. Xecho "checking malloc declaration"
  523. XAC_PROGRAM_EGREP([malloc( |    |\()],[
  524. X#if HAVE_STDLIB_H
  525. X#   include <stdlib.h>
  526. X#endif
  527. X],AC_DEFINE(MALLOC_DECL))
  528. X
  529. Xecho "checking open declaration"
  530. XAC_PROGRAM_EGREP([open( |    |\()],[
  531. X#include <fcntl.h>
  532. X],AC_DEFINE(OPEN_DECL))
  533. X
  534. Xecho "checking read declaration"
  535. XAC_PROGRAM_EGREP([read( |    |\()],[
  536. X#if HAVE_UNISTD_H
  537. X#   include <unistd.h>
  538. X#endif
  539. X],AC_DEFINE(READ_DECL))
  540. X
  541. XAC_FUNC_CHECK(gethostname,[
  542. X    AC_DEFINE(HAVE_GETHOSTNAME)
  543. X    have_ghn=1
  544. X],[
  545. X    AC_HAVE_HEADERS(sys/utsname.h)
  546. X    AC_HAVE_FUNCS(uname)
  547. X])
  548. Xif test -n "$have_ghn"; then
  549. X    echo "checking gethostname declaration"
  550. X    AC_PROGRAM_EGREP([gethostname( |    |\()],[
  551. X    #include <sys/types.h>
  552. X    #if HAVE_UNISTD_H
  553. X    #   include <unistd.h>
  554. X    #endif
  555. X    ],AC_DEFINE(GETHOSTNAME_DECL))
  556. Xfi
  557. X
  558. XAC_OUTPUT(Makefile)
  559. END_OF_FILE
  560.   if test 3425 -ne `wc -c <'casu-3.3/configure.in'`; then
  561.     echo shar: \"'casu-3.3/configure.in'\" unpacked with wrong size!
  562.   fi
  563.   # end of 'casu-3.3/configure.in'
  564. fi
  565. if test -f 'casu-3.3/eg.friends' -a "${1}" != "-c" ; then 
  566.   echo shar: Will not clobber existing file \"'casu-3.3/eg.friends'\"
  567. else
  568.   echo shar: Extracting \"'casu-3.3/eg.friends'\" \(135 characters\)
  569.   sed "s/^X//" >'casu-3.3/eg.friends' <<'END_OF_FILE'
  570. Xrxkajv  OzFuzzy
  571. Xs902113    Zak, programmer of flon
  572. X
  573. Xzrmitcs RMIT computer society
  574. Xbob    Joe Bob Briggs
  575. X
  576. X
  577. Xroot    Da Boss
  578. Xnroot        Da boss again.
  579. END_OF_FILE
  580.   if test 135 -ne `wc -c <'casu-3.3/eg.friends'`; then
  581.     echo shar: \"'casu-3.3/eg.friends'\" unpacked with wrong size!
  582.   fi
  583.   # end of 'casu-3.3/eg.friends'
  584. fi
  585. if test -f 'casu-3.3/eg.torc' -a "${1}" != "-c" ; then 
  586.   echo shar: Will not clobber existing file \"'casu-3.3/eg.torc'\"
  587. else
  588.   echo shar: Extracting \"'casu-3.3/eg.torc'\" \(187 characters\)
  589.   sed "s/^X//" >'casu-3.3/eg.torc' <<'END_OF_FILE'
  590. X. lm
  591. X: ttyp0
  592. XP Zak
  593. XY You rang?
  594. XI I'm idle - beep me
  595. XN Can't you see I'm busy? Mail me...
  596. XG I'm not here at the moment, mail me at: lm@rmit.edu.au
  597. Xa cyric s902117
  598. Xa tau s861298
  599. Xa god root
  600. END_OF_FILE
  601.   if test 187 -ne `wc -c <'casu-3.3/eg.torc'`; then
  602.     echo shar: \"'casu-3.3/eg.torc'\" unpacked with wrong size!
  603.   fi
  604.   # end of 'casu-3.3/eg.torc'
  605. fi
  606. if test -f 'casu-3.3/getutent.c' -a "${1}" != "-c" ; then 
  607.   echo shar: Will not clobber existing file \"'casu-3.3/getutent.c'\"
  608. else
  609.   echo shar: Extracting \"'casu-3.3/getutent.c'\" \(1292 characters\)
  610.   sed "s/^X//" >'casu-3.3/getutent.c' <<'END_OF_FILE'
  611. X/*
  612. X *  CaSU - communications & status utilities.
  613. X *  Copyright (C) 1992, 1993 Luke Mewburn <lm@rmit.edu.au>
  614. X *    incorporating:
  615. X *       flon - lists your friends who are logged on.
  616. X *       to - send a short message to a friend
  617. X *
  618. X *  This program is free software; you can redistribute it and/or modify
  619. X *  it under the terms of the GNU General Public License as published by
  620. X *  the Free Software Foundation; either version 2 of the License, or
  621. X *  (at your option) any later version.
  622. X *  
  623. X *  This program is distributed in the hope that it will be useful,
  624. X *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  625. X *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  626. X *  GNU General Public License for more details.
  627. X *  
  628. X *  You should have received a copy of the GNU General Public License
  629. X *  along with this program; if not, write to the Free Software
  630. X *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  631. X *
  632. X */
  633. X
  634. X#include "casu.h"
  635. X
  636. Xstatic int    fd = -1;
  637. X
  638. X/*
  639. X * getutent -    support for boxes that need it
  640. X */
  641. Xutmp_s *
  642. Xgetutent()
  643. X{
  644. X    static utmp_s    buf;
  645. X
  646. X    if (fd == -1)
  647. X    {
  648. X    fd = open(PATH_UTMP, O_RDONLY, 0);
  649. X    if (fd == -1)
  650. X        return NULL;
  651. X    }
  652. X    if (read(fd, &buf, sizeof(buf)) <= 0)
  653. X    return NULL;
  654. X    return &buf;
  655. X}
  656. X
  657. Xvoid
  658. Xendutent()
  659. X{
  660. X    close(fd);
  661. X}
  662. END_OF_FILE
  663.   if test 1292 -ne `wc -c <'casu-3.3/getutent.c'`; then
  664.     echo shar: \"'casu-3.3/getutent.c'\" unpacked with wrong size!
  665.   fi
  666.   # end of 'casu-3.3/getutent.c'
  667. fi
  668. if test -f 'casu-3.3/main.c' -a "${1}" != "-c" ; then 
  669.   echo shar: Will not clobber existing file \"'casu-3.3/main.c'\"
  670. else
  671.   echo shar: Extracting \"'casu-3.3/main.c'\" \(2837 characters\)
  672.   sed "s/^X//" >'casu-3.3/main.c' <<'END_OF_FILE'
  673. X/*
  674. X *  CaSU - communications & status utilities.
  675. X *  Copyright (C) 1992, 1993 Luke Mewburn <lm@rmit.edu.au>
  676. X *    incorporating:
  677. X *       flon - lists your friends who are logged on.
  678. X *       to - send a short message to a friend
  679. X *
  680. X *  This program is free software; you can redistribute it and/or modify
  681. X *  it under the terms of the GNU General Public License as published by
  682. X *  the Free Software Foundation; either version 2 of the License, or
  683. X *  (at your option) any later version.
  684. X *  
  685. X *  This program is distributed in the hope that it will be useful,
  686. X *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  687. X *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  688. X *  GNU General Public License for more details.
  689. X *  
  690. X *  You should have received a copy of the GNU General Public License
  691. X *  along with this program; if not, write to the Free Software
  692. X *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  693. X *
  694. X */
  695. X
  696. X#define _MAIN_
  697. X#include "casu.h"
  698. X
  699. X#ifdef M_SYSV
  700. X    utmp_s    Kludge;
  701. X#endif /* for SCO */
  702. X
  703. X
  704. X/*
  705. X *    flon main
  706. X */
  707. X
  708. Xvoid
  709. Xflon_main(argc, argv)
  710. X    int argc;
  711. X    char *argv[];
  712. X{
  713. X    char    *ffile_path=NULL, *format_str=NULL;
  714. X    char    *yes_str=NULL, *no_str=NULL;
  715. X    int        origargc = argc;
  716. X
  717. X    add_envopt(&argc, &argv, STRflon);
  718. X    parse_options(origargc, argc, argv, &ffile_path, &format_str,
  719. X            &yes_str, &no_str);
  720. X    parse_format(format_str);
  721. X    get_utmp(1);            /* need it sorted/filtered */
  722. X    if (flags & NEED_FFILE)
  723. X        get_friends(ffile_path);
  724. X#if !USE_GETPWENT
  725. X    if ((flags & (NEED_PASSWD | BEST_NAME)) && (flags & ALL_ON))
  726. X    get_passwd(_PATH_PASSWD);
  727. X#endif /* !USE_GETPWENT */
  728. X    print_output(yes_str, no_str);
  729. X} /* flon_main */
  730. X
  731. X
  732. X/*
  733. X *    who main
  734. X */
  735. X
  736. Xvoid
  737. Xwho_main(argc, argv)
  738. X    int argc;
  739. X    char *argv[];
  740. X{
  741. X    if (argc > 2)
  742. X    {
  743. X    if (    (strcmp(argv[1], "am")) ||
  744. X        (argv[2][1] != '\0') ||
  745. X        ( (argv[2][0] != 'i') &&
  746. X          (argv[2][0] != 'I')) ||
  747. X        (argc > 3) )
  748. X    {
  749. X        fprintf(stderr, "Usage: %s [ file ]\n      %s am { i , I }\n",
  750. X            argv[0], argv[0]);
  751. X        exit(1);
  752. X    }
  753. X    get_utmp(1);            /* needed for who_am_I() - filter it */
  754. X    who_am_I();
  755. X    return;
  756. X    }
  757. X    if (argc == 2)
  758. X    utmp_file=argv[1];        /* emulate  who <file>  */
  759. X
  760. X    flags = NO_HEADER + NO_TAILER + ALL_ON;
  761. X                    /* no head or tail, & list all */
  762. X    get_utmp(0);            /* don't filter utmp file */
  763. X    parse_format(WHO_FORMAT);
  764. X
  765. X    print_output(" ", "*");
  766. X} /* who_main */
  767. X
  768. X
  769. X/*
  770. X *    main
  771. X */
  772. X
  773. Xint
  774. Xmain(argc, argv)
  775. X    int argc;
  776. X    char *argv[];
  777. X{
  778. X    char *p;
  779. X    if (argv[0] == NULL)
  780. X    exit(1);
  781. X
  782. X    min_idle = MINIDLE;
  783. X    max_idle = MAXIDLE;
  784. X    utmp_file = PATH_UTMP;
  785. X
  786. X    progname = argv[0];
  787. X    if ((p = strrchr(progname, '/')) != NULL)
  788. X    progname = ++p;
  789. X    if (strcmp(progname, WHO_PROG) == 0)
  790. X    who_main(argc, argv);
  791. X    else
  792. X    flon_main(argc, argv);
  793. X    exit(0);
  794. X    return 0;    /* shut the compiler up */
  795. X} /* main */
  796. END_OF_FILE
  797.   if test 2837 -ne `wc -c <'casu-3.3/main.c'`; then
  798.     echo shar: \"'casu-3.3/main.c'\" unpacked with wrong size!
  799.   fi
  800.   # end of 'casu-3.3/main.c'
  801. fi
  802. if test -f 'casu-3.3/qsort.c' -a "${1}" != "-c" ; then 
  803.   echo shar: Will not clobber existing file \"'casu-3.3/qsort.c'\"
  804. else
  805.   echo shar: Extracting \"'casu-3.3/qsort.c'\" \(8218 characters\)
  806.   sed "s/^X//" >'casu-3.3/qsort.c' <<'END_OF_FILE'
  807. X/*-
  808. X * Copyright (c) 1980, 1983, 1990 The Regents of the University of California.
  809. X * All rights reserved.
  810. X *
  811. X * Redistribution and use in source and binary forms, with or without
  812. X * modification, are permitted provided that the following conditions
  813. X * are met:
  814. X * 1. Redistributions of source code must retain the above copyright
  815. X *    notice, this list of conditions and the following disclaimer.
  816. X * 2. Redistributions in binary form must reproduce the above copyright
  817. X *    notice, this list of conditions and the following disclaimer in the
  818. X *    documentation and/or other materials provided with the distribution.
  819. X * 3. All advertising materials mentioning features or use of this software
  820. X *    must display the following acknowledgement:
  821. X *    This product includes software developed by the University of
  822. X *    California, Berkeley and its contributors.
  823. X * 4. Neither the name of the University nor the names of its contributors
  824. X *    may be used to endorse or promote products derived from this software
  825. X *    without specific prior written permission.
  826. X *
  827. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  828. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  829. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  830. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  831. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  832. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  833. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  834. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  835. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  836. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  837. X * SUCH DAMAGE.
  838. X */
  839. X
  840. X#if defined(LIBC_SCCS) && !defined(lint)
  841. Xstatic char sccsid[] = "@(#)qsort.c    5.9 (Berkeley) 2/23/91";
  842. X#endif /* LIBC_SCCS and not lint */
  843. X
  844. X#include "casu.h"        /* Luke, 930608 */
  845. X#if 0
  846. X#include <sys/types.h>
  847. X#include <stdlib.h>
  848. X#endif
  849. X
  850. Xstatic void insertion_sort    __PROT((char *bot, int nmemb, register int size,
  851. X                    int (*compar)()));
  852. Xstatic void quick_sort        __PROT((char *bot, int nmemb, register int size,
  853. X                    int (*compar)()));
  854. X
  855. X/*
  856. X * MTHRESH is the smallest partition for which we compare for a median
  857. X * value instead of using the middle value.
  858. X */
  859. X#define    MTHRESH    6
  860. X
  861. X/*
  862. X * THRESH is the minimum number of entries in a partition for continued
  863. X * partitioning.
  864. X */
  865. X#define    THRESH    4
  866. X
  867. Xvoid
  868. Xnqsort(bot, nmemb, size, compar)
  869. X    void *bot;
  870. X    size_t nmemb, size;
  871. X    int (*compar) __PROT((const void *, const void *));
  872. X{
  873. X    if (nmemb <= 1)
  874. X        return;
  875. X
  876. X    if (nmemb >= THRESH)
  877. X        quick_sort(bot, nmemb, size, compar);
  878. X    else
  879. X        insertion_sort(bot, nmemb, size, compar);
  880. X}
  881. X
  882. X/*
  883. X * Swap two areas of size number of bytes.  Although qsort(3) permits random
  884. X * blocks of memory to be sorted, sorting pointers is almost certainly the
  885. X * common case (and, were it not, could easily be made so).  Regardless, it
  886. X * isn't worth optimizing; the SWAP's get sped up by the cache, and pointer
  887. X * arithmetic gets lost in the time required for comparison function calls.
  888. X */
  889. X#define    SWAP(a, b) { \
  890. X    cnt = size; \
  891. X    do { \
  892. X        ch = *a; \
  893. X        *a++ = *b; \
  894. X        *b++ = ch; \
  895. X    } while (--cnt); \
  896. X}
  897. X
  898. X/*
  899. X * Knuth, Vol. 3, page 116, Algorithm Q, step b, argues that a single pass
  900. X * of straight insertion sort after partitioning is complete is better than
  901. X * sorting each small partition as it is created.  This isn't correct in this
  902. X * implementation because comparisons require at least one (and often two)
  903. X * function calls and are likely to be the dominating expense of the sort.
  904. X * Doing a final insertion sort does more comparisons than are necessary
  905. X * because it compares the "edges" and medians of the partitions which are
  906. X * known to be already sorted.
  907. X *
  908. X * This is also the reasoning behind selecting a small THRESH value (see
  909. X * Knuth, page 122, equation 26), since the quicksort algorithm does less
  910. X * comparisons than the insertion sort.
  911. X */
  912. X#define    SORT(bot, n) { \
  913. X    if (n > 1) \
  914. X        if (n == 2) { \
  915. X            t1 = bot + size; \
  916. X            if (compar(t1, bot) < 0) \
  917. X                SWAP(t1, bot); \
  918. X        } else \
  919. X            insertion_sort(bot, n, size, compar); \
  920. X}
  921. X
  922. Xstatic void
  923. Xquick_sort(bot, nmemb, size, compar)
  924. X    register char *bot;
  925. X    register int size;
  926. X    int nmemb, (*compar)();
  927. X{
  928. X    register int cnt;
  929. X    register unsigned char ch;
  930. X    register char *top, *mid, *t1, *t2;
  931. X    register int n1, n2;
  932. X    char *bsv;
  933. X
  934. X    /* bot and nmemb must already be set. */
  935. Xpartition:
  936. X
  937. X    /* find mid and top elements */
  938. X    mid = bot + size * (nmemb >> 1);
  939. X    top = bot + (nmemb - 1) * size;
  940. X
  941. X    /*
  942. X     * Find the median of the first, last and middle element (see Knuth,
  943. X     * Vol. 3, page 123, Eq. 28).  This test order gets the equalities
  944. X     * right.
  945. X     */
  946. X    if (nmemb >= MTHRESH) {
  947. X        n1 = compar(bot, mid);
  948. X        n2 = compar(mid, top);
  949. X        if (n1 < 0 && n2 > 0)
  950. X            t1 = compar(bot, top) < 0 ? top : bot;
  951. X        else if (n1 > 0 && n2 < 0)
  952. X            t1 = compar(bot, top) > 0 ? top : bot;
  953. X        else
  954. X            t1 = mid;
  955. X
  956. X        /* if mid element not selected, swap selection there */
  957. X        if (t1 != mid) {
  958. X            SWAP(t1, mid);
  959. X            mid -= size;
  960. X        }
  961. X    }
  962. X
  963. X    /* Standard quicksort, Knuth, Vol. 3, page 116, Algorithm Q. */
  964. X#define    didswap    n1
  965. X#define    newbot    t1
  966. X#define    replace    t2
  967. X    didswap = 0;
  968. X    for (bsv = bot;;) {
  969. X        for (; bot < mid && compar(bot, mid) <= 0; bot += size);
  970. X        while (top > mid) {
  971. X            if (compar(mid, top) <= 0) {
  972. X                top -= size;
  973. X                continue;
  974. X            }
  975. X            newbot = bot + size;    /* value of bot after swap */
  976. X            if (bot == mid)        /* top <-> mid, mid == top */
  977. X                replace = mid = top;
  978. X            else {            /* bot <-> top */
  979. X                replace = top;
  980. X                top -= size;
  981. X            }
  982. X            goto swap;
  983. X        }
  984. X        if (bot == mid)
  985. X            break;
  986. X
  987. X        /* bot <-> mid, mid == bot */
  988. X        replace = mid;
  989. X        newbot = mid = bot;        /* value of bot after swap */
  990. X        top -= size;
  991. X
  992. Xswap:        SWAP(bot, replace);
  993. X        bot = newbot;
  994. X        didswap = 1;
  995. X    }
  996. X
  997. X    /*
  998. X     * Quicksort behaves badly in the presence of data which is already
  999. X     * sorted (see Knuth, Vol. 3, page 119) going from O N lg N to O N^2.
  1000. X     * To avoid this worst case behavior, if a re-partitioning occurs
  1001. X     * without swapping any elements, it is not further partitioned and
  1002. X     * is insert sorted.  This wins big with almost sorted data sets and
  1003. X     * only loses if the data set is very strangely partitioned.  A fix
  1004. X     * for those data sets would be to return prematurely if the insertion
  1005. X     * sort routine is forced to make an excessive number of swaps, and
  1006. X     * continue the partitioning.
  1007. X     */
  1008. X    if (!didswap) {
  1009. X        insertion_sort(bsv, nmemb, size, compar);
  1010. X        return;
  1011. X    }
  1012. X
  1013. X    /*
  1014. X     * Re-partition or sort as necessary.  Note that the mid element
  1015. X     * itself is correctly positioned and can be ignored.
  1016. X     */
  1017. X#define    nlower    n1
  1018. X#define    nupper    n2
  1019. X    bot = bsv;
  1020. X    nlower = (mid - bot) / size;    /* size of lower partition */
  1021. X    mid += size;
  1022. X    nupper = nmemb - nlower - 1;    /* size of upper partition */
  1023. X
  1024. X    /*
  1025. X     * If must call recursively, do it on the smaller partition; this
  1026. X     * bounds the stack to lg N entries.
  1027. X     */
  1028. X    if (nlower > nupper) {
  1029. X        if (nupper >= THRESH)
  1030. X            quick_sort(mid, nupper, size, compar);
  1031. X        else {
  1032. X            SORT(mid, nupper);
  1033. X            if (nlower < THRESH) {
  1034. X                SORT(bot, nlower);
  1035. X                return;
  1036. X            }
  1037. X        }
  1038. X        nmemb = nlower;
  1039. X    } else {
  1040. X        if (nlower >= THRESH)
  1041. X            quick_sort(bot, nlower, size, compar);
  1042. X        else {
  1043. X            SORT(bot, nlower);
  1044. X            if (nupper < THRESH) {
  1045. X                SORT(mid, nupper);
  1046. X                return;
  1047. X            }
  1048. X        }
  1049. X        bot = mid;
  1050. X        nmemb = nupper;
  1051. X    }
  1052. X    goto partition;
  1053. X    /* NOTREACHED */
  1054. X}
  1055. X
  1056. Xstatic void
  1057. Xinsertion_sort(bot, nmemb, size, compar)
  1058. X    char *bot;
  1059. X    register int size;
  1060. X    int nmemb, (*compar)();
  1061. X{
  1062. X    register int cnt;
  1063. X    register unsigned char ch;
  1064. X    register char *s1, *s2, *t1, *t2, *top;
  1065. X
  1066. X    /*
  1067. X     * A simple insertion sort (see Knuth, Vol. 3, page 81, Algorithm
  1068. X     * S).  Insertion sort has the same worst case as most simple sorts
  1069. X     * (O N^2).  It gets used here because it is (O N) in the case of
  1070. X     * sorted data.
  1071. X     */
  1072. X    top = bot + nmemb * size;
  1073. X    for (t1 = bot + size; t1 < top;) {
  1074. X        for (t2 = t1; (t2 -= size) >= bot && compar(t1, t2) < 0;);
  1075. X        if (t1 != (t2 += size)) {
  1076. X            /* Bubble bytes up through each element. */
  1077. X            for (cnt = size; cnt--; ++t1) {
  1078. X                ch = *t1;
  1079. X                for (s1 = s2 = t1; (s2 -= size) >= t2; s1 = s2)
  1080. X                    *s1 = *s2;
  1081. X                *s1 = ch;
  1082. X            }
  1083. X        } else
  1084. X            t1 += size;
  1085. X    }
  1086. X}
  1087. END_OF_FILE
  1088.   if test 8218 -ne `wc -c <'casu-3.3/qsort.c'`; then
  1089.     echo shar: \"'casu-3.3/qsort.c'\" unpacked with wrong size!
  1090.   fi
  1091.   # end of 'casu-3.3/qsort.c'
  1092. fi
  1093. if test -f 'casu-3.3/tags' -a "${1}" != "-c" ; then 
  1094.   echo shar: Will not clobber existing file \"'casu-3.3/tags'\"
  1095. else
  1096.   echo shar: Extracting \"'casu-3.3/tags'\" \(1842 characters\)
  1097.   sed "s/^X//" >'casu-3.3/tags' <<'END_OF_FILE'
  1098. XMmain    main.c    /^main(argc, argv)$/
  1099. XMto    to.c    /^main(margc, margv)$/
  1100. XSORT    qsort.c    /^#define    SORT(bot, n) { \\$/
  1101. XSWAP    qsort.c    /^#define    SWAP(a, b) { \\$/
  1102. Xadd_alist_ent    to.c    /^add_alist_ent(alias, userid, them)$/
  1103. Xadd_envopt    init.c    /^void add_envopt(argcp, argvp, name)$/
  1104. Xcompare_friends    fileio.c    /^compare_friends(entry1, entry2)$/
  1105. Xcompare_users    fileio.c    /^compare_users(entry1, entry2)$/
  1106. Xcompare_utmp    fileio.c    /^compare_utmp(entry1, entry2)$/
  1107. Xconstruct_message    to.c    /^construct_message(me)$/
  1108. Xconvert_realname    various.c    /^convert_realname(tfb, name, uid)$/
  1109. Xdump_status    to.c    /^dump_status(me)$/
  1110. Xendutent    getutent.c    /^endutent()$/
  1111. Xerrexit    various.c    /^errexit(m1, m2)$/
  1112. Xerrmesg    various.c    /^errmesg(m1, m2)$/
  1113. Xfilter_buf    to.c    /^filter_buf(buf)$/
  1114. Xflon_main    main.c    /^flon_main(argc, argv)$/
  1115. Xget_friends    fileio.c    /^get_friends(frfile)$/
  1116. Xget_passwd    fileio.c    /^get_passwd(pwfile)$/
  1117. Xget_pwent    to.c    /^get_pwent(nam)$/
  1118. Xget_username    various.c    /^get_username()$/
  1119. Xget_utmp    fileio.c    /^get_utmp(sort_required)$/
  1120. Xgetutent    getutent.c    /^getutent()$/
  1121. Xinsertion_sort    qsort.c    /^insertion_sort(bot, nmemb, size, compar)$/
  1122. Xload_rcfile    to.c    /^load_rcfile(them, nam)$/
  1123. Xlookup_user    to.c    /^lookup_user(me, them)$/
  1124. Xnbsearch    bsearch.c    /^nbsearch(key, base0, nmemb, size, compar)$/
  1125. Xnqsort    qsort.c    /^nqsort(bot, nmemb, size, compar)$/
  1126. Xparse_format    init.c    /^parse_format(format)$/
  1127. Xparse_options    init.c    /^parse_options(origargc, myArgc, myArgv, frfile, fo/
  1128. Xprint_output    print.c    /^print_output(yes_str, no_str)$/
  1129. Xprocess_options    to.c    /^process_options(me, you)$/
  1130. Xquick_sort    qsort.c    /^quick_sort(bot, nmemb, size, compar)$/
  1131. Xremove_alist_ent    to.c    /^remove_alist_ent(user, them, rm_type)$/
  1132. Xsend_message    to.c    /^send_message(me, you)$/
  1133. Xstrnc0py    various.c    /^strnc0py(s1, s2, n)$/
  1134. Xupdate_torc    to.c    /^update_torc(me)$/
  1135. Xwho_am_I    print.c    /^who_am_I()$/
  1136. Xwho_main    main.c    /^who_main(argc, argv)$/
  1137. END_OF_FILE
  1138.   if test 1842 -ne `wc -c <'casu-3.3/tags'`; then
  1139.     echo shar: \"'casu-3.3/tags'\" unpacked with wrong size!
  1140.   fi
  1141.   # end of 'casu-3.3/tags'
  1142. fi
  1143. if test -f 'casu-3.3/various.c' -a "${1}" != "-c" ; then 
  1144.   echo shar: Will not clobber existing file \"'casu-3.3/various.c'\"
  1145. else
  1146.   echo shar: Extracting \"'casu-3.3/various.c'\" \(3719 characters\)
  1147.   sed "s/^X//" >'casu-3.3/various.c' <<'END_OF_FILE'
  1148. X/*
  1149. X *  CaSU - communications & status utilities.
  1150. X *  Copyright (C) 1992, 1993 Luke Mewburn <lm@rmit.edu.au>
  1151. X *    incorporating:
  1152. X *       flon - lists your friends who are logged on.
  1153. X *       to - send a short message to a friend
  1154. X *
  1155. X *  This program is free software; you can redistribute it and/or modify
  1156. X *  it under the terms of the GNU General Public License as published by
  1157. X *  the Free Software Foundation; either version 2 of the License, or
  1158. X *  (at your option) any later version.
  1159. X *  
  1160. X *  This program is distributed in the hope that it will be useful,
  1161. X *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  1162. X *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1163. X *  GNU General Public License for more details.
  1164. X *  
  1165. X *  You should have received a copy of the GNU General Public License
  1166. X *  along with this program; if not, write to the Free Software
  1167. X *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1168. X *
  1169. X */
  1170. X
  1171. X#include "casu.h"
  1172. X
  1173. X/*
  1174. X *     errmesg
  1175. X * print a message to stderr, in a consistant format.
  1176. X * output is of the form:
  1177. X *    progname: 'm2' - m1.\n        # m2 is ! NULL
  1178. X *    progname: m1.\n            # m2 is NULL
  1179. X */
  1180. Xvoid
  1181. Xerrmesg(m1, m2)
  1182. X    char *m1, *m2;
  1183. X{
  1184. X    fprintf(stderr, "%s: ", progname);
  1185. X    if (m2)
  1186. X    fprintf(stderr, "'%s' - ", m2);
  1187. X    fprintf(stderr, "%s.\n", m1);
  1188. X} /* errmesg */
  1189. X
  1190. X
  1191. X/*
  1192. X *     errexit
  1193. X *
  1194. X * use errmesg to print a message and exit the program.
  1195. X */
  1196. Xvoid
  1197. Xerrexit(m1, m2)
  1198. X    char *m1, *m2;
  1199. X{
  1200. X    errmesg(m1, m2);
  1201. X    exit(1);
  1202. X} /* errexit */
  1203. X
  1204. X
  1205. X/*
  1206. X *     strnc0py
  1207. X *
  1208. X * as strncpy, but always put in the \0 (assume array is siz+1 long)
  1209. X */
  1210. Xchar *
  1211. Xstrnc0py(s1, s2, n)
  1212. X    char *s1, *s2;
  1213. X    size_t n;
  1214. X{
  1215. X    s1[n] = '\0';
  1216. X    return strncpy(s1, s2, n);
  1217. X} /* strnc0py */
  1218. X
  1219. X
  1220. X/*
  1221. X *    get_username
  1222. X *
  1223. X * find out the username of the user...
  1224. X */
  1225. Xchar *
  1226. Xget_username()
  1227. X{
  1228. X    struct passwd    *pwbufr;
  1229. X    char        *myname;
  1230. X    int            my_uid;
  1231. X    static char        namebuf[UT_NAMESIZE+1];
  1232. X
  1233. X    myname=getlogin();
  1234. X    if (myname == NULL)        /* attempt to get name another way */
  1235. X    {
  1236. X    my_uid = (int) getuid();
  1237. X    if (pw_list != NULL)
  1238. X    {
  1239. X        int lp;
  1240. X        for (lp = 0; lp < pw_count; lp++)
  1241. X        if (pw_list[lp].uid == my_uid)
  1242. X            break;
  1243. X        if (lp != pw_count)
  1244. X        myname = pw_list[lp].username;
  1245. X    }
  1246. X    else    /* don't use inbuilt passwd file - USE_GETPWENT does this too */
  1247. X    {
  1248. X        if ((pwbufr = getpwuid(my_uid)) != NULL)
  1249. X        myname = pwbufr->pw_name;
  1250. X    }
  1251. X    }
  1252. X    if (myname == NULL)
  1253. X    myname = "";
  1254. X    strnc0py(namebuf, myname, UT_NAMESIZE);
  1255. X    return (namebuf);
  1256. X} /* get_username */
  1257. X
  1258. X
  1259. X/*
  1260. X *    convert_realname
  1261. X *
  1262. X * converts the GCOS field at tfb to a full name, replacing
  1263. X * occurances of `&' with name. If uid matches the last request,
  1264. X * it will return the last converted entry (cache!). It returns
  1265. X * a pointer to an internal static buffer
  1266. X */
  1267. Xchar *
  1268. Xconvert_realname(tfb, name, uid)
  1269. X    char *tfb, *name;
  1270. X    int  uid;
  1271. X{
  1272. X    static char    realnam[BUFSIZ + 1];
  1273. X    static int    last_uid = -1;
  1274. X
  1275. X    char    *namep, *final;
  1276. X    int        len, namelen;
  1277. X
  1278. X    if (last_uid == uid)
  1279. X    return realnam;
  1280. X    final = strchr(tfb, ',');
  1281. X    if (final != NULL)
  1282. X    *final = '\0';
  1283. X    if (strchr(tfb, '&') == NULL)
  1284. X    return tfb;
  1285. X    final = tfb;
  1286. X    namelen = strlen(name) - 1;
  1287. X    for (namep=tfb, len=1; *namep && len < BUFSIZ ; namep++, len++)
  1288. X    {
  1289. X    if (*namep=='&')
  1290. X    {
  1291. X        if (len + namelen >= BUFSIZ)
  1292. X        break;        /* safety net for copy below */
  1293. X        len += namelen;
  1294. X    }
  1295. X    }
  1296. X    final = namep;
  1297. X    for (namep=tfb, len=0; namep < final ; namep++, len++)
  1298. X    {
  1299. X    if (*namep=='&')
  1300. X    {
  1301. X        strcpy(&realnam[len], name);
  1302. X        if (islower(realnam[len]))
  1303. X        realnam[len] = toupper(realnam[len]);
  1304. X        len += namelen;
  1305. X    }
  1306. X    else
  1307. X        realnam[len] = *namep;
  1308. X    }
  1309. X    realnam[len]='\0';
  1310. X    last_uid = uid;
  1311. X    return realnam;
  1312. X} /* convert_realname */
  1313. END_OF_FILE
  1314.   if test 3719 -ne `wc -c <'casu-3.3/various.c'`; then
  1315.     echo shar: \"'casu-3.3/various.c'\" unpacked with wrong size!
  1316.   fi
  1317.   # end of 'casu-3.3/various.c'
  1318. fi
  1319. echo shar: End of archive 4 \(of 4\).
  1320. cp /dev/null ark4isdone
  1321. MISSING=""
  1322. for I in 1 2 3 4 ; do
  1323.     if test ! -f ark${I}isdone ; then
  1324.     MISSING="${MISSING} ${I}"
  1325.     fi
  1326. done
  1327. if test "${MISSING}" = "" ; then
  1328.     echo You have unpacked all 4 archives.
  1329.     rm -f ark[1-9]isdone
  1330. else
  1331.     echo You still must unpack the following archives:
  1332.     echo "        " ${MISSING}
  1333. fi
  1334. exit 0
  1335. exit 0 # Just in case...
  1336.