e663022
diff -up cups-1.4.7/backend/snmp-supplies.c.snmp-quirks cups-1.4.7/backend/snmp-supplies.c
e663022
--- cups-1.4.7/backend/snmp-supplies.c.snmp-quirks	2011-03-10 04:50:59.000000000 +0100
e663022
+++ cups-1.4.7/backend/snmp-supplies.c	2011-06-28 11:11:57.944155996 +0200
e663022
@@ -49,6 +49,13 @@
eb8e84b
 
eb8e84b
 
eb8e84b
 /*
eb8e84b
+ * Printer quirks...
eb8e84b
+ */
eb8e84b
+
2553f69
+#define QUIRK_CAPACITY	(1<<0)
eb8e84b
+
eb8e84b
+
eb8e84b
+/*
eb8e84b
  * Local structures...
eb8e84b
  */
eb8e84b
 
e663022
@@ -68,6 +75,12 @@ typedef struct				/**** Printer state ta
eb8e84b
   const char	*keyword;		/* IPP printer-state-reasons keyword */
eb8e84b
 } backend_state_t;
eb8e84b
 
2553f69
+typedef struct				/**** Quirk names table ****/
eb8e84b
+{
2553f69
+  int		bit;			/* Quirk bit */
2553f69
+  const char	*keyword;		/* cupsSNMPQuirks keyword */
2553f69
+} quirk_name_t;
eb8e84b
+
eb8e84b
 
eb8e84b
 /*
eb8e84b
  * Local globals...
e663022
@@ -79,6 +92,7 @@ static int		current_state = -1;
eb8e84b
 static int		charset = -1;	/* Character set for supply names */
eb8e84b
 static int		num_supplies = 0;
eb8e84b
 					/* Number of supplies found */
eb8e84b
+static int		quirks = 0;	/* Printer quirks */
eb8e84b
 static backend_supplies_t supplies[CUPS_MAX_SUPPLIES];
eb8e84b
 					/* Supply information */
e663022
 static int		supply_state = -1;
e663022
@@ -180,6 +194,15 @@ static const backend_state_t const suppl
e663022
 			  { CUPS_TONER_EMPTY, "toner-empty-warning" }
eb8e84b
 			};
eb8e84b
 
2553f69
+static const quirk_name_t const quirk_names[] =
eb8e84b
+			{
2553f69
+			 /*
2553f69
+			  * The prtMarkerSuppliesLevel values are
2553f69
+			  * percentages, not levels relative to the
2553f69
+			  * stated capacity.
2553f69
+			  */
2553f69
+			  { QUIRK_CAPACITY, "capacity" }
eb8e84b
+			};
eb8e84b
 
eb8e84b
 /*
eb8e84b
  * Local functions...
e663022
@@ -233,6 +256,9 @@ backendSNMPSupplies(
eb8e84b
 
e663022
     for (i = 0, ptr = value; i < num_supplies; i ++, ptr += strlen(ptr))
e663022
     {
2553f69
+      if (quirks & QUIRK_CAPACITY)
e663022
+        supplies[i].max_capacity = 100;
eb8e84b
+
e663022
       percent = 100 * supplies[i].level / supplies[i].max_capacity;
e663022
 
e663022
       if (percent <= 10)
e663022
@@ -406,6 +432,7 @@ backend_init_supplies(
2553f69
     http_addr_t *addr)			/* I - Printer address */
2553f69
 {
2553f69
   int		i,			/* Looping var */
2553f69
+		len,			/* Quirk name length */
2553f69
 		type;			/* Current marker type */
2553f69
   cups_file_t	*cachefile;		/* Cache file */
2553f69
   const char	*cachedir;		/* CUPS_CACHEDIR value */
e663022
@@ -467,6 +494,7 @@ backend_init_supplies(
eb8e84b
   current_state = -1;
eb8e84b
   num_supplies  = -1;
eb8e84b
   charset       = -1;
eb8e84b
+  quirks	= 0;
eb8e84b
 
eb8e84b
   memset(supplies, 0, sizeof(supplies));
eb8e84b
 
e663022
@@ -482,6 +510,34 @@ backend_init_supplies(
2553f69
     return;
2553f69
   }
eb8e84b
 
2553f69
+  if (ppd &&
2553f69
+      (ppdattr = ppdFindAttr(ppd, "cupsSNMPQuirks", NULL)) != NULL &&
2553f69
+      ppdattr->value)
eb8e84b
+  {
2553f69
+    ptr = ppdattr->value;
2553f69
+    while (*ptr != '\0')
eb8e84b
+    {
2553f69
+     /*
2553f69
+      * Match keyword against quirk_names table.
2553f69
+      */
2553f69
+
2553f69
+      for (i = 0; i < sizeof (quirk_names) / sizeof (quirk_names[0]); i++)
2553f69
+      {
2553f69
+	len = strlen (quirk_names[i].keyword);
d52d3c8
+	if (!strncmp (ptr, quirk_names[i].keyword, len) &&
d52d3c8
+	    (ptr[len] == '\0' || ptr[len] == ' '))
2553f69
+	  quirks |= quirk_names[i].bit;
2553f69
+      }
2553f69
+
2553f69
+     /*
2553f69
+      * Advance to next keyword.
2553f69
+      */
2553f69
+
2553f69
+      ptr += strcspn (ptr, " ");
2553f69
+      ptr += strspn (ptr, " ");
eb8e84b
+    }
eb8e84b
+  }
eb8e84b
+
2553f69
   ppdClose(ppd);
2553f69
 
eb8e84b
  /*