]>
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/".
12 * This file is subject to the Apple OS-Developed Software exception.
16 * Include necessary headers.
19 #include "backend-private.h"
23 * 'main()' - Show the supplies state of a printer.
26 int /* O - Exit status */
27 main(int argc
, /* I - Number of command-line args */
28 char *argv
[]) /* I - Command-line arguments */
30 http_addrlist_t
*host
; /* Host addresses */
31 int snmp_fd
; /* SNMP socket */
32 int page_count
, /* Current page count */
33 printer_state
; /* Current printer state */
38 puts("Usage: testsupplies ip-or-hostname");
42 if ((host
= httpAddrGetList(argv
[1], AF_UNSPEC
, "9100")) == NULL
)
48 if ((snmp_fd
= _cupsSNMPOpen(host
->addr
.addr
.sa_family
)) < 0)
56 fputs("backendSNMPSupplies: ", stdout
);
58 if (backendSNMPSupplies(snmp_fd
, &(host
->addr
), &page_count
,
65 printf("backendSNMPSupplies: %s (page_count=%d, printer_state=%d)\n",
66 page_count
< 0 || printer_state
< CUPS_TC_other
||
67 printer_state
> CUPS_TC_warmup
? "FAIL" : "PASS",
68 page_count
, printer_state
);