2011-07-26 09:06:18 +00:00
|
|
|
diff -up cups-1.4.8/backend/snmp-supplies.c.snmp-quirks cups-1.4.8/backend/snmp-supplies.c
|
|
|
|
--- cups-1.4.8/backend/snmp-supplies.c.snmp-quirks 2011-07-06 22:27:31.000000000 +0200
|
|
|
|
+++ cups-1.4.8/backend/snmp-supplies.c 2011-07-26 11:02:14.709121584 +0200
|
2011-06-28 09:48:01 +00:00
|
|
|
@@ -49,6 +49,13 @@
|
2010-04-13 11:22:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
+ * Printer quirks...
|
|
|
|
+ */
|
|
|
|
+
|
2010-06-09 15:52:18 +00:00
|
|
|
+#define QUIRK_CAPACITY (1<<0)
|
2010-04-13 11:22:19 +00:00
|
|
|
+
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
* Local structures...
|
|
|
|
*/
|
|
|
|
|
2011-06-28 09:48:01 +00:00
|
|
|
@@ -68,6 +75,12 @@ typedef struct /**** Printer state ta
|
2010-04-13 11:22:19 +00:00
|
|
|
const char *keyword; /* IPP printer-state-reasons keyword */
|
|
|
|
} backend_state_t;
|
|
|
|
|
2010-06-09 15:52:18 +00:00
|
|
|
+typedef struct /**** Quirk names table ****/
|
2010-04-13 11:22:19 +00:00
|
|
|
+{
|
2010-06-09 15:52:18 +00:00
|
|
|
+ int bit; /* Quirk bit */
|
|
|
|
+ const char *keyword; /* cupsSNMPQuirks keyword */
|
|
|
|
+} quirk_name_t;
|
2010-04-13 11:22:19 +00:00
|
|
|
+
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Local globals...
|
2011-06-28 09:48:01 +00:00
|
|
|
@@ -79,6 +92,7 @@ static int current_state = -1;
|
2010-04-13 11:22:19 +00:00
|
|
|
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 */
|
2011-06-28 09:48:01 +00:00
|
|
|
static int supply_state = -1;
|
|
|
|
@@ -180,6 +194,15 @@ static const backend_state_t const suppl
|
|
|
|
{ CUPS_TONER_EMPTY, "toner-empty-warning" }
|
2010-04-13 11:22:19 +00:00
|
|
|
};
|
|
|
|
|
2010-06-09 15:52:18 +00:00
|
|
|
+static const quirk_name_t const quirk_names[] =
|
2010-04-13 11:22:19 +00:00
|
|
|
+ {
|
2010-06-09 15:52:18 +00:00
|
|
|
+ /*
|
|
|
|
+ * The prtMarkerSuppliesLevel values are
|
|
|
|
+ * percentages, not levels relative to the
|
|
|
|
+ * stated capacity.
|
|
|
|
+ */
|
|
|
|
+ { QUIRK_CAPACITY, "capacity" }
|
2010-04-13 11:22:19 +00:00
|
|
|
+ };
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Local functions...
|
2011-06-28 09:48:01 +00:00
|
|
|
@@ -233,6 +256,9 @@ backendSNMPSupplies(
|
2010-04-13 11:22:19 +00:00
|
|
|
|
2011-06-28 09:48:01 +00:00
|
|
|
for (i = 0, ptr = value; i < num_supplies; i ++, ptr += strlen(ptr))
|
|
|
|
{
|
2010-06-09 15:52:18 +00:00
|
|
|
+ if (quirks & QUIRK_CAPACITY)
|
2011-06-28 09:48:01 +00:00
|
|
|
+ supplies[i].max_capacity = 100;
|
2010-04-13 11:22:19 +00:00
|
|
|
+
|
2011-07-26 09:06:18 +00:00
|
|
|
if (supplies[i].max_capacity > 0)
|
|
|
|
percent = 100 * supplies[i].level / supplies[i].max_capacity;
|
|
|
|
else
|
|
|
|
@@ -409,6 +435,7 @@ backend_init_supplies(
|
2010-06-09 15:52:18 +00:00
|
|
|
http_addr_t *addr) /* I - Printer address */
|
|
|
|
{
|
|
|
|
int i, /* Looping var */
|
|
|
|
+ len, /* Quirk name length */
|
|
|
|
type; /* Current marker type */
|
|
|
|
cups_file_t *cachefile; /* Cache file */
|
|
|
|
const char *cachedir; /* CUPS_CACHEDIR value */
|
2011-07-26 09:06:18 +00:00
|
|
|
@@ -470,6 +497,7 @@ backend_init_supplies(
|
2010-04-13 11:22:19 +00:00
|
|
|
current_state = -1;
|
|
|
|
num_supplies = -1;
|
|
|
|
charset = -1;
|
|
|
|
+ quirks = 0;
|
|
|
|
|
|
|
|
memset(supplies, 0, sizeof(supplies));
|
|
|
|
|
2011-07-26 09:06:18 +00:00
|
|
|
@@ -485,6 +513,34 @@ backend_init_supplies(
|
2010-06-09 15:52:18 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-04-13 11:22:19 +00:00
|
|
|
|
2010-06-09 15:52:18 +00:00
|
|
|
+ if (ppd &&
|
|
|
|
+ (ppdattr = ppdFindAttr(ppd, "cupsSNMPQuirks", NULL)) != NULL &&
|
|
|
|
+ ppdattr->value)
|
2010-04-13 11:22:19 +00:00
|
|
|
+ {
|
2010-06-09 15:52:18 +00:00
|
|
|
+ ptr = ppdattr->value;
|
|
|
|
+ while (*ptr != '\0')
|
2010-04-13 11:22:19 +00:00
|
|
|
+ {
|
2010-06-09 15:52:18 +00:00
|
|
|
+ /*
|
|
|
|
+ * Match keyword against quirk_names table.
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ for (i = 0; i < sizeof (quirk_names) / sizeof (quirk_names[0]); i++)
|
|
|
|
+ {
|
|
|
|
+ len = strlen (quirk_names[i].keyword);
|
2010-08-23 10:22:55 +00:00
|
|
|
+ if (!strncmp (ptr, quirk_names[i].keyword, len) &&
|
|
|
|
+ (ptr[len] == '\0' || ptr[len] == ' '))
|
2010-06-09 15:52:18 +00:00
|
|
|
+ quirks |= quirk_names[i].bit;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * Advance to next keyword.
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ ptr += strcspn (ptr, " ");
|
|
|
|
+ ptr += strspn (ptr, " ");
|
2010-04-13 11:22:19 +00:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2010-06-09 15:52:18 +00:00
|
|
|
ppdClose(ppd);
|
|
|
|
|
2010-04-13 11:22:19 +00:00
|
|
|
/*
|