xref: /onnv-gate/usr/src/lib/libshell/common/include/history.h (revision 12068:08a39a083754)
14887Schin /***********************************************************************
24887Schin *                                                                      *
34887Schin *               This software is part of the ast package               *
4*12068SRoger.Faulkner@Oracle.COM *          Copyright (c) 1982-2010 AT&T Intellectual Property          *
54887Schin *                      and is licensed under the                       *
64887Schin *                  Common Public License, Version 1.0                  *
78462SApril.Chin@Sun.COM *                    by AT&T Intellectual Property                     *
84887Schin *                                                                      *
94887Schin *                A copy of the License is available at                 *
104887Schin *            http://www.opensource.org/licenses/cpl1.0.txt             *
114887Schin *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
124887Schin *                                                                      *
134887Schin *              Information and Software Systems Research               *
144887Schin *                            AT&T Research                             *
154887Schin *                           Florham Park NJ                            *
164887Schin *                                                                      *
174887Schin *                  David Korn <dgk@research.att.com>                   *
184887Schin *                                                                      *
194887Schin ***********************************************************************/
204887Schin #pragma prototyped
214887Schin #ifndef HIST_VERSION
224887Schin /*
234887Schin  *	Interface for history mechanism
244887Schin  *	written by David Korn
254887Schin  *
264887Schin  */
274887Schin 
284887Schin #include	<ast.h>
294887Schin 
304887Schin #define HIST_CHAR	'!'
314887Schin #define HIST_VERSION	1		/* history file format version no. */
324887Schin 
334887Schin typedef struct
344887Schin {
354887Schin 	Sfdisc_t	histdisc;	/* discipline for history */
364887Schin 	Sfio_t		*histfp;	/* history file stream pointer */
374887Schin 	char		*histname;	/* name of history file */
384887Schin 	int32_t		histind;	/* current command number index */
394887Schin 	int		histsize;	/* number of accessible history lines */
404887Schin #ifdef _HIST_PRIVATE
414887Schin 	_HIST_PRIVATE
424887Schin #endif /* _HIST_PRIVATE */
434887Schin } History_t;
444887Schin 
454887Schin typedef struct
464887Schin {
474887Schin 	int hist_command;
484887Schin 	int hist_line;
494887Schin 	int hist_char;
504887Schin } Histloc_t;
514887Schin 
524887Schin /* the following are readonly */
534887Schin extern const char	hist_fname[];
544887Schin 
554887Schin extern int _Hist;
564887Schin #define	hist_min(hp)	((_Hist=((int)((hp)->histind-(hp)->histsize)))>=0?_Hist:0)
574887Schin #define	hist_max(hp)	((int)((hp)->histind))
584887Schin /* these are the history interface routines */
598462SApril.Chin@Sun.COM extern int		sh_histinit(void *);
604887Schin extern void 		hist_cancel(History_t*);
614887Schin extern void 		hist_close(History_t*);
624887Schin extern int		hist_copy(char*, int, int, int);
634887Schin extern void 		hist_eof(History_t*);
644887Schin extern Histloc_t	hist_find(History_t*,char*,int, int, int);
654887Schin extern void 		hist_flush(History_t*);
664887Schin extern void 		hist_list(History_t*,Sfio_t*, off_t, int, char*);
674887Schin extern int		hist_match(History_t*,off_t, char*, int*);
684887Schin extern off_t		hist_tell(History_t*,int);
694887Schin extern off_t		hist_seek(History_t*,int);
704887Schin extern char 		*hist_word(char*, int, int);
714887Schin #if SHOPT_ESH
724887Schin     extern Histloc_t	hist_locate(History_t*,int, int, int);
734887Schin #endif	/* SHOPT_ESH */
744887Schin 
754887Schin #endif /* HIST_VERSION */
76