]>
git.ipfire.org Git - thirdparty/cups.git/blob - test/ipptest.c
2 * "$Id: ipptest.c 7847 2008-08-19 04:22:14Z mike $"
4 * IPP test command for the Common UNIX Printing System (CUPS).
6 * Copyright 2007-2009 by Apple Inc.
7 * Copyright 1997-2007 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/".
17 * main() - Parse options and do tests.
18 * do_tests() - Do tests as specified in the test file.
19 * expect_matches() - Return true if the tag matches the specification.
20 * get_token() - Get a token from a file.
21 * print_attr() - Print an attribute on the screen.
22 * print_col() - Print a collection attribute on the screen.
23 * usage() - Show program usage.
27 * Include necessary headers...
32 #include <cups/string.h>
36 #include <cups/cups.h>
37 #include <cups/language.h>
38 #include <cups/http-private.h>
41 #endif /* !O_BINARY */
48 typedef struct _cups_expect_s
/**** Expected attribute info ****/
50 int not_expect
; /* Don't expect attribute? */
51 char *name
, /* Attribute name */
52 *of_type
, /* Type name */
53 *same_count_as
, /* Parallel attribute name */
54 *if_defined
; /* Only required if variable defined */
62 int Chunking
= 0; /* Use chunked requests */
63 int Verbosity
= 0; /* Show all attributes? */
70 static int do_tests(const char *uri
, const char *testfile
);
71 static int expect_matches(_cups_expect_t
*expect
, ipp_tag_t value_tag
);
72 static char *get_token(FILE *fp
, char *buf
, int buflen
,
74 static void print_attr(ipp_attribute_t
*attr
);
75 static void print_col(ipp_t
*col
);
76 static void usage(void);
80 * 'main()' - Parse options and do tests.
83 int /* O - Exit status */
84 main(int argc
, /* I - Number of command-line args */
85 char *argv
[]) /* I - Command-line arguments */
87 int i
; /* Looping var */
88 int status
; /* Status of tests... */
89 char *opt
; /* Current option */
90 const char *uri
, /* URI to use */
91 *testfile
; /* Test file to use */
92 int interval
; /* Test interval */
98 * testipp URL testfile
106 for (i
= 1; i
< argc
; i
++)
108 if (argv
[i
][0] == '-')
110 for (opt
= argv
[i
] + 1; *opt
; opt
++)
114 case 'c' : /* Enable HTTP chunking */
118 case 'd' : /* Define a variable */
123 fputs("ipptest: Missing name=value for \"-d\"!\n", stderr
);
130 case 'i' : /* Test every N seconds */
135 fputs("ipptest: Missing seconds for \"-i\"!\n", stderr
);
139 interval
= atoi(argv
[i
]);
142 case 'v' : /* Be verbose */
147 fprintf(stderr
, "ipptest: Unknown option \"-%c\"!\n", *opt
);
153 else if (!strncmp(argv
[i
], "ipp://", 6) ||
154 !strncmp(argv
[i
], "http://", 7) ||
155 !strncmp(argv
[i
], "https://", 8))
161 if (!testfile
&& uri
)
163 fputs("ipptest: May only specify a single URI before a test!\n",
179 if (!do_tests(uri
, testfile
))
184 if (!uri
|| !testfile
)
188 * Loop if the interval is set...
196 do_tests(uri
, testfile
);
209 * 'do_tests()' - Do tests as specified in the test file.
212 static int /* 1 = success, 0 = failure */
213 do_tests(const char *uri
, /* I - URI to connect on */
214 const char *testfile
) /* I - Test file to use */
216 int i
; /* Looping var */
217 int linenum
; /* Current line number */
218 int version
; /* IPP version number to use */
219 http_t
*http
; /* HTTP connection to server */
220 char scheme
[HTTP_MAX_URI
], /* URI scheme */
221 userpass
[HTTP_MAX_URI
], /* username:password */
222 server
[HTTP_MAX_URI
], /* Server */
223 resource
[HTTP_MAX_URI
]; /* Resource path */
224 int port
; /* Port number */
225 FILE *fp
; /* Test file */
226 char token
[1024], /* Token from file */
227 *tokenptr
, /* Pointer into token */
228 temp
[1024], /* Temporary string */
229 *tempptr
; /* Pointer into temp string */
230 ipp_t
*request
; /* IPP request */
231 ipp_t
*response
; /* IPP response */
232 ipp_op_t op
; /* Operation */
233 ipp_tag_t group
; /* Current group */
234 ipp_tag_t value
; /* Current value type */
235 ipp_attribute_t
*attrptr
, /* Attribute pointer */
236 *found
; /* Found attribute */
237 char attr
[128]; /* Attribute name */
238 int num_statuses
; /* Number of valid status codes */
239 ipp_status_t statuses
[100]; /* Valid status codes */
240 int num_expects
; /* Number of expected attributes */
241 _cups_expect_t expects
[100], /* Expected attributes */
242 *expect
, /* Current expected attribute */
243 *last_expect
; /* Last EXPECT (for predicates) */
244 int num_displayed
; /* Number of displayed attributes */
245 char *displayed
[100]; /* Displayed attributes */
246 char name
[1024]; /* Name of test */
247 char filename
[1024]; /* Filename */
248 int pass
; /* Did we pass the test? */
249 int job_id
; /* Job ID from last operation */
250 int subscription_id
; /* Subscription ID from last operation */
254 * Open the test file...
257 if ((fp
= fopen(testfile
, "r")) == NULL
)
259 printf("Unable to open test file %s - %s\n", testfile
, strerror(errno
));
264 * Connect to the server...
267 httpSeparateURI(HTTP_URI_CODING_ALL
, uri
, scheme
, sizeof(scheme
), userpass
,
268 sizeof(userpass
), server
, sizeof(server
), &port
, resource
,
270 if ((http
= httpConnect(server
, port
)) == NULL
)
272 printf("Unable to connect to %s on port %d - %s\n", server
, port
,
282 printf("\"%s\":\n", testfile
);
289 while (get_token(fp
, token
, sizeof(token
), &linenum
) != NULL
)
292 * Expect an open brace...
295 if (strcmp(token
, "{"))
297 printf("Unexpected token %s seen on line %d - aborting test!\n", token
,
304 * Initialize things...
307 httpSeparateURI(HTTP_URI_CODING_ALL
, uri
, scheme
, sizeof(scheme
), userpass
,
308 sizeof(userpass
), server
, sizeof(server
), &port
, resource
,
313 group
= IPP_TAG_ZERO
;
320 strcpy(name
, testfile
);
321 if (strrchr(name
, '.') != NULL
)
322 *strrchr(name
, '.') = '\0';
325 * Parse until we see a close brace...
328 while (get_token(fp
, token
, sizeof(token
), &linenum
) != NULL
)
330 if (strcasecmp(token
, "EXPECT") &&
331 strcasecmp(token
, "IF-DEFINED") &&
332 strcasecmp(token
, "OF-TYPE") &&
333 strcasecmp(token
, "SAME-COUNT-AS"))
336 if (!strcmp(token
, "}"))
338 else if (!strcasecmp(token
, "NAME"))
344 get_token(fp
, name
, sizeof(name
), &linenum
);
346 else if (!strcasecmp(token
, "VERSION"))
349 * IPP version number for test...
352 int major
, minor
; /* Major/minor IPP version */
355 get_token(fp
, temp
, sizeof(temp
), &linenum
);
356 if (sscanf(temp
, "%d.%d", &major
, &minor
) == 2 &&
357 major
>= 0 && minor
>= 0 && minor
< 10)
358 version
= major
* 10 + minor
;
361 printf("Bad version %s seen on line %d - aborting test!\n", token
,
368 else if (!strcasecmp(token
, "RESOURCE"))
374 get_token(fp
, resource
, sizeof(resource
), &linenum
);
376 else if (!strcasecmp(token
, "OPERATION"))
382 get_token(fp
, token
, sizeof(token
), &linenum
);
383 op
= ippOpValue(token
);
385 else if (!strcasecmp(token
, "GROUP"))
391 get_token(fp
, token
, sizeof(token
), &linenum
);
392 value
= ippTagValue(token
);
395 ippAddSeparator(request
);
399 else if (!strcasecmp(token
, "DELAY"))
402 * Delay before operation...
407 get_token(fp
, token
, sizeof(token
), &linenum
);
408 if ((delay
= atoi(token
)) > 0)
411 else if (!strcasecmp(token
, "ATTR"))
417 get_token(fp
, token
, sizeof(token
), &linenum
);
418 value
= ippTagValue(token
);
419 get_token(fp
, attr
, sizeof(attr
), &linenum
);
420 get_token(fp
, temp
, sizeof(temp
), &linenum
);
422 token
[sizeof(token
) - 1] = '\0';
424 for (tempptr
= temp
, tokenptr
= token
;
425 *tempptr
&& tokenptr
< (token
+ sizeof(token
) - 1);)
429 * Substitute a string/number...
432 if (!strncasecmp(tempptr
+ 1, "uri", 3))
434 strlcpy(tokenptr
, uri
, sizeof(token
) - (tokenptr
- token
));
437 else if (!strncasecmp(tempptr
+ 1, "scheme", 6) ||
438 !strncasecmp(tempptr
+ 1, "method", 6))
440 strlcpy(tokenptr
, scheme
, sizeof(token
) - (tokenptr
- token
));
443 else if (!strncasecmp(tempptr
+ 1, "username", 8))
445 strlcpy(tokenptr
, userpass
, sizeof(token
) - (tokenptr
- token
));
448 else if (!strncasecmp(tempptr
+ 1, "hostname", 8))
450 strlcpy(tokenptr
, server
, sizeof(token
) - (tokenptr
- token
));
453 else if (!strncasecmp(tempptr
+ 1, "port", 4))
455 snprintf(tokenptr
, sizeof(token
) - (tokenptr
- token
),
459 else if (!strncasecmp(tempptr
+ 1, "resource", 8))
461 strlcpy(tokenptr
, resource
, sizeof(token
) - (tokenptr
- token
));
464 else if (!strncasecmp(tempptr
+ 1, "job-id", 6))
466 snprintf(tokenptr
, sizeof(token
) - (tokenptr
- token
),
470 else if (!strncasecmp(tempptr
+ 1, "notify-subscription-id", 22))
472 snprintf(tokenptr
, sizeof(token
) - (tokenptr
- token
),
473 "%d", subscription_id
);
476 else if (!strncasecmp(tempptr
+ 1, "user", 4))
478 strlcpy(tokenptr
, cupsUser(), sizeof(token
) - (tokenptr
- token
));
481 else if (!strncasecmp(tempptr
+ 1, "ENV[", 4))
483 char *end
; /* End of $ENV[name] */
486 if ((end
= strchr(tempptr
+ 5, ']')) != NULL
)
490 getenv(tempptr
+ 5) ? getenv(tempptr
+ 5) : tempptr
+ 5,
491 sizeof(token
) - (tokenptr
- token
));
496 *tokenptr
++ = *tempptr
++;
502 *tokenptr
++ = *tempptr
++;
506 tokenptr
+= strlen(tokenptr
);
510 *tokenptr
++ = *tempptr
++;
516 case IPP_TAG_BOOLEAN
:
517 if (!strcasecmp(token
, "true"))
518 ippAddBoolean(request
, group
, attr
, 1);
520 ippAddBoolean(request
, group
, attr
, atoi(token
));
523 case IPP_TAG_INTEGER
:
525 ippAddInteger(request
, group
, value
, attr
, atoi(token
));
528 case IPP_TAG_RESOLUTION
:
529 puts(" ERROR: resolution tag not yet supported!");
533 puts(" ERROR: range tag not yet supported!");
537 if (!strchr(token
, ','))
538 ippAddString(request
, group
, value
, attr
, NULL
, token
);
542 * Multiple string values...
545 int num_values
; /* Number of values */
546 char *values
[100], /* Values */
547 *ptr
; /* Pointer to next value */
553 for (ptr
= strchr(token
, ','); ptr
; ptr
= strchr(ptr
, ','))
556 values
[num_values
] = ptr
;
560 ippAddStrings(request
, group
, value
, attr
, num_values
,
561 NULL
, (const char **)values
);
566 else if (!strcasecmp(token
, "FILE"))
572 get_token(fp
, filename
, sizeof(filename
), &linenum
);
574 else if (!strcasecmp(token
, "STATUS") &&
575 num_statuses
< (int)(sizeof(statuses
) / sizeof(statuses
[0])))
581 get_token(fp
, token
, sizeof(token
), &linenum
);
582 statuses
[num_statuses
] = ippErrorValue(token
);
585 else if (!strcasecmp(token
, "EXPECT"))
588 * Expected attributes...
591 if (num_expects
>= (int)(sizeof(expects
) / sizeof(expects
[0])))
593 fprintf(stderr
, "ipptest: Too many EXPECT's on line %d\n", linenum
);
599 get_token(fp
, token
, sizeof(token
), &linenum
);
601 last_expect
= expects
+ num_expects
;
606 last_expect
->not_expect
= 1;
607 last_expect
->name
= strdup(token
+ 1);
611 last_expect
->not_expect
= 0;
612 last_expect
->name
= strdup(token
);
615 last_expect
->of_type
= NULL
;
616 last_expect
->same_count_as
= NULL
;
617 last_expect
->if_defined
= NULL
;
619 else if (!strcasecmp(token
, "OF-TYPE"))
621 get_token(fp
, token
, sizeof(token
), &linenum
);
624 last_expect
->of_type
= strdup(token
);
628 "ipptest: OF-TYPE without a preceding EXPECT on line %d\n",
635 else if (!strcasecmp(token
, "SAME-COUNT-AS"))
637 get_token(fp
, token
, sizeof(token
), &linenum
);
640 last_expect
->same_count_as
= strdup(token
);
644 "ipptest: SAME-COUNT-AS without a preceding EXPECT on line "
651 else if (!strcasecmp(token
, "IF-DEFINED"))
653 get_token(fp
, token
, sizeof(token
), &linenum
);
656 last_expect
->if_defined
= strdup(token
);
660 "ipptest: IF-DEFINED without a preceding EXPECT on line %d\n",
667 else if (!strcasecmp(token
, "DISPLAY") &&
668 num_displayed
< (int)(sizeof(displayed
) / sizeof(displayed
[0])))
671 * Display attributes...
674 get_token(fp
, token
, sizeof(token
), &linenum
);
675 displayed
[num_displayed
] = strdup(token
);
681 "ipptest: Unexpected token %s seen on line %d - aborting "
682 "test!\n", token
, linenum
);
690 * Submit the IPP request...
693 request
->request
.op
.version
[0] = version
/ 10;
694 request
->request
.op
.version
[1] = version
% 10;
695 request
->request
.op
.operation_id
= op
;
696 request
->request
.op
.request_id
= 1;
700 printf(" %s:\n", ippOpString(op
));
702 for (attrptr
= request
->attrs
; attrptr
; attrptr
= attrptr
->next
)
706 printf(" %-60.60s [", name
);
711 http_status_t status
= cupsSendRequest(http
, request
, resource
, 0);
713 if (status
== HTTP_CONTINUE
&& filename
[0])
715 int fd
; /* File to send */
716 char buffer
[8192]; /* Copy buffer */
717 ssize_t bytes
; /* Bytes read/written */
720 if ((fd
= open(filename
, O_RDONLY
| O_BINARY
)) >= 0)
722 while ((bytes
= read(fd
, buffer
, sizeof(buffer
))) > 0)
723 if ((status
= cupsWriteRequestData(http
, buffer
,
724 bytes
)) != HTTP_CONTINUE
)
733 if (status
== HTTP_CONTINUE
)
734 response
= cupsGetResponse(http
, resource
);
738 else if (filename
[0])
739 response
= cupsDoFileRequest(http
, request
, resource
, filename
);
741 response
= cupsDoIORequest(http
, request
, resource
, -1,
744 if (response
== NULL
)
748 curtime
= time(NULL
);
751 printf(" ERROR %04x (%s) @ %s\n", cupsLastError(),
752 cupsLastErrorString(), ctime(&curtime
));
757 if (http
->version
!= HTTP_1_1
)
760 if ((attrptr
= ippFindAttribute(response
, "job-id",
761 IPP_TAG_INTEGER
)) != NULL
)
762 job_id
= attrptr
->values
[0].integer
;
764 if ((attrptr
= ippFindAttribute(response
, "notify-subscription-id",
765 IPP_TAG_INTEGER
)) != NULL
)
766 subscription_id
= attrptr
->values
[0].integer
;
768 for (i
= 0; i
< num_statuses
; i
++)
769 if (response
->request
.status
.status_code
== statuses
[i
])
772 if (i
== num_statuses
&& num_statuses
> 0)
776 for (i
= num_expects
, expect
= expects
; i
> 0; i
--, expect
++)
778 if (expect
->if_defined
&& !getenv(expect
->if_defined
))
781 found
= ippFindAttribute(response
, expect
->name
, IPP_TAG_ZERO
);
783 if ((found
== NULL
) != expect
->not_expect
||
784 (found
&& !expect_matches(expect
, found
->value_tag
)))
790 if (found
&& expect
->same_count_as
)
792 attrptr
= ippFindAttribute(response
, expect
->same_count_as
,
795 if (!attrptr
|| attrptr
->num_values
!= found
->num_values
)
807 printf(" RECEIVED: %lu bytes in response\n",
808 (unsigned long)ippLength(response
));
812 for (attrptr
= response
->attrs
;
814 attrptr
= attrptr
->next
)
819 else if (num_displayed
> 0)
821 for (attrptr
= response
->attrs
;
823 attrptr
= attrptr
->next
)
827 for (i
= 0; i
< num_displayed
; i
++)
829 if (!strcmp(displayed
[i
], attrptr
->name
))
842 printf(" RECEIVED: %lu bytes in response\n",
843 (unsigned long)ippLength(response
));
845 if (http
->version
!= HTTP_1_1
)
846 printf(" BAD HTTP VERSION (%d.%d)\n", http
->version
/ 100,
847 http
->version
% 100);
849 for (i
= 0; i
< num_statuses
; i
++)
850 if (response
->request
.status
.status_code
== statuses
[i
])
853 if (i
== num_statuses
&& num_statuses
> 0)
856 printf(" status-code = %04x (%s)\n",
857 cupsLastError(), ippErrorString(cupsLastError()));
859 for (i
= num_expects
, expect
= expects
; i
> 0; i
--, expect
++)
861 if (expect
->if_defined
&& !getenv(expect
->if_defined
))
864 found
= ippFindAttribute(response
, expect
->name
, IPP_TAG_ZERO
);
866 if ((found
== NULL
) != expect
->not_expect
)
868 if (expect
->not_expect
)
869 printf(" NOT EXPECTED: %s\n", expect
->name
);
871 printf(" EXPECTED: %s\n", expect
->name
);
875 if (!expect_matches(expect
, found
->value_tag
))
876 printf(" EXPECTED: %s of type %s but got %s\n",
877 expect
->name
, expect
->of_type
,
878 ippTagString(found
->value_tag
));
879 else if (expect
->same_count_as
)
881 attrptr
= ippFindAttribute(response
, expect
->same_count_as
,
885 printf(" EXPECTED: %s (%d values) same count as %s "
887 expect
->name
, found
->num_values
, expect
->same_count_as
);
888 else if (attrptr
->num_values
!= found
->num_values
)
889 printf(" EXPECTED: %s (%d values) same count as %s "
891 expect
->name
, found
->num_values
, expect
->same_count_as
,
892 attrptr
->num_values
);
897 for (attrptr
= response
->attrs
; attrptr
!= NULL
; attrptr
= attrptr
->next
)
904 for (i
= num_expects
, expect
= expects
; i
> 0; i
--, expect
++)
908 free(expect
->of_type
);
909 if (expect
->same_count_as
)
910 free(expect
->same_count_as
);
911 if (expect
->if_defined
)
912 free(expect
->if_defined
);
926 * 'expect_matches()' - Return true if the tag matches the specification.
929 static int /* O - 1 if matches, 0 otherwise */
931 _cups_expect_t
*expect
, /* I - Expected attribute */
932 ipp_tag_t value_tag
) /* I - Value tag for attribute */
934 int match
; /* Match? */
935 char *of_type
, /* Type name to match */
936 *next
; /* Next name to match */
940 * If we don't expect a particular type, return immediately...
943 if (!expect
->of_type
)
947 * Parse the "of_type" value since the string can contain multiple attribute
948 * types separated by "|"...
951 for (of_type
= expect
->of_type
, match
= 0; !match
&& of_type
; of_type
= next
)
954 * Find the next separator, and set it (temporarily) to nul if present.
957 if ((next
= strchr(of_type
, '|')) != NULL
)
961 * Support some meta-types to make it easier to write the test file.
964 if (!strcmp(of_type
, "text"))
965 match
= value_tag
== IPP_TAG_TEXTLANG
|| value_tag
== IPP_TAG_TEXT
;
966 else if (!strcmp(of_type
, "name"))
967 match
= value_tag
== IPP_TAG_NAMELANG
|| value_tag
== IPP_TAG_NAME
;
968 else if (!strcmp(of_type
, "collection"))
969 match
= value_tag
== IPP_TAG_BEGIN_COLLECTION
;
971 match
= value_tag
== ippTagValue(of_type
);
974 * Restore the separator if we have one...
986 * 'get_token()' - Get a token from a file.
989 static char * /* O - Token from file or NULL on EOF */
990 get_token(FILE *fp
, /* I - File to read from */
991 char *buf
, /* I - Buffer to read into */
992 int buflen
, /* I - Length of buffer */
993 int *linenum
) /* IO - Current line number */
995 int ch
, /* Character from file */
996 quote
; /* Quoting character */
997 char *bufptr
, /* Pointer into buffer */
998 *bufend
; /* End of buffer */
1004 * Skip whitespace...
1007 while (isspace(ch
= getc(fp
)))
1019 else if (ch
== '\'' || ch
== '\"')
1027 bufend
= buf
+ buflen
- 1;
1029 while ((ch
= getc(fp
)) != EOF
)
1032 else if (bufptr
< bufend
)
1044 while ((ch
= getc(fp
)) != EOF
)
1053 * Whitespace delimited text...
1059 bufend
= buf
+ buflen
- 1;
1061 while ((ch
= getc(fp
)) != EOF
)
1062 if (isspace(ch
) || ch
== '#')
1064 else if (bufptr
< bufend
)
1078 * 'print_attr()' - Print an attribute on the screen.
1082 print_attr(ipp_attribute_t
*attr
) /* I - Attribute to print */
1084 int i
; /* Looping var */
1087 if (attr
->name
== NULL
)
1089 puts(" -- separator --");
1093 printf(" %s (%s%s) = ", attr
->name
,
1094 attr
->num_values
> 1 ? "1setOf " : "",
1095 ippTagString(attr
->value_tag
));
1097 switch (attr
->value_tag
)
1099 case IPP_TAG_INTEGER
:
1101 for (i
= 0; i
< attr
->num_values
; i
++)
1102 printf("%d ", attr
->values
[i
].integer
);
1105 case IPP_TAG_BOOLEAN
:
1106 for (i
= 0; i
< attr
->num_values
; i
++)
1107 if (attr
->values
[i
].boolean
)
1113 case IPP_TAG_NOVALUE
:
1117 case IPP_TAG_RANGE
:
1118 for (i
= 0; i
< attr
->num_values
; i
++)
1119 printf("%d-%d ", attr
->values
[i
].range
.lower
,
1120 attr
->values
[i
].range
.upper
);
1123 case IPP_TAG_RESOLUTION
:
1124 for (i
= 0; i
< attr
->num_values
; i
++)
1125 printf("%dx%d%s ", attr
->values
[i
].resolution
.xres
,
1126 attr
->values
[i
].resolution
.yres
,
1127 attr
->values
[i
].resolution
.units
== IPP_RES_PER_INCH
?
1131 case IPP_TAG_STRING
:
1134 case IPP_TAG_KEYWORD
:
1135 case IPP_TAG_CHARSET
:
1137 case IPP_TAG_MIMETYPE
:
1138 case IPP_TAG_LANGUAGE
:
1139 for (i
= 0; i
< attr
->num_values
; i
++)
1140 printf("\"%s\" ", attr
->values
[i
].string
.text
);
1143 case IPP_TAG_TEXTLANG
:
1144 case IPP_TAG_NAMELANG
:
1145 for (i
= 0; i
< attr
->num_values
; i
++)
1146 printf("\"%s\",%s ", attr
->values
[i
].string
.text
,
1147 attr
->values
[i
].string
.charset
);
1150 case IPP_TAG_BEGIN_COLLECTION
:
1151 for (i
= 0; i
< attr
->num_values
; i
++)
1156 print_col(attr
->values
[i
].collection
);
1161 break; /* anti-compiler-warning-code */
1169 * 'print_col()' - Print a collection attribute on the screen.
1173 print_col(ipp_t
*col
) /* I - Collection attribute to print */
1175 int i
; /* Looping var */
1176 ipp_attribute_t
*attr
; /* Current attribute in collection */
1180 for (attr
= col
->attrs
; attr
; attr
= attr
->next
)
1182 printf("%s(%s%s)=", attr
->name
, attr
->num_values
> 1 ? "1setOf " : "",
1183 ippTagString(attr
->value_tag
));
1185 switch (attr
->value_tag
)
1187 case IPP_TAG_INTEGER
:
1189 for (i
= 0; i
< attr
->num_values
; i
++)
1190 printf("%d ", attr
->values
[i
].integer
);
1193 case IPP_TAG_BOOLEAN
:
1194 for (i
= 0; i
< attr
->num_values
; i
++)
1195 if (attr
->values
[i
].boolean
)
1201 case IPP_TAG_NOVALUE
:
1205 case IPP_TAG_RANGE
:
1206 for (i
= 0; i
< attr
->num_values
; i
++)
1207 printf("%d-%d ", attr
->values
[i
].range
.lower
,
1208 attr
->values
[i
].range
.upper
);
1211 case IPP_TAG_RESOLUTION
:
1212 for (i
= 0; i
< attr
->num_values
; i
++)
1213 printf("%dx%d%s ", attr
->values
[i
].resolution
.xres
,
1214 attr
->values
[i
].resolution
.yres
,
1215 attr
->values
[i
].resolution
.units
== IPP_RES_PER_INCH
?
1219 case IPP_TAG_STRING
:
1222 case IPP_TAG_KEYWORD
:
1223 case IPP_TAG_CHARSET
:
1225 case IPP_TAG_MIMETYPE
:
1226 case IPP_TAG_LANGUAGE
:
1227 for (i
= 0; i
< attr
->num_values
; i
++)
1228 printf("\"%s\" ", attr
->values
[i
].string
.text
);
1231 case IPP_TAG_TEXTLANG
:
1232 case IPP_TAG_NAMELANG
:
1233 for (i
= 0; i
< attr
->num_values
; i
++)
1234 printf("\"%s\",%s ", attr
->values
[i
].string
.text
,
1235 attr
->values
[i
].string
.charset
);
1238 case IPP_TAG_BEGIN_COLLECTION
:
1239 for (i
= 0; i
< attr
->num_values
; i
++)
1241 print_col(attr
->values
[i
].collection
);
1247 break; /* anti-compiler-warning-code */
1256 * 'usage()' - Show program usage.
1262 fputs("Usage: ipptest [options] URL testfile [ ... testfileN ]\n", stderr
);
1263 fputs("Options:\n", stderr
);
1264 fputs("\n", stderr
);
1265 fputs("-c Send requests using chunking.\n", stderr
);
1266 fputs("-d name=value Define variable.\n", stderr
);
1267 fputs("-i seconds Repeat the last test file with the given interval.\n",
1269 fputs("-v Show all attributes in response, even on success.\n",
1277 * End of "$Id: ipptest.c 7847 2008-08-19 04:22:14Z mike $".