about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-02-27 07:28:05 +0000
committerEric Wong <normalperson@yhbt.net>2011-02-27 07:37:25 +0000
commit2a7697fea8f0a427e0cd37f08b49480c749c8f6a (patch)
tree329166421fb2b2a2959ccc5853d891a28e3ea5c7
parent71bcc1cac1a687d8e7222e7cca52b5628ea896ff (diff)
downloadmahoro-2a7697fea8f0a427e0cd37f08b49480c749c8f6a.tar.gz
add missing constants I found in magic.h
-rw-r--r--mahoro.c93
1 files changed, 92 insertions, 1 deletions
diff --git a/mahoro.c b/mahoro.c
index 2a597ee..e9e5e91 100644
--- a/mahoro.c
+++ b/mahoro.c
@@ -162,19 +162,110 @@ void Init_mahoro(void)
         cMahoro      = rb_define_class("Mahoro", rb_cObject);
         eMahoroError = rb_define_class_under(cMahoro, "Error", rb_eStandardError);
 
+        /* No special handling, the default */
         rb_define_const(cMahoro, "NONE", INT2FIX(MAGIC_NONE));
+
+        /* print debugging messages to stderr */
         rb_define_const(cMahoro, "DEBUG", INT2FIX(MAGIC_DEBUG));
+
+        /* Follow symlinks */
         rb_define_const(cMahoro, "SYMLINK", INT2FIX(MAGIC_SYMLINK));
+
+        /* Check inside compressed files */
         rb_define_const(cMahoro, "COMPRESS", INT2FIX(MAGIC_COMPRESS));
+
+        /* Look at the contents of devices */
         rb_define_const(cMahoro, "DEVICES", INT2FIX(MAGIC_DEVICES));
-        rb_define_const(cMahoro, "MIME", INT2FIX(MAGIC_MIME));
+
+        /* Return only the MIME type */
+#ifdef MAGIC_MIME_TYPE
+        rb_define_const(cMahoro, "MIME_TYPE", INT2FIX(MAGIC_MIME_TYPE));
+#endif
+
+        /* Return all matches */
         rb_define_const(cMahoro, "CONTINUE", INT2FIX(MAGIC_CONTINUE));
+
+        /*
+         * Check the magic database for consistency and
+         * print warnings to stderr
+         */
         rb_define_const(cMahoro, "CHECK", INT2FIX(MAGIC_CHECK));
+
+        /* preserve access time of files analyzed */
         rb_define_const(cMahoro, "PRESERVE_ATIME",
                               INT2FIX(MAGIC_PRESERVE_ATIME));
+
+        /*
+         * Don't translate unprintable characters to a \\ooo octal
+         * representation
+         */
         rb_define_const(cMahoro, "RAW", INT2FIX(MAGIC_RAW));
+
+        /*
+         * Treat operating system errors while trying to open files
+         * and follow symlinks as real errors, instead of printing
+         * them in the magic buffer.
+         */
         rb_define_const(cMahoro, "ERROR", INT2FIX(MAGIC_ERROR));
 
+#ifdef MAGIC_MIME_ENCODING
+        /* return a MIME encoding, instead of a textual description. */
+        rb_define_const(cMahoro, "MIME_ENCODING", INT2FIX(MAGIC_MIME_ENCODING));
+#endif
+
+        /* return both MIME type and encoding */
+        rb_define_const(cMahoro, "MIME", INT2FIX(MAGIC_MIME));
+
+#ifdef MAGIC_APPLE
+        /* return both Apple creator and type */
+        rb_define_const(cMahoro, "APPLE", INT2FIX(MAGIC_APPLE));
+#endif
+
+#ifdef MAGIC_NO_CHECK_COMPRESS
+        /* Don't check for or inside compressed files */
+        rb_define_const(cMahoro, "NO_CHECK_COMPRESS",
+                        INT2FIX(MAGIC_NO_CHECK_COMPRESS));
+#endif
+
+#ifdef MAGIC_NO_CHECK_TAR
+        /* Don't examine tar files */
+        rb_define_const(cMahoro, "NO_CHECK_TAR", INT2FIX(MAGIC_NO_CHECK_TAR));
+#endif
+
+#ifdef MAGIC_NO_CHECK_SOFT
+        /* Don't consult magic files */
+        rb_define_const(cMahoro, "NO_CHECK_SOFT", INT2FIX(MAGIC_NO_CHECK_SOFT));
+#endif
+
+#ifdef MAGIC_NO_CHECK_APPTYPE
+        /* Don't check application type (EMX only) */
+        rb_define_const(cMahoro, "NO_CHECK_APPTYPE",
+                        INT2FIX(MAGIC_NO_CHECK_APPTYPE));
+#endif
+
+#ifdef MAGIC_NO_CHECK_ELF
+        /* Don't check for ELF details */
+        rb_define_const(cMahoro, "NO_CHECK_ELF", INT2FIX(MAGIC_NO_CHECK_ELF));
+#endif
+
+#ifdef MAGIC_NO_CHECK_ASCII
+        /* Don't check for various types of ASCII files */
+        rb_define_const(cMahoro, "NO_CHECK_TEXT",
+                        INT2FIX(MAGIC_NO_CHECK_ASCII));
+#endif
+
+#ifdef MAGIC_NO_CHECK_TOKENS
+        /* Don't check for known tokens inside ASCII files */
+        rb_define_const(cMahoro, "NO_CHECK_TOKENS",
+                        INT2FIX(MAGIC_NO_CHECK_TOKENS));
+#endif
+
+#ifdef MAGIC_NO_CHECK_ENCODING
+        /* Don't check for text encodings */
+        rb_define_const(cMahoro, "NO_CHECK_ENCODING",
+                        INT2FIX(MAGIC_NO_CHECK_ENCODING));
+#endif
+
         rb_define_alloc_func(cMahoro, mahoro_allocate);
         rb_define_method(cMahoro, "initialize", mahoro_initialize, -1);
         rb_define_method(cMahoro, "file", mahoro_file, 1);