From 65608e0f8bbc0190cc1b7646f653e796c807f02b Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 27 Dec 2011 16:50:50 +0100 Subject: import cups from F16 --- cups-snmp-quirks.patch | 115 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 cups-snmp-quirks.patch (limited to 'cups-snmp-quirks.patch') diff --git a/cups-snmp-quirks.patch b/cups-snmp-quirks.patch new file mode 100644 index 0000000..fdc7cc5 --- /dev/null +++ b/cups-snmp-quirks.patch @@ -0,0 +1,115 @@ +diff -up cups-1.5b1/backend/snmp-supplies.c.snmp-quirks cups-1.5b1/backend/snmp-supplies.c +--- cups-1.5b1/backend/snmp-supplies.c.snmp-quirks 2011-05-20 05:49:49.000000000 +0200 ++++ cups-1.5b1/backend/snmp-supplies.c 2011-05-24 17:15:55.000000000 +0200 +@@ -47,6 +47,13 @@ + + + /* ++ * Printer quirks... ++ */ ++ ++#define QUIRK_CAPACITY (1<<0) ++ ++ ++/* + * Local structures... + */ + +@@ -66,6 +73,12 @@ typedef struct /**** Printer state ta + const char *keyword; /* IPP printer-state-reasons keyword */ + } backend_state_t; + ++typedef struct /**** Quirk names table ****/ ++{ ++ int bit; /* Quirk bit */ ++ const char *keyword; /* cupsSNMPQuirks keyword */ ++} quirk_name_t; ++ + + /* + * Local globals... +@@ -77,6 +90,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 */ + static int supply_state = -1; +@@ -176,6 +190,15 @@ static const backend_state_t const suppl + { CUPS_TONER_EMPTY, "toner-empty-warning" } + }; + ++static const quirk_name_t const quirk_names[] = ++ { ++ /* ++ * The prtMarkerSuppliesLevel values are ++ * percentages, not levels relative to the ++ * stated capacity. ++ */ ++ { QUIRK_CAPACITY, "capacity" } ++ }; + + /* + * Local functions... +@@ -229,6 +252,9 @@ backendSNMPSupplies( + + for (i = 0, ptr = value; i < num_supplies; i ++, ptr += strlen(ptr)) + { ++ if (quirks & QUIRK_CAPACITY) ++ supplies[i].max_capacity = 100; ++ + if (supplies[i].max_capacity > 0) + percent = 100 * supplies[i].level / supplies[i].max_capacity; + else +@@ -401,6 +427,7 @@ backend_init_supplies( + 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 */ +@@ -462,6 +489,7 @@ backend_init_supplies( + current_state = -1; + num_supplies = -1; + charset = -1; ++ quirks = 0; + + memset(supplies, 0, sizeof(supplies)); + +@@ -477,6 +505,34 @@ backend_init_supplies( + return; + } + ++ if (ppd && ++ (ppdattr = ppdFindAttr(ppd, "cupsSNMPQuirks", NULL)) != NULL && ++ ppdattr->value) ++ { ++ ptr = ppdattr->value; ++ while (*ptr != '\0') ++ { ++ /* ++ * Match keyword against quirk_names table. ++ */ ++ ++ for (i = 0; i < sizeof (quirk_names) / sizeof (quirk_names[0]); i++) ++ { ++ len = strlen (quirk_names[i].keyword); ++ if (!strncmp (ptr, quirk_names[i].keyword, len) && ++ (ptr[len] == '\0' || ptr[len] == ' ')) ++ quirks |= quirk_names[i].bit; ++ } ++ ++ /* ++ * Advance to next keyword. ++ */ ++ ++ ptr += strcspn (ptr, " "); ++ ptr += strspn (ptr, " "); ++ } ++ } ++ + ppdClose(ppd); + + /* -- cgit