]> 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 5771 2006-07-20 18:06:20Z mike $"
3 *
4 * MIME type/conversion database definitions for the Common UNIX Printing System (CUPS).
5 *
6 * Copyright 1997-2006 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/array.h>
29 # include <cups/ipp.h>
30 # include <cups/file.h>
31
32
33 /*
34 * C++ magic...
35 */
36
37 # ifdef __cplusplus
38 extern "C" {
39 # endif /* __cplusplus */
40
41
42 /*
43 * Constants...
44 */
45
46 # define MIME_MAX_SUPER 16 /* Maximum size of supertype name */
47 # define MIME_MAX_TYPE IPP_MAX_NAME /* Maximum size of type name */
48 # define MIME_MAX_FILTER 256 /* Maximum size of filter pathname */
49 # define MIME_MAX_BUFFER 4096 /* Maximum size of file buffer */
50
51
52 /*
53 * Types/structures...
54 */
55
56 typedef enum
57 {
58 MIME_MAGIC_NOP, /* No operation */
59 MIME_MAGIC_AND, /* Logical AND of all children */
60 MIME_MAGIC_OR, /* Logical OR of all children */
61 MIME_MAGIC_MATCH, /* Filename match */
62 MIME_MAGIC_ASCII, /* ASCII characters in range */
63 MIME_MAGIC_PRINTABLE, /* Printable characters (32-255) in range */
64 MIME_MAGIC_STRING, /* String matches */
65 MIME_MAGIC_CHAR, /* Character/byte matches */
66 MIME_MAGIC_SHORT, /* Short/16-bit word matches */
67 MIME_MAGIC_INT, /* Integer/32-bit word matches */
68 MIME_MAGIC_LOCALE, /* Current locale matches string */
69 MIME_MAGIC_CONTAINS, /* File contains a string */
70 MIME_MAGIC_ISTRING /* Case-insensitive string matches */
71 } mime_op_t;
72
73 typedef struct _mime_magic_s /**** MIME Magic Data ****/
74 {
75 struct _mime_magic_s *prev, /* Previous rule */
76 *next, /* Next rule */
77 *parent, /* Parent rules */
78 *child; /* Child rules */
79 short op, /* Operation code (see above) */
80 invert; /* Invert the result */
81 int offset, /* Offset in file */
82 region, /* Region length */
83 length; /* Length of data */
84 union
85 {
86 char matchv[64]; /* Match value */
87 char localev[64]; /* Locale value */
88 char stringv[64]; /* String value */
89 char charv; /* Byte value */
90 short shortv; /* Short value */
91 int intv; /* Integer value */
92 } value;
93 } mime_magic_t;
94
95 typedef struct _mime_type_s /**** MIME Type Data ****/
96 {
97 mime_magic_t *rules; /* Rules used to detect this type */
98 char super[MIME_MAX_SUPER], /* Super-type name ("image", "application", etc.) */
99 type[MIME_MAX_TYPE]; /* Type name ("png", "postscript", etc.) */
100 } mime_type_t;
101
102 typedef struct _mime_filter_s /**** MIME Conversion Filter Data ****/
103 {
104 mime_type_t *src, /* Source type */
105 *dst; /* Destination type */
106 int cost; /* Relative cost */
107 char filter[MIME_MAX_FILTER];/* Filter program to use */
108 } mime_filter_t;
109
110 typedef struct _mime_s /**** MIME Database ****/
111 {
112 cups_array_t *types; /* File types */
113 cups_array_t *filters; /* Type conversion filters */
114 cups_array_t *srcs; /* Filters sorted by source type */
115 } mime_t;
116
117
118 /*
119 * Functions...
120 */
121
122 extern void mimeDelete(mime_t *mime);
123 extern mime_t *mimeLoad(const char *pathname, const char *filterpath);
124 extern mime_t *mimeMerge(mime_t *mime, const char *pathname,
125 const char *filterpath);
126 extern mime_t *mimeNew(void);
127
128 extern mime_type_t *mimeAddType(mime_t *mime, const char *super,
129 const char *type);
130 extern int mimeAddTypeRule(mime_type_t *mt, const char *rule);
131 extern void mimeDeleteType(mime_t *mime, mime_type_t *mt);
132 extern mime_type_t *mimeFileType(mime_t *mime, const char *pathname,
133 const char *filename, int *compression);
134 extern mime_type_t *mimeFirstType(mime_t *mime);
135 extern mime_type_t *mimeNextType(mime_t *mime);
136 extern int mimeNumTypes(mime_t *mime);
137 extern mime_type_t *mimeType(mime_t *mime, const char *super,
138 const char *type);
139
140 extern mime_filter_t *mimeAddFilter(mime_t *mime, mime_type_t *src,
141 mime_type_t *dst, int cost,
142 const char *filter);
143 extern void mimeDeleteFilter(mime_t *mime, mime_filter_t *filter);
144 extern cups_array_t *mimeFilter(mime_t *mime, mime_type_t *src,
145 mime_type_t *dst, int *cost);
146 extern mime_filter_t *mimeFirstFilter(mime_t *mime);
147 extern mime_filter_t *mimeNextFilter(mime_t *mime);
148 extern int mimeNumFilters(mime_t *mime);
149
150 # ifdef __cplusplus
151 }
152 # endif /* __cplusplus */
153 #endif /* !_CUPS_MIME_H_ */
154
155 /*
156 * End of "$Id: mime.h 5771 2006-07-20 18:06:20Z mike $".
157 */