]> git.ipfire.org Git - thirdparty/cups.git/blob - scheduler/mime.h
Load cups into easysw/current.
[thirdparty/cups.git] / scheduler / mime.h
1 /*
2 * "$Id: mime.h 4613 2005-08-30 12:41:48Z mike $"
3 *
4 * MIME type/conversion database definitions for the Common UNIX Printing System (CUPS).
5 *
6 * Copyright 1997-2005 by Easy Software Products, all rights reserved.
7 *
8 * These coded instructions, statements, and computer programs are the
9 * property of Easy Software Products and are protected by Federal
10 * copyright law. Distribution and use rights are outlined in the file
11 * "LICENSE.txt" which should have been included with this file. If this
12 * file is missing or damaged please contact Easy Software Products
13 * at:
14 *
15 * Attn: CUPS Licensing Information
16 * Easy Software Products
17 * 44141 Airport View Drive, Suite 204
18 * Hollywood, Maryland 20636 USA
19 *
20 * Voice: (301) 373-9600
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
23 */
24
25 #ifndef _CUPS_MIME_H_
26 # define _CUPS_MIME_H_
27
28 # include <cups/ipp.h>
29 # include <cups/file.h>
30
31
32 /*
33 * C++ magic...
34 */
35
36 # ifdef _cplusplus
37 extern "C" {
38 # endif /* _cplusplus */
39
40
41 /*
42 * Constants...
43 */
44
45 # define MIME_MAX_SUPER 16 /* Maximum size of supertype name */
46 # define MIME_MAX_TYPE IPP_MAX_NAME /* Maximum size of type name */
47 # define MIME_MAX_FILTER 256 /* Maximum size of filter pathname */
48 # define MIME_MAX_BUFFER 8192 /* Maximum size of file buffer */
49
50
51 /*
52 * Types/structures...
53 */
54
55 typedef enum
56 {
57 MIME_MAGIC_NOP, /* No operation */
58 MIME_MAGIC_AND, /* Logical AND of all children */
59 MIME_MAGIC_OR, /* Logical OR of all children */
60 MIME_MAGIC_MATCH, /* Filename match */
61 MIME_MAGIC_ASCII, /* ASCII characters in range */
62 MIME_MAGIC_PRINTABLE, /* Printable characters (32-255) in range */
63 MIME_MAGIC_STRING, /* String matches */
64 MIME_MAGIC_CHAR, /* Character/byte matches */
65 MIME_MAGIC_SHORT, /* Short/16-bit word matches */
66 MIME_MAGIC_INT, /* Integer/32-bit word matches */
67 MIME_MAGIC_LOCALE, /* Current locale matches string */
68 MIME_MAGIC_CONTAINS, /* File contains a string */
69 MIME_MAGIC_ISTRING /* Case-insensitive string matches */
70 } mime_op_t;
71
72 typedef struct mime_magic_str /**** MIME Magic Data ****/
73 {
74 struct mime_magic_str *prev, /* Previous rule */
75 *next, /* Next rule */
76 *parent, /* Parent rules */
77 *child; /* Child rules */
78 short op, /* Operation code (see above) */
79 invert; /* Invert the result */
80 int offset, /* Offset in file */
81 region, /* Region length */
82 length; /* Length of data */
83 union
84 {
85 char matchv[64]; /* Match value */
86 char localev[64]; /* Locale value */
87 char stringv[64]; /* String value */
88 char charv; /* Byte value */
89 short shortv; /* Short value */
90 int intv; /* Integer value */
91 } value;
92 } mime_magic_t;
93
94 typedef struct /**** MIME Type Data ****/
95 {
96 char super[MIME_MAX_SUPER], /* Super-type name ("image", "application", etc.) */
97 *type; /* Type name ("png", "postscript", etc.) */
98 mime_magic_t *rules; /* Rules used to detect this type */
99 } mime_type_t;
100
101 typedef struct /**** MIME Conversion Filter Data ****/
102 {
103 mime_type_t *src, /* Source type */
104 *dst; /* Destination type */
105 int cost; /* Relative cost */
106 char filter[MIME_MAX_FILTER];/* Filter program to use */
107 } mime_filter_t;
108
109 typedef struct /**** MIME Database ****/
110 {
111 int num_types; /* Number of file types */
112 mime_type_t **types; /* File types */
113 int num_filters; /* Number of type conversion filters */
114 mime_filter_t *filters; /* Type conversion filters */
115 } mime_t;
116
117
118 /*
119 * Functions...
120 */
121
122 extern void mimeDelete(mime_t *mime);
123 #define mimeLoad(pathname,filterpath) \
124 mimeMerge((mime_t *)0, (pathname), (filterpath))
125 extern mime_t *mimeMerge(mime_t *mime, const char *pathname,
126 const char *filterpath);
127 extern mime_t *mimeNew(void);
128
129 extern mime_type_t *mimeAddType(mime_t *mime, const char *super, const char *type);
130 extern int mimeAddTypeRule(mime_type_t *mt, const char *rule);
131 extern mime_type_t *mimeFileType(mime_t *mime, const char *pathname,
132 int *compression);
133 extern mime_type_t *mimeType(mime_t *mime, const char *super, const char *type);
134
135 extern mime_filter_t *mimeAddFilter(mime_t *mime, mime_type_t *src, mime_type_t *dst,
136 int cost, const char *filter);
137 extern mime_filter_t *mimeFilter(mime_t *mime, mime_type_t *src, mime_type_t *dst,
138 int *num_filters, int max_depth);
139
140 # ifdef _cplusplus
141 }
142 # endif /* _cplusplus */
143 #endif /* !_CUPS_MIME_H_ */
144
145 /*
146 * End of "$Id: mime.h 4613 2005-08-30 12:41:48Z mike $".
147 */