]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - backend/snmp.c
Load cups into easysw/current.
[thirdparty/cups.git] / backend / snmp.c
index d571bf1059e789d99b9ee14849b8d63ced06dab5..8ac2dea4fd004c11f953fa41b194399c9d587fd9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: snmp.c 5453 2006-04-23 12:08:18Z mike $"
+ * "$Id: snmp.c 5663 2006-06-15 20:36:42Z mike $"
  *
  *   SNMP discovery backend for the Common UNIX Printing System (CUPS).
  *
  * Include necessary headers.
  */
 
-#include <cups/backend.h>
 #include <cups/http-private.h>
-#include <cups/cups.h>
-#include <cups/string.h>
+#include "backend-private.h"
 #include <cups/array.h>
 #include <cups/file.h>
-#include <errno.h>
-#include <signal.h>
-
-#define SNMP_BACKEND
-#include "ieee1284.c"
 
 
 /*
@@ -1244,7 +1237,7 @@ fix_make_model(
     const char *old_make_model,                /* I - Old make-and-model string */
     int        make_model_size)                /* I - Size of new string buffer */
 {
-  const char   *mmptr;                 /* Pointer into make-and-model string */
+  char *mmptr;                         /* Pointer into make-and-model string */
 
 
  /*
@@ -1259,7 +1252,7 @@ fix_make_model(
     * with a single HP manufacturer prefix...
     */
 
-    mmptr = old_make_model + 15;
+    mmptr = (char *)old_make_model + 15;
 
     while (isspace(*mmptr & 255))
       mmptr ++;
@@ -1292,7 +1285,16 @@ fix_make_model(
     * becomes "Tektronix Phaser 560"...
     */
 
-    _cups_strcpy((char *)mmptr, mmptr + 7);
+    _cups_strcpy(mmptr, mmptr + 7);
+  }
+
+  if ((mmptr = strchr(make_model, ',')) != NULL)
+  {
+   /*
+    * Drop anything after a trailing comma...
+    */
+
+    *mmptr = '\0';
   }
 }
 
@@ -1433,9 +1435,10 @@ list_devices(void)
        cache;
        cache = (snmp_cache_t *)cupsArrayNext(Devices))
     if (cache->uri)
-      printf("network %s \"%s\" \"%s\" \"%s\"\n",
+      printf("network %s \"%s\" \"%s %s\" \"%s\"\n",
              cache->uri,
             cache->make_and_model ? cache->make_and_model : "Unknown",
+            cache->make_and_model ? cache->make_and_model : "Unknown",
             cache->addrname, cache->id ? cache->id : "");
 }
 
@@ -1637,6 +1640,14 @@ probe_device(snmp_cache_t *device)       /* I - Device */
             !strchr(info->values[0].string.text, ';')))
          info = NULL;
 
+       /*
+        * Don't use the printer-make-and-model if it contains a generic
+       * string like "Ricoh IPP Printer"...
+       */
+
+       if (model && strstr(model->values[0].string.text, "IPP Printer"))
+         model = NULL;
+
        /*
         * If we don't have a printer-make-and-model string from the printer
        * but do have the 1284 device ID string, generate a make-and-model
@@ -1646,7 +1657,9 @@ probe_device(snmp_cache_t *device)        /* I - Device */
        if (model)
           strlcpy(temp, model->values[0].string.text, sizeof(temp));
        else if (info)
-         get_make_model(info->values[0].string.text, temp, sizeof(temp));
+         backendGetMakeModel(info->values[0].string.text, temp, sizeof(temp));
+        else
+         temp[0] = '\0';
 
         fix_make_model(make_model, temp, sizeof(make_model));
 
@@ -1918,8 +1931,8 @@ read_snmp_response(int fd)                /* I - SNMP socket file descriptor */
       * Description is the IEEE-1284 device ID...
       */
 
-      get_make_model(packet.object_value.string, make_model,
-                     sizeof(make_model));
+      backendGetMakeModel(packet.object_value.string, make_model,
+                         sizeof(make_model));
     }
     else
     {
@@ -2202,5 +2215,5 @@ update_cache(snmp_cache_t *device,        /* I - Device */
 
 
 /*
- * End of "$Id: snmp.c 5453 2006-04-23 12:08:18Z mike $".
+ * End of "$Id: snmp.c 5663 2006-06-15 20:36:42Z mike $".
  */