]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/filter.c
Merge changes from CUPS 1.4svn-r7696.
[thirdparty/cups.git] / scheduler / filter.c
index bb63900726cdc6690b84714369386669c0089921..6df0483f9866afa161f127e42e020e86e35e90cd 100644 (file)
@@ -1,34 +1,25 @@
 /*
- * "$Id: filter.c 5493 2006-05-05 16:33:57Z mike $"
+ * "$Id: filter.c 7694 2008-06-26 00:23:20Z mike $"
  *
  *   File type conversion routines for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 1997-2006 by Easy Software Products, all rights reserved.
+ *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   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/".
  *
  * Contents:
  *
- *   mimeAddFilter()   - Add a filter to the current MIME database.
- *   mimeFilter()      - Find the fastest way to convert from one type to
- *                       another.
- *   compare_filters() - Compare two filters...
- *   find_filters()    - Find the filters to convert from one type to another.
- *   lookup()          - Lookup a filter...
+ *   mimeAddFilter()    - Add a filter to the current MIME database.
+ *   mimeFilter()       - Find the fastest way to convert from one type to
+ *                        another.
+ *   mimeFilterLookup() - Lookup a filter...
+ *   compare_filters()  - Compare two filters...
+ *   find_filters()     - Find the filters to convert from one type to another.
  */
 
 /*
@@ -64,7 +55,6 @@ static int            compare_srcs(mime_filter_t *, mime_filter_t *);
 static cups_array_t    *find_filters(mime_t *mime, mime_type_t *src,
                                      mime_type_t *dst, int *cost,
                                      _mime_typelist_t *visited);
-static mime_filter_t   *lookup(mime_t *, mime_type_t *, mime_type_t *);
 
 
 /*
@@ -93,7 +83,7 @@ mimeAddFilter(mime_t      *mime,      /* I - MIME database */
   * destination...
   */
 
-  if ((temp = lookup(mime, src, dst)) != NULL)
+  if ((temp = mimeFilterLookup(mime, src, dst)) != NULL)
   {
    /*
     * Yup, does the existing filter have a higher cost?  If so, copy the
@@ -193,6 +183,25 @@ mimeFilter(mime_t      *mime,              /* I - MIME database */
 }
 
 
+/*
+ * 'mimeFilterLookup()' - Lookup a filter...
+ */
+
+mime_filter_t *                                /* O - Filter for src->dst */
+mimeFilterLookup(mime_t      *mime,    /* I - MIME database */
+                 mime_type_t *src,     /* I - Source type */
+                 mime_type_t *dst)     /* I - Destination type */
+{
+  mime_filter_t        key;                    /* Key record for filter search */
+
+
+  key.src = src;
+  key.dst = dst;
+
+  return ((mime_filter_t *)cupsArrayFind(mime->filters, &key));
+}
+
+
 /*
  * 'compare_filters()' - Compare two filters...
  */
@@ -260,13 +269,13 @@ find_filters(mime_t           *mime,      /* I - MIME database */
   * See if there is a filter that can convert the files directly...
   */
 
-  if ((current = lookup(mime, src, dst)) != NULL)
+  if ((current = mimeFilterLookup(mime, src, dst)) != NULL)
   {
    /*
     * Got a direct filter!
     */
 
-    DEBUG_puts("Direct filter found!");
+    DEBUG_puts("find_filters: Direct filter found!");
 
     if ((mintemp = cupsArrayNew(NULL, NULL)) == NULL)
       return (NULL);
@@ -278,8 +287,8 @@ find_filters(mime_t           *mime,        /* I - MIME database */
     if (!cost)
       return (mintemp);
 
-    DEBUG_puts("    Found direct filter:");
-    DEBUG_printf(("    %s (cost=%d)\n", current->filter, mincost));
+    DEBUG_puts("find_filters: Found direct filter:");
+    DEBUG_printf(("find_filters: %s (cost=%d)\n", current->filter, mincost));
   }
   else
   {
@@ -346,6 +355,8 @@ find_filters(mime_t           *mime,        /* I - MIME database */
     * any...)
     */
 
+    tempcost += current->cost;
+
     if (tempcost < mincost)
     {
       cupsArrayDelete(mintemp);
@@ -356,7 +367,7 @@ find_filters(mime_t           *mime,        /* I - MIME database */
       */
 
       mintemp = temp;
-      mincost = tempcost + current->cost;
+      mincost = tempcost;
       cupsArrayInsert(mintemp, current);
     }
     else
@@ -370,11 +381,13 @@ find_filters(mime_t           *mime,      /* I - MIME database */
     */
 
 #ifdef DEBUG
-    printf("    Returning %d filters:\n", cupsArrayCount(mintemp));
+    DEBUG_printf(("find_filters: Returning %d filters:\n",
+                  cupsArrayCount(mintemp)));
+
     for (current = (mime_filter_t *)cupsArrayFirst(mintemp);
          current;
         current = (mime_filter_t *)cupsArrayNext(mintemp))
-      printf("    %s\n", current->filter);
+      DEBUG_printf(("find_filters: %s\n", current->filter));
 #endif /* DEBUG */
 
     if (cost)
@@ -383,31 +396,12 @@ find_filters(mime_t           *mime,      /* I - MIME database */
     return (mintemp);
   }
 
-  DEBUG_puts("    Returning zippo...");
+  DEBUG_puts("find_filters: Returning zippo...");
 
   return (NULL);
 }
 
 
 /*
- * 'lookup()' - Lookup a filter...
- */
-
-static mime_filter_t *                 /* O - Filter for src->dst */
-lookup(mime_t      *mime,              /* I - MIME database */
-       mime_type_t *src,               /* I - Source type */
-       mime_type_t *dst)               /* I - Destination type */
-{
-  mime_filter_t        key;                    /* Key record for filter search */
-
-
-  key.src = src;
-  key.dst = dst;
-
-  return ((mime_filter_t *)cupsArrayFind(mime->filters, &key));
-}
-
-
-/*
- * End of "$Id: filter.c 5493 2006-05-05 16:33:57Z mike $".
+ * End of "$Id: filter.c 7694 2008-06-26 00:23:20Z mike $".
  */