]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/backend.c
Remove all of the Subversion keywords from various source files.
[thirdparty/cups.git] / cups / backend.c
index 83613ea20e6110f2a53243932df2c3c0604c5ebb..b84ea5ca3a5d233cfe777310de252c4f72307478 100644 (file)
@@ -1,24 +1,16 @@
 /*
- * "$Id: backend.c 7810 2008-07-29 01:11:15Z mike $"
+ * Backend functions for CUPS.
  *
- *   Backend functions for CUPS.
+ * Copyright 2007-2015 by Apple Inc.
+ * Copyright 2006 by Easy Software Products.
  *
- *   Copyright 2007-2010 by Apple Inc.
- *   Copyright 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/".
  *
- *   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:
- *
- *   cupsBackendDeviceURI() - Get the device URI for a backend.
- *   cupsBackendReport()    - Write a device line from a backend.
- *   quote_string()         - Write a quoted string to stdout, escaping \ and ".
+ * This file is subject to the Apple OS-Developed Software exception.
  */
 
 /*
@@ -27,6 +19,7 @@
 
 #include "cups-private.h"
 #include "backend.h"
+#include "ppd.h"
 
 
 /*
@@ -44,14 +37,18 @@ static void quote_string(const char *s);
  * variable or the device URI passed in argv[0], whichever is found
  * first.
  *
- * @since CUPS 1.2/Mac OS X 10.5@
+ * @since CUPS 1.2/OS X 10.5@
  */
 
 const char *                           /* O - Device URI or @code NULL@ */
 cupsBackendDeviceURI(char **argv)      /* I - Command-line arguments */
 {
-  const char   *device_uri;            /* Device URI */
+  const char   *device_uri,            /* Device URI */
+               *auth_info_required;    /* AUTH_INFO_REQUIRED env var */
   _cups_globals_t *cg = _cupsGlobals();        /* Global info */
+  int          options;                /* Resolve options */
+  ppd_file_t   *ppd;                   /* PPD file */
+  ppd_attr_t   *ppdattr;               /* PPD attribute */
 
 
   if ((device_uri = getenv("DEVICE_URI")) == NULL)
@@ -62,8 +59,22 @@ cupsBackendDeviceURI(char **argv)    /* I - Command-line arguments */
     device_uri = argv[0];
   }
 
+  options = _HTTP_RESOLVE_STDERR;
+  if ((auth_info_required = getenv("AUTH_INFO_REQUIRED")) != NULL &&
+      !strcmp(auth_info_required, "negotiate"))
+    options |= _HTTP_RESOLVE_FQDN;
+
+  if ((ppd = ppdOpenFile(getenv("PPD"))) != NULL)
+  {
+    if ((ppdattr = ppdFindAttr(ppd, "cupsIPPFaxOut", NULL)) != NULL &&
+        !_cups_strcasecmp(ppdattr->value, "true"))
+      options |= _HTTP_RESOLVE_FAXOUT;
+
+    ppdClose(ppd);
+  }
+
   return (_httpResolveURI(device_uri, cg->resolved_uri,
-                          sizeof(cg->resolved_uri), 1));
+                          sizeof(cg->resolved_uri), options, NULL, NULL));
 }
 
 
@@ -74,7 +85,7 @@ cupsBackendDeviceURI(char **argv)     /* I - Command-line arguments */
  * It handles quoting of special characters in the device-make-and-model,
  * device-info, device-id, and device-location strings.
  *
- * @since CUPS 1.4/Mac OS X 10.6@
+ * @since CUPS 1.4/OS X 10.6@
  */
 
 void
@@ -118,7 +129,10 @@ quote_string(const char *s)                /* I - String to write */
       if (*s == '\\' || *s == '\"')
        putchar('\\');
 
-      putchar(*s);
+      if (((*s & 255) < ' ' && *s != '\t') || *s == 0x7f)
+        putchar(' ');
+      else
+        putchar(*s);
 
       s ++;
     }
@@ -126,8 +140,3 @@ quote_string(const char *s)         /* I - String to write */
 
   putchar('\"');
 }
-
-
-/*
- * End of "$Id: backend.c 7810 2008-07-29 01:11:15Z mike $".
- */