/*
- * "$Id: testipp.c 11890 2014-05-22 13:59:21Z msweet $"
+ * "$Id: testipp.c 11889 2014-05-22 13:54:15Z msweet $"
*
- * IPP test program for CUPS.
+ * IPP test program for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
- * Copyright 1997-2005 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2005 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * main() - Main entry.
- * hex_dump() - Produce a hex dump of a buffer.
- * print_attributes() - Print the attributes in a request...
- * read_cb() - Read data from a buffer.
- * write_cb() - Write data into a buffer.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
* Local globals...
*/
-ipp_uchar_t collection[] = /* Collection buffer */
+static ipp_uchar_t collection[] = /* Collection buffer */
{
0x01, 0x01, /* IPP version */
0x00, 0x02, /* Print-Job operation */
IPP_TAG_END /* end tag */
};
-ipp_uchar_t mixed[] = /* Mixed value buffer */
+static ipp_uchar_t mixed[] = /* Mixed value buffer */
{
0x01, 0x01, /* IPP version */
0x00, 0x02, /* Print-Job operation */
* Local functions...
*/
-void hex_dump(const char *title, ipp_uchar_t *buffer, int bytes);
+void hex_dump(const char *title, ipp_uchar_t *buffer, size_t bytes);
void print_attributes(ipp_t *ipp, int indent);
ssize_t read_cb(_ippdata_t *data, ipp_uchar_t *buffer, size_t bytes);
ssize_t write_cb(_ippdata_t *data, ipp_uchar_t *buffer, size_t bytes);
*media_size, /* media-size attribute */
*attr; /* Other attribute */
ipp_state_t state; /* State */
- int length; /* Length of data */
+ size_t length; /* Length of data */
cups_file_t *fp; /* File pointer */
- int i; /* Looping var */
+ size_t i; /* Looping var */
int status; /* Status of tests (0 = success, 1 = fail) */
#ifdef DEBUG
const char *name; /* Option name */
if (length != sizeof(collection))
{
printf("FAIL - wrong ippLength(), %d instead of %d bytes!\n",
- length, (int)sizeof(collection));
+ (int)length, (int)sizeof(collection));
status = 1;
}
else
if (data.wbuffer[i] != collection[i])
break;
- printf("FAIL - output does not match baseline at 0x%04x!\n", i);
+ printf("FAIL - output does not match baseline at 0x%04x!\n", (unsigned)i);
hex_dump("Bytes Written", data.wbuffer, data.wused);
hex_dump("Baseline", collection, sizeof(collection));
status = 1;
else if (length != sizeof(collection))
{
printf("FAIL - wrong ippLength(), %d instead of %d bytes!\n",
- length, (int)sizeof(collection));
+ (int)length, (int)sizeof(collection));
print_attributes(request, 8);
status = 1;
}
}
}
+ /*
+ * Test hierarchical find...
+ */
+
+ fputs("ippFindAttribute(media-col/media-size/x-dimension): ", stdout);
+ if ((attr = ippFindAttribute(request, "media-col/media-size/x-dimension", IPP_TAG_INTEGER)) != NULL)
+ {
+ if (ippGetInteger(attr, 0) != 21590)
+ {
+ printf("FAIL (wrong value for x-dimension - %d)\n", ippGetInteger(attr, 0));
+ status = 1;
+ }
+ else
+ puts("PASS");
+ }
+ else
+ {
+ puts("FAIL (not found)");
+ status = 1;
+ }
+
+ fputs("ippFindNextAttribute(media-col/media-size/x-dimension): ", stdout);
+ if ((attr = ippFindNextAttribute(request, "media-col/media-size/x-dimension", IPP_TAG_INTEGER)) != NULL)
+ {
+ if (ippGetInteger(attr, 0) != 21000)
+ {
+ printf("FAIL (wrong value for x-dimension - %d)\n", ippGetInteger(attr, 0));
+ status = 1;
+ }
+ else
+ puts("PASS");
+ }
+ else
+ {
+ puts("FAIL (not found)");
+ status = 1;
+ }
+
+ fputs("ippFindNextAttribute(media-col/media-size/x-dimension) again: ", stdout);
+ if ((attr = ippFindNextAttribute(request, "media-col/media-size/x-dimension", IPP_TAG_INTEGER)) != NULL)
+ {
+ printf("FAIL (got %d, expected nothing)\n", ippGetInteger(attr, 0));
+ status = 1;
+ }
+ else
+ puts("PASS");
+
ippDelete(request);
/*
else if (length != (sizeof(mixed) + 4))
{
printf("FAIL - wrong ippLength(), %d instead of %d bytes!\n",
- length, (int)sizeof(mixed) + 4);
+ (int)length, (int)sizeof(mixed) + 4);
print_attributes(request, 8);
status = 1;
}
* Read IPP files...
*/
- for (i = 1; i < argc; i ++)
+ for (i = 1; i < (size_t)argc; i ++)
{
if ((fp = cupsFileOpen(argv[i], "r")) == NULL)
{
void
hex_dump(const char *title, /* I - Title */
ipp_uchar_t *buffer, /* I - Buffer to dump */
- int bytes) /* I - Number of bytes */
+ size_t bytes) /* I - Number of bytes */
{
- int i, j; /* Looping vars */
- int ch; /* Current ASCII char */
+ size_t i, j; /* Looping vars */
+ int ch; /* Current ASCII char */
/*
* Show the offset...
*/
- printf(" %04x ", i);
+ printf(" %04x ", (unsigned)i);
/*
* Then up to 16 bytes in hex...
* Return the number of bytes read...
*/
- return (count);
+ return ((ssize_t)count);
}
* Return the number of bytes written...
*/
- return (count);
+ return ((ssize_t)count);
}
/*
- * End of "$Id: testipp.c 11890 2014-05-22 13:59:21Z msweet $".
+ * End of "$Id: testipp.c 11889 2014-05-22 13:54:15Z msweet $".
*/