Top |
enum | SearchType |
enum | HelpPaths |
enum | PkgType |
typedef | ConfigPaths |
struct | ConfigPaths_ |
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.
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.
int
utf8_encoded (const char *s
);
The primary use of this function is to determine whether a filename can be passed to regular C-library functions on MS Windows: if it's in UTF-8 the answer is No -- unless it's in the ASCII subset of UTF-8.
FILE * gretl_fopen (const char *fname
,const char *mode
);
A wrapper for the C library's fopen()
, using
g_fopen()
on Windows, and adding some error handling.
int gretl_test_fopen (const char *fname
,const char *mode
);
Attempts to open fname
in the given mode; if the opening
is successful the stream is then closed.
FILE *
gretl_read_user_file (const char *fname
);
Attempts to open fname
in read-only mode. If the file
is not found when the name is used "as is", we use
gretl_maybe_prepend_dir()
to prepend the user's gretl
working directory and try again.
FILE * gretl_mktemp (char *pattern
,const char *mode
);
A wrapper for the combination of mkstemp()
and fdopen()
,
using the associated GLib functions on Windows.
On successful exit pattern
holds the name of the newly
created file.
int gretl_open (const char *pathname
,int flags
,int mode
);
A wrapper for the C library's open()
, using GLib on
Windows and adding some error handling.
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.
int
gretl_remove (const char *path
);
A wrapper for remove()
, using the GLib counterpart
on Windows.
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 UTF-16.
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.
int
gretl_file_exists (const char *fname
);
Uses the C library's stat()
function, making allowance for
the possibility that fname
has to be converted from UTF-8
to the locale encoding or vice versa.
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.
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 UTF-16 on Windows.
int
gretl_deltree (const char *path
);
Carries out recursive deletion of the specified directory.
int gretl_setenv (const char *name
,const char *value
);
Cross-platform wrapper for setenv()
.
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 UTF-16.
char * gretl_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 get_full_filename()
.
If fname
does not already have a dot-extension we may also try adding
an appropriate gretl extension in case no file is found.
fname |
on input, the initially given file name; on output a path may be prepended and/or a suffix may be appended. This variable must be of size at least MAXLEN bytes to allow for possible additions. |
|
script |
if non-zero, assume the file we're looking for is a hansl script. |
int get_full_filename (const char *fname
,char *fullname
,gretlopt opt
);
Includes elementary path-searching: try adding various paths to the
given fname
, if appropriate, and see if it can be opened. For
internal gretl use.
fname |
input filename. |
|
fullname |
filename to be filled out: must be at least MAXLEN bytes. |
|
opt |
if OPT_S, treat as a script; if OPT_I we're responding
to the "include" command; if OPT_W, pass |
char ** get_plausible_search_dirs (SearchType stype
,int *n_dirs
);
stype |
DATA_SEARCH for data file packages, DB_SEARCH for gretl databases, FUNCS_SEARCH for function packages, or SCRIPT_SEARCH for hansl scripts. |
|
n_dirs |
location to receive the number of directories. |
an array of plausible search paths, depending on the
type
of search. The array should be freed when you are done
with it, using strings_array_free()
.
char * gretl_function_package_get_path (const char *name
,PkgType type
);
Searches a list of directories in which we might expect to find function packages, and, if the package in question is found, returns a newly allocated string holding the full path to the package's gfn file. Public (system) directories are searched first, then directories in the user's filespace.
name |
the name of the package to find, without the .gfn extension. |
|
type |
|
int get_package_data_path (int ci
,const char *fname
,char *fullname
);
Looks for fname
in association with the name of a function
package, which must have been set previously using the
--frompkg option with the "open" command.
void
set_gretl_plugin_path (const char *path
);
For use by third-party code: the purpose of this function is to ensure that libgretl can find its plugins.
prefix
, if given, should be the path under which the plugins
are installed. On a unix-type system this might be, for example,
/usr/local/lib/gretl-gtk2; on MS Windows it might be
c:\program files\gretl\plugins.
const char *
maybe_get_default_workdir (void
);
Figures the full path to the default value of the
user's gretl working directory; call this defdir
.
If this defdir
turns out to be the same as the
current gretl working directory, as would be returned
by gretl_workdir()
, this function returns NULL,
otherwise it returns the defdir
value.
char *
gretl_maybe_prepend_dir (char *fname
);
If fname
starts with the construction "~/" to indicate
the user's HOME, replace this with the full path to that
directory. Otherwise, if fname
is not already an
absolute path, prepend the user's gretl working directory.
Otherwise do nothing.
void get_gretl_config_from_file (FILE *fp
,ConfigPaths *cpaths
,char *dbproxy
,int *use_proxy
,int *updated
,gchar **gptheme
);
char * gretl_build_path (char *targ
,const gchar *first_element
,...
);
Writes to targ
a path composed of first_element
plus any additional string arguments supplied before
a terminating NULL. An appropriate separator is inserted
between the components of the path.
struct ConfigPaths_ { char gretldir[MAXLEN]; char workdir[MAXLEN]; #if !defined(WIN32) || !defined(PKGBUILD) char gnuplot[MAXLEN]; #endif char x12a[MAXLEN]; char tramo[MAXLEN]; char rbinpath[MAXLEN]; char rlibpath[MAXLEN]; char oxlpath[MAXLEN]; char octpath[MAXLEN]; char statapath[MAXLEN]; char pypath[MAXLEN]; char jlpath[MAXLEN]; char lppath[MAXLEN]; char mpiexec[MAXLEN]; char mpi_hosts[MAXLEN]; char pngfont[128]; int no_dotdir; };