xref: /titanic_50/usr/src/lib/libast/common/include/magic.h (revision 8cdd6a74847b5ae6ed26727528bdf6b139cf7552)
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  * Glenn Fowler
25  * AT&T Research
26  *
27  * magic interface definitions
28  */
29 
30 #ifndef _MAGIC_H
31 #define _MAGIC_H
32 
33 #include <sfio.h>
34 #include <ls.h>
35 
36 #define MAGIC_VERSION	19961031L
37 
38 #ifndef MAGIC_FILE
39 #define MAGIC_FILE	"lib/file/magic"
40 #endif
41 
42 #ifndef MAGIC_DIR
43 #define MAGIC_DIR	"lib/file"
44 #endif
45 
46 #define MAGIC_FILE_ENV	"MAGICFILE"
47 
48 #define MAGIC_MIME	(1<<0)		/* magictype returns MIME type	*/
49 #define MAGIC_VERBOSE	(1<<1)		/* verbose magic file errors	*/
50 
51 #define MAGIC_USER	(1L<<16)	/* first user flag bit		*/
52 
53 struct Magic_s;
54 struct Magicdisc_s;
55 
56 typedef struct Magicdisc_s
57 {
58 	unsigned long	version;	/* interface version		*/
59 	unsigned long	flags;		/* MAGIC_* flags		*/
60 	Error_f		errorf;		/* error function		*/
61 } Magicdisc_t;
62 
63 typedef struct Magic_s
64 {
65 	const char*	id;		/* library id string		*/
66 
67 #ifdef _MAGIC_PRIVATE_
68 	_MAGIC_PRIVATE_
69 #endif
70 
71 } Magic_t;
72 
73 #if _BLD_ast && defined(__EXPORT__)
74 #define extern		__EXPORT__
75 #endif
76 
77 extern Magic_t*		magicopen(Magicdisc_t*);
78 extern int		magicload(Magic_t*, const char*, unsigned long);
79 extern int		magiclist(Magic_t*, Sfio_t*);
80 extern char*		magictype(Magic_t*, Sfio_t*, const char*, struct stat*);
81 extern int		magicclose(Magic_t*);
82 
83 #undef	extern
84 
85 #endif
86