1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
3 <!-- SECTION: Programming -->
5 <title>MIME API
</title>
6 <meta name=
"keywords" content=
"Programming">
7 <meta http-equiv=
"Content-Type" content=
"text/html;charset=utf-8">
8 <meta name=
"creator" content=
"Mini-XML v2.7">
9 <style type=
"text/css"><!--
11 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
14 H1, H2, H3, H4, H5, H6, P, TD, TH {
15 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
19 font-family: monaco, courier, monospace;
24 font-family: monaco, courier, monospace;
28 border: dotted thin #7f7f7f;
44 border: dotted thin #999999;
49 PRE.command EM, PRE.example EM {
50 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
54 font-family: monaco, courier, monospace;
65 border: solid thin #999999;
76 -moz-border-radius: 10px;
81 text-decoration: none;
84 A:link:hover, A:visited:hover, A:active {
85 text-decoration: underline;
92 TR.data, TD.data, TR.data TD {
95 border-bottom: solid 1pt #999999;
99 border-bottom: solid 1pt #999999;
106 border: solid thin #999999;
107 border-collapse: collapse;
123 border: solid thin #cccccc;
130 border-bottom: solid thin #999999;
139 caption-side: bottom;
163 border: thin solid black;
171 H2 SPAN.info, H3 SPAN.info, H4 SPAN.info {
180 border-bottom: solid 2pt #000000;
183 DIV.indent, TABLE.indent {
191 border-collapse: collapse;
194 TABLE.indent TD, TABLE.indent TH {
199 border-collapse: collapse;
207 border-bottom: solid thin #cccccc;
212 vertical-align: bottom;
221 border-bottom: solid thin #eeeeee;
226 TABLE.list TR:nth-child(even) {
230 TABLE.list TR:nth-child(odd) {
249 font-family: monaco, courier, monospace;
253 border: solid thin #999999;
254 border-collapse: collapse;
259 DIV.summary TABLE TD, DIV.summary TABLE TH {
260 border: solid thin #999999;
266 DIV.summary TABLE THEAD TH {
270 /* API documentation styles... */
277 div.body h3, div.body h4, div.body h5 {
278 margin-bottom: 0.5em;
281 .class, .enumeration, .function, .struct, .typedef, .union {
282 border-bottom: solid thin #999999;
289 code, p.code, pre, ul.code li {
290 font-family: monaco, courier, monospace;
293 ul.code, ul.contents, ul.subcontents {
294 list-style-type: none;
304 ul.contents li ul.code, ul.contents li ul.subcontents {
317 margin-bottom: 0.5em;
320 /* This is just for the HTML files generated with the framedhelp target */
323 border: solid thin black;
332 div.contents ul.contents {
335 div.contents ul.subcontents li {
344 "$Id: api-array.header 8087 2008-10-27 21:37:05Z mike $"
346 MIME API header for CUPS.
348 Copyright 2009 by Apple Inc.
350 These coded instructions, statements, and computer programs are the
351 property of Apple Inc. and are protected by Federal copyright
352 law. Distribution and use rights are outlined in the file "LICENSE.txt"
353 which should have been included with this file. If this file is
354 file is missing or damaged, see the license at "http://www.cups.org/".
357 <h1 class='title'
>MIME API
</h1>
359 <div class='summary'
><table summary='General Information'
>
373 <td>Programming:
<a href='api-overview.html' target='_top'
>Introduction to CUPS Programming
</a></td>
377 <h2 class=
"title">Contents
</h2>
378 <ul class=
"contents">
379 <li><a href=
"#OVERVIEW">Overview
</a></li>
380 <li><a href=
"#FUNCTIONS">Functions
</a><ul class=
"code">
381 <li><a href=
"#mimeAddFilter" title=
"Add a filter to the current MIME database.">mimeAddFilter
</a></li>
382 <li><a href=
"#mimeAddType" title=
"Add a MIME type to a database.">mimeAddType
</a></li>
383 <li><a href=
"#mimeAddTypeRule" title=
"Add a detection rule for a file type.">mimeAddTypeRule
</a></li>
384 <li><a href=
"#mimeDelete" title=
"Delete (free) a MIME database.">mimeDelete
</a></li>
385 <li><a href=
"#mimeDeleteFilter" title=
"Delete a filter from the MIME database.">mimeDeleteFilter
</a></li>
386 <li><a href=
"#mimeDeleteType" title=
"Delete a type from the MIME database.">mimeDeleteType
</a></li>
387 <li><a href=
"#mimeFileType" title=
"Determine the type of a file.">mimeFileType
</a></li>
388 <li><a href=
"#mimeFilter" title=
"Find the fastest way to convert from one type to another.">mimeFilter
</a></li>
389 <li><a href=
"#mimeFilter2" title=
"Find the fastest way to convert from one type to another,
390 including file size.">mimeFilter2
</a></li>
391 <li><a href=
"#mimeFilterLookup" title=
"Lookup a filter.">mimeFilterLookup
</a></li>
392 <li><a href=
"#mimeFirstFilter" title=
"Get the first filter in the MIME database.">mimeFirstFilter
</a></li>
393 <li><a href=
"#mimeFirstType" title=
"Get the first type in the MIME database.">mimeFirstType
</a></li>
394 <li><a href=
"#mimeLoad" title=
"Create a new MIME database from disk.">mimeLoad
</a></li>
395 <li><a href=
"#mimeLoadFilters" title=
"Load filter definitions from disk.">mimeLoadFilters
</a></li>
396 <li><a href=
"#mimeLoadTypes" title=
"Load type definitions from disk.">mimeLoadTypes
</a></li>
397 <li><a href=
"#mimeNew" title=
"Create a new, empty MIME database.">mimeNew
</a></li>
398 <li><a href=
"#mimeNextFilter" title=
"Get the next filter in the MIME database.">mimeNextFilter
</a></li>
399 <li><a href=
"#mimeNextType" title=
"Get the next type in the MIME database.">mimeNextType
</a></li>
400 <li><a href=
"#mimeNumFilters" title=
"Next type">mimeNumFilters
</a></li>
401 <li><a href=
"#mimeNumTypes" title=
"MIME database">mimeNumTypes
</a></li>
402 <li><a href=
"#mimeSetErrorCallback" title=
"Set the callback for error messages.">mimeSetErrorCallback
</a></li>
403 <li><a href=
"#mimeType" title=
"Lookup a file type.">mimeType
</a></li>
405 <li><a href=
"#TYPES">Data Types
</a><ul class=
"code">
406 <li><a href=
"#const" title=
"MIME Database">const
</a></li>
407 <li><a href=
"#mime_filter_t" title=
"MIME Conversion Filter Data">mime_filter_t
</a></li>
408 <li><a href=
"#mime_magic_t" title=
"MIME Magic Data">mime_magic_t
</a></li>
409 <li><a href=
"#mime_op_t" title=
"Types/structures...">mime_op_t
</a></li>
410 <li><a href=
"#mime_t" title=
"MIME Database">mime_t
</a></li>
411 <li><a href=
"#mime_type_t" title=
"MIME Type Data">mime_type_t
</a></li>
415 "$Id: api-array.shtml 7616 2008-05-28 00:34:13Z mike $"
417 MIME API introduction for CUPS.
419 Copyright 2009 by Apple Inc.
421 These coded instructions, statements, and computer programs are the
422 property of Apple Inc. and are protected by Federal copyright
423 law. Distribution and use rights are outlined in the file "LICENSE.txt"
424 which should have been included with this file. If this file is
425 file is missing or damaged, see the license at "http://www.cups.org/".
428 <h2 class='title'
><a name='OVERVIEW'
>Overview
</a></h2>
430 <p>The MIME API provides file typing and conversion services for CUPS.
</p>
431 <h2 class=
"title"><a name=
"FUNCTIONS">Functions
</a></h2>
432 <h3 class=
"function"><a name=
"mimeAddFilter">mimeAddFilter
</a></h3>
433 <p class=
"description">Add a filter to the current MIME database.
</p>
435 <a href=
"#mime_filter_t">mime_filter_t
</a> *mimeAddFilter (
<br>
436 <a href=
"#mime_t">mime_t
</a> *mime,
<br>
437 <a href=
"#mime_type_t">mime_type_t
</a> *src,
<br>
438 <a href=
"#mime_type_t">mime_type_t
</a> *dst,
<br>
439 int cost,
<br>
440 <a href=
"#const">const
</a> char *filter
<br>
442 <h4 class=
"parameters">Parameters
</h4>
445 <dd class=
"description">MIME database
</dd>
447 <dd class=
"description">Source type
</dd>
449 <dd class=
"description">Destination type
</dd>
451 <dd class=
"description">Relative time/resource cost
</dd>
453 <dd class=
"description">Filter program to run
</dd>
455 <h4 class=
"returnvalue">Return Value
</h4>
456 <p class=
"description">New filter
</p>
457 <h3 class=
"function"><a name=
"mimeAddType">mimeAddType
</a></h3>
458 <p class=
"description">Add a MIME type to a database.
</p>
460 <a href=
"#mime_type_t">mime_type_t
</a> *mimeAddType (
<br>
461 <a href=
"#mime_t">mime_t
</a> *mime,
<br>
462 <a href=
"#const">const
</a> char *super,
<br>
463 <a href=
"#const">const
</a> char *type
<br>
465 <h4 class=
"parameters">Parameters
</h4>
468 <dd class=
"description">MIME database
</dd>
470 <dd class=
"description">Super-type name
</dd>
472 <dd class=
"description">Type name
</dd>
474 <h4 class=
"returnvalue">Return Value
</h4>
475 <p class=
"description">New (or existing) MIME type
</p>
476 <h3 class=
"function"><a name=
"mimeAddTypeRule">mimeAddTypeRule
</a></h3>
477 <p class=
"description">Add a detection rule for a file type.
</p>
479 int mimeAddTypeRule (
<br>
480 <a href=
"#mime_type_t">mime_type_t
</a> *mt,
<br>
481 <a href=
"#const">const
</a> char *rule
<br>
483 <h4 class=
"parameters">Parameters
</h4>
486 <dd class=
"description">Type to add to
</dd>
488 <dd class=
"description">Rule to add
</dd>
490 <h4 class=
"returnvalue">Return Value
</h4>
491 <p class=
"description">0 on success, -
1 on failure
</p>
492 <h3 class=
"function"><a name=
"mimeDelete">mimeDelete
</a></h3>
493 <p class=
"description">Delete (free) a MIME database.
</p>
495 void mimeDelete (
<br>
496 <a href=
"#mime_t">mime_t
</a> *mime
<br>
498 <h4 class=
"parameters">Parameters
</h4>
501 <dd class=
"description">MIME database
</dd>
503 <h3 class=
"function"><a name=
"mimeDeleteFilter">mimeDeleteFilter
</a></h3>
504 <p class=
"description">Delete a filter from the MIME database.
</p>
506 void mimeDeleteFilter (
<br>
507 <a href=
"#mime_t">mime_t
</a> *mime,
<br>
508 <a href=
"#mime_filter_t">mime_filter_t
</a> *filter
<br>
510 <h4 class=
"parameters">Parameters
</h4>
513 <dd class=
"description">MIME database
</dd>
515 <dd class=
"description">Filter
</dd>
517 <h3 class=
"function"><a name=
"mimeDeleteType">mimeDeleteType
</a></h3>
518 <p class=
"description">Delete a type from the MIME database.
</p>
520 void mimeDeleteType (
<br>
521 <a href=
"#mime_t">mime_t
</a> *mime,
<br>
522 <a href=
"#mime_type_t">mime_type_t
</a> *mt
<br>
524 <h4 class=
"parameters">Parameters
</h4>
527 <dd class=
"description">MIME database
</dd>
529 <dd class=
"description">Type
</dd>
531 <h3 class=
"function"><a name=
"mimeFileType">mimeFileType
</a></h3>
532 <p class=
"description">Determine the type of a file.
</p>
534 <a href=
"#mime_type_t">mime_type_t
</a> *mimeFileType (
<br>
535 <a href=
"#mime_t">mime_t
</a> *mime,
<br>
536 <a href=
"#const">const
</a> char *pathname,
<br>
537 <a href=
"#const">const
</a> char *filename,
<br>
538 int *compression
<br>
540 <h4 class=
"parameters">Parameters
</h4>
543 <dd class=
"description">MIME database
</dd>
545 <dd class=
"description">Name of file to check on disk
</dd>
547 <dd class=
"description">Original filename or NULL
</dd>
549 <dd class=
"description">Is the file compressed?
</dd>
551 <h4 class=
"returnvalue">Return Value
</h4>
552 <p class=
"description">Type of file
</p>
553 <h3 class=
"function"><a name=
"mimeFilter">mimeFilter
</a></h3>
554 <p class=
"description">Find the fastest way to convert from one type to another.
</p>
556 cups_array_t *mimeFilter (
<br>
557 <a href=
"#mime_t">mime_t
</a> *mime,
<br>
558 <a href=
"#mime_type_t">mime_type_t
</a> *src,
<br>
559 <a href=
"#mime_type_t">mime_type_t
</a> *dst,
<br>
560 int *cost
<br>
562 <h4 class=
"parameters">Parameters
</h4>
565 <dd class=
"description">MIME database
</dd>
567 <dd class=
"description">Source file type
</dd>
569 <dd class=
"description">Destination file type
</dd>
571 <dd class=
"description">Cost of filters
</dd>
573 <h4 class=
"returnvalue">Return Value
</h4>
574 <p class=
"description">Array of filters to run
</p>
575 <h3 class=
"function"><a name=
"mimeFilter2">mimeFilter2
</a></h3>
576 <p class=
"description">Find the fastest way to convert from one type to another,
577 including file size.
</p>
579 cups_array_t *mimeFilter2 (
<br>
580 <a href=
"#mime_t">mime_t
</a> *mime,
<br>
581 <a href=
"#mime_type_t">mime_type_t
</a> *src,
<br>
582 size_t srcsize,
<br>
583 <a href=
"#mime_type_t">mime_type_t
</a> *dst,
<br>
584 int *cost
<br>
586 <h4 class=
"parameters">Parameters
</h4>
589 <dd class=
"description">MIME database
</dd>
591 <dd class=
"description">Source file type
</dd>
593 <dd class=
"description">Size of source file
</dd>
595 <dd class=
"description">Destination file type
</dd>
597 <dd class=
"description">Cost of filters
</dd>
599 <h4 class=
"returnvalue">Return Value
</h4>
600 <p class=
"description">Array of filters to run
</p>
601 <h3 class=
"function"><a name=
"mimeFilterLookup">mimeFilterLookup
</a></h3>
602 <p class=
"description">Lookup a filter.
</p>
604 <a href=
"#mime_filter_t">mime_filter_t
</a> *mimeFilterLookup (
<br>
605 <a href=
"#mime_t">mime_t
</a> *mime,
<br>
606 <a href=
"#mime_type_t">mime_type_t
</a> *src,
<br>
607 <a href=
"#mime_type_t">mime_type_t
</a> *dst
<br>
609 <h4 class=
"parameters">Parameters
</h4>
612 <dd class=
"description">MIME database
</dd>
614 <dd class=
"description">Source type
</dd>
616 <dd class=
"description">Destination type
</dd>
618 <h4 class=
"returnvalue">Return Value
</h4>
619 <p class=
"description">Filter for src-
>dst
</p>
620 <h3 class=
"function"><a name=
"mimeFirstFilter">mimeFirstFilter
</a></h3>
621 <p class=
"description">Get the first filter in the MIME database.
</p>
623 <a href=
"#mime_filter_t">mime_filter_t
</a> *mimeFirstFilter (
<br>
624 <a href=
"#mime_t">mime_t
</a> *mime
<br>
626 <h4 class=
"parameters">Parameters
</h4>
629 <dd class=
"description">MIME database
</dd>
631 <h4 class=
"returnvalue">Return Value
</h4>
632 <p class=
"description">Filter or NULL
</p>
633 <h3 class=
"function"><a name=
"mimeFirstType">mimeFirstType
</a></h3>
634 <p class=
"description">Get the first type in the MIME database.
</p>
636 <a href=
"#mime_type_t">mime_type_t
</a> *mimeFirstType (
<br>
637 <a href=
"#mime_t">mime_t
</a> *mime
<br>
639 <h4 class=
"parameters">Parameters
</h4>
642 <dd class=
"description">MIME database
</dd>
644 <h4 class=
"returnvalue">Return Value
</h4>
645 <p class=
"description">Type or NULL
</p>
646 <h3 class=
"function"><a name=
"mimeLoad">mimeLoad
</a></h3>
647 <p class=
"description">Create a new MIME database from disk.
</p>
649 <a href=
"#mime_t">mime_t
</a> *mimeLoad (
<br>
650 <a href=
"#const">const
</a> char *pathname,
<br>
651 <a href=
"#const">const
</a> char *filterpath
<br>
653 <h4 class=
"parameters">Parameters
</h4>
656 <dd class=
"description">Directory to load
</dd>
658 <dd class=
"description">Directory to load
</dd>
660 <h4 class=
"returnvalue">Return Value
</h4>
661 <p class=
"description">New MIME database
</p>
662 <h4 class=
"discussion">Discussion
</h4>
663 <p class=
"discussion">This function uses
<a href=
"#mimeLoadFilters"><code>mimeLoadFilters
</code></a> and
<a href=
"#mimeLoadTypes"><code>mimeLoadTypes
</code></a> to
664 create a MIME database from a single directory.
</p>
665 <h3 class=
"function"><a name=
"mimeLoadFilters">mimeLoadFilters
</a></h3>
666 <p class=
"description">Load filter definitions from disk.
</p>
668 <a href=
"#mime_t">mime_t
</a> *mimeLoadFilters (
<br>
669 <a href=
"#mime_t">mime_t
</a> *mime,
<br>
670 <a href=
"#const">const
</a> char *pathname,
<br>
671 <a href=
"#const">const
</a> char *filterpath
<br>
673 <h4 class=
"parameters">Parameters
</h4>
676 <dd class=
"description">MIME database
</dd>
678 <dd class=
"description">Directory to load from
</dd>
680 <dd class=
"description">Default filter program directory
</dd>
682 <h4 class=
"returnvalue">Return Value
</h4>
683 <p class=
"description">MIME database
</p>
684 <h4 class=
"discussion">Discussion
</h4>
685 <p class=
"discussion">This function loads all of the .convs files from the specified directory.
686 Use
<a href=
"#mimeLoadTypes"><code>mimeLoadTypes
</code></a> to load all types before you load the filters.
</p>
687 <h3 class=
"function"><a name=
"mimeLoadTypes">mimeLoadTypes
</a></h3>
688 <p class=
"description">Load type definitions from disk.
</p>
690 <a href=
"#mime_t">mime_t
</a> *mimeLoadTypes (
<br>
691 <a href=
"#mime_t">mime_t
</a> *mime,
<br>
692 <a href=
"#const">const
</a> char *pathname
<br>
694 <h4 class=
"parameters">Parameters
</h4>
697 <dd class=
"description">MIME database or
<code>NULL
</code> to create a new one
</dd>
699 <dd class=
"description">Directory to load from
</dd>
701 <h4 class=
"returnvalue">Return Value
</h4>
702 <p class=
"description">MIME database
</p>
703 <h4 class=
"discussion">Discussion
</h4>
704 <p class=
"discussion">This function loads all of the .types files from the specified directory.
705 Use
<a href=
"#mimeLoadFilters"><code>mimeLoadFilters
</code></a> to load all filters after you load the types.
</p>
706 <h3 class=
"function"><a name=
"mimeNew">mimeNew
</a></h3>
707 <p class=
"description">Create a new, empty MIME database.
</p>
709 <a href=
"#mime_t">mime_t
</a> *mimeNew (void);
</p>
710 <h4 class=
"returnvalue">Return Value
</h4>
711 <p class=
"description">MIME database
</p>
712 <h3 class=
"function"><a name=
"mimeNextFilter">mimeNextFilter
</a></h3>
713 <p class=
"description">Get the next filter in the MIME database.
</p>
715 <a href=
"#mime_filter_t">mime_filter_t
</a> *mimeNextFilter (
<br>
716 <a href=
"#mime_t">mime_t
</a> *mime
<br>
718 <h4 class=
"parameters">Parameters
</h4>
721 <dd class=
"description">MIME database
</dd>
723 <h4 class=
"returnvalue">Return Value
</h4>
724 <p class=
"description">Filter or NULL
</p>
725 <h3 class=
"function"><a name=
"mimeNextType">mimeNextType
</a></h3>
726 <p class=
"description">Get the next type in the MIME database.
</p>
728 <a href=
"#mime_type_t">mime_type_t
</a> *mimeNextType (
<br>
729 <a href=
"#mime_t">mime_t
</a> *mime
<br>
731 <h4 class=
"parameters">Parameters
</h4>
734 <dd class=
"description">MIME database
</dd>
736 <h4 class=
"returnvalue">Return Value
</h4>
737 <p class=
"description">Type or NULL
</p>
738 <h3 class=
"function"><a name=
"mimeNumFilters">mimeNumFilters
</a></h3>
739 <p class=
"description">Next type
</p>
741 int mimeNumFilters (
<br>
742 <a href=
"#mime_t">mime_t
</a> *mime
<br>
744 <h4 class=
"parameters">Parameters
</h4>
747 <dd class=
"description">MIME database
</dd>
749 <h4 class=
"returnvalue">Return Value
</h4>
750 <p class=
"description">Get the number of filters in a MIME database.
</p>
751 <h3 class=
"function"><a name=
"mimeNumTypes">mimeNumTypes
</a></h3>
752 <p class=
"description">MIME database
</p>
754 int mimeNumTypes (
<br>
755 <a href=
"#mime_t">mime_t
</a> *mime
<br>
757 <h4 class=
"parameters">Parameters
</h4>
760 <dd class=
"description">MIME database
</dd>
762 <h4 class=
"returnvalue">Return Value
</h4>
763 <p class=
"description">Get the number of types in a MIME database.
</p>
764 <h3 class=
"function"><a name=
"mimeSetErrorCallback">mimeSetErrorCallback
</a></h3>
765 <p class=
"description">Set the callback for error messages.
</p>
767 void mimeSetErrorCallback (
<br>
768 <a href=
"#mime_t">mime_t
</a> *mime,
<br>
769 mime_error_cb_t cb,
<br>
770 void *ctx
<br>
772 <h4 class=
"parameters">Parameters
</h4>
775 <dd class=
"description">MIME database
</dd>
777 <dd class=
"description">Callback function
</dd>
779 <dd class=
"description">Context pointer for callback
</dd>
781 <h3 class=
"function"><a name=
"mimeType">mimeType
</a></h3>
782 <p class=
"description">Lookup a file type.
</p>
784 <a href=
"#mime_type_t">mime_type_t
</a> *mimeType (
<br>
785 <a href=
"#mime_t">mime_t
</a> *mime,
<br>
786 <a href=
"#const">const
</a> char *super,
<br>
787 <a href=
"#const">const
</a> char *type
<br>
789 <h4 class=
"parameters">Parameters
</h4>
792 <dd class=
"description">MIME database
</dd>
794 <dd class=
"description">Super-type name
</dd>
796 <dd class=
"description">Type name
</dd>
798 <h4 class=
"returnvalue">Return Value
</h4>
799 <p class=
"description">Matching file type definition
</p>
800 <h2 class=
"title"><a name=
"TYPES">Data Types
</a></h2>
801 <h3 class=
"typedef"><a name=
"const">const
</a></h3>
802 <p class=
"description">MIME Database
</p>
804 typedef void (*constmime_error_cb_t)(void *;
806 <h3 class=
"typedef"><a name=
"mime_filter_t">mime_filter_t
</a></h3>
807 <p class=
"description">MIME Conversion Filter Data
</p>
809 typedef struct _mime_filter_s mime_filter_t;
811 <h3 class=
"typedef"><a name=
"mime_magic_t">mime_magic_t
</a></h3>
812 <p class=
"description">MIME Magic Data
</p>
814 typedef struct _mime_magic_s mime_magic_t;
816 <h3 class=
"typedef"><a name=
"mime_op_t">mime_op_t
</a></h3>
817 <p class=
"description">Types/structures...
</p>
819 typedef enum mime_op_t;
821 <h3 class=
"typedef"><a name=
"mime_t">mime_t
</a></h3>
822 <p class=
"description">MIME Database
</p>
824 typedef struct _mime_s mime_t;
826 <h3 class=
"typedef"><a name=
"mime_type_t">mime_type_t
</a></h3>
827 <p class=
"description">MIME Type Data
</p>
829 typedef struct _mime_type_s mime_type_t;