xref: /titanic_41/usr/src/lib/libast/common/include/mime.h (revision bbb1277b6ec1b0daad4e3ed1a2b891d3e2ece2eb)
1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *          Copyright (c) 1985-2009 AT&T Intellectual Property          *
5 *                      and is licensed under the                       *
6 *                  Common Public License, Version 1.0                  *
7 *                    by AT&T Intellectual Property                     *
8 *                                                                      *
9 *                A copy of the License is available at                 *
10 *            http://www.opensource.org/licenses/cpl1.0.txt             *
11 *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
12 *                                                                      *
13 *              Information and Software Systems Research               *
14 *                            AT&T Research                             *
15 *                           Florham Park NJ                            *
16 *                                                                      *
17 *                 Glenn Fowler <gsf@research.att.com>                  *
18 *                  David Korn <dgk@research.att.com>                   *
19 *                   Phong Vo <kpv@research.att.com>                    *
20 *                                                                      *
21 ***********************************************************************/
22 #pragma prototyped
23 
24 /*
25  * mime/mailcap interface
26  */
27 
28 #ifndef _MIMETYPE_H
29 #define _MIMETYPE_H	1
30 
31 #include <sfio.h>
32 #include <ls.h>
33 
34 #define MIME_VERSION	19970717L
35 
36 #ifndef MIME_FILES
37 #define MIME_FILES	"~/.mailcap:/usr/local/etc/mailcap:/usr/etc/mailcap:/etc/mailcap:/etc/mail/mailcap:/usr/public/lib/mailcap"
38 #endif
39 
40 #define MIME_FILES_ENV	"MAILCAP"
41 
42 #define MIME_LIST	(1<<0)		/* mimeload arg is : list	*/
43 #define MIME_NOMAGIC	(1<<1)		/* no magic for mimetype()	*/
44 #define MIME_PIPE	(1<<2)		/* mimeview() io is piped	*/
45 #define MIME_REPLACE	(1<<3)		/* replace existing definition	*/
46 
47 #define MIME_USER	(1L<<16)	/* first user flag bit		*/
48 
49 struct Mime_s;
50 typedef struct Mime_s Mime_t;
51 
52 struct Mimedisc_s;
53 typedef struct Mimedisc_s Mimedisc_t;
54 
55 typedef int (*Mimevalue_f)(Mime_t*, void*, char*, size_t, Mimedisc_t*);
56 
57 struct Mimedisc_s
58 {
59 	unsigned long	version;	/* interface version		*/
60 	unsigned long	flags;		/* MIME_* flags			*/
61 	Error_f		errorf;		/* error function		*/
62 	Mimevalue_f	valuef;		/* value extraction function	*/
63 };
64 
65 struct Mime_s
66 {
67 	const char*	id;		/* library id string		*/
68 
69 #ifdef _MIME_PRIVATE_
70 	_MIME_PRIVATE_
71 #endif
72 
73 };
74 
75 #if _BLD_ast && defined(__EXPORT__)
76 #define extern		__EXPORT__
77 #endif
78 
79 extern Mime_t*	mimeopen(Mimedisc_t*);
80 extern int	mimeload(Mime_t*, const char*, unsigned long);
81 extern int	mimelist(Mime_t*, Sfio_t*, const char*);
82 extern int	mimeclose(Mime_t*);
83 extern int	mimeset(Mime_t*, char*, unsigned long);
84 extern char*	mimetype(Mime_t*, Sfio_t*, const char*, struct stat*);
85 extern char*	mimeview(Mime_t*, const char*, const char*, const char*, const char*);
86 extern int	mimehead(Mime_t*, void*, size_t, size_t, char*);
87 extern int	mimecmp(const char*, const char*, char**);
88 
89 #undef	extern
90 
91 #endif
92