/*
* "$Id$"
*
- * Backend test program for CUPS.
+ * Backend test program for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2005 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2005 by Easy Software Products, all rights reserved.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * "LICENSE" which should have been included with this file. If this
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * "LICENSE" which should have been included with this file. If this
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * main() - Run the named backend.
- * sigterm_handler() - Flag when we get SIGTERM.
- * usage() - Show usage information.
- * walk_cb() - Show results of cupsSideChannelSNMPWalk...
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
if (getcwd(libpath, sizeof(libpath)) &&
(ptr = strrchr(libpath, '/')) != NULL && !strcmp(ptr, "/backend"))
{
- strlcpy(ptr, "/cups", sizeof(libpath) - (ptr - libpath));
+ strlcpy(ptr, "/cups", sizeof(libpath) - (size_t)(ptr - libpath));
if (!access(libpath, 0))
{
#ifdef __APPLE__
*/
if ((bytes = cupsBackChannelRead(buffer, sizeof(buffer), 0)) > 0)
- write(2, buffer, bytes);
+ write(2, buffer, (size_t)bytes);
/*
* Throttle output to ~100hz...
*/
while ((bytes = cupsBackChannelRead(buffer, sizeof(buffer), 5.0)) > 0)
- write(2, buffer, bytes);
+ write(2, buffer, (size_t)bytes);
exit(0);
}
while ((bytes = cupsBackChannelRead(buffer, sizeof(buffer),
timeout)) > 0)
{
- write(2, buffer, bytes);
+ write(2, buffer, (size_t)bytes);
timeout = 5.0;
}
write(2, "\nDEBUG: END\n", 12);
int datalen, /* I - Length of data */
void *context) /* I - Context (unused) */
{
- printf("CUPS_SC_CMD_SNMP_WALK %s, %d bytes (%s)\n", oid, datalen, data);
+ char temp[80];
+
+ (void)context;
+
+ if ((size_t)datalen > (sizeof(temp) - 1))
+ {
+ memcpy(temp, data, sizeof(temp) - 1);
+ temp[sizeof(temp) - 1] = '\0';
+ }
+ else
+ {
+ memcpy(temp, data, datalen);
+ temp[datalen] = '\0';
+ }
+
+ printf("CUPS_SC_CMD_SNMP_WALK %s, %d bytes (%s)\n", oid, datalen, temp);
}