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