]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/testipp.c
4 * IPP test program for CUPS.
6 * Copyright 2007-2013 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/".
15 * This file is subject to the Apple OS-Developed Software exception.
19 * main() - Main entry.
20 * hex_dump() - Produce a hex dump of a buffer.
21 * print_attributes() - Print the attributes in a request...
22 * read_cb() - Read data from a buffer.
23 * write_cb() - Write data into a buffer.
27 * Include necessary headers...
31 #include "string-private.h"
32 #include "ipp-private.h"
45 typedef struct _ippdata_t
47 size_t rpos
, /* Read position */
48 wused
, /* Bytes used */
49 wsize
; /* Max size of buffer */
50 ipp_uchar_t
*wbuffer
; /* Buffer */
58 ipp_uchar_t collection
[] = /* Collection buffer */
60 0x01, 0x01, /* IPP version */
61 0x00, 0x02, /* Print-Job operation */
62 0x00, 0x00, 0x00, 0x01,
68 0x00, 0x12, /* Name length + name */
69 'a','t','t','r','i','b','u','t','e','s','-',
70 'c','h','a','r','s','e','t',
71 0x00, 0x05, /* Value length + value */
75 0x00, 0x1b, /* Name length + name */
76 'a','t','t','r','i','b','u','t','e','s','-',
77 'n','a','t','u','r','a','l','-','l','a','n',
79 0x00, 0x02, /* Value length + value */
83 0x00, 0x0b, /* Name length + name */
84 'p','r','i','n','t','e','r','-','u','r','i',
85 0x00, 0x1c, /* Value length + value */
86 'i','p','p',':','/','/','l','o','c','a','l',
87 'h','o','s','t','/','p','r','i','n','t','e',
88 'r','s','/','f','o','o',
90 IPP_TAG_JOB
, /* job group tag */
92 IPP_TAG_BEGIN_COLLECTION
,
93 /* begCollection tag */
94 0x00, 0x09, /* Name length + name */
95 'm', 'e', 'd', 'i', 'a', '-', 'c', 'o', 'l',
96 0x00, 0x00, /* No value */
97 IPP_TAG_MEMBERNAME
, /* memberAttrName tag */
98 0x00, 0x00, /* No name */
99 0x00, 0x0a, /* Value length + value */
100 'm', 'e', 'd', 'i', 'a', '-', 's', 'i', 'z', 'e',
101 IPP_TAG_BEGIN_COLLECTION
,
102 /* begCollection tag */
103 0x00, 0x00, /* Name length + name */
104 0x00, 0x00, /* No value */
106 /* memberAttrName tag */
107 0x00, 0x00, /* No name */
108 0x00, 0x0b, /* Value length + value */
109 'x', '-', 'd', 'i', 'm', 'e', 'n', 's', 'i', 'o', 'n',
110 IPP_TAG_INTEGER
, /* integer tag */
111 0x00, 0x00, /* No name */
112 0x00, 0x04, /* Value length + value */
113 0x00, 0x00, 0x54, 0x56,
115 /* memberAttrName tag */
116 0x00, 0x00, /* No name */
117 0x00, 0x0b, /* Value length + value */
118 'y', '-', 'd', 'i', 'm', 'e', 'n', 's', 'i', 'o', 'n',
119 IPP_TAG_INTEGER
, /* integer tag */
120 0x00, 0x00, /* No name */
121 0x00, 0x04, /* Value length + value */
122 0x00, 0x00, 0x6d, 0x24,
123 IPP_TAG_END_COLLECTION
,
124 /* endCollection tag */
125 0x00, 0x00, /* No name */
126 0x00, 0x00, /* No value */
127 IPP_TAG_MEMBERNAME
, /* memberAttrName tag */
128 0x00, 0x00, /* No name */
129 0x00, 0x0b, /* Value length + value */
130 'm', 'e', 'd', 'i', 'a', '-', 'c', 'o', 'l', 'o', 'r',
131 IPP_TAG_KEYWORD
, /* keyword tag */
132 0x00, 0x00, /* No name */
133 0x00, 0x04, /* Value length + value */
136 IPP_TAG_MEMBERNAME
, /* memberAttrName tag */
137 0x00, 0x00, /* No name */
138 0x00, 0x0a, /* Value length + value */
139 'm', 'e', 'd', 'i', 'a', '-', 't', 'y', 'p', 'e',
140 IPP_TAG_KEYWORD
, /* keyword tag */
141 0x00, 0x00, /* No name */
142 0x00, 0x05, /* Value length + value */
143 'p', 'l', 'a', 'i', 'n',
144 IPP_TAG_END_COLLECTION
,
145 /* endCollection tag */
146 0x00, 0x00, /* No name */
147 0x00, 0x00, /* No value */
149 IPP_TAG_BEGIN_COLLECTION
,
150 /* begCollection tag */
151 0x00, 0x00, /* No name */
152 0x00, 0x00, /* No value */
153 IPP_TAG_MEMBERNAME
, /* memberAttrName tag */
154 0x00, 0x00, /* No name */
155 0x00, 0x0a, /* Value length + value */
156 'm', 'e', 'd', 'i', 'a', '-', 's', 'i', 'z', 'e',
157 IPP_TAG_BEGIN_COLLECTION
,
158 /* begCollection tag */
159 0x00, 0x00, /* Name length + name */
160 0x00, 0x00, /* No value */
162 /* memberAttrName tag */
163 0x00, 0x00, /* No name */
164 0x00, 0x0b, /* Value length + value */
165 'x', '-', 'd', 'i', 'm', 'e', 'n', 's', 'i', 'o', 'n',
166 IPP_TAG_INTEGER
, /* integer tag */
167 0x00, 0x00, /* No name */
168 0x00, 0x04, /* Value length + value */
169 0x00, 0x00, 0x52, 0x08,
171 /* memberAttrName tag */
172 0x00, 0x00, /* No name */
173 0x00, 0x0b, /* Value length + value */
174 'y', '-', 'd', 'i', 'm', 'e', 'n', 's', 'i', 'o', 'n',
175 IPP_TAG_INTEGER
, /* integer tag */
176 0x00, 0x00, /* No name */
177 0x00, 0x04, /* Value length + value */
178 0x00, 0x00, 0x74, 0x04,
179 IPP_TAG_END_COLLECTION
,
180 /* endCollection tag */
181 0x00, 0x00, /* No name */
182 0x00, 0x00, /* No value */
183 IPP_TAG_MEMBERNAME
, /* memberAttrName tag */
184 0x00, 0x00, /* No name */
185 0x00, 0x0b, /* Value length + value */
186 'm', 'e', 'd', 'i', 'a', '-', 'c', 'o', 'l', 'o', 'r',
187 IPP_TAG_KEYWORD
, /* keyword tag */
188 0x00, 0x00, /* No name */
189 0x00, 0x05, /* Value length + value */
190 'p', 'l', 'a', 'i', 'd',
192 IPP_TAG_MEMBERNAME
, /* memberAttrName tag */
193 0x00, 0x00, /* No name */
194 0x00, 0x0a, /* Value length + value */
195 'm', 'e', 'd', 'i', 'a', '-', 't', 'y', 'p', 'e',
196 IPP_TAG_KEYWORD
, /* keyword tag */
197 0x00, 0x00, /* No name */
198 0x00, 0x06, /* Value length + value */
199 'g', 'l', 'o', 's', 's', 'y',
200 IPP_TAG_END_COLLECTION
,
201 /* endCollection tag */
202 0x00, 0x00, /* No name */
203 0x00, 0x00, /* No value */
205 IPP_TAG_END
/* end tag */
208 ipp_uchar_t mixed
[] = /* Mixed value buffer */
210 0x01, 0x01, /* IPP version */
211 0x00, 0x02, /* Print-Job operation */
212 0x00, 0x00, 0x00, 0x01,
217 IPP_TAG_INTEGER
, /* integer tag */
218 0x00, 0x1f, /* Name length + name */
219 'n', 'o', 't', 'i', 'f', 'y', '-', 'l', 'e', 'a', 's', 'e',
220 '-', 'd', 'u', 'r', 'a', 't', 'i', 'o', 'n', '-', 's', 'u',
221 'p', 'p', 'o', 'r', 't', 'e', 'd',
222 0x00, 0x04, /* Value length + value */
223 0x00, 0x00, 0x00, 0x01,
225 IPP_TAG_RANGE
, /* rangeOfInteger tag */
226 0x00, 0x00, /* No name */
227 0x00, 0x08, /* Value length + value */
228 0x00, 0x00, 0x00, 0x10,
229 0x00, 0x00, 0x00, 0x20,
231 IPP_TAG_END
/* end tag */
239 void hex_dump(const char *title
, ipp_uchar_t
*buffer
, int bytes
);
240 void print_attributes(ipp_t
*ipp
, int indent
);
241 ssize_t
read_cb(_ippdata_t
*data
, ipp_uchar_t
*buffer
, size_t bytes
);
242 ssize_t
write_cb(_ippdata_t
*data
, ipp_uchar_t
*buffer
, size_t bytes
);
246 * 'main()' - Main entry.
249 int /* O - Exit status */
250 main(int argc
, /* I - Number of command-line arguments */
251 char *argv
[]) /* I - Command-line arguments */
253 _ippdata_t data
; /* IPP buffer */
254 ipp_uchar_t buffer
[8192]; /* Write buffer data */
255 ipp_t
*cols
[2], /* Collections */
256 *size
; /* media-size collection */
257 ipp_t
*request
; /* Request */
258 ipp_attribute_t
*media_col
, /* media-col attribute */
259 *media_size
, /* media-size attribute */
260 *attr
; /* Other attribute */
261 ipp_state_t state
; /* State */
262 int length
; /* Length of data */
263 cups_file_t
*fp
; /* File pointer */
264 int i
; /* Looping var */
265 int status
; /* Status of tests (0 = success, 1 = fail) */
266 const char *name
; /* Option name */
274 * Test request generation code...
277 printf("Create Sample Request: ");
280 request
->request
.op
.version
[0] = 0x01;
281 request
->request
.op
.version
[1] = 0x01;
282 request
->request
.op
.operation_id
= IPP_OP_PRINT_JOB
;
283 request
->request
.op
.request_id
= 1;
285 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_CHARSET
,
286 "attributes-charset", NULL
, "utf-8");
287 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_LANGUAGE
,
288 "attributes-natural-language", NULL
, "en");
289 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
290 "printer-uri", NULL
, "ipp://localhost/printers/foo");
294 ippAddInteger(size
, IPP_TAG_ZERO
, IPP_TAG_INTEGER
, "x-dimension", 21590);
295 ippAddInteger(size
, IPP_TAG_ZERO
, IPP_TAG_INTEGER
, "y-dimension", 27940);
296 ippAddCollection(cols
[0], IPP_TAG_JOB
, "media-size", size
);
298 ippAddString(cols
[0], IPP_TAG_JOB
, IPP_TAG_KEYWORD
, "media-color", NULL
,
300 ippAddString(cols
[0], IPP_TAG_JOB
, IPP_TAG_KEYWORD
, "media-type", NULL
,
305 ippAddInteger(size
, IPP_TAG_ZERO
, IPP_TAG_INTEGER
, "x-dimension", 21000);
306 ippAddInteger(size
, IPP_TAG_ZERO
, IPP_TAG_INTEGER
, "y-dimension", 29700);
307 ippAddCollection(cols
[1], IPP_TAG_JOB
, "media-size", size
);
309 ippAddString(cols
[1], IPP_TAG_JOB
, IPP_TAG_KEYWORD
, "media-color", NULL
,
311 ippAddString(cols
[1], IPP_TAG_JOB
, IPP_TAG_KEYWORD
, "media-type", NULL
,
314 ippAddCollections(request
, IPP_TAG_JOB
, "media-col", 2,
315 (const ipp_t
**)cols
);
319 length
= ippLength(request
);
320 if (length
!= sizeof(collection
))
322 printf("FAIL - wrong ippLength(), %d instead of %d bytes!\n",
323 length
, (int)sizeof(collection
));
333 printf("Write Sample to Memory: ");
336 data
.wsize
= sizeof(buffer
);
337 data
.wbuffer
= buffer
;
339 while ((state
= ippWriteIO(&data
, (ipp_iocb_t
)write_cb
, 1, NULL
,
340 request
)) != IPP_STATE_DATA
)
341 if (state
== IPP_STATE_ERROR
)
344 if (state
!= IPP_STATE_DATA
)
346 printf("FAIL - %d bytes written.\n", (int)data
.wused
);
349 else if (data
.wused
!= sizeof(collection
))
351 printf("FAIL - wrote %d bytes, expected %d bytes!\n", (int)data
.wused
,
352 (int)sizeof(collection
));
353 hex_dump("Bytes Written", data
.wbuffer
, data
.wused
);
354 hex_dump("Baseline", collection
, sizeof(collection
));
357 else if (memcmp(data
.wbuffer
, collection
, data
.wused
))
359 for (i
= 0; i
< data
.wused
; i
++)
360 if (data
.wbuffer
[i
] != collection
[i
])
363 printf("FAIL - output does not match baseline at 0x%04x!\n", i
);
364 hex_dump("Bytes Written", data
.wbuffer
, data
.wused
);
365 hex_dump("Baseline", collection
, sizeof(collection
));
374 * Read the data back in and confirm...
377 printf("Read Sample from Memory: ");
382 while ((state
= ippReadIO(&data
, (ipp_iocb_t
)read_cb
, 1, NULL
,
383 request
)) != IPP_STATE_DATA
)
384 if (state
== IPP_STATE_ERROR
)
387 length
= ippLength(request
);
389 if (state
!= IPP_STATE_DATA
)
391 printf("FAIL - %d bytes read.\n", (int)data
.rpos
);
394 else if (data
.rpos
!= data
.wused
)
396 printf("FAIL - read %d bytes, expected %d bytes!\n", (int)data
.rpos
,
398 print_attributes(request
, 8);
401 else if (length
!= sizeof(collection
))
403 printf("FAIL - wrong ippLength(), %d instead of %d bytes!\n",
404 length
, (int)sizeof(collection
));
405 print_attributes(request
, 8);
411 fputs("ippFindAttribute(media-col): ", stdout
);
412 if ((media_col
= ippFindAttribute(request
, "media-col",
413 IPP_TAG_BEGIN_COLLECTION
)) == NULL
)
415 if ((media_col
= ippFindAttribute(request
, "media-col",
416 IPP_TAG_ZERO
)) == NULL
)
417 puts("FAIL (not found)");
419 printf("FAIL (wrong type - %s)\n", ippTagString(media_col
->value_tag
));
423 else if (media_col
->num_values
!= 2)
425 printf("FAIL (wrong count - %d)\n", media_col
->num_values
);
433 fputs("ippFindAttribute(media-size 1): ", stdout
);
434 if ((media_size
= ippFindAttribute(media_col
->values
[0].collection
,
436 IPP_TAG_BEGIN_COLLECTION
)) == NULL
)
438 if ((media_size
= ippFindAttribute(media_col
->values
[0].collection
,
440 IPP_TAG_ZERO
)) == NULL
)
441 puts("FAIL (not found)");
443 printf("FAIL (wrong type - %s)\n",
444 ippTagString(media_size
->value_tag
));
450 if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
451 "x-dimension", IPP_TAG_INTEGER
)) == NULL
)
453 if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
454 "x-dimension", IPP_TAG_ZERO
)) == NULL
)
455 puts("FAIL (missing x-dimension)");
457 printf("FAIL (wrong type for x-dimension - %s)\n",
458 ippTagString(attr
->value_tag
));
462 else if (attr
->values
[0].integer
!= 21590)
464 printf("FAIL (wrong value for x-dimension - %d)\n",
465 attr
->values
[0].integer
);
468 else if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
470 IPP_TAG_INTEGER
)) == NULL
)
472 if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
473 "y-dimension", IPP_TAG_ZERO
)) == NULL
)
474 puts("FAIL (missing y-dimension)");
476 printf("FAIL (wrong type for y-dimension - %s)\n",
477 ippTagString(attr
->value_tag
));
481 else if (attr
->values
[0].integer
!= 27940)
483 printf("FAIL (wrong value for y-dimension - %d)\n",
484 attr
->values
[0].integer
);
491 fputs("ippFindAttribute(media-size 2): ", stdout
);
492 if ((media_size
= ippFindAttribute(media_col
->values
[1].collection
,
494 IPP_TAG_BEGIN_COLLECTION
)) == NULL
)
496 if ((media_size
= ippFindAttribute(media_col
->values
[1].collection
,
498 IPP_TAG_ZERO
)) == NULL
)
499 puts("FAIL (not found)");
501 printf("FAIL (wrong type - %s)\n",
502 ippTagString(media_size
->value_tag
));
508 if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
510 IPP_TAG_INTEGER
)) == NULL
)
512 if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
513 "x-dimension", IPP_TAG_ZERO
)) == NULL
)
514 puts("FAIL (missing x-dimension)");
516 printf("FAIL (wrong type for x-dimension - %s)\n",
517 ippTagString(attr
->value_tag
));
521 else if (attr
->values
[0].integer
!= 21000)
523 printf("FAIL (wrong value for x-dimension - %d)\n",
524 attr
->values
[0].integer
);
527 else if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
529 IPP_TAG_INTEGER
)) == NULL
)
531 if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
532 "y-dimension", IPP_TAG_ZERO
)) == NULL
)
533 puts("FAIL (missing y-dimension)");
535 printf("FAIL (wrong type for y-dimension - %s)\n",
536 ippTagString(attr
->value_tag
));
540 else if (attr
->values
[0].integer
!= 29700)
542 printf("FAIL (wrong value for y-dimension - %d)\n",
543 attr
->values
[0].integer
);
554 * Read the mixed data and confirm we converted everything to rangeOfInteger
558 printf("Read Mixed integer/rangeOfInteger from Memory: ");
562 data
.wused
= sizeof(mixed
);
563 data
.wsize
= sizeof(mixed
);
564 data
.wbuffer
= mixed
;
566 while ((state
= ippReadIO(&data
, (ipp_iocb_t
)read_cb
, 1, NULL
,
567 request
)) != IPP_STATE_DATA
)
568 if (state
== IPP_STATE_ERROR
)
571 length
= ippLength(request
);
573 if (state
!= IPP_STATE_DATA
)
575 printf("FAIL - %d bytes read.\n", (int)data
.rpos
);
578 else if (data
.rpos
!= sizeof(mixed
))
580 printf("FAIL - read %d bytes, expected %d bytes!\n", (int)data
.rpos
,
582 print_attributes(request
, 8);
585 else if (length
!= (sizeof(mixed
) + 4))
587 printf("FAIL - wrong ippLength(), %d instead of %d bytes!\n",
588 length
, (int)sizeof(mixed
) + 4);
589 print_attributes(request
, 8);
595 fputs("ippFindAttribute(notify-lease-duration-supported): ", stdout
);
596 if ((attr
= ippFindAttribute(request
, "notify-lease-duration-supported",
597 IPP_TAG_ZERO
)) == NULL
)
599 puts("FAIL (not found)");
602 else if (attr
->value_tag
!= IPP_TAG_RANGE
)
604 printf("FAIL (wrong type - %s)\n", ippTagString(attr
->value_tag
));
607 else if (attr
->num_values
!= 2)
609 printf("FAIL (wrong count - %d)\n", attr
->num_values
);
612 else if (attr
->values
[0].range
.lower
!= 1 ||
613 attr
->values
[0].range
.upper
!= 1 ||
614 attr
->values
[1].range
.lower
!= 16 ||
615 attr
->values
[1].range
.upper
!= 32)
617 printf("FAIL (wrong values - %d,%d and %d,%d)\n",
618 attr
->values
[0].range
.lower
,
619 attr
->values
[0].range
.upper
,
620 attr
->values
[1].range
.lower
,
621 attr
->values
[1].range
.upper
);
631 * Test that private option array is sorted...
634 fputs("_ippCheckOptions: ", stdout
);
635 if ((name
= _ippCheckOptions()) == NULL
)
639 printf("FAIL (\"%s\" out of order)\n", name
);
645 * Test _ippFindOption() private API...
648 fputs("_ippFindOption(\"printer-type\"): ", stdout
);
649 if (_ippFindOption("printer-type"))
664 puts("Core IPP tests failed.");
666 puts("Core IPP tests passed.");
674 for (i
= 1; i
< argc
; i
++)
676 if ((fp
= cupsFileOpen(argv
[i
], "r")) == NULL
)
678 printf("Unable to open \"%s\" - %s\n", argv
[i
], strerror(errno
));
684 while ((state
= ippReadIO(fp
, (ipp_iocb_t
)cupsFileRead
, 1, NULL
,
685 request
)) == IPP_STATE_ATTRIBUTE
);
687 if (state
!= IPP_STATE_DATA
)
689 printf("Error reading IPP message from \"%s\"!\n", argv
[i
]);
694 printf("\n%s:\n", argv
[i
]);
695 print_attributes(request
, 4);
708 * 'hex_dump()' - Produce a hex dump of a buffer.
712 hex_dump(const char *title
, /* I - Title */
713 ipp_uchar_t
*buffer
, /* I - Buffer to dump */
714 int bytes
) /* I - Number of bytes */
716 int i
, j
; /* Looping vars */
717 int ch
; /* Current ASCII char */
721 * Show lines of 16 bytes at a time...
724 printf(" %s:\n", title
);
726 for (i
= 0; i
< bytes
; i
+= 16)
735 * Then up to 16 bytes in hex...
738 for (j
= 0; j
< 16; j
++)
740 printf(" %02x", buffer
[i
+ j
]);
745 * Then the ASCII representation of the bytes...
751 for (j
= 0; j
< 16 && (i
+ j
) < bytes
; j
++)
753 ch
= buffer
[i
+ j
] & 127;
755 if (ch
< ' ' || ch
== 127)
767 * 'print_attributes()' - Print the attributes in a request...
771 print_attributes(ipp_t
*ipp
, /* I - IPP request */
772 int indent
) /* I - Indentation */
774 int i
; /* Looping var */
775 ipp_tag_t group
; /* Current group */
776 ipp_attribute_t
*attr
; /* Current attribute */
777 _ipp_value_t
*val
; /* Current value */
778 static const char * const tags
[] = /* Value/group tag strings */
781 "operation-attributes-tag",
782 "job-attributes-tag",
783 "end-of-attributes-tag",
784 "printer-attributes-tag",
785 "unsupported-attributes-tag",
786 "subscription-attributes-tag",
787 "event-attributes-tag",
845 "textWithoutLanguage",
846 "nameWithoutLanguage",
858 for (group
= IPP_TAG_ZERO
, attr
= ipp
->attrs
; attr
; attr
= attr
->next
)
860 if (!attr
->name
&& indent
== 4)
862 group
= IPP_TAG_ZERO
;
867 if (group
!= attr
->group_tag
)
869 group
= attr
->group_tag
;
871 printf("\n%*s%s:\n\n", indent
- 4, "", tags
[group
]);
874 printf("%*s%s (", indent
, "", attr
->name
? attr
->name
: "(null)");
875 if (attr
->num_values
> 1)
877 printf("%s):", tags
[attr
->value_tag
]);
879 switch (attr
->value_tag
)
882 case IPP_TAG_INTEGER
:
883 for (i
= 0, val
= attr
->values
; i
< attr
->num_values
; i
++, val
++)
884 printf(" %d", val
->integer
);
888 case IPP_TAG_BOOLEAN
:
889 for (i
= 0, val
= attr
->values
; i
< attr
->num_values
; i
++, val
++)
890 printf(" %s", val
->boolean
? "true" : "false");
895 for (i
= 0, val
= attr
->values
; i
< attr
->num_values
; i
++, val
++)
896 printf(" %d-%d", val
->range
.lower
, val
->range
.upper
);
902 time_t vtime
; /* Date/Time value */
903 struct tm
*vdate
; /* Date info */
904 char vstring
[256]; /* Formatted time */
906 for (i
= 0, val
= attr
->values
; i
< attr
->num_values
; i
++, val
++)
908 vtime
= ippDateToTime(val
->date
);
909 vdate
= localtime(&vtime
);
910 strftime(vstring
, sizeof(vstring
), "%c", vdate
);
911 printf(" (%s)", vstring
);
917 case IPP_TAG_RESOLUTION
:
918 for (i
= 0, val
= attr
->values
; i
< attr
->num_values
; i
++, val
++)
919 printf(" %dx%d%s", val
->resolution
.xres
, val
->resolution
.yres
,
920 val
->resolution
.units
== IPP_RES_PER_INCH
? "dpi" : "dpcm");
924 case IPP_TAG_STRING
:
925 case IPP_TAG_TEXTLANG
:
926 case IPP_TAG_NAMELANG
:
929 case IPP_TAG_KEYWORD
:
931 case IPP_TAG_URISCHEME
:
932 case IPP_TAG_CHARSET
:
933 case IPP_TAG_LANGUAGE
:
934 case IPP_TAG_MIMETYPE
:
935 for (i
= 0, val
= attr
->values
; i
< attr
->num_values
; i
++, val
++)
936 printf(" \"%s\"", val
->string
.text
);
940 case IPP_TAG_BEGIN_COLLECTION
:
943 for (i
= 0, val
= attr
->values
; i
< attr
->num_values
; i
++, val
++)
947 print_attributes(val
->collection
, indent
+ 4);
952 printf("UNKNOWN (%d values)\n", attr
->num_values
);
960 * 'read_cb()' - Read data from a buffer.
963 ssize_t
/* O - Number of bytes read */
964 read_cb(_ippdata_t
*data
, /* I - Data */
965 ipp_uchar_t
*buffer
, /* O - Buffer to read */
966 size_t bytes
) /* I - Number of bytes to read */
968 size_t count
; /* Number of bytes */
972 * Copy bytes from the data buffer to the read buffer...
975 if ((count
= data
->wsize
- data
->rpos
) > bytes
)
978 memcpy(buffer
, data
->wbuffer
+ data
->rpos
, count
);
982 * Return the number of bytes read...
990 * 'write_cb()' - Write data into a buffer.
993 ssize_t
/* O - Number of bytes written */
994 write_cb(_ippdata_t
*data
, /* I - Data */
995 ipp_uchar_t
*buffer
, /* I - Buffer to write */
996 size_t bytes
) /* I - Number of bytes to write */
998 size_t count
; /* Number of bytes */
1002 * Loop until all bytes are written...
1005 if ((count
= data
->wsize
- data
->wused
) > bytes
)
1008 memcpy(data
->wbuffer
+ data
->wused
, buffer
, count
);
1009 data
->wused
+= count
;
1012 * Return the number of bytes written...