Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/lib/libtksh/include/tkshlib.h
1810 views
1
#pragma prototyped
2
#ifndef __TKSHLIB_H_
3
#define __TKSHLIB_H_
4
5
#include <tksh.h>
6
#include <config.h>
7
#include <stdio.h>
8
#include <ctype.h>
9
#undef NTcl_FreeResult
10
#define NTcl_FreeResult(interp) do { sfprintf(sfstderr, "Free of %s at %s %d (%x)\n", (interp)->result, __FILE__, __LINE__, (interp)->freeProc); (interp)->freeProc = 0; } while(0)
11
12
#include "shcompat.h"
13
14
#define DEFAULT_PD_PREC 6
15
#define DEFAULT_PD_FORMAT "%g"
16
17
/*
18
* The macro below is used to modify a "char" value (e.g. by casting
19
* it to an unsigned character) so that it can be used safely with
20
* macros such as isspace.
21
*/
22
23
#define UCHAR(c) ((unsigned char) (c))
24
25
/*
26
* Given a size or address, the macro below "aligns" it to the machine's
27
* memory unit size (e.g. an 8-byte boundary) so that anything can be
28
* placed at the aligned address without fear of an alignment error.
29
*/
30
31
#define TCL_ALIGN(x) ((x + 7) & ~7)
32
33
/*
34
* Patchlevel
35
*/
36
37
#if TCL_MINOR_VERSION == 3
38
#define TCL_PATCH_LEVEL 106
39
#else
40
#ifndef TCL_PATCH_LEVEL
41
#define TCL_PATCH_LEVEL "7.4" /* The only ver that wouldn't already set it */
42
#endif
43
#endif
44
45
#ifndef NO_TCL_INTERP /* Parsing stuff */
46
47
typedef struct ParseValue {
48
char *buffer; /* Address of first character in
49
* output buffer. */
50
char *next; /* Place to store next character in
51
* output buffer. */
52
char *end; /* Address of the last usable character
53
* in the buffer. */
54
void (*expandProc)(struct ParseValue *pvPtr, int needed);
55
/* Procedure to call when space runs out;
56
* it will make more space. */
57
ClientData clientData; /* Arbitrary information for use of
58
* expandProc. */
59
} ParseValue;
60
61
/*
62
* A table used to classify input characters to assist in parsing
63
* Tcl commands. The table should be indexed with a signed character
64
* using the CHAR_TYPE macro. The character may have a negative
65
* value.
66
*/
67
68
extern char tclTypeTable[];
69
#define CHAR_TYPE(c) (tclTypeTable+128)[c]
70
71
#if _BLD_tcl && defined(__EXPORT__)
72
#define extern __EXPORT__
73
#endif
74
75
/*
76
* Possible values returned by CHAR_TYPE:
77
*
78
* TCL_NORMAL - All characters that don't have special significance
79
* to the Tcl language.
80
* TCL_SPACE - Character is space, tab, or return.
81
* TCL_COMMAND_END - Character is newline or null or semicolon or
82
* close-bracket.
83
* TCL_QUOTE - Character is a double-quote.
84
* TCL_OPEN_BRACKET - Character is a "[".
85
* TCL_OPEN_BRACE - Character is a "{".
86
* TCL_CLOSE_BRACE - Character is a "}".
87
* TCL_BACKSLASH - Character is a "\".
88
* TCL_DOLLAR - Character is a "$".
89
*/
90
91
#define TCL_NORMAL 0
92
#define TCL_SPACE 1
93
#define TCL_COMMAND_END 2
94
#define TCL_QUOTE 3
95
#define TCL_OPEN_BRACKET 4
96
#define TCL_OPEN_BRACE 5
97
#define TCL_CLOSE_BRACE 6
98
#define TCL_BACKSLASH 7
99
#define TCL_DOLLAR 8
100
101
#ifndef TCL_BRACKET_TERM
102
#define TCL_BRACKET_TERM 1 /* in tcl7.3 header, not 7.4 */
103
#endif
104
#define TCL_ALLOW_EXCEPTIONS 4 /* in tcl7.4 only */
105
106
107
extern void TclExpandParseValue(ParseValue *pvPtr, int needed);
108
109
extern int TclNeedSpace(char *start, char *end);
110
111
extern void TclSetupEnv(Tcl_Interp *interp);
112
113
extern void TclWinFlushEvents(void);
114
115
extern int Tcl_NumEventsFound(void);
116
117
#endif
118
119
120
#ifndef NO_TCL_INTERP /* Tcl backward compat. stuff */
121
122
/*
123
*----------------------------------------------------------------
124
* Data structures related to procedures. These are used primarily
125
* in tclProc.c
126
*----------------------------------------------------------------
127
*/
128
129
/*
130
* The structure below defines an argument to a procedure, which
131
* consists of a name and an (optional) default value.
132
*/
133
134
typedef struct Arg {
135
struct Arg *nextPtr; /* Next argument for this procedure,
136
* or NULL if this is the last argument. */
137
char *defValue; /* Pointer to arg's default value, or NULL
138
* if no default value. */
139
char name[4]; /* Name of argument starts here. The name
140
* is followed by space for the default,
141
* if there is one. The actual size of this
142
* field will be as large as necessary to
143
* hold both name and default value. THIS
144
* MUST BE THE LAST FIELD IN THE STRUCTURE!! */
145
} Arg;
146
147
/*
148
* The structure below defines a command procedure, which consists of
149
* a collection of Tcl commands plus information about arguments and
150
* variables.
151
*/
152
153
typedef struct Proc {
154
struct Interp *iPtr; /* Interpreter for which this command
155
* is defined. */
156
int refCount; /* Reference count: 1 if still present
157
* in command table plus 1 for each call
158
* to the procedure that is currently
159
* active. This structure can be freed
160
* when refCount becomes zero. */
161
char *command; /* Command that constitutes the body of
162
* the procedure (dynamically allocated). */
163
Arg *argPtr; /* Pointer to first of procedure's formal
164
* arguments, or NULL if none. */
165
} Proc;
166
167
extern Proc * TclIsProc(Tcl_CmdInfo *cmdPtr);
168
extern Proc * TclFindProc(Interp *iPtr, char *procName);
169
extern int TclUpdateReturnInfo(Interp *iPtr);
170
171
extern char * TkshMapName(char *name);
172
extern char * TkshMapKeyword(char *name);
173
extern char * TkshLibDir(void);
174
175
extern int TkshSetListMode(int mode);
176
177
#endif
178
179
extern int Tcl_TclEval(Tcl_Interp *interp, char *cmd);
180
extern int Tcl_TclEvalFile(Tcl_Interp *interp, char *fileName);
181
182
#undef extern
183
184
#include "debug.h"
185
186
typedef struct TclEventSource {
187
Tcl_EventSetupProc *setupProc; /* This procedure is called by
188
* Tcl_DoOneEvent to set up information
189
* for the wait operation, such as
190
* files to wait for or maximum
191
* timeout. */
192
Tcl_EventCheckProc *checkProc; /* This procedure is called by
193
* Tcl_DoOneEvent after its wait
194
* operation to see what events
195
* are ready and queue them. */
196
ClientData clientData; /* Arbitrary one-word argument to pass
197
* to setupProc and checkProc. */
198
struct TclEventSource *nextPtr; /* Next in list of all event sources
199
* defined for applicaton. */
200
} TclEventSource;
201
202
#define TclPlatformExit(status) exit(status)
203
204
#if _BLD_tcl && defined(__EXPORT__)
205
#define extern __EXPORT__
206
#endif
207
208
EXTERN Tcl_Channel TclGetDefaultStdChannel(int type);
209
EXTERN Tcl_Channel TclFindFileChannel(Tcl_File inFil, Tcl_File outFile,
210
int *fileUsedPtr);
211
EXTERN int TclGetLoadedPackages(Tcl_Interp *interp,
212
char *targetName);
213
EXTERN int TclInterpInit(Tcl_Interp *interp);
214
EXTERN void TclPlatformInit(Tcl_Interp *interp);
215
EXTERN void TclFreePackageInfo(Interp *iPtr);
216
EXTERN int TclChdir(Tcl_Interp *interp, char *dirName);
217
EXTERN char * TclGetCwd(Tcl_Interp *interp);
218
EXTERN int TclPreventAliasLoop(Tcl_Interp *interp,
219
Tcl_Interp *cmdInterp, char *cmdName,
220
Tcl_CmdProc *proc, ClientData clientData);
221
EXTERN int TclFindElement(Tcl_Interp *interp,
222
char *list, char **elementPtr, char **nextPtr,
223
int *sizePtr, int *bracePtr);
224
EXTERN void TclCopyAndCollapse(int count, char *src, char *dst);
225
EXTERN int TclGetListIndex(Tcl_Interp *interp,
226
char *string, int *indexPtr);
227
EXTERN unsigned long TclGetSeconds(void);
228
EXTERN void TclGetTime(Tcl_Time *time);
229
EXTERN int TclGetTimeZ(unsigned long time);
230
EXTERN int TclGetDate(char *p, unsigned long now, long zone,
231
unsigned long *timePtr);
232
EXTERN int TclGuessPackageName(char *fileName,
233
Tcl_DString *bufPtr);
234
EXTERN int TclLoadFile(Tcl_Interp *interp,
235
char *fileName, char *sym1, char *sym2,
236
Tcl_PackageInitProc **proc1Ptr,
237
Tcl_PackageInitProc **proc2Ptr);
238
EXTERN char * TclGetExtension(char *name);
239
EXTERN int TclGetOpenMode(Tcl_Interp *interp,
240
char *string, int *seekFlagPtr);
241
EXTERN unsigned long TclGetClicks(void);
242
EXTERN int TclIdlePending(void);
243
EXTERN int TclServiceIdle(void);
244
EXTERN int TclWaitForFile(Tcl_File file, int mask, int timeout);
245
EXTERN int TclParseBraces(Tcl_Interp *interp,
246
char *string, char **termPtr, ParseValue *pvPtr);
247
EXTERN int TclParseNestedCmd(Tcl_Interp *interp,
248
char *string, int flags, char **termPtr,
249
ParseValue *pvPtr);
250
EXTERN int TclParseQuotes(Tcl_Interp *interp,
251
char *string, int termChar, int flags,
252
char **termPtr, ParseValue *pvPtr);
253
EXTERN int TclParseWords(Tcl_Interp *interp,
254
char *string, int flags, int maxWords,
255
char **termPtr, int *argcPtr, char **argv,
256
ParseValue *pvPtr);
257
258
259
260
extern char * TclPrecTraceProc(ClientData clientData,
261
Tcl_Interp *interp, char *name1, char *name2,
262
int flags);
263
264
#undef extern
265
266
/*
267
*----------------------------------------------------------------
268
* Variables shared among Tcl modules but not used by the outside
269
* world:
270
*----------------------------------------------------------------
271
*/
272
273
extern int tclInInterpreterDeletion;
274
extern char * tclExecutableName;
275
276
277
void TkshCreateInterp(Tcl_Interp *interp, void *data);
278
279
typedef struct Trace {
280
int level; /* Only trace commands at nesting level
281
* less than or equal to this. */
282
Tcl_CmdTraceProc *proc; /* Procedure to call to trace command. */
283
ClientData clientData; /* Arbitrary value to pass to proc. */
284
struct Trace *nextPtr; /* Next in list of traces for this interp. */
285
} Trace;
286
287
288
289
typedef struct AssocData {
290
Tcl_InterpDeleteProc *proc; /* Proc to call when deleting. */
291
ClientData clientData; /* Value to pass to proc. */
292
} AssocData;
293
294
#endif /* __TKSHLIB_H_ */
295
296