]>
git.ipfire.org Git - thirdparty/cups.git/blob - notifier/testnotify.c
2 * Test notifier for CUPS.
4 * Copyright 2007-2016 by Apple Inc.
5 * Copyright 1997-2005 by Easy Software Products.
7 * These coded instructions, statements, and computer programs are the
8 * property of Apple Inc. and are protected by Federal copyright
9 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
10 * which should have been included with this file. If this file is
11 * missing or damaged, see the license at "http://www.cups.org/".
15 * Include necessary headers...
18 #include <cups/cups-private.h>
25 void print_attributes(ipp_t
*ipp
, int indent
);
29 * 'main()' - Main entry for the test notifier.
32 int /* O - Exit status */
33 main(int argc
, /* I - Number of command-line arguments */
34 char *argv
[]) /* I - Command-line arguments */
36 int i
; /* Looping var */
37 ipp_t
*event
; /* Event from scheduler */
38 ipp_state_t state
; /* IPP event state */
43 fprintf(stderr
, "DEBUG: argc=%d\n", argc
);
44 for (i
= 0; i
< argc
; i
++)
45 fprintf(stderr
, "DEBUG: argv[%d]=\"%s\"\n", i
, argv
[i
]);
46 fprintf(stderr
, "DEBUG: TMPDIR=\"%s\"\n", getenv("TMPDIR"));
51 while ((state
= ippReadFile(0, event
)) != IPP_DATA
)
53 if (state
<= IPP_IDLE
)
57 if (state
== IPP_ERROR
)
58 fputs("DEBUG: ippReadFile() returned IPP_ERROR!\n", stderr
);
60 if (state
<= IPP_IDLE
)
66 print_attributes(event
, 4);
70 * If the recipient URI is "testnotify://nowait", then we exit after each
74 if (!strcmp(argv
[1], "testnotify://nowait"))
81 * 'print_attributes()' - Print the attributes in a request...
85 print_attributes(ipp_t
*ipp
, /* I - IPP request */
86 int indent
) /* I - Indentation */
88 ipp_tag_t group
; /* Current group */
89 ipp_attribute_t
*attr
; /* Current attribute */
90 char buffer
[1024]; /* Value buffer */
93 for (group
= IPP_TAG_ZERO
, attr
= ipp
->attrs
; attr
; attr
= attr
->next
)
95 if ((attr
->group_tag
== IPP_TAG_ZERO
&& indent
<= 8) || !attr
->name
)
102 if (group
!= attr
->group_tag
)
104 group
= attr
->group_tag
;
106 fprintf(stderr
, "DEBUG: %*s%s:\n\n", indent
- 4, "", ippTagString(group
));
109 ippAttributeString(attr
, buffer
, sizeof(buffer
));
111 fprintf(stderr
, "DEBUG: %*s%s (%s%s) %s\n", indent
, "", attr
->name
,
112 attr
->num_values
> 1 ? "1setOf " : "",
113 ippTagString(attr
->value_tag
), buffer
);