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