]>
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 * Licensed under Apache License v2.0. See the file "LICENSE" for more
11 * Include necessary headers.
14 #include "backend-private.h"
18 * 'main()' - Show the supplies state of a printer.
21 int /* O - Exit status */
22 main(int argc
, /* I - Number of command-line args */
23 char *argv
[]) /* I - Command-line arguments */
25 http_addrlist_t
*host
; /* Host addresses */
26 int snmp_fd
; /* SNMP socket */
27 int page_count
, /* Current page count */
28 printer_state
; /* Current printer state */
33 puts("Usage: testsupplies ip-or-hostname");
37 if ((host
= httpAddrGetList(argv
[1], AF_UNSPEC
, "9100")) == NULL
)
43 if ((snmp_fd
= _cupsSNMPOpen(host
->addr
.addr
.sa_family
)) < 0)
51 fputs("backendSNMPSupplies: ", stdout
);
53 if (backendSNMPSupplies(snmp_fd
, &(host
->addr
), &page_count
,
60 printf("backendSNMPSupplies: %s (page_count=%d, printer_state=%d)\n",
61 page_count
< 0 || printer_state
< CUPS_TC_other
||
62 printer_state
> CUPS_TC_warmup
? "FAIL" : "PASS",
63 page_count
, printer_state
);