1
0
mirror of https://github.com/simh/simh.git synced 2026-01-11 23:52:58 +00:00

SCP: Extend hierarchical help for device type attach language insertion

This allows all devices across all simulators to avoid having identical
attach language which may have host platform specific language.
This commit is contained in:
Mark Pizzolato 2025-10-10 17:46:19 -10:00
parent d569493baf
commit 6825288a94
2 changed files with 71 additions and 7 deletions

69
scp.c
View File

@ -1585,10 +1585,10 @@ static const char simh_help1[] =
" Expression can contain arbitrary combinations of constant\n"
" values, simulator registers and environment variables \n"
"5Examples:\n"
"++SET ENV -A A=7+2\n"
"++SET ENV -A A=A-1\n"
"++ECHO A=%%A%%\n"
"++A=8\n"
"++SET ENV -A VAR=7+2\n"
"++SET ENV -A VAR=VAR-1\n"
"++ECHO VAR=%%VAR%%\n"
"++VAR=8\n"
"4Gathering Input From A User\n"
" Input from a user can be obtained by:\n\n"
"+set environment -P \"Prompt String\" name=default\n\n"
@ -1811,7 +1811,8 @@ static const char simh_help2[] =
" %%SIM_VM_RELEASE%%, %%SIM_VERSION_MODE%%, %%SIM_GIT_COMMIT_ID%%,\n"
" %%SIM_GIT_COMMIT_TIME%%, %%SIM_ARCHIVE_GIT_COMMIT_ID%%,\n"
" %%SIM_ARCHIVE_GIT_COMMIT_TIME%%, %%SIM_RUNLIMIT%%, %%SIM_RUNLIMIT_UNITS%%,\n"
" %%SIM_HOST_CORE_COUNT%%, %%SIM_HOST_MAX_THREADS%%\n\n"
" %%SIM_HOST_CORE_COUNT%%, %%SIM_HOST_MAX_THREADS%%,\n"
" %%SIM_ETHERNET_CAPABILITIES%%\n\n"
"+Token %%0 expands to the command file name.\n"
"+Token %%n (n being a single digit) expands to the n'th argument\n"
"+Token %%* expands to the whole set of arguments (%%1 ... %%9)\n\n"
@ -15397,8 +15398,8 @@ if (_get_tool_version (cmd)[0]) {
snprintf (gbuf, sizeof (gbuf), "%s %s", cmd, cptr);
return spawn_cmd (0, gbuf);
}
else
return SCPE_NOFNC;
sim_messagef (SCPE_NOFNC, "The %s command is not currently available on this system.\n", cmd);
return sim_messagef (SCPE_NOFNC, "You may want to try installing the appropriate package for this system\n");
}
t_stat tar_cmd (int32 flag, CONST char *cptr)
@ -15510,7 +15511,60 @@ size_t asnum = 0;
char *const *hblock;
const char *ep;
t_bool excluded = FALSE;
char *exptext = NULL;
if (dptr != NULL) {
int i;
static const char *attach_inserts[] = {"%A", "%0A", "%1A", "%2A", "%3A", "%4A", "%5A", "%6A", "%7A", "%8A", "%9A", NULL};
for (i = 0; (attach_inserts[i] != NULL) &&
((ep = strstr (htext, attach_inserts[i])) == NULL); i++) ;
if (ep != NULL) {
const char *insert_string = "";
size_t insert_size = 0;
size_t explen;
int addlevel = 0;
int epskip = 0;
++epskip; /* skip % */
if (sim_isdigit (*(ep + 1))) {
addlevel = *(ep + 1) - '0';
++epskip; /* skip digit */
}
++epskip; /* skip A */
/* As each of the device types have hierarchical help available, the */
/* insertion property here should be added. */
switch (DEV_TYPE(dptr)) {
case DEV_ETHER:
insert_string = eth_attach_scp_help_string (dptr);
insert_size = strlen (insert_string);
break;
}
explen = strlen (htext) + insert_size; /* size includes \0 since we're skipping the %A */
exptext = malloc (explen);
memcpy (exptext, htext, ep - htext);
if (addlevel > 0) { /* Need to find and adjust level indications */
const char *ins = insert_string;
t_bool last_nl = TRUE;
char *op = exptext + (ep - htext);
while (*ins) {
if (last_nl && sim_isdigit (*ins))
*op++ = addlevel + *ins;
else
*op++ = *ins;
last_nl = (*ins == '\n');
++ins;
}
*op = '\0';
}
else
strlcpy (exptext + (ep - htext), insert_string, explen - (ep - htext));
strlcat (exptext, ep + epskip, explen);
htext = exptext;
}
}
/* variable arguments consumed table.
* The scheme used allows arguments to be accessed in random
* order, but for portability, all arguments must be char *.
@ -15736,6 +15790,7 @@ for (hblock = astrings; (htext = *hblock) != NULL; hblock++) {
vsnum = 0;
} /* all strings */
free (exptext);
return topic;
}

View File

@ -49,6 +49,15 @@
* * %S - Inserts the current simulator name (e.g. "PDP-10")
* * %C - Inserts the current value of the sim_vm_interval_units string
* * %I - Inserts the current value of the sim_vm_step_unit string
* * %{#}A - Inserts the internal device type ATTACH string based on the type of
* the device (DEV_DISK, DEV_TAPE, DEV_SCSI, DEV_MUX, DEV_CARD, DEV_ETHER,
* DEV_DISPLAY) for the device being processed. Each of these device types
* may or may not have an ATTACH string available. If none is available,
* then nothing is inserted. The insertion occurs BEFORE the whole input
* is processed for its hierarchical/structural sections. This allows
* the inserted string to add to the heirarchy when desired.
* The # is optional. When present, the number # is added to each
* hierarchy level indicated in the included ATTACH string inserted.
* * %#s - Inserts the string suppled in the "#"th optional argument to the help
* routine. # starts with 1. Any embedded newlines will cause following
* text to be indented.