]> git.ipfire.org Git - thirdparty/cups.git/blame - backend/testsupplies.c
Import CUPS v1.7.1
[thirdparty/cups.git] / backend / testsupplies.c
CommitLineData
568fa3fa 1/*
61515785 2 * "$Id: testsupplies.c 3247 2011-05-12 06:22:31Z msweet $"
568fa3fa 3 *
321d8d57 4 * SNMP supplies test program for CUPS.
568fa3fa 5 *
321d8d57 6 * Copyright 2008-2011 by Apple Inc.
568fa3fa
MS
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
32int /* O - Exit status */
33main(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
7a14d768 54 if ((snmp_fd = _cupsSNMPOpen(host->addr.addr.sa_family)) < 0)
568fa3fa
MS
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/*
61515785 82 * End of "$Id: testsupplies.c 3247 2011-05-12 06:22:31Z msweet $".
568fa3fa 83 */