]>
git.ipfire.org Git - thirdparty/cups.git/blob - backend/testsupplies.c
2 * SNMP supplies test program for CUPS.
4 * Copyright 2008-2011 by Apple Inc.
6 * These coded instructions, statements, and computer programs are the
7 * property of Apple Inc. and are protected by Federal copyright
8 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
9 * "LICENSE" which should have been included with this file. If this
10 * file is missing or damaged, see the license at "http://www.cups.org/".
14 * Include necessary headers.
17 #include "backend-private.h"
21 * 'main()' - Show the supplies state of a printer.
24 int /* O - Exit status */
25 main(int argc
, /* I - Number of command-line args */
26 char *argv
[]) /* I - Command-line arguments */
28 http_addrlist_t
*host
; /* Host addresses */
29 int snmp_fd
; /* SNMP socket */
30 int page_count
, /* Current page count */
31 printer_state
; /* Current printer state */
36 puts("Usage: testsupplies ip-or-hostname");
40 if ((host
= httpAddrGetList(argv
[1], AF_UNSPEC
, "9100")) == NULL
)
46 if ((snmp_fd
= _cupsSNMPOpen(host
->addr
.addr
.sa_family
)) < 0)
54 fputs("backendSNMPSupplies: ", stdout
);
56 if (backendSNMPSupplies(snmp_fd
, &(host
->addr
), &page_count
,
63 printf("backendSNMPSupplies: %s (page_count=%d, printer_state=%d)\n",
64 page_count
< 0 || printer_state
< CUPS_TC_other
||
65 printer_state
> CUPS_TC_warmup
? "FAIL" : "PASS",
66 page_count
, printer_state
);