1 /* 2 * BEGIN illumos section 3 * This is an unstable interface; changes may be made 4 * without notice. 5 * END illumos section 6 */ 7 /*********************************************************************** 8 * * 9 * This software is part of the ast package * 10 * Copyright (c) 1985-2011 AT&T Intellectual Property * 11 * and is licensed under the * 12 * Eclipse Public License, Version 1.0 * 13 * by AT&T Intellectual Property * 14 * * 15 * A copy of the License is available at * 16 * http://www.eclipse.org/org/documents/epl-v10.html * 17 * (with md5 checksum b35adb5213ca9657e911e9befb180842) * 18 * * 19 * Information and Software Systems Research * 20 * AT&T Research * 21 * Florham Park NJ * 22 * * 23 * Glenn Fowler <gsf@research.att.com> * 24 * David Korn <dgk@research.att.com> * 25 * Phong Vo <kpv@research.att.com> * 26 * * 27 ***********************************************************************/ 28 #pragma prototyped 29 /* 30 * Glenn Fowler 31 * AT&T Research 32 * 33 * magic interface definitions 34 */ 35 36 #ifndef _MAGIC_H 37 #define _MAGIC_H 38 39 #include <sfio.h> 40 #include <ls.h> 41 42 #define MAGIC_VERSION 19961031L 43 44 #ifndef MAGIC_FILE 45 #define MAGIC_FILE "lib/file/magic" 46 #endif 47 48 #ifndef MAGIC_DIR 49 #define MAGIC_DIR "lib/file" 50 #endif 51 52 #define MAGIC_FILE_ENV "MAGICFILE" 53 54 #define MAGIC_MIME (1<<0) /* magictype returns MIME type */ 55 #define MAGIC_VERBOSE (1<<1) /* verbose magic file errors */ 56 #define MAGIC_ALL (1<<2) /* list all table matches */ 57 58 #define MAGIC_USER (1L<<16) /* first user flag bit */ 59 60 struct Magic_s; 61 struct Magicdisc_s; 62 63 typedef struct Magicdisc_s 64 { 65 unsigned long version; /* interface version */ 66 unsigned long flags; /* MAGIC_* flags */ 67 Error_f errorf; /* error function */ 68 } Magicdisc_t; 69 70 typedef struct Magic_s 71 { 72 const char* id; /* library id string */ 73 74 #ifdef _MAGIC_PRIVATE_ 75 _MAGIC_PRIVATE_ 76 #endif 77 78 } Magic_t; 79 80 #if _BLD_ast && defined(__EXPORT__) 81 #define extern __EXPORT__ 82 #endif 83 84 extern Magic_t* magicopen(Magicdisc_t*); 85 extern int magicload(Magic_t*, const char*, unsigned long); 86 extern int magiclist(Magic_t*, Sfio_t*); 87 extern char* magictype(Magic_t*, Sfio_t*, const char*, struct stat*); 88 extern int magicclose(Magic_t*); 89 90 #undef extern 91 92 #endif 93