aboutsummaryrefslogtreecommitdiff
path: root/src/util/program.c
diff options
context:
space:
mode:
authorAlessio Vanni <vannilla@firemail.cc>2020-10-10 17:19:53 +0200
committerChristian Grothoff <christian@grothoff.org>2020-10-11 10:30:46 +0200
commit77339944c9605919a035744df1a839a6e5793a37 (patch)
tree39314fcbb31f3aa6b3c2050a40bcfa151f717873 /src/util/program.c
parent03199f7f246e1d636c9feb921d66be48c907130f (diff)
downloadgnunet-77339944c9605919a035744df1a839a6e5793a37.tar.gz
gnunet-77339944c9605919a035744df1a839a6e5793a37.zip
Allow applications to change ProjectData with only some fields
Some simple applications (e.g. thin clients) might want to change the ProjectData structure (e.g. for gettext), but might not meet all the requirements needed to fill it out completely. A thin client might not provide any library, making the `libname' field useless. More importantly, not every application requires a configuration: some of them, especially clients, might simply use command line options to drive their behaviour.
Diffstat (limited to 'src/util/program.c')
-rw-r--r--src/util/program.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/util/program.c b/src/util/program.c
index 8bda34b4f..b5484855c 100644
--- a/src/util/program.c
+++ b/src/util/program.c
@@ -232,15 +232,20 @@ GNUNET_PROGRAM_run2 (int argc,
232 sizeof(struct GNUNET_GETOPT_CommandLineOption), 232 sizeof(struct GNUNET_GETOPT_CommandLineOption),
233 &cmd_sorter); 233 &cmd_sorter);
234 loglev = NULL; 234 loglev = NULL;
235 xdg = getenv ("XDG_CONFIG_HOME"); 235 if (NULL != pd->config_file && NULL != pd->user_config_file)
236 if (NULL != xdg) 236 {
237 GNUNET_asprintf (&cfg_fn, 237 xdg = getenv ("XDG_CONFIG_HOME");
238 "%s%s%s", 238 if (NULL != xdg)
239 xdg, 239 GNUNET_asprintf (&cfg_fn,
240 DIR_SEPARATOR_STR, 240 "%s%s%s",
241 pd->config_file); 241 xdg,
242 DIR_SEPARATOR_STR,
243 pd->config_file);
244 else
245 cfg_fn = GNUNET_strdup (pd->user_config_file);
246 }
242 else 247 else
243 cfg_fn = GNUNET_strdup (pd->user_config_file); 248 cfg_fn = NULL;
244 lpfx = GNUNET_strdup (binaryName); 249 lpfx = GNUNET_strdup (binaryName);
245 if (NULL != (spc = strstr (lpfx, " "))) 250 if (NULL != (spc = strstr (lpfx, " ")))
246 *spc = '\0'; 251 *spc = '\0';
@@ -269,7 +274,7 @@ GNUNET_PROGRAM_run2 (int argc,
269 } 274 }
270 else 275 else
271 { 276 {
272 if (GNUNET_YES == GNUNET_DISK_file_test (cfg_fn)) 277 if (NULL != cfg_fn && GNUNET_YES == GNUNET_DISK_file_test (cfg_fn))
273 { 278 {
274 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, cfg_fn)) 279 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, cfg_fn))
275 { 280 {
@@ -284,7 +289,7 @@ GNUNET_PROGRAM_run2 (int argc,
284 goto cleanup; 289 goto cleanup;
285 } 290 }
286 } 291 }
287 else 292 else if (NULL != cfg_fn)
288 { 293 {
289 GNUNET_free (cfg_fn); 294 GNUNET_free (cfg_fn);
290 cfg_fn = NULL; 295 cfg_fn = NULL;