2 This file is part of GNUnet.
3 (C) 2006, 2007, 2008, 2009 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file src/util/configuration.c
23 * @brief configuration management
25 * @author Christian Grothoff
29 #include "gnunet_common.h"
30 #include "gnunet_configuration_lib.h"
31 #include "gnunet_crypto_lib.h"
32 #include "gnunet_disk_lib.h"
33 #include "gnunet_os_lib.h"
34 #include "gnunet_strings_lib.h"
38 * @brief configuration entry
44 * This is a linked list.
46 struct ConfigEntry *next;
54 * current, commited value
61 * @brief configuration section
66 * This is a linked list.
68 struct ConfigSection *next;
71 * entries in the section
73 struct ConfigEntry *entries;
83 * @brief configuration data
85 struct GNUNET_CONFIGURATION_Handle
88 * Configuration sections.
90 struct ConfigSection *sections;
93 * Modification indication since last save
94 * GNUNET_NO if clean, GNUNET_YES if dirty,
95 * GNUNET_SYSERR on error (i.e. last save failed)
103 * Used for diffing a configuration object against
108 const struct GNUNET_CONFIGURATION_Handle *cfgDefault;
109 struct GNUNET_CONFIGURATION_Handle *cfgDiff;
115 * Create a GNUNET_CONFIGURATION_Handle.
117 * @return fresh configuration object
119 struct GNUNET_CONFIGURATION_Handle *
120 GNUNET_CONFIGURATION_create ()
122 return GNUNET_malloc (sizeof (struct GNUNET_CONFIGURATION_Handle));
127 * Destroy configuration object.
129 * @param cfg configuration to destroy
132 GNUNET_CONFIGURATION_destroy (struct GNUNET_CONFIGURATION_Handle *cfg)
134 struct ConfigSection *sec;
136 while (NULL != (sec = cfg->sections))
137 GNUNET_CONFIGURATION_remove_section (cfg, sec->name);
143 * Parse a configuration file, add all of the options in the
144 * file to the configuration environment.
146 * @param cfg configuration to update
147 * @param filename name of the configuration file
148 * @return GNUNET_OK on success, GNUNET_SYSERR on error
151 GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg,
152 const char *filename)
166 fn = GNUNET_STRINGS_filename_expand (filename);
168 return GNUNET_SYSERR;
169 dirty = cfg->dirty; /* back up value! */
170 if (NULL == (fp = FOPEN (fn, "r")))
172 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "fopen", fn);
174 return GNUNET_SYSERR;
178 section = GNUNET_strdup ("");
179 memset (line, 0, 256);
181 while (NULL != fgets (line, 255, fp))
184 for (i = 0; i < 255; i++)
187 if (line[0] == '\n' || line[0] == '#' || line[0] == '%' ||
191 for (i = 0; (i < 255 && line[i] != 0); i++)
192 if (line[i] != ' ' && line[i] != '\n' && line[i] != '\r')
196 /* remove tailing whitespace */
197 for (i = strlen (line) - 1; (i >= 0) && (isspace ( (unsigned char) line[i])); i--)
199 if (1 == sscanf (line, "@INLINE@ %191[^\n]", value))
202 if (GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, value))
203 ret = GNUNET_SYSERR; /* failed to parse included config */
205 else if (1 == sscanf (line, "[%99[^]]]", value))
208 GNUNET_free (section);
209 section = GNUNET_strdup (value);
211 else if (2 == sscanf (line, " %63[^= ] = %191[^\n]", tag, value))
215 i = strlen (value) - 1;
216 while ((i >= 0) && (isspace ( (unsigned char) value[i])))
223 while ((value[i] != '\0') && (value[i] != '"'))
233 GNUNET_CONFIGURATION_set_value_string (cfg,
234 section, tag, &value[i]);
236 else if (1 == sscanf (line, " %63[^= ] =[^\n]", tag))
239 GNUNET_CONFIGURATION_set_value_string (cfg, section, tag, "");
244 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
246 ("Syntax error in configuration file `%s' at line %u.\n"),
252 GNUNET_assert (0 == fclose (fp));
253 /* restore dirty flag - anything we set in the meantime
256 GNUNET_free (section);
262 * Test if there are configuration options that were
263 * changed since the last save.
265 * @param cfg configuration to inspect
266 * @return GNUNET_NO if clean, GNUNET_YES if dirty, GNUNET_SYSERR on error (i.e. last save failed)
269 GNUNET_CONFIGURATION_is_dirty (const struct GNUNET_CONFIGURATION_Handle *cfg)
276 * Write configuration file.
278 * @param cfg configuration to write
279 * @param filename where to write the configuration
280 * @return GNUNET_OK on success, GNUNET_SYSERR on error
283 GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg,
284 const char *filename)
286 struct ConfigSection *sec;
287 struct ConfigEntry *ent;
294 fn = GNUNET_STRINGS_filename_expand (filename);
296 return GNUNET_SYSERR;
297 if (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn))
300 return GNUNET_SYSERR;
302 if (NULL == (fp = FOPEN (fn, "w")))
304 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "fopen", fn);
306 return GNUNET_SYSERR;
313 if (0 > fprintf (fp, "[%s]\n", sec->name))
321 if (ent->val != NULL)
323 val = GNUNET_malloc (strlen (ent->val) * 2 + 1);
324 strcpy (val, ent->val);
325 while (NULL != (pos = strstr (val, "\n")))
327 memmove (&pos[2], &pos[1], strlen (&pos[1]));
331 if (0 > fprintf (fp, "%s = %s\n", ent->key, val))
343 if (0 > fprintf (fp, "\n"))
351 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "fprintf", filename);
352 GNUNET_assert (0 == fclose (fp));
355 cfg->dirty = GNUNET_SYSERR; /* last write failed */
356 return GNUNET_SYSERR;
358 cfg->dirty = GNUNET_NO; /* last write succeeded */
364 * Iterate over all options in the configuration.
366 * @param cfg configuration to inspect
367 * @param iter function to call on each option
368 * @param iter_cls closure for iter
371 GNUNET_CONFIGURATION_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg,
372 GNUNET_CONFIGURATION_Iterator iter,
375 struct ConfigSection *spos;
376 struct ConfigEntry *epos;
378 spos = cfg->sections;
381 epos = spos->entries;
384 iter (iter_cls, spos->name, epos->key, epos->val);
393 * Iterate over values of a section in the configuration.
395 * @param cfg configuration to inspect
396 * @param section the section
397 * @param iter function to call on each option
398 * @param iter_cls closure for iter
401 GNUNET_CONFIGURATION_iterate_section_values (const struct GNUNET_CONFIGURATION_Handle *cfg,
403 GNUNET_CONFIGURATION_Iterator iter,
406 struct ConfigSection *spos;
407 struct ConfigEntry *epos;
409 spos = cfg->sections;
410 while ((spos != NULL) && (0 != strcmp (spos->name, section)))
416 epos = spos->entries;
419 iter (iter_cls, spos->name, epos->key, epos->val);
426 * Iterate over all sections in the configuration.
428 * @param cfg configuration to inspect
429 * @param iter function to call on each section
430 * @param iter_cls closure for iter
433 GNUNET_CONFIGURATION_iterate_sections (const struct GNUNET_CONFIGURATION_Handle *cfg,
434 GNUNET_CONFIGURATION_Section_Iterator iter,
437 struct ConfigSection *spos;
438 struct ConfigSection *next;
440 next = cfg->sections;
445 iter (iter_cls, spos->name);
450 * Remove the given section and all options in it.
452 * @param cfg configuration to inspect
453 * @param section name of the section to remove
455 void GNUNET_CONFIGURATION_remove_section (struct GNUNET_CONFIGURATION_Handle *cfg,
458 struct ConfigSection *spos;
459 struct ConfigSection *prev;
460 struct ConfigEntry *ent;
463 spos = cfg->sections;
466 if (0 == strcmp (section,
470 cfg->sections = spos->next;
472 prev->next = spos->next;
473 while (NULL != (ent = spos->entries))
475 spos->entries = ent->next;
476 GNUNET_free (ent->key);
477 GNUNET_free_non_null (ent->val);
479 cfg->dirty = GNUNET_YES;
481 GNUNET_free (spos->name);
492 * Copy a configuration value to the given target configuration.
493 * Overwrites existing entries.
495 * @param cls the destination configuration (struct GNUNET_CONFIGURATION_Handle*)
496 * @param section section for the value
497 * @param option option name of the value
498 * @param value value to copy
501 copy_entry (void *cls,
502 const char *section, const char *option, const char *value)
504 struct GNUNET_CONFIGURATION_Handle *dst = cls;
505 GNUNET_CONFIGURATION_set_value_string (dst, section, option, value);
510 * Duplicate an existing configuration object.
512 * @param cfg configuration to duplicate
513 * @return duplicate configuration
515 struct GNUNET_CONFIGURATION_Handle *
516 GNUNET_CONFIGURATION_dup (const struct GNUNET_CONFIGURATION_Handle *cfg)
518 struct GNUNET_CONFIGURATION_Handle *ret;
520 ret = GNUNET_CONFIGURATION_create ();
521 GNUNET_CONFIGURATION_iterate (cfg, ©_entry, ret);
530 * @param section FIXME
531 * @return matching entry, NULL if not found
533 static struct ConfigSection *
534 findSection (const struct GNUNET_CONFIGURATION_Handle *cfg,
537 struct ConfigSection *pos;
540 while ((pos != NULL) && (0 != strcasecmp (section, pos->name)))
547 * Find an entry from a configuration.
549 * @param cfg handle to the configuration
550 * @param section section the option is in
551 * @param key the option
552 * @return matching entry, NULL if not found
554 static struct ConfigEntry *
555 findEntry (const struct GNUNET_CONFIGURATION_Handle *cfg,
556 const char *section, const char *key)
558 struct ConfigSection *sec;
559 struct ConfigEntry *pos;
561 sec = findSection (cfg, section);
565 while ((pos != NULL) && (0 != strcasecmp (key, pos->key)))
572 * A callback function, compares entries from two configurations
573 * (default against a new configuration) and write the diffs in a
574 * diff-configuration object (the callback object).
576 * @param cls the diff configuration (struct DiffHandle*)
577 * @param section section for the value (of the default conf.)
578 * @param option option name of the value (of the default conf.)
579 * @param value value to copy (of the default conf.)
582 compareEntries (void *cls,
583 const char *section, const char *option, const char *value)
585 struct DiffHandle *dh = cls;
586 struct ConfigEntry *entNew;
588 entNew = findEntry (dh->cfgDefault, section, option);
589 if ( (entNew != NULL) &&
590 (strcmp (entNew->val, value) == 0) )
592 GNUNET_CONFIGURATION_set_value_string (dh->cfgDiff,
600 * Write only configuration entries that have been changed to configuration file
601 * @param cfgDefault default configuration
602 * @param cfgNew new configuration
603 * @param filename where to write the configuration diff between default and new
604 * @return GNUNET_OK on success, GNUNET_SYSERR on error
607 GNUNET_CONFIGURATION_write_diffs (const struct GNUNET_CONFIGURATION_Handle
609 const struct GNUNET_CONFIGURATION_Handle *cfgNew,
610 const char *filename)
613 struct DiffHandle diffHandle;
615 diffHandle.cfgDiff = GNUNET_CONFIGURATION_create ();
616 diffHandle.cfgDefault = cfgDefault;
617 GNUNET_CONFIGURATION_iterate (cfgNew, compareEntries, &diffHandle);
618 ret = GNUNET_CONFIGURATION_write (diffHandle.cfgDiff, filename);
619 GNUNET_CONFIGURATION_destroy (diffHandle.cfgDiff);
625 * Set a configuration value that should be a string.
627 * @param cfg configuration to update
628 * @param section section of interest
629 * @param option option of interest
630 * @param value value to set
633 GNUNET_CONFIGURATION_set_value_string (struct GNUNET_CONFIGURATION_Handle
636 const char *option, const char *value)
638 struct ConfigSection *sec;
639 struct ConfigEntry *e;
641 e = findEntry (cfg, section, option);
644 GNUNET_free_non_null (e->val);
645 e->val = GNUNET_strdup (value);
648 sec = findSection (cfg, section);
651 sec = GNUNET_malloc (sizeof (struct ConfigSection));
652 sec->name = GNUNET_strdup (section);
653 sec->next = cfg->sections;
656 e = GNUNET_malloc (sizeof (struct ConfigEntry));
657 e->key = GNUNET_strdup (option);
658 e->val = GNUNET_strdup (value);
659 e->next = sec->entries;
665 * Set a configuration value that should be a number.
667 * @param cfg configuration to update
668 * @param section section of interest
669 * @param option option of interest
670 * @param number value to set
673 GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle
674 *cfg, const char *section,
676 unsigned long long number)
679 GNUNET_snprintf (s, 64, "%llu", number);
680 GNUNET_CONFIGURATION_set_value_string (cfg, section, option, s);
685 * Get a configuration value that should be a number.
687 * @param cfg configuration to inspect
688 * @param section section of interest
689 * @param option option of interest
690 * @param number where to store the numeric value of the option
691 * @return GNUNET_OK on success, GNUNET_SYSERR on error
694 GNUNET_CONFIGURATION_get_value_number (const struct
695 GNUNET_CONFIGURATION_Handle *cfg,
698 unsigned long long *number)
700 struct ConfigEntry *e;
702 e = findEntry (cfg, section, option);
704 return GNUNET_SYSERR;
705 if (1 != SSCANF (e->val, "%llu", number))
706 return GNUNET_SYSERR;
712 * Get a configuration value that should be a relative time.
714 * @param cfg configuration to inspect
715 * @param section section of interest
716 * @param option option of interest
717 * @param time set to the time value stored in the configuration
718 * @return GNUNET_OK on success, GNUNET_SYSERR on error
721 GNUNET_CONFIGURATION_get_value_time (const struct GNUNET_CONFIGURATION_Handle
722 *cfg, const char *section,
724 struct GNUNET_TIME_Relative *time)
726 struct ConfigEntry *e;
727 unsigned long long num;
729 e = findEntry (cfg, section, option);
731 return GNUNET_SYSERR;
732 if ( (0 == strcasecmp (e->val, "infinity")) ||
733 (0 == strcasecmp (e->val, "forever")) )
735 *time = GNUNET_TIME_UNIT_FOREVER_REL;
738 if (1 != SSCANF (e->val, "%llu", &num))
739 return GNUNET_SYSERR;
740 time->rel_value = (uint64_t) num;
746 * Get a configuration value that should be a string.
748 * @param cfg configuration to inspect
749 * @param section section of interest
750 * @param option option of interest
751 * @param value will be set to a freshly allocated configuration
752 * value, or NULL if option is not specified
753 * @return GNUNET_OK on success, GNUNET_SYSERR on error
756 GNUNET_CONFIGURATION_get_value_string (const struct
757 GNUNET_CONFIGURATION_Handle *cfg,
759 const char *option, char **value)
761 struct ConfigEntry *e;
763 e = findEntry (cfg, section, option);
764 if ((e == NULL) || (e->val == NULL))
767 return GNUNET_SYSERR;
769 *value = GNUNET_strdup (e->val);
775 * Get a configuration value that should be in a set of
778 * @param cfg configuration to inspect
779 * @param section section of interest
780 * @param option option of interest
781 * @param choices NULL-terminated list of legal values
782 * @param value will be set to an entry in the legal list,
783 * or NULL if option is not specified and no default given
784 * @return GNUNET_OK on success, GNUNET_SYSERR on error
787 GNUNET_CONFIGURATION_get_value_choice (const struct
788 GNUNET_CONFIGURATION_Handle *cfg,
791 const char **choices,
794 struct ConfigEntry *e;
797 e = findEntry (cfg, section, option);
799 return GNUNET_SYSERR;
801 while (choices[i] != NULL)
803 if (0 == strcasecmp (choices[i], e->val))
807 if (choices[i] == NULL)
809 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
810 _("Configuration value '%s' for '%s'"
811 " in section '%s' is not in set of legal choices\n"),
812 e->val, option, section);
813 return GNUNET_SYSERR;
821 * Test if we have a value for a particular option
822 * @param cfg configuration to inspect
823 * @param section section of interest
824 * @param option option of interest
825 * @return GNUNET_YES if so, GNUNET_NO if not.
828 GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle
829 *cfg, const char *section,
832 struct ConfigEntry *e;
833 if ((NULL == (e = findEntry (cfg, section, option))) || (e->val == NULL))
840 * Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR"
841 * where either in the "PATHS" section or the environtment
842 * "FOO" is set to "DIRECTORY".
844 * @param cfg configuration to use for path expansion
845 * @param orig string to $-expand (will be freed!)
846 * @return $-expanded string
849 GNUNET_CONFIGURATION_expand_dollar (const struct GNUNET_CONFIGURATION_Handle
861 while ((orig[i] != '/') && (orig[i] != '\\') && (orig[i] != '\0'))
872 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg,
876 if (NULL == (env = getenv (&orig[1])))
878 orig[i] = DIR_SEPARATOR;
881 prefix = GNUNET_strdup (env);
883 result = GNUNET_malloc (strlen (prefix) + strlen (post) + 2);
884 strcpy (result, prefix);
885 if ((strlen (prefix) == 0) ||
886 ((prefix[strlen (prefix) - 1] != DIR_SEPARATOR) && (strlen (post) > 0)))
887 strcat (result, DIR_SEPARATOR_STR);
888 strcat (result, post);
889 GNUNET_free (prefix);
896 * Get a configuration value that should be a string.
898 * @param cfg configuration to inspect
899 * @param section section of interest
900 * @param option option of interest
901 * @param value will be set to a freshly allocated configuration
902 * value, or NULL if option is not specified
903 * @return GNUNET_OK on success, GNUNET_SYSERR on error
906 GNUNET_CONFIGURATION_get_value_filename (const struct
907 GNUNET_CONFIGURATION_Handle *cfg,
909 const char *option, char **value)
914 GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &tmp))
917 return GNUNET_SYSERR;
919 tmp = GNUNET_CONFIGURATION_expand_dollar (cfg, tmp);
920 *value = GNUNET_STRINGS_filename_expand (tmp);
923 return GNUNET_SYSERR;
929 * Get a configuration value that should be in a set of
930 * "GNUNET_YES" or "GNUNET_NO".
932 * @param cfg configuration to inspect
933 * @param section section of interest
934 * @param option option of interest
935 * @return GNUNET_YES, GNUNET_NO or GNUNET_SYSERR
938 GNUNET_CONFIGURATION_get_value_yesno (const struct GNUNET_CONFIGURATION_Handle
939 *cfg, const char *section,
942 static const char *yesno[] = { "YES", "NO", NULL };
946 ret = GNUNET_CONFIGURATION_get_value_choice (cfg,
947 section, option, yesno, &val);
948 if (ret == GNUNET_SYSERR)
957 * Iterate over the set of filenames stored in a configuration value.
959 * @param cfg configuration to inspect
960 * @param section section of interest
961 * @param option option of interest
962 * @param cb function to call on each filename
963 * @param cb_cls closure for cb
964 * @return number of filenames iterated over, -1 on error
967 GNUNET_CONFIGURATION_iterate_value_filenames (const struct
968 GNUNET_CONFIGURATION_Handle
969 *cfg, const char *section,
971 GNUNET_FileNameCallback cb,
981 GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &list))
983 GNUNET_assert (list != NULL);
988 while (pos[0] == ' ')
990 if (strlen (pos) == 0)
993 while ((end[0] != ' ') && (end[0] != '\0'))
1001 memmove (end, &end[1], strlen (&end[1]) + 1);
1003 /* illegal, but just keep it */
1006 /* illegal, but just ignore that there was a '/' */
1014 if (strlen (pos) > 0)
1017 if ((cb != NULL) && (GNUNET_OK != cb (cb_cls, pos)))
1019 ret = GNUNET_SYSERR;
1035 * @param value FIXME
1039 escape_name (const char *value)
1045 escaped = GNUNET_malloc (strlen (value) * 2 + 1);
1046 memset (escaped, 0, strlen (value) * 2 + 1);
1049 while (rpos[0] != '\0')
1072 * @param cls string we compare with (const char*)
1073 * @param fn filename we are currently looking at
1074 * @return GNUNET_OK if the names do not match, GNUNET_SYSERR if they do
1077 test_match (void *cls, const char *fn)
1079 const char *of = cls;
1080 return (0 == strcmp (of, fn)) ? GNUNET_SYSERR : GNUNET_OK;
1085 * Append a filename to a configuration value that
1086 * represents a list of filenames
1088 * @param cfg configuration to update
1089 * @param section section of interest
1090 * @param option option of interest
1091 * @param value filename to append
1092 * @return GNUNET_OK on success,
1093 * GNUNET_NO if the filename already in the list
1094 * GNUNET_SYSERR on error
1097 GNUNET_CONFIGURATION_append_value_filename (struct GNUNET_CONFIGURATION_Handle
1099 const char *section,
1108 == GNUNET_CONFIGURATION_iterate_value_filenames (cfg,
1113 return GNUNET_NO; /* already exists */
1115 GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &old))
1116 old = GNUNET_strdup ("");
1117 escaped = escape_name (value);
1118 nw = GNUNET_malloc (strlen (old) + strlen (escaped) + 2);
1120 if (strlen (old) > 0)
1122 strcat (nw, escaped);
1123 GNUNET_CONFIGURATION_set_value_string (cfg, section, option, nw);
1126 GNUNET_free (escaped);
1132 * Remove a filename from a configuration value that
1133 * represents a list of filenames
1135 * @param cfg configuration to update
1136 * @param section section of interest
1137 * @param option option of interest
1138 * @param value filename to remove
1139 * @return GNUNET_OK on success,
1140 * GNUNET_NO if the filename is not in the list,
1141 * GNUNET_SYSERR on error
1144 GNUNET_CONFIGURATION_remove_value_filename (struct GNUNET_CONFIGURATION_Handle
1146 const char *section,
1157 GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &list))
1159 match = escape_name (value);
1163 while (pos[0] == ' ')
1165 if (strlen (pos) == 0)
1168 while ((end[0] != ' ') && (end[0] != '\0'))
1179 /* illegal, but just keep it */
1182 /* illegal, but just ignore that there was a '/' */
1190 if (0 == strcmp (pos, match))
1193 memmove (pos, &end[1], strlen (&end[1]) + 1);
1201 GNUNET_CONFIGURATION_set_value_string (cfg,
1202 section, option, list);
1204 GNUNET_free (match);
1213 GNUNET_free (match);
1219 * Load configuration (starts with defaults, then loads
1220 * system-specific configuration).
1222 * @param cfg configuration to update
1223 * @param filename name of the configuration file, NULL to load defaults
1224 * @return GNUNET_OK on success, GNUNET_SYSERR on error
1227 GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg,
1228 const char *filename)
1233 ipath = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR);
1235 return GNUNET_SYSERR;
1237 GNUNET_asprintf (&baseconfig,
1238 "%s%s%s", ipath, DIR_SEPARATOR_STR, "defaults.conf");
1239 GNUNET_free (ipath);
1241 GNUNET_CONFIGURATION_parse (cfg, baseconfig)) ||
1242 (!((filename == NULL) ||
1243 (GNUNET_OK == GNUNET_CONFIGURATION_parse (cfg, filename)))))
1245 GNUNET_free (baseconfig);
1246 return (filename == NULL) ? GNUNET_OK : GNUNET_SYSERR;
1248 GNUNET_free (baseconfig);
1249 if ( ((GNUNET_YES != GNUNET_CONFIGURATION_have_value (cfg,
1251 "DEFAULTCONFIG"))) &&
1252 (filename != NULL) )
1253 GNUNET_CONFIGURATION_set_value_string (cfg,
1257 if ((GNUNET_YES == GNUNET_CONFIGURATION_have_value (cfg,
1260 (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (cfg,
1263 GNUNET_CRYPTO_random_disable_entropy_gathering ();
1269 /* end of configuration.c */