/*
- * "$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.
*/
/*
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 *);
/*
* 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
}
+/*
+ * '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...
*/
* 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);
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
{
* any...)
*/
+ tempcost += current->cost;
+
if (tempcost < mincost)
{
cupsArrayDelete(mintemp);
*/
mintemp = temp;
- mincost = tempcost + current->cost;
+ mincost = tempcost;
cupsArrayInsert(mintemp, current);
}
else
*/
#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)
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 $".
*/