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,
245 ("Syntax error in configuration file `%s' at line %u.\n"),
251 GNUNET_assert (0 == fclose (fp));
252 /* restore dirty flag - anything we set in the meantime
255 GNUNET_free (section);
261 * Test if there are configuration options that were
262 * changed since the last save.
264 * @param cfg configuration to inspect
265 * @return GNUNET_NO if clean, GNUNET_YES if dirty, GNUNET_SYSERR on error (i.e. last save failed)
268 GNUNET_CONFIGURATION_is_dirty (const struct GNUNET_CONFIGURATION_Handle *cfg)
275 * Write configuration file.
277 * @param cfg configuration to write
278 * @param filename where to write the configuration
279 * @return GNUNET_OK on success, GNUNET_SYSERR on error
282 GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg,
283 const char *filename)
285 struct ConfigSection *sec;
286 struct ConfigEntry *ent;
293 fn = GNUNET_STRINGS_filename_expand (filename);
295 return GNUNET_SYSERR;
296 if (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn))
299 return GNUNET_SYSERR;
301 if (NULL == (fp = FOPEN (fn, "w")))
303 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "fopen", fn);
305 return GNUNET_SYSERR;
312 if (0 > fprintf (fp, "[%s]\n", sec->name))
320 if (ent->val != NULL)
322 val = GNUNET_malloc (strlen (ent->val) * 2 + 1);
323 strcpy (val, ent->val);
324 while (NULL != (pos = strstr (val, "\n")))
326 memmove (&pos[2], &pos[1], strlen (&pos[1]));
330 if (0 > fprintf (fp, "%s = %s\n", ent->key, val))
342 if (0 > fprintf (fp, "\n"))
350 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "fprintf", filename);
351 GNUNET_assert (0 == fclose (fp));
354 cfg->dirty = GNUNET_SYSERR; /* last write failed */
355 return GNUNET_SYSERR;
357 cfg->dirty = GNUNET_NO; /* last write succeeded */
363 * Iterate over all options in the configuration.
365 * @param cfg configuration to inspect
366 * @param iter function to call on each option
367 * @param iter_cls closure for iter
370 GNUNET_CONFIGURATION_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg,
371 GNUNET_CONFIGURATION_Iterator iter,
374 struct ConfigSection *spos;
375 struct ConfigEntry *epos;
377 spos = cfg->sections;
380 epos = spos->entries;
383 iter (iter_cls, spos->name, epos->key, epos->val);
392 * Iterate over values of a section in the configuration.
394 * @param cfg configuration to inspect
395 * @param section the section
396 * @param iter function to call on each option
397 * @param iter_cls closure for iter
400 GNUNET_CONFIGURATION_iterate_section_values (const struct
401 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
435 GNUNET_CONFIGURATION_Section_Iterator
436 iter, void *iter_cls)
438 struct ConfigSection *spos;
439 struct ConfigSection *next;
441 next = cfg->sections;
446 iter (iter_cls, spos->name);
451 * Remove the given section and all options in it.
453 * @param cfg configuration to inspect
454 * @param section name of the section to remove
457 GNUNET_CONFIGURATION_remove_section (struct GNUNET_CONFIGURATION_Handle *cfg,
460 struct ConfigSection *spos;
461 struct ConfigSection *prev;
462 struct ConfigEntry *ent;
465 spos = cfg->sections;
468 if (0 == strcmp (section, spos->name))
471 cfg->sections = spos->next;
473 prev->next = spos->next;
474 while (NULL != (ent = spos->entries))
476 spos->entries = ent->next;
477 GNUNET_free (ent->key);
478 GNUNET_free_non_null (ent->val);
480 cfg->dirty = GNUNET_YES;
482 GNUNET_free (spos->name);
493 * Copy a configuration value to the given target configuration.
494 * Overwrites existing entries.
496 * @param cls the destination configuration (struct GNUNET_CONFIGURATION_Handle*)
497 * @param section section for the value
498 * @param option option name of the value
499 * @param value value to copy
502 copy_entry (void *cls,
503 const char *section, const char *option, const char *value)
505 struct GNUNET_CONFIGURATION_Handle *dst = cls;
507 GNUNET_CONFIGURATION_set_value_string (dst, section, option, value);
512 * Duplicate an existing configuration object.
514 * @param cfg configuration to duplicate
515 * @return duplicate configuration
517 struct GNUNET_CONFIGURATION_Handle *
518 GNUNET_CONFIGURATION_dup (const struct GNUNET_CONFIGURATION_Handle *cfg)
520 struct GNUNET_CONFIGURATION_Handle *ret;
522 ret = GNUNET_CONFIGURATION_create ();
523 GNUNET_CONFIGURATION_iterate (cfg, ©_entry, ret);
532 * @param section FIXME
533 * @return matching entry, NULL if not found
535 static struct ConfigSection *
536 findSection (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section)
538 struct ConfigSection *pos;
541 while ((pos != NULL) && (0 != strcasecmp (section, pos->name)))
548 * Find an entry from a configuration.
550 * @param cfg handle to the configuration
551 * @param section section the option is in
552 * @param key the option
553 * @return matching entry, NULL if not found
555 static struct ConfigEntry *
556 findEntry (const struct GNUNET_CONFIGURATION_Handle *cfg,
557 const char *section, const char *key)
559 struct ConfigSection *sec;
560 struct ConfigEntry *pos;
562 sec = findSection (cfg, section);
566 while ((pos != NULL) && (0 != strcasecmp (key, pos->key)))
573 * A callback function, compares entries from two configurations
574 * (default against a new configuration) and write the diffs in a
575 * diff-configuration object (the callback object).
577 * @param cls the diff configuration (struct DiffHandle*)
578 * @param section section for the value (of the default conf.)
579 * @param option option name of the value (of the default conf.)
580 * @param value value to copy (of the default conf.)
583 compareEntries (void *cls,
584 const char *section, const char *option, const char *value)
586 struct DiffHandle *dh = cls;
587 struct ConfigEntry *entNew;
589 entNew = findEntry (dh->cfgDefault, section, option);
590 if ((entNew != NULL) && (strcmp (entNew->val, value) == 0))
592 GNUNET_CONFIGURATION_set_value_string (dh->cfgDiff, section, option, value);
597 * Write only configuration entries that have been changed to configuration file
598 * @param cfgDefault default configuration
599 * @param cfgNew new configuration
600 * @param filename where to write the configuration diff between default and new
601 * @return GNUNET_OK on success, GNUNET_SYSERR on error
604 GNUNET_CONFIGURATION_write_diffs (const struct GNUNET_CONFIGURATION_Handle
606 const struct GNUNET_CONFIGURATION_Handle
607 *cfgNew, const char *filename)
610 struct DiffHandle diffHandle;
612 diffHandle.cfgDiff = GNUNET_CONFIGURATION_create ();
613 diffHandle.cfgDefault = cfgDefault;
614 GNUNET_CONFIGURATION_iterate (cfgNew, compareEntries, &diffHandle);
615 ret = GNUNET_CONFIGURATION_write (diffHandle.cfgDiff, filename);
616 GNUNET_CONFIGURATION_destroy (diffHandle.cfgDiff);
622 * Set a configuration value that should be a string.
624 * @param cfg configuration to update
625 * @param section section of interest
626 * @param option option of interest
627 * @param value value to set
630 GNUNET_CONFIGURATION_set_value_string (struct GNUNET_CONFIGURATION_Handle
633 const char *option, const char *value)
635 struct ConfigSection *sec;
636 struct ConfigEntry *e;
638 e = findEntry (cfg, section, option);
641 GNUNET_free_non_null (e->val);
642 e->val = GNUNET_strdup (value);
645 sec = findSection (cfg, section);
648 sec = GNUNET_malloc (sizeof (struct ConfigSection));
649 sec->name = GNUNET_strdup (section);
650 sec->next = cfg->sections;
653 e = GNUNET_malloc (sizeof (struct ConfigEntry));
654 e->key = GNUNET_strdup (option);
655 e->val = GNUNET_strdup (value);
656 e->next = sec->entries;
662 * Set a configuration value that should be a number.
664 * @param cfg configuration to update
665 * @param section section of interest
666 * @param option option of interest
667 * @param number value to set
670 GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle
671 *cfg, const char *section,
673 unsigned long long number)
677 GNUNET_snprintf (s, 64, "%llu", number);
678 GNUNET_CONFIGURATION_set_value_string (cfg, section, option, s);
683 * Get a configuration value that should be a number.
685 * @param cfg configuration to inspect
686 * @param section section of interest
687 * @param option option of interest
688 * @param number where to store the numeric value of the option
689 * @return GNUNET_OK on success, GNUNET_SYSERR on error
692 GNUNET_CONFIGURATION_get_value_number (const struct
693 GNUNET_CONFIGURATION_Handle *cfg,
696 unsigned long long *number)
698 struct ConfigEntry *e;
700 e = findEntry (cfg, section, option);
702 return GNUNET_SYSERR;
703 if (1 != SSCANF (e->val, "%llu", number))
704 return GNUNET_SYSERR;
710 * Get a configuration value that should be a relative time.
712 * @param cfg configuration to inspect
713 * @param section section of interest
714 * @param option option of interest
715 * @param time set to the time value stored in the configuration
716 * @return GNUNET_OK on success, GNUNET_SYSERR on error
719 GNUNET_CONFIGURATION_get_value_time (const struct GNUNET_CONFIGURATION_Handle
720 *cfg, const char *section,
722 struct GNUNET_TIME_Relative *time)
724 struct ConfigEntry *e;
725 unsigned long long num;
727 e = findEntry (cfg, section, option);
729 return GNUNET_SYSERR;
730 if ((0 == strcasecmp (e->val, "infinity")) ||
731 (0 == strcasecmp (e->val, "forever")))
733 *time = GNUNET_TIME_UNIT_FOREVER_REL;
736 if (1 != SSCANF (e->val, "%llu", &num))
737 return GNUNET_SYSERR;
738 time->rel_value = (uint64_t) num;
744 * Get a configuration value that should be a string.
746 * @param cfg configuration to inspect
747 * @param section section of interest
748 * @param option option of interest
749 * @param value will be set to a freshly allocated configuration
750 * value, or NULL if option is not specified
751 * @return GNUNET_OK on success, GNUNET_SYSERR on error
754 GNUNET_CONFIGURATION_get_value_string (const struct
755 GNUNET_CONFIGURATION_Handle *cfg,
757 const char *option, char **value)
759 struct ConfigEntry *e;
761 e = findEntry (cfg, section, option);
762 if ((e == NULL) || (e->val == NULL))
765 return GNUNET_SYSERR;
767 *value = GNUNET_strdup (e->val);
773 * Get a configuration value that should be in a set of
776 * @param cfg configuration to inspect
777 * @param section section of interest
778 * @param option option of interest
779 * @param choices NULL-terminated list of legal values
780 * @param value will be set to an entry in the legal list,
781 * or NULL if option is not specified and no default given
782 * @return GNUNET_OK on success, GNUNET_SYSERR on error
785 GNUNET_CONFIGURATION_get_value_choice (const struct
786 GNUNET_CONFIGURATION_Handle *cfg,
789 const char **choices, const char **value)
791 struct ConfigEntry *e;
794 e = findEntry (cfg, section, option);
796 return GNUNET_SYSERR;
798 while (choices[i] != NULL)
800 if (0 == strcasecmp (choices[i], e->val))
804 if (choices[i] == NULL)
806 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
807 _("Configuration value '%s' for '%s'"
808 " in section '%s' is not in set of legal choices\n"),
809 e->val, option, section);
810 return GNUNET_SYSERR;
818 * Test if we have a value for a particular option
819 * @param cfg configuration to inspect
820 * @param section section of interest
821 * @param option option of interest
822 * @return GNUNET_YES if so, GNUNET_NO if not.
825 GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle
826 *cfg, const char *section, const char *option)
828 struct ConfigEntry *e;
830 if ((NULL == (e = findEntry (cfg, section, option))) || (e->val == NULL))
837 * Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR"
838 * where either in the "PATHS" section or the environtment
839 * "FOO" is set to "DIRECTORY".
841 * @param cfg configuration to use for path expansion
842 * @param orig string to $-expand (will be freed!)
843 * @return $-expanded string
846 GNUNET_CONFIGURATION_expand_dollar (const struct GNUNET_CONFIGURATION_Handle
858 while ((orig[i] != '/') && (orig[i] != '\\') && (orig[i] != '\0'))
869 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg,
873 if (NULL == (env = getenv (&orig[1])))
875 orig[i] = DIR_SEPARATOR;
878 prefix = GNUNET_strdup (env);
880 result = GNUNET_malloc (strlen (prefix) + strlen (post) + 2);
881 strcpy (result, prefix);
882 if ((strlen (prefix) == 0) ||
883 ((prefix[strlen (prefix) - 1] != DIR_SEPARATOR) && (strlen (post) > 0)))
884 strcat (result, DIR_SEPARATOR_STR);
885 strcat (result, post);
886 GNUNET_free (prefix);
893 * Get a configuration value that should be a string.
895 * @param cfg configuration to inspect
896 * @param section section of interest
897 * @param option option of interest
898 * @param value will be set to a freshly allocated configuration
899 * value, or NULL if option is not specified
900 * @return GNUNET_OK on success, GNUNET_SYSERR on error
903 GNUNET_CONFIGURATION_get_value_filename (const struct
904 GNUNET_CONFIGURATION_Handle *cfg,
906 const char *option, char **value)
911 GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &tmp))
914 return GNUNET_SYSERR;
916 tmp = GNUNET_CONFIGURATION_expand_dollar (cfg, tmp);
917 *value = GNUNET_STRINGS_filename_expand (tmp);
920 return GNUNET_SYSERR;
926 * Get a configuration value that should be in a set of
927 * "GNUNET_YES" or "GNUNET_NO".
929 * @param cfg configuration to inspect
930 * @param section section of interest
931 * @param option option of interest
932 * @return GNUNET_YES, GNUNET_NO or GNUNET_SYSERR
935 GNUNET_CONFIGURATION_get_value_yesno (const struct GNUNET_CONFIGURATION_Handle
936 *cfg, const char *section,
939 static const char *yesno[] = { "YES", "NO", NULL };
943 ret = GNUNET_CONFIGURATION_get_value_choice (cfg,
944 section, option, yesno, &val);
945 if (ret == GNUNET_SYSERR)
954 * Iterate over the set of filenames stored in a configuration value.
956 * @param cfg configuration to inspect
957 * @param section section of interest
958 * @param option option of interest
959 * @param cb function to call on each filename
960 * @param cb_cls closure for cb
961 * @return number of filenames iterated over, -1 on error
964 GNUNET_CONFIGURATION_iterate_value_filenames (const struct
965 GNUNET_CONFIGURATION_Handle
966 *cfg, const char *section,
968 GNUNET_FileNameCallback cb,
978 GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &list))
980 GNUNET_assert (list != NULL);
985 while (pos[0] == ' ')
987 if (strlen (pos) == 0)
990 while ((end[0] != ' ') && (end[0] != '\0'))
998 memmove (end, &end[1], strlen (&end[1]) + 1);
1000 /* illegal, but just keep it */
1003 /* illegal, but just ignore that there was a '/' */
1011 if (strlen (pos) > 0)
1014 if ((cb != NULL) && (GNUNET_OK != cb (cb_cls, pos)))
1016 ret = GNUNET_SYSERR;
1032 * @param value FIXME
1036 escape_name (const char *value)
1042 escaped = GNUNET_malloc (strlen (value) * 2 + 1);
1043 memset (escaped, 0, strlen (value) * 2 + 1);
1046 while (rpos[0] != '\0')
1069 * @param cls string we compare with (const char*)
1070 * @param fn filename we are currently looking at
1071 * @return GNUNET_OK if the names do not match, GNUNET_SYSERR if they do
1074 test_match (void *cls, const char *fn)
1076 const char *of = cls;
1078 return (0 == strcmp (of, fn)) ? GNUNET_SYSERR : GNUNET_OK;
1083 * Append a filename to a configuration value that
1084 * represents a list of filenames
1086 * @param cfg configuration to update
1087 * @param section section of interest
1088 * @param option option of interest
1089 * @param value filename to append
1090 * @return GNUNET_OK on success,
1091 * GNUNET_NO if the filename already in the list
1092 * GNUNET_SYSERR on error
1095 GNUNET_CONFIGURATION_append_value_filename (struct GNUNET_CONFIGURATION_Handle
1097 const char *section,
1106 == GNUNET_CONFIGURATION_iterate_value_filenames (cfg,
1111 return GNUNET_NO; /* already exists */
1113 GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &old))
1114 old = GNUNET_strdup ("");
1115 escaped = escape_name (value);
1116 nw = GNUNET_malloc (strlen (old) + strlen (escaped) + 2);
1118 if (strlen (old) > 0)
1120 strcat (nw, escaped);
1121 GNUNET_CONFIGURATION_set_value_string (cfg, section, option, nw);
1124 GNUNET_free (escaped);
1130 * Remove a filename from a configuration value that
1131 * represents a list of filenames
1133 * @param cfg configuration to update
1134 * @param section section of interest
1135 * @param option option of interest
1136 * @param value filename to remove
1137 * @return GNUNET_OK on success,
1138 * GNUNET_NO if the filename is not in the list,
1139 * GNUNET_SYSERR on error
1142 GNUNET_CONFIGURATION_remove_value_filename (struct GNUNET_CONFIGURATION_Handle
1144 const char *section,
1155 GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &list))
1157 match = escape_name (value);
1161 while (pos[0] == ' ')
1163 if (strlen (pos) == 0)
1166 while ((end[0] != ' ') && (end[0] != '\0'))
1177 /* illegal, but just keep it */
1180 /* illegal, but just ignore that there was a '/' */
1188 if (0 == strcmp (pos, match))
1191 memmove (pos, &end[1], strlen (&end[1]) + 1);
1199 GNUNET_CONFIGURATION_set_value_string (cfg, section, option, list);
1201 GNUNET_free (match);
1210 GNUNET_free (match);
1216 * Load configuration (starts with defaults, then loads
1217 * system-specific configuration).
1219 * @param cfg configuration to update
1220 * @param filename name of the configuration file, NULL to load defaults
1221 * @return GNUNET_OK on success, GNUNET_SYSERR on error
1224 GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg,
1225 const char *filename)
1230 ipath = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR);
1232 return GNUNET_SYSERR;
1234 GNUNET_asprintf (&baseconfig,
1235 "%s%s%s", ipath, DIR_SEPARATOR_STR, "defaults.conf");
1236 GNUNET_free (ipath);
1238 GNUNET_CONFIGURATION_parse (cfg, baseconfig)) ||
1239 (!((filename == NULL) ||
1240 (GNUNET_OK == GNUNET_CONFIGURATION_parse (cfg, filename)))))
1242 GNUNET_free (baseconfig);
1243 return (filename == NULL) ? GNUNET_OK : GNUNET_SYSERR;
1245 GNUNET_free (baseconfig);
1246 if (((GNUNET_YES != GNUNET_CONFIGURATION_have_value (cfg,
1248 "DEFAULTCONFIG"))) &&
1250 GNUNET_CONFIGURATION_set_value_string (cfg,
1251 "PATHS", "DEFAULTCONFIG", filename);
1252 if ((GNUNET_YES == GNUNET_CONFIGURATION_have_value (cfg,
1255 (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (cfg,
1258 GNUNET_CRYPTO_random_disable_entropy_gathering ();
1264 /* end of configuration.c */