summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README3
-rw-r--r--prtmib.c32
2 files changed, 33 insertions, 2 deletions
diff --git a/README b/README
index cd41fb6..4b97c6c 100644
--- a/README
+++ b/README
@@ -24,7 +24,8 @@ Columns
'*' = <= LOWPCT, '!' = <= CRITPCT
src which mapping filled toner: std | xrx | km | -
model sysDescr up to ';' (Xerox firmware blob stripped),
- trailing " vN" dropped, then truncated
+ trailing " vN" dropped, KONICA MINOLTA -> KM,
+ Xerox -> XRX, then truncated
-v also prints every varbind (OID, MIB name, BER tag, value) and a
short packet trace.
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;