interact

interact —

Synopsis

#define             MAXSAVENAME
#define             CMD_NULL
#define             CMD_COMMENT
typedef             CMD;
typedef             ExecState;
enum                CmdEchoFlags;
enum                ProgramOptions;
enum                ExecFlags;
#define             HIDDEN_COMMAND                      (c)
int                 gretl_cmd_init                      (CMD *cmd);
void                gretl_cmd_free                      (CMD *cmd);
CMD *               gretl_cmd_new                       (void);
void                gretl_cmd_destroy                   (CMD *cmd);
void                gretl_cmd_set_context               (CMD *cmd,
                                                         int ci);
void                gretl_cmd_destroy_context           (CMD *cmd);
char *              gretl_cmd_get_savename              (char *sname);
gretlopt            gretl_cmd_get_opt                   (const CMD *cmd);
void                gretl_cmd_set_opt                   (CMD *cmd,
                                                         gretlopt opt);
int                 parse_command_line                  (char *line,
                                                         CMD *cmd,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo);
int                 get_command_index                   (char *line,
                                                         CMD *cmd);
int                 command_number                      (const char *cmd);
int                 cli_help                            (const char *cmdword,
                                                         gretlopt opt,
                                                         PRN *prn);
int                 parseopt                            (int *pargc,
                                                         char ***pargv,
                                                         gretlopt *popt,
                                                         char *fname);
void                echo_cmd                            (const CMD *cmd,
                                                         const DATAINFO *pdinfo,
                                                         const char *line,
                                                         unsigned char flags,
                                                         PRN *prn);
void                echo_function_call                  (const char *line,
                                                         unsigned char flags,
                                                         PRN *prn);
void                safe_print_line                     (const char *line,
                                                         int *plen,
                                                         PRN *prn);
int                 gretl_cmd_exec                      (ExecState *s,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo);
int                 call_pca_plugin                     (VMatrix *cmat,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);
int                 gretl_shell_grab                    (const char *arg,
                                                         char **sout);

Description

Details

MAXSAVENAME

#define MAXSAVENAME 32


CMD_NULL

#define CMD_NULL    -1


CMD_COMMENT

#define CMD_COMMENT -2


CMD

typedef struct CMD_ CMD;


ExecState

typedef struct ExecState_ ExecState;


enum CmdEchoFlags

typedef enum {
    CMD_BATCH_MODE     = 1 << 0,
    CMD_STACKING       = 1 << 1,
    CMD_RECORDING      = 1 << 2,
    CMD_CLI            = 1 << 3
} CmdEchoFlags;


enum ProgramOptions

typedef enum {
    OPT_BATCH   = 1 << 0,
    OPT_HELP    = 1 << 1,
    OPT_VERSION = 1 << 2,
    OPT_RUNIT   = 1 << 3,
    OPT_DBOPEN  = 1 << 4,
    OPT_WEBDB   = 1 << 5,
    OPT_FNPKG   = 1 << 6,
    OPT_DUMP    = 1 << 7,
    OPT_DEBUG   = 1 << 8,
    OPT_QUIET   = 1 << 9,
    OPT_ENGLISH = 1 << 10
} ProgramOptions;


enum ExecFlags

typedef enum {
    CONSOLE_EXEC      = 1 << 0,
    SCRIPT_EXEC       = 1 << 1,
    INCLUDE_EXEC      = 1 << 2,
    FUNCTION_EXEC     = 1 << 3,
    DEBUG_EXEC        = 1 << 4
} ExecFlags;


HIDDEN_COMMAND()

#define HIDDEN_COMMAND(c) (c == FUNCERR || c == FUNCRET)

c :

gretl_cmd_init ()

int                 gretl_cmd_init                      (CMD *cmd);

cmd :
Returns :

gretl_cmd_free ()

void                gretl_cmd_free                      (CMD *cmd);

cmd :

gretl_cmd_new ()

CMD *               gretl_cmd_new                       (void);

Returns :

gretl_cmd_destroy ()

void                gretl_cmd_destroy                   (CMD *cmd);

cmd :

gretl_cmd_set_context ()

void                gretl_cmd_set_context               (CMD *cmd,
                                                         int ci);

cmd :
ci :

gretl_cmd_destroy_context ()

void                gretl_cmd_destroy_context           (CMD *cmd);

cmd :

gretl_cmd_get_savename ()

char *              gretl_cmd_get_savename              (char *sname);

sname :
Returns :

gretl_cmd_get_opt ()

gretlopt            gretl_cmd_get_opt                   (const CMD *cmd);

cmd :
Returns :

gretl_cmd_set_opt ()

void                gretl_cmd_set_opt                   (CMD *cmd,
                                                         gretlopt opt);

cmd :
opt :

parse_command_line ()

int                 parse_command_line                  (char *line,
                                                         CMD *cmd,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo);

Parses line and fills out cmd accordingly.

line : the command line.
cmd : pointer to command struct.
pZ : pointer to data matrix.
pdinfo : pointer to data information struct.
Returns : 0 on success, non-zero error code on error.

get_command_index ()

int                 get_command_index                   (char *line,
                                                         CMD *cmd);

Parse line and assign to the ci field of cmd the index number of the command embedded in line. Note: this is a "lite" version of parse_command_line(). It is used when commands are being stacked for execution within a loop. Command options are not parsed out of line.

line : command line.
cmd : pointer to gretl command struct.
Returns : 1 on error, otherwise 0.

command_number ()

int                 command_number                      (const char *cmd);

cmd :
Returns :

cli_help ()

int                 cli_help                            (const char *cmdword,
                                                         gretlopt opt,
                                                         PRN *prn);

Searches in the gretl helpfile for help on cmdword and, if help is found, prints it to prn. If cmdword is NULL, lists the valid commands.

cmdword : the command on which help is wanted.
opt : may include OPT_F to give priority to functions rather than commands.
prn : pointer to gretl printing struct.
Returns : 0 on success, 1 if the helpfile was not found or the requested topic was not found.

parseopt ()

int                 parseopt                            (int *pargc,
                                                         char ***pargv,
                                                         gretlopt *popt,
                                                         char *fname);

Parses options out of the command line into popt and fills out fname if applicable.

pargc : pointer to count of arguments.
pargv : pointer to command-line argument array.
popt : location to receive option(s).
fname : optional filename argument.
Returns : 0 on success, non-zero in case of bad options.

echo_cmd ()

void                echo_cmd                            (const CMD *cmd,
                                                         const DATAINFO *pdinfo,
                                                         const char *line,
                                                         unsigned char flags,
                                                         PRN *prn);

Echoes the user command represented by cmd and line, to stdout (if prn is NULL) or prn. This is used for two distinct purposes: to give visual feedback on the command supplied, and (in some contexts) to record a command that was executed interactively.

cmd : pointer to CMD struct.
pdinfo : pointer to data information struct.
line : "raw" command line associated with cmd.
flags : bitwise OR of elements from CmdEchoFlags.
prn : pointer to gretl printing struct (or NULL).

echo_function_call ()

void                echo_function_call                  (const char *line,
                                                         unsigned char flags,
                                                         PRN *prn);

line :
flags :
prn :

safe_print_line ()

void                safe_print_line                     (const char *line,
                                                         int *plen,
                                                         PRN *prn);

line :
plen :
prn :

gretl_cmd_exec ()

int                 gretl_cmd_exec                      (ExecState *s,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo);

s :
pZ :
pdinfo :
Returns :

call_pca_plugin ()

int                 call_pca_plugin                     (VMatrix *cmat,
                                                         double ***pZ,
                                                         DATAINFO *pdinfo,
                                                         gretlopt opt,
                                                         PRN *prn);

cmat :
pZ :
pdinfo :
opt :
prn :
Returns :

gretl_shell_grab ()

int                 gretl_shell_grab                    (const char *arg,
                                                         char **sout);

Calls the shell to execute arg syncronously and captures the standard output, if any, in sout.

arg : command line to be executed.
sout : location to receive output from command.
Returns : 0 on successful completion, non-zero on error.