]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/mime.c
Load cups into easysw/current.
[thirdparty/cups.git] / scheduler / mime.c
index 1de12fe347ff6e878900739dfb7c27f7bdbb7fb4..052b42922e9b77f9892451a70cf650e5c5c3ac47 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$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).
  *
@@ -51,6 +51,7 @@
 #include <stdlib.h>
 #include <ctype.h>
 
+#include <cups/debug.h>
 #include <cups/dir.h>
 #include <cups/string.h>
 #include "mime.h"
@@ -96,15 +97,6 @@ mimeDelete(mime_t *mime)             /* I - MIME database */
   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...
   */
@@ -114,12 +106,22 @@ mimeDelete(mime_t *mime)          /* I - MIME database */
        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);
 }
 
@@ -137,6 +139,17 @@ mimeDeleteFilter(mime_t        *mime,      /* I - MIME database */
 
   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;
+  }
 }
 
 
@@ -474,6 +487,8 @@ load_convs(mime_t       *mime,              /* I - MIME database */
   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...
   */
@@ -484,6 +499,8 @@ load_convs(mime_t       *mime,              /* I - MIME database */
     * Skip blank lines and lines starting with a #...
     */
 
+    DEBUG_puts(line);
+
     if (!line[0] || line[0] == '#')
       continue;
 
@@ -532,7 +549,10 @@ load_convs(mime_t       *mime,             /* I - MIME database */
       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...
@@ -563,7 +583,10 @@ load_convs(mime_t       *mime,             /* I - MIME database */
       */
 
       if (!add_fcache(filtercache, filter, filterpath))
+      {
+        DEBUG_printf(("    Filter %s not found in %s!\n", filter, filterpath)); 
         continue;
+      }
     }
 
    /*
@@ -628,7 +651,7 @@ load_types(mime_t     *mime,                /* I - MIME database */
 {
   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 */
@@ -643,6 +666,8 @@ load_types(mime_t     *mime,                /* I - MIME database */
   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...
   */
@@ -653,6 +678,8 @@ load_types(mime_t     *mime,                /* I - MIME database */
     * Skip blank lines and lines starting with a #...
     */
 
+    DEBUG_puts(line);
+
     if (!line[0] || line[0] == '#')
       continue;
 
@@ -711,5 +738,5 @@ load_types(mime_t     *mime,                /* I - MIME database */
 
 
 /*
- * 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 $".
  */