1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
/*
* "$Id: testsupplies.c 3247 2011-05-12 06:22:31Z msweet $"
*
* SNMP supplies test program for CUPS.
*
* Copyright 2008-2011 by Apple Inc.
*
* 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() - Show the supplies state of a printer.
*/
/*
* Include necessary headers.
*/
#include "backend-private.h"
/*
* 'main()' - Show the supplies state of a printer.
*/
int /* O - Exit status */
main(int argc, /* I - Number of command-line args */
char *argv[]) /* I - Command-line arguments */
{
http_addrlist_t *host; /* Host addresses */
int snmp_fd; /* SNMP socket */
int page_count, /* Current page count */
printer_state; /* Current printer state */
if (argc != 2)
{
puts("Usage: testsupplies ip-or-hostname");
return (1);
}
if ((host = httpAddrGetList(argv[1], AF_UNSPEC, "9100")) == NULL)
{
perror(argv[1]);
return (1);
}
if ((snmp_fd = _cupsSNMPOpen(host->addr.addr.sa_family)) < 0)
{
perror(argv[1]);
return (1);
}
for (;;)
{
fputs("backendSNMPSupplies: ", stdout);
if (backendSNMPSupplies(snmp_fd, &(host->addr), &page_count,
&printer_state))
{
puts("FAIL");
return (1);
}
printf("backendSNMPSupplies: %s (page_count=%d, printer_state=%d)\n",
page_count < 0 || printer_state < CUPS_TC_other ||
printer_state > CUPS_TC_warmup ? "FAIL" : "PASS",
page_count, printer_state);
sleep(5);
}
}
/*
* End of "$Id: testsupplies.c 3247 2011-05-12 06:22:31Z msweet $".
*/
|