projects
/
unix-history
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ecb924d
)
still more fixes from rick@seismo
author
Jim Bloom
<bloom@ucbvax.Berkeley.EDU>
Thu, 10 Oct 1985 08:08:14 +0000
(
00:08
-0800)
committer
Jim Bloom
<bloom@ucbvax.Berkeley.EDU>
Thu, 10 Oct 1985 08:08:14 +0000
(
00:08
-0800)
SCCS-vsn: usr.bin/uucp/uucico/fio.c 5.2
SCCS-vsn: usr.bin/uucp/libuu/gename.c 5.6
SCCS-vsn: usr.bin/uucp/libuu/getprm.c 5.4
SCCS-vsn: usr.bin/uucp/uucico/gio.c 5.5
SCCS-vsn: usr.bin/uucp/libuu/logent.c 5.6
usr/src/usr.bin/uucp/libuu/gename.c
patch
|
blob
|
blame
|
history
usr/src/usr.bin/uucp/libuu/getprm.c
patch
|
blob
|
blame
|
history
usr/src/usr.bin/uucp/libuu/logent.c
patch
|
blob
|
blame
|
history
usr/src/usr.bin/uucp/uucico/fio.c
patch
|
blob
|
blame
|
history
usr/src/usr.bin/uucp/uucico/gio.c
patch
|
blob
|
blame
|
history
diff --git
a/usr/src/usr.bin/uucp/libuu/gename.c
b/usr/src/usr.bin/uucp/libuu/gename.c
index
663661b
..
d4d2624
100644
(file)
--- a/
usr/src/usr.bin/uucp/libuu/gename.c
+++ b/
usr/src/usr.bin/uucp/libuu/gename.c
@@
-1,10
+1,21
@@
#ifndef lint
#ifndef lint
-static char sccsid[] = "@(#)gename.c 5.
5
(Berkeley) %G%";
+static char sccsid[] = "@(#)gename.c 5.
6
(Berkeley) %G%";
#endif
#include "uucp.h"
#define SEQLEN 4
#endif
#include "uucp.h"
#define SEQLEN 4
+#define SLOCKTIME 10L
+#define SLOCKTRIES 5
+/*
+ * the alphabet can be anything, but if it's not in ascii order,
+ * sequence ordering is not preserved
+ */
+static char alphabet[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+#ifdef BSD4_2
+#include <sys/file.h>
+#endif BSD4_2
/*LINTLIBRARY*/
/*LINTLIBRARY*/
@@
-14,34
+25,12
@@
static char sccsid[] = "@(#)gename.c 5.5 (Berkeley) %G%";
gename(pre, sys, grade, file)
char pre, *sys, grade, *file;
{
gename(pre, sys, grade, file)
char pre, *sys, grade, *file;
{
- static char sqnum[5];
-
- getseq(sqnum);
- sprintf(file,"%c.%.*s%c%.*s", pre, SYSNSIZE, sys, grade, SEQLEN, sqnum);
- DEBUG(4, "file - %s\n", file);
-}
-
-#define SLOCKTIME 10L
-#define SLOCKTRIES 5
-
-/*
- * get next sequence number
- */
-
-static
-getseq(snum)
-register char *snum;
-{
- /*
- * the alphabet can be anything, but if it's not in ascii order,
- * sequence ordering is not preserved
- */
- char *alphabet =
- "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
register int i, fd;
register int i, fd;
+ static char snum[5];
static char *lastchar = NULL;
if (lastchar == NULL || (snum[SEQLEN-1] = *(lastchar++)) == '\0') {
static char *lastchar = NULL;
if (lastchar == NULL || (snum[SEQLEN-1] = *(lastchar++)) == '\0') {
+#ifndef BSD4_2
for (i = 0; i < SLOCKTRIES; i++) {
if (!ulockf(SEQLOCK, SLOCKTIME))
break;
for (i = 0; i < SLOCKTRIES; i++) {
if (!ulockf(SEQLOCK, SLOCKTIME))
break;
@@
-49,33
+38,22
@@
register char *snum;
}
if (i >= SLOCKTRIES) {
}
if (i >= SLOCKTRIES) {
- int alphalen;
logent(SEQLOCK, "CAN NOT LOCK");
logent(SEQLOCK, "CAN NOT LOCK");
- alphalen = strlen(alphabet);
- srand((int)time((time_t *)0));
- for (i=1;i<SEQLEN;i++)
- *snum++ = alphabet[rand() % alphalen];
- lastchar = alphabet;
- *snum = *lastchar++;
- return;
+ goto getrandseq;
}
}
+#endif !BSD4_2
if ((fd = open(SEQFILE, 2)) >= 0) {
if ((fd = open(SEQFILE, 2)) >= 0) {
- int alphalen;
- register char *p;
- char *index();
-
- alphalen = strlen(alphabet);
+ register char *p;
+#ifdef BSD4_2
+ flock(fd, LOCK_EX);
+#endif !BSD4_2
read(fd, snum, SEQLEN);
read(fd, snum, SEQLEN);
- /* initialize rand() for possible use */
- srand((int)time((time_t *)0));
/* increment the penultimate character */
for (i = SEQLEN - 2; i >= 0; --i) {
/* increment the penultimate character */
for (i = SEQLEN - 2; i >= 0; --i) {
- if ((p = index(alphabet, snum[i])) == NULL) {
- p = &alphabet[rand() % alphalen];
- DEBUG(6, "bad seqf: %s\n", snum);
- }
- if (++p < &alphabet[alphalen]) {
+ if ((p = index(alphabet, snum[i])) == NULL)
+ goto getrandseq;
+ if (++p < &alphabet[sizeof alphabet - 1]) {
snum[i] = *p;
break;
} else /* carry */
snum[i] = *p;
break;
} else /* carry */
@@
-83,17
+61,25
@@
register char *snum;
}
snum[SEQLEN-1] = alphabet[0];
} else {
}
snum[SEQLEN-1] = alphabet[0];
} else {
+ extern int errno;
+ fd = creat(SEQFILE, 0666);
+getrandseq: srand((int)time((time_t *)0));
+ assert(SEQFILE, "is missing or trashed\n", errno);
for (i = 0; i < SEQLEN; i++)
for (i = 0; i < SEQLEN; i++)
- snum[i] = alphabet[0];
- if ((fd = creat(SEQFILE, 0666)) < 0)
- return;
+ snum[i] = alphabet[rand() % (sizeof alphabet - 1)];
+ snum[SEQLEN-1] = alphabet[0];
}
}
- lseek(fd, 0L, 0);
- write(fd, snum, SEQLEN);
- close(fd);
+ if (fd >= 0) {
+ lseek(fd, 0L, 0);
+ write(fd, snum, SEQLEN);
+ close(fd);
+ }
+#ifndef BSD4_2
rmlock(SEQLOCK);
rmlock(SEQLOCK);
+#endif !BSD4_2
lastchar = alphabet + 1;
}
lastchar = alphabet + 1;
}
- return;
+ sprintf(file,"%c.%.*s%c%.*s", pre, SYSNSIZE, sys, grade, SEQLEN, snum);
+ DEBUG(4, "file - %s\n", file);
}
}
diff --git
a/usr/src/usr.bin/uucp/libuu/getprm.c
b/usr/src/usr.bin/uucp/libuu/getprm.c
index
d8b4885
..
730ce8a
100644
(file)
--- a/
usr/src/usr.bin/uucp/libuu/getprm.c
+++ b/
usr/src/usr.bin/uucp/libuu/getprm.c
@@
-1,13
+1,11
@@
#ifndef lint
#ifndef lint
-static char sccsid[] = "@(#)getprm.c 5.
3
(Berkeley) %G%";
+static char sccsid[] = "@(#)getprm.c 5.
4
(Berkeley) %G%";
#endif
#include "uucp.h"
#define LQUOTE '('
#define RQUOTE ')'
#endif
#include "uucp.h"
#define LQUOTE '('
#define RQUOTE ')'
-#define NOSYSPART 0
-#define HASSYSPART 1
/*LINTLIBRARY*/
/*LINTLIBRARY*/
@@
-67,44
+65,3
@@
register char *s, *prm;
return s;
}
return s;
}
-
-/*
- * split into system and file part
- *
- * return codes:
- * NOSYSPART
- * HASSYSPART
- */
-
-split(name, sys, rest)
-register char *name, *rest;
-char *sys;
-{
- register char *c;
- register int i;
-
- if (*name == LQUOTE) {
- if ((c = index(name + 1, RQUOTE)) != NULL) {
- /* strip off quotes */
- name++;
- while (c != name)
- *rest++ = *name++;
- *rest = '\0';
- *sys = '\0';
- return NOSYSPART;
- }
- }
-
- if ((c = index(name, '!')) == NULL) {
- strcpy(rest, name);
- *sys = '\0';
- return NOSYSPART;
- }
-
- *c++ = '\0';
- strncpy(sys, name, MAXBASENAME);
- sys[MAXBASENAME] = '\0';
-
- strcpy(rest, c);
- return HASSYSPART;
-}
diff --git
a/usr/src/usr.bin/uucp/libuu/logent.c
b/usr/src/usr.bin/uucp/libuu/logent.c
index
fb29473
..
27f9fa2
100644
(file)
--- a/
usr/src/usr.bin/uucp/libuu/logent.c
+++ b/
usr/src/usr.bin/uucp/libuu/logent.c
@@
-1,5
+1,5
@@
#ifndef lint
#ifndef lint
-static char sccsid[] = "@(#)logent.c 5.
5
(Berkeley) %G%";
+static char sccsid[] = "@(#)logent.c 5.
6
(Berkeley) %G%";
#endif
#include "uucp.h"
#endif
#include "uucp.h"
@@
-81,7
+81,6
@@
register FILE *fp;
static pid = 0;
register struct tm *tp;
extern struct tm *localtime();
static pid = 0;
register struct tm *tp;
extern struct tm *localtime();
- time_t clock;
if (text == NULL)
text = "";
if (text == NULL)
text = "";
@@
-89,16
+88,20
@@
register FILE *fp;
status = "";
if (!pid)
pid = getpid();
status = "";
if (!pid)
pid = getpid();
- time(&clock);
- tp = localtime(&clock);
- fprintf(fp, "%s %s ", User, Rmtname);
#ifdef USG
#ifdef USG
- fprintf(fp, "(%d/%d-%2.2d:%2.2d-%d) ", tp->tm_mon + 1,
-
tp->tm_mday, tp->tm_hour, tp->tm_min, pid)
;
+ time(&Now.time);
+
Now.millitm = 0
;
#else !USG
#else !USG
- fprintf(fp, "(%d/%d-%02d:%02d-%d) ", tp->tm_mon + 1,
- tp->tm_mday, tp->tm_hour, tp->tm_min, pid);
+ ftime(&Now);
#endif !USG
#endif !USG
+ tp = localtime(&Now.time);
+#ifdef USG
+ fprintf(fp, "%s %s (%d/%d-%2.2d:%2.2d-%d) ",
+#else !USG
+ fprintf(fp, "%s %s (%d/%d-%02d:%02d-%d) ",
+#endif !USG
+ User, Rmtname, tp->tm_mon + 1, tp->tm_mday,
+ tp->tm_hour, tp->tm_min, pid);
fprintf(fp, "%s (%s)\n", status, text);
/* Since it's buffered */
fprintf(fp, "%s (%s)\n", status, text);
/* Since it's buffered */
@@
-144,7
+147,6
@@
char *text;
{
register struct tm *tp;
extern struct tm *localtime();
{
register struct tm *tp;
extern struct tm *localtime();
- struct timeb clock;
#ifdef LOGBYSITE
char lfile[MAXFULLNAME];
static char SLogRmtname[64];
#ifdef LOGBYSITE
char lfile[MAXFULLNAME];
static char SLogRmtname[64];
@@
-184,22
+186,22
@@
char *text;
}
#ifdef USG
}
#ifdef USG
- time(&
clock
.time);
-
clock
.millitm = 0;
+ time(&
Now
.time);
+
Now
.millitm = 0;
#else !USG
#else !USG
- ftime(&
clock
);
+ ftime(&
Now
);
#endif !USG
#endif !USG
- tp = localtime(&
clock
.time);
+ tp = localtime(&
Now
.time);
fprintf(Sp, "%s %s ", User, Rmtname);
#ifdef USG
fprintf(Sp, "(%d/%d-%2.2d:%2.2d) ", tp->tm_mon + 1,
tp->tm_mday, tp->tm_hour, tp->tm_min);
fprintf(Sp, "%s %s ", User, Rmtname);
#ifdef USG
fprintf(Sp, "(%d/%d-%2.2d:%2.2d) ", tp->tm_mon + 1,
tp->tm_mday, tp->tm_hour, tp->tm_min);
- fprintf(Sp, "(%ld) %s\n",
clock
.time, text);
+ fprintf(Sp, "(%ld) %s\n",
Now
.time, text);
#else !USG
fprintf(Sp, "(%d/%d-%02d:%02d) ", tp->tm_mon + 1,
tp->tm_mday, tp->tm_hour, tp->tm_min);
#else !USG
fprintf(Sp, "(%d/%d-%02d:%02d) ", tp->tm_mon + 1,
tp->tm_mday, tp->tm_hour, tp->tm_min);
- fprintf(Sp, "(%ld.%02u) %s\n",
clock.time, clock
.millitm/10, text);
+ fprintf(Sp, "(%ld.%02u) %s\n",
Now.time, Now
.millitm/10, text);
#endif !USG
/* Position at end and flush */
#endif !USG
/* Position at end and flush */
diff --git
a/usr/src/usr.bin/uucp/uucico/fio.c
b/usr/src/usr.bin/uucp/uucico/fio.c
index
533bf31
..
779e650
100644
(file)
--- a/
usr/src/usr.bin/uucp/uucico/fio.c
+++ b/
usr/src/usr.bin/uucp/uucico/fio.c
@@
-1,5
+1,5
@@
#ifndef lint
#ifndef lint
-static char sccsid[] = "@(#)fio.c 5.
1
(Berkeley) %G%";
+static char sccsid[] = "@(#)fio.c 5.
2
(Berkeley) %G%";
#endif
/*
#endif
/*
@@
-23,17
+23,28
@@
static char sccsid[] = "@(#)fio.c 5.1 (Berkeley) %G%";
* to trigger packet transmission, hence par 3 should be
* set to 2; a good value for the Idle Timer (par 4) is 10.
* All other pars should be set to 0.
* to trigger packet transmission, hence par 3 should be
* set to 2; a good value for the Idle Timer (par 4) is 10.
* All other pars should be set to 0.
+ *
* Normally a calling site will take care of setting the
* local PAD pars via an X.28 command and those of the remote
* PAD via an X.29 command, unless the remote site has a
* special channel assigned for this protocol with the proper
* par settings.
*
* Normally a calling site will take care of setting the
* local PAD pars via an X.28 command and those of the remote
* PAD via an X.29 command, unless the remote site has a
* special channel assigned for this protocol with the proper
* par settings.
*
- * Author: Piet Beertema, CWI, Amsterdam, Sep 1984
+ * Additional comments for hosts with direct X.25 access:
+ * - the global variable IsTcpIp, when set, excludes the ioctl's,
+ * so the same binary can run on X.25 and non-X.25 hosts;
+ * - reads are done in small chunks, which can be smaller than
+ * the packet size; your X.25 driver must support that.
+ *
+ *
+ * Author:
+ * Piet Beertema, CWI, Amsterdam, Sep 1984
+ * Modified for X.25 hosts:
+ * Robert Elz, Melbourne Univ, Mar 1985
*/
*/
-#include <signal.h>
#include "uucp.h"
#include "uucp.h"
+#include <signal.h>
#ifdef USG
#include <termio.h>
#else !USG
#ifdef USG
#include <termio.h>
#else !USG
@@
-41,7
+52,14
@@
static char sccsid[] = "@(#)fio.c 5.1 (Berkeley) %G%";
#endif !USG
#include <setjmp.h>
#endif !USG
#include <setjmp.h>
-#define FBUFSIZ 256
+#define FIBUFSIZ 256 /* for X.25 interfaces: set equal to packet size,
+ * but see comment above
+ */
+
+#define FOBUFSIZ 256 /* for X.25 interfaces: set equal to packet size;
+ * otherwise make as large as feasible to reduce
+ * number of write system calls
+ */
#ifndef MAXMSGLEN
#define MAXMSGLEN BUFSIZ
#ifndef MAXMSGLEN
#define MAXMSGLEN BUFSIZ
@@
-70,16
+88,18
@@
fturnon()
int ret;
struct termio ttbuf;
int ret;
struct termio ttbuf;
- ioctl(Ifn, TCGETA, &ttbuf);
+ if (!IsTcpIp) {
+ ioctl(Ifn, TCGETA, &ttbuf);
#ifdef USG
#ifdef USG
- ttbuf.c_iflag = IXOFF|IXON|ISTRIP;
-
ttbuf.c_cc[VMIN] = FBUFSIZ > 64 ? 64 : F
BUFSIZ;
- ttbuf.c_cc[VTIME] = 5;
-#else
- ttbuf.sg_flags = ANYP|CBREAK|TANDEM;
+
ttbuf.c_iflag = IXOFF|IXON|ISTRIP;
+
ttbuf.c_cc[VMIN] = FIBUFSIZ > 64 ? 64 : FI
BUFSIZ;
+
ttbuf.c_cc[VTIME] = 5;
+#else
!USG
+
ttbuf.sg_flags = ANYP|CBREAK|TANDEM;
#endif USG
#endif USG
- ret = ioctl(Ifn, TCSETA, &ttbuf);
- ASSERT(ret >= 0, "STTY FAILED", "", ret);
+ ret = ioctl(Ifn, TCSETA, &ttbuf);
+ ASSERT(ret >= 0, "STTY FAILED", "", ret);
+ }
fsig = signal(SIGALRM, falarm);
/* give the other side time to perform its ioctl;
* otherwise it may flush out the first data this
fsig = signal(SIGALRM, falarm);
/* give the other side time to perform its ioctl;
* otherwise it may flush out the first data this
@@
-110,6
+130,7
@@
char type;
if (*(s-1) == '\n')
s--;
*s++ = '\r';
if (*(s-1) == '\n')
s--;
*s++ = '\r';
+ *s = 0;
(void) write(fn, bufr, s - bufr);
return SUCCESS;
}
(void) write(fn, bufr, s - bufr);
return SUCCESS;
}
@@
-127,10
+148,12
@@
register int fn;
for (;;) {
if (read(fn, str, 1) <= 0)
goto msgerr;
for (;;) {
if (read(fn, str, 1) <= 0)
goto msgerr;
+ *str &= 0177;
if (*str == '\r')
break;
if (*str == '\r')
break;
- if (*str < ' ')
+ if (*str < ' ')
{
continue;
continue;
+ }
if (str++ >= smax)
goto msgerr;
}
if (str++ >= smax)
goto msgerr;
}
@@
-146,12
+169,12
@@
fwrdata(fp1, fn)
FILE *fp1;
int fn;
{
FILE *fp1;
int fn;
{
- register int flen, alen, ret;
- char ibuf[FBUFSIZ];
- char ack;
+ register int alen, ret;
+ register char *obp;
+ char ack, ibuf[MAXMSGLEN];
+ int flen, mil, retries = 0;
long abytes, fbytes;
struct timeb t1, t2;
long abytes, fbytes;
struct timeb t1, t2;
- int mil, retries = 0;
ret = FAIL;
retry:
ret = FAIL;
retry:
@@
-164,31
+187,22
@@
retry:
#else !USG
ftime(&t1);
#endif !USG
#else !USG
ftime(&t1);
#endif !USG
- while ((flen = fread(ibuf, sizeof (char), FBUFSIZ, fp1)) > 0) {
- alen = fwrblk(fn, ibuf, flen);
- abytes += alen >= 0 ? alen : -alen;
- if (alen <= 0)
- goto acct;
+ do {
+ alen = fwrblk(fn, fp1, &flen);
fbytes += flen;
fbytes += flen;
- }
- sprintf(ibuf, "\176\176%04x\r", fchksum);
- abytes += alen = strlen(ibuf);
- if (write(fn, ibuf, alen) == alen) {
- DEBUG(8, "%d\n", alen);
- DEBUG(8, "checksum: %04x\n", fchksum);
- if (frdmsg(ibuf, fn) != FAIL) {
- if ((ack = ibuf[0]) == 'G')
- ret = 0;
- DEBUG(4, "ack - '%c'\n", ack);
+ if (alen <= 0) {
+ abytes -= alen;
+ goto acct;
}
}
+ abytes += alen;
+ } while (!feof(fp1) && !ferror(fp1));
+ DEBUG(8, "\nchecksum: %04x\n", fchksum);
+ if (frdmsg(ibuf, fn) != FAIL) {
+ if ((ack = ibuf[0]) == 'G')
+ ret = SUCCESS;
+ DEBUG(4, "ack - '%c'\n", ack);
}
acct:
}
acct:
- if (ack == 'R') {
- DEBUG(4, "RETRY:\n", 0);
- fseek(fp1, 0L, 0);
- retries++;
- goto retry;
- }
#ifdef USG
time(&t2.time);
t2.millitm = 0;
#ifdef USG
time(&t2.time);
t2.millitm = 0;
@@
-203,14
+217,20
@@
acct:
mil += 1000;
}
sprintf(ibuf, "sent data %ld bytes %ld.%02d secs",
mil += 1000;
}
sprintf(ibuf, "sent data %ld bytes %ld.%02d secs",
-
fbytes, (long)t2.time, mil/
10);
+
fbytes, (long)t2.time, mil /
10);
sysacct(abytes, t2.time - t1.time);
sysacct(abytes, t2.time - t1.time);
- if (retries > 0)
- sprintf(
(char *)ibuf+strlen(ibuf),"
%d retries", retries);
+ if (retries > 0)
+ sprintf(
&ibuf[strlen(ibuf)], ",
%d retries", retries);
DEBUG(1, "%s\n", ibuf);
syslog(ibuf);
DEBUG(1, "%s\n", ibuf);
syslog(ibuf);
+ if (ack == 'R') {
+ DEBUG(4, "RETRY:\n", 0);
+ fseek(fp1, 0L, 0);
+ retries++;
+ goto retry;
+ }
#ifdef SYSACCT
#ifdef SYSACCT
- if (ret)
+ if (ret
== FAIL
)
sysaccf(NULL); /* force accounting */
#endif SYSACCT
return ret;
sysaccf(NULL); /* force accounting */
#endif SYSACCT
return ret;
@@
-225,11
+245,10
@@
register FILE *fp2;
{
register int flen;
register char eof;
{
register int flen;
register char eof;
- char ibuf[FBUFSIZ];
- int ret, retries = 0;
+ char ibuf[F
I
BUFSIZ];
+ int ret,
mil,
retries = 0;
long alen, abytes, fbytes;
struct timeb t1, t2;
long alen, abytes, fbytes;
struct timeb t1, t2;
- int mil;
ret = FAIL;
retry:
ret = FAIL;
retry:
@@
-246,31
+265,14
@@
retry:
abytes += alen;
if (flen < 0)
goto acct;
abytes += alen;
if (flen < 0)
goto acct;
- if (eof = flen > FBUFSIZ)
- flen -= FBUFSIZ + 1;
+ if (eof = flen > F
I
BUFSIZ)
+ flen -= F
I
BUFSIZ + 1;
fbytes += flen;
if (fwrite(ibuf, sizeof (char), flen, fp2) != flen)
goto acct;
} while (!eof);
fbytes += flen;
if (fwrite(ibuf, sizeof (char), flen, fp2) != flen)
goto acct;
} while (!eof);
- ret =
0
;
+ ret =
SUCCESS
;
acct:
acct:
- if (ret) {
- if (retries++ < MAXRETRIES) {
- DEBUG(8, "send ack: 'R'\n", 0);
- fwrmsg('R', "", fn);
- fseek(fp2, 0L, 0);
- DEBUG(4, "RETRY:\n", 0);
- goto retry;
- }
- DEBUG(8, "send ack: 'Q'\n", 0);
- fwrmsg('Q', "", fn);
-#ifdef SYSACCT
- sysaccf(NULL); /* force accounting */
-#endif SYSACCT
- } else {
- DEBUG(8, "send ack: 'G'\n", 0);
- fwrmsg('G', "", fn);
- }
#ifdef USG
time(&t2.time);
t2.millitm = 0;
#ifdef USG
time(&t2.time);
t2.millitm = 0;
@@
-285,12
+287,30
@@
acct:
mil += 1000;
}
sprintf(ibuf, "received data %ld bytes %ld.%02d secs",
mil += 1000;
}
sprintf(ibuf, "received data %ld bytes %ld.%02d secs",
- fbytes, (long)t2.time, mil/10);
- sysacct(abytes, t2.time - t1.time);
+ fbytes, (long)t2.time, mil/10);
if (retries > 0)
if (retries > 0)
- sprintf((char *)ibuf+strlen(ibuf)," %d retries", retries);
+ sprintf(&ibuf[strlen(ibuf)]," %d retries", retries);
+ sysacct(abytes, t2.time - t1.time);
DEBUG(1, "%s\n", ibuf);
syslog(ibuf);
DEBUG(1, "%s\n", ibuf);
syslog(ibuf);
+ if (ret == FAIL) {
+ if (retries++ < MAXRETRIES) {
+ DEBUG(8, "send ack: 'R'\n", 0);
+ fwrmsg('R', "", fn);
+ fseek(fp2, 0L, 0);
+ DEBUG(4, "RETRY:\n", 0);
+ goto retry;
+ }
+ DEBUG(8, "send ack: 'Q'\n", 0);
+ fwrmsg('Q', "", fn);
+#ifdef SYSACCT
+ sysaccf(NULL); /* force accounting */
+#endif SYSACCT
+ }
+ else {
+ DEBUG(8, "send ack: 'G'\n", 0);
+ fwrmsg('G', "", fn);
+ }
return ret;
}
return ret;
}
@@
-300,100
+320,115
@@
register char *blk;
register int len;
register int fn;
{
register int len;
register int fn;
{
- static int ret = FBUFSIZ / 2;
-#ifndef Not080
- extern int linebaudrate;
-#endif Not080
+ static int ret = FIBUFSIZ / 2;
if (setjmp(Ffailbuf))
return FAIL;
if (setjmp(Ffailbuf))
return FAIL;
-#ifndef Not080
- if (len == FBUFSIZ && ret < FBUFSIZ / 2 &&
- linebaudrate > 0 && linebaudrate < 4800)
- sleep(1);
-#endif Not080
(void) alarm(MAXMSGTIME);
ret = read(fn, blk, len);
alarm(0);
return ret <= 0 ? FAIL : ret;
}
(void) alarm(MAXMSGTIME);
ret = read(fn, blk, len);
alarm(0);
return ret <= 0 ? FAIL : ret;
}
+#if !defined(BSD4_2) && !defined(USG)
/* call ultouch every TC calls to either frdblk or fwrblk */
/* call ultouch every TC calls to either frdblk or fwrblk */
-
-#define TC 20
-static int tc = TC;
+#define TC 20
+static int tc = TC;
+#endif !defined(BSD4_2) && !defined(USG)
/* Byte conversion:
*
/* Byte conversion:
*
- * from
pre to
- * 000-037
172 100-137
- * 040-171
040-171
- * 172-177
173 072-077
- * 200-237
174 100-137
- * 240-371
175 040-171
- * 372-377
176 072-077
+ * from pre to
+ * 000-037 172 100-137
+ * 040-171 040-171
+ * 172-177 173 072-077
+ * 200-237 174 100-137
+ * 240-371 175 040-171
+ * 372-377 176 072-077
*/
static
*/
static
-fwrblk(fn,
ip, len
)
+fwrblk(fn,
fp, lenp
)
int fn;
int fn;
-register
char *i
p;
-
register int len
;
+register
FILE *f
p;
+
int *lenp
;
{
register char *op;
{
register char *op;
- register int sum, nl;
+ register int c, sum, nl, len;
+ char obuf[FOBUFSIZ + 8];
int ret;
int ret;
- char obuf[FBUFSIZ * 2];
+#if !defined(BSD4_2) && !defined(USG)
/* call ultouch occasionally */
if (--tc < 0) {
tc = TC;
ultouch();
}
/* call ultouch occasionally */
if (--tc < 0) {
tc = TC;
ultouch();
}
- DEBUG(8, "%d/", len);
+#endif !defined(BSD4_2) && !defined(USG)
op = obuf;
nl = 0;
op = obuf;
nl = 0;
+ len = 0;
sum = fchksum;
sum = fchksum;
- do {
+ while ((c = getc(fp)) != EOF) {
+ len++;
if (sum & 0x8000) {
sum <<= 1;
sum++;
} else
sum <<= 1;
if (sum & 0x8000) {
sum <<= 1;
sum++;
} else
sum <<= 1;
- sum +=
*ip & 0377
;
+ sum +=
c
;
sum &= 0xffff;
sum &= 0xffff;
- if (
*ip
& 0200) {
-
*ip
&= 0177;
- if (
*ip
< 040) {
+ if (
c
& 0200) {
+
c
&= 0177;
+ if (
c
< 040) {
*op++ = '\174';
*op++ = '\174';
- *op++ =
*ip++
+ 0100;
+ *op++ =
c
+ 0100;
} else
} else
- if (
*ip
<= 0171) {
+ if (
c
<= 0171) {
*op++ = '\175';
*op++ = '\175';
- *op++ =
*ip++
;
+ *op++ =
c
;
}
else {
*op++ = '\176';
}
else {
*op++ = '\176';
- *op++ =
*ip++
- 0100;
+ *op++ =
c
- 0100;
}
nl += 2;
} else {
}
nl += 2;
} else {
- if (
*ip
< 040) {
+ if (
c
< 040) {
*op++ = '\172';
*op++ = '\172';
- *op++ =
*ip++
+ 0100;
+ *op++ =
c
+ 0100;
nl += 2;
} else
nl += 2;
} else
- if (
*ip
<= 0171) {
- *op++ =
*ip++
;
+ if (
c
<= 0171) {
+ *op++ =
c
;
nl++;
} else {
*op++ = '\173';
nl++;
} else {
*op++ = '\173';
- *op++ =
*ip++
- 0100;
+ *op++ =
c
- 0100;
nl += 2;
}
}
nl += 2;
}
}
- } while (--len);
+ if (nl >= FOBUFSIZ - 1) {
+ /*
+ * peek at next char, see if it will fit
+ */
+ c = getc(fp);
+ if (c == EOF)
+ break;
+ (void) ungetc(c, fp);
+ if (nl >= FOBUFSIZ || c < 040 || c > 0171)
+ goto writeit;
+ }
+ }
+ /*
+ * At EOF - append checksum, there is space for it...
+ */
+ sprintf(op, "\176\176%04x\r", sum);
+ nl += strlen(op);
+writeit:
+ *lenp = len;
fchksum = sum;
fchksum = sum;
+ DEBUG(8, "%d/", len);
DEBUG(8, "%d,", nl);
ret = write(fn, obuf, nl);
return ret == nl ? nl : ret < 0 ? 0 : -ret;
DEBUG(8, "%d,", nl);
ret = write(fn, obuf, nl);
return ret == nl ? nl : ret < 0 ? 0 : -ret;
@@
-411,13
+446,14
@@
long *rlen;
int i;
static char special = 0;
int i;
static char special = 0;
+#if !defined(BSD4_2) && !defined(USG)
/* call ultouch occasionally */
if (--tc < 0) {
tc = TC;
ultouch();
}
/* call ultouch occasionally */
if (--tc < 0) {
tc = TC;
ultouch();
}
-
- if ((len = frdbuf(ip, FBUFSIZ, fn)) == FAIL) {
+#endif !defined(BSD4_2) && !defined(USG)
+ if ((len = frdbuf(ip, F
I
BUFSIZ, fn)) == FAIL) {
*rlen = 0;
goto dcorr;
}
*rlen = 0;
goto dcorr;
}
@@
-435,7
+471,7
@@
long *rlen;
if (*ip++ != '\176' || (i = --len) > 5)
goto dcorr;
while (i--)
if (*ip++ != '\176' || (i = --len) > 5)
goto dcorr;
while (i--)
- *op++ = *ip++;
+ *op++ = *ip++
& 0177
;
while (len < 5) {
i = frdbuf(&buf[len], 5 - len, fn);
if (i == FAIL) {
while (len < 5) {
i = frdbuf(&buf[len], 5 - len, fn);
if (i == FAIL) {
@@
-445,13
+481,15
@@
long *rlen;
DEBUG(8, ",%d", i);
len += i;
*rlen += i;
DEBUG(8, ",%d", i);
len += i;
*rlen += i;
+ while (i--)
+ *op++ &= 0177;
}
if (buf[4] != '\r')
goto dcorr;
sscanf(buf, "%4x", &fchksum);
DEBUG(8, "\nchecksum: %04x\n", sum);
if (fchksum == sum)
}
if (buf[4] != '\r')
goto dcorr;
sscanf(buf, "%4x", &fchksum);
DEBUG(8, "\nchecksum: %04x\n", sum);
if (fchksum == sum)
- return FBUFSIZ + 1 + nl;
+ return F
I
BUFSIZ + 1 + nl;
else {
DEBUG(8, "\n", 0);
DEBUG(4, "Bad checksum\n", 0);
else {
DEBUG(8, "\n", 0);
DEBUG(4, "Bad checksum\n", 0);
@@
-503,8
+541,9
@@
dcorr:
DEBUG(8, "\n", 0);
DEBUG(4, "Data corrupted\n", 0);
while (len != FAIL) {
DEBUG(8, "\n", 0);
DEBUG(4, "Data corrupted\n", 0);
while (len != FAIL) {
- if ((len = frdbuf(erbp, FBUFSIZ, fn)) != FAIL)
+ if ((len = frdbuf(erbp, F
I
BUFSIZ, fn)) != FAIL)
*rlen += len;
}
return FAIL;
}
*rlen += len;
}
return FAIL;
}
+
diff --git
a/usr/src/usr.bin/uucp/uucico/gio.c
b/usr/src/usr.bin/uucp/uucico/gio.c
index
84d1887
..
07e4a4d
100644
(file)
--- a/
usr/src/usr.bin/uucp/uucico/gio.c
+++ b/
usr/src/usr.bin/uucp/uucico/gio.c
@@
-1,5
+1,5
@@
#ifndef lint
#ifndef lint
-static char sccsid[] = "@(#)gio.c 5.
4
(Berkeley) %G%";
+static char sccsid[] = "@(#)gio.c 5.
5
(Berkeley) %G%";
#endif
#include "uucp.h"
#endif
#include "uucp.h"
@@
-190,9
+190,11
@@
FILE *fp2;
return SUCCESS;
}
return SUCCESS;
}
-/* call ultouch every TC calls to either grdblk or gwrblk -- rti!trt */
+#if !defined(BSD4_2) && !defined(USG)
+/* call ultouch every TC calls to either grdblk or gwrblk */
#define TC 20
static int tc = TC;
#define TC 20
static int tc = TC;
+#endif !BSD4_2 && !USG
/*ARGSUSED*/
grdblk(blk, len, fn)
/*ARGSUSED*/
grdblk(blk, len, fn)
@@
-201,11
+203,13
@@
char *blk;
{
register int i, ret;
{
register int i, ret;
+#if !defined(BSD4_2) && !defined(USG)
/* call ultouch occasionally */
if (--tc < 0) {
tc = TC;
ultouch();
}
/* call ultouch occasionally */
if (--tc < 0) {
tc = TC;
ultouch();
}
+#endif !BSD4_2 && !USG
for (i = 0; i < len; i += ret) {
ret = pkread(Pk, blk, len - i);
if (ret < 0)
for (i = 0; i < len; i += ret) {
ret = pkread(Pk, blk, len - i);
if (ret < 0)
@@
-221,13
+225,12
@@
char *blk;
gwrblk(blk, len, fn)
register char *blk;
{
gwrblk(blk, len, fn)
register char *blk;
{
- register int ret;
-
- /* call ultouch occasionally -- rti!trt */
+#if !defined(BSD4_2) && !defined(USG)
+ /* call ultouch occasionally */
if (--tc < 0) {
tc = TC;
ultouch();
}
if (--tc < 0) {
tc = TC;
ultouch();
}
- ret = pkwrite(Pk, blk, len);
- return
ret
;
+#endif !BSD4_2 && !USG
+ return
pkwrite(Pk, blk, len)
;
}
}