/*
- * "$Id: mime.c 5057 2006-02-02 20:38:29Z mike $"
+ * "$Id: mime.c 5605 2006-05-30 19:38:02Z mike $"
*
* MIME database file routines for the Common UNIX Printing System (CUPS).
*
#include <stdlib.h>
#include <ctype.h>
+#include <cups/debug.h>
#include <cups/dir.h>
#include <cups/string.h>
#include "mime.h"
if (!mime)
return;
- /*
- * Loop through the file types and delete any rules...
- */
-
- for (type = (mime_type_t *)cupsArrayFirst(mime->types);
- type;
- type = (mime_type_t *)cupsArrayNext(mime->types))
- mimeDeleteType(mime, type);
-
/*
* Loop through filters and free them...
*/
filter = (mime_filter_t *)cupsArrayNext(mime->filters))
mimeDeleteFilter(mime, filter);
+ /*
+ * Loop through the file types and delete any rules...
+ */
+
+ for (type = (mime_type_t *)cupsArrayFirst(mime->types);
+ type;
+ type = (mime_type_t *)cupsArrayNext(mime->types))
+ mimeDeleteType(mime, type);
+
/*
* Free the types and filters arrays, and then the MIME database structure.
*/
cupsArrayDelete(mime->types);
cupsArrayDelete(mime->filters);
+ cupsArrayDelete(mime->srcs);
free(mime);
}
cupsArrayRemove(mime->filters, filter);
free(filter);
+
+ /*
+ * Deleting a filter invalidates the source lookup cache used by
+ * mimeFilter()...
+ */
+
+ if (mime->srcs)
+ {
+ cupsArrayDelete(mime->srcs);
+ mime->srcs = NULL;
+ }
}
if ((fp = cupsFileOpen(filename, "r")) == NULL)
return;
+ DEBUG_printf(("\"%s\":\n", filename));
+
/*
* Then read each line from the file, skipping any comments in the file...
*/
* Skip blank lines and lines starting with a #...
*/
+ DEBUG_puts(line);
+
if (!line[0] || line[0] == '#')
continue;
continue;
if ((dsttype = mimeType(mime, super, type)) == NULL)
+ {
+ DEBUG_printf((" Destination type %s/%s not found!\n", super, type));
continue;
+ }
/*
* Then get the cost and filter program...
*/
if (!add_fcache(filtercache, filter, filterpath))
+ {
+ DEBUG_printf((" Filter %s not found in %s!\n", filter, filterpath));
continue;
+ }
}
/*
{
cups_file_t *fp; /* Types file */
int linelen; /* Length of line */
- char line[65536], /* Input line from file */
+ char line[32768], /* Input line from file */
*lineptr, /* Current position in line */
super[MIME_MAX_SUPER], /* Super-type name */
type[MIME_MAX_TYPE], /* Type name */
if ((fp = cupsFileOpen(filename, "r")) == NULL)
return;
+ DEBUG_printf(("\"%s\":\n", filename));
+
/*
* Then read each line from the file, skipping any comments in the file...
*/
* Skip blank lines and lines starting with a #...
*/
+ DEBUG_puts(line);
+
if (!line[0] || line[0] == '#')
continue;
/*
- * End of "$Id: mime.c 5057 2006-02-02 20:38:29Z mike $".
+ * End of "$Id: mime.c 5605 2006-05-30 19:38:02Z mike $".
*/