38{
43
48
53
58
63};
64
65
70{
75
80
85
93
98
103
108
113};
114
116{
121
126
128
130
136
141};
142
143
148{
153
158
163
168
173
178
185
190
195
202};
203
204
210{
212
214};
215
216
217void
220{
222}
223
224
227{
230
233
234
238 {
240 "PATHS",
241 "DATADIR",
244 }
248 {
250 "PATHS",
251 "LIBDIR",
254 }
258 {
260 "PATHS",
261 "BINDIR",
264 }
268 {
270 "PATHS",
271 "PREFIX",
274 }
278 {
280 "PATHS",
281 "LOCALEDIR",
284 }
288 {
290 "PATHS",
291 "ICONDIR",
294 }
298 {
300 "PATHS",
301 "DOCDIR",
304 }
308 {
310 "PATHS",
311 "LIBEXECDIR",
314 }
316}
317
318
319void
321{
324
328 {
333 cf);
335 }
338}
339
340
345 void *cb_cls)
346{
349
354 {
358 }
363}
364
365
370{
375
380};
381
382
395{
397
402}
403
404
414 const char *section)
415{
417
419 return NULL;
421 while ( (NULL != pos) &&
422 (0 != strcasecmp (section,
425 return pos;
426}
427
428
429static int
431 const void *b)
432{
433 return strcmp (*((const char **) a),
434 *((const char **) b));
435}
436
437
445 const char *path_or_glob,
446 bool path_is_glob,
447 const char *restrict_section,
448 const char *source_filename,
449 unsigned int source_lineno)
450{
451 char *inline_path = NULL;
455 .files_length = 0,
456 };
459
460
461 GNUNET_assert (! (path_is_glob && (NULL != restrict_section)));
462
463 if (NULL == source_filename)
464 {
466 "Refusing to parse inline configurations, "
467 "not allowed without source filename!\n");
470 }
471
472 if ('/' == *path_or_glob)
474 else
475 {
476
477
478
479 char *source_realpath;
480 char *endsep;
481
482 source_realpath = realpath (source_filename,
483 NULL);
484 if (NULL == source_realpath)
485 {
486
488
491 }
492 endsep = strrchr (source_realpath, '/');
494 *endsep = '\0';
496 "%s/%s",
497 source_realpath,
498 path_or_glob);
499 free (source_realpath);
500 }
501
502 if (path_is_glob)
503 {
504 int nret;
505
507 "processing config glob '%s'\n",
508 inline_path);
509
512 &igc);
513 if (-1 == nret)
514 {
517 }
521 sizeof (char *),
523 for (int i = 0; i < nret; i++)
524 {
528 {
531 }
532 }
534 }
535 else if (NULL != restrict_section)
536 {
540
542
544
545 if (NULL == cs)
546 {
552 }
554 {
555 const char *pwname;
556 const char *grname;
558 struct stat istat;
559
561 if (0 == stat (sfn, &istat))
562 {
563 struct passwd *pw = getpwuid (istat.st_uid);
564 struct group *gr = getgrgid (istat.st_gid);
565 pwname = (NULL == pw) ? "<unknown>" : pw->pw_name;
566 grname = (NULL == gr) ? "<unknown>" : gr->gr_name;
567
569 "%s:%s %o",
570 pwname,
571 grname,
572 istat.st_mode);
573 }
574 else
575 {
577 }
578 if (source_filename)
579 {
580
584 }
585 }
586
587
588 {
594 cf);
595 }
596
598 {
601
604 }
605
609 inline_path);
611 {
613 fun_ret = inner_ret;
615 }
616
618 restrict_section);
619 if (NULL == cs)
620 {
622 "Configuration file '%s' loaded with @inline-secret@ "
623 "does not contain section '%s'.\n",
624 inline_path,
625 restrict_section);
626
627
628
631 }
633 NULL != ce;
634 ce = ce->next)
636 restrict_section,
637 ce->key,
638 ce->val);
640 }
643 inline_path))
644 {
647 }
648 else
649 {
651 }
654 if (NULL != other_cfg)
658 {
662 }
663 return fun_ret;
664}
665
666
677 const char *section,
679{
681
683 section)))
684 return NULL;
686 pos != NULL;
688 if (0 == strcasecmp (
key,
689 pos->key))
690 return pos;
692 {
694 "Section '%s' is marked as inaccessible, because the configuration "
695 "file that contains the section can't be read. Attempts to use "
696 "option '%s' will fail.\n",
697 section,
699 return NULL;
700 }
701 return NULL;
702}
703
704
714static void
716 const char *section,
717 const char *option,
718 const char *hint_filename,
719 unsigned int hint_line)
720{
723 return;
724 if (! e)
725 return;
728}
729
730
733 const char *mem,
735 const char *source_filename)
736{
737 size_t line_size;
738 unsigned int nr;
739 size_t r_bytes;
740 size_t to_read;
742 char *section;
743 char *eq;
744 char *tag;
746 char *line_orig = NULL;
747
749 section = NULL;
750 nr = 0;
751 r_bytes = 0;
752 while (r_bytes <
size)
753 {
754 const char *pos;
756 bool emptyline;
757
759
760 to_read =
size - r_bytes;
761 pos = memchr (&mem[r_bytes], '\n', to_read);
762 if (NULL == pos)
763 {
765 line_size = to_read);
766 r_bytes += line_size;
767 }
768 else
769 {
771 line_size = (pos - &mem[r_bytes]));
772 r_bytes += line_size + 1;
773 }
775
776 nr++;
777
779 for (size_t i = 0; i < line_size; i++)
780 {
787 }
788
790 continue;
791
792
793 for (size_t i = line_size - 1;
794 (i >= 1) && (isspace ((
unsigned char)
line[i]));
795 i--)
797
798
799 for (;
line[0] !=
'\0' && (isspace ((
unsigned char)
line[0]));
line++)
800 ;
801
802
803 if ( (
'#' ==
line[0]) ||
805 continue;
806
807
809 {
810 char *
end = strchr (
line + 1,
'@');
811 char *directive;
813
815 {
817 "Illegal directive in line %u (parsing restricted section %s)\n",
818 nr,
821 break;
822 }
823
825 {
827 "Bad directive in line %u\n",
828 nr);
830 break;
831 }
833 directive =
line + 1;
834
835 if (0 == strcasecmp (directive,
836 "INLINE"))
837 {
838 const char *path =
end + 1;
839
840
841 for (; isspace (*path); path++)
842 ;
843
845 path,
846 false,
847 NULL,
848 source_filename,
849 nr);
850 }
851 else if (0 == strcasecmp (directive,
852 "INLINE-MATCHING"))
853 {
854 const char *path =
end + 1;
855
856
857 for (; isspace (*path); path++)
858 ;
859
861 path,
862 true,
863 NULL,
864 source_filename,
865 nr);
866 }
867 else if (0 == strcasecmp (directive,
868 "INLINE-SECRET"))
869 {
870 char *secname =
end + 1;
871 char *secname_end;
872 const char *path;
873
874
875 for (; isspace (*secname); secname++)
876 ;
877
878 secname_end = strchr (secname, ' ');
879
880 if (NULL == secname_end)
881 {
883 "Bad inline-secret directive in line %u\n",
884 nr);
886 break;
887 }
888 *secname_end = '\0';
889 path = secname_end + 1;
890
891
892 for (; isspace (*path); path++)
893 ;
894
896 path,
897 false,
898 secname,
899 source_filename,
900 nr);
901 }
902 else
903 {
905 "Unknown or malformed directive '%s' in line %u\n",
906 directive,
907 nr);
909 break;
910 }
912 {
914 break;
915 }
916 continue;
917 }
918 if ( (
'[' ==
line[0]) &&
919 (
']' ==
line[line_size - 1]) )
920 {
921
922 line[line_size - 1] =
'\0';
926 continue;
927 }
928 if (NULL != (eq = strchr (
line,
'=')))
929 {
930
931 if (NULL == section)
932 {
934 "Syntax error while deserializing in line %u (option without section)\n",
935 nr);
937 break;
938 }
939
940
942
943 for (int i = strlen (tag) - 1;
944 (i >= 1) && (isspace ((unsigned char) tag[i]));
945 i--)
946 tag[i] = '\0';
947
948
950 while (isspace ((
unsigned char)
value[0]))
952 for (
int i = strlen (
value) - 1;
953 (i >= 1) && (isspace ((
unsigned char)
value[i]));
954 i--)
956
957
958 if ( (
'"' ==
value[0]) &&
960 {
963 }
965 section,
966 tag,
969 {
971 section,
972 tag,
973 source_filename
974 ? source_filename
975 : "<input>",
976 nr);
977 }
979 continue;
980 }
981
983 "Syntax error while deserializing in line %u\n",
984 nr);
986 break;
987 }
993}
994
995
999{
1000 uint64_t fs64;
1002 char *fn;
1003 char *mem;
1004 int dirty;
1006 ssize_t sret;
1007
1010 "Asked to parse config file `%s'\n",
1011 fn);
1012 if (NULL == fn)
1014
1015
1016
1017 {
1021
1022
1023 for (; NULL != cf; parent = cf, cf = cf->
prev)
1024 {
1025
1026 if (cf->level >= lvl)
1027 continue;
1029 if ( (NULL == cf->source_filename) ||
1031 continue;
1032 if (0 == strcmp (cf->source_filename,
1034 {
1035 if (NULL == parent)
1036 {
1038 "Forbidden direct cyclic configuration import (%s -> %s)\n",
1039 cf->source_filename,
1041 }
1042 else
1044 "Forbidden indirect cyclic configuration import (%s -> ... -> %s -> %s)\n",
1045 cf->source_filename,
1050 }
1051 }
1052
1053 }
1054
1055
1056 {
1058
1063 cf);
1064 }
1065
1069 &fs64,
1072 {
1074 "Error while determining the file size of `%s'\n",
1075 fn);
1078 }
1080 {
1084 }
1088 mem,
1090 if ((sret < 0) || (
fs != (
size_t) sret))
1091 {
1093 "Error while reading file `%s'\n",
1094 fn);
1098 }
1100 "Deserializing contents of file `%s'\n",
1101 fn);
1103 mem,
1105 fn);
1107 {
1109 _ (
"Failed to parse configuration file `%s'\n"),
1110 fn);
1111 }
1114
1115
1118}
1119
1120
1123{
1125}
1126
1127
1135static bool
1138{
1139 if (0 != strcasecmp ("PATHS",
1140 sec))
1141 return false;
1142 return ( (0 == strcasecmp ("DATADIR",
1144 (0 == strcasecmp ("LIBDIR",
1146 (0 == strcasecmp ("BINDIR",
1148 (0 == strcasecmp ("PREFIX",
1150 (0 == strcasecmp ("LOCALEDIR",
1152 (0 == strcasecmp ("ICONDIR",
1154 (0 == strcasecmp ("DOCDIR",
1156 (0 == strcasecmp ("DEFAULTCONFIG",
1158 (0 == strcasecmp ("LIBEXECDIR",
1160}
1161
1162
1163char *
1166{
1167 char *mem;
1168 char *cbuf;
1169 char *val;
1170 char *pos;
1171 size_t m_size;
1172 size_t c_size;
1173
1174
1175 m_size = 0;
1177 NULL != sec;
1178 sec = sec->next)
1179 {
1180 if (sec->inaccessible && (NULL == sec->entries))
1181 continue;
1182
1183 m_size += strlen (sec->name) + 3;
1185 NULL != ent;
1186 ent = ent->next)
1187 {
1189 ent->key))
1190 continue;
1191 if (NULL != ent->val)
1192 {
1193
1194 pos = ent->val;
1195 while (NULL != (pos = strstr (pos, "\n")))
1196 {
1197 m_size++;
1198 pos++;
1199 }
1200
1201
1202 m_size += strlen (ent->key) + strlen (ent->val) + 4;
1203 }
1204 }
1205
1206 m_size++;
1207 }
1208
1209
1211 c_size = 0;
1214 NULL != sec;
1215 sec = sec->next)
1216 {
1217 int len;
1218
1220 "[%s]\n",
1221 sec->name);
1224 cbuf,
1225 len);
1226 c_size += len;
1229 NULL != ent;
1230 ent = ent->next)
1231 {
1233 ent->key))
1234 continue;
1235 if (NULL != ent->val)
1236 {
1238 strcpy (val, ent->val);
1239 while (NULL != (pos = strstr (val, "\n")))
1240 {
1241 memmove (&pos[2], &pos[1], strlen (&pos[1]));
1242 pos[0] = '\\';
1243 pos[1] = 'n';
1244 }
1248 c_size += len;
1250 }
1251 }
1253 c_size++;
1254 }
1257 return mem;
1258}
1259
1260
1269static void
1274{
1276 ipk);
1277 const char *ipkname;
1278 switch (ipk)
1279 {
1281 ipkname = "IPK_DATADIR";
1282 break;
1284 ipkname = "IPK_BINDIR";
1285 break;
1287 ipkname = "IPK_LIBDIR";
1288 break;
1290 ipkname = "IPK_PREFIX";
1292 ipkname = "IPK_LOCALEDIR";
1293 break;
1295 ipkname = "IPK_ICONDIR";
1297 ipkname = "IPK_DOCDIR";
1298 break;
1300 ipkname = "IPK_LIBEXECDIR";
1301 break;
1303 ipkname = "IPK_SELF_PREFIX";
1304 break;
1305 default:
1306 ipkname = "??";
1307 break;
1308 }
1310 "# %s = %s\n",
1311 ipkname,
1312 v);
1314}
1315
1316
1317char *
1320{
1322
1324 "#\n# Configuration file diagnostics\n#\n");
1326 "# Entry point: %s\n",
1328 "<none>");
1330 "#\n# Files Loaded:\n");
1331
1333 NULL != cfil;
1334 cfil = cfil->next)
1335 {
1337 "# ");
1338 for (unsigned int i = 0; i < cfil->level; i++)
1340 "+");
1341 if (0 != cfil->level)
1343 " ");
1344
1346 "%s",
1347 cfil->source_filename);
1348
1349 if (NULL != cfil->hint_restrict_section)
1351 " (%s secret section %s)",
1352 cfil->hint_inaccessible
1353 ? "inaccessible"
1354 : "loaded",
1355 cfil->hint_restrict_section);
1356
1358 "\n");
1359 }
1360
1362 "#\n# Installation paths:\n");
1363
1373
1374
1376 "#\n\n");
1377
1379 NULL != sec;
1380 sec = sec->next)
1381 {
1382 if (sec->hint_secret_filename)
1384 "# secret section from %s\n# secret file stat %s\n",
1385 sec->hint_secret_filename,
1386 sec->hint_secret_stat);
1387 if (sec->hint_inlined_from_filename)
1388 {
1390 "# inlined from %s:%u\n",
1391 sec->hint_inlined_from_filename,
1392 sec->hint_inlined_from_line);
1393 }
1395 "[%s]\n\n",
1396 sec->name);
1397 if (sec->inaccessible && (NULL == sec->entries))
1398 {
1400 "# <section contents inaccessible>\n\n\n");
1401 continue;
1402 }
1404 NULL != ent;
1405 ent = ent->next)
1406 {
1408 ent->key))
1409 continue;
1410 if (NULL != ent->val)
1411 {
1412 char *pos;
1414 strcpy (val, ent->val);
1415 while (NULL != (pos = strstr (val, "\n")))
1416 {
1417 memmove (&pos[2], &pos[1], strlen (&pos[1]));
1418 pos[0] = '\\';
1419 pos[1] = 'n';
1420 }
1421 if (NULL != ent->hint_filename)
1422 {
1424 "# %s:%u\n",
1425 ent->hint_filename,
1426 ent->hint_lineno);
1427 }
1429 "%s = %s\n",
1430 ent->key,
1431 val);
1433 }
1435 }
1436 if (sec->inaccessible)
1437 {
1439 "# <additional section contents inaccessible>\n\n\n");
1440 continue;
1441 }
1442
1444 }
1446}
1447
1448
1453{
1454 char *fn;
1455 char *cfg_buf;
1457
1459 if (fn == NULL)
1462 {
1465 }
1468 {
1470
1480 {
1484 }
1485 if (((ssize_t)
size) !=
1487 cfg_buf,
1489 {
1491 "write",
1492 fn);
1499 }
1502 }
1507}
1508
1509
1510void
1514 void *iter_cls)
1515{
1517 NULL != spos;
1518 spos = spos->next)
1520 NULL != epos;
1521 epos = epos->next)
1522 if (NULL != epos->val)
1523 iter (iter_cls,
1524 spos->name,
1525 epos->key,
1526 epos->val);
1527}
1528
1529
1530void
1533 const char *section,
1535 void *iter_cls)
1536{
1538
1540 while ((spos != NULL) && (0 != strcasecmp (spos->
name, section)))
1542 if (NULL == spos)
1543 return;
1545 NULL != epos;
1546 epos = epos->next)
1547 if (NULL != epos->val)
1548 iter (iter_cls,
1550 epos->key,
1551 epos->val);
1553 {
1555 "Section '%s' is marked as inaccessible, because a configuration "
1556 "file that contains the section can't be read.\n",
1557 section);
1558 return;
1559 }
1560}
1561
1562
1563void
1567 void *iter_cls)
1568{
1571
1573 while (NULL !=
next)
1574 {
1578 continue;
1579 iter (iter_cls,
1581 }
1582}
1583
1584
1585void
1587 const char *section)
1588{
1592
1593 prev = NULL;
1595 while (NULL != spos)
1596 {
1597 if (0 == strcasecmp (section,
1599 {
1600 if (NULL == prev)
1602 else
1604 while (NULL != (ent = spos->
entries))
1605 {
1612 }
1618 return;
1619 }
1620 prev = spos;
1622 }
1623}
1624
1625
1635static void
1637 const char *section,
1638 const char *option,
1640{
1642
1644 section,
1645 option,
1647}
1648
1649
1653{
1655
1661}
1662
1663
1674static void
1676 const char *section,
1677 const char *option,
1679{
1682
1684 if ((NULL != entNew) && (NULL != entNew->
val) &&
1685 (0 == strcmp (entNew->
val,
value)))
1686 return;
1688 section,
1689 option,
1691}
1692
1693
1698{
1700
1706 &diffHandle);
1707 return diffHandle.cfgDiff;
1708}
1709
1710
1716{
1719
1724}
1725
1726
1727void
1730 const char *section,
1731 const char *option,
1733{
1736 char *nv;
1737
1739 if (NULL != e)
1740 {
1742 {
1745 }
1746 else
1747 {
1751 }
1752 return;
1753 }
1755 if (sec == NULL)
1756 {
1761 }
1767}
1768
1769
1770void
1772 const char *section,
1773 const char *option,
1774 unsigned long long number)
1775{
1776 char s[64];
1777
1779 64,
1780 "%llu",
1783 section,
1784 option,
1785 s);
1786}
1787
1788
1792 const char *section,
1793 const char *option,
1794 unsigned long long *
number)
1795{
1798
1800 section,
1801 option)))
1805 if (1 != sscanf (e->
val,
1806 "%llu%1s",
1811}
1812
1813
1814void
1816 const char *section,
1817 const char *option,
1819{
1820 char s[64];
1821
1822
1823 const locale_t cl = newlocale (LC_NUMERIC_MASK,
1824 "C",
1825 (locale_t) 0);
1826 locale_t old_locale = uselocale (cl);
1828 64,
1829 "%f",
1831 uselocale (old_locale);
1833 section,
1834 option,
1835 s);
1836}
1837
1838
1842 const char *section,
1843 const char *option,
1845{
1848
1850 section,
1851 option)))
1855
1856 {
1857 const locale_t cl = newlocale (LC_NUMERIC_MASK,
1858 "C",
1859 (locale_t) 0);
1860 locale_t old_locale = uselocale (cl);
1861
1862 if (1 != sscanf (e->
val,
1863 "%f%1s",
1867 uselocale (old_locale);
1868 }
1870}
1871
1872
1876 const char *section,
1877 const char *option,
1879{
1882
1884 section,
1885 option)))
1890 time);
1893 section,
1894 option,
1895 _ (
"Not a valid relative time specification"));
1897}
1898
1899
1903 const char *section,
1904 const char *option,
1905 unsigned long long *
size)
1906{
1908
1910 section,
1911 option)))
1917}
1918
1919
1933 const char *section,
1934 const char *option,
1936{
1938
1940 section,
1941 option))) ||
1943 {
1946 }
1949}
1950
1951
1955 const char *section,
1956 const char *option,
1957 const char *const *choices,
1959{
1961 unsigned int i;
1962
1964 section,
1965 option)))
1967 for (i = 0; NULL !=
choices[i]; i++)
1968 if (0 == strcasecmp (choices[i], e->
val))
1969 break;
1970 if (NULL == choices[i])
1971 {
1973 _ (
"Configuration value '%s' for '%s'"
1974 " in section '%s' is not in set of legal choices\n"),
1976 option,
1977 section);
1979 }
1982}
1983
1984
1987 const char *section,
1988 const char *option,
1989 void *buf,
1990 size_t buf_size)
1991{
1995
1999 section,
2000 option,
2005 {
2008 }
2012 buf,
2013 buf_size))
2014 {
2017 }
2020}
2021
2022
2025 const char *section,
2026 const char *option)
2027{
2029
2031 section,
2032 option))) ||
2036}
2037
2038
2054static char *
2056 char *orig,
2057 unsigned int depth)
2058{
2062 const char *post;
2064 char *def;
2066 unsigned int lopen;
2067 char erased_char;
2068 char *erased_pos;
2069 size_t len;
2070
2071 if (NULL == orig)
2072 return NULL;
2073 if (depth > 128)
2074 {
2076 "Recursive expansion suspected, aborting $-expansion for term `%s'\n",
2077 orig);
2078 return orig;
2079 }
2081 "Asked to $-expand %s\n",
2082 orig);
2083 if ('$' != orig[0])
2084 {
2086 "Doesn't start with $ - not expanding\n");
2087 return orig;
2088 }
2089 erased_char = 0;
2090 erased_pos = NULL;
2091 if ('{' == orig[1])
2092 {
2094 lopen = 1;
2096 while (lopen > 0)
2097 {
2100 {
2101 case '}':
2102 lopen--;
2103 break;
2104
2105 case '{':
2106 lopen++;
2107 break;
2108
2109 case '\0':
2111 "Missing closing `}' in option `%s'\n",
2112 orig);
2113 return orig;
2114
2115 default:
2116 break;
2117 }
2118 }
2123 def = strchr (orig, ':');
2124 if (NULL != def)
2125 {
2126 *def = '\0';
2127 def++;
2128 if (('-' == *def) || ('=' == *def))
2129 def++;
2131 }
2132 }
2133 else
2134 {
2135 int i;
2136
2138 def = NULL;
2139 i = 0;
2140 while ( (orig[i] != '/') &&
2141 (orig[i] != '\\') &&
2142 (orig[i] != '\0') &&
2143 (orig[i] != ' ') )
2144 i++;
2145 if (orig[i] == '\0')
2146 {
2147 post = "";
2148 }
2149 else
2150 {
2151 erased_char = orig[i];
2152 erased_pos = &orig[i];
2153 orig[i] = '\0';
2154 post = &orig[i + 1];
2155 }
2156 }
2158 "Split into `%s' and `%s' with default %s\n",
2160 post,
2161 def);
2164 "PATHS",
2167 {
2169 {
2170
2172 def,
2173 depth + 1);
2175 }
2177 {
2179 if (erased_pos)
2180 *erased_pos = erased_char;
2182 "Failed to expand `%s' in `%s' as it is neither found in [PATHS] nor defined as an environmental variable\n",
2184 orig);
2186 return orig;
2187 }
2189 }
2192 if ((erased_pos) && ('}' != erased_char))
2193 {
2194 len = strlen (
prefix) + 1;
2196 prefix[len - 1] = erased_char;
2198 }
2206}
2207
2208
2209char *
2212 char *orig)
2213{
2214 char *dup;
2215 size_t i;
2216 size_t len;
2217
2218 for (i = 0; '\0' != orig[i]; i++)
2219 {
2220 if ('$' != orig[i])
2221 continue;
2225 len = strlen (dup) + 1;
2229 }
2230 return orig;
2231}
2232
2233
2237 const char *section,
2238 const char *option,
2240{
2241 char *tmp;
2243
2245 section,
2246 option,
2247 &tmp);
2249 {
2251 "Failed to retrieve filename\n");
2254 }
2256 tmp);
2262}
2263
2264
2268 const char *section,
2269 const char *option)
2270{
2271 static const char *yesno[] = {
2272 "YES",
2273 "NO",
2274 NULL
2275 };
2278
2281 section,
2282 option,
2283 yesno,
2287 if (
val == yesno[0])
2290}
2291
2292
2293int
2296 const char *section,
2297 const char *option,
2299 void *cb_cls)
2300{
2302 char *pos;
2304 char old;
2306
2309 section,
2310 option,
2312 return 0;
2316 while (1)
2317 {
2318 while (pos[0] == ' ')
2319 pos++;
2320 if (strlen (pos) == 0)
2321 break;
2323 while ((
end[0] !=
' ') && (
end[0] !=
'\0'))
2324 {
2326 {
2328 {
2329 case '\\':
2330 case ' ':
2331 memmove (
end, &
end[1], strlen (&
end[1]) + 1);
2332
2333 case '\0':
2334
2335 break;
2336
2337 default:
2338
2339 break;
2340 }
2341 }
2343 }
2346 if (strlen (pos) > 0)
2347 {
2349 if ( (NULL != cb) &&
2351 pos)))
2352 {
2354 break;
2355 }
2356 }
2357 if (old == '\0')
2358 break;
2360 }
2363}
2364
2365
2372static char *
2374{
2375 char *escaped;
2376 const char *rpos;
2377 char *wpos;
2378
2380 memset (escaped, 0, strlen (
value) * 2 + 1);
2382 wpos = escaped;
2383 while (rpos[0] != '\0')
2384 {
2385 switch (rpos[0])
2386 {
2387 case '\\':
2388 case ' ':
2389 wpos[0] = '\\';
2390 wpos[1] = rpos[0];
2391 wpos += 2;
2392 break;
2393
2394 default:
2395 wpos[0] = rpos[0];
2396 wpos++;
2397 }
2398 rpos++;
2399 }
2400 return escaped;
2401}
2402
2403
2413 const char *fn)
2414{
2415 const char *of = cls;
2416
2417 return (0 == strcmp (of, fn))
2420}
2421
2422
2426 const char *section,
2427 const char *option,
2429{
2430 char *escaped;
2431 char *old;
2432 char *nw;
2433
2436 section,
2437 option,
2446 strcpy (nw, old);
2447 if (strlen (old) > 0)
2448 strcat (nw, " ");
2449 strcat (nw, escaped);
2451 section,
2452 option,
2453 nw);
2458}
2459
2460
2464 const char *section,
2465 const char *option,
2467{
2469 char *pos;
2471 char *match;
2472 char old;
2473
2476 section,
2477 option,
2482 while (1)
2483 {
2484 while (pos[0] == ' ')
2485 pos++;
2486 if (strlen (pos) == 0)
2487 break;
2489 while ((
end[0] !=
' ') && (
end[0] !=
'\0'))
2490 {
2492 {
2494 {
2495 case '\\':
2496 case ' ':
2498 break;
2499
2500 case '\0':
2501
2502 break;
2503
2504 default:
2505
2506 break;
2507 }
2508 }
2510 }
2513 if (0 == strcmp (pos, match))
2514 {
2515 if (old != '\0')
2516 memmove (pos,
2518 strlen (&
end[1]) + 1);
2519 else
2520 {
2522 pos[-1] = '\0';
2523 else
2524 pos[0] = '\0';
2525 }
2527 section,
2528 option,
2533 }
2534 if (old == '\0')
2535 break;
2538 }
2542}
2543
2544
2548 const char *defaults_d)
2549{
2552 .files_length = 0,
2553 };
2555
2559 &files_context))
2561 qsort (files_context.
files,
2563 sizeof (char *),
2565 for (
unsigned int i = 0; i < files_context.
files_length; i++)
2566 {
2567 const char *ext;
2569
2570
2572 if ( (NULL == ext) ||
2573 (0 != strcmp (ext,
2574 ".conf")) )
2575 {
2577 "Skipping file `%s'\n",
2580 continue;
2581 }
2585 break;
2586 }
2588 {
2589 for (
size_t i = 0; i < files_context.
files_length; i++)
2593 0);
2594 }
2595 return fun_ret;
2596}
2597
2598
2599char *
2602{
2603 char *cfg_fn;
2604 const char *xdg =
getenv (
"XDG_CONFIG_HOME");
2605
2606 if (NULL != xdg)
2608 "%s%s%s",
2609 xdg,
2612 else
2614
2616 return cfg_fn;
2618
2619
2620
2621
2623 "/etc/%s",
2627 return cfg_fn;
2629
2631 "/etc/%s/%s",
2636 return cfg_fn;
2637
2639 return NULL;
2640}
2641
2642
2647{
2648 char *baseconfig;
2649 const char *base_config_varname;
2650
2652 {
2653
2656 }
2659 {
2662 }
2663
2665
2666 if ((NULL != base_config_varname)
2667 && (NULL != (baseconfig =
getenv (base_config_varname))))
2668 {
2670 }
2671 else
2672 {
2673 char *ipath;
2674
2677 if (NULL == ipath)
2678 {
2681 }
2683 "%s%s",
2684 ipath,
2685 "config.d");
2687 }
2688
2689 {
2691
2693
2699 dname)))
2700 {
2702 "Failed to load base configuration from '%s'\n",
2706 }
2708 }
2713 {
2714
2716 "Failed to load configuration from file '%s'\n",
2719 }
2722 "PATHS",
2723 "DEFAULTCONFIG"))) &&
2726 "PATHS",
2727 "DEFAULTCONFIG",
2730}
2731
2732
2741static void
2743 const char *section,
2744 const char *option,
2746{
2748
2749 char *value_fn;
2750 char *fn;
2751
2754 section,
2755 option,
2756 &value_fn));
2758 if (NULL == fn)
2759 fn = value_fn;
2760 else
2762 fprintf (stdout,
2763 "%s = %s\n",
2764 option,
2765 fn);
2767}
2768
2769
2778static void
2780 const char *section,
2781 const char *option,
2783{
2784 (void) cls;
2785 (void) section;
2786
2787 fprintf (stdout,
2788 "%s = %s\n",
2789 option,
2791}
2792
2793
2800static void
2802 const char *section)
2803{
2804 (void) cls;
2805 fprintf (stdout,
2806 "%s\n",
2807 section);
2808}
2809
2810
2811void
2813 void *cls,
2814 char *const *args,
2815 const char *cfgfile,
2817{
2821
2822 (void) args;
2824 {
2825
2830 cfgfile))
2831 {
2832 fprintf (stderr,
2833 _ (
"Failed to load config file `%s'"),
2834 cfgfile);
2835 return;
2836 }
2838 }
2839
2843 {
2844 fprintf (stderr,
2845 _ (
"The following sections are available:\n"));
2848 NULL);
2849 return;
2850 }
2853 {
2854 char *serialization;
2855
2857 {
2858 fprintf (stderr,
2859 _ (
"%s, %s or %s argument is required\n"),
2860 "--section",
2861 "--list-sections",
2862 "--diagnostics");
2864 return;
2865 }
2867 fprintf (stdout,
2868 "%s",
2869 serialization);
2871 }
2872 else if ( (NULL != cs->
section) &&
2873 (NULL == cs->
value) )
2874 {
2876 {
2884 }
2885 else
2886 {
2888
2890 {
2896 {
2901 return;
2902 }
2903 }
2904 else
2905 {
2911 {
2916 return;
2917 }
2918 }
2919 fprintf (stdout,
2920 "%s\n",
2923 }
2924 }
2926 {
2928 {
2929 fprintf (stderr,
2930 _ (
"--option argument required to set value\n"));
2932 return;
2933 }
2940 }
2942 {
2943 char *cfg_fn = NULL;
2944
2945 if (NULL == out)
2947
2948 if (NULL == cfgfile)
2949 {
2950 const char *xdg =
getenv (
"XDG_CONFIG_HOME");
2951
2952 if (NULL != xdg)
2954 "%s%s%s",
2955 xdg,
2958 else
2960 cfgfile = cfg_fn;
2961 }
2962
2964 {
2966
2970 NULL))
2971 {
2972 fprintf (stderr,
2973 _ (
"failed to load configuration defaults"));
2978 return;
2979 }
2982 out,
2983 cfgfile))
2986 }
2987 else
2988 {
2991 cfgfile))
2993 }
2995 }
2996 if (NULL != out)
2998 if (NULL != ncfg)
3000}
3001
3002
3003void
3006{
3010}
3011
3012
3016{
3018}
3019
3020
3021
struct GNUNET_MQ_Envelope * env
static bool do_skip(const char *sec, const char *key)
Should we skip this configuration entry when serializing?
static void print_filename_option(void *cls, const char *section, const char *option, const char *value)
Print each option in a given section as a filename.
static struct ConfigEntry * find_entry(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *key)
Find an entry from a configuration.
static enum GNUNET_GenericReturnValue handle_inline(struct GNUNET_CONFIGURATION_Handle *cfg, const char *path_or_glob, bool path_is_glob, const char *restrict_section, const char *source_filename, unsigned int source_lineno)
Handle an inline directive.
static void print_section_name(void *cls, const char *section)
Print out given section name.
static char * escape_name(const char *value)
FIXME.
static void compare_entries(void *cls, const char *section, const char *option, const char *value)
A callback function, compares entries from two configurations (default against a new configuration) a...
static enum GNUNET_GenericReturnValue test_match(void *cls, const char *fn)
FIXME.
static struct ConfigSection * find_section(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section)
Find a section entry from a configuration.
static int pstrcmp(const void *a, const void *b)
static char * expand_dollar(const struct GNUNET_CONFIGURATION_Handle *cfg, char *orig, unsigned int depth)
Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR" where either in the "PATHS" section or...
static enum GNUNET_GenericReturnValue collect_files_cb(void *cls, const char *filename)
Function called with a filename.
static void copy_entry(void *cls, const char *section, const char *option, const char *value)
Copy a configuration value to the given target configuration.
static void print_option(void *cls, const char *section, const char *option, const char *value)
Print each option in a given section.
static void dump_os_ipk(const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_Buffer *buf, enum GNUNET_OS_InstallationPathKind ipk)
Dump an os installation path to a buffer.
static void set_entry_hint(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *hint_filename, unsigned int hint_line)
Set a configuration hint.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
static int start
Set if we are to start default services (including ARM).
static int list
Set if we should print a list of currently running services.
static int ret
Final status code.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static int end
Set if we are to shutdown all services (including ARM).
static int prefix
If printing the value of PREFIX has been requested.
static char * line
Desired phone line (string to be converted to a hash).
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_FS_Handle * fs
Handle to FS service.
static OpusEncoder * enc
OPUS encoder.
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
static char * res
Currently read line or NULL on EOF.
static char * value
Value of the record to add/remove.
static size_t data_size
Number of bytes in data.
static int result
Global testing status.
static void cleanup()
Cleanup task.
static struct GNUNET_Process * p
Helper process we started.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_data(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, void *buf, size_t buf_size)
Get Crockford32-encoded fixed-size binary data from a configuration.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(const struct GNUNET_OS_ProjectData *pd)
Create a new configuration object.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_is_dirty(const struct GNUNET_CONFIGURATION_Handle *cfg)
Test if there are configuration options that were changed since the last save.
void GNUNET_CONFIGURATION_set_value_string(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value)
Set a configuration value that should be a string.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_append_value_filename(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value)
Append a filename to a configuration value that represents a list of filenames.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
void GNUNET_CONFIGURATION_remove_section(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section)
Remove the given section and all options in it.
enum GNUNET_GenericReturnValue(* GNUNET_CONFIGURATION_Callback)(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
Signature of a function to be run with a configuration.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing configuration object.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
void GNUNET_CONFIGURATION_iterate_sections(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_SectionIterator iter, void *iter_cls)
Iterate over all sections in the configuration.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
void GNUNET_CONFIGURATION_config_settings_free(struct GNUNET_CONFIGURATION_ConfigSettings *cs)
Free resources associated with cs.
void GNUNET_CONFIGURATION_iterate(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_Iterator iter, void *iter_cls)
Iterate over all options in the configuration.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_remove_value_filename(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value)
Remove a filename from a configuration value that represents a list of filenames.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_parse_and_run(const struct GNUNET_OS_ProjectData *pd, const char *filename, GNUNET_CONFIGURATION_Callback cb, void *cb_cls)
Parse a configuration file filename and run the function cb with the resulting configuration object.
void GNUNET_CONFIGURATION_config_tool_run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main task to run to perform operations typical for gnunet-config as per the configuration settings gi...
void(* GNUNET_CONFIGURATION_SectionIterator)(void *cls, const char *section)
Function to iterate over all configuration sections.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_deserialize(struct GNUNET_CONFIGURATION_Handle *cfg, const char *mem, size_t size, const char *source_filename)
De-serializes configuration.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_size(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *size)
Get a configuration value that should be a size in bytes.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
char * GNUNET_CONFIGURATION_serialize(const struct GNUNET_CONFIGURATION_Handle *cfg, size_t *size)
Serializes the given configuration.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
void GNUNET_CONFIGURATION_set_value_number(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long number)
Set a configuration value that should be a number.
char * GNUNET_CONFIGURATION_default_filename(const struct GNUNET_OS_ProjectData *pd)
Return the filename of the default configuration filename that is used when no explicit configuration...
char * GNUNET_CONFIGURATION_expand_dollar(const struct GNUNET_CONFIGURATION_Handle *cfg, char *orig)
Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR" where either in the "PATHS" section or...
void GNUNET_CONFIGURATION_set_value_float(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, float number)
Set a configuration value that should be a float.
const struct GNUNET_OS_ProjectData * GNUNET_CONFIGURATION_get_project_data(const struct GNUNET_CONFIGURATION_Handle *cfg)
Return the project data associated with this configuration.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_get_diff(const struct GNUNET_CONFIGURATION_Handle *cfg_default, const struct GNUNET_CONFIGURATION_Handle *cfg_new)
Compute configuration with only entries that have been changed.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_parse(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Parse a configuration file, add all of the options in the file to the configuration environment.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_float(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, float *number)
Get a configuration value that should be a floating point number.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_load_from(struct GNUNET_CONFIGURATION_Handle *cfg, const char *defaults_d)
Load default configuration.
int GNUNET_CONFIGURATION_iterate_value_filenames(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, GNUNET_FileNameCallback cb, void *cb_cls)
Iterate over the set of filenames stored in a configuration value.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_have_value(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Test if we have a value for a particular option.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_choice(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *const *choices, const char **value)
Get a configuration value that should be in a set of predefined strings.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_write(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Write configuration file.
void(* GNUNET_CONFIGURATION_Iterator)(void *cls, const char *section, const char *option, const char *value)
Function to iterate over options.
void GNUNET_CONFIGURATION_iterate_section_values(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, GNUNET_CONFIGURATION_Iterator iter, void *iter_cls)
Iterate over values of a section in the configuration.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_write_diffs(const struct GNUNET_CONFIGURATION_Handle *cfg_default, const struct GNUNET_CONFIGURATION_Handle *cfg_new, const char *filename)
Write only configuration entries that have been changed to configuration file.
char * GNUNET_CONFIGURATION_serialize_diagnostics(const struct GNUNET_CONFIGURATION_Handle *cfg)
Serializes the given configuration with diagnostics information.
void GNUNET_CONFIGURATION_enable_diagnostics(struct GNUNET_CONFIGURATION_Handle *cfg)
Enable extra diagnostics.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
int GNUNET_DISK_glob(const char *glob_pattern, GNUNET_FileNameCallback callback, void *callback_cls)
Find all files matching a glob pattern.
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_test_read(const char *fil)
Check that fil corresponds to a filename and the file has read permissions.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_size(const char *filename, uint64_t *size, int include_symbolic_links, int single_file_mode)
Get the size of the file (or directory) of the given file (in bytes).
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_remove(const char *filename)
Remove all files in a directory (rm -rf).
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_test(const char *fil, int is_readable)
Test if fil is a directory and listable.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create_for_file(const char *filename)
Create the directory structure for storing a file.
ssize_t GNUNET_DISK_fn_read(const char *fn, void *result, size_t len)
Read the contents of a binary file into a buffer.
int GNUNET_DISK_directory_scan(const char *dir_name, GNUNET_FileNameCallback callback, void *callback_cls)
Scan a directory for files.
@ GNUNET_DISK_OPEN_WRITE
Open the file for writing.
@ GNUNET_DISK_OPEN_TRUNCATE
Truncate file if it exists.
@ GNUNET_DISK_OPEN_CREATE
Create file if it doesn't exist.
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
@ GNUNET_DISK_PERM_GROUP_READ
Group can read.
@ GNUNET_DISK_PERM_GROUP_WRITE
Group can write.
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
enum GNUNET_GenericReturnValue(* GNUNET_FileNameCallback)(void *cls, const char *filename)
Function called with a filename.
#define GNUNET_log(kind,...)
char * GNUNET_buffer_reap_str(struct GNUNET_Buffer *buf)
Clear the buffer and return the string it contained.
void GNUNET_buffer_write_fstr(struct GNUNET_Buffer *buf, const char *fmt,...) __attribute__((format(printf
Write a 0-terminated formatted string to a buffer, excluding the 0-terminator.
void GNUNET_buffer_write_str(struct GNUNET_Buffer *buf, const char *str)
Write a 0-terminated string to a buffer, excluding the 0-terminator.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_GenericReturnValue
Named constants for return values.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
void GNUNET_log_config_invalid(enum GNUNET_ErrorType kind, const char *section, const char *option, const char *required)
Log error message about invalid configuration option value.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
#define GNUNET_strndup(a, length)
Wrapper around GNUNET_xstrndup_.
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_realloc(ptr, size)
Wrapper around realloc.
#define GNUNET_array_append(arr, len, element)
Append an element to an array (growing the array by one).
#define GNUNET_free(ptr)
Wrapper around free.
char * GNUNET_OS_installation_get_path(const struct GNUNET_OS_ProjectData *pd, enum GNUNET_OS_InstallationPathKind dirkind)
Get the path to a specific GNUnet installation directory or, with GNUNET_OS_IPK_SELF_PREFIX,...
GNUNET_OS_InstallationPathKind
Possible installation paths to request.
@ GNUNET_OS_IPK_SELF_PREFIX
Return the installation directory of this application, not the one of the overall GNUnet installation...
@ GNUNET_OS_IPK_ICONDIR
Return the prefix of the path with application icons (share/icons/).
@ GNUNET_OS_IPK_DATADIR
Return the directory where data is installed (share/gnunet/)
@ GNUNET_OS_IPK_DOCDIR
Return the prefix of the path with documentation files, including the license (share/doc/gnunet/).
@ GNUNET_OS_IPK_LOCALEDIR
Return the directory where translations are installed (share/locale/)
@ GNUNET_OS_IPK_LIBDIR
Return the directory where libraries are installed.
@ GNUNET_OS_IPK_PREFIX
Return the "PREFIX" directory given to configure.
@ GNUNET_OS_IPK_BINDIR
Return the directory where the program binaries are installed.
@ GNUNET_OS_IPK_LIBEXECDIR
Return the directory where helper binaries are installed (lib/gnunet/libexec/)
char * GNUNET_STRINGS_filename_expand(const char *fil)
Complete filename (a la shell) from abbrevition.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_fancy_time_to_relative(const char *fancy_time, struct GNUNET_TIME_Relative *rtime)
Convert a given fancy human-readable time to our internal representation.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_fancy_size_to_bytes(const char *fancy_size, unsigned long long *size)
Convert a given fancy human-readable size to bytes.
static unsigned int size
Size of the "table".
Closure to collect_files_cb.
char ** files
Collected files from globbing.
unsigned int files_length
Size of the files array.
char * hint_filename
Diagnostics information for the filename.
struct ConfigEntry * next
This is a linked list.
char * key
key for this entry
unsigned int hint_lineno
Diagnostics information for the line number.
char * val
current, committed value
char * hint_restrict_section
Was this configuration file parsed via @inline-secret@?
char * source_filename
Source filename.
bool hint_inaccessible
Was this configuration file inaccessible?
unsigned int level
Level in the tree of loaded config files.
char * name
name of the section
char * hint_inlined_from_filename
For secret sections: Where was this inlined from?
struct ConfigEntry * entries
entries in the section
bool inaccessible
Is the configuration section marked as inaccessible?
struct ConfigSection * next
This is a linked list.
char * hint_secret_filename
Diagnostics hint for the secret file.
unsigned int hint_inlined_from_line
For secret sections: Where was this inlined from?
char * hint_secret_stat
Extra information regarding permissions of the secret file.
Used for diffing a configuration object against the default one.
const struct GNUNET_CONFIGURATION_Handle * cfg_default
struct GNUNET_CONFIGURATION_Handle * cfgDiff
Dynamically growing buffer.
Closure for GNUNET_CONFIGURATION_config_tool_run() with settings for what should be done with the con...
char * value
Value to set.
int full
Should the generated configuration file contain the whole configuration?
int global_ret
Return value from the operation, to be returned from 'main'.
int diagnostics
Should we give extra diagnostics?
int list_sections
Whether to show the sections.
int rewrite
Should we write out the configuration file, even if no value was changed?
char * option
Name of the option.
char * section
Name of the section.
int is_filename
Treat option as a filename.
struct ConfigFile * loaded_files_tail
Linked list of loaded files.
bool load_called
Was the configuration ever loaded via GNUNET_CONFIGURATION_load?
unsigned int current_nest_level
Current nesting level of file loading.
const struct GNUNET_OS_ProjectData * pd
Project data for this configuration object.
struct ConfigSection * sections
Configuration sections.
struct ConfigFile * loaded_files_head
Linked list of loaded files.
char * main_filename
Name of the entry point configuration file.
enum GNUNET_GenericReturnValue dirty
Modification indication since last save GNUNET_NO if clean, GNUNET_YES if dirty, GNUNET_SYSERR on err...
bool diagnostics
Enable diagnostics.
const char * restrict_section
When parsing into this configuration, and this value is non-NULL, only parse sections of the same nam...
Handle used to access files (and pipes).
Project-specific data used to help the OS subsystem find installation paths.
const char * base_config_varname
Name of an environment variable that can be used to override the location from which default configur...
const char * project_dirname
Name of the project that is used in the "libexec" prefix, For example, "gnunet".
const char * user_config_file
Configuration file name to use (if $XDG_CONFIG_HOME is not set).
const char * config_file
Configuration file name (in $XDG_CONFIG_HOME) to use.
Time for relative time used by GNUnet, in microseconds.