GnuCash  4.11-354-g0815ab64c1
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. More...
 

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 165 of file gnc-environment.c.

166 {
167  gchar *config_path;
168  gchar *env_path;
169  gchar *env_parm;
170 
171  /* Export default parameters to the environment */
172  env_parm = gnc_path_get_prefix();
173  if (!g_setenv("GNC_HOME", env_parm, FALSE))
174  g_warning ("Couldn't set/override environment variable GNC_HOME.");
175  g_free (env_parm);
176  env_parm = gnc_path_get_bindir();
177  if (!g_setenv("GNC_BIN", env_parm, FALSE))
178  g_warning ("Couldn't set/override environment variable GNC_BIN.");
179  g_free (env_parm);
180  env_parm = gnc_path_get_pkglibdir();
181  if (!g_setenv("GNC_LIB", env_parm, FALSE))
182  g_warning ("Couldn't set/override environment variable GNC_LIB.");
183  g_free (env_parm);
184  env_parm = gnc_path_get_pkgdatadir();
185  if (!g_setenv("GNC_DATA", env_parm, FALSE))
186  g_warning ("Couldn't set/override environment variable GNC_DATA.");
187  g_free (env_parm);
188  env_parm = gnc_path_get_pkgsysconfdir();
189  if (!g_setenv("GNC_CONF", env_parm, FALSE))
190  g_warning ("Couldn't set/override environment variable GNC_CONF.");
191  g_free (env_parm);
192  env_parm = gnc_path_get_libdir();
193  if (!g_setenv("SYS_LIB", env_parm, FALSE))
194  g_warning ("Couldn't set/override environment variable SYS_LIB.");
195  g_free (env_parm);
196 
197  config_path = gnc_path_get_pkgsysconfdir();
198 #ifdef G_OS_WIN32
199  {
200  /* unhide files without extension */
201  gchar *pathext = g_build_path(";", ".", g_getenv("PATHEXT"),
202  (gchar*) NULL);
203  g_setenv("PATHEXT", pathext, TRUE);
204  g_free(pathext);
205  }
206 #endif
207 
208  /* Parse the environment file that got installed with gnucash */
209  env_path = g_build_filename (config_path, "environment", NULL);
210  gnc_environment_parse_one(env_path);
211  g_free (env_path);
212 
213  /* Parse local overrides for this file */
214  env_path = g_build_filename (config_path, "environment.local", NULL);
215  gnc_environment_parse_one(env_path);
216  g_free (env_path);
217  g_free (config_path);
218 }