1 /*
2  *  gretl -- Gnu Regression, Econometrics and Time-series Library
3  *  Copyright (C) 2001 Allin Cottrell and Riccardo "Jack" Lucchetti
4  *
5  *  This program is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation, either version 3 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  *
18  */
19 
20 /* interact.h for gretl */
21 
22 #ifndef INTERACT_H
23 #define INTERACT_H
24 
25 #define MAXSAVENAME 32
26 #define CMD_NULL    -1
27 #define CMD_COMMENT -2
28 #define CMD_MASKED  -3
29 
30 typedef struct CMD_ CMD;
31 typedef struct ExecState_ ExecState;
32 
33 typedef enum {
34     OPT_BATCH   = 1 << 0,
35     OPT_HELP    = 1 << 1,
36     OPT_VERSION = 1 << 2,
37     OPT_RUNIT   = 1 << 3,
38     OPT_DBOPEN  = 1 << 4,
39     OPT_WEBDB   = 1 << 5,
40     OPT_FNPKG   = 1 << 6,
41     OPT_DUMP    = 1 << 7,
42     OPT_DEBUG   = 1 << 8,
43     OPT_QUIET   = 1 << 9,
44     OPT_ENGLISH = 1 << 10,
45     OPT_BASQUE  = 1 << 11,
46     OPT_MAKEPKG = 1 << 12,
47     OPT_INSTPKG = 1 << 13,
48     OPT_TOOL    = 1 << 14
49 } ProgramOptions;
50 
51 typedef enum {
52     CONSOLE_EXEC      = 1 << 0,
53     SCRIPT_EXEC       = 1 << 1,
54     INCLUDE_EXEC      = 1 << 2,
55     FUNCTION_EXEC     = 1 << 3,
56     DEBUG_EXEC        = 1 << 4,
57     CALLBACK_EXEC     = 1 << 5,
58     INIT_EXEC         = 1 << 6
59 } ExecFlags;
60 
61 #define HIDDEN_COMMAND(c) (c == FUNCERR || c == FUNCRET)
62 
63 /* functions follow */
64 
65 int gretl_cmd_init (CMD *cmd);
66 
67 void gretl_cmd_free (CMD *cmd);
68 
69 CMD *gretl_cmd_new (void);
70 
71 void gretl_cmd_destroy (CMD *cmd);
72 
73 void gretl_cmd_set_context (CMD *cmd, int ci);
74 
75 void gretl_cmd_destroy_context (CMD *cmd);
76 
77 const char *gretl_cmd_get_savename (CMD *cmd);
78 
79 gretlopt gretl_cmd_get_opt (const CMD *cmd);
80 
81 void gretl_cmd_set_opt (CMD *cmd, gretlopt opt);
82 
83 int parse_command_line (ExecState *s, DATASET *dset, void *ptr);
84 
85 int parse_gui_command (char *line, CMD *cmd, DATASET *dset);
86 
87 const char *get_parser_errline (void);
88 
89 int get_command_index (ExecState *s, int cmode);
90 
91 int command_number (const char *cmd);
92 
93 void gretl_echo_command (CMD *cmd, const char *line, PRN *prn);
94 
95 void gretl_record_command (CMD *cmd, const char *line, PRN *prn);
96 
97 void safe_print_line (const char *line, int *plen, PRN *prn);
98 
99 int gretl_cmd_exec (ExecState *s, DATASET *dset);
100 
101 int call_pca_plugin (VMatrix *cmat, DATASET *dset,
102 		     gretlopt opt, PRN *prn);
103 
104 int gretl_shell_grab (const char *arg, char **sout);
105 
106 void manufacture_gui_callback (int ci);
107 
108 void gretl_flush (PRN *prn);
109 
110 int is_plotting_command (CMD *cmd);
111 
112 void set_plot_produced (void);
113 
114 int gretl_delete_variables (int *list,
115 			    const char *param,
116 			    gretlopt opt,
117 			    DATASET *dset,
118 			    int *renumber,
119 			    PRN *prn);
120 
121 int lib_join_data (const char *param,
122 		   const char *filename,
123 		   DATASET *dset,
124 		   gretlopt opt,
125 		   PRN *prn);
126 
127 #endif /* INTERACT_H */
128 
129 
130