]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/adminutil.c
Load cups into easysw/current.
[thirdparty/cups.git] / cups / adminutil.c
index 5ef1a590f7dab5d8dee0290c121ff3183c497d5d..20a97af301333eece8becec2a43104ac5fdec356 100644 (file)
@@ -1,26 +1,17 @@
 /*
- * "$Id: adminutil.c 6361 2007-03-19 16:01:28Z mike $"
+ * "$Id: adminutil.c 6649 2007-07-11 21:46:42Z mike $"
  *
  *   Administration utility API definitions for the Common UNIX Printing
  *   System (CUPS).
  *
+ *   Copyright 2007 by Apple Inc.
  *   Copyright 2001-2007 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
- *   property of Easy Software Products 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 missing or damaged please contact Easy Software Products
- *   at:
- *
- *       Attn: CUPS Licensing Information
- *       Easy Software Products
- *       44141 Airport View Drive, Suite 204
- *       Hollywood, Maryland 20636 USA
- *
- *       Voice: (301) 373-9600
- *       EMail: cups-info@cups.org
- *         WWW: http://www.cups.org
+ *   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.
  *
  * Local functions...
  */
 
+extern int             _cupsAdminGetServerSettings(http_t *http,
+                                                   int *num_settings,
+                                                   cups_option_t **settings);
+extern int             _cupsAdminSetServerSettings(http_t *http,
+                                                   int num_settings,
+                                                   cups_option_t *settings);
 static int             do_samba_command(const char *command,
                                         const char *address,
                                         const char *subcommand,
@@ -102,6 +99,7 @@ cupsAdminCreateWindowsPPD(
                        option[41],     /* Option */
                        choice[41];     /* Choice */
   int                  jcloption,      /* In a JCL option? */
+                       jclorder,       /* Next JCL order dependency */
                        linenum;        /* Current line number */
   time_t               curtime;        /* Current time */
   struct tm            *curdate;       /* Current date */
@@ -199,6 +197,7 @@ cupsAdminCreateWindowsPPD(
   */
 
   jcloption = 0;
+  jclorder  = 0;
   linenum   = 0;
   language  = cupsLangDefault();
 
@@ -237,10 +236,23 @@ cupsAdminCreateWindowsPPD(
       jcloption = 0;
       cupsFilePrintf(dstfp, "%s\n", line);
     }
+    else if (jcloption && !strncmp(line, "*OrderDependency:", 17))
+    {
+      for (ptr = line + 17; *ptr && isspace(*ptr & 255); ptr ++);
+
+      ptr = strchr(ptr, ' ');
+
+      if (ptr)
+      {
+       cupsFilePrintf(dstfp, "*OrderDependency: %d%s\n", jclorder, ptr);
+       jclorder ++;
+      }
+      else
+        cupsFilePrintf(dstfp, "%s\n", line);
+    }
     else if (jcloption &&
              strncmp(line, "*End", 4) &&
-             strncmp(line, "*Default", 8) &&
-             strncmp(line, "*OrderDependency", 16))
+             strncmp(line, "*Default", 8))
     {
       if ((ptr = strchr(line, ':')) == NULL)
       {
@@ -357,24 +369,24 @@ cupsAdminCreateWindowsPPD(
                                   IPP_TAG_ZERO)) != NULL &&
       (suppattr = ippFindAttribute(response, "job-hold-until-supported",
                                    IPP_TAG_ZERO)) != NULL)
-    write_option(dstfp, 10, "cupsJobHoldUntil", "Hold Until", "job-hold-until",
-                 suppattr, defattr, 0, 1);
+    write_option(dstfp, jclorder ++, "cupsJobHoldUntil", "Hold Until",
+                 "job-hold-until", suppattr, defattr, 0, 1);
 
   if ((defattr = ippFindAttribute(response, "job-priority-default",
                                   IPP_TAG_INTEGER)) != NULL &&
       (suppattr = ippFindAttribute(response, "job-priority-supported",
                                    IPP_TAG_RANGE)) != NULL)
-    write_option(dstfp, 11, "cupsJobPriority", "Priority", "job-priority",
-                 suppattr, defattr, 0, 1);
+    write_option(dstfp, jclorder ++, "cupsJobPriority", "Priority",
+                 "job-priority", suppattr, defattr, 0, 1);
 
   if ((defattr = ippFindAttribute(response, "job-sheets-default",
                                   IPP_TAG_ZERO)) != NULL &&
       (suppattr = ippFindAttribute(response, "job-sheets-supported",
                                    IPP_TAG_ZERO)) != NULL)
   {
-    write_option(dstfp, 20, "cupsJobSheetsStart", "Start Banner",
+    write_option(dstfp, jclorder ++, "cupsJobSheetsStart", "Start Banner",
                  "job-sheets", suppattr, defattr, 0, 2);
-    write_option(dstfp, 21, "cupsJobSheetsEnd", "End Banner",
+    write_option(dstfp, jclorder ++, "cupsJobSheetsEnd", "End Banner",
                  "job-sheets", suppattr, defattr, 1, 2);
   }
 
@@ -655,12 +667,15 @@ cupsAdminExportSamba(
                                "are installed!")),
               sizeof(message));
 
-    _cupsSetError(IPP_INTERNAL_ERROR, message);
+    _cupsSetError(IPP_NOT_FOUND, message);
     _cupsLangPrintf(logfile, "%s\n", message);
   }
 
   if (have_drivers == 0)
+  {
+    _cupsSetError(IPP_NOT_FOUND, message);
     return (0);
+  }
 
  /*
   * Finally, associate the drivers we just added with the queue...
@@ -1314,14 +1329,21 @@ _cupsAdminSetServerSettings(
     {
       if (!wrote_browsing)
       {
+       int new_remote_printers = (remote_printers > 0 ||
+                                  (remote_printers == -1 &&
+                                   old_remote_printers > 0));
+       int new_share_printers = (share_printers > 0 ||
+                                 (share_printers == -1 &&
+                                  old_share_printers > 0));
+
         wrote_browsing = 1;
 
-        if (remote_printers > 0 || share_printers > 0)
+        if (new_remote_printers || new_share_printers)
        {
-         if (remote_printers > 0 && share_printers > 0)
+         if (new_remote_printers && new_share_printers)
            cupsFilePuts(temp,
                         "# Enable printer sharing and shared printers.\n");
-         else if (remote_printers > 0)
+         else if (new_remote_printers)
            cupsFilePuts(temp,
                         "# Show shared printers on the local network.\n");
          else
@@ -1331,10 +1353,10 @@ _cupsAdminSetServerSettings(
          cupsFilePuts(temp, "Browsing On\n");
          cupsFilePuts(temp, "BrowseOrder allow,deny\n");
 
-         if (remote_printers > 0)
+         if (new_remote_printers)
            cupsFilePuts(temp, "BrowseAllow all\n");
 
-         if (share_printers > 0)
+         if (new_share_printers)
            cupsFilePuts(temp, "BrowseAddress @LOCAL\n");
         }
        else
@@ -2188,5 +2210,5 @@ write_option(cups_file_t     *dstfp,      /* I - PPD file */
 
 
 /*
- * End of "$Id: adminutil.c 6361 2007-03-19 16:01:28Z mike $".
+ * End of "$Id: adminutil.c 6649 2007-07-11 21:46:42Z mike $".
  */