home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / ckc197.zip / ckuins.txt < prev    next >
Text File  |  2000-03-16  |  123KB  |  2,485 lines

  1. C-KERMIT 7.0 INSTALLATION INSTRUCTIONS FOR UNIX
  2.  
  3.   As of C-Kermit version:  7.0.197
  4.   This file last updated:  8 February 2000
  5.  
  6.   Author: Frank da Cruz, Columbia University
  7.  
  8.   Copyright (C) 1985, 2000,
  9.     Trustees of Columbia University in the City of New York.
  10.     All rights reserved.  See the C-Kermit COPYING.TXT file or the
  11.     copyright text in the ckcmai.c module for disclaimer and permissions.
  12.  
  13.  
  14. DOCUMENTATION
  15.  
  16.   Frank da Cruz and Christine M. Gianone, "Using C-Kermit", Second Edition,
  17.   1997, Digital Press / Butterworth-Heinemann, Woburn, MA, ISBN 1-55558-164-1
  18.   US single-copy price: $44.95; quantity discounts available.  Available in
  19.   computer bookstores or directly from Columbia University:
  20.  
  21.     The Kermit Project
  22.     Columbia University
  23.     612 West 115th Street
  24.     New York NY  10025-7799  USA
  25.     Telephone: +1 (212) 854-3703
  26.     Email: kermit-orders@columbia.edu
  27.     Web: http://www.columbia.edu/kermit/
  28.  
  29.   The CKERMIT2.TXT file contains supplementary info for C-Kermit 7.0 to be
  30.   used until the 3rd edition of the manual is ready.
  31.  
  32.  
  33. CONTENTS
  34.  
  35.  1. OVERVIEW
  36.  2. INSTALLING FROM PACKAGES
  37.  3. INSTALLING PREBUILT BINARIES
  38.  4. BUILDING FROM SOURCE CODE
  39.     4.0. Special Considerations for C-Kermit 7.0
  40.     4.1. The UNIX Makefile
  41.     4.2. The C-Kermit Initialization File
  42.     4.3. The 2.x BSD Makefile
  43.     4.4. The Plan 9 Makefile
  44.     4.5. Makefile Failures
  45.  5. INSTALLING THE KERMIT FILES
  46.  6. INSTALLING UNIX C-KERMIT FROM DOS-FORMAT DISKETTES
  47.  7. CHECKING THE RESULTS
  48.  8. REDUCING THE SIZE OF THE EXECUTABLE PROGRAM IMAGE
  49.  9. UNIX VERSIONS
  50.     9.1. Standards
  51.     9.1.1. POSIX
  52.     9.1.2. ANSI C
  53.     9.1.3. Other Standards
  54.     9.2. Library Issues
  55.     9.3. UNIX File System Peculiarities
  56.     9.4. Hardware Flow Control
  57.     9.5. Terminal Speeds
  58.     9.6. Millisecond Sleeps
  59.     9.7. Nondestructive Input Buffer Peeking
  60.     9.8. Other System-Dependent Features
  61.     9.9. Terminal Interruption
  62. 10. DIALING OUT AND COORDINATING WITH UUCP
  63. 11. RUNNING UNIX C-KERMIT SETUID OR SETGID
  64. 12. CONFIGURING UNIX WORKSTATIONS
  65. 13. BIZARRE BEHAVIOR AT RUNTIME
  66. 14. CRASHES AND CORE DUMPS
  67. 15. SYSLOGGING
  68. 16. SECURITY OPTIONS
  69.  
  70.  
  71. 1. OVERVIEW
  72.  
  73. This file contains UNIX-specific information.  A lot of it.  Unlike most
  74. other packages, C-Kermit tries very hard to be portable to every UNIX variety
  75. (and every release of each one) known to exist, including many that are quite
  76. old, as well as to other platforms like VMS, AOS/VS, VOS, OS-9, the BeBox,
  77. the Amiga, etc.
  78.  
  79. Since C-Kermit gets so deeply into the file system, i/o system, and other
  80. areas that differ radically from one UNIX platform to the next, this means
  81. that a lot can go wrong when you try to install C-Kermit on (for example) a
  82. new release of a particular variety of UNIX, in which certain things might
  83. have changed that C-Kermit depended upon.
  84.  
  85. This file concentrates on installation.  For a description of general
  86. configuration options for C-Kermit, please read the file ckccfg.txt.  For
  87. troubleshooting after installation, see the files ckcbwr.txt and ckubwr.txt.
  88. The latter, in particular, contains lots of information on lots of specific
  89. UNIX platforms.  If you want to work on the source code, see the C-Kermit
  90. Program Logic Manual, ckcplm.txt.
  91.  
  92. You may install C-Kermit:
  93.  
  94.  . From an "install package", if one is available.
  95.  . As a prebuilt binary, if available, plus accompanying text files.
  96.  . By building from source code.
  97.  
  98.  
  99. 2. INSTALLING FROM PACKAGES
  100.  
  101. Various UNIX varieties -- Red Hat Linux, Solaris, etc -- now incorporate the
  102. idea of "install packages", and many users expect to find all new applications
  103. in this format.  A selection of install packages might be available for any
  104. given release of C-Kermit, but there is a tradeoff between convenience and
  105. safety.  UNIX presents several notable problems to the builder of install
  106. packages:
  107.  
  108.  a. Since C-Kermit is portable to many non-UNIX platforms (VMS, VOS, AOS/VS,
  109.     etc), some of the files in the C-Kermit distribution do not fit into the
  110.     UNIX application model.  In particular, C-Kermit includes some plain
  111.     text files (described in Section 5) and UNIX has no standard place to
  112.     put such files.  Typical UNIX package managers do not allow for them.
  113.     Where should they go, and how will the user know where to find them?
  114.  
  115.  b. Installation of any program that will be used to make modem calls requires
  116.     some important decisions from the installer regarded security and
  117.     privilege.
  118.  
  119. Item (b) is discussed at length in Section 10 of this document, but the
  120. package-related aspects are also given here.  The basic problem is that UNIX
  121. dialout devices and the UUCP "lock files" that regulate contention for them
  122. (described in Section 10) are protected against "world".  Therefore, the
  123. install procedure must either run as root in order to give the Kermit binary
  124. the required permissions, or else it must open up the permissions on the
  125. devices and lockfile directory.  Otherwise, the Kermit program just installed
  126. WILL NOT WORK for dialing out.
  127.  
  128. Thus, a well-crafted installation procedure should present the options and
  129. allow the installer to choose:
  130.  
  131.  a. Check the permissions of the lockfile directory and the dialout devices.
  132.     If they do not allow unprivileged R/W access, then:
  133.  
  134.  b. "Your UUCP lockfile directory and/or dialout devices require privilege
  135.     to access.  You must either change their permissions or install Kermit
  136.     with privileges."
  137.  
  138.  c. "If you wish to install Kermit with privileges, it will be given the
  139.     same owner, group, and permissions as the cu program so it can use the
  140.     dialout devices."
  141.  
  142.  d. If they choose (c) but the user is not root, give message that the
  143.     install procedure can be run only by root and then quit.
  144.  
  145. The Kermit Project does not necessarily have the resources or the expertise
  146. to make install packages for any (and certainly not all) UNIX (and other)
  147. platforms.  Most install packages, therefore, are contributed by others, and
  148. they do not necessarily follow the guidelines given above.
  149.  
  150. If you are an end user who has obtained a C-Kermit install package for a
  151. particular platform, you should be aware that some additional steps might
  152. needed.  Read Section 10 for details.
  153.  
  154.  
  155. 3. INSTALLING PREBUILT BINARIES
  156.  
  157. Hundreds of prebuilt C-Kermit binaries are available on the CDROM in the
  158. BINARY tree, and at our ftp site in the kermit/binaries area (with names
  159. starting with "ck").  To install a prebuilt binary:
  160.  
  161.  a. Rename the binary to "wermit".
  162.  
  163.  b. Follow steps (b) through (e) in Section 4.
  164.  
  165. But first...  Please heed the following cautions:
  166.  
  167.  a. If you pick the wrong one, it won't work (or worse).
  168.  
  169.  b. Even when you pick the appropriate binary, it still might not work due
  170.     to shared-library mismatches, etc. (see Section 4.0).
  171.  
  172.  c. Don't expect a binary built on or for version "n" of your OS to work
  173.     on version "m" (where m < n).  However, it is usually safe to run a
  174.     binary built on (or for) an older OS release on a newer one.
  175.  
  176.  
  177. 4. BUILDING FROM SOURCE CODE
  178.  
  179. C-Kermit is designed to be built and used on as many platforms as possible:
  180. UNIX and non-UNIX, old and new (and ancient), ANSI C and K&R.  The UNIX
  181. version does not use or depend on any external tools for building except the
  182. "make" utility, the C compiler, and the linker.  It does not use any automated
  183. configuration tools such as configure, autoconf, automake, libtool, etc.
  184. Everything in C-Kermit has been built by hand based on direct experience or
  185. reports from users.
  186.  
  187. The C-Kermit makefile contains the rules for building the program for each of
  188. the hundreds of different kinds of UNIX systems that C-Kermit attempts to
  189. support.  It covers all UNIX variations since about 1980 -- pretty much
  190. everything after UNIX V6.  Separate makefiles are used for Plan 9 and 2.x BSD.
  191.  
  192. Prerequisites:
  193.  
  194.  . The C compiler, linker, and make program must be installed.
  195.  . The C libraries and header files must be installed (*).
  196.  . The C-Kermit source code and makefile in your current directory.
  197.  . The C-Kermit text files (Section 5) in your current directory.
  198.  
  199. (*) This is becoming problematic in this new age of "selective installs"
  200.     e.g. of Linux packages.  C-Kermit builds will often fail because replying
  201.     "no" to some obscure Linux installation option will result in missing
  202.     libraries or header files.
  203.  
  204. Plus:
  205.  
  206.  . For TCP/IP networking support, the sockets library and related header
  207.    files must be installed.
  208.  
  209.  . For the curses-based fullscreen file-ransfer display, the curses or
  210.    ncurses header file(s) and library, and probably also the termcap and/or
  211.    termlib library.  Note that the names and locations of these files and
  212.    libraries are likely to change capriciously with every new release of your
  213.    UNIX product.  If you discover that the C-Kermit build procedure fails
  214.    because your curses and/or termxxx headers or libraries are not named or
  215.    located as expected, please let us know.  In the meantime, work around by
  216.    installing symlinks.
  217.  
  218.  . IMPORTANT: Modern Linux distributions might give you the choice during
  219.    installation of whether to install the "ncurses development package"
  220.    (perhaps called "ncurses-devel").  If you did not install it, you won't
  221.    be able to build C-Kermit with curses support included.  In this case,
  222.    either go back and install ncurses, or else choose (or create) a
  223.    non-curses makefile target for your platform.  To install the ncurses
  224.    developers tools in Red Hat Linux, do:
  225.  
  226.      mount redhat cdrom
  227.      goto RedHat/RPMS
  228.      rpm -ivh ncurses-devel*.rpm
  229.      or to have the exact name ls ncurse* and load as
  230.      rpm -ivh filename
  231.      then leave the cdrom and unmount it.
  232.  
  233. Directions:
  234.  
  235. The makefile might need to be renamed from ckuker.mak to makefile.
  236.  
  237.  a. Type "make xxx" where xxx is the name of the makefile target most
  238.     appropriate to your platform, e.g. "make linux", "make aix43", etc.  Read
  239.     the comments at the top of the makefile for a complete list of available
  240.     targets (it's a long list).
  241.  
  242.  b. Test the resulting 'wermit' file (see Section 7 for suggestions).
  243.     If it's OK, proceed; otherwise notify us.
  244.  
  245.  c. Rename the 'wermit' file to 'kermit', copy it to the desired binary
  246.     directory (such as /usr/local/bin or /opt/something), and if it is to be
  247.     used for dialing out, give it the same owner, group, and permissions as
  248.     the 'cu' program (IMPORTANT: read Sections 10 and 11 for details).
  249.  
  250.  d. Install the man page, ckuker.nr, with your local man pages.
  251.  
  252.  e. Install the accompanying text files (see Section 5).
  253.  
  254. Steps (c) through (e) can be accomplished using the 'install' target in the
  255. makefile.  Directories are specified by the following variables:
  256.  
  257.  Name        Default
  258.   BINDIR      /usr/local/bin
  259.   MANDIR      /usr/man/manl
  260.   MANEXT      l (that's letter "l" for "local", not digit 1)
  261.   INFODIR     /usr/local/doc/kermit
  262.  
  263. To use the defaults, just type "make install".  You can override any of the
  264. defaults on the 'make' command line, e.g.:
  265.  
  266.   make "INFODIR=/usr/share/lib/kermit" install
  267.  
  268. The 'install' target does not attempt to set Kermit's owner, group, and
  269. permissions to allow dialing out.  This requires privileges and open eyes.
  270. Please read Sections 10 and 11 below, make the necessary decisions, and then
  271. implement them by hand as described in those sections.
  272.  
  273.  
  274. 4.0. Special Considerations for C-Kermit 7.0
  275.  
  276. (Also see ckccfg.txt Section 8.)
  277.  
  278. Lots of new features have been added, requiring access to new symbols, APIs,
  279. libraries, etc, and this will no doubt cause problems in compiling, linking,
  280. or execution on platforms where 6.0 and earlier built without incident.  This
  281. section contains all we know as of the date of this file.
  282.  
  283. The first category concerns the new Kermit Service Daemon (IKSD; see separate
  284. iksd.txt file for details):
  285.  
  286. The wtmp File
  287.   When C-Kermit is started as an IKSD (under inetd), it makes syslog and wtmp
  288.   entries, and also keeps its own ftpd-like log.  The code assumes the wtmp
  289.   log is /var/log/wtmp on Linux and /usr/adm/wtmp elsewhere.  No doubt this
  290.   assumption will need adjustment.  Use -DWTMPFILE=path to override at compile
  291.   time (there is also a runtime override).  See iksd.txt for details.
  292.  
  293. UTMP, utsname(), etc.
  294.   C-Kermit 7.0 gets as much info as it can about its job -- mainly for IKSD
  295.   logging -- from utmp.  But of course utmp formats and fields differ, and
  296.   for that matter, there can be two different header files, <utmp.h> and
  297.   <utmpx.h>.  Look for HAVEUTMPX and HAVEUTHOST in ckufio.c, let me know of
  298.   any needed adjustments.
  299.  
  300. Password lookup
  301.   IKSD also needs to authenticate incoming users against the password list.
  302.   In some cases, this requires the addition of -lcrypt (e.g. in Unixware 2.x).
  303.   In most others, the crypt functions are in the regular C library.  If you
  304.   get "crypt" as an unresolved symbol at link time, add -lcrypt to LIBS.
  305.   If your site has local replacement libraries for authentication, you might
  306.   need a special LIBS clause such as "LIBS= -L/usr/local/lib -lpwent".
  307.  
  308. getusershell()
  309.   This is called by the IKSD at login time to see if a user has been
  310.   "turned off".  But many UNIX platforms lack this function.  In that case,
  311.   you will get unresolved symbol reports at link time for _getusershell,
  312.   _endusershell; to work around, add -DNOGETUSERSHELL.
  313.  
  314. initgroups()
  315.   This is called by IKSD after successful authentication.  But some platforms
  316.   do not have this function, so obviously it can't be called there, in which
  317.   case add -DNOINITGROUPS.
  318.  
  319. setreuid(), setregid() not found or "deprecated"
  320.   Find out what your UNIX variety wants you to use instead, and make
  321.   appropriate substitutions in routine zvpass(), module ckufio.c.
  322.  
  323. printf()
  324.   IKSD installs a printf() substitute to allow redirection of printf-like
  325.   output to the connection.  However, this can conflict with some curses
  326.   libraries.  In this case, separate binaries must be built for IKSD and
  327.   non-IKSD use.
  328.  
  329. If you encounter difficulties with any of the above, and you are not
  330. interested in running C-Kermit as an IKSD, then simply add NOIKSD to CFLAGS
  331. and rebuild.  Example:
  332.  
  333.   make sco286
  334.   (get lots of errors)
  335.   make clean
  336.   make sco286 "KFLAGS=-DNOIKSD"
  337.  
  338. Some non-IKSD things to watch out for:
  339.  
  340. Return type of main()
  341.   The main() routine is in ckcmai.c.  If you get complaints about "main:
  342.   return type is not blah", define MAINTYPE on the CC command line, e.g.
  343.   'make xxx "KFLAGS=-DMAINTYPE=blah"' (where "blah" is int, long, or whatever).
  344.   If the complaint is "Attempt to return a value from a function of type void"
  345.   then add -DMAINISVOID:  'make xxx "KFLAGS=-DMAINISVOID"'
  346.  
  347. DNS Service Records
  348.   This feature allows a remote host to redirect C-Kermit to the appropriate
  349.   socket for the requested service; e.g. if C-Kermit requests service
  350.   "telnet" and the host offers Telnet service on port 999 rather than the
  351.   customary port 23.  If you get compile-time complaints about not being
  352.   able to find <resolv.h>, <netdb.h>, or <arpa/nameser.h>, add -DNO_DNS_SRV
  353.   to CFLAGS.  If you get link-time complaints about unresolved symbols
  354.   res_search or dn_expand, try adding -lresolve to LIBS.
  355.  
  356. \v(ipaddress)
  357.   If "echo \v(ipaddress)" shows an empty string rather than your local
  358.   IP address, add -DCKGHNLHOST to CFLAGS and rebuild.
  359.  
  360. <sys/wait.h>
  361.   If this file can't be found at compile time, add -DNOREDIRECT to CFLAGS.
  362.   This disables the REDIRECT and PIPE commands and anything else that needs
  363.   the wait() system service.
  364.  
  365. syslog()
  366.   C-Kermit can now write syslog records.  Some older platforms might not have
  367.   the syslog facility.  In that case, add -DNOSYSLOG.  Others might have it,
  368.   but require addition of -lsocket to LIBS (SCO OSR5 is an example).  See
  369.   Section 15.
  370.  
  371. putenv()
  372.   If "_putenv" comes up as an undefined symbol, add -DNOPUTENV to CFLAGS
  373.   and rebuild.
  374.  
  375. "Passing arg1 of 'time' from incompatible pointer"
  376.   This is a mess.  See the mass of #ifdefs in the appropriate module,
  377.   ckutio.c or ckufio.c.
  378.  
  379. gettimeofday()
  380.   Wrong number of arguments.  On most platforms, gettimeofday() takes two
  381.   arguments, but on a handful of others (e.g. Motorola System V/88 V4,
  382.   SNI Reliant UNIX 5.43, etc) it takes one.  If your version of gettimeofday()
  383.   is being called with two args but wants one, add -DGTODONEARG.
  384.  
  385. "Assignment makes pointer from integer without a cast"
  386.   This warning might appear in ckufio.c or ckutio (or elsewhere), and usually
  387.   can be traced to the use of a system or library function that returns a
  388.   pointer but that is not declared in the system header files even though it
  389.   should be.  Several functions are commonly associated with this error:
  390.    . getcwd(): Add -DDCLGETCWD to CFLAGS and rebuild.
  391.    . popen():  Add -DDCLPOPEN  to CFLAGS and rebuild.
  392.    . fdopen(): Add -DDCLFDOPEN to CFLAGS and rebuild.
  393.  
  394. "Operands of = have incompatible types" (or "Incompatible types in assignment")
  395.   If this comes from ckcnet.c and comes from a statement involving inet_addr(),
  396.   try adding -DINADDRX to CFLAGS.  If that doesn't help, then try adding
  397.   -DNOMHHOST.
  398.  
  399. Complaints about args to get/setsockopt(), getpeername(), getsockname()
  400.   These are all in ckcnet.c.  Different platforms & OS's and versions of the
  401.   same OS change this all the time: int, size_t, unsigned long, etc.  All the
  402.   affected variables are declared according to #ifdefs within ckcnet.c, so
  403.   find the declarations and adjust the #ifdefs accordingly.
  404.  
  405. size_t
  406.   In case of complaints about "unknown type size_t", add -DSIZE_T=int (or
  407.   other appropriate type) to CFLAGS.
  408.  
  409. 'tz' undefined
  410. Use of undefined enum/struct/union 'timezone'
  411. Left of 'tv_sec' specifies undefined struct/union 'timeval'
  412.   And similar complaints in ckutio.c: Add -DNOGFTIMER and/or -DNOTIMEVAL.
  413.  
  414. Symlinks
  415.   The new built-in DIRECTORY command should show symlinks like "ls -l" does.
  416.   If it does not, check to see if your platform has the lstat() and
  417.   readlink() functions.  If so, add -DUSE_LSTAT and -DCKSYMLINK to CFLAGS
  418.   and rebuild.  On the other hand, if lstat() is unresolved at link time,
  419.   add -DNOLSTAT to CFLAGS.  If readlink() is also unresolved, add -DNOSYMLINK.
  420.  
  421. realpath()
  422.   Link-time complains about realpath() -- find the library in which it resides
  423.   and add it to LIBS (example for Unixware 7.1: "-lcudk70") or add
  424.   -DNOREALPATH to CFLAGS and rebuild.
  425.  
  426. Failure to locate header file <term.h>
  427.   Usually happens on Linux systems that have the C compiler installed,
  428.   but not the ncurses package (see comments about selective installs above).
  429.   Go back and install ncurses, or use "make linuxnc" (Linux No Curses).
  430.  
  431. "Can't find shared library libc.so.2.1"
  432. "Can't find shared library libncurses.so.3.0", etc...
  433.   You are trying to run a binary that was built on a computer that has
  434.   different library versions than your computer, and your computer's
  435.   loader is picky about library version numbers.  Rebuild from source
  436.   on your computer.
  437.  
  438. Time (struct tm) related difficulties:
  439.   Errors like the following:
  440.  
  441.     "ckutio.c", line 11994: incomplete struct/union/enum tm: _tm
  442.     "ckutio.c", line 11995: error: cannot dereference non-pointer type
  443.     "ckutio.c", line 11995: error: assignment type mismatch
  444.     "ckutio.c", line 11997: warning: using out of scope declaration: localtime
  445.     "ckutio.c", line 11997: error: unknown operand size: op "="
  446.     "ckutio.c", line 11997: error: assignment type mismatch
  447.     "ckutio.c", line 11998: error: undefined struct/union member: tm_year
  448.     "ckutio.c", line 12000: error: undefined struct/union member: tm_mon
  449.     "ckutio.c", line 12001: error: undefined struct/union member: tm_mday
  450.     "ckutio.c", line 12002: error: undefined struct/union member: tm_hour
  451.     "ckutio.c", line 12003: error: undefined struct/union member: tm_min
  452.     "ckutio.c", line 12004: error: undefined struct/union member: tm_sec
  453.  
  454.   are due to failure to include the appropriate time.h header files.  UNIX
  455.   platforms generally have one or more of the following: <time.h>,
  456.   <sys/time.h>, and <sys/timeb.h>.  Any combination of these might be
  457.   required.  Defaults are set up for each makefile target.  The defaults can
  458.   be corrected on the CC command line by adding the appropriate definition
  459.   from the following list to CFLAGS:
  460.  
  461.     -DTIMEH         Include <time.h>
  462.     -DNOTIMEH       Don't include <time.h>
  463.     -DSYSTIMEH      Include <sys/time.h>
  464.     -DNOSYSTIMEH    Don't include <sys/time.h>
  465.     -DSYSTIMEBH     Include <sys/timeb.h>
  466.     -DNOSYSTIMEBH   Don't include <sys/timeb.h>
  467.  
  468.   Note that <sys/timeb.h> is relatively scarce in the System V and POSIX
  469.   environments; the only platform of recent vintage where it is still used is
  470.   OSF/1 and its derivatives (Digital UNIX and Tru64 UNIX).
  471.  
  472. Struct timeval and/or timezone not declared:
  473.   In some cases, merely including the appropriate time.h header files is still
  474.   not enough.  POSIX.1 does not define the timeval struct, and so the items we
  475.   need from the header are protected against us by #ifndef _POSIX_SOURCE or
  476.   somesuch.  In this case, we have to declare the timeval (and timezone)
  477.   structs ourselves.  To force this, include -DDCLTIMEVAL in CFLAGS.
  478.  
  479. Warnings about dn_expand() Argument #4
  480.   WARNING: argument is incompatible with prototyp.  It's the old char versus
  481.   unsigned char stupidity again.  Try to find a compiler switch like GCC's
  482.   "-funsigned-char".  Failing that, add -DCKQUERYTYPE=xxx to CFLAGS, where
  483.   xxx is whatever 'man dn_expand' tells you the type of the 4th argument
  484.   should be (presumably either char or unsigned char; in the latter case use
  485.   CHAR to avoid confusion caused by multiple words.
  486.  
  487. Switch Table Overflow (in ckouni.c)
  488.   Add -DNOUNICODE to CFLAGS.
  489.  
  490. Compile-time warnings about ck_out() or tgetstr() or tputs():
  491.   Easy solution: Add -DNOTERMCAP to CFLAGS.  But then you lose the SCREEN
  492.   function.  Real solution:  Try all different combinations of the following
  493.   CFLAGS:
  494.          -DTPUTSARGTYPE=char    -DTPUTSFNTYPE=int
  495.          -DTPUTSARGTYPE=int     -DTPUTSFNTYPE=void
  496.  
  497.   Until the warnings go away, except maybe "ck_outc: return with a value in
  498.   a function returning void", and in that case also add -DTPUTSISVOID.
  499.  
  500. "Passing arg 1 of to tputs() makes pointer from integer without a cast":
  501.   Add -DTPUTSARG1CONST to CFLAGS.
  502.  
  503. "Undefined symbol: dup2"
  504.   Add -DNOZEXEC to CFLAGS.
  505.  
  506. "header file 'termcap.h' not found"
  507.   Add -DNOHTERMCAP to CFLAGS.
  508.  
  509. Other difficulties are generally of the "where is curses.h and what is it
  510. called this week?" variety (most easily solved by making symlinks in the
  511. include and lib directories), or overzealous complaints regarding type
  512. mismatches in function calls because of the totally needless and silly
  513. signed versus unsigned char conflict (*), etc.  In any case, please send any
  514. compilation or linking warnings or errors to the author, preferably along
  515. with fixes.
  516.  
  517. (*) C-Kermit does not use the signed property of chars at all anywhere,
  518.     ever.  So if all chars and char *'s can be made unsigned at compile
  519.     time, as they can in gcc with "-funsigned-char", they should be.
  520.  
  521. IMPORTANT: If you find any of these hints necessary for a particular make
  522. target (or you hit upon others not listed here), PLEASE SEND A REPORT TO:
  523.  
  524.   kermit-support@columbia.edu.
  525.  
  526. 4.1. The UNIX Makefile
  527.  
  528. If your distribution does not contain a file with this name, then
  529. rename the file called ckuker.mak to makefile:
  530.  
  531.   mv ckuker.mak makefile
  532.  
  533. and then you type "make xxx", where xxx is the system you want to build
  534. C-Kermit for.  These are listed in the comments at the top of the makefile.
  535. For example, to build C-Kermit for Linux, type:
  536.  
  537.   make linux
  538.  
  539. The makefile is quite long, and at least two versions of UNIX, SCO Xenix/286
  540. and 2.x BSD, cannot cope with its length.  An attempt to "make sco286" gives
  541. the message "Make: Cannot alloc mem for env..  Stop".  Solution: edit away
  542. some or all of the nonrelevant material from the makefile.   (A separate
  543. version of the makefile is provided for BSD 2.x: ckubs2.mak but C-Kermit 7.0
  544. can't be build for BSD 2.x -- it has simply grown too large.)
  545.  
  546. Some make programs reportedly cannot handle continued lines (lines ending
  547. in backslash (\)).  If you have a problem with the makefile, try editing the
  548. makefile to join the continued lines (remove the backslashes and the following
  549. linefeed).
  550.  
  551. Other makefile troubles may occur because tabs in the makefile have somehow
  552. been converted to spaces.  Spaces and tabs are distinct in UNIX makefiles.
  553.  
  554. Similarly, carriage returns might have been added to the end of each line,
  555. which also proves confusing to most UNIX versions of make.
  556.  
  557. Check to see if there are comments about your particular version in its
  558. makefile entry itself.  In a text editor such as EMACS or VI, search for the
  559. make entry name followed by a colon, e.g. "linux:" (if you really are building
  560. C-Kermit for Linux, do this now).
  561.  
  562. Check to see if there are comments about your particular version in the
  563. ckubwr.txt file.
  564.  
  565. If you have trouble with building ckwart.c, or running the resulting wart
  566. preprocessor program on ckcpro.w:
  567.  
  568.   1. Just "touch" the ckcpro.c file that comes in the distribution and
  569.      then give the "make" command again, or:
  570.  
  571.   2. Compile ckwart.c "by hand":  cc -o wart ckwart.c, or:
  572.  
  573.   3. Try various other tricks.  E.g. one Linux user reported that that adding
  574.      the "static" switch to the rule for building wart fixed everything:
  575.  
  576.      wart: ckwart.$(EXT)
  577.            $(CC) -static -o wart ckwart.$(EXT) $(LIBS)
  578.  
  579. If your compiler supports a compile-time option to treat ALL chars (and
  580. char *'s, etc) as unsigned, by all means use it -- and send me email to let
  581. me know what it is.
  582.  
  583. To add compilation options (which are explained later in this document) to
  584. your makefile entry without editing the makefile, include "KFLAGS=..." on the
  585. make command line, for example:
  586.  
  587.   make linux KFLAGS=-DNODEBUG
  588.   make bsd "KFLAGS=-DKANJI -DNODEBUG -DNOTLOG -DDYNAMIC -UTCPSOCKET"
  589.  
  590. Multiple options must be separated by spaces.  Quotes are necessary if the
  591. KFLAGS= clause includes spaces.  The KFLAGS are added to the end of the CFLAGS
  592. that are defined in the selected makefile entry.  For example, the "bsd" entry
  593. includes -DBSD4 -DTCPSOCKET, so the second example above compiles Kermit with
  594. the following options:
  595.  
  596.   -DBSD4 -DTCPSOCKET -DKANJI -DNODEBUG -DNOTLOG -DDYNAMIC -UTCPSOCKET
  597.  
  598. (Notice how "-UTCPSOCKET" is used to negate the effect of the "-DTCPSOCKET"
  599. option that is included in the makefile entry.)
  600.  
  601. WARNING: Be careful with KFLAGS.  If you build C-Kermit, change some files,
  602. and then run make again using the same make entry but specifying different
  603. KFLAGS than last time, make won't detect it and you could easily wind up with
  604. inconsistent object modules, e.g. some of them built with a certain option,
  605. others not.  When in doubt, "make clean" first to make sure all your object
  606. files are consistent.  Similarly, if you change CFLAGS, LIBS, or any other
  607. items in the makefile, or you rebuild using a different makefile entry, "make
  608. clean" first.
  609.  
  610. If you create a new makefile entry, use static linking if possible.  Even
  611. though this makes your C-Kermit binary bigger, the resulting binary will be
  612. more portable.  Dynamically linked binaries tend to run only on the exact
  613. configuration and version where they were built; on others, invocation tends
  614. to fail with a message like:
  615.  
  616.   Can't find shared library "libc.so.2.1"
  617.  
  618. 4.2. The C-Kermit Initialization File
  619.  
  620. There are several choices for how to handle the C-Kermit initialization file.
  621.  
  622.  a. The default action is to execute ~/.kermrc (i.e. the ".kermrc" file in
  623.     the user's login directory) upon startup.  But since the initialization
  624.     is standardized, it would be wasteful on multiuser systems to duplicate it
  625.     in every user's home directory.
  626.  
  627.  b. Define a system-wide initialization file (described below).
  628.  
  629.  c. Install the standard initialization file in the system-wide PATH as an
  630.     executable Kerbang script (ckermit2.txt Section 7.19).  Users who want to
  631.     take advantage of the services directory and other features that are
  632.     defined in the standard initialization file can "run" the initialization
  633.     file to get them, whereas those who don't need them can run Kermit
  634.     directly.
  635.  
  636. If you want to define a system-wide initialization file for C-Kermit, rather
  637. than making each user have her/his own copy, define the symbol CK_SYSINI to be
  638. the full pathname of the file, e.g.:
  639.  
  640.   -DCK_SYSINI=\\\"/usr/local/lib/kermit/ckermit.ini\\\"
  641.  
  642. It's best to edit the makefile to add this, because there is no good method
  643. for putting it on the 'make' command line with KFLAGS -- the number of escapes
  644. (\\\\...) for the doublequotes would depend on how deeply the particular make
  645. entry is nested; each level of nesting strips off another layer of escapes.
  646. Here's one example that works, but other targets will be different:
  647.  
  648.   make sunos41 "KFLAGS=-DCK_SYSINI=\\\\\\\"/usr/local/lib/ckermit.ini\\\\\\\""
  649.  
  650. Or, you can define CK_DSYSINI (note "D") to build C-Kermit with its built-in
  651. default name for a system-wide init file, /usr/local/bin/ckermit.ini, or
  652. /usr/share/lib/kermit/ckermit.ini, depending on which version of UNIX it is.
  653. Since no quoting is needed, this one works with KFLAGS, e.g.:
  654.  
  655.   make sunos41c KFLAGS=-DCK_DSYSINI
  656.  
  657. The question arises: if you want C-Kermit to have a system-wide initialization
  658. file, should it take precedence over the user's own?  There are valid reasons
  659. for answering yes or no.  By default, if you build C-Kermit with a system-wide
  660. initialization file, it will take precedence over the user's -- that is, it
  661. will be executed instead of the user's, if the user has one.  You might also
  662. want to set things up so the user's init file is executed if she has one, but
  663. if she doesn't, the system-wide one will be.  Either setup is possible.
  664. Assuming CK_SYSINI is defined, then the following symbols determine the order:
  665.  
  666.   CK_INI_A
  667.     This means the system-wide init file is looked for first; if found, it
  668.     is executed.  If not found, the user's init file is executed.
  669.  
  670.   CK_INI_B
  671.     This means the user's init file is looked for first; if found, it is
  672.     executed.  If not found, the system-wide init file is executed.
  673.  
  674. If CK_SYSINI is defined, but neither CK_INI_A nor CK_INI_B are defined (or
  675. both of them are), then CK_INI_A is assumed.
  676.  
  677. If you build Kermit with CK_SYSINI and CK_INI_A, you can "chain" to the user's
  678. own initialization file (if any) by ending (or starting, depending on the
  679. desired precedence) the system-wide init file with a command like:
  680.  
  681.   if exist \v(home).kermrc take \v(home).kermrc
  682.  
  683. In any case, the initialization file should chain to the user's customization
  684. file, as in this clause from the standard ckermit.ini:
  685.  
  686.   if exist \m(_myinit)  {        ; If it exists,
  687.       echo Executing \m(_myinit)...    ; print message,
  688.       take \m(_myinit)            ; and TAKE the file.
  689.   }
  690.  
  691. 4.3. The 2.x BSD Makefile
  692.  
  693. Use the separate makefile ckubs2.mak.  Read the instructions in that file.
  694. NOTE: C-Kermit 6.0 was probably the last version of C-Kermit that could be
  695. built for 2.x BSD -- it just barely fit with a few bytes to spare into the
  696. maximum overlay model.  More recent versions are larger.  But it might be
  697. possible to make it fit using different overlay arrangements; anybody who
  698. cares is welcome to try.
  699.  
  700. 4.4. The Plan 9 Makefile
  701.  
  702. Use the separate makefile ckpker.mk.
  703.  
  704. 4.5. Makefile Failures
  705.  
  706. First, be sure the source files are stored on your current disk and directory
  707. with the right names (in lowercase).  Second, make sure that the makefile
  708. itself does not contain any lines with leading spaces: indented lines must all
  709. start with horizontal TAB, and no spaces.
  710.  
  711. Then make sure that your UNIX PATH is defined to find the appropriate compiler
  712. for your makefile entry.  For example, on SunOS systems, "make sunos41" builds
  713. C-Kermit for the BSD environment, and assumes that /usr/ucb/cc will be used
  714. for compilation and linking.  If your PATH has /usr/5bin ahead of /usr/ucb,
  715. you can have problems at compile or link time (a commonly reported symptom is
  716. the inability to find "ftime" during linking).  Fix such problems by
  717. redefining your UNIX PATH, or by specifying the appropriate "cc" in CC=
  718. and CC2= statements in your makefile entry.
  719.  
  720. During edits 166-167, considerable effort went into making C-Kermit compilable
  721. by ANSI C compilers.  This includes prototyping all of C-Kermit's functions,
  722. and including the ANSI-defined system header files for system and library
  723. functions, as defined in K & R, second edition: <string.h>, <stdlib.h>,
  724. <unistd.h> (except in NeXTSTEP this is <libc.h>), and <sys/stdtypes.h>.  If
  725. you get warnings about any of these header files not being found, or about
  726. argument mismatches involving pid_t, uid_t, or gid_t, look in ckcdeb.h and
  727. make amendments.  C-Kermit assumes it is being compiled by an ANSI-compliant C
  728. compiler if __STDC__ is defined, normally defined by the compiler itself.  You
  729. can force ANSI compilation without defining __STDC__ (which some compilers
  730. won't let you define) by including -DCK_ANSIC on the cc command line.
  731.  
  732. On the other hand, if your compiler defines __STDC__ but still complains about
  733. the syntax of Kermit's function prototypes, you can disable the ANSI-style
  734. function prototyping by including -DNOANSI on the command line.
  735.  
  736. For SCO OpenServer, UNIX, ODT, and XENIX compilations, be sure to pick the
  737. most appropriate makefile entry, and be sure you have installed an SCO
  738. development system that is keyed to your exact SCO operating system release,
  739. down to the minor version (like 2.3.1).
  740.  
  741. Also note that SCO distributes some of its libraries in encrypted form, and
  742. they must be decrypted before C-Kermit can be linked with them.  If not, you
  743. might see a message like:
  744.  
  745.   ld: file /usr/lib/libsocket.a is of unknown type: magic number = 6365
  746.  
  747. To decrypt, you must supply a key (password) that came with your license.
  748. Call SCO for further info.
  749.  
  750. If your compiler uses something other than int for the pid (process id) data
  751. type, put -DPID_T=pid_t or whatever in your CFLAGS.
  752.  
  753. If you get complaints about unknown data types uid_t and gid_t, put
  754. -DUID_T=xxx -DGID_T=yyy in your CFLAGS, where xxx and yyy are the appropriate
  755. types.
  756.  
  757. If your compilation fails because of conflicting or duplicate declarations for
  758. sys_errlist, add -DNDSYSERRLIST to CFLAGS.
  759.  
  760. If your compilation dies because getpwnam() is being redeclared (or because
  761. of "conflicting types for getwpnam"), add -DNDGPWNAM to your CFLAGS.
  762. If that doesn't work, then add -DDCGPWNAM to your CFLAGS (see ckufio.c around
  763. line 440).
  764.  
  765. If the compiler complains about the declaration of getpwnam() during an ANSI C
  766. compilation, remove the declaration from ckufio.c or change the argument in
  767. the prototype from (char *) to (const char *).
  768.  
  769. If you get complaints that getpwuid() is being called with an improper type,
  770. put -DPWID_T=xx in your CFLAGS.
  771.  
  772. If you get compile-time warnings that t_brkc or t_eofc (tchars structure
  773. members, used in BSD-based versions) are undefined, or structure-member-
  774. related warnings that might be traced to this fact, add -DNOBRKC to CFLAGS.
  775.  
  776. If you get a linker message to the effect that _setreuid or _setregid is not
  777. defined, add -DNOSETREU to CFLAGS, or add -DCKTYP_H=<blah> to CFLAGS to make
  778. C-Kermit read the right <types.h>-kind-of-file to pick up these definitions.
  779.  
  780. If you get a message that _popen is undefined, add -DNOPOPEN to CFLAGS.
  781.  
  782. If you get a complaint at compile time about an illegal pointer-integer
  783. combination in ckufio.c involving popen(), or at link time that _popen is an
  784. undefined symbol, add the declaration "FILE *popen();" to the function zxcmd()
  785. in ckufio.c (this declaration is supposed to be in <stdio.h>).  If making this
  786. change does not help, then apparently your UNIX does not have the popen()
  787. function, so you should add -DNOPOPEN to your make entry, in which case
  788. certain functions involving "file" i/o to the standard input and output of
  789. subprocesses will not be available.
  790.  
  791. If your linker complains that _getcwd is undefined, you can add a getcwd()
  792. function to ckufio.c, or add it to your libc.a library using ar:
  793.  
  794. #include <stdio.h>
  795.  
  796. char *
  797. getcwd(buf,size) char *buf; int size; {
  798. #ifndef NOPOPEN
  799. #ifdef DCLPOPEN
  800.     FILE *popen();
  801. #endif
  802.     FILE *pfp;
  803.  
  804.     if (!buf) return(NULL);
  805.     if (!(pfp = popen("pwd","r"))) return(NULL);
  806.     fgets(buf,size-2,pfp);
  807.     pclose(pfp);
  808.     buf[strlen(buf)-1] = '\0';
  809.     return((char *)buf);
  810. #else
  811.     buf[0] = '\0';
  812.     return(NULL);
  813. #endif /* NOPOPEN */
  814. }
  815.  
  816. #ifdef NOPOPEN
  817. FILE *popen(s,t) char *s,*t; {
  818.     return(NULL);
  819. }
  820. #endif /* NOPOPEN */
  821.  
  822. If you get complaints about NPROC having an invalid value, add a valid
  823. definition for it (depends on your system), as in the cray entry.
  824.  
  825. If you get some symbol that's multiply defined, it probably means that a
  826. variable name used by Kermit is also used in one of your system libraries that
  827. Kermit is linked with.  For example, under PC/IX some library has a variable
  828. or function called "data", and the variable "data" is also used extensively by
  829. Kermit.  Rather than edit the Kermit source files, just put a -D in the make
  830. entry CFLAGS to change the Kermit symbol at compile time.  In this example, it
  831. might be -Ddata=datax.
  832.  
  833. Some symbol is defined in your system's header files, but it produces
  834. conflicts with, or undesired results from, Kermit.  Try undefining the symbol
  835. in the makefile entry's CFLAGS, for example -UFIONREAD.
  836.  
  837. Some well-known symbol is missing from your system header files.  Try defining
  838. in the makefile entry's CFLAGS, for example -DFREAD=1.
  839.  
  840. You get many warnings about pointer mismatches.  This probably means that
  841. Kermit is assuming an int type for signal() when it should be void, or
  842. vice-versa.  Try adding -DSIG_I (for integer signal()) or -DSIG_V (for void)
  843. to CFLAGS.  Or just include KFLAGS=-DSIG_V (or whatever) in your "make"
  844. command, for example:
  845.  
  846.   make bsd KFLAGS=-DSIG_V
  847.  
  848. You get many messages about variables that are declared and/or set but never
  849. used.  It is difficult to avoid these because of all the conditional
  850. compilation in the program.  Ignore these messages.
  851.  
  852. Some of C-Kermit's modules are so large, or contain so many character string
  853. constants, or are so offensive in some other way, that some C compilers give
  854. up and refuse to compile them.  This is usually because the -O (optimize)
  855. option is included in the make entry.  If this happens to you, you can
  856. (a) remove the -O option from the make entry, which will turn off the
  857. optimizer for ALL modules; or (b) compile the offending module(s) by hand,
  858. including all the switches from make entry except for -O, and then give the
  859. appropriate "make" command again; or (c) increase the value of the -Olimit
  860. option, if your compiler supports this option; or (d) change the makefile
  861. entry to first compile each offending module explicitly without optimization,
  862. then compile the others normally (with optimization), for example:
  863.  
  864. #Fortune 32:16, For:Pro 2.1 (mostly like 4.1bsd)
  865. ft21:
  866.     @echo 'Making C-Kermit $(CKVER) for Fortune 32:16 For:Pro 2.1...'
  867.     $(MAKE) ckuusx.$(EXT) "CFLAGS= -DNODEBUG -DBSD4 -DFT21 -DNOFILEH \
  868.     -SYM 800 \ -DDYNAMIC -DNOSETBUF -DCK_CURSES $(KFLAGS) -DPID_T=short"
  869.     $(MAKE) ckuxla.$(EXT) "CFLAGS= -DNODEBUG -DBSD4 -DFT21 -DNOFILEH \
  870.     -SYM 800 \ -DDYNAMIC -DNOSETBUF -DCK_CURSES $(KFLAGS) -DPID_T=short"
  871.     $(MAKE) ckudia.$(EXT) "CFLAGS= -DNODEBUG -DBSD4 -DFT21 -DNOFILEH \
  872.     -SYM 800 \ -DDYNAMIC -DNOSETBUF -DCK_CURSES $(KFLAGS) -DPID_T=short"
  873.     $(MAKE) wermit "CFLAGS= -O -DNODEBUG -DBSD4 -DFT21 -DNOFILEH -SYM 800 \
  874.     -DDYNAMIC -DNOSETBUF -DCK_CURSES $(KFLAGS) -DPID_T=short" \
  875.     "LNKFLAGS= -n -s" "LIBS= -lcurses -ltermcap -lv -lnet"
  876.  
  877. As an extreme example, some compilers (e.g. gcc on the DG AViiON) have been
  878. known to dump core when trying to compile ckwart.c with optimization.  So just
  879. do this one "by hand":
  880.  
  881.   cc -o wart ckwart.c
  882.  
  883. or:
  884.  
  885.   touch ckcpro.c
  886.  
  887. and then give the "make" command again.
  888.  
  889. Speaking of wart, it is unavoidable that some picky compilers might generate
  890. "statement unreachable" messages when compiling ckcpro.c.  Unreachable
  891. statements can be generated by the wart program, which generates ckcpro.c
  892. automatically from ckcpro.w, which translates lex-like state/input
  893. constructions into a big switch/case construction.
  894.  
  895. Some function in Kermit wreaks havoc when it is called.  Change all
  896. invocations of the function into a macro that evaluates to the appropriate
  897. return code that would have been returned by the function had it been called
  898. and failed, for example: -Dzkself()=0.  Obviously not a good idea if the
  899. function is really needed.
  900.  
  901. If you have just installed SunOS 4.1.2 or 4.1.3, you might find that C-Kermit
  902. (and any other C program) fails to link because of unresolved references from
  903. within libc.  This is because of a mistake in Sun's /usr/lib/shlib.etc files
  904. for building the new libc.  Change the libc Makefile so that the "ld" lines
  905. have "-ldl" at the end.  Change the README file to say "mv xccs.multibyte.
  906. xccs.multibyte.o" and follow that instruction.
  907.  
  908.  
  909. 5. INSTALLING THE KERMIT FILES
  910.  
  911. There is an "install" entry in the makefile, but it is only a sample.  Since
  912. every site has its own layout and requirements, it is better to install the
  913. Kermit files by hand.
  914.  
  915. After you have built and tested the C-Kermit program successfully, you can
  916. discard the object (ck*.o) files, which are no longer needed.  Use "make
  917. clean" to do this.  If you don't need the source files (ck[cuw]*.[cwh]), you
  918. can remove them too.
  919.  
  920. You should install the C-Kermit program in a directory that is in the users'
  921. PATH, but that is not likely to be overwritten when you install a new version
  922. of the operating system.  A good candidate would be the /usr/local/bin/
  923. directory.  Example:
  924.  
  925.   mv wermit /usr/local/bin/kermit
  926.   chmod 775 /usr/local/bin/kermit  <--  But see Section 10.
  927.  
  928. You should also install the man page, which is called ckuker.nr, in the
  929. man page directory for local commands, such as /usr/man/manl/, renamed
  930. appropriately, e.g. to kermit.l.
  931.  
  932. Several text files should be placed in a publicly readable directory, and the
  933. man page should be altered, if necessary (in the FILES section), to point to
  934. that directory.  Suggested directory names are:
  935.  
  936.   /usr/local/doc/kermit/
  937.   /usr/local/lib/kermit/
  938.   /usr/share/lib/kermit/
  939.  
  940. (or any of these without the "/kermit").  Upon startup, C-Kermit checks the
  941. following environment variables whose purpose is to specify the directory
  942. where the C-Kermit text files are, in the following order:
  943.  
  944.   K_INFO_DIRECTORY
  945.   K_INFO_DIR
  946.   KERMITINFO
  947.  
  948. If any of these is defined, C-Kermit checks for the existence of the
  949. ckermit2.txt file (the C-Kermit 7.0 updates documentation).  If not found,
  950. it checks the directories listed above (both with and without the "/kermit")
  951. plus several others to see if they contain the ckermit2.txt file.  If found,
  952. various C-Kermit messages can refer the user to this directory.
  953.  
  954.   READ.ME
  955.     Explanation of the following files.  You can create this file by
  956.     clipping out the following file list.
  957.  
  958.   COPYING.TXT
  959.     Copyright notice, permissions, and disclaimer.
  960.  
  961.   ckermit.ini
  962.     The standard initialization file.  Users should copy this to
  963.     their home directories and rename it to .kermrc.  (In C-Kermit 5A(190)
  964.     and later, you can designate a single copy as the system-wide
  965.     initialization file; details above).
  966.  
  967.   ckermod.ini
  968.     A sample customization file.  Users should copy this file to
  969.     their home directories, make any desired modifications (user- or
  970.     site-specific customizations), and rename it to .mykermrc.
  971.  
  972.   ckermit.kdd
  973.     A sample dialing directory file.
  974.  
  975.   ckermit.knd
  976.     A sample network directory.
  977.  
  978.   ckermit.ksd
  979.     A sample services directory.
  980.  
  981.   ckedemo.ksc
  982.     Macro definitions from "Using C-Kermit".
  983.  
  984.   ckevt.ksc
  985.     Command file to demonstrate special screen effects from "Using C-Kermit".
  986.  
  987.   ckepage.ksc
  988.     A sample script for sending alphanumeric pages.
  989.  
  990.   ckurzsz.ini
  991.     Macros for using rz and sz as external protocols.
  992.  
  993.   ckermit2.txt
  994.     A file listing the updates, changes, and corrections made to C-Kermit
  995.     since publication of "Using C-Kermit".
  996.  
  997.   ckcbwr.txt
  998.     The general C-Kermit "beware" file.
  999.  
  1000.   ckubwr.txt
  1001.     The UNIX-specific C-Kermit beware file.
  1002.  
  1003. We recommend that the C-Kermit initialization file, named ckermit.ini in the
  1004. distribution, be executed by all users, since it defines and sets up certain
  1005. important features, such as the dialing directory, services directory,
  1006. commonly-used macros, etc.  On multiuser systems, it can be put in a common
  1007. place and shared by all users, but this requires building C-Kermit from source
  1008. in a special way, which embeds the full path of common initialization file in
  1009. the program binary, described above.
  1010.  
  1011. Alternatively, each user can copy the ckermit.ini file into her login
  1012. directory and rename it to .kermrc.
  1013.  
  1014. The user's private "customization file" goes in the login directory and is
  1015. called .mykermrc.
  1016.  
  1017.  
  1018. 6. INSTALLING UNIX C-KERMIT FROM DOS-FORMAT DISKETTES
  1019.  
  1020. If you received a DOS-format diskette containing a binary executable C-Kermit
  1021. program plus supporting text files, be sure to chmod +x the executable before
  1022. attempting to run it.
  1023.  
  1024. In version 5A(190) and later, all the text files on the C-Kermit DOS-format
  1025. diskettes are in UNIX format: LF at the end of each line rather than CRLF.
  1026. This means that no conversions are necessary when copying to your UNIX file
  1027. system, and that all the files on the diskette, text and binary, can be copied
  1028. together.  The following comments apply to the DOS-format diskettes furnished
  1029. with version 5A(189) and earlier or to other DOS-format diskettes you might
  1030. have obtained from other sources.
  1031.  
  1032. If you have received C-Kermit on MS-DOS format diskettes (such as those
  1033. distributed by Columbia University), you should make sure that your
  1034. DOS-to-UNIX conversion utility (such as "dosread") both: (1) changes line
  1035. terminators in all files from carriage-return linefeed (CRLF) to just linefeed
  1036. (LF) (such as "dosread -a") and remove any Ctrl-Z's, and (2) that all
  1037. filenames are converted from uppercase to lowercase.  If these conversions
  1038. were not done, you can use the following shell script on your UNIX system to
  1039. do them:
  1040. ---(cut here)---
  1041. #!/bin/sh
  1042. #
  1043. # Shell script to convert C-Kermit DOS-format files into UNIX format.
  1044. # Lowercases the filenames, strips out carriage returns and Ctrl-Z's.
  1045. #
  1046. x=$1 # the name of the source directory
  1047. y=$2 # the name of the target directory if [ $# -lt 2 ]; then
  1048.   echo "usage: $0 source-directory target-directory"
  1049.   exit 1
  1050. fi
  1051. if cd $1 ; then
  1052.   echo "Converting files from $1 to $2"
  1053. else
  1054.   echo "$0: cannot cd to $1"
  1055.   exit 1
  1056. fi
  1057. for i in *; do
  1058.   j=`echo $i | tr 'A-Z' 'a-z'`
  1059.   echo $x/$i =\> $y/$j
  1060.   tr -d '\015\032' < $i > $y/$j
  1061. done
  1062. ---(cut here)---
  1063. Cut out this shell script, save it as "convert.sh" (or any other name you
  1064. prefer), then "chmod +x convert.sh".  Then, create a new, empty directory
  1065. to put the converted files in, and then "convert.sh /xxx /yyy" where /xxx
  1066. is the name of the directory where the PC-format files are, and /yyy is the
  1067. name of the new, empty directory.  The converted files will appear in the
  1068. new directory.
  1069.  
  1070.  
  1071. 7. CHECKING THE RESULTS
  1072.  
  1073. First some quick checks for problems that can be easily corrected by
  1074. recompiling with different options:
  1075.  
  1076. DIRECTORY listing is garbage
  1077.   Permissions, size, and date are random garbage (but the filenames are
  1078.   correct) in a C-Kermit DIRECTORY listing.  On some platforms, the lstat()
  1079.   function is present but simply doesn't work; try adding -DNOLSTAT to CFLAGS
  1080.   and rebuild.  If that doesn't fix it, also add -DNOLINKBITS.  If it's
  1081.   still not fixed, remove -DNOLSTAT and -DNOLINKBITS and add -DNOSYMLINK.
  1082.  
  1083. curses
  1084.   When you make a connection with C-Kermit and transfer files using the
  1085.   fullscreen (curses) file-transfer display, and then get the C-Kermit>
  1086.   prompt back afterwards, do characters echo when you type them?  If not,
  1087.   the curses library has altered the buffering of /dev/tty.  Try rebuilding
  1088.   with KFLAGS=-DCK_NEWTERM.  If it already has -DCK_NEWTERM in CFLAGS, try
  1089.   removing it.  If this doesn't help, then rebuild with -DNONOSETBUF (yes,
  1090.   two NO's).  If none of this works (and you can't fix the code), then either
  1091.   don't use the fullscreen display, or rebuild with -DNOCURSES.
  1092.  
  1093. Ctrl-L or any SCREEN command crashes C-Kermit:
  1094.   Rebuild with -DNOTERMCAP
  1095.  
  1096. No prompt after CONNECT:
  1097.   After escaping back from CONNECT mode, does your C-Kermit> prompt
  1098.   disappear?  (Yet, typing "?" still produces a command list, etc)
  1099.   In that case, add -DCKCONINTB4CB to CFLAGS and rebuild.
  1100.  
  1101. Here is a more thorough checklist can use to tell whether your version of
  1102. C-Kermit was built correctly for your UNIX system, with hints on how to fix
  1103. or work around problems:
  1104.  
  1105.   a. Start C-Kermit (usually by typing "./wermit" in the directory where you
  1106.      ran the makefile).  Do you see the C-Kermit> prompt?  If not, C-Kermit
  1107.      incorrectly deduced that it was running in the background.  The test is
  1108.      in conbgt() in ckutio.c.  If you can fix it for your system, please send
  1109.      in the fix (Hint: read about "PID_T" below).  Otherwise, you can force
  1110.      C-Kermit to foreground mode by starting it with the -z command line
  1111.      option, as in "kermit -z", or giving the interactive command SET
  1112.      BACKGROUND OFF.
  1113.  
  1114.   b. When you type characters at the C-Kermit prompt, do they echo
  1115.      immediately?  If not, something is wrong with concb() and probably the
  1116.      other terminal mode settings routines in ckutio.c.  Be sure you have used
  1117.      the most appropriate make entry.
  1118.  
  1119.   c. At the C-Kermit> prompt, type "send *?".  C-Kermit should list all the
  1120.      files in the current directory.  If not, it was built for the wrong type
  1121.      of UNIX file system.  Details below.  In the meantime, try SET
  1122.      WILDCARD-EXPANSION SHELL as a workaround.
  1123.  
  1124.   d. CD to a directory that contains a variety of files, symlinks, and
  1125.      subdirectories and give a DIRECTORY command at the C-Kermit> prompt. Do
  1126.      the permissions, size, and date appear correct?  If not see Section 4.0.
  1127.  
  1128.   3. Assuming your platform supports long file names, create a file with a
  1129.      long name in your current directory, e.g.:
  1130.  
  1131.      % touch thisisafilewithaveryveryveryveryveryveryveryverylooooooooongname
  1132.  
  1133.      (you might need to make it longer than this, perhaps as long as 257
  1134.      or even 1025 characters).
  1135.  
  1136.      Check with ls to see if your version of UNIX truncated the name.  Now
  1137.      start C-Kermit and type "send thisis<ESC>".  Does Kermit complete the
  1138.      name, showing the same name as ls did?  If not, wrong filesystem.  Read
  1139.      on.
  1140.  
  1141.   f. Make sure that Kermit has the maximum path length right.  Just type
  1142.      SHOW FILE and see what it says about this.  If it is too short, there
  1143.      could be some problems at runtime.  To correct, look in ckcdeb.h to
  1144.      see how the symbol CKMAXPATH is set and make any needed adjustments.
  1145.  
  1146.   g. Send a file to your new Kermit program from a different Kermit program
  1147.      that is known to work.  Is the date/timestamp of the new file identical
  1148.      to the original?  If not, adjustments are needed in zstrdt() in
  1149.      ckufio.c.
  1150.  
  1151.   h. Go to another computer (Computer B) from which you can send files to
  1152.      C-Kermit.  Connect Computer B to the computer (A) where you are testing
  1153.      C-Kermit.  Then:
  1154.  
  1155.   i. Send a file from B to A.  Make sure it transferred OK and was created
  1156.        with the the right name.
  1157.  
  1158.   j. Send a file from B to A, specifying an "as-name" that is very, very
  1159.      long (longer than the maximum name length on computer A).  Check to
  1160.      make sure that the file was received OK and that its name was truncated
  1161.      to Computer A's maximum length.  If not, check the MAXNAMLEN definition
  1162.      in ckufio.c.
  1163.  
  1164.   k. Tell C-Kermit on Computer A to "set receive pathnames relative" and
  1165.      then send it a file from Computer B specifying an as-name that contains
  1166.      several directory segments:
  1167.  
  1168.        send foo dir1/dir2/dir3/foo
  1169.  
  1170.      Check to make sure that dir1/dir2/dir3/foo was created in Computer A's
  1171.      current directory (i.e. that three levels of directories were created).
  1172.  
  1173.   l. Repeat step k, but make each path segment in the pathname longer than
  1174.      Computer A's maximum name length.  Make sure each directory name, and
  1175.      the final filename, were truncated properly.
  1176.  
  1177.   m. Type Ctrl-C (or whatever your UNIX interrupt character is) at the prompt.
  1178.      Do you get "^C..." and a new prompt?  If instead, you get a core dump
  1179.      (this shouldn't happen any more) "rm core" and then rebuild with
  1180.      -DNOCCTRAP added to your CFLAGS.  If it did work, then type another
  1181.      Ctrl-C.  If this does the same thing as the first one, then Ctrl-C
  1182.      handling is OK.  Otherwise, the SIGINT signal is either not getting
  1183.      re-armed (shouldn't happen) or is being masked off after the first time
  1184.      it is caught, in which case, if your UNIX is POSIX-based, try rebuilding
  1185.      C-Kermit with -DCK_POSIX_SIG.
  1186.  
  1187.   n. Type Ctrl-Z (or whatever your UNIX suspend character is) to put C-Kermit
  1188.      in the background.  Did it work?  If nothing happened, then (a) your
  1189.      version of UNIX does not support job control, or (b) your version of
  1190.      C-Kermit was probably built with -DNOJC.  If your session became totally
  1191.      frozen, then you are probably running C-Kermit on a UNIX version that
  1192.      supports job control, but under a shell that doesn't.  If that's not the
  1193.      case, look in the congm() and psuspend() routines in ckutio.c and see if
  1194.      you can figure out what's wrong.  If you can't, rebuild with -DNOJC.
  1195.  
  1196.   o. Give a SET LINE command for a dialout device, e.g. "set line /dev/tty00".
  1197.      If you got some kind of permission or access denied message, go read
  1198.      Section 10 and then come back here.
  1199.  
  1200.   p. After giving a successful SET LINE command, type "show comm" to
  1201.      see the communication parameters.  Do they make sense?
  1202.  
  1203.   q. Type "set speed ?" and observe the list of available speeds.  Is it
  1204.        what you expected?  If not, see Section 2 of ckccfg.txt.
  1205.  
  1206.   r. Give a SET SPEED command to change the device's speed.  Did it work?
  1207.        (Type "show comm" again to check.)
  1208.  
  1209.   s. Try dialing out: SET MODEM TYPE <whatever>, SET LINE <whatever>, SET
  1210.      SPEED <whatever>, DIAL <phone-number>.  If it doesn't work, keep
  1211.      reading.  After dialing, can you REDIAL?
  1212.  
  1213.   t. If your version was built with TCP/IP network support, try the TELNET
  1214.      command.
  1215.  
  1216.   u. Transfer some files in remote mode on incoming asynchronous serial
  1217.      (direct or modem) connections, and on incoming network (telnet, rlogin,
  1218.      terminal server) connections.  If you get lots of errors, try different
  1219.      SET FLOW settings on the remote Kermit program.
  1220.  
  1221.   v. Establish a serial connection from C-Kermit to another computer (direct
  1222.      or dialed) and transfer some files.  If you have network support, do the
  1223.      same with a network connection.
  1224.  
  1225.   x. If your version was built with fullscreen file transfer display support,
  1226.      check that it works during local-mode file transfer.  Also, check
  1227.      C-Kermit's operation afterwards: is the echoing funny?  etc etc.  If
  1228.      there are problems, see Section 4.
  1229.  
  1230.   y. If your version was built with script programming language support,
  1231.      TAKE the ckedemo.ksc file to give it a workout.
  1232.  
  1233.   z. Does C-Kermit interlock correctly with UUCP-family programs (cu, tip,
  1234.      uucp, etc)?  If not, read the section DIALING OUT AND COORDINATING WITH
  1235.      UUCP below.
  1236.  
  1237.   A. Modem signals...  Give a SET LINE command to a serial device and then
  1238.      type the SHOW MODEM command.  If it says "Modem signals unavailable in
  1239.      this version of Kermit", then you might want to look at the ttgmdm()
  1240.      routine in ckutio.c and add the needed code -- if indeed your version of
  1241.      UNIX provides a way to get modem signals (some don't; e.g. modem signals
  1242.      are a foreign concept to POSIX, requiring politically incorrect
  1243.      workarounds).
  1244.  
  1245.      If it says "Modem signals unavailable", then it is likely that the API
  1246.      for getting modem signals is provided, but it doesn't actually do
  1247.      anything (e.g. ioctl(ttyfd,TIOCMGET,&x) returns EINVAL).
  1248.  
  1249.      In any case, it still should be able to manipulate the DTR signal.  To
  1250.      test, SET LINE <name-of-dialout-device>, SET MODEM NONE, and HANGUP.
  1251.      The DTR light should go out momentarily.  If it doesn't, see if you can
  1252.      add the needed code for your system to the tthang() routine in ckutio.c.
  1253.  
  1254.      If your version of Kermit has the SET FLOW RTS/CTS command, check to
  1255.      see if it works: give Kermit this command, set your modem for RTS/CTS,
  1256.      transfer some files (using big packet and window sizes) and watch the
  1257.      RTS and CTS lights on the modem.  If they go on and off (and Kermit does
  1258.      not get packet errors), then it works.  If your version of Kermit does
  1259.      not have this command, but your version of UNIX does support hardware
  1260.      flow control, take a look at the tthflow() command in ckutio.c and see
  1261.      if you can add the needed code (see the section on HARDWARE FLOW
  1262.      CONTROL below).
  1263.  
  1264.      (And please send back any added code to the author, so that others can
  1265.      benefit from it and it can be carried forward into future releases.)
  1266.  
  1267.   B. If C-Kermit starts normally and issues its prompt, echoing is normal,
  1268.      etc, but then after returning from a CONNECT session, the prompt no
  1269.      longer appears, try rebuilding with -DCKCONINTB4CB.
  1270.  
  1271.  
  1272. 8. REDUCING THE SIZE OF THE EXECUTABLE PROGRAM IMAGE
  1273.  
  1274.   a. Many of C-Kermit's options and features can be deselected at compile
  1275.      time.  The greatest savings at the least sacrifice in functionality is
  1276.      to disable the logging of debug information by defining NODEBUG during
  1277.      compilation.  See the ckccfg.txt file for further information.
  1278.  
  1279.   b. Use shared libraries rather than static linking.  This is the default
  1280.      on many UNIX systems anyway.  However, executables built for dynamic
  1281.      linking with shared libraries are generally not portable away from the
  1282.      machine they were built on, so this is recommended if the binary is for
  1283.      your use only.
  1284.  
  1285.   c. Most UNIX systems have a "strip" command to remove symbol table
  1286.      information from an executable program image.  "man strip" for further
  1287.      information.  The same effect can be achieved by including "-s" among
  1288.      the link flags when building C-Kermit.
  1289.  
  1290.   d. SCO, Interactive, and some other UNIX versions have an "mcs" command.
  1291.      "mcs -d wermit" can be used to delete the contents of the ".comment"
  1292.      section from the executable program image.
  1293.  
  1294.   e. Many modern optimizers can be instructed to optimize for space rather
  1295.      than execution efficiency.  Check the CFLAGS in the makefile entry,
  1296.      adjust as desired.
  1297.  
  1298.  
  1299. 9. UNIX VERSIONS
  1300.  
  1301. There are several major varieties of UNIX: Bell Laboratories Seventh Edition,
  1302. AT&T System V, Berkeley Standard Distribution (BSD), and POSIX.  Each has
  1303. many, many subvarieties and descendents, and there are also hybrids that
  1304. exhibit symptoms of two or more varieties, plus special quirks of their own.
  1305.  
  1306. Seventh edition versions of C-Kermit include the compile-time option -DV7 in
  1307. the CFLAGS string in the makefile entry.  Various V7-based implementations are
  1308. also supported: -DCOHERENT, -DMINIX, etc.
  1309.  
  1310. AT&T-based versions of UNIX Kermit include the compile-time option -DATTSV
  1311. (standing for AT&T UNIX System V).  This applies to System III and to System V
  1312. up to and including Release 2.  For System V Release 3, the flag -DSVR3 should
  1313. be used instead (which also implies -DATTSV).  This is because the data type
  1314. of signal() and several other functions was changed between SVR2 and SVR3.
  1315. For System V Release 4, include -DSVR4 because of changes in UUCP lockfile
  1316. conventions; this also implies -DSVR3 and -DATTSV.
  1317.  
  1318. For BSD, the flag -BSDxx must be included, where xx is the BSD version
  1319. number, for example BSD4 (for version 4.2 or later, using only 4.2 features),
  1320. -DBSD41 (for BSD 4.1 only), -DBSD43 (for 4.3 or later), -DBSD29 (BSD 2.9
  1321. for DEC PDP-11s).  BSD44 is BSD4.4, which is the basis of FreeBSD,
  1322. NetBSD, OpenBSD, BSDI, and others, and which contains many POSIX features.
  1323.  
  1324. For POSIX, include the flag -DPOSIX.  POSIX defines a whole new set of
  1325. terminal i/o functions that are not found in traditional AT&T or Berkeley
  1326. implementations, and also defines the symbol _POSIX_SOURCE, which is used
  1327. in many system and library header files, mainly to disable non-POSIX features.
  1328.  
  1329. Note (circa 1997): In order to enable serial speeds higher than 38400 bps,
  1330. it is generally necessary to add -DPOSIX (among other things), since the older
  1331. terminal APIs can not accommodate the new speeds -- out o' bits.  But this
  1332. often also means wholesale conversion to POSIX APIs.  In general, just try
  1333. adding -DPOSIX and then see what goes wrong.  Be wary of features
  1334. disappearing: when _POSIX_SOURCE is defined, all sorts of things that were
  1335. perfectly OK before suddenly become politically incorrect -- like reading
  1336. modem signals, doing hardware flow control, etc.  POSIX was evidently not
  1337. designed with serial communication in mind!
  1338.  
  1339. Case in point: In UnixWare 7.0, #define'ing POSIX causes strictness clauses
  1340. in the header files to take effect.  These prevent <sys/time.h> from defining
  1341. the timeval and timezone structs, which are needed for all sorts of things
  1342. (like select()).  Thus, if we want the high serial speeds, we have to
  1343. circumvent the POSIX clauses.
  1344.  
  1345. Similarly in SCO OpenServer R5.0.4 where, again, we must use the POSIX APIs to
  1346. get at serial speeds higher than 38400, but then doing so removes hardware
  1347. flow control -- just when we need it most!  In cases like this, dirty tricks
  1348. are the only recourse (search for SCO_OSR504 in ckutio.c for examples).
  1349.  
  1350. For reasons like this, UNIX implementations tend to be neither pure AT&T nor
  1351. pure BSD nor pure POSIX, but a mixture of two or more of these, with
  1352. "compatibility features" allowing different varieties of programs to be built
  1353. on the same computer.  In general, Kermit tries not to mix & match but to keep
  1354. a consistent repertoire throughout.  However, there are certain UNIX
  1355. implementations that only work when you mix and match.  For example, the
  1356. Silicon Graphics IRIX operating system (prior to version 3.3) is an AT&T UNIX
  1357. but with a BSD file system.  The only way you can build Kermit successfully
  1358. for this configuration is to include -DSVR3 plus the special option -DLONGFN,
  1359. meaning "pretend I was built with -DBSDxx when it's time to compile
  1360. file-related code".  See the "iris" makefile entry.
  1361.  
  1362. 9.1. Standards
  1363.  
  1364. In edits 166-167, C-Kermit was heavily modified to try to keep abreast of new
  1365. standards while still remaining compatible with old versions of C and UNIX.
  1366. There are two new standards of interest: ANSI C (as described in Kernighan and
  1367. Ritchie, "The C Programming Language", Second Edition, Prentice Hall, 1988)
  1368. and POSIX.1 (IEEE Standard 1003.1 and ISO/IEC 9945-1, 1990, "Portable
  1369. Operating System Interface").  These two standards have nothing to do with
  1370. each other: you can build C-Kermit with a non-ANSI compiler for a POSIX
  1371. system, or for a non-POSIX system with with an ANSI compiler.
  1372.  
  1373. 9.1.1. POSIX
  1374.  
  1375. POSIX.1 defines a repertoire of system functions and header files for use by C
  1376. language programs.  Most notably, the ioctl() function is not allowed in
  1377. POSIX; all ioctl() functions have been replaced by device-specific functions
  1378. like tcsetattr(), tcsendbreak(), etc.
  1379.  
  1380. Computer systems that claim some degree of POSIX compliance have made some
  1381. attempt to put their header files in the right places and give them the right
  1382. names, and to provide system library functions with the right names and
  1383. calling conventions.  Within the header files, POSIX-compliant functions are
  1384. supposed to be within #ifdef _POSIX_SOURCE..#endif conditionals, and non-POSIX
  1385. items are not within these conditionals.
  1386.  
  1387. If C-Kermit is built with the -DPOSIX flag, it attempts to configure itself
  1388. for a pure POSIX environment.  It defines _POSIX_SOURCE, it calls only
  1389. POSIX-defined functions, and it includes POSIX-defined header files.
  1390.  
  1391. If Kermit is built with -D_POSIX_SOURCE but not -DPOSIX, C-Kermit must be
  1392. built with one of the -DBSD or -DATTSV flags (or one that implies them), but
  1393. still uses only the POSIX features in the system header files.  This allows
  1394. C-Kermit to be built on BSD or AT&T systems that have some degree of POSIX
  1395. compliance, but still use BSD or AT&T specific features.
  1396.  
  1397. If Kermit is built with neither -D_POSIX_SOURCE nor -DPOSIX, the functions and
  1398. header files of the selected version of UNIX (or VMS, etc) are used according
  1399. to the CFLAGS Kermit was built with.
  1400.  
  1401. The POSIX standard does not define anything about uucp lockfiles.  "make
  1402. posix" uses NO (repeat, NO) lockfile conventions.  If your POSIX-compliant
  1403. UNIX version uses a lockfile convention such as HDBUUCP (see below), use
  1404. the "posix" entry, but include the appropriate lockfile option in your KFLAGS
  1405. on the "make" command line, for example:
  1406.  
  1407.    make posix "KFLAGS=-DHDBUUCP"
  1408.  
  1409. POSIX.1 also lacks certain other features that Kermit needs.  For example:
  1410.  
  1411.  - There is no defined way for an application to do wildcard matching of
  1412.    filenames.  Kermit uses the inode in the directory structure, but POSIX.1
  1413.    does not include this concept.  (Later POSIX revisions include functions
  1414.    named (I think) glob() and fnmatch(), but these functions are not yet in
  1415.    Kermit, and might not be appropriate in any case.)
  1416.  
  1417.  - There is no POSIX mechanism for sensing or controlling modem signals,
  1418.    nor to enable RTS/CTS or other hardware flow control.
  1419.  
  1420.  - There is no select() for multiplexing i/o, and therefore no TCP/IP.
  1421.  
  1422.  - There is no way to check if characters are waiting in a communications
  1423.    device (or console) input buffer, short of trying to read them -- no
  1424.    select(), ioctl(fd,FIONREAD,blah), rdchk(), etc.  This is bad for CONNECT
  1425.    mode and bad for sliding windows.
  1426.  
  1427.  - No way to do a millisecond sleep (no nap(), usleep(), select(), etc).
  1428.  
  1429.  - There is no popen().
  1430.  
  1431. So at this point, there cannot be one single fully functional POSIX form of
  1432. C-Kermit unless it also has "extensions", as do Linux, QNX, etc.
  1433.  
  1434. More on POSIX (quoting from a newsgroup posting by Dave Butenhof
  1435. <butenhof@zko.dec.com>):
  1436.  
  1437. Standards tend to look at themselves as "enabling". So POSIX standards say
  1438. that, in order to use POSIX functions, a program must define some macro that
  1439. will put the development environment in "POSIX mode". For the ancient POSIX
  1440. 1003.1-1990, the symbol is _POSIX_SOURCE. For recent revisions, it's
  1441. _POSIX_C_SOURCE with an appropriate value. POSIX 1003.1-1996 says that, to
  1442. use its features in a portable manner, you must define
  1443. _POSIX_C_SOURCE=199506L before including any header files. Casper's guess --
  1444. and mine -- is that you're doing this.
  1445.  
  1446. But for Solaris, or Digital UNIX, the picture is different. POSIX is one
  1447. important but small part of the universe. Yet POSIX unconditionally and
  1448. unambiguously REQUIRES that, when _POSIX_C_SOURCE=199506L, ALL of the
  1449. functions and definitions required by the standard, and NO others (except in
  1450. specific restricted namespaces, specifically "_" followed by an uppercase
  1451. letter or "__" followed by a lowercase letter) shall be visible. That kinda
  1452. puts a cramp on BSD and SVID support, because those require names that are
  1453. not in the "protected" POSIX namespaces. It's ILLEGAL to make those symbols
  1454. visible, unless you've done something else that's beyond the scope of POSIX
  1455. to allow the system to infer that you didn't really mean it.
  1456.  
  1457. In most cases, you should just compile, with no standards-related macros
  1458. defined. The system will make available every interface and definition that
  1459. isn't incompatible with the "main stream". There may indeed be cases where
  1460. two standards cross, and you really can't use both together. But, in
  1461. general, they play nicely together as long as you don't do anything rash --
  1462. like telling the system that it's not allowed to let them.
  1463.  
  1464. In the area of threads, both Solaris and Digital UNIX support incompatible
  1465. thread APIs. We have POSIX and DCE, they have POSIX and UI. The nasty areas
  1466. are in the _r routines and in some aspects of signal behavior. You cannot
  1467. compile a single source file that uses both semantics. That's life. It
  1468. sounds as if Solaris defaults to the UI variants, but allows you to define
  1469. this _POSIX_THREAD_SEMANTICS to get around it. We default to POSIX, and
  1470. allow you to define _PTHREAD_USE_D4 (automatically defined by the cc
  1471. "-threads" switch) to select the DCE thread variants. That default, because
  1472. you're operating outside of any individual standard, is really just a
  1473. marketing decision.
  1474.  
  1475. (end quote)
  1476.  
  1477. 9.1.2. ANSI C
  1478.  
  1479. The major difference between ANSI C and earlier C compilers is function
  1480. prototyping.  ANSI C allows function arguments to be checked for type
  1481. agreement, and (when possible) type coercion in the event of a mismatch.  For
  1482. this to work, functions and their arguments must be declared before they are
  1483. called.  The form for function declarations is different in ANSI C and
  1484. non-ANSI C (ANSI C also accepts the earlier form, but then does not do type
  1485. checking).
  1486.  
  1487. As of edit 167, C-Kermit tries to take full advantage of ANSI C features,
  1488. especially function prototyping.  This removes many bugs introduced by
  1489. differing data types used or returned by the same functions on different
  1490. computers.  ANSI C features are automatically enabled when the symbol __STDC__
  1491. is defined.  Most ANSI C compilers, such as GNU CC and the new DEC C compiler
  1492. define this symbol internally.
  1493.  
  1494. On the downside, ANSI C compilation increases the administrative/bureacratic
  1495. burden, spewing out countless unneeded warnings about mismatched types,
  1496. especially when we are dealing with signed and unsigned characters, requiring
  1497. casts everywhere to shut up the mindless complaints -- there is no use for
  1498. signed chars in Kermit (or probably anywhere else).  Some compilers,
  1499. mercifully, include a "treat all chars as unsigned" option, and when available
  1500. it should be used -- not only to stop the warnings, but also to avoid unhelpful
  1501. sign extension on high-bit characters.
  1502.  
  1503. To force use of ANSI C prototypes, include -DCK_ANSIC on the cc command line.
  1504. To disable the use of ANSI prototypes, include -DNOANSI.
  1505.  
  1506. 9.1.3. Other Standards
  1507.  
  1508. As the years go by, standards with-which-all-must-comply continue to pile up:
  1509. AES, XPG2, XPG3, XPG4, FIPS 151-2, successive generations of POSIX, OSF/1,
  1510. X/Open, Spec 1170, UNIX95, Open Group UNIX98, Single Unix Spec 98 (or other
  1511. number), ISO/IEC 9945-1, ISO 9899, 88Open, OS 99, not to mention "mature
  1512. standards" like V7, 4.2/4.3BSD, System V R3 and R4 (SVID2 and SVID3), 4.4BSD
  1513. (the basis for BSDI, OpenBSD, NetBSD, FreeBSD, etc), /usr/group, plus assorted
  1514. seismic pronouncements of the neverending series of ephemeral corporate
  1515. consortia, not to mention the libc-vs-glibc turmoil in the Linux arena and who
  1516. knows what else.
  1517.  
  1518. None of these standards simplifies life for portable applications like
  1519. C-Kermit -- each one is simply one more environment to support (or circumvent,
  1520. as in many cases these standards do more harm than good by denying access to
  1521. facilities we need, e.g. as noted in above in 9.1.1).
  1522.  
  1523. 9.2. Library Issues
  1524.  
  1525. On most modern platforms, applications are -- and often must be -- dynamically
  1526. linked.  This has numerous advantages (smaller executables, ability to patch
  1527. a library and thereby patch all applications that use it, etc), but also
  1528. causes some headaches: most commonly, the library ID built into the executable
  1529. at link time does not match the ID of the corresponding library on the target
  1530. system, and so the loader refuses to let the application run.
  1531.  
  1532. This problem only gets worse over time.  In the Linux and *BSD world, we also
  1533. have totally different libraries (each with their own names and numbering
  1534. systems) that cover the same territory; for example, curses vs ncurses, libc
  1535. versus glibc.  Combinations proliferate and any given PC might have any
  1536. combination.  For this reason it is becoming increasingly difficult to produce
  1537. a "Linux binary" for a given architecture (e.g. PC or Alpha).  There has to
  1538. be a separate binary for (at least) every combination of curses vs ncurses
  1539. and libc vs glibc.
  1540.  
  1541. In such cases, the best advice is for every user to build C-Kermit from source
  1542. code on the system where it will run.
  1543.  
  1544. 9.3. UNIX File System Peculiarities
  1545.  
  1546. Normally, including a BSD, System-V, POSIX, or DIRENT flag in the make entry
  1547. selects the right file system code.  But some versions of UNIX are
  1548. inconsistent in this regard, and building in the normal way either gives
  1549. compiler or linker errors, or results in problems at runtime, typically
  1550. failure to properly expand wildcard file specifications when you do something
  1551. like "send *.*", or failure to recognize long filenames, as in "send
  1552. filewithaveryveryveryveryverylongname".
  1553.  
  1554. C-Kermit is supposed to know about all the various styles of UNIX file
  1555. systems, but it has to be told which one to use when you build it, usually in
  1556. the makefile entry CFLAGS as shown below, but you might also have to add
  1557. something like -I/usr/include/bsd to CFLAGS, or something like -lbsd to LIBS.
  1558.  
  1559. C-Kermit gives you the following CFLAGS switches to adapt to your file system's
  1560. peculiarities:
  1561.  
  1562.   -DDIRENT   - #include <dirent.h>
  1563.   -DSDIRENT  - #include <sys/dirent.h>
  1564.   -DNDIR     - #include <ndir.h>
  1565.   -DXNDIR    - #include <sys/ndir.h>
  1566.   -DRTU      - #include "/usr/lib/ndir.h", only if NDIR and XNDIR not defined.
  1567.   -DSYSUTIMH - #include <sys/utime.h> for setting file creation dates.
  1568.   -DUTIMEH   - #include <utime.h> for setting file creation dates.
  1569.  
  1570. (Note, RTU should only be used for Masscomp RTU systems, because it also
  1571. selects certain other RTU-specific features.)
  1572.  
  1573. If none of these is defined, then <sys/dir.h> is used.  IMPORTANT: If your
  1574. system has the file /usr/include/dirent.h then be sure to add -DDIRENT to your
  1575. makefile entry's CFLAGS.  "dirent" should be used in preference to any of the
  1576. others, because it supports all the features of your file system, and the
  1577. others probably don't.
  1578.  
  1579. Having selected the appropriate directory header file, you might also need to
  1580. tell Kermit how to declare the routines and variables it needs to read the
  1581. directory.  This happens most commonly on AT&T System-V based UNIXes,
  1582. particularly System V R3 and earlier, that provide long file and directory
  1583. names (longer than 14 characters).  Examples include certain releases of
  1584. HP-UX, DIAB DNIX, older versions of Silicon Graphics IRIX, and perhaps also
  1585. MIPS.  In this case, try adding -DLONGFN to your makefile entry.
  1586.  
  1587. Another problem child is <sys/file.h>.  Most UNIX C-Kermit versions need to
  1588. #include this file from within ckutio.c and ckufio.c, but some not only do not
  1589. need to include it, but MUST not include it because (a) it doesn't exist, or
  1590. (b) it has already been included by some other header file and it doesn't
  1591. protect itself against multiple inclusion, or (c) some other reason that
  1592. prevents successful compilation.  If you have compilation problems that seem
  1593. to stem from including this file, then add the following switch to CFLAGS in
  1594. your makefile entry:
  1595.  
  1596.   -DNOFILEH
  1597.  
  1598. There are a few odd cases where <sys/file.h> must be included in one of the
  1599. cku[ft]io.c files, but not the other.  In that case, add the aforementioned
  1600. switch, but go into the file that needs <sys/file.h> and add something like
  1601. this:
  1602.  
  1603.   #ifdef XXX       /* (where XXX is a symbol unique to your system) */
  1604.   #undef NOFILEH
  1605.   #endif /* XXX */
  1606.  
  1607. before the section that includes <sys/file.h>.
  1608.  
  1609. Kermit's SEND command expands wildcard characters "?" and "*" itself.  Before
  1610. version 5A, commands like "send *" would send all regular (non-directory)
  1611. files, including "hidden files" (whose names start with ".").  In version 5A,
  1612. the default behavior is to match like the Bourne shell or the ls command, and
  1613. not include files whose names start with dot.  Such files can still be sent if
  1614. the dot is included explicitly in the SEND command: "send .oofa, send .*".  To
  1615. change back to the old way and let leading wildcard characters match dot
  1616. files, include the following in your CFLAGS:
  1617.  
  1618.   -DMATCHDOT
  1619.  
  1620. (In C-Kermit 6.0, there is also a command to control this at runtime.)
  1621.  
  1622. If you get compile-time complaints about data type mismatches for process-ID
  1623. related functions like getpid(), add -DPID_T=pid_t.
  1624.  
  1625. If you get compile-time complaints about data type mismatches for user ID
  1626. related functions like getuid(), add -DUID_T=uid_t.
  1627.  
  1628. If you get compile-time complaints about data type mismatches for user-ID
  1629. related functions like getgid(), add -DGID_T=gid_t.
  1630.  
  1631. If you get compile-time complaints about data type mismatches for getpwuid(),
  1632. add -DPWID_T=uid_t (or whatever it should be).
  1633.  
  1634. File creation dates: C-Kermit attempts to set the creation date/time of an
  1635. incoming file according to the date/time given in the file's attribute
  1636. packet, if any.  If you find that the dates are set incorrectly, you might
  1637. need to build Kermit with the -DSYSUTIMEH flag, to tell it to include
  1638. <sys/utime.h>.  If that doesn't help, look at the code in zstrdt() in
  1639. ckufio.c.
  1640.  
  1641. 9.4. Hardware Flow Control
  1642.  
  1643. Hardware flow control is a problematic concept in many popular UNIX
  1644. implementations.  Often it is lacking altogether, and when available, the
  1645. application program interface (API) to it is inconsistent from system to
  1646. system.  Here are some examples:
  1647.  
  1648.   a. POSIX does not support hardware flow control.
  1649.  
  1650.   b. RTS/CTS flow control support MIGHT be available for System V R3 and
  1651.      later if /usr/include/termiox.h exists (its successful operation also
  1652.      depends on the device driver, and the device itself, not to mention the
  1653.      cable, etc, actually supporting it).  If your SVR3-or-later UNIX system
  1654.      does have this file, add:
  1655.  
  1656.        -DTERMIOX
  1657.  
  1658.      to your CFLAGS.  If the file is in /usr/include/sys instead, add:
  1659.  
  1660.        -DSTERMIOX
  1661.  
  1662.      Note that the presence of this file does not guarantee that RTS/CTS will
  1663.      actually work -- that depends on the device-driver implementation
  1664.      (reportedly, many UNIX versions treat hardware-flow-control related
  1665.      ioctl's as no-ops).
  1666.  
  1667.   c. Search ("grep -i") through /usr/include/*.h and /usr/include/sys/*.h for
  1668.      RTS or CTS and see what turns up.  For example, in SunOS 4.x we find
  1669.      "CRTSCTS".  Figuring out how to use it is another question entirely!  In
  1670.      IBM AIX RS/6000 3.x, we have to "add" a new "line discipline" (and you
  1671.      won't find uppercase RTS or CTS symbols in the header files).
  1672.  
  1673.   d. NeXTSTEP and IRIX, and possibly others, support hardware flow control,
  1674.      but do not furnish an API to control it, and thus on these systems
  1675.      Kermit has no command to select it -- instead, a special device name
  1676.      must be used.  (NeXTSTEP: /dev/cufa instead of /dev/cua; IRIX:
  1677.      /dev/ttyf00)
  1678.  
  1679. See the routine tthflow() in ckutio.c for details.  If you find that your
  1680. system offers hardware flow control selection under program control, you can
  1681. add this capability to C-Kermit as follows:
  1682.  
  1683.   a. See if it agrees with one of the methods already used in tthflow().
  1684.      If not, add new code, appropriately #ifdef'd.
  1685.  
  1686.   b. Add -DCK_RTSCTS to the compiler CFLAGS in your makefile entry or define
  1687.      this symbol within the appropriate #ifdef's in ckcdeb.h.
  1688.  
  1689. To illustrate the difficulties with RTS/CTS, here is a tale from Jamie Watson
  1690. <jw@adasoft.ch>, who added the RTS/CTS code for the RS/6000, about his
  1691. attempts to do the same for DEC ULTRIX:
  1692.  
  1693.    "The number and type of hardware signals available to/from a serial port
  1694.    vary between different machines and different types of serial interfaces on
  1695.    each machine.  This means that, for example, there are virtually no
  1696.    hardware signals in or out available on the DECsystem 3000/3100 series; on
  1697.    the DECsystem 5000/2xx series all modem signals in/out are present on both
  1698.    built-in serial ports; on the DECsystem 5100 some ports have all signals
  1699.    and some only have some; and so on...  It looks to me as if this pretty
  1700.    well rules out any attempt to use hardware flow control on these platforms,
  1701.    even if we could figure out how to do it.  The confusion on the user level
  1702.    about whether or not it should work for any given platform or port would be
  1703.    tremendous.  And then it isn't clear how to use the hardware signals even
  1704.    in the cases where the device supports them."
  1705.  
  1706. 9.5. Terminal Speeds
  1707.  
  1708. The allowable speeds for the SET SPEED command are defined in ckcdeb.h.  If
  1709. your system supports speeds that are not listed in "set speed ?", you can
  1710. add definitions for them to ckcdeb.h.
  1711.  
  1712. Then if the speed you are adding is one that was never used before in Kermit,
  1713. such as 921600, you'll also need to add the appropriate keywords to spdtab[]
  1714. in ckuus3.c, and the corresponding case to ttsspd() in ckutio.c.
  1715.  
  1716. 9.6. Millisecond Sleeps
  1717.  
  1718. There is no standard for millisecond sleeps, but at least five different
  1719. functions have appeared in various UNIX versions that can be used for this
  1720. purpose: nap() (mostly in System V), usleep() (found at least in SunOS and
  1721. NeXT OS), select() (found in 4.2BSD and later, and part of any TCP/IP sockets
  1722. library), nanosleep(), and sginap().  If you have any of these available, pick
  1723. one (in this order of preference, if you have more than one):
  1724.  
  1725.   -DSELECT: Include this in CFLAGS if your system has the select() function.
  1726.   -DNAP:    Include this in CFLAGS if your system has the nap() function.
  1727.   -USLEEP:  Include this in CFLAGS if your system has the usleep() function.
  1728.  
  1729. NOTE: The nap() function is assumed to be a function that puts the process
  1730. to sleep for the given number of milliseconds.  If your system's nap()
  1731. function does something else or uses some other units of time (like the NCR
  1732. Tower 32, which uses clock-ticks), do not include -DNAP.
  1733.  
  1734. Reportedly, all versions of System V R4 for Intel-based computers, and
  1735. possibly also SVR3.2, include nap() as a kernel call, but it's not in the
  1736. library.  To include code to use it via syscall(3112,x), without having to
  1737. include Xenix compatibility features, include the following compile-time
  1738. option:
  1739.  
  1740.   -DNAPHACK
  1741.  
  1742. 9.7. Nondestructive Input Buffer Peeking
  1743.  
  1744. Some AT&T UNIX versions have no way to check if input is waiting on a tty
  1745. device, but this is a very important feature for Kermit.  Without it, sliding
  1746. windows might not work very well (or at all), and you also have to type your
  1747. escape character to get Kermit's attention in order to interrupt a local-mode
  1748. file transfer.  If your system offers an FIONREAD ioctl, the build procedure
  1749. should pick that up automatically and use it, which is ideal.
  1750.  
  1751. If your system lacks FIONREAD but has a select() function, this can be used
  1752. instead.  If the build procedure fails to include it (SHOW FEATURES will
  1753. list SELECT), then you can add it to your CFLAGS:
  1754.  
  1755.   -DSELECT
  1756.  
  1757. Conversely, if the build procedure tries to use select() when it really is
  1758. not there, add:
  1759.  
  1760.   -DNOSELECT
  1761.  
  1762. Note: select() is not part of System V nor of POSIX, but it has been added to
  1763. various System-V- and POSIX-based systems as an extension.
  1764.  
  1765. Some System-V variations (SCO Xenix/UNIX/ODT and DIAB DNIX) include a rdchk()
  1766. function that can be used for buffer peeking.  It returns 0 if no characters
  1767. are waiting and 1 if characters are waiting (but unlike FIONREAD, it does not
  1768. tell the actual number).  If your system has rdchk(), add:
  1769.  
  1770.   -DRDCHK:  Include this in CFLAGS if your system has the rdchk() function.
  1771.  
  1772. Otherwise, if your version of UNIX has the poll() function (and the
  1773. /usr/include/poll.h file) -- which appears to be a standard part of System V
  1774. going back to at least SVR3, include:
  1775.  
  1776.   -DCK_POLL
  1777.  
  1778. 9.8. Other System-Dependent Features
  1779.  
  1780. Systems with <termios.h> might have the symbol IEXTEN defined.  This is used
  1781. to turn "extended features" in the tty device driver on and off, such as
  1782. Ctrl-O to toggle output flushing, Ctrl-V to quote input characters, etc.
  1783.  
  1784. In most UNIX implementations, it should be turned off during Kermit operation,
  1785. so if ckutio.c finds this symbol, it uses it.  This is necessary, at least, on
  1786. BSDI.  On some systems, however, IEXTEN is either misdefined or
  1787. misimplemented.  The symptom is that CR, when typed to the command processor,
  1788. is echoed as LF, rather than CRLF.  This happens (at least) on Convex/OS 9.1.
  1789. The solution is to add the following symbol to the makefile entry's CFLACS:
  1790.  
  1791.   -DNOIEXTEN
  1792.  
  1793. However, in at least one UNIX implementation, QNX 4.21, IEXTEN must be set
  1794. before hardware flow control can be used.
  1795.  
  1796. In edits 177 and earlier, workstation users noticed a "slow screen writing"
  1797. phenomenon during interactive command parsing.  This was traced to a setbuf()
  1798. call in ckutio.c that made console (stdout) writes unbuffered.  This setbuf()
  1799. call has been there forever, and could not be removed without some risk.
  1800. Kermit's operation was tested on the NeXT in edit 178 with the setbuf() call
  1801. removed, and the slow-writing symptom was cured, and everything else (command
  1802. parsing, proper wakeup on ?, ESC, Ctrl-U, and other editing characters,
  1803. terminal emulation, remote-mode and local-mode file transfer, etc) seemed to
  1804. work as well as or better than before.  In subsequent edits, this change was
  1805. made to many other versions too, with no apparent ill effects.  To remove the
  1806. setbuf() call for your version of Kermit, add:
  1807.  
  1808.   -DNOSETBUF
  1809.  
  1810. Later reports indicate that adding -DNOSETBUF has other beneficial effects,
  1811. like cutting down on swapping when Kermit is run on workstations with small
  1812. memories.  But BEWARE: on certain small UNIX systems, notably the AT&T 6300
  1813. and 3B1 (the very same ones that benefit from NOSETBUF), NOSETBUF seems to
  1814. conflict with CK_CURSES.  The program builds and runs OK, but after once using
  1815. the curses display, echoing is messed up.  In this case, we use a System-V
  1816. specific variation in the curses code, using newterm() to prevent System V
  1817. from altering the buffering.  See makefile entries for AT&T 6300 and 3B1.
  1818.  
  1819. The UNIX version of C-Kermit includes code to switch to file descriptor zero
  1820. (stdin) for remote-mode file transfer.  This code is necessary to prevent
  1821. Kermit from giving the impression that it is "idle" during file transfers,
  1822. which, at some sites, can result in the job being logged out in the middle of
  1823. an active file transfer by idle-job monitors.
  1824.  
  1825. However, this feature can interfere with certain setups; for example, there is
  1826. a package which substitutes a pty/tty pair for /dev/tty and sets file
  1827. descriptor 0 to be read-only, preventing Kermit from sending packets.  Or...
  1828. When a UNIX shell is invoked under the PICK environment, file descriptor 0
  1829. is inoperative.
  1830.  
  1831. To remove this feature and allow Kermit to work in such environments, add the
  1832. compile-time option:
  1833.  
  1834.   -DNOFDZERO
  1835.  
  1836. On some versions of UNIX, earlier releases of C-Kermit were reported to render
  1837. a tty device unusable after a hangup operation.  Examples include IBM AIX on
  1838. the RT PC and RS/6000.  A typical symptom of this phenomenon is that the DIAL
  1839. command doesn't work, but CONNECTing to the device and dialing manually do
  1840. work.  A further test is to SET DIAL HANGUP OFF, which should make dialing
  1841. work once by skipping the pre-dial hangup.  However, after the connection is
  1842. broken, it can't be used any more: subsequent attempts to DIAL the same device
  1843. don't work.  The cure is usually to close and reopen the device as part of the
  1844. hangup operation.  To do this, include the following compile-time option:
  1845.  
  1846.   -DCLSOPN
  1847.  
  1848. Similarly, there is a section of code in ttopen(), which does another
  1849. close(open()) to force the O_NDELAY mode change.  On some systems, the
  1850. close(open()) is required to make the mode change take effect, and apparently
  1851. on most others it does no harm.  But reportedly on at least one System V R4
  1852. implementation, and on SCO Xenix 3.2, the close(open()) operation hangs
  1853. if the device lacks carrier, EVEN THOUGH the CLOCAL characteristic has just
  1854. been set to avoid this very problem.  If this happens to you, add this to
  1855. your CFLAGS:
  1856.  
  1857.   -DNOCOTFMC
  1858.  
  1859. or, equivalently, in your KFLAGS on the make command line.  It stands for
  1860. NO Close(Open()) To Force Mode Change.
  1861.  
  1862. C-Kermit renames files when you give a RENAME command and also according to
  1863. the current SET FILE COLLISION option when receiving files.  The normal UNIX
  1864. way to rename a file is via two system calls: link() and unlink().  But
  1865. this leaves open a window of vulnerability.  Some UNIX systems also offer an
  1866. atomic rename(oldname,newname) function.  If your version of UNIX has this
  1867. function, add the following to your CFLAGS:
  1868.  
  1869.   -DRENAME
  1870.  
  1871. C-Kermit predefines the RENAME for several UNIX versions in ckcdeb.h (SVR4,
  1872. SUNOS41, BSD44, AIXRS, etc).  You can tell if rename() is being used if the
  1873. SHOW FEATURES command includes RENAME in the compiler options list.  If the
  1874. predefined RENAME symbol causes trouble, then add NORENAME to your CFLAGS.
  1875. Trouble includes:
  1876.  
  1877.   a. Linker complains that _rename is an unresolved symbol.
  1878.  
  1879.   b. Linking works, but Kermit's RENAME command doesn't work (which happens
  1880.      because older versions of rename() might have their arguments reversed).
  1881.  
  1882. If rename() is not used, then Kermit uses link()/unlink(), which is equivalent
  1883. except it is not atomic: there is a tiny interval in which some other process
  1884. might "do something" to one of the files or links.
  1885.  
  1886. Some UNIX systems (Olivetti X/OS, Amdahl UTS/V, ICL SVR3, etc) define the
  1887. S_ISREG and S_ISDIR macros incorrectly.  This is compensated for automatically
  1888. in ckufio.c.  Other systems might have this same problem.  If you get a
  1889. compile-time error message regarding S_ISREG and/or S_ISDIR, add the following
  1890. to your CFLAGS:
  1891.  
  1892.   -DISDIRBUG
  1893.  
  1894. Finally, here's a symbol you should NEVER define:
  1895.  
  1896.   -DCOMMENT
  1897.  
  1898. It's used for commenting out blocks of code.  If for some reason you find
  1899. that your compiler has COMMENT defined, then add -UCOMMENT to CFLAGS or KFLAGS!
  1900. Similarly, some header files have been known to define COMMENT, in which case
  1901. you must add "#undef COMMENT" to each C-Kermit source module, after all the
  1902. #includes.
  1903.  
  1904. 9.9. Terminal Interruption
  1905.  
  1906. When C-Kermit enters interactive command mode, it sets a Control-C (terminal
  1907. keyboard interrupt = SIGINT) trap to allow it to return to the command prompt
  1908. whenever the user types Control-C (or whatever is assigned to be the interrupt
  1909. character).  This is implemented using setjmp() and longjmp().  On some
  1910. systems, depending on the machine architecture and C compiler and who knows
  1911. what else, you might get "Memory fault (coredump)" or "longjmp botch" instead
  1912. of the desired effect (this should not happen in 5A(190) and later).  In that
  1913. case, add -DNOCCTRAP to your CFLAGS and rebuild the program.
  1914.  
  1915. Job control -- the ability to "suspend" C-Kermit on a UNIX system by typing
  1916. the "susp" character (normally Ctrl-Z) and then resume execution later (with
  1917. the "fg" command) -- is a tricky business.  C-Kermit must trap suspend signals
  1918. so it can put the terminal back into normal mode when you suspend it (Kermit
  1919. puts the terminal into various strange modes during interactive command
  1920. parsing, CONNECT, and file transfer).  Supporting code is compiled into
  1921. C-Kermit automatically if <signal.h> includes a definition for the SIGTSTP
  1922. signal.  HOWEVER... some systems define this signal without supporting
  1923. job control correctly.  You can build Kermit to ignore SIGTSTP signals by
  1924. including the -DNOJC option in CFLAGS.  (You can also do this at runtime by
  1925. giving the command SET SUSPEND OFF.)
  1926.  
  1927.   NOTE: As of version 5A(190), C-Kermit makes another safety check.
  1928.   Even if job control is available in the operating system (according to
  1929.   the numerous checks made in congm()), it will still disable the catching
  1930.   of SIGTSTP signals if SIGTSTP was set to SIG_IGN at the time C-Kermit
  1931.   was started.
  1932.  
  1933. System V R3 and earlier systems normally do not support job control.  If you
  1934. have an SVR3 system that does, include the following option in your CFLAGS:
  1935.  
  1936.   -DSVR3JC
  1937.  
  1938. On systems that correctly implement POSIX signal handling, signals can be
  1939. handled more reliably than in Bell, Berkeley, or AT&T UNIXes.  On systems
  1940. (such as QNX) that are "strictly POSIX", POSIX signal handling *must* be used,
  1941. otherwise no signal will work more than once.  If you have POSIX-based system
  1942. and you find that your version of Kermit responds to Ctrl-C (SIGINT) or Ctrl-Z
  1943. (SIGTSTP) only once, then you should add the following option to your CFLAGS:
  1944.  
  1945.   -DCK_POSIX_SIG
  1946.  
  1947. But be careful; some POSIX implementations, notably 4.4BSD, include POSIX
  1948. signal handling symbols and functions as "stubs" only, which do nothing.  Look
  1949. in <signal.h> for sigsetjmp and siglongjmp and read the comments.
  1950.  
  1951. 10. DIALING OUT AND COORDINATING WITH UUCP
  1952.  
  1953. The short version:
  1954.  
  1955.   In order for C-Kermit to be able to dial out from your UNIX computer,
  1956.   you need to give it the same owner, group, and permissions as your
  1957.   other dialout programs, such as cu, tip, minicom, uucp, seyon, etc.
  1958.  
  1959. The long version:
  1960.  
  1961. Make sure your dialout line is correctly configured for dialing out (as
  1962. opposed to login).  The method for doing this is different for each kind of
  1963. UNIX.  Consult your system documentation for configuring lines for dialing out
  1964. (for example, Sun SPARCstation IPC users should read the section "Setting up
  1965. Modem Software" in the Desktop SPARC Sun System & Network Manager's Guide, or
  1966. the Terminals and Modems section of the HP manual, "Configuring HP-UX for
  1967. Peripherals" (e.g. /usr/sbin/sam => Peripheral Devices => Terminals and Modems
  1968. => Add Modem).
  1969.  
  1970. Unlike other operating systems, UNIX allows multiple users to access the same
  1971. serial device at the same time, even though there is no earthly reason why two
  1972. users should do this.  When they do, user A will read some of the incoming
  1973. characters, and user B will read the others.  In all likelihood, neither user
  1974. will see them all.  Furthermore, User B can hang up User A's call, etc.
  1975.  
  1976. Rather than change UNIX to enforce exclusive access to serial devices such as
  1977. ttys, UNIX developers chose instead to use a "lock file".  Any process that
  1978. wants to open a tty device should first check to see if a file of a certain
  1979. name exists, and if so, not to open the device.  If the file does not exist,
  1980. the process creates the file and then opens the device.  When the process
  1981. closes the device, it destroys the lockfile.  This procedure was originated
  1982. for use with UNIX's UUCP, CU, and TIP programs, and so these lockfiles are
  1983. commonly called "UUCP lockfiles" (UUCP = UNIX-to-UNIX Copy Program).
  1984.  
  1985. As you can imagine, this method is riddled with pitfalls:
  1986.  
  1987.   - If a process does not observe the prevailing lockfile convention,
  1988.     then it can interfere with other "polite" processes.  And in fact,
  1989.     very few UNIX applications or commands handle lockfiles at all; an
  1990.     original design goal of UNIX was that "everything is a file", and
  1991.     countless utilities operate on files directly (by opening them) or
  1992.     indirectly through redirection of standard i/o, without creating or
  1993.     looking for lockfiles.
  1994.  
  1995.   - If a process crashes while it has the device open, the lockfile is
  1996.     left behind, preventing further processes from using the device.
  1997.  
  1998.   - Various versions of UNIX use different names for the lockfiles, put
  1999.     them in different directories, with different owners and groups and
  2000.     permissions, and specify their contents differently.
  2001.  
  2002.   - On a given platform, the lockfile conventions may change from one UNIX
  2003.     release to the next (for example, SunOS 4.0 to 4.1) or, in the case of
  2004.     Linux, across different distributions.
  2005.  
  2006.   - The same tty device might have more than one name, and most lockfile
  2007.     conventions don't allow for this.  Similarly for symbolic links.
  2008.  
  2009. In an attempt to address the problem of "stale" lockfiles, most UUCP
  2010. implementations put the PID (Process ID) of the creating process in the
  2011. lockfile.  Thus, another process that wants to open the corresponding device
  2012. can check not only for the lockfile itself, but also can check the PID for
  2013. validity.  But this doesn't work well either:
  2014.  
  2015.   - PIDs are stored in diverse formats that change with every new release
  2016.     (short, integer, long, or string in any of various formats).  If the
  2017.     reading program does not follow the same convention as the writing
  2018.     program, it can diagnose a valid PID to be invalid, and therefore not
  2019.     honor the lock.
  2020.  
  2021.   - PIDs recycle.  If the lockfile was created by PID 1234, which later
  2022.     crashed without removing the lockfile, and then a new process 1234 exists
  2023.     a the time the lockfile is checked, the lockfile will be improperly taken
  2024.     as valid, and access to the device denied unnecessarily.
  2025.  
  2026. Several techniques address the problem of multiple names for the same device:
  2027.  
  2028.   - Multiple lockfiles.  For example, if the user opens a device through a
  2029.     symlink, a lockfile is created for both the symlink name and the true
  2030.     name (obtained from readlink()).  However, when multiple drivers are
  2031.     installed for the same device (e.g. /dev/cua, /dev/cufa, etc), this
  2032.     approach won't work unless all applications *know* all the different
  2033.     names for the same device and make lockfiles for all of them, which is
  2034.     obviously not practical.
  2035.  
  2036.   - Lockfiles whose names are not based on the device name.  These
  2037.     lockfiles generally have names like LK.inode/major/minor, where
  2038.     inode, major, and minor are numbers, which will always be the same for
  2039.     any physical device, no matter what its name.  This form of lockfile is
  2040.     used in System V R4 and its derivatives, such as Solaris, UnixWare,
  2041.     etc.  If lockfiles must be used (as opposed to, say, kernel-based
  2042.     locks), this would seem to be the most effective form.
  2043.  
  2044. Most versions of UNIX were not designed to accommodate third-party
  2045. communications software; thus vendors of these UNIX products feel no
  2046. compunction about changing lockfile conventions from release to release, since
  2047. they also change their versions of the cu, uucp, tip, etc, programs at the
  2048. same time to match.  And since the source code to these programs is not
  2049. published, it is difficult for makers of third-party products (like C-Kermit)
  2050. to find out what the new conventions are.  It also forces release of new
  2051. versions of C-Kermit whenever the OS vendor makes a change like this.
  2052.  
  2053. Some UNIX vendors have taken a small step to simplify communications
  2054. application development for their products: the inclusion of lockfile routines
  2055. in the standard system C runtime libraries to shield the application from the
  2056. details of lockfile management (IBM AIX is an example).  When such routines
  2057. are used, communications applications do not need modification when lockfile
  2058. conventions change (although they will need recompiling if the routines are
  2059. statically linked into the application).  In the AIX example, the simple
  2060. function calls ttylock(), ttyunlock(), and ttylocked() replace hundreds of
  2061. lines of ugly code in C-Kermit that attempts to keep pace with every release
  2062. of every UNIX product over the last 20 years.  Inclusion of ttylock() code
  2063. occurs when:
  2064.  
  2065.   -DUSETTYLOCK
  2066.  
  2067. is included in the CFLAGS.
  2068.  
  2069. If such routines are available, they should be used.  The rest of this section
  2070. applies when they are not.
  2071.  
  2072. To fit in with UUCP and other UNIX-based communication software, C-Kermit must
  2073. have the same idea as your system's uucp, cu, and tip programs about what the
  2074. UUCP lock directory is called, what the lockfile itself is called, and what
  2075. its contents should be.  In most cases, C-Kermit preprocessor flags create the
  2076. appropriate configuration at compile time if the appropriate makefile target
  2077. was used (see ckutio.c).  The following CFLAGS options can be used to override
  2078. the built-in configuration:
  2079.  
  2080.   -DLCKDIR:   Tells Kermit that the UUCP lock directory is /usr/spool/uucp/LCK.
  2081.  
  2082.   -DACUCNTRL: Tells Kermit to use the BSD 4.3 acucntrl() program to turn
  2083.               off getty (login) on the line before using it, and restore
  2084.               getty when done.
  2085.  
  2086.   -DHDBUUCP:  Include this if your system uses Honey DanBer UUCP, in which
  2087.               the lockfile directory and format are relatively standardized.
  2088.  
  2089.   -DLOCK_DIR=\\\"/xxx/yyy\\\": Gives the lock directory name explicitly.
  2090.               The triple quoting is necessary.  For example:
  2091.               "CFLAGS= -DBSD4 -DLOCK_DIR=\\\"/usr/local/locks\\\" -DNODEBUG"
  2092.               (NOTE: The triple quoting assumes this is a "top-level" make
  2093.               entry, and not a make entry that calls another one.)
  2094.  
  2095.   -DLFDEVNO   The lockfile name uses the tty device inode and major and minor
  2096.               numbers: LK.dev.maj.min, as in Sys V R4, e.g. LK.035.044.008.
  2097.  
  2098. When the LK.inode.major.minor form is used, a single lockfile is enough.
  2099. Otherwise, a single lockfile rarely suffices.  For example, in Linux, it is
  2100. common to have a /dev/modem symbolic link to an actual dialout device, like
  2101. /dev/cua0 or /dev/ttyS0, whose purpose is to hide the details of the actual
  2102. driver from the user.  So if one user opens /dev/modem, a lockfile called
  2103. LCK..modem is created, which does not prevent another user from
  2104. simulataneously opening the same device by its real name.
  2105.  
  2106. On SCO UNIX platforms, we have a slightly different problem: the same device
  2107. is, by convention, known by "lowercase" and "uppercase" names, depending on
  2108. whether it has modem control.  So by convention, communications programs are
  2109. supposed to create the lockfiles based on the lowercase name.  But some
  2110. programs don't follow this convention.  In HP-UX, we have several different
  2111. names for each serial device.  And so on.
  2112.  
  2113. For this reason, on platforms where the LK.inode.major.minor form is not used,
  2114. C-Kermit also creates a secondary lockfile (which is simply a link to the
  2115. first) if:
  2116.  
  2117.   a. The given device name is a symbolic link.  The secondary link is based
  2118.      on the device's real name.
  2119.  
  2120.   b. On SCO: The device name is not a symbolic link, but it contains uppercase
  2121.      letters.  The primary link is based on the lowercase name; the secondary
  2122.      link is based on the name that was given.
  2123.  
  2124.   c. On HP-UX: The device name starts with "cu".  The primary link is based on
  2125.      the name that was given; the secondary link is based on the corresponding
  2126.      "ttyd" device, e.g. "LCK..cua0p0" and "LCK..ttyd0p0".
  2127.  
  2128. NOTE: symlinks are not handled in HP-UX.
  2129.  
  2130. Honey DanBer (HDB) UUCP, which is becoming increasingly popular, has two
  2131. characteristics:
  2132.  
  2133.    a. Lockfiles are kept in /usr/spool/locks/ (usually).
  2134.  
  2135.    b. A lockfile contains the process id (pid) in ASCII, rather than as an int.
  2136.  
  2137. Non-HDB selections assume the lockfile contains the pid in int form (or,
  2138. more precisely, in PID_T form, where PID_T is either int or pid_t, depending
  2139. on your system's C library and header files).  (b), by the way, is subject
  2140. to interpretation: the numeric ASCII string may or may not be terminated by
  2141. a newline, it may or may not have leading spaces (or zeros), and the number
  2142. of leading spaces or zeros can differ, and the differences can be significant.
  2143.  
  2144. Even if you build the program with the right lockfile option, you can still
  2145. have problems when you try to open the device.  Here are the error messages
  2146. you can get from SET LINE, and what they mean:
  2147.  
  2148.    a. "Timed out, no carrier."  This one is not related to lockfiles.  It
  2149.       means that you have SET CARRIER ON xx, where xx is the number of seconds
  2150.       to wait for carrier, and carrier did not appear within xx seconds.
  2151.       Solution: SET CARRIER AUTO or OFF.
  2152.  
  2153.    b. "Sorry, access to lock denied."  Kermit has been configured to use
  2154.       lockfiles, but (a) the lockfile directory is write-protected against
  2155.       you, or (b) it does not exist.  The "access to lock denied" message will
  2156.       tell you the reason.  If the directory does not exist, check to make
  2157.       sure Kermit is using the right name.  Just because version "n" of your
  2158.       UNIX used a certain lockfile directory is no gurantee that version n.1
  2159.       does not use a different one.  Workaround: ask the system administrator
  2160.       to install a symbolic link from the old name to the new name.  Other
  2161.       solutions: (see below)
  2162.  
  2163.    c. "Sorry, access to tty device denied."  The tty device that you specified
  2164.       in your SET LINE command is read/write protected against you.
  2165.       Solution: (see below)
  2166.  
  2167.    d. "Sorry, device is in use."  The tty device you have specified is
  2168.       currently being used by another user.  A prefatory message gives you
  2169.       an "ls -l" listing of the lockfile, which should show the username of
  2170.       the person who created it, plus a message "pid = nnn" to show you the
  2171.       process id of the user's program.  Solutions: try another device,
  2172.       wait until the other user is finished, ask the other user to hurry up,
  2173.       or ask the system manager for help.
  2174.  
  2175.    e. "Sorry, can't open connection: <reason>".  The device cannot be opened
  2176.       for some other reason, which is listed.
  2177.  
  2178.    f. "sh: /usr/lib/uucp/acucntrl: not found".  This means your Kermit program
  2179.       was built with the -DACUCNTRL switch, but your computer system does not
  2180.       have the BSD 4.3 acucntrl program.  Solution: install the acucntrl
  2181.       program if you have it, or rebuild Kermit without the -DACUCNTRL switch.
  2182.  
  2183. There are two solutions for problems (b) and (c), both of which involve
  2184. intervention by your UNIX system administrator (superuser):
  2185.  
  2186.    a. Have the superuser change the permission of the lockfile directory and
  2187.       to the tty devices so that everyone on the system has read/write
  2188.       permission.
  2189.  
  2190.         su% chmod 777 /usr/spool/locks (or whatever the path is)
  2191.         su% chmod 666 /dev/ttyXX
  2192.  
  2193.       One risk here is that people can write lots of junk into the lockfile
  2194.       directory, delete other people's files in the lockfile directory, and
  2195.       intercept other people's data as it goes in and out of the tty device.
  2196.       The major danger here would be intercepting a privileged password.  Of
  2197.       course, any user could write a short, ordinary, unprivileged program to
  2198.       do exactly the same thing if the tty device was world read/writeable.
  2199.       The other risk as that telephone calls are not controlled -- anybody on
  2200.       your system can make them, without having to belong to any particular
  2201.       group, and this could run up your phone bill.
  2202.  
  2203.    b. Have the superuser change Kermit to run setuid and/or setgid to the
  2204.       owner and/or group of the lockfile directory and the tty devices if
  2205.       necessary), typically uucp (see next section), but NOT root.  Example:
  2206.  
  2207.     su% chown uucp kermit          - or -  chgrp uucp kermit
  2208.     su% chmod u+s kermit (setuid)  - or -  chmod g+s kermit (setgid)
  2209.  
  2210.       and then make sure the lockfile directory, and the tty devices, have
  2211.       owner (setuid) and/or group (setgid) write permission.  For example:
  2212.  
  2213.         su% chmod o+rwx /usr/spool/uucp
  2214.         su% chown uucp /dev/ttyXX ; chmod 600 /dev/ttyXX
  2215.  
  2216.       In some cases, the owner and group must be distinct; the key point is
  2217.       that read/write access is required to both the UUCP lockfile directory
  2218.       and the tty itself.
  2219.  
  2220. If you make C-Kermit setuid or setgid to root, it refuses to run:
  2221.  
  2222.   Fatal: C-Kermit setuid to root!
  2223.  
  2224. Example:
  2225.  
  2226.   crw-r-----   1 uucp     uucp       5,  67 Feb 11 06:23 /dev/cua3
  2227.   drwxrwxr-x   3 root     uucp         1024 Feb 11 06:22 /var/lock
  2228.  
  2229. requires suid uucp to get read/write access on /dev/cua3 and sgid to get
  2230. read/write access on /var/lock (since you can't set Kermit's uid or gid to
  2231. root).
  2232.  
  2233. For the lockfile mechanism to achieve its desired purpose -- prevention of
  2234. access to the same tty device by more than one process at a time -- ALL
  2235. programs on a given computer that open, read or write, and close tty devices
  2236. must use the SAME lockfile conventions.  Unfortunately, this is often not the
  2237. case.  Here is a typical example of how this can go wrong: In SunOS 4.0 and
  2238. earler, the lockfile directory was /usr/spool/uucp; in 4.1 it was changed to
  2239. /var/spool/locks in the quest for political correctness.  Consequently, any
  2240. third-party programs (such as C-Kermit) that were not modified to account for
  2241. this change, recompiled, and reinstalled, did not use the same lockfiles as
  2242. uucp, tip, etc, and so the entire purpose of the lockfile is defeated.
  2243.  
  2244. What if your UNIX system does not have UUCP installed?  For example, you have
  2245. a UNIX workstation, and you do not use uucp, cu, or tip, or UUCP was not even
  2246. supplied with your version of UNIX (QNX is an example).  In this case, you
  2247. have two choices:
  2248.  
  2249.    a. If there may be more than one person running Kermit at the same time,
  2250.       competing for the same tty device, then create a special lockfile
  2251.       directory just for Kermit, for example, /usr/spool/kermit, and make sure
  2252.       you have read/write access to it.  Then add the following to your
  2253.       makefile entry CFLAGS, as shown earlier:
  2254.  
  2255.            -DLOCK_DIR=\\\"/usr/spool/kermit\\\"
  2256.  
  2257.    b. If you are the only user on your workstation, and no other processes will
  2258.       ever be competing with Kermit for the dialout tty device, then add
  2259.       -DNOUUCP to your makefile entry's CFLAGS and rebuild Kermit.
  2260.  
  2261. 11. RUNNING UNIX C-KERMIT SETUID OR SETGID
  2262.  
  2263. Even if you don't intend to run C-Kermit setuid, somebody else might come
  2264. along and chown and chmod it after it has been built.  You should be sure that
  2265. it is built correctly to run setuid on your system.  For POSIX and AT&T UNIX
  2266. based versions, you don't have to do anything special.
  2267.  
  2268. For 4.2 and 4.3 BSD-based UNIX versions, you normally need not add anything
  2269. special to the makefile.  The program assumes that the setreuid() and
  2270. setregid() functions are available, without which we cannot switch back &
  2271. forth between real & effective uids.  If "make" complains that _setreuid or
  2272. _setregid is/are not defined, add -DNOSETREU to CFLAGS.  In this case it is
  2273. very likely (but not certain) that you cannot protect ttys and lockfiles
  2274. against people and have them run Kermit setuid.
  2275.  
  2276. If make does not complain about this, you should find out whether your BSD
  2277. version (4.3 or other systems like SunOS 4.x that claim to include BSD 4.3
  2278. compatibility) includes the saved-setuid feature (see long notes under edit
  2279. 146 in ckc178.upd).  If it does, then add -DSAVEDUID to CFLAGS.
  2280.  
  2281.   IMPORTANT NOTE: Most UNIX system documentation will not give you the
  2282.   required information.  To determine whether your UNIX system supplies the
  2283.   the saved-original-effective-user/group-id feature, use the ckuuid.c
  2284.   program.  Read and follow the instructions in the comments at the beginning.
  2285.  
  2286. C-Kermit for 4.4BSD-based systems automatically use sete[ug]id().  See
  2287. ckutio.c.
  2288.  
  2289. If you have a version of UNIX that is not BSD-based, but which supplies the
  2290. setreuid() and setregid() functions, and these are the only way to switch
  2291. between real and effective uid, add -DSETREUID to your makefile entry.
  2292.  
  2293.   WARNING: There are two calls to access() in ckufio.c, by which Kermit checks
  2294.   to see if it can create an output file.  These calls will not work correctly
  2295.   when (a) you have installed C-Kermit setuid or setgid on a BSD-based UNIX
  2296.   system, and (b) the saved-original-effective-uid/gid feature is not present,
  2297.   and (c) the access() function always checks what it believes to be the real
  2298.   ID rather than the effective ID.  This is the case, for example, in Olivetti
  2299.   X/OS and in NeXTSTEP.  In such cases, you can force correct operation of
  2300.   access() calls by defining the symbol SW_ACC_ID at compile time in CFLAGS.
  2301.  
  2302. If you have a version of UNIX that does not allow a process to switch back and
  2303. forth between its effective and real user and group ids multiple times, you
  2304. probably should not attempt to run Kermit setuid, because once having given up
  2305. its effective uid or gid (which it must do in order to transfer files, fork a
  2306. shell, etc) it can never get it back, and so it can not use the original
  2307. effective uid or gid to create or delete uucp lockfiles.  In this case, you'll
  2308. either have to set the permissions on your lockfile directory to make them
  2309. publicly read/writable, or dispense with locking altogether.
  2310.  
  2311. MORAL: Are you thoroughly sickened and/or frightened by all that you have just
  2312. read?  You should be.  What is the real answer?  Simple.  Serial devices --
  2313. such as ttys and magnetic tapes -- in UNIX should be opened with exclusive
  2314. access only, enforced by the UNIX kernel.  Shared access has no conceivable
  2315. purpose, legitimate or otherwise, except by privileged system programs such as
  2316. getty.  The original design dates from the late 1960s, when UNIX was developed
  2317. for laboratory use under a philosophy of trust by people within shouting
  2318. distance of each other -- but even then, no useful purpose was served by this
  2319. particular form of openness; it was probably more of a political statement.
  2320. Since the emergence of UNIX from the laboratory into the commercial market, we
  2321. have seen every vestige of openness -- but this one -- stripped away.  I'd
  2322. like to see some influential UNIX maker take the bold step of making the
  2323. simple kernel change required to enforce exclusive access of serial devices.
  2324. (Well, perhaps not so simple when bidirectionality must also be a goal -- but
  2325. then other OS's like VMS solved this problem 20 years ago.)
  2326.  
  2327. 12. CONFIGURING UNIX WORKSTATIONS
  2328.  
  2329. On desktop workstations that are used by only the user at the console
  2330. keyboard, C-Kermit is always used in local mode.  But as delivered, C-Kermit
  2331. runs in remote mode by default.  To put it in local mode at startup, you can
  2332. put a SET LINE command in your .kermrc.
  2333.  
  2334. You can also build C-Kermit to start up in local mode by default.  To do this,
  2335. include the following in the CFLAGS in your makefile entry:
  2336.  
  2337. -DDFTTY=\\\"/dev/ttyxx\\\"
  2338.  
  2339. where ttyxx is the name of the device you will be using for communications.
  2340. Presently there is no way of setting the default modem type at compile time,
  2341. so use this option only for direct lines.
  2342.  
  2343. C-Kermit does not work well on certain workstations if it is not run from
  2344. within a terminal window.  For example, you cannot start C-Kermit on a NeXT by
  2345. launching it directly from NeXTstep.  Similarly for Sun workstations in the
  2346. Open Windows environment.  Run Kermit in a terminal window.
  2347.  
  2348. 13. BIZARRE BEHAVIOR AT RUNTIME
  2349.  
  2350. See the beware file, ckubwr.txt, for hints about runtime misbehavior.
  2351. This section lists some runtime problems that can be cured by rebuilding
  2352. C-Kermit.
  2353.  
  2354. The program starts, but there is no prompt, and certain operations don't work
  2355. (you see error messages like "Kermit command error in background execution").
  2356. This is because Kermit thinks it is running in the background.  See conbgt()
  2357. in ckutio.c.  Try rebuilding Kermit with:
  2358.  
  2359.  -DPID_T=pid_t
  2360.  
  2361. added to your CFLAGS.  If that doesn't help, find out the actual data type
  2362. for pids (look in types.h or similar file) and use it in place of "pid_t",
  2363. for example:
  2364.  
  2365.  -DPID_T=short
  2366.  
  2367. Unexplainable and inappropriate error messages ("Sockets not supported on this
  2368. device", etc) have been traced in at least one case to a lack of agreement
  2369. between the system header files and the actual kernel.  This happened because
  2370. the GNU C compiler (gcc) was being used.  gcc wants to have ANSI-C-compliant
  2371. header files, and so part of the installation procedure for gcc is to run a
  2372. shell script called "fixincludes", which translates the system's header files
  2373. into a separate set of headers that gcc likes.  So far so good.  Later, a new
  2374. version of the operating system is installed and nobody remembers to run
  2375. fixincludes again.  From that point, any program compiled with gcc that makes
  2376. use of header files (particularly ioctl.h) is very likely to misbehave.
  2377. Solution: run fixincludes again, or use your system's regular C compiler,
  2378. libraries, and header files instead of gcc.
  2379.  
  2380. 14. CRASHES AND CORE DUMPS
  2381.  
  2382. If C-Kermit constitently dumps core at the beginning of a file transfer,
  2383. look in SHOW FEATURES for CKREALPATH.  If found, rebuild with -DNOREALPATH
  2384. and see if that fixes the problem (some UNIXes have realpath() but it doesn't
  2385. work).
  2386.  
  2387. Total failure of the Kermit program can occur because of bad memory
  2388. references, bad system calls, or problems with dynamic memory allocation.
  2389. First, try to reproduce the problem with debugging turned on: run Kermit with
  2390. the -d command-line option (for example, "wermit -d") and then examine the
  2391. resulting debug.log file.  The last entry should be in the vicinity of the
  2392. crash.  In VMS, a crash automatically produces a "stack dump" which shows the
  2393. routine where the crash occurs.  In some versions of UNIX, you can get a stack
  2394. dump with "adb" -- just type "adb wermit core" and then give the command "$c",
  2395. then Ctrl-D to quit (note: replace "wermit" by "kermit" or by the full
  2396. pathname of the executable that crashed if it is not in the current
  2397. directory).  Or use gdb to get a backtrace, etc.
  2398.  
  2399. In edit 186, one implementation, UNISYS 5000/95 built with "make sys5r3", has
  2400. been reported to run out of memory very quickly (e.g. while executing a short
  2401. initialization file that contains a SET DIAL DIRECTORY command).  Debug logs
  2402. show that malloc calls are failing, reason unknown.  For this and any other
  2403. implementation that gives error messages about "malloc failure" or "memory
  2404. allocation failure", rebuild the program *without* the -DDYNAMIC CFLAGS
  2405. definition, for example:
  2406.  
  2407.   make sys5r3 KFLAGS=-UDYNAMIC
  2408.  
  2409. As of edit 169, C-Kermit includes a malloc() debugging package which you may
  2410. link with the Kermit program to catch runtime malloc errors.  See the makefile
  2411. entries for sunos41md and nextmd for examples of how to select malloc
  2412. debugging.  Once you have linked Kermit with the malloc debugger, it will halt
  2413. with an informative message if a malloc-related error occurs and, if possible,
  2414. dump core.  For this reason, malloc-debugging versions of Kermit should be
  2415. built without the "-s" link option (which removes symbols, preventing analysis
  2416. of the core dump).  You have several ways to track down the malloc error:
  2417. Analyze the core dump with adb.  Or reproduce the problem with "log debug" and
  2418. then look at the code around the last debug.log entry.  If you have gcc, build
  2419. the program with "-g" added to CFLAGS and then debug it with gdb, e.g.
  2420.  
  2421.   gdb wermit
  2422.   break main
  2423.   run
  2424.   .. set other breakpoints or watchpoints
  2425.   continue
  2426.  
  2427. Watchpoints are especially useful for finding memory leaks, but they make
  2428. the program run about a thousand times slower than usual, so don't set them
  2429. until the last possible moment.  When a watchpoint is hit, you can use the
  2430. "where" command to find out which C-Kermit source statement triggered it.
  2431.  
  2432. If you have the Pure Software Inc "Purify" product, see the sunos41cp makefile
  2433. entry for an example of how to use it to debug C-Kermit.
  2434.  
  2435.  
  2436. 15. SYSLOGGING
  2437.  
  2438. "Syslogging" means recording selected in the system log via the UNIX syslog()
  2439. facility, which is available in most UNIX versions.  Syslogging is not done
  2440. unless C-Kermit is started with:
  2441.  
  2442.   --syslog:n
  2443.  
  2444. on the command-line, where n is a number greater than 0 to indicate the level
  2445. of syslogging.  See iksd.txt Section 4.2 for details.
  2446.  
  2447. Obviously you can't depend on users to include --syslog:3 (or whatever) on the
  2448. command line every time they start C-Kermit, so if you want certain kinds of
  2449. records to be recorded in the system log, you can build C-Kermit with forced
  2450. syslogging at the desired level, e.g.:
  2451.  
  2452.   make linux KFLAGS=-DSYSLOGLEVEL=2
  2453.  
  2454. Levels 2 and 3 are the most likely candidates for this treatment.  Level 2
  2455. forces logging of all successful dialout calls (e.g. for checking against or
  2456. phone bills), and level 3 records all connections (SET LINE or SET HOST /
  2457. TELNET / RLOGIN, etc) so you can see who is connecting out from your system,
  2458. and to where.
  2459.  
  2460. Level 2 and 3 records are equivalent to those in the connection log; see
  2461. ckermit2.txt for a detailed description of the connection log.
  2462.  
  2463.  
  2464. 16. SECURITY OPTIONS
  2465.  
  2466. C-Kermit 6.1 and later may be built with Kerberos(TM) and/or SRP(TM) (Secure
  2467. Remote Password) capabilities.  These require external libraries that are
  2468. restricted from export by USA law.  See the security.txt file for details.
  2469.  
  2470. Sample makefile entries are provided for Linux:
  2471.  
  2472.   linux:               Regular Linux C-Kermit
  2473.   linux+krb5:          Linux C-Kermit with Kerberos V support
  2474.   linux+krb5+krb4:     Linux C-Kermit with Kerberos IV and V support
  2475.   linux+srp:           Linux C-Kermit with SRP
  2476.   linux+srp+no-des:    Linux C-Kermit with SRP but no DES
  2477.   linux+srp-export:    Linux C-Kermit with SRP, exportable
  2478.   linux+srp+pam:       Linux C-Kermit with SRP with PAM authentication
  2479.   linux+krb5+krb4+srp: Linux C-Kermit with Kerberos IV and V support + SRP
  2480.  
  2481. and so on.  Similarly for other platforms like Solaris, AIX, etc.  Others
  2482. can be added modeled on the ones in the makefile.
  2483.  
  2484. (End of ckuins.txt)
  2485.