]>
Commit | Line | Data |
---|---|---|
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 MS |
11 | */ |
12 | ||
13 | /* | |
14 | * Include necessary headers. | |
15 | */ | |
16 | ||
17 | #include "backend-private.h" | |
18 | ||
19 | ||
20 | /* | |
21 | * 'main()' - Show the supplies state of a printer. | |
22 | */ | |
23 | ||
24 | int /* O - Exit status */ | |
25 | main(int argc, /* I - Number of command-line args */ | |
26 | char *argv[]) /* I - Command-line arguments */ | |
27 | { | |
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 */ | |
32 | ||
33 | ||
34 | if (argc != 2) | |
35 | { | |
36 | puts("Usage: testsupplies ip-or-hostname"); | |
37 | return (1); | |
38 | } | |
39 | ||
40 | if ((host = httpAddrGetList(argv[1], AF_UNSPEC, "9100")) == NULL) | |
41 | { | |
42 | perror(argv[1]); | |
43 | return (1); | |
44 | } | |
45 | ||
7a14d768 | 46 | if ((snmp_fd = _cupsSNMPOpen(host->addr.addr.sa_family)) < 0) |
568fa3fa MS |
47 | { |
48 | perror(argv[1]); | |
49 | return (1); | |
50 | } | |
51 | ||
52 | for (;;) | |
53 | { | |
54 | fputs("backendSNMPSupplies: ", stdout); | |
55 | ||
56 | if (backendSNMPSupplies(snmp_fd, &(host->addr), &page_count, | |
57 | &printer_state)) | |
58 | { | |
59 | puts("FAIL"); | |
60 | return (1); | |
61 | } | |
62 | ||
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); | |
67 | ||
68 | sleep(5); | |
69 | } | |
70 | } |