SCP: Add SET <dev|unit> APPEND|EOF to position to EOF
Sequential devices (LPT, PTR , PTP, etc.) can be positioned to EOF. Readable devices will encounter EOF on the next I/O operation. Writable devices will append. Either APPEND or EOF produce the same result independent of whether the device is opened for oread or write.
This commit is contained in:
parent
c22766b760
commit
083080e71d
1 changed files with 40 additions and 3 deletions
43
scp.c
43
scp.c
|
@ -464,6 +464,7 @@ t_stat set_dev_radix (DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
|
|||
t_stat set_dev_enbdis (DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
|
||||
t_stat set_dev_debug (DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
|
||||
t_stat set_unit_enbdis (DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
|
||||
t_stat set_unit_append (DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
|
||||
t_stat ssh_break (FILE *st, const char *cptr, int32 flg);
|
||||
t_stat show_cmd_fi (FILE *ofile, int32 flag, CONST char *cptr);
|
||||
t_stat show_config (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
|
||||
|
@ -2506,6 +2507,8 @@ static C1TAB set_dev_tab[] = {
|
|||
{ "DISABLED", &set_dev_enbdis, 0 },
|
||||
{ "DEBUG", &set_dev_debug, 1 },
|
||||
{ "NODEBUG", &set_dev_debug, 0 },
|
||||
{ "APPEND", &set_unit_append, 0 },
|
||||
{ "EOF", &set_unit_append, 0 },
|
||||
{ NULL, NULL, 0 }
|
||||
};
|
||||
|
||||
|
@ -2514,6 +2517,8 @@ static C1TAB set_unit_tab[] = {
|
|||
{ "DISABLED", &set_unit_enbdis, 0 },
|
||||
{ "DEBUG", &set_dev_debug, 2+1 },
|
||||
{ "NODEBUG", &set_dev_debug, 2+0 },
|
||||
{ "APPEND", &set_unit_append, 0 },
|
||||
{ "EOF", &set_unit_append, 0 },
|
||||
{ NULL, NULL, 0 }
|
||||
};
|
||||
|
||||
|
@ -3231,6 +3236,16 @@ if ((dptr->modifiers) && (dptr->units) && (enabled_units != 1)) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (enabled_units) {
|
||||
for (unit=0; unit < dptr->numunits; unit++)
|
||||
if ((!(dptr->units[unit].flags & UNIT_DIS)) &&
|
||||
(dptr->units[unit].flags & UNIT_SEQ) &&
|
||||
(!(dptr->units[unit].flags & UNIT_MUSTBUF))) {
|
||||
sprintf (buf, "set %s%s APPEND", sim_uname (&dptr->units[unit]), (enabled_units > 1) ? "n" : "");
|
||||
fprintf (st, "%-30s\tSets %s position to EOF\n", buf, sim_uname (&dptr->units[unit]), (enabled_units > 1) ? "n" : "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (deb_desc_available) {
|
||||
fprintf (st, "\n*%s device DEBUG settings:\n", sim_dname (dptr));
|
||||
for (dep = dptr->debflags; dep->name != NULL; dep++)
|
||||
|
@ -5560,7 +5575,7 @@ else {
|
|||
for (i = 0; i < dptr->numunits; i++) { /* check units */
|
||||
up = (dptr->units) + i; /* att or active? */
|
||||
if ((up->flags & UNIT_ATT) || sim_is_active (up))
|
||||
return SCPE_NOFNC; /* can't do it */
|
||||
return sim_messagef (SCPE_NOFNC, "%s has attached or busy units\n", sim_dname (dptr)); /* can't do it */
|
||||
}
|
||||
dptr->flags = dptr->flags | DEV_DIS; /* disable */
|
||||
}
|
||||
|
@ -5582,7 +5597,7 @@ if (flag) /* enb? enable */
|
|||
else {
|
||||
if ((uptr->flags & UNIT_ATT) || /* dsb */
|
||||
sim_is_active (uptr)) /* more tests */
|
||||
return SCPE_NOFNC;
|
||||
return sim_messagef (SCPE_NOFNC, "%s is attached or busy\n", sim_uname (uptr));
|
||||
uptr->flags = uptr->flags | UNIT_DIS; /* disable */
|
||||
}
|
||||
return SCPE_OK;
|
||||
|
@ -5639,6 +5654,25 @@ while (*cptr) {
|
|||
return r;
|
||||
}
|
||||
|
||||
/* Set sequential unit position to EOF */
|
||||
|
||||
t_stat set_unit_append (DEVICE *dptr, UNIT *uptr, int32 flags, CONST char *cptr)
|
||||
{
|
||||
if (!(uptr->flags & UNIT_SEQ))
|
||||
return sim_messagef (SCPE_NOFNC, "%s is not a sequential device.\n", sim_uname (uptr));
|
||||
if (uptr->flags & UNIT_BUF)
|
||||
return sim_messagef (SCPE_NOFNC, "Can't append to a buffered device %s.\n", sim_uname (uptr));
|
||||
if (!(uptr->flags & UNIT_ATT))
|
||||
return SCPE_UNATT;
|
||||
|
||||
if (0 == sim_fseek (uptr->fileref, 0, SEEK_END)) {
|
||||
uptr->pos = (t_addr)sim_ftell (uptr->fileref); /* Position at end of file */
|
||||
return SCPE_OK;
|
||||
}
|
||||
|
||||
return sim_messagef (SCPE_IERR, "%s Can't seek to end of file: %s - %s\n", sim_uname (uptr), uptr->filename, strerror (errno));
|
||||
}
|
||||
|
||||
/* Show command */
|
||||
|
||||
t_stat show_cmd (int32 flag, CONST char *cptr)
|
||||
|
@ -9266,7 +9300,10 @@ if (flag & EX_I) {
|
|||
return dfltinc;
|
||||
}
|
||||
if (uptr->flags & UNIT_RO) /* read only? */
|
||||
return SCPE_RO;
|
||||
return sim_messagef (SCPE_RO, "%s is read only.\n"
|
||||
"%sse a writable device to change %s\n",
|
||||
sim_uname (uptr), (uptr->flags & UNIT_ROABLE) ? "Attach Read/Write or u" : "U",
|
||||
uptr->filename ? uptr->filename : "it");
|
||||
mask = width_mask[dptr->dwidth];
|
||||
|
||||
GET_RADIX (rdx, dptr->dradix);
|
||||
|
|
Loading…
Add table
Reference in a new issue