]> git.ipfire.org Git - thirdparty/cups.git/blame - backend/testsupplies.c
Remove all of the Subversion keywords from various source files.
[thirdparty/cups.git] / backend / testsupplies.c
CommitLineData
568fa3fa 1/*
503b54c9 2 * SNMP supplies test program for CUPS.
568fa3fa 3 *
503b54c9 4 * Copyright 2008-2011 by Apple Inc.
568fa3fa 5 *
503b54c9
MS
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/".
568fa3fa 11 *
503b54c9 12 * This file is subject to the Apple OS-Developed Software exception.
568fa3fa
MS
13 */
14
15/*
16 * Include necessary headers.
17 */
18
19#include "backend-private.h"
20
21
22/*
23 * 'main()' - Show the supplies state of a printer.
24 */
25
26int /* O - Exit status */
27main(int argc, /* I - Number of command-line args */
28 char *argv[]) /* I - Command-line arguments */
29{
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 */
34
35
36 if (argc != 2)
37 {
38 puts("Usage: testsupplies ip-or-hostname");
39 return (1);
40 }
41
42 if ((host = httpAddrGetList(argv[1], AF_UNSPEC, "9100")) == NULL)
43 {
44 perror(argv[1]);
45 return (1);
46 }
47
7a14d768 48 if ((snmp_fd = _cupsSNMPOpen(host->addr.addr.sa_family)) < 0)
568fa3fa
MS
49 {
50 perror(argv[1]);
51 return (1);
52 }
53
54 for (;;)
55 {
56 fputs("backendSNMPSupplies: ", stdout);
57
58 if (backendSNMPSupplies(snmp_fd, &(host->addr), &page_count,
59 &printer_state))
60 {
61 puts("FAIL");
62 return (1);
63 }
64
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);
69
70 sleep(5);
71 }
72}