]> git.ipfire.org Git - thirdparty/cups.git/blame - scheduler/mime.h
Load cups into easysw/current.
[thirdparty/cups.git] / scheduler / mime.h
CommitLineData
ef416fc2 1/*
d09495fa 2 * "$Id: mime.h 5771 2006-07-20 18:06:20Z mike $"
ef416fc2 3 *
4 * MIME type/conversion database definitions for the Common UNIX Printing System (CUPS).
5 *
fa73b229 6 * Copyright 1997-2006 by Easy Software Products, all rights reserved.
ef416fc2 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
fa73b229 28# include <cups/array.h>
ef416fc2 29# include <cups/ipp.h>
30# include <cups/file.h>
31
32
33/*
34 * C++ magic...
35 */
36
d09495fa 37# ifdef __cplusplus
ef416fc2 38extern "C" {
d09495fa 39# endif /* __cplusplus */
ef416fc2 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 */
4400e98d 49# define MIME_MAX_BUFFER 4096 /* Maximum size of file buffer */
ef416fc2 50
51
52/*
53 * Types/structures...
54 */
55
56typedef 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
4400e98d 73typedef struct _mime_magic_s /**** MIME Magic Data ****/
ef416fc2 74{
bd7854cb 75 struct _mime_magic_s *prev, /* Previous rule */
ef416fc2 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
4400e98d 95typedef struct _mime_type_s /**** MIME Type Data ****/
ef416fc2 96{
ef416fc2 97 mime_magic_t *rules; /* Rules used to detect this type */
fa73b229 98 char super[MIME_MAX_SUPER], /* Super-type name ("image", "application", etc.) */
99 type[MIME_MAX_TYPE]; /* Type name ("png", "postscript", etc.) */
ef416fc2 100} mime_type_t;
101
4400e98d 102typedef struct _mime_filter_s /**** MIME Conversion Filter Data ****/
ef416fc2 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
4400e98d 110typedef struct _mime_s /**** MIME Database ****/
ef416fc2 111{
fa73b229 112 cups_array_t *types; /* File types */
113 cups_array_t *filters; /* Type conversion filters */
a74454a7 114 cups_array_t *srcs; /* Filters sorted by source type */
ef416fc2 115} mime_t;
116
117
118/*
119 * Functions...
120 */
121
122extern void mimeDelete(mime_t *mime);
fa73b229 123extern mime_t *mimeLoad(const char *pathname, const char *filterpath);
ef416fc2 124extern mime_t *mimeMerge(mime_t *mime, const char *pathname,
125 const char *filterpath);
126extern mime_t *mimeNew(void);
127
fa73b229 128extern mime_type_t *mimeAddType(mime_t *mime, const char *super,
129 const char *type);
ef416fc2 130extern int mimeAddTypeRule(mime_type_t *mt, const char *rule);
fa73b229 131extern void mimeDeleteType(mime_t *mime, mime_type_t *mt);
ef416fc2 132extern mime_type_t *mimeFileType(mime_t *mime, const char *pathname,
4400e98d 133 const char *filename, int *compression);
fa73b229 134extern mime_type_t *mimeFirstType(mime_t *mime);
135extern mime_type_t *mimeNextType(mime_t *mime);
136extern int mimeNumTypes(mime_t *mime);
137extern mime_type_t *mimeType(mime_t *mime, const char *super,
138 const char *type);
139
140extern mime_filter_t *mimeAddFilter(mime_t *mime, mime_type_t *src,
141 mime_type_t *dst, int cost,
142 const char *filter);
143extern void mimeDeleteFilter(mime_t *mime, mime_filter_t *filter);
144extern cups_array_t *mimeFilter(mime_t *mime, mime_type_t *src,
bd7854cb 145 mime_type_t *dst, int *cost);
fa73b229 146extern mime_filter_t *mimeFirstFilter(mime_t *mime);
147extern mime_filter_t *mimeNextFilter(mime_t *mime);
148extern int mimeNumFilters(mime_t *mime);
ef416fc2 149
d09495fa 150# ifdef __cplusplus
ef416fc2 151}
d09495fa 152# endif /* __cplusplus */
ef416fc2 153#endif /* !_CUPS_MIME_H_ */
154
155/*
d09495fa 156 * End of "$Id: mime.h 5771 2006-07-20 18:06:20Z mike $".
ef416fc2 157 */