summaryrefslogtreecommitdiffstats
path: root/gnu/libexec/uucp/uucico
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1995-08-19 21:30:30 +0000
committerache <ache@FreeBSD.org>1995-08-19 21:30:30 +0000
commitb06a057b826e638a06edc1f92d5eed32662e0077 (patch)
treee1ea6a3b65e0f2e9f5d6e0f0f3956a82ada4b85b /gnu/libexec/uucp/uucico
parenta80ddb7b20df1716802b47c395201f120b369ee6 (diff)
downloadFreeBSD-src-b06a057b826e638a06edc1f92d5eed32662e0077.zip
FreeBSD-src-b06a057b826e638a06edc1f92d5eed32662e0077.tar.gz
Commit delta: current -> 1.06 + FreeBSD configuration
Diffstat (limited to 'gnu/libexec/uucp/uucico')
-rw-r--r--gnu/libexec/uucp/uucico/Makefile6
-rw-r--r--gnu/libexec/uucp/uucico/prote.c20
-rw-r--r--gnu/libexec/uucp/uucico/protf.c10
-rw-r--r--gnu/libexec/uucp/uucico/protg.c24
-rw-r--r--gnu/libexec/uucp/uucico/proti.c65
-rw-r--r--gnu/libexec/uucp/uucico/protj.c6
-rw-r--r--gnu/libexec/uucp/uucico/prott.c10
-rw-r--r--gnu/libexec/uucp/uucico/proty.c660
-rw-r--r--gnu/libexec/uucp/uucico/protz.c20
-rw-r--r--gnu/libexec/uucp/uucico/rec.c114
-rw-r--r--gnu/libexec/uucp/uucico/send.c116
-rw-r--r--gnu/libexec/uucp/uucico/time.c6
-rw-r--r--gnu/libexec/uucp/uucico/trans.c289
-rw-r--r--gnu/libexec/uucp/uucico/uucico.814
-rw-r--r--gnu/libexec/uucp/uucico/uucico.c112
-rw-r--r--gnu/libexec/uucp/uucico/xcmd.c14
16 files changed, 1143 insertions, 343 deletions
diff --git a/gnu/libexec/uucp/uucico/Makefile b/gnu/libexec/uucp/uucico/Makefile
index f968c35..f93d4b4 100644
--- a/gnu/libexec/uucp/uucico/Makefile
+++ b/gnu/libexec/uucp/uucico/Makefile
@@ -1,5 +1,5 @@
# Makefile for uucico
-# $Id: Makefile,v 1.6 1994/05/31 15:55:43 ache Exp $
+# $Id: Makefile,v 1.7 1995/05/13 12:29:57 ache Exp $
BINDIR= $(libxdir)
BINOWN= $(owner)
@@ -7,8 +7,8 @@ BINMODE= 4555
PROG= uucico
SRCS= uucico.c trans.c send.c rec.c xcmd.c prot.c protg.c protf.c \
- prott.c prote.c proti.c protj.c protz.c time.c chat.c \
- conn.c copy.c log.c tcp.c tli.c util.c
+ prott.c prote.c proti.c protj.c proty.c protz.c time.c log.c \
+ chat.c conn.c util.c copy.c
LDADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP)
DPADD+= $(LIBUNIX) $(LIBUUCONF) $(LIBUUCP)
CFLAGS+= -I$(.CURDIR)/../common_sources\
diff --git a/gnu/libexec/uucp/uucico/prote.c b/gnu/libexec/uucp/uucico/prote.c
index 4cff75b..fc73b5d 100644
--- a/gnu/libexec/uucp/uucico/prote.c
+++ b/gnu/libexec/uucp/uucico/prote.c
@@ -1,7 +1,7 @@
/* prote.c
The 'e' protocol.
- Copyright (C) 1991, 1992 Ian Lance Taylor
+ Copyright (C) 1991, 1992, 1995 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -17,16 +17,16 @@
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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
+ c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
*/
#include "uucp.h"
#if USE_RCS_ID
-const char prote_rcsid[] = "$Id: prote.c,v 1.2 1994/05/07 18:13:43 ache Exp $";
+const char prote_rcsid[] = "$Id: prote.c,v 1.20 1995/08/02 00:24:28 ian Rel $";
#endif
#include "uudefs.h"
@@ -97,7 +97,7 @@ festart (qdaemon, pzlog)
/* Stop the protocol. */
/*ARGSUSED*/
-boolean
+boolean
feshutdown (qdaemon)
struct sdaemon *qdaemon;
{
@@ -254,6 +254,16 @@ feprocess_data (qdaemon, pfexit, pcneed)
cinbuf = iPrecend - iPrecstart;
if (cinbuf < 0)
cinbuf += CRECBUFLEN;
+
+ if (cEbytes == 0)
+ {
+ if (! fgot_data (qdaemon, abPrecbuf, (size_t) 0,
+ (const char *) NULL, (size_t) 0,
+ -1, -1, (long) -1, TRUE, pfexit))
+ return FALSE;
+ if (*pfexit)
+ return TRUE;
+ }
}
/* Here we can read real data for the file. */
diff --git a/gnu/libexec/uucp/uucico/protf.c b/gnu/libexec/uucp/uucico/protf.c
index c38b9a1..289dbeff 100644
--- a/gnu/libexec/uucp/uucico/protf.c
+++ b/gnu/libexec/uucp/uucico/protf.c
@@ -17,16 +17,16 @@
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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
+ c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
*/
#include "uucp.h"
#if USE_RCS_ID
-const char protf_rcsid[] = "$Id: protf.c,v 1.2 1994/05/07 18:13:45 ache Exp $";
+const char protf_rcsid[] = "$Id: protf.c,v 1.33 1995/06/21 19:15:17 ian Rel $";
#endif
#include <ctype.h>
@@ -247,7 +247,7 @@ ffsenddata (qdaemon, zdata, cdata, ilocal, iremote, ipos)
char ab[CFBUFSIZE * 2];
char *ze;
register unsigned int itmpchk;
-
+
cFsent_data += cdata;
ze = ab;
@@ -759,7 +759,7 @@ ffawait_cksum (qtrans, qdaemon, zdata, cdata)
xfree (qtrans->pinfo);
return FALSE;
}
-
+
icheck = (unsigned int) strtol ((char *) zdata, (char **) NULL, 16);
if (icheck != (iFcheck & 0xffff))
diff --git a/gnu/libexec/uucp/uucico/protg.c b/gnu/libexec/uucp/uucico/protg.c
index efae85f..eda4ed0 100644
--- a/gnu/libexec/uucp/uucico/protg.c
+++ b/gnu/libexec/uucp/uucico/protg.c
@@ -1,7 +1,7 @@
/* protg.c
The 'g' protocol.
- Copyright (C) 1991, 1992, 1993, 1994 Ian Lance Taylor
+ Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -17,16 +17,16 @@
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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
+ c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
*/
#include "uucp.h"
#if USE_RCS_ID
-const char protg_rcsid[] = "$Id: protg.c,v 1.2 1994/05/07 18:13:46 ache Exp $";
+const char protg_rcsid[] = "$Id: protg.c,v 1.68 1995/06/21 19:15:22 ian Rel $";
#endif
#include <ctype.h>
@@ -137,7 +137,7 @@ const char protg_rcsid[] = "$Id: protg.c,v 1.2 1994/05/07 18:13:46 ache Exp $";
/* Maximum amount of data in a single packet. This is set by the <k>
field in the header; the amount of data in a packet is
2 ** (<k> + 4). <k> ranges from 1 to 8. */
-
+
#define CMAXDATAINDEX (8)
#define CMAXDATA (1 << (CMAXDATAINDEX + 4))
@@ -446,7 +446,7 @@ fgstart (qdaemon, pzlog)
iGrequest_packsize, qdaemon->qproto->bname);
iseg = 1;
}
-
+
if (iGrequest_winsize <= 0 || iGrequest_winsize > 7)
{
ulog (LOG_ERROR, "Illegal window size %d for '%c' protocol",
@@ -561,7 +561,7 @@ fvstart (qdaemon, pzlog)
if (iGrequest_packsize == IPACKSIZE)
iGrequest_packsize = 1024;
return fgstart (qdaemon, pzlog);
-}
+}
/* Exchange initialization messages with the other system.
@@ -1140,7 +1140,7 @@ fgwait_for_packet (qdaemon, freturncontrol, ctimeout, cretries)
size_t cneed;
boolean ffound;
size_t crec;
-
+
if (! fgprocess_data (qdaemon, TRUE, freturncontrol, &fexit,
&cneed, &ffound))
return FALSE;
@@ -1502,7 +1502,7 @@ fgprocess_data (qdaemon, fdoacks, freturncontrol, pfexit, pcneed, pffound)
cinbuf -= CFRAMELEN;
/* Make sure we have enough data. If we don't, wait for
- more. */
+ more. */
cwant = (int) CPACKLEN (ab);
if (cinbuf < cwant)
@@ -1511,7 +1511,7 @@ fgprocess_data (qdaemon, fdoacks, freturncontrol, pfexit, pcneed, pffound)
*pcneed = cwant - cinbuf;
return TRUE;
}
-
+
/* Set up the data pointers and compute the checksum. */
if (iPrecend >= iPrecstart)
cfirst = cwant;
@@ -1546,7 +1546,7 @@ fgprocess_data (qdaemon, fdoacks, freturncontrol, pfexit, pcneed, pffound)
(((0xaaaa - (icheck ^ (ab[IFRAME_CONTROL] & 0xff)))
& 0xffff)));
}
-
+
ihdrcheck = (unsigned short) (((ab[IFRAME_CHECKHIGH] & 0xff) << 8)
| (ab[IFRAME_CHECKLOW] & 0xff));
@@ -1614,7 +1614,7 @@ fgprocess_data (qdaemon, fdoacks, freturncontrol, pfexit, pcneed, pffound)
&& CONTROL_XXX (ab[IFRAME_CONTROL]) == RR
&& iGremote_ack == CONTROL_YYY (ab[IFRAME_CONTROL])
&& INEXTSEQ (iGremote_ack) != iGsendseq
- && iGretransmit_seq != -1)
+ && iGretransmit_seq == -1)
{
DEBUG_MESSAGE0 (DEBUG_PROTO | DEBUG_ABNORMAL,
"fgprocess_data: Treating duplicate RR as RJ");
diff --git a/gnu/libexec/uucp/uucico/proti.c b/gnu/libexec/uucp/uucico/proti.c
index 17b540e..3209892 100644
--- a/gnu/libexec/uucp/uucico/proti.c
+++ b/gnu/libexec/uucp/uucico/proti.c
@@ -1,7 +1,7 @@
/* proti.c
The 'i' protocol.
- Copyright (C) 1992, 1993 Ian Lance Taylor
+ Copyright (C) 1992, 1993, 1995 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -17,16 +17,16 @@
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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
+ c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
*/
#include "uucp.h"
#if USE_RCS_ID
-const char proti_rcsid[] = "$Id: proti.c,v 1.2 1994/05/07 18:13:48 ache Exp $";
+const char proti_rcsid[] = "$Id: proti.c,v 1.33 1995/06/21 19:15:28 ian Rel $";
#endif
#include <ctype.h>
@@ -146,8 +146,8 @@ const char proti_rcsid[] = "$Id: proti.c,v 1.2 1994/05/07 18:13:48 ache Exp $";
#define SPOS (4)
#define CLOSE (5)
-/* Largest possible packet size (plus 1). */
-#define IMAXPACKSIZE (1 << 12)
+/* Largest possible packet size. */
+#define IMAXPACKSIZE ((1 << 12) - 1)
/* Largest possible sequence number (plus 1). */
#define IMAXSEQ 32
@@ -239,6 +239,11 @@ static int cIsync_retries = CSYNC_RETRIES;
``timeout''). */
static int cItimeout = CTIMEOUT;
+/* Timeout to use when waiting for an acknowledgement to open up space
+ in the window. This is computed based on the window size and the
+ connection speed. */
+static int cIwindow_timeout = CTIMEOUT;
+
/* Number of times to retry sending a packet before giving up
(protocol parameter ``retries''). */
static int cIretries = CRETRIES;
@@ -406,6 +411,7 @@ fijstart (qdaemon, pzlog, imaxpacksize, pfsend, pfreceive)
unsigned long icksum;
int ctries;
int csyncs;
+ long ibaud;
*pzlog = NULL;
@@ -413,7 +419,7 @@ fijstart (qdaemon, pzlog, imaxpacksize, pfsend, pfreceive)
pfIreceive = pfreceive;
if (iIforced_remote_packsize <= 0
- || iIforced_remote_packsize >= imaxpacksize)
+ || iIforced_remote_packsize > imaxpacksize)
iIforced_remote_packsize = 0;
else
iIremote_packsize = iIforced_remote_packsize;
@@ -508,6 +514,42 @@ fijstart (qdaemon, pzlog, imaxpacksize, pfsend, pfreceive)
}
}
+ /* Calculate the window timeout. */
+ ibaud = iconn_baud (qdaemon->qconn);
+ if (ibaud == 0)
+ cIwindow_timeout = cItimeout;
+ else
+ {
+ /* We expect to receive an ACK about halfway through each
+ window. In principle, an entire window might be sitting in a
+ modem buffer while we are waiting for an ACK. Therefore, the
+ minimum time we should wait for an ACK is
+ (1/2 window size) * (seconds / byte) + (roundtrip time) ==
+ (1/2 window size) * (1 / (baud / 10)) + (roundtrip time) ==
+ (1/2 window size) * (10 / baud) + (roundtrip time) ==
+ (5 * (window size)) / baud + (roundtrip time)
+
+ The window size is iIremote_packsize * iIremote_winsize. For
+ typical settings of packsize == 1024, winsize == 16, baud ==
+ 9600, this equation works out to
+ (5 * 1024 * 16) / 9600 == 8 seconds
+ We then take cItimeout as the round trip time, which gives us
+ some flexibility. We get more flexibility because it is
+ quite likely that by the time we have finished sending out
+ the last packet in a window, the first one has already been
+ received by the remote system. */
+ cIwindow_timeout = ((5 * iIremote_packsize * iIremote_winsize) / ibaud
+ + cItimeout);
+ }
+
+ /* If we are the callee, bump both timeouts by one, to make it less
+ likely that both systems will timeout simultaneously. */
+ if (! qdaemon->fcaller)
+ {
+ ++cItimeout;
+ ++cIwindow_timeout;
+ }
+
/* We got a SYNC packet; set up packet buffers to use. */
if (iIremote_packsize > imaxpacksize)
iIremote_packsize = imaxpacksize;
@@ -607,6 +649,7 @@ fishutdown (qdaemon)
cIsync_timeout = CSYNC_TIMEOUT;
cIsync_retries = CSYNC_RETRIES;
cItimeout = CTIMEOUT;
+ cIwindow_timeout = CTIMEOUT;
cIretries = CRETRIES;
cIerrors = CERRORS;
cIerror_decay = CERROR_DECAY;
@@ -741,7 +784,7 @@ fiwindow_wait (qdaemon)
sends the entire packet. Hopefully that will trigger an ACK
or a NAK and get us going again. */
DEBUG_MESSAGE0 (DEBUG_PROTO, "fiwindow_wait: Waiting for ACK");
- if (! fiwait_for_packet (qdaemon, cItimeout, cIretries,
+ if (! fiwait_for_packet (qdaemon, cIwindow_timeout, cIretries,
TRUE, (boolean *) NULL))
return FALSE;
}
@@ -866,7 +909,7 @@ fisenddata (qdaemon, zdata, cdata, ilocal, iremote, ipos)
DEBUG_MESSAGE4 (DEBUG_PROTO,
"fisenddata: Sending packet %d size %d local %d remote %d",
- iIsendseq, (int) cdata, ilocal, iremote);
+ iIsendseq, (int) cdata, ilocal, iremote);
iIsendseq = INEXTSEQ (iIsendseq);
++cIsent_packets;
@@ -1535,7 +1578,7 @@ fiprocess_packet (qdaemon, zhdr, zfirst, cfirst, zsecond, csecond, pfexit)
case NAK:
/* We must resend the requested packet. */
- {
+ {
int iseq;
char *zsend;
size_t clen;
@@ -1598,7 +1641,7 @@ fiprocess_packet (qdaemon, zhdr, zfirst, cfirst, zsecond, csecond, pfexit)
zsend[IHDR_CHECK] = IHDRCHECK_VAL (zsend);
iIlocal_ack = iIrecseq;
}
-
+
++cIresent_packets;
clen = CHDRCON_GETBYTES (zsend[IHDR_CONTENTS1],
diff --git a/gnu/libexec/uucp/uucico/protj.c b/gnu/libexec/uucp/uucico/protj.c
index 091099e..3d7c206 100644
--- a/gnu/libexec/uucp/uucico/protj.c
+++ b/gnu/libexec/uucp/uucico/protj.c
@@ -17,16 +17,16 @@
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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
+ c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
*/
#include "uucp.h"
#if USE_RCS_ID
-const char protj_rcsid[] = "$Id: protj.c,v 1.4 1994/01/30 21:01:46 ian Rel $";
+const char protj_rcsid[] = "$Id: protj.c,v 1.6 1995/06/21 19:15:32 ian Rel $";
#endif
#include <ctype.h>
diff --git a/gnu/libexec/uucp/uucico/prott.c b/gnu/libexec/uucp/uucico/prott.c
index 8bf703a..dec4557 100644
--- a/gnu/libexec/uucp/uucico/prott.c
+++ b/gnu/libexec/uucp/uucico/prott.c
@@ -17,16 +17,16 @@
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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
+ c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
*/
#include "uucp.h"
#if USE_RCS_ID
-const char prott_rcsid[] = "$Id: prott.c,v 1.2 1994/05/07 18:13:51 ache Exp $";
+const char prott_rcsid[] = "$Id: prott.c,v 1.29 1995/06/21 19:15:36 ian Rel $";
#endif
#include "uudefs.h"
@@ -96,7 +96,7 @@ ftstart (qdaemon, pzlog)
/* Stop the protocol. */
/*ARGSUSED*/
-boolean
+boolean
ftshutdown (qdaemon)
struct sdaemon *qdaemon;
{
@@ -269,7 +269,7 @@ ftprocess_data (qdaemon, pfexit, pcneed)
return FALSE;
iPrecstart = (iPrecstart + clen) % CRECBUFLEN;
-
+
if (*pfexit)
return TRUE;
diff --git a/gnu/libexec/uucp/uucico/proty.c b/gnu/libexec/uucp/uucico/proty.c
new file mode 100644
index 0000000..f15671e
--- /dev/null
+++ b/gnu/libexec/uucp/uucico/proty.c
@@ -0,0 +1,660 @@
+/* proty.c
+ The 'y' protocol.
+
+ Copyright (C) 1994, 1995 Jorge Cwik and Ian Lance Taylor
+
+ This file is part of the Taylor UUCP package.
+
+ 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 "uucp.h"
+
+#if USE_RCS_ID
+const char proty_id[] = "$Id: proty.c,v 1.4 1995/06/21 19:15:40 ian Rel $";
+#endif
+
+#include "uudefs.h"
+#include "uuconf.h"
+#include "conn.h"
+#include "trans.h"
+#include "system.h"
+#include "prot.h"
+
+/* The 'y' protocol, and this implementation, was written and designed
+ by Jorge Cwik <jorge@satlink.net>. Some of the routines, and the
+ coding style in general, were taken verbatim or adapted from other
+ Taylor UUCP modules. Mark Delany made the initial testings and
+ helped in portability issues.
+
+ This protocol does not perform any kind of error correction or flow
+ control. It does do error checking. It does not require an end to
+ end reliable link. It is recommended for error-free (also called
+ semi-reliable) connections as provided by error correcting modems.
+ It needs an eight bit clean channel and some kind of flow control
+ at the lower layers, typically RTS/CTS hardware flow control.
+
+ The flow of the file transmission is completely unidirectional.
+ There are no ACKs or NAKs outside file boundaries. This makes it
+ very suitable for half duplex modulations (like PEP) and
+ connections with very long delays, like multihop satellite links. */
+
+/* This protocol uses 16 bit little-endian ints in the packet header. */
+#define FROMLITTLE(p) (((p)[0] & 0xff) + (((p)[1] & 0xff) << 8))
+#define TOLITTLE(p, i) ((p)[0] = (i) & 0xff, (p)[1] = ((i) >> 8) & 0xff)
+
+/* The buffer and packet size we use. */
+#define CYBUFSIZE (1024)
+#define IYPACKSIZE (1024)
+
+/* The offset in the buffer to the data. */
+#define CYFRAMELEN (6)
+
+/* Offsets in a packet header. */
+#define YFRAME_SEQ_OFF (0)
+#define YFRAME_LEN_OFF (2)
+#define YFRAME_CTL_OFF (2)
+#define YFRAME_CHK_OFF (4)
+
+/* Offsets in a packet header viewed as an array of shorts. */
+#define YFRAME_SEQ (0)
+#define YFRAME_LEN (1)
+#define YFRAME_CTL (1)
+#define YFRAME_CHK (2)
+
+/* The default timeout. */
+#define CYTIMEOUT (60)
+
+/* Control packet types. */
+#define YPKT_ACK (0xFFFE)
+#define YPKT_ERR (0xFFFD)
+#define YPKT_BAD (0xFFFC)
+
+/* The protocol version number. */
+#define Y_VERSION (1)
+
+/* When the protocol starts up, it transmit the following information:
+ 1 byte version
+ 1 byte packet size
+ 2 byte flags (none currently defined)
+ Future revision may expand the structure as long as these members
+ keep their current offset. */
+#define Y_INIT_HDR_LEN (4)
+#define Y_INIT_HDR_VERSION_OFF (0)
+#define Y_INIT_HDR_PKTSIZE_OFF (1)
+#define Y_INIT_HDR_FLAGS_OFF (2)
+
+/* The initialization length of the lowest accepted version. */
+#define MIN_Y_SYNC (4)
+
+/* Not strictly needed, but I would not want to accept a 32k sync pkt. */
+#define MAX_Y_SYNC IYPACKSIZE
+
+/* Local and remote packet sizes (we actually use the same value for
+ both). */
+static size_t iYlocal_packsize = IYPACKSIZE;
+static size_t iYremote_packsize = IYPACKSIZE;
+
+/* Local and remote packet sequence numbers. */
+static unsigned short iYlocal_pktnum;
+static unsigned short iYremote_pktnum;
+
+/* The timeout. */
+static int cYtimeout = CYTIMEOUT;
+
+/* Transmitter buffer. */
+static char *zYbuf;
+
+/* Protocol parameters. */
+
+struct uuconf_cmdtab asYproto_params[] =
+{
+ { "timeout", UUCONF_CMDTABTYPE_INT, (pointer) &cYtimeout, NULL },
+ { "packet-size", UUCONF_CMDTABTYPE_INT, (pointer) &iYlocal_packsize, NULL },
+ { NULL, 0, NULL, NULL }
+};
+
+/* Local functions. */
+
+static boolean fywait_for_packet P((struct sdaemon *qdaemon,
+ boolean *pfexit));
+static unsigned short iychecksum P((const char *z, size_t c));
+static unsigned short iychecksum2 P((const char *zfirst, size_t cfirst,
+ const char *zsecond, size_t csecond));
+static boolean fywait_for_header P((struct sdaemon *qdaemon,
+ unsigned short header[3], int timeout));
+static boolean fysend_pkt P((struct sdaemon *qdaemon,
+ const void *zdata, size_t cdata));
+static boolean fysend_control P((struct sdaemon *qdaemon,
+ int itype));
+static boolean fyread_data P((struct sdaemon *qdaemon, size_t clen,
+ int timeout));
+
+/* Exchange sync packets at protocol startup. */
+
+static boolean
+fyxchg_syncs (qdaemon)
+ struct sdaemon *qdaemon;
+{
+ char inithdr[Y_INIT_HDR_LEN];
+ unsigned short header[3];
+ unsigned short ichk;
+ size_t clen, cfirst;
+ int rpktsize;
+
+ /* Send our configuration. We could use only one array (for local
+ and remote). But this is safer in case the code changes and
+ depend on separate ones. */
+
+ inithdr[Y_INIT_HDR_VERSION_OFF] = Y_VERSION;
+ inithdr[Y_INIT_HDR_PKTSIZE_OFF] = iYlocal_packsize >> 8;
+ TOLITTLE (inithdr + Y_INIT_HDR_FLAGS_OFF, 0);
+
+ if (! fysend_pkt (qdaemon, inithdr, Y_INIT_HDR_LEN))
+ return FALSE;
+
+ if (! fywait_for_header (qdaemon, header, cYtimeout))
+ return FALSE;
+
+ DEBUG_MESSAGE0 (DEBUG_UUCP_PROTO, "fyxchg_syncs: Got sync header");
+ clen = header[YFRAME_LEN];
+
+ if (clen < MIN_Y_SYNC || clen > MAX_Y_SYNC)
+ {
+ ulog (LOG_ERROR, "Bad 'y' protocol sync packet length");
+ return FALSE;
+ }
+
+ /* It may be better to integrate this code with fywait_for_packet. */
+ if (! fyread_data (qdaemon, clen, cYtimeout))
+ return FALSE;
+
+ cfirst = CRECBUFLEN - iPrecstart;
+ ichk = iychecksum2 (abPrecbuf + iPrecstart, cfirst,
+ abPrecbuf, clen - cfirst);
+
+ rpktsize = BUCHAR (abPrecbuf[(iPrecstart + 1) % CRECBUFLEN]);
+
+ /* Future versions of the protocol may need to check and react
+ according to the version number. */
+
+ if (rpktsize == 0 || header[YFRAME_CHK] != ichk)
+ {
+ ulog (LOG_ERROR, "Bad 'y' protocol sync packet");
+ return FALSE;
+ }
+
+ iYremote_packsize = rpktsize << 8;
+
+ /* Some may want to do this different and in effect the protocol
+ support this. But I like the idea that the packet size would be
+ the same in both directions. This allows the caller to select
+ both packet sizes without changing the configuration at the
+ server. */
+ if (iYremote_packsize > iYlocal_packsize)
+ iYremote_packsize = iYlocal_packsize;
+
+ iPrecstart = (iPrecstart + clen) % CRECBUFLEN;
+ return TRUE;
+}
+
+/* Start the protocol. */
+
+boolean
+fystart (qdaemon, pzlog)
+ struct sdaemon *qdaemon;
+ char **pzlog;
+{
+ *pzlog = NULL;
+
+ /* This should force, or at least enable if available, RTS/CTS
+ hardware flow control !! */
+
+ /* The 'y' protocol requires an eight bit clean link */
+ if (! fconn_set (qdaemon->qconn, PARITYSETTING_NONE,
+ STRIPSETTING_EIGHTBITS, XONXOFF_OFF))
+ return FALSE;
+
+ iYlocal_pktnum = iYremote_pktnum = 0;
+
+ /* Only multiple of 256 sizes are allowed */
+ iYlocal_packsize &= ~0xff;
+ if (iYlocal_packsize < 256 || iYlocal_packsize > (16*1024))
+ iYlocal_packsize = IYPACKSIZE;
+
+ /* Exhange SYNC packets */
+ if (! fyxchg_syncs (qdaemon))
+ {
+ /* Restore defaults */
+ cYtimeout = CYTIMEOUT;
+ iYlocal_packsize = IYPACKSIZE;
+ return FALSE;
+ }
+
+ zYbuf = (char *) xmalloc (CYBUFSIZE + CYFRAMELEN);
+ return TRUE;
+}
+
+/* Shutdown the protocol. */
+
+boolean
+fyshutdown (qdaemon)
+ struct sdaemon *qdaemon;
+{
+ xfree ((pointer) zYbuf);
+ zYbuf = NULL;
+ cYtimeout = CYTIMEOUT;
+ iYlocal_packsize = IYPACKSIZE;
+ return TRUE;
+}
+
+/* Send a command string. We send packets containing the string until
+ the entire string has been sent, including the zero terminator. */
+
+/*ARGSUSED*/
+boolean
+fysendcmd (qdaemon, z, ilocal, iremote)
+ struct sdaemon *qdaemon;
+ const char *z;
+ int ilocal;
+ int iremote;
+{
+ size_t clen;
+
+ DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO, "fysendcmd: Sending command \"%s\"", z);
+
+ clen = strlen (z) + 1;
+
+ while (clen > 0)
+ {
+ size_t csize;
+
+ csize = clen;
+ if (csize > iYremote_packsize)
+ csize = iYremote_packsize;
+
+ if (! fysend_pkt (qdaemon, z, csize))
+ return FALSE;
+
+ z += csize;
+ clen -= csize;
+ }
+
+ return TRUE;
+}
+
+/* Get space to be filled with data. We always use zYbuf, which was
+ allocated from the heap. */
+
+char *
+zygetspace (qdaemon, pclen)
+ struct sdaemon *qdaemon;
+ size_t *pclen;
+{
+ *pclen = iYremote_packsize;
+ return zYbuf + CYFRAMELEN;
+}
+
+/* Send out a data packet. */
+
+boolean
+fysenddata (qdaemon, zdata, cdata, ilocal, iremote, ipos)
+ struct sdaemon *qdaemon;
+ char *zdata;
+ size_t cdata;
+ int ilocal;
+ int iremote;
+ long ipos;
+{
+#if DEBUG > 0
+ if (cdata > iYremote_packsize)
+ ulog (LOG_FATAL, "fysend_packet: Packet size too large");
+#endif
+
+ TOLITTLE (zYbuf + YFRAME_SEQ_OFF, iYlocal_pktnum);
+ ++iYlocal_pktnum;
+ TOLITTLE (zYbuf + YFRAME_LEN_OFF, cdata);
+ TOLITTLE (zYbuf + YFRAME_CHK_OFF, iychecksum (zdata, cdata));
+
+ /* We pass FALSE to fsend_data since we don't expect the other side
+ to be sending us anything just now. */
+ return fsend_data (qdaemon->qconn, zYbuf, cdata + CYFRAMELEN, FALSE);
+}
+
+/* Wait for data to come in and process it until we've finished a
+ command or a file. */
+
+boolean
+fywait (qdaemon)
+ struct sdaemon *qdaemon;
+{
+ boolean fexit = FALSE;
+
+ while (! fexit)
+ {
+ if (! fywait_for_packet (qdaemon, &fexit))
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/* File level routines
+ We could handle this inside the other public routines,
+ but this is cleaner and better for future expansions */
+
+boolean
+fyfile (qdaemon, qtrans, fstart, fsend, cbytes, pfhandled)
+ struct sdaemon *qdaemon;
+ struct stransfer *qtrans;
+ boolean fstart;
+ boolean fsend;
+ long cbytes;
+ boolean *pfhandled;
+{
+ unsigned short header[3];
+
+ *pfhandled = FALSE;
+
+ if (! fstart)
+ {
+ if (fsend)
+ {
+ /* It is critical that the timeout here would be long
+ enough. We have just sent a full file without any kind
+ of flow control at the protocol level. The traffic may
+ be buffered in many places of the link, and the remote
+ may take a while until cathing up. */
+ if (! fywait_for_header (qdaemon, header, cYtimeout * 2))
+ return FALSE;
+
+ if (header[YFRAME_CTL] != (unsigned short) YPKT_ACK)
+ {
+ DEBUG_MESSAGE1 (DEBUG_PROTO | DEBUG_ABNORMAL,
+ "fyfile: Error from remote: 0x%04X", header[1]);
+ ulog (LOG_ERROR, "Received 'y' protocol error from remote");
+ return FALSE;
+ }
+ }
+ else
+ {
+ /* This is technically not requireed. But I've put this in
+ the protocol to allow easier expansions. */
+ return fysend_control (qdaemon, YPKT_ACK);
+ }
+ }
+
+ return TRUE;
+}
+
+/* Send a control packet, not used during the normal file
+ transmission. */
+
+static boolean
+fysend_control (qdaemon, itype)
+ struct sdaemon *qdaemon;
+ int itype;
+{
+ char header[CYFRAMELEN];
+
+ TOLITTLE (header + YFRAME_SEQ_OFF, iYlocal_pktnum);
+ iYlocal_pktnum++;
+ TOLITTLE (header + YFRAME_CTL_OFF, itype);
+ TOLITTLE (header + YFRAME_CHK_OFF, 0);
+
+ return fsend_data (qdaemon->qconn, header, CYFRAMELEN, FALSE);
+}
+
+/* Private function to send a packet. This one doesn't need the data
+ to be in the buffer provided by zygetspace. I've found it worth
+ for avoiding memory copies. Somebody may want to do it otherwise */
+
+static boolean
+fysend_pkt (qdaemon, zdata, cdata)
+ struct sdaemon *qdaemon;
+ const void *zdata;
+ size_t cdata;
+{
+ char header[CYFRAMELEN];
+
+ TOLITTLE (header + YFRAME_SEQ_OFF, iYlocal_pktnum);
+ iYlocal_pktnum++;
+ TOLITTLE (header + YFRAME_LEN_OFF, cdata);
+ TOLITTLE (header + YFRAME_CHK_OFF, iychecksum (zdata, cdata));
+
+ if (! fsend_data (qdaemon->qconn, header, CYFRAMELEN, FALSE))
+ return FALSE;
+ return fsend_data (qdaemon->qconn, zdata, cdata, FALSE);
+}
+
+/* Wait until enough data arrived from the comm line. This protocol
+ doesn't need to perform any kind of action while waiting. */
+
+static boolean
+fyread_data (qdaemon, clen, timeout)
+ struct sdaemon *qdaemon;
+ size_t clen;
+ int timeout;
+{
+ int cinbuf;
+ size_t crec;
+
+ cinbuf = iPrecend - iPrecstart;
+ if (cinbuf < 0)
+ cinbuf += CRECBUFLEN;
+
+ if (cinbuf < clen)
+ {
+ if (! freceive_data (qdaemon->qconn, clen - cinbuf, &crec,
+ timeout, TRUE))
+ return FALSE;
+ cinbuf += crec;
+ if (cinbuf < clen)
+ {
+ if (! freceive_data (qdaemon->qconn, clen - cinbuf, &crec,
+ timeout, TRUE))
+ return FALSE;
+ }
+ cinbuf += crec;
+ if (cinbuf < clen)
+ {
+ ulog (LOG_ERROR, "Timed out waiting for data");
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+/* Receive a remote packet header, check for correct sequence number. */
+
+static boolean
+fywait_for_header (qdaemon, header, timeout)
+ struct sdaemon *qdaemon;
+ unsigned short header[3];
+ int timeout;
+{
+ if (! fyread_data (qdaemon, CYFRAMELEN, timeout))
+ return FALSE;
+
+ /* Somebody may want to optimize this in a portable way. I'm not
+ sure it's worth, but the output by gcc for the portable construct
+ is so bad (even with optimization), that I couldn't resist. */
+
+ if (iPrecstart <= (CRECBUFLEN - CYFRAMELEN))
+ {
+ header[0] = FROMLITTLE (abPrecbuf + iPrecstart);
+ header[1] = FROMLITTLE (abPrecbuf + iPrecstart + 2);
+ header[2] = FROMLITTLE (abPrecbuf + iPrecstart + 4);
+ }
+ else
+ {
+ register int i, j;
+
+ for (i = j = 0; j < CYFRAMELEN; i++, j += 2)
+ {
+ header[i] =
+ (((abPrecbuf[(iPrecstart + j + 1) % CRECBUFLEN] & 0xff) << 8)
+ + (abPrecbuf[(iPrecstart + j) % CRECBUFLEN] & 0xff));
+ }
+ }
+
+ iPrecstart = (iPrecstart + CYFRAMELEN) % CRECBUFLEN;
+
+ DEBUG_MESSAGE3 (DEBUG_UUCP_PROTO,
+ "fywait_for_header: Got header: 0x%04X, 0x%04X, 0x%04X",
+ header[0], header[1], header[2]);
+
+ if (header[YFRAME_SEQ] != iYremote_pktnum++)
+ {
+ ulog (LOG_ERROR, "Incorrect 'y' packet sequence");
+ fysend_control (qdaemon, YPKT_BAD);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/* Receive a remote data packet */
+
+static boolean
+fywait_for_packet (qdaemon, pfexit)
+ struct sdaemon *qdaemon;
+ boolean *pfexit;
+{
+ unsigned short header[3], ichk;
+ size_t clen, cfirst;
+
+ if (! fywait_for_header (qdaemon, header, cYtimeout))
+ return FALSE;
+
+ clen = header[YFRAME_LEN];
+ if (clen == 0 && pfexit != NULL)
+ {
+ /* I Suppose the pointers could be NULL ??? */
+ return fgot_data (qdaemon, abPrecbuf, 0, abPrecbuf, 0,
+ -1, -1, (long) -1, TRUE, pfexit);
+ }
+
+ if (clen & 0x8000)
+ {
+ DEBUG_MESSAGE1 (DEBUG_PROTO | DEBUG_ABNORMAL,
+ "fywait_for_packet: Error from remote: 0x%04X",
+ header[YFRAME_CTL]);
+ ulog (LOG_ERROR, "Remote error packet");
+ return FALSE;
+ }
+
+ /* This is really not neccessary. But if this check is removed,
+ take in mind that the packet may be up to 32k long. */
+ if (clen > iYlocal_packsize)
+ {
+ ulog (LOG_ERROR, "Packet too large");
+ return FALSE;
+ }
+
+ if (! fyread_data (qdaemon, clen, cYtimeout))
+ return FALSE;
+
+ cfirst = CRECBUFLEN - iPrecstart;
+ if (cfirst > clen)
+ cfirst = clen;
+
+ if (cfirst == clen)
+ ichk = iychecksum (abPrecbuf + iPrecstart, clen);
+ else
+ ichk = iychecksum2 (abPrecbuf + iPrecstart, cfirst,
+ abPrecbuf, clen - cfirst);
+ if (header[YFRAME_CHK] != ichk)
+ {
+ DEBUG_MESSAGE2 (DEBUG_PROTO | DEBUG_ABNORMAL,
+ "fywait_for_packet: Bad checksum 0x%x != 0x%x",
+ header[YFRAME_CHK], ichk);
+ fysend_control (qdaemon, YPKT_ERR);
+ ulog (LOG_ERROR, "Checksum error");
+ return FALSE;
+ }
+
+ if (pfexit != NULL
+ && ! fgot_data (qdaemon, abPrecbuf + iPrecstart, cfirst,
+ abPrecbuf, clen - cfirst,
+ -1, -1, (long) -1, TRUE, pfexit))
+ return FALSE;
+
+ iPrecstart = (iPrecstart + clen) % CRECBUFLEN;
+
+ return TRUE;
+}
+
+/* Compute 16 bit checksum */
+
+#ifdef __GNUC__
+#ifdef __i386__
+#define I386_ASM
+#endif
+#endif
+
+#ifdef I386_ASM
+#define ROTATE(i) \
+ asm ("rolw $1,%0" : "=g" (i) : "g" (i))
+#else
+#define ROTATE(i) i += i + ((i & 0x8000) >> 15)
+#endif
+
+static unsigned short
+iychecksum (z, c)
+ register const char *z;
+ register size_t c;
+{
+ register unsigned short ichk;
+
+ ichk = 0xffff;
+
+ while (c-- > 0)
+ {
+ ROTATE (ichk);
+ ichk += BUCHAR (*z++);
+ }
+
+ return ichk;
+}
+
+static unsigned short
+iychecksum2 (zfirst, cfirst, zsecond, csecond)
+ const char *zfirst;
+ size_t cfirst;
+ const char *zsecond;
+ size_t csecond;
+{
+ register unsigned short ichk;
+ register const char *z;
+ register size_t c;
+
+ z = zfirst;
+ c = cfirst + csecond;
+
+ ichk = 0xffff;
+
+ while (c-- > 0)
+ {
+ ROTATE (ichk);
+ ichk += BUCHAR (*z++);
+
+ /* If the first buffer has been finished, switch to the second. */
+ if (--cfirst == 0)
+ z = zsecond;
+ }
+
+ return ichk;
+}
diff --git a/gnu/libexec/uucp/uucico/protz.c b/gnu/libexec/uucp/uucico/protz.c
index 7bcf803..5dd2473 100644
--- a/gnu/libexec/uucp/uucico/protz.c
+++ b/gnu/libexec/uucp/uucico/protz.c
@@ -8,7 +8,7 @@
* Ian Taylor's UUCP package.
*
* It was originally developed to establish a uucp link between myself and my
- * employer: Ivation Datasystems, Inc. of Ottawa.
+ * employer: Ivation Datasystems, Inc. of Ottawa.
*
* My thanks to Ivation for letting me release this to the public. Given that
* Zmodem is in the public domain, no additional copyrights have been added.
@@ -139,7 +139,7 @@
* ZDATA (ZCRCG, xx bytes) - received ok
* ZDATA (ZCRCF, 0 bytes) - corrupted
*
- * At this point the receiver would like to send back a ZRPOS with a value
+ * At this point the receiver would like to send back a ZRPOS with a value
* of the size of the file. However, it can't because the value is divided
* by 32, and it would have to round up to the next multiple of 32. This
* seemed a little ugly, so I went with using the entire header to store
@@ -148,7 +148,7 @@
*****************************************************************************
*
* Source version:
- *
+ *
* 1.1,2,3
* Protocol version 0
* Early attempts, completely rewritten later.
@@ -181,7 +181,7 @@
#include "uucp.h"
#if USE_RCS_ID
-const char protz_rcsid[] = "$Id: protz.c,v 1.2 1994/05/07 18:13:52 ache Exp $";
+const char protz_rcsid[] = "$Id: protz.c,v 1.8 1993/12/20 00:44:49 ian Rel $";
#endif
#include <errno.h>
@@ -1397,14 +1397,14 @@ static unsigned long crc_32_tab[] = { /* CRC polynomial 0xedb88320 */
};
/*
- * updcrc macro derived from article Copyright (C) 1986 Stephen Satchell.
+ * updcrc macro derived from article Copyright (C) 1986 Stephen Satchell.
* NOTE: First argument must be in range 0 to 255.
* Second argument is referenced twice.
- *
- * Programmers may incorporate any or all code into their programs,
- * giving proper credit within the source. Publication of the
- * source routines is permitted so long as proper credit is given
- * to Stephen Satchell, Satchell Evaluations and Chuck Forsberg,
+ *
+ * Programmers may incorporate any or all code into their programs,
+ * giving proper credit within the source. Publication of the
+ * source routines is permitted so long as proper credit is given
+ * to Stephen Satchell, Satchell Evaluations and Chuck Forsberg,
* Omen Technology.
*/
diff --git a/gnu/libexec/uucp/uucico/rec.c b/gnu/libexec/uucp/uucico/rec.c
index 08b31a4..4a8f163 100644
--- a/gnu/libexec/uucp/uucico/rec.c
+++ b/gnu/libexec/uucp/uucico/rec.c
@@ -1,7 +1,7 @@
/* rec.c
Routines to receive a file.
- Copyright (C) 1991, 1992, 1993, 1994 Ian Lance Taylor
+ Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -17,16 +17,16 @@
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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
+ c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
*/
#include "uucp.h"
#if USE_RCS_ID
-const char rec_rcsid[] = "$Id: rec.c,v 1.3 1994/11/06 10:17:11 davidg Exp $";
+const char rec_rcsid[] = "$Id: rec.c,v 1.43 1995/08/02 01:21:12 ian Rel $";
#endif
#include <errno.h>
@@ -123,7 +123,7 @@ urrec_free (qtrans)
}
utransfree (qtrans);
-}
+}
/* Set up a request for a file from the remote system. This may be
called before the remote system has been called.
@@ -208,6 +208,7 @@ flocal_rec_file_init (qdaemon, qcmd)
ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
return FALSE;
}
+ slocalsys.uuconf_zname = (char *) zlocalname;
}
else if (iuuconf != UUCONF_SUCCESS)
{
@@ -364,8 +365,13 @@ flocal_rec_send_request (qtrans, qdaemon)
qtrans->iremote);
ubuffree (zsend);
- if (! fret)
- urrec_free (qtrans);
+ /* There is a potential space leak here: if pfsendcmd fails, we
+ might need to free qtrans. However, it is possible that by the
+ time pfsendcmd returns, a response will have been received which
+ led to the freeing of qtrans anyhow. One way to fix this would
+ be some sort of counter in qtrans to track allocations, but since
+ the space leak is small, and the conversation has failed anyhow,
+ it doesn't seem worth it. */
return fret;
}
@@ -569,7 +575,7 @@ fremote_send_file_init (qdaemon, qcmd, iremote)
qcmd->zfrom);
return fremote_send_fail (qdaemon, qcmd, FAILURE_PERM, iremote);
}
-
+
fspool = fspool_file (qcmd->zto);
/* We don't accept remote command files. An execution request may
@@ -795,6 +801,16 @@ fremote_send_reply (qtrans, qdaemon)
qinfo->freplied = TRUE;
+ if (! (*qdaemon->qproto->pfsendcmd) (qdaemon, ab, qtrans->ilocal,
+ qtrans->iremote))
+ {
+ (void) ffileclose (qtrans->e);
+ (void) remove (qinfo->ztemp);
+ /* Should probably free qtrans here, but see the comment at the
+ end of flocal_rec_send_request. */
+ return FALSE;
+ }
+
if (qdaemon->qproto->pffile != NULL)
{
boolean fhandled;
@@ -809,15 +825,6 @@ fremote_send_reply (qtrans, qdaemon)
}
}
- if (! (*qdaemon->qproto->pfsendcmd) (qdaemon, ab, qtrans->ilocal,
- qtrans->iremote))
- {
- (void) ffileclose (qtrans->e);
- (void) remove (qinfo->ztemp);
- urrec_free (qtrans);
- return FALSE;
- }
-
return TRUE;
}
@@ -861,16 +868,7 @@ fremote_send_fail_send (qtrans, qdaemon)
{
struct srecfailinfo *qinfo = (struct srecfailinfo *) qtrans->pinfo;
char ab[4];
- boolean fret;
- int ilocal = qtrans->ilocal;
- int iremote = qtrans->iremote;
-
- /* Wait for the end of file marker if we haven't gotten it yet. */
- if (! qinfo->freceived)
- {
- if (! fqueue_receive (qdaemon, qtrans))
- return FALSE;
- }
+ int ilocal, iremote;
ab[0] = qtrans->s.bcmd;
ab[1] = 'N';
@@ -897,20 +895,26 @@ fremote_send_fail_send (qtrans, qdaemon)
ab[2] = '\0';
break;
}
-
+
ab[3] = '\0';
- qinfo->fsent = TRUE;
+ ilocal = qtrans->ilocal;
+ iremote = qtrans->iremote;
- if (qinfo->freceived)
+ /* Wait for the end of file marker if we haven't gotten it yet. */
+ if (! qinfo->freceived)
+ {
+ qinfo->fsent = TRUE;
+ if (! fqueue_receive (qdaemon, qtrans))
+ return FALSE;
+ }
+ else
{
xfree (qtrans->pinfo);
utransfree (qtrans);
}
- fret = (*qdaemon->qproto->pfsendcmd) (qdaemon, ab, ilocal, iremote);
-
- return fret;
+ return (*qdaemon->qproto->pfsendcmd) (qdaemon, ab, ilocal, iremote);
}
/* Discard data until we reach the end of the file. This is used for
@@ -990,7 +994,13 @@ frec_file_end (qtrans, qdaemon, zdata, cdata)
zalc = NULL;
- if (! ffileclose (qtrans->e))
+ if (! fsysdep_sync (qtrans->e, qtrans->s.zto))
+ {
+ zerr = strerror (errno);
+ (void) ffileclose (qtrans->e);
+ (void) remove (qinfo->ztemp);
+ }
+ else if (! ffileclose (qtrans->e))
{
zerr = strerror (errno);
ulog (LOG_ERROR, "%s: close: %s", qtrans->s.zto, zerr);
@@ -1063,13 +1073,13 @@ frec_file_end (qtrans, qdaemon, zdata, cdata)
imode = 0666;
(void) fsysdep_change_mode (qinfo->zfile, imode);
}
-
+
zerr = NULL;
}
ustats (zerr == NULL, qtrans->s.zuser, qdaemon->qsys->uuconf_zname,
FALSE, qtrans->cbytes, qtrans->isecs, qtrans->imicros,
- qdaemon->fmaster);
+ qdaemon->fcaller);
qdaemon->creceived += qtrans->cbytes;
if (zerr == NULL)
@@ -1173,15 +1183,26 @@ frec_file_end (qtrans, qdaemon, zdata, cdata)
fprintf (e, "C %s\n", qtrans->s.zcmd);
fbad = FALSE;
- if (fclose (e) == EOF)
+
+ if (! fstdiosync (e, ztemp))
{
- ulog (LOG_ERROR, "fclose: %s", strerror (errno));
+ (void) fclose (e);
(void) remove (ztemp);
fbad = TRUE;
}
if (! fbad)
{
+ if (fclose (e) == EOF)
+ {
+ ulog (LOG_ERROR, "fclose: %s", strerror (errno));
+ (void) remove (ztemp);
+ fbad = TRUE;
+ }
+ }
+
+ if (! fbad)
+ {
if (! fsysdep_move_file (ztemp, zxqtfile, TRUE, FALSE, FALSE,
(const char *) NULL))
{
@@ -1235,9 +1256,7 @@ frec_file_send_confirm (qtrans, qdaemon)
{
struct srecinfo *qinfo = (struct srecinfo *) qtrans->pinfo;
const char *zsend;
- boolean fret;
- int ilocal = qtrans->ilocal;
- int iremote = qtrans->iremote;
+ int ilocal, iremote;
if (! qinfo->fmoved)
zsend = "CN5";
@@ -1255,17 +1274,18 @@ frec_file_send_confirm (qtrans, qdaemon)
zsend = "CYM";
}
- /* Now, if that was a remote command, then when the confirmation
- message is acked we no longer have to remember that we received
- that file. */
+ /* If that was a remote command, then, when the confirmation message
+ is acked, we no longer have to remember that we received that
+ file. */
if (! qinfo->flocal && qinfo->fmoved)
usent_receive_ack (qdaemon, qtrans);
- urrec_free (qtrans);
+ ilocal = qtrans->ilocal;
+ iremote = qtrans->iremote;
- fret = (*qdaemon->qproto->pfsendcmd) (qdaemon, zsend, ilocal, iremote);
+ urrec_free (qtrans);
- return fret;
+ return (*qdaemon->qproto->pfsendcmd) (qdaemon, zsend, ilocal, iremote);
}
/* Discard a temporary file if it is not useful. A temporary file is
diff --git a/gnu/libexec/uucp/uucico/send.c b/gnu/libexec/uucp/uucico/send.c
index 72d0083..6cd7450 100644
--- a/gnu/libexec/uucp/uucico/send.c
+++ b/gnu/libexec/uucp/uucico/send.c
@@ -1,7 +1,7 @@
/* send.c
Routines to send a file.
- Copyright (C) 1991, 1992, 1993, 1994 Ian Lance Taylor
+ Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -17,16 +17,16 @@
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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
+ c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
*/
#include "uucp.h"
#if USE_RCS_ID
-const char send_rcsid[] = "$Id: send.c,v 1.3 1994/11/06 10:17:13 davidg Exp $";
+const char send_rcsid[] = "$Id: send.c,v 1.51 1995/06/21 19:15:49 ian Rel $";
#endif
#include <errno.h>
@@ -51,19 +51,21 @@ struct ssendinfo
boolean flocal;
/* TRUE if this is a spool directory file. */
boolean fspool;
- /* TRUE if the file has been completely sent. Also used in
- flocal_send_cancelled to mean that the file send will never
- succeed. */
+ /* TRUE if the file has been completely sent. */
boolean fsent;
+ /* TRUE if the file send will never succeed; used by
+ flocal_send_cancelled. */
+ boolean fnever;
/* Execution file for sending an unsupported E request. */
char *zexec;
+ /* Confirmation command received in fsend_await_confirm. */
+ char *zconfirm;
};
/* Local functions. */
static void usfree_send P((struct stransfer *qtrans));
-static boolean flocal_send_fail P((struct stransfer *qtrans,
- struct scmd *qcmd,
+static boolean flocal_send_fail P((struct scmd *qcmd,
struct sdaemon *qdaemon,
const char *zwhy));
static boolean flocal_send_request P((struct stransfer *qtrans,
@@ -106,11 +108,12 @@ usfree_send (qtrans)
ubuffree (qinfo->zmail);
ubuffree (qinfo->zfile);
ubuffree (qinfo->zexec);
+ ubuffree (qinfo->zconfirm);
xfree (qtrans->pinfo);
}
utransfree (qtrans);
-}
+}
/* Set up a local request to send a file. This may be called before
we have even tried to call the remote system.
@@ -198,7 +201,7 @@ flocal_send_file_init (qdaemon, qcmd)
is possible, but it might have changed since then. */
if (! qsys->uuconf_fcall_transfer
&& ! qsys->uuconf_fcalled_transfer)
- return flocal_send_fail ((struct stransfer *) NULL, qcmd, qdaemon,
+ return flocal_send_fail (qcmd, qdaemon,
"not permitted to transfer files");
/* We can't do the request now, but it may get done later. */
@@ -215,8 +218,7 @@ flocal_send_file_init (qdaemon, qcmd)
qsys->uuconf_pzlocal_send,
qsys->uuconf_zpubdir, TRUE,
TRUE, qcmd->zuser))
- return flocal_send_fail ((struct stransfer *) NULL, qcmd, qdaemon,
- "not permitted to send");
+ return flocal_send_fail (qcmd, qdaemon, "not permitted to send");
zfile = zbufcpy (qcmd->zfrom);
}
else
@@ -235,14 +237,12 @@ flocal_send_file_init (qdaemon, qcmd)
{
ubuffree (zfile);
if (cbytes != -1)
- return flocal_send_fail ((struct stransfer *) NULL, qcmd, qdaemon,
- "can not get size");
+ return flocal_send_fail (qcmd, qdaemon, "can not get size");
/* A cbytes value of -1 means that the file does not exist.
This can happen legitimately if it has already been sent from
the spool directory. */
if (! fspool)
- return flocal_send_fail ((struct stransfer *) NULL, qcmd, qdaemon,
- "does not exist");
+ return flocal_send_fail (qcmd, qdaemon, "does not exist");
(void) fsysdep_did_work (qcmd->pseq);
return TRUE;
}
@@ -263,11 +263,10 @@ flocal_send_file_init (qdaemon, qcmd)
else
qdaemon->cmax_ever = c2;
}
-
+
if (qdaemon->cmax_ever != -1
&& qdaemon->cmax_ever < qcmd->cbytes)
- return flocal_send_fail ((struct stransfer *) NULL, qcmd, qdaemon,
- "too large to send");
+ return flocal_send_fail (qcmd, qdaemon, "too large to send");
return TRUE;
}
@@ -286,6 +285,7 @@ flocal_send_file_init (qdaemon, qcmd)
qinfo->fspool = fspool;
qinfo->fsent = FALSE;
qinfo->zexec = NULL;
+ qinfo->zconfirm = NULL;
qtrans = qtransalc (qcmd);
qtrans->psendfn = flocal_send_request;
@@ -298,8 +298,7 @@ flocal_send_file_init (qdaemon, qcmd)
this reports an error to the log file and to the user. */
static boolean
-flocal_send_fail (qtrans, qcmd, qdaemon, zwhy)
- struct stransfer *qtrans;
+flocal_send_fail (qcmd, qdaemon, zwhy)
struct scmd *qcmd;
struct sdaemon *qdaemon;
const char *zwhy;
@@ -369,8 +368,7 @@ flocal_send_request (qtrans, qdaemon)
if (qdaemon->cmax_receive != -1
&& qdaemon->cmax_receive < qinfo->cbytes)
{
- fret = flocal_send_fail (qtrans, &qtrans->s, qdaemon,
- "too large for receiver");
+ fret = flocal_send_fail (&qtrans->s, qdaemon, "too large for receiver");
usfree_send (qtrans);
return fret;
}
@@ -500,8 +498,8 @@ flocal_send_request (qtrans, qdaemon)
qtrans->iremote);
ubuffree (zsend);
- if (! fret)
- usfree_send (qtrans);
+ /* If fret is FALSE, we should free qtrans here, but see the comment
+ at the end of flocal_rec_send_request. */
return fret;
}
@@ -594,12 +592,8 @@ flocal_send_await_reply (qtrans, qdaemon, zdata, cdata)
}
else
{
- if (! flocal_send_fail ((struct stransfer *) NULL, &qtrans->s,
- qdaemon, zerr))
- {
- usfree_send (qtrans);
- return FALSE;
- }
+ if (! flocal_send_fail (&qtrans->s, qdaemon, zerr))
+ return FALSE;
}
/* If the protocol does not support multiple channels, we can
@@ -637,8 +631,7 @@ flocal_send_await_reply (qtrans, qdaemon, zdata, cdata)
qtrans->psendfn = flocal_send_cancelled;
qtrans->precfn = NULL;
- /* Reuse fsent to pass fnever to flocal_send_cancelled. */
- qinfo->fsent = fnever;
+ qinfo->fnever = fnever;
return fqueue_send (qdaemon, qtrans);
}
@@ -672,6 +665,7 @@ flocal_send_await_reply (qtrans, qdaemon, zdata, cdata)
protocol supports multiple channels, we have already called
fqueue_send; calling it again would move the request in the
queue, which would make the log file a bit confusing. */
+ qtrans->fcmd = TRUE;
qtrans->precfn = fsend_await_confirm;
if (qinfo->fsent)
return fqueue_receive (qdaemon, qtrans);
@@ -814,9 +808,8 @@ flocal_send_cancelled (qtrans, qdaemon)
/* If we are breaking a 'E' command into two 'S' commands, and that
was for the first 'S' command, and the first 'S' command will
- never be sent (passed as qinfo->fsent), we still have to send the
- second one. */
- if (qinfo->fsent
+ never be sent, we still have to send the second one. */
+ if (qinfo->fnever
&& qtrans->s.bcmd == 'E'
&& (qdaemon->ifeatures & FEATURE_EXEC) == 0
&& qinfo->zexec == NULL)
@@ -937,6 +930,7 @@ fremote_rec_file_init (qdaemon, qcmd, iremote)
qinfo->fspool = FALSE;
qinfo->fsent = FALSE;
qinfo->zexec = NULL;
+ qinfo->zconfirm = NULL;
qtrans = qtransalc (qcmd);
qtrans->psendfn = fremote_rec_reply;
@@ -962,11 +956,17 @@ fremote_rec_reply (qtrans, qdaemon)
qtrans->fsendfile = TRUE;
qtrans->psendfn = fsend_file_end;
+ qtrans->fcmd = TRUE;
qtrans->precfn = fsend_await_confirm;
if (! fqueue_send (qdaemon, qtrans))
return FALSE;
+ qtrans->zlog = zbufalc (sizeof "Sending ( bytes) "
+ + strlen (qtrans->s.zfrom) + 25);
+ sprintf (qtrans->zlog, "Sending %s (%ld bytes)", qtrans->s.zfrom,
+ qinfo->cbytes);
+
/* We send the file size because SVR4 UUCP does. We don't look for
it. We send a trailing M if we want to request a hangup. We
send it both after the mode and at the end of the entire string;
@@ -982,15 +982,11 @@ fremote_rec_reply (qtrans, qdaemon)
qtrans->iremote))
{
(void) ffileclose (qtrans->e);
- usfree_send (qtrans);
+ /* Should probably free qtrans here, but see the comment at the
+ end of flocal_rec_send_request. */
return FALSE;
}
- qtrans->zlog = zbufalc (sizeof "Sending ( bytes) "
- + strlen (qtrans->s.zfrom) + 25);
- sprintf (qtrans->zlog, "Sending %s (%ld bytes)", qtrans->s.zfrom,
- qinfo->cbytes);
-
if (qdaemon->qproto->pffile != NULL)
{
boolean fhandled;
@@ -1039,9 +1035,7 @@ fremote_rec_fail_send (qtrans, qdaemon)
{
enum tfailure *ptinfo = (enum tfailure *) qtrans->pinfo;
const char *z;
- boolean fret;
- int ilocal = qtrans->ilocal;
- int iremote = qtrans->iremote;
+ int ilocal, iremote;
switch (*ptinfo)
{
@@ -1056,11 +1050,14 @@ fremote_rec_fail_send (qtrans, qdaemon)
z = "RN";
break;
}
+
+ ilocal = qtrans->ilocal;
+ iremote = qtrans->iremote;
xfree (qtrans->pinfo);
utransfree (qtrans);
- fret = (*qdaemon->qproto->pfsendcmd) (qdaemon, z, ilocal, iremote);
- return fret;
+
+ return (*qdaemon->qproto->pfsendcmd) (qdaemon, z, ilocal, iremote);
}
/* This is called when the main loop has finished sending a file. It
@@ -1093,8 +1090,13 @@ fsend_file_end (qtrans, qdaemon)
qinfo->fsent = TRUE;
+ /* If zconfirm is set, then we have already received the
+ confirmation, and should call fsend_await_confirm directly. */
+ if (qinfo->zconfirm != NULL)
+ return fsend_await_confirm (qtrans, qdaemon, qinfo->zconfirm,
+ strlen (qinfo->zconfirm) + 1);
+
/* qtrans->precfn should have been set by a previous function. */
- qtrans->fcmd = TRUE;
return fqueue_receive (qdaemon, qtrans);
}
@@ -1112,6 +1114,18 @@ fsend_await_confirm (qtrans, qdaemon, zdata, cdata)
boolean fnever;
const char *zerr;
+ /* If fsent is FALSE, it means that we have received the
+ confirmation before fsend_file_end got called. To avoid
+ confusion, we save away the confirmation message, and let
+ fsend_file_end call us directly. If we did not do this, we would
+ have to fix a thorny race condition in floop, which wants to
+ refer to the qtrans structure after sending the end of the file. */
+ if (! qinfo->fsent)
+ {
+ qinfo->zconfirm = zbufcpy (zdata);
+ return TRUE;
+ }
+
if (qinfo->zexec == NULL)
(void) ffileclose (qtrans->e);
@@ -1153,7 +1167,7 @@ fsend_await_confirm (qtrans, qdaemon, zdata, cdata)
ustats (zerr == NULL, qtrans->s.zuser, qdaemon->qsys->uuconf_zname,
TRUE, qtrans->cbytes, qtrans->isecs, qtrans->imicros,
- qdaemon->fmaster);
+ qdaemon->fcaller);
qdaemon->csent += qtrans->cbytes;
if (zerr == NULL)
@@ -1264,6 +1278,8 @@ fsend_exec_file_init (qtrans, qdaemon)
qtrans->isecs = 0;
qtrans->imicros = 0;
qinfo->fsent = FALSE;
+ ubuffree (qinfo->zconfirm);
+ qinfo->zconfirm = NULL;
return fqueue_send (qdaemon, qtrans);
}
diff --git a/gnu/libexec/uucp/uucico/time.c b/gnu/libexec/uucp/uucico/time.c
index a83f732..7484246 100644
--- a/gnu/libexec/uucp/uucico/time.c
+++ b/gnu/libexec/uucp/uucico/time.c
@@ -17,16 +17,16 @@
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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
+ c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
*/
#include "uucp.h"
#if USE_RCS_ID
-const char time_rcsid[] = "$Id: time.c,v 1.19 1994/01/30 21:01:46 ian Rel $";
+const char time_rcsid[] = "$Id: time.c,v 1.21 1995/06/21 19:16:02 ian Rel $";
#endif
#include <ctype.h>
diff --git a/gnu/libexec/uucp/uucico/trans.c b/gnu/libexec/uucp/uucico/trans.c
index 1cb5487..b2babd6 100644
--- a/gnu/libexec/uucp/uucico/trans.c
+++ b/gnu/libexec/uucp/uucico/trans.c
@@ -1,7 +1,7 @@
/* trans.c
Routines to handle file transfers.
- Copyright (C) 1992, 1993 Ian Lance Taylor
+ Copyright (C) 1992, 1993, 1995 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -17,16 +17,16 @@
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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
+ c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
*/
#include "uucp.h"
#if USE_RCS_ID
-const char trans_rcsid[] = "$Id: trans.c,v 1.2 1994/05/07 18:13:59 ache Exp $";
+const char trans_rcsid[] = "$Id: trans.c,v 1.40 1995/08/11 02:43:32 ian Rel $";
#endif
#include <errno.h>
@@ -45,9 +45,8 @@ static void utdequeue P((struct stransfer *));
static void utchanalc P((struct sdaemon *qdaemon, struct stransfer *qtrans));
__inline__ static struct stransfer *qtchan P((int ichan));
__inline__ static void utchanfree P((struct stransfer *qtrans));
-static boolean ftcharge P((struct sdaemon *qdaemon,
- struct stransfer *qtrans,
- boolean fsend, boolean fforce));
+static boolean fttime P((struct sdaemon *qdaemon, long *pisecs,
+ long *pimicros));
static boolean fcheck_queue P((struct sdaemon *qdaemon));
static boolean ftadd_cmd P((struct sdaemon *qdaemon, const char *z,
size_t cdata, int iremote, boolean flast));
@@ -93,19 +92,15 @@ static int iTchan;
This is maintained for remote jobs. */
static struct stransfer *aqTremote[IMAX_CHAN + 1];
-/* A structure used to charge time to file transfers. */
-struct scharge
-{
- /* The transfer we are currently charging. */
- struct stransfer *qtrans;
- /* The time at the last update. */
- long isecs;
- long imicros;
-};
+/* The transaction we are currently receiving. This is used to avoid
+ getting the time too frequently. */
+static struct stransfer *qTtiming_rec;
-/* We are always charging one send and one receive. */
-static struct scharge sTsend;
-static struct scharge sTreceive;
+/* The time from which to charge any received data. This is either
+ the last time we charged for received data, or the last time
+ something was put on the empty receive queue. */
+static long iTrecsecs;
+static long iTrecmicros;
/* The minimum amount of time, in seconds, to wait between times we
check the spool directory, if we are busy transferring data. If we
@@ -216,9 +211,7 @@ fqueue_remote (qdaemon, qtrans)
aqTremote[qtrans->iremote] = qtrans;
utdequeue (qtrans);
utqueue (&qTremote, qtrans, FALSE);
-
- /* We just received data for this transfer, so start charging. */
- return ftcharge (qdaemon, qtrans, FALSE, FALSE);
+ return TRUE;
}
/* Queue up a transfer with something to send. */
@@ -267,10 +260,6 @@ fqueue_send (qdaemon, qtrans)
qtrans->pqqueue = &qTsend;
}
- /* Since we're now going to wait to send data, don't charge this
- transfer for receive time. */
- if (qtrans == sTreceive.qtrans)
- return ftcharge (qdaemon, (struct stransfer *) NULL, FALSE, FALSE);
return TRUE;
}
@@ -285,13 +274,16 @@ fqueue_receive (qdaemon, qtrans)
if (qtrans->precfn == NULL)
ulog (LOG_FATAL, "fqueue_receive: Bad call");
#endif
+
+ /* If this is the only item on the receive queue, we do not want to
+ charge it for any time during which we have not been waiting for
+ anything, so update the receive timestamp. */
+ if (qTreceive == NULL)
+ iTrecsecs = ixsysdep_process_time (&iTrecmicros);
+
utdequeue (qtrans);
utqueue (&qTreceive, qtrans, FALSE);
- /* Since we are now going to wait to receive data, don't charge this
- transfer for send time. */
- if (qtrans == sTsend.qtrans)
- return ftcharge (qdaemon, (struct stransfer *) NULL, TRUE, FALSE);
return TRUE;
}
@@ -411,8 +403,8 @@ utransfree (q)
ubuffree ((char *) q->s.ztemp);
ubuffree ((char *) q->s.znotify);
ubuffree ((char *) q->s.zcmd);
-
- utchanfree (q);
+
+ utchanfree (q);
if (q->iremote > 0)
{
aqTremote[q->iremote] = NULL;
@@ -433,80 +425,32 @@ utransfree (q)
q->precfn = NULL;
#endif
- /* Don't try to charge time to this structure any longer. */
- if (sTsend.qtrans == q)
- sTsend.qtrans = NULL;
- if (sTreceive.qtrans == q)
- sTreceive.qtrans = NULL;
+ /* Avoid any possible confusion in the timing code. */
+ if (qTtiming_rec == q)
+ qTtiming_rec = NULL;
utdequeue (q);
utqueue (&qTavail, q, FALSE);
}
-/* Handle timing of file tranfers. This is called when processing
- starts for a transfer structure. All time up to the next call to
- this function is charged to that transfer structure. Sending time
- and receiving time are charged separately. Normally if we are
- about to start charging the same structure we are already charging,
- we do nothing; but if the fforce argument is TRUE, we charge the
- time anyhow. */
+/* Get the time. This is a wrapper around ixsysdep_process_time. If
+ enough time has elapsed since the last time we got the time, check
+ the work queue. */
static boolean
-ftcharge (qdaemon, qtrans, fsend, fforce)
+fttime (qdaemon, pisecs, pimicros)
struct sdaemon *qdaemon;
- struct stransfer *qtrans;
- boolean fsend;
- boolean fforce;
+ long *pisecs;
+ long *pimicros;
{
- struct scharge *qcharge, *qother;
- long inextsecs, inextmicros;
-
- if (fsend)
- {
- qcharge = &sTsend;
- qother = &sTreceive;
- }
- else
- {
- qcharge = &sTreceive;
- qother = &sTsend;
- }
-
- if (! fforce && qtrans == qcharge->qtrans)
- return TRUE;
-
- inextsecs = ixsysdep_process_time (&inextmicros);
- if (qcharge->qtrans != NULL)
- {
- qcharge->qtrans->isecs += inextsecs - qcharge->isecs;
- qcharge->qtrans->imicros += inextmicros - qcharge->imicros;
-
- /* If we are charging the same structure for both send and
- receive, update the time we are not currently charging so
- that we don't charge twice for the same time. */
- if (qcharge->qtrans == qother->qtrans)
- {
- qother->isecs = inextsecs;
- qother->imicros = inextmicros;
- }
- }
-
- qcharge->qtrans = qtrans;
- qcharge->isecs = inextsecs;
- qcharge->imicros = inextmicros;
-
- /* If enough time has elapsed since the last time we checked the
- queue, check it again. We do this here because we have already
- gone to the trouble of getting the time. */
- if (inextsecs - iTchecktime >= CCHECKWAIT)
+ *pisecs = ixsysdep_process_time (pimicros);
+ if (*pisecs - iTchecktime >= CCHECKWAIT)
{
if (! fcheck_queue (qdaemon))
return FALSE;
}
-
return TRUE;
}
-
/* Gather local commands and queue them up for later processing. Also
recompute time based control values. */
@@ -517,6 +461,7 @@ fqueue (qdaemon, pfany)
boolean *pfany;
{
const struct uuconf_system *qsys;
+ long ival;
int bgrade;
struct uuconf_timespan *qlocal_size, *qremote_size;
@@ -526,13 +471,18 @@ fqueue (qdaemon, pfany)
qsys = qdaemon->qsys;
/* If we are not the caller, the grade will be set during the
- initial handshake. */
+ initial handshake, although this may be overridden by the
+ calledtimegrade configuration option. */
if (! qdaemon->fcaller)
- bgrade = qdaemon->bgrade;
+ {
+ if (! ftimespan_match (qsys->uuconf_qcalledtimegrade, &ival,
+ (int *) NULL))
+ bgrade = qdaemon->bgrade;
+ else
+ bgrade = (char) ival;
+ }
else
{
- long ival;
-
if (! ftimespan_match (qsys->uuconf_qtimegrade, &ival,
(int *) NULL))
bgrade = '\0';
@@ -612,7 +562,7 @@ fqueue (qdaemon, pfany)
break;
#endif
}
- }
+ }
if (pfany != NULL)
*pfany = qTlocal != NULL;
@@ -639,8 +589,7 @@ uclear_queue (qdaemon)
qTreceive = NULL;
cTchans = 0;
iTchan = 0;
- sTsend.qtrans = NULL;
- sTreceive.qtrans = NULL;
+ qTtiming_rec = NULL;
cTcmdlen = 0;
qTreceive_ack = NULL;
for (i = 0; i < IMAX_CHAN + 1; i++)
@@ -812,12 +761,10 @@ floop (qdaemon)
if (! q->fsendfile)
{
- if (! ftcharge (qdaemon, q, TRUE, TRUE))
- {
- fret = FALSE;
- break;
- }
-
+ /* Technically, we should add the time required for this
+ call to q->isecs and q->imicros. In practice, the
+ amount of time required should be sufficiently small
+ that it can be safely disregarded. */
if (! (*q->psendfn) (q, qdaemon))
{
fret = FALSE;
@@ -826,11 +773,16 @@ floop (qdaemon)
}
else
{
- if (! ftcharge (qdaemon, q, TRUE, FALSE))
+ long isecs, imicros;
+ boolean fcharged;
+ long inextsecs = 0, inextmicros;
+
+ if (! fttime (qdaemon, &isecs, &imicros))
{
fret = FALSE;
break;
}
+ fcharged = FALSE;
if (q->zlog != NULL)
{
@@ -864,7 +816,7 @@ floop (qdaemon)
else
{
cdata = cfileread (q->e, zdata, cdata);
- if (ffilereaderror (q->e, cdata))
+ if (ffileioerror (q->e, cdata))
{
/* There is no way to report a file reading
error, so we just drop the connection. */
@@ -891,17 +843,48 @@ floop (qdaemon)
/* We must update the time now, because this
call may make an entry in the statistics
file. */
- if (! ftcharge (qdaemon, q, TRUE, TRUE))
- fret = FALSE;
+ inextsecs = ixsysdep_process_time (&inextmicros);
+ DEBUG_MESSAGE4 (DEBUG_UUCP_PROTO,
+ "floop: Charging %ld to %c %s %s",
+ ((inextsecs - isecs) * 1000000
+ + inextmicros - imicros),
+ q->s.bcmd, q->s.zfrom, q->s.zto);
+ q->isecs += inextsecs - isecs;
+ q->imicros += inextmicros - imicros;
+ fcharged = TRUE;
+
q->fsendfile = FALSE;
+
if (! (*q->psendfn) (q, qdaemon))
fret = FALSE;
+
break;
}
}
if (! fret)
break;
+
+ if (! fcharged)
+ {
+ inextsecs = ixsysdep_process_time (&inextmicros);
+ DEBUG_MESSAGE4 (DEBUG_UUCP_PROTO,
+ "floop: Charging %ld to %c %s %s",
+ ((inextsecs - isecs) * 1000000
+ + inextmicros - imicros),
+ q->s.bcmd, q->s.zfrom, q->s.zto);
+ q->isecs += inextsecs - isecs;
+ q->imicros += inextmicros - imicros;
+ }
+
+ if (inextsecs - iTchecktime >= CCHECKWAIT)
+ {
+ if (! fcheck_queue (qdaemon))
+ {
+ fret = FALSE;
+ break;
+ }
+ }
}
}
}
@@ -926,7 +909,7 @@ floop (qdaemon)
TRUE if we just receive data for a file. This routine never sets
*pfexit to FALSE. */
-boolean
+boolean
fgot_data (qdaemon, zfirst, cfirst, zsecond, csecond, ilocal, iremote, ipos,
fallacked, pfexit)
struct sdaemon *qdaemon;
@@ -943,6 +926,7 @@ fgot_data (qdaemon, zfirst, cfirst, zsecond, csecond, ilocal, iremote, ipos,
struct stransfer *q;
int cwrote;
boolean fret;
+ long isecs, imicros;
if (fallacked && qTreceive_ack != NULL)
uwindow_acked (qdaemon, TRUE);
@@ -989,6 +973,11 @@ fgot_data (qdaemon, zfirst, cfirst, zsecond, csecond, ilocal, iremote, ipos,
if (pfexit != NULL && (qdaemon->fhangup || qTremote != NULL))
*pfexit = TRUE;
+ /* Time spent waiting for a new command is not charged to
+ anybody. */
+ if (! fttime (qdaemon, &iTrecsecs, &iTrecmicros))
+ fret = FALSE;
+
return fret;
}
else
@@ -1011,6 +1000,54 @@ fgot_data (qdaemon, zfirst, cfirst, zsecond, csecond, ilocal, iremote, ipos,
fret = TRUE;
+ if (q->zlog != NULL && ! q->fsendfile)
+ {
+ ulog (LOG_NORMAL, "%s", q->zlog);
+ ubuffree (q->zlog);
+ q->zlog = NULL;
+ }
+
+ if (cfirst == 0 || q->fcmd || ! q->frecfile || q != qTtiming_rec)
+ {
+ struct stransfer *qcharge;
+
+ /* Either we are receiving some sort of command, or we are
+ receiving data for a transfer other than the one we are
+ currently timing. It we are currently timing a transfer,
+ charge any accumulated time to it. Otherwise, if we
+ currently have something to send, just forget about the
+ accumulated time (when using a bidirectional protocol, it's
+ very difficult to charge this time correctly). Otherwise,
+ charge it to whatever transfer receives it. */
+ if (! fttime (qdaemon, &isecs, &imicros))
+ fret = FALSE;
+ if (qTtiming_rec != NULL)
+ qcharge = qTtiming_rec;
+ else if (qTsend != NULL)
+ qcharge = NULL;
+ else
+ qcharge = q;
+ if (qcharge != NULL)
+ {
+ DEBUG_MESSAGE4 (DEBUG_UUCP_PROTO,
+ "fgot_data: Charging %ld to %c %s %s",
+ ((isecs - iTrecsecs) * 1000000
+ + imicros - iTrecmicros),
+ qcharge->s.bcmd, qcharge->s.zfrom,
+ qcharge->s.zto);
+ qcharge->isecs += isecs - iTrecsecs;
+ qcharge->imicros += imicros - iTrecmicros;
+ }
+ iTrecsecs = isecs;
+ iTrecmicros = imicros;
+
+ /* If we received file data, start timing the new transfer. */
+ if (cfirst == 0 || q->fcmd || ! q->frecfile)
+ qTtiming_rec = NULL;
+ else
+ qTtiming_rec = q;
+ }
+
/* If we're receiving a command, then accumulate it up to the null
byte. */
if (q->fcmd)
@@ -1050,8 +1087,6 @@ fgot_data (qdaemon, zfirst, cfirst, zsecond, csecond, ilocal, iremote, ipos,
char *zcmd;
size_t ccmd;
- if (! ftcharge (qdaemon, q, FALSE, TRUE))
- fret = FALSE;
zcmd = q->zcmd;
ccmd = q->ccmd;
q->fcmd = FALSE;
@@ -1061,11 +1096,6 @@ fgot_data (qdaemon, zfirst, cfirst, zsecond, csecond, ilocal, iremote, ipos,
fret = FALSE;
ubuffree (zcmd);
}
- else
- {
- if (! ftcharge (qdaemon, q, FALSE, FALSE))
- fret = FALSE;
- }
if (pfexit != NULL
&& (qdaemon->fhangup
@@ -1077,8 +1107,6 @@ fgot_data (qdaemon, zfirst, cfirst, zsecond, csecond, ilocal, iremote, ipos,
{
/* We're either not receiving a file or the file transfer is
complete. */
- if (! ftcharge (qdaemon, q, FALSE, TRUE))
- fret = FALSE;
q->frecfile = FALSE;
if (! (*q->precfn) (q, qdaemon, zfirst, cfirst))
fret = FALSE;
@@ -1095,16 +1123,6 @@ fgot_data (qdaemon, zfirst, cfirst, zsecond, csecond, ilocal, iremote, ipos,
}
else
{
- if (! ftcharge (qdaemon, q, FALSE, FALSE))
- fret = FALSE;
-
- if (q->zlog != NULL)
- {
- ulog (LOG_NORMAL, "%s", q->zlog);
- ubuffree (q->zlog);
- q->zlog = NULL;
- }
-
if (ipos != -1 && ipos != q->ipos)
{
DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO,
@@ -1146,7 +1164,7 @@ fgot_data (qdaemon, zfirst, cfirst, zsecond, csecond, ilocal, iremote, ipos,
}
else
{
- if (cwrote < 0)
+ if (ffileioerror (q->e, cwrote))
ulog (LOG_ERROR, "write: %s", strerror (errno));
else
ulog (LOG_ERROR,
@@ -1216,7 +1234,8 @@ ftadd_cmd (qdaemon, z, clen, iremote, flast)
DEBUG_MESSAGE1 (DEBUG_UUCP_PROTO,
"ftadd_cmd: Got command \"%s\"", zbuf);
- if (! fparse_cmd (zbuf, &s))
+ if (! fparse_cmd (zbuf, &s)
+ || s.bcmd == 'P')
{
ulog (LOG_ERROR, "Received garbled command \"%s\"", zbuf);
return TRUE;
@@ -1253,6 +1272,7 @@ ftadd_cmd (qdaemon, z, clen, iremote, flast)
q = qtransalc ((struct scmd *) NULL);
q->psendfn = fremote_hangup_reply;
q->iremote = iremote;
+ q->s.bcmd = 'H';
return fqueue_remote (qdaemon, q);
}
case 'N':
@@ -1401,11 +1421,6 @@ ufailed (qdaemon)
{
register struct stransfer *q;
- /* Update the transfer times, but avoid looking in the queue. */
- iTchecktime = ixsysdep_process_time ((long *) NULL);
- (void) ftcharge (qdaemon, (struct stransfer *) NULL, TRUE, TRUE);
- (void) ftcharge (qdaemon, (struct stransfer *) NULL, FALSE, TRUE);
-
if (qTsend != NULL)
{
q = qTsend;
@@ -1416,7 +1431,7 @@ ufailed (qdaemon)
{
ustats (FALSE, q->s.zuser, qdaemon->qsys->uuconf_zname,
q->fsendfile, q->cbytes, q->isecs, q->imicros,
- FALSE);
+ qdaemon->fcaller);
if (q->fsendfile)
qdaemon->csent += q->cbytes;
else
@@ -1439,7 +1454,7 @@ ufailed (qdaemon)
{
ustats (FALSE, q->s.zuser, qdaemon->qsys->uuconf_zname,
q->fsendfile, q->cbytes, q->isecs, q->imicros,
- FALSE);
+ qdaemon->fcaller);
if (q->fsendfile)
qdaemon->csent += q->cbytes;
else
diff --git a/gnu/libexec/uucp/uucico/uucico.8 b/gnu/libexec/uucp/uucico/uucico.8
index 99f5682..a7ca915 100644
--- a/gnu/libexec/uucp/uucico/uucico.8
+++ b/gnu/libexec/uucp/uucico/uucico.8
@@ -1,5 +1,5 @@
-''' $Id: uucico.8,v 1.3 1994/05/07 18:14:01 ache Exp $
-.TH uucico 8 "Taylor UUCP 1.05"
+''' $Id: uucico.8,v 1.18 1995/06/26 22:36:09 ian Rel $
+.TH uucico 8 "Taylor UUCP 1.06"
.SH NAME
uucico \- UUCP file transfer daemon
.SH SYNOPSIS
@@ -250,8 +250,8 @@ is equivalent to
.B \-\-debug abnormal,chat.
The debugging output is sent to the debugging file, usually one of
-/var/spool/uucp/Debug, /var/spool/uucp/DEBUG, or
-/var/spool/uucp/.Admin/audit.local.
+/var/spool/uucp/Debug, /usr/spool/uucp/DEBUG, or
+/usr/spool/uucp/.Admin/audit.local.
.TP 5
.B \-I file, \-\-config file
Set configuration file to use. This option may not be available,
@@ -264,12 +264,6 @@ Report version information and exit.
.TP 5
.B \-\-help
Print a help message and exit.
-.TP 5
-.B \-u login
-This option is ignored. It is only included because some versions of
-uucpd invoke
-.I uucico
-with it.
.SH FILES
The file names may be changed at compilation time or by the
configuration file, so these are only approximations.
diff --git a/gnu/libexec/uucp/uucico/uucico.c b/gnu/libexec/uucp/uucico/uucico.c
index 8183980..4044a31 100644
--- a/gnu/libexec/uucp/uucico/uucico.c
+++ b/gnu/libexec/uucp/uucico/uucico.c
@@ -1,7 +1,7 @@
/* uucico.c
This is the main UUCP communication program.
- Copyright (C) 1991, 1992, 1993, 1994 Ian Lance Taylor
+ Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -17,16 +17,16 @@
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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
+ c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
*/
#include "uucp.h"
#if USE_RCS_ID
-const char uucico_rcsid[] = "$Id: uucico.c,v 1.3 1994/05/25 20:14:52 ache Exp $";
+const char uucico_rcsid[] = "$Id: uucico.c,v 1.190 1995/06/29 19:35:59 ian Rel $";
#endif
#include <ctype.h>
@@ -95,7 +95,10 @@ static const struct sprotocol asProtocols[] =
ffsenddata, ffwait, fffile },
{ 'v', UUCONF_RELIABLE_EIGHT, 1, TRUE,
asGproto_params, fvstart, fgshutdown, fgsendcmd, zggetspace,
- fgsenddata, fgwait, NULL }
+ fgsenddata, fgwait, NULL },
+ { 'y', UUCONF_RELIABLE_RELIABLE | UUCONF_RELIABLE_EIGHT, 1, TRUE,
+ asYproto_params, fystart, fyshutdown, fysendcmd, zygetspace,
+ fysenddata, fywait, fyfile }
};
#define CPROTOCOLS (sizeof asProtocols / sizeof asProtocols[0])
@@ -161,8 +164,9 @@ static void uapply_proto_params P((pointer puuconf, int bproto,
static boolean fsend_uucp_cmd P((struct sconnection *qconn,
const char *z));
static char *zget_uucp_cmd P((struct sconnection *qconn,
- boolean frequired));
-static char *zget_typed_line P((struct sconnection *qconn));
+ boolean frequired, boolean fstrip));
+static char *zget_typed_line P((struct sconnection *qconn,
+ boolean fstrip));
/* Long getopt options. */
static const struct option asLongopts[] =
@@ -333,7 +337,7 @@ main (argc, argv)
else
uusage ();
break;
-
+
case 's':
/* Set system name */
zsystem = optarg;
@@ -386,7 +390,7 @@ main (argc, argv)
case 'v':
/* Print version and exit. */
- printf ("%s: Taylor UUCP %s, copyright (C) 1991, 1992, 1993, 1994 Ian Lance Taylor\n",
+ printf ("%s: Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n",
zProgram, VERSION);
exit (EXIT_SUCCESS);
/*NOTREACHED*/
@@ -784,7 +788,7 @@ uusage ()
static void
uhelp ()
{
- printf ("Taylor UUCP %s, copyright (C) 1991, 1992, 1993, 1994 Ian Lance Taylor\n",
+ printf ("Taylor UUCP %s, copyright (C) 1991, 92, 93, 94, 1995 Ian Lance Taylor\n",
VERSION);
printf ("Usage: %s [options]\n", zProgram);
printf (" -s,-S,--system system: Call system (-S implies -f)\n");
@@ -877,6 +881,7 @@ fcall (puuconf, zconfig, fuuxqt, qorigsys, qport, fifwork, fforce, fdetach,
if (! fsysdep_get_status (qorigsys, &sstat, (boolean *) NULL))
return FALSE;
+ ubuffree (sstat.zstring);
/* Make sure it's been long enough since the last failed call, and
that we haven't exceeded the maximum number of retries. Even if
@@ -1205,8 +1210,10 @@ fdo_call (qdaemon, qstat, qdialer, pfcalled, pterr)
pointer puuconf;
const struct uuconf_system *qsys;
struct sconnection *qconn;
- const char *zport;
int iuuconf;
+ int istrip;
+ boolean fstrip;
+ const char *zport;
char *zstr;
long istart_time;
char *zlog;
@@ -1215,6 +1222,14 @@ fdo_call (qdaemon, qstat, qdialer, pfcalled, pterr)
qsys = qdaemon->qsys;
qconn = qdaemon->qconn;
+ iuuconf = uuconf_strip (puuconf, &istrip);
+ if (iuuconf != UUCONF_SUCCESS)
+ {
+ ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
+ return FALSE;
+ }
+ fstrip = (istrip & UUCONF_STRIP_PROTO) != 0;
+
*pterr = STATUS_LOGIN_FAILED;
if (qconn->qport == NULL)
@@ -1234,7 +1249,7 @@ fdo_call (qdaemon, qstat, qdialer, pfcalled, pterr)
/* We should now see "Shere" from the other system. Newer systems
send "Shere=foo" where foo is the remote name. */
- zstr = zget_uucp_cmd (qconn, TRUE);
+ zstr = zget_uucp_cmd (qconn, TRUE, fstrip);
if (zstr == NULL)
return FALSE;
@@ -1339,7 +1354,7 @@ fdo_call (qdaemon, qstat, qdialer, pfcalled, pterr)
ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
return FALSE;
}
- }
+ }
zsend = zbufalc (strlen (qdaemon->zlocalname) + 70);
if (! qsys->uuconf_fsequence)
@@ -1385,7 +1400,7 @@ fdo_call (qdaemon, qstat, qdialer, pfcalled, pterr)
/* Now we should see ROK or Rreason where reason gives a cryptic
reason for failure. If we are talking to a counterpart, we will
get back ROKN, possibly with a feature bitfield attached. */
- zstr = zget_uucp_cmd (qconn, TRUE);
+ zstr = zget_uucp_cmd (qconn, TRUE, fstrip);
if (zstr == NULL)
return FALSE;
@@ -1460,7 +1475,7 @@ fdo_call (qdaemon, qstat, qdialer, pfcalled, pterr)
/* The slave should now send \020Pprotos\0 where protos is a list of
supported protocols. Each protocol is a single character. */
- zstr = zget_uucp_cmd (qconn, TRUE);
+ zstr = zget_uucp_cmd (qconn, TRUE, fstrip);
if (zstr == NULL)
return FALSE;
@@ -1618,7 +1633,7 @@ fdo_call (qdaemon, qstat, qdialer, pfcalled, pterr)
before the hangup string. */
for (i = 0; i < 25; i++)
{
- zstr = zget_uucp_cmd (qconn, FALSE);
+ zstr = zget_uucp_cmd (qconn, FALSE, fstrip);
if (zstr == NULL)
break;
fdone = strstr (zstr, "OOOOOO") != NULL;
@@ -1700,13 +1715,23 @@ flogin_prompt (puuconf, zconfig, fuuxqt, qconn, zlogin)
struct sconnection *qconn;
const char *zlogin;
{
+ int iuuconf;
+ int istrip;
+ boolean fstrip;
char *zuser, *zpass;
boolean fret;
- int iuuconf;
struct scallin_info s;
DEBUG_MESSAGE0 (DEBUG_HANDSHAKE, "flogin_prompt: Waiting for login");
+ iuuconf = uuconf_strip (puuconf, &istrip);
+ if (iuuconf != UUCONF_SUCCESS)
+ {
+ ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
+ return FALSE;
+ }
+ fstrip = (istrip & UUCONF_STRIP_LOGIN) != 0;
+
zuser = NULL;
if (zlogin == NULL)
{
@@ -1715,7 +1740,7 @@ flogin_prompt (puuconf, zconfig, fuuxqt, qconn, zlogin)
ubuffree (zuser);
if (! fconn_write (qconn, "login: ", sizeof "login: " - 1))
return FALSE;
- zuser = zget_typed_line (qconn);
+ zuser = zget_typed_line (qconn, fstrip);
}
while (zuser != NULL && *zuser == '\0');
@@ -1731,7 +1756,7 @@ flogin_prompt (puuconf, zconfig, fuuxqt, qconn, zlogin)
return FALSE;
}
- zpass = zget_typed_line (qconn);
+ zpass = zget_typed_line (qconn, fstrip);
if (zpass == NULL)
{
ubuffree (zuser);
@@ -1819,10 +1844,12 @@ faccept_call (puuconf, zconfig, fuuxqt, zlogin, qconn, pzsystem)
const char **pzsystem;
{
long istart_time;
+ int iuuconf;
+ int istrip;
+ boolean fstrip;
const char *zport;
struct uuconf_port *qport;
struct uuconf_port sport;
- int iuuconf;
struct uuconf_dialer *qdialer;
struct uuconf_dialer sdialer;
boolean ftcp_port;
@@ -1847,6 +1874,17 @@ faccept_call (puuconf, zconfig, fuuxqt, zlogin, qconn, pzsystem)
istart_time = ixsysdep_time ((long *) NULL);
+ iuuconf = uuconf_strip (puuconf, &istrip);
+ if (iuuconf != UUCONF_SUCCESS)
+ {
+ ulog_uuconf (LOG_ERROR, puuconf, iuuconf);
+ uaccept_call_cleanup (puuconf, (struct uuconf_system *) NULL,
+ (struct uuconf_port *) NULL,
+ &sport, (char *) NULL);
+ return FALSE;
+ }
+ fstrip = (istrip & UUCONF_STRIP_PROTO) != 0;
+
/* Figure out protocol parameters determined by the port. If no
port was specified we're reading standard input, so try to get
the port name and read information from the port file. We only
@@ -1907,7 +1945,7 @@ faccept_call (puuconf, zconfig, fuuxqt, zlogin, qconn, pzsystem)
}
else
qdialer = qport->uuconf_u.uuconf_smodem.uuconf_qdialer;
- }
+ }
else if (qport->uuconf_ttype == UUCONF_PORTTYPE_TCP
|| (qport->uuconf_ttype == UUCONF_PORTTYPE_TLI
&& (qport->uuconf_ireliable
@@ -1981,7 +2019,7 @@ faccept_call (puuconf, zconfig, fuuxqt, zlogin, qconn, pzsystem)
return FALSE;
}
- zstr = zget_uucp_cmd (qconn, TRUE);
+ zstr = zget_uucp_cmd (qconn, TRUE, fstrip);
if (zstr == NULL)
{
uaccept_call_cleanup (puuconf, (struct uuconf_system *) NULL,
@@ -2195,7 +2233,7 @@ faccept_call (puuconf, zconfig, fuuxqt, zlogin, qconn, pzsystem)
getopt, which is distributed with the program anyhow. */
optind = 0;
opterr = 0;
-
+
while ((iopt = getopt (pzset - paz, paz,
"N::p:Q:RU:v:x:")) != EOF)
{
@@ -2427,9 +2465,9 @@ faccept_call (puuconf, zconfig, fuuxqt, zlogin, qconn, pzsystem)
uaccept_call_cleanup (puuconf, &ssys, qport, &sport, zloc);
return FALSE;
}
-
+
/* The master will now send back the selected protocol. */
- zstr = zget_uucp_cmd (qconn, TRUE);
+ zstr = zget_uucp_cmd (qconn, TRUE, fstrip);
if (zstr == NULL)
{
sstat.ttype = STATUS_FAILED;
@@ -2581,7 +2619,7 @@ faccept_call (puuconf, zconfig, fuuxqt, zlogin, qconn, pzsystem)
string. */
for (i = 0; i < 25; i++)
{
- zstr = zget_uucp_cmd (qconn, FALSE);
+ zstr = zget_uucp_cmd (qconn, FALSE, fstrip);
if (zstr == NULL)
break;
fdone = strstr (zstr, "OOOOOO") != NULL;
@@ -2719,9 +2757,10 @@ fsend_uucp_cmd (qconn, z)
#define CINCREMENT (100)
static char *
-zget_uucp_cmd (qconn, frequired)
+zget_uucp_cmd (qconn, frequired, fstrip)
struct sconnection *qconn;
boolean frequired;
+ boolean fstrip;
{
char *zalc;
size_t calc;
@@ -2757,7 +2796,7 @@ zget_uucp_cmd (qconn, frequired)
while ((ctimeout = (int) (iendtime - ixsysdep_time ((long *) NULL))) > 0)
{
int b;
-
+
b = breceive_char (qconn, ctimeout, frequired);
/* Now b == -1 on timeout, -2 on error. */
if (b < 0)
@@ -2777,10 +2816,8 @@ zget_uucp_cmd (qconn, frequired)
}
/* Apparently some systems use parity on these strings, so we
- strip the parity bit. This may need to be configurable at
- some point, although only if system names can have eight bit
- characters. */
- if (! isprint (BUCHAR (b)))
+ optionally strip the parity bit. */
+ if (fstrip)
b &= 0x7f;
#if DEBUG > 1
@@ -2870,10 +2907,11 @@ zget_uucp_cmd (qconn, frequired)
did, ignore a leading \n to account for \r\n pairs. */
static char *
-zget_typed_line (qconn)
+zget_typed_line (qconn, fstrip)
struct sconnection *qconn;
+ boolean fstrip;
{
- static boolean flastcr;
+ static boolean flastcr;
char *zalc;
size_t calc;
size_t cgot;
@@ -2897,7 +2935,7 @@ zget_typed_line (qconn)
while (TRUE)
{
int b;
-
+
b = breceive_char (qconn, CTIMEOUT, FALSE);
/* Now b == -1 on timeout, -2 on error. */
@@ -2922,6 +2960,10 @@ zget_typed_line (qconn)
continue;
}
+ /* Optionally strip the parity bit. */
+ if (fstrip)
+ b &= 0x7f;
+
#if DEBUG > 1
if (FDEBUGGING (DEBUG_CHAT))
{
diff --git a/gnu/libexec/uucp/uucico/xcmd.c b/gnu/libexec/uucp/uucico/xcmd.c
index b563a53..a02411a 100644
--- a/gnu/libexec/uucp/uucico/xcmd.c
+++ b/gnu/libexec/uucp/uucico/xcmd.c
@@ -1,7 +1,7 @@
/* xcmd.c
Routines to handle work requests.
- Copyright (C) 1991, 1992, 1993 Ian Lance Taylor
+ Copyright (C) 1991, 1992, 1993, 1995 Ian Lance Taylor
This file is part of the Taylor UUCP package.
@@ -17,16 +17,16 @@
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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
The author of the program may be contacted at ian@airs.com or
- c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139.
+ c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
*/
#include "uucp.h"
#if USE_RCS_ID
-const char xcmd_rcsid[] = "$Id: xcmd.c,v 1.14 1994/04/04 03:25:12 ian Rel $";
+const char xcmd_rcsid[] = "$Id: xcmd.c,v 1.19 1995/06/21 20:20:42 ian Rel $";
#endif
#include <errno.h>
@@ -97,8 +97,8 @@ flocal_xcmd_request (qtrans, qdaemon)
qtrans->iremote);
ubuffree (zsend);
- if (! fret)
- utransfree (qtrans);
+ /* If fret is FALSE, we should free qtrans here, but see the comment
+ at the end of flocal_rec_send_request. */
return fret;
}
@@ -330,7 +330,7 @@ fremote_xcmd_init (qdaemon, qcmd, iremote)
/* Copy the file either to the final destination or to the
spool directory. */
- if (! fcopy_file (zfile, zto, qdestsys == NULL, fmkdirs))
+ if (! fcopy_file (zfile, zto, qdestsys == NULL, fmkdirs, FALSE))
{
ubuffree (zto);
break;
OpenPOWER on IntegriCloud