/*
- * "$Id: ippfind.c 11594 2014-02-14 20:09:01Z msweet $"
+ * "$Id: ippfind.c 12139 2014-08-29 17:50:38Z msweet $"
*
* Utility to find IPP printers via Bonjour/DNS-SD and optionally run
* commands such as IPP and Bonjour conformance tests. This tool is
{
int i, /* Looping var */
have_output = 0,/* Have output expression */
- status = IPPFIND_EXIT_TRUE;
+ status = IPPFIND_EXIT_FALSE;
/* Exit status */
const char *opt, /* Option character */
*search; /* Current browse/resolve string */
* Parse command-line...
*/
+ if (getenv("IPPFIND_DEBUG"))
+ for (i = 1; i < argc; i ++)
+ fprintf(stderr, "argv[%d]=\"%s\"\n", i, argv[i]);
+
for (i = 1; i < argc; i ++)
{
if (argv[i][0] == '-')
NULL)) == NULL)
return (IPPFIND_EXIT_MEMORY);
}
- else if (!strncmp(argv[i], "--txt-", 5))
+ else if (!strncmp(argv[i], "--txt-", 6))
{
- const char *key = argv[i] + 5;/* TXT key */
+ const char *key = argv[i] + 6;/* TXT key */
i ++;
if (i >= argc)
service->ref = NULL;
}
- if (!eval_expr(service, expressions))
- status = IPPFIND_EXIT_FALSE;
+ if (eval_expr(service, expressions))
+ status = IPPFIND_EXIT_TRUE;
service->is_processed = 1;
}
result = !regexec(&(expression->re), val, 0, NULL, 0);
else
result = 0;
+
+ if (getenv("IPPFIND_DEBUG"))
+ printf("TXT_REGEX of \"%s\": %d\n", val, result);
break;
case IPPFIND_OP_URI_REGEX :
result = !regexec(&(expression->re), service->uri, 0, NULL, 0);
strlcpy(tptr, scheme + 22, sizeof(temp) - (size_t)(tptr - temp));
else if (!strncmp(keyword, "txt_", 4))
{
- if ((ptr = (char *)cupsGetOption(keyword + 4, service->num_txt,
- service->txt)) != NULL)
- strlcpy(tptr, strdup(ptr), sizeof(temp) - (size_t)(tptr - temp));
+ const char *txt = cupsGetOption(keyword + 4, service->num_txt, service->txt);
+ if (txt)
+ strlcpy(tptr, txt, sizeof(temp) - (size_t)(tptr - temp));
else
*tptr = '\0';
}
}
#ifdef WIN32
+ if (getenv("IPPFIND_DEBUG"))
+ {
+ printf("\nProgram:\n %s\n", args[0]);
+ puts("\nArguments:");
+ for (i = 0; i < num_args; i ++)
+ printf(" %s\n", myargv[i]);
+ puts("\nEnvironment:");
+ for (i = 0; i < myenvc; i ++)
+ printf(" %s\n", myenvp[i]);
+ }
+
status = _spawnvpe(_P_WAIT, args[0], myargv, myenvp);
#else
* Return whether the program succeeded or crashed...
*/
+ if (getenv("IPPFIND_DEBUG"))
+ {
+#ifdef WIN32
+ printf("Exit Status: %d\n", status);
+#else
+ if (WIFEXITED(status))
+ printf("Exit Status: %d\n", WEXITSTATUS(status));
+ else
+ printf("Terminating Signal: %d\n", WTERMSIG(status));
+#endif /* WIN32 */
+ }
+
return (status == 0);
}
/*
- * End of "$Id: ippfind.c 11594 2014-02-14 20:09:01Z msweet $".
+ * End of "$Id: ippfind.c 12139 2014-08-29 17:50:38Z msweet $".
*/