+/*
+ * Copyright (c) 1983, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * %sccs.include.redist.c%
+ */
+
+#ifndef lint
+static char copyright[] =
+"@(#) Copyright (c) 1983, 1993\n\
+ The Regents of the University of California. All rights reserved.\n";
+#endif /* not lint */
+
#define SSIZE 64
char device[SSIZE];
char count[SSIZE], mode[SSIZE], pos[SSIZE], op[SSIZE];
#define SSIZE 64
char device[SSIZE];
char count[SSIZE], mode[SSIZE], pos[SSIZE], op[SSIZE];
FILE *debug;
#define DEBUG(f) if (debug) fprintf(debug, f)
#define DEBUG1(f,a) if (debug) fprintf(debug, f, a)
#define DEBUG2(f,a1,a2) if (debug) fprintf(debug, f, a1, a2)
FILE *debug;
#define DEBUG(f) if (debug) fprintf(debug, f)
#define DEBUG1(f,a) if (debug) fprintf(debug, f, a)
#define DEBUG2(f,a1,a2) if (debug) fprintf(debug, f, a1, a2)
DEBUG2("rmtd: O %s %s\n", device, mode);
tape = open(device, atoi(mode));
if (tape < 0)
DEBUG2("rmtd: O %s %s\n", device, mode);
tape = open(device, atoi(mode));
if (tape < 0)
for (i = 0; i < n; i += cc) {
cc = read(0, &record[i], n - i);
if (cc <= 0) {
DEBUG("rmtd: premature eof\n");
for (i = 0; i < n; i += cc) {
cc = read(0, &record[i], n - i);
if (cc <= 0) {
DEBUG("rmtd: premature eof\n");
- (void) sprintf(resp, "A%d\n", rval);
- (void) write(1, resp, strlen(resp));
- (void) write(1, record, rval);
+ (void)sprintf(resp, "A%d\n", rval);
+ (void)write(1, resp, strlen(resp));
+ (void)write(1, record, rval);
- (void) write(1, (char *)&mtget, sizeof (mtget));
- goto respond;
+ (void)sprintf(resp, "A%d\n", rval);
+ (void)write(1, resp, strlen(resp));
+ (void)write(1, (char *)&mtget, sizeof (mtget));
+ goto top;
- (void) sprintf(resp, "A%d\n", rval);
- (void) write(1, resp, strlen(resp));
+ (void)sprintf(resp, "A%d\n", rval);
+ (void)write(1, resp, strlen(resp));
+char *
+checkbuf(record, size)
+ char *record;
+ int size;
+{
+
+ if (size <= maxrecsize)
+ return (record);
+ if (record != 0)
+ free(record);
+ record = malloc(size);
+ if (record == 0) {
+ DEBUG("rmtd: cannot allocate buffer space\n");
+ exit(4);
+ }
+ maxrecsize = size;
+ while (size > 1024 &&
+ setsockopt(0, SOL_SOCKET, SO_RCVBUF, &size, sizeof (size)) < 0)
+ size -= 1024;
+ return (record);
+}
+
+void
- DEBUG2("rmtd: E %d (%s)\n", num, sys_errlist[num]);
- (void) sprintf(resp, "E%d\n%s\n", num, sys_errlist[num]);
- (void) write(1, resp, strlen (resp));
+ DEBUG2("rmtd: E %d (%s)\n", num, strerror(num));
+ (void)sprintf(resp, "E%d\n%s\n", num, strerror(num));
+ (void)write(1, resp, strlen(resp));