[BACK]Return to dw.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / ctfconv

Annotation of src/usr.bin/ctfconv/dw.h, Revision 1.1

1.1     ! mpi         1: /*
        !             2:  * Copyright (c) 2016 Martin Pieuchot
        !             3:  *
        !             4:  * Permission to use, copy, modify, and distribute this software for any
        !             5:  * purpose with or without fee is hereby granted, provided that the above
        !             6:  * copyright notice and this permission notice appear in all copies.
        !             7:  *
        !             8:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
        !             9:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
        !            10:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
        !            11:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
        !            12:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
        !            13:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
        !            14:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
        !            15:  */
        !            16:
        !            17: #ifndef _DW_H_
        !            18: #define _DW_H_
        !            19:
        !            20: struct dwbuf {
        !            21:        const char              *buf;
        !            22:        size_t                   len;
        !            23: };
        !            24:
        !            25: struct dwattr {
        !            26:        SIMPLEQ_ENTRY(dwattr)    dat_next;
        !            27:        uint64_t                 dat_attr;
        !            28:        uint64_t                 dat_form;
        !            29: };
        !            30:
        !            31: struct dwaval {
        !            32:        SIMPLEQ_ENTRY(dwaval)    dav_next;
        !            33:        struct dwattr           *dav_dat;       /* corresponding attribute */
        !            34:        union {
        !            35:                struct dwbuf     _buf;
        !            36:                struct {
        !            37:                        const char      *_str;
        !            38:                        union {
        !            39:                                uint64_t         _u64;
        !            40:                                int64_t          _s64;
        !            41:                                uint32_t         _u32;
        !            42:                                uint16_t         _u16;
        !            43:                                uint8_t          _u8;
        !            44:                        } _T;
        !            45:                } _V;
        !            46:        } AV;
        !            47: #define dav_buf        AV._buf
        !            48: #define dav_str        AV._V._str
        !            49: #define dav_u64        AV._V._T._u64
        !            50: #define dav_s64        AV._V._T._s64
        !            51: #define dav_u32        AV._V._T._u32
        !            52: #define dav_u16        AV._V._T._u16
        !            53: #define dav_u8 AV._V._T._u8
        !            54: };
        !            55:
        !            56: SIMPLEQ_HEAD(dwaval_queue, dwaval);
        !            57:
        !            58: struct dwdie {
        !            59:        SIMPLEQ_ENTRY(dwdie)     die_next;
        !            60:        struct dwabbrev         *die_dab;
        !            61:        size_t                   die_offset;
        !            62:        uint8_t                  die_lvl;
        !            63:        struct dwaval_queue      die_avals;
        !            64: };
        !            65:
        !            66: SIMPLEQ_HEAD(dwdie_queue, dwdie);
        !            67:
        !            68: struct dwabbrev {
        !            69:        SIMPLEQ_ENTRY(dwabbrev)  dab_next;
        !            70:        uint64_t                 dab_code;
        !            71:        uint64_t                 dab_tag;
        !            72:        uint8_t                  dab_children;
        !            73:        SIMPLEQ_HEAD(, dwattr)   dab_attrs;
        !            74: };
        !            75:
        !            76: SIMPLEQ_HEAD(dwabbrev_queue, dwabbrev);
        !            77:
        !            78: struct dwcu {
        !            79:        uint64_t                 dcu_length;
        !            80:        uint64_t                 dcu_abbroff;
        !            81:        uint16_t                 dcu_version;
        !            82:        uint8_t                  dcu_psize;
        !            83:        size_t                   dcu_offset;    /* offset in the segment */
        !            84:        struct dwabbrev_queue    dcu_abbrevs;
        !            85:        struct dwdie_queue       dcu_dies;
        !            86: };
        !            87:
        !            88: const char     *dw_tag2name(uint64_t);
        !            89: const char     *dw_at2name(uint64_t);
        !            90: const char     *dw_form2name(uint64_t);
        !            91: const char     *dw_op2name(uint8_t);
        !            92:
        !            93: int     dw_loc_parse(struct dwbuf *, uint8_t *, uint64_t *, uint64_t *);
        !            94:
        !            95: int     dw_ab_parse(struct dwbuf *, struct dwabbrev_queue *);
        !            96: int     dw_cu_parse(struct dwbuf *, struct dwbuf *, size_t, struct dwcu **);
        !            97:
        !            98: void    dw_dabq_purge(struct dwabbrev_queue *);
        !            99: void    dw_dcu_free(struct dwcu *);
        !           100:
        !           101:
        !           102: #endif /* _DW_H_ */