]>
Commit | Line | Data |
---|---|---|
568fa3fa | 1 | /* |
503b54c9 | 2 | * SNMP supplies test program for CUPS. |
568fa3fa | 3 | * |
53f8d64f | 4 | * Copyright © 2008-2011 by Apple Inc. |
568fa3fa | 5 | * |
53f8d64f MS |
6 | * Licensed under Apache License v2.0. See the file "LICENSE" for more |
7 | * information. | |
568fa3fa MS |
8 | */ |
9 | ||
10 | /* | |
11 | * Include necessary headers. | |
12 | */ | |
13 | ||
14 | #include "backend-private.h" | |
15 | ||
16 | ||
17 | /* | |
18 | * 'main()' - Show the supplies state of a printer. | |
19 | */ | |
20 | ||
21 | int /* O - Exit status */ | |
22 | main(int argc, /* I - Number of command-line args */ | |
23 | char *argv[]) /* I - Command-line arguments */ | |
24 | { | |
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 */ | |
29 | ||
30 | ||
31 | if (argc != 2) | |
32 | { | |
33 | puts("Usage: testsupplies ip-or-hostname"); | |
34 | return (1); | |
35 | } | |
36 | ||
37 | if ((host = httpAddrGetList(argv[1], AF_UNSPEC, "9100")) == NULL) | |
38 | { | |
39 | perror(argv[1]); | |
40 | return (1); | |
41 | } | |
42 | ||
7a14d768 | 43 | if ((snmp_fd = _cupsSNMPOpen(host->addr.addr.sa_family)) < 0) |
568fa3fa MS |
44 | { |
45 | perror(argv[1]); | |
46 | return (1); | |
47 | } | |
48 | ||
49 | for (;;) | |
50 | { | |
51 | fputs("backendSNMPSupplies: ", stdout); | |
52 | ||
53 | if (backendSNMPSupplies(snmp_fd, &(host->addr), &page_count, | |
54 | &printer_state)) | |
55 | { | |
56 | puts("FAIL"); | |
57 | return (1); | |
58 | } | |
59 | ||
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); | |
64 | ||
65 | sleep(5); | |
66 | } | |
67 | } |