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

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