/*
- * "$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"
/*
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 */
/*
* with a single HP manufacturer prefix...
*/
- mmptr = old_make_model + 15;
+ mmptr = (char *)old_make_model + 15;
while (isspace(*mmptr & 255))
mmptr ++;
* 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';
}
}
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 : "");
}
!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
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));
* 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
{
/*
- * 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 $".
*/