summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSean Kurtz <seankurtz75@gmail.com>2026-11-24 11:56:17 -0600
committerSean Kurtz <seankurtz75@gmail.com>2026-11-24 11:56:28 -0600
commit0c64cc686ce1238c81815d0ce49811e6e2f33769 (patch)
treec02c7e76b6be37ce865aefdba6144e6ed209fe18
parentf6ced3cd511d860ef09bc127ead184f71b4e4b55 (diff)
downloadwhoson-0c64cc686ce1238c81815d0ce49811e6e2f33769.tar.gz
whoson: convert opercmd's EBCDIC display to ASCII
With -fzos-le-char-mode=ascii the literals are ASCII, but opercmd still returns its display in EBCDIC, so every parse matched nothing and only the header printed. Convert each response in place with __e2a_l before the parser sees it, and the stderr text before it is echoed.
-rw-r--r--README.md4
-rw-r--r--whoson.c14
2 files changed, 12 insertions, 6 deletions
diff --git a/README.md b/README.md
index 2508b08..10b9d79 100644
--- a/README.md
+++ b/README.md
@@ -45,8 +45,8 @@ make PREFIX=/usr/local install # -> /usr/local/bin/whoson
```
The sources are ASCII and stay that way; the build is in ASCII character mode
-(`-fzos-le-char-mode=ascii`), which is what ZOAU returns and what the ssh
-channel carries.
+(`-fzos-le-char-mode=ascii`). ZOAU hands its display back in EBCDIC, so
+`run_display` converts each response in place (`__e2a_l`) before it is parsed.
## How the data is produced
diff --git a/whoson.c b/whoson.c
index d3364c3..bcf720c 100644
--- a/whoson.c
+++ b/whoson.c
@@ -15,8 +15,8 @@
* so the console command has to arrive as one argv element: it is passed in
* double quotes, "D TS,A". Unquoted, the D is taken for an option letter and
* the call fails with opercmd's usage text (rc 2). The program is built in
- * ASCII character mode, so the argument and the returned text share one
- * encoding.
+ * ASCII character mode and passes the command in that mode; opercmd returns
+ * the display itself in EBCDIC, so run_display converts each response.
*
* A TSO/E session reports its own CPU time (CT), elapsed time (ET), job id
* (WUID/SCL/P) and region (RGP), so those columns need no second source. An
@@ -381,7 +381,8 @@ static int compare_rows(const void *a, const void *b)
/* Run one display; returns 0 and a NUL-terminated copy of stdout, or -1.
* ASCII (the build's character mode), and quoted so that the whole command is
- * one argv element. */
+ * one argv element. The display that comes back is EBCDIC, so it is converted
+ * to ASCII here before the parser sees it. */
static int run_display(zoautil_vector4_t *vector, const char *args,
zoautil_options_t options, char **out)
{
@@ -402,9 +403,12 @@ static int run_display(zoautil_vector4_t *vector, const char *args,
"stderr_len = %d\n", response->cmd_rc,
response->stdout_len, response->stderr_len);
if (response != NULL && response->stderr_response != NULL &&
- response->stderr_len > 0)
+ response->stderr_len > 0) {
+ __e2a_l(response->stderr_response,
+ (size_t)response->stderr_len);
fprintf(stderr, "%.*s\n", response->stderr_len,
response->stderr_response);
+ }
if (response != NULL)
free_response(response);
return -1;
@@ -421,6 +425,8 @@ static int run_display(zoautil_vector4_t *vector, const char *args,
return -1;
}
memcpy(*out, response->stdout_response, (size_t)response->stdout_len);
+ /* The display is EBCDIC; this program is ASCII. */
+ __e2a_l(*out, (size_t)response->stdout_len);
(*out)[response->stdout_len] = '\0';
free_response(response);
return 0;