xref: /illumos-gate/usr/src/cmd/mdb/common/mdb/mdb_cmdbuf.h (revision 9b0bb795691f70ec1b1796f6d15266f82d7a3200)
1 /*
2  * CDDL HEADER START
3  *
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 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_MDB_CMDBUF_H
27 #define	_MDB_CMDBUF_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/types.h>
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 typedef struct mdb_cmdbuf {
38 	char **cmd_history;	/* Circular array of history buffers */
39 	char *cmd_linebuf;	/* Temporary history for current buffer */
40 	char *cmd_buf;		/* Current line buffer */
41 	size_t cmd_linelen;	/* Maximum line length */
42 	size_t cmd_histlen;	/* Maximum history entries */
43 	size_t cmd_halloc;	/* Number of allocated history entries */
44 	size_t cmd_buflen;	/* Number of bytes in current line buffer */
45 	size_t cmd_bufidx;	/* Byte position in current line buffer */
46 	ssize_t cmd_hold;	/* Oldest history entry index */
47 	ssize_t cmd_hnew;	/* Newest history entry index */
48 	ssize_t cmd_hcur;	/* Current history entry index */
49 	ssize_t cmd_hlen;	/* Number of valid history buffers */
50 } mdb_cmdbuf_t;
51 
52 #ifdef _MDB
53 
54 extern void mdb_cmdbuf_create(mdb_cmdbuf_t *);
55 extern void mdb_cmdbuf_destroy(mdb_cmdbuf_t *);
56 
57 extern const char *mdb_cmdbuf_accept(mdb_cmdbuf_t *);
58 
59 extern int mdb_cmdbuf_caninsert(mdb_cmdbuf_t *, size_t);
60 extern int mdb_cmdbuf_atstart(mdb_cmdbuf_t *);
61 extern int mdb_cmdbuf_atend(mdb_cmdbuf_t *);
62 
63 extern int mdb_cmdbuf_insert(mdb_cmdbuf_t *, int);
64 extern int mdb_cmdbuf_backspace(mdb_cmdbuf_t *, int);
65 extern int mdb_cmdbuf_delchar(mdb_cmdbuf_t *, int);
66 extern int mdb_cmdbuf_fwdchar(mdb_cmdbuf_t *, int);
67 extern int mdb_cmdbuf_backchar(mdb_cmdbuf_t *, int);
68 extern int mdb_cmdbuf_transpose(mdb_cmdbuf_t *, int);
69 extern int mdb_cmdbuf_home(mdb_cmdbuf_t *, int);
70 extern int mdb_cmdbuf_end(mdb_cmdbuf_t *, int);
71 extern int mdb_cmdbuf_fwdword(mdb_cmdbuf_t *, int);
72 extern int mdb_cmdbuf_backword(mdb_cmdbuf_t *, int);
73 extern int mdb_cmdbuf_killfwdword(mdb_cmdbuf_t *, int);
74 extern int mdb_cmdbuf_killbackword(mdb_cmdbuf_t *, int);
75 extern int mdb_cmdbuf_kill(mdb_cmdbuf_t *, int);
76 extern int mdb_cmdbuf_reset(mdb_cmdbuf_t *, int);
77 extern int mdb_cmdbuf_prevhist(mdb_cmdbuf_t *, int);
78 extern int mdb_cmdbuf_nexthist(mdb_cmdbuf_t *, int);
79 extern int mdb_cmdbuf_findhist(mdb_cmdbuf_t *, int);
80 
81 #endif /* _MDB */
82 
83 #ifdef	__cplusplus
84 }
85 #endif
86 
87 #endif	/* _MDB_CMDBUF_H */
88