gretl_paths

gretl_paths —

Synopsis

enum                SearchLocation;
enum                HelpPaths;
typedef             ConfigPaths;
void                set_string_table_written            (void);
int                 gretl_string_table_written          (void);
int                 gretl_path_prepend                  (char *file,
                                                         const char *path);
int                 gretl_normalize_path                (char *path);
int                 slash_terminate                     (char *path);
void                set_stdio_use_utf8                  (void);
int                 get_stdio_use_utf8                  (void);
int                 string_is_utf8                      (unsigned char *s);
FILE *              gretl_fopen                         (const char *fname,
                                                         const char *mode);
int                 gretl_open                          (const char *pathname,
                                                         int flags);
int                 gretl_rename                        (const char *oldpath,
                                                         const char *newpath);
int                 gretl_remove                        (const char *path);
gzFile              gretl_gzopen                        (const char *fname,
                                                         const char *mode);
int                 gretl_stat                          (const char *fname,
                                                         struct stat *buf);
int                 gretl_mkdir                         (const char *path);
int                 gretl_chdir                         (const char *path);
int                 gretl_deltree                       (const char *path);
int                 gretl_setenv                        (const char *name,
                                                         const char *value);
int                 gretl_write_access                  (char *fname);
int                 gretl_is_xml_file                   (const char *fname);
int                 gretl_isdir                         (const char *path);
char *              addpath                             (char *fname,
                                                         int script);
int                 getopenfile                         (const char *line,
                                                         char *fname,
                                                         gretlopt opt);
int                 fname_has_path                      (const char *fname);
int                 has_system_prefix                   (const char *fname,
                                                         int locus);
void                show_paths                          (void);
int                 gretl_set_paths                     (ConfigPaths *paths,
                                                         gretlopt opt);
int                 gretl_update_paths                  (ConfigPaths *cpaths,
                                                         gretlopt opt);
const char *        helpfile_path                       (int id);
const char *        gretl_home                          (void);
const char *        gretl_lib_path                      (void);
const char *        gretl_dotdir                        (void);
const char *        gretl_workdir                       (void);
char *              gretl_default_workdir               (void);
int                 set_gretl_work_dir                  (const char *path);
const char *        gretl_maybe_switch_dir              (const char *fname);
char *              gretl_maybe_prepend_dir             (char *fname);
const char *        gretl_gnuplot_path                  (void);
const char *        gretl_plotfile                      (void);
char *              set_gretl_plotfile                  (const char *fname);
const char *        gretl_binbase                       (void);
const char *        gretl_ratsbase                      (void);
const char *        gretl_tramo                         (void);
const char *        gretl_tramo_dir                     (void);
const char *        gretl_x12_arima                     (void);
const char *        gretl_x12_arima_dir                 (void);
const char *        gretl_rbin_path                     (void);
const char *        gretl_rlib_path                     (void);
const char *        gretl_png_font                      (void);
const char *        gretl_oxl_path                      (void);
const char *        gretl_current_dir                   (void);
void                gretl_set_current_dir               (const char *s);
void                set_gretl_png_font                  (const char *s);
int                 gretl_mkstemp                       (char *tmpl);
void                get_gretl_rc_path                   (char *rcfile);
int                 cli_read_rc                         (void);

Description

Details

enum SearchLocation

typedef enum {
    CURRENT_DIR,
    DATA_SEARCH,
    SCRIPT_SEARCH,
    FUNCS_SEARCH,
    USER_SEARCH
} SearchLocation;


enum HelpPaths

typedef enum {
    GRETL_HELPFILE,
    GRETL_CMD_HELPFILE,
    GRETL_CLI_HELPFILE
} HelpPaths;


ConfigPaths

typedef struct ConfigPaths_ ConfigPaths;


set_string_table_written ()

void                set_string_table_written            (void);


gretl_string_table_written ()

int                 gretl_string_table_written          (void);

Returns :

gretl_path_prepend ()

int                 gretl_path_prepend                  (char *file,
                                                         const char *path);

Creates a path string by prepending path, plus an appropriate separator if needed, to file. The result is written back into file: this variable is assumed to have storage for at least MAXLEN characters.

file : target filename.
path : path to prepend.
Returns : 0 on success, or 1 if the final path string would exceed MAXLEN characters (including nul-termination).

gretl_normalize_path ()

int                 gretl_normalize_path                (char *path);

path :
Returns :

slash_terminate ()

int                 slash_terminate                     (char *path);

Check whether path is already slash-terminated, and if not, append a SLASH; path should be a large enough array to accept an extra byte.

path : path string.
Returns : 1 if a slash was appended, otherwise 0.

set_stdio_use_utf8 ()

void                set_stdio_use_utf8                  (void);

Sets gretl's internal state so as to ensure that filenames are given in UTF-8 when passed to functions such as the C library's fopen().


get_stdio_use_utf8 ()

int                 get_stdio_use_utf8                  (void);

Returns : 1 if filenames should be in UTF-8 when passed to the C library's fopen() and friends, otherwise 0.

string_is_utf8 ()

int                 string_is_utf8                      (unsigned char *s);

s :
Returns :

gretl_fopen ()

FILE *              gretl_fopen                         (const char *fname,
                                                         const char *mode);

A wrapper for the C library's fopen(), making allowance for the possibility that fname has to be converted from UTF-8 to the locale encoding or vice versa.

fname : name of file to be opened.
mode : mode in which to open the file.
Returns : file pointer, or NULL on failure.

gretl_open ()

int                 gretl_open                          (const char *pathname,
                                                         int flags);

A wrapper for the C library's open(), making allowance for the possibility that pathname has to be converted from UTF-8 to the locale encoding or vice versa.

pathname : name of file to be opened.
flags : flags to pass to the system open().
Returns : new file descriptor, or -1 on error.

gretl_rename ()

int                 gretl_rename                        (const char *oldpath,
                                                         const char *newpath);

A wrapper for the C library's rename(), making allowance for the possibility that oldpath and/or newpath have to be converted from UTF-8 to the locale encoding or vice versa.

oldpath : name of file to be opened.
newpath : new name to give the file.
Returns : 0 on success, non-zero on failure.

gretl_remove ()

int                 gretl_remove                        (const char *path);

A wrapper for remove(), making allowance for the possibility that path has to be converted from UTF-8 to the locale encoding or vice versa.

path : name of file or directory to remove.
Returns : 0 on sucess, non-zero on failure.

gretl_gzopen ()

gzFile              gretl_gzopen                        (const char *fname,
                                                         const char *mode);

A wrapper for zlib's gzopen(), making allowance for the possibility that fname has to be converted from UTF-8 to the locale encoding or vice versa.

fname : name of gzipped file to be opened.
mode : mode in which to open the file.
Returns : pointer to gzip stream, or NULL on failure.

gretl_stat ()

int                 gretl_stat                          (const char *fname,
                                                         struct stat *buf);

A wrapper for the C library's stat(), making allowance for the possibility that fname has to be converted from UTF-8 to the locale encoding or vice versa.

fname : name of file to be examined.
buf : pointer to struct stat.
Returns : 0 on success, non-zero on failure.

gretl_mkdir ()

int                 gretl_mkdir                         (const char *path);

Calls the underlying library function to create the specified directory with mode 0755. If the directory in question already exists, this does not count as an error.

path : name of directory to be created.
Returns : 0 on success, non-zero on error.

gretl_chdir ()

int                 gretl_chdir                         (const char *path);

A wrapper for POSIX chdir(), making allowance for the possibility that path has to be converted from UTF-8 to the locale encoding or vice versa.

path : name of directory.
Returns : 0 on sucess, non-zero on failure.

gretl_deltree ()

int                 gretl_deltree                       (const char *path);

Carries out recursive deletion of the specified directory. Note: the current working directory should be set to one level above path when this function is called. FIXME.

path : name of directory to be deleted.
Returns : 0 on success, non-zero on error.

gretl_setenv ()

int                 gretl_setenv                        (const char *name,
                                                         const char *value);

Cross-platform wrapper for setenv().

name : name of variable to be set.
value : value to set.
Returns : 0 on success, non-zero on failure.

gretl_write_access ()

int                 gretl_write_access                  (char *fname);

fname : name of file to test.
Returns : 0 on success (meaning that the current user has write access to fname), non-zero on failure.

gretl_is_xml_file ()

int                 gretl_is_xml_file                   (const char *fname);

fname : name of file to test.
Returns : 1 if fname appears to be a (possibly gzipped) XML file, otherwise 0.

gretl_isdir ()

int                 gretl_isdir                         (const char *path);

A test for whether or not path is the name of a directory, allowing for the possibility that path has to be converted from UTF-8 to the locale encoding or vice versa.

path : path to check.
Returns : 1 if path is the name of a directory, else 0.

addpath ()

char *              addpath                             (char *fname,
                                                         int script);

Elementary path-searching: try adding various paths to the given fname and see if it can be opened. Usually called by getopenfile().

fname : initially given file name.
script : if non-zero, suppose the file is a command script.
Returns : the full name of the file that was found, or NULL if no file could be found.

getopenfile ()

int                 getopenfile                         (const char *line,
                                                         char *fname,
                                                         gretlopt opt);

Elementary path-searching: try adding various paths to the given fname and see if it can be opened.

line : command line (e.g. "open foo").
fname : filename to be filled out.
opt : if includes OPT_W, treat as web filename and don't try to add path, if OPT_S, treat as a script.
Returns : 0 on successful parsing of line, 1 on error.

fname_has_path ()

int                 fname_has_path                      (const char *fname);

fname :
Returns :

has_system_prefix ()

int                 has_system_prefix                   (const char *fname,
                                                         int locus);

fname :
locus :
Returns :

show_paths ()

void                show_paths                          (void);


gretl_set_paths ()

int                 gretl_set_paths                     (ConfigPaths *paths,
                                                         gretlopt opt);

paths :
opt :
Returns :

gretl_update_paths ()

int                 gretl_update_paths                  (ConfigPaths *cpaths,
                                                         gretlopt opt);

cpaths :
opt :
Returns :

helpfile_path ()

const char *        helpfile_path                       (int id);

id :
Returns :

gretl_home ()

const char *        gretl_home                          (void);

Returns :

gretl_lib_path ()

const char *        gretl_lib_path                      (void);

Returns :

gretl_dotdir ()

const char *        gretl_dotdir                        (void);

Returns :

gretl_workdir ()

const char *        gretl_workdir                       (void);

Returns :

gretl_default_workdir ()

char *              gretl_default_workdir               (void);

Returns :

set_gretl_work_dir ()

int                 set_gretl_work_dir                  (const char *path);

path :
Returns :

gretl_maybe_switch_dir ()

const char *        gretl_maybe_switch_dir              (const char *fname);

fname :
Returns :

gretl_maybe_prepend_dir ()

char *              gretl_maybe_prepend_dir             (char *fname);

fname :
Returns :

gretl_gnuplot_path ()

const char *        gretl_gnuplot_path                  (void);

Returns :

gretl_plotfile ()

const char *        gretl_plotfile                      (void);

Returns :

set_gretl_plotfile ()

char *              set_gretl_plotfile                  (const char *fname);

fname :
Returns :

gretl_binbase ()

const char *        gretl_binbase                       (void);

Returns :

gretl_ratsbase ()

const char *        gretl_ratsbase                      (void);

Returns :

gretl_tramo ()

const char *        gretl_tramo                         (void);

Returns :

gretl_tramo_dir ()

const char *        gretl_tramo_dir                     (void);

Returns :

gretl_x12_arima ()

const char *        gretl_x12_arima                     (void);

Returns :

gretl_x12_arima_dir ()

const char *        gretl_x12_arima_dir                 (void);

Returns :

gretl_rbin_path ()

const char *        gretl_rbin_path                     (void);

Returns :

gretl_rlib_path ()

const char *        gretl_rlib_path                     (void);

Returns :

gretl_png_font ()

const char *        gretl_png_font                      (void);

Returns :

gretl_oxl_path ()

const char *        gretl_oxl_path                      (void);

Returns :

gretl_current_dir ()

const char *        gretl_current_dir                   (void);

Returns :

gretl_set_current_dir ()

void                gretl_set_current_dir               (const char *s);

s :

set_gretl_png_font ()

void                set_gretl_png_font                  (const char *s);

s :

gretl_mkstemp ()

int                 gretl_mkstemp                       (char *tmpl);

tmpl : template filename.
Returns : A file handle (as from open()) to the file opened for reading and writing, or -1 on failure.

get_gretl_rc_path ()

void                get_gretl_rc_path                   (char *rcfile);

rcfile :

cli_read_rc ()

int                 cli_read_rc                         (void);

Returns :