]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Add missing file.`
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Tue, 26 Aug 2008 03:55:07 +0000 (03:55 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Tue, 26 Aug 2008 03:55:07 +0000 (03:55 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@922 a1ca3aef-8c08-0410-bb20-df032aa958be

cups/testconflicts.c [new file with mode: 0644]

diff --git a/cups/testconflicts.c b/cups/testconflicts.c
new file mode 100644 (file)
index 0000000..6d52649
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * "$Id$"
+ *
+ *   PPD constraint test program for the Common UNIX Printing System (CUPS).
+ *
+ *   Copyright 2008 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.
+ *
+ * Contents:
+ *
+ *   main() - Main entry.
+ */
+
+/*
+ * Include necessary headers...
+ */
+
+#include "cups.h"
+#include "string.h"
+
+
+/*
+ * 'main()' - Main entry.
+ */
+
+int                                    /* O - Exit status */
+main(int  argc,                                /* I - Number of command-line arguments */
+     char *argv[])                     /* I - Command-line arguments */
+{
+  int          i;                      /* Looping var */
+  ppd_file_t   *ppd;                   /* PPD file loaded from disk */
+  char         line[256];              /* Input buffer */
+  int          num_options;            /* Number of options */
+  cups_option_t        *options;               /* Options */
+
+
+  if (argc != 2)
+  {
+    puts("Usage: testconflicts filename.ppd");
+    return (1);
+  }
+
+  if ((ppd = ppdOpenFile(argv[1])) == NULL)
+  {
+    ppd_status_t       err;            /* Last error in file */
+    int                        linenum;        /* Line number in file */
+
+    err = ppdLastError(&linenum);
+
+    printf("Unable to open PPD file \"%s\": %s on line %d\n", argv[1],
+           ppdErrorString(err), linenum);
+    return (1);
+  }
+
+  ppdMarkDefaults(ppd);
+
+  for (;;)
+  {
+    num_options = 0;
+    options     = NULL;
+
+    if (!cupsResolveConflicts(ppd, NULL, NULL, &num_options, &options))
+      puts("Unable to resolve conflicts!");
+    else if (num_options > 0)
+    {
+      fputs("Resolved conflicts with the following options:\n   ", stdout);
+      for (i = 0; i < num_options; i ++)
+       printf(" %s=%s", options[i].name, options[i].value);
+      putchar('\n');
+
+      cupsFreeOptions(num_options, options);
+    }
+
+    printf("\nNew Option(s): ");
+    fflush(stdout);
+    if (!fgets(line, sizeof(line), stdin) || line[0] == '\n')
+      break;
+
+    num_options = cupsParseOptions(line, 0, &options);
+    if (cupsMarkOptions(ppd, num_options, options))
+      puts("Options Conflict!");
+    cupsFreeOptions(num_options, options);
+  }
+
+  return (0);
+}
+
+
+/*
+ * End of "$Id$".
+ */