GnuCash c935c2f+
Loading...
Searching...
No Matches
Files | Functions

The API in this file is used to read the environment configuration file and set up a number of environment variables based on the values found in it. More...

Files

file  gnc-environment.h
 code to set up the environment for proper gnucash functioning.
 

Functions

void gnc_environment_setup (void)
 Parse <prefix>/etc/gnucash/environment and set environment variables based on the contents of that file.
 

Detailed Description

The API in this file is used to read the environment configuration file and set up a number of environment variables based on the values found in it.

These parameters can be used to configure certain aspects of gnucash or components it depends on.

For example if not installed in the standard prefix "/usr", environment variable XDG_DATA_DIRS should be set such that glib can find the gsettings schemas installed by GnuCash and yelp can find the help file and guide (if these are installed).

Function Documentation

◆ gnc_environment_setup()

void gnc_environment_setup ( void  )

Parse <prefix>/etc/gnucash/environment and set environment variables based on the contents of that file.

Read the comments in <prefix>/etc/gnucash/environment for more details.

Definition at line 184 of file gnc-environment.c.

185{
186 gchar *config_path;
187 gchar *env_path;
188 gchar *env_parm;
189
190 /* Export default parameters to the environment */
191 env_parm = gnc_path_get_prefix();
192 if (!g_setenv("GNC_HOME", env_parm, TRUE))
193 g_warning ("Couldn't set/override environment variable GNC_HOME.");
194 g_free (env_parm);
195 env_parm = gnc_path_get_bindir();
196 if (!g_setenv("GNC_BIN", env_parm, TRUE))
197 g_warning ("Couldn't set/override environment variable GNC_BIN.");
198 g_free (env_parm);
199 env_parm = gnc_path_get_pkglibdir();
200 if (!g_setenv("GNC_LIB", env_parm, TRUE))
201 g_warning ("Couldn't set/override environment variable GNC_LIB.");
202 g_free (env_parm);
203 env_parm = gnc_path_get_pkgdatadir();
204 if (!g_setenv("GNC_DATA", env_parm, TRUE))
205 g_warning ("Couldn't set/override environment variable GNC_DATA.");
206 g_free (env_parm);
207 env_parm = gnc_path_get_pkgsysconfdir();
208 if (!g_setenv("GNC_CONF", env_parm, TRUE))
209 g_warning ("Couldn't set/override environment variable GNC_CONF.");
210 g_free (env_parm);
211 env_parm = gnc_path_get_libdir();
212 if (!g_setenv("SYS_LIB", env_parm, TRUE))
213 g_warning ("Couldn't set/override environment variable SYS_LIB.");
214 g_free (env_parm);
215
216 config_path = gnc_path_get_pkgsysconfdir();
217#ifdef G_OS_WIN32
218 {
219 /* unhide files without extension */
220 gchar *pathext = g_build_path(";", ".", g_getenv("PATHEXT"),
221 (gchar*) NULL);
222 g_setenv("PATHEXT", pathext, TRUE);
223 g_free(pathext);
224 }
225#endif
226
227 /* Parse the environment file that got installed with gnucash */
228 env_path = g_build_filename (config_path, "environment", NULL);
229 gnc_environment_parse_one(env_path);
230 g_free (env_path);
231
232 /* Parse local overrides for this file */
233 env_path = g_build_filename (config_path, "environment.local", NULL);
234 gnc_environment_parse_one(env_path);
235 g_free (env_path);
236 g_free (config_path);
237}