SCP: Provide command context for messages emitted during ATTACH and DETACH
Context and non error messages will be suppressed in quiet mode or when -Q switch is explicitly supplied on command line
This commit is contained in:
parent
5b248cf7f4
commit
3d1f092573
4 changed files with 39 additions and 68 deletions
38
scp.c
38
scp.c
|
@ -582,6 +582,7 @@ static int32 sim_do_echo = 0; /* the echo status of th
|
|||
static int32 sim_show_message = 1; /* the message display status of the currently open do file */
|
||||
static int32 sim_on_inherit = 0; /* the inherit status of on state and conditions when executing do files */
|
||||
static int32 sim_do_depth = 0;
|
||||
static t_bool sim_cmd_echoed = FALSE; /* Command was emitted already prior to message output */
|
||||
|
||||
static int32 sim_on_check[MAX_DO_NEST_LVL+1];
|
||||
static char *sim_on_actions[MAX_DO_NEST_LVL+1][SCPE_MAX_ERR+1];
|
||||
|
@ -985,7 +986,7 @@ static const char simh_help[] =
|
|||
" attached read only, its contents can be examined but not modified.\n"
|
||||
"5-q\n"
|
||||
" If the -q switch is specified when creating a new file (-n) or opening one\n"
|
||||
" read only (-r), the message announcing this fact is suppressed.\n"
|
||||
" read only (-r), any messages announcing these facts will be suppressed.\n"
|
||||
"5-f\n"
|
||||
" For simulated magnetic tapes, the ATTACH command can specify the format of\n"
|
||||
" the attached tape image file:\n\n"
|
||||
|
@ -2283,6 +2284,7 @@ while (stat != SCPE_EXIT) { /* in case exit */
|
|||
}
|
||||
if (*cptr == 0) /* ignore blank */
|
||||
continue;
|
||||
sim_cmd_echoed = TRUE;
|
||||
sim_sub_args (cbuf, sizeof(cbuf), argv);
|
||||
if (sim_log) /* log cmd */
|
||||
fprintf (sim_log, "%s%s\n", sim_prompt, cptr);
|
||||
|
@ -3089,6 +3091,7 @@ do {
|
|||
continue;
|
||||
if (echo) /* echo if -v */
|
||||
sim_printf("%s> %s\n", do_position(), cptr);
|
||||
sim_cmd_echoed = echo;
|
||||
if (*cptr == ':') /* ignore label */
|
||||
continue;
|
||||
cptr = get_glyph_cmd (cptr, gbuf); /* get command glyph */
|
||||
|
@ -5958,18 +5961,14 @@ if ((sim_switches & SWMASK ('R')) || /* read only? */
|
|||
if (uptr->fileref == NULL) /* open fail? */
|
||||
return attach_err (uptr, SCPE_OPENERR); /* yes, error */
|
||||
uptr->flags = uptr->flags | UNIT_RO; /* set rd only */
|
||||
if (!sim_quiet && !(sim_switches & SWMASK ('Q'))) {
|
||||
sim_printf ("%s: unit is read only\n", sim_dname (dptr));
|
||||
}
|
||||
sim_messagef (SCPE_OK, "%s: unit is read only\n", sim_dname (dptr));
|
||||
}
|
||||
else {
|
||||
if (sim_switches & SWMASK ('N')) { /* new file only? */
|
||||
uptr->fileref = sim_fopen (cptr, "wb+"); /* open new file */
|
||||
if (uptr->fileref == NULL) /* open fail? */
|
||||
return attach_err (uptr, SCPE_OPENERR); /* yes, error */
|
||||
if (!sim_quiet && !(sim_switches & SWMASK ('Q'))) {
|
||||
sim_printf ("%s: creating new file\n", sim_dname (dptr));
|
||||
}
|
||||
sim_messagef (SCPE_OK, "%s: creating new file\n", sim_dname (dptr));
|
||||
}
|
||||
else { /* normal */
|
||||
uptr->fileref = sim_fopen (cptr, "rb+"); /* open r/w */
|
||||
|
@ -5985,9 +5984,7 @@ else {
|
|||
if (uptr->fileref == NULL) /* open fail? */
|
||||
return attach_err (uptr, SCPE_OPENERR); /* yes, error */
|
||||
uptr->flags = uptr->flags | UNIT_RO; /* set rd only */
|
||||
if (!sim_quiet) {
|
||||
sim_printf ("%s: unit is read only\n", sim_dname (dptr));
|
||||
}
|
||||
sim_messagef (SCPE_OK, "%s: unit is read only\n", sim_dname (dptr));
|
||||
}
|
||||
else { /* doesn't exist */
|
||||
if (sim_switches & SWMASK ('E')) /* must exist? */
|
||||
|
@ -5995,9 +5992,7 @@ else {
|
|||
uptr->fileref = sim_fopen (cptr, "wb+");/* open new file */
|
||||
if (uptr->fileref == NULL) /* open fail? */
|
||||
return attach_err (uptr, SCPE_OPENERR); /* yes, error */
|
||||
if (!sim_quiet) {
|
||||
sim_printf ("%s: creating new file\n", sim_dname (dptr));
|
||||
}
|
||||
sim_messagef (SCPE_OK, "%s: creating new file\n", sim_dname (dptr));
|
||||
}
|
||||
} /* end if null */
|
||||
} /* end else */
|
||||
|
@ -6008,9 +6003,7 @@ if (uptr->flags & UNIT_BUFABLE) { /* buffer? */
|
|||
uptr->filebuf = calloc (cap, SZ_D (dptr)); /* allocate */
|
||||
if (uptr->filebuf == NULL) /* no buffer? */
|
||||
return attach_err (uptr, SCPE_MEM); /* error */
|
||||
if (!sim_quiet) {
|
||||
sim_printf ("%s: buffering file in memory\n", sim_dname (dptr));
|
||||
}
|
||||
sim_messagef (SCPE_OK, "%s: buffering file in memory\n", sim_dname (dptr));
|
||||
uptr->hwmark = (uint32)sim_fread (uptr->filebuf, /* read file */
|
||||
SZ_D (dptr), cap, uptr->fileref);
|
||||
uptr->flags = uptr->flags | UNIT_BUF; /* set buffered */
|
||||
|
@ -6126,9 +6119,7 @@ if ((dptr = find_dev_from_unit (uptr)) == NULL)
|
|||
if ((uptr->flags & UNIT_BUF) && (uptr->filebuf)) {
|
||||
uint32 cap = (uptr->hwmark + dptr->aincr - 1) / dptr->aincr;
|
||||
if (uptr->hwmark && ((uptr->flags & UNIT_RO) == 0)) {
|
||||
if (!sim_quiet) {
|
||||
sim_printf ("%s: writing buffer to file\n", sim_dname (dptr));
|
||||
}
|
||||
sim_messagef (SCPE_OK, "%s: writing buffer to file\n", sim_dname (dptr));
|
||||
rewind (uptr->fileref);
|
||||
sim_fwrite (uptr->filebuf, SZ_D (dptr), cap, uptr->fileref);
|
||||
if (ferror (uptr->fileref))
|
||||
|
@ -11315,6 +11306,8 @@ int32 len;
|
|||
va_list arglist;
|
||||
t_bool inhibit_message = (!sim_show_message || (stat & SCPE_NOMESSAGE));
|
||||
|
||||
if ((stat == SCPE_OK) && (sim_quiet || (sim_switches & SWMASK ('Q'))))
|
||||
return stat;
|
||||
while (1) { /* format passed string, args */
|
||||
va_start (arglist, fmt);
|
||||
#if defined(NO_vsnprintf)
|
||||
|
@ -11341,10 +11334,11 @@ while (1) { /* format passed string, arg
|
|||
break;
|
||||
}
|
||||
|
||||
if ((sim_do_ocptr[sim_do_depth]) &&
|
||||
((stat & ~SCPE_NOMESSAGE) != SCPE_OK)) {
|
||||
if (!sim_do_echo && !sim_quiet && !inhibit_message)
|
||||
if (sim_do_ocptr[sim_do_depth]) {
|
||||
if (!sim_do_echo && !sim_quiet && !inhibit_message && !sim_cmd_echoed) {
|
||||
sim_printf("%s> %s\n", do_position(), sim_do_ocptr[sim_do_depth]);
|
||||
sim_cmd_echoed = TRUE;
|
||||
}
|
||||
else {
|
||||
if (sim_deb) { /* Always put context in debug output */
|
||||
TMLN *saved_oline = sim_oline;
|
||||
|
|
53
sim_disk.c
53
sim_disk.c
|
@ -1362,9 +1362,7 @@ if (sim_switches & SWMASK ('C')) { /* create vhd disk & cop
|
|||
sim_switches = saved_sim_switches;
|
||||
return sim_messagef (r, "Can't open source VHD: %s\n", cptr);
|
||||
}
|
||||
if (!sim_quiet) {
|
||||
sim_printf ("%s%d: creating new virtual disk '%s'\n", sim_dname (dptr), (int)(uptr-dptr->units), gbuf);
|
||||
}
|
||||
sim_messagef (SCPE_OK, "%s%d: creating new virtual disk '%s'\n", sim_dname (dptr), (int)(uptr-dptr->units), gbuf);
|
||||
capac_factor = ((dptr->dwidth / dptr->aincr) == 16) ? 2 : 1; /* capacity units (word: 2, byte: 1) */
|
||||
vhd = sim_vhd_disk_create (gbuf, ((t_offset)uptr->capac)*capac_factor*((dptr->flags & DEV_SECTORS) ? 512 : 1));
|
||||
if (!vhd) {
|
||||
|
@ -1383,8 +1381,7 @@ if (sim_switches & SWMASK ('C')) { /* create vhd disk & cop
|
|||
return SCPE_MEM;
|
||||
}
|
||||
for (lba = 0; (lba < total_sectors) && (r == SCPE_OK); lba += sects) {
|
||||
if (!sim_quiet)
|
||||
sim_printf ("%s%d: Copied %dMB. %d%% complete.\r", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000), (int)((((float)lba)*100)/total_sectors));
|
||||
sim_messagef (SCPE_OK, "%s%d: Copied %dMB. %d%% complete.\r", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000), (int)((((float)lba)*100)/total_sectors));
|
||||
sects = sectors_per_buffer;
|
||||
if (lba + sects > total_sectors)
|
||||
sects = total_sectors - lba;
|
||||
|
@ -1400,12 +1397,10 @@ if (sim_switches & SWMASK ('C')) { /* create vhd disk & cop
|
|||
uptr->flags = saved_unit_flags;
|
||||
}
|
||||
}
|
||||
if (!sim_quiet) {
|
||||
if (r == SCPE_OK)
|
||||
sim_printf ("\n%s%d: Copied %dMB. Done.\n", sim_dname (dptr), (int)(uptr-dptr->units), (int)(((t_offset)lba*sector_size)/1000000));
|
||||
else
|
||||
sim_printf ("\n%s%d: Error copying: %s.\n", sim_dname (dptr), (int)(uptr-dptr->units), sim_error_text (r));
|
||||
}
|
||||
if (r == SCPE_OK)
|
||||
sim_messagef (SCPE_OK, "\n%s%d: Copied %dMB. Done.\n", sim_dname (dptr), (int)(uptr-dptr->units), (int)(((t_offset)lba*sector_size)/1000000));
|
||||
else
|
||||
sim_messagef (r, "\n%s%d: Error copying: %s.\n", sim_dname (dptr), (int)(uptr-dptr->units), sim_error_text (r));
|
||||
if ((r == SCPE_OK) && (sim_switches & SWMASK ('V'))) {
|
||||
uint8 *verify_buf = (uint8*) malloc (1024*1024);
|
||||
|
||||
|
@ -1416,8 +1411,7 @@ if (sim_switches & SWMASK ('C')) { /* create vhd disk & cop
|
|||
return SCPE_MEM;
|
||||
}
|
||||
for (lba = 0; (lba < total_sectors) && (r == SCPE_OK); lba += sects) {
|
||||
if (!sim_quiet)
|
||||
sim_printf ("%s%d: Verified %dMB. %d%% complete.\r", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000), (int)((((float)lba)*100)/total_sectors));
|
||||
sim_messagef (SCPE_OK, "%s%d: Verified %dMB. %d%% complete.\r", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000), (int)((((float)lba)*100)/total_sectors));
|
||||
sects = sectors_per_buffer;
|
||||
if (lba + sects > total_sectors)
|
||||
sects = total_sectors - lba;
|
||||
|
@ -1439,7 +1433,7 @@ if (sim_switches & SWMASK ('C')) { /* create vhd disk & cop
|
|||
}
|
||||
if (!sim_quiet) {
|
||||
if (r == SCPE_OK)
|
||||
sim_printf ("\n%s%d: Verified %dMB. Done.\n", sim_dname (dptr), (int)(uptr-dptr->units), (int)(((t_offset)lba*sector_size)/1000000));
|
||||
sim_messagef (r, "\n%s%d: Verified %dMB. Done.\n", sim_dname (dptr), (int)(uptr-dptr->units), (int)(((t_offset)lba*sector_size)/1000000));
|
||||
else {
|
||||
t_lba i;
|
||||
uint32 save_dctrl = dptr->dctrl;
|
||||
|
@ -1544,9 +1538,7 @@ if ((sim_switches & SWMASK ('R')) || /* read only? */
|
|||
if (uptr->fileref == NULL) /* open fail? */
|
||||
return _err_return (uptr, SCPE_OPENERR); /* yes, error */
|
||||
uptr->flags = uptr->flags | UNIT_RO; /* set rd only */
|
||||
if (!sim_quiet) {
|
||||
sim_printf ("%s%d: unit is read only\n", sim_dname (dptr), (int)(uptr-dptr->units));
|
||||
}
|
||||
sim_messagef (SCPE_OK, "%s%d: unit is read only\n", sim_dname (dptr), (int)(uptr-dptr->units));
|
||||
}
|
||||
else { /* normal */
|
||||
uptr->fileref = open_function (cptr, "rb+"); /* open r/w */
|
||||
|
@ -1558,8 +1550,7 @@ else { /* normal */
|
|||
if (uptr->fileref == NULL) /* open fail? */
|
||||
return _err_return (uptr, SCPE_OPENERR);/* yes, error */
|
||||
uptr->flags = uptr->flags | UNIT_RO; /* set rd only */
|
||||
if (!sim_quiet)
|
||||
sim_printf ("%s%d: unit is read only\n", sim_dname (dptr), (int)(uptr-dptr->units));
|
||||
sim_messagef (SCPE_OK, "%s%d: unit is read only\n", sim_dname (dptr), (int)(uptr-dptr->units));
|
||||
}
|
||||
else { /* doesn't exist */
|
||||
if (sim_switches & SWMASK ('E')) /* must exist? */
|
||||
|
@ -1570,8 +1561,7 @@ else { /* normal */
|
|||
uptr->fileref = open_function (cptr, "wb+");/* open new file */
|
||||
if (uptr->fileref == NULL) /* open fail? */
|
||||
return _err_return (uptr, SCPE_OPENERR);/* yes, error */
|
||||
if (!sim_quiet)
|
||||
sim_printf ("%s%d: creating new file\n", sim_dname (dptr), (int)(uptr-dptr->units));
|
||||
sim_messagef (SCPE_OK, "%s%d: creating new file\n", sim_dname (dptr), (int)(uptr-dptr->units));
|
||||
created = TRUE;
|
||||
}
|
||||
} /* end if null */
|
||||
|
@ -1655,11 +1645,9 @@ if ((created) && (!copied)) {
|
|||
(void)remove (cptr); /* remove the created file */
|
||||
return SCPE_OPENERR;
|
||||
}
|
||||
if (!sim_quiet)
|
||||
sim_printf ("%s%d: Initialized To Sector Address %dMB. %d%% complete.\r", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000), (int)((((float)lba)*100)/total_sectors));
|
||||
sim_messagef (SCPE_OK, "%s%d: Initialized To Sector Address %dMB. %d%% complete.\r", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000), (int)((((float)lba)*100)/total_sectors));
|
||||
}
|
||||
if (!sim_quiet)
|
||||
sim_printf ("%s%d: Initialized To Sector Address %dMB. 100%% complete.\n", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000));
|
||||
sim_messagef (SCPE_OK, "%s%d: Initialized To Sector Address %dMB. 100%% complete.\n", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000));
|
||||
free (init_buf);
|
||||
}
|
||||
if (pdp11tracksize)
|
||||
|
@ -1708,11 +1696,9 @@ if (sim_switches & SWMASK ('K')) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!sim_quiet)
|
||||
sim_printf ("%s%d: Verified containing Sector Address %dMB. %d%% complete.\r", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000), (int)((((float)lba)*100)/total_sectors));
|
||||
sim_messagef (SCPE_OK, "%s%d: Verified containing Sector Address %dMB. %d%% complete.\r", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000), (int)((((float)lba)*100)/total_sectors));
|
||||
}
|
||||
if (!sim_quiet)
|
||||
sim_printf ("%s%d: Verified containing Sector Address %dMB. 100%% complete.\n", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000));
|
||||
sim_messagef (SCPE_OK, "%s%d: Verified containing Sector Address %dMB. 100%% complete.\n", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000));
|
||||
free (verify_buf);
|
||||
uptr->dynflags |= UNIT_DISK_CHK;
|
||||
}
|
||||
|
@ -3643,8 +3629,7 @@ static FILE *sim_vhd_disk_merge (const char *szVHDPath, char **ParentVHD)
|
|||
continue;
|
||||
++BlocksToMerge;
|
||||
}
|
||||
if (!sim_quiet)
|
||||
sim_printf ("Merging %s\ninto %s\n", szVHDPath, hVHD->ParentVHDPath);
|
||||
sim_messagef (SCPE_OK, "Merging %s\ninto %s\n", szVHDPath, hVHD->ParentVHDPath);
|
||||
for (BlockNumber=NeededBlock=0; BlockNumber < NtoHl (hVHD->Dynamic.MaxTableEntries); ++BlockNumber) {
|
||||
uint32 BlockSectors = SectorsPerBlock;
|
||||
|
||||
|
@ -3667,8 +3652,7 @@ static FILE *sim_vhd_disk_merge (const char *szVHDPath, char **ParentVHD)
|
|||
SectorSize,
|
||||
SectorsPerBlock*BlockNumber))
|
||||
break;
|
||||
if (!sim_quiet)
|
||||
sim_printf ("Merged %dMB. %d%% complete.\r", (int)((((float)NeededBlock)*SectorsPerBlock)*SectorSize/1000000), (int)((((float)NeededBlock)*100)/BlocksToMerge));
|
||||
sim_messagef (SCPE_OK, "Merged %dMB. %d%% complete.\r", (int)((((float)NeededBlock)*SectorsPerBlock)*SectorSize/1000000), (int)((((float)NeededBlock)*100)/BlocksToMerge));
|
||||
hVHD->BAT[BlockNumber] = VHD_BAT_FREE_ENTRY;
|
||||
}
|
||||
if (BlockNumber < NtoHl (hVHD->Dynamic.MaxTableEntries)) {
|
||||
|
@ -3676,8 +3660,7 @@ static FILE *sim_vhd_disk_merge (const char *szVHDPath, char **ParentVHD)
|
|||
}
|
||||
else {
|
||||
Status = 0;
|
||||
if (!sim_quiet)
|
||||
sim_printf ("Merged %dMB. 100%% complete.\n", (int)((((float)NeededBlock)*SectorsPerBlock)*SectorSize/1000000));
|
||||
sim_messagef (SCPE_OK, "Merged %dMB. 100%% complete.\n", (int)((((float)NeededBlock)*SectorsPerBlock)*SectorSize/1000000));
|
||||
fclose (hVHD->File);
|
||||
hVHD->File = NULL;
|
||||
(void)remove (szVHDPath);
|
||||
|
|
|
@ -378,8 +378,7 @@ return FALSE;
|
|||
t_stat sim_tape_set_async (UNIT *uptr, int latency)
|
||||
{
|
||||
#if !defined(SIM_ASYNCH_IO)
|
||||
sim_printf ("Tape: can't operate asynchronously\r\n");
|
||||
return SCPE_NOFNC;
|
||||
return sim_messagef (SCPE_NOFNC, "Tape: can't operate asynchronously\r\n");
|
||||
#else
|
||||
struct tape_context *ctx = (struct tape_context *)uptr->tape_ctx;
|
||||
pthread_attr_t attr;
|
||||
|
|
13
sim_tmxr.c
13
sim_tmxr.c
|
@ -2394,7 +2394,6 @@ CONST char *tptr = cptr;
|
|||
t_bool nolog, notelnet, listennotelnet, modem_control, loopback, datagram, packet;
|
||||
TMLN *lp;
|
||||
t_stat r = SCPE_OK;
|
||||
t_bool not_quiet = (!sim_quiet) && (0 == (sim_switches & SWMASK ('Q')));
|
||||
|
||||
if (*tptr == '\0')
|
||||
return SCPE_ARG;
|
||||
|
@ -2660,8 +2659,7 @@ while (*tptr) {
|
|||
free (mp->port);
|
||||
mp->port = NULL;
|
||||
}
|
||||
if (not_quiet)
|
||||
sim_printf ("Listening on port %s\n", listen);
|
||||
sim_messagef (SCPE_OK, "Listening on port %s\n", listen);
|
||||
mp->port = (char *)realloc (mp->port, 1 + strlen (listen));
|
||||
strcpy (mp->port, listen); /* save port */
|
||||
mp->master = sock; /* save master socket */
|
||||
|
@ -2694,8 +2692,7 @@ while (*tptr) {
|
|||
if (loopback) {
|
||||
if (mp->lines > 1)
|
||||
return sim_messagef (SCPE_ARG, "Ambiguous Loopback specification\n");
|
||||
if (not_quiet)
|
||||
sim_printf ("Operating in loopback mode\n");
|
||||
sim_messagef (SCPE_OK, "Operating in loopback mode\n");
|
||||
for (i = 0; i < mp->lines; i++) {
|
||||
lp = mp->ldsc + i;
|
||||
tmxr_set_line_loopback (lp, loopback);
|
||||
|
@ -2813,8 +2810,7 @@ while (*tptr) {
|
|||
if (sock == INVALID_SOCKET) /* open error */
|
||||
return sim_messagef (SCPE_OPENERR, "Can't listen on port: %s\n", listen);
|
||||
_mux_detach_line (lp, TRUE, FALSE);
|
||||
if (not_quiet)
|
||||
sim_printf ("Line %d Listening on port %s\n", line, listen);
|
||||
sim_messagef (SCPE_OK, "Line %d Listening on port %s\n", line, listen);
|
||||
lp->port = (char *)realloc (lp->port, 1 + strlen (listen));
|
||||
strcpy (lp->port, listen); /* save port */
|
||||
lp->master = sock; /* save master socket */
|
||||
|
@ -2872,8 +2868,7 @@ while (*tptr) {
|
|||
}
|
||||
if (loopback) {
|
||||
tmxr_set_line_loopback (lp, loopback);
|
||||
if (not_quiet)
|
||||
sim_printf ("Line %d operating in loopback mode\n", line);
|
||||
sim_messagef (SCPE_OK, "Line %d operating in loopback mode\n", line);
|
||||
}
|
||||
lp->modem_control = modem_control;
|
||||
if (speed[0] && (!datagram) && (!lp->serport))
|
||||
|
|
Loading…
Add table
Reference in a new issue