aboutsummaryrefslogtreecommitdiff
path: root/src/util/configuration.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/configuration.c')
-rw-r--r--src/util/configuration.c451
1 files changed, 208 insertions, 243 deletions
diff --git a/src/util/configuration.c b/src/util/configuration.c
index a38438ba8..f327071de 100644
--- a/src/util/configuration.c
+++ b/src/util/configuration.c
@@ -30,9 +30,10 @@
30#include "gnunet_configuration_lib.h" 30#include "gnunet_configuration_lib.h"
31#include "gnunet_disk_lib.h" 31#include "gnunet_disk_lib.h"
32 32
33#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__) 33#define LOG(kind, ...) GNUNET_log_from (kind, "util", __VA_ARGS__)
34 34
35#define LOG_STRERROR_FILE(kind,syscall,filename) GNUNET_log_from_strerror_file (kind, "util", syscall, filename) 35#define LOG_STRERROR_FILE(kind, syscall, filename) \
36 GNUNET_log_from_strerror_file (kind, "util", syscall, filename)
36 37
37/** 38/**
38 * @brief configuration entry 39 * @brief configuration entry
@@ -95,7 +96,6 @@ struct GNUNET_CONFIGURATION_Handle
95 * #GNUNET_SYSERR on error (i.e. last save failed) 96 * #GNUNET_SYSERR on error (i.e. last save failed)
96 */ 97 */
97 int dirty; 98 int dirty;
98
99}; 99};
100 100
101 101
@@ -152,23 +152,20 @@ GNUNET_CONFIGURATION_destroy (struct GNUNET_CONFIGURATION_Handle *cfg)
152 */ 152 */
153int 153int
154GNUNET_CONFIGURATION_parse_and_run (const char *filename, 154GNUNET_CONFIGURATION_parse_and_run (const char *filename,
155 GNUNET_CONFIGURATION_Callback cb, 155 GNUNET_CONFIGURATION_Callback cb,
156 void *cb_cls) 156 void *cb_cls)
157{ 157{
158 struct GNUNET_CONFIGURATION_Handle *cfg; 158 struct GNUNET_CONFIGURATION_Handle *cfg;
159 int ret; 159 int ret;
160 160
161 cfg = GNUNET_CONFIGURATION_create (); 161 cfg = GNUNET_CONFIGURATION_create ();
162 if (GNUNET_OK != 162 if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, filename))
163 GNUNET_CONFIGURATION_load (cfg,
164 filename))
165 { 163 {
166 GNUNET_break (0); 164 GNUNET_break (0);
167 GNUNET_CONFIGURATION_destroy (cfg); 165 GNUNET_CONFIGURATION_destroy (cfg);
168 return GNUNET_SYSERR; 166 return GNUNET_SYSERR;
169 } 167 }
170 ret = cb (cb_cls, 168 ret = cb (cb_cls, cfg);
171 cfg);
172 GNUNET_CONFIGURATION_destroy (cfg); 169 GNUNET_CONFIGURATION_destroy (cfg);
173 return ret; 170 return ret;
174} 171}
@@ -187,9 +184,9 @@ GNUNET_CONFIGURATION_parse_and_run (const char *filename,
187 */ 184 */
188int 185int
189GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg, 186GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg,
190 const char *mem, 187 const char *mem,
191 size_t size, 188 size_t size,
192 const char *basedir) 189 const char *basedir)
193{ 190{
194 char *line; 191 char *line;
195 char *line_orig; 192 char *line_orig;
@@ -224,7 +221,8 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg,
224 } 221 }
225 else 222 else
226 { 223 {
227 line_orig = GNUNET_strndup (&mem[r_bytes], line_size = (pos - &mem[r_bytes])); 224 line_orig =
225 GNUNET_strndup (&mem[r_bytes], line_size = (pos - &mem[r_bytes]));
228 r_bytes += line_size + 1; 226 r_bytes += line_size + 1;
229 } 227 }
230 line = line_orig; 228 line = line_orig;
@@ -246,51 +244,46 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg,
246 continue; 244 continue;
247 245
248 /* remove tailing whitespace */ 246 /* remove tailing whitespace */
249 for (i = line_size - 1; (i >= 1) && (isspace ((unsigned char) line[i]));i--) 247 for (i = line_size - 1; (i >= 1) && (isspace ((unsigned char) line[i]));
248 i--)
250 line[i] = '\0'; 249 line[i] = '\0';
251 250
252 /* remove leading whitespace */ 251 /* remove leading whitespace */
253 for (; line[0] != '\0' && (isspace ((unsigned char) line[0])); line++); 252 for (; line[0] != '\0' && (isspace ((unsigned char) line[0])); line++)
253 ;
254 254
255 /* ignore comments */ 255 /* ignore comments */
256 if ( ('#' == line[0]) || ('%' == line[0]) ) 256 if (('#' == line[0]) || ('%' == line[0]))
257 continue; 257 continue;
258 258
259 /* handle special "@INLINE@" directive */ 259 /* handle special "@INLINE@" directive */
260 if (0 == strncasecmp (line, 260 if (0 == strncasecmp (line, "@INLINE@ ", strlen ("@INLINE@ ")))
261 "@INLINE@ ",
262 strlen ("@INLINE@ ")))
263 { 261 {
264 /* @INLINE@ value */ 262 /* @INLINE@ value */
265 value = &line[strlen ("@INLINE@ ")]; 263 value = &line[strlen ("@INLINE@ ")];
266 if (NULL != basedir) 264 if (NULL != basedir)
267 { 265 {
268 char *fn; 266 char *fn;
269 267
270 GNUNET_asprintf (&fn, 268 GNUNET_asprintf (&fn, "%s/%s", basedir, value);
271 "%s/%s", 269 if (GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, fn))
272 basedir, 270 {
273 value); 271 GNUNET_free (fn);
274 if (GNUNET_OK != 272 ret = GNUNET_SYSERR; /* failed to parse included config */
275 GNUNET_CONFIGURATION_parse (cfg, 273 break;
276 fn)) 274 }
277 { 275 GNUNET_free (fn);
278 GNUNET_free (fn);
279 ret = GNUNET_SYSERR; /* failed to parse included config */
280 break;
281 }
282 GNUNET_free (fn);
283 } 276 }
284 else 277 else
285 { 278 {
286 LOG (GNUNET_ERROR_TYPE_DEBUG, 279 LOG (GNUNET_ERROR_TYPE_DEBUG,
287 "Ignoring parsing @INLINE@ configurations, not allowed!\n"); 280 "Ignoring parsing @INLINE@ configurations, not allowed!\n");
288 ret = GNUNET_SYSERR; 281 ret = GNUNET_SYSERR;
289 break; 282 break;
290 } 283 }
291 continue; 284 continue;
292 } 285 }
293 if ( ('[' == line[0]) && (']' == line[line_size - 1]) ) 286 if (('[' == line[0]) && (']' == line[line_size - 1]))
294 { 287 {
295 /* [value] */ 288 /* [value] */
296 line[line_size - 1] = '\0'; 289 line[line_size - 1] = '\0';
@@ -304,23 +297,25 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg,
304 /* tag = value */ 297 /* tag = value */
305 tag = GNUNET_strndup (line, eq - line); 298 tag = GNUNET_strndup (line, eq - line);
306 /* remove tailing whitespace */ 299 /* remove tailing whitespace */
307 for (i = strlen (tag) - 1; (i >= 1) && (isspace ((unsigned char) tag[i]));i--) 300 for (i = strlen (tag) - 1; (i >= 1) && (isspace ((unsigned char) tag[i]));
308 tag[i] = '\0'; 301 i--)
302 tag[i] = '\0';
309 303
310 /* Strip whitespace */ 304 /* Strip whitespace */
311 value = eq + 1; 305 value = eq + 1;
312 while (isspace ((unsigned char) value[0])) 306 while (isspace ((unsigned char) value[0]))
313 value++; 307 value++;
314 for (i = strlen (value) - 1; (i >= 1) && (isspace ((unsigned char) value[i]));i--) 308 for (i = strlen (value) - 1;
315 value[i] = '\0'; 309 (i >= 1) && (isspace ((unsigned char) value[i]));
310 i--)
311 value[i] = '\0';
316 312
317 /* remove quotes */ 313 /* remove quotes */
318 i = 0; 314 i = 0;
319 if ( ('"' == value[0]) && 315 if (('"' == value[0]) && ('"' == value[strlen (value) - 1]))
320 ('"' == value[strlen (value) - 1]) )
321 { 316 {
322 value[strlen (value) - 1] = '\0'; 317 value[strlen (value) - 1] = '\0';
323 value++; 318 value++;
324 } 319 }
325 GNUNET_CONFIGURATION_set_value_string (cfg, section, tag, &value[i]); 320 GNUNET_CONFIGURATION_set_value_string (cfg, section, tag, &value[i]);
326 GNUNET_free (tag); 321 GNUNET_free (tag);
@@ -328,14 +323,14 @@ GNUNET_CONFIGURATION_deserialize (struct GNUNET_CONFIGURATION_Handle *cfg,
328 } 323 }
329 /* parse error */ 324 /* parse error */
330 LOG (GNUNET_ERROR_TYPE_WARNING, 325 LOG (GNUNET_ERROR_TYPE_WARNING,
331 _("Syntax error while deserializing in line %u\n"), 326 _ ("Syntax error while deserializing in line %u\n"),
332 nr); 327 nr);
333 ret = GNUNET_SYSERR; 328 ret = GNUNET_SYSERR;
334 break; 329 break;
335 } 330 }
336 GNUNET_free_non_null (line_orig); 331 GNUNET_free_non_null (line_orig);
337 GNUNET_free (section); 332 GNUNET_free (section);
338 GNUNET_assert ( (GNUNET_OK != ret) || (r_bytes == size) ); 333 GNUNET_assert ((GNUNET_OK != ret) || (r_bytes == size));
339 return ret; 334 return ret;
340} 335}
341 336
@@ -362,55 +357,40 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg,
362 ssize_t sret; 357 ssize_t sret;
363 358
364 fn = GNUNET_STRINGS_filename_expand (filename); 359 fn = GNUNET_STRINGS_filename_expand (filename);
365 LOG (GNUNET_ERROR_TYPE_DEBUG, 360 LOG (GNUNET_ERROR_TYPE_DEBUG, "Asked to parse config file `%s'\n", fn);
366 "Asked to parse config file `%s'\n",
367 fn);
368 if (NULL == fn) 361 if (NULL == fn)
369 return GNUNET_SYSERR; 362 return GNUNET_SYSERR;
370 dirty = cfg->dirty; /* back up value! */ 363 dirty = cfg->dirty; /* back up value! */
371 if (GNUNET_SYSERR == 364 if (GNUNET_SYSERR ==
372 GNUNET_DISK_file_size (fn, 365 GNUNET_DISK_file_size (fn, &fs64, GNUNET_YES, GNUNET_YES))
373 &fs64,
374 GNUNET_YES,
375 GNUNET_YES))
376 { 366 {
377 LOG (GNUNET_ERROR_TYPE_WARNING, 367 LOG (GNUNET_ERROR_TYPE_WARNING,
378 "Error while determining the file size of `%s'\n", 368 "Error while determining the file size of `%s'\n",
379 fn); 369 fn);
380 GNUNET_free (fn); 370 GNUNET_free (fn);
381 return GNUNET_SYSERR; 371 return GNUNET_SYSERR;
382 } 372 }
383 if (fs64 > SIZE_MAX) 373 if (fs64 > SIZE_MAX)
384 { 374 {
385 GNUNET_break (0); /* File size is more than the heap size */ 375 GNUNET_break (0); /* File size is more than the heap size */
386 GNUNET_free (fn); 376 GNUNET_free (fn);
387 return GNUNET_SYSERR; 377 return GNUNET_SYSERR;
388 } 378 }
389 fs = fs64; 379 fs = fs64;
390 mem = GNUNET_malloc (fs); 380 mem = GNUNET_malloc (fs);
391 sret = GNUNET_DISK_fn_read (fn, 381 sret = GNUNET_DISK_fn_read (fn, mem, fs);
392 mem, 382 if ((sret < 0) || (fs != (size_t) sret))
393 fs);
394 if ( (sret < 0) ||
395 (fs != (size_t) sret) )
396 { 383 {
397 LOG (GNUNET_ERROR_TYPE_WARNING, 384 LOG (GNUNET_ERROR_TYPE_WARNING, _ ("Error while reading file `%s'\n"), fn);
398 _("Error while reading file `%s'\n"),
399 fn);
400 GNUNET_free (fn); 385 GNUNET_free (fn);
401 GNUNET_free (mem); 386 GNUNET_free (mem);
402 return GNUNET_SYSERR; 387 return GNUNET_SYSERR;
403 } 388 }
404 LOG (GNUNET_ERROR_TYPE_DEBUG, 389 LOG (GNUNET_ERROR_TYPE_DEBUG, "Deserializing contents of file `%s'\n", fn);
405 "Deserializing contents of file `%s'\n",
406 fn);
407 endsep = strrchr (fn, (int) '/'); 390 endsep = strrchr (fn, (int) '/');
408 if (NULL != endsep) 391 if (NULL != endsep)
409 *endsep = '\0'; 392 *endsep = '\0';
410 ret = GNUNET_CONFIGURATION_deserialize (cfg, 393 ret = GNUNET_CONFIGURATION_deserialize (cfg, mem, fs, fn);
411 mem,
412 fs,
413 fn);
414 GNUNET_free (fn); 394 GNUNET_free (fn);
415 GNUNET_free (mem); 395 GNUNET_free (mem);
416 /* restore dirty flag - anything we set in the meantime 396 /* restore dirty flag - anything we set in the meantime
@@ -444,7 +424,7 @@ GNUNET_CONFIGURATION_is_dirty (const struct GNUNET_CONFIGURATION_Handle *cfg)
444 */ 424 */
445char * 425char *
446GNUNET_CONFIGURATION_serialize (const struct GNUNET_CONFIGURATION_Handle *cfg, 426GNUNET_CONFIGURATION_serialize (const struct GNUNET_CONFIGURATION_Handle *cfg,
447 size_t *size) 427 size_t *size)
448{ 428{
449 struct ConfigSection *sec; 429 struct ConfigSection *sec;
450 struct ConfigEntry *ent; 430 struct ConfigEntry *ent;
@@ -466,16 +446,16 @@ GNUNET_CONFIGURATION_serialize (const struct GNUNET_CONFIGURATION_Handle *cfg,
466 { 446 {
467 if (NULL != ent->val) 447 if (NULL != ent->val)
468 { 448 {
469 /* if val has any '\n' then they occupy +1 character as '\n'->'\\','n' */ 449 /* if val has any '\n' then they occupy +1 character as '\n'->'\\','n' */
470 pos = ent->val; 450 pos = ent->val;
471 while (NULL != (pos = strstr (pos, "\n"))) 451 while (NULL != (pos = strstr (pos, "\n")))
472 { 452 {
473 m_size++; 453 m_size++;
474 pos++; 454 pos++;
475 } 455 }
476 /* For each key = value pair we need to add 4 characters (2 456 /* For each key = value pair we need to add 4 characters (2
477 spaces and 1 equal-to character and 1 new line) */ 457 spaces and 1 equal-to character and 1 new line) */
478 m_size += strlen (ent->key) + strlen (ent->val) + 4; 458 m_size += strlen (ent->key) + strlen (ent->val) + 4;
479 } 459 }
480 } 460 }
481 /* A new line after section end */ 461 /* A new line after section end */
@@ -498,23 +478,23 @@ GNUNET_CONFIGURATION_serialize (const struct GNUNET_CONFIGURATION_Handle *cfg,
498 { 478 {
499 if (NULL != ent->val) 479 if (NULL != ent->val)
500 { 480 {
501 val = GNUNET_malloc (strlen (ent->val) * 2 + 1); 481 val = GNUNET_malloc (strlen (ent->val) * 2 + 1);
502 strcpy (val, ent->val); 482 strcpy (val, ent->val);
503 while (NULL != (pos = strstr (val, "\n"))) 483 while (NULL != (pos = strstr (val, "\n")))
504 { 484 {
505 memmove (&pos[2], &pos[1], strlen (&pos[1])); 485 memmove (&pos[2], &pos[1], strlen (&pos[1]));
506 pos[0] = '\\'; 486 pos[0] = '\\';
507 pos[1] = 'n'; 487 pos[1] = 'n';
508 } 488 }
509 len = GNUNET_asprintf (&cbuf, "%s = %s\n", ent->key, val); 489 len = GNUNET_asprintf (&cbuf, "%s = %s\n", ent->key, val);
510 GNUNET_free (val); 490 GNUNET_free (val);
511 GNUNET_memcpy (mem + c_size, cbuf, len); 491 GNUNET_memcpy (mem + c_size, cbuf, len);
512 c_size += len; 492 c_size += len;
513 GNUNET_free (cbuf); 493 GNUNET_free (cbuf);
514 } 494 }
515 } 495 }
516 GNUNET_memcpy (mem + c_size, "\n", 1); 496 GNUNET_memcpy (mem + c_size, "\n", 1);
517 c_size ++; 497 c_size++;
518 sec = sec->next; 498 sec = sec->next;
519 } 499 }
520 GNUNET_assert (c_size == m_size); 500 GNUNET_assert (c_size == m_size);
@@ -548,25 +528,26 @@ GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg,
548 return GNUNET_SYSERR; 528 return GNUNET_SYSERR;
549 } 529 }
550 cfg_buf = GNUNET_CONFIGURATION_serialize (cfg, &size); 530 cfg_buf = GNUNET_CONFIGURATION_serialize (cfg, &size);
551 sret = GNUNET_DISK_fn_write (fn, cfg_buf, size, 531 sret = GNUNET_DISK_fn_write (fn,
552 GNUNET_DISK_PERM_USER_READ 532 cfg_buf,
553 | GNUNET_DISK_PERM_USER_WRITE 533 size,
554 | GNUNET_DISK_PERM_GROUP_READ 534 GNUNET_DISK_PERM_USER_READ |
555 | GNUNET_DISK_PERM_GROUP_WRITE); 535 GNUNET_DISK_PERM_USER_WRITE |
556 if ( (sret < 0) || 536 GNUNET_DISK_PERM_GROUP_READ |
557 (size != (size_t) sret) ) 537 GNUNET_DISK_PERM_GROUP_WRITE);
538 if ((sret < 0) || (size != (size_t) sret))
558 { 539 {
559 GNUNET_free (fn); 540 GNUNET_free (fn);
560 GNUNET_free (cfg_buf); 541 GNUNET_free (cfg_buf);
561 LOG (GNUNET_ERROR_TYPE_WARNING, 542 LOG (GNUNET_ERROR_TYPE_WARNING,
562 "Writing configuration to file `%s' failed\n", 543 "Writing configuration to file `%s' failed\n",
563 filename); 544 filename);
564 cfg->dirty = GNUNET_SYSERR; /* last write failed */ 545 cfg->dirty = GNUNET_SYSERR; /* last write failed */
565 return GNUNET_SYSERR; 546 return GNUNET_SYSERR;
566 } 547 }
567 GNUNET_free (fn); 548 GNUNET_free (fn);
568 GNUNET_free (cfg_buf); 549 GNUNET_free (cfg_buf);
569 cfg->dirty = GNUNET_NO; /* last write succeeded */ 550 cfg->dirty = GNUNET_NO; /* last write succeeded */
570 return GNUNET_OK; 551 return GNUNET_OK;
571} 552}
572 553
@@ -589,7 +570,7 @@ GNUNET_CONFIGURATION_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg,
589 for (spos = cfg->sections; NULL != spos; spos = spos->next) 570 for (spos = cfg->sections; NULL != spos; spos = spos->next)
590 for (epos = spos->entries; NULL != epos; epos = epos->next) 571 for (epos = spos->entries; NULL != epos; epos = epos->next)
591 if (NULL != epos->val) 572 if (NULL != epos->val)
592 iter (iter_cls, spos->name, epos->key, epos->val); 573 iter (iter_cls, spos->name, epos->key, epos->val);
593} 574}
594 575
595 576
@@ -602,11 +583,11 @@ GNUNET_CONFIGURATION_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg,
602 * @param iter_cls closure for @a iter 583 * @param iter_cls closure for @a iter
603 */ 584 */
604void 585void
605GNUNET_CONFIGURATION_iterate_section_values (const struct 586GNUNET_CONFIGURATION_iterate_section_values (
606 GNUNET_CONFIGURATION_Handle *cfg, 587 const struct GNUNET_CONFIGURATION_Handle *cfg,
607 const char *section, 588 const char *section,
608 GNUNET_CONFIGURATION_Iterator iter, 589 GNUNET_CONFIGURATION_Iterator iter,
609 void *iter_cls) 590 void *iter_cls)
610{ 591{
611 struct ConfigSection *spos; 592 struct ConfigSection *spos;
612 struct ConfigEntry *epos; 593 struct ConfigEntry *epos;
@@ -630,9 +611,10 @@ GNUNET_CONFIGURATION_iterate_section_values (const struct
630 * @param iter_cls closure for @a iter 611 * @param iter_cls closure for @a iter
631 */ 612 */
632void 613void
633GNUNET_CONFIGURATION_iterate_sections (const struct GNUNET_CONFIGURATION_Handle *cfg, 614GNUNET_CONFIGURATION_iterate_sections (
634 GNUNET_CONFIGURATION_Section_Iterator iter, 615 const struct GNUNET_CONFIGURATION_Handle *cfg,
635 void *iter_cls) 616 GNUNET_CONFIGURATION_Section_Iterator iter,
617 void *iter_cls)
636{ 618{
637 struct ConfigSection *spos; 619 struct ConfigSection *spos;
638 struct ConfigSection *next; 620 struct ConfigSection *next;
@@ -757,8 +739,8 @@ find_section (const struct GNUNET_CONFIGURATION_Handle *cfg,
757 */ 739 */
758static struct ConfigEntry * 740static struct ConfigEntry *
759find_entry (const struct GNUNET_CONFIGURATION_Handle *cfg, 741find_entry (const struct GNUNET_CONFIGURATION_Handle *cfg,
760 const char *section, 742 const char *section,
761 const char *key) 743 const char *key)
762{ 744{
763 struct ConfigSection *sec; 745 struct ConfigSection *sec;
764 struct ConfigEntry *pos; 746 struct ConfigEntry *pos;
@@ -786,15 +768,14 @@ static void
786compare_entries (void *cls, 768compare_entries (void *cls,
787 const char *section, 769 const char *section,
788 const char *option, 770 const char *option,
789 const char *value) 771 const char *value)
790{ 772{
791 struct DiffHandle *dh = cls; 773 struct DiffHandle *dh = cls;
792 struct ConfigEntry *entNew; 774 struct ConfigEntry *entNew;
793 775
794 entNew = find_entry (dh->cfg_default, section, option); 776 entNew = find_entry (dh->cfg_default, section, option);
795 if ( (NULL != entNew) && 777 if ((NULL != entNew) && (NULL != entNew->val) &&
796 (NULL != entNew->val) && 778 (0 == strcmp (entNew->val, value)))
797 (0 == strcmp (entNew->val, value)) )
798 return; 779 return;
799 GNUNET_CONFIGURATION_set_value_string (dh->cfgDiff, section, option, value); 780 GNUNET_CONFIGURATION_set_value_string (dh->cfgDiff, section, option, value);
800} 781}
@@ -808,8 +789,9 @@ compare_entries (void *cls,
808 * @return configuration with only the differences, never NULL 789 * @return configuration with only the differences, never NULL
809 */ 790 */
810struct GNUNET_CONFIGURATION_Handle * 791struct GNUNET_CONFIGURATION_Handle *
811GNUNET_CONFIGURATION_get_diff (const struct GNUNET_CONFIGURATION_Handle *cfg_default, 792GNUNET_CONFIGURATION_get_diff (
812 const struct GNUNET_CONFIGURATION_Handle *cfg_new) 793 const struct GNUNET_CONFIGURATION_Handle *cfg_default,
794 const struct GNUNET_CONFIGURATION_Handle *cfg_new)
813{ 795{
814 struct DiffHandle diffHandle; 796 struct DiffHandle diffHandle;
815 797
@@ -829,10 +811,10 @@ GNUNET_CONFIGURATION_get_diff (const struct GNUNET_CONFIGURATION_Handle *cfg_def
829 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 811 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
830 */ 812 */
831int 813int
832GNUNET_CONFIGURATION_write_diffs (const struct GNUNET_CONFIGURATION_Handle 814GNUNET_CONFIGURATION_write_diffs (
833 *cfg_default, 815 const struct GNUNET_CONFIGURATION_Handle *cfg_default,
834 const struct GNUNET_CONFIGURATION_Handle 816 const struct GNUNET_CONFIGURATION_Handle *cfg_new,
835 *cfg_new, const char *filename) 817 const char *filename)
836{ 818{
837 int ret; 819 int ret;
838 struct GNUNET_CONFIGURATION_Handle *diff; 820 struct GNUNET_CONFIGURATION_Handle *diff;
@@ -854,7 +836,8 @@ GNUNET_CONFIGURATION_write_diffs (const struct GNUNET_CONFIGURATION_Handle
854 */ 836 */
855void 837void
856GNUNET_CONFIGURATION_set_value_string (struct GNUNET_CONFIGURATION_Handle *cfg, 838GNUNET_CONFIGURATION_set_value_string (struct GNUNET_CONFIGURATION_Handle *cfg,
857 const char *section, const char *option, 839 const char *section,
840 const char *option,
858 const char *value) 841 const char *value)
859{ 842{
860 struct ConfigSection *sec; 843 struct ConfigSection *sec;
@@ -904,19 +887,13 @@ GNUNET_CONFIGURATION_set_value_string (struct GNUNET_CONFIGURATION_Handle *cfg,
904void 887void
905GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle *cfg, 888GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle *cfg,
906 const char *section, 889 const char *section,
907 const char *option, 890 const char *option,
908 unsigned long long number) 891 unsigned long long number)
909{ 892{
910 char s[64]; 893 char s[64];
911 894
912 GNUNET_snprintf (s, 895 GNUNET_snprintf (s, 64, "%llu", number);
913 64, 896 GNUNET_CONFIGURATION_set_value_string (cfg, section, option, s);
914 "%llu",
915 number);
916 GNUNET_CONFIGURATION_set_value_string (cfg,
917 section,
918 option,
919 s);
920} 897}
921 898
922 899
@@ -930,10 +907,11 @@ GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle *cfg,
930 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 907 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
931 */ 908 */
932int 909int
933GNUNET_CONFIGURATION_get_value_number (const struct GNUNET_CONFIGURATION_Handle *cfg, 910GNUNET_CONFIGURATION_get_value_number (
934 const char *section, 911 const struct GNUNET_CONFIGURATION_Handle *cfg,
935 const char *option, 912 const char *section,
936 unsigned long long *number) 913 const char *option,
914 unsigned long long *number)
937{ 915{
938 struct ConfigEntry *e; 916 struct ConfigEntry *e;
939 char dummy[2]; 917 char dummy[2];
@@ -942,10 +920,7 @@ GNUNET_CONFIGURATION_get_value_number (const struct GNUNET_CONFIGURATION_Handle
942 return GNUNET_SYSERR; 920 return GNUNET_SYSERR;
943 if (NULL == e->val) 921 if (NULL == e->val)
944 return GNUNET_SYSERR; 922 return GNUNET_SYSERR;
945 if (1 != SSCANF (e->val, 923 if (1 != sscanf (e->val, "%llu%1s", number, dummy))
946 "%llu%1s",
947 number,
948 dummy))
949 return GNUNET_SYSERR; 924 return GNUNET_SYSERR;
950 return GNUNET_OK; 925 return GNUNET_OK;
951} 926}
@@ -961,10 +936,11 @@ GNUNET_CONFIGURATION_get_value_number (const struct GNUNET_CONFIGURATION_Handle
961 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 936 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
962 */ 937 */
963int 938int
964GNUNET_CONFIGURATION_get_value_float (const struct GNUNET_CONFIGURATION_Handle *cfg, 939GNUNET_CONFIGURATION_get_value_float (
965 const char *section, 940 const struct GNUNET_CONFIGURATION_Handle *cfg,
966 const char *option, 941 const char *section,
967 float *number) 942 const char *option,
943 float *number)
968{ 944{
969 struct ConfigEntry *e; 945 struct ConfigEntry *e;
970 char dummy[2]; 946 char dummy[2];
@@ -973,16 +949,12 @@ GNUNET_CONFIGURATION_get_value_float (const struct GNUNET_CONFIGURATION_Handle
973 return GNUNET_SYSERR; 949 return GNUNET_SYSERR;
974 if (NULL == e->val) 950 if (NULL == e->val)
975 return GNUNET_SYSERR; 951 return GNUNET_SYSERR;
976 if (1 != SSCANF (e->val, 952 if (1 != sscanf (e->val, "%f%1s", number, dummy))
977 "%f%1s",
978 number,
979 dummy))
980 return GNUNET_SYSERR; 953 return GNUNET_SYSERR;
981 return GNUNET_OK; 954 return GNUNET_OK;
982} 955}
983 956
984 957
985
986/** 958/**
987 * Get a configuration value that should be a relative time. 959 * Get a configuration value that should be a relative time.
988 * 960 *
@@ -993,27 +965,25 @@ GNUNET_CONFIGURATION_get_value_float (const struct GNUNET_CONFIGURATION_Handle
993 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 965 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
994 */ 966 */
995int 967int
996GNUNET_CONFIGURATION_get_value_time (const struct GNUNET_CONFIGURATION_Handle *cfg, 968GNUNET_CONFIGURATION_get_value_time (
997 const char *section, 969 const struct GNUNET_CONFIGURATION_Handle *cfg,
998 const char *option, 970 const char *section,
999 struct GNUNET_TIME_Relative *time) 971 const char *option,
972 struct GNUNET_TIME_Relative *time)
1000{ 973{
1001 struct ConfigEntry *e; 974 struct ConfigEntry *e;
1002 int ret; 975 int ret;
1003 976
1004 if (NULL == (e = find_entry (cfg, 977 if (NULL == (e = find_entry (cfg, section, option)))
1005 section,
1006 option)))
1007 return GNUNET_SYSERR; 978 return GNUNET_SYSERR;
1008 if (NULL == e->val) 979 if (NULL == e->val)
1009 return GNUNET_SYSERR; 980 return GNUNET_SYSERR;
1010 ret = GNUNET_STRINGS_fancy_time_to_relative (e->val, 981 ret = GNUNET_STRINGS_fancy_time_to_relative (e->val, time);
1011 time);
1012 if (GNUNET_OK != ret) 982 if (GNUNET_OK != ret)
1013 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, 983 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
1014 section, 984 section,
1015 option, 985 option,
1016 _("Not a valid relative time specification")); 986 _ ("Not a valid relative time specification"));
1017 return ret; 987 return ret;
1018} 988}
1019 989
@@ -1028,10 +998,11 @@ GNUNET_CONFIGURATION_get_value_time (const struct GNUNET_CONFIGURATION_Handle *c
1028 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 998 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
1029 */ 999 */
1030int 1000int
1031GNUNET_CONFIGURATION_get_value_size (const struct GNUNET_CONFIGURATION_Handle *cfg, 1001GNUNET_CONFIGURATION_get_value_size (
1032 const char *section, 1002 const struct GNUNET_CONFIGURATION_Handle *cfg,
1033 const char *option, 1003 const char *section,
1034 unsigned long long *size) 1004 const char *option,
1005 unsigned long long *size)
1035{ 1006{
1036 struct ConfigEntry *e; 1007 struct ConfigEntry *e;
1037 1008
@@ -1054,15 +1025,15 @@ GNUNET_CONFIGURATION_get_value_size (const struct GNUNET_CONFIGURATION_Handle *c
1054 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 1025 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
1055 */ 1026 */
1056int 1027int
1057GNUNET_CONFIGURATION_get_value_string (const struct GNUNET_CONFIGURATION_Handle *cfg, 1028GNUNET_CONFIGURATION_get_value_string (
1058 const char *section, 1029 const struct GNUNET_CONFIGURATION_Handle *cfg,
1059 const char *option, 1030 const char *section,
1060 char **value) 1031 const char *option,
1032 char **value)
1061{ 1033{
1062 struct ConfigEntry *e; 1034 struct ConfigEntry *e;
1063 1035
1064 if ( (NULL == (e = find_entry (cfg, section, option))) || 1036 if ((NULL == (e = find_entry (cfg, section, option))) || (NULL == e->val))
1065 (NULL == e->val) )
1066 { 1037 {
1067 *value = NULL; 1038 *value = NULL;
1068 return GNUNET_SYSERR; 1039 return GNUNET_SYSERR;
@@ -1085,11 +1056,12 @@ GNUNET_CONFIGURATION_get_value_string (const struct GNUNET_CONFIGURATION_Handle
1085 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 1056 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
1086 */ 1057 */
1087int 1058int
1088GNUNET_CONFIGURATION_get_value_choice (const struct GNUNET_CONFIGURATION_Handle *cfg, 1059GNUNET_CONFIGURATION_get_value_choice (
1089 const char *section, 1060 const struct GNUNET_CONFIGURATION_Handle *cfg,
1090 const char *option, 1061 const char *section,
1091 const char *const *choices, 1062 const char *option,
1092 const char **value) 1063 const char *const *choices,
1064 const char **value)
1093{ 1065{
1094 struct ConfigEntry *e; 1066 struct ConfigEntry *e;
1095 unsigned int i; 1067 unsigned int i;
@@ -1102,8 +1074,8 @@ GNUNET_CONFIGURATION_get_value_choice (const struct GNUNET_CONFIGURATION_Handle
1102 if (NULL == choices[i]) 1074 if (NULL == choices[i])
1103 { 1075 {
1104 LOG (GNUNET_ERROR_TYPE_ERROR, 1076 LOG (GNUNET_ERROR_TYPE_ERROR,
1105 _("Configuration value '%s' for '%s'" 1077 _ ("Configuration value '%s' for '%s'"
1106 " in section '%s' is not in set of legal choices\n"), 1078 " in section '%s' is not in set of legal choices\n"),
1107 e->val, 1079 e->val,
1108 option, 1080 option,
1109 section); 1081 section);
@@ -1138,10 +1110,8 @@ GNUNET_CONFIGURATION_get_data (const struct GNUNET_CONFIGURATION_Handle *cfg,
1138 size_t data_size; 1110 size_t data_size;
1139 1111
1140 if (GNUNET_OK != 1112 if (GNUNET_OK !=
1141 (res = GNUNET_CONFIGURATION_get_value_string (cfg, 1113 (res =
1142 section, 1114 GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &enc)))
1143 option,
1144 &enc)))
1145 return res; 1115 return res;
1146 data_size = (strlen (enc) * 5) / 8; 1116 data_size = (strlen (enc) * 5) / 8;
1147 if (data_size != buf_size) 1117 if (data_size != buf_size)
@@ -1150,9 +1120,7 @@ GNUNET_CONFIGURATION_get_data (const struct GNUNET_CONFIGURATION_Handle *cfg,
1150 return GNUNET_SYSERR; 1120 return GNUNET_SYSERR;
1151 } 1121 }
1152 if (GNUNET_OK != 1122 if (GNUNET_OK !=
1153 GNUNET_STRINGS_string_to_data (enc, 1123 GNUNET_STRINGS_string_to_data (enc, strlen (enc), buf, buf_size))
1154 strlen (enc),
1155 buf, buf_size))
1156 { 1124 {
1157 GNUNET_free (enc); 1125 GNUNET_free (enc);
1158 return GNUNET_SYSERR; 1126 return GNUNET_SYSERR;
@@ -1221,17 +1189,15 @@ expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg,
1221 if (depth > 128) 1189 if (depth > 128)
1222 { 1190 {
1223 LOG (GNUNET_ERROR_TYPE_WARNING, 1191 LOG (GNUNET_ERROR_TYPE_WARNING,
1224 _("Recursive expansion suspected, aborting $-expansion for term `%s'\n"), 1192 _ (
1193 "Recursive expansion suspected, aborting $-expansion for term `%s'\n"),
1225 orig); 1194 orig);
1226 return orig; 1195 return orig;
1227 } 1196 }
1228 LOG (GNUNET_ERROR_TYPE_DEBUG, 1197 LOG (GNUNET_ERROR_TYPE_DEBUG, "Asked to $-expand %s\n", orig);
1229 "Asked to $-expand %s\n",
1230 orig);
1231 if ('$' != orig[0]) 1198 if ('$' != orig[0])
1232 { 1199 {
1233 LOG (GNUNET_ERROR_TYPE_DEBUG, 1200 LOG (GNUNET_ERROR_TYPE_DEBUG, "Doesn't start with $ - not expanding\n");
1234 "Doesn't start with $ - not expanding\n");
1235 return orig; 1201 return orig;
1236 } 1202 }
1237 erased_char = 0; 1203 erased_char = 0;
@@ -1254,7 +1220,7 @@ expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg,
1254 break; 1220 break;
1255 case '\0': 1221 case '\0':
1256 LOG (GNUNET_ERROR_TYPE_WARNING, 1222 LOG (GNUNET_ERROR_TYPE_WARNING,
1257 _("Missing closing `%s' in option `%s'\n"), 1223 _ ("Missing closing `%s' in option `%s'\n"),
1258 "}", 1224 "}",
1259 orig); 1225 orig);
1260 return orig; 1226 return orig;
@@ -1271,8 +1237,7 @@ expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg,
1271 { 1237 {
1272 *def = '\0'; 1238 *def = '\0';
1273 def++; 1239 def++;
1274 if ( ('-' == *def) || 1240 if (('-' == *def) || ('=' == *def))
1275 ('=' == *def) )
1276 def++; 1241 def++;
1277 def = GNUNET_strdup (def); 1242 def = GNUNET_strdup (def);
1278 } 1243 }
@@ -1282,10 +1247,8 @@ expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg,
1282 start = &orig[1]; 1247 start = &orig[1];
1283 def = NULL; 1248 def = NULL;
1284 i = 0; 1249 i = 0;
1285 while ( (orig[i] != '/') && 1250 while ((orig[i] != '/') && (orig[i] != '\\') && (orig[i] != '\0') &&
1286 (orig[i] != '\\') && 1251 (orig[i] != ' '))
1287 (orig[i] != '\0') &&
1288 (orig[i] != ' ') )
1289 i++; 1252 i++;
1290 if (orig[i] == '\0') 1253 if (orig[i] == '\0')
1291 { 1254 {
@@ -1305,10 +1268,7 @@ expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg,
1305 post, 1268 post,
1306 def); 1269 def);
1307 if (GNUNET_OK != 1270 if (GNUNET_OK !=
1308 GNUNET_CONFIGURATION_get_value_string (cfg, 1271 GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", start, &prefix))
1309 "PATHS",
1310 start,
1311 &prefix))
1312 { 1272 {
1313 if (NULL == (env = getenv (start))) 1273 if (NULL == (env = getenv (start)))
1314 { 1274 {
@@ -1322,15 +1282,17 @@ expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg,
1322 if (erased_pos) 1282 if (erased_pos)
1323 *erased_pos = erased_char; 1283 *erased_pos = erased_char;
1324 LOG (GNUNET_ERROR_TYPE_WARNING, 1284 LOG (GNUNET_ERROR_TYPE_WARNING,
1325 _("Failed to expand `%s' in `%s' as it is neither found in [PATHS] nor defined as an environmental variable\n"), 1285 _ (
1326 start, orig); 1286 "Failed to expand `%s' in `%s' as it is neither found in [PATHS] nor defined as an environmental variable\n"),
1287 start,
1288 orig);
1327 GNUNET_free (start); 1289 GNUNET_free (start);
1328 return orig; 1290 return orig;
1329 } 1291 }
1330 prefix = GNUNET_strdup (env); 1292 prefix = GNUNET_strdup (env);
1331 } 1293 }
1332 prefix = GNUNET_CONFIGURATION_expand_dollar (cfg, prefix); 1294 prefix = GNUNET_CONFIGURATION_expand_dollar (cfg, prefix);
1333 if ( (erased_pos) && ('}' != erased_char) ) 1295 if ((erased_pos) && ('}' != erased_char))
1334 { 1296 {
1335 len = strlen (prefix) + 1; 1297 len = strlen (prefix) + 1;
1336 prefix = GNUNET_realloc (prefix, len + 1); 1298 prefix = GNUNET_realloc (prefix, len + 1);
@@ -1364,8 +1326,9 @@ expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg,
1364 * @return $-expanded string 1326 * @return $-expanded string
1365 */ 1327 */
1366char * 1328char *
1367GNUNET_CONFIGURATION_expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg, 1329GNUNET_CONFIGURATION_expand_dollar (
1368 char *orig) 1330 const struct GNUNET_CONFIGURATION_Handle *cfg,
1331 char *orig)
1369{ 1332{
1370 char *dup; 1333 char *dup;
1371 size_t i; 1334 size_t i;
@@ -1397,18 +1360,18 @@ GNUNET_CONFIGURATION_expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cf
1397 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 1360 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
1398 */ 1361 */
1399int 1362int
1400GNUNET_CONFIGURATION_get_value_filename (const struct GNUNET_CONFIGURATION_Handle *cfg, 1363GNUNET_CONFIGURATION_get_value_filename (
1401 const char *section, 1364 const struct GNUNET_CONFIGURATION_Handle *cfg,
1402 const char *option, 1365 const char *section,
1403 char **value) 1366 const char *option,
1367 char **value)
1404{ 1368{
1405 char *tmp; 1369 char *tmp;
1406 1370
1407 if (GNUNET_OK != 1371 if (GNUNET_OK !=
1408 GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &tmp)) 1372 GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &tmp))
1409 { 1373 {
1410 LOG (GNUNET_ERROR_TYPE_DEBUG, 1374 LOG (GNUNET_ERROR_TYPE_DEBUG, "Failed to retrieve filename\n");
1411 "Failed to retrieve filename\n");
1412 *value = NULL; 1375 *value = NULL;
1413 return GNUNET_SYSERR; 1376 return GNUNET_SYSERR;
1414 } 1377 }
@@ -1431,16 +1394,17 @@ GNUNET_CONFIGURATION_get_value_filename (const struct GNUNET_CONFIGURATION_Handl
1431 * @return #GNUNET_YES, #GNUNET_NO or #GNUNET_SYSERR 1394 * @return #GNUNET_YES, #GNUNET_NO or #GNUNET_SYSERR
1432 */ 1395 */
1433int 1396int
1434GNUNET_CONFIGURATION_get_value_yesno (const struct GNUNET_CONFIGURATION_Handle *cfg, 1397GNUNET_CONFIGURATION_get_value_yesno (
1435 const char *section, 1398 const struct GNUNET_CONFIGURATION_Handle *cfg,
1436 const char *option) 1399 const char *section,
1400 const char *option)
1437{ 1401{
1438 static const char *yesno[] = { "YES", "NO", NULL }; 1402 static const char *yesno[] = {"YES", "NO", NULL};
1439 const char *val; 1403 const char *val;
1440 int ret; 1404 int ret;
1441 1405
1442 ret = 1406 ret =
1443 GNUNET_CONFIGURATION_get_value_choice (cfg, section, option, yesno, &val); 1407 GNUNET_CONFIGURATION_get_value_choice (cfg, section, option, yesno, &val);
1444 if (ret == GNUNET_SYSERR) 1408 if (ret == GNUNET_SYSERR)
1445 return ret; 1409 return ret;
1446 if (val == yesno[0]) 1410 if (val == yesno[0])
@@ -1460,11 +1424,12 @@ GNUNET_CONFIGURATION_get_value_yesno (const struct GNUNET_CONFIGURATION_Handle *
1460 * @return number of filenames iterated over, -1 on error 1424 * @return number of filenames iterated over, -1 on error
1461 */ 1425 */
1462int 1426int
1463GNUNET_CONFIGURATION_iterate_value_filenames (const struct GNUNET_CONFIGURATION_Handle *cfg, 1427GNUNET_CONFIGURATION_iterate_value_filenames (
1464 const char *section, 1428 const struct GNUNET_CONFIGURATION_Handle *cfg,
1465 const char *option, 1429 const char *section,
1466 GNUNET_FileNameCallback cb, 1430 const char *option,
1467 void *cb_cls) 1431 GNUNET_FileNameCallback cb,
1432 void *cb_cls)
1468{ 1433{
1469 char *list; 1434 char *list;
1470 char *pos; 1435 char *pos;
@@ -1590,20 +1555,23 @@ test_match (void *cls, const char *fn)
1590 * #GNUNET_SYSERR on error 1555 * #GNUNET_SYSERR on error
1591 */ 1556 */
1592int 1557int
1593GNUNET_CONFIGURATION_append_value_filename (struct GNUNET_CONFIGURATION_Handle *cfg, 1558GNUNET_CONFIGURATION_append_value_filename (
1594 const char *section, 1559 struct GNUNET_CONFIGURATION_Handle *cfg,
1595 const char *option, 1560 const char *section,
1596 const char *value) 1561 const char *option,
1562 const char *value)
1597{ 1563{
1598 char *escaped; 1564 char *escaped;
1599 char *old; 1565 char *old;
1600 char *nw; 1566 char *nw;
1601 1567
1602 if (GNUNET_SYSERR == 1568 if (GNUNET_SYSERR ==
1603 GNUNET_CONFIGURATION_iterate_value_filenames (cfg, section, option, 1569 GNUNET_CONFIGURATION_iterate_value_filenames (cfg,
1570 section,
1571 option,
1604 &test_match, 1572 &test_match,
1605 (void *) value)) 1573 (void *) value))
1606 return GNUNET_NO; /* already exists */ 1574 return GNUNET_NO; /* already exists */
1607 if (GNUNET_OK != 1575 if (GNUNET_OK !=
1608 GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &old)) 1576 GNUNET_CONFIGURATION_get_value_string (cfg, section, option, &old))
1609 old = GNUNET_strdup (""); 1577 old = GNUNET_strdup ("");
@@ -1634,10 +1602,11 @@ GNUNET_CONFIGURATION_append_value_filename (struct GNUNET_CONFIGURATION_Handle *
1634 * #GNUNET_SYSERR on error 1602 * #GNUNET_SYSERR on error
1635 */ 1603 */
1636int 1604int
1637GNUNET_CONFIGURATION_remove_value_filename (struct GNUNET_CONFIGURATION_Handle 1605GNUNET_CONFIGURATION_remove_value_filename (
1638 *cfg, const char *section, 1606 struct GNUNET_CONFIGURATION_Handle *cfg,
1639 const char *option, 1607 const char *section,
1640 const char *value) 1608 const char *option,
1609 const char *value)
1641{ 1610{
1642 char *list; 1611 char *list;
1643 char *pos; 1612 char *pos;
@@ -1719,16 +1688,14 @@ static int
1719parse_configuration_file (void *cls, const char *filename) 1688parse_configuration_file (void *cls, const char *filename)
1720{ 1689{
1721 struct GNUNET_CONFIGURATION_Handle *cfg = cls; 1690 struct GNUNET_CONFIGURATION_Handle *cfg = cls;
1722 char * ext; 1691 char *ext;
1723 int ret; 1692 int ret;
1724 1693
1725 /* Examine file extension */ 1694 /* Examine file extension */
1726 ext = strrchr (filename, '.'); 1695 ext = strrchr (filename, '.');
1727 if ((NULL == ext) || (0 != strcmp (ext, ".conf"))) 1696 if ((NULL == ext) || (0 != strcmp (ext, ".conf")))
1728 { 1697 {
1729 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1698 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Skipping file `%s'\n", filename);
1730 "Skipping file `%s'\n",
1731 filename);
1732 return GNUNET_OK; 1699 return GNUNET_OK;
1733 } 1700 }
1734 1701
@@ -1747,13 +1714,11 @@ parse_configuration_file (void *cls, const char *filename)
1747 */ 1714 */
1748int 1715int
1749GNUNET_CONFIGURATION_load_from (struct GNUNET_CONFIGURATION_Handle *cfg, 1716GNUNET_CONFIGURATION_load_from (struct GNUNET_CONFIGURATION_Handle *cfg,
1750 const char *defaults_d) 1717 const char *defaults_d)
1751{ 1718{
1752 if (GNUNET_SYSERR == 1719 if (GNUNET_SYSERR ==
1753 GNUNET_DISK_directory_scan (defaults_d, 1720 GNUNET_DISK_directory_scan (defaults_d, &parse_configuration_file, cfg))
1754 &parse_configuration_file, 1721 return GNUNET_SYSERR; /* no configuration at all found */
1755 cfg))
1756 return GNUNET_SYSERR; /* no configuration at all found */
1757 return GNUNET_OK; 1722 return GNUNET_OK;
1758} 1723}
1759 1724