]>
git.ipfire.org Git - thirdparty/cups.git/blob - notifier/testnotify.c
4 * Test notifier for CUPS.
6 * Copyright 2007-2011 by Apple Inc.
7 * Copyright 1997-2005 by Easy Software Products.
9 * These coded instructions, statements, and computer programs are the
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/".
17 * main() - Main entry for the test notifier.
18 * print_attributes() - Print the attributes in a request...
22 * Include necessary headers...
25 #include <cups/cups-private.h>
32 void print_attributes(ipp_t
*ipp
, int indent
);
36 * 'main()' - Main entry for the test notifier.
39 int /* O - Exit status */
40 main(int argc
, /* I - Number of command-line arguments */
41 char *argv
[]) /* I - Command-line arguments */
43 int i
; /* Looping var */
44 ipp_t
*event
; /* Event from scheduler */
45 ipp_state_t state
; /* IPP event state */
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
]);
53 fprintf(stderr
, "DEBUG: TMPDIR=\"%s\"\n", getenv("TMPDIR"));
58 while ((state
= ippReadFile(0, event
)) != IPP_DATA
)
60 if (state
<= IPP_IDLE
)
64 if (state
== IPP_ERROR
)
65 fputs("DEBUG: ippReadFile() returned IPP_ERROR!\n", stderr
);
67 if (state
<= IPP_IDLE
)
73 print_attributes(event
, 4);
77 * If the recipient URI is "testnotify://nowait", then we exit after each
81 if (!strcmp(argv
[1], "testnotify://nowait"))
88 * 'print_attributes()' - Print the attributes in a request...
92 print_attributes(ipp_t
*ipp
, /* I - IPP request */
93 int indent
) /* I - Indentation */
95 ipp_tag_t group
; /* Current group */
96 ipp_attribute_t
*attr
; /* Current attribute */
97 char buffer
[1024]; /* Value buffer */
100 for (group
= IPP_TAG_ZERO
, attr
= ipp
->attrs
; attr
; attr
= attr
->next
)
102 if ((attr
->group_tag
== IPP_TAG_ZERO
&& indent
<= 8) || !attr
->name
)
104 group
= IPP_TAG_ZERO
;
109 if (group
!= attr
->group_tag
)
111 group
= attr
->group_tag
;
113 fprintf(stderr
, "DEBUG: %*s%s:\n\n", indent
- 4, "", ippTagString(group
));
116 ippAttributeString(attr
, buffer
, sizeof(buffer
));
118 fprintf(stderr
, "DEBUG: %*s%s (%s%s) %s", indent
, "", attr
->name
,
119 attr
->num_values
> 1 ? "1setOf " : "",
120 ippTagString(attr
->value_tag
), buffer
);