1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*******************************************************/
/* "C" Language Integrated Production System */
/* */
/* CLIPS Version 6.40 07/30/16 */
/* */
/* COMMAND LINE HEADER FILE */
/*******************************************************/
/*************************************************************/
/* Purpose: Provides a set of routines for processing */
/* commands entered at the top level prompt. */
/* */
/* Principal Programmer(s): */
/* Gary D. Riley */
/* */
/* Contributing Programmer(s): */
/* */
/* Revision History: */
/* */
/* 6.24: Renamed BOOLEAN macro type to intBool. */
/* */
/* Refactored several functions and added */
/* additional functions for use by an interface */
/* layered on top of CLIPS. */
/* */
/* 6.30: Local variables set with the bind function */
/* persist until a reset/clear command is issued. */
/* */
/* Changed garbage collection algorithm. */
/* */
/* Changed integer type/precision. */
/* */
/* Metrowerks CodeWarrior (MAC_MCW, IBM_MCW) is */
/* no longer supported. */
/* */
/* UTF-8 support. */
/* */
/* Command history and editing support */
/* */
/* Used genstrcpy instead of strcpy. */
/* */
/* Added before command execution callback */
/* function. */
/* */
/* Fixed RouteCommand return value. */
/* */
/* Added AwaitingInput flag. */
/* */
/* Added const qualifiers to remove C++ */
/* deprecation warnings. */
/* */
/* 6.40: Refactored code to reduce header dependencies */
/* in sysdep.c. */
/* */
/* Removed LOCALE definition. */
/* */
/* Pragma once and other inclusion changes. */
/* */
/* Added support for booleans with <stdbool.h>. */
/* */
/* Removed use of void pointers for specific */
/* data structures. */
/* */
/*************************************************************/
#ifndef _H_commline
#pragma once
#define _H_commline
#define COMMANDLINE_DATA 40
#include <stdlib.h>
typedef void AfterPromptFunction(Environment *);
typedef bool BeforeCommandExecutionFunction(Environment *);
typedef void EventFunction(Environment *);
struct commandLineData
{
bool EvaluatingTopLevelCommand;
bool HaltCommandLoopBatch;
#if ! RUN_TIME
struct expr *CurrentCommand;
char *CommandString;
size_t MaximumCharacters;
bool ParsingTopLevelCommand;
const char *BannerString;
EventFunction *EventCallback;
AfterPromptFunction *AfterPromptCallback;
BeforeCommandExecutionFunction *BeforeCommandExecutionCallback;
#endif
};
#define CommandLineData(theEnv) ((struct commandLineData *) GetEnvironmentData(theEnv,COMMANDLINE_DATA))
void InitializeCommandLineData(Environment *);
bool ExpandCommandString(Environment *,int);
void FlushCommandString(Environment *);
void SetCommandString(Environment *,const char *);
void AppendCommandString(Environment *,const char *);
void InsertCommandString(Environment *,const char *,unsigned);
char *GetCommandString(Environment *);
int CompleteCommand(const char *);
void CommandLoop(Environment *);
void CommandLoopBatch(Environment *);
void CommandLoopBatchDriver(Environment *);
void PrintPrompt(Environment *);
void PrintBanner(Environment *);
void SetAfterPromptFunction(Environment *,AfterPromptFunction *);
void SetBeforeCommandExecutionFunction(Environment *,BeforeCommandExecutionFunction *);
bool RouteCommand(Environment *,const char *,bool);
EventFunction *SetEventFunction(Environment *,EventFunction *);
bool TopLevelCommand(Environment *);
void AppendNCommandString(Environment *,const char *,unsigned);
void SetNCommandString(Environment *,const char *,unsigned);
const char *GetCommandCompletionString(Environment *,const char *,size_t);
bool ExecuteIfCommandComplete(Environment *);
void CommandLoopOnceThenBatch(Environment *);
bool CommandCompleteAndNotEmpty(Environment *);
void SetHaltCommandLoopBatch(Environment *,bool);
bool GetHaltCommandLoopBatch(Environment *);
void RerouteStdin(Environment *,int,char *[]);
#endif