Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/ie/history.h
1808 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1984-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* David Korn <[email protected]> *
18
* Pat Sullivan *
19
* *
20
***********************************************************************/
21
/*
22
* UNIX shell
23
* Header File for history mechanism
24
* written by David Korn
25
*
26
*/
27
28
29
30
#ifndef IOBSIZE
31
# define IOBSIZE 1024
32
#endif
33
#define FC_CHAR '!'
34
#define HIS_DFLT 128 /* default size of history list */
35
#define HISMAX (sizeof(int)*IOBSIZE)
36
#define HISBIG (0100000-1024) /* 1K less than maximum short */
37
#define HISLINE 16 /* estimate of average sized history line */
38
#define MAXLINE 258 /* longest history line permitted */
39
40
#define H_UNDO 0201 /* invalidate previous command */
41
#define H_CMDNO 0202 /* next 3 bytes give command number */
42
#define H_VERSION 1 /* history file format version no. */
43
44
struct history
45
{
46
struct fileblk *fixfp; /* file descriptor for history file */
47
int fixfd; /* file number for history file */
48
char *fixname; /* name of history file */
49
off_t fixcnt; /* offset into history file */
50
int fixind; /* current command number index */
51
int fixmax; /* number of accessible history lines */
52
int fixflush; /* set if flushed outside of hflush() */
53
off_t fixcmds[1]; /* byte offset for recent commands */
54
};
55
56
typedef struct
57
{
58
int his_command;
59
int his_line;
60
} histloc;
61
62
extern struct history *hist_ptr;
63
64
#ifndef KSHELL
65
extern void p_flush();
66
extern void p_setout();
67
extern void p_char();
68
extern void p_str();
69
# ifdef __STDC__
70
# define nam_strval(s) getenv(#s)
71
# else
72
# define nam_strval(s) getenv("s")
73
# endif /* __STDC__ */
74
# define NIL ((char*)0)
75
# define sh_fail ed_failed
76
# define sh_copy ed_movstr
77
#ifdef PROTO
78
extern char *ed_movstr(const char*, char*);
79
#else
80
extern char *ed_movstr();
81
#endif /* PROTO */
82
#endif /* KSHELL */
83
84
/* the following are readonly */
85
extern const char hist_fname[];
86
extern const char e_history[];
87
88
/* these are the history interface routines */
89
#ifdef PROTO
90
extern int hist_open(void);
91
extern void hist_cancel(void);
92
extern void hist_close(void);
93
extern int hist_copy(char*,int,int);
94
extern void hist_eof(void);
95
extern histloc hist_find(char*,int,int,int);
96
extern void hist_flush(void);
97
extern void hist_list(off_t,int,char*);
98
extern int hist_match(off_t,char*,int);
99
extern off_t hist_position(int);
100
extern void hist_subst(const char*,int,char*);
101
extern char *hist_word(char*,int);
102
# ifdef ESH
103
extern histloc hist_locate(int,int,int);
104
# endif /* ESH */
105
#else
106
extern int hist_open();
107
extern void hist_cancel();
108
extern void hist_close();
109
extern int hist_copy();
110
extern void hist_eof();
111
extern histloc hist_find();
112
extern void hist_flush();
113
extern void hist_list();
114
extern int hist_match();
115
extern off_t hist_position();
116
extern void hist_subst();
117
extern char *hist_word();
118
# ifdef ESH
119
extern histloc hist_locate();
120
# endif /* ESH */
121
#endif /* PROTO */
122
123