]> git.ipfire.org Git - thirdparty/cups.git/blame - notifier/testnotify.c
Update svn:keyword properties.
[thirdparty/cups.git] / notifier / testnotify.c
CommitLineData
ef416fc2 1/*
f2d18633 2 * "$Id$"
ef416fc2 3 *
71e16022 4 * Test notifier for CUPS.
ef416fc2 5 *
e60ec91f 6 * Copyright 2007-2011 by Apple Inc.
ef416fc2 7 * Copyright 1997-2005 by Easy Software Products.
8 *
9 * These coded instructions, statements, and computer programs are the
bc44d920 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/".
ef416fc2 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
e60ec91f 25#include <cups/cups-private.h>
ef416fc2 26
27
28/*
29 * Local functions...
30 */
31
32void print_attributes(ipp_t *ipp, int indent);
33
34
35/*
36 * 'main()' - Main entry for the test notifier.
37 */
38
39int /* O - Exit status */
40main(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]);
cda47a96 53 fprintf(stderr, "DEBUG: TMPDIR=\"%s\"\n", getenv("TMPDIR"));
ef416fc2 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);
8ca02f3c 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);
ef416fc2 83 }
84}
85
86
87/*
88 * 'print_attributes()' - Print the attributes in a request...
89 */
90
91void
92print_attributes(ipp_t *ipp, /* I - IPP request */
93 int indent) /* I - Indentation */
94{
ef416fc2 95 ipp_tag_t group; /* Current group */
96 ipp_attribute_t *attr; /* Current attribute */
e60ec91f 97 char buffer[1024]; /* Value buffer */
ef416fc2 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
e60ec91f 113 fprintf(stderr, "DEBUG: %*s%s:\n\n", indent - 4, "", ippTagString(group));
ef416fc2 114 }
115
a2326b5b 116 ippAttributeString(attr, buffer, sizeof(buffer));
ef416fc2 117
e60ec91f
MS
118 fprintf(stderr, "DEBUG: %*s%s (%s%s) %s", indent, "", attr->name,
119 attr->num_values > 1 ? "1setOf " : "",
120 ippTagString(attr->value_tag), buffer);
ef416fc2 121 }
122}
123
124
125/*
f2d18633 126 * End of "$Id$".
ef416fc2 127 */