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

  1. Newsgroups: comp.sources.misc
  2. From: lm@rmit.edu.au (Luke Mewburn)
  3. Subject: v41i076:  casu - comms. & status utils, v3.3, Part01/04
  4. Message-ID: <csm-v41i076=casu.205241@sparky.Sterling.COM>
  5. X-Md4-Signature: 12cdd896e2596a898054f943de9a358f
  6. Sender: kent@sparky.sterling.com (Kent Landfield)
  7. Reply-To: Luke Mewburn <lm@rmit.edu.au>
  8. Organization: Sterling Software
  9. Date: Mon, 10 Jan 1994 02:52:58 GMT
  10. Approved: kent@sparky.sterling.com
  11.  
  12. Submitted-by: lm@rmit.edu.au (Luke Mewburn)
  13. Posting-number: Volume 41, Issue 76
  14. Archive-name: casu/part01
  15. Environment: UNIX, ANSI-C
  16.  
  17. CaSU -- communications & status utilities.
  18.  
  19. CaSU is a collection of programs for communicating with, and showing
  20. the status of, other users (especially your friends). The package
  21. currently consists of:
  22.     flon --    lists your friends who are logged on
  23.     to --    sends a short message to another user
  24.  
  25.  _flon_ uses the `$HOME/.friends' file to instruct it on which users to
  26. selectively display.  The file eg.friends contains sample information.
  27. The $FLON environment variable is also used by _flon_.  Refer to the
  28. manual (source form is `FLON.rof') for more details.
  29.  
  30.  _to_ uses the `$HOME/.torc' file to store various parameters.  The
  31. various settings in this text file can either be directly edited,
  32. or set via command line options.  The eg.torc file contains a sample. 
  33. Refer to the manual (source form is `TO.rof') for more details.
  34.  
  35. CaSU 3.3 has successfully been ported (in that the author has personally
  36. tested the auto-configured scripts) to the following architectures:
  37.     A/UX 3.0, NetBSD 0.8, Solaris 2, SunOS 4.1.3, Umax 2.4
  38. Flon and To (at various stages of their development) have also been
  39. ported to the following architectures: (and theoretically should still
  40. work without problems)
  41.     386BSD 0.1, AIX, Dynix, Irix 4, Linux, SCO Unix, SVR4 (non-Solaris)
  42.  
  43.  _to_ may need to be installed by the system administrator if your system
  44. limits who can access a user's tty. During configuration, if a message
  45. such as:
  46.     checking mesg y permissions
  47.     - `to' is setgid to group 5
  48. appears, then this is the case.
  49.  
  50. Some people may wish to install the manual pages unformatted. If this
  51. is the case, clear the `ROFF =' variable in the Makefile, and the
  52. Makefile will determine that you wish to install them unformatted.
  53. In this case, you may wish to change the manual destination directory
  54. and extensions to man1 and 1 respectively (from cat1 and 0 respectively.)
  55.  
  56. By default, _flon_ will install a hardlink to itself with the name of
  57. `who' (to use _flon_ as who). If you don't want this behaviour, modify
  58. the Makefile and clear the `who_prog =' variable.
  59.  
  60. Future enhancements currently being considered include:
  61.  - addition of a calendar program
  62.  - enhance package to become the rcaid (remote communications and
  63.   interactive diary) currently being designed by myself and
  64.   Andrew Vanderstock, which contains the following subsystems:
  65.     - remote to (``rto'')
  66.     - remote flon (``rlon'')
  67.     - remote calendar (``rcal'')
  68.     - remote pin-board (``rpin'')
  69.  
  70. Bug reports, fixes, suggestions, and enhancements would be gratefully
  71. accepted by the author, who may be contacted via email at:
  72.     <lm@rmit.edu.au>
  73.  
  74. Luke Mewburn
  75. ----
  76. #! /bin/sh
  77. # This is a shell archive.  Remove anything before this line, then feed it
  78. # into a shell via "sh file" or similar.  To overwrite existing files,
  79. # type "sh file -c".
  80. # Contents:  casu-3.3 casu-3.3/configure casu-3.3/to.c
  81. # Wrapped by kent@sparky on Sun Jan  9 20:46:38 1994
  82. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
  83. echo If this archive is complete, you will see the following message:
  84. echo '          "shar: End of archive 1 (of 4)."'
  85. if test ! -d 'casu-3.3' ; then
  86.     echo shar: Creating directory \"'casu-3.3'\"
  87.     mkdir 'casu-3.3'
  88. fi
  89. if test -f 'casu-3.3/configure' -a "${1}" != "-c" ; then 
  90.   echo shar: Will not clobber existing file \"'casu-3.3/configure'\"
  91. else
  92.   echo shar: Extracting \"'casu-3.3/configure'\" \(27563 characters\)
  93.   sed "s/^X//" >'casu-3.3/configure' <<'END_OF_FILE'
  94. X#!/bin/sh
  95. X# Guess values for system-dependent variables and create Makefiles.
  96. X# Generated automatically using autoconf.
  97. X# Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
  98. X
  99. X# This program is free software; you can redistribute it and/or modify
  100. X# it under the terms of the GNU General Public License as published by
  101. X# the Free Software Foundation; either version 2, or (at your option)
  102. X# any later version.
  103. X
  104. X# This program is distributed in the hope that it will be useful,
  105. X# but WITHOUT ANY WARRANTY; without even the implied warranty of
  106. X# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  107. X# GNU General Public License for more details.
  108. X
  109. X# You should have received a copy of the GNU General Public License
  110. X# along with this program; if not, write to the Free Software
  111. X# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  112. X
  113. X# Usage: configure [--srcdir=DIR] [--host=HOST] [--gas] [--nfp]
  114. X#        [--prefix=PREFIX] [--exec-prefix=PREFIX] [--with-PACKAGE[=VALUE]]
  115. X# Ignores all args except --srcdir, --prefix, --exec-prefix, and
  116. X# --with-PACKAGE[=VALUE] unless this script has special code to handle it.
  117. X
  118. Xfor arg
  119. Xdo
  120. X  # Handle --exec-prefix with a space before the argument.
  121. X  if test x$next_exec_prefix = xyes; then exec_prefix=$arg; next_exec_prefix=
  122. X  # Handle --host with a space before the argument.
  123. X  elif test x$next_host = xyes; then next_host=
  124. X  # Handle --prefix with a space before the argument.
  125. X  elif test x$next_prefix = xyes; then prefix=$arg; next_prefix=
  126. X  # Handle --srcdir with a space before the argument.
  127. X  elif test x$next_srcdir = xyes; then srcdir=$arg; next_srcdir=
  128. X  else
  129. X    case $arg in
  130. X     # For backward compatibility, recognize -exec-prefix and --exec_prefix.
  131. X     -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* | --exec=* | --exe=* | --ex=* | --e=*)
  132. X    exec_prefix=`echo $arg | sed 's/[-a-z_]*=//'` ;;
  133. X     -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- | --exec | --exe | --ex | --e)
  134. X    next_exec_prefix=yes ;;
  135. X
  136. X     -gas | --gas | --ga | --g) ;;
  137. X
  138. X     -host=* | --host=* | --hos=* | --ho=* | --h=*) ;;
  139. X     -host | --host | --hos | --ho | --h)
  140. X    next_host=yes ;;
  141. X
  142. X     -nfp | --nfp | --nf) ;;
  143. X
  144. X     -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
  145. X    prefix=`echo $arg | sed 's/[-a-z_]*=//'` ;;
  146. X     -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
  147. X    next_prefix=yes ;;
  148. X
  149. X     -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=* | --s=*)
  150. X    srcdir=`echo $arg | sed 's/[-a-z_]*=//'` ;;
  151. X     -srcdir | --srcdir | --srcdi | --srcd | --src | --sr | --s)
  152. X    next_srcdir=yes ;;
  153. X
  154. X     -with-* | --with-*)
  155. X       package=`echo $arg|sed -e 's/-*with-//' -e 's/=.*//'`
  156. X       # Reject names that aren't valid shell variable names.
  157. X       if test -n "`echo $package| sed 's/[-a-zA-Z0-9_]//g'`"; then
  158. X         echo "configure: $package: invalid package name" >&2; exit 1
  159. X       fi
  160. X       package=`echo $package| sed 's/-/_/g'`
  161. X       case "$arg" in
  162. X         *=*) val="`echo $arg|sed 's/[^=]*=//'`" ;;
  163. X         *) val=1 ;;
  164. X       esac
  165. X       eval "with_$package='$val'" ;;
  166. X
  167. X     -v | -verbose | --verbose | --verbos | --verbo | --verb | --ver | --ve | --v)
  168. X       verbose=yes ;;
  169. X
  170. X     *) ;;
  171. X    esac
  172. X  fi
  173. Xdone
  174. X
  175. Xtrap 'rm -fr conftest* confdefs* core; exit 1' 1 3 15
  176. Xtrap 'rm -f confdefs*' 0
  177. X
  178. X# NLS nuisances.
  179. X# These must not be set unconditionally because not all systems understand
  180. X# e.g. LANG=C (notably SCO).
  181. Xif test "${LC_ALL+set}" = 'set' ; then LC_ALL=C; export LC_ALL; fi
  182. Xif test "${LANG+set}"   = 'set' ; then LANG=C;   export LANG;   fi
  183. X
  184. Xrm -f conftest* confdefs.h
  185. X# AIX cpp loses on an empty file, so make sure it contains at least a newline.
  186. Xecho > confdefs.h
  187. Xcompile='${CC-cc} $CFLAGS conftest.c -o conftest $LIBS >/dev/null 2>&1'
  188. X
  189. X# A filename unique to this package, relative to the directory that
  190. X# configure is in, which we can look for to find out if srcdir is correct.
  191. Xunique_file=casu.h
  192. X
  193. X# Find the source files, if location was not specified.
  194. Xif test -z "$srcdir"; then
  195. X  srcdirdefaulted=yes
  196. X  # Try the directory containing this script, then `..'.
  197. X  prog=$0
  198. X  confdir=`echo $prog|sed 's%/[^/][^/]*$%%'`
  199. X  test "X$confdir" = "X$prog" && confdir=.
  200. X  srcdir=$confdir
  201. X  if test ! -r $srcdir/$unique_file; then
  202. X    srcdir=..
  203. X  fi
  204. Xfi
  205. Xif test ! -r $srcdir/$unique_file; then
  206. X  if test x$srcdirdefaulted = xyes; then
  207. X    echo "configure: Can not find sources in \`${confdir}' or \`..'." 1>&2
  208. X  else
  209. X    echo "configure: Can not find sources in \`${srcdir}'." 1>&2
  210. X  fi
  211. X  exit 1
  212. Xfi
  213. X# Preserve a srcdir of `.' to avoid automounter screwups with pwd.
  214. X# But we can't avoid them for `..', to make subdirectories work.
  215. Xcase $srcdir in
  216. X  .|/*|~*) ;;
  217. X  *) srcdir=`cd $srcdir; pwd` ;; # Make relative path absolute.
  218. Xesac
  219. X
  220. X
  221. X# Save the original args to write them into config.status later.
  222. Xconfigure_args="$*"
  223. X
  224. XPROGS="flon to"
  225. Xif test -z "$CC"; then
  226. X  # Extract the first word of `gcc', so it can be a program name with args.
  227. X  set dummy gcc; word=$2
  228. X  echo checking for $word
  229. X  IFS="${IFS=     }"; saveifs="$IFS"; IFS="${IFS}:"
  230. X  for dir in $PATH; do
  231. X    test -z "$dir" && dir=.
  232. X    if test -f $dir/$word; then
  233. X      CC="gcc"
  234. X      break
  235. X    fi
  236. X  done
  237. X  IFS="$saveifs"
  238. Xfi
  239. Xtest -z "$CC" && CC="cc"
  240. Xtest -n "$CC" && test -n "$verbose" && echo "    setting CC to $CC"
  241. X
  242. X# Find out if we are using GNU C, under whatever name.
  243. Xcat > conftest.c <<EOF
  244. X#ifdef __GNUC__
  245. X  yes
  246. X#endif
  247. XEOF
  248. X${CC-cc} -E conftest.c > conftest.out 2>&1
  249. Xif egrep yes conftest.out >/dev/null 2>&1; then
  250. X  GCC=1 # For later tests.
  251. Xfi
  252. Xrm -f conftest*
  253. X
  254. Xecho checking how to run the C preprocessor
  255. Xif test -z "$CPP"; then
  256. X  # This must be in double quotes, not single quotes, because CPP may get
  257. X  # substituted into the Makefile and ``${CC-cc}'' will simply confuse
  258. X  # make.  It must be expanded now.
  259. X  CPP="${CC-cc} -E"
  260. X  cat > conftest.c <<EOF
  261. X#include "confdefs.h"
  262. X#include <stdio.h>
  263. XSyntax Error
  264. XEOF
  265. Xerr=`eval "($CPP conftest.c >/dev/null) 2>&1"`
  266. Xif test -z "$err"; then
  267. X  :
  268. Xelse
  269. X  rm -rf conftest*
  270. X  CPP=/lib/cpp
  271. Xfi
  272. Xrm -f conftest*
  273. Xfi
  274. Xtest ".${verbose}" != "." && echo "    setting CPP to $CPP"
  275. X
  276. X# Make sure to not get the incompatible SysV /etc/install and
  277. X# /usr/sbin/install, which might be in PATH before a BSD-like install,
  278. X# or the SunOS /usr/etc/install directory, or the AIX /bin/install,
  279. X# or the AFS install, which mishandles nonexistent args, or
  280. X# /usr/ucb/install on SVR4, which tries to use the nonexistent group
  281. X# `staff'.  On most BSDish systems install is in /usr/bin, not /usr/ucb
  282. X# anyway.  Sigh.
  283. Xif test "z${INSTALL}" = "z" ; then
  284. X  echo checking for install
  285. X  IFS="${IFS=     }"; saveifs="$IFS"; IFS="${IFS}:"
  286. X  for dir in $PATH; do
  287. X    test -z "$dir" && dir=.
  288. X    case $dir in
  289. X    /etc|/usr/sbin|/usr/etc|/usr/afsws/bin|/usr/ucb) ;;
  290. X    *)
  291. X      if test -f $dir/installbsd; then
  292. X    INSTALL="$dir/installbsd -c" # OSF1
  293. X    INSTALL_PROGRAM='$(INSTALL)'
  294. X    INSTALL_DATA='$(INSTALL) -m 644'
  295. X    break
  296. X      fi
  297. X      if test -f $dir/install; then
  298. X    if grep dspmsg $dir/install >/dev/null 2>&1; then
  299. X      : # AIX
  300. X    else
  301. X      INSTALL="$dir/install -c"
  302. X      INSTALL_PROGRAM='$(INSTALL)'
  303. X      INSTALL_DATA='$(INSTALL) -m 644'
  304. X      break
  305. X    fi
  306. X      fi
  307. X      ;;
  308. X    esac
  309. X  done
  310. X  IFS="$saveifs"
  311. Xfi
  312. XINSTALL=${INSTALL-cp}
  313. Xtest -n "$verbose" && echo "    setting INSTALL to $INSTALL"
  314. XINSTALL_PROGRAM=${INSTALL_PROGRAM-'$(INSTALL)'}
  315. Xtest -n "$verbose" && echo "    setting INSTALL_PROGRAM to $INSTALL_PROGRAM"
  316. XINSTALL_DATA=${INSTALL_DATA-'$(INSTALL)'}
  317. Xtest -n "$verbose" && echo "    setting INSTALL_DATA to $INSTALL_DATA"
  318. X
  319. Xecho checking for ln -s
  320. Xrm -f conftestdata
  321. Xif ln -s X conftestdata 2>/dev/null
  322. Xthen
  323. X  rm -f conftestdata
  324. X  LN_S="ln -s"
  325. Xelse
  326. X  LN_S=ln
  327. Xfi
  328. X
  329. X
  330. Xif test -z "$ROFF"; then
  331. X  # Extract the first word of `nroff', so it can be a program name with args.
  332. X  set dummy nroff; word=$2
  333. X  echo checking for $word
  334. X  IFS="${IFS=     }"; saveifs="$IFS"; IFS="${IFS}:"
  335. X  for dir in $PATH; do
  336. X    test -z "$dir" && dir=.
  337. X    if test -f $dir/$word; then
  338. X      ROFF="nroff -man"
  339. X      break
  340. X    fi
  341. X  done
  342. X  IFS="$saveifs"
  343. Xfi
  344. Xtest -z "$ROFF" && ROFF="cat"
  345. Xtest -n "$ROFF" && test -n "$verbose" && echo "    setting ROFF to $ROFF"
  346. X
  347. Xif test -z "$TBL"; then
  348. X  # Extract the first word of `tbl', so it can be a program name with args.
  349. X  set dummy tbl; word=$2
  350. X  echo checking for $word
  351. X  IFS="${IFS=     }"; saveifs="$IFS"; IFS="${IFS}:"
  352. X  for dir in $PATH; do
  353. X    test -z "$dir" && dir=.
  354. X    if test -f $dir/$word; then
  355. X      TBL="tbl"
  356. X      break
  357. X    fi
  358. X  done
  359. X  IFS="$saveifs"
  360. Xfi
  361. Xtest -z "$TBL" && TBL="cat"
  362. Xtest -n "$TBL" && test -n "$verbose" && echo "    setting TBL to $TBL"
  363. X
  364. Xif test -z "$YPWHICH"; then
  365. X  # Extract the first word of `ypwhich', so it can be a program name with args.
  366. X  set dummy ypwhich; word=$2
  367. X  echo checking for $word
  368. X  IFS="${IFS=     }"; saveifs="$IFS"; IFS="${IFS}:"
  369. X  for dir in $PATH; do
  370. X    test -z "$dir" && dir=.
  371. X    if test -f $dir/$word; then
  372. X      YPWHICH="ypwhich"
  373. X      break
  374. X    fi
  375. X  done
  376. X  IFS="$saveifs"
  377. Xfi
  378. Xtest -z "$YPWHICH" && YPWHICH="false"
  379. Xtest -n "$YPWHICH" && test -n "$verbose" && echo "    setting YPWHICH to $YPWHICH"
  380. X
  381. X
  382. Xecho checking for AIX
  383. Xcat > conftest.c <<EOF
  384. X#include "confdefs.h"
  385. X#ifdef _AIX
  386. X  yes
  387. X#endif
  388. X
  389. XEOF
  390. Xeval "$CPP conftest.c > conftest.out 2>&1"
  391. Xif egrep "yes" conftest.out >/dev/null 2>&1; then
  392. X  rm -rf conftest*
  393. X  
  394. X{
  395. Xtest -n "$verbose" && \
  396. Xecho "    defining _ALL_SOURCE"
  397. Xecho "#define" _ALL_SOURCE 1 >> confdefs.h
  398. XDEFS="$DEFS -D_ALL_SOURCE=1"
  399. X}
  400. X
  401. X
  402. Xfi
  403. Xrm -f conftest*
  404. X
  405. X
  406. XLIBS_save="${LIBS}"
  407. XLIBS="${LIBS} -lseq"
  408. Xhave_lib=""
  409. Xecho checking for -lseq
  410. Xcat > conftest.c <<EOF
  411. X#include "confdefs.h"
  412. X
  413. Xint main() { exit(0); }
  414. Xint t() { main(); }
  415. XEOF
  416. Xif eval $compile; then
  417. X  rm -rf conftest*
  418. X  have_lib="1"
  419. X
  420. Xfi
  421. Xrm -f conftest*
  422. XLIBS="${LIBS_save}"
  423. Xif test -n "${have_lib}"; then
  424. X   :; LIBS="$LIBS -lseq"
  425. Xelse
  426. X   :; 
  427. Xfi
  428. X
  429. X
  430. Xecho checking for minix/config.h
  431. Xcat > conftest.c <<EOF
  432. X#include "confdefs.h"
  433. X#include <minix/config.h>
  434. XEOF
  435. Xerr=`eval "($CPP conftest.c >/dev/null) 2>&1"`
  436. Xif test -z "$err"; then
  437. X  rm -rf conftest*
  438. X  MINIX=1
  439. X
  440. Xfi
  441. Xrm -f conftest*
  442. X
  443. X# The Minix shell can't assign to the same variable on the same line!
  444. Xif test -n "$MINIX"; then
  445. X  
  446. X{
  447. Xtest -n "$verbose" && \
  448. Xecho "    defining _POSIX_SOURCE"
  449. Xecho "#define" _POSIX_SOURCE 1 >> confdefs.h
  450. XDEFS="$DEFS -D_POSIX_SOURCE=1"
  451. X}
  452. X
  453. X  
  454. X{
  455. Xtest -n "$verbose" && \
  456. Xecho "    defining" _POSIX_1_SOURCE to be 2
  457. Xecho "#define" _POSIX_1_SOURCE 2 >> confdefs.h
  458. XDEFS="$DEFS -D_POSIX_1_SOURCE=2"
  459. X}
  460. X
  461. X  
  462. X{
  463. Xtest -n "$verbose" && \
  464. Xecho "    defining _MINIX"
  465. Xecho "#define" _MINIX 1 >> confdefs.h
  466. XDEFS="$DEFS -D_MINIX=1"
  467. X}
  468. X
  469. Xfi
  470. X
  471. Xecho checking for POSIXized ISC
  472. Xif test -d /etc/conf/kconfig.d &&
  473. X  grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1
  474. Xthen
  475. X  ISC=1 # If later tests want to check for ISC.
  476. X  
  477. X{
  478. Xtest -n "$verbose" && \
  479. Xecho "    defining _POSIX_SOURCE"
  480. Xecho "#define" _POSIX_SOURCE 1 >> confdefs.h
  481. XDEFS="$DEFS -D_POSIX_SOURCE=1"
  482. X}
  483. X
  484. X  if test -n "$GCC"; then
  485. X    CC="$CC -posix"
  486. X  else
  487. X    CC="$CC -Xp"
  488. X  fi
  489. Xfi
  490. X
  491. X
  492. Xecho checking for ANSI C header files
  493. Xcat > conftest.c <<EOF
  494. X#include "confdefs.h"
  495. X#include <stdlib.h>
  496. X#include <stdarg.h>
  497. X#include <string.h>
  498. X#include <float.h>
  499. XEOF
  500. Xerr=`eval "($CPP conftest.c >/dev/null) 2>&1"`
  501. Xif test -z "$err"; then
  502. X  rm -rf conftest*
  503. X  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
  504. Xecho '#include "confdefs.h"
  505. X#include <string.h>' > conftest.c
  506. Xeval "$CPP conftest.c > conftest.out 2>&1"
  507. Xif egrep "memchr" conftest.out >/dev/null 2>&1; then
  508. X  rm -rf conftest*
  509. X  # SGI's /bin/cc from Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
  510. Xcat > conftest.c <<EOF
  511. X#include "confdefs.h"
  512. X#include <ctype.h>
  513. X#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
  514. X#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
  515. X#define XOR(e,f) (((e) && !(f)) || (!(e) && (f)))
  516. Xint main () { int i; for (i = 0; i < 256; i++)
  517. Xif (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
  518. Xexit (0); }
  519. X
  520. XEOF
  521. Xeval $compile
  522. Xif test -s conftest && (./conftest; exit) 2>/dev/null; then
  523. X  
  524. X{
  525. Xtest -n "$verbose" && \
  526. Xecho "    defining STDC_HEADERS"
  527. Xecho "#define" STDC_HEADERS 1 >> confdefs.h
  528. XDEFS="$DEFS -DSTDC_HEADERS=1"
  529. X}
  530. X
  531. X
  532. Xfi
  533. Xrm -fr conftest*
  534. X
  535. Xfi
  536. Xrm -f conftest*
  537. X
  538. X
  539. Xfi
  540. Xrm -f conftest*
  541. X
  542. Xfor hdr in stdlib.h
  543. Xdo
  544. Xtrhdr=HAVE_`echo $hdr | tr '[a-z]./' '[A-Z]__'`
  545. Xecho checking for ${hdr}
  546. Xcat > conftest.c <<EOF
  547. X#include "confdefs.h"
  548. X#include <${hdr}>
  549. XEOF
  550. Xerr=`eval "($CPP conftest.c >/dev/null) 2>&1"`
  551. Xif test -z "$err"; then
  552. X  rm -rf conftest*
  553. X  
  554. X{
  555. Xtest -n "$verbose" && \
  556. Xecho "    defining ${trhdr}"
  557. Xecho "#define" ${trhdr} 1 >> confdefs.h
  558. XDEFS="$DEFS -D${trhdr}=1"
  559. X}
  560. X
  561. X
  562. Xfi
  563. Xrm -f conftest*
  564. Xdone
  565. X
  566. Xecho checking for uid_t in sys/types.h
  567. Xecho '#include "confdefs.h"
  568. X#include <sys/types.h>' > conftest.c
  569. Xeval "$CPP conftest.c > conftest.out 2>&1"
  570. Xif egrep "uid_t" conftest.out >/dev/null 2>&1; then
  571. X  :
  572. Xelse
  573. X  rm -rf conftest*
  574. X  
  575. X{
  576. Xtest -n "$verbose" && \
  577. Xecho "    defining" uid_t to be int
  578. Xecho "#define" uid_t int >> confdefs.h
  579. XDEFS="$DEFS -Duid_t=int"
  580. X}
  581. X{
  582. Xtest -n "$verbose" && \
  583. Xecho "    defining" gid_t to be int
  584. Xecho "#define" gid_t int >> confdefs.h
  585. XDEFS="$DEFS -Dgid_t=int"
  586. X}
  587. X
  588. Xfi
  589. Xrm -f conftest*
  590. X
  591. Xecho checking for mode_t in sys/types.h
  592. Xecho '#include "confdefs.h"
  593. X#include <sys/types.h>' > conftest.c
  594. Xeval "$CPP conftest.c > conftest.out 2>&1"
  595. Xif egrep "mode_t" conftest.out >/dev/null 2>&1; then
  596. X  :
  597. Xelse
  598. X  rm -rf conftest*
  599. X  
  600. X{
  601. Xtest -n "$verbose" && \
  602. Xecho "    defining" mode_t to be int
  603. Xecho "#define" mode_t int >> confdefs.h
  604. XDEFS="$DEFS -Dmode_t=int"
  605. X}
  606. X
  607. Xfi
  608. Xrm -f conftest*
  609. X
  610. Xecho checking for size_t in sys/types.h
  611. Xecho '#include "confdefs.h"
  612. X#include <sys/types.h>' > conftest.c
  613. Xeval "$CPP conftest.c > conftest.out 2>&1"
  614. Xif egrep "size_t" conftest.out >/dev/null 2>&1; then
  615. X  :
  616. Xelse
  617. X  rm -rf conftest*
  618. X  
  619. X{
  620. Xtest -n "$verbose" && \
  621. Xecho "    defining" size_t to be unsigned
  622. Xecho "#define" size_t unsigned >> confdefs.h
  623. XDEFS="$DEFS -Dsize_t=unsigned"
  624. X}
  625. X
  626. Xfi
  627. Xrm -f conftest*
  628. X
  629. X
  630. Xecho checking whether cross-compiling
  631. X# If we cannot run a trivial program, we must be cross compiling.
  632. Xcat > conftest.c <<EOF
  633. X#include "confdefs.h"
  634. Xmain(){exit(0);}
  635. XEOF
  636. Xeval $compile
  637. Xif test -s conftest && (./conftest; exit) 2>/dev/null; then
  638. X  :
  639. Xelse
  640. X  cross_compiling=1
  641. Xfi
  642. Xrm -fr conftest*
  643. X
  644. Xprog='/* Ultrix mips cc rejects this.  */
  645. Xtypedef int charset[2]; const charset x;
  646. X/* SunOS 4.1.1 cc rejects this.  */
  647. Xchar const *const *ccp;
  648. Xchar **p;
  649. X/* AIX XL C 1.02.0.0 rejects this.
  650. X   It does not let you subtract one const X* pointer from another in an arm
  651. X   of an if-expression whose if-part is not a constant expression */
  652. Xconst char *g = "string";
  653. Xccp = &g + (g ? g-g : 0);
  654. X/* HPUX 7.0 cc rejects these. */
  655. X++ccp;
  656. Xp = (char**) ccp;
  657. Xccp = (char const *const *) p;
  658. X{ /* SCO 3.2v4 cc rejects this.  */
  659. X  char *t;
  660. X  char const *s = 0 ? (char *) 0 : (char const *) 0;
  661. X
  662. X  *t++ = 0;
  663. X}
  664. X{ /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
  665. X  int x[] = {25,17};
  666. X  const int *foo = &x[0];
  667. X  ++foo;
  668. X}
  669. X{ /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
  670. X  typedef const int *iptr;
  671. X  iptr p = 0;
  672. X  ++p;
  673. X}
  674. X{ /* AIX XL C 1.02.0.0 rejects this saying
  675. X     "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
  676. X  struct s { int j; const int *ap[3]; };
  677. X  struct s *b; b->j = 5;
  678. X}
  679. X{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
  680. X  const int foo = 10;
  681. X}'
  682. Xecho checking for lack of working const
  683. Xcat > conftest.c <<EOF
  684. X#include "confdefs.h"
  685. X
  686. Xint main() { exit(0); }
  687. Xint t() { $prog }
  688. XEOF
  689. Xif eval $compile; then
  690. X  :
  691. Xelse
  692. X  rm -rf conftest*
  693. X  
  694. X{
  695. Xtest -n "$verbose" && \
  696. Xecho "    defining" const to be empty
  697. Xecho "#define" const  >> confdefs.h
  698. XDEFS="$DEFS -Dconst="
  699. X}
  700. X
  701. Xfi
  702. Xrm -f conftest*
  703. X
  704. X
  705. Xecho checking for netdb.h
  706. Xcat > conftest.c <<EOF
  707. X#include "confdefs.h"
  708. X#include <netdb.h>
  709. XEOF
  710. Xerr=`eval "($CPP conftest.c >/dev/null) 2>&1"`
  711. Xif test -z "$err"; then
  712. X  rm -rf conftest*
  713. X  echo '#include "confdefs.h"
  714. X#include <netdb.h>' > conftest.c
  715. Xeval "$CPP conftest.c > conftest.out 2>&1"
  716. Xif egrep "MAXHOSTNAMELEN" conftest.out >/dev/null 2>&1; then
  717. X  rm -rf conftest*
  718. X  
  719. X{
  720. Xtest -n "$verbose" && \
  721. Xecho "    defining NEED_NETDB_H"
  722. Xecho "#define" NEED_NETDB_H 1 >> confdefs.h
  723. XDEFS="$DEFS -DNEED_NETDB_H=1"
  724. X}
  725. X
  726. X
  727. Xfi
  728. Xrm -f conftest*
  729. X
  730. X
  731. Xfi
  732. Xrm -f conftest*
  733. X
  734. X
  735. Xecho "checking mesg y permissions"
  736. Xcat > conftest.c <<EOF
  737. X#include "confdefs.h"
  738. X
  739. X    #include <sys/types.h>
  740. X    #include <sys/stat.h>
  741. X    #include <stdio.h>
  742. X    main() {
  743. X    struct stat sb; char *x; int om, m; FILE *fp;
  744. X    if (!(x = ttyname(0))) exit(1);
  745. X    if (stat(x, &sb)) exit(1);
  746. X    om = sb.st_mode;
  747. X    if (chmod(x, om & ~077)) exit(1);
  748. X    m = system("mesg y");
  749. X    if (m == -1 || m == 127) exit(1);
  750. X    if (stat(x, &sb)) exit(1);
  751. X    m = sb.st_mode;
  752. X    if (chmod(x, om)) exit(1);
  753. X    if (!(m & 002)) {
  754. X        if (!(fp=fopen("conftest_grp", "w")))
  755. X        exit(1);
  756. X        fprintf(fp, "%d\n", sb.st_gid);
  757. X        fclose(fp);
  758. X    }
  759. X    exit(0);
  760. X    }
  761. X
  762. XEOF
  763. Xeval $compile
  764. Xif test -s conftest && (./conftest; exit) 2>/dev/null; then
  765. X  
  766. X    if test -f conftest_grp; then
  767. X    echo "- 'to' is setgid to group `cat conftest_grp`"
  768. X    
  769. X{
  770. Xtest -n "$verbose" && \
  771. Xecho "    defining TTY_RESTRICTED"
  772. Xecho "#define" TTY_RESTRICTED 1 >> confdefs.h
  773. XDEFS="$DEFS -DTTY_RESTRICTED=1"
  774. X}
  775. X
  776. X    TO_GRP=`cat conftest_grp`
  777. X    else
  778. X    echo "- anyone can write to tty"
  779. X    fi
  780. X
  781. X
  782. Xelse
  783. X  echo "- can't determine - assume anyone can write to tty"
  784. X
  785. Xfi
  786. Xrm -fr conftest*
  787. X    
  788. Xecho "checking for YP/NIS"
  789. Xif $YPWHICH >/dev/null 2>&1; then
  790. X    echo "- running YP, using system getpwent"
  791. X    usegetpw=1
  792. Xelse
  793. X    echo "checking for getpwent db caches"
  794. X    if test -f /etc/passwd.dir || test -f /etc/pwd.db; then
  795. X    echo "- they're there, using system getpwent"
  796. X    usegetpw=1
  797. X    else
  798. X    echo "- unavailable, using own getpwent"
  799. X    fi
  800. Xfi
  801. Xif test -n "$usegetpw"; then
  802. X    
  803. X{
  804. Xtest -n "$verbose" && \
  805. Xecho "    defining USE_GETPWENT"
  806. Xecho "#define" USE_GETPWENT 1 >> confdefs.h
  807. XDEFS="$DEFS -DUSE_GETPWENT=1"
  808. X}
  809. X
  810. Xfi
  811. X
  812. Xecho checking for utmpx.h
  813. Xcat > conftest.c <<EOF
  814. X#include "confdefs.h"
  815. X#include <utmpx.h>
  816. XEOF
  817. Xerr=`eval "($CPP conftest.c >/dev/null) 2>&1"`
  818. Xif test -z "$err"; then
  819. X  rm -rf conftest*
  820. X  
  821. X{
  822. Xtest -n "$verbose" && \
  823. Xecho "    defining HAVE_UTMPX_H"
  824. Xecho "#define" HAVE_UTMPX_H 1 >> confdefs.h
  825. XDEFS="$DEFS -DHAVE_UTMPX_H=1"
  826. X}
  827. X
  828. X    
  829. X{
  830. Xtest -n "$verbose" && \
  831. Xecho "    defining HAVE_UT_TYPE"
  832. Xecho "#define" HAVE_UT_TYPE 1 >> confdefs.h
  833. XDEFS="$DEFS -DHAVE_UT_TYPE=1"
  834. X}
  835. X
  836. X    
  837. X{
  838. Xtest -n "$verbose" && \
  839. Xecho "    defining HAVE_UT_HOST"
  840. Xecho "#define" HAVE_UT_HOST 1 >> confdefs.h
  841. XDEFS="$DEFS -DHAVE_UT_HOST=1"
  842. X}
  843. X
  844. X
  845. X
  846. Xelse
  847. X  rm -rf conftest*
  848. X  echo "checking for struct utmp.ut_type"
  849. X    echo '#include "confdefs.h"
  850. X#include <utmp.h>' > conftest.c
  851. Xeval "$CPP conftest.c > conftest.out 2>&1"
  852. Xif egrep "ut_type" conftest.out >/dev/null 2>&1; then
  853. X  rm -rf conftest*
  854. X  
  855. X{
  856. Xtest -n "$verbose" && \
  857. Xecho "    defining HAVE_UT_TYPE"
  858. Xecho "#define" HAVE_UT_TYPE 1 >> confdefs.h
  859. XDEFS="$DEFS -DHAVE_UT_TYPE=1"
  860. X}
  861. X
  862. X
  863. Xfi
  864. Xrm -f conftest*
  865. X
  866. X    echo "checking for struct umtp.ut_host"
  867. X    echo '#include "confdefs.h"
  868. X#include <utmp.h>' > conftest.c
  869. Xeval "$CPP conftest.c > conftest.out 2>&1"
  870. Xif egrep "ut_host" conftest.out >/dev/null 2>&1; then
  871. X  rm -rf conftest*
  872. X  
  873. X{
  874. Xtest -n "$verbose" && \
  875. Xecho "    defining HAVE_UT_HOST"
  876. Xecho "#define" HAVE_UT_HOST 1 >> confdefs.h
  877. XDEFS="$DEFS -DHAVE_UT_HOST=1"
  878. X}
  879. X
  880. X
  881. Xfi
  882. Xrm -f conftest*
  883. X
  884. X
  885. Xfi
  886. Xrm -f conftest*
  887. X
  888. X
  889. XLIBS_save="${LIBS}"
  890. XLIBS="${LIBS} -lnsl"
  891. Xhave_lib=""
  892. Xecho checking for -lnsl
  893. Xcat > conftest.c <<EOF
  894. X#include "confdefs.h"
  895. X
  896. Xint main() { exit(0); }
  897. Xint t() { main(); }
  898. XEOF
  899. Xif eval $compile; then
  900. X  rm -rf conftest*
  901. X  have_lib="1"
  902. X
  903. Xfi
  904. Xrm -f conftest*
  905. XLIBS="${LIBS_save}"
  906. Xif test -n "${have_lib}"; then
  907. X   :; LIBS="$LIBS -lnsl"
  908. Xelse
  909. X   :; 
  910. Xfi
  911. X
  912. XLIBS_save="${LIBS}"
  913. XLIBS="${LIBS} -lsocket"
  914. Xhave_lib=""
  915. Xecho checking for -lsocket
  916. Xcat > conftest.c <<EOF
  917. X#include "confdefs.h"
  918. X
  919. Xint main() { exit(0); }
  920. Xint t() { main(); }
  921. XEOF
  922. Xif eval $compile; then
  923. X  rm -rf conftest*
  924. X  have_lib="1"
  925. X
  926. Xfi
  927. Xrm -f conftest*
  928. XLIBS="${LIBS_save}"
  929. Xif test -n "${have_lib}"; then
  930. X   :; LIBS="$LIBS -lsocket"
  931. Xelse
  932. X   :; 
  933. Xfi
  934. X
  935. Xfor func in strerror
  936. Xdo
  937. Xtrfunc=HAVE_`echo $func | tr '[a-z]' '[A-Z]'`
  938. Xecho checking for ${func}
  939. Xcat > conftest.c <<EOF
  940. X#include "confdefs.h"
  941. X#include <ctype.h>
  942. Xint main() { exit(0); }
  943. Xint t() { 
  944. X/* The GNU C library defines this for functions which it implements
  945. X    to always fail with ENOSYS.  Some functions are actually named
  946. X    something starting with __ and the normal name is an alias.  */
  947. X#if defined (__stub_${func}) || defined (__stub___${func})
  948. Xchoke me
  949. X#else
  950. X/* Override any gcc2 internal prototype to avoid an error.  */
  951. Xextern char ${func}(); ${func}();
  952. X#endif
  953. X }
  954. XEOF
  955. Xif eval $compile; then
  956. X  rm -rf conftest*
  957. X  {
  958. Xtest -n "$verbose" && \
  959. Xecho "    defining ${trfunc}"
  960. Xecho "#define" ${trfunc} 1 >> confdefs.h
  961. XDEFS="$DEFS -D${trfunc}=1"
  962. X}
  963. X
  964. X
  965. Xfi
  966. Xrm -f conftest*
  967. Xdone
  968. X
  969. Xfor func in getutent
  970. Xdo
  971. Xecho checking for ${func}
  972. Xcat > conftest.c <<EOF
  973. X#include "confdefs.h"
  974. X#include <ctype.h>
  975. Xint main() { exit(0); }
  976. Xint t() { 
  977. X/* The GNU C library defines this for functions which it implements
  978. X    to always fail with ENOSYS.  Some functions are actually named
  979. X    something starting with __ and the normal name is an alias.  */
  980. X#if defined (__stub_${func}) || defined (__stub___${func})
  981. Xchoke me
  982. X#else
  983. X/* Override any gcc2 internal prototype to avoid an error.  */
  984. Xextern char ${func}(); ${func}();
  985. X#endif
  986. X }
  987. XEOF
  988. Xif eval $compile; then
  989. X  :
  990. Xelse
  991. X  rm -rf conftest*
  992. X  LIBOBJS="$LIBOBJS ${func}.o"
  993. Xtest -n "$verbose" && echo "    using ${func}.o instead"
  994. Xfi
  995. Xrm -f conftest*
  996. X
  997. Xdone
  998. X
  999. X
  1000. Xecho "checking malloc declaration"
  1001. Xcat > conftest.c <<EOF
  1002. X#include "confdefs.h"
  1003. X
  1004. X#if HAVE_STDLIB_H
  1005. X#   include <stdlib.h>
  1006. X#endif
  1007. X
  1008. XEOF
  1009. Xeval "$CPP conftest.c > conftest.out 2>&1"
  1010. Xif egrep "malloc( |    |\()" conftest.out >/dev/null 2>&1; then
  1011. X  rm -rf conftest*
  1012. X  
  1013. X{
  1014. Xtest -n "$verbose" && \
  1015. Xecho "    defining MALLOC_DECL"
  1016. Xecho "#define" MALLOC_DECL 1 >> confdefs.h
  1017. XDEFS="$DEFS -DMALLOC_DECL=1"
  1018. X}
  1019. X
  1020. X
  1021. Xfi
  1022. Xrm -f conftest*
  1023. X
  1024. X
  1025. Xecho "checking open declaration"
  1026. Xcat > conftest.c <<EOF
  1027. X#include "confdefs.h"
  1028. X
  1029. X#include <fcntl.h>
  1030. X
  1031. XEOF
  1032. Xeval "$CPP conftest.c > conftest.out 2>&1"
  1033. Xif egrep "open( |    |\()" conftest.out >/dev/null 2>&1; then
  1034. X  rm -rf conftest*
  1035. X  
  1036. X{
  1037. Xtest -n "$verbose" && \
  1038. Xecho "    defining OPEN_DECL"
  1039. Xecho "#define" OPEN_DECL 1 >> confdefs.h
  1040. XDEFS="$DEFS -DOPEN_DECL=1"
  1041. X}
  1042. X
  1043. X
  1044. Xfi
  1045. Xrm -f conftest*
  1046. X
  1047. X
  1048. Xecho "checking read declaration"
  1049. Xcat > conftest.c <<EOF
  1050. X#include "confdefs.h"
  1051. X
  1052. X#if HAVE_UNISTD_H
  1053. X#   include <unistd.h>
  1054. X#endif
  1055. X
  1056. XEOF
  1057. Xeval "$CPP conftest.c > conftest.out 2>&1"
  1058. Xif egrep "read( |    |\()" conftest.out >/dev/null 2>&1; then
  1059. X  rm -rf conftest*
  1060. X  
  1061. X{
  1062. Xtest -n "$verbose" && \
  1063. Xecho "    defining READ_DECL"
  1064. Xecho "#define" READ_DECL 1 >> confdefs.h
  1065. XDEFS="$DEFS -DREAD_DECL=1"
  1066. X}
  1067. X
  1068. X
  1069. Xfi
  1070. Xrm -f conftest*
  1071. X
  1072. X
  1073. Xecho checking for gethostname
  1074. Xcat > conftest.c <<EOF
  1075. X#include "confdefs.h"
  1076. X#include <ctype.h>
  1077. Xint main() { exit(0); }
  1078. Xint t() { 
  1079. X/* The GNU C library defines this for functions which it implements
  1080. X    to always fail with ENOSYS.  Some functions are actually named
  1081. X    something starting with __ and the normal name is an alias.  */
  1082. X#if defined (__stub_gethostname) || defined (__stub___gethostname)
  1083. Xchoke me
  1084. X#else
  1085. X/* Override any gcc2 internal prototype to avoid an error.  */
  1086. Xextern char gethostname(); gethostname();
  1087. X#endif
  1088. X }
  1089. XEOF
  1090. Xif eval $compile; then
  1091. X  rm -rf conftest*
  1092. X  
  1093. X{
  1094. Xtest -n "$verbose" && \
  1095. Xecho "    defining HAVE_GETHOSTNAME"
  1096. Xecho "#define" HAVE_GETHOSTNAME 1 >> confdefs.h
  1097. XDEFS="$DEFS -DHAVE_GETHOSTNAME=1"
  1098. X}
  1099. X
  1100. X    have_ghn=1
  1101. X
  1102. X
  1103. Xelse
  1104. X  rm -rf conftest*
  1105. X  for hdr in sys/utsname.h
  1106. Xdo
  1107. Xtrhdr=HAVE_`echo $hdr | tr 'a-z./' 'A-Z__'`
  1108. Xecho checking for ${hdr}
  1109. Xcat > conftest.c <<EOF
  1110. X#include "confdefs.h"
  1111. X#include <${hdr}>
  1112. XEOF
  1113. Xerr=`eval "($CPP conftest.c >/dev/null) 2>&1"`
  1114. Xif test -z "$err"; then
  1115. X  rm -rf conftest*
  1116. X  
  1117. X{
  1118. Xtest -n "$verbose" && \
  1119. Xecho "    defining ${trhdr}"
  1120. Xecho "#define" ${trhdr} 1 >> confdefs.h
  1121. XDEFS="$DEFS -D${trhdr}=1"
  1122. X}
  1123. X
  1124. X
  1125. Xfi
  1126. Xrm -f conftest*
  1127. Xdone
  1128. X
  1129. X    for func in uname
  1130. Xdo
  1131. Xtrfunc=HAVE_`echo $func | tr 'a-z' 'A-Z'`
  1132. Xecho checking for ${func}
  1133. Xcat > conftest.c <<EOF
  1134. X#include "confdefs.h"
  1135. X#include <ctype.h>
  1136. Xint main() { exit(0); }
  1137. Xint t() { 
  1138. X/* The GNU C library defines this for functions which it implements
  1139. X    to always fail with ENOSYS.  Some functions are actually named
  1140. X    something starting with __ and the normal name is an alias.  */
  1141. X#if defined (__stub_${func}) || defined (__stub___${func})
  1142. Xchoke me
  1143. X#else
  1144. X/* Override any gcc2 internal prototype to avoid an error.  */
  1145. Xextern char ${func}(); ${func}();
  1146. X#endif
  1147. X }
  1148. XEOF
  1149. Xif eval $compile; then
  1150. X  rm -rf conftest*
  1151. X  {
  1152. Xtest -n "$verbose" && \
  1153. Xecho "    defining ${trfunc}"
  1154. Xecho "#define" ${trfunc} 1 >> confdefs.h
  1155. XDEFS="$DEFS -D${trfunc}=1"
  1156. X}
  1157. X
  1158. X
  1159. Xfi
  1160. Xrm -f conftest*
  1161. Xdone
  1162. X
  1163. X
  1164. Xfi
  1165. Xrm -f conftest*
  1166. X
  1167. Xif test -n "$have_ghn"; then
  1168. X    echo "checking gethostname declaration"
  1169. X    cat > conftest.c <<EOF
  1170. X#include "confdefs.h"
  1171. X
  1172. X    #include <sys/types.h>
  1173. X    #if HAVE_UNISTD_H
  1174. X    #   include <unistd.h>
  1175. X    #endif
  1176. X    
  1177. XEOF
  1178. Xeval "$CPP conftest.c > conftest.out 2>&1"
  1179. Xif egrep "gethostname( |    |\()" conftest.out >/dev/null 2>&1; then
  1180. X  rm -rf conftest*
  1181. X  
  1182. X{
  1183. Xtest -n "$verbose" && \
  1184. Xecho "    defining GETHOSTNAME_DECL"
  1185. Xecho "#define" GETHOSTNAME_DECL 1 >> confdefs.h
  1186. XDEFS="$DEFS -DGETHOSTNAME_DECL=1"
  1187. X}
  1188. X
  1189. X
  1190. Xfi
  1191. Xrm -f conftest*
  1192. X
  1193. Xfi
  1194. X
  1195. X# Set default prefixes.
  1196. Xif test -n "$prefix"; then
  1197. X  test -z "$exec_prefix" && exec_prefix='${prefix}'
  1198. X  prsub="s%^prefix\\([     ]*\\)=\\([     ]*\\).*$%prefix\\1=\\2$prefix%"
  1199. Xfi
  1200. Xif test -n "$exec_prefix"; then
  1201. X  prsub="$prsub
  1202. Xs%^exec_prefix\\([     ]*\\)=\\([     ]*\\).*$%exec_prefix\\1=\\2$exec_prefix%"
  1203. Xfi
  1204. X# Quote sed substitution magic chars in DEFS.
  1205. Xcat >conftest.def <<EOF
  1206. X$DEFS
  1207. XEOF
  1208. Xescape_ampersand_and_backslash='s%[&\\]%\\&%g'
  1209. XDEFS=`sed "$escape_ampersand_and_backslash" <conftest.def`
  1210. Xrm -f conftest.def
  1211. X# Substitute for predefined variables.
  1212. X
  1213. Xtrap 'rm -f config.status; exit 1' 1 3 15
  1214. Xecho creating config.status
  1215. Xrm -f config.status
  1216. Xcat > config.status <<EOF
  1217. X#!/bin/sh
  1218. X# Generated automatically by configure.
  1219. X# Run this file to recreate the current configuration.
  1220. X# This directory was configured as follows,
  1221. X# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
  1222. X#
  1223. X# $0 $configure_args
  1224. X
  1225. Xfor arg
  1226. Xdo
  1227. X  case "\$arg" in
  1228. X    -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
  1229. X    echo running \${CONFIG_SHELL-/bin/sh} $0 $configure_args
  1230. X    exec \${CONFIG_SHELL-/bin/sh} $0 $configure_args ;;
  1231. X    *) echo "Usage: config.status --recheck" 2>&1; exit 1 ;;
  1232. X  esac
  1233. Xdone
  1234. X
  1235. Xtrap 'rm -f Makefile; exit 1' 1 3 15
  1236. XPROGS='$PROGS'
  1237. XCC='$CC'
  1238. XCPP='$CPP'
  1239. XINSTALL='$INSTALL'
  1240. XINSTALL_PROGRAM='$INSTALL_PROGRAM'
  1241. XINSTALL_DATA='$INSTALL_DATA'
  1242. XLN_S='$LN_S'
  1243. XROFF='$ROFF'
  1244. XTBL='$TBL'
  1245. XYPWHICH='$YPWHICH'
  1246. XTO_GRP='$TO_GRP'
  1247. XLIBOBJS='$LIBOBJS'
  1248. XLIBS='$LIBS'
  1249. Xsrcdir='$srcdir'
  1250. XDEFS='$DEFS'
  1251. Xprefix='$prefix'
  1252. Xexec_prefix='$exec_prefix'
  1253. Xprsub='$prsub'
  1254. Xextrasub='$extrasub'
  1255. XEOF
  1256. Xcat >> config.status <<\EOF
  1257. X
  1258. Xtop_srcdir=$srcdir
  1259. X
  1260. XCONFIG_FILES=${CONFIG_FILES-"Makefile"}
  1261. Xfor file in .. ${CONFIG_FILES}; do if test "x$file" != x..; then
  1262. X  srcdir=$top_srcdir
  1263. X  # Remove last slash and all that follows it.  Not all systems have dirname.
  1264. X  dir=`echo $file|sed 's%/[^/][^/]*$%%'`
  1265. X  if test "$dir" != "$file"; then
  1266. X    test "$top_srcdir" != . && srcdir=$top_srcdir/$dir
  1267. X    test ! -d $dir && mkdir $dir
  1268. X  fi
  1269. X  echo creating $file
  1270. X  rm -f $file
  1271. X  echo "# Generated automatically from `echo $file|sed 's|.*/||'`.in by configure." > $file
  1272. X  sed -e "
  1273. X$prsub
  1274. X$extrasub
  1275. Xs%@PROGS@%$PROGS%g
  1276. Xs%@CC@%$CC%g
  1277. Xs%@CPP@%$CPP%g
  1278. Xs%@INSTALL@%$INSTALL%g
  1279. Xs%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
  1280. Xs%@INSTALL_DATA@%$INSTALL_DATA%g
  1281. Xs%@LN_S@%$LN_S%g
  1282. Xs%@ROFF@%$ROFF%g
  1283. Xs%@TBL@%$TBL%g
  1284. Xs%@YPWHICH@%$YPWHICH%g
  1285. Xs%@TO_GRP@%$TO_GRP%g
  1286. Xs%@LIBOBJS@%$LIBOBJS%g
  1287. Xs%@LIBS@%$LIBS%g
  1288. Xs%@srcdir@%$srcdir%g
  1289. Xs%@DEFS@%$DEFS%
  1290. X" $top_srcdir/${file}.in >> $file
  1291. Xfi; done
  1292. X
  1293. X
  1294. Xexit 0
  1295. XEOF
  1296. Xchmod +x config.status
  1297. X${CONFIG_SHELL-/bin/sh} config.status
  1298. X
  1299. END_OF_FILE
  1300.   if test 27563 -ne `wc -c <'casu-3.3/configure'`; then
  1301.     echo shar: \"'casu-3.3/configure'\" unpacked with wrong size!
  1302.   fi
  1303.   chmod +x 'casu-3.3/configure'
  1304.   # end of 'casu-3.3/configure'
  1305. fi
  1306. if test -f 'casu-3.3/to.c' -a "${1}" != "-c" ; then 
  1307.   echo shar: Will not clobber existing file \"'casu-3.3/to.c'\"
  1308. else
  1309.   echo shar: Extracting \"'casu-3.3/to.c'\" \(21895 characters\)
  1310.   sed "s/^X//" >'casu-3.3/to.c' <<'END_OF_FILE'
  1311. X/*
  1312. X *  CaSU - communications & status utilities.
  1313. X *  Copyright (C) 1992, 1993 Luke Mewburn <lm@rmit.edu.au>
  1314. X *    incorporating:
  1315. X *       flon - lists your friends who are logged on.
  1316. X *       to - send a short message to a friend
  1317. X *
  1318. X *  This program is free software; you can redistribute it and/or modify
  1319. X *  it under the terms of the GNU General Public License as published by
  1320. X *  the Free Software Foundation; either version 2 of the License, or
  1321. X *  (at your option) any later version.
  1322. X *  
  1323. X *  This program is distributed in the hope that it will be useful,
  1324. X *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  1325. X *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1326. X *  GNU General Public License for more details.
  1327. X *  
  1328. X *  You should have received a copy of the GNU General Public License
  1329. X *  along with this program; if not, write to the Free Software
  1330. X *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1331. X *
  1332. X */
  1333. X
  1334. X#define _MAIN_
  1335. X#include "casu.h"
  1336. X
  1337. X#ifdef M_SYSV
  1338. X    utmp_s    Kludge;
  1339. X#endif /* for SCO */
  1340. X
  1341. X
  1342. Xstatic    int     argc;
  1343. Xstatic    char    **argv;
  1344. X
  1345. X/*
  1346. X * add_alist_ent -    add an alias/userid pair to the global linked list;
  1347. X *            if alias is empty, just add - as it's an exclude entry,
  1348. X *            not an alias.
  1349. X */
  1350. Xstatic void
  1351. Xadd_alist_ent(alias, userid, them)
  1352. X    char    *alias, *userid;
  1353. X    user_t    *them;
  1354. X{
  1355. X    alist *p = them->aliases;
  1356. X
  1357. X    if (alias[0])        /* find matching alias */
  1358. X    {
  1359. X    while (p != NULL)
  1360. X    {
  1361. X        if (strcmp(p->alias, alias) == 0)
  1362. X        break;
  1363. X        p = p->next;
  1364. X    }
  1365. X    }
  1366. X    else            /* find matching exclude entry */
  1367. X    {
  1368. X    while (p != NULL)
  1369. X    {
  1370. X        if ((!p->alias[0]) && (strcmp(p->userid, userid) == 0))
  1371. X        break;
  1372. X        p = p->next;
  1373. X    }
  1374. X    }
  1375. X    if (p == NULL)        /* not found - add new element */
  1376. X    {
  1377. X    p = (alist *) malloc (sizeof(alist));
  1378. X    if (p == NULL)
  1379. X        errexit(strerror(errno), NULL);
  1380. X    p->next = them->aliases;
  1381. X    them->aliases = p;
  1382. X    }
  1383. X    strnc0py(p->alias, alias, sizeof(p->alias) - 1);
  1384. X    strnc0py(p->userid, userid, sizeof(p->userid) - 1);
  1385. X} /* add_alist_ent */
  1386. X
  1387. X
  1388. X/*
  1389. X * remove_alist_ent - remove an alias/userid pair from the global linked list;
  1390. X */
  1391. Xstatic void
  1392. Xremove_alist_ent(user, them, rm_type)
  1393. X    char    *user;
  1394. X    user_t    *them;
  1395. X#define REMOVE_EXCLUDE    0
  1396. X#define REMOVE_ALIAS    1
  1397. X    int        rm_type;    /* 1 == remove alias, 0 === remove exclude */
  1398. X{
  1399. X    alist *p = them->aliases, *last;
  1400. X
  1401. X    last = NULL;
  1402. X    while (p != NULL)            /* find relevant entry */
  1403. X    {
  1404. X    if (rm_type == REMOVE_ALIAS)
  1405. X    {
  1406. X        if (strcmp(p->alias, user) == 0)
  1407. X        break;
  1408. X    }
  1409. X    else    /* REMOVE_EXCLUDE */
  1410. X        if ((! p->alias[0]) && (strcmp(p->userid, user) == 0))
  1411. X        break;
  1412. X    last = p;
  1413. X    p = p->next;
  1414. X    }
  1415. X    if (p == NULL)            /* not there - complain */
  1416. X    {
  1417. X    if (rm_type == REMOVE_ALIAS)
  1418. X        errmesg("alias not found", user);
  1419. X    else
  1420. X        errmesg("exclude entry not found", user);
  1421. X    return;
  1422. X    }
  1423. X    if (last != NULL)            /* de-link it from the list */
  1424. X    last->next = p->next;
  1425. X    else
  1426. X    them->aliases = p->next;    /* don't bother free()ing it... */
  1427. X} /* remove_alist_ent */
  1428. X
  1429. X
  1430. X/*
  1431. X * get_pwent -    get an appropriate entry from the password file.
  1432. X *        if given NULL, assume it's for this user
  1433. X */
  1434. Xstatic struct passwd *
  1435. Xget_pwent(nam)
  1436. X    char *nam;
  1437. X{
  1438. X    struct passwd *pwent;
  1439. X    if (nam == NULL)
  1440. X    pwent = getpwuid(getuid());
  1441. X    else
  1442. X    pwent = getpwnam(nam);
  1443. X    return pwent;
  1444. X} /* get_pwent */
  1445. X
  1446. X
  1447. X/*
  1448. X * load_rcfile - read in the rcfile for the respective user
  1449. X *        into the data struct. if nam == NULL, also add
  1450. X *        aliases to the global list;
  1451. X */
  1452. Xstatic void
  1453. Xload_rcfile(them, nam)
  1454. X     user_t    *them;
  1455. X     char     *nam;
  1456. X{
  1457. X    FILE        *fp;
  1458. X    char        buf[LINESIZ + 1], rcfile[MAXPATHLEN + 1];
  1459. X    char        user[UT_NAMESIZE + 1], alias[ALIASLEN + 1];
  1460. X    struct stat        sbuf;
  1461. X    int            ch;
  1462. X    struct passwd    *pwent;
  1463. X    static char        aliasfmt[16];    /* see below */
  1464. X
  1465. X    if (!aliasfmt[0])
  1466. X    sprintf(aliasfmt, "%%%ds %%%ds", ALIASLEN, UT_NAMESIZE);
  1467. X
  1468. X    them->yes[0] = '\0';        /* clear everything */
  1469. X    them->no[0] = '\0';
  1470. X    them->gone[0] = '\0';
  1471. X    them->idle[0] = '\0';
  1472. X    them->dotuser[0] = '\0';
  1473. X    them->dottty[0] = '\0';
  1474. X    them->exclude[0] = '\0';
  1475. X    them->aliases = NULL;
  1476. X
  1477. X    pwent = get_pwent(nam);        /* get info from /etc/passwd */
  1478. X    if (!pwent)
  1479. X    if (!nam)
  1480. X        errexit("you don't exist", NULL);
  1481. X    else
  1482. X        errexit("doesn't exist", nam);
  1483. X    strnc0py(them->name,
  1484. X        convert_realname(pwent->pw_gecos, pwent->pw_name, pwent->pw_uid),
  1485. X        sizeof(them->name) - 1);
  1486. X    strnc0py(them->userid, pwent->pw_name, sizeof(them->userid) - 1);
  1487. X    strnc0py(them->homedir, pwent->pw_dir, sizeof(them->homedir) - 1);
  1488. X
  1489. X    strnc0py(rcfile, pwent->pw_dir, sizeof(rcfile) - 1);
  1490. X    if (strlen(rcfile) + strlen(STRtorc) >= sizeof(rcfile) - 1)
  1491. X    errexit("filename is too long", STRtorc);
  1492. X    strcat(rcfile, STRtorc);
  1493. X    if (stat(rcfile, &sbuf) == -1)    /* open their .torc */
  1494. X    return;
  1495. X    fp = fopen(rcfile, "r");
  1496. X    if (fp == NULL)
  1497. X    return;
  1498. X    while (fgets(buf, sizeof(buf), fp) != NULL)
  1499. X    {                    /* read it in */
  1500. X    if (strlen(buf) == sizeof(buf) - 1 )
  1501. X        while ((ch = fgetc(fp)) != EOF)
  1502. X        if (ch == '\n')
  1503. X            break;        /* gobble extra chars */
  1504. X    buf[strlen(buf) - 1] = '\0';
  1505. X    ch = isupper(buf[0]) ? tolower(buf[0]) : buf[0];
  1506. X    switch (ch)
  1507. X    {
  1508. X    case '.':            /* . user */
  1509. X        strnc0py(them->dotuser, buf + (buf[1] == ' ' ? 2 : 1),
  1510. X            sizeof(them->dotuser) - 1);
  1511. X        break;
  1512. X    case ':':            /* . tty */
  1513. X        strnc0py(them->dottty, buf + 2, sizeof(them->dottty) - 1);
  1514. X        break;
  1515. X    case 'y':            /* yes AR */
  1516. X        strnc0py(them->yes, buf + 2, sizeof(them->yes) - 1);
  1517. X        break;
  1518. X    case 'n':            /* no AR */
  1519. X        strnc0py(them->no, buf + 2, sizeof(them->no) - 1);
  1520. X        break;
  1521. X    case 'g':            /* gone AR */
  1522. X        strnc0py(them->gone, buf + 2, sizeof(them->gone) - 1);
  1523. X        break;
  1524. X    case 'i':            /* idle AR */
  1525. X        strnc0py(them->idle, buf + 2, sizeof(them->idle) - 1);
  1526. X        break;
  1527. X    case 'x':            /* exclude AR */
  1528. X        strnc0py(them->exclude, buf + 2, sizeof(them->exclude) - 1);
  1529. X        break;
  1530. X    case 'p':            /* pseudonym/name/whatever */
  1531. X        strnc0py(them->name, buf + 2, sizeof(them->name) - 1);
  1532. X        flags |= PSEUDO_MOD;
  1533. X        break;
  1534. X    case 'a':            /* add an alias */
  1535. X        if (nam == NULL)    /* only add aliases to sender's struct */
  1536. X        {
  1537. X        sscanf(buf + 1, aliasfmt, alias, user);
  1538. X        add_alist_ent(alias, user, them);
  1539. X        }
  1540. X        break;
  1541. X    case 'e':        /* add an exclude entry */
  1542. X        add_alist_ent("", buf + 2, them);
  1543. X        break;
  1544. X    default:
  1545. X        if (flags & DEBUG)
  1546. X        {
  1547. X        buf[1] = '\0';    /* so errmesg doesn't die */
  1548. X        errmesg("illegal specifier (DEBUG)", buf);
  1549. X        }
  1550. X        break;
  1551. X    }
  1552. X    } /* while */
  1553. X} /* load_rcfile */
  1554. X
  1555. X
  1556. X/*
  1557. X * dump_status -     dump status of user rec.
  1558. X */
  1559. Xstatic void
  1560. Xdump_status(me)
  1561. X    user_t    *me;
  1562. X{
  1563. X    struct stat sbuf;
  1564. X
  1565. X    if (!me->tty)
  1566. X    printf("Not attached to a tty.\n");
  1567. X    else
  1568. X    {
  1569. X    if (stat(me->tty, &sbuf) == -1)
  1570. X        errmesg(strerror(errno), me->tty);
  1571. X    else
  1572. X        printf("Incoming messages are %sabled.\n",
  1573. X            (sbuf.st_mode & MESGS_ON) ? "en" : "dis");
  1574. X    }
  1575. X    printf("Name:      %s\n", me->name);
  1576. X    if (me->tty)
  1577. X    printf("Terminal:  %s\n", me->tty);
  1578. X    if (me->dotuser[0] != '\0')
  1579. X    {
  1580. X    if (me->dottty[0] != '\0')
  1581. X        printf("Last user: %s (%s)\n", me->dotuser, me->dottty);
  1582. X    else
  1583. X        printf("Last user: %s\n", me->dotuser);
  1584. X    }
  1585. X    if (me->yes[0] != '\0')
  1586. X    printf("Mesg ON autoreply:  %s\n", me->yes);
  1587. X    if (me->no[0] != '\0')
  1588. X    printf("Mesg OFF autoreply: %s\n", me->no);
  1589. X    if (me->gone[0] != '\0')
  1590. X    printf("Gone autoreply:     %s\n", me->gone);
  1591. X    if (me->idle[0] != '\0')
  1592. X    printf("Idle autoreply:     %s\n", me->idle);
  1593. X    if (me->exclude[0] != '\0')
  1594. X    printf("Exclude autoreply:  %s\n", me->exclude);
  1595. X} /* dump_status */
  1596. X
  1597. X
  1598. X/*
  1599. X * process_options -    parse the options available
  1600. X */
  1601. Xstatic void
  1602. Xprocess_options(me, you)
  1603. X    user_t    *me, *you;
  1604. X{
  1605. X    int        ch;
  1606. X
  1607. X    opterr=1;
  1608. X    while ((ch = getopt(argc, argv, "a:bde:E:hlnrt:u:yvP:I:Y:N:G:X:V")) != -1)
  1609. X    {
  1610. X    switch (ch)
  1611. X    {
  1612. X    case 'a':
  1613. X        if (argc == optind)
  1614. X        {
  1615. X        fprintf(stderr, "Usage: %s -a alias userid\n", progname);
  1616. X        flags |= ERROR;
  1617. X        break;
  1618. X        }
  1619. X        add_alist_ent(optarg, argv[optind++], me);
  1620. X        flags |= DB_MOD;
  1621. X        break;
  1622. X    case 'b':
  1623. X        flags |= BEEP;
  1624. X        break;
  1625. X    case 'd':
  1626. X        flags |= DEBUG;
  1627. X        break;
  1628. X    case 'e':
  1629. X        add_alist_ent("", optarg, me);
  1630. X        flags |= DB_MOD;
  1631. X        break;
  1632. X    case 'E':
  1633. X        remove_alist_ent(optarg, me, REMOVE_EXCLUDE);
  1634. X        flags |= DB_MOD;
  1635. X        break;
  1636. X    case 'l':
  1637. X        flags |= LISTALIAS;
  1638. X        break;
  1639. X    case 'h':
  1640. X        flags |= HELP;
  1641. X        break;
  1642. X    case 'n':
  1643. X        flags &= ~MESG_Y;
  1644. X        flags |= MESG_N;
  1645. X        break;
  1646. X    case 'y':
  1647. X        flags |= MESG_Y;
  1648. X        flags &= ~MESG_N;
  1649. X        break;
  1650. X    case 'r':
  1651. X        flags |= STATUS;
  1652. X        break;
  1653. X    case 't':
  1654. X        you->tty = optarg;
  1655. X        flags |= DB_MOD;
  1656. X        break;
  1657. X    case 'u':
  1658. X        remove_alist_ent(optarg, me, REMOVE_ALIAS);
  1659. X        flags |= DB_MOD;
  1660. X        break;
  1661. X    case 'v':
  1662. X    case 'V':
  1663. X        flags |= LISTVERSION;
  1664. X        break;
  1665. X    case 'Y':
  1666. X        strnc0py(me->yes, optarg, sizeof(me->yes) - 1);
  1667. X        flags |= DB_MOD;
  1668. X        break;
  1669. X    case 'P':
  1670. X        strnc0py(me->name, optarg, sizeof(me->name) - 1);
  1671. X        flags |= (PSEUDO_MOD + DB_MOD);
  1672. X        break;
  1673. X    case 'N':
  1674. X        strnc0py(me->no, optarg, sizeof(me->no) - 1);
  1675. X        flags |= DB_MOD;
  1676. X        break;
  1677. X    case 'G':
  1678. X        strnc0py(me->gone, optarg, sizeof(me->gone) - 1);
  1679. X        flags |= DB_MOD;
  1680. X        break;
  1681. X    case 'I':
  1682. X        strnc0py(me->idle, optarg, sizeof(me->idle) - 1);
  1683. X        flags |= DB_MOD;
  1684. X        break;
  1685. X    case 'X':
  1686. X        strnc0py(me->exclude, optarg, sizeof(me->exclude) - 1);
  1687. X        flags |= DB_MOD;
  1688. X        break;
  1689. X    case '?':
  1690. X        flags |= ERROR;
  1691. X        break;
  1692. X    }
  1693. X    }
  1694. X
  1695. X    if (flags & DEBUG)
  1696. X    printf("DEBUG: argc %d  optind %d  flags %d \n", argc, optind, flags);
  1697. X
  1698. X        /* barf if just -b, -t ttyxx, or no args */
  1699. X    if (   (argc == optind)        /* non-productive usage */
  1700. X    && ((flags & BEEP) || (you->tty) || (argc == 1)))
  1701. X    flags |= ERROR;
  1702. X
  1703. X    if (flags & (MESG_Y + MESG_N))    /* change tty mode */
  1704. X    {
  1705. X    struct stat sbuf;
  1706. X    if (!me->tty)
  1707. X        errmesg("unable to change status of tty - no such tty", NULL);
  1708. X    else
  1709. X        if (stat(me->tty, &sbuf) == -1)
  1710. X        errmesg(strerror(errno), me->tty);
  1711. X        else
  1712. X        {
  1713. X        if (flags & MESG_N)
  1714. X            sbuf.st_mode &= ~MESGS_ON;
  1715. X        else
  1716. X            sbuf.st_mode |= MESGS_ON;
  1717. X        chmod(me->tty, sbuf.st_mode);
  1718. X        }
  1719. X    }
  1720. X
  1721. X    if (flags & STATUS)            /* show status */
  1722. X    dump_status(me);
  1723. X
  1724. X    if (flags & LISTALIAS)        /* list aliases */
  1725. X    {
  1726. X    alist *p = me->aliases;
  1727. X    if (p)
  1728. X        printf("UserID\t  Alias\n------\t  -----\n");
  1729. X    else
  1730. X        printf("No aliases defined.\n");
  1731. X    while (p)
  1732. X    {
  1733. X        printf("%s\t  %s\n", p->userid, p->alias[0] ? p->alias
  1734. X                            : "** EXCLUDED **");
  1735. X        p = p->next;
  1736. X    }
  1737. X    }
  1738. X
  1739. X    if (flags & (ERROR + LISTVERSION + HELP))
  1740. X    {
  1741. X    fprintf(stderr, "\
  1742. XUsage: %s [-a alias user] [-u alias] [-bdlnyr] [-G gone] [-Y yes] [-N no]\n\
  1743. X\t[-I idle] [-X exclude] [-P pseudo] [-e user] [-E user] [-t term]\n\
  1744. X\t[-h] -[vV]  [user [message]]\n\
  1745. X", progname);
  1746. X    if (flags & (HELP))
  1747. X    {
  1748. X        fprintf(stderr, "\
  1749. X\n\
  1750. XTo - send a short message to another user\n\
  1751. X\n\
  1752. XUsage:  %s [options] user [message] \tsends message to user (*)\n\
  1753. X\n\
  1754. Xoptions can be:\n\
  1755. X    -a alias user    add an alias to your .torc\n\
  1756. X    -u alias    unalias an alias\n\
  1757. X    -b        beep other user with message\n\
  1758. X    -e user        add `user' to the exclude list\n\
  1759. X    -E user        remove `user' from the exclude list\n\
  1760. X    -h        this help page\n\
  1761. X    -n        turn messages off\n\
  1762. X    -y        turn messages on\n\
  1763. X    -l        list aliases\n\
  1764. X    -r        list status\n\
  1765. X    -t term        send to tty `term'\n\
  1766. X    -P name        set pseudonym to name\n\
  1767. X    -I mesg        set `idle' autoreply to mesg\n\
  1768. X    -G mesg        set `gone' autoreply to mesg\n\
  1769. X    -N mesg        set `mesg n' autoreply to mesg\n\
  1770. X    -Y mesg        set `mesg y' autoreply to mesg\n\
  1771. X    -X mesg        set `exclude' autoreply to mesg\n\
  1772. X    -V        version infomation\n\
  1773. X\n\
  1774. XThe options can be used in conjunction with each other.\n\
  1775. X\n\
  1776. X(*) Reads message from terminal if you don't specify one.\n\
  1777. X", progname);
  1778. X    }
  1779. X    if (flags & (HELP + LISTVERSION))
  1780. X    {
  1781. X        fprintf(stderr, "\
  1782. X\n\
  1783. X%s version %s, %s.\n\
  1784. XCopyright (C) 1993 Luke Mewburn\n\
  1785. XEmail: <lm@rmit.edu.au>\n\
  1786. XThis is free software, and you are welcome to redistribute it under certain\n\
  1787. Xconditions. See version 2 of the GNU Public License for more details.\n\
  1788. X", progname, VERSION, RELDATE);
  1789. X    }
  1790. X    exit((flags & ERROR ) != 0);
  1791. X    }
  1792. X} /* process_options */
  1793. X
  1794. X
  1795. X/*
  1796. X * lookup_user -    find a user and put info in user_t struct
  1797. X */
  1798. Xstatic int
  1799. Xlookup_user(me, them)
  1800. X    user_t *me, *them;
  1801. X{
  1802. X    alist        *p = me->aliases;
  1803. X    struct passwd    *pwent;
  1804. X    char        *target;
  1805. X    
  1806. X    if (argc > optind)
  1807. X    target = argv[optind++];
  1808. X    else
  1809. X    return 0;
  1810. X    if (strcmp(target, ".") == 0)    /* is a .user */
  1811. X    {
  1812. X    if (me->dotuser[0] == '\0')
  1813. X    {
  1814. X        errmesg("no `.' user defined", NULL);
  1815. X        return 0;
  1816. X    }
  1817. X    target = me->dotuser;
  1818. X    if ((!them->tty) && (me->dottty[0] != '\0'))
  1819. X        them->tty = me->dottty;    /* use last tty */
  1820. X    }
  1821. X    else                /* is it an alias? */
  1822. X    {
  1823. X    while (p)
  1824. X    {
  1825. X        if (strcmp(target, p->alias) == 0)
  1826. X        {
  1827. X        target = p->userid;
  1828. X        break;
  1829. X        }
  1830. X        p = p->next;
  1831. X    }
  1832. X    }
  1833. X    pwent = get_pwent(target);        /* check if user */
  1834. X    if (! pwent)
  1835. X    {
  1836. X    errmesg("doesn't exist", target);
  1837. X    return 0;
  1838. X    }
  1839. X    strnc0py(them->name,
  1840. X        convert_realname(pwent->pw_gecos, pwent->pw_name, pwent->pw_uid),
  1841. X        sizeof(them->name) - 1);
  1842. X    strnc0py(them->userid, pwent->pw_name, sizeof(them->userid) - 1);
  1843. X    strnc0py(them->homedir, pwent->pw_dir, sizeof(them->homedir) - 1);
  1844. X    if (target != me->dotuser)
  1845. X    {
  1846. X    strnc0py(me->dotuser, target, sizeof(me->dotuser) - 1);
  1847. X    flags |= DB_MOD;
  1848. X    }
  1849. X    return 1;
  1850. X} /* lookup_user */
  1851. X
  1852. X
  1853. X/*
  1854. X * update_torc -    write out change .torc file
  1855. X */
  1856. Xstatic void
  1857. Xupdate_torc(me)
  1858. X    user_t *me;
  1859. X{
  1860. X    FILE    *fp;
  1861. X    alist    *p = me->aliases;
  1862. X    char    rcfile[MAXPATHLEN + 1];
  1863. X    struct stat    sbuf;
  1864. X
  1865. X    if (!(flags & DB_MOD))    /* only write if info was modified */
  1866. X    return;
  1867. X
  1868. X    strnc0py(rcfile, me->homedir, sizeof(rcfile) - 1);
  1869. X    if (strlen(rcfile) + strlen(STRtorc) >= sizeof(rcfile) - 1)
  1870. X    errexit("filename is too long", STRtorc);
  1871. X    strcat(rcfile, STRtorc);
  1872. X
  1873. X#if TTY_RESTRICTED
  1874. X    setgid(getgid());        /* so a new .torc has user's group, not `tty' */
  1875. X#endif /* TTY_RESTRICTED */
  1876. X    fp = fopen(rcfile, "w");
  1877. X    if (fp == NULL)
  1878. X    errexit(strerror(errno), NULL);
  1879. X    if (me->dotuser[0] != '\0')
  1880. X    fprintf(fp, ". %s\n", me->dotuser);
  1881. X    if (me->dottty[0] != '\0')
  1882. X    fprintf(fp, ": %s\n", me->dottty);
  1883. X    if (flags & PSEUDO_MOD)
  1884. X    if (me->name[0] != '\0')
  1885. X        fprintf(fp, "P %s\n", me->name);
  1886. X    if (me->yes[0] != '\0')
  1887. X    fprintf(fp, "Y %s\n", me->yes);
  1888. X    if (me->idle[0] != '\0')
  1889. X    fprintf(fp, "I %s\n", me->idle);
  1890. X    if (me->no[0] != '\0')
  1891. X    fprintf(fp, "N %s\n", me->no);
  1892. X    if (me->gone[0] != '\0')
  1893. X    fprintf(fp, "G %s\n", me->gone);
  1894. X    if (me->exclude[0] != '\0')
  1895. X    fprintf(fp, "X %s\n", me->exclude);
  1896. X    while (p)
  1897. X    {
  1898. X    if (p->alias[0])    /* exclude entries have this field empty */
  1899. X        fprintf(fp, "a %s %s\n", p->alias, p->userid);
  1900. X    else
  1901. X        fprintf(fp, "e %s\n", p->userid);
  1902. X    p = p->next;
  1903. X    }
  1904. X    if (stat(rcfile, &sbuf) != -1)    /* set the file to be world readable */
  1905. X    {
  1906. X    sbuf.st_mode |= 0444;
  1907. X    chmod(rcfile, sbuf.st_mode);
  1908. X    }
  1909. X    fclose(fp);
  1910. X} /* update_torc */
  1911. X
  1912. X
  1913. X/*
  1914. X * filter_buf - remove control characters from a NUL terminated char buffer
  1915. X */
  1916. X
  1917. Xstatic void
  1918. Xfilter_buf(buf)
  1919. X    char *buf;
  1920. X{
  1921. X#if 1            /* set to 0 to disable this function */
  1922. X    int i;
  1923. X    for (i = 0; i < strlen(buf); i++)
  1924. X    if (! (isprint(buf[i]) || buf[i] == '\t'))
  1925. X        buf[i] = '?';
  1926. X#endif
  1927. X} /* filter_buf */
  1928. X
  1929. X
  1930. X/*
  1931. X * construct_message -    build message from argv[], or read it from stdin
  1932. X */
  1933. Xstatic void
  1934. Xconstruct_message(me)
  1935. X    user_t *me;
  1936. X{
  1937. X    int        i, pos, len;
  1938. X
  1939. X    me->message[0] = '\0';
  1940. X    if (argc != optind)        /* build up message from argv[] */
  1941. X    {
  1942. X    pos = len = 0;
  1943. X    for (i = optind; i < argc; i++)
  1944. X    {
  1945. X        len = strlen(argv[i]);
  1946. X        if (len + pos > sizeof(me->message) - 1)
  1947. X        break;
  1948. X        strnc0py(me->message + pos, argv[i], len);
  1949. X        pos += len;
  1950. X        me->message[pos++] = ' ';
  1951. X    }
  1952. X    me->message[pos] = '\0';
  1953. X    }
  1954. X    else            /* interactively grab message */
  1955. X    {
  1956. X    if (!me->tty)        /* don't read message from non-terminal */
  1957. X    {
  1958. X        strnc0py(me->message, "I would like to talk to you",
  1959. X                sizeof(me->message) - 1);
  1960. X        return;
  1961. X    }
  1962. X    printf("Message: ");
  1963. X    if (fgets(me->message, sizeof(me->message), stdin) == NULL)
  1964. X    {
  1965. X        strnc0py(me->message, "I would like to talk to you",
  1966. X                sizeof(me->message) - 1);
  1967. X        return;
  1968. X    }
  1969. X    len = strlen(me->message);
  1970. X    if (me->message[len - 1] == '\n')
  1971. X        me->message[--len] = '\0';
  1972. X    }
  1973. X} /* construct_message */
  1974. X
  1975. X
  1976. X/*
  1977. X * send_message -    send the message...
  1978. X */
  1979. Xstatic void
  1980. Xsend_message(me, you)
  1981. X    user_t *me, *you;
  1982. X{
  1983. X    utmp_s *        utent;
  1984. X    char        host[MAXHOSTNAMELEN + 2];
  1985. X    static char        tty[sizeof(_PATH_DEV)+UT_LINESIZE]=_PATH_DEV;
  1986. X    char        *p, *timestr;
  1987. X    int            i;
  1988. X    FILE *        fp;
  1989. X    time_t        now;
  1990. X    alist        *pers;
  1991. X    struct stat        stbuf;
  1992. X#if HAVE_UNAME
  1993. X    struct utsname    unamebuf;
  1994. X#endif /* HAVE_UNAME */
  1995. X    static struct {
  1996. X    char        tty[sizeof(tty)];
  1997. X    time_t        idle;
  1998. X    int        res;
  1999. X    } cur;
  2000. X#define R_SENT        (1<<0)
  2001. X#define R_ISON        (1<<1)
  2002. X#define R_VALID        (1<<2)
  2003. X#define R_EXCLUDE    (1<<3)
  2004. X
  2005. X    host[sizeof(host) - 1] = '\0';    /* get hostname _somehow_ */
  2006. X    host[0] ='@';
  2007. X#if HAVE_GETHOSTNAME
  2008. X    if (gethostname(host + 1, sizeof(host) - 2) == -1)
  2009. X    host[0] = '\0';
  2010. X#else /* !HAVE_GETHOSTNAME */
  2011. X#   if HAVE_UNAME
  2012. X    if (uname(&unamebuf) == 0)
  2013. X    strnc0py(host + 1, unamebuf.nodename, sizeof(host) - 2);
  2014. X    else    /* fallthru #endif */
  2015. X#   endif /* HAVE_UNAME */
  2016. X    host[0] = '\0';
  2017. X#endif  /* !HAVE_GETHOSTNAME */
  2018. X
  2019. X    now = time(NULL);
  2020. X    timestr = ctime(&now) + 11;
  2021. X    timestr[5] = '\0';
  2022. X
  2023. X    cur.res = 0;
  2024. X    if (flags & DEBUG)
  2025. X    printf("DEBUG: me->message is :%s:\n", me->message);
  2026. X    load_rcfile(you, you->userid);
  2027. X    construct_message(me);
  2028. X    pers = you->aliases;
  2029. X    while (pers)        /* see if they're excluding you */
  2030. X    {
  2031. X    if ((strcmp(me->userid, pers->userid) == 0) && (! pers->alias[0]))
  2032. X    {
  2033. X        cur.res |= R_EXCLUDE;
  2034. X        break;
  2035. X    }
  2036. X    pers = pers->next;
  2037. X    }
  2038. X    if (! (cur.res & R_EXCLUDE))    /* if !excluded, find tty */
  2039. X    while ((utent = getutent()) != NULL)
  2040. X    {
  2041. X        if (NULL_UTMP_ENTRY(utent))
  2042. X        continue;
  2043. X        if (strncmp(utent->ut_name, you->userid, sizeof(utent->ut_name) -1))
  2044. X        continue;        /* not them */
  2045. X        cur.res |= R_ISON;
  2046. X        strcpy(tty + sizeof(_PATH_DEV) - 1, utent->ut_line);
  2047. X        if (you->tty)        /* want specific tty */
  2048. X        {
  2049. X        if (strcmp(utent->ut_line, you->tty) != 0)
  2050. X            continue;
  2051. X        strcpy(cur.tty, tty);
  2052. X        cur.res |= R_VALID;
  2053. X        break;
  2054. X        }
  2055. X        else
  2056. X        {
  2057. X        if (me->tty && strcmp(me->tty, tty) == 0)
  2058. X            continue;        /* don't do my current terminal */
  2059. X        }
  2060. X        i = stat(tty, &stbuf);
  2061. X        if (!cur.idle || ((i != -1) && stbuf.st_atime > cur.idle))
  2062. X        {
  2063. X        strcpy(cur.tty, tty);    /* remember idle info */
  2064. X        cur.res |= R_VALID;
  2065. X        if (i != -1)
  2066. X            cur.idle = stbuf.st_atime;
  2067. X        }
  2068. X    } /* while */
  2069. X
  2070. X                    /* if valid tty, attempt to send */
  2071. X    if ((cur.res & R_VALID) && ((fp = fopen(cur.tty, "a")) != NULL))
  2072. X    {
  2073. X    cur.res |= R_SENT;
  2074. X    if (flags & BEEP)
  2075. X        fprintf(fp, "%c", BELL);    /* Beep! */
  2076. X
  2077. X    if (!me->tty)
  2078. X        me->tty = "/dev/tty??";    /* hmm... stdin wasn't stdin */
  2079. X    filter_buf(me->name);        /* Clean up your name & message */
  2080. X    filter_buf(me->message);    /*   and send it */
  2081. X    fprintf(fp, "\r-=> From %s (%s%s) on %s at %s :- \n\r",
  2082. X        me->name, me->userid, host,
  2083. X        me->tty + sizeof(_PATH_DEV) - 1, timestr);
  2084. X    fprintf(fp, "%s  \n\r", me->message);
  2085. X    fclose(fp);
  2086. X    }
  2087. X    p = NULL;
  2088. X    filter_buf(you->name);
  2089. X    if (cur.res & R_EXCLUDE)        /* They don't like you */
  2090. X    {
  2091. X    printf("%s: %s (%s) has excluded you as a sender.\n",
  2092. X            progname, you->name, you->userid);
  2093. X    p = you->exclude;
  2094. X    } else if (! (cur.res & R_ISON))    /* They're not on */
  2095. X    {
  2096. X    printf("%s: %s (%s) isn't logged on.\n",
  2097. X            progname, you->name, you->userid);
  2098. X    p = you->gone;
  2099. X    }
  2100. X    else if (! (cur.res & R_SENT))    /* Didn't work for other reason */
  2101. X    {
  2102. X    if (!(cur.res & R_VALID))
  2103. X    {
  2104. X        if ((strncmp(me->userid, you->userid, sizeof(me->userid) - 1) == 0)
  2105. X        || !you->tty)        /* only if >1 usernames on same uid */
  2106. X        printf("%s: You are only logged on once.\n", progname);
  2107. X        else            /* Not on specific tty */
  2108. X        printf("%s: %s (%s) isn't logged onto the tty '%s'.\n",
  2109. X            progname, you->name, you->userid, you->tty);
  2110. X    }
  2111. X    else                /* No write perms to tty */
  2112. X    {
  2113. X        printf("%s: Access to %s's (%s) terminal denied.\n",
  2114. X            progname, you->name, you->userid);
  2115. X        p = you->no;
  2116. X    }
  2117. X
  2118. X    }
  2119. X    else
  2120. X    {
  2121. X    if (cur.idle)            /* Have an idle message */
  2122. X    {
  2123. X        if (now - cur.idle > min_idle)
  2124. X        if (strlen(you->idle))
  2125. X            p = you->idle;
  2126. X    }
  2127. X    if (p == NULL)
  2128. X        p = you->yes;
  2129. X    if (stat(me->tty, &stbuf) != -1)
  2130. X    {
  2131. X        if (! (stbuf.st_mode & MESGS_ON))    /* Just to let you know... */
  2132. X        printf("Warning: you have your messages disabled. %s can't reply\n", you->name);
  2133. X    }
  2134. X    printf("Message sent to %s (%s%s) on %s.\n",    /* Print results */
  2135. X            you->name, you->userid, host, 
  2136. X            cur.tty + sizeof(_PATH_DEV) - 1);
  2137. X        /* record where the message really went */
  2138. X    strnc0py(me->dottty, cur.tty + sizeof(_PATH_DEV) - 1,
  2139. X                sizeof(me->dottty) - 1);
  2140. X    }
  2141. X    if (p && strlen(p))            /* An autoreply exists */
  2142. X    {
  2143. X    filter_buf(p);            /* Remove illegal chars */
  2144. X    printf("-=> Auto-reply from %s :-\n%s\n", you->name, p);
  2145. X    }
  2146. X    endutent();
  2147. X} /* send_message */
  2148. X
  2149. X
  2150. X/*
  2151. X *    main function
  2152. X */
  2153. Xint
  2154. Xmain(margc, margv)
  2155. X    int margc;
  2156. X    char *margv[];
  2157. X{
  2158. X    user_t    me_s, *me = &me_s;
  2159. X    user_t    you_s, *you = &you_s;
  2160. X    char     *p;
  2161. X
  2162. X    min_idle = MINIDLE;
  2163. X    argc = margc;
  2164. X    argv = margv;
  2165. X    me->tty = ttyname(0);
  2166. X    you->tty = NULL;
  2167. X    progname = argv[0];                /* Basename invocation name */
  2168. X    if ((p = strrchr(progname, '/')) != NULL)
  2169. X    progname = ++p;
  2170. X    flags = 0;
  2171. X
  2172. X    load_rcfile(me, NULL);
  2173. X    if (  ((p = getenv("PSEUDONYM")) != NULL)    /* Get default name for you */
  2174. X    || ((p = getenv("NAME")) != NULL))
  2175. X    {
  2176. X    if (  (strcmp(me->name, p) != 0)
  2177. X        && (!(flags & PSEUDO_MOD)))
  2178. X    {
  2179. X        strnc0py(me->name, p, sizeof(me->name) - 1);
  2180. X        flags |= (PSEUDO_MOD + DB_MOD);
  2181. X    }
  2182. X    }
  2183. X    process_options(me, you);
  2184. X    if (lookup_user(me, you))
  2185. X    send_message(me, you);
  2186. X    update_torc(me);
  2187. X    return 0;
  2188. X} /* main */
  2189. END_OF_FILE
  2190.   if test 21895 -ne `wc -c <'casu-3.3/to.c'`; then
  2191.     echo shar: \"'casu-3.3/to.c'\" unpacked with wrong size!
  2192.   fi
  2193.   # end of 'casu-3.3/to.c'
  2194. fi
  2195. echo shar: End of archive 1 \(of 4\).
  2196. cp /dev/null ark1isdone
  2197. MISSING=""
  2198. for I in 1 2 3 4 ; do
  2199.     if test ! -f ark${I}isdone ; then
  2200.     MISSING="${MISSING} ${I}"
  2201.     fi
  2202. done
  2203. if test "${MISSING}" = "" ; then
  2204.     echo You have unpacked all 4 archives.
  2205.     rm -f ark[1-9]isdone
  2206. else
  2207.     echo You still must unpack the following archives:
  2208.     echo "        " ${MISSING}
  2209. fi
  2210. exit 0
  2211. exit 0 # Just in case...
  2212.