cups/cups-snmp-quirks.patch

87 lines
2.3 KiB
Diff

diff -up cups-1.4.3/backend/snmp-supplies.c.snmp-quirks cups-1.4.3/backend/snmp-supplies.c
--- cups-1.4.3/backend/snmp-supplies.c.snmp-quirks 2009-11-20 01:27:57.000000000 +0000
+++ cups-1.4.3/backend/snmp-supplies.c 2010-04-13 11:54:13.508023630 +0100
@@ -38,6 +38,15 @@
/*
+ * Printer quirks...
+ */
+
+/* The prtMarkerSuppliesLevel values are percentages, not levels
+ * relative to the stated capacity. */
+#define QUIRK_LEVEL_IS_PERCENTAGE (1<<0)
+
+
+/*
* Local structures...
*/
@@ -57,6 +66,12 @@ typedef struct /**** Printer state ta
const char *keyword; /* IPP printer-state-reasons keyword */
} backend_state_t;
+typedef struct /**** Printer quirk table ****/
+{
+ const char *description; /* hrDeviceDescr */
+ int quirks; /* quirks (bitmask) */
+} printer_quirk_t;
+
/*
* Local globals...
@@ -68,6 +83,7 @@ static int current_state = -1;
static int charset = -1; /* Character set for supply names */
static int num_supplies = 0;
/* Number of supplies found */
+static int quirks = 0; /* Printer quirks */
static backend_supplies_t supplies[CUPS_MAX_SUPPLIES];
/* Supply information */
@@ -153,6 +169,11 @@ static const backend_state_t const print
{ CUPS_TC_outputFull, "output-area-full-warning" }
};
+static const printer_quirk_t const printer_quirks[] =
+ {
+ { "Officejet Pro 8500 A909g", QUIRK_LEVEL_IS_PERCENTAGE }
+ };
+
/*
* Local functions...
@@ -208,6 +229,9 @@ backendSNMPSupplies(
if (i)
*ptr++ = ',';
+ if (quirks & QUIRK_LEVEL_IS_PERCENTAGE)
+ supplies[i].max_capacity = 100;
+
if (supplies[i].max_capacity > 0)
sprintf(ptr, "%d", 100 * supplies[i].level / supplies[i].max_capacity);
else
@@ -366,6 +390,7 @@ backend_init_supplies(
current_state = -1;
num_supplies = -1;
charset = -1;
+ quirks = 0;
memset(supplies, 0, sizeof(supplies));
@@ -404,6 +429,15 @@ backend_init_supplies(
fprintf(stderr, "DEBUG2: hrDeviceDesc=\"%s\"\n", description);
+ for (i = 0; i < sizeof (printer_quirks) / sizeof (printer_quirks[0]); i++)
+ {
+ if (!strcmp (description, printer_quirks[i].description))
+ {
+ quirks = printer_quirks[i].quirks;
+ break;
+ }
+ }
+
/*
* See if we have already queried this device...
*/