]>
Commit | Line | Data |
---|---|---|
ef416fc2 | 1 | /* |
75bd9771 | 2 | * "$Id: mime.h 7694 2008-06-26 00:23:20Z mike $" |
ef416fc2 | 3 | * |
4 | * MIME type/conversion database definitions for the Common UNIX Printing System (CUPS). | |
5 | * | |
dd1abb6b | 6 | * Copyright 2007-2008 by Apple Inc. |
f7deaa1a | 7 | * Copyright 1997-2007 by Easy Software Products, all rights reserved. |
ef416fc2 | 8 | * |
9 | * These coded instructions, statements, and computer programs are the | |
bc44d920 | 10 | * property of Apple Inc. and are protected by Federal copyright |
11 | * law. Distribution and use rights are outlined in the file "LICENSE.txt" | |
12 | * which should have been included with this file. If this file is | |
13 | * file is missing or damaged, see the license at "http://www.cups.org/". | |
ef416fc2 | 14 | */ |
15 | ||
16 | #ifndef _CUPS_MIME_H_ | |
17 | # define _CUPS_MIME_H_ | |
18 | ||
fa73b229 | 19 | # include <cups/array.h> |
ef416fc2 | 20 | # include <cups/ipp.h> |
21 | # include <cups/file.h> | |
22 | ||
23 | ||
24 | /* | |
25 | * C++ magic... | |
26 | */ | |
27 | ||
d09495fa | 28 | # ifdef __cplusplus |
ef416fc2 | 29 | extern "C" { |
d09495fa | 30 | # endif /* __cplusplus */ |
ef416fc2 | 31 | |
32 | ||
33 | /* | |
34 | * Constants... | |
35 | */ | |
36 | ||
37 | # define MIME_MAX_SUPER 16 /* Maximum size of supertype name */ | |
38 | # define MIME_MAX_TYPE IPP_MAX_NAME /* Maximum size of type name */ | |
39 | # define MIME_MAX_FILTER 256 /* Maximum size of filter pathname */ | |
4400e98d | 40 | # define MIME_MAX_BUFFER 4096 /* Maximum size of file buffer */ |
ef416fc2 | 41 | |
42 | ||
43 | /* | |
44 | * Types/structures... | |
45 | */ | |
46 | ||
47 | typedef enum | |
48 | { | |
49 | MIME_MAGIC_NOP, /* No operation */ | |
50 | MIME_MAGIC_AND, /* Logical AND of all children */ | |
51 | MIME_MAGIC_OR, /* Logical OR of all children */ | |
52 | MIME_MAGIC_MATCH, /* Filename match */ | |
53 | MIME_MAGIC_ASCII, /* ASCII characters in range */ | |
54 | MIME_MAGIC_PRINTABLE, /* Printable characters (32-255) in range */ | |
55 | MIME_MAGIC_STRING, /* String matches */ | |
56 | MIME_MAGIC_CHAR, /* Character/byte matches */ | |
57 | MIME_MAGIC_SHORT, /* Short/16-bit word matches */ | |
58 | MIME_MAGIC_INT, /* Integer/32-bit word matches */ | |
59 | MIME_MAGIC_LOCALE, /* Current locale matches string */ | |
60 | MIME_MAGIC_CONTAINS, /* File contains a string */ | |
61 | MIME_MAGIC_ISTRING /* Case-insensitive string matches */ | |
62 | } mime_op_t; | |
63 | ||
4400e98d | 64 | typedef struct _mime_magic_s /**** MIME Magic Data ****/ |
ef416fc2 | 65 | { |
bd7854cb | 66 | struct _mime_magic_s *prev, /* Previous rule */ |
ef416fc2 | 67 | *next, /* Next rule */ |
68 | *parent, /* Parent rules */ | |
69 | *child; /* Child rules */ | |
70 | short op, /* Operation code (see above) */ | |
71 | invert; /* Invert the result */ | |
72 | int offset, /* Offset in file */ | |
73 | region, /* Region length */ | |
74 | length; /* Length of data */ | |
75 | union | |
76 | { | |
77 | char matchv[64]; /* Match value */ | |
78 | char localev[64]; /* Locale value */ | |
79 | char stringv[64]; /* String value */ | |
80 | char charv; /* Byte value */ | |
81 | short shortv; /* Short value */ | |
82 | int intv; /* Integer value */ | |
83 | } value; | |
84 | } mime_magic_t; | |
85 | ||
4400e98d | 86 | typedef struct _mime_type_s /**** MIME Type Data ****/ |
ef416fc2 | 87 | { |
ef416fc2 | 88 | mime_magic_t *rules; /* Rules used to detect this type */ |
dd1abb6b | 89 | int priority; /* Priority of this type */ |
fa73b229 | 90 | char super[MIME_MAX_SUPER], /* Super-type name ("image", "application", etc.) */ |
91 | type[MIME_MAX_TYPE]; /* Type name ("png", "postscript", etc.) */ | |
ef416fc2 | 92 | } mime_type_t; |
93 | ||
4400e98d | 94 | typedef struct _mime_filter_s /**** MIME Conversion Filter Data ****/ |
ef416fc2 | 95 | { |
96 | mime_type_t *src, /* Source type */ | |
97 | *dst; /* Destination type */ | |
98 | int cost; /* Relative cost */ | |
99 | char filter[MIME_MAX_FILTER];/* Filter program to use */ | |
100 | } mime_filter_t; | |
101 | ||
4400e98d | 102 | typedef struct _mime_s /**** MIME Database ****/ |
ef416fc2 | 103 | { |
fa73b229 | 104 | cups_array_t *types; /* File types */ |
105 | cups_array_t *filters; /* Type conversion filters */ | |
a74454a7 | 106 | cups_array_t *srcs; /* Filters sorted by source type */ |
ef416fc2 | 107 | } mime_t; |
108 | ||
109 | ||
110 | /* | |
111 | * Functions... | |
112 | */ | |
113 | ||
114 | extern void mimeDelete(mime_t *mime); | |
fa73b229 | 115 | extern mime_t *mimeLoad(const char *pathname, const char *filterpath); |
75bd9771 MS |
116 | extern mime_t *mimeLoadFilters(mime_t *mime, const char *pathname, |
117 | const char *filterpath); | |
118 | extern mime_t *mimeLoadTypes(mime_t *mime, const char *pathname); | |
ef416fc2 | 119 | |
fa73b229 | 120 | extern mime_type_t *mimeAddType(mime_t *mime, const char *super, |
121 | const char *type); | |
ef416fc2 | 122 | extern int mimeAddTypeRule(mime_type_t *mt, const char *rule); |
fa73b229 | 123 | extern void mimeDeleteType(mime_t *mime, mime_type_t *mt); |
ef416fc2 | 124 | extern mime_type_t *mimeFileType(mime_t *mime, const char *pathname, |
4400e98d | 125 | const char *filename, int *compression); |
fa73b229 | 126 | extern mime_type_t *mimeFirstType(mime_t *mime); |
127 | extern mime_type_t *mimeNextType(mime_t *mime); | |
128 | extern int mimeNumTypes(mime_t *mime); | |
129 | extern mime_type_t *mimeType(mime_t *mime, const char *super, | |
130 | const char *type); | |
131 | ||
132 | extern mime_filter_t *mimeAddFilter(mime_t *mime, mime_type_t *src, | |
133 | mime_type_t *dst, int cost, | |
134 | const char *filter); | |
135 | extern void mimeDeleteFilter(mime_t *mime, mime_filter_t *filter); | |
136 | extern cups_array_t *mimeFilter(mime_t *mime, mime_type_t *src, | |
bd7854cb | 137 | mime_type_t *dst, int *cost); |
f7deaa1a | 138 | extern mime_filter_t *mimeFilterLookup(mime_t *mime, mime_type_t *src, |
139 | mime_type_t *dst); | |
fa73b229 | 140 | extern mime_filter_t *mimeFirstFilter(mime_t *mime); |
141 | extern mime_filter_t *mimeNextFilter(mime_t *mime); | |
142 | extern int mimeNumFilters(mime_t *mime); | |
ef416fc2 | 143 | |
d09495fa | 144 | # ifdef __cplusplus |
ef416fc2 | 145 | } |
d09495fa | 146 | # endif /* __cplusplus */ |
ef416fc2 | 147 | #endif /* !_CUPS_MIME_H_ */ |
148 | ||
149 | /* | |
75bd9771 | 150 | * End of "$Id: mime.h 7694 2008-06-26 00:23:20Z mike $". |
ef416fc2 | 151 | */ |