| Libgretl Reference Manual | ||||
|---|---|---|---|---|
| Top | Description | ||||
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);
typedef enum {
CURRENT_DIR,
DATA_SEARCH,
SCRIPT_SEARCH,
FUNCS_SEARCH,
USER_SEARCH
} SearchLocation;
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). |
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. |
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().
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.
|
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.
|
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. |
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. |
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. |
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.
|
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. |
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. |
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. |
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. |
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. |
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.
|
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.
|
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.
|
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.
|
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.
|
int has_system_prefix (const char *fname,
int locus);
fname : |
|
locus : |
|
| Returns : |
int gretl_update_paths (ConfigPaths *cpaths, gretlopt opt);
cpaths : |
|
opt : |
|
| Returns : |
const char * gretl_maybe_switch_dir (const char *fname);
fname : |
|
| Returns : |
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.
|