]>
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) */
267 const char *name
; /* Option name */
276 * Test request generation code...
279 printf("Create Sample Request: ");
282 request
->request
.op
.version
[0] = 0x01;
283 request
->request
.op
.version
[1] = 0x01;
284 request
->request
.op
.operation_id
= IPP_OP_PRINT_JOB
;
285 request
->request
.op
.request_id
= 1;
287 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_CHARSET
,
288 "attributes-charset", NULL
, "utf-8");
289 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_LANGUAGE
,
290 "attributes-natural-language", NULL
, "en");
291 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
292 "printer-uri", NULL
, "ipp://localhost/printers/foo");
296 ippAddInteger(size
, IPP_TAG_ZERO
, IPP_TAG_INTEGER
, "x-dimension", 21590);
297 ippAddInteger(size
, IPP_TAG_ZERO
, IPP_TAG_INTEGER
, "y-dimension", 27940);
298 ippAddCollection(cols
[0], IPP_TAG_JOB
, "media-size", size
);
300 ippAddString(cols
[0], IPP_TAG_JOB
, IPP_TAG_KEYWORD
, "media-color", NULL
,
302 ippAddString(cols
[0], IPP_TAG_JOB
, IPP_TAG_KEYWORD
, "media-type", NULL
,
307 ippAddInteger(size
, IPP_TAG_ZERO
, IPP_TAG_INTEGER
, "x-dimension", 21000);
308 ippAddInteger(size
, IPP_TAG_ZERO
, IPP_TAG_INTEGER
, "y-dimension", 29700);
309 ippAddCollection(cols
[1], IPP_TAG_JOB
, "media-size", size
);
311 ippAddString(cols
[1], IPP_TAG_JOB
, IPP_TAG_KEYWORD
, "media-color", NULL
,
313 ippAddString(cols
[1], IPP_TAG_JOB
, IPP_TAG_KEYWORD
, "media-type", NULL
,
316 ippAddCollections(request
, IPP_TAG_JOB
, "media-col", 2,
317 (const ipp_t
**)cols
);
321 length
= ippLength(request
);
322 if (length
!= sizeof(collection
))
324 printf("FAIL - wrong ippLength(), %d instead of %d bytes!\n",
325 length
, (int)sizeof(collection
));
335 printf("Write Sample to Memory: ");
338 data
.wsize
= sizeof(buffer
);
339 data
.wbuffer
= buffer
;
341 while ((state
= ippWriteIO(&data
, (ipp_iocb_t
)write_cb
, 1, NULL
,
342 request
)) != IPP_STATE_DATA
)
343 if (state
== IPP_STATE_ERROR
)
346 if (state
!= IPP_STATE_DATA
)
348 printf("FAIL - %d bytes written.\n", (int)data
.wused
);
351 else if (data
.wused
!= sizeof(collection
))
353 printf("FAIL - wrote %d bytes, expected %d bytes!\n", (int)data
.wused
,
354 (int)sizeof(collection
));
355 hex_dump("Bytes Written", data
.wbuffer
, data
.wused
);
356 hex_dump("Baseline", collection
, sizeof(collection
));
359 else if (memcmp(data
.wbuffer
, collection
, data
.wused
))
361 for (i
= 0; i
< data
.wused
; i
++)
362 if (data
.wbuffer
[i
] != collection
[i
])
365 printf("FAIL - output does not match baseline at 0x%04x!\n", i
);
366 hex_dump("Bytes Written", data
.wbuffer
, data
.wused
);
367 hex_dump("Baseline", collection
, sizeof(collection
));
376 * Read the data back in and confirm...
379 printf("Read Sample from Memory: ");
384 while ((state
= ippReadIO(&data
, (ipp_iocb_t
)read_cb
, 1, NULL
,
385 request
)) != IPP_STATE_DATA
)
386 if (state
== IPP_STATE_ERROR
)
389 length
= ippLength(request
);
391 if (state
!= IPP_STATE_DATA
)
393 printf("FAIL - %d bytes read.\n", (int)data
.rpos
);
396 else if (data
.rpos
!= data
.wused
)
398 printf("FAIL - read %d bytes, expected %d bytes!\n", (int)data
.rpos
,
400 print_attributes(request
, 8);
403 else if (length
!= sizeof(collection
))
405 printf("FAIL - wrong ippLength(), %d instead of %d bytes!\n",
406 length
, (int)sizeof(collection
));
407 print_attributes(request
, 8);
413 fputs("ippFindAttribute(media-col): ", stdout
);
414 if ((media_col
= ippFindAttribute(request
, "media-col",
415 IPP_TAG_BEGIN_COLLECTION
)) == NULL
)
417 if ((media_col
= ippFindAttribute(request
, "media-col",
418 IPP_TAG_ZERO
)) == NULL
)
419 puts("FAIL (not found)");
421 printf("FAIL (wrong type - %s)\n", ippTagString(media_col
->value_tag
));
425 else if (media_col
->num_values
!= 2)
427 printf("FAIL (wrong count - %d)\n", media_col
->num_values
);
435 fputs("ippFindAttribute(media-size 1): ", stdout
);
436 if ((media_size
= ippFindAttribute(media_col
->values
[0].collection
,
438 IPP_TAG_BEGIN_COLLECTION
)) == NULL
)
440 if ((media_size
= ippFindAttribute(media_col
->values
[0].collection
,
442 IPP_TAG_ZERO
)) == NULL
)
443 puts("FAIL (not found)");
445 printf("FAIL (wrong type - %s)\n",
446 ippTagString(media_size
->value_tag
));
452 if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
453 "x-dimension", IPP_TAG_INTEGER
)) == NULL
)
455 if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
456 "x-dimension", IPP_TAG_ZERO
)) == NULL
)
457 puts("FAIL (missing x-dimension)");
459 printf("FAIL (wrong type for x-dimension - %s)\n",
460 ippTagString(attr
->value_tag
));
464 else if (attr
->values
[0].integer
!= 21590)
466 printf("FAIL (wrong value for x-dimension - %d)\n",
467 attr
->values
[0].integer
);
470 else if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
472 IPP_TAG_INTEGER
)) == NULL
)
474 if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
475 "y-dimension", IPP_TAG_ZERO
)) == NULL
)
476 puts("FAIL (missing y-dimension)");
478 printf("FAIL (wrong type for y-dimension - %s)\n",
479 ippTagString(attr
->value_tag
));
483 else if (attr
->values
[0].integer
!= 27940)
485 printf("FAIL (wrong value for y-dimension - %d)\n",
486 attr
->values
[0].integer
);
493 fputs("ippFindAttribute(media-size 2): ", stdout
);
494 if ((media_size
= ippFindAttribute(media_col
->values
[1].collection
,
496 IPP_TAG_BEGIN_COLLECTION
)) == NULL
)
498 if ((media_size
= ippFindAttribute(media_col
->values
[1].collection
,
500 IPP_TAG_ZERO
)) == NULL
)
501 puts("FAIL (not found)");
503 printf("FAIL (wrong type - %s)\n",
504 ippTagString(media_size
->value_tag
));
510 if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
512 IPP_TAG_INTEGER
)) == NULL
)
514 if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
515 "x-dimension", IPP_TAG_ZERO
)) == NULL
)
516 puts("FAIL (missing x-dimension)");
518 printf("FAIL (wrong type for x-dimension - %s)\n",
519 ippTagString(attr
->value_tag
));
523 else if (attr
->values
[0].integer
!= 21000)
525 printf("FAIL (wrong value for x-dimension - %d)\n",
526 attr
->values
[0].integer
);
529 else if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
531 IPP_TAG_INTEGER
)) == NULL
)
533 if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
534 "y-dimension", IPP_TAG_ZERO
)) == NULL
)
535 puts("FAIL (missing y-dimension)");
537 printf("FAIL (wrong type for y-dimension - %s)\n",
538 ippTagString(attr
->value_tag
));
542 else if (attr
->values
[0].integer
!= 29700)
544 printf("FAIL (wrong value for y-dimension - %d)\n",
545 attr
->values
[0].integer
);
556 * Read the mixed data and confirm we converted everything to rangeOfInteger
560 printf("Read Mixed integer/rangeOfInteger from Memory: ");
564 data
.wused
= sizeof(mixed
);
565 data
.wsize
= sizeof(mixed
);
566 data
.wbuffer
= mixed
;
568 while ((state
= ippReadIO(&data
, (ipp_iocb_t
)read_cb
, 1, NULL
,
569 request
)) != IPP_STATE_DATA
)
570 if (state
== IPP_STATE_ERROR
)
573 length
= ippLength(request
);
575 if (state
!= IPP_STATE_DATA
)
577 printf("FAIL - %d bytes read.\n", (int)data
.rpos
);
580 else if (data
.rpos
!= sizeof(mixed
))
582 printf("FAIL - read %d bytes, expected %d bytes!\n", (int)data
.rpos
,
584 print_attributes(request
, 8);
587 else if (length
!= (sizeof(mixed
) + 4))
589 printf("FAIL - wrong ippLength(), %d instead of %d bytes!\n",
590 length
, (int)sizeof(mixed
) + 4);
591 print_attributes(request
, 8);
597 fputs("ippFindAttribute(notify-lease-duration-supported): ", stdout
);
598 if ((attr
= ippFindAttribute(request
, "notify-lease-duration-supported",
599 IPP_TAG_ZERO
)) == NULL
)
601 puts("FAIL (not found)");
604 else if (attr
->value_tag
!= IPP_TAG_RANGE
)
606 printf("FAIL (wrong type - %s)\n", ippTagString(attr
->value_tag
));
609 else if (attr
->num_values
!= 2)
611 printf("FAIL (wrong count - %d)\n", attr
->num_values
);
614 else if (attr
->values
[0].range
.lower
!= 1 ||
615 attr
->values
[0].range
.upper
!= 1 ||
616 attr
->values
[1].range
.lower
!= 16 ||
617 attr
->values
[1].range
.upper
!= 32)
619 printf("FAIL (wrong values - %d,%d and %d,%d)\n",
620 attr
->values
[0].range
.lower
,
621 attr
->values
[0].range
.upper
,
622 attr
->values
[1].range
.lower
,
623 attr
->values
[1].range
.upper
);
633 * Test that private option array is sorted...
636 fputs("_ippCheckOptions: ", stdout
);
637 if ((name
= _ippCheckOptions()) == NULL
)
641 printf("FAIL (\"%s\" out of order)\n", name
);
647 * Test _ippFindOption() private API...
650 fputs("_ippFindOption(\"printer-type\"): ", stdout
);
651 if (_ippFindOption("printer-type"))
666 puts("Core IPP tests failed.");
668 puts("Core IPP tests passed.");
676 for (i
= 1; i
< argc
; i
++)
678 if ((fp
= cupsFileOpen(argv
[i
], "r")) == NULL
)
680 printf("Unable to open \"%s\" - %s\n", argv
[i
], strerror(errno
));
686 while ((state
= ippReadIO(fp
, (ipp_iocb_t
)cupsFileRead
, 1, NULL
,
687 request
)) == IPP_STATE_ATTRIBUTE
);
689 if (state
!= IPP_STATE_DATA
)
691 printf("Error reading IPP message from \"%s\"!\n", argv
[i
]);
696 printf("\n%s:\n", argv
[i
]);
697 print_attributes(request
, 4);
710 * 'hex_dump()' - Produce a hex dump of a buffer.
714 hex_dump(const char *title
, /* I - Title */
715 ipp_uchar_t
*buffer
, /* I - Buffer to dump */
716 int bytes
) /* I - Number of bytes */
718 int i
, j
; /* Looping vars */
719 int ch
; /* Current ASCII char */
723 * Show lines of 16 bytes at a time...
726 printf(" %s:\n", title
);
728 for (i
= 0; i
< bytes
; i
+= 16)
737 * Then up to 16 bytes in hex...
740 for (j
= 0; j
< 16; j
++)
742 printf(" %02x", buffer
[i
+ j
]);
747 * Then the ASCII representation of the bytes...
753 for (j
= 0; j
< 16 && (i
+ j
) < bytes
; j
++)
755 ch
= buffer
[i
+ j
] & 127;
757 if (ch
< ' ' || ch
== 127)
769 * 'print_attributes()' - Print the attributes in a request...
773 print_attributes(ipp_t
*ipp
, /* I - IPP request */
774 int indent
) /* I - Indentation */
776 int i
; /* Looping var */
777 ipp_tag_t group
; /* Current group */
778 ipp_attribute_t
*attr
; /* Current attribute */
779 _ipp_value_t
*val
; /* Current value */
780 static const char * const tags
[] = /* Value/group tag strings */
783 "operation-attributes-tag",
784 "job-attributes-tag",
785 "end-of-attributes-tag",
786 "printer-attributes-tag",
787 "unsupported-attributes-tag",
788 "subscription-attributes-tag",
789 "event-attributes-tag",
847 "textWithoutLanguage",
848 "nameWithoutLanguage",
860 for (group
= IPP_TAG_ZERO
, attr
= ipp
->attrs
; attr
; attr
= attr
->next
)
862 if (!attr
->name
&& indent
== 4)
864 group
= IPP_TAG_ZERO
;
869 if (group
!= attr
->group_tag
)
871 group
= attr
->group_tag
;
873 printf("\n%*s%s:\n\n", indent
- 4, "", tags
[group
]);
876 printf("%*s%s (", indent
, "", attr
->name
? attr
->name
: "(null)");
877 if (attr
->num_values
> 1)
879 printf("%s):", tags
[attr
->value_tag
]);
881 switch (attr
->value_tag
)
884 case IPP_TAG_INTEGER
:
885 for (i
= 0, val
= attr
->values
; i
< attr
->num_values
; i
++, val
++)
886 printf(" %d", val
->integer
);
890 case IPP_TAG_BOOLEAN
:
891 for (i
= 0, val
= attr
->values
; i
< attr
->num_values
; i
++, val
++)
892 printf(" %s", val
->boolean
? "true" : "false");
897 for (i
= 0, val
= attr
->values
; i
< attr
->num_values
; i
++, val
++)
898 printf(" %d-%d", val
->range
.lower
, val
->range
.upper
);
904 time_t vtime
; /* Date/Time value */
905 struct tm
*vdate
; /* Date info */
906 char vstring
[256]; /* Formatted time */
908 for (i
= 0, val
= attr
->values
; i
< attr
->num_values
; i
++, val
++)
910 vtime
= ippDateToTime(val
->date
);
911 vdate
= localtime(&vtime
);
912 strftime(vstring
, sizeof(vstring
), "%c", vdate
);
913 printf(" (%s)", vstring
);
919 case IPP_TAG_RESOLUTION
:
920 for (i
= 0, val
= attr
->values
; i
< attr
->num_values
; i
++, val
++)
921 printf(" %dx%d%s", val
->resolution
.xres
, val
->resolution
.yres
,
922 val
->resolution
.units
== IPP_RES_PER_INCH
? "dpi" : "dpcm");
926 case IPP_TAG_STRING
:
927 case IPP_TAG_TEXTLANG
:
928 case IPP_TAG_NAMELANG
:
931 case IPP_TAG_KEYWORD
:
933 case IPP_TAG_URISCHEME
:
934 case IPP_TAG_CHARSET
:
935 case IPP_TAG_LANGUAGE
:
936 case IPP_TAG_MIMETYPE
:
937 for (i
= 0, val
= attr
->values
; i
< attr
->num_values
; i
++, val
++)
938 printf(" \"%s\"", val
->string
.text
);
942 case IPP_TAG_BEGIN_COLLECTION
:
945 for (i
= 0, val
= attr
->values
; i
< attr
->num_values
; i
++, val
++)
949 print_attributes(val
->collection
, indent
+ 4);
954 printf("UNKNOWN (%d values)\n", attr
->num_values
);
962 * 'read_cb()' - Read data from a buffer.
965 ssize_t
/* O - Number of bytes read */
966 read_cb(_ippdata_t
*data
, /* I - Data */
967 ipp_uchar_t
*buffer
, /* O - Buffer to read */
968 size_t bytes
) /* I - Number of bytes to read */
970 size_t count
; /* Number of bytes */
974 * Copy bytes from the data buffer to the read buffer...
977 if ((count
= data
->wsize
- data
->rpos
) > bytes
)
980 memcpy(buffer
, data
->wbuffer
+ data
->rpos
, count
);
984 * Return the number of bytes read...
992 * 'write_cb()' - Write data into a buffer.
995 ssize_t
/* O - Number of bytes written */
996 write_cb(_ippdata_t
*data
, /* I - Data */
997 ipp_uchar_t
*buffer
, /* I - Buffer to write */
998 size_t bytes
) /* I - Number of bytes to write */
1000 size_t count
; /* Number of bytes */
1004 * Loop until all bytes are written...
1007 if ((count
= data
->wsize
- data
->wused
) > bytes
)
1010 memcpy(data
->wbuffer
+ data
->wused
, buffer
, count
);
1011 data
->wused
+= count
;
1014 * Return the number of bytes written...