Delete gnu/dist/gkermit, and the reachover Makefile in gnu/usr.bin/gkermit.
It is being replaced by the BSD-licenced ekermit, as proposed on tech-userlevel on 7 Aug 2014.
This commit is contained in:
parent
0c788622cb
commit
6dd38064f5
105
gnu/dist/gkermit/ANNOUNCE
vendored
105
gnu/dist/gkermit/ANNOUNCE
vendored
@ -1,105 +0,0 @@
|
||||
From news@columbia.edu Fri Dec 17 21:05:44 1999
|
||||
From: fdc@watsun.cc.columbia.edu (Frank da Cruz)
|
||||
Subject: Announcing a new GPL'd Kermit program for UNIX
|
||||
Date: 18 Dec 1999 01:49:54 GMT
|
||||
Organization: Columbia University
|
||||
Message-ID: <83ep82$8st$1@newsmaster.cc.columbia.edu>
|
||||
To: kermit.misc@columbia.edu
|
||||
|
||||
|
||||
This to announce a brief testing period for a new, compact, and GPL'd
|
||||
Kermit program for UNIX. The new program is called G-Kermit (GNU Kermit).
|
||||
It is intended to meet the need for a Kermit protocol implementation
|
||||
that is:
|
||||
|
||||
. Stable and low-maintenance
|
||||
. Small and fast with no frills
|
||||
. Released under the GNU Public License
|
||||
|
||||
G-Kermit is command-line only (no interactive commands or scripting) and
|
||||
remote-mode only (no making connections). It has an extremely simple user
|
||||
interface, and implements a large subset of the Kermit protocol in a small
|
||||
amount of highly portable code.
|
||||
|
||||
It has been built and tested on a wide variety of UNIX platforms, ranging
|
||||
from early-1980s-era to up-to-the-minute, using both traditional C and
|
||||
ANSI C. It is designed to be as independent as possible of platform-
|
||||
specific features, and therefore to be stable for many years if we resist
|
||||
the temptation to add features to it. The size of the binary ranges from
|
||||
29K (on HP-UX 8.00) to 99K on Ultrix/MIPS, with an average size of 52K
|
||||
over 37 builds, and a typical size of 34K on PC-based UNIXes.
|
||||
|
||||
It's easy to build, install, and uninstall. It requires no privileges.
|
||||
Documentation is included as a plain-text README file and a man page.
|
||||
|
||||
You can find G-Kermit 1.00 Beta.01 at:
|
||||
|
||||
ftp://kermit.columbia.edu/kermit/test/tar/gkermit.tar.Z (78K)
|
||||
ftp://kermit.columbia.edu/kermit/test/tar/gkermit.tar.gz (53K)
|
||||
|
||||
Uncompress, untar, read the README file, and take it from there (in most
|
||||
cases you just type "make" to build it).
|
||||
|
||||
Send test reports to kermit-support@columbia.edu.
|
||||
|
||||
- Frank
|
||||
|
||||
------------------------------
|
||||
Updates since the first Beta release:
|
||||
|
||||
Beta.02 20 Dec 99:
|
||||
. Handle situation in which gkermit was built with MAXRP < DEFRP.
|
||||
. Handle situation in which gkermit was built with MAXRP > 9020.
|
||||
. Don't allocate tinbuf[] if built with USE_GETCHAR.
|
||||
. Fix cmdlin() to return start state.
|
||||
. Updates & fixes to README incl notes about HP-UX 6.5.
|
||||
. Don't show bogus packet in debug log if user interrupted with ^C...
|
||||
. Use EAGAIN instead of EWOULDBLOCK on SVR3 and earlier.
|
||||
. Fixed interruption vs streaming (but the fix was in C-Kermit).
|
||||
|
||||
Beta.03 21 Dec 99:
|
||||
. <srfil>F was not encoding the filename before sending it back in the ACK.
|
||||
. Avoid creating files with multiple backup prefixes.
|
||||
. Change clean target in makefile to not use wildcards (for HP-UX 6 and 7).
|
||||
. Add missing option -w to usage message.
|
||||
. Fixed assorted typos and errors in README.
|
||||
. Changed crc routine to guard better against sign extension.
|
||||
. Catch transmission errors when receiving and streaming.
|
||||
. Added -x switch to let user force Xon/Xoff if not built with SETXONXOFF.
|
||||
. Removed ttflui() call from streamon() - it wrecked multifile transfers.
|
||||
|
||||
Beta.04 22 Dec 99:
|
||||
. Changed non-ANSI VOID def from nothing to int.
|
||||
. Added -DNOXONXOFF to override automatic setting of Xon/Xoff on HPUX.
|
||||
. In decode(), got rid of zputc() -- just call putc() inline.
|
||||
. More debugging.
|
||||
|
||||
Beta.05 23 Dec 99:
|
||||
. Add zchko() and call it from rcvfil().
|
||||
. Change zrtol() and zbackup() to return success/failure codes; this prevents
|
||||
gkermit from overwriting original file if zbackup fails, e.g. on
|
||||
NFS-mounted DOS file system.
|
||||
|
||||
Beta.06 23 Dec 99:
|
||||
. Sleep a sec after erroring out & before exiting to allow any/some/more
|
||||
incoming packets to be absorbed by ttflui() in doexit().
|
||||
. Improved the E-packet messages.
|
||||
. Added stty target to makefile.
|
||||
. Added support for 2.11BSD (16-bit. 64K address space) and bsd211 target.
|
||||
|
||||
Beta.07 24 Dec 99:
|
||||
. Allowed for SIG_I and SIG_V definition on CC command line.
|
||||
. Added --x to override automatic setting of Xon/Xoff.
|
||||
. gkermit -d now runs ttopen and ttpkt to record settings in debug log.
|
||||
. Fixed recording of GKERMIT options in debug log.
|
||||
. Allowed gkermit to receive NULs unprefixed.
|
||||
. Allowed -d to take an optional filename arg.
|
||||
. Fixed backup file creation to avoid duplicate backup suffixes.
|
||||
|
||||
Beta.08 25 Dec 99:
|
||||
. Fixed zbackup() to not create filenames longer than MAXPATHLEN.
|
||||
. Fixed reception of files containing NUL bytes.
|
||||
. Final cleanup with "gcc -Wall".
|
||||
|
||||
Release 1.00 25 Dec 99.
|
||||
------------------------------
|
340
gnu/dist/gkermit/COPYING
vendored
340
gnu/dist/gkermit/COPYING
vendored
@ -1,340 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 19yy <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
1014
gnu/dist/gkermit/README
vendored
1014
gnu/dist/gkermit/README
vendored
File diff suppressed because it is too large
Load Diff
367
gnu/dist/gkermit/gcmdline.c
vendored
367
gnu/dist/gkermit/gcmdline.c
vendored
@ -1,367 +0,0 @@
|
||||
/* G C M D L I N -- gkermit command line parser */
|
||||
|
||||
/*
|
||||
Author:
|
||||
Frank da Cruz
|
||||
The Kermit Project
|
||||
Columbia University
|
||||
612 West 115th Street
|
||||
New York NY 10025-7799 USA
|
||||
http://www.columbia.edu/kermit/
|
||||
kermit@columbia.edu
|
||||
|
||||
Copyright (C) 1999,
|
||||
The Trustees of Columbia University in the City of New York.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "gkermit.h"
|
||||
|
||||
/* Externals */
|
||||
|
||||
extern int nfils, parity, text, backup, rpsiz, urpsiz, timint;
|
||||
extern int literal, quiet, keep, streamok, nomodes, manual, xonxoff, noxonxoff;
|
||||
extern char ttname[], *cmerrp, *cmarg, *cmarg2;
|
||||
extern FILE * db;
|
||||
|
||||
/* Variables exported from this module */
|
||||
|
||||
extern char **cmlist; /* Pointer to file list in argv */
|
||||
extern char **xargv; /* Global copies of argv */
|
||||
extern int xargc; /* and argc */
|
||||
|
||||
/* Variables and symbols local to this module */
|
||||
|
||||
static int action = 0; /* Action selected on command line */
|
||||
|
||||
_MYPROTOTYPE( static int doarg, (char) );
|
||||
_MYPROTOTYPE( VOID fatal, (char *) );
|
||||
_MYPROTOTYPE( VOID usage, (void) );
|
||||
|
||||
#ifndef NOGETENV
|
||||
#define GARGC 32
|
||||
#define GBUFSIZ 256
|
||||
static char gbuf[GBUFSIZ], *gargs[GARGC], *gptr = NULL;
|
||||
static int gargc;
|
||||
#endif /* NOGETENV */
|
||||
|
||||
int /* Command-line parser */
|
||||
cmdlin() {
|
||||
char c;
|
||||
int x;
|
||||
#ifndef NOGETENV
|
||||
char * p = NULL;
|
||||
#endif /* NOGETENV */
|
||||
|
||||
cmarg = ""; /* Initialize results */
|
||||
cmlist = NULL;
|
||||
action = 0;
|
||||
|
||||
#ifndef NOGETENV
|
||||
if ((p = getenv("GKERMIT"))) {
|
||||
int i, xc, flag = 0;
|
||||
char **xv = NULL;
|
||||
|
||||
strncpy(gbuf,p,GBUFSIZ-1); /* Make a pokeable copy */
|
||||
gbuf[GBUFSIZ-1] = NUL;
|
||||
gptr = p;
|
||||
p = gbuf;
|
||||
|
||||
/* Turn it into an argument vector */
|
||||
|
||||
for (i = 0; gbuf[i] && i < GBUFSIZ && gargc < GARGC; i++) {
|
||||
if (!flag) {
|
||||
if (gbuf[i] <= SP)
|
||||
continue;
|
||||
flag = 1;
|
||||
gargs[gargc++] = &gbuf[i];
|
||||
} else if (flag && gbuf[i] <= SP) {
|
||||
gbuf[i] = NUL;
|
||||
flag = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
xv = xargv; /* Save original argument vector */
|
||||
xc = xargc;
|
||||
xargv = gargs; /* Redirect it to the one we made */
|
||||
xargc = gargc;
|
||||
|
||||
while (xargc-- > 0) { /* Go through the words */
|
||||
if (**xargv == '-') { /* Got an option (begins with dash) */
|
||||
c = *(*xargv+1); /* Get the option letter */
|
||||
x = doarg(c); /* Go handle the option */
|
||||
if (x < 0) doexit(1);
|
||||
} else { /* No dash where expected */
|
||||
fprintf(stderr,
|
||||
"?GKERMIT variable option error: \"%s\"\n",
|
||||
*xargv
|
||||
);
|
||||
usage(); /* Give usage message */
|
||||
doexit(0);
|
||||
}
|
||||
xargv++;
|
||||
}
|
||||
xargv = xv; /* Restore original argument vector */
|
||||
xargc = xc;
|
||||
}
|
||||
#endif /* NOGETENV */
|
||||
|
||||
while (--xargc > 0) { /* Go through command line words */
|
||||
xargv++;
|
||||
if (**xargv == '-') { /* Got an option (begins with dash) */
|
||||
c = *(*xargv+1); /* Get the option letter */
|
||||
x = doarg(c); /* Go handle the option */
|
||||
if (x < 0) doexit(1);
|
||||
} else { /* No dash where expected */
|
||||
fprintf(stderr,"?Command-line option error: \"%s\"\n", *xargv);
|
||||
usage(); /* Give usage message */
|
||||
doexit(1);
|
||||
}
|
||||
}
|
||||
return(action); /* Then do any requested protocol */
|
||||
}
|
||||
|
||||
/* D O A R G -- Do a command-line argument. */
|
||||
|
||||
static int
|
||||
#ifdef __STDC__
|
||||
doarg(char x)
|
||||
#else
|
||||
doarg(x) char x;
|
||||
#endif /* __STDC__ */
|
||||
{
|
||||
int z; char *xp, **p;
|
||||
|
||||
xp = *xargv+1; /* Pointer for bundled args */
|
||||
while (x) {
|
||||
switch (x) {
|
||||
case 'r': /* Receive */
|
||||
if (action) fatal("conflicting actions");
|
||||
action = 'v';
|
||||
break;
|
||||
|
||||
case 's': /* Send */
|
||||
if (action) fatal("conflicting actions");
|
||||
if (*(xp+1)) fatal("invalid argument bundling after -s");
|
||||
nfils = 0; /* Initialize file counter, flag */
|
||||
cmlist = xargv+1; /* Remember this pointer */
|
||||
if (zchki(*cmlist) < 0)
|
||||
fatal("file not found or not accessible");
|
||||
while (--xargc > 0) { /* Traverse the list */
|
||||
*xargv++;
|
||||
if (**xargv == '-')
|
||||
break;
|
||||
nfils++;
|
||||
}
|
||||
xargc++, *xargv--; /* Adjust argv/argc */
|
||||
if (nfils < 1) fatal("missing filename for -s");
|
||||
action = 's';
|
||||
break;
|
||||
|
||||
case 'g': /* get */
|
||||
if (action) fatal("conflicting actions");
|
||||
if (*(xp+1)) fatal("invalid argument bundling after -g");
|
||||
*xargv++, xargc--;
|
||||
if ((xargc == 0) || (**xargv == '-'))
|
||||
fatal("missing filename for -g");
|
||||
cmarg = *xargv;
|
||||
action = 'r';
|
||||
break;
|
||||
|
||||
case 'h': /* Help */
|
||||
case '?':
|
||||
usage();
|
||||
doexit(0);
|
||||
|
||||
case 'i': /* Binary (image) file transfer */
|
||||
manual = 1;
|
||||
text = 0;
|
||||
break;
|
||||
|
||||
case 'T': /* Text file transfer */
|
||||
manual = 1;
|
||||
text = 1;
|
||||
break;
|
||||
|
||||
case 'p': /* Parity */
|
||||
if (*(xp+1)) fatal("invalid argument bundling");
|
||||
*xargv++, xargc--;
|
||||
if ((xargc < 1) || (**xargv == '-'))
|
||||
fatal("missing parity");
|
||||
switch(x = **xargv) {
|
||||
case 'e': /* Even */
|
||||
case 'o': /* Odd */
|
||||
case 'm': /* Mark */
|
||||
case 's': parity = x; break; /* Space */
|
||||
case 'n': parity = 0; break; /* None */
|
||||
default: fatal("invalid parity");
|
||||
}
|
||||
break;
|
||||
|
||||
case 'w': /* Writeover */
|
||||
backup = 0; /* Don't back up existing files */
|
||||
break;
|
||||
|
||||
case 'd': /* Debug */
|
||||
p = xargv;
|
||||
*p++;
|
||||
if ((xargc < 2) || (**p == '-')) {
|
||||
db = fopen("debug.log","w");
|
||||
} else {
|
||||
*xargv++, xargc--;
|
||||
db = fopen(*xargv,"w");
|
||||
}
|
||||
if (db) {
|
||||
extern char * versio, * build;
|
||||
if (!versio) versio = "";
|
||||
if (!build) build = "";
|
||||
debug = 1;
|
||||
setbuf(db,NULL);
|
||||
fprintf(db,"%s: %s\n",
|
||||
(*versio ? versio : "GKERMIT VERSION UNKNOWN"),
|
||||
(*build ? build : "BUILD UNKNOWN")
|
||||
);
|
||||
fprintf(db,"MAXPATHLEN = %d\n",MAXPATHLEN);
|
||||
if (gptr) fprintf(db,"GKERMIT=\"%s\"\n",gptr);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'a': /* As-name */
|
||||
if (*(xp+1)) fatal("invalid argument bundling after -a");
|
||||
*xargv++, xargc--;
|
||||
if ((xargc == 0) || (**xargv == '-'))
|
||||
fatal("missing name for -a");
|
||||
cmarg2 = *xargv;
|
||||
if (debug) fprintf(db,"as-name: %s\n",cmarg2);
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
if (*(xp+1)) fatal("invalid argument bundling after -e");
|
||||
xargv++, xargc--;
|
||||
if ((xargc < 1) || (**xargv == '-'))
|
||||
fatal("missing length");
|
||||
z = atoi(*xargv); /* Convert to number. */
|
||||
if (z >= 40 && z <= MAXRP) {
|
||||
rpsiz = urpsiz = z;
|
||||
if (z > 94) rpsiz = 94; /* Fallback if other Kermit can't */
|
||||
} else { /* do long packets. */
|
||||
fatal("Unsupported packet length");
|
||||
}
|
||||
break;
|
||||
|
||||
case 'b': /* Timeout */
|
||||
if (*(xp+1)) fatal("invalid argument bundling after -b");
|
||||
xargv++, xargc--;
|
||||
if ((xargc < 1) || (**xargv == '-'))
|
||||
fatal("missing value");
|
||||
z = atoi(*xargv); /* Convert to number */
|
||||
if (z < 0) z = 0;
|
||||
if (z > 90) z = 90;
|
||||
timint = z;
|
||||
break;
|
||||
|
||||
case 'P': /* Path (file) names literal */
|
||||
literal = 1;
|
||||
break;
|
||||
|
||||
case 'q': /* Quiet */
|
||||
quiet = 1;
|
||||
break;
|
||||
|
||||
case 'K': /* Keep incompletely received files */
|
||||
keep = 1;
|
||||
break;
|
||||
|
||||
case 'S': /* Disable streaming */
|
||||
streamok = -1;
|
||||
break;
|
||||
|
||||
case 'X': /* gkermit is an external protocol */
|
||||
quiet = 1; /* No messages */
|
||||
nomodes = 1; /* Don't set tty modes */
|
||||
break;
|
||||
|
||||
case 'x': /* Force Xon/Xoff */
|
||||
xonxoff = 1;
|
||||
noxonxoff = 0;
|
||||
break;
|
||||
|
||||
case '-': /* Don't force Xon/Xoff */
|
||||
if (*(xp+1) == 'x') {
|
||||
xonxoff = 0;
|
||||
noxonxoff = 1;
|
||||
} else {
|
||||
fatal("invalid argument, type 'gkermit -h' for help");
|
||||
}
|
||||
xp++;
|
||||
break;
|
||||
|
||||
default: /* Anything else */
|
||||
fatal("invalid argument, type 'gkermit -h' for help");
|
||||
}
|
||||
x = *++xp; /* See if options are bundled */
|
||||
}
|
||||
if (debug) {
|
||||
if (action)
|
||||
fprintf(db,"cmdlin action = %c\n",action);
|
||||
else
|
||||
fprintf(db,"cmdlin action = (none)\n");
|
||||
}
|
||||
return(action);
|
||||
}
|
||||
|
||||
VOID
|
||||
fatal(msg) char *msg; { /* Fatal error message */
|
||||
fprintf(stderr,"\r\nFatal: %s",msg); /* doexit supplies crlf.. */
|
||||
doexit(1); /* Exit indicating failure */
|
||||
}
|
||||
|
||||
VOID
|
||||
usage() {
|
||||
extern char * versio, * build, * url, * email;
|
||||
if (!versio) versio = "";
|
||||
if (!*versio) versio = "gkermit UNKNOWN VERSION";
|
||||
if (!build) build = "UNKNOWN BUILD";
|
||||
if (!url) url = "";
|
||||
if (!email) email = "";
|
||||
fprintf(stderr,"%s: %s.\n",versio,build);
|
||||
fprintf(stderr,"Usage: gkermit [ options ]\n");
|
||||
fprintf(stderr,"Options:\n");
|
||||
fprintf(stderr," -r Receive files\n");
|
||||
fprintf(stderr," -s fn Send files\n");
|
||||
fprintf(stderr," -g fn Get files from server\n");
|
||||
fprintf(stderr," -a fn As-name for single file\n");
|
||||
fprintf(stderr," -i Image (binary) mode transfer\n");
|
||||
fprintf(stderr," -T Text mode transfer\n");
|
||||
fprintf(stderr," -P Path/filename conversion disabled\n");
|
||||
fprintf(stderr," -w Write over existing files with same name\n");
|
||||
fprintf(stderr," -K Keep incompletely received files\n");
|
||||
fprintf(stderr," -p x Parity: x = o[dd],e[ven],m[ark],s[pace],n[one]\n")
|
||||
;
|
||||
fprintf(stderr," -e n Receive packet-length (40-%d)\n",MAXRP);
|
||||
fprintf(stderr," -b n Timeout (sec, 0 = none)\n");
|
||||
fprintf(stderr," -x Force Xon/Xoff (--x = Don't force Xon/Xoff)\n");
|
||||
fprintf(stderr," -S Disable streaming\n");
|
||||
fprintf(stderr," -X External protocol\n");
|
||||
fprintf(stderr," -q Quiet (suppress messages)\n");
|
||||
fprintf(stderr," -d [fn] Debug to ./debug.log [or specified file]\n");
|
||||
fprintf(stderr," -h Help (this message)\n");
|
||||
if (*url || *email)
|
||||
fprintf(stderr,"More info: %s <%s>",url,email);
|
||||
}
|
1092
gnu/dist/gkermit/gkermit.c
vendored
1092
gnu/dist/gkermit/gkermit.c
vendored
File diff suppressed because it is too large
Load Diff
247
gnu/dist/gkermit/gkermit.h
vendored
247
gnu/dist/gkermit/gkermit.h
vendored
@ -1,247 +0,0 @@
|
||||
/* G K E R M I T . H -- GNU Kermit header */
|
||||
/*
|
||||
Author:
|
||||
Frank da Cruz
|
||||
The Kermit Project
|
||||
Columbia University
|
||||
612 West 115th Street
|
||||
New York NY 10025-7799 USA
|
||||
http://www.columbia.edu/kermit/
|
||||
kermit@columbia.edu
|
||||
|
||||
Copyright (C) 1999,
|
||||
The Trustees of Columbia University in the City of New York.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _GKERMIT_H
|
||||
#define _GKERMIT_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Kermit protocol definitions */
|
||||
|
||||
#define MAXTRY 10 /* Packet retry limit */
|
||||
|
||||
#ifndef SMALL /* Define small systems here */
|
||||
#ifdef pdp11 /* PDP-11 (64K address space) */
|
||||
#define SMALL
|
||||
#endif /* pdp11 */
|
||||
#endif /* SMALL */
|
||||
|
||||
#ifdef SMALL /* Buffer sizes for small systems */
|
||||
|
||||
#define MAXSP 4000
|
||||
#define MAXRP 4000
|
||||
#define DEFRP 1000
|
||||
#define MAXPATHLEN 255
|
||||
#define DEVNAMLEN 64
|
||||
#define MAXRECORD 255
|
||||
|
||||
#else /* 32-bit and 64-bit platforms... */
|
||||
|
||||
#ifndef MAXSP
|
||||
#define MAXSP 9000 /* Maximum send packet size */
|
||||
#endif /* MAXSP */
|
||||
|
||||
#ifndef MAXRP /* Maximum receive packet size */
|
||||
#define MAXRP 9000
|
||||
#endif /* MAXRP */
|
||||
|
||||
#ifndef DEFRP /* Default receive packet size */
|
||||
#define DEFRP 4000
|
||||
#endif /* DEFRP */
|
||||
|
||||
#endif /* SMALL */
|
||||
|
||||
#define CTTNAM "/dev/tty" /* Default terminal name */
|
||||
|
||||
/* Sizes for file/device-name and file i/o buffers */
|
||||
|
||||
#ifndef MAXPATHLEN /* Maximum file specification length */
|
||||
#define MAXPATHLEN 1024
|
||||
#endif /* MAXPATHLEN */
|
||||
|
||||
#ifndef MAXNAMLEN /* Maximum file name length */
|
||||
#define MAXNAMLEN 256
|
||||
#endif /* MAXNAMLEN */
|
||||
|
||||
#ifndef DEVNAMLEN /* Maximum device name length */
|
||||
#define DEVNAMLEN 1024
|
||||
#endif /* DEVNAMLEN */
|
||||
|
||||
#ifndef MAXRECORD /* Text file input buffer length */
|
||||
#define MAXRECORD 4080
|
||||
#endif /* MAXRECORD */
|
||||
|
||||
#ifdef __STDC__
|
||||
#define VOID void
|
||||
#else
|
||||
#define VOID int
|
||||
#endif /* __STDC__ */
|
||||
|
||||
/* SVORPOSIX = System V or POSIX */
|
||||
|
||||
#ifndef SVORPOSIX
|
||||
#ifdef POSIX
|
||||
#define SVORPOSIX
|
||||
#else
|
||||
#ifdef SYSV
|
||||
#define SVORPOSIX
|
||||
#endif /* SYSV */
|
||||
#endif /* POSIX */
|
||||
#endif /* SVORPOSIX */
|
||||
|
||||
/* Signal type */
|
||||
|
||||
#ifndef SIG_V
|
||||
#ifndef SIG_I
|
||||
#ifdef SVORPOSIX
|
||||
#define SIG_V
|
||||
#else
|
||||
#define SIG_I
|
||||
#endif /* SVORPOSIX */
|
||||
#endif /* SIG_I */
|
||||
#endif /* SIG_V */
|
||||
|
||||
#ifdef SIG_I
|
||||
#define SIGRETURN return(0)
|
||||
#ifndef SIGTYP
|
||||
#define SIGTYP int
|
||||
#endif /* SIGTYP */
|
||||
#else
|
||||
#ifdef SIG_V
|
||||
#define SIGRETURN return
|
||||
#ifndef SIGTYP
|
||||
#define SIGTYP void
|
||||
#endif /* SIGTYP */
|
||||
#endif /* SIG_V */
|
||||
#endif /* SIG_I */
|
||||
|
||||
/* WHATAMI bit definitions */
|
||||
|
||||
#define WMI_FMODE 2 /* File transfer mode */
|
||||
#define WMI_FNAME 4 /* File name conversion */
|
||||
#define WMI_STREAM 8 /* I have a reliable transport */
|
||||
#define WMI_CLEAR 16 /* I have a clear channel */
|
||||
#define WMI_FLAG 32 /* Flag that WHATAMI field is valid */
|
||||
#define WMI2_XMODE 1 /* Transfer mode auto(0)/manual(1) */
|
||||
#define WMI2_RECU 2 /* Transfer is recursive */
|
||||
#define WMI2_FLAG 32 /* Flag that WHATAMI2 field is valid */
|
||||
|
||||
/* Data types */
|
||||
|
||||
#ifndef CHAR
|
||||
#define CHAR unsigned char
|
||||
#endif /* CHAR */
|
||||
|
||||
#ifndef ULONG
|
||||
#define ULONG unsigned long
|
||||
#endif /* ULONG */
|
||||
|
||||
/* Pointer and character constants */
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0 /* NULL pointer */
|
||||
#endif /* NULL */
|
||||
|
||||
#define NUL '\000' /* ASCII NUL character */
|
||||
#define LF '\012' /* ASCII Linefeed */
|
||||
#define CR '\015' /* ASCII Carriage Return */
|
||||
#define SP '\040' /* ASCII space character */
|
||||
#define DEL 127 /* ASCII DEL */
|
||||
|
||||
/* Macros */
|
||||
|
||||
#define tochar(ch) ((ch) + SP ) /* Number to character */
|
||||
#define xunchar(ch) ((ch) - SP ) /* Character to number */
|
||||
#define ctl(ch) ((ch) ^ 64 ) /* Controllify/Uncontrollify */
|
||||
#define zgetc(a) (((--zincnt)>=0) ? ((int)(*zinptr++) & 0xff) : zfillbuf(a))
|
||||
|
||||
/* Function prototype macro works for both ANSI and K&R C */
|
||||
|
||||
#ifdef __STDC__
|
||||
#define _MYPROTOTYPE( func, parms ) func parms
|
||||
#else
|
||||
#define _MYPROTOTYPE( func, parms ) func()
|
||||
#endif /* __STDC__ */
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
_MYPROTOTYPE( SIGTYP doexit, (int) );
|
||||
_MYPROTOTYPE( VOID sysinit, (void) );
|
||||
_MYPROTOTYPE( char dopar, (char) );
|
||||
_MYPROTOTYPE( VOID tmsg, (char *) );
|
||||
_MYPROTOTYPE( VOID tmsgl, (char *) );
|
||||
_MYPROTOTYPE( int ttopen, (char *) );
|
||||
_MYPROTOTYPE( int ttpkt, (int) );
|
||||
_MYPROTOTYPE( int ttres, (void) );
|
||||
_MYPROTOTYPE( int ttinl, (char *, int, int, char, char, int) );
|
||||
_MYPROTOTYPE( int ttol, (char *, int) );
|
||||
_MYPROTOTYPE( int ttchk, (void) );
|
||||
_MYPROTOTYPE( int ttflui, (void) );
|
||||
_MYPROTOTYPE( long zchki, (char *) );
|
||||
_MYPROTOTYPE( int zchko, (char *) );
|
||||
_MYPROTOTYPE( int zopeni, (char *) );
|
||||
_MYPROTOTYPE( int zopeno, (char *) );
|
||||
_MYPROTOTYPE( int zclosi, (void) );
|
||||
_MYPROTOTYPE( int zcloso, (int) );
|
||||
_MYPROTOTYPE( int zfillbuf, (int) );
|
||||
_MYPROTOTYPE( VOID zltor, (char *, char *, int) );
|
||||
_MYPROTOTYPE( int zrtol, (char *, char *, int, int) );
|
||||
_MYPROTOTYPE( int zbackup, (char *) );
|
||||
|
||||
_MYPROTOTYPE( int input, (void) ); /* Input to state machine (like lex) */
|
||||
_MYPROTOTYPE( VOID nxtpkt, (void) ); /* Increment packet number */
|
||||
_MYPROTOTYPE( int ack, (void) ); /* Send empty Acknowledgment */
|
||||
_MYPROTOTYPE( int ack1, (char *) ); /* Send data-bearing Acknowledgment */
|
||||
_MYPROTOTYPE( int nak, (void) ); /* Send Negative acknowledgement */
|
||||
_MYPROTOTYPE( VOID tinit, (void) ); /* Transaction initialization */
|
||||
_MYPROTOTYPE( VOID errpkt, (char *) ); /* Send error packet */
|
||||
_MYPROTOTYPE( int sinit, (char) ); /* Send S packet */
|
||||
_MYPROTOTYPE( int sfile, (void) ); /* Send File header packet */
|
||||
_MYPROTOTYPE( int sdata, (void) ); /* Send Data packet */
|
||||
_MYPROTOTYPE( int seof, (char *) ); /* Send EOF packet */
|
||||
_MYPROTOTYPE( int seot, (void) ); /* Send EOT packet */
|
||||
_MYPROTOTYPE( int resend, (void) ); /* Resend a packet */
|
||||
_MYPROTOTYPE( int decode, (int) ); /* Decode packet data field */
|
||||
_MYPROTOTYPE( int encstr, (char *) ); /* Encode a memory string */
|
||||
_MYPROTOTYPE( int gattr, (char *) ); /* Get incoming file attributes */
|
||||
_MYPROTOTYPE( int sattr, (void) ); /* Send file attributes */
|
||||
_MYPROTOTYPE( VOID ginit, (void) ); /* Transaction initialization */
|
||||
_MYPROTOTYPE( int scmd, (char, char *) ); /* Send command to Kermit server */
|
||||
_MYPROTOTYPE( VOID rinit, (void) ); /* Receive initialization */
|
||||
_MYPROTOTYPE( int gnfile, (void) ); /* Get next filename */
|
||||
_MYPROTOTYPE( int rcvfil, (void) ); /* Receive incoming file */
|
||||
_MYPROTOTYPE( VOID spar, (char *) ); /* Set parameters from other Kermit */
|
||||
_MYPROTOTYPE( char *rpar, (void) ); /* Tell parameters to other Kermit */
|
||||
_MYPROTOTYPE( VOID usage, (void) ); /* Give usage message */
|
||||
_MYPROTOTYPE( int gwart, (void) ); /* State table switcher */
|
||||
|
||||
/* Externs */
|
||||
|
||||
#ifdef ERRNO_H
|
||||
#include <errno.h>
|
||||
#else
|
||||
extern int errno;
|
||||
#endif /* ERRNO_H */
|
||||
#ifndef _GKERMIT_C
|
||||
extern int debug;
|
||||
#endif /* _GKERMIT_C */
|
||||
|
||||
#endif /* _GKERMIT_H */
|
||||
|
||||
/* End gkermit.h */
|
342
gnu/dist/gkermit/gkermit.nr
vendored
342
gnu/dist/gkermit/gkermit.nr
vendored
@ -1,342 +0,0 @@
|
||||
.\" @(#) gkermit.1 1.00 Columbia University 1999/12/25
|
||||
.TH GKERMIT 1C "25 Dec 1999" "UNIX G-Kermit"
|
||||
.SH NAME
|
||||
gkermit \- G-Kermit (GNU Kermit) 1.00 file transfer software.
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.sp
|
||||
gkermit [ options ] -s file(s) Send files
|
||||
gkermit [ options ] -g file(s) Get files
|
||||
gkermit [ options ] -r Receive files
|
||||
.PP
|
||||
.SH DESCRIPTION
|
||||
G-Kermit is a UNIX program for transferring files using the
|
||||
Kermit protocol. G-Kermit is a product of Kermit Project at Columbia
|
||||
University. It is free software under the GNU Public License. See the
|
||||
COPYING file for details.
|
||||
.PP
|
||||
.SS INVOKING G-KERMIT
|
||||
.PP
|
||||
The G-Kermit binary is called "gkermit". It should be stored someplace
|
||||
in your UNIX PATH; normally it is available as /usr/local/bin/gkermit.
|
||||
To run G-Kermit, just type "gkermit" followed by command-line options that
|
||||
tell it what to do. If no options are given, it prints a usage message
|
||||
listing the available options.
|
||||
.PP
|
||||
If an option takes an argument, the argument is required; if an option does
|
||||
not take an argument, no argument may be given (exception: -d). The action
|
||||
options are -r, -s, and -g. Only one action option may be given. If no
|
||||
action options are given, G-Kermit does nothing (except possibly to print its
|
||||
usage message or create a debug.log file). Here are some examples ("$ " is
|
||||
the shell prompt):
|
||||
.nf
|
||||
.sp
|
||||
$ gkermit -s hello.c <-- Send the hello.c file
|
||||
$ gkermit -s hello.* <-- Send all hello.* files
|
||||
$ gkermit -r <-- Wait to receive files
|
||||
$ gkermit -g hello.c <-- Get hello.c file
|
||||
$ gkermit -g hello.\\* <-- Get all hello.* files
|
||||
.sp
|
||||
.fi
|
||||
Options that do not take arguments can be "bundled" with other options.
|
||||
An option that takes an argument must always be followed by a space and
|
||||
then its argument(s). Examples:
|
||||
.nf
|
||||
.sp
|
||||
$ gkermit -is hello.o <-- Send hello.o in binary mode
|
||||
$ gkermit -dr <-- Receive with debugging
|
||||
.sp
|
||||
.fi
|
||||
.SS COMMAND-LINE OPTIONS
|
||||
.sp
|
||||
.nf
|
||||
-r RECEIVE. Wait for incoming files.
|
||||
-s fn SEND. Send file(s) specified by fn.
|
||||
-g fn GET. Get specified file(s) from server.
|
||||
-a fn AS-NAME. Alternative name for file.
|
||||
-i IMAGE. Binary-mode transfer (default).
|
||||
-T TEXT. Text-mode transfer.
|
||||
-P PATH (filename) conversion disabled.
|
||||
-w WRITEOVER when filenames collide.
|
||||
-K KEEP incompletely received files.
|
||||
-p x PARITY. x = e,o,m,s,n; default = n(one).
|
||||
-e n PACKET LENGTH. n = 40-9000; default=4000.
|
||||
-b n TIMEOUT. Per-packet timeout, seconds.
|
||||
-x XON/XOFF. Set Xon/Xoff in the tty driver.
|
||||
--x Unset Xon/Xoff in the tty driver.
|
||||
-S STREAMING disabled.
|
||||
-X EXTERNAL. G-Kermit is an external protocol.
|
||||
-q QUIET. Suppress messages.
|
||||
-d DEBUG. Write debugging info to ./debug.log.
|
||||
-d fn DEBUG. Write debugging info to given file.
|
||||
-h HELP. Display brief usage message.
|
||||
.fi
|
||||
.PP
|
||||
You may supply options to G-Kermit on the command line or through the
|
||||
GKERMIT environment variable, which can contain any valid gkermit
|
||||
command-line options. These are processed before the actual command-line
|
||||
options and so can be overridden by them. Example for bash or ksh, which you
|
||||
can put in your profile if you want to always keep incomplete files, suppress
|
||||
streaming, suppress messages, and use Space parity:
|
||||
.nf
|
||||
.sp
|
||||
export GKERMIT="-K -S -q -p s"
|
||||
.fi
|
||||
.PP
|
||||
.SS MECHANICS OF FILE TRANSFER
|
||||
.PP
|
||||
To transfer files with G-Kermit you must be connected through a terminal
|
||||
emulator to the UNIX system where G-Kermit is running, meaning you are
|
||||
online to UNIX and have access to the shell prompt (or to a menu that has
|
||||
an option to invoke G-Kermit). The connection can be serial (direct or
|
||||
dialed) or network (Telnet, Rlogin, X.25, etc).
|
||||
.PP
|
||||
When you tell G-Kermit to SEND a file (or files), e.g. with:
|
||||
.nf
|
||||
.sp
|
||||
$ gkermit -Ts oofa.txt
|
||||
.sp
|
||||
.fi
|
||||
it pauses for a second and then sends its first packet. What happens next
|
||||
depends on the capabilities of your terminal emulator:
|
||||
.PP
|
||||
.in +0.5i
|
||||
.ll -0.5i
|
||||
.ta +0.2i
|
||||
.ti -0.2i
|
||||
\(bu If your emulator supports Kermit "autodownloads" then it receives the
|
||||
file automatically and puts you back in the terminal screen when done.
|
||||
.sp
|
||||
.ti -0.2i
|
||||
\(bu Otherwise, you'll need to take whatever action is required by your
|
||||
emulator to get its attention: a mouse action, a keystroke like Alt-x,
|
||||
or a character sequence like Ctrl-\\ or Ctrl-] followed by the letter
|
||||
"c" (this is called "escaping back") and then tell it to receive the
|
||||
file. When the transfer is complete, you must instruct your emulator
|
||||
to go back to its terminal screen.
|
||||
.ll +0.5i
|
||||
.in -0.5i
|
||||
.fi
|
||||
.PP
|
||||
During file transfer, most terminal emulators put up some kind of running
|
||||
display of the file transfer progress.
|
||||
.PP
|
||||
When you tell G-Kermit to RECEIVE (with "gkermit -r"), this requires you to
|
||||
escape back to your terminal emulator and instruct it to send the desired
|
||||
file(s).
|
||||
.PP
|
||||
If your terminal emulator supports Kermit autodownloads AND Kermit server
|
||||
mode, then you can use GET ("gkermit -g files...") rather than RECEIVE
|
||||
("gkermit -r"), and the rest happens automatically, as when G-Kermit is
|
||||
sending.
|
||||
.SS INTERRUPTING FILE TRANSFER
|
||||
.PP
|
||||
G-Kermit supports file and group interruption. The method for interrupting
|
||||
a transfer depends on your terminal emulator. For example, while the
|
||||
file-transfer display is active, you might type the letter 'x' to cancel the
|
||||
current file and go on to the next one (if any), and the letter 'z' to
|
||||
cancel the group. Or there might be buttons you can click with your mouse.
|
||||
.PP
|
||||
When G-Kermit is in packet mode and your terminal emulator is in its
|
||||
terminal screen, you can also type three (3) Ctrl-C characters in a row to
|
||||
make G-Kermit exit and restore the normal terminal modes.
|
||||
.PP
|
||||
.SS TEXT AND BINARY TRANSFER MODE
|
||||
.PP
|
||||
When sending files in binary mode, G-Kermit sends every byte exactly as it
|
||||
is stored on the disk. This mode is appropriate for program binaries,
|
||||
graphics files, tar archives, compressed files, etc, and is G-Kermit's
|
||||
default file transfer mode when sending. When receiving files in binary
|
||||
mode, G-Kermit simply copies each byte to disk. (Obviously the bytes are
|
||||
encoded for transmission, but the encoding and decoding procedures give a
|
||||
replica of the original file after transfer.)
|
||||
.PP
|
||||
When sending files in text mode, G-Kermit converts the record format to the
|
||||
common one that is defined for the Kermit protocol, namely lines terminated
|
||||
by carriage return and linefeed (CRLF); the receiver converts the CRLFs to
|
||||
whatever line-end or record-format convention is used on its platform. When
|
||||
receiving files in text mode, G-Kermit simply strips carriage returns,
|
||||
leaving only a linefeed at the end of each line, which is the UNIX
|
||||
convention.
|
||||
.PP
|
||||
When receiving files, the sender's transfer mode (text or binary)
|
||||
predominates if the sender gives this information to G-Kermit in a Kermit
|
||||
File Attribute packet, which of course depends on whether your terminal
|
||||
emulator's Kermit protocol has this feature. Otherwise, if you gave a -i or
|
||||
-T option on the gkermit command line, the corresponding mode is used;
|
||||
otherwise the default mode (binary) is used.
|
||||
.PP
|
||||
Furthermore, when either sending or receiving, G-Kermit and your terminal
|
||||
emulator's Kermit can inform each other of their OS type (UNIX in G-Kermit's
|
||||
case). If your emulator supports this capability, which is called
|
||||
"automatic peer recognition", and it tells G-Kermit that its platform is
|
||||
also UNIX, G-Kermit and the emulator's Kermit automatically switch into
|
||||
binary mode, since no record-format conversion is necessary in this case.
|
||||
Automatic peer recognition is disabled automatically if you include the -i
|
||||
(image) or -T (text) option.
|
||||
.PP
|
||||
When sending, G-Kermit sends all files in the same mode, text or binary.
|
||||
There is no automatic per-file mode switching. When receiving, however,
|
||||
per-file switching occurs automatically based on the incoming Attribute
|
||||
packets, if any (explained below), that accompany each file.
|
||||
.PP
|
||||
.SS PATHNAMES
|
||||
.PP
|
||||
When SENDING a file, G-Kermit obtains the filenames from the command line.
|
||||
It depends on the shell to expand metacharacters (wildcards and tilde).
|
||||
.PP
|
||||
G-Kermit uses the full pathname given to find and open the file, but then
|
||||
strips the pathname before sending the name to the receiver. For example:
|
||||
.nf
|
||||
.sp
|
||||
$ gkermit -s /etc/hosts
|
||||
.sp
|
||||
.fi
|
||||
results in the receiver getting a file called "HOSTS" or "hosts" (the
|
||||
directory part, "/etc/", is stripped).
|
||||
.PP
|
||||
However, if a pathname is included in the -a option, the directory part
|
||||
is not stripped:
|
||||
.nf
|
||||
.sp
|
||||
$ gkermit -s /etc/hosts -a /tmp/hosts
|
||||
.sp
|
||||
.fi
|
||||
This example sends the /etc/hosts file but tells the receiver that its name
|
||||
is "/tmp/hosts". What the receiver does with the pathname is, of course, up
|
||||
to the receiver, which might have various options for dealing with incoming
|
||||
pathnames.
|
||||
.PP
|
||||
When RECEIVING a file, G-Kermit does NOT strip the pathname. If the
|
||||
incoming filename includes a path, G-Kermit tries to store the file in the
|
||||
specified place. If the path does not exist, the transfer fails. The
|
||||
incoming pathname can, of course, be overridden with the -a option.
|
||||
.PP
|
||||
.SS FILENAME CONVERSION
|
||||
.PP
|
||||
When sending a file, G-Kermit normally converts outbound filenames to
|
||||
common form: uppercase, no more than one period, and no funny characters.
|
||||
So, for example, gkermit.tar.gz would be sent as GKERMIT_TAR.GZ.
|
||||
.PP
|
||||
When receiving a file, if the name is all uppercase, G-Kermit converts it
|
||||
to all lowercase. If the name contains any lowercase letters, G-Kermit
|
||||
leaves the name alone.
|
||||
.PP
|
||||
If the automatic peer recognition feature is available in the terminal
|
||||
emulator, and G-Kermit recognizes the emulator's platform as UNIX, G-Kermit
|
||||
automatically disables filename conversion and sends and accepts filenames
|
||||
literally.
|
||||
.PP
|
||||
You can force literal filenames by including the -P option on the command
|
||||
line.
|
||||
.PP
|
||||
.SS FILENAME COLLISIONS
|
||||
.PP
|
||||
When G-Kermit receives a file whose name is the same as that of an existing
|
||||
file, G-Kermit "backs up" the existing file by adding a unique suffix to its
|
||||
name. The suffix is ".~n~", where n is a number. This kind of backup suffix
|
||||
is compatible with GNU EMACS and various other popular applications.
|
||||
.PP
|
||||
To defeat the backup feature and have incoming files overwrite existing
|
||||
files of the same name, include the -w (writeover) option on the command
|
||||
line.
|
||||
.PP
|
||||
.SH RETURN VALUES
|
||||
G-Kermit resturns an exit status code of 0 if all actions succeeded
|
||||
and 1 if any actions failed.
|
||||
.PP
|
||||
.SH IMPLEMENTATION NOTES
|
||||
G-Kermit is designed to be small, portable, and stable, and is intended for
|
||||
use only on the "far end" of a connection; it does not make connections
|
||||
itself, although it can be used as an external protocol by other programs that
|
||||
do make connections. To keep it small and stable, it does not include sliding
|
||||
windows, a command or scripting language or character-set translation. To
|
||||
keep it portable and stable, it avoids use of system services that are not
|
||||
standardized across all UNIX varieties and therefore, in particular, does not
|
||||
support file timestamps, internal wildcard expansion, and other features that
|
||||
are not implemented consistently (or at all) across all UNIXes.
|
||||
.PP
|
||||
.SH ENVIRONMENT
|
||||
A GKERMIT environment variable may be defined (for example in your shell
|
||||
profile) to include G-Kermit command-line options; these are processed by
|
||||
G-Kermit before any options that are specified on the command line, and
|
||||
therefore are overriden by command-line options.
|
||||
.PP
|
||||
.SH DIAGNOSTICS
|
||||
If an error occurs during file
|
||||
transfer G-Kermit sends an error packet to your terminal emulator to cancel
|
||||
the transfer; an appropriate error message should be displayed on your
|
||||
screen.
|
||||
.PP
|
||||
.SH ERRORS
|
||||
File transfers can fail for a number of reasons:
|
||||
.sp
|
||||
.in +0.5i
|
||||
.ll -0.5i
|
||||
.ta +0.2i
|
||||
.ti -0.2i
|
||||
\(bu Lack of read access to a source file.
|
||||
.ti -0.2i
|
||||
\(bu Lack of write access to a target directory.
|
||||
.ti -0.2i
|
||||
\(bu Lack of adequate flow control.
|
||||
.ti -0.2i
|
||||
\(bu Use of streaming on an unreliable connection.
|
||||
.ti -0.2i
|
||||
\(bu Excessive unprefixing of control characters.
|
||||
.ti -0.2i
|
||||
\(bu Sending bare 8-bit data on a 7-bit connection.
|
||||
.ti -0.2i
|
||||
\(bu Packets too long for receiver's buffers.
|
||||
.ti -0.2i
|
||||
\(bu Timeout interval too short for connection.
|
||||
.ti -0.2i
|
||||
.ll +0.5i
|
||||
.in -0.5i
|
||||
.fi
|
||||
.sp
|
||||
and many others; these are covered in the references.
|
||||
.PP
|
||||
.SH REFERENCES
|
||||
.PP
|
||||
The Kermit protocol is specified in "Kermit, A File Transfer Protocol" by
|
||||
Frank da Cruz, Digital Press (1987). A correctness proof of the Kermit
|
||||
protocol appears in "Specification and Validation Methods", edited by Egon
|
||||
Boerger, Oxford University Press (1995). "Using C-Kermit" by Frank da Cruz
|
||||
and Christine M. Gianone, Digital Press (1997, or later edition) explains many
|
||||
of the terms and techniques referenced here in case you are not familiar with
|
||||
them, and also includes tutorials on data communications, extensive
|
||||
troubleshooting and performance tips, etc. Various other books on Kermit are
|
||||
available from Digital Press. Online resources include:
|
||||
.nf
|
||||
.sp
|
||||
Web: http://www.columbia.edu/kermit/
|
||||
FTP: ftp://kermit.columbia.edu/kermit/g/
|
||||
News: comp.protocols.kermit.misc
|
||||
Email: kermit-support@columbia.edu
|
||||
.fi
|
||||
.sp
|
||||
Also see the README file distributed with G-Kermit for further detail. It
|
||||
can also be found at ftp://kermit.columbia.edu/kermit/g/README.
|
||||
.PP
|
||||
.SH BUGS
|
||||
The speed of a file transfer depends not only on the speed of the two
|
||||
computers involved and the characteristics of the connection, but also on the
|
||||
capabilities and configuration of the two Kermit programs. Kermit is a fast
|
||||
and reliable protocol, but not all implementations of it are necessarily fast
|
||||
or reliable.
|
||||
.PP
|
||||
Nonstreaming transfers on a TCP/IP connection might be inordinately slow
|
||||
if one or both of the TCP/IP stacks uses the Nagle or Delayed ACK tricks.
|
||||
Streaming is used automatically if the other Kermit supports it.
|
||||
.PP
|
||||
When receiving files in text mode, G-Kermit strips all carriage returns,
|
||||
even if they aren't followed by linefeed.
|
||||
.PP
|
||||
A backups files are not guaranteed to have the highest number in their
|
||||
backup suffix.
|
||||
.PP
|
||||
.SH AUTHOR
|
||||
Frank da Cruz, the Kermit Project, Columbia University, New York City,
|
||||
December 1999.
|
||||
.br
|
362
gnu/dist/gkermit/gproto.c
vendored
362
gnu/dist/gkermit/gproto.c
vendored
@ -1,362 +0,0 @@
|
||||
|
||||
/* WARNING -- This C source program generated by gwart preprocessor. */
|
||||
/* Do not edit this file; edit the gwart-format source file instead, */
|
||||
/* and then run it through gwart to produce a new C source file. */
|
||||
|
||||
/* G P R O T O -- Protocol module for gkermit */ /* -*-C-*- */
|
||||
|
||||
/*
|
||||
Author:
|
||||
Frank da Cruz
|
||||
The Kermit Project
|
||||
Columbia University
|
||||
612 West 115th Street
|
||||
New York NY 10025-7799 USA
|
||||
http://www.columbia.edu/kermit/
|
||||
kermit@columbia.edu
|
||||
|
||||
Copyright (C) 1999,
|
||||
The Trustees of Columbia University in the City of New York.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "gkermit.h"
|
||||
|
||||
_MYPROTOTYPE( int closof, (void) ); /* Close output file */
|
||||
_MYPROTOTYPE( VOID errpkt, (char *) ); /* Send Error packet */
|
||||
|
||||
extern char * xdata, *rdatap, **cmlist, *cmarg, *rpar(), strbuf[], filnam[];
|
||||
extern int start, bctu, bctr, delay, cx, cz, failure, attributes, datalen;
|
||||
extern int streamok, streaming, timint;
|
||||
extern FILE * db;
|
||||
|
||||
static int x;
|
||||
|
||||
static VOID
|
||||
streamon() { /* Start streaming if negotiated */
|
||||
x = 0;
|
||||
if (streamok > 0) {
|
||||
streaming = 1;
|
||||
timint = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Declare gwart states (like lex) */
|
||||
|
||||
#define ssini 1
|
||||
#define ssfil 2
|
||||
#define ssdat 3
|
||||
#define ssatt 4
|
||||
#define sseot 5
|
||||
#define sseof 6
|
||||
#define sipkt 7
|
||||
#define srini 8
|
||||
#define srfil 9
|
||||
#define srdat 10
|
||||
#define sratt 11
|
||||
|
||||
/* Packets are read by the input() function, which returns the packet type */
|
||||
/* that serves as the input to the state machine, which follows... */
|
||||
|
||||
|
||||
#define BEGIN state =
|
||||
|
||||
int state = 0;
|
||||
|
||||
int
|
||||
gwart()
|
||||
{
|
||||
int c,actno;
|
||||
extern short tbl[];
|
||||
while (1) {
|
||||
c = input() - 32;
|
||||
if (c < 0 || c > 95) c = 0;
|
||||
if ((actno = tbl[c + state*96]) != -1)
|
||||
switch(actno) {
|
||||
case 1:
|
||||
{ /* Start state for Send. */
|
||||
tinit(); /* Initialize transaction. */
|
||||
if (sinit('S') < 0) { errpkt("sinit"); } /* Build and send the S packet. */
|
||||
else BEGIN ssini;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{ /* Receive ACK to I packet */
|
||||
spar(rdatap); /* Set parameters from it */
|
||||
bctu = bctr; /* Switch to negotiated block check */
|
||||
if (gnfile() > 0) { /* Is there a file to send? */
|
||||
if (sfile() < 0) { /* Yes, open it, send F packet, */
|
||||
errpkt("sfile");
|
||||
} else { /* No error */
|
||||
streamon();
|
||||
BEGIN ssfil;
|
||||
}
|
||||
} else { /* No files to send, */
|
||||
if (seot() < 0) { errpkt("seot"); } /* so send EOT packet. */
|
||||
else BEGIN sseot;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
{ /* Receive ACK to File header packet */
|
||||
if (attributes) { /* If attributes negotiated */
|
||||
if (sattr() < 0) { /* Send file attributes */
|
||||
errpkt("sattr");
|
||||
} else
|
||||
BEGIN ssatt;
|
||||
} else if ((x = sdata()) == 0) { /* Otherwise send first Data packet */
|
||||
if (seof("") < 0) { /* Empty file - send EOF */
|
||||
errpkt("seof");
|
||||
} else {
|
||||
BEGIN sseof;
|
||||
}
|
||||
} else if (x < 0) { /* Error */
|
||||
errpkt("sdata");
|
||||
} else { /* OK - switch to Data state */
|
||||
BEGIN ssdat;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
{ /* Receive ACK to Attribute packet */
|
||||
if (*rdatap == 'N') { /* Check for refusal */
|
||||
seof("D");
|
||||
BEGIN sseof;
|
||||
} else if ((x = sdata()) == 0) { /* Otherwise send first Data packet */
|
||||
if (seof("") < 0) { /* Empty file - send EOF */
|
||||
errpkt("seof");
|
||||
} else {
|
||||
BEGIN sseof;
|
||||
}
|
||||
} else if (x < 0) { /* Error */
|
||||
errpkt("sdata");
|
||||
} else { /* OK - switch to Data state */
|
||||
BEGIN ssdat;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
{ /* Receive ACK to Data packet */
|
||||
if (*rdatap == 'X') /* Check for file cancellation */
|
||||
cx = 1;
|
||||
else if (*rdatap == 'Z') /* Check for batch cancellation */
|
||||
cz = 1;
|
||||
if ((x = sdata()) == 0) { /* Send data packet if data left. */
|
||||
if (seof((cx | cz) ? "D" : "") < 0) { /* If not, send Z packet */
|
||||
errpkt("seof");
|
||||
} else {
|
||||
BEGIN sseof;
|
||||
}
|
||||
} else if (x < 0) /* Fatal error sending data */
|
||||
errpkt("sdata");
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
{ /* Receive ACK to EOF */
|
||||
if (gnfile() > 0) { /* Get next file from list */
|
||||
if (sfile() > 0)
|
||||
BEGIN ssfil;
|
||||
else { errpkt("sfile"); }
|
||||
} else { /* No more files */
|
||||
seot(); /* Send EOT */
|
||||
BEGIN sseot;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
{ return(failure); }
|
||||
break;
|
||||
case 8:
|
||||
{ tinit(); rinit(); BEGIN srini; }
|
||||
break;
|
||||
case 9:
|
||||
{ /* Receive S packet */
|
||||
spar(rdatap); /* Set parameters from it */
|
||||
ack1(rpar()); /* ACK with our parameters */
|
||||
bctu = bctr; /* Switch to negotiated block check */
|
||||
streamon();
|
||||
BEGIN srfil; /* Wait for file or EOT */
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
{ ack(); return(failure); }
|
||||
break;
|
||||
case 11:
|
||||
{ /* Receive File header packet */
|
||||
if (rcvfil() < 0) {
|
||||
errpkt("rcvfil");
|
||||
} else {
|
||||
encstr(filnam);
|
||||
ack1(xdata);
|
||||
streamon();
|
||||
BEGIN sratt;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
{ /* Receive Attribute packet */
|
||||
if (gattr(rdatap) == 0) {
|
||||
ack();
|
||||
} else {
|
||||
ack1("\"");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 13:
|
||||
{ /* Receive first Data packet */
|
||||
if (decode(datalen) < 0) {
|
||||
errpkt("Packet decoding error");
|
||||
} else {
|
||||
ack();
|
||||
BEGIN srdat;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
{ /* Empty file */
|
||||
if (*rdatap == 'D') /* Check for Discard directive */
|
||||
cx = 1;
|
||||
if (closof() < 0) { /* Close the output file */
|
||||
errpkt("closof");
|
||||
} else {
|
||||
ack(); /* Send ACK */
|
||||
BEGIN srfil; /* Wait for another file or EOT */
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 15:
|
||||
{ /* Receive Data packet */
|
||||
if (decode(datalen) < 0)
|
||||
errpkt("Packet decoding error");
|
||||
else
|
||||
ack();
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
{ /* Receive EOF packet */
|
||||
if (*rdatap == 'D') /* Check for Discard directive */
|
||||
cx = 1;
|
||||
if (closof() < 0) { /* Close the output file */
|
||||
errpkt("closof");
|
||||
} else {
|
||||
ack(); /* Send ACK */
|
||||
BEGIN srfil; /* Wait for another file or EOT */
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 17:
|
||||
{ /* Start state for Get */
|
||||
tinit(); /* Initialize transaction */
|
||||
ginit(); /* Initialize Get */
|
||||
sinit('I'); /* Send I packet */
|
||||
BEGIN sipkt;
|
||||
}
|
||||
break;
|
||||
case 18:
|
||||
{ /* Receive ACK for I packet */
|
||||
spar(rdatap); /* Set parameters from it */
|
||||
if (scmd('R',cmarg) < 0) /* Send GET packet file filespec */
|
||||
errpkt("scmd");
|
||||
else
|
||||
BEGIN srini; /* Wait for S packet */
|
||||
}
|
||||
break;
|
||||
case 19:
|
||||
{ return(failure = 1); }
|
||||
break;
|
||||
case 20:
|
||||
{ errpkt("Unknown packet type"); }
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
short tbl[] = {
|
||||
-1, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 17, 1, 20, 20, 8, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
-1, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 2, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 17, 1, 20, 20, 8, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
-1, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 3, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 17, 1, 20, 20, 8, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
-1, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 5, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 17, 1, 20, 20, 8, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
-1, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 4, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 17, 1, 20, 20, 8, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
-1, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 7, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 17, 1, 20, 20, 8, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
-1, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 6, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 17, 1, 20, 20, 8, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
-1, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 18, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 17, 1, 20, 20, 8, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
-1, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 9, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 17, 1, 20, 20, 8, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
-1, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 10, 20, 20, 19, 11, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 17, 1, 20, 20, 8, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
-1, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 15, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 16, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 17, 1, 20, 20, 8, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 12, 20, 20, 13, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 14, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 17, 1, 20, 20, 8, 20, 20, 20, 20, 20, 20, 20, 20,20
|
||||
};
|
||||
|
228
gnu/dist/gkermit/gproto.w
vendored
228
gnu/dist/gkermit/gproto.w
vendored
@ -1,228 +0,0 @@
|
||||
/* G P R O T O -- Protocol module for gkermit */ /* -*-C-*- */
|
||||
|
||||
/*
|
||||
Author:
|
||||
Frank da Cruz
|
||||
The Kermit Project
|
||||
Columbia University
|
||||
612 West 115th Street
|
||||
New York NY 10025-7799 USA
|
||||
http://www.columbia.edu/kermit/
|
||||
kermit@columbia.edu
|
||||
|
||||
Copyright (C) 1999,
|
||||
The Trustees of Columbia University in the City of New York.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "gkermit.h"
|
||||
|
||||
_MYPROTOTYPE( int closof, (void) ); /* Close output file */
|
||||
_MYPROTOTYPE( VOID errpkt, (char *) ); /* Send Error packet */
|
||||
|
||||
extern char * xdata, *rdatap, **cmlist, *cmarg, *rpar(), strbuf[], filnam[];
|
||||
extern int start, bctu, bctr, delay, cx, cz, failure, attributes, datalen;
|
||||
extern int streamok, streaming, timint;
|
||||
extern FILE * db;
|
||||
|
||||
static int x;
|
||||
|
||||
static VOID
|
||||
streamon() { /* Start streaming if negotiated */
|
||||
x = 0;
|
||||
if (streamok > 0) {
|
||||
streaming = 1;
|
||||
timint = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Declare gwart states (like lex) */
|
||||
|
||||
%states ssini ssfil ssdat ssatt sseot sseof sipkt
|
||||
%states srini srfil srdat sratt
|
||||
|
||||
/* Packets are read by the input() function, which returns the packet type */
|
||||
/* that serves as the input to the state machine, which follows... */
|
||||
|
||||
%%
|
||||
/* Sending states... */
|
||||
|
||||
s { /* Start state for Send. */
|
||||
tinit(); /* Initialize transaction. */
|
||||
if (sinit('S') < 0) { errpkt("sinit"); } /* Build and send the S packet. */
|
||||
else BEGIN ssini;
|
||||
}
|
||||
<ssini>Y { /* Receive ACK to I packet */
|
||||
spar(rdatap); /* Set parameters from it */
|
||||
bctu = bctr; /* Switch to negotiated block check */
|
||||
if (gnfile() > 0) { /* Is there a file to send? */
|
||||
if (sfile() < 0) { /* Yes, open it, send F packet, */
|
||||
errpkt("sfile");
|
||||
} else { /* No error */
|
||||
streamon();
|
||||
BEGIN ssfil;
|
||||
}
|
||||
} else { /* No files to send, */
|
||||
if (seot() < 0) { errpkt("seot"); } /* so send EOT packet. */
|
||||
else BEGIN sseot;
|
||||
}
|
||||
}
|
||||
<ssfil>Y { /* Receive ACK to File header packet */
|
||||
if (attributes) { /* If attributes negotiated */
|
||||
if (sattr() < 0) { /* Send file attributes */
|
||||
errpkt("sattr");
|
||||
} else
|
||||
BEGIN ssatt;
|
||||
} else if ((x = sdata()) == 0) { /* Otherwise send first Data packet */
|
||||
if (seof("") < 0) { /* Empty file - send EOF */
|
||||
errpkt("seof");
|
||||
} else {
|
||||
BEGIN sseof;
|
||||
}
|
||||
} else if (x < 0) { /* Error */
|
||||
errpkt("sdata");
|
||||
} else { /* OK - switch to Data state */
|
||||
BEGIN ssdat;
|
||||
}
|
||||
}
|
||||
<ssatt>Y { /* Receive ACK to Attribute packet */
|
||||
if (*rdatap == 'N') { /* Check for refusal */
|
||||
seof("D");
|
||||
BEGIN sseof;
|
||||
} else if ((x = sdata()) == 0) { /* Otherwise send first Data packet */
|
||||
if (seof("") < 0) { /* Empty file - send EOF */
|
||||
errpkt("seof");
|
||||
} else {
|
||||
BEGIN sseof;
|
||||
}
|
||||
} else if (x < 0) { /* Error */
|
||||
errpkt("sdata");
|
||||
} else { /* OK - switch to Data state */
|
||||
BEGIN ssdat;
|
||||
}
|
||||
}
|
||||
<ssdat>Y { /* Receive ACK to Data packet */
|
||||
if (*rdatap == 'X') /* Check for file cancellation */
|
||||
cx = 1;
|
||||
else if (*rdatap == 'Z') /* Check for batch cancellation */
|
||||
cz = 1;
|
||||
if ((x = sdata()) == 0) { /* Send data packet if data left. */
|
||||
if (seof((cx | cz) ? "D" : "") < 0) { /* If not, send Z packet */
|
||||
errpkt("seof");
|
||||
} else {
|
||||
BEGIN sseof;
|
||||
}
|
||||
} else if (x < 0) /* Fatal error sending data */
|
||||
errpkt("sdata");
|
||||
}
|
||||
<sseof>Y { /* Receive ACK to EOF */
|
||||
if (gnfile() > 0) { /* Get next file from list */
|
||||
if (sfile() > 0)
|
||||
BEGIN ssfil;
|
||||
else { errpkt("sfile"); }
|
||||
} else { /* No more files */
|
||||
seot(); /* Send EOT */
|
||||
BEGIN sseot;
|
||||
}
|
||||
}
|
||||
<sseot>Y { return(failure); } /* Send ACK to EOT - done */
|
||||
|
||||
/* Receiving states... */
|
||||
|
||||
v { tinit(); rinit(); BEGIN srini; } /* Start-state for Receive */
|
||||
|
||||
<srini>S { /* Receive S packet */
|
||||
spar(rdatap); /* Set parameters from it */
|
||||
ack1(rpar()); /* ACK with our parameters */
|
||||
bctu = bctr; /* Switch to negotiated block check */
|
||||
streamon();
|
||||
BEGIN srfil; /* Wait for file or EOT */
|
||||
}
|
||||
|
||||
<srfil>B { ack(); return(failure); } /* Receive EOT packet */
|
||||
|
||||
<srfil>F { /* Receive File header packet */
|
||||
if (rcvfil() < 0) {
|
||||
errpkt("rcvfil");
|
||||
} else {
|
||||
encstr(filnam);
|
||||
ack1(xdata);
|
||||
streamon();
|
||||
BEGIN sratt;
|
||||
}
|
||||
}
|
||||
<sratt>A { /* Receive Attribute packet */
|
||||
if (gattr(rdatap) == 0) {
|
||||
ack();
|
||||
} else {
|
||||
ack1("\"");
|
||||
}
|
||||
}
|
||||
<sratt>D { /* Receive first Data packet */
|
||||
if (decode(datalen) < 0) {
|
||||
errpkt("Packet decoding error");
|
||||
} else {
|
||||
ack();
|
||||
BEGIN srdat;
|
||||
}
|
||||
}
|
||||
<sratt>Z { /* Empty file */
|
||||
if (*rdatap == 'D') /* Check for Discard directive */
|
||||
cx = 1;
|
||||
if (closof() < 0) { /* Close the output file */
|
||||
errpkt("closof");
|
||||
} else {
|
||||
ack(); /* Send ACK */
|
||||
BEGIN srfil; /* Wait for another file or EOT */
|
||||
}
|
||||
}
|
||||
<srdat>D { /* Receive Data packet */
|
||||
if (decode(datalen) < 0)
|
||||
errpkt("Packet decoding error");
|
||||
else
|
||||
ack();
|
||||
}
|
||||
<srdat>Z { /* Receive EOF packet */
|
||||
if (*rdatap == 'D') /* Check for Discard directive */
|
||||
cx = 1;
|
||||
if (closof() < 0) { /* Close the output file */
|
||||
errpkt("closof");
|
||||
} else {
|
||||
ack(); /* Send ACK */
|
||||
BEGIN srfil; /* Wait for another file or EOT */
|
||||
}
|
||||
}
|
||||
|
||||
/* GET files from a Kermit server... */
|
||||
|
||||
r { /* Start state for Get */
|
||||
tinit(); /* Initialize transaction */
|
||||
ginit(); /* Initialize Get */
|
||||
sinit('I'); /* Send I packet */
|
||||
BEGIN sipkt;
|
||||
}
|
||||
<sipkt>Y { /* Receive ACK for I packet */
|
||||
spar(rdatap); /* Set parameters from it */
|
||||
if (scmd('R',cmarg) < 0) /* Send GET packet file filespec */
|
||||
errpkt("scmd");
|
||||
else
|
||||
BEGIN srini; /* Wait for S packet */
|
||||
}
|
||||
|
||||
E { return(failure = 1); } /* Receive an Error packet */
|
||||
|
||||
. { errpkt("Unknown packet type"); } /* Handle unwanted packet types. */
|
||||
%%
|
1177
gnu/dist/gkermit/gunixio.c
vendored
1177
gnu/dist/gkermit/gunixio.c
vendored
File diff suppressed because it is too large
Load Diff
643
gnu/dist/gkermit/gwart.c
vendored
643
gnu/dist/gkermit/gwart.c
vendored
@ -1,643 +0,0 @@
|
||||
/*
|
||||
G W A R T -- GNU version of Wart
|
||||
|
||||
A small subset of "lex" sufficient for converting the Kermit
|
||||
protocol state table from lex notation to C.
|
||||
|
||||
Authors:
|
||||
Jeff Damens, Frank da Cruz
|
||||
The Kermit Project, Columbia University
|
||||
http://www.columbia.edu/kermit/
|
||||
kermit@columbia.edu
|
||||
|
||||
Copyright (C) 1984, 1999,
|
||||
The Trustees of Columbia University in the City of New York.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
* input format is:
|
||||
* lines to be copied | %state <state names...>
|
||||
* %%
|
||||
* <state> | <state,state,...> CHAR { actions }
|
||||
* ...
|
||||
* %%
|
||||
* more lines to be copied
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include "gkermit.h"
|
||||
|
||||
#define TBL_TYPE "short" /* C data type of state table */
|
||||
|
||||
#define C_L 014 /* Formfeed */
|
||||
|
||||
#define SEP 1 /* Token types */
|
||||
#define LBRACK 2
|
||||
#define RBRACK 3
|
||||
#define WORD 4
|
||||
#define COMMA 5
|
||||
|
||||
/* Storage sizes */
|
||||
|
||||
#define MAXSTATES 50 /* max number of states */
|
||||
#define MAXWORD 50 /* max # of chars/word */
|
||||
#define SBYTES ((MAXSTATES+6)/8) /* # of bytes for state bitmask */
|
||||
|
||||
/* Name of gwart function in generated program */
|
||||
|
||||
#ifndef FNAME
|
||||
#define FNAME "gwart"
|
||||
#endif /* FNAME */
|
||||
|
||||
/* Structure for state information */
|
||||
|
||||
struct transx {
|
||||
CHAR states[SBYTES]; /* included states */
|
||||
int anyst; /* true if this good from any state */
|
||||
CHAR inchr; /* input character */
|
||||
int actno; /* associated action */
|
||||
struct transx *nxt;
|
||||
}; /* next transition */
|
||||
typedef struct transx *trans;
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
_MYPROTOTYPE( VOID fatal, (char *) );
|
||||
_MYPROTOTYPE( VOID setwstate, (int, trans) );
|
||||
_MYPROTOTYPE( int teststate, (int, trans) );
|
||||
_MYPROTOTYPE( trans rdinput, (FILE *, FILE *) );
|
||||
_MYPROTOTYPE( VOID initial, (FILE *, FILE *) );
|
||||
_MYPROTOTYPE( int isin, (char *, int) );
|
||||
_MYPROTOTYPE( int isword, (int) );
|
||||
_MYPROTOTYPE( VOID rdword, (FILE *, char *) );
|
||||
_MYPROTOTYPE( VOID rdstates, (FILE *, FILE *) );
|
||||
_MYPROTOTYPE( trans newtrans, (void) );
|
||||
_MYPROTOTYPE( trans rdrules, (FILE *, FILE *) );
|
||||
_MYPROTOTYPE( VOID statelist, (FILE *, trans) );
|
||||
_MYPROTOTYPE( VOID copyact, (FILE *, FILE *, int) );
|
||||
_MYPROTOTYPE( int faction, (trans, int, int) );
|
||||
_MYPROTOTYPE( VOID emptytbl, (void) );
|
||||
_MYPROTOTYPE( VOID addaction, (int, int, int) );
|
||||
_MYPROTOTYPE( VOID writetbl, (FILE *) );
|
||||
_MYPROTOTYPE( VOID warray, (FILE *, char *, int [], int, char *) );
|
||||
_MYPROTOTYPE( VOID prolog, (FILE *) );
|
||||
_MYPROTOTYPE( VOID epilogue, (FILE *) );
|
||||
_MYPROTOTYPE( VOID copyrest, (FILE *, FILE *) );
|
||||
_MYPROTOTYPE( int gettoken, (FILE *) );
|
||||
_MYPROTOTYPE( VOID rdcmnt, (FILE *) );
|
||||
_MYPROTOTYPE( VOID clrhash, (void) );
|
||||
_MYPROTOTYPE( int hash, (char *) );
|
||||
_MYPROTOTYPE( VOID enter, (char *, int) );
|
||||
_MYPROTOTYPE( int lkup, (char *) );
|
||||
_MYPROTOTYPE( static char* copy, (char *s) );
|
||||
|
||||
/* Variables and tables */
|
||||
|
||||
int lines, nstates, nacts;
|
||||
int tbl[MAXSTATES*96];
|
||||
char tokval[MAXWORD];
|
||||
char *tbl_type = TBL_TYPE;
|
||||
|
||||
char *txt1 = "\n#define BEGIN state =\n\nint state = 0;\n\nint\n";
|
||||
|
||||
char *fname = FNAME; /* Generated function name goes here */
|
||||
|
||||
/* Rest of program... */
|
||||
|
||||
char *txt2 = "()\n\
|
||||
{\n\
|
||||
int c,actno;\n\
|
||||
extern ";
|
||||
|
||||
/* Data type of state table is inserted here (short or int) */
|
||||
|
||||
char *txt2a =
|
||||
" tbl[];\n\
|
||||
while (1) {\n\
|
||||
c = input() - 32;\n\
|
||||
if (c < 0 || c > 95) c = 0;\n";
|
||||
|
||||
char *txt2b = " if ((actno = tbl[c + state*96]) != -1)\n\
|
||||
switch(actno) {\n";
|
||||
|
||||
/* this program's output goes here, followed by final text... */
|
||||
|
||||
char *txt3 = "\n }\n }\n}\n\n";
|
||||
|
||||
|
||||
/*
|
||||
* turn on the bit associated with the given state
|
||||
*
|
||||
*/
|
||||
VOID
|
||||
setwstate(state,t) int state; trans t; {
|
||||
int idx,msk;
|
||||
idx = state/8; /* byte associated with state */
|
||||
msk = 0x80 >> (state % 8); /* bit mask for state */
|
||||
t->states[idx] |= msk;
|
||||
}
|
||||
|
||||
/*
|
||||
* see if the state is involved in the transition
|
||||
*
|
||||
*/
|
||||
int
|
||||
teststate(state,t) int state; trans t; {
|
||||
int idx,msk;
|
||||
idx = state/8;
|
||||
msk = 0x80 >> (state % 8);
|
||||
return(t->states[idx] & msk);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* read input from here...
|
||||
*
|
||||
*/
|
||||
|
||||
trans
|
||||
rdinput(infp,outfp) FILE *infp, *outfp; {
|
||||
trans x;
|
||||
lines = 1; /* line counter */
|
||||
nstates = 0; /* no states */
|
||||
nacts = 0; /* no actions yet */
|
||||
fprintf(outfp,"\n%c* WARNING -- This C source program generated by ",'/');
|
||||
fprintf(outfp,"gwart preprocessor. */\n");
|
||||
fprintf(outfp,"%c* Do not edit this file; edit the gwart-format ",'/');
|
||||
fprintf(outfp,"source file instead, */\n");
|
||||
fprintf(outfp,"%c* and then run it through gwart to produce a new ",'/');
|
||||
fprintf(outfp,"C source file. */\n\n");
|
||||
|
||||
initial(infp,outfp); /* read state names, initial defs */
|
||||
prolog(outfp); /* write out our initial code */
|
||||
x = rdrules(infp,outfp); /* read rules */
|
||||
epilogue(outfp); /* write out epilogue code */
|
||||
return(x);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* initial - read initial definitions and state names. Returns
|
||||
* on EOF or %%.
|
||||
*
|
||||
*/
|
||||
VOID
|
||||
initial(infp,outfp) FILE *infp, *outfp; {
|
||||
int c;
|
||||
char wordbuf[MAXWORD];
|
||||
while ((c = getc(infp)) != EOF) {
|
||||
if (c == '%') {
|
||||
rdword(infp,wordbuf);
|
||||
if (strcmp(wordbuf,"states") == 0)
|
||||
rdstates(infp,outfp);
|
||||
else if (strcmp(wordbuf,"%") == 0) return;
|
||||
else fprintf(outfp,"%%%s",wordbuf);
|
||||
}
|
||||
else putc(c,outfp);
|
||||
if (c == '\n') lines++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* boolean function to tell if the given character can be part of
|
||||
* a word.
|
||||
*
|
||||
*/
|
||||
int
|
||||
isin(s,c) char *s; int c; {
|
||||
for (; *s != '\0'; s++)
|
||||
if (*s == (char) c) return(1);
|
||||
return(0);
|
||||
}
|
||||
int
|
||||
isword(c) int c; {
|
||||
static char special[] = ".%_-$@"; /* these are allowable */
|
||||
return(isalnum(c) || isin(special,c));
|
||||
}
|
||||
|
||||
/*
|
||||
* read the next word into the given buffer.
|
||||
*
|
||||
*/
|
||||
VOID
|
||||
rdword(fp,buf) FILE *fp; char *buf; {
|
||||
int len = 0,c;
|
||||
while (isword(c = getc(fp)) && ++len < MAXWORD) *buf++ = (char) c;
|
||||
*buf++ = '\0'; /* tie off word */
|
||||
ungetc(c,fp); /* put break char back */
|
||||
}
|
||||
|
||||
/*
|
||||
* read state names, up to a newline.
|
||||
*
|
||||
*/
|
||||
VOID
|
||||
rdstates(fp,ofp) FILE *fp,*ofp; {
|
||||
int c;
|
||||
char wordbuf[MAXWORD];
|
||||
while ((c = getc(fp)) != EOF && c != '\n') {
|
||||
if (isspace(c) || c == C_L) continue; /* skip whitespace */
|
||||
ungetc(c,fp); /* put char back */
|
||||
rdword(fp,wordbuf); /* read the whole word */
|
||||
enter(wordbuf,++nstates); /* put into symbol tbl */
|
||||
fprintf(ofp,"#define %s %d\n",wordbuf,nstates);
|
||||
}
|
||||
lines++;
|
||||
}
|
||||
|
||||
/*
|
||||
* allocate a new, empty transition node
|
||||
*
|
||||
*/
|
||||
trans
|
||||
newtrans() {
|
||||
trans new;
|
||||
int i;
|
||||
new = (trans) malloc(sizeof (struct transx));
|
||||
for (i=0; i<SBYTES; i++) new->states[i] = 0;
|
||||
new->anyst = 0;
|
||||
new->nxt = NULL;
|
||||
return(new);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* read all the rules.
|
||||
*
|
||||
*/
|
||||
|
||||
trans
|
||||
rdrules(fp,out) FILE *fp,*out; {
|
||||
trans head,cur,prev;
|
||||
int curtok;
|
||||
head = cur = prev = NULL;
|
||||
while ((curtok = gettoken(fp)) != SEP)
|
||||
|
||||
switch(curtok) {
|
||||
case LBRACK:
|
||||
if (cur == NULL)
|
||||
cur = newtrans();
|
||||
else
|
||||
fatal("duplicate state list");
|
||||
statelist(fp,cur); /* set states */
|
||||
continue; /* prepare to read char */
|
||||
|
||||
case WORD:
|
||||
if ((int)strlen(tokval) != 1)
|
||||
fatal("multiple chars in state");
|
||||
if (cur == NULL) {
|
||||
cur = newtrans();
|
||||
cur->anyst = 1;
|
||||
}
|
||||
cur->actno = ++nacts;
|
||||
cur->inchr = (char) (tokval[0] - 32);
|
||||
if (head == NULL)
|
||||
head = cur;
|
||||
else
|
||||
prev->nxt = cur;
|
||||
prev = cur;
|
||||
cur = NULL;
|
||||
copyact(fp,out,nacts);
|
||||
break;
|
||||
default: fatal("bad input format");
|
||||
}
|
||||
return(head);
|
||||
}
|
||||
|
||||
/*
|
||||
* read a list of (comma-separated) states, set them in the
|
||||
* given transition.
|
||||
*
|
||||
*/
|
||||
VOID
|
||||
statelist(fp,t) FILE *fp; trans t; {
|
||||
int curtok,sval;
|
||||
curtok = COMMA;
|
||||
while (curtok != RBRACK) {
|
||||
if (curtok != COMMA) fatal("missing comma");
|
||||
if ((curtok = gettoken(fp)) != WORD) fatal("missing state name");
|
||||
if ((sval = lkup(tokval)) == -1) {
|
||||
fprintf(stderr,"state %s undefined\n",tokval);
|
||||
fatal("undefined state");
|
||||
}
|
||||
setwstate(sval,t);
|
||||
curtok = gettoken(fp);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* copy an action from the input to the output file
|
||||
*
|
||||
*/
|
||||
VOID
|
||||
copyact(inp,outp,actno) FILE *inp,*outp; int actno; {
|
||||
int c,bcnt;
|
||||
fprintf(outp,"case %d:\n",actno);
|
||||
while (c = getc(inp), (isspace(c) || c == C_L))
|
||||
if (c == '\n') lines++;
|
||||
if (c == '{') {
|
||||
bcnt = 1;
|
||||
fputs(" {",outp);
|
||||
while (bcnt > 0 && (c = getc(inp)) != EOF) {
|
||||
if (c == '{') bcnt++;
|
||||
else if (c == '}') bcnt--;
|
||||
else if (c == '\n') lines++;
|
||||
putc(c,outp);
|
||||
}
|
||||
if (bcnt > 0) fatal("action doesn't end");
|
||||
} else {
|
||||
while (c != '\n' && c != EOF) {
|
||||
putc(c,outp);
|
||||
c = getc(inp);
|
||||
}
|
||||
lines++;
|
||||
}
|
||||
fprintf(outp,"\n break;\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* find the action associated with a given character and state.
|
||||
* returns -1 if one can't be found.
|
||||
*
|
||||
*/
|
||||
int
|
||||
faction(hd,state,chr) trans hd; int state,chr; {
|
||||
while (hd != NULL) {
|
||||
if (hd->anyst || teststate(state,hd))
|
||||
if (hd->inchr == ('.' - 32) || hd->inchr == (char) chr)
|
||||
return(hd->actno);
|
||||
hd = hd->nxt;
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* empty the table...
|
||||
*
|
||||
*/
|
||||
VOID
|
||||
emptytbl() {
|
||||
int i;
|
||||
for (i=0; i<nstates*96; i++) tbl[i] = -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* add the specified action to the output for the given state and chr.
|
||||
*
|
||||
*/
|
||||
VOID
|
||||
addaction(act,state,chr) int act,state,chr; {
|
||||
tbl[state*96 + chr] = act;
|
||||
}
|
||||
|
||||
VOID
|
||||
writetbl(fp) FILE *fp; {
|
||||
warray(fp,"tbl",tbl,96*(nstates+1),TBL_TYPE);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* write an array to the output file, given its name and size.
|
||||
*
|
||||
*/
|
||||
VOID
|
||||
warray(fp,nam,cont,siz,typ) FILE *fp; char *nam; int cont[],siz; char *typ; {
|
||||
int i;
|
||||
fprintf(fp,"%s %s[] = {\n",typ,nam);
|
||||
for (i = 0; i < siz - 1; ) {
|
||||
fprintf(fp," %2d,",cont[i]);
|
||||
if ((++i % 16) == 0) putc('\n',fp);
|
||||
}
|
||||
fprintf(fp,"%2d\n};\n",cont[siz-1]);
|
||||
}
|
||||
|
||||
int
|
||||
main(argc,argv) int argc; char **argv; {
|
||||
trans head;
|
||||
int state,c;
|
||||
FILE *infile,*outfile;
|
||||
|
||||
if (argc > 1) {
|
||||
if ((infile = fopen(argv[1],"r")) == NULL) {
|
||||
fprintf(stderr,"Can't open %s\n",argv[1]);
|
||||
fatal("unreadable input file");
|
||||
}
|
||||
} else infile = stdin;
|
||||
|
||||
if (argc > 2) {
|
||||
if ((outfile = fopen(argv[2],"w")) == NULL) {
|
||||
fprintf(stderr,"Can't write to %s\n",argv[2]);
|
||||
fatal("bad output file");
|
||||
}
|
||||
} else outfile = stdout;
|
||||
|
||||
clrhash(); /* empty hash table */
|
||||
head = rdinput(infile,outfile); /* read input file */
|
||||
emptytbl(); /* empty our tables */
|
||||
for (state = 0; state <= nstates; state++)
|
||||
for (c = 1; c < 96; c++) /* find actions, */
|
||||
addaction(faction(head,state,c),state,c); /* add to tbl */
|
||||
writetbl(outfile);
|
||||
copyrest(infile,outfile);
|
||||
printf("%d states, %d actions\n",nstates,nacts);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* fatal error handler
|
||||
*
|
||||
*/
|
||||
|
||||
VOID
|
||||
fatal(msg) char *msg; {
|
||||
fprintf(stderr,"error in line %d: %s\n",lines,msg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
VOID
|
||||
prolog(outfp) FILE *outfp; {
|
||||
int c;
|
||||
while ((c = *txt1++) != '\0') putc(c,outfp);
|
||||
while ((c = *fname++) != '\0') putc(c,outfp);
|
||||
while ((c = *txt2++) != '\0') putc(c,outfp);
|
||||
while ((c = *tbl_type++) != '\0') putc(c,outfp);
|
||||
while ((c = *txt2a++) != '\0') putc(c,outfp);
|
||||
while ((c = *txt2b++) != '\0') putc(c,outfp);
|
||||
}
|
||||
|
||||
VOID
|
||||
epilogue(outfp) FILE *outfp; {
|
||||
int c;
|
||||
while ((c = *txt3++) != '\0') putc(c,outfp);
|
||||
}
|
||||
|
||||
VOID
|
||||
copyrest(in,out) FILE *in,*out; {
|
||||
int c;
|
||||
while ((c = getc(in)) != EOF) putc(c,out);
|
||||
}
|
||||
|
||||
/*
|
||||
* gettoken - returns token type of next token, sets tokval
|
||||
* to the string value of the token if appropriate.
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
gettoken(fp) FILE *fp; {
|
||||
int c;
|
||||
while (1) { /* loop if reading comments... */
|
||||
do {
|
||||
c = getc(fp);
|
||||
if (c == '\n') lines++;
|
||||
} while ((isspace(c) || c == C_L)); /* skip whitespace */
|
||||
switch(c) {
|
||||
case EOF:
|
||||
return(SEP);
|
||||
case '%':
|
||||
if ((c = getc(fp)) == '%') return(SEP);
|
||||
tokval[0] = '%';
|
||||
tokval[1] = (char) c;
|
||||
rdword(fp,tokval+2);
|
||||
return(WORD);
|
||||
case '<':
|
||||
return(LBRACK);
|
||||
case '>':
|
||||
return(RBRACK);
|
||||
case ',':
|
||||
return(COMMA);
|
||||
case '/':
|
||||
if ((c = getc(fp)) == '*') {
|
||||
rdcmnt(fp); /* skip over the comment */
|
||||
continue;
|
||||
} else { /* and keep looping */
|
||||
ungetc(c,fp); /* put this back into input */
|
||||
c = '/'; /* put character back, fall thru */
|
||||
}
|
||||
|
||||
default:
|
||||
if (isword(c)) {
|
||||
ungetc(c,fp);
|
||||
rdword(fp,tokval);
|
||||
return(WORD);
|
||||
} else fatal("Invalid character in input");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* skip over a comment
|
||||
*
|
||||
*/
|
||||
|
||||
VOID
|
||||
rdcmnt(fp) FILE *fp; {
|
||||
int c,star,prcnt;
|
||||
prcnt = star = 0; /* no star seen yet */
|
||||
while (!((c = getc(fp)) == '/' && star)) {
|
||||
if (c == EOF || (prcnt && c == '%')) fatal("Unterminated comment");
|
||||
prcnt = (c == '%');
|
||||
star = (c == '*');
|
||||
if (c == '\n') lines++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* symbol table management for gwart
|
||||
*
|
||||
* entry points:
|
||||
* clrhash - empty hash table.
|
||||
* enter - enter a name into the symbol table
|
||||
* lkup - find a name's value in the symbol table.
|
||||
*/
|
||||
#define HASHSIZE 101 /* # of entries in hash table */
|
||||
|
||||
struct sym {
|
||||
char *name; /* symbol name */
|
||||
int val; /* value */
|
||||
struct sym *hnxt; /* next on collision chain */
|
||||
} *htab[HASHSIZE]; /* the hash table */
|
||||
|
||||
/*
|
||||
* empty the hash table before using it...
|
||||
*
|
||||
*/
|
||||
VOID
|
||||
clrhash() {
|
||||
int i;
|
||||
for (i=0; i<HASHSIZE; i++) htab[i] = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* compute the value of the hash for a symbol
|
||||
*
|
||||
*/
|
||||
int
|
||||
hash(name) char *name; {
|
||||
int sum;
|
||||
for (sum = 0; *name != '\0'; name++) sum += (sum + *name);
|
||||
sum %= HASHSIZE; /* take sum mod hashsize */
|
||||
if (sum < 0) sum += HASHSIZE; /* disallow negative hash value */
|
||||
return(sum);
|
||||
}
|
||||
|
||||
/*
|
||||
* make a private copy of a string...
|
||||
*
|
||||
*/
|
||||
static char*
|
||||
copy(s) char *s; {
|
||||
char *new;
|
||||
new = (char *) malloc((int)strlen(s) + 1);
|
||||
strcpy(new,s);
|
||||
return(new);
|
||||
}
|
||||
|
||||
/*
|
||||
* enter state name into the hash table
|
||||
*
|
||||
*/
|
||||
VOID
|
||||
enter(name,svalue) char *name; int svalue; {
|
||||
int h;
|
||||
struct sym *cur;
|
||||
if (lkup(name) != -1) {
|
||||
fprintf(stderr,"state \"%s\" appears twice...\n", name);
|
||||
exit(1);
|
||||
}
|
||||
h = hash(name);
|
||||
cur = (struct sym *)malloc(sizeof (struct sym));
|
||||
cur->name = copy(name);
|
||||
cur->val = svalue;
|
||||
cur->hnxt = htab[h];
|
||||
htab[h] = cur;
|
||||
}
|
||||
|
||||
/*
|
||||
* find name in the symbol table, return its value. Returns -1
|
||||
* if not found.
|
||||
*
|
||||
*/
|
||||
int
|
||||
lkup(name) char *name; {
|
||||
struct sym *cur;
|
||||
for (cur = htab[hash(name)]; cur != NULL; cur = cur->hnxt)
|
||||
if (strcmp(cur->name,name) == 0) return(cur->val);
|
||||
return(-1);
|
||||
}
|
134
gnu/dist/gkermit/makefile
vendored
134
gnu/dist/gkermit/makefile
vendored
@ -1,134 +0,0 @@
|
||||
# makefile for gkermit - works with make or gmake.
|
||||
#
|
||||
# Author:
|
||||
# Frank da Cruz
|
||||
# The Kermit Project, Columbia University
|
||||
# http://www.columbia.edu/kermit/
|
||||
# kermit@columbia.edu
|
||||
# December 1999
|
||||
#
|
||||
# Main build targets:
|
||||
# posix: Build for any POSIX-based platform (default).
|
||||
# sysv: Build for any AT&T UNIX System V based platform.
|
||||
# bsd: Build for any UNIX V7 or 4.3 (or earlier) BSD based platform.
|
||||
#
|
||||
# Special build targets:
|
||||
# sysvx Like sysv but uses getchar()/putchar().
|
||||
# stty Uses system("stty blah") instead of API calls.
|
||||
# bsd211 For 2.11BSD on the PDP-11 - no nested makes.
|
||||
#
|
||||
# Other targets:
|
||||
# clean: Remove object files
|
||||
# install: Install gkermit
|
||||
# uninstall: Uninstall gkermit
|
||||
#
|
||||
# Default compiler is cc. To force gcc use:
|
||||
# make "CC=gcc" [ <target> ]
|
||||
#
|
||||
# See README and COPYING for further information.
|
||||
|
||||
# Sample installation values - change or override as needed.
|
||||
|
||||
BINDIR = /usr/local/bin
|
||||
MANDIR = /usr/man/manl
|
||||
TEXTDIR = /usr/local/doc
|
||||
INFODIR = /usr/local/info
|
||||
MANEXT = l
|
||||
|
||||
# Default compiler and flags
|
||||
|
||||
CC=cc
|
||||
CFLAGS= -DPOSIX -O $(KFLAGS)
|
||||
|
||||
# Object files
|
||||
|
||||
OBJECTS= gproto.o gkermit.o gunixio.o gcmdline.o
|
||||
|
||||
# Targets and dependencies
|
||||
|
||||
all: gwart gkermit
|
||||
|
||||
gwart.o: gwart.c
|
||||
$(CC) $(CFLAGS) -c gwart.c
|
||||
|
||||
gwart: gwart.o
|
||||
$(CC) -o gwart gwart.o
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) -c $<
|
||||
|
||||
gproto.c: gproto.w gkermit.h
|
||||
./gwart gproto.w gproto.c
|
||||
|
||||
gkermit.o: gkermit.c gkermit.h
|
||||
|
||||
gunixio.o: gunixio.c gkermit.h
|
||||
|
||||
gcmdline.o: gcmdline.c gkermit.h
|
||||
|
||||
gkermit: gproto.o gkermit.o gunixio.o gcmdline.o
|
||||
$(CC) -o gkermit $(OBJECTS)
|
||||
|
||||
bsd: gwart
|
||||
$(MAKE) "CC=$(CC)" "CFLAGS=-DBSD -O $(KFLAGS)" gkermit
|
||||
|
||||
sysv: gwart
|
||||
$(MAKE) "CC=$(CC)" "CFLAGS=-DSYSV -O $(KFLAGS)" gkermit
|
||||
|
||||
posix: gwart
|
||||
$(MAKE) "CC=$(CC)" "CFLAGS=-DPOSIX -O $(KFLAGS)" gkermit
|
||||
|
||||
sysvx: gwart
|
||||
$(MAKE) "CC=$(CC)" \
|
||||
"CFLAGS=-DSYSV -DUSE_GETCHAR -O $(KFLAGS)" gkermit
|
||||
|
||||
stty: gwart
|
||||
$(MAKE) "CC=$(CC)" "CFLAGS=$(KFLAGS)" gkermit
|
||||
|
||||
bsd211: gwart
|
||||
./gwart gproto.w gproto.c
|
||||
cc -DBSD $(KFLAGS) -c gkermit.c
|
||||
cc -DBSD $(KFLAGS) -c gproto.c
|
||||
cc -DBSD $(KFLAGS) -c gcmdline.c
|
||||
cc -DBSD $(KFLAGS) -c gunixio.c
|
||||
cc -o gkermit $(OBJECTS)
|
||||
|
||||
clean:
|
||||
rm -f $(OBJECTS) gproto.o gproto.c gwart.o gwart
|
||||
|
||||
install:
|
||||
@if test -f ./gkermit; then \
|
||||
echo "Installing gkermit..." ; \
|
||||
else \
|
||||
echo "Please build the gkermit binary first." ; \
|
||||
exit ; \
|
||||
fi
|
||||
@echo Copying gkermit to $(BINDIR)...
|
||||
@cp gkermit $(BINDIR)/gkermit
|
||||
@chmod 755 $(BINDIR)/gkermit
|
||||
@ls -lg $(BINDIR)/gkermit
|
||||
@if test -d $(TEXTDIR); then \
|
||||
echo "$(TEXTDIR) exists..." ; \
|
||||
else \
|
||||
echo "Creating $(TEXTDIR)/..." ; \
|
||||
mkdir $(TEXTDIR) ; \
|
||||
chmod 755 $(TEXTDIR) ; \
|
||||
fi
|
||||
@echo Copying README to $(TEXTDIR)/gkermit.txt...
|
||||
@cp README $(TEXTDIR)/gkermit.txt
|
||||
@chmod 644 $(TEXTDIR)/gkermit.txt
|
||||
@ls -lg $(TEXTDIR)/gkermit.txt
|
||||
@echo Installing man page in $(MANDIR)/gkermit.$(MANEXT)...
|
||||
@cp gkermit.nr $(MANDIR)/gkermit.$(MANEXT)
|
||||
@chmod 644 $(MANDIR)/gkermit.$(MANEXT)
|
||||
@ls -lg $(MANDIR)/gkermit.$(MANEXT)
|
||||
|
||||
uninstall:
|
||||
@echo Uninstalling gkermit...
|
||||
rm -f $(BINDIR)/gkermit \
|
||||
$(TEXTDIR)/gkermit.txt \
|
||||
$(MANDIR)gkermit.$(MANEXT)
|
||||
|
||||
.PHONY: clean install uninstall
|
||||
|
||||
# (end)
|
@ -1,25 +0,0 @@
|
||||
# $NetBSD: Makefile,v 1.3 2011/05/26 12:56:28 joerg Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
USE_FORT?= yes # data driven bugs?
|
||||
|
||||
DIST= ${NETBSDSRCDIR}/gnu/dist/gkermit
|
||||
|
||||
PROG= gkermit
|
||||
SRCS= gcmdline.c gkermit.c gproto.c gunixio.c
|
||||
MAN= gkermit.1
|
||||
|
||||
# Note that we do not use gwart. Provided gproto.w is unchanged,
|
||||
# the distributed gproto.c does not need to be updated.
|
||||
|
||||
BUILDSYMLINKS+= gkermit.nr gkermit.1
|
||||
|
||||
CPPFLAGS+= -DPOSIX
|
||||
CPPFLAGS+= -I${DIST}
|
||||
|
||||
CWARNFLAGS.clang+= -Wno-unused-value
|
||||
|
||||
.PATH: ${DIST}
|
||||
|
||||
.include <bsd.prog.mk>
|
Loading…
Reference in New Issue
Block a user