]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/testipp.c
2 * IPP test program for CUPS.
4 * Copyright © 2007-2018 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...
15 #include "string-private.h"
16 #include "ipp-private.h"
29 typedef struct _ippdata_t
31 size_t rpos
, /* Read position */
32 wused
, /* Bytes used */
33 wsize
; /* Max size of buffer */
34 ipp_uchar_t
*wbuffer
; /* Buffer */
42 static ipp_uchar_t collection
[] = /* Collection buffer */
44 0x01, 0x01, /* IPP version */
45 0x00, 0x02, /* Print-Job operation */
46 0x00, 0x00, 0x00, 0x01,
52 0x00, 0x12, /* Name length + name */
53 'a','t','t','r','i','b','u','t','e','s','-',
54 'c','h','a','r','s','e','t',
55 0x00, 0x05, /* Value length + value */
59 0x00, 0x1b, /* Name length + name */
60 'a','t','t','r','i','b','u','t','e','s','-',
61 'n','a','t','u','r','a','l','-','l','a','n',
63 0x00, 0x02, /* Value length + value */
67 0x00, 0x0b, /* Name length + name */
68 'p','r','i','n','t','e','r','-','u','r','i',
69 0x00, 0x1c, /* Value length + value */
70 'i','p','p',':','/','/','l','o','c','a','l',
71 'h','o','s','t','/','p','r','i','n','t','e',
72 'r','s','/','f','o','o',
74 IPP_TAG_JOB
, /* job group tag */
76 IPP_TAG_BEGIN_COLLECTION
,
77 /* begCollection tag */
78 0x00, 0x09, /* Name length + name */
79 'm', 'e', 'd', 'i', 'a', '-', 'c', 'o', 'l',
80 0x00, 0x00, /* No value */
81 IPP_TAG_MEMBERNAME
, /* memberAttrName tag */
82 0x00, 0x00, /* No name */
83 0x00, 0x0a, /* Value length + value */
84 'm', 'e', 'd', 'i', 'a', '-', 's', 'i', 'z', 'e',
85 IPP_TAG_BEGIN_COLLECTION
,
86 /* begCollection tag */
87 0x00, 0x00, /* Name length + name */
88 0x00, 0x00, /* No value */
90 /* memberAttrName tag */
91 0x00, 0x00, /* No name */
92 0x00, 0x0b, /* Value length + value */
93 'x', '-', 'd', 'i', 'm', 'e', 'n', 's', 'i', 'o', 'n',
94 IPP_TAG_INTEGER
, /* integer tag */
95 0x00, 0x00, /* No name */
96 0x00, 0x04, /* Value length + value */
97 0x00, 0x00, 0x54, 0x56,
99 /* memberAttrName tag */
100 0x00, 0x00, /* No name */
101 0x00, 0x0b, /* Value length + value */
102 'y', '-', 'd', 'i', 'm', 'e', 'n', 's', 'i', 'o', 'n',
103 IPP_TAG_INTEGER
, /* integer tag */
104 0x00, 0x00, /* No name */
105 0x00, 0x04, /* Value length + value */
106 0x00, 0x00, 0x6d, 0x24,
107 IPP_TAG_END_COLLECTION
,
108 /* endCollection tag */
109 0x00, 0x00, /* No name */
110 0x00, 0x00, /* No value */
111 IPP_TAG_MEMBERNAME
, /* memberAttrName tag */
112 0x00, 0x00, /* No name */
113 0x00, 0x0b, /* Value length + value */
114 'm', 'e', 'd', 'i', 'a', '-', 'c', 'o', 'l', 'o', 'r',
115 IPP_TAG_KEYWORD
, /* keyword tag */
116 0x00, 0x00, /* No name */
117 0x00, 0x04, /* Value length + value */
120 IPP_TAG_MEMBERNAME
, /* memberAttrName tag */
121 0x00, 0x00, /* No name */
122 0x00, 0x0a, /* Value length + value */
123 'm', 'e', 'd', 'i', 'a', '-', 't', 'y', 'p', 'e',
124 IPP_TAG_KEYWORD
, /* keyword tag */
125 0x00, 0x00, /* No name */
126 0x00, 0x05, /* Value length + value */
127 'p', 'l', 'a', 'i', 'n',
128 IPP_TAG_END_COLLECTION
,
129 /* endCollection tag */
130 0x00, 0x00, /* No name */
131 0x00, 0x00, /* No value */
133 IPP_TAG_BEGIN_COLLECTION
,
134 /* begCollection tag */
135 0x00, 0x00, /* No name */
136 0x00, 0x00, /* No value */
137 IPP_TAG_MEMBERNAME
, /* memberAttrName tag */
138 0x00, 0x00, /* No name */
139 0x00, 0x0a, /* Value length + value */
140 'm', 'e', 'd', 'i', 'a', '-', 's', 'i', 'z', 'e',
141 IPP_TAG_BEGIN_COLLECTION
,
142 /* begCollection tag */
143 0x00, 0x00, /* Name length + name */
144 0x00, 0x00, /* No value */
146 /* memberAttrName tag */
147 0x00, 0x00, /* No name */
148 0x00, 0x0b, /* Value length + value */
149 'x', '-', 'd', 'i', 'm', 'e', 'n', 's', 'i', 'o', 'n',
150 IPP_TAG_INTEGER
, /* integer tag */
151 0x00, 0x00, /* No name */
152 0x00, 0x04, /* Value length + value */
153 0x00, 0x00, 0x52, 0x08,
155 /* memberAttrName tag */
156 0x00, 0x00, /* No name */
157 0x00, 0x0b, /* Value length + value */
158 'y', '-', 'd', 'i', 'm', 'e', 'n', 's', 'i', 'o', 'n',
159 IPP_TAG_INTEGER
, /* integer tag */
160 0x00, 0x00, /* No name */
161 0x00, 0x04, /* Value length + value */
162 0x00, 0x00, 0x74, 0x04,
163 IPP_TAG_END_COLLECTION
,
164 /* endCollection tag */
165 0x00, 0x00, /* No name */
166 0x00, 0x00, /* No value */
167 IPP_TAG_MEMBERNAME
, /* memberAttrName tag */
168 0x00, 0x00, /* No name */
169 0x00, 0x0b, /* Value length + value */
170 'm', 'e', 'd', 'i', 'a', '-', 'c', 'o', 'l', 'o', 'r',
171 IPP_TAG_KEYWORD
, /* keyword tag */
172 0x00, 0x00, /* No name */
173 0x00, 0x05, /* Value length + value */
174 'p', 'l', 'a', 'i', 'd',
176 IPP_TAG_MEMBERNAME
, /* memberAttrName tag */
177 0x00, 0x00, /* No name */
178 0x00, 0x0a, /* Value length + value */
179 'm', 'e', 'd', 'i', 'a', '-', 't', 'y', 'p', 'e',
180 IPP_TAG_KEYWORD
, /* keyword tag */
181 0x00, 0x00, /* No name */
182 0x00, 0x06, /* Value length + value */
183 'g', 'l', 'o', 's', 's', 'y',
184 IPP_TAG_END_COLLECTION
,
185 /* endCollection tag */
186 0x00, 0x00, /* No name */
187 0x00, 0x00, /* No value */
189 IPP_TAG_END
/* end tag */
192 static ipp_uchar_t mixed
[] = /* Mixed value buffer */
194 0x01, 0x01, /* IPP version */
195 0x00, 0x02, /* Print-Job operation */
196 0x00, 0x00, 0x00, 0x01,
201 IPP_TAG_INTEGER
, /* integer tag */
202 0x00, 0x1f, /* Name length + name */
203 'n', 'o', 't', 'i', 'f', 'y', '-', 'l', 'e', 'a', 's', 'e',
204 '-', 'd', 'u', 'r', 'a', 't', 'i', 'o', 'n', '-', 's', 'u',
205 'p', 'p', 'o', 'r', 't', 'e', 'd',
206 0x00, 0x04, /* Value length + value */
207 0x00, 0x00, 0x00, 0x01,
209 IPP_TAG_RANGE
, /* rangeOfInteger tag */
210 0x00, 0x00, /* No name */
211 0x00, 0x08, /* Value length + value */
212 0x00, 0x00, 0x00, 0x10,
213 0x00, 0x00, 0x00, 0x20,
215 IPP_TAG_END
/* end tag */
223 void hex_dump(const char *title
, ipp_uchar_t
*buffer
, size_t bytes
);
224 void print_attributes(ipp_t
*ipp
, int indent
);
225 ssize_t
read_cb(_ippdata_t
*data
, ipp_uchar_t
*buffer
, size_t bytes
);
226 int token_cb(_ipp_file_t
*f
, _ipp_vars_t
*v
, void *user_data
, const char *token
);
227 ssize_t
write_cb(_ippdata_t
*data
, ipp_uchar_t
*buffer
, size_t bytes
);
231 * 'main()' - Main entry.
234 int /* O - Exit status */
235 main(int argc
, /* I - Number of command-line arguments */
236 char *argv
[]) /* I - Command-line arguments */
238 _ippdata_t data
; /* IPP buffer */
239 ipp_uchar_t buffer
[8192]; /* Write buffer data */
240 ipp_t
*cols
[2], /* Collections */
241 *size
; /* media-size collection */
242 ipp_t
*request
; /* Request */
243 ipp_attribute_t
*media_col
, /* media-col attribute */
244 *media_size
, /* media-size attribute */
245 *attr
; /* Other attribute */
246 ipp_state_t state
; /* State */
247 size_t length
; /* Length of data */
248 cups_file_t
*fp
; /* File pointer */
249 size_t i
; /* Looping var */
250 int status
; /* Status of tests (0 = success, 1 = fail) */
252 const char *name
; /* Option name */
261 * Test request generation code...
264 printf("Create Sample Request: ");
267 request
->request
.op
.version
[0] = 0x01;
268 request
->request
.op
.version
[1] = 0x01;
269 request
->request
.op
.operation_id
= IPP_OP_PRINT_JOB
;
270 request
->request
.op
.request_id
= 1;
272 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_CHARSET
,
273 "attributes-charset", NULL
, "utf-8");
274 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_LANGUAGE
,
275 "attributes-natural-language", NULL
, "en");
276 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
277 "printer-uri", NULL
, "ipp://localhost/printers/foo");
281 ippAddInteger(size
, IPP_TAG_ZERO
, IPP_TAG_INTEGER
, "x-dimension", 21590);
282 ippAddInteger(size
, IPP_TAG_ZERO
, IPP_TAG_INTEGER
, "y-dimension", 27940);
283 ippAddCollection(cols
[0], IPP_TAG_JOB
, "media-size", size
);
285 ippAddString(cols
[0], IPP_TAG_JOB
, IPP_TAG_KEYWORD
, "media-color", NULL
,
287 ippAddString(cols
[0], IPP_TAG_JOB
, IPP_TAG_KEYWORD
, "media-type", NULL
,
292 ippAddInteger(size
, IPP_TAG_ZERO
, IPP_TAG_INTEGER
, "x-dimension", 21000);
293 ippAddInteger(size
, IPP_TAG_ZERO
, IPP_TAG_INTEGER
, "y-dimension", 29700);
294 ippAddCollection(cols
[1], IPP_TAG_JOB
, "media-size", size
);
296 ippAddString(cols
[1], IPP_TAG_JOB
, IPP_TAG_KEYWORD
, "media-color", NULL
,
298 ippAddString(cols
[1], IPP_TAG_JOB
, IPP_TAG_KEYWORD
, "media-type", NULL
,
301 ippAddCollections(request
, IPP_TAG_JOB
, "media-col", 2,
302 (const ipp_t
**)cols
);
306 length
= ippLength(request
);
307 if (length
!= sizeof(collection
))
309 printf("FAIL - wrong ippLength(), %d instead of %d bytes!\n",
310 (int)length
, (int)sizeof(collection
));
320 printf("Write Sample to Memory: ");
323 data
.wsize
= sizeof(buffer
);
324 data
.wbuffer
= buffer
;
326 while ((state
= ippWriteIO(&data
, (ipp_iocb_t
)write_cb
, 1, NULL
,
327 request
)) != IPP_STATE_DATA
)
328 if (state
== IPP_STATE_ERROR
)
331 if (state
!= IPP_STATE_DATA
)
333 printf("FAIL - %d bytes written.\n", (int)data
.wused
);
336 else if (data
.wused
!= sizeof(collection
))
338 printf("FAIL - wrote %d bytes, expected %d bytes!\n", (int)data
.wused
,
339 (int)sizeof(collection
));
340 hex_dump("Bytes Written", data
.wbuffer
, data
.wused
);
341 hex_dump("Baseline", collection
, sizeof(collection
));
344 else if (memcmp(data
.wbuffer
, collection
, data
.wused
))
346 for (i
= 0; i
< data
.wused
; i
++)
347 if (data
.wbuffer
[i
] != collection
[i
])
350 printf("FAIL - output does not match baseline at 0x%04x!\n", (unsigned)i
);
351 hex_dump("Bytes Written", data
.wbuffer
, data
.wused
);
352 hex_dump("Baseline", collection
, sizeof(collection
));
361 * Read the data back in and confirm...
364 printf("Read Sample from Memory: ");
369 while ((state
= ippReadIO(&data
, (ipp_iocb_t
)read_cb
, 1, NULL
,
370 request
)) != IPP_STATE_DATA
)
371 if (state
== IPP_STATE_ERROR
)
374 length
= ippLength(request
);
376 if (state
!= IPP_STATE_DATA
)
378 printf("FAIL - %d bytes read.\n", (int)data
.rpos
);
381 else if (data
.rpos
!= data
.wused
)
383 printf("FAIL - read %d bytes, expected %d bytes!\n", (int)data
.rpos
,
385 print_attributes(request
, 8);
388 else if (length
!= sizeof(collection
))
390 printf("FAIL - wrong ippLength(), %d instead of %d bytes!\n",
391 (int)length
, (int)sizeof(collection
));
392 print_attributes(request
, 8);
398 fputs("ippFindAttribute(media-col): ", stdout
);
399 if ((media_col
= ippFindAttribute(request
, "media-col",
400 IPP_TAG_BEGIN_COLLECTION
)) == NULL
)
402 if ((media_col
= ippFindAttribute(request
, "media-col",
403 IPP_TAG_ZERO
)) == NULL
)
404 puts("FAIL (not found)");
406 printf("FAIL (wrong type - %s)\n", ippTagString(media_col
->value_tag
));
410 else if (media_col
->num_values
!= 2)
412 printf("FAIL (wrong count - %d)\n", media_col
->num_values
);
420 fputs("ippFindAttribute(media-size 1): ", stdout
);
421 if ((media_size
= ippFindAttribute(media_col
->values
[0].collection
,
423 IPP_TAG_BEGIN_COLLECTION
)) == NULL
)
425 if ((media_size
= ippFindAttribute(media_col
->values
[0].collection
,
427 IPP_TAG_ZERO
)) == NULL
)
428 puts("FAIL (not found)");
430 printf("FAIL (wrong type - %s)\n",
431 ippTagString(media_size
->value_tag
));
437 if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
438 "x-dimension", IPP_TAG_INTEGER
)) == NULL
)
440 if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
441 "x-dimension", IPP_TAG_ZERO
)) == NULL
)
442 puts("FAIL (missing x-dimension)");
444 printf("FAIL (wrong type for x-dimension - %s)\n",
445 ippTagString(attr
->value_tag
));
449 else if (attr
->values
[0].integer
!= 21590)
451 printf("FAIL (wrong value for x-dimension - %d)\n",
452 attr
->values
[0].integer
);
455 else if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
457 IPP_TAG_INTEGER
)) == NULL
)
459 if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
460 "y-dimension", IPP_TAG_ZERO
)) == NULL
)
461 puts("FAIL (missing y-dimension)");
463 printf("FAIL (wrong type for y-dimension - %s)\n",
464 ippTagString(attr
->value_tag
));
468 else if (attr
->values
[0].integer
!= 27940)
470 printf("FAIL (wrong value for y-dimension - %d)\n",
471 attr
->values
[0].integer
);
478 fputs("ippFindAttribute(media-size 2): ", stdout
);
479 if ((media_size
= ippFindAttribute(media_col
->values
[1].collection
,
481 IPP_TAG_BEGIN_COLLECTION
)) == NULL
)
483 if ((media_size
= ippFindAttribute(media_col
->values
[1].collection
,
485 IPP_TAG_ZERO
)) == NULL
)
486 puts("FAIL (not found)");
488 printf("FAIL (wrong type - %s)\n",
489 ippTagString(media_size
->value_tag
));
495 if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
497 IPP_TAG_INTEGER
)) == NULL
)
499 if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
500 "x-dimension", IPP_TAG_ZERO
)) == NULL
)
501 puts("FAIL (missing x-dimension)");
503 printf("FAIL (wrong type for x-dimension - %s)\n",
504 ippTagString(attr
->value_tag
));
508 else if (attr
->values
[0].integer
!= 21000)
510 printf("FAIL (wrong value for x-dimension - %d)\n",
511 attr
->values
[0].integer
);
514 else if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
516 IPP_TAG_INTEGER
)) == NULL
)
518 if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
519 "y-dimension", IPP_TAG_ZERO
)) == NULL
)
520 puts("FAIL (missing y-dimension)");
522 printf("FAIL (wrong type for y-dimension - %s)\n",
523 ippTagString(attr
->value_tag
));
527 else if (attr
->values
[0].integer
!= 29700)
529 printf("FAIL (wrong value for y-dimension - %d)\n",
530 attr
->values
[0].integer
);
539 * Test hierarchical find...
542 fputs("ippFindAttribute(media-col/media-size/x-dimension): ", stdout
);
543 if ((attr
= ippFindAttribute(request
, "media-col/media-size/x-dimension", IPP_TAG_INTEGER
)) != NULL
)
545 if (ippGetInteger(attr
, 0) != 21590)
547 printf("FAIL (wrong value for x-dimension - %d)\n", ippGetInteger(attr
, 0));
555 puts("FAIL (not found)");
559 fputs("ippFindNextAttribute(media-col/media-size/x-dimension): ", stdout
);
560 if ((attr
= ippFindNextAttribute(request
, "media-col/media-size/x-dimension", IPP_TAG_INTEGER
)) != NULL
)
562 if (ippGetInteger(attr
, 0) != 21000)
564 printf("FAIL (wrong value for x-dimension - %d)\n", ippGetInteger(attr
, 0));
572 puts("FAIL (not found)");
576 fputs("ippFindNextAttribute(media-col/media-size/x-dimension) again: ", stdout
);
577 if ((attr
= ippFindNextAttribute(request
, "media-col/media-size/x-dimension", IPP_TAG_INTEGER
)) != NULL
)
579 printf("FAIL (got %d, expected nothing)\n", ippGetInteger(attr
, 0));
588 * Read the mixed data and confirm we converted everything to rangeOfInteger
592 printf("Read Mixed integer/rangeOfInteger from Memory: ");
596 data
.wused
= sizeof(mixed
);
597 data
.wsize
= sizeof(mixed
);
598 data
.wbuffer
= mixed
;
600 while ((state
= ippReadIO(&data
, (ipp_iocb_t
)read_cb
, 1, NULL
,
601 request
)) != IPP_STATE_DATA
)
602 if (state
== IPP_STATE_ERROR
)
605 length
= ippLength(request
);
607 if (state
!= IPP_STATE_DATA
)
609 printf("FAIL - %d bytes read.\n", (int)data
.rpos
);
612 else if (data
.rpos
!= sizeof(mixed
))
614 printf("FAIL - read %d bytes, expected %d bytes!\n", (int)data
.rpos
,
616 print_attributes(request
, 8);
619 else if (length
!= (sizeof(mixed
) + 4))
621 printf("FAIL - wrong ippLength(), %d instead of %d bytes!\n",
622 (int)length
, (int)sizeof(mixed
) + 4);
623 print_attributes(request
, 8);
629 fputs("ippFindAttribute(notify-lease-duration-supported): ", stdout
);
630 if ((attr
= ippFindAttribute(request
, "notify-lease-duration-supported",
631 IPP_TAG_ZERO
)) == NULL
)
633 puts("FAIL (not found)");
636 else if (attr
->value_tag
!= IPP_TAG_RANGE
)
638 printf("FAIL (wrong type - %s)\n", ippTagString(attr
->value_tag
));
641 else if (attr
->num_values
!= 2)
643 printf("FAIL (wrong count - %d)\n", attr
->num_values
);
646 else if (attr
->values
[0].range
.lower
!= 1 ||
647 attr
->values
[0].range
.upper
!= 1 ||
648 attr
->values
[1].range
.lower
!= 16 ||
649 attr
->values
[1].range
.upper
!= 32)
651 printf("FAIL (wrong values - %d,%d and %d,%d)\n",
652 attr
->values
[0].range
.lower
,
653 attr
->values
[0].range
.upper
,
654 attr
->values
[1].range
.lower
,
655 attr
->values
[1].range
.upper
);
665 * Test that private option array is sorted...
668 fputs("_ippCheckOptions: ", stdout
);
669 if ((name
= _ippCheckOptions()) == NULL
)
673 printf("FAIL (\"%s\" out of order)\n", name
);
679 * Test _ippFindOption() private API...
682 fputs("_ippFindOption(\"printer-type\"): ", stdout
);
683 if (_ippFindOption("printer-type"))
698 puts("Core IPP tests failed.");
700 puts("Core IPP tests passed.");
708 for (i
= 1; i
< (size_t)argc
; i
++)
710 if (strlen(argv
[i
]) > 5 && !strcmp(argv
[i
] + strlen(argv
[i
]) - 5, ".test"))
713 * Read an ASCII IPP message...
716 _ipp_vars_t v
; /* IPP variables */
718 _ippVarsInit(&v
, NULL
, NULL
, token_cb
);
719 request
= _ippFileParse(&v
, argv
[i
], NULL
);
725 * Read a raw (binary) IPP message...
728 if ((fp
= cupsFileOpen(argv
[i
], "r")) == NULL
)
730 printf("Unable to open \"%s\" - %s\n", argv
[i
], strerror(errno
));
736 while ((state
= ippReadIO(fp
, (ipp_iocb_t
)cupsFileRead
, 1, NULL
,
737 request
)) == IPP_STATE_ATTRIBUTE
);
739 if (state
!= IPP_STATE_DATA
)
741 printf("Error reading IPP message from \"%s\": %s\n", argv
[i
], cupsLastErrorString());
753 printf("\n%s:\n", argv
[i
]);
754 print_attributes(request
, 4);
765 * 'hex_dump()' - Produce a hex dump of a buffer.
769 hex_dump(const char *title
, /* I - Title */
770 ipp_uchar_t
*buffer
, /* I - Buffer to dump */
771 size_t bytes
) /* I - Number of bytes */
773 size_t i
, j
; /* Looping vars */
774 int ch
; /* Current ASCII char */
778 * Show lines of 16 bytes at a time...
781 printf(" %s:\n", title
);
783 for (i
= 0; i
< bytes
; i
+= 16)
789 printf(" %04x ", (unsigned)i
);
792 * Then up to 16 bytes in hex...
795 for (j
= 0; j
< 16; j
++)
797 printf(" %02x", buffer
[i
+ j
]);
802 * Then the ASCII representation of the bytes...
808 for (j
= 0; j
< 16 && (i
+ j
) < bytes
; j
++)
810 ch
= buffer
[i
+ j
] & 127;
812 if (ch
< ' ' || ch
== 127)
824 * 'print_attributes()' - Print the attributes in a request...
828 print_attributes(ipp_t
*ipp
, /* I - IPP request */
829 int indent
) /* I - Indentation */
831 ipp_tag_t group
; /* Current group */
832 ipp_attribute_t
*attr
; /* Current attribute */
833 char buffer
[2048]; /* Value string */
836 for (group
= IPP_TAG_ZERO
, attr
= ipp
->attrs
; attr
; attr
= attr
->next
)
838 if (!attr
->name
&& indent
== 4)
840 group
= IPP_TAG_ZERO
;
845 if (group
!= attr
->group_tag
)
847 group
= attr
->group_tag
;
849 printf("\n%*s%s:\n\n", indent
- 4, "", ippTagString(group
));
852 ippAttributeString(attr
, buffer
, sizeof(buffer
));
854 printf("%*s%s (%s%s): %s\n", indent
, "", attr
->name
? attr
->name
: "(null)", attr
->num_values
> 1 ? "1setOf " : "", ippTagString(attr
->value_tag
), buffer
);
860 * 'read_cb()' - Read data from a buffer.
863 ssize_t
/* O - Number of bytes read */
864 read_cb(_ippdata_t
*data
, /* I - Data */
865 ipp_uchar_t
*buffer
, /* O - Buffer to read */
866 size_t bytes
) /* I - Number of bytes to read */
868 size_t count
; /* Number of bytes */
872 * Copy bytes from the data buffer to the read buffer...
875 if ((count
= data
->wsize
- data
->rpos
) > bytes
)
878 memcpy(buffer
, data
->wbuffer
+ data
->rpos
, count
);
882 * Return the number of bytes read...
885 return ((ssize_t
)count
);
890 * 'token_cb()' - Token callback for ASCII IPP data file parser.
893 int /* O - 1 on success, 0 on failure */
894 token_cb(_ipp_file_t
*f
, /* I - IPP file data */
895 _ipp_vars_t
*v
, /* I - IPP variables */
896 void *user_data
, /* I - User data pointer */
897 const char *token
) /* I - Token string */
905 f
->group_tag
= IPP_TAG_PRINTER
;
909 fprintf(stderr
, "Unknown directive \"%s\" on line %d of \"%s\".\n", token
, f
->linenum
, f
->filename
);
918 * 'write_cb()' - Write data into a buffer.
921 ssize_t
/* O - Number of bytes written */
922 write_cb(_ippdata_t
*data
, /* I - Data */
923 ipp_uchar_t
*buffer
, /* I - Buffer to write */
924 size_t bytes
) /* I - Number of bytes to write */
926 size_t count
; /* Number of bytes */
930 * Loop until all bytes are written...
933 if ((count
= data
->wsize
- data
->wused
) > bytes
)
936 memcpy(data
->wbuffer
+ data
->wused
, buffer
, count
);
937 data
->wused
+= count
;
940 * Return the number of bytes written...
943 return ((ssize_t
)count
);