summaryrefslogtreecommitdiffhomepage
path: root/src/mdb.h
diff options
context:
space:
mode:
authorSean Kurtz <seankurtz75@gmail.com>2026-11-27 18:15:26 -0600
committerGitHub <noreply@github.com>2026-11-27 18:15:26 -0600
commit83e8fbc692b36be5ac9011ccf26b1b232d560008 (patch)
treeab62a06c6a49b343b33d41b502487b233128ad80 /src/mdb.h
parent4c95e6490d189b47cad050744de9768465e0307b (diff)
parentb5bb63d4760f6f6e0282fc9f7eec36b41705458c (diff)
downloadztop-main.tar.gz
Merge pull request #7 from skurtz97/feature/views-and-dec-glyphsHEADmain
views: PS, FS and LOG, and a DEC-graphics frame
Diffstat (limited to 'src/mdb.h')
-rw-r--r--src/mdb.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/mdb.h b/src/mdb.h
new file mode 100644
index 0000000..58ba606
--- /dev/null
+++ b/src/mdb.h
@@ -0,0 +1,37 @@
+/** @file mdb.h
+ * @brief Pull a job name and a line of text out of a message data block.
+ *
+ * An MDB (IEAVM105) is a chain of objects, each two bytes of length
+ * followed by two of type. The general object (type 1) names the job
+ * that wrote the message at +48; a text object (type 4) holds its line at
+ * +9. The walk is here rather than in src/ztop.c because this is the one
+ * place ztop parses bytes that came from another address space, and it is
+ * the part worth a test that runs anywhere.
+ */
+#ifndef ZTOP_MDB_H
+#define ZTOP_MDB_H
+
+#include <stddef.h>
+
+/** Largest text line kept: a console line is at most 132 columns. */
+enum { MDB_TEXT_MAX = 200 };
+
+/**
+ * @brief Extract the job name and the first text object of an MDB copy.
+ *
+ * @param mdb the block as zmcs() copied it out of the console's space
+ * @param len how many bytes of it are valid
+ * @param job out: job name, blank padded or empty; never left unterminated
+ * @param joblen size of @p job
+ * @param text out: the line, trimmed; empty when there is none
+ * @param textlen size of @p text
+ * @return true when a text object was found
+ *
+ * Every length read is checked against @p len before it is used: the
+ * block was written by someone else, so a length in it is input, not a
+ * fact.
+ */
+bool mdb_line(const char *mdb, int len, char *job, size_t joblen, char *text,
+ size_t textlen);
+
+#endif /* ZTOP_MDB_H */