summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSean Kurtz <seankurtz75@gmail.com>2026-11-24 11:57:48 -0600
committerGitHub <noreply@github.com>2026-11-24 11:57:48 -0600
commit03042dfefee7b8e35b07db74c090eb5823be0265 (patch)
treec02c7e76b6be37ce865aefdba6144e6ed209fe18
parent44b584e03b4ec6326f01afb389d3fc30d7bfc011 (diff)
parent0c64cc686ce1238c81815d0ce49811e6e2f33769 (diff)
downloadwhoson-03042dfefee7b8e35b07db74c090eb5823be0265.tar.gz
Merge pull request #7 from skurtz97/fix/ascii-char-mode
Build in ASCII character mode, converting opercmd's EBCDIC display
-rw-r--r--Makefile11
-rw-r--r--README.md13
-rw-r--r--whoson.c16
3 files changed, 24 insertions, 16 deletions
diff --git a/Makefile b/Makefile
index eb9e8f4..333a1fc 100644
--- a/Makefile
+++ b/Makefile
@@ -18,10 +18,9 @@
# the sidedeck as a DD and fail with IEW2763S. The library also has to be
# reachable at run time through LIBPATH.
#
-# EBCDIC is deliberate: the ssh channel converts terminal output from EBCDIC
-# to ASCII, and ZOAU returns its text in EBCDIC. Source stays ASCII-tagged;
-# the compiler turns literals into EBCDIC. Only opercmd's argument string is
-# converted to ASCII, in whoson.c.
+# ASCII character mode is deliberate: the text ZOAU returns and the text the
+# ssh channel carries are ASCII, so literals stay ASCII and the display fields
+# compare the way they are parsed. Source stays ASCII-tagged.
#
# POSIX make syntax: z/OS has IBM's make as well as GNU make. Avoid ?=,
# which IBM's make does not accept; .PHONY is supported by both.
@@ -32,7 +31,7 @@ BINDIR = $(PREFIX)/bin
CC = /usr/lpp/IBM/cnw/v2r1/openxl/bin/ibm-clang
CPPFLAGS = -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=200809L -D_ALL_SOURCE \
-D_EXT
-CFLAGS = -std=c17 -O2 -m64 -fzos-le-char-mode=ebcdic -Wall -Wextra \
+CFLAGS = -std=c17 -O3 -m64 -fzos-le-char-mode=ascii -Wall -Wextra \
-Wpedantic -Wshadow -Wconversion -I$(ZOAU_HOME)/include
ZOAU_DLL = $(ZOAU_HOME)/lib/zoautil.x
CEEOPTS = HEAPCHK(ON,1,32),RPTSTG(ON),FILETAG(AUTOCVT,AUTOTAG),POSIX(ON)
@@ -52,7 +51,7 @@ whoson: whoson.c
install: whoson
mkdir -p $(BINDIR)
cp whoson $(BINDIR)/whoson
- chmod 755 $(BINDIR)/whoson
+ chmod +x $(BINDIR)/whoson
check: whoson
LIBPATH=$(ZOAU_HOME)/lib:$$LIBPATH \
diff --git a/README.md b/README.md
index 8511168..10b9d79 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@ SKURTZ TSO/E OMVS OWT O 0058 33554625 TSU08400 000.870 00.08.00 TSO
`TYPE` is `TSO/E` for a session listed by `DISPLAY TS,A`, `SSH` for a session
whose process is an `sshd`, and `TSO/E OMVS` for a TSO/E session that is also
-using an OMVS process — a TSO/E logon you can reach the POSIX side from. `PID`
+using an OMVS process - a TSO/E logon you can reach the POSIX side from. `PID`
is the OMVS process id of that session, matched to the TSO/E session by
address space id: an SSH session always has one, a TSO/E session only while it
owns an OMVS process, and `NA` otherwise.
@@ -33,7 +33,7 @@ its sidedeck imports `CODE64`.
## Build and run
```sh
-make # builds ./whoson with ibm-clang, -m64, EBCDIC character mode
+make # builds ./whoson with ibm-clang, -m64, ASCII character mode
make check # runs it under the CEE heap checker and storage report
make install # copies it to ~/.local/bin, creating it if needed
```
@@ -44,8 +44,9 @@ make install # copies it to ~/.local/bin, creating it if needed
make PREFIX=/usr/local install # -> /usr/local/bin/whoson
```
-The sources are ASCII and stay that way; the compiler turns the literals into
-EBCDIC, which is what ZOAU returns and what the console display looks like.
+The sources are ASCII and stay that way; the build is in ASCII character mode
+(`-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
@@ -61,8 +62,8 @@ so the program does not shell out to `opercmd`:
a daemon account and is dropped, which keeps started tasks out of the list.
The vector's `opercmd` splits its argument string into `argv` without a shell,
-so the console command is passed quoted (`"D TS,A"`) as a single argument, in
-EBCDIC. Unquoted, the `D` is read as an option letter and the call fails with
+so the console command is passed quoted (`"D TS,A"`) as a single argument.
+Unquoted, the `D` is read as an option letter and the call fails with
`opercmd`'s usage text and rc 2.
## License
diff --git a/whoson.c b/whoson.c
index f34a8f3..bcf720c 100644
--- a/whoson.c
+++ b/whoson.c
@@ -14,8 +14,9 @@
* The vector's opercmd splits its argument string into argv without a shell,
* 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 arguments stay in
- * EBCDIC; an ASCII-converted copy fails with rc 1 and no message.
+ * the call fails with opercmd's usage text (rc 2). The program is built in
+ * 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
@@ -379,7 +380,9 @@ static int compare_rows(const void *a, const void *b)
}
/* Run one display; returns 0 and a NUL-terminated copy of stdout, or -1.
- * EBCDIC, and quoted so that the whole command is one argv element. */
+ * ASCII (the build's character mode), and quoted so that the whole command is
+ * 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)
{
@@ -400,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;
@@ -419,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;