Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When a filter is not found the error messages are misguiding. #2410

Closed
michaelrsweet opened this Issue Jun 6, 2007 · 3 comments

Comments

Projects
None yet
1 participant
@michaelrsweet
Copy link
Collaborator

michaelrsweet commented Jun 6, 2007

Version: 1.5-feature
CUPS.org User: mdornseif

If a filter from mime.convs is not found there is no error message. Instead the type/filter path is silently dropped, leading later on to "Unsupported format 'application/...'" errors. A "filter 'foobar' not found" error would be much nicer.

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

michaelrsweet commented Jun 7, 2007

CUPS.org User: mike

Unfortunately, the MIME code cannot log scheduler errors because it is not part of the scheduler.

I'm changing this to a RFE, but it probably won't get addressed until CUPS 1.4.

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

michaelrsweet commented May 6, 2011

CUPS.org User: mike

Fixed in Subversion repository.

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

michaelrsweet commented May 6, 2011

"str2410.patch":

Index: conf/mime.convs.in

--- conf/mime.convs.in (revision 9747)
+++ conf/mime.convs.in (working copy)
@@ -38,56 +38,51 @@

PostScript filters

-application/pdf application/vnd.cups-postscript 66 pdftops
+@DEFAULT_PDFTOPS@application/pdf application/vnd.cups-postscript 66 pdftops
application/postscript application/vnd.cups-postscript 66 pstops
-application/x-cshell application/postscript 33 texttops
-application/x-csource application/postscript 33 texttops
-application/x-perl application/postscript 33 texttops
-application/x-shell application/postscript 33 texttops
-text/plain application/postscript 33 texttops
-text/css application/postscript 33 texttops
-text/html application/postscript 33 texttops
-image/gif application/vnd.cups-postscript 66 imagetops
-image/png application/vnd.cups-postscript 66 imagetops
-image/jpeg application/vnd.cups-postscript 66 imagetops
-image/tiff application/vnd.cups-postscript 66 imagetops
-image/x-bitmap application/vnd.cups-postscript 66 imagetops
-image/x-photocd application/vnd.cups-postscript 66 imagetops
-image/x-portable-anymap application/vnd.cups-postscript 66 imagetops
-image/x-portable-bitmap application/vnd.cups-postscript 66 imagetops
-image/x-portable-graymap application/vnd.cups-postscript 66 imagetops
-image/x-portable-pixmap application/vnd.cups-postscript 66 imagetops
-image/x-sgi-rgb application/vnd.cups-postscript 66 imagetops
-image/x-xbitmap application/vnd.cups-postscript 66 imagetops
-image/x-xpixmap application/vnd.cups-postscript 66 imagetops
-#image/x-xwindowdump application/vnd.cups-postscript 66 imagetops
-image/x-sun-raster application/vnd.cups-postscript 66 imagetops
-application/vnd.cups-banner application/postscript 33 bannertops
+@DEFAULT_TEXTTOPS@application/x-cshell application/postscript 33 texttops
+@DEFAULT_TEXTTOPS@application/x-csource application/postscript 33 texttops
+@DEFAULT_TEXTTOPS@application/x-perl application/postscript 33 texttops
+@DEFAULT_TEXTTOPS@application/x-shell application/postscript 33 texttops
+@DEFAULT_TEXTTOPS@text/plain application/postscript 33 texttops
+@DEFAULT_TEXTTOPS@text/css application/postscript 33 texttops
+@DEFAULT_TEXTTOPS@text/html application/postscript 33 texttops
+@DEFAULT_IMAGEFILTERS@image/gif application/vnd.cups-postscript 66 imagetops
+@DEFAULT_IMAGEFILTERS@image/png application/vnd.cups-postscript 66 imagetops
+@DEFAULT_IMAGEFILTERS@image/jpeg application/vnd.cups-postscript 66 imagetops
+@DEFAULT_IMAGEFILTERS@image/tiff application/vnd.cups-postscript 66 imagetops
+@DEFAULT_IMAGEFILTERS@image/x-bitmap application/vnd.cups-postscript 66 imagetops
+@DEFAULT_IMAGEFILTERS@image/x-photocd application/vnd.cups-postscript 66 imagetops
+@DEFAULT_IMAGEFILTERS@image/x-portable-anymap application/vnd.cups-postscript 66 imagetops
+@DEFAULT_IMAGEFILTERS@image/x-portable-bitmap application/vnd.cups-postscript 66 imagetops
+@DEFAULT_IMAGEFILTERS@image/x-portable-graymap application/vnd.cups-postscript 66 imagetops
+@DEFAULT_IMAGEFILTERS@image/x-portable-pixmap application/vnd.cups-postscript 66 imagetops
+@DEFAULT_IMAGEFILTERS@image/x-sgi-rgb application/vnd.cups-postscript 66 imagetops
+@DEFAULT_IMAGEFILTERS@image/x-xbitmap application/vnd.cups-postscript 66 imagetops
+@DEFAULT_IMAGEFILTERS@image/x-xpixmap application/vnd.cups-postscript 66 imagetops
+@DEFAULT_IMAGEFILTERS@image/x-sun-raster application/vnd.cups-postscript 66 imagetops
+@DEFAULT_BANNERTOPS@application/vnd.cups-banner application/postscript 33 bannertops

########################################################################

Raster filters...

-image/gif application/vnd.cups-raster 100 imagetoraster
-image/png application/vnd.cups-raster 100 imagetoraster
-image/jpeg application/vnd.cups-raster 100 imagetoraster
-image/tiff application/vnd.cups-raster 100 imagetoraster
-image/x-bitmap application/vnd.cups-raster 100 imagetoraster
-image/x-photocd application/vnd.cups-raster 100 imagetoraster
-image/x-portable-anymap application/vnd.cups-raster 100 imagetoraster
-image/x-portable-bitmap application/vnd.cups-raster 100 imagetoraster
-image/x-portable-graymap application/vnd.cups-raster 100 imagetoraster
-image/x-portable-pixmap application/vnd.cups-raster 100 imagetoraster
-image/x-sgi-rgb application/vnd.cups-raster 100 imagetoraster
-image/x-xbitmap application/vnd.cups-raster 100 imagetoraster
-image/x-xpixmap application/vnd.cups-raster 100 imagetoraster
-#image/x-xwindowdump application/vnd.cups-raster 100 imagetoraster
-image/x-sun-raster application/vnd.cups-raster 100 imagetoraster
+@DEFAULT_IMAGEFILTERS@image/gif application/vnd.cups-raster 100 imagetoraster
+@DEFAULT_IMAGEFILTERS@image/png application/vnd.cups-raster 100 imagetoraster
+@DEFAULT_IMAGEFILTERS@image/jpeg application/vnd.cups-raster 100 imagetoraster
+@DEFAULT_IMAGEFILTERS@image/tiff application/vnd.cups-raster 100 imagetoraster
+@DEFAULT_IMAGEFILTERS@image/x-bitmap application/vnd.cups-raster 100 imagetoraster
+@DEFAULT_IMAGEFILTERS@image/x-photocd application/vnd.cups-raster 100 imagetoraster
+@DEFAULT_IMAGEFILTERS@image/x-portable-anymap application/vnd.cups-raster 100 imagetoraster
+@DEFAULT_IMAGEFILTERS@image/x-portable-bitmap application/vnd.cups-raster 100 imagetoraster
+@DEFAULT_IMAGEFILTERS@image/x-portable-graymap application/vnd.cups-raster 100 imagetoraster
+@DEFAULT_IMAGEFILTERS@image/x-portable-pixmap application/vnd.cups-raster 100 imagetoraster
+@DEFAULT_IMAGEFILTERS@image/x-sgi-rgb application/vnd.cups-raster 100 imagetoraster
+@DEFAULT_IMAGEFILTERS@image/x-xbitmap application/vnd.cups-raster 100 imagetoraster
+@DEFAULT_IMAGEFILTERS@image/x-xpixmap application/vnd.cups-raster 100 imagetoraster
+@DEFAULT_IMAGEFILTERS@image/x-sun-raster application/vnd.cups-raster 100 imagetoraster

-# pstoraster is part of GPL Ghostscript...

-application/vnd.cups-postscript application/vnd.cups-raster 100 pstoraster

PWG Raster filter for IPP Everywhere...

application/vnd.cups-raster image/pwg-raster 100 rastertopwg

Index: config-scripts/cups-defaults.m4

--- config-scripts/cups-defaults.m4 (revision 9747)
+++ config-scripts/cups-defaults.m4 (working copy)
@@ -440,25 +440,35 @@

if test "x$enable_bannertops" = xno; then
BANNERTOPS=""

  • DEFAULT_BANNERTOPS="#"
    elif test "x$enable_bannertops" = xyes; then
    BANNERTOPS="bannertops"
  • DEFAULT_BANNERTOPS=""
    elif test $uname = Darwin; then
    BANNERTOPS=""
  • DEFAULT_BANNERTOPS="#"
    else
    BANNERTOPS="bannertops"
  • DEFAULT_BANNERTOPS=""
    fi

if test "x$enable_texttops" = xno; then
TEXTTOPS=""

  • DEFAULT_TEXTTOPS="#"
    elif test "x$enable_texttops" = xyes; then
    TEXTTOPS="texttops"
  • DEFAULT_TEXTTOPS=""
    elif test $uname = Darwin; then
    TEXTTOPS=""
  • DEFAULT_TEXTTOPS="#"
    else
    TEXTTOPS="texttops"
  • DEFAULT_TEXTTOPS=""
    fi

AC_SUBST(BANNERTOPS)
+AC_SUBST(DEFAULT_BANNERTOPS)
+AC_SUBST(DEFAULT_TEXTTOPS)
AC_SUBST(TEXTTOPS)

dnl Fonts

Index: config-scripts/cups-pdf.m4

--- config-scripts/cups-pdf.m4 (revision 9749)
+++ config-scripts/cups-pdf.m4 (working copy)
@@ -87,9 +87,9 @@
else
AC_MSG_RESULT(no)
fi
-fi

-if test "x$CUPS_GHOSTSCRIPT" != x; then

  • DEFAULT_PDFTOPS=""
    +elif test "x$CUPS_GHOSTSCRIPT" != x; then
    AC_MSG_CHECKING(whether gs supports the ps2write device)
    if ($CUPS_GHOSTSCRIPT -h 2>&1 | grep -q ps2write); then
    AC_MSG_RESULT(yes)
    @@ -97,10 +97,15 @@
    else
    AC_MSG_RESULT(no)
    fi
  • DEFAULT_PDFTOPS=""
    +else
  • DEFAULT_PDFTOPS="#"
    fi

AC_DEFINE_UNQUOTED(CUPS_PDFTOPS, "$CUPS_PDFTOPS")
AC_DEFINE_UNQUOTED(CUPS_GHOSTSCRIPT, "$CUPS_GHOSTSCRIPT")
+AC_SUBST(DEFAULT_PDFTOPS)
AC_SUBST(PDFTOPS)

dnl

Index: config-scripts/cups-image.m4

--- config-scripts/cups-image.m4 (revision 9747)
+++ config-scripts/cups-image.m4 (working copy)
@@ -1,9 +1,9 @@
dnl
dnl "$Id$"
dnl
-dnl Image library/filter stuff for the Common UNIX Printing System (CUPS).
+dnl Image library/filter stuff for CUPS.
dnl
-dnl Copyright 2007-2009 by Apple Inc.
+dnl Copyright 2007-2011 by Apple Inc.
dnl Copyright 1997-2006 by Easy Software Products, all rights reserved.
dnl
dnl These coded instructions, statements, and computer programs are the
@@ -16,17 +16,20 @@
dnl See if we want the image filters included at all...
AC_ARG_ENABLE(image, [ --enable-image always build the image filters])

+DEFAULT_IMAGEFILTERS="#"
IMGFILTERS=""
if test "x$enable_image" != xno; then
AC_MSG_CHECKING(whether to build image filters)
if test "x$enable_image" = xyes -o $uname != Darwin; then
IMGFILTERS="imagetops imagetoraster"

  •   DEFAULT_IMAGEFILTERS=""
             AC_MSG_RESULT(yes)
     else
             AC_MSG_RESULT(no)
     fi
    
    fi

+AC_SUBST(DEFAULT_IMAGEFILTERS)
AC_SUBST(IMGFILTERS)

dnl Check for image libraries...

Index: test/run-stp-tests.sh

--- test/run-stp-tests.sh (revision 9747)
+++ test/run-stp-tests.sh (working copy)
@@ -267,6 +267,8 @@
ln -s $root/filter/pstops /tmp/cups-$user/bin/filter
ln -s $root/filter/rastertoepson /tmp/cups-$user/bin/filter
ln -s $root/filter/rastertohp /tmp/cups-$user/bin/filter
+ln -s $root/filter/rastertolabel /tmp/cups-$user/bin/filter
+ln -s $root/filter/rastertopwg /tmp/cups-$user/bin/filter
ln -s $root/filter/texttops /tmp/cups-$user/bin/filter

ln -s $root/data/classified /tmp/cups-$user/share/banners
@@ -286,6 +288,14 @@
ln -s $root/data/*.defs /tmp/cups-$user/share/ppdc
ln -s $root/templates /tmp/cups-$user/share

+if test -f $root/filter/imagetops; then

  • ln -s $root/filter/imagetops /tmp/cups-$user/bin/filter
    +fi

+if test -f $root/filter/imagetoraster; then

  • ln -s $root/filter/imagetoraster /tmp/cups-$user/bin/filter
    +fi

Mac OS X filters and configuration files...

@@ -301,6 +311,8 @@
ln -s /usr/libexec/cups/filter/pstoappleps /tmp/cups-$user/bin/filter
ln -s /usr/libexec/cups/filter/pstocupsraster /tmp/cups-$user/bin/filter
ln -s /usr/libexec/cups/filter/pstopdffilter /tmp/cups-$user/bin/filter

  • ln -s /usr/libexec/cups/filter/rastertourf /tmp/cups-$user/bin/filter
  • ln -s /usr/libexec/cups/filter/xhtmltopdf /tmp/cups-$user/bin/filter

if test -f /private/etc/cups/apple.types; then
ln -s /private/etc/cups/apple.* /tmp/cups-$user/share/mime
@@ -308,8 +320,6 @@
ln -s /usr/share/cups/mime/apple.* /tmp/cups-$user/share/mime
fi
else

  • ln -s $root/filter/imagetops /tmp/cups-$user/bin/filter
  • ln -s $root/filter/imagetoraster /tmp/cups-$user/bin/filter
    ln -s $root/filter/pdftops /tmp/cups-$user/bin/filter
    fi

Index: xcode/CUPS.xcodeproj/project.pbxproj

--- xcode/CUPS.xcodeproj/project.pbxproj (revision 9749)
+++ xcode/CUPS.xcodeproj/project.pbxproj (working copy)
@@ -386,6 +386,7 @@
726AD70C135E8B11002C930D /* Security.framework in Frameworks / = {isa = PBXBuildFile; fileRef = 72220F4B133306BB00FCA411 / Security.framework /; };
726AD70D135E8B11002C930D /
SystemConfiguration.framework in Frameworks / = {isa = PBXBuildFile; fileRef = 72220F4C133306BB00FCA411 / SystemConfiguration.framework /; };
726AD70E135E8B5E002C930D /
libiconv.dylib in Frameworks / = {isa = PBXBuildFile; fileRef = 72220F51133308C100FCA411 / libiconv.dylib */; };

  •   7271883D1374AB14001A2036 /\* mime-private.h in Headers _/ = {isa = PBXBuildFile; fileRef = 7271883C1374AB14001A2036 /_ mime-private.h _/; };
    72F75A5C1336F988004BB496 /_ cupstestppd.c in Sources _/ = {isa = PBXBuildFile; fileRef = 72F75A5B1336F988004BB496 /_ cupstestppd.c _/; };
    72F75A671336FA38004BB496 /_ libcups.dylib in Frameworks _/ = {isa = PBXBuildFile; fileRef = 72220EAE1333047D00FCA411 /_ libcups.dylib _/; };
    72F75A6C1336FA8A004BB496 /_ error.c in Sources _/ = {isa = PBXBuildFile; fileRef = 72F75A691336FA8A004BB496 /_ error.c _/; };
    
    @@ -1418,6 +1419,7 @@
    72718839137498E4001A2036 /_ image-zoom.c / = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = "image-zoom.c"; path = "../filter/image-zoom.c"; sourceTree = ""; };
    7271883A137498E4001A2036 /
    image.c / = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = image.c; path = ../filter/image.c; sourceTree = ""; };
    7271883B137498E4001A2036 /
    image.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = image.h; path = ../filter/image.h; sourceTree = ""; };
  •   7271883C1374AB14001A2036 /\* mime-private.h _/ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "mime-private.h"; path = "../scheduler/mime-private.h"; sourceTree = "<group>"; };
    72F75A4C1336F31B004BB496 /_ libcups_static.a _/ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libcups_static.a; sourceTree = BUILT_PRODUCTS_DIR; };
    72F75A521336F950004BB496 /_ cupstestppd _/ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = cupstestppd; sourceTree = BUILT_PRODUCTS_DIR; };
    72F75A5B1336F988004BB496 /_ cupstestppd.c _/ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = cupstestppd.c; path = ../systemv/cupstestppd.c; sourceTree = "<group>"; };
    
    @@ -1950,6 +1952,7 @@
    72220EE4133305BB00FCA411 /_ ipp-private.h /,
    72220EE9133305BB00FCA411 /
    language-private.h /,
    72220EEE133305BB00FCA411 /
    md5-private.h */,
  •           7271883C1374AB14001A2036 /\* mime-private.h _/,
            72220EF5133305BB00FCA411 /_ ppd-private.h _/,
            72220EF9133305BB00FCA411 /_ pwg-private.h _/,
            72220EFE133305BB00FCA411 /_ snmp-private.h _/,
    
    @@ -2252,6 +2255,7 @@
    buildActionMask = 2147483647;
    files = (
    72220FB813330BCE00FCA411 /_ mime.h in Headers */,
  •           7271883D1374AB14001A2036 /\* mime-private.h in Headers _/,
        );
        runOnlyForDeploymentPostprocessing = 0;
    };
    

    Index: scheduler/mime-private.h

    --- scheduler/mime-private.h (revision 9747)
    +++ scheduler/mime-private.h (working copy)
    @@ -1,10 +1,9 @@
    /_
    • "$Id$"
      *
  • * MIME type/conversion database definitions for CUPS.
  • * Private MIME type/conversion database definitions for CUPS.
    *
  • * Copyright 2007-2011 by Apple Inc.
  • * Copyright 1997-2007 by Easy Software Products, all rights reserved.
  • * Copyright 2011 by Apple Inc.
    *
    • These coded instructions, statements, and computer programs are the
    • property of Apple Inc. and are protected by Federal copyright
      @@ -13,12 +12,10 @@
    • file is missing or damaged, see the license at "http://www.cups.org/".
      */

-#ifndef CUPS_MIME_H
-# define CUPS_MIME_H
+#ifndef CUPS_MIME_PRIVATE_H
+# define CUPS_MIME_PRIVATE_H

-# include <cups/array.h>
-# include <cups/ipp.h>
-# include <cups/file.h>
+# include "mime.h"

/*
@@ -31,124 +28,20 @@

/*

  • * Constants...
  • * Prototypes...
    */

-# define MIME_MAX_SUPER 16 /* Maximum size of supertype name /
-# define MIME_MAX_TYPE IPP_MAX_NAME /
Maximum size of type name /
-# define MIME_MAX_FILTER 256 /
Maximum size of filter pathname /
-# define MIME_MAX_BUFFER 4096 /
Maximum size of file buffer _/
+extern void mimeError(mime_t *mime, const char *format, ...)
+#ifdef GNUC
+attribute ((format (printf, 2, 3)))
+#endif /
GNUC */
+;

-/*

  • * Types/structures...

- */

-typedef enum
-{

  • MIME_MAGIC_NOP, /* No operation */
  • MIME_MAGIC_AND, /* Logical AND of all children */
  • MIME_MAGIC_OR, /* Logical OR of all children */
  • MIME_MAGIC_MATCH, /* Filename match */
  • MIME_MAGIC_ASCII, /* ASCII characters in range */
  • MIME_MAGIC_PRINTABLE, /* Printable characters (32-255) in range */
  • MIME_MAGIC_STRING, /* String matches */
  • MIME_MAGIC_CHAR, /* Character/byte matches */
  • MIME_MAGIC_SHORT, /* Short/16-bit word matches */
  • MIME_MAGIC_INT, /* Integer/32-bit word matches */
  • MIME_MAGIC_LOCALE, /* Current locale matches string */
  • MIME_MAGIC_CONTAINS, /* File contains a string */
  • MIME_MAGIC_ISTRING /* Case-insensitive string matches _/
    -} mime_op_t;

-typedef struct mime_magic_s /*** MIME Magic Data ****/
-{

  • struct _mime_magic_s prev, / Previous rule */
  •       _next,      /_ Next rule */
    
  •       _parent,    /_ Parent rules */
    
  •       _child;     /_ Child rules */
    
  • short op, /* Operation code (see above) */
  •   invert;         /\* Invert the result */
    
  • int offset, /* Offset in file */
  •   region,         /\* Region length */
    
  •   length;         /\* Length of data */
    
  • union
  • {
  • char matchv[64]; /* Match value */
  • char localev[64]; /* Locale value */
  • char stringv[64]; /* String value */
  • unsigned char charv; /* Byte value */
  • unsigned short shortv; /* Short value */
  • unsigned intv; /* Integer value */
  • } value;
    -} mime_magic_t;

-typedef struct _mime_type_s /**** MIME Type Data ****/
-{

  • mime_magic_t rules; / Rules used to detect this type */
  • int priority; /* Priority of this type */
  • char super[MIME_MAX_SUPER], /* Super-type name ("image", "application", etc.) */
  •   type[MIME_MAX_TYPE];    /\* Type name ("png", "postscript", etc.) _/
    

    -} mime_type_t;

    -typedef struct mime_filter_s /*** MIME Conversion Filter Data ****/
    -{
  • mime_type_t src, / Source type */
  •   _dst;           /_ Destination type */
    
  • int cost; /* Relative cost */
  • char filter[MIME_MAX_FILTER];/* Filter program to use */
  • size_t maxsize; /* Maximum file size for this filter _/
    -} mime_filter_t;

-typedef struct mime_s /*** MIME Database ****/
-{

  • cups_array_t types; / File types */
  • cups_array_t filters; / Type conversion filters */
  • cups_array_t srcs; / Filters sorted by source type _/
    -} mime_t;

-/_

  • * Functions...

- */

-extern void mimeDelete(mime_t *mime);
-extern mime_t *mimeLoad(const char *pathname, const char *filterpath);
-extern mime_t *mimeLoadFilters(mime_t *mime, const char *pathname,

  •                        const char *filterpath);
    

    -extern mime_t *mimeLoadTypes(mime_t *mime, const char *pathname);

    -extern mime_type_t *mimeAddType(mime_t *mime, const char *super,
  •                    const char *type);
    
    -extern int mimeAddTypeRule(mime_type_t *mt, const char *rule);
    -extern void mimeDeleteType(mime_t *mime, mime_type_t *mt);
    -extern mime_type_t *mimeFileType(mime_t *mime, const char *pathname,
  •                     const char *filename, int *compression);
    
    -extern mime_type_t *mimeFirstType(mime_t *mime);
    -extern mime_type_t *mimeNextType(mime_t *mime);
    -extern int mimeNumTypes(mime_t *mime);
    -extern mime_type_t *mimeType(mime_t *mime, const char *super,

- const char *type);

-extern mime_filter_t *mimeAddFilter(mime_t *mime, mime_type_t *src,

  •                      mime_type_t *dst, int cost,
    
  •                  const char *filter);
    

    -extern void mimeDeleteFilter(mime_t *mime, mime_filter_t *filter);
    -extern cups_array_t *mimeFilter(mime_t *mime, mime_type_t *src,

  •                   mime_type_t *dst, int *cost);
    

    -extern cups_array_t *mimeFilter2(mime_t *mime, mime_type_t *src,

  •                    size_t srcsize, mime_type_t *dst,
    
  •                int *cost);
    

    -extern mime_filter_t *mimeFilterLookup(mime_t *mime, mime_type_t *src,

  •                         mime_type_t *dst);
    

    -extern mime_filter_t *mimeFirstFilter(mime_t *mime);
    -extern mime_filter_t *mimeNextFilter(mime_t *mime);

    -extern int mimeNumFilters(mime_t *mime);

    ifdef __cplusplus

    }

    endif /* __cplusplus */

    -#endif /* !CUPS_MIME_H /
    +#endif /
    !CUPS_MIME_PRIVATE_H */

    /*

    • End of "$Id$".
      Index: scheduler/conf.c

      --- scheduler/conf.c (revision 9747)
      +++ scheduler/conf.c (working copy)
      @@ -21,6 +21,7 @@
    • cupsdReadConfiguration() - Read the cupsd.conf file.
    • get_address() - Get an address + port number from a line.
    • get_addr_and_mask() - Get an IP address and netmask.
    • mime_error_cb() - Log a MIME error.
    • parse_aaa() - Parse authentication, authorization, and access
    •                          control lines.
      
    • parse_fatal_errors() - Parse FatalErrors values in a string.
      @@ -205,6 +206,7 @@
      static http_addrlist_t *get_address(const char *value, int defport);
      static int get_addr_and_mask(const char *value, unsigned *ip,
      unsigned *mask);
      +static void mime_error_cb(void *ctx, const char *message);
      static int parse_aaa(cupsd_location_t *loc, char *line,
      char *value, int linenum);
      static int parse_fatal_errors(const char *s);
      @@ -1379,7 +1381,10 @@
      snprintf(temp, sizeof(temp), "%s/filter", ServerBin);
      snprintf(mimedir, sizeof(mimedir), "%s/mime", DataDir);
  • MimeDatabase = mimeLoadTypes(NULL, mimedir);

  • MimeDatabase = mimeNew();

  • mimeSetErrorCallback(MimeDatabase, mime_error_cb, NULL);

  • MimeDatabase = mimeLoadTypes(MimeDatabase, mimedir);
    MimeDatabase = mimeLoadTypes(MimeDatabase, ServerRoot);
    MimeDatabase = mimeLoadFilters(MimeDatabase, mimedir, temp);
    MimeDatabase = mimeLoadFilters(MimeDatabase, ServerRoot, temp);
    @@ -1822,6 +1827,18 @@

/*

  • * 'mime_error_cb()' - Log a MIME error.
  • /
    +
    +static void
    +mime_error_cb(void *ctx, /
    I - Context pointer (unused) */
  •          const char _message) /_ I - Message */
    
    +{
  • cupsdLogMessage(CUPSD_LOG_ERROR, "%s", message);
    +}

+/*

  • 'parse_aaa()' - Parse authentication, authorization, and access control lines.
    */

Index: scheduler/mime.c

--- scheduler/mime.c (revision 9747)
+++ scheduler/mime.c (working copy)
@@ -14,24 +14,27 @@
*

  • Contents:
    *

    • * mimeDelete() - Delete (free) a MIME database.
    • * mimeDeleteFilter() - Delete a filter from the MIME database.
    • * mimeDeleteType() - Delete a type from the MIME database.
    • * mimeFirstFilter() - Get the first filter in the MIME database.
    • * mimeFirstType() - Get the first type in the MIME database.
    • * mimeLoad() - Create a new MIME database from disk.
    • * mimeMerge() - Merge a MIME database from disk with the current one.
    • * mimeNew() - Create a new, empty MIME database.
    • * mimeNextFilter() - Get the next filter in the MIME database.
    • * mimeNextType() - Get the next type in the MIME database.
    • * mimeNumFilters() - Get the number of filters in a MIME database.
    • * mimeNumTypes() - Get the number of types in a MIME database.
    • * mime_add_fcache() - Add a filter to the filter cache.
    • * mime_compare_fcache() - Compare two filter cache entries.
    • * mime_delete_fcache() - Free all memory used by the filter cache.
    • * mime_delete_rules() - Free all memory for the given rule tree.
    • * mime_load_convs() - Load a xyz.convs file...
    • * mime_load_types() - Load a xyz.types file...
    • * mimeDelete() - Delete (free) a MIME database.
    • * mimeDeleteFilter() - Delete a filter from the MIME database.
    • * mimeDeleteType() - Delete a type from the MIME database.
    • * _mimeError() - Show an error message.
    • * mimeFirstFilter() - Get the first filter in the MIME database.
    • * mimeFirstType() - Get the first type in the MIME database.
    • * mimeLoad() - Create a new MIME database from disk.
    • * mimeLoadFilters() - Load filter definitions from disk.
    • * mimeLoadTypes() - Load type definitions from disk.
    • * mimeNew() - Create a new, empty MIME database.
    • * mimeNextFilter() - Get the next filter in the MIME database.
    • * mimeNextType() - Get the next type in the MIME database.
    • * mimeNumFilters() - Get the number of filters in a MIME database.
    • * mimeNumTypes() - Get the number of types in a MIME database.
    • * mimeSetErrorCallback() - Set the callback for error messages.
    • * mime_add_fcache() - Add a filter to the filter cache.
    • * mime_compare_fcache() - Compare two filter cache entries.
    • * mime_delete_fcache() - Free all memory used by the filter cache.
    • * mime_delete_rules() - Free all memory for the given rule tree.
    • * mime_load_convs() - Load a xyz.convs file.
    • * mime_load_types() - Load a xyz.types file.
      */

    /*
    @@ -41,7 +44,7 @@
    #include <cups/string-private.h>
    #include <cups/debug-private.h>
    #include <cups/dir.h>
    -#include "mime.h"
    +#include "mime-private.h"

    /*
    @@ -68,7 +71,6 @@
    const char *filterpath,
    cups_array_t *filtercache);
    static void mime_load_types(mime_t *mime, const char *filename);
    -static mime_t *mime_new(void);

    /*
    @@ -185,6 +187,30 @@

    /*

    • * '_mimeError()' - Show an error message.
    • _/
      +
      +void
      +mimeError(mime_t *mime, / I - MIME database */
    •       const char _message,        /_ I - Printf-style message string */
      
    •  ...)             /\* I - Additional arguments as needed */
      
      +{
    • va_list ap; /* Argument pointer */
    • char buffer[8192]; /* Message buffer */
    • if (mime->error_cb)
    • {
    • va_start(ap, message);
    • vsnprintf(buffer, sizeof(buffer), message, ap);
    • va_end(ap);
    • (*mime->error_cb)(mime->error_ctx, buffer);
    • }
      +}

    +/*

  • 'mimeFirstFilter()' - Get the first filter in the MIME database.
    */

@@ -296,6 +322,7 @@
{
DEBUG_printf(("1mimeLoadFilters: Unable to open "%s": %s", pathname,
strerror(errno)));

  • _mimeError(mime, "Unable to open "%s": %s", pathname, strerror(errno));
    return (mime);
    }

@@ -355,6 +382,7 @@
DEBUG_printf(("1mimeLoadTypes: Unable to open "%s": %s", pathname,
strerror(errno)));
DEBUG_printf(("1mimeLoadTypes: Returning %p.", mime));

  • _mimeError(mime, "Unable to open "%s": %s", pathname, strerror(errno));
    return (mime);
    }

@@ -363,7 +391,7 @@
*/

if (!mime)

  • mime = mime_new();
  • mime = mimeNew();

if (!mime)
{
@@ -400,6 +428,17 @@

/*

  • * 'mimeNew()' - Create a new, empty MIME database.
  • /
    +
    +mime_t * /
    O - MIME database */
    +mimeNew(void)
    +{
  • return ((mime_t _)calloc(1, sizeof(mime_t)));
    +}

+/_

  • 'mimeNextFilter()' - Get the next filter in the MIME database.
    */

@@ -496,6 +535,24 @@

/*

  • * 'mimeSetErrorCallback()' - Set the callback for error messages.
  • */
    +
    +void
    +mimeSetErrorCallback(
  • mime_t mime, / I - MIME database */
  • mime_error_cb_t cb, /* I - Callback function */
  • void ctx) / I - Context pointer for callback */
    +{
  • if (mime)
  • {
  • mime->error_cb = cb;
  • mime->error_ctx = ctx;
  • }
    +}

+/*

  • 'mime_add_fcache()' - Add a filter to the filter cache.
    */

@@ -609,7 +666,7 @@

/*

  • * 'mime_load_convs()' - Load a xyz.convs file...

    • 'mime_load_convs()' - Load a xyz.convs file.
      */

    static void
    @@ -642,6 +699,7 @@
    {
    DEBUG_printf(("3mime_load_convs: Unable to open "%s": %s", filename,
    strerror(errno)));

  • _mimeError(mime, "Unable to open "%s": %s", filename, strerror(errno));
    return;
    }

@@ -741,6 +799,7 @@
{
DEBUG_printf(("mime_load_convs: Filter %s not found in %s.", filter,
filterpath));

  •    _mimeError(mime, "Filter \"%s\" not found.", filter);
     continue;
    

    }
    }
    @@ -798,7 +857,7 @@

    /*

  • * 'mime_load_types()' - Load a xyz.types file...

    • 'mime_load_types()' - Load a xyz.types file.
      */

    static void
    @@ -825,6 +884,7 @@
    {
    DEBUG_printf(("3mime_load_types: Unable to open "%s": %s", filename,
    strerror(errno)));

  • _mimeError(mime, "Unable to open "%s": %s", filename, strerror(errno));
    return;
    }

@@ -896,16 +956,5 @@

/*

  • * 'mime_new()' - Create a new, empty MIME database.

- */

-static mime_t * /* O - MIME database */
-mime_new(void)
-{

  • return ((mime_t _)calloc(1, sizeof(mime_t)));
    -}

-/_

  • End of "$Id$".
    _/
    Index: scheduler/mime.h

    --- scheduler/mime.h (revision 9747)
    +++ scheduler/mime.h (working copy)
    @@ -100,11 +100,15 @@
    size_t maxsize; /_ Maximum file size for this filter */
    } mime_filter_t;

+typedef void (_mime_error_cb_t)(void *ctx, const char *message);
+
typedef struct mime_s /*** MIME Database ****/
{

  • cups_array_t types; / File types */
  • cups_array_t filters; / Type conversion filters */
  • cups_array_t srcs; / Filters sorted by source type */
  • cups_array_t types; / File types */
  • cups_array_t filters; / Type conversion filters */
  • cups_array_t srcs; / Filters sorted by source type */
  • mime_error_cb_t error_cb; /* Error message callback */
  • void error_ctx; / Pointer for callback */
    } mime_t;

@@ -113,6 +117,7 @@
*/

extern void mimeDelete(mime_t *mime);
+extern mime_t *mimeNew(void) _CUPS_API_1_5;
extern mime_t *mimeLoad(const char *pathname, const char *filterpath);
extern mime_t *mimeLoadFilters(mime_t *mime, const char *pathname,
const char *filterpath);
@@ -144,6 +149,8 @@
extern mime_filter_t *mimeFirstFilter(mime_t *mime);
extern mime_filter_t *mimeNextFilter(mime_t *mime);
extern int mimeNumFilters(mime_t *mime);
+extern void mimeSetErrorCallback(mime_t *mime, mime_error_cb_t cb,

  •                            void *context) _CUPS_API_1_5;
    

    ifdef __cplusplus

    }

    Index: scheduler/libcupsmime.exp

    --- scheduler/libcupsmime.exp (revision 9747)
    +++ scheduler/libcupsmime.exp (working copy)
    @@ -12,8 +12,10 @@
    _mimeLoad
    _mimeLoadFilters
    _mimeLoadTypes
    +_mimeNew
    _mimeNextFilter
    _mimeNextType
    _mimeNumFilters
    _mimeNumTypes
    +_mimeSetErrorCallback
    _mimeType

@michaelrsweet michaelrsweet added this to the Stable milestone Mar 17, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.