Revert manifest to default one
[external/cups.git] / backend / testsupplies.c
1 /*
2  * "$Id: testsupplies.c 9771 2011-05-12 05:21:56Z mike $"
3  *
4  *   SNMP supplies test program for CUPS.
5  *
6  *   Copyright 2008-2011 by Apple Inc.
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
32 int                                     /* O - Exit status */
33 main(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
54   if ((snmp_fd = _cupsSNMPOpen(host->addr.addr.sa_family)) < 0)
55   {
56     perror(argv[1]);
57     return (1);
58   }
59
60   for (;;)
61   {
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     }
70
71     printf("backendSNMPSupplies: %s (page_count=%d, printer_state=%d)\n",
72            page_count < 0 || printer_state < CUPS_TC_other ||
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: testsupplies.c 9771 2011-05-12 05:21:56Z mike $".
83  */