]> git.ipfire.org Git - thirdparty/cups.git/blame - backend/testsupplies.c
Changelog.
[thirdparty/cups.git] / backend / testsupplies.c
CommitLineData
f089e349 1/*
2 * "$Id$"
3 *
5b9bc2e0 4 * SNMP supplies test program for CUPS.
f089e349 5 *
5b9bc2e0 6 * Copyright 2008-2011 by Apple Inc.
f089e349 7 *
8 * These coded instructions, statements, and computer programs are the
9 * property of Apple Inc. and are protected by Federal copyright
10 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
11 * "LICENSE" which should have been included with this file. If this
12 * file is missing or damaged, see the license at "http://www.cups.org/".
13 *
14 * This file is subject to the Apple OS-Developed Software exception.
15 *
16 * Contents:
17 *
18 * main() - Show the supplies state of a printer.
19 */
20
21/*
22 * Include necessary headers.
23 */
24
25#include "backend-private.h"
26
27
28/*
29 * 'main()' - Show the supplies state of a printer.
30 */
31
32int /* O - Exit status */
33main(int argc, /* I - Number of command-line args */
34 char *argv[]) /* I - Command-line arguments */
35{
36 http_addrlist_t *host; /* Host addresses */
37 int snmp_fd; /* SNMP socket */
38 int page_count, /* Current page count */
39 printer_state; /* Current printer state */
40
41
42 if (argc != 2)
43 {
44 puts("Usage: testsupplies ip-or-hostname");
45 return (1);
46 }
47
48 if ((host = httpAddrGetList(argv[1], AF_UNSPEC, "9100")) == NULL)
49 {
50 perror(argv[1]);
51 return (1);
52 }
53
b9e7ae13 54 if ((snmp_fd = _cupsSNMPOpen(host->addr.addr.sa_family)) < 0)
f089e349 55 {
56 perror(argv[1]);
57 return (1);
58 }
59
60 for (;;)
61 {
5ba153ab 62 fputs("backendSNMPSupplies: ", stdout);
63
64 if (backendSNMPSupplies(snmp_fd, &(host->addr), &page_count,
65 &printer_state))
66 {
67 puts("FAIL");
68 return (1);
69 }
f089e349 70
71 printf("backendSNMPSupplies: %s (page_count=%d, printer_state=%d)\n",
2f0e849a 72 page_count < 0 || printer_state < CUPS_TC_other ||
f089e349 73 printer_state > CUPS_TC_warmup ? "FAIL" : "PASS",
74 page_count, printer_state);
75
76 sleep(5);
77 }
78}
79
80
81/*
82 * End of "$Id$".
83 */