]> granicus.if.org Git - file/commitdiff
Add MAGIC_NODESC for no-description printing.
authorChristos Zoulas <christos@zoulas.com>
Thu, 21 May 2015 18:25:29 +0000 (18:25 +0000)
committerChristos Zoulas <christos@zoulas.com>
Thu, 21 May 2015 18:25:29 +0000 (18:25 +0000)
Make name nodes not print description if MAGIC_NODESC

src/magic.h.in
src/softmagic.c

index 3e7b10e0937a9fe923245c1166acc75ce124245a..ba7884cbe7f9d3da4fd741ed2ac9fa6c302c3f90 100644 (file)
@@ -45,6 +45,7 @@
 #define        MAGIC_APPLE             0x0000800 /* Return the Apple creator/type */
 #define        MAGIC_EXTENSION         0x1000000 /* Return a /-separated list of
                                           * extensions  */
+#define MAGIC_NODESC           (MAGIC_EXTENSION|MAGIC_MIME|MAGIC_APPLE)
 
 #define        MAGIC_NO_CHECK_COMPRESS 0x0001000 /* Don't check for compressed files */
 #define        MAGIC_NO_CHECK_TAR      0x0002000 /* Don't check for tar files */
index 09c2ff62614ffbd9a4b726af95cd964cb42aacd4..9608b968b5f983b6ad93183b4e1a4ce9cacf1c38 100644 (file)
@@ -32,7 +32,7 @@
 #include "file.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: softmagic.c,v 1.214 2015/04/09 20:01:41 christos Exp $")
+FILE_RCSID("@(#)$File: softmagic.c,v 1.215 2015/05/21 18:25:29 christos Exp $")
 #endif /* lint */
 
 #include "magic.h"
@@ -147,7 +147,7 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
        unsigned int cont_level = 0;
        int returnvalv = 0, e; /* if a match is found it is set to 1*/
        int firstline = 1; /* a flag to print X\n  X\n- X */
-       int print = (ms->flags & (MAGIC_MIME|MAGIC_APPLE|MAGIC_EXTENSION)) == 0;
+       int print = (ms->flags & MAGIC_NODESC) == 0;
 
        if (returnval == NULL)
                returnval = &returnvalv;
@@ -1674,7 +1674,7 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
                        return -1;
 
                if (rv == 1) {
-                       if ((ms->flags & (MAGIC_MIME|MAGIC_APPLE|MAGIC_EXTENSION)) == 0 &&
+                       if ((ms->flags & MAGIC_NODESC) == 0 &&
                            file_printf(ms, F(ms, m, "%u"), offset) == -1) {
                                free(rbuf);
                                return -1;
@@ -1711,6 +1711,8 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
                return rv;
 
        case FILE_NAME:
+               if (ms->flags & MAGIC_NODESC)
+                       return 1;
                if (file_printf(ms, "%s", m->desc) == -1)
                        return -1;
                return 1;
@@ -2152,7 +2154,7 @@ handle_annotation(struct magic_set *ms, struct magic *m)
 private int
 print_sep(struct magic_set *ms, int firstline)
 {
-       if (ms->flags & MAGIC_MIME)
+       if (ms->flags & MAGIC_NODESC)
                return 0;
        if (firstline)
                return 0;