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

Annotation of src/usr.bin/tmux/imsg.h, Revision 1.1

1.1     ! nicm        1: /*     $OpenBSD: imsg.h,v 1.3 2009/06/07 05:56:25 eric Exp $   */
        !             2:
        !             3: /*
        !             4:  * Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org>
        !             5:  * Copyright (c) 2006, 2007, 2008 Reyk Floeter <reyk@openbsd.org>
        !             6:  * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
        !             7:  *
        !             8:  * Permission to use, copy, modify, and distribute this software for any
        !             9:  * purpose with or without fee is hereby granted, provided that the above
        !            10:  * copyright notice and this permission notice appear in all copies.
        !            11:  *
        !            12:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
        !            13:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
        !            14:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
        !            15:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
        !            16:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
        !            17:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
        !            18:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
        !            19:  */
        !            20:
        !            21: #include <sys/tree.h>
        !            22:
        !            23: #define READ_BUF_SIZE          65535
        !            24: #define IMSG_HEADER_SIZE       sizeof(struct imsg_hdr)
        !            25: #define MAX_IMSGSIZE           16384
        !            26:
        !            27: struct buf {
        !            28:        TAILQ_ENTRY(buf)         entry;
        !            29:        u_char                  *buf;
        !            30:        size_t                   size;
        !            31:        size_t                   max;
        !            32:        size_t                   wpos;
        !            33:        size_t                   rpos;
        !            34:        int                      fd;
        !            35: };
        !            36:
        !            37: struct msgbuf {
        !            38:        TAILQ_HEAD(, buf)        bufs;
        !            39:        u_int32_t                queued;
        !            40:        int                      fd;
        !            41: };
        !            42:
        !            43: struct buf_read {
        !            44:        u_char                   buf[READ_BUF_SIZE];
        !            45:        u_char                  *rptr;
        !            46:        size_t                   wpos;
        !            47: };
        !            48:
        !            49: struct imsg_fd {
        !            50:        TAILQ_ENTRY(imsg_fd)    entry;
        !            51:        int                     fd;
        !            52: };
        !            53:
        !            54: struct imsgbuf {
        !            55:        TAILQ_HEAD(, imsg_fd)    fds;
        !            56:        struct buf_read          r;
        !            57:        struct msgbuf            w;
        !            58:        int                      fd;
        !            59:        pid_t                    pid;
        !            60: };
        !            61:
        !            62: #define IMSGF_HASFD    1
        !            63:
        !            64: struct imsg_hdr {
        !            65:        u_int32_t        type;
        !            66:        u_int16_t        len;
        !            67:        u_int16_t        flags;
        !            68:        u_int32_t        peerid;
        !            69:        u_int32_t        pid;
        !            70: };
        !            71:
        !            72: struct imsg {
        !            73:        struct imsg_hdr  hdr;
        !            74:        int              fd;
        !            75:        void            *data;
        !            76: };
        !            77:
        !            78:
        !            79: /* buffer.c */
        !            80: struct buf     *buf_open(size_t);
        !            81: struct buf     *buf_dynamic(size_t, size_t);
        !            82: int             buf_add(struct buf *, const void *, size_t);
        !            83: void           *buf_reserve(struct buf *, size_t);
        !            84: void           *buf_seek(struct buf *, size_t, size_t);
        !            85: size_t          buf_size(struct buf *);
        !            86: size_t          buf_left(struct buf *);
        !            87: void            buf_close(struct msgbuf *, struct buf *);
        !            88: int             buf_write(struct msgbuf *);
        !            89: void            buf_free(struct buf *);
        !            90: void            msgbuf_init(struct msgbuf *);
        !            91: void            msgbuf_clear(struct msgbuf *);
        !            92: int             msgbuf_write(struct msgbuf *);
        !            93:
        !            94: /* imsg.c */
        !            95: void    imsg_init(struct imsgbuf *, int);
        !            96: ssize_t         imsg_read(struct imsgbuf *);
        !            97: ssize_t         imsg_get(struct imsgbuf *, struct imsg *);
        !            98: int     imsg_compose(struct imsgbuf *, u_int32_t, u_int32_t, pid_t,
        !            99:            int, void *, u_int16_t);
        !           100: int     imsg_composev(struct imsgbuf *, u_int32_t, u_int32_t,  pid_t,
        !           101:            int, const struct iovec *, int);
        !           102: struct buf *imsg_create(struct imsgbuf *, u_int32_t, u_int32_t, pid_t,
        !           103:            u_int16_t);
        !           104: int     imsg_add(struct buf *, void *, u_int16_t);
        !           105: void    imsg_close(struct imsgbuf *, struct buf *);
        !           106: void    imsg_free(struct imsg *);
        !           107: int     imsg_flush(struct imsgbuf *);
        !           108: void    imsg_clear(struct imsgbuf *);