From 0f74fffad21df22a2c851f32f4bc6aa9e3c6e8d2 Mon Sep 17 00:00:00 2001 From: bryan Date: Thu, 27 Aug 2026 11:34:09 +0200 Subject: Abbreviate KONICA MINOLTA and Xerox in the model column. sysDescr prefixes become KM and XRX before truncation. --- prtmib.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'prtmib.c') diff --git a/prtmib.c b/prtmib.c index e56e571..bef5372 100644 --- a/prtmib.c +++ b/prtmib.c @@ -890,8 +890,15 @@ putdescr(const struct Bind *b, int max) static void putmodel(const struct Bind *b, int max) { + static const struct { + const char *from; + const char *to; + } vend[] = { + { "KONICA MINOLTA", "KM" }, + { "Xerox", "XRX" }, + }; char buf[128]; - int i, n, out; + int i, n, out, k, fl, tl, ok; char *p, *v; if (!b || b->nstr <= 0) { @@ -927,6 +934,29 @@ putmodel(const struct Bind *b, int max) if (*p == '\0') *v = '\0'; } + /* "KONICA MINOLTA bizhub C250i" -> "KM bizhub C250i" + * "Xerox WorkCentre 7835" -> "XRX WorkCentre 7835" */ + n = (int)strlen(buf); + for (k = 0; k < (int)LEN(vend); k++) { + fl = (int)strlen(vend[k].from); + if (n < fl) + continue; + ok = 1; + for (i = 0; i < fl; i++) + if (tolower((unsigned char)buf[i]) != + tolower((unsigned char)vend[k].from[i])) { + ok = 0; + break; + } + if (!ok) + continue; + if (buf[fl] != '\0' && buf[fl] != ' ') + continue; + tl = (int)strlen(vend[k].to); + memmove(buf + tl, buf + fl, (size_t)(n - fl + 1)); + memcpy(buf, vend[k].to, (size_t)tl); + break; + } n = (int)strlen(buf); if (n > max) n = max; -- cgit v1.2.3