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] == '%' || line[0] == '\r')
190 for (i = 0; (i < 255 && line[i] != 0); i++)
191 if (line[i] != ' ' && line[i] != '\n' && line[i] != '\r')
195 /* remove tailing whitespace */
196 for (i = strlen (line) - 1; (i >= 0) && (isspace ((unsigned char) line[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, section, tag, &value[i]);
235 else if (1 == sscanf (line, " %63[^= ] =[^\n]", tag))
238 GNUNET_CONFIGURATION_set_value_string (cfg, section, tag, "");
243 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
244 _("Syntax error in configuration file `%s' at line %u.\n"),
250 GNUNET_assert (0 == fclose (fp));
251 /* restore dirty flag - anything we set in the meantime
254 GNUNET_free (section);
260 * Test if there are configuration options that were
261 * changed since the last save.
263 * @param cfg configuration to inspect
264 * @return GNUNET_NO if clean, GNUNET_YES if dirty, GNUNET_SYSERR on error (i.e. last save failed)
267 GNUNET_CONFIGURATION_is_dirty (const struct GNUNET_CONFIGURATION_Handle *cfg)
274 * Write configuration file.
276 * @param cfg configuration to write
277 * @param filename where to write the configuration
278 * @return GNUNET_OK on success, GNUNET_SYSERR on error
281 GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg,
282 const char *filename)
284 struct ConfigSection *sec;
285 struct ConfigEntry *ent;
292 fn = GNUNET_STRINGS_filename_expand (filename);
294 return GNUNET_SYSERR;
295 if (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn))
298 return GNUNET_SYSERR;
300 if (NULL == (fp = FOPEN (fn, "w")))
302 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "fopen", fn);
304 return GNUNET_SYSERR;
311 if (0 > fprintf (fp, "[%s]\n", sec->name))
319 if (ent->val != NULL)
321 val = GNUNET_malloc (strlen (ent->val) * 2 + 1);
322 strcpy (val, ent->val);
323 while (NULL != (pos = strstr (val, "\n")))
325 memmove (&pos[2], &pos[1], strlen (&pos[1]));
329 if (0 > fprintf (fp, "%s = %s\n", ent->key, val))
341 if (0 > fprintf (fp, "\n"))
349 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "fprintf", filename);
350 GNUNET_assert (0 == fclose (fp));
353 cfg->dirty = GNUNET_SYSERR; /* last write failed */
354 return GNUNET_SYSERR;
356 cfg->dirty = GNUNET_NO; /* last write succeeded */
362 * Iterate over all options in the configuration.
364 * @param cfg configuration to inspect
365 * @param iter function to call on each option
366 * @param iter_cls closure for iter
369 GNUNET_CONFIGURATION_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg,
370 GNUNET_CONFIGURATION_Iterator iter,
373 struct ConfigSection *spos;
374 struct ConfigEntry *epos;
376 spos = cfg->sections;
379 epos = spos->entries;
382 iter (iter_cls, spos->name, epos->key, epos->val);
391 * Iterate over values of a section in the configuration.
393 * @param cfg configuration to inspect
394 * @param section the section
395 * @param iter function to call on each option
396 * @param iter_cls closure for iter
399 GNUNET_CONFIGURATION_iterate_section_values (const struct
400 GNUNET_CONFIGURATION_Handle *cfg,
402 GNUNET_CONFIGURATION_Iterator iter,
405 struct ConfigSection *spos;
406 struct ConfigEntry *epos;
408 spos = cfg->sections;
409 while ((spos != NULL) && (0 != strcmp (spos->name, section)))
415 epos = spos->entries;
418 iter (iter_cls, spos->name, epos->key, epos->val);
425 * Iterate over all sections in the configuration.
427 * @param cfg configuration to inspect
428 * @param iter function to call on each section
429 * @param iter_cls closure for iter
432 GNUNET_CONFIGURATION_iterate_sections (const struct GNUNET_CONFIGURATION_Handle
434 GNUNET_CONFIGURATION_Section_Iterator
435 iter, void *iter_cls)
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
456 GNUNET_CONFIGURATION_remove_section (struct GNUNET_CONFIGURATION_Handle *cfg,
459 struct ConfigSection *spos;
460 struct ConfigSection *prev;
461 struct ConfigEntry *ent;
464 spos = cfg->sections;
467 if (0 == strcmp (section, spos->name))
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, const char *section, const char *option,
504 struct GNUNET_CONFIGURATION_Handle *dst = cls;
506 GNUNET_CONFIGURATION_set_value_string (dst, section, option, value);
511 * Duplicate an existing configuration object.
513 * @param cfg configuration to duplicate
514 * @return duplicate configuration
516 struct GNUNET_CONFIGURATION_Handle *
517 GNUNET_CONFIGURATION_dup (const struct GNUNET_CONFIGURATION_Handle *cfg)
519 struct GNUNET_CONFIGURATION_Handle *ret;
521 ret = GNUNET_CONFIGURATION_create ();
522 GNUNET_CONFIGURATION_iterate (cfg, ©_entry, ret);
531 * @param section FIXME
532 * @return matching entry, NULL if not found
534 static struct ConfigSection *
535 findSection (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section)
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, const char *section,
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, const char *section, const char *option,
585 struct DiffHandle *dh = cls;
586 struct ConfigEntry *entNew;
588 entNew = findEntry (dh->cfgDefault, section, option);
589 if ((entNew != NULL) && (strcmp (entNew->val, value) == 0))
591 GNUNET_CONFIGURATION_set_value_string (dh->cfgDiff, section, option, value);
596 * Write only configuration entries that have been changed to configuration file
597 * @param cfgDefault default configuration
598 * @param cfgNew new configuration
599 * @param filename where to write the configuration diff between default and new
600 * @return GNUNET_OK on success, GNUNET_SYSERR on error
603 GNUNET_CONFIGURATION_write_diffs (const struct GNUNET_CONFIGURATION_Handle
605 const struct GNUNET_CONFIGURATION_Handle
606 *cfgNew, const char *filename)
609 struct DiffHandle diffHandle;
611 diffHandle.cfgDiff = GNUNET_CONFIGURATION_create ();
612 diffHandle.cfgDefault = cfgDefault;
613 GNUNET_CONFIGURATION_iterate (cfgNew, compareEntries, &diffHandle);
614 ret = GNUNET_CONFIGURATION_write (diffHandle.cfgDiff, filename);
615 GNUNET_CONFIGURATION_destroy (diffHandle.cfgDiff);
621 * Set a configuration value that should be a string.
623 * @param cfg configuration to update
624 * @param section section of interest
625 * @param option option of interest
626 * @param value value to set
629 GNUNET_CONFIGURATION_set_value_string (struct GNUNET_CONFIGURATION_Handle *cfg,
630 const char *section, const char *option,
633 struct ConfigSection *sec;
634 struct ConfigEntry *e;
636 e = findEntry (cfg, section, option);
639 GNUNET_free_non_null (e->val);
640 e->val = GNUNET_strdup (value);
643 sec = findSection (cfg, section);
646 sec = GNUNET_malloc (sizeof (struct ConfigSection));
647 sec->name = GNUNET_strdup (section);
648 sec->next = cfg->sections;
651 e = GNUNET_malloc (sizeof (struct ConfigEntry));
652 e->key = GNUNET_strdup (option);
653 e->val = GNUNET_strdup (value);
654 e->next = sec->entries;
660 * Set a configuration value that should be a number.
662 * @param cfg configuration to update
663 * @param section section of interest
664 * @param option option of interest
665 * @param number value to set
668 GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle *cfg,
669 const char *section, const char *option,
670 unsigned long long number)
674 GNUNET_snprintf (s, 64, "%llu", number);
675 GNUNET_CONFIGURATION_set_value_string (cfg, section, option, s);
680 * Get a configuration value that should be a number.
682 * @param cfg configuration to inspect
683 * @param section section of interest
684 * @param option option of interest
685 * @param number where to store the numeric value of the option
686 * @return GNUNET_OK on success, GNUNET_SYSERR on error
689 GNUNET_CONFIGURATION_get_value_number (const struct GNUNET_CONFIGURATION_Handle
690 *cfg, const char *section,
692 unsigned long long *number)
694 struct ConfigEntry *e;
696 e = findEntry (cfg, section, option);
698 return GNUNET_SYSERR;
699 if (1 != SSCANF (e->val, "%llu", number))
700 return GNUNET_SYSERR;
706 * Get a configuration value that should be a relative time.
708 * @param cfg configuration to inspect
709 * @param section section of interest
710 * @param option option of interest
711 * @param time set to the time value stored in the configuration
712 * @return GNUNET_OK on success, GNUNET_SYSERR on error
715 GNUNET_CONFIGURATION_get_value_time (const struct GNUNET_CONFIGURATION_Handle
716 *cfg, const char *section,
718 struct GNUNET_TIME_Relative *time)
720 struct ConfigEntry *e;
721 unsigned long long num;
723 e = findEntry (cfg, section, option);
725 return GNUNET_SYSERR;
726 if ((0 == strcasecmp (e->val, "infinity")) ||
727 (0 == strcasecmp (e->val, "forever")))
729 *time = GNUNET_TIME_UNIT_FOREVER_REL;
732 if (1 != SSCANF (e->val, "%llu", &num))
733 return GNUNET_SYSERR;
734 time->rel_value = (uint64_t) num;
740 * Get a configuration value that should be a string.
742 * @param cfg configuration to inspect
743 * @param section section of interest
744 * @param option option of interest
745 * @param value will be set to a freshly allocated configuration
746 * value, or NULL if option is not specified
747 * @return GNUNET_OK on success, GNUNET_SYSERR on error
750 GNUNET_CONFIGURATION_get_value_string (const struct GNUNET_CONFIGURATION_Handle
751 *cfg, const char *section,
752 const char *option, char **value)
754 struct ConfigEntry *e;
756 e = findEntry (cfg, section, option);
757 if ((e == NULL) || (e->val == NULL))
760 return GNUNET_SYSERR;
762 *value = GNUNET_strdup (e->val);
768 * Get a configuration value that should be in a set of
771 * @param cfg configuration to inspect
772 * @param section section of interest
773 * @param option option of interest
774 * @param choices NULL-terminated list of legal values
775 * @param value will be set to an entry in the legal list,
776 * or NULL if option is not specified and no default given
777 * @return GNUNET_OK on success, GNUNET_SYSERR on error
780 GNUNET_CONFIGURATION_get_value_choice (const struct GNUNET_CONFIGURATION_Handle
781 *cfg, const char *section,
782 const char *option, const char **choices,
785 struct ConfigEntry *e;
788 e = findEntry (cfg, section, option);
790 return GNUNET_SYSERR;
792 while (choices[i] != NULL)
794 if (0 == strcasecmp (choices[i], e->val))
798 if (choices[i] == NULL)
800 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
801 _("Configuration value '%s' for '%s'"
802 " in section '%s' is not in set of legal choices\n"), e->val,
804 return GNUNET_SYSERR;
812 * Test if we have a value for a particular option
813 * @param cfg configuration to inspect
814 * @param section section of interest
815 * @param option option of interest
816 * @return GNUNET_YES if so, GNUNET_NO if not.
819 GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle *cfg,
820 const char *section, const char *option)
822 struct ConfigEntry *e;
824 if ((NULL == (e = findEntry (cfg, section, option))) || (e->val == NULL))
831 * Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR"
832 * where either in the "PATHS" section or the environtment
833 * "FOO" is set to "DIRECTORY".
835 * @param cfg configuration to use for path expansion
836 * @param orig string to $-expand (will be freed!)
837 * @return $-expanded string
840 GNUNET_CONFIGURATION_expand_dollar (const struct GNUNET_CONFIGURATION_Handle
852 while ((orig[i] != '/') && (orig[i] != '\\') && (orig[i] != '\0'))
864 GNUNET_CONFIGURATION_get_value_filename (cfg, "PATHS", &orig[1], &prefix))
866 if (NULL == (env = getenv (&orig[1])))
868 orig[i] = DIR_SEPARATOR;
871 prefix = GNUNET_strdup (env);
873 result = GNUNET_malloc (strlen (prefix) + strlen (post) + 2);
874 strcpy (result, prefix);
875 if ((strlen (prefix) == 0) ||
876 ((prefix[strlen (prefix) - 1] != DIR_SEPARATOR) && (strlen (post) > 0)))
877 strcat (result, DIR_SEPARATOR_STR);
878 strcat (result, post);
879 GNUNET_free (prefix);
886 * Get a configuration value that should be a string.
888 * @param cfg configuration to inspect
889 * @param section section of interest
890 * @param option option of interest
891 * @param value will be set to a freshly allocated configuration
892 * value, or NULL if option is not specified
893 * @return GNUNET_OK on success, GNUNET_SYSERR on error
896 GNUNET_CONFIGURATION_get_value_filename (const struct
897 GNUNET_CONFIGURATION_Handle *cfg,
899 const char *option, char **value)
904 GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &tmp))
907 return GNUNET_SYSERR;
909 tmp = GNUNET_CONFIGURATION_expand_dollar (cfg, tmp);
910 *value = GNUNET_STRINGS_filename_expand (tmp);
913 return GNUNET_SYSERR;
919 * Get a configuration value that should be in a set of
920 * "GNUNET_YES" or "GNUNET_NO".
922 * @param cfg configuration to inspect
923 * @param section section of interest
924 * @param option option of interest
925 * @return GNUNET_YES, GNUNET_NO or GNUNET_SYSERR
928 GNUNET_CONFIGURATION_get_value_yesno (const struct GNUNET_CONFIGURATION_Handle
929 *cfg, const char *section,
932 static const char *yesno[] = { "YES", "NO", NULL };
937 GNUNET_CONFIGURATION_get_value_choice (cfg, section, option, yesno, &val);
938 if (ret == GNUNET_SYSERR)
947 * Iterate over the set of filenames stored in a configuration value.
949 * @param cfg configuration to inspect
950 * @param section section of interest
951 * @param option option of interest
952 * @param cb function to call on each filename
953 * @param cb_cls closure for cb
954 * @return number of filenames iterated over, -1 on error
957 GNUNET_CONFIGURATION_iterate_value_filenames (const struct
958 GNUNET_CONFIGURATION_Handle *cfg,
961 GNUNET_FileNameCallback cb,
971 GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &list))
973 GNUNET_assert (list != NULL);
978 while (pos[0] == ' ')
980 if (strlen (pos) == 0)
983 while ((end[0] != ' ') && (end[0] != '\0'))
991 memmove (end, &end[1], strlen (&end[1]) + 1);
993 /* illegal, but just keep it */
996 /* illegal, but just ignore that there was a '/' */
1004 if (strlen (pos) > 0)
1007 if ((cb != NULL) && (GNUNET_OK != cb (cb_cls, pos)))
1009 ret = GNUNET_SYSERR;
1025 * @param value FIXME
1029 escape_name (const char *value)
1035 escaped = GNUNET_malloc (strlen (value) * 2 + 1);
1036 memset (escaped, 0, strlen (value) * 2 + 1);
1039 while (rpos[0] != '\0')
1062 * @param cls string we compare with (const char*)
1063 * @param fn filename we are currently looking at
1064 * @return GNUNET_OK if the names do not match, GNUNET_SYSERR if they do
1067 test_match (void *cls, const char *fn)
1069 const char *of = cls;
1071 return (0 == strcmp (of, fn)) ? GNUNET_SYSERR : GNUNET_OK;
1076 * Append a filename to a configuration value that
1077 * represents a list of filenames
1079 * @param cfg configuration to update
1080 * @param section section of interest
1081 * @param option option of interest
1082 * @param value filename to append
1083 * @return GNUNET_OK on success,
1084 * GNUNET_NO if the filename already in the list
1085 * GNUNET_SYSERR on error
1088 GNUNET_CONFIGURATION_append_value_filename (struct GNUNET_CONFIGURATION_Handle
1089 *cfg, const char *section,
1097 if (GNUNET_SYSERR ==
1098 GNUNET_CONFIGURATION_iterate_value_filenames (cfg, section, option,
1101 return GNUNET_NO; /* already exists */
1103 GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &old))
1104 old = GNUNET_strdup ("");
1105 escaped = escape_name (value);
1106 nw = GNUNET_malloc (strlen (old) + strlen (escaped) + 2);
1108 if (strlen (old) > 0)
1110 strcat (nw, escaped);
1111 GNUNET_CONFIGURATION_set_value_string (cfg, section, option, nw);
1114 GNUNET_free (escaped);
1120 * Remove a filename from a configuration value that
1121 * represents a list of filenames
1123 * @param cfg configuration to update
1124 * @param section section of interest
1125 * @param option option of interest
1126 * @param value filename to remove
1127 * @return GNUNET_OK on success,
1128 * GNUNET_NO if the filename is not in the list,
1129 * GNUNET_SYSERR on error
1132 GNUNET_CONFIGURATION_remove_value_filename (struct GNUNET_CONFIGURATION_Handle
1133 *cfg, const char *section,
1144 GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &list))
1146 match = escape_name (value);
1150 while (pos[0] == ' ')
1152 if (strlen (pos) == 0)
1155 while ((end[0] != ' ') && (end[0] != '\0'))
1166 /* illegal, but just keep it */
1169 /* illegal, but just ignore that there was a '/' */
1177 if (0 == strcmp (pos, match))
1180 memmove (pos, &end[1], strlen (&end[1]) + 1);
1188 GNUNET_CONFIGURATION_set_value_string (cfg, section, option, list);
1190 GNUNET_free (match);
1199 GNUNET_free (match);
1205 * Load configuration (starts with defaults, then loads
1206 * system-specific configuration).
1208 * @param cfg configuration to update
1209 * @param filename name of the configuration file, NULL to load defaults
1210 * @return GNUNET_OK on success, GNUNET_SYSERR on error
1213 GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg,
1214 const char *filename)
1219 ipath = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR);
1221 return GNUNET_SYSERR;
1223 GNUNET_asprintf (&baseconfig, "%s%s%s", ipath, DIR_SEPARATOR_STR,
1225 GNUNET_free (ipath);
1226 if ((GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, baseconfig)) ||
1227 (!((filename == NULL) ||
1228 (GNUNET_OK == GNUNET_CONFIGURATION_parse (cfg, filename)))))
1230 GNUNET_free (baseconfig);
1231 return (filename == NULL) ? GNUNET_OK : GNUNET_SYSERR;
1233 GNUNET_free (baseconfig);
1235 GNUNET_CONFIGURATION_have_value (cfg, "PATHS", "DEFAULTCONFIG"))) &&
1237 GNUNET_CONFIGURATION_set_value_string (cfg, "PATHS", "DEFAULTCONFIG",
1240 GNUNET_CONFIGURATION_have_value (cfg, "TESTING", "WEAKRANDOM")) &&
1242 GNUNET_CONFIGURATION_get_value_yesno (cfg, "TESTING", "WEAKRANDOM")))
1243 GNUNET_CRYPTO_random_disable_entropy_gathering ();
1249 /* end of configuration.c */