/*
- * "$Id: ipptest.c 5023 2006-01-29 14:39:44Z mike $"
+ * "$Id: ipptest.c 5037 2006-02-01 15:19:59Z mike $"
*
* IPP test command for the Common UNIX Printing System (CUPS).
*
*
* Contents:
*
- * main() - Parse options and do tests.
- * do_tests() - Do tests as specified in the test file.
- * get_tag() - Get an IPP value or group tag from a name...
- * get_token() - Get a token from a file.
- * print_attr() - Print an attribute on the screen.
+ * main() - Parse options and do tests.
+ * do_tests() - Do tests as specified in the test file.
+ * get_tag() - Get an IPP value or group tag from a name...
+ * get_token() - Get a token from a file.
+ * print_attr() - Print an attribute on the screen.
+ * usage() - Show program usage.
*/
/*
#include <cups/language.h>
+/*
+ * Globals...
+ */
+
+int Verbosity = 0; /* Show all attributes? */
+
+
/*
* Local functions...
*/
ipp_tag_t get_tag(const char *);
char *get_token(FILE *, char *, int, int *linenum);
void print_attr(ipp_attribute_t *);
+void usage(const char *option);
/*
{
int i; /* Looping var */
int status; /* Status of tests... */
+ const char *uri; /* URI to use */
+ const char *testfile; /* Test file to use */
/*
* testipp URL testfile
*/
- if (argc < 3)
+ uri = NULL;
+ testfile = NULL;
+ status = 0;
+
+ for (i = 1; i < argc; i ++)
{
- fputs("Usage: ipptest URL testfile [ ... testfileN ]\n", stderr);
- return (1);
- }
+ if (argv[i][0] == '-')
+ {
+ if (!strcmp(argv[i], "-v"))
+ Verbosity ++;
+ else
+ usage(argv[i]);
+ }
+ else if (!strncmp(argv[i], "ipp://", 6) ||
+ !strncmp(argv[i], "http://", 7) ||
+ !strncmp(argv[i], "https://", 8))
+ {
+ /*
+ * Set URI...
+ */
- /*
- * Run tests...
- */
+ if (!testfile && uri)
+ usage(NULL);
+
+ uri = argv[i];
+ testfile = NULL;
+ }
+ else
+ {
+ /*
+ * Run test...
+ */
+
+ testfile = argv[i];
+
+ if (!do_tests(uri, testfile))
+ status ++;
+ }
+ }
- for (i = 2, status = 1; status && i < argc; i ++)
- status = status && do_tests(argv[1], argv[i]);
+ if (!uri || !testfile)
+ usage(NULL);
/*
* Exit...
*/
- return (!status);
+ return (status);
}
printf(" RECEIVED: %lu bytes in response\n",
(unsigned long)ippLength(response));
- if (num_displayed > 0)
+ if (Verbosity)
+ {
+ for (attrptr = response->attrs; attrptr != NULL; attrptr = attrptr->next)
+ print_attr(attrptr);
+ }
+ else if (num_displayed > 0)
{
for (attrptr = response->attrs; attrptr != NULL; attrptr = attrptr->next)
if (attrptr->name)
/*
- * End of "$Id: ipptest.c 5023 2006-01-29 14:39:44Z mike $".
+ * 'usage()' - Show program usage.
+ */
+
+void
+usage(const char *option) /* I - Option string or NULL */
+{
+ if (option)
+ fprintf(stderr, "ipptest: Unknown option \"%s\"!\n", option);
+
+ fputs("Usage: ipptest [options] URL testfile [ ... testfileN ]\n", stderr);
+ fputs("Options:\n", stderr);
+ fputs("\n", stderr);
+ fputs("-v Show all attributes in response, even on success.\n", stderr);
+
+ exit(1);
+}
+
+
+/*
+ * End of "$Id: ipptest.c 5037 2006-02-01 15:19:59Z mike $".
*/