]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/testipp.c
2 * "$Id: testipp.c 6649 2007-07-11 21:46:42Z mike $"
4 * IPP test program for CUPS.
6 * Copyright 2007-2011 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) */
273 * Test request generation code...
276 printf("Create Sample Request: ");
279 request
->request
.op
.version
[0] = 0x01;
280 request
->request
.op
.version
[1] = 0x01;
281 request
->request
.op
.operation_id
= IPP_PRINT_JOB
;
282 request
->request
.op
.request_id
= 1;
284 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_CHARSET
,
285 "attributes-charset", NULL
, "utf-8");
286 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_LANGUAGE
,
287 "attributes-natural-language", NULL
, "en");
288 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
,
289 "printer-uri", NULL
, "ipp://localhost/printers/foo");
293 ippAddInteger(size
, IPP_TAG_ZERO
, IPP_TAG_INTEGER
, "x-dimension", 21590);
294 ippAddInteger(size
, IPP_TAG_ZERO
, IPP_TAG_INTEGER
, "y-dimension", 27940);
295 ippAddCollection(cols
[0], IPP_TAG_JOB
, "media-size", size
);
297 ippAddString(cols
[0], IPP_TAG_JOB
, IPP_TAG_KEYWORD
, "media-color", NULL
,
299 ippAddString(cols
[0], IPP_TAG_JOB
, IPP_TAG_KEYWORD
, "media-type", NULL
,
304 ippAddInteger(size
, IPP_TAG_ZERO
, IPP_TAG_INTEGER
, "x-dimension", 21000);
305 ippAddInteger(size
, IPP_TAG_ZERO
, IPP_TAG_INTEGER
, "y-dimension", 29700);
306 ippAddCollection(cols
[1], IPP_TAG_JOB
, "media-size", size
);
308 ippAddString(cols
[1], IPP_TAG_JOB
, IPP_TAG_KEYWORD
, "media-color", NULL
,
310 ippAddString(cols
[1], IPP_TAG_JOB
, IPP_TAG_KEYWORD
, "media-type", NULL
,
313 ippAddCollections(request
, IPP_TAG_JOB
, "media-col", 2,
314 (const ipp_t
**)cols
);
318 length
= ippLength(request
);
319 if (length
!= sizeof(collection
))
321 printf("FAIL - wrong ippLength(), %d instead of %d bytes!\n",
322 length
, (int)sizeof(collection
));
332 printf("Write Sample to Memory: ");
335 data
.wsize
= sizeof(buffer
);
336 data
.wbuffer
= buffer
;
338 while ((state
= ippWriteIO(&data
, (ipp_iocb_t
)write_cb
, 1, NULL
,
339 request
)) != IPP_DATA
)
340 if (state
== IPP_ERROR
)
343 if (state
!= IPP_DATA
)
345 printf("FAIL - %d bytes written.\n", (int)data
.wused
);
348 else if (data
.wused
!= sizeof(collection
))
350 printf("FAIL - wrote %d bytes, expected %d bytes!\n", (int)data
.wused
,
351 (int)sizeof(collection
));
352 hex_dump("Bytes Written", data
.wbuffer
, data
.wused
);
353 hex_dump("Baseline", collection
, sizeof(collection
));
356 else if (memcmp(data
.wbuffer
, collection
, data
.wused
))
358 for (i
= 0; i
< data
.wused
; i
++)
359 if (data
.wbuffer
[i
] != collection
[i
])
362 printf("FAIL - output does not match baseline at 0x%04x!\n", i
);
363 hex_dump("Bytes Written", data
.wbuffer
, data
.wused
);
364 hex_dump("Baseline", collection
, sizeof(collection
));
373 * Read the data back in and confirm...
376 printf("Read Sample from Memory: ");
381 while ((state
= ippReadIO(&data
, (ipp_iocb_t
)read_cb
, 1, NULL
,
382 request
)) != IPP_DATA
)
383 if (state
== IPP_ERROR
)
386 length
= ippLength(request
);
388 if (state
!= IPP_DATA
)
390 printf("FAIL - %d bytes read.\n", (int)data
.rpos
);
393 else if (data
.rpos
!= data
.wused
)
395 printf("FAIL - read %d bytes, expected %d bytes!\n", (int)data
.rpos
,
397 print_attributes(request
, 8);
400 else if (length
!= sizeof(collection
))
402 printf("FAIL - wrong ippLength(), %d instead of %d bytes!\n",
403 length
, (int)sizeof(collection
));
404 print_attributes(request
, 8);
410 fputs("ippFindAttribute(media-col): ", stdout
);
411 if ((media_col
= ippFindAttribute(request
, "media-col",
412 IPP_TAG_BEGIN_COLLECTION
)) == NULL
)
414 if ((media_col
= ippFindAttribute(request
, "media-col",
415 IPP_TAG_ZERO
)) == NULL
)
416 puts("FAIL (not found)");
418 printf("FAIL (wrong type - %s)\n", ippTagString(media_col
->value_tag
));
422 else if (media_col
->num_values
!= 2)
424 printf("FAIL (wrong count - %d)\n", media_col
->num_values
);
432 fputs("ippFindAttribute(media-size 1): ", stdout
);
433 if ((media_size
= ippFindAttribute(media_col
->values
[0].collection
,
435 IPP_TAG_BEGIN_COLLECTION
)) == NULL
)
437 if ((media_size
= ippFindAttribute(media_col
->values
[0].collection
,
439 IPP_TAG_ZERO
)) == NULL
)
440 puts("FAIL (not found)");
442 printf("FAIL (wrong type - %s)\n",
443 ippTagString(media_size
->value_tag
));
449 if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
450 "x-dimension", IPP_TAG_INTEGER
)) == NULL
)
452 if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
453 "x-dimension", IPP_TAG_ZERO
)) == NULL
)
454 puts("FAIL (missing x-dimension)");
456 printf("FAIL (wrong type for x-dimension - %s)\n",
457 ippTagString(attr
->value_tag
));
461 else if (attr
->values
[0].integer
!= 21590)
463 printf("FAIL (wrong value for x-dimension - %d)\n",
464 attr
->values
[0].integer
);
467 else if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
469 IPP_TAG_INTEGER
)) == NULL
)
471 if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
472 "y-dimension", IPP_TAG_ZERO
)) == NULL
)
473 puts("FAIL (missing y-dimension)");
475 printf("FAIL (wrong type for y-dimension - %s)\n",
476 ippTagString(attr
->value_tag
));
480 else if (attr
->values
[0].integer
!= 27940)
482 printf("FAIL (wrong value for y-dimension - %d)\n",
483 attr
->values
[0].integer
);
490 fputs("ippFindAttribute(media-size 2): ", stdout
);
491 if ((media_size
= ippFindAttribute(media_col
->values
[1].collection
,
493 IPP_TAG_BEGIN_COLLECTION
)) == NULL
)
495 if ((media_size
= ippFindAttribute(media_col
->values
[1].collection
,
497 IPP_TAG_ZERO
)) == NULL
)
498 puts("FAIL (not found)");
500 printf("FAIL (wrong type - %s)\n",
501 ippTagString(media_size
->value_tag
));
507 if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
509 IPP_TAG_INTEGER
)) == NULL
)
511 if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
512 "x-dimension", IPP_TAG_ZERO
)) == NULL
)
513 puts("FAIL (missing x-dimension)");
515 printf("FAIL (wrong type for x-dimension - %s)\n",
516 ippTagString(attr
->value_tag
));
520 else if (attr
->values
[0].integer
!= 21000)
522 printf("FAIL (wrong value for x-dimension - %d)\n",
523 attr
->values
[0].integer
);
526 else if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
528 IPP_TAG_INTEGER
)) == NULL
)
530 if ((attr
= ippFindAttribute(media_size
->values
[0].collection
,
531 "y-dimension", IPP_TAG_ZERO
)) == NULL
)
532 puts("FAIL (missing y-dimension)");
534 printf("FAIL (wrong type for y-dimension - %s)\n",
535 ippTagString(attr
->value_tag
));
539 else if (attr
->values
[0].integer
!= 29700)
541 printf("FAIL (wrong value for y-dimension - %d)\n",
542 attr
->values
[0].integer
);
553 * Read the mixed data and confirm we converted everything to rangeOfInteger
557 printf("Read Mixed integer/rangeOfInteger from Memory: ");
561 data
.wused
= sizeof(mixed
);
562 data
.wsize
= sizeof(mixed
);
563 data
.wbuffer
= mixed
;
565 while ((state
= ippReadIO(&data
, (ipp_iocb_t
)read_cb
, 1, NULL
,
566 request
)) != IPP_DATA
)
567 if (state
== IPP_ERROR
)
570 length
= ippLength(request
);
572 if (state
!= IPP_DATA
)
574 printf("FAIL - %d bytes read.\n", (int)data
.rpos
);
577 else if (data
.rpos
!= sizeof(mixed
))
579 printf("FAIL - read %d bytes, expected %d bytes!\n", (int)data
.rpos
,
581 print_attributes(request
, 8);
584 else if (length
!= (sizeof(mixed
) + 4))
586 printf("FAIL - wrong ippLength(), %d instead of %d bytes!\n",
587 length
, (int)sizeof(mixed
) + 4);
588 print_attributes(request
, 8);
594 fputs("ippFindAttribute(notify-lease-duration-supported): ", stdout
);
595 if ((attr
= ippFindAttribute(request
, "notify-lease-duration-supported",
596 IPP_TAG_ZERO
)) == NULL
)
598 puts("FAIL (not found)");
601 else if (attr
->value_tag
!= IPP_TAG_RANGE
)
603 printf("FAIL (wrong type - %s)\n", ippTagString(attr
->value_tag
));
606 else if (attr
->num_values
!= 2)
608 printf("FAIL (wrong count - %d)\n", attr
->num_values
);
611 else if (attr
->values
[0].range
.lower
!= 1 ||
612 attr
->values
[0].range
.upper
!= 1 ||
613 attr
->values
[1].range
.lower
!= 16 ||
614 attr
->values
[1].range
.upper
!= 32)
616 printf("FAIL (wrong values - %d,%d and %d,%d)\n",
617 attr
->values
[0].range
.lower
,
618 attr
->values
[0].range
.upper
,
619 attr
->values
[1].range
.lower
,
620 attr
->values
[1].range
.upper
);
629 * Test _ippFindOption() private API...
632 fputs("_ippFindOption(printer-type): ", stdout
);
633 if (_ippFindOption("printer-type"))
648 puts("Core IPP tests failed.");
650 puts("Core IPP tests passed.");
658 for (i
= 1; i
< argc
; i
++)
660 if ((fp
= cupsFileOpen(argv
[i
], "r")) == NULL
)
662 printf("Unable to open \"%s\" - %s\n", argv
[i
], strerror(errno
));
668 while ((state
= ippReadIO(fp
, (ipp_iocb_t
)cupsFileRead
, 1, NULL
,
669 request
)) == IPP_ATTRIBUTE
);
671 if (state
!= IPP_DATA
)
673 printf("Error reading IPP message from \"%s\"!\n", argv
[i
]);
678 printf("\n%s:\n", argv
[i
]);
679 print_attributes(request
, 4);
692 * 'hex_dump()' - Produce a hex dump of a buffer.
696 hex_dump(const char *title
, /* I - Title */
697 ipp_uchar_t
*buffer
, /* I - Buffer to dump */
698 int bytes
) /* I - Number of bytes */
700 int i
, j
; /* Looping vars */
701 int ch
; /* Current ASCII char */
705 * Show lines of 16 bytes at a time...
708 printf(" %s:\n", title
);
710 for (i
= 0; i
< bytes
; i
+= 16)
719 * Then up to 16 bytes in hex...
722 for (j
= 0; j
< 16; j
++)
724 printf(" %02x", buffer
[i
+ j
]);
729 * Then the ASCII representation of the bytes...
735 for (j
= 0; j
< 16 && (i
+ j
) < bytes
; j
++)
737 ch
= buffer
[i
+ j
] & 127;
739 if (ch
< ' ' || ch
== 127)
751 * 'print_attributes()' - Print the attributes in a request...
755 print_attributes(ipp_t
*ipp
, /* I - IPP request */
756 int indent
) /* I - Indentation */
758 int i
; /* Looping var */
759 ipp_tag_t group
; /* Current group */
760 ipp_attribute_t
*attr
; /* Current attribute */
761 _ipp_value_t
*val
; /* Current value */
762 static const char * const tags
[] = /* Value/group tag strings */
765 "operation-attributes-tag",
766 "job-attributes-tag",
767 "end-of-attributes-tag",
768 "printer-attributes-tag",
769 "unsupported-attributes-tag",
770 "subscription-attributes-tag",
771 "event-attributes-tag",
829 "textWithoutLanguage",
830 "nameWithoutLanguage",
842 for (group
= IPP_TAG_ZERO
, attr
= ipp
->attrs
; attr
; attr
= attr
->next
)
844 if (!attr
->name
&& indent
== 4)
846 group
= IPP_TAG_ZERO
;
851 if (group
!= attr
->group_tag
)
853 group
= attr
->group_tag
;
855 printf("\n%*s%s:\n\n", indent
- 4, "", tags
[group
]);
858 printf("%*s%s (", indent
, "", attr
->name
? attr
->name
: "(null)");
859 if (attr
->num_values
> 1)
861 printf("%s):", tags
[attr
->value_tag
]);
863 switch (attr
->value_tag
)
866 case IPP_TAG_INTEGER
:
867 for (i
= 0, val
= attr
->values
; i
< attr
->num_values
; i
++, val
++)
868 printf(" %d", val
->integer
);
872 case IPP_TAG_BOOLEAN
:
873 for (i
= 0, val
= attr
->values
; i
< attr
->num_values
; i
++, val
++)
874 printf(" %s", val
->boolean
? "true" : "false");
879 for (i
= 0, val
= attr
->values
; i
< attr
->num_values
; i
++, val
++)
880 printf(" %d-%d", val
->range
.lower
, val
->range
.upper
);
886 time_t vtime
; /* Date/Time value */
887 struct tm
*vdate
; /* Date info */
888 char vstring
[256]; /* Formatted time */
890 for (i
= 0, val
= attr
->values
; i
< attr
->num_values
; i
++, val
++)
892 vtime
= ippDateToTime(val
->date
);
893 vdate
= localtime(&vtime
);
894 strftime(vstring
, sizeof(vstring
), "%c", vdate
);
895 printf(" (%s)", vstring
);
901 case IPP_TAG_RESOLUTION
:
902 for (i
= 0, val
= attr
->values
; i
< attr
->num_values
; i
++, val
++)
903 printf(" %dx%d%s", val
->resolution
.xres
, val
->resolution
.yres
,
904 val
->resolution
.units
== IPP_RES_PER_INCH
? "dpi" : "dpc");
908 case IPP_TAG_STRING
:
909 case IPP_TAG_TEXTLANG
:
910 case IPP_TAG_NAMELANG
:
913 case IPP_TAG_KEYWORD
:
915 case IPP_TAG_URISCHEME
:
916 case IPP_TAG_CHARSET
:
917 case IPP_TAG_LANGUAGE
:
918 case IPP_TAG_MIMETYPE
:
919 for (i
= 0, val
= attr
->values
; i
< attr
->num_values
; i
++, val
++)
920 printf(" \"%s\"", val
->string
.text
);
924 case IPP_TAG_BEGIN_COLLECTION
:
927 for (i
= 0, val
= attr
->values
; i
< attr
->num_values
; i
++, val
++)
931 print_attributes(val
->collection
, indent
+ 4);
936 printf("UNKNOWN (%d values)\n", attr
->num_values
);
944 * 'read_cb()' - Read data from a buffer.
947 ssize_t
/* O - Number of bytes read */
948 read_cb(_ippdata_t
*data
, /* I - Data */
949 ipp_uchar_t
*buffer
, /* O - Buffer to read */
950 size_t bytes
) /* I - Number of bytes to read */
952 size_t count
; /* Number of bytes */
956 * Copy bytes from the data buffer to the read buffer...
959 if ((count
= data
->wsize
- data
->rpos
) > bytes
)
962 memcpy(buffer
, data
->wbuffer
+ data
->rpos
, count
);
966 * Return the number of bytes read...
974 * 'write_cb()' - Write data into a buffer.
977 ssize_t
/* O - Number of bytes written */
978 write_cb(_ippdata_t
*data
, /* I - Data */
979 ipp_uchar_t
*buffer
, /* I - Buffer to write */
980 size_t bytes
) /* I - Number of bytes to write */
982 size_t count
; /* Number of bytes */
986 * Loop until all bytes are written...
989 if ((count
= data
->wsize
- data
->wused
) > bytes
)
992 memcpy(data
->wbuffer
+ data
->wused
, buffer
, count
);
993 data
->wused
+= count
;
996 * Return the number of bytes written...
1004 * End of "$Id: testipp.c 6649 2007-07-11 21:46:42Z mike $".