#
# API library Makefile for CUPS.
#
-# Copyright 2007-2013 by Apple Inc.
+# Copyright 2007-2014 by Apple Inc.
# Copyright 1997-2006 by Easy Software Products, all rights reserved.
#
# These coded instructions, statements, and computer programs are the
UNITTARGETS = \
testadmin \
testarray \
+ testcache \
testconflicts \
testcups \
testfile \
./testarray
+#
+# testcache (dependency on static CUPS library is intentional)
+#
+
+testcache: testcache.o $(LIBCUPSSTATIC)
+ echo Linking $@...
+ $(CC) $(LDFLAGS) -o $@ testcache.o $(LIBCUPSSTATIC) \
+ $(LIBGSSAPI) $(SSLLIBS) $(DNSSDLIBS) $(COMMONLIBS) $(LIBZ)
+
+
#
# testconflicts (dependency on static CUPS library is intentional)
#
* Range check input...
*/
+ DEBUG_printf(("_ppdCacheGetFinishingValues(pc=%p, num_options=%d, options=%p, max_values=%d, values=%p)", pc, num_options, options, max_values, values));
+
if (!pc || !pc->finishings || num_options < 1 || max_values < 1 || !values)
+ {
+ DEBUG_puts("_ppdCacheGetFinishingValues: Bad arguments, returning 0.");
return (0);
+ }
/*
* Go through the finishings options and see what is set...
f;
f = (_pwg_finishings_t *)cupsArrayNext(pc->finishings))
{
+ DEBUG_printf(("_ppdCacheGetFinishingValues: Checking %d (%s)", f->value, ippEnumString("finishings", f->value)));
+
for (i = f->num_options, option = f->options; i > 0; i --, option ++)
+ {
+ DEBUG_printf(("_ppdCacheGetFinishingValues: %s=%s?", option->name, option->value));
+
if ((val = cupsGetOption(option->name, num_options, options)) == NULL ||
_cups_strcasecmp(option->value, val))
+ {
+ DEBUG_puts("_ppdCacheGetFinishingValues: NO");
break;
+ }
+ }
if (i == 0)
{
+ DEBUG_printf(("_ppdCacheGetFinishingValues: Adding %d.", f->value));
+
values[num_values ++] = f->value;
if (num_values >= max_values)
}
}
+ DEBUG_printf(("_ppdCacheGetFinishingValues: Returning %d.", num_values));
+
return (num_values);
}
--- /dev/null
+/*
+ * "$Id$"
+ *
+ * PPD cache testing program for CUPS.
+ *
+ * Copyright 2009-2014 by Apple Inc.
+ *
+ * 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.
+ */
+
+/*
+ * Include necessary headers...
+ */
+
+#include "ppd-private.h"
+#include "file-private.h"
+
+
+/*
+ * 'main()' - Main entry.
+ */
+
+int /* O - Exit status */
+main(int argc, /* I - Number of command-line args */
+ char *argv[]) /* I - Command-line arguments */
+{
+ int i; /* Looping var */
+ const char *ppdfile = NULL;/* PPD filename */
+ ppd_file_t *ppd; /* PPD file */
+ int num_options = 0;/* Number of options */
+ cups_option_t *options = NULL;/* Options */
+ _ppd_cache_t *pc; /* PPD cache and PWG mapping data */
+ int num_finishings, /* Number of finishing options */
+ finishings[20]; /* Finishing options */
+
+
+ if (argc < 2)
+ {
+ puts("Usage: ./testcache filename.ppd [name=value ... name=value]");
+ return (1);
+ }
+
+ ppdfile = argv[1];
+ if ((ppd = ppdOpenFile(ppdfile)) == NULL)
+ {
+ ppd_status_t err; /* Last error in file */
+ int line; /* Line number in file */
+
+
+ err = ppdLastError(&line);
+
+ fprintf(stderr, "Unable to open \"%s\": %s on line %d\n", ppdfile, ppdErrorString(err), line);
+ return (1);
+ }
+
+ if ((pc = _ppdCacheCreateWithPPD(ppd)) == NULL)
+ {
+ fprintf(stderr, "Unable to create PPD cache from \"%s\".\n", ppdfile);
+ return (1);
+ }
+
+ for (i = 2; i < argc; i ++)
+ num_options = cupsParseOptions(argv[i], num_options, &options);
+
+ ppdMarkDefaults(ppd);
+ cupsMarkOptions(ppd, num_options, options);
+
+ num_finishings = _ppdCacheGetFinishingValues(pc, num_options, options, (int)sizeof(finishings) / sizeof(finishings[0]), finishings);
+
+ fputs("finishings=", stdout);
+ for (i = 0; i < num_finishings; i ++)
+ if (i)
+ printf(",%d", finishings[i]);
+ else
+ printf("%d", finishings[i]);
+ fputs("\n", stdout);
+
+ return (0);
+}
+
+
+/*
+ * End of "$Id$".
+ */