]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/testppd.c
Migrate Windows conditional code to _WIN32 define.
[thirdparty/cups.git] / cups / testppd.c
index deff81c453f978f5723e773c7608ad0247781b74..3e4f29b03819b1f3a56b9200fa6a827d3e297b5e 100644 (file)
@@ -1,18 +1,10 @@
 /*
- * "$Id$"
- *
  * PPD test program for CUPS.
  *
- * Copyright 2007-2015 by Apple Inc.
+ * Copyright 2007-2017 by Apple Inc.
  * Copyright 1997-2006 by Easy Software Products.
  *
- * 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.
+ * Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
  */
 
 /*
 
 #undef _CUPS_NO_DEPRECATED
 #include "cups-private.h"
+#include "ppd-private.h"
 #include <sys/stat.h>
-#ifdef WIN32
+#ifdef _WIN32
 #  include <io.h>
 #else
 #  include <unistd.h>
 #  include <fcntl.h>
-#endif /* WIN32 */
+#endif /* _WIN32 */
 #include <math.h>
 
 
@@ -877,6 +870,13 @@ main(int  argc,                            /* I - Number of command-line arguments */
                host[256],              /* Hostname */
                resource[256];          /* Resource path */
     int                port;                   /* Port number */
+    static const char * const pattrs[] =/* Requested printer attributes */
+    {
+      "job-template",
+      "printer-defaults",
+      "printer-description",
+      "media-col-database"
+    };
 
     if (httpSeparateURI(HTTP_URI_CODING_ALL, argv[1], scheme, sizeof(scheme), userpass, sizeof(userpass), host, sizeof(host), &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
     {
@@ -893,6 +893,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
 
     request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES);
     ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, argv[1]);
+    ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes", sizeof(pattrs) / sizeof(pattrs[0]), NULL, pattrs);
     response = cupsDoRequest(http, request, resource);
 
     if (_ppdCreateFromIPP(buffer, sizeof(buffer), response))
@@ -901,6 +902,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
       puts("Unable to create PPD.");
 
     ippDelete(response);
+    httpClose(http);
     return (0);
   }
   else
@@ -909,7 +911,19 @@ main(int  argc,                            /* I - Number of command-line arguments */
     struct stat        fileinfo;               /* File information */
 
 
-    if (!strncmp(argv[1], "-d", 2))
+    if (strchr(argv[1], ':'))
+    {
+     /*
+      * Server PPD...
+      */
+
+      if ((filename = cupsGetServerPPD(CUPS_HTTP_DEFAULT, argv[1])) == NULL)
+      {
+        printf("%s: %s\n", argv[1], cupsLastErrorString());
+        return (1);
+      }
+    }
+    else if (!strncmp(argv[1], "-d", 2))
     {
       const char *printer;             /* Printer name */
 
@@ -1154,8 +1168,3 @@ main(int  argc,                           /* I - Number of command-line arguments */
 
   return (status);
 }
-
-
-/*
- * End of "$Id$".
- */