1*4887Schin /*********************************************************************** 2*4887Schin * * 3*4887Schin * This software is part of the ast package * 4*4887Schin * Copyright (c) 1982-2007 AT&T Knowledge Ventures * 5*4887Schin * and is licensed under the * 6*4887Schin * Common Public License, Version 1.0 * 7*4887Schin * by AT&T Knowledge Ventures * 8*4887Schin * * 9*4887Schin * A copy of the License is available at * 10*4887Schin * http://www.opensource.org/licenses/cpl1.0.txt * 11*4887Schin * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 12*4887Schin * * 13*4887Schin * Information and Software Systems Research * 14*4887Schin * AT&T Research * 15*4887Schin * Florham Park NJ * 16*4887Schin * * 17*4887Schin * David Korn <dgk@research.att.com> * 18*4887Schin * * 19*4887Schin ***********************************************************************/ 20*4887Schin #pragma prototyped 21*4887Schin #ifndef HIST_VERSION 22*4887Schin /* 23*4887Schin * Interface for history mechanism 24*4887Schin * written by David Korn 25*4887Schin * 26*4887Schin */ 27*4887Schin 28*4887Schin #include <ast.h> 29*4887Schin 30*4887Schin #define HIST_CHAR '!' 31*4887Schin #define HIST_VERSION 1 /* history file format version no. */ 32*4887Schin 33*4887Schin typedef struct 34*4887Schin { 35*4887Schin Sfdisc_t histdisc; /* discipline for history */ 36*4887Schin Sfio_t *histfp; /* history file stream pointer */ 37*4887Schin char *histname; /* name of history file */ 38*4887Schin int32_t histind; /* current command number index */ 39*4887Schin int histsize; /* number of accessible history lines */ 40*4887Schin #ifdef _HIST_PRIVATE 41*4887Schin _HIST_PRIVATE 42*4887Schin #endif /* _HIST_PRIVATE */ 43*4887Schin } History_t; 44*4887Schin 45*4887Schin typedef struct 46*4887Schin { 47*4887Schin int hist_command; 48*4887Schin int hist_line; 49*4887Schin int hist_char; 50*4887Schin } Histloc_t; 51*4887Schin 52*4887Schin /* the following are readonly */ 53*4887Schin extern const char hist_fname[]; 54*4887Schin 55*4887Schin extern int _Hist; 56*4887Schin #define hist_min(hp) ((_Hist=((int)((hp)->histind-(hp)->histsize)))>=0?_Hist:0) 57*4887Schin #define hist_max(hp) ((int)((hp)->histind)) 58*4887Schin /* these are the history interface routines */ 59*4887Schin extern int sh_histinit(void); 60*4887Schin extern void hist_cancel(History_t*); 61*4887Schin extern void hist_close(History_t*); 62*4887Schin extern int hist_copy(char*, int, int, int); 63*4887Schin extern void hist_eof(History_t*); 64*4887Schin extern Histloc_t hist_find(History_t*,char*,int, int, int); 65*4887Schin extern void hist_flush(History_t*); 66*4887Schin extern void hist_list(History_t*,Sfio_t*, off_t, int, char*); 67*4887Schin extern int hist_match(History_t*,off_t, char*, int*); 68*4887Schin extern off_t hist_tell(History_t*,int); 69*4887Schin extern off_t hist_seek(History_t*,int); 70*4887Schin extern char *hist_word(char*, int, int); 71*4887Schin #if SHOPT_ESH 72*4887Schin extern Histloc_t hist_locate(History_t*,int, int, int); 73*4887Schin #endif /* SHOPT_ESH */ 74*4887Schin 75*4887Schin #endif /* HIST_VERSION */ 76