1 diff -up cups-1.4.3/backend/snmp-supplies.c.snmp-quirks cups-1.4.3/backend/snmp-supplies.c
2 --- cups-1.4.3/backend/snmp-supplies.c.snmp-quirks 2009-11-20 01:27:57.000000000 +0000
3 +++ cups-1.4.3/backend/snmp-supplies.c 2010-06-09 16:27:05.515019804 +0100
11 +#define QUIRK_CAPACITY (1<<0)
18 @@ -57,6 +64,12 @@ typedef struct /**** Printer state ta
19 const char *keyword; /* IPP printer-state-reasons keyword */
22 +typedef struct /**** Quirk names table ****/
24 + int bit; /* Quirk bit */
25 + const char *keyword; /* cupsSNMPQuirks keyword */
31 @@ -68,6 +81,7 @@ static int current_state = -1;
32 static int charset = -1; /* Character set for supply names */
33 static int num_supplies = 0;
34 /* Number of supplies found */
35 +static int quirks = 0; /* Printer quirks */
36 static backend_supplies_t supplies[CUPS_MAX_SUPPLIES];
37 /* Supply information */
39 @@ -153,6 +167,15 @@ static const backend_state_t const print
40 { CUPS_TC_outputFull, "output-area-full-warning" }
43 +static const quirk_name_t const quirk_names[] =
46 + * The prtMarkerSuppliesLevel values are
47 + * percentages, not levels relative to the
50 + { QUIRK_CAPACITY, "capacity" }
55 @@ -208,6 +231,9 @@ backendSNMPSupplies(
59 + if (quirks & QUIRK_CAPACITY)
60 + supplies[i].max_capacity = 100;
62 if (supplies[i].max_capacity > 0)
63 sprintf(ptr, "%d", 100 * supplies[i].level / supplies[i].max_capacity);
65 @@ -305,6 +331,7 @@ backend_init_supplies(
66 http_addr_t *addr) /* I - Printer address */
68 int i, /* Looping var */
69 + len, /* Quirk name length */
70 type; /* Current marker type */
71 cups_file_t *cachefile; /* Cache file */
72 const char *cachedir; /* CUPS_CACHEDIR value */
73 @@ -366,6 +393,7 @@ backend_init_supplies(
79 memset(supplies, 0, sizeof(supplies));
81 @@ -381,6 +409,34 @@ backend_init_supplies(
86 + (ppdattr = ppdFindAttr(ppd, "cupsSNMPQuirks", NULL)) != NULL &&
89 + ptr = ppdattr->value;
90 + while (*ptr != '\0')
93 + * Match keyword against quirk_names table.
96 + for (i = 0; i < sizeof (quirk_names) / sizeof (quirk_names[0]); i++)
98 + len = strlen (quirk_names[i].keyword);
99 + if (!strncmp (ptr, quirk_names[i].keyword, len) &&
100 + (ptr[len] == '\0' || ptr[len] == ' '))
101 + quirks |= quirk_names[i].bit;
105 + * Advance to next keyword.
108 + ptr += strcspn (ptr, " ");
109 + ptr += strspn (ptr, " ");