/*
- * "$Id$"
+ * "$Id: ipptest.c 6503 2007-05-01 23:06:44Z mike $"
*
* IPP test command for the Common UNIX Printing System (CUPS).
*
- * Copyright 1997-2006 by Easy Software Products.
+ * Copyright 1997-2007 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
* property of Easy Software Products and are protected by Federal
int status; /* Status of tests... */
const char *uri; /* URI to use */
const char *testfile; /* Test file to use */
+ int interval; /* Test interval */
/*
uri = NULL;
testfile = NULL;
status = 0;
+ interval = 0;
for (i = 1; i < argc; i ++)
{
{
if (!strcmp(argv[i], "-v"))
Verbosity ++;
+ else if (!strcmp(argv[i], "-d"))
+ {
+ i ++;
+
+ if (i >= argc)
+ usage(NULL);
+ else
+ putenv(argv[i]);
+ }
+ else if (!strcmp(argv[i], "-i"))
+ {
+ i++;
+
+ if (i >= argc)
+ usage(NULL);
+ else
+ interval = atoi(argv[i]);
+ }
else
usage(argv[i]);
}
if (!uri || !testfile)
usage(NULL);
+ /*
+ * Loop if the interval is set...
+ */
+
+ if (interval)
+ {
+ for (;;)
+ {
+ sleep(interval);
+ do_tests(uri, testfile);
+ }
+ }
+
/*
* Exit...
*/
strlcpy(tokenptr, cupsUser(), sizeof(token) - (tokenptr - token));
tempptr += 5;
}
+ else if (!strncasecmp(tempptr + 1, "ENV[", 4))
+ {
+ char *end; /* End of $ENV[name] */
+
+
+ if ((end = strchr(tempptr + 5, ']')) != NULL)
+ {
+ *end++ = '\0';
+ strlcpy(tokenptr,
+ getenv(tempptr + 5) ? getenv(tempptr + 5) : tempptr + 5,
+ sizeof(token) - (tokenptr - token));
+ tempptr = end;
+ }
+ else
+ {
+ *tokenptr++ = *tempptr++;
+ *tokenptr = '\0';
+ }
+ }
else
{
- *tokenptr++ = *tempptr ++;
+ *tokenptr++ = *tempptr++;
*tokenptr = '\0';
}
if (filename[0])
response = cupsDoFileRequest(http, request, resource, filename);
else
- response = cupsDoRequest(http, request, resource);
+ response = cupsDoIORequest(http, request, resource, -1,
+ Verbosity ? 1 : -1);
if (response == NULL)
{
puts(" BAD STATUS");
printf(" status-code = %04x (%s)\n",
- cupsLastError(), cupsLastErrorString());
+ cupsLastError(), ippErrorString(cupsLastError()));
for (i = 0; i < num_expects; i ++)
if (ippFindAttribute(response, expects[i], IPP_TAG_ZERO) == NULL)
return;
}
- printf(" %s (%s) = ", attr->name, get_tag_string(attr->value_tag));
+ printf(" %s (%s%s) = ", attr->name,
+ attr->num_values > 1 ? "1setOf " : "",
+ get_tag_string(attr->value_tag));
switch (attr->value_tag)
{
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);
+ fputs("-i N Repeat the last test file once every N seconds.\n", stderr);
+ fputs("-v Show all attributes in response, even on success.\n", stderr);
exit(1);
}
/*
- * End of "$Id$".
+ * End of "$Id: ipptest.c 6503 2007-05-01 23:06:44Z mike $".
*/