]>
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 * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
11 * Include necessary headers...
14 #include <cups/cups-private.h>
21 void print_attributes(ipp_t
*ipp
, int indent
);
25 * 'main()' - Main entry for the test notifier.
28 int /* O - Exit status */
29 main(int argc
, /* I - Number of command-line arguments */
30 char *argv
[]) /* I - Command-line arguments */
32 int i
; /* Looping var */
33 ipp_t
*event
; /* Event from scheduler */
34 ipp_state_t state
; /* IPP event state */
39 fprintf(stderr
, "DEBUG: argc=%d\n", argc
);
40 for (i
= 0; i
< argc
; i
++)
41 fprintf(stderr
, "DEBUG: argv[%d]=\"%s\"\n", i
, argv
[i
]);
42 fprintf(stderr
, "DEBUG: TMPDIR=\"%s\"\n", getenv("TMPDIR"));
47 while ((state
= ippReadFile(0, event
)) != IPP_DATA
)
49 if (state
<= IPP_IDLE
)
53 if (state
== IPP_ERROR
)
54 fputs("DEBUG: ippReadFile() returned IPP_ERROR!\n", stderr
);
56 if (state
<= IPP_IDLE
)
62 print_attributes(event
, 4);
66 * If the recipient URI is "testnotify://nowait", then we exit after each
70 if (!strcmp(argv
[1], "testnotify://nowait"))
77 * 'print_attributes()' - Print the attributes in a request...
81 print_attributes(ipp_t
*ipp
, /* I - IPP request */
82 int indent
) /* I - Indentation */
84 ipp_tag_t group
; /* Current group */
85 ipp_attribute_t
*attr
; /* Current attribute */
86 char buffer
[1024]; /* Value buffer */
89 for (group
= IPP_TAG_ZERO
, attr
= ipp
->attrs
; attr
; attr
= attr
->next
)
91 if ((attr
->group_tag
== IPP_TAG_ZERO
&& indent
<= 8) || !attr
->name
)
98 if (group
!= attr
->group_tag
)
100 group
= attr
->group_tag
;
102 fprintf(stderr
, "DEBUG: %*s%s:\n\n", indent
- 4, "", ippTagString(group
));
105 ippAttributeString(attr
, buffer
, sizeof(buffer
));
107 fprintf(stderr
, "DEBUG: %*s%s (%s%s) %s\n", indent
, "", attr
->name
,
108 attr
->num_values
> 1 ? "1setOf " : "",
109 ippTagString(attr
->value_tag
), buffer
);