]> git.ipfire.org Git - thirdparty/cups.git/blame - backend/testbackend.c
Import CUPS v1.7.1
[thirdparty/cups.git] / backend / testbackend.c
CommitLineData
568fa3fa 1/*
61515785 2 * "$Id: testbackend.c 4297 2013-05-10 16:04:59Z msweet $"
568fa3fa 3 *
71e16022 4 * Backend test program for CUPS.
568fa3fa 5 *
dcb445bc 6 * Copyright 2007-2012 by Apple Inc.
568fa3fa
MS
7 * Copyright 1997-2005 by Easy Software Products, all rights reserved.
8 *
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * "LICENSE" which should have been included with this file. If this
13 * file is missing or damaged, see the license at "http://www.cups.org/".
14 *
15 * This file is subject to the Apple OS-Developed Software exception.
16 *
17 * Contents:
18 *
97c9a8d7
MS
19 * main() - Run the named backend.
20 * sigterm_handler() - Flag when we get SIGTERM.
21 * usage() - Show usage information.
22 * walk_cb() - Show results of cupsSideChannelSNMPWalk...
568fa3fa
MS
23 */
24
25/*
26 * Include necessary headers.
27 */
28
71e16022 29#include <cups/string-private.h>
568fa3fa
MS
30#include <cups/cups.h>
31#include <cups/sidechannel.h>
32#include <unistd.h>
33#include <fcntl.h>
568fa3fa 34#include <sys/wait.h>
97c9a8d7
MS
35#include <signal.h>
36
37
38/*
39 * Local globals...
40 */
41
42static int job_canceled = 0;
568fa3fa
MS
43
44
45/*
46 * Local functions...
47 */
48
97c9a8d7 49static void sigterm_handler(int sig);
85dda01c 50static void usage(void) __attribute__((noreturn));
b9faaae1
MS
51static void walk_cb(const char *oid, const char *data, int datalen,
52 void *context);
568fa3fa
MS
53
54
55/*
56 * 'main()' - Run the named backend.
57 *
58 * Usage:
59 *
dcb445bc 60 * testbackend [-s] [-t] device-uri job-id user title copies options [file]
568fa3fa
MS
61 */
62
63int /* O - Exit status */
64main(int argc, /* I - Number of command-line args */
65 char *argv[]) /* I - Command-line arguments */
66{
67 int first_arg, /* First argument for backend */
97c9a8d7 68 do_cancel = 0, /* Simulate a cancel-job via SIGTERM */
e07d4801
MS
69 do_ps = 0, /* Do PostScript query+test? */
70 do_pcl = 0, /* Do PCL query+test? */
568fa3fa 71 do_side_tests = 0, /* Test side-channel ops? */
b9faaae1
MS
72 do_trickle = 0, /* Trickle data to backend */
73 do_walk = 0, /* Do OID lookup (0) or walking (1) */
74 show_log = 0; /* Show log messages from backends? */
75 const char *oid = ".1.3.6.1.2.1.43.10.2.1.4.1.1";
76 /* OID to lookup or walk */
568fa3fa 77 char scheme[255], /* Scheme in URI == backend */
dcb445bc
MS
78 backend[1024], /* Backend path */
79 libpath[1024], /* Path for libcups */
80 *ptr; /* Pointer into path */
568fa3fa 81 const char *serverbin; /* CUPS_SERVERBIN environment variable */
97c9a8d7
MS
82 int fd, /* Temporary file descriptor */
83 back_fds[2], /* Back-channel pipe */
568fa3fa
MS
84 side_fds[2], /* Side-channel socket */
85 data_fds[2], /* Data pipe */
97c9a8d7
MS
86 back_pid = -1, /* Backend process ID */
87 data_pid = -1, /* Trickle process ID */
568fa3fa
MS
88 pid, /* Process ID */
89 status; /* Exit status */
90
91
dcb445bc
MS
92 /*
93 * Get the current directory and point the run-time linker at the "cups"
94 * subdirectory...
95 */
96
97 if (getcwd(libpath, sizeof(libpath)) &&
98 (ptr = strrchr(libpath, '/')) != NULL && !strcmp(ptr, "/backend"))
99 {
100 strlcpy(ptr, "/cups", sizeof(libpath) - (ptr - libpath));
3e7fe0ca
MS
101 if (!access(libpath, 0))
102 {
dcb445bc 103#ifdef __APPLE__
3e7fe0ca 104 fprintf(stderr, "Setting DYLD_LIBRARY_PATH to \"%s\".\n", libpath);
dcb445bc
MS
105 setenv("DYLD_LIBRARY_PATH", libpath, 1);
106#else
3e7fe0ca 107 fprintf(stderr, "Setting LD_LIBRARY_PATH to \"%s\".\n", libpath);
dcb445bc
MS
108 setenv("LD_LIBRARY_PATH", libpath, 1);
109#endif /* __APPLE__ */
3e7fe0ca
MS
110 }
111 else
112 perror(libpath);
dcb445bc
MS
113 }
114
568fa3fa
MS
115 /*
116 * See if we have side-channel tests to do...
117 */
118
119 for (first_arg = 1;
120 argv[first_arg] && argv[first_arg][0] == '-';
121 first_arg ++)
b9faaae1
MS
122 if (!strcmp(argv[first_arg], "-d"))
123 show_log = 1;
97c9a8d7
MS
124 else if (!strcmp(argv[first_arg], "-cancel"))
125 do_cancel = 1;
e07d4801
MS
126 else if (!strcmp(argv[first_arg], "-pcl"))
127 do_pcl = 1;
b9faaae1 128 else if (!strcmp(argv[first_arg], "-ps"))
e07d4801 129 do_ps = 1;
634763e8 130 else if (!strcmp(argv[first_arg], "-s"))
568fa3fa
MS
131 do_side_tests = 1;
132 else if (!strcmp(argv[first_arg], "-t"))
133 do_trickle = 1;
b9faaae1
MS
134 else if (!strcmp(argv[first_arg], "-get") && (first_arg + 1) < argc)
135 {
136 first_arg ++;
137
138 do_side_tests = 1;
139 oid = argv[first_arg];
140 }
141 else if (!strcmp(argv[first_arg], "-walk") && (first_arg + 1) < argc)
142 {
143 first_arg ++;
144
145 do_side_tests = 1;
146 do_walk = 1;
147 oid = argv[first_arg];
148 }
568fa3fa
MS
149 else
150 usage();
151
152 argc -= first_arg;
153 if (argc < 6 || argc > 7 || (argc == 7 && do_trickle))
154 usage();
155
156 /*
157 * Extract the scheme from the device-uri - that's the program we want to
158 * execute.
159 */
160
161 if (sscanf(argv[first_arg], "%254[^:]", scheme) != 1)
162 {
163 fputs("testbackend: Bad device-uri - no colon!\n", stderr);
164 return (1);
165 }
166
167 if (!access(scheme, X_OK))
168 strlcpy(backend, scheme, sizeof(backend));
169 else
170 {
171 if ((serverbin = getenv("CUPS_SERVERBIN")) == NULL)
172 serverbin = CUPS_SERVERBIN;
173
174 snprintf(backend, sizeof(backend), "%s/backend/%s", serverbin, scheme);
175 if (access(backend, X_OK))
176 {
177 fprintf(stderr, "testbackend: Unknown device scheme \"%s\"!\n", scheme);
178 return (1);
179 }
180 }
181
182 /*
183 * Create the back-channel pipe and side-channel socket...
184 */
185
186 open("/dev/null", O_WRONLY); /* Make sure fd 3 and 4 are used */
187 open("/dev/null", O_WRONLY);
188
189 pipe(back_fds);
190 fcntl(back_fds[0], F_SETFL, fcntl(back_fds[0], F_GETFL) | O_NONBLOCK);
191 fcntl(back_fds[1], F_SETFL, fcntl(back_fds[1], F_GETFL) | O_NONBLOCK);
192
193 socketpair(AF_LOCAL, SOCK_STREAM, 0, side_fds);
194 fcntl(side_fds[0], F_SETFL, fcntl(side_fds[0], F_GETFL) | O_NONBLOCK);
195 fcntl(side_fds[1], F_SETFL, fcntl(side_fds[1], F_GETFL) | O_NONBLOCK);
196
197 /*
198 * Execute the trickle process as needed...
199 */
200
97c9a8d7 201 if (do_trickle || do_pcl || do_ps || do_cancel)
568fa3fa
MS
202 {
203 pipe(data_fds);
204
97c9a8d7
MS
205 signal(SIGTERM, sigterm_handler);
206
207 if ((data_pid = fork()) == 0)
568fa3fa
MS
208 {
209 /*
e07d4801
MS
210 * Trickle/query child comes here. Rearrange file descriptors so that
211 * FD 1, 3, and 4 point to the backend...
568fa3fa
MS
212 */
213
97c9a8d7
MS
214 if ((fd = open("/dev/null", O_RDONLY)) != 0)
215 {
216 dup2(fd, 0);
217 close(fd);
218 }
568fa3fa 219
97c9a8d7
MS
220 if (data_fds[1] != 1)
221 {
222 dup2(data_fds[1], 1);
223 close(data_fds[1]);
224 }
568fa3fa 225 close(data_fds[0]);
634763e8 226
97c9a8d7
MS
227 if (back_fds[0] != 3)
228 {
229 dup2(back_fds[0], 3);
230 close(back_fds[0]);
231 }
634763e8
MS
232 close(back_fds[1]);
233
97c9a8d7
MS
234 if (side_fds[0] != 4)
235 {
236 dup2(side_fds[0], 4);
237 close(side_fds[0]);
238 }
634763e8
MS
239 close(side_fds[1]);
240
241 if (do_trickle)
242 {
243 /*
244 * Write 10 spaces, 1 per second...
245 */
246
247 int i; /* Looping var */
248
249 for (i = 0; i < 10; i ++)
250 {
251 write(1, " ", 1);
252 sleep(1);
253 }
254 }
97c9a8d7
MS
255 else if (do_cancel)
256 {
257 /*
258 * Write PS or PCL lines until we see SIGTERM...
259 */
260
261 int line = 0, page = 0; /* Current line and page */
262 ssize_t bytes; /* Number of bytes of response data */
263 char buffer[1024]; /* Output buffer */
264
265
266 if (do_pcl)
267 write(1, "\033E", 2);
268 else
269 write(1, "%!\n/Courier findfont 12 scalefont setfont 0 setgray\n", 52);
270
271 while (!job_canceled)
272 {
273 if (line == 0)
274 {
275 page ++;
276
277 if (do_pcl)
278 snprintf(buffer, sizeof(buffer), "PCL Page %d\r\n\r\n", page);
279 else
280 snprintf(buffer, sizeof(buffer),
281 "18 732 moveto (PS Page %d) show\n", page);
282
283 write(1, buffer, strlen(buffer));
284 }
285
286 line ++;
287
288 if (do_pcl)
289 snprintf(buffer, sizeof(buffer), "Line %d\r\n", line);
290 else
291 snprintf(buffer, sizeof(buffer), "18 %d moveto (Line %d) show\n",
292 720 - line * 12, line);
293
294 write(1, buffer, strlen(buffer));
295
296 if (line >= 55)
297 {
298 /*
299 * Eject after 55 lines...
300 */
301
302 line = 0;
303 if (do_pcl)
304 write(1, "\014", 1);
305 else
306 write(1, "showpage\n", 9);
307 }
308
309 /*
310 * Check for back-channel data...
311 */
312
313 if ((bytes = cupsBackChannelRead(buffer, sizeof(buffer), 0)) > 0)
314 write(2, buffer, bytes);
315
316 /*
317 * Throttle output to ~100hz...
318 */
319
320 usleep(10000);
321 }
322
323 /*
324 * Eject current page with info...
325 */
326
327 if (do_pcl)
328 snprintf(buffer, sizeof(buffer),
329 "Canceled on line %d of page %d\r\n\014\033E", line, page);
330 else
331 snprintf(buffer, sizeof(buffer),
332 "\n18 %d moveto (Canceled on line %d of page %d)\nshowpage\n",
333 720 - line * 12, line, page);
334
335 write(1, buffer, strlen(buffer));
336
337 /*
338 * See if we get any back-channel data...
339 */
340
341 while ((bytes = cupsBackChannelRead(buffer, sizeof(buffer), 5.0)) > 0)
342 write(2, buffer, bytes);
343
344 exit(0);
345 }
634763e8 346 else
568fa3fa
MS
347 {
348 /*
e07d4801 349 * Do PS or PCL query + test pages.
568fa3fa
MS
350 */
351
e07d4801
MS
352 char buffer[1024]; /* Buffer for response data */
353 ssize_t bytes; /* Number of bytes of response data */
354 double timeout; /* Timeout */
355 const char *data; /* Data to send */
356 static const char *pcl_data = /* PCL data */
357 "\033%-12345X@PJL\r\n"
358 "@PJL JOB NAME = \"Hello, World!\"\r\n"
359 "@PJL INFO USTATUS\r\n"
360 "@PJL ENTER LANGUAGE = PCL\r\n"
361 "\033E"
362 "Hello, World!\n"
363 "\014"
364 "\033%-12345X@PJL\r\n"
365 "@PJL EOJ NAME=\"Hello, World!\"\r\n"
366 "\033%-12345X";
367 static const char *ps_data = /* PostScript data */
634763e8
MS
368 "%!\n"
369 "save\n"
b9faaae1 370 "product = flush\n"
634763e8
MS
371 "currentpagedevice /PageSize get aload pop\n"
372 "2 copy gt {exch} if\n"
373 "(Unknown)\n"
374 "19 dict\n"
375 "dup [612 792] (Letter) put\n"
376 "dup [612 1008] (Legal) put\n"
377 "dup [612 935] (w612h935) put\n"
378 "dup [522 756] (Executive) put\n"
379 "dup [595 842] (A4) put\n"
380 "dup [420 595] (A5) put\n"
381 "dup [499 709] (ISOB5) put\n"
382 "dup [516 728] (B5) put\n"
383 "dup [612 936] (w612h936) put\n"
384 "dup [284 419] (Postcard) put\n"
385 "dup [419.5 567] (DoublePostcard) put\n"
386 "dup [558 774] (w558h774) put\n"
387 "dup [553 765] (w553h765) put\n"
388 "dup [522 737] (w522h737) put\n"
389 "dup [499 709] (EnvISOB5) put\n"
390 "dup [297 684] (Env10) put\n"
391 "dup [459 649] (EnvC5) put\n"
392 "dup [312 624] (EnvDL) put\n"
393 "dup [279 540] (EnvMonarch) put\n"
394 "{ exch aload pop 4 index sub abs 5 le exch\n"
395 " 5 index sub abs 5 le and\n"
396 " {exch pop exit} {pop} ifelse\n"
397 "} bind forall\n"
398 "= flush pop pop\n"
e07d4801
MS
399 "/Courier findfont 12 scalefont setfont\n"
400 "0 setgray 36 720 moveto (Hello, ) show product show (!) show\n"
401 "showpage\n"
634763e8
MS
402 "restore\n"
403 "\004";
404
405
e07d4801
MS
406 if (do_pcl)
407 data = pcl_data;
408 else
409 data = ps_data;
410
411 write(1, data, strlen(data));
634763e8 412 write(2, "DEBUG: START\n", 13);
e07d4801
MS
413 timeout = 60.0;
414 while ((bytes = cupsBackChannelRead(buffer, sizeof(buffer),
415 timeout)) > 0)
416 {
634763e8 417 write(2, buffer, bytes);
e07d4801
MS
418 timeout = 5.0;
419 }
634763e8 420 write(2, "\nDEBUG: END\n", 12);
568fa3fa
MS
421 }
422
423 exit(0);
424 }
97c9a8d7 425 else if (data_pid < 0)
568fa3fa
MS
426 {
427 perror("testbackend: Unable to fork");
428 return (1);
429 }
430 }
431 else
432 data_fds[0] = data_fds[1] = -1;
433
434 /*
435 * Execute the backend...
436 */
437
97c9a8d7 438 if ((back_pid = fork()) == 0)
568fa3fa
MS
439 {
440 /*
441 * Child comes here...
442 */
443
97c9a8d7 444 if (do_trickle || do_ps || do_pcl || do_cancel)
568fa3fa 445 {
97c9a8d7
MS
446 if (data_fds[0] != 0)
447 {
448 dup2(data_fds[0], 0);
449 close(data_fds[0]);
450 }
568fa3fa
MS
451 close(data_fds[1]);
452 }
453
b9faaae1
MS
454 if (!show_log)
455 {
97c9a8d7
MS
456 if ((fd = open("/dev/null", O_WRONLY)) != 2)
457 {
458 dup2(fd, 2);
459 close(fd);
460 }
b9faaae1
MS
461 }
462
97c9a8d7
MS
463 if (back_fds[1] != 3)
464 {
465 dup2(back_fds[1], 3);
466 close(back_fds[0]);
467 }
568fa3fa
MS
468 close(back_fds[1]);
469
97c9a8d7
MS
470 if (side_fds[1] != 4)
471 {
472 dup2(side_fds[1], 4);
473 close(side_fds[0]);
474 }
568fa3fa
MS
475 close(side_fds[1]);
476
477 execv(backend, argv + first_arg);
1340db2d 478 fprintf(stderr, "testbackend: Unable to execute \"%s\": %s\n", backend,
568fa3fa
MS
479 strerror(errno));
480 return (errno);
481 }
97c9a8d7 482 else if (back_pid < 0)
568fa3fa
MS
483 {
484 perror("testbackend: Unable to fork");
485 return (1);
486 }
487
488 /*
489 * Parent comes here, setup back and side channel file descriptors...
490 */
491
97c9a8d7 492 if (do_trickle || do_ps || do_pcl || do_cancel)
568fa3fa
MS
493 {
494 close(data_fds[0]);
495 close(data_fds[1]);
496 }
497
97c9a8d7
MS
498 if (back_fds[0] != 3)
499 {
500 dup2(back_fds[0], 3);
501 close(back_fds[0]);
502 }
568fa3fa
MS
503 close(back_fds[1]);
504
97c9a8d7
MS
505 if (side_fds[0] != 4)
506 {
507 dup2(side_fds[0], 4);
508 close(side_fds[0]);
509 }
568fa3fa
MS
510 close(side_fds[1]);
511
512 /*
513 * Do side-channel tests as needed, then wait for the backend...
514 */
515
516 if (do_side_tests)
517 {
518 int length; /* Length of buffer */
519 char buffer[2049]; /* Buffer for reponse */
520 cups_sc_status_t scstatus; /* Status of side-channel command */
521 static const char * const statuses[] =
522 {
523 "CUPS_SC_STATUS_NONE", /* No status */
524 "CUPS_SC_STATUS_OK", /* Operation succeeded */
525 "CUPS_SC_STATUS_IO_ERROR", /* An I/O error occurred */
526 "CUPS_SC_STATUS_TIMEOUT", /* The backend did not respond */
527 "CUPS_SC_STATUS_NO_RESPONSE", /* The device did not respond */
528 "CUPS_SC_STATUS_BAD_MESSAGE", /* The command/response message was invalid */
529 "CUPS_SC_STATUS_TOO_BIG", /* Response too big */
530 "CUPS_SC_STATUS_NOT_IMPLEMENTED" /* Command not implemented */
531 };
532
533
20fbc903
MS
534 sleep(2);
535
568fa3fa
MS
536 length = 0;
537 scstatus = cupsSideChannelDoRequest(CUPS_SC_CMD_DRAIN_OUTPUT, buffer,
1340db2d 538 &length, 60.0);
568fa3fa
MS
539 printf("CUPS_SC_CMD_DRAIN_OUTPUT returned %s\n", statuses[scstatus]);
540
541 length = 1;
542 scstatus = cupsSideChannelDoRequest(CUPS_SC_CMD_GET_BIDI, buffer,
543 &length, 5.0);
544 printf("CUPS_SC_CMD_GET_BIDI returned %s, %d\n", statuses[scstatus], buffer[0]);
545
546 length = sizeof(buffer) - 1;
547 scstatus = cupsSideChannelDoRequest(CUPS_SC_CMD_GET_DEVICE_ID, buffer,
548 &length, 5.0);
549 buffer[length] = '\0';
550 printf("CUPS_SC_CMD_GET_DEVICE_ID returned %s, \"%s\"\n",
551 statuses[scstatus], buffer);
552
553 length = 1;
554 scstatus = cupsSideChannelDoRequest(CUPS_SC_CMD_GET_STATE, buffer,
555 &length, 5.0);
556 printf("CUPS_SC_CMD_GET_STATE returned %s, %02X\n", statuses[scstatus],
557 buffer[0] & 255);
558
b9faaae1
MS
559 if (do_walk)
560 {
561 /*
562 * Walk the OID tree...
563 */
564
565 scstatus = cupsSideChannelSNMPWalk(oid, 5.0, walk_cb, NULL);
566 printf("CUPS_SC_CMD_SNMP_WALK returned %s\n", statuses[scstatus]);
567 }
568 else
569 {
570 /*
571 * Lookup the same OID twice...
572 */
573
574 length = sizeof(buffer);
575 scstatus = cupsSideChannelSNMPGet(oid, buffer, &length, 5.0);
82cc1f9a
MS
576 printf("CUPS_SC_CMD_SNMP_GET %s returned %s, %d bytes (%s)\n", oid,
577 statuses[scstatus], (int)length, buffer);
b9faaae1
MS
578
579 length = sizeof(buffer);
580 scstatus = cupsSideChannelSNMPGet(oid, buffer, &length, 5.0);
82cc1f9a
MS
581 printf("CUPS_SC_CMD_SNMP_GET %s returned %s, %d bytes (%s)\n", oid,
582 statuses[scstatus], (int)length, buffer);
b9faaae1 583 }
20fbc903 584
568fa3fa
MS
585 length = 0;
586 scstatus = cupsSideChannelDoRequest(CUPS_SC_CMD_SOFT_RESET, buffer,
587 &length, 5.0);
588 printf("CUPS_SC_CMD_SOFT_RESET returned %s\n", statuses[scstatus]);
589 }
590
97c9a8d7 591 if (do_cancel)
568fa3fa 592 {
97c9a8d7
MS
593 sleep(1);
594 kill(data_pid, SIGTERM);
595 kill(back_pid, SIGTERM);
596 }
85dda01c 597
97c9a8d7
MS
598 while ((pid = wait(&status)) > 0)
599 {
600 if (status)
601 {
602 if (WIFEXITED(status))
603 printf("%s exited with status %d!\n",
604 pid == back_pid ? backend : "test",
605 WEXITSTATUS(status));
606 else
607 printf("%s crashed with signal %d!\n",
608 pid == back_pid ? backend : "test",
609 WTERMSIG(status));
610 }
568fa3fa
MS
611 }
612
613 /*
614 * Exit accordingly...
615 */
616
617 return (status != 0);
618}
619
620
97c9a8d7
MS
621/*
622 * 'sigterm_handler()' - Flag when we get SIGTERM.
623 */
624
625static void
626sigterm_handler(int sig) /* I - Signal */
627{
628 (void)sig;
629
630 job_canceled = 1;
631}
632
633
568fa3fa
MS
634/*
635 * 'usage()' - Show usage information.
636 */
637
638static void
639usage(void)
640{
82cc1f9a 641 puts("Usage: testbackend [-cancel] [-d] [-ps | -pcl] [-s [-get OID] "
97c9a8d7 642 "[-walk OID]] [-t] device-uri job-id user title copies options [file]");
b9faaae1
MS
643 puts("");
644 puts("Options:");
97c9a8d7 645 puts(" -cancel Simulate a canceled print job after 2 seconds.");
b9faaae1 646 puts(" -d Show log messages from backend.");
82cc1f9a 647 puts(" -get OID Lookup the specified SNMP OID.");
1340db2d 648 puts(" (.1.3.6.1.2.1.43.10.2.1.4.1.1 is a good one for printers)");
e07d4801
MS
649 puts(" -pcl Send PCL+PJL query and test page to backend.");
650 puts(" -ps Send PostScript query and test page to backend.");
1340db2d 651 puts(" -s Do side-channel + SNMP tests.");
b9faaae1
MS
652 puts(" -t Send spaces slowly to backend ('trickle').");
653 puts(" -walk OID Walk the specified SNMP OID.");
1340db2d 654 puts(" (.1.3.6.1.2.1.43 is a good one for printers)");
b9faaae1 655
568fa3fa
MS
656 exit(1);
657}
658
659
b9faaae1
MS
660/*
661 * 'walk_cb()' - Show results of cupsSideChannelSNMPWalk...
662 */
663
664static void
665walk_cb(const char *oid, /* I - OID */
666 const char *data, /* I - Data */
667 int datalen, /* I - Length of data */
668 void *context) /* I - Context (unused) */
669{
94436c5a
MS
670 char temp[80];
671 if (datalen > (sizeof(temp) - 1))
672 {
673 memcpy(temp, data, sizeof(temp) - 1);
674 temp[sizeof(temp) - 1] = '\0';
675 }
676 else
677 {
678 memcpy(temp, data, datalen);
679 temp[datalen] = '\0';
680 }
681
682 printf("CUPS_SC_CMD_SNMP_WALK %s, %d bytes (%s)\n", oid, datalen, temp);
b9faaae1
MS
683}
684
685
568fa3fa 686/*
61515785 687 * End of "$Id: testbackend.c 4297 2013-05-10 16:04:59Z msweet $".
568fa3fa 688 */