1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright (c) 1999-2001 by Sun Microsystems, Inc. 24*7c478bd9Sstevel@tonic-gate * All rights reserved. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _MDB_IO_IMPL_H 28*7c478bd9Sstevel@tonic-gate #define _MDB_IO_IMPL_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #include <mdb/mdb_io.h> 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 33*7c478bd9Sstevel@tonic-gate extern "C" { 34*7c478bd9Sstevel@tonic-gate #endif 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate #ifdef _MDB 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate typedef struct mdb_io_ops { 39*7c478bd9Sstevel@tonic-gate ssize_t (*io_read)(mdb_io_t *, void *, size_t); 40*7c478bd9Sstevel@tonic-gate ssize_t (*io_write)(mdb_io_t *, const void *, size_t); 41*7c478bd9Sstevel@tonic-gate off64_t (*io_seek)(mdb_io_t *, off64_t, int); 42*7c478bd9Sstevel@tonic-gate int (*io_ctl)(mdb_io_t *, int, void *); 43*7c478bd9Sstevel@tonic-gate void (*io_close)(mdb_io_t *); 44*7c478bd9Sstevel@tonic-gate const char *(*io_name)(mdb_io_t *); 45*7c478bd9Sstevel@tonic-gate void (*io_link)(mdb_io_t *, mdb_iob_t *); 46*7c478bd9Sstevel@tonic-gate void (*io_unlink)(mdb_io_t *, mdb_iob_t *); 47*7c478bd9Sstevel@tonic-gate int (*io_setattr)(mdb_io_t *, int, uint_t); 48*7c478bd9Sstevel@tonic-gate void (*io_suspend)(mdb_io_t *); 49*7c478bd9Sstevel@tonic-gate void (*io_resume)(mdb_io_t *); 50*7c478bd9Sstevel@tonic-gate } mdb_io_ops_t; 51*7c478bd9Sstevel@tonic-gate 52*7c478bd9Sstevel@tonic-gate #define IOP_READ(io, buf, len) ((io)->io_ops->io_read((io), (buf), (len))) 53*7c478bd9Sstevel@tonic-gate #define IOP_WRITE(io, buf, len) ((io)->io_ops->io_write((io), (buf), (len))) 54*7c478bd9Sstevel@tonic-gate #define IOP_SEEK(io, off, whence) ((io)->io_ops->io_seek((io), (off), (whence))) 55*7c478bd9Sstevel@tonic-gate #define IOP_CTL(io, req, arg) ((io)->io_ops->io_ctl((io), (req), (arg))) 56*7c478bd9Sstevel@tonic-gate #define IOP_CLOSE(io) ((io)->io_ops->io_close((io))) 57*7c478bd9Sstevel@tonic-gate #define IOP_NAME(io) ((io)->io_ops->io_name((io))) 58*7c478bd9Sstevel@tonic-gate #define IOP_LINK(io, iob) ((io)->io_ops->io_link((io), (iob))) 59*7c478bd9Sstevel@tonic-gate #define IOP_UNLINK(io, iob) ((io)->io_ops->io_unlink((io), (iob))) 60*7c478bd9Sstevel@tonic-gate #define IOP_SETATTR(io, r, a) ((io)->io_ops->io_setattr((io), (r), (a))) 61*7c478bd9Sstevel@tonic-gate #define IOP_SUSPEND(io) ((io)->io_ops->io_suspend((io))) 62*7c478bd9Sstevel@tonic-gate #define IOP_RESUME(io) ((io)->io_ops->io_resume((io))) 63*7c478bd9Sstevel@tonic-gate 64*7c478bd9Sstevel@tonic-gate #define IOPF_READ(io) \ 65*7c478bd9Sstevel@tonic-gate ((ssize_t (*)(mdb_io_t *, void *, size_t))(io)->io_ops->io_read) 66*7c478bd9Sstevel@tonic-gate 67*7c478bd9Sstevel@tonic-gate #define IOPF_WRITE(io) \ 68*7c478bd9Sstevel@tonic-gate ((ssize_t (*)(mdb_io_t *, void *, size_t))(io)->io_ops->io_write) 69*7c478bd9Sstevel@tonic-gate 70*7c478bd9Sstevel@tonic-gate #define ATT_STANDOUT 0x01 /* Standout mode */ 71*7c478bd9Sstevel@tonic-gate #define ATT_UNDERLINE 0x02 /* Underline mode */ 72*7c478bd9Sstevel@tonic-gate #define ATT_REVERSE 0x04 /* Reverse video mode */ 73*7c478bd9Sstevel@tonic-gate #define ATT_BOLD 0x08 /* Bold text mode */ 74*7c478bd9Sstevel@tonic-gate #define ATT_DIM 0x10 /* Dim text mode */ 75*7c478bd9Sstevel@tonic-gate #define ATT_ALTCHARSET 0x20 /* Alternate character set mode */ 76*7c478bd9Sstevel@tonic-gate 77*7c478bd9Sstevel@tonic-gate #define ATT_ALL 0x3f /* Mask of all valid attributes */ 78*7c478bd9Sstevel@tonic-gate 79*7c478bd9Sstevel@tonic-gate #define ATT_OFF 0 /* Turn attributes off */ 80*7c478bd9Sstevel@tonic-gate #define ATT_ON 1 /* Turn attributes on */ 81*7c478bd9Sstevel@tonic-gate 82*7c478bd9Sstevel@tonic-gate struct mdb_io { 83*7c478bd9Sstevel@tonic-gate const mdb_io_ops_t *io_ops; /* I/O type-specific operations */ 84*7c478bd9Sstevel@tonic-gate void *io_data; /* I/O type-specific data pointer */ 85*7c478bd9Sstevel@tonic-gate mdb_io_t *io_next; /* Link to next i/o object on stack */ 86*7c478bd9Sstevel@tonic-gate size_t io_refcnt; /* Reference count */ 87*7c478bd9Sstevel@tonic-gate }; 88*7c478bd9Sstevel@tonic-gate 89*7c478bd9Sstevel@tonic-gate struct mdb_iob { 90*7c478bd9Sstevel@tonic-gate char *iob_buf; /* Input/output buffer */ 91*7c478bd9Sstevel@tonic-gate size_t iob_bufsiz; /* Size of iob_buf in bytes */ 92*7c478bd9Sstevel@tonic-gate char *iob_bufp; /* Current buffer location */ 93*7c478bd9Sstevel@tonic-gate size_t iob_nbytes; /* Number of bytes in io_buf */ 94*7c478bd9Sstevel@tonic-gate size_t iob_nlines; /* Lines output on current page */ 95*7c478bd9Sstevel@tonic-gate size_t iob_lineno; /* Storage for saved yylineno */ 96*7c478bd9Sstevel@tonic-gate size_t iob_rows; /* Terminal height */ 97*7c478bd9Sstevel@tonic-gate size_t iob_cols; /* Terminal width */ 98*7c478bd9Sstevel@tonic-gate size_t iob_tabstop; /* Tab stop width */ 99*7c478bd9Sstevel@tonic-gate size_t iob_margin; /* Margin width */ 100*7c478bd9Sstevel@tonic-gate uint_t iob_flags; /* Flags (see <mdb/mdb_io.h>) */ 101*7c478bd9Sstevel@tonic-gate mdb_io_t *iob_iop; /* I/o implementation pointer */ 102*7c478bd9Sstevel@tonic-gate mdb_io_t *iob_pgp; /* Pager i/o implementation pointer */ 103*7c478bd9Sstevel@tonic-gate mdb_iob_t *iob_next; /* Stack next pointer */ 104*7c478bd9Sstevel@tonic-gate }; 105*7c478bd9Sstevel@tonic-gate 106*7c478bd9Sstevel@tonic-gate /* 107*7c478bd9Sstevel@tonic-gate * Stub functions for i/o backend implementors: these stubs either act as 108*7c478bd9Sstevel@tonic-gate * pass-through no-ops or return ENOTSUP as appropriate. 109*7c478bd9Sstevel@tonic-gate */ 110*7c478bd9Sstevel@tonic-gate extern ssize_t no_io_read(mdb_io_t *, void *, size_t); 111*7c478bd9Sstevel@tonic-gate extern ssize_t no_io_write(mdb_io_t *, const void *, size_t); 112*7c478bd9Sstevel@tonic-gate extern off64_t no_io_seek(mdb_io_t *, off64_t, int); 113*7c478bd9Sstevel@tonic-gate extern int no_io_ctl(mdb_io_t *, int, void *); 114*7c478bd9Sstevel@tonic-gate extern void no_io_close(mdb_io_t *); 115*7c478bd9Sstevel@tonic-gate extern const char *no_io_name(mdb_io_t *); 116*7c478bd9Sstevel@tonic-gate extern void no_io_link(mdb_io_t *, mdb_iob_t *); 117*7c478bd9Sstevel@tonic-gate extern void no_io_unlink(mdb_io_t *, mdb_iob_t *); 118*7c478bd9Sstevel@tonic-gate extern int no_io_setattr(mdb_io_t *, int, uint_t); 119*7c478bd9Sstevel@tonic-gate extern void no_io_suspend(mdb_io_t *); 120*7c478bd9Sstevel@tonic-gate extern void no_io_resume(mdb_io_t *); 121*7c478bd9Sstevel@tonic-gate 122*7c478bd9Sstevel@tonic-gate #endif /* _MDB */ 123*7c478bd9Sstevel@tonic-gate 124*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 125*7c478bd9Sstevel@tonic-gate } 126*7c478bd9Sstevel@tonic-gate #endif 127*7c478bd9Sstevel@tonic-gate 128*7c478bd9Sstevel@tonic-gate #endif /* _MDB_IO_IMPL_H */ 129