#include "mime-private.h"
-//
-// Debug macros that used to be private API...
-//
-
-#define DEBUG_puts(x)
-#define DEBUG_printf(...)
-
-
//
// Local types...
//
// Local functions...
//
-static int mime_compare_ftypess(mime_ftypes_t *a, mime_ftypes_t *b, void *data);
+static int mime_compare_ftypes(mime_ftypes_t *a, mime_ftypes_t *b, void *data);
static int mime_compare_filters(mime_filter_t *, mime_filter_t *, void *);
static int mime_compare_srcs(mime_filter_t *, mime_filter_t *, void *);
static mime_ftypes_t *mime_find_ftypes(mime_t *mime, mime_type_t *dst);
const char *filter) // I - Filter program to run
{
mime_filter_t *temp; // New filter
- mime_ftypes_t *c; // Filter cache
- DEBUG_printf(("mimeAddFilter(mime=%p, src=%p(%s/%s), dst=%p(%s/%s), cost=%d, "
- "filter=\"%s\")", mime,
- src, src ? src->super : "???", src ? src->type : "???",
- dst, dst ? dst->super : "???", dst ? dst->type : "???",
- cost, filter));
-
- /*
- * Range-check the input...
- */
+ MIME_DEBUG("mimeAddFilter(mime=%p, src=%p(%s/%s), dst=%p(%s/%s), cost=%d, filter=\"%s\")\n", (void *)mime, (void *)src, src ? src->super : "???", src ? src->type : "???", (void *)dst, dst ? dst->super : "???", dst ? dst->type : "???", cost, filter);
+ // Range-check the input...
if (!mime || !src || !dst || !filter)
{
- DEBUG_puts("1mimeAddFilter: Returning NULL.");
+ MIME_DEBUG("mimeAddFilter: Returning NULL.\n");
return (NULL);
}
- // See if we have a cache for this destination type...
- if ((c = mime_find_ftypes(mime, dst)) == NULL)
- {
- // No, add a cache for this type...
- if ((c = (mime_ftypes_t *)calloc(1, sizeof(mime_ftypes_t))) != NULL)
- {
- c->dst = dst;
-
- if (!mime->ftypes)
- mime->ftypes = cupsArrayNew3((cups_array_cb_t)mime_compare_ftypess, /*cb_data*/NULL, /*hash_cb*/NULL, /*hash_size*/0, /*copy_cb*/NULL, (cups_afree_cb_t)mime_free_ftypes);
- cupsArrayAdd(mime->ftypes, c);
- }
- }
-
- if (c && !cupsArrayFind(c->srcs, src))
- {
- // Add source type to list of source types that can be converted to the
- // destination type...
- if (!c->srcs)
- c->srcs = cupsArrayNew3((cups_array_cb_t)_mimeCompareTypes, /*cb_data*/NULL, /*hash_cb*/NULL, /*hash_size*/0, /*copy_cb*/NULL, /*free_cb*/NULL);
-
- cupsArrayAdd(c->srcs, src);
- }
-
- /*
- * See if we already have an existing filter for the given source and
- * destination...
- */
-
+ // See if we already have an existing filter for the given source and
+ // destination...
if ((temp = mimeFilterLookup(mime, src, dst)) != NULL)
{
- /*
- * Yup, does the existing filter have a higher cost? If so, copy the
- * filter and cost to the existing filter entry and return it...
- */
-
+ // Yup, does the existing filter have a higher cost? If so, copy the
+ // filter and cost to the existing filter entry and return it...
if (temp->cost > cost)
{
- DEBUG_printf(("1mimeAddFilter: Replacing filter \"%s\", cost %d.",
- temp->filter, temp->cost));
+ MIME_DEBUG("mimeAddFilter: Replacing filter \"%s\", cost %d.\n", temp->filter, temp->cost);
temp->cost = cost;
cupsCopyString(temp->filter, filter, sizeof(temp->filter));
}
}
else
{
- /*
- * Nope, add a new one...
- */
-
+ // Nope, add a new one...
if (!mime->filters)
mime->filters = cupsArrayNew3((cups_array_cb_t)mime_compare_filters, /*cb_data*/NULL, /*hash_cb*/NULL, /*hash_size*/0, /*copy_cb*/NULL, (cups_afree_cb_t)mime_free_filter);
if ((temp = calloc(1, sizeof(mime_filter_t))) == NULL)
return (NULL);
- /*
- * Copy the information over and sort if necessary...
- */
-
+ // Copy the information over and sort if necessary...
temp->src = src;
temp->dst = dst;
temp->cost = cost;
cupsCopyString(temp->filter, filter, sizeof(temp->filter));
- DEBUG_puts("1mimeAddFilter: Adding new filter.");
+ MIME_DEBUG("mimeAddFilter: Adding new filter.\n");
cupsArrayAdd(mime->filters, temp);
cupsArrayAdd(mime->srcs, temp);
}
- /*
- * Return the new/updated filter...
- */
-
- DEBUG_printf("1mimeAddFilter: Returning %p.", temp);
+ // Return the new/updated filter...
+ MIME_DEBUG("mimeAddFilter: Returning %p.\n", (void *)temp);
return (temp);
}
mime_type_t *dst, // I - Destination file type
int *cost) // O - Cost of filters
{
- DEBUG_printf(("mimeFilter(mime=%p, src=%p(%s/%s), dst=%p(%s/%s), "
- "cost=%p(%d))", mime,
- src, src ? src->super : "???", src ? src->type : "???",
- dst, dst ? dst->super : "???", dst ? dst->type : "???",
- cost, cost ? *cost : 0));
+ MIME_DEBUG("mimeFilter(mime=%p, src=%p(%s/%s), dst=%p(%s/%s), cost=%p(%d))\n", (void *)mime, (void *)src, src ? src->super : "???", src ? src->type : "???", (void *)dst, dst ? dst->super : "???", dst ? dst->type : "???", (void *)cost, cost ? *cost : 0);
return (mimeFilter2(mime, src, 0, dst, cost));
}
cups_array_t *filters; // Array of filters to run
- /*
- * Range-check the input...
- */
-
- DEBUG_printf(("mimeFilter2(mime=%p, src=%p(%s/%s), srcsize=" CUPS_LLFMT
- ", dst=%p(%s/%s), cost=%p(%d))", mime,
- src, src ? src->super : "???", src ? src->type : "???",
- CUPS_LLCAST srcsize,
- dst, dst ? dst->super : "???", dst ? dst->type : "???",
- cost, cost ? *cost : 0));
+ // Range-check the input...
+ MIME_DEBUG("mimeFilter2(mime=%p, src=%p(%s/%s), srcsize=" CUPS_LLFMT ", dst=%p(%s/%s), cost=%p(%d))\n", (void *)mime, (void *)src, src ? src->super : "???", src ? src->type : "???", CUPS_LLCAST srcsize, (void *)dst, dst ? dst->super : "???", dst ? dst->type : "???", (void *)cost, cost ? *cost : 0);
if (cost)
*cost = 0;
if (!mime || !src || !dst)
return (NULL);
- /*
- * (Re)build the source lookup array as needed...
- */
-
+ // (Re)build the source lookup array as needed...
if (!mime->srcs)
{
mime_filter_t *current; // Current filter
mime->srcs = cupsArrayNew((cups_array_cb_t)mime_compare_srcs, NULL);
- for (current = mimeFirstFilter(mime);
- current;
- current = mimeNextFilter(mime))
+ for (current = mimeFirstFilter(mime); current; current = mimeNextFilter(mime))
cupsArrayAdd(mime->srcs, current);
}
- /*
- * Find the filters...
- */
-
+ // Find the filters...
filters = mime_find_filters(mime, src, srcsize, dst, cost, NULL);
- DEBUG_printf(("1mimeFilter2: Returning %d filter(s), cost %d:",
- cupsArrayCount(filters), cost ? *cost : -1));
+ MIME_DEBUG("mimeFilter2: Returning %d filter(s), cost %d:\n", cupsArrayCount(filters), cost ? *cost : -1);
#ifdef DEBUG
{
mime_filter_t *filter; // Current filter
- for (filter = (mime_filter_t *)cupsArrayFirst(filters);
- filter;
- filter = (mime_filter_t *)cupsArrayNext(filters))
- DEBUG_printf(("1mimeFilter2: %s/%s %s/%s %d %s", filter->src->super,
- filter->src->type, filter->dst->super, filter->dst->type,
- filter->cost, filter->filter));
+ for (filter = (mime_filter_t *)cupsArrayFirst(filters); filter; filter = (mime_filter_t *)cupsArrayNext(filters))
+ MIME_DEBUG("mimeFilter2: %s/%s %s/%s %d %s\n", filter->src->super, filter->src->type, filter->dst->super, filter->dst->type, filter->cost, filter->filter);
}
#endif // DEBUG
*filter; // Matching filter
- DEBUG_printf("2mimeFilterLookup(mime=%p, src=%p(%s/%s), dst=%p(%s/%s))", mime, src, src ? src->super : "???", src ? src->type : "???", dst, dst ? dst->super : "???", dst ? dst->type : "???");
+ MIME_DEBUG("mimeFilterLookup(mime=%p, src=%p(%s/%s), dst=%p(%s/%s))\n", (void *)mime, (void *)src, src ? src->super : "???", src ? src->type : "???", (void *)dst, dst ? dst->super : "???", dst ? dst->type : "???");
key.src = src;
key.dst = dst;
filter = (mime_filter_t *)cupsArrayFind(mime->filters, &key);
- DEBUG_printf("3mimeFilterLookup: Returning %p(%s).", filter, filter ? filter->filter : "???");
+ MIME_DEBUG("mimeFilterLookup: Returning %p(%s).\n", (void *)filter, filter ? filter->filter : "???");
return (filter);
}
mime_type_t *dst, // I - Destination media type
cups_array_t *srcs) // I - Array of source types or `NULL` for none
{
+ MIME_DEBUG("mimeGetFilterTypes(mime=%p, dst=%p(%s/%s), srcs=%p)\n", (void *)mime, (void *)dst, dst ? dst->super : "???", dst ? dst->type : "???", (void *)srcs);
+
// Range check input...
if (!mime || !dst)
return (srcs);
+ // (Re)build the filter destination cache as needed...
+ if (!mime->ftypes)
+ {
+ mime_filter_t *current; // Current filter
+ mime_ftypes_t *cftype; // Current filter type
+
+ MIME_DEBUG("mimeGetFilterTypes: Building the filter destination cache.\n");
+
+ mime->ftypes = cupsArrayNew3((cups_array_cb_t)mime_compare_ftypes, /*cb_data*/NULL, /*hash_cb*/NULL, /*hash_size*/0, /*copy_cb*/NULL, (cups_afree_cb_t)mime_free_ftypes);
+
+ for (current = mimeFirstFilter(mime); current; current = mimeNextFilter(mime))
+ {
+ // See if we have a cache for this destination type...
+ MIME_DEBUG("mimeGetFilterTypes: Filter '%s' (%s/%s to %s/%s, cost %d)\n", current->filter, current->src->super, current->src->type, current->dst->super, current->dst->type, current->cost);
+
+ if ((cftype = mime_find_ftypes(mime, current->dst)) == NULL)
+ {
+ // No, add a cache for this type...
+ if ((cftype = (mime_ftypes_t *)calloc(1, sizeof(mime_ftypes_t))) != NULL)
+ {
+ MIME_DEBUG("mimeGetFilterTypes: Adding %s/%s to destination cache.\n", current->dst->super, current->dst->type);
+ cftype->dst = current->dst;
+ cupsArrayAdd(mime->ftypes, cftype);
+ }
+ }
+
+ if (cftype && !cupsArrayFind(cftype->srcs, current->src))
+ {
+ // Add source type to list of source types that can be converted to the
+ // destination type...
+ if (!cftype->srcs)
+ cftype->srcs = cupsArrayNew3((cups_array_cb_t)_mimeCompareTypes, /*cb_data*/NULL, /*hash_cb*/NULL, /*hash_size*/0, /*copy_cb*/NULL, /*free_cb*/NULL);
+
+ MIME_DEBUG("mimeGetFilterTypes: Adding %s/%s to %s/%s association.\n", current->src->super, current->src->type, current->dst->super, current->dst->type);
+ cupsArrayAdd(cftype->srcs, current->src);
+ }
+ }
+ }
+
// Get source types...
return (mime_get_filter_types(mime, dst, srcs, 0));
}
//
-// 'mime_compare_ftypess()' - Compare two filter caches.
+// 'mime_compare_ftypes()' - Compare two filter caches.
//
static int // O - Result of comparison
-mime_compare_ftypess(
+mime_compare_ftypes(
mime_ftypes_t *a, // I - First cache
mime_ftypes_t *b, // I - Second cache
void *data) // I - Callback data (not used)
*listptr; // Pointer in list
- DEBUG_printf("2mime_find_filters(mime=%p, src=%p(%s/%s), srcsize=" CUPS_LLFMT ", dst=%p(%s/%s), cost=%p, list=%p)", mime, src, src->super, src->type, CUPS_LLCAST srcsize, dst, dst->super, dst->type, cost, list);
+ MIME_DEBUG("mime_find_filters(mime=%p, src=%p(%s/%s), srcsize=" CUPS_LLFMT ", dst=%p(%s/%s), cost=%p, list=%p)\n", (void *)mime, (void *)src, src->super, src->type, CUPS_LLCAST srcsize, (void *)dst, dst->super, dst->type, (void *)cost, (void *)list);
/*
* See if there is a filter that can convert the files directly...
*/
- if ((current = mimeFilterLookup(mime, src, dst)) != NULL &&
- (current->maxsize == 0 || srcsize <= current->maxsize))
+ if ((current = mimeFilterLookup(mime, src, dst)) != NULL && (current->maxsize == 0 || srcsize <= current->maxsize))
{
- /*
- * Got a direct filter!
- */
-
- DEBUG_puts("3mime_find_filters: Direct filter found.");
+ // Got a direct filter!
+ MIME_DEBUG("mime_find_filters: Direct filter found.\n");
if ((mintemp = cupsArrayNew(NULL, NULL)) == NULL)
{
- DEBUG_puts("3mime_find_filters: Returning NULL (out of memory).");
+ MIME_DEBUG("mime_find_filters: Returning NULL (out of memory).\n");
return (NULL);
}
if (!cost)
{
- DEBUG_printf(("3mime_find_filters: Returning 1 filter, cost %d:",
- mincost));
- DEBUG_printf(("3mime_find_filters: %s/%s %s/%s %d %s",
- current->src->super, current->src->type,
- current->dst->super, current->dst->type,
- current->cost, current->filter));
+ MIME_DEBUG("mime_find_filters: Returning 1 filter, cost %d:\n", mincost);
+ MIME_DEBUG("mime_find_filters: %s/%s %s/%s %d %s\n", current->src->super, current->src->type, current->dst->super, current->dst->type, current->cost, current->filter);
return (mintemp);
}
}
else
{
- /*
- * No direct filter...
- */
-
+ // No direct filter...
mintemp = NULL;
mincost = 9999999;
}
- /*
- * Initialize this node in the type list...
- */
-
+ // Initialize this node in the type list...
listnode.next = list;
- /*
- * OK, now look for filters from the source type to any other type...
- */
-
+ // OK, now look for filters from the source type to any other type...
srckey.src = src;
- for (current = (mime_filter_t *)cupsArrayFind(mime->srcs, &srckey);
- current && current->src == src;
- current = (mime_filter_t *)cupsArrayNext(mime->srcs))
+ for (current = (mime_filter_t *)cupsArrayFind(mime->srcs, &srckey); current && current->src == src; current = (mime_filter_t *)cupsArrayNext(mime->srcs))
{
- /*
- * See if we have already tried the destination type as a source
- * type (this avoids extra filter looping...)
- */
-
+ // See if we have already tried the destination type as a source
+ // type (this avoids extra filter looping...)
mime_type_t *current_dst; // Current destination type
if (current->maxsize > 0 && srcsize > current->maxsize)
continue;
- for (listptr = list, current_dst = current->dst;
- listptr;
- listptr = listptr->next)
+ for (listptr = list, current_dst = current->dst; listptr; listptr = listptr->next)
+ {
if (current_dst == listptr->src)
break;
+ }
if (listptr)
continue;
- /*
- * See if we have any filters that can convert from the destination type
- * of this filter to the final type...
- */
-
+ // See if we have any filters that can convert from the destination type
+ // of this filter to the final type...
listnode.src = current->src;
cupsArraySave(mime->srcs);
- temp = mime_find_filters(mime, current->dst, srcsize, dst, &tempcost,
- &listnode);
+ temp = mime_find_filters(mime, current->dst, srcsize, dst, &tempcost, &listnode);
cupsArrayRestore(mime->srcs);
if (!temp)
if (!cost)
{
- DEBUG_printf(("3mime_find_filters: Returning %d filter(s), cost %d:",
- cupsArrayCount(temp), tempcost));
+ MIME_DEBUG("mime_find_filters: Returning %d filter(s), cost %d:\n", cupsArrayCount(temp), tempcost);
#ifdef DEBUG
- for (current = (mime_filter_t *)cupsArrayFirst(temp);
- current;
- current = (mime_filter_t *)cupsArrayNext(temp))
- DEBUG_printf(("3mime_find_filters: %s/%s %s/%s %d %s",
- current->src->super, current->src->type,
- current->dst->super, current->dst->type,
- current->cost, current->filter));
+ for (current = (mime_filter_t *)cupsArrayFirst(temp); current; current = (mime_filter_t *)cupsArrayNext(temp))
+ MIME_DEBUG("mime_find_filters: %s/%s %s/%s %d %s\n", current->src->super, current->src->type, current->dst->super, current->dst->type, current->cost, current->filter);
#endif // DEBUG
return (temp);
}
- /*
- * Found a match; see if this one is less costly than the last (if
- * any...)
- */
-
+ // Found a match; see if this one is less costly than the last (if any...)
tempcost += current->cost;
if (tempcost < mincost)
{
cupsArrayDelete(mintemp);
- /*
- * Hey, we got a match! Add the current filter to the beginning of the
- * filter list...
- */
-
+ // Hey, we got a match! Add the current filter to the beginning of the
+ // filter list...
mintemp = temp;
mincost = tempcost;
cupsArrayInsert(mintemp, current);
}
else
+ {
cupsArrayDelete(temp);
+ }
}
if (mintemp)
{
- /*
- * Hey, we got a match!
- */
-
- DEBUG_printf(("3mime_find_filters: Returning %d filter(s), cost %d:",
- cupsArrayCount(mintemp), mincost));
+ // Hey, we got a match!
+ MIME_DEBUG("mime_find_filters: Returning %d filter(s), cost %d:\n", cupsArrayCount(mintemp), mincost);
#ifdef DEBUG
- for (current = (mime_filter_t *)cupsArrayFirst(mintemp);
- current;
- current = (mime_filter_t *)cupsArrayNext(mintemp))
- DEBUG_printf(("3mime_find_filters: %s/%s %s/%s %d %s",
- current->src->super, current->src->type,
- current->dst->super, current->dst->type,
- current->cost, current->filter));
+ for (current = (mime_filter_t *)cupsArrayFirst(mintemp); current; current = (mime_filter_t *)cupsArrayNext(mintemp))
+ MIME_DEBUG("mime_find_filters: %s/%s %s/%s %d %s\n", current->src->super, current->src->type, current->dst->super, current->dst->type, current->cost, current->filter);
#endif // DEBUG
if (cost)
return (mintemp);
}
- DEBUG_puts("3mime_find_filters: Returning NULL (no matches).");
+ MIME_DEBUG("mime_find_filters: Returning NULL (no matches).\n");
return (NULL);
}
srcs = cupsArrayNew3((cups_array_cb_t)_mimeCompareTypes, /*cb_data*/NULL, /*hash_cb*/NULL, /*hash_size*/0, /*copy_cb*/NULL, /*free_cb*/NULL);
// Add the source to the array...
+ MIME_DEBUG("mime_get_filter_types: Adding %s/%s to %s/%s filter.\n", src->super, src->type, dst->super, dst->type);
cupsArrayAdd(srcs, src);
if (level < 4)
}
}
+#ifdef DEBUG
+ if (level == 0)
+ MIME_DEBUG("mime_get_filter_types: Returning %p(%d entries)\n", (void *)srcs, (int)cupsArrayGetCount(srcs));
+#endif // DEBUG
+
return (srcs);
}
# endif // __cplusplus
+//
+// Debug macros (simpler than for libcups)...
+//
+
+# ifdef DEBUG
+# define MIME_DEBUG(...) fprintf(stderr, __VA_ARGS__)
+# else
+# define MIME_DEBUG(...)
+# endif // DEBUG
+
+
//
// Prototypes...
//
#include "mime-private.h"
-//
-// Debug macros that used to be private API...
-//
-
-#define DEBUG_puts(x)
-#define DEBUG_printf(...)
-
-
//
// Local types...
//
void
mimeDelete(mime_t *mime) // I - MIME database
{
- DEBUG_printf("mimeDelete(mime=%p)", mime);
+ MIME_DEBUG("mimeDelete(mime=%p)\n", (void *)mime);
if (!mime)
return;
mimeDeleteFilter(mime_t *mime, // I - MIME database
mime_filter_t *filter) // I - Filter
{
- DEBUG_printf("mimeDeleteFilter(mime=%p, filter=%p(%s/%s->%s/%s, cost=%d, maxsize=" CUPS_LLFMT "))", mime, filter, filter ? filter->src->super : "???", filter ? filter->src->type : "???", filter ? filter->dst->super : "???", filter ? filter->dst->super : "???", filter ? filter->cost : -1, filter ? CUPS_LLCAST filter->maxsize : CUPS_LLCAST -1);
+ MIME_DEBUG("mimeDeleteFilter(mime=%p, filter=%p(%s/%s->%s/%s, cost=%d, maxsize=" CUPS_LLFMT "))\n", (void *)mime, (void *)filter, filter ? filter->src->super : "???", filter ? filter->src->type : "???", filter ? filter->dst->super : "???", filter ? filter->dst->super : "???", filter ? filter->cost : -1, filter ? CUPS_LLCAST filter->maxsize : CUPS_LLCAST -1);
if (!mime || !filter)
return;
#ifdef DEBUG
if (!cupsArrayFind(mime->filters, filter))
- DEBUG_puts("1mimeDeleteFilter: Filter not in MIME database.");
+ MIME_DEBUG("mimeDeleteFilter: Filter not in MIME database.\n");
#endif // DEBUG
cupsArrayRemove(mime->filters, filter);
- // Deleting a filter invalidates the source lookup cache used by mimeFilter()...
+ // Deleting a filter invalidates the source and destination lookup caches...
if (mime->srcs)
{
- DEBUG_puts("1mimeDeleteFilter: Deleting source lookup cache.");
+ MIME_DEBUG("mimeDeleteFilter: Deleting source lookup cache.\n");
cupsArrayDelete(mime->srcs);
mime->srcs = NULL;
}
- // TODO: Also invalidate the filter types array?
+ if (mime->ftypes)
+ {
+ MIME_DEBUG("mimeDeleteFilter: Deleting destination lookup cache.\n");
+ cupsArrayDelete(mime->ftypes);
+ mime->ftypes = NULL;
+ }
}
mimeDeleteType(mime_t *mime, // I - MIME database
mime_type_t *mt) // I - Type
{
- DEBUG_printf("mimeDeleteType(mime=%p, mt=%p(%s/%s))", mime, mt, mt ? mt->super : "???", mt ? mt->type : "???");
+ MIME_DEBUG("mimeDeleteType(mime=%p, mt=%p(%s/%s))\n", (void *)mime, (void *)mt, mt ? mt->super : "???", mt ? mt->type : "???");
if (!mime || !mt)
return;
#ifdef DEBUG
if (!cupsArrayFind(mime->types, mt))
- DEBUG_puts("1mimeDeleteFilter: Type not in MIME database.");
+ MIME_DEBUG("mimeDeleteFilter: Type not in MIME database.\n");
#endif // DEBUG
cupsArrayRemove(mime->types, mt);
mime_filter_t * // O - Filter or NULL
mimeFirstFilter(mime_t *mime) // I - MIME database
{
- DEBUG_printf("6mimeFirstFilter(mime=%p)", mime);
+ MIME_DEBUG("mimeFirstFilter(mime=%p)\n", (void *)mime);
if (!mime)
{
- DEBUG_puts("7mimeFirstFilter: Returning NULL.");
+ MIME_DEBUG("mimeFirstFilter: Returning NULL.\n");
return (NULL);
}
else
mime_filter_t *first = (mime_filter_t *)cupsArrayGetFirst(mime->filters);
// First filter
- DEBUG_printf("7mimeFirstFilter: Returning %p.", first);
+ MIME_DEBUG("mimeFirstFilter: Returning %p.\n", (void *)first);
return (first);
}
}
mime_type_t * // O - Type or NULL
mimeFirstType(mime_t *mime) // I - MIME database
{
- DEBUG_printf("6mimeFirstType(mime=%p)", mime);
+ MIME_DEBUG("mimeFirstType(mime=%p)\n", (void *)mime);
if (!mime)
{
- DEBUG_puts("7mimeFirstType: Returning NULL.");
+ MIME_DEBUG("mimeFirstType: Returning NULL.\n");
return (NULL);
}
else
mime_type_t *first = (mime_type_t *)cupsArrayGetFirst(mime->types);
// First type
- DEBUG_printf("7mimeFirstType: Returning %p.", first);
+ MIME_DEBUG("mimeFirstType: Returning %p.\n", (void *)first);
return (first);
}
}
{
mime_t *mime; // New MIME database
- DEBUG_printf("mimeLoad(pathname=\"%s\", filterpath=\"%s\")", pathname, filterpath);
+ MIME_DEBUG("mimeLoad(pathname=\"%s\", filterpath=\"%s\")\n", pathname, filterpath);
mime = mimeLoadFilters(mimeLoadTypes(NULL, pathname), pathname, filterpath);
- DEBUG_printf("1mimeLoad: Returning %p.", mime);
+ MIME_DEBUG("mimeLoad: Returning %p.\n", (void *)mime);
return (mime);
}
cups_array_t *filtercache; // Filter cache
- DEBUG_printf("mimeLoadFilters(mime=%p, pathname=\"%s\", filterpath=\"%s\")", mime, pathname, filterpath);
+ MIME_DEBUG("mimeLoadFilters(mime=%p, pathname=\"%s\", filterpath=\"%s\")\n", (void *)mime, pathname, filterpath);
// Range check input...
if (!mime || !pathname || !filterpath)
{
- DEBUG_puts("1mimeLoadFilters: Bad arguments.");
+ MIME_DEBUG("mimeLoadFilters: Bad arguments.\n");
return (mime);
}
// Then open the directory specified by pathname...
if ((dir = cupsDirOpen(pathname)) == NULL)
{
- DEBUG_printf("1mimeLoadFilters: Unable to open \"%s\": %s", pathname, strerror(errno));
+ MIME_DEBUG("mimeLoadFilters: Unable to open \"%s\": %s\n", pathname, strerror(errno));
_mimeError(mime, "Unable to open \"%s\": %s", pathname, strerror(errno));
return (mime);
}
{
// Load a mime.convs file...
snprintf(filename, sizeof(filename), "%s/%s", pathname, dent->filename);
- DEBUG_printf("1mimeLoadFilters: Loading \"%s\".", filename);
+ MIME_DEBUG("mimeLoadFilters: Loading \"%s\".\n", filename);
mime_load_convs(mime, filename, filterpath, filtercache);
}
}
char filename[1024]; // Full filename of .types file
- DEBUG_printf("mimeLoadTypes(mime=%p, pathname=\"%s\")", mime, pathname);
+ MIME_DEBUG("mimeLoadTypes(mime=%p, pathname=\"%s\")\n", (void *)mime, pathname);
// First open the directory specified by pathname...
if ((dir = cupsDirOpen(pathname)) == NULL)
{
- DEBUG_printf("1mimeLoadTypes: Unable to open \"%s\": %s", pathname, strerror(errno));
- DEBUG_printf("1mimeLoadTypes: Returning %p.", mime);
+ MIME_DEBUG("mimeLoadTypes: Unable to open \"%s\": %s\n", pathname, strerror(errno));
+ MIME_DEBUG("mimeLoadTypes: Returning %p.\n", (void *)mime);
_mimeError(mime, "Unable to open \"%s\": %s", pathname, strerror(errno));
return (mime);
}
if (!mime)
{
cupsDirClose(dir);
- DEBUG_puts("1mimeLoadTypes: Returning NULL.");
+ MIME_DEBUG("mimeLoadTypes: Returning NULL.\n");
return (NULL);
}
{
// Load a mime.types file...
snprintf(filename, sizeof(filename), "%s/%s", pathname, dent->filename);
- DEBUG_printf("1mimeLoadTypes: Loading \"%s\".", filename);
+ MIME_DEBUG("mimeLoadTypes: Loading \"%s\".\n", filename);
mime_load_types(mime, filename);
}
}
cupsDirClose(dir);
- DEBUG_printf("1mimeLoadTypes: Returning %p.", mime);
+ MIME_DEBUG("mimeLoadTypes: Returning %p.\n", (void *)mime);
return (mime);
}
mime_filter_t * // O - Filter or NULL
mimeNextFilter(mime_t *mime) // I - MIME database
{
- DEBUG_printf("6mimeNextFilter(mime=%p)", mime);
+ MIME_DEBUG("mimeNextFilter(mime=%p)\n", (void *)mime);
if (!mime)
{
- DEBUG_puts("7mimeNextFilter: Returning NULL.");
+ MIME_DEBUG("mimeNextFilter: Returning NULL.\n");
return (NULL);
}
else
mime_filter_t *next = (mime_filter_t *)cupsArrayGetNext(mime->filters);
// Next filter
- DEBUG_printf("7mimeNextFilter: Returning %p.", next);
+ MIME_DEBUG("mimeNextFilter: Returning %p.\n", (void *)next);
return (next);
}
}
mime_type_t * // O - Type or NULL
mimeNextType(mime_t *mime) // I - MIME database
{
- DEBUG_printf("6mimeNextType(mime=%p)", mime);
+ MIME_DEBUG("mimeNextType(mime=%p)\n", (void *)mime);
if (!mime)
{
- DEBUG_puts("7mimeNextType: Returning NULL.");
+ MIME_DEBUG("mimeNextType: Returning NULL.\n");
return (NULL);
}
else
mime_type_t *next = (mime_type_t *)cupsArrayGetNext(mime->types);
// Next type
- DEBUG_printf("7mimeNextType: Returning %p.", next);
+ MIME_DEBUG("mimeNextType: Returning %p.\n", (void *)next);
return (next);
}
}
int
mimeNumFilters(mime_t *mime) // I - MIME database
{
- DEBUG_printf("mimeNumFilters(mime=%p)", mime);
+ MIME_DEBUG("mimeNumFilters(mime=%p\n)", (void *)mime);
if (!mime)
{
- DEBUG_puts("1mimeNumFilters: Returning 0.");
+ MIME_DEBUG("mimeNumFilters: Returning 0.\n");
return (0);
}
else
{
- DEBUG_printf("1mimeNumFilters: Returning %d.", (int)cupsArrayGetCount(mime->filters));
+ MIME_DEBUG("mimeNumFilters: Returning %d.\n", (int)cupsArrayGetCount(mime->filters));
return ((int)cupsArrayGetCount(mime->filters));
}
}
int
mimeNumTypes(mime_t *mime) // I - MIME database
{
- DEBUG_printf("mimeNumTypes(mime=%p)", mime);
+ MIME_DEBUG("mimeNumTypes(mime=%p\n)", (void *)mime);
if (!mime)
{
- DEBUG_puts("1mimeNumTypes: Returning 0.");
+ MIME_DEBUG("mimeNumTypes: Returning 0.\n");
return (0);
}
else
{
- DEBUG_printf("1mimeNumTypes: Returning %d.", (int)cupsArrayGetCount(mime->types));
+ MIME_DEBUG("mimeNumTypes: Returning %d.\n", (int)cupsArrayGetCount(mime->types));
return ((int)cupsArrayGetCount(mime->types));
}
}
char path[1024]; // Full path to filter
- DEBUG_printf("2mime_add_fcache(filtercache=%p, name=\"%s\", filterpath=\"%s\")", filtercache, name, filterpath);
+ MIME_DEBUG("mime_add_fcache(filtercache=%p, name=\"%s\", filterpath=\"%s\")", filtercache, name, filterpath);
key.name = (char *)name;
if ((temp = (_mime_fcache_t *)cupsArrayFind(filtercache, &key)) != NULL)
{
- DEBUG_printf("3mime_add_fcache: Returning \"%s\".", temp->path);
+ MIME_DEBUG("mime_add_fcache: Returning \"%s\".\n", temp->path);
return (temp->path);
}
if ((temp = calloc(1, sizeof(_mime_fcache_t))) == NULL)
{
- DEBUG_puts("3mime_add_fcache: Returning NULL.");
+ MIME_DEBUG("mime_add_fcache: Returning NULL.\n");
return (NULL);
}
cupsArrayAdd(filtercache, temp);
- DEBUG_printf("3mime_add_fcache: Returning \"%s\".", temp->path);
+ MIME_DEBUG("mime_add_fcache: Returning \"%s\".\n", temp->path);
return (temp->path);
}
_mime_fcache_t *current; // Current cache entry
- DEBUG_printf("2mime_delete_fcache(filtercache=%p)", filtercache);
+ MIME_DEBUG("mime_delete_fcache(filtercache=%p)\n", (void *)filtercache);
for (current = (_mime_fcache_t *)cupsArrayGetFirst(filtercache); current; current = (_mime_fcache_t *)cupsArrayGetNext(filtercache))
{
int cost; // Cost of filter
- DEBUG_printf("2mime_load_convs(mime=%p, filename=\"%s\", filterpath=\"%s\", filtercache=%p)", mime, filename, filterpath, filtercache);
+ MIME_DEBUG("mime_load_convs(mime=%p, filename=\"%s\", filterpath=\"%s\", filtercache=%p)\n", (void *)mime, filename, filterpath, (void *)filtercache);
// First try to open the file...
if ((fp = cupsFileOpen(filename, "r")) == NULL)
{
- DEBUG_printf("3mime_load_convs: Unable to open \"%s\": %s", filename, strerror(errno));
+ MIME_DEBUG("mime_load_convs: Unable to open \"%s\": %s\n", filename, strerror(errno));
_mimeError(mime, "Unable to open \"%s\": %s", filename, strerror(errno));
return;
}
if ((dsttype = mimeType(mime, super, type)) == NULL)
{
- DEBUG_printf("3mime_load_convs: Destination type %s/%s not found.", super, type);
+ MIME_DEBUG("mime_load_convs: Destination type %s/%s not found.\n", super, type);
continue;
}
// Verify that the filter exists and is executable...
if (!mime_add_fcache(filtercache, filter, filterpath))
{
- DEBUG_printf("mime_load_convs: Filter %s not found in %s.", filter, filterpath);
+ MIME_DEBUG("mime_load_convs: Filter %s not found in %s.\n", filter, filterpath);
_mimeError(mime, "Filter \"%s\" not found.", filter);
continue;
}
mime_type_t *typeptr; // New MIME type
- DEBUG_printf("2mime_load_types(mime=%p, filename=\"%s\")", mime, filename);
+ MIME_DEBUG("mime_load_types(mime=%p, filename=\"%s\")\n", (void *)mime, filename);
// First try to open the file...
if ((fp = cupsFileOpen(filename, "r")) == NULL)
{
- DEBUG_printf("3mime_load_types: Unable to open \"%s\": %s", filename, strerror(errno));
+ MIME_DEBUG("mime_load_types: Unable to open \"%s\": %s\n", filename, strerror(errno));
_mimeError(mime, "Unable to open \"%s\": %s", filename, strerror(errno));
return;
}
* Delete the current filter...
*/
+ cupsdLogPrinter(p, CUPSD_LOG_DEBUG2, "delete_printer_filters: Removing filter '%s' (%s/%s to %s/%s, cost %d)", filter->filter, filter->src->super, filter->src->type, filter->dst->super, filter->dst->type, filter->cost);
mimeDeleteFilter(MimeDatabase, filter);
}
}
for (type = (mime_type_t *)cupsArrayFirst(p->dest_types); type; type = (mime_type_t *)cupsArrayNext(p->dest_types))
+ {
+ cupsdLogPrinter(p, CUPSD_LOG_DEBUG2, "delete_printer_filters: Removing type %s/%s", type->super, type->type);
mimeDeleteType(MimeDatabase, type);
+ }
cupsArrayDelete(p->dest_types);
p->dest_types = NULL;
#include "mime-private.h"
-//
-// Debug macros that used to be private API...
-//
-
-#define DEBUG_puts(x)
-#define DEBUG_printf(...)
-
-
//
// Local types...
//
size_t typelen; // Length of type name
- DEBUG_printf(("mimeAddType(mime=%p, super=\"%s\", type=\"%s\")", mime, super,
- type));
+ MIME_DEBUG("mimeAddType(mime=%p, super=\"%s\", type=\"%s\")\n", (void *)mime, super, type);
// Range check input...
if (!mime || !super || !*super || !type || !*type)
{
- DEBUG_puts("1mimeAddType: Returning NULL (bad arguments).");
+ MIME_DEBUG("mimeAddType: Returning NULL (bad arguments).");
return (NULL);
}
// See if the type already exists; if so, return the existing type...
if ((temp = mimeType(mime, super, type)) != NULL)
{
- DEBUG_printf("1mimeAddType: Returning %p (existing).", temp);
+ MIME_DEBUG("mimeAddType: Returning %p (existing).\n", (void *)temp);
return (temp);
}
if (!mime->types)
{
- DEBUG_puts("1mimeAddType: Returning NULL (no types).");
+ MIME_DEBUG("mimeAddType: Returning NULL (no types).\n");
return (NULL);
}
if ((temp = calloc(1, sizeof(mime_type_t) - MIME_MAX_TYPE + typelen)) == NULL)
{
- DEBUG_puts("1mimeAddType: Returning NULL (out of memory).");
+ MIME_DEBUG("mimeAddType: Returning NULL (out of memory).\n");
return (NULL);
}
cupsArrayAdd(mime->types, temp);
- DEBUG_printf("1mimeAddType: Returning %p (new).", temp);
+ MIME_DEBUG("mimeAddType: Returning %p (new).\n", (void *)temp);
return (temp);
}
*current; // Current rule
- DEBUG_printf(("mimeAddTypeRule(mt=%p(%s/%s), rule=\"%s\")", mt,
- mt ? mt->super : "???", mt ? mt->type : "???", rule));
+ MIME_DEBUG("mimeAddTypeRule(mt=%p(%s/%s), rule=\"%s\")\n", (void *)mt, mt ? mt->super : "???", mt ? mt->type : "???", rule);
// Range check input...
if (!mt || !rule)
// Find the last rule in the top-level of the rules tree.
for (current = mt->rules; current; current = current->next)
+ {
if (!current->next)
break;
+ }
// Parse the rules string. Most rules are either a file extension or a
// comparison function:
if (*rule == '(')
{
- DEBUG_puts("1mimeAddTypeRule: New parenthesis group");
+ MIME_DEBUG("mimeAddTypeRule: New parenthesis group.\n");
logic = MIME_MAGIC_NOP;
rule ++;
}
else if (*rule == ')')
{
- DEBUG_puts("1mimeAddTypeRule: Close paren...");
+ MIME_DEBUG("mimeAddTypeRule: Close paren.\n");
if (current == NULL || current->parent == NULL)
return (-1);
current->prev = NULL;
current->parent = temp;
- DEBUG_printf("1mimeAddTypeRule: Creating new AND group %p.", temp);
+ MIME_DEBUG("mimeAddTypeRule: Creating new AND group %p.\n", (void *)temp);
}
else if (current->parent)
{
- DEBUG_printf("1mimeAddTypeRule: Setting group %p op to AND.", current->parent);
+ MIME_DEBUG("mimeAddTypeRule: Setting group %p op to AND.\n", (void *)current->parent);
current->parent->op = MIME_MAGIC_AND;
}
if ((temp = calloc(1, sizeof(mime_magic_t))) == NULL)
return (-1);
- DEBUG_printf("1mimeAddTypeRule: Creating new AND group %p inside OR group.", temp);
+ MIME_DEBUG("mimeAddTypeRule: Creating new AND group %p inside OR group.\n", (void *)temp);
while (current->prev != NULL)
{
else
{
// This isn't the top rule, so go up one level...
- DEBUG_puts("1mimeAddTypeRule: Going up one level.");
+ MIME_DEBUG("mimeAddTypeRule: Going up one level.\n");
current = current->parent;
}
}
}
else if (*rule == '!')
{
- DEBUG_puts("1mimeAddTypeRule: NOT");
+ MIME_DEBUG("mimeAddTypeRule: NOT\n");
invert = 1;
rule ++;
}
if (logic == MIME_MAGIC_NOP)
{
// Add parenthetical grouping...
- DEBUG_printf("1mimeAddTypeRule: Making new OR group %p for parenthesis.", temp);
+ MIME_DEBUG("mimeAddTypeRule: Making new OR group %p for parenthesis.\n", (void *)temp);
temp->op = MIME_MAGIC_OR;
logic = MIME_MAGIC_OR;
}
- DEBUG_printf("1mimeAddTypeRule: Adding %p: %s, op=MIME_MAGIC_%s(%d), logic=MIME_MAGIC_%s, invert=%d.", temp, name, debug_ops[op], op, debug_ops[logic], invert);
+ MIME_DEBUG("mimeAddTypeRule: Adding %p: %s, op=MIME_MAGIC_%s(%d), logic=MIME_MAGIC_%s, invert=%d.\n", (void *)temp, name, debug_ops[op], op, debug_ops[logic], invert);
// Fill in data for the rule...
current = temp;
else
temp->value.charv = (unsigned char)strtol(value[1], NULL, 0);
- DEBUG_printf(("1mimeAddTypeRule: CHAR(%d,0x%02x)", temp->offset,
- temp->value.charv));
+ MIME_DEBUG("mimeAddTypeRule: CHAR(%d,0x%02x)", temp->offset, temp->value.charv);
break;
case MIME_MAGIC_SHORT :
temp->offset = strtol(value[0], NULL, 0);
*best; // Best match
- DEBUG_printf(("mimeFileType(mime=%p, pathname=\"%s\", filename=\"%s\", "
- "compression=%p)", mime, pathname, filename, compression));
+ MIME_DEBUG("mimeFileType(mime=%p, pathname=\"%s\", filename=\"%s\", compression=%p)\n", (void *)mime, pathname, filename, (void *)compression);
// Range check input parameters...
if (!mime || !pathname)
{
- DEBUG_puts("1mimeFileType: Returning NULL.");
+ MIME_DEBUG("mimeFileType: Returning NULL.\n");
return (NULL);
}
// Try to open the file...
if ((fb.fp = cupsFileOpen(pathname, "r")) == NULL)
{
- DEBUG_printf(("1mimeFileType: Unable to open \"%s\": %s", pathname,
- strerror(errno)));
- DEBUG_puts("1mimeFileType: Returning NULL.");
+ MIME_DEBUG("mimeFileType: Unable to open \"%s\": %s\n", pathname, strerror(errno));
+ MIME_DEBUG("mimeFileType: Returning NULL.\n");
return (NULL);
}
if (fb.length <= 0)
{
- DEBUG_printf("1mimeFileType: Unable to read from \"%s\": %s", pathname, strerror(errno));
- DEBUG_puts("1mimeFileType: Returning NULL.");
+ MIME_DEBUG("mimeFileType: Unable to read from \"%s\": %s\n", pathname, strerror(errno));
+ MIME_DEBUG("mimeFileType: Returning NULL.\n");
cupsFileClose(fb.fp);
if (compression)
{
*compression = cupsFileCompression(fb.fp);
- DEBUG_printf("1mimeFileType: *compression=%d", *compression);
+ MIME_DEBUG("mimeFileType: *compression=%d\n", *compression);
}
cupsFileClose(fb.fp);
- DEBUG_printf(("1mimeFileType: Returning %p(%s/%s).", best,
- best ? best->super : "???", best ? best->type : "???"));
+ MIME_DEBUG("mimeFileType: Returning %p(%s/%s).\n", (void *)best, best ? best->super : "???", best ? best->type : "???");
return (best);
}
*mt; // Matching type
- DEBUG_printf(("mimeType(mime=%p, super=\"%s\", type=\"%s\")", mime, super,
- type));
+ MIME_DEBUG("mimeType(mime=%p, super=\"%s\", type=\"%s\")\n", (void *)mime, super, type);
// Range check input...
if (!mime || !super || !type)
{
- DEBUG_puts("1mimeType: Returning NULL.");
+ MIME_DEBUG("mimeType: Returning NULL.\n");
return (NULL);
}
cupsCopyString(key.type, type, sizeof(key.type));
mt = (mime_type_t *)cupsArrayFind(mime->types, &key);
- DEBUG_printf("1mimeType: Returning %p.", mt);
+ MIME_DEBUG("mimeType: Returning %p.\n", (void *)mt);
return (mt);
}
unsigned char *bufptr; // Pointer into buffer
- DEBUG_printf("4mime_check_rules(filename=\"%s\", fb=%p, rules=%p)", filename, fb, rules);
+ MIME_DEBUG("mime_check_rules(filename=\"%s\", fb=%p, rules=%p)\n", filename, (void *)fb, (void *)rules);
if (rules == NULL)
return (0);
fb->offset = rules->offset;
}
- DEBUG_printf("4mime_check_rules: MIME_MAGIC_ASCII fb->length=%d", fb->length);
+ MIME_DEBUG("mime_check_rules: MIME_MAGIC_ASCII fb->length=%d", fb->length);
}
// Test for ASCII printable characters plus standard control chars.
fb->offset = rules->offset;
}
- DEBUG_printf("4mime_check_rules: MIME_MAGIC_PRINTABLE fb->length=%d", fb->length);
+ MIME_DEBUG("mime_check_rules: MIME_MAGIC_PRINTABLE fb->length=%d", fb->length);
}
// Test for 8-bit printable characters plus standard control chars.
break;
case MIME_MAGIC_REGEX :
- DEBUG_printf("5mime_check_rules: regex(%d, \"%s\")", rules->offset, rules->value.stringv);
+ MIME_DEBUG("mime_check_rules: regex(%d, \"%s\")", rules->offset, rules->value.stringv);
// Load the buffer if necessary...
if (fb->offset < 0 || rules->offset < fb->offset || (rules->offset + rules->length) > (fb->offset + fb->length))
fb->offset = rules->offset;
}
- DEBUG_printf("4mime_check_rules: MIME_MAGIC_REGEX fb->length=%d", fb->length);
+ MIME_DEBUG("mime_check_rules: MIME_MAGIC_REGEX fb->length=%d", fb->length);
- DEBUG_printf("5mime_check_rules: loaded %d byte fb->buffer at %d, starts with \"%c%c%c%c\".", fb->length, fb->offset, fb->buffer[0], fb->buffer[1], fb->buffer[2], fb->buffer[3]);
+ MIME_DEBUG("mime_check_rules: loaded %d byte fb->buffer at %d, starts with \"%c%c%c%c\".", fb->length, fb->offset, fb->buffer[0], fb->buffer[1], fb->buffer[2], fb->buffer[3]);
}
// Compare the buffer against the string. If the file is too
result = !regexec(&(rules->value.rev), temp, 0, NULL, 0);
}
- DEBUG_printf("5mime_check_rules: result=%d", result);
+ MIME_DEBUG("mime_check_rules: result=%d", result);
break;
case MIME_MAGIC_STRING :
- DEBUG_printf("5mime_check_rules: string(%d, \"%s\")", rules->offset, rules->value.stringv);
+ MIME_DEBUG("mime_check_rules: string(%d, \"%s\")", rules->offset, rules->value.stringv);
// Load the buffer if necessary...
if (fb->offset < 0 || rules->offset < fb->offset || (rules->offset + rules->length) > (fb->offset + fb->length))
fb->offset = rules->offset;
}
- DEBUG_printf("4mime_check_rules: MIME_MAGIC_STRING fb->length=%d", fb->length);
+ MIME_DEBUG("mime_check_rules: MIME_MAGIC_STRING fb->length=%d", fb->length);
- DEBUG_printf("5mime_check_rules: loaded %d byte fb->buffer at %d, starts with \"%c%c%c%c\".", fb->length, fb->offset, fb->buffer[0], fb->buffer[1], fb->buffer[2], fb->buffer[3]);
+ MIME_DEBUG("mime_check_rules: loaded %d byte fb->buffer at %d, starts with \"%c%c%c%c\".", fb->length, fb->offset, fb->buffer[0], fb->buffer[1], fb->buffer[2], fb->buffer[3]);
}
// Compare the buffer against the string. If the file is too
result = 0;
else
result = !memcmp(fb->buffer + rules->offset - fb->offset, rules->value.stringv, (size_t)rules->length);
- DEBUG_printf("5mime_check_rules: result=%d", result);
+ MIME_DEBUG("mime_check_rules: result=%d", result);
break;
case MIME_MAGIC_ISTRING :
fb->offset = rules->offset;
}
- DEBUG_printf("4mime_check_rules: MIME_MAGIC_ISTRING fb->length=%d", fb->length);
+ MIME_DEBUG("mime_check_rules: MIME_MAGIC_ISTRING fb->length=%d", fb->length);
}
// Compare the buffer against the string. If the file is too
fb->offset = rules->offset;
}
- DEBUG_printf("4mime_check_rules: MIME_MAGIC_CHAR fb->length=%d", fb->length);
+ MIME_DEBUG("mime_check_rules: MIME_MAGIC_CHAR fb->length=%d", fb->length);
}
// Compare the character values; if the file is too short, it
fb->offset = rules->offset;
}
- DEBUG_printf("4mime_check_rules: MIME_MAGIC_SHORT fb->length=%d", fb->length);
+ MIME_DEBUG("mime_check_rules: MIME_MAGIC_SHORT fb->length=%d", fb->length);
}
// Compare the short values; if the file is too short, it can't match...
fb->offset = rules->offset;
}
- DEBUG_printf("4mime_check_rules: MIME_MAGIC_INT fb->length=%d", fb->length);
+ MIME_DEBUG("mime_check_rules: MIME_MAGIC_INT fb->length=%d", fb->length);
}
// Compare the int values; if the file is too short, it can't match...
fb->offset = rules->offset;
}
- DEBUG_printf("4mime_check_rules: MIME_MAGIC_CONTAINS fb->length=%d", fb->length);
+ MIME_DEBUG("mime_check_rules: MIME_MAGIC_CONTAINS fb->length=%d", fb->length);
}
// Compare the buffer against the string. If the file is too
// OK, now if the current logic is OR and this result is true, this
// rule set is true. If the current logic is AND and this result is false,
// the rule set is false...
- DEBUG_printf("5mime_check_rules: result of test %p (MIME_MAGIC_%s) is %d", rules, debug_ops[rules->op], result);
+ MIME_DEBUG("mime_check_rules: result of test %p (MIME_MAGIC_%s) is %d.\n", (void *)rules, debug_ops[rules->op], result);
if ((result && logic == MIME_MAGIC_OR) || (!result && logic == MIME_MAGIC_AND))
return (result);
mime_magic_t *next; // Next rule to free
- DEBUG_printf("2mime_delete_rules(rules=%p)", rules);
+ MIME_DEBUG("mime_delete_rules(rules=%p)\n", (void *)rules);
// Free the rules list, descending recursively to free any child rules.
while (rules != NULL)