]>
Commit | Line | Data |
---|---|---|
ef416fc2 | 1 | /* |
4400e98d | 2 | * "$Id: mime.h 5058 2006-02-02 21:58:45Z 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 | ||
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 */ | |
4400e98d | 49 | # define MIME_MAX_BUFFER 4096 /* Maximum size of file buffer */ |
ef416fc2 | 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 | ||
4400e98d | 73 | typedef struct _mime_magic_s /**** MIME Magic Data ****/ |
ef416fc2 | 74 | { |
75 | struct mime_magic_str *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 | ||
4400e98d | 95 | typedef 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 | 102 | typedef 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 | 110 | typedef struct _mime_s /**** MIME Database ****/ |
ef416fc2 | 111 | { |
fa73b229 | 112 | cups_array_t *types; /* File types */ |
113 | cups_array_t *filters; /* Type conversion filters */ | |
ef416fc2 | 114 | } mime_t; |
115 | ||
116 | ||
117 | /* | |
118 | * Functions... | |
119 | */ | |
120 | ||
121 | extern void mimeDelete(mime_t *mime); | |
fa73b229 | 122 | extern mime_t *mimeLoad(const char *pathname, const char *filterpath); |
ef416fc2 | 123 | extern mime_t *mimeMerge(mime_t *mime, const char *pathname, |
124 | const char *filterpath); | |
125 | extern mime_t *mimeNew(void); | |
126 | ||
fa73b229 | 127 | extern mime_type_t *mimeAddType(mime_t *mime, const char *super, |
128 | const char *type); | |
ef416fc2 | 129 | extern int mimeAddTypeRule(mime_type_t *mt, const char *rule); |
fa73b229 | 130 | extern void mimeDeleteType(mime_t *mime, mime_type_t *mt); |
ef416fc2 | 131 | extern mime_type_t *mimeFileType(mime_t *mime, const char *pathname, |
4400e98d | 132 | const char *filename, int *compression); |
fa73b229 | 133 | extern mime_type_t *mimeFirstType(mime_t *mime); |
134 | extern mime_type_t *mimeNextType(mime_t *mime); | |
135 | extern int mimeNumTypes(mime_t *mime); | |
136 | extern mime_type_t *mimeType(mime_t *mime, const char *super, | |
137 | const char *type); | |
138 | ||
139 | extern mime_filter_t *mimeAddFilter(mime_t *mime, mime_type_t *src, | |
140 | mime_type_t *dst, int cost, | |
141 | const char *filter); | |
142 | extern void mimeDeleteFilter(mime_t *mime, mime_filter_t *filter); | |
143 | extern cups_array_t *mimeFilter(mime_t *mime, mime_type_t *src, | |
144 | mime_type_t *dst, int *cost, int max_depth); | |
145 | extern mime_filter_t *mimeFirstFilter(mime_t *mime); | |
146 | extern mime_filter_t *mimeNextFilter(mime_t *mime); | |
147 | extern int mimeNumFilters(mime_t *mime); | |
ef416fc2 | 148 | |
149 | # ifdef _cplusplus | |
150 | } | |
151 | # endif /* _cplusplus */ | |
152 | #endif /* !_CUPS_MIME_H_ */ | |
153 | ||
154 | /* | |
4400e98d | 155 | * End of "$Id: mime.h 5058 2006-02-02 21:58:45Z mike $". |
ef416fc2 | 156 | */ |