SCP: Add a SIM_OSTYPE built-in environment variable.

This commit is contained in:
Mark Pizzolato 2017-11-20 15:23:19 -08:00
parent 61679ed8f0
commit 7246e74004

26
scp.c
View file

@ -1373,7 +1373,8 @@ static const char simh_help[] =
" %%CTIME%%, %%DATE_YYYY%%, %%DATE_YY%%, %%DATE_YC%%, %%DATE_MM%%, %%DATE_MMM%%,\n" " %%CTIME%%, %%DATE_YYYY%%, %%DATE_YY%%, %%DATE_YC%%, %%DATE_MM%%, %%DATE_MMM%%,\n"
" %%DATE_MONTH%%, %%DATE_DD%%, %%DATE_D%%, %%DATE_WYYYY%%, %%DATE_WW%%,\n" " %%DATE_MONTH%%, %%DATE_DD%%, %%DATE_D%%, %%DATE_WYYYY%%, %%DATE_WW%%,\n"
" %%TIME_HH%%, %%TIME_MM%%, %%TIME_SS%%, %%STATUS%%, %%TSTATUS%%, %%SIM_VERIFY%%,\n" " %%TIME_HH%%, %%TIME_MM%%, %%TIME_SS%%, %%STATUS%%, %%TSTATUS%%, %%SIM_VERIFY%%,\n"
" %%SIM_QUIET%%, %%SIM_MESSAGE%%\n\n" " %%SIM_QUIET%%, %%SIM_MESSAGE%% %%SIM_MESSAGE%%\n"
" %%SIM_NAME%%, %%SIM_BIN_NAME%%, %%SIM_BIN_PATH%%m %%SIM_OSTYPE%%\n\n"
"+Token %%0 expands to the command file name.\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 %%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" "+Token %%* expands to the whole set of arguments (%%1 ... %%9)\n\n"
@ -1412,7 +1413,11 @@ static const char simh_help[] =
"++%%SIM_VERIFY%% The Verify/Verbose mode of the current Do command file\n" "++%%SIM_VERIFY%% The Verify/Verbose mode of the current Do command file\n"
"++%%SIM_VERBOSE%% The Verify/Verbose mode of the current Do command file\n" "++%%SIM_VERBOSE%% The Verify/Verbose mode of the current Do command file\n"
"++%%SIM_QUIET%% The Quiet mode of the current Do command file\n" "++%%SIM_QUIET%% The Quiet mode of the current Do command file\n"
"++%%SIM_MESSAGE%% The message display status of the current Do command file\n\n" "++%%SIM_MESSAGE%% The message display status of the current Do command file\n"
"++%%SIM_NAME%% The name of the current simulator\n"
"++%%SIM_BIN_NAME%% The program name of the current simulator\n"
"++%%SIM_BIN_PATH%% The program path that invoked the current simulator\n"
"++%%SIM_OSTYPE%% The Operating System running the current simulator\n\n"
"+Environment variable lookups are done first with the precise name between\n" "+Environment variable lookups are done first with the precise name between\n"
"+the %% characters and if that fails, then the name between the %% characters\n" "+the %% characters and if that fails, then the name between the %% characters\n"
"+is upcased and a lookup of that valus is attempted.\n\n" "+is upcased and a lookup of that valus is attempted.\n\n"
@ -2201,6 +2206,7 @@ if (!sim_quiet) {
printf ("\n"); printf ("\n");
show_version (stdout, NULL, NULL, 0, NULL); show_version (stdout, NULL, NULL, 0, NULL);
} }
show_version (stdnul, NULL, NULL, 1, NULL); /* Quietly set SIM_OSTYPE */
if (sim_dflt_dev == NULL) /* if no default */ if (sim_dflt_dev == NULL) /* if no default */
sim_dflt_dev = sim_devices[0]; sim_dflt_dev = sim_devices[0];
if (((sim_dflt_dev->flags & DEV_DEBUG) == 0) && /* default device without debug? */ if (((sim_dflt_dev->flags & DEV_DEBUG) == 0) && /* default device without debug? */
@ -4841,6 +4847,7 @@ fprintf (st, " %s", SIM_VERSION_MODE);
if (flag) { if (flag) {
t_bool idle_capable; t_bool idle_capable;
uint32 os_ms_sleep_1, os_tick_size; uint32 os_ms_sleep_1, os_tick_size;
char os_type[128] = "Unknown";
fprintf (st, "\n Simulator Framework Capabilities:"); fprintf (st, "\n Simulator Framework Capabilities:");
fprintf (st, "\n %s", sim_si64); fprintf (st, "\n %s", sim_si64);
@ -4934,6 +4941,8 @@ if (flag) {
#else #else
"VAX"; "VAX";
#endif #endif
strlcpy (os_type, "OpenVMS ", sizeof (os_type));
strlcat (os_type, arch, sizeof (os_type));
fprintf (st, "\n OS: OpenVMS %s %s", arch, __VMS_VERSION); fprintf (st, "\n OS: OpenVMS %s %s", arch, __VMS_VERSION);
} }
#elif defined(_WIN32) #elif defined(_WIN32)
@ -4959,6 +4968,7 @@ if (flag) {
fprintf (st, "\n OS: %s", osversion); fprintf (st, "\n OS: %s", osversion);
fprintf (st, "\n Architecture: %s%s%s, Processors: %s", arch, proc_arch3264 ? " on " : "", proc_arch3264 ? proc_arch3264 : "", procs); fprintf (st, "\n Architecture: %s%s%s, Processors: %s", arch, proc_arch3264 ? " on " : "", proc_arch3264 ? proc_arch3264 : "", procs);
fprintf (st, "\n Processor Id: %s, Level: %s, Revision: %s", proc_id ? proc_id : "", proc_level ? proc_level : "", proc_rev ? proc_rev : ""); fprintf (st, "\n Processor Id: %s, Level: %s, Revision: %s", proc_id ? proc_id : "", proc_level ? proc_level : "", proc_rev ? proc_rev : "");
strlcpy (os_type, "Windows", sizeof (os_type));
} }
#else #else
if (1) { if (1) {
@ -4975,8 +4985,20 @@ if (flag) {
pclose (f); pclose (f);
} }
fprintf (st, "\n OS: %s", osversion); fprintf (st, "\n OS: %s", osversion);
if ((f = popen ("uname", "r"))) {
memset (os_type, 0, sizeof (os_type));
do {
if (NULL == fgets (os_type, sizeof (os_type)-1, f))
break;
sim_trim_endspc (os_type);
} while (os_type[0] == '\0');
pclose (f);
}
} }
#endif #endif
if ((!strcmp (os_type, "Unknown")) && (getenv ("OSTYPE")))
strlcpy (os_type, getenv ("OSTYPE"), sizeof (os_type));
setenv ("SIM_OSTYPE", os_type, 1);
} }
#if defined(SIM_GIT_COMMIT_ID) #if defined(SIM_GIT_COMMIT_ID)
#define S_xstr(a) S_str(a) #define S_xstr(a) S_str(a)