4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #ifndef _MDB_IO_H
27 #define _MDB_IO_H
28
29 #pragma ident "%Z%%M% %I% %E% SMI"
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #ifdef _MDB
36
37 #include <sys/types.h>
38 #include <setjmp.h>
39 #include <stdarg.h>
40 #include <stdio.h>
41
42 typedef struct mdb_iob mdb_iob_t; /* I/O buffer */
43 typedef struct mdb_io mdb_io_t; /* I/O implementation */
44 struct mdb_arg; /* Argument structure */
45
46 #define MDB_IOB_DEFTAB 8 /* Default tabstop */
47 #define MDB_IOB_DEFMARGIN 16 /* Default margin width */
48 #define MDB_IOB_DEFROWS 24 /* Default rows */
49 #define MDB_IOB_DEFCOLS 80 /* Default columns */
50
132
133 extern void mdb_iob_fill(mdb_iob_t *, int, size_t);
134 extern void mdb_iob_ws(mdb_iob_t *, size_t);
135 extern void mdb_iob_tab(mdb_iob_t *);
136 extern void mdb_iob_nl(mdb_iob_t *);
137
138 extern ssize_t mdb_iob_ngets(mdb_iob_t *, char *, size_t);
139 extern int mdb_iob_getc(mdb_iob_t *);
140 extern int mdb_iob_ungetc(mdb_iob_t *, int);
141 extern int mdb_iob_eof(mdb_iob_t *);
142 extern int mdb_iob_err(mdb_iob_t *);
143
144 extern ssize_t mdb_iob_read(mdb_iob_t *, void *, size_t);
145 extern ssize_t mdb_iob_write(mdb_iob_t *, const void *, size_t);
146 extern int mdb_iob_ctl(mdb_iob_t *, int, void *);
147 extern const char *mdb_iob_name(mdb_iob_t *);
148 extern size_t mdb_iob_lineno(mdb_iob_t *);
149 extern size_t mdb_iob_gettabstop(mdb_iob_t *);
150 extern size_t mdb_iob_getmargin(mdb_iob_t *);
151
152 extern void mdb_iob_stack_create(mdb_iob_stack_t *);
153 extern void mdb_iob_stack_destroy(mdb_iob_stack_t *);
154 extern void mdb_iob_stack_push(mdb_iob_stack_t *, mdb_iob_t *, size_t);
155 extern mdb_iob_t *mdb_iob_stack_pop(mdb_iob_stack_t *);
156 extern size_t mdb_iob_stack_size(mdb_iob_stack_t *);
157
158 extern const char *mdb_iob_format2str(const char *);
159
160 /*
161 * Available i/o backend constructors for common MDB code. These are
162 * implemented in the corresponding .c files.
163 */
164 extern mdb_io_t *mdb_logio_create(mdb_io_t *);
165 extern mdb_io_t *mdb_fdio_create_path(const char **, const char *, int, mode_t);
166 extern mdb_io_t *mdb_fdio_create_named(int fd, const char *);
167 extern mdb_io_t *mdb_fdio_create(int);
168 extern mdb_io_t *mdb_strio_create(const char *);
169 extern mdb_io_t *mdb_termio_create(const char *, mdb_io_t *, mdb_io_t *);
170 extern mdb_io_t *mdb_pipeio_create(mdb_iobsvc_f *, mdb_iobsvc_f *);
171 extern mdb_io_t *mdb_nullio_create(void);
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 *
25 * Copyright 2020 Joyent, Inc.
26 */
27
28 #ifndef _MDB_IO_H
29 #define _MDB_IO_H
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #ifdef _MDB
36
37 #include <sys/types.h>
38 #include <setjmp.h>
39 #include <stdarg.h>
40 #include <stdio.h>
41
42 typedef struct mdb_iob mdb_iob_t; /* I/O buffer */
43 typedef struct mdb_io mdb_io_t; /* I/O implementation */
44 struct mdb_arg; /* Argument structure */
45
46 #define MDB_IOB_DEFTAB 8 /* Default tabstop */
47 #define MDB_IOB_DEFMARGIN 16 /* Default margin width */
48 #define MDB_IOB_DEFROWS 24 /* Default rows */
49 #define MDB_IOB_DEFCOLS 80 /* Default columns */
50
132
133 extern void mdb_iob_fill(mdb_iob_t *, int, size_t);
134 extern void mdb_iob_ws(mdb_iob_t *, size_t);
135 extern void mdb_iob_tab(mdb_iob_t *);
136 extern void mdb_iob_nl(mdb_iob_t *);
137
138 extern ssize_t mdb_iob_ngets(mdb_iob_t *, char *, size_t);
139 extern int mdb_iob_getc(mdb_iob_t *);
140 extern int mdb_iob_ungetc(mdb_iob_t *, int);
141 extern int mdb_iob_eof(mdb_iob_t *);
142 extern int mdb_iob_err(mdb_iob_t *);
143
144 extern ssize_t mdb_iob_read(mdb_iob_t *, void *, size_t);
145 extern ssize_t mdb_iob_write(mdb_iob_t *, const void *, size_t);
146 extern int mdb_iob_ctl(mdb_iob_t *, int, void *);
147 extern const char *mdb_iob_name(mdb_iob_t *);
148 extern size_t mdb_iob_lineno(mdb_iob_t *);
149 extern size_t mdb_iob_gettabstop(mdb_iob_t *);
150 extern size_t mdb_iob_getmargin(mdb_iob_t *);
151
152 extern void mdb_iob_set_autowrap(mdb_iob_t *);
153
154 extern void mdb_iob_stack_create(mdb_iob_stack_t *);
155 extern void mdb_iob_stack_destroy(mdb_iob_stack_t *);
156 extern void mdb_iob_stack_push(mdb_iob_stack_t *, mdb_iob_t *, size_t);
157 extern mdb_iob_t *mdb_iob_stack_pop(mdb_iob_stack_t *);
158 extern size_t mdb_iob_stack_size(mdb_iob_stack_t *);
159
160 extern const char *mdb_iob_format2str(const char *);
161
162 /*
163 * Available i/o backend constructors for common MDB code. These are
164 * implemented in the corresponding .c files.
165 */
166 extern mdb_io_t *mdb_logio_create(mdb_io_t *);
167 extern mdb_io_t *mdb_fdio_create_path(const char **, const char *, int, mode_t);
168 extern mdb_io_t *mdb_fdio_create_named(int fd, const char *);
169 extern mdb_io_t *mdb_fdio_create(int);
170 extern mdb_io_t *mdb_strio_create(const char *);
171 extern mdb_io_t *mdb_termio_create(const char *, mdb_io_t *, mdb_io_t *);
172 extern mdb_io_t *mdb_pipeio_create(mdb_iobsvc_f *, mdb_iobsvc_f *);
173 extern mdb_io_t *mdb_nullio_create(void);
|