1 /*********************************************************************** 2 * * 3 * This software is part of the ast package * 4 * Copyright (c) 1985-2011 AT&T Intellectual Property * 5 * and is licensed under the * 6 * Eclipse Public License, Version 1.0 * 7 * by AT&T Intellectual Property * 8 * * 9 * A copy of the License is available at * 10 * http://www.eclipse.org/org/documents/epl-v10.html * 11 * (with md5 checksum b35adb5213ca9657e911e9befb180842) * 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 #define MAGIC_ALL (1<<2) /* list all table matches */ 51 52 #define MAGIC_USER (1L<<16) /* first user flag bit */ 53 54 struct Magic_s; 55 struct Magicdisc_s; 56 57 typedef struct Magicdisc_s 58 { 59 unsigned long version; /* interface version */ 60 unsigned long flags; /* MAGIC_* flags */ 61 Error_f errorf; /* error function */ 62 } Magicdisc_t; 63 64 typedef struct Magic_s 65 { 66 const char* id; /* library id string */ 67 68 #ifdef _MAGIC_PRIVATE_ 69 _MAGIC_PRIVATE_ 70 #endif 71 72 } Magic_t; 73 74 #if _BLD_ast && defined(__EXPORT__) 75 #define extern __EXPORT__ 76 #endif 77 78 extern Magic_t* magicopen(Magicdisc_t*); 79 extern int magicload(Magic_t*, const char*, unsigned long); 80 extern int magiclist(Magic_t*, Sfio_t*); 81 extern char* magictype(Magic_t*, Sfio_t*, const char*, struct stat*); 82 extern int magicclose(Magic_t*); 83 84 #undef extern 85 86 #endif 87