[BACK]Return to magic-dump.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / file

Annotation of src/usr.bin/file/magic-dump.c, Revision 1.1

1.1     ! nicm        1: /* $OpenBSD$ */
        !             2:
        !             3: /*
        !             4:  * Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
        !             5:  *
        !             6:  * Permission to use, copy, modify, and distribute this software for any
        !             7:  * purpose with or without fee is hereby granted, provided that the above
        !             8:  * copyright notice and this permission notice appear in all copies.
        !             9:  *
        !            10:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
        !            11:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
        !            12:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
        !            13:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
        !            14:  * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
        !            15:  * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
        !            16:  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
        !            17:  */
        !            18:
        !            19: #include <sys/types.h>
        !            20:
        !            21: #include <stdio.h>
        !            22:
        !            23: #include "magic.h"
        !            24:
        !            25: static void
        !            26: magic_dump_line(struct magic_line *ml, u_int depth)
        !            27: {
        !            28:        struct magic_line       *child;
        !            29:        u_int                    i;
        !            30:
        !            31:        printf("%u", ml->line);
        !            32:        for (i = 0; i < depth; i++)
        !            33:                printf(">");
        !            34:        printf(" %s/%s%s%s%s [%u]%s\n", ml->type_string,
        !            35:            ml->result == NULL ? "" : ml->result,
        !            36:            ml->mimetype == NULL ? "" : " (",
        !            37:            ml->mimetype == NULL ? "" : ml->mimetype,
        !            38:            ml->mimetype == NULL ? "" : ")",
        !            39:            ml->strength, ml->text ? " (text)" : "");
        !            40:
        !            41:        TAILQ_FOREACH(child, &ml->children, entry)
        !            42:                magic_dump_line(child, depth + 1);
        !            43:
        !            44: }
        !            45:
        !            46: void
        !            47: magic_dump(struct magic *m)
        !            48: {
        !            49:        struct magic_line       *ml;
        !            50:
        !            51:        RB_FOREACH(ml, magic_tree, &m->tree)
        !            52:                magic_dump_line(ml, 0);
        !            53: }