]> git.ipfire.org Git - thirdparty/cups.git/blame - scheduler/mime.h
Copyright update...
[thirdparty/cups.git] / scheduler / mime.h
CommitLineData
79df52e3 1/*
efb2f309 2 * "$Id: mime.h,v 1.4 2002/01/02 17:59:17 mike Exp $"
79df52e3 3 *
0b74af7d 4 * MIME type/conversion database definitions for the Common UNIX Printing System (CUPS).
79df52e3 5 *
efb2f309 6 * Copyright 1997-2002 by Easy Software Products, all rights reserved.
79df52e3 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
8784b6a6 17 * 44141 Airport View Drive, Suite 204
79df52e3 18 * Hollywood, Maryland 20636-3111 USA
19 *
20 * Voice: (301) 373-9603
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
79df52e3 23 */
24
0b74af7d 25#ifndef _MIME_H_
26# define _MIME_H_
27
0b74af7d 28/*
29 * C++ magic...
30 */
31
32# ifdef _cplusplus
33extern "C" {
34# endif /* _cplusplus */
35
36
37/*
38 * Constants...
39 */
40
41# define MIME_MAX_SUPER 16 /* Maximum size of supertype name */
42# define MIME_MAX_TYPE 32 /* Maximum size of type name */
43# define MIME_MAX_FILTER 256 /* Maximum size of filter pathname */
44# define MIME_MAX_BUFFER 8192 /* Maximum size of file buffer */
45
46
47/*
48 * Types/structures...
49 */
50
51typedef enum
52{
53 MIME_MAGIC_NOP, /* No operation */
54 MIME_MAGIC_AND, /* Logical AND of all children */
55 MIME_MAGIC_OR, /* Logical OR of all children */
56 MIME_MAGIC_MATCH, /* Filename match */
57 MIME_MAGIC_ASCII, /* ASCII characters in range */
58 MIME_MAGIC_PRINTABLE, /* Printable characters (32-255) in range */
59 MIME_MAGIC_STRING, /* String matches */
60 MIME_MAGIC_CHAR, /* Character/byte matches */
61 MIME_MAGIC_SHORT, /* Short/16-bit word matches */
62 MIME_MAGIC_INT, /* Integer/32-bit word matches */
3d9e2586 63 MIME_MAGIC_LOCALE, /* Current locale matches string */
64 MIME_MAGIC_CONTAINS /* File contains a string */
0b74af7d 65} mime_op_t;
66
67typedef struct mime_magic_str /**** MIME Magic Data ****/
68{
69 struct mime_magic_str *prev, /* Previous rule */
70 *next, /* Next rule */
71 *parent, /* Parent rules */
72 *child; /* Child rules */
73 short op, /* Operation code (see above) */
74 invert; /* Invert the result */
75 int offset, /* Offset in file */
3d9e2586 76 region, /* Region length */
0b74af7d 77 length; /* Length of data */
78 union
79 {
80 char matchv[64]; /* Match value */
81 char localev[64]; /* Locale value */
82 char stringv[64]; /* String value */
83 char charv; /* Byte value */
84 short shortv; /* Short value */
85 int intv; /* Integer value */
86 } value;
87} mime_magic_t;
88
89typedef struct /**** MIME Type Data ****/
90{
91 char super[MIME_MAX_SUPER], /* Super-type name ("image", "application", etc.) */
92 type[MIME_MAX_TYPE]; /* Type name ("png", "postscript", etc.) */
93 mime_magic_t *rules; /* Rules used to detect this type */
94} mime_type_t;
95
96typedef struct /**** MIME Conversion Filter Data ****/
97{
98 mime_type_t *src, /* Source type */
99 *dst; /* Destination type */
100 int cost; /* Relative cost */
101 char filter[MIME_MAX_FILTER];/* Filter program to use */
102} mime_filter_t;
103
104typedef struct /**** MIME Database ****/
105{
106 int num_types; /* Number of file types */
107 mime_type_t **types; /* File types */
108 int num_filters; /* Number of type conversion filters */
109 mime_filter_t *filters; /* Type conversion filters */
110} mime_t;
111
112
113/*
114 * Functions...
115 */
116
117extern void mimeDelete(mime_t *mime);
3b960317 118#define mimeLoad(pathname) mimeMerge((mime_t *)0, (pathname));
063e1ac7 119extern mime_t *mimeMerge(mime_t *mime, const char *pathname);
0b74af7d 120extern mime_t *mimeNew(void);
121
063e1ac7 122extern mime_type_t *mimeAddType(mime_t *mime, const char *super, const char *type);
123extern int mimeAddTypeRule(mime_type_t *mt, const char *rule);
124extern mime_type_t *mimeFileType(mime_t *mime, const char *pathname);
125extern mime_type_t *mimeType(mime_t *mime, const char *super, const char *type);
0b74af7d 126
127extern mime_filter_t *mimeAddFilter(mime_t *mime, mime_type_t *src, mime_type_t *dst,
063e1ac7 128 int cost, const char *filter);
0b74af7d 129extern mime_filter_t *mimeFilter(mime_t *mime, mime_type_t *src, mime_type_t *dst,
130 int *num_filters);
131
132# ifdef _cplusplus
133}
134# endif /* _cplusplus */
0b74af7d 135#endif /* !_MIME_H_ */
79df52e3 136
137/*
efb2f309 138 * End of "$Id: mime.h,v 1.4 2002/01/02 17:59:17 mike Exp $".
79df52e3 139 */