mirror of
https://github.com/PDP-10/klh10.git
synced 2026-01-11 23:52:54 +00:00
Rename FILE *logf and static void log(char *fmt, ...)
because gcc complains about them: vdkfmt.c:133:7: warning: built-in function 'logf' declared as non-function tapedd.c:246:7: warning: built-in function 'logf' declared as non-function enaddr.c:174:13: warning: conflicting types for built-in function 'log' even though it probably should not. <math.h> has not been included as far as I can see.
This commit is contained in:
parent
9800c5b768
commit
d59d61451c
@ -171,7 +171,7 @@ char *log_strerror(err)
|
||||
|
||||
|
||||
|
||||
static void log(char *fmt, ...)
|
||||
static void logit(char *fmt, ...)
|
||||
{
|
||||
fprintf(stderr, "[%s: ", log_progname);
|
||||
{
|
||||
@ -255,7 +255,7 @@ static void logfatal_ser(int num, char *fmt, ...)
|
||||
|
||||
|
||||
#define dp_strerror log_strerror
|
||||
#define dbprint log
|
||||
#define dbprint logit
|
||||
#define dbprintln logln
|
||||
#define error logerror
|
||||
#define syserr logerror_ser
|
||||
|
||||
116
src/tapedd.c
116
src/tapedd.c
@ -243,7 +243,7 @@ long sw_recskip = 0;
|
||||
long sw_fileskip = 0;
|
||||
rsiz_t sw_bothsiz = 0;
|
||||
char *sw_logpath = NULL;
|
||||
FILE *logf = NULL;
|
||||
FILE *logfile = NULL;
|
||||
|
||||
struct dev {
|
||||
char *d_pname; /* Print name, "In" or "Out" */
|
||||
@ -363,7 +363,7 @@ os_strerror(int err)
|
||||
|
||||
void errhan(void *arg, struct vmtape *t, char *s)
|
||||
{
|
||||
fprintf(logf, "; %s: %s\n", t->mt_devname, s);
|
||||
fprintf(logfile, "; %s: %s\n", t->mt_devname, s);
|
||||
}
|
||||
|
||||
|
||||
@ -371,7 +371,7 @@ void efatal(char *errmsg) /* print error message and exit */
|
||||
/* error message string */
|
||||
{
|
||||
fflush(stdout);
|
||||
fprintf(logf, "\n?%s\n",errmsg);
|
||||
fprintf(logfile, "\n?%s\n",errmsg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -384,7 +384,7 @@ main(int argc, char **argv)
|
||||
register struct dev *d;
|
||||
int ret;
|
||||
|
||||
logf = stderr;
|
||||
logfile = stderr;
|
||||
signal(SIGINT, exit); /* Allow int to terminate log files etc */
|
||||
|
||||
vmt_init(&dvi.d_vmt, "TapeIn");
|
||||
@ -399,11 +399,11 @@ main(int argc, char **argv)
|
||||
|
||||
|
||||
if (!sw_logpath)
|
||||
logf = stderr;
|
||||
logfile = stderr;
|
||||
else {
|
||||
if ((logf = fopen(sw_logpath, "w")) == NULL) {
|
||||
logf = stderr;
|
||||
fprintf(logf, "; Cannot open log file \"%s\", using stderr.\n",
|
||||
if ((logfile = fopen(sw_logpath, "w")) == NULL) {
|
||||
logfile = stderr;
|
||||
fprintf(logfile, "; Cannot open log file \"%s\", using stderr.\n",
|
||||
sw_logpath);
|
||||
}
|
||||
}
|
||||
@ -420,26 +420,26 @@ main(int argc, char **argv)
|
||||
if (!dvo.d_recsiz) dvo.d_recsiz = sw_bothsiz;
|
||||
if (sw_verbose) {
|
||||
#define LOGTAPE(d,name) \
|
||||
fprintf(logf, "; %s tape spec \"%s\" (Type: %s", \
|
||||
fprintf(logfile, "; %s tape spec \"%s\" (Type: %s", \
|
||||
name, (d).d_path, mtypstr[(d).d_istape]); \
|
||||
if ((d).d_istape == MTYP_VIRT) \
|
||||
fprintf(logf, " format: %s", vmt_fmtname((d).d_vfmt)); \
|
||||
fprintf(logf, ")\n")
|
||||
fprintf(logfile, " format: %s", vmt_fmtname((d).d_vfmt)); \
|
||||
fprintf(logfile, ")\n")
|
||||
|
||||
LOGTAPE(dvi, " Input");
|
||||
LOGTAPE(dvo, "Output");
|
||||
#undef LOGTAPE
|
||||
|
||||
if (dvi.d_recsiz)
|
||||
fprintf(logf, "; Input record size %ld\n", (long)dvi.d_recsiz);
|
||||
fprintf(logfile, "; Input record size %ld\n", (long)dvi.d_recsiz);
|
||||
if (dvo.d_recsiz)
|
||||
fprintf(logf, "; Output record size %ld\n", (long)dvo.d_recsiz);
|
||||
fprintf(logfile, "; Output record size %ld\n", (long)dvo.d_recsiz);
|
||||
if (sw_maxfile)
|
||||
fprintf(logf, "; Max tapemarks (files) to process: %ld\n", sw_maxfile);
|
||||
fprintf(logfile, "; Max tapemarks (files) to process: %ld\n", sw_maxfile);
|
||||
if (sw_maxrec)
|
||||
fprintf(logf, "; Max records to process: %ld\n", sw_maxrec);
|
||||
fprintf(logfile, "; Max records to process: %ld\n", sw_maxrec);
|
||||
if (sw_logpath)
|
||||
fprintf(logf, "; Using logging path %s\n", sw_logpath);
|
||||
fprintf(logfile, "; Using logging path %s\n", sw_logpath);
|
||||
}
|
||||
|
||||
/* Open I/O files as appropriate */
|
||||
@ -472,25 +472,25 @@ main(int argc, char **argv)
|
||||
|
||||
|
||||
/* Do it! */
|
||||
fprintf(logf, "; Copying from \"%s\" to \"%s\"...\n", dvi.d_path,
|
||||
fprintf(logfile, "; Copying from \"%s\" to \"%s\"...\n", dvi.d_path,
|
||||
dvo.d_path ? dvo.d_path : NULLDEV);
|
||||
if (!docopy()) {
|
||||
fprintf(logf, "; Stopped unexpectedly.\n");
|
||||
fprintf(logfile, "; Stopped unexpectedly.\n");
|
||||
ret = FALSE;
|
||||
}
|
||||
if (!devclose(&dvo)) {
|
||||
fprintf(logf, "; Error closing output.\n");
|
||||
fprintf(logfile, "; Error closing output.\n");
|
||||
ret = FALSE;
|
||||
}
|
||||
for (d = &dvi; d; d = (d == &dvi) ? &dvo : NULL) {
|
||||
if (d->d_istape)
|
||||
fprintf(logf, "; %3s: %ld+%ld errs, %ld files, %ld recs, %"
|
||||
fprintf(logfile, "; %3s: %ld+%ld errs, %ld files, %ld recs, %"
|
||||
VMTAPE_POS_FMT "d bytes\n",
|
||||
d->d_pname, d->mta_herr, d->mta_serr,
|
||||
d->d_files, d->d_recs, d->d_tloc);
|
||||
}
|
||||
|
||||
fclose(logf);
|
||||
fclose(logfile);
|
||||
exit(ret ? 0 : 1);
|
||||
}
|
||||
|
||||
@ -537,7 +537,7 @@ int docopy(void)
|
||||
if (vmt_framecnt(&dvi.d_vmt)) {
|
||||
if (!devwrite(&dvo, dvi.d_buff,
|
||||
(rsiz_t)vmt_framecnt(&dvi.d_vmt))) {
|
||||
fprintf(logf, "; Stopped due to output write error: %s\n",
|
||||
fprintf(logfile, "; Stopped due to output write error: %s\n",
|
||||
os_strerror(-1));
|
||||
ret = FALSE;
|
||||
break;
|
||||
@ -576,7 +576,7 @@ int docopy(void)
|
||||
}
|
||||
|
||||
if (err < 0) {
|
||||
fprintf(logf, "; Stopped due to input read error: %s\n",
|
||||
fprintf(logfile, "; Stopped due to input read error: %s\n",
|
||||
os_strerror(-1));
|
||||
ret = FALSE;
|
||||
}
|
||||
@ -603,11 +603,11 @@ do_tdtest(void)
|
||||
char *errstr = NULL;
|
||||
|
||||
if (!dvi.d_cpath) {
|
||||
fprintf(logf, "; No input tape directory specified\n");
|
||||
fprintf(logfile, "; No input tape directory specified\n");
|
||||
return 1;
|
||||
}
|
||||
if (!dvo.d_cpath) {
|
||||
fprintf(logf, "; No output tape directory specified\n");
|
||||
fprintf(logfile, "; No output tape directory specified\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -629,7 +629,7 @@ do_tdtest(void)
|
||||
}
|
||||
|
||||
if (errstr) {
|
||||
fprintf(logf,"; Problem with tape desc file \"%s\": %s\n",
|
||||
fprintf(logfile,"; Problem with tape desc file \"%s\": %s\n",
|
||||
dvi.d_cpath, errstr);
|
||||
return 1;
|
||||
}
|
||||
@ -638,7 +638,7 @@ do_tdtest(void)
|
||||
if (strcmp(dvo.d_cpath, "") == 0) {
|
||||
tdof = stdout;
|
||||
} else if ((tdof = fopen(dvo.d_cpath, "w")) == NULL) {
|
||||
fprintf(logf,"Cannot open tape desc file \"%s\": %s\n",
|
||||
fprintf(logfile,"Cannot open tape desc file \"%s\": %s\n",
|
||||
dvo.d_cpath, os_strerror(-1));
|
||||
return FALSE;
|
||||
}
|
||||
@ -880,7 +880,7 @@ int devopen(register struct dev *d, int wrtf)
|
||||
strncpy(v.vmta_datpath, d->d_rpath, sizeof(v.vmta_datpath));
|
||||
}
|
||||
if (!vmt_attrmount(&d->d_vmt, &v)) { /* Try mounting it */
|
||||
fprintf(logf, "; Couldn't mount %sput virtual tape: %s\n",
|
||||
fprintf(logfile, "; Couldn't mount %sput virtual tape: %s\n",
|
||||
d->d_pname, d->d_path);
|
||||
return FALSE;
|
||||
}
|
||||
@ -898,7 +898,7 @@ int devopen(register struct dev *d, int wrtf)
|
||||
char *s;
|
||||
rpath = malloc(strlen(d->d_path)+4+1);
|
||||
if (!rpath) {
|
||||
fprintf(logf, "; Cannot malloc data filename\n");
|
||||
fprintf(logfile, "; Cannot malloc data filename\n");
|
||||
return FALSE;
|
||||
}
|
||||
strcpy(rpath, d->d_path);
|
||||
@ -915,7 +915,7 @@ int devopen(register struct dev *d, int wrtf)
|
||||
** the tapedesc or rawdata path was explicitly given.
|
||||
*/
|
||||
if (!vmt_xmount(&(d->d_vmt), d->d_cpath, d->d_rpath, wrtf)) {
|
||||
fprintf(logf, "; Couldn't mount %sput virtual tape: %s\n",
|
||||
fprintf(logfile, "; Couldn't mount %sput virtual tape: %s\n",
|
||||
d->d_pname, d->d_path);
|
||||
return FALSE;
|
||||
}
|
||||
@ -937,7 +937,7 @@ int devopen(register struct dev *d, int wrtf)
|
||||
if (strcmp(d->d_rpath, "") == 0) {
|
||||
d->d_fd = wrtf ? FD_STDOUT : FD_STDIN;
|
||||
} else if (!os_mtopen(d, wrtf)) {
|
||||
fprintf(logf, "; Cannot open %sput: %s\n",
|
||||
fprintf(logfile, "; Cannot open %sput: %s\n",
|
||||
d->d_pname, os_strerror(-1));
|
||||
return FALSE;
|
||||
}
|
||||
@ -962,27 +962,27 @@ int devopen(register struct dev *d, int wrtf)
|
||||
if (d->d_cpath) {
|
||||
|
||||
if (!(d->d_vmt.mt_filename = dupcstr(d->d_cpath))) {
|
||||
fprintf(logf, "; malloc failed for cpath dupcstr\n");
|
||||
fprintf(logfile, "; malloc failed for cpath dupcstr\n");
|
||||
return FALSE;
|
||||
}
|
||||
if (strcmp(d->d_cpath, "") == 0) {
|
||||
d->d_vmt.mt_ctlf = (wrtf ? stdout : stdin);
|
||||
} else if ((d->d_vmt.mt_ctlf =
|
||||
fopen(d->d_cpath, (wrtf ? "w" : "r"))) == NULL) {
|
||||
fprintf(logf,"Cannot open tape desc file \"%s\": %s\n",
|
||||
fprintf(logfile,"Cannot open tape desc file \"%s\": %s\n",
|
||||
d->d_cpath, os_strerror(-1));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Tape-desc file open, now parse it if reading */
|
||||
if (!wrtf && !tdr_scan(&(d->d_vmt), d->d_vmt.mt_ctlf, d->d_cpath)) {
|
||||
fprintf(logf, "; Cannot parse tape desc\n");
|
||||
fprintf(logfile, "; Cannot parse tape desc\n");
|
||||
return FALSE;
|
||||
}
|
||||
/* Do final setup if writing */
|
||||
if (wrtf && d->d_rpath) {
|
||||
if (!(d->d_vmt.mt_datpath = dupcstr(d->d_rpath))) {
|
||||
fprintf(logf, "; malloc failed for rpath dupcstr\n");
|
||||
fprintf(logfile, "; malloc failed for rpath dupcstr\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@ -997,7 +997,7 @@ int devopen(register struct dev *d, int wrtf)
|
||||
if (d->d_blen <= d->d_recsiz) /* If it's bigger, */
|
||||
d->d_blen = d->d_recsiz; /* adjust quietly */
|
||||
else /* else warn user */
|
||||
fprintf(logf, "; Tapedir forcing larger %sput record size (%ld instead of %ld)\n",
|
||||
fprintf(logfile, "; Tapedir forcing larger %sput record size (%ld instead of %ld)\n",
|
||||
d->d_pname, (long)d->d_blen, (long)d->d_recsiz);
|
||||
|
||||
}
|
||||
@ -1029,7 +1029,7 @@ int devbuffer(struct dev *d, char *buffp, rsiz_t blen)
|
||||
*/
|
||||
blen = (blen + 511) & ~511; /* Relies on fact 512 is power of 2 */
|
||||
if ((buffp = malloc(blen)) == NULL) {
|
||||
fprintf(logf, "; Cannot malloc %sput buffer (size %ld)\n",
|
||||
fprintf(logfile, "; Cannot malloc %sput buffer (size %ld)\n",
|
||||
d->d_pname, blen);
|
||||
return FALSE;
|
||||
}
|
||||
@ -1091,7 +1091,7 @@ int devread(struct dev *d)
|
||||
/* Still to do? Handle dir-only case, plus dir+dev case? */
|
||||
ret = os_mtread(d); /* Attempt read from device */
|
||||
if (ret < 0) {
|
||||
fprintf(logf, "; %sput device read error: %s\n",
|
||||
fprintf(logfile, "; %sput device read error: %s\n",
|
||||
d->d_pname, os_strerror(-1));
|
||||
return ret;
|
||||
}
|
||||
@ -1161,7 +1161,7 @@ int devwerr(struct dev *d, int err)
|
||||
|
||||
if (d->d_cpath) { /* Have tapedir? */
|
||||
if (!td_recapp(&d->d_vmt.mt_tdr, (long)0, 0, err)) {
|
||||
fprintf(logf, "devwerr: td_recapp malloc failed");
|
||||
fprintf(logfile, "devwerr: td_recapp malloc failed");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -1178,7 +1178,7 @@ int devweof(struct dev *d)
|
||||
else {
|
||||
if (d->d_cpath) { /* Have tapedir? */
|
||||
if (!td_recapp(&d->d_vmt.mt_tdr, (long)0, 1, 0)) {
|
||||
fprintf(logf, "devweof: td_recapp malloc failed");
|
||||
fprintf(logfile, "devweof: td_recapp malloc failed");
|
||||
ret = FALSE;
|
||||
}
|
||||
}
|
||||
@ -1276,7 +1276,7 @@ int os_mtread(struct dev *dp)
|
||||
acs[1] = dp->d_fd;
|
||||
acs[2] = (int)&iov;
|
||||
if (jsys(DUMPI, acs) > 0) {
|
||||
fprintf(logf, "; Warning: DUMPI won for max rec size %ld!\n",
|
||||
fprintf(logfile, "; Warning: DUMPI won for max rec size %ld!\n",
|
||||
(long)dp->d_blen);
|
||||
dp->mta_frms = dp->d_blen;
|
||||
return 1;
|
||||
@ -1287,14 +1287,14 @@ int os_mtread(struct dev *dp)
|
||||
case monsym("IOX5"): /* Device or data error (rec length) */
|
||||
acs[1] = dp->d_fd;
|
||||
if (jsys(GDSTS, acs) <= 0) {
|
||||
fprintf(logf, "; Tape GDSTS%% error: %s\n", os_strerror(-1));
|
||||
fprintf(logfile, "; Tape GDSTS%% error: %s\n", os_strerror(-1));
|
||||
os_mtclrerr(dp->d_fd);
|
||||
dp->mta_herr++;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
fprintf(logf, "; Tape DUMPI%% error: %s\n", os_strerror(-1));
|
||||
fprintf(logfile, "; Tape DUMPI%% error: %s\n", os_strerror(-1));
|
||||
os_mtclrerr(dp->d_fd);
|
||||
dp->mta_herr++;
|
||||
return 0;
|
||||
@ -1302,7 +1302,7 @@ int os_mtread(struct dev *dp)
|
||||
|
||||
/* Analyze "error". acs[2] has flags, [3] has count in LH */
|
||||
flgs = acs[2];
|
||||
t20status(dp, logf, flgs, acs[3]);
|
||||
t20status(dp, logfile, flgs, acs[3]);
|
||||
dp->mta_frms = ((unsigned)acs[3]) >> 18; /* Find cnt of data */
|
||||
|
||||
/* Opening in industry-compatible mode apparently works to force use of
|
||||
@ -1310,7 +1310,7 @@ int os_mtread(struct dev *dp)
|
||||
/* dp->mta_frms *= sizeof(int); */
|
||||
os_mtclrerr(dp->d_fd);
|
||||
if (flgs & (MT_DVE|MT_DAE)) {
|
||||
fprintf(logf, "; Tape error: %s\n",
|
||||
fprintf(logfile, "; Tape error: %s\n",
|
||||
(flgs & MT_DVE) ? "Device" : "Data");
|
||||
dp->mta_serr++;
|
||||
continue; /* Try again */
|
||||
@ -1339,14 +1339,14 @@ int os_mtread(struct dev *dp)
|
||||
if (dp->mta_frms <= 0) {
|
||||
case -1: /* Error */
|
||||
dp->mta_serr++;
|
||||
fprintf(logf, "; Tape read error: %s\n", os_strerror(-1));
|
||||
os_mtstatus(dp, logf); /* Show full status */
|
||||
fprintf(logfile, "; Tape read error: %s\n", os_strerror(-1));
|
||||
os_mtstatus(dp, logfile); /* Show full status */
|
||||
if (retry <= 0) {
|
||||
if (os_mtfsr(dp)) { /* Try spacing over 1 rec */
|
||||
retry = dp->mta_retry;
|
||||
dp->mta_herr++;
|
||||
} else {
|
||||
fprintf(logf, "; Cannot proceed past read error, aborting...\n");
|
||||
fprintf(logfile, "; Cannot proceed past read error, aborting...\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -1365,7 +1365,7 @@ int os_mtread(struct dev *dp)
|
||||
}
|
||||
} else
|
||||
if (dp->mta_frms >= dp->d_blen)
|
||||
fprintf(logf, "; Warning: read max rec size %ld!\n",
|
||||
fprintf(logfile, "; Warning: read max rec size %ld!\n",
|
||||
dp->mta_frms);
|
||||
|
||||
|
||||
@ -1397,7 +1397,7 @@ int os_mtwrite(struct dev *dp)
|
||||
}
|
||||
/* Error return */
|
||||
dp->mta_serr++;
|
||||
fprintf(logf, "; Tape DUMPO%% error: %s\n", os_strerror(-1));
|
||||
fprintf(logfile, "; Tape DUMPO%% error: %s\n", os_strerror(-1));
|
||||
os_mtclrerr(dp->d_fd);
|
||||
dp->mta_herr++;
|
||||
return 0;
|
||||
@ -1415,10 +1415,10 @@ int os_mtwrite(struct dev *dp)
|
||||
if (dp->d_istape == MTYP_QIC) {
|
||||
full = (used + 0777) & ~0777; /* Round up to 512-byte boundary */
|
||||
if (used < dp->d_recsiz)
|
||||
fprintf(logf, "; Warning: partial record padded out (%ld => %ld)\n",
|
||||
fprintf(logfile, "; Warning: partial record padded out (%ld => %ld)\n",
|
||||
(long)used, (long)full);
|
||||
if (full > dp->d_blen) {
|
||||
fprintf(logf, "; Internal bug: padout exceeds buffer (%ld > %ld)\n",
|
||||
fprintf(logfile, "; Internal bug: padout exceeds buffer (%ld > %ld)\n",
|
||||
(long)full, (long)dp->d_blen);
|
||||
full = dp->d_blen;
|
||||
}
|
||||
@ -1437,12 +1437,12 @@ int os_mtwrite(struct dev *dp)
|
||||
}
|
||||
/* Error of some kind */
|
||||
dp->mta_serr++;
|
||||
fprintf(logf, "; (Rec %ld, try %d) ",
|
||||
fprintf(logfile, "; (Rec %ld, try %d) ",
|
||||
dp->d_recs, dp->mta_retry - retry);
|
||||
if (ret < 0) {
|
||||
fprintf(logf, "Tape write error: %s\n", os_strerror(-1));
|
||||
fprintf(logfile, "Tape write error: %s\n", os_strerror(-1));
|
||||
} else {
|
||||
fprintf(logf, "Tape write truncated: %d, shd be %ld\n",
|
||||
fprintf(logfile, "Tape write truncated: %d, shd be %ld\n",
|
||||
ret, (long)used);
|
||||
if (ret > 0) {
|
||||
used -= ret; /* Update to write out rest */
|
||||
@ -1452,7 +1452,7 @@ int os_mtwrite(struct dev *dp)
|
||||
dp->mta_frms += ret;
|
||||
}
|
||||
}
|
||||
os_mtstatus(dp, logf); /* Show full status */
|
||||
os_mtstatus(dp, logfile); /* Show full status */
|
||||
} while (--retry > 0); /* Continue N times */
|
||||
dp->mta_herr++;
|
||||
#endif
|
||||
@ -1471,7 +1471,7 @@ int os_mtweof(struct dev *dp) /* Write a tapemark */
|
||||
mtcmd.mt_op = MTWEOF;
|
||||
mtcmd.mt_count = 1;
|
||||
if (ioctl(dp->d_fd, MTIOCTOP, &mtcmd) < 0) {
|
||||
fprintf(logf, "; MTWEOF ioctl failed: %s\n", os_strerror(-1));
|
||||
fprintf(logfile, "; MTWEOF ioctl failed: %s\n", os_strerror(-1));
|
||||
dp->mta_herr++;
|
||||
return FALSE;
|
||||
}
|
||||
@ -1491,7 +1491,7 @@ int os_mtfsr(struct dev *dp) /* Forward Space Record (to inter-record gap)*/
|
||||
mtcmd.mt_op = MTFSR;
|
||||
mtcmd.mt_count = 1;
|
||||
if (ioctl(dp->d_fd, MTIOCTOP, &mtcmd) < 0) {
|
||||
fprintf(logf, "; MTFSR ioctl failed: %s\n", os_strerror(-1));
|
||||
fprintf(logfile, "; MTFSR ioctl failed: %s\n", os_strerror(-1));
|
||||
dp->mta_herr++;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
60
src/vdkfmt.c
60
src/vdkfmt.c
@ -130,7 +130,7 @@ int sw_verbose;
|
||||
int sw_maxsec;
|
||||
int sw_maxfile;
|
||||
char *sw_logpath;
|
||||
FILE *logf;
|
||||
FILE *logfile;
|
||||
|
||||
#define DBGFLG sw_verbose
|
||||
|
||||
@ -244,7 +244,7 @@ os_strerror(int err)
|
||||
|
||||
void errhan(struct vdk_unit *t, char *s)
|
||||
{
|
||||
fprintf(logf, "; %s: %s\n", t->dk_devname, s);
|
||||
fprintf(logfile, "; %s: %s\n", t->dk_devname, s);
|
||||
}
|
||||
|
||||
|
||||
@ -252,7 +252,7 @@ void efatal(char *errmsg) /* print error message and exit */
|
||||
/* error message string */
|
||||
{
|
||||
fflush(stdout);
|
||||
fprintf(logf, "\n?%s\n",errmsg);
|
||||
fprintf(logfile, "\n?%s\n",errmsg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -262,7 +262,7 @@ main(int argc, char **argv)
|
||||
{
|
||||
int ret;
|
||||
|
||||
logf = stderr;
|
||||
logfile = stderr;
|
||||
signal(SIGINT, exit); /* Allow int to terminate log files etc */
|
||||
|
||||
dvi.d_fmt = dvo.d_fmt = -1;
|
||||
@ -272,11 +272,11 @@ main(int argc, char **argv)
|
||||
|
||||
|
||||
if (!sw_logpath)
|
||||
logf = stderr;
|
||||
logfile = stderr;
|
||||
else {
|
||||
if ((logf = fopen(sw_logpath, "w")) == NULL) {
|
||||
logf = stderr;
|
||||
fprintf(logf, "; Cannot open log file \"%s\", using stderr.\n",
|
||||
if ((logfile = fopen(sw_logpath, "w")) == NULL) {
|
||||
logfile = stderr;
|
||||
fprintf(logfile, "; Cannot open log file \"%s\", using stderr.\n",
|
||||
sw_logpath);
|
||||
}
|
||||
}
|
||||
@ -287,23 +287,23 @@ main(int argc, char **argv)
|
||||
dvi.d_dcf.dcf_ntrk *
|
||||
dvi.d_dcf.dcf_ncyl;
|
||||
if (sw_verbose) {
|
||||
fprintf(logf, "; Input disk spec \"%s\" (Type: %s) Format: %s\n",
|
||||
fprintf(logfile, "; Input disk spec \"%s\" (Type: %s) Format: %s\n",
|
||||
dvi.d_path, mtypstr[dvi.d_isdisk],
|
||||
fmttab[dvi.d_fmt]);
|
||||
fprintf(logf, "; Output disk spec \"%s\" (Type: %s) Format: %s\n",
|
||||
fprintf(logfile, "; Output disk spec \"%s\" (Type: %s) Format: %s\n",
|
||||
dvo.d_path, mtypstr[dvo.d_isdisk],
|
||||
fmttab[dvo.d_fmt]);
|
||||
|
||||
/* Show config info here */
|
||||
fprintf(logf, "; Drive type: %s\n", dvi.d_dcf.dcf_name);
|
||||
fprintf(logf, "; %ld sectors, %d wds/sec\n", dvi.d_totsec,
|
||||
fprintf(logfile, "; Drive type: %s\n", dvi.d_dcf.dcf_name);
|
||||
fprintf(logfile, "; %ld sectors, %d wds/sec\n", dvi.d_totsec,
|
||||
dvi.d_dcf.dcf_nwds);
|
||||
fprintf(logf, "; (%d secs, %d trks, %d cyls\n",
|
||||
fprintf(logfile, "; (%d secs, %d trks, %d cyls\n",
|
||||
dvi.d_dcf.dcf_nsec,
|
||||
dvi.d_dcf.dcf_ntrk,
|
||||
dvi.d_dcf.dcf_ncyl);
|
||||
if (sw_logpath)
|
||||
fprintf(logf, "; Using logging path %s\n", sw_logpath);
|
||||
fprintf(logfile, "; Using logging path %s\n", sw_logpath);
|
||||
}
|
||||
|
||||
/* Open I/O files as appropriate */
|
||||
@ -313,27 +313,27 @@ main(int argc, char **argv)
|
||||
exit(1);
|
||||
|
||||
/* Do it! */
|
||||
fprintf(logf, "; Copying from \"%s\" to \"%s\"...\n", dvi.d_path,
|
||||
fprintf(logfile, "; Copying from \"%s\" to \"%s\"...\n", dvi.d_path,
|
||||
dvo.d_path ? dvo.d_path : NULLDEV);
|
||||
if (ret = docopy())
|
||||
ret = devclose(&dvo);
|
||||
else (void) devclose(&dvo);
|
||||
|
||||
if (!ret) fprintf(logf, "; Stopped unexpectedly.\n");
|
||||
if (!ret) fprintf(logfile, "; Stopped unexpectedly.\n");
|
||||
|
||||
#if 0
|
||||
{
|
||||
register struct devdk *d;
|
||||
for (d = &dvi; d; d = (d == &dvi) ? &dvo : NULL) {
|
||||
if (d->d_isdisk)
|
||||
fprintf(logf, "; %s: %d+%d errs, %d secs, %ld bytes\n",
|
||||
fprintf(logfile, "; %s: %d+%d errs, %d secs, %ld bytes\n",
|
||||
d->d_pname, d->mta_herr, d->mta_serr,
|
||||
d->d_secs, d->d_tloc);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
fclose(logf);
|
||||
fclose(logfile);
|
||||
exit(ret ? 0 : 1);
|
||||
}
|
||||
|
||||
@ -347,13 +347,13 @@ int docopy(void)
|
||||
int nwrt = 0;
|
||||
|
||||
if (DBGFLG)
|
||||
fprintf(logf, "; Pages:\n");
|
||||
fprintf(logfile, "; Pages:\n");
|
||||
|
||||
for (; nsect <= dvi.d_totsec;) {
|
||||
|
||||
err = devread(&dvi, nsect, wbuff); /* Get a sector */
|
||||
if (!err) {
|
||||
fprintf(logf, "; Aborting loop, last err: %s\n", os_strerror(-1));
|
||||
fprintf(logfile, "; Aborting loop, last err: %s\n", os_strerror(-1));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -366,7 +366,7 @@ int docopy(void)
|
||||
nwrt++;
|
||||
err = devwrite(&dvo, nsect, wbuff); /* Write a sector */
|
||||
if (!err) {
|
||||
fprintf(logf, "; Aborting loop, last err: %s\n",
|
||||
fprintf(logfile, "; Aborting loop, last err: %s\n",
|
||||
os_strerror(-1));
|
||||
return 0;
|
||||
}
|
||||
@ -377,14 +377,14 @@ int docopy(void)
|
||||
/* Hack to show nice pattern, one char per 4-sector page */
|
||||
if (DBGFLG) {
|
||||
if ((nsect & 03) == 0) {
|
||||
putc(pagsym[nwrt&03], logf);
|
||||
putc(pagsym[nwrt&03], logfile);
|
||||
nwrt = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (DBGFLG)
|
||||
fprintf(logf, "\n");
|
||||
fprintf(logfile, "\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -515,7 +515,7 @@ int devopen(register struct devdk *d, int wrtf)
|
||||
char *opath, *path;
|
||||
|
||||
if (!(opath = d->d_path) || !*opath) {
|
||||
fprintf(logf, "; Null mount path\n");
|
||||
fprintf(logfile, "; Null mount path\n");
|
||||
return FALSE;
|
||||
}
|
||||
path = malloc(strlen(opath)+1);
|
||||
@ -532,7 +532,7 @@ int devopen(register struct devdk *d, int wrtf)
|
||||
d->d_vdk.dk_nwds = d->d_dcf.dcf_nwds;
|
||||
|
||||
if (!vdk_mount(&(d->d_vdk), path, wrtf)) {
|
||||
fprintf(logf, "; Cannot mount device \"%s\": %s\n",
|
||||
fprintf(logfile, "; Cannot mount device \"%s\": %s\n",
|
||||
path, os_strerror(d->d_vdk.dk_err));
|
||||
free(path);
|
||||
return FALSE;
|
||||
@ -547,7 +547,7 @@ int devclose(struct devdk *d)
|
||||
int res = TRUE;
|
||||
|
||||
if (DBGFLG && d->d_path)
|
||||
fprintf(logf, "; Closing \"%s\"\n", d->d_path);
|
||||
fprintf(logfile, "; Closing \"%s\"\n", d->d_path);
|
||||
|
||||
if (d->d_isdisk) {
|
||||
res = vdk_unmount(&(d->d_vdk)); /* Close real disk */
|
||||
@ -570,14 +570,14 @@ int devread(struct devdk *d, long int daddr, w10_t *buff)
|
||||
|
||||
#if 0
|
||||
if (DBGFLG)
|
||||
fprintf(logf, "; read daddr=%ld\n", daddr);
|
||||
fprintf(logfile, "; read daddr=%ld\n", daddr);
|
||||
#endif
|
||||
|
||||
nsec = vdk_read(&d->d_vdk, buff, (uint32)daddr, 1);
|
||||
|
||||
if (d->d_vdk.dk_err
|
||||
|| (nsec != 1)) {
|
||||
fprintf(logf, "; read error on %s: %s\n",
|
||||
fprintf(logfile, "; read error on %s: %s\n",
|
||||
d->d_vdk.dk_filename, os_strerror(d->d_vdk.dk_err));
|
||||
return FALSE;
|
||||
}
|
||||
@ -592,14 +592,14 @@ int devwrite(struct devdk *d, long int daddr, w10_t *buff)
|
||||
|
||||
#if 0
|
||||
if (DBGFLG)
|
||||
fprintf(logf, "; write daddr=%ld\n", daddr);
|
||||
fprintf(logfile, "; write daddr=%ld\n", daddr);
|
||||
#endif
|
||||
|
||||
nsec = vdk_write(&d->d_vdk, buff, (uint32)daddr, 1);
|
||||
|
||||
if (d->d_vdk.dk_err
|
||||
|| (nsec != 1)) {
|
||||
fprintf(logf, "; write error on %s: %s\n",
|
||||
fprintf(logfile, "; write error on %s: %s\n",
|
||||
d->d_vdk.dk_filename, os_strerror(d->d_vdk.dk_err));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user