]>
Commit | Line | Data |
---|---|---|
ea082260 | 1 | /* |
2 | * "$Id$" | |
3 | * | |
3d94661a | 4 | * Test notifier for CUPS. |
ea082260 | 5 | * |
84471d6f | 6 | * Copyright 2007-2011 by Apple Inc. |
ea082260 | 7 | * Copyright 1997-2005 by Easy Software Products. |
8 | * | |
9 | * These coded instructions, statements, and computer programs are the | |
4e8d321f | 10 | * property of Apple Inc. and are protected by Federal copyright |
11 | * law. Distribution and use rights are outlined in the file "LICENSE.txt" | |
12 | * which should have been included with this file. If this file is | |
13 | * file is missing or damaged, see the license at "http://www.cups.org/". | |
ea082260 | 14 | * |
15 | * Contents: | |
16 | * | |
17 | * main() - Main entry for the test notifier. | |
18 | * print_attributes() - Print the attributes in a request... | |
19 | */ | |
20 | ||
21 | /* | |
22 | * Include necessary headers... | |
23 | */ | |
24 | ||
84471d6f | 25 | #include <cups/cups-private.h> |
ea082260 | 26 | |
27 | ||
28 | /* | |
29 | * Local functions... | |
30 | */ | |
31 | ||
32 | void print_attributes(ipp_t *ipp, int indent); | |
33 | ||
34 | ||
35 | /* | |
36 | * 'main()' - Main entry for the test notifier. | |
37 | */ | |
38 | ||
39 | int /* O - Exit status */ | |
40 | main(int argc, /* I - Number of command-line arguments */ | |
41 | char *argv[]) /* I - Command-line arguments */ | |
42 | { | |
43 | int i; /* Looping var */ | |
44 | ipp_t *event; /* Event from scheduler */ | |
45 | ipp_state_t state; /* IPP event state */ | |
46 | ||
47 | ||
48 | setbuf(stderr, NULL); | |
49 | ||
50 | fprintf(stderr, "DEBUG: argc=%d\n", argc); | |
51 | for (i = 0; i < argc; i ++) | |
52 | fprintf(stderr, "DEBUG: argv[%d]=\"%s\"\n", i, argv[i]); | |
c4c5e9a7 | 53 | fprintf(stderr, "DEBUG: TMPDIR=\"%s\"\n", getenv("TMPDIR")); |
ea082260 | 54 | |
55 | for (;;) | |
56 | { | |
57 | event = ippNew(); | |
58 | while ((state = ippReadFile(0, event)) != IPP_DATA) | |
59 | { | |
60 | if (state <= IPP_IDLE) | |
61 | break; | |
62 | } | |
63 | ||
64 | if (state == IPP_ERROR) | |
65 | fputs("DEBUG: ippReadFile() returned IPP_ERROR!\n", stderr); | |
66 | ||
67 | if (state <= IPP_IDLE) | |
68 | { | |
69 | ippDelete(event); | |
70 | return (0); | |
71 | } | |
72 | ||
73 | print_attributes(event, 4); | |
74 | ippDelete(event); | |
d828e432 | 75 | |
76 | /* | |
77 | * If the recipient URI is "testnotify://nowait", then we exit after each | |
78 | * event... | |
79 | */ | |
80 | ||
81 | if (!strcmp(argv[1], "testnotify://nowait")) | |
82 | return (0); | |
ea082260 | 83 | } |
84 | } | |
85 | ||
86 | ||
87 | /* | |
88 | * 'print_attributes()' - Print the attributes in a request... | |
89 | */ | |
90 | ||
91 | void | |
92 | print_attributes(ipp_t *ipp, /* I - IPP request */ | |
93 | int indent) /* I - Indentation */ | |
94 | { | |
ea082260 | 95 | ipp_tag_t group; /* Current group */ |
96 | ipp_attribute_t *attr; /* Current attribute */ | |
84471d6f | 97 | char buffer[1024]; /* Value buffer */ |
ea082260 | 98 | |
99 | ||
100 | for (group = IPP_TAG_ZERO, attr = ipp->attrs; attr; attr = attr->next) | |
101 | { | |
102 | if ((attr->group_tag == IPP_TAG_ZERO && indent <= 8) || !attr->name) | |
103 | { | |
104 | group = IPP_TAG_ZERO; | |
105 | fputc('\n', stderr); | |
106 | continue; | |
107 | } | |
108 | ||
109 | if (group != attr->group_tag) | |
110 | { | |
111 | group = attr->group_tag; | |
112 | ||
84471d6f | 113 | fprintf(stderr, "DEBUG: %*s%s:\n\n", indent - 4, "", ippTagString(group)); |
ea082260 | 114 | } |
115 | ||
55b69f38 | 116 | ippAttributeString(attr, buffer, sizeof(buffer)); |
ea082260 | 117 | |
84471d6f | 118 | fprintf(stderr, "DEBUG: %*s%s (%s%s) %s", indent, "", attr->name, |
119 | attr->num_values > 1 ? "1setOf " : "", | |
120 | ippTagString(attr->value_tag), buffer); | |
ea082260 | 121 | } |
122 | } | |
123 | ||
124 | ||
125 | /* | |
126 | * End of "$Id$". | |
127 | */ |