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{
682
684 return NULL;
686 {
688 "Section '%s' is marked as inaccessible, because the configuration "
689 "file that contains the section can't be read. Attempts to use "
690 "option '%s' will fail.\n",
691 section,
693 return NULL;
694 }
696 while ((pos != NULL) && (0 != strcasecmp (
key, pos->
key)))
698 return pos;
699}
700
701
711static void
713 const char *section,
714 const char *option,
716 unsigned int hint_line)
717{
720 return;
721 if (! e)
722 return;
725}
726
727
730 const char *mem,
732 const char *source_filename)
733{
734 size_t line_size;
735 unsigned int nr;
736 size_t r_bytes;
737 size_t to_read;
739 char *section;
740 char *eq;
741 char *tag;
743 char *line_orig = NULL;
744
746 section = NULL;
747 nr = 0;
748 r_bytes = 0;
749 while (r_bytes <
size)
750 {
751 char *pos;
753 bool emptyline;
754
756
757 to_read =
size - r_bytes;
758 pos = memchr (&mem[r_bytes], '\n', to_read);
759 if (NULL == pos)
760 {
762 line_size = to_read);
763 r_bytes += line_size;
764 }
765 else
766 {
768 line_size = (pos - &mem[r_bytes]));
769 r_bytes += line_size + 1;
770 }
772
773 nr++;
774
776 for (size_t i = 0; i < line_size; i++)
777 {
784 }
785
787 continue;
788
789
790 for (size_t i = line_size - 1;
791 (i >= 1) && (isspace ((
unsigned char)
line[i]));
792 i--)
794
795
796 for (;
line[0] !=
'\0' && (isspace ((
unsigned char)
line[0]));
line++)
797 ;
798
799
800 if ( (
'#' ==
line[0]) ||
802 continue;
803
804
806 {
807 char *
end = strchr (
line + 1,
'@');
808 char *directive;
810
812 {
814 "Illegal directive in line %u (parsing restricted section %s)\n",
815 nr,
818 break;
819 }
820
822 {
824 "Bad directive in line %u\n",
825 nr);
827 break;
828 }
830 directive =
line + 1;
831
832 if (0 == strcasecmp (directive,
833 "INLINE"))
834 {
835 const char *path =
end + 1;
836
837
838 for (; isspace (*path); path++)
839 ;
840
842 path,
843 false,
844 NULL,
845 source_filename,
846 nr);
847 }
848 else if (0 == strcasecmp (directive,
849 "INLINE-MATCHING"))
850 {
851 const char *path =
end + 1;
852
853
854 for (; isspace (*path); path++)
855 ;
856
858 path,
859 true,
860 NULL,
861 source_filename,
862 nr);
863 }
864 else if (0 == strcasecmp (directive,
865 "INLINE-SECRET"))
866 {
867 char *secname =
end + 1;
868 char *secname_end;
869 const char *path;
870
871
872 for (; isspace (*secname); secname++)
873 ;
874
875 secname_end = strchr (secname, ' ');
876
877 if (NULL == secname_end)
878 {
880 "Bad inline-secret directive in line %u\n",
881 nr);
883 break;
884 }
885 *secname_end = '\0';
886 path = secname_end + 1;
887
888
889 for (; isspace (*path); path++)
890 ;
891
893 path,
894 false,
895 secname,
896 source_filename,
897 nr);
898 }
899 else
900 {
902 "Unknown or malformed directive '%s' in line %u\n",
903 directive,
904 nr);
906 break;
907 }
909 {
911 break;
912 }
913 continue;
914 }
915 if ( (
'[' ==
line[0]) &&
916 (
']' ==
line[line_size - 1]) )
917 {
918
919 line[line_size - 1] =
'\0';
923 continue;
924 }
925 if (NULL != (eq = strchr (
line,
'=')))
926 {
927
928 if (NULL == section)
929 {
931 "Syntax error while deserializing in line %u (option without section)\n",
932 nr);
934 break;
935 }
936
937
939
940 for (int i = strlen (tag) - 1;
941 (i >= 1) && (isspace ((unsigned char) tag[i]));
942 i--)
943 tag[i] = '\0';
944
945
947 while (isspace ((
unsigned char)
value[0]))
949 for (
int i = strlen (
value) - 1;
950 (i >= 1) && (isspace ((
unsigned char)
value[i]));
951 i--)
953
954
955 if ( (
'"' ==
value[0]) &&
957 {
960 }
962 section,
963 tag,
966 {
968 section,
969 tag,
970 source_filename
971 ? source_filename
972 : "<input>",
973 nr);
974 }
976 continue;
977 }
978
980 "Syntax error while deserializing in line %u\n",
981 nr);
983 break;
984 }
990}
991
992
996{
997 uint64_t fs64;
999 char *fn;
1000 char *mem;
1001 int dirty;
1003 ssize_t sret;
1004
1007 "Asked to parse config file `%s'\n",
1008 fn);
1009 if (NULL == fn)
1011
1012
1013
1014 {
1018
1019
1020 for (; NULL != cf; parent = cf, cf = cf->
prev)
1021 {
1022
1023 if (cf->level >= lvl)
1024 continue;
1026 if ( (NULL == cf->source_filename) ||
1028 continue;
1029 if (0 == strcmp (cf->source_filename,
1031 {
1032 if (NULL == parent)
1033 {
1035 "Forbidden direct cyclic configuration import (%s -> %s)\n",
1036 cf->source_filename,
1038 }
1039 else
1041 "Forbidden indirect cyclic configuration import (%s -> ... -> %s -> %s)\n",
1042 cf->source_filename,
1047 }
1048 }
1049
1050 }
1051
1052
1053 {
1055
1060 cf);
1061 }
1062
1066 &fs64,
1069 {
1071 "Error while determining the file size of `%s'\n",
1072 fn);
1075 }
1077 {
1081 }
1085 mem,
1087 if ((sret < 0) || (
fs != (
size_t) sret))
1088 {
1090 "Error while reading file `%s'\n",
1091 fn);
1095 }
1097 "Deserializing contents of file `%s'\n",
1098 fn);
1100 mem,
1102 fn);
1104 {
1106 _ (
"Failed to parse configuration file `%s'\n"),
1107 fn);
1108 }
1111
1112
1115}
1116
1117
1120{
1122}
1123
1124
1132static bool
1135{
1136 if (0 != strcasecmp ("PATHS",
1137 sec))
1138 return false;
1139 return ( (0 == strcasecmp ("DATADIR",
1141 (0 == strcasecmp ("LIBDIR",
1143 (0 == strcasecmp ("BINDIR",
1145 (0 == strcasecmp ("PREFIX",
1147 (0 == strcasecmp ("LOCALEDIR",
1149 (0 == strcasecmp ("ICONDIR",
1151 (0 == strcasecmp ("DOCDIR",
1153 (0 == strcasecmp ("DEFAULTCONFIG",
1155 (0 == strcasecmp ("LIBEXECDIR",
1157}
1158
1159
1160char *
1163{
1164 char *mem;
1165 char *cbuf;
1166 char *val;
1167 char *pos;
1168 size_t m_size;
1169 size_t c_size;
1170
1171
1172 m_size = 0;
1174 NULL != sec;
1175 sec = sec->next)
1176 {
1177 if (sec->inaccessible)
1178 continue;
1179
1180 m_size += strlen (sec->name) + 3;
1182 NULL != ent;
1183 ent = ent->next)
1184 {
1186 ent->key))
1187 continue;
1188 if (NULL != ent->val)
1189 {
1190
1191 pos = ent->val;
1192 while (NULL != (pos = strstr (pos, "\n")))
1193 {
1194 m_size++;
1195 pos++;
1196 }
1197
1198
1199 m_size += strlen (ent->key) + strlen (ent->val) + 4;
1200 }
1201 }
1202
1203 m_size++;
1204 }
1205
1206
1208 c_size = 0;
1211 NULL != sec;
1212 sec = sec->next)
1213 {
1214 int len;
1215
1217 "[%s]\n",
1218 sec->name);
1221 cbuf,
1222 len);
1223 c_size += len;
1226 NULL != ent;
1227 ent = ent->next)
1228 {
1230 ent->key))
1231 continue;
1232 if (NULL != ent->val)
1233 {
1235 strcpy (val, ent->val);
1236 while (NULL != (pos = strstr (val, "\n")))
1237 {
1238 memmove (&pos[2], &pos[1], strlen (&pos[1]));
1239 pos[0] = '\\';
1240 pos[1] = 'n';
1241 }
1245 c_size += len;
1247 }
1248 }
1250 c_size++;
1251 }
1254 return mem;
1255}
1256
1257
1266static void
1271{
1273 ipk);
1274 const char *ipkname;
1275 switch (ipk)
1276 {
1278 ipkname = "IPK_DATADIR";
1279 break;
1281 ipkname = "IPK_BINDIR";
1282 break;
1284 ipkname = "IPK_LIBDIR";
1285 break;
1287 ipkname = "IPK_PREFIX";
1289 ipkname = "IPK_LOCALEDIR";
1290 break;
1292 ipkname = "IPK_ICONDIR";
1294 ipkname = "IPK_DOCDIR";
1295 break;
1297 ipkname = "IPK_LIBEXECDIR";
1298 break;
1300 ipkname = "IPK_SELF_PREFIX";
1301 break;
1302 default:
1303 ipkname = "??";
1304 break;
1305 }
1307 "# %s = %s\n",
1308 ipkname,
1309 v);
1311}
1312
1313
1314char *
1317{
1319
1321 "#\n# Configuration file diagnostics\n#\n");
1323 "# Entry point: %s\n",
1325 "<none>");
1327 "#\n# Files Loaded:\n");
1328
1330 NULL != cfil;
1331 cfil = cfil->next)
1332 {
1334 "# ");
1335 for (unsigned int i = 0; i < cfil->level; i++)
1337 "+");
1338 if (0 != cfil->level)
1340 " ");
1341
1343 "%s",
1344 cfil->source_filename);
1345
1346 if (NULL != cfil->hint_restrict_section)
1348 " (%s secret section %s)",
1349 cfil->hint_inaccessible
1350 ? "inaccessible"
1351 : "loaded",
1352 cfil->hint_restrict_section);
1353
1355 "\n");
1356 }
1357
1359 "#\n# Installation paths:\n");
1360
1370
1371
1373 "#\n\n");
1374
1376 NULL != sec;
1377 sec = sec->next)
1378 {
1379 if (sec->hint_secret_filename)
1381 "# secret section from %s\n# secret file stat %s\n",
1382 sec->hint_secret_filename,
1383 sec->hint_secret_stat);
1384 if (sec->hint_inlined_from_filename)
1385 {
1387 "# inlined from %s:%u\n",
1388 sec->hint_inlined_from_filename,
1389 sec->hint_inlined_from_line);
1390 }
1392 "[%s]\n\n",
1393 sec->name);
1394 if (sec->inaccessible)
1395 {
1397 "# <section contents inaccessible>\n\n\n");
1398 continue;
1399 }
1401 NULL != ent;
1402 ent = ent->next)
1403 {
1405 ent->key))
1406 continue;
1407 if (NULL != ent->val)
1408 {
1409 char *pos;
1411 strcpy (val, ent->val);
1412 while (NULL != (pos = strstr (val, "\n")))
1413 {
1414 memmove (&pos[2], &pos[1], strlen (&pos[1]));
1415 pos[0] = '\\';
1416 pos[1] = 'n';
1417 }
1418 if (NULL != ent->hint_filename)
1419 {
1421 "# %s:%u\n",
1422 ent->hint_filename,
1423 ent->hint_lineno);
1424 }
1426 "%s = %s\n",
1427 ent->key,
1428 val);
1430 }
1432 }
1434 }
1436}
1437
1438
1443{
1444 char *fn;
1445 char *cfg_buf;
1447
1449 if (fn == NULL)
1452 {
1455 }
1458 {
1460
1470 {
1474 }
1475 if (((ssize_t)
size) !=
1477 cfg_buf,
1479 {
1481 "write",
1482 fn);
1489 }
1492 }
1497}
1498
1499
1500void
1504 void *iter_cls)
1505{
1507 NULL != spos;
1508 spos = spos->next)
1510 NULL != epos;
1511 epos = epos->next)
1512 if (NULL != epos->val)
1513 iter (iter_cls,
1514 spos->name,
1515 epos->key,
1516 epos->val);
1517}
1518
1519
1520void
1523 const char *section,
1525 void *iter_cls)
1526{
1528
1530 while ((spos != NULL) && (0 != strcasecmp (spos->
name, section)))
1532 if (NULL == spos)
1533 return;
1535 {
1537 "Section '%s' is marked as inaccessible, because the configuration "
1538 "file that contains the section can't be read.\n",
1539 section);
1540 return;
1541 }
1543 NULL != epos;
1544 epos = epos->next)
1545 if (NULL != epos->val)
1546 iter (iter_cls,
1548 epos->key,
1549 epos->val);
1550}
1551
1552
1553void
1557 void *iter_cls)
1558{
1561
1563 while (
next != NULL)
1564 {
1568 iter (iter_cls,
1570 }
1571}
1572
1573
1574void
1576 const char *section)
1577{
1581
1582 prev = NULL;
1584 while (NULL != spos)
1585 {
1586 if (0 == strcasecmp (section,
1588 {
1589 if (NULL == prev)
1591 else
1593 while (NULL != (ent = spos->
entries))
1594 {
1601 }
1607 return;
1608 }
1609 prev = spos;
1611 }
1612}
1613
1614
1624static void
1626 const char *section,
1627 const char *option,
1629{
1631
1633 section,
1634 option,
1636}
1637
1638
1642{
1644
1650}
1651
1652
1663static void
1665 const char *section,
1666 const char *option,
1668{
1671
1673 if ((NULL != entNew) && (NULL != entNew->
val) &&
1674 (0 == strcmp (entNew->
val,
value)))
1675 return;
1677 section,
1678 option,
1680}
1681
1682
1687{
1689
1695 &diffHandle);
1696 return diffHandle.cfgDiff;
1697}
1698
1699
1705{
1708
1713}
1714
1715
1716void
1719 const char *section,
1720 const char *option,
1722{
1725 char *nv;
1726
1728 if (NULL != e)
1729 {
1731 {
1734 }
1735 else
1736 {
1740 }
1741 return;
1742 }
1744 if (sec == NULL)
1745 {
1750 }
1756}
1757
1758
1759void
1761 const char *section,
1762 const char *option,
1763 unsigned long long number)
1764{
1765 char s[64];
1766
1768 64,
1769 "%llu",
1772 section,
1773 option,
1774 s);
1775}
1776
1777
1781 const char *section,
1782 const char *option,
1783 unsigned long long *
number)
1784{
1787
1789 section,
1790 option)))
1794 if (1 != sscanf (e->
val,
1795 "%llu%1s",
1800}
1801
1802
1803void
1805 const char *section,
1806 const char *option,
1808{
1809 char s[64];
1810
1811
1812 const locale_t cl = newlocale (LC_NUMERIC_MASK,
1813 "C",
1814 (locale_t) 0);
1815 locale_t old_locale = uselocale (cl);
1817 64,
1818 "%f",
1820 uselocale (old_locale);
1822 section,
1823 option,
1824 s);
1825}
1826
1827
1831 const char *section,
1832 const char *option,
1834{
1837
1839 section,
1840 option)))
1844
1845 {
1846 const locale_t cl = newlocale (LC_NUMERIC_MASK,
1847 "C",
1848 (locale_t) 0);
1849 locale_t old_locale = uselocale (cl);
1850
1851 if (1 != sscanf (e->
val,
1852 "%f%1s",
1856 uselocale (old_locale);
1857 }
1859}
1860
1861
1865 const char *section,
1866 const char *option,
1868{
1871
1873 section,
1874 option)))
1879 time);
1882 section,
1883 option,
1884 _ (
"Not a valid relative time specification"));
1886}
1887
1888
1892 const char *section,
1893 const char *option,
1894 unsigned long long *
size)
1895{
1897
1899 section,
1900 option)))
1906}
1907
1908
1922 const char *section,
1923 const char *option,
1925{
1927
1929 section,
1930 option))) ||
1932 {
1935 }
1938}
1939
1940
1944 const char *section,
1945 const char *option,
1946 const char *const *choices,
1948{
1950 unsigned int i;
1951
1953 section,
1954 option)))
1956 for (i = 0; NULL !=
choices[i]; i++)
1957 if (0 == strcasecmp (choices[i], e->
val))
1958 break;
1959 if (NULL == choices[i])
1960 {
1962 _ (
"Configuration value '%s' for '%s'"
1963 " in section '%s' is not in set of legal choices\n"),
1965 option,
1966 section);
1968 }
1971}
1972
1973
1976 const char *section,
1977 const char *option,
1978 void *buf,
1979 size_t buf_size)
1980{
1984
1988 section,
1989 option,
1994 {
1997 }
2001 buf,
2002 buf_size))
2003 {
2006 }
2009}
2010
2011
2014 const char *section,
2015 const char *option)
2016{
2018
2020 section,
2021 option))) ||
2025}
2026
2027
2043static char *
2045 char *orig,
2046 unsigned int depth)
2047{
2051 const char *post;
2053 char *def;
2055 unsigned int lopen;
2056 char erased_char;
2057 char *erased_pos;
2058 size_t len;
2059
2060 if (NULL == orig)
2061 return NULL;
2062 if (depth > 128)
2063 {
2065 "Recursive expansion suspected, aborting $-expansion for term `%s'\n",
2066 orig);
2067 return orig;
2068 }
2070 "Asked to $-expand %s\n",
2071 orig);
2072 if ('$' != orig[0])
2073 {
2075 "Doesn't start with $ - not expanding\n");
2076 return orig;
2077 }
2078 erased_char = 0;
2079 erased_pos = NULL;
2080 if ('{' == orig[1])
2081 {
2083 lopen = 1;
2085 while (lopen > 0)
2086 {
2089 {
2090 case '}':
2091 lopen--;
2092 break;
2093
2094 case '{':
2095 lopen++;
2096 break;
2097
2098 case '\0':
2100 "Missing closing `}' in option `%s'\n",
2101 orig);
2102 return orig;
2103
2104 default:
2105 break;
2106 }
2107 }
2112 def = strchr (orig, ':');
2113 if (NULL != def)
2114 {
2115 *def = '\0';
2116 def++;
2117 if (('-' == *def) || ('=' == *def))
2118 def++;
2120 }
2121 }
2122 else
2123 {
2124 int i;
2125
2127 def = NULL;
2128 i = 0;
2129 while ( (orig[i] != '/') &&
2130 (orig[i] != '\\') &&
2131 (orig[i] != '\0') &&
2132 (orig[i] != ' ') )
2133 i++;
2134 if (orig[i] == '\0')
2135 {
2136 post = "";
2137 }
2138 else
2139 {
2140 erased_char = orig[i];
2141 erased_pos = &orig[i];
2142 orig[i] = '\0';
2143 post = &orig[i + 1];
2144 }
2145 }
2147 "Split into `%s' and `%s' with default %s\n",
2149 post,
2150 def);
2153 "PATHS",
2156 {
2158 {
2159
2161 def,
2162 depth + 1);
2164 }
2166 {
2168 if (erased_pos)
2169 *erased_pos = erased_char;
2171 "Failed to expand `%s' in `%s' as it is neither found in [PATHS] nor defined as an environmental variable\n",
2173 orig);
2175 return orig;
2176 }
2178 }
2181 if ((erased_pos) && ('}' != erased_char))
2182 {
2183 len = strlen (
prefix) + 1;
2185 prefix[len - 1] = erased_char;
2187 }
2195}
2196
2197
2198char *
2201 char *orig)
2202{
2203 char *dup;
2204 size_t i;
2205 size_t len;
2206
2207 for (i = 0; '\0' != orig[i]; i++)
2208 {
2209 if ('$' != orig[i])
2210 continue;
2214 len = strlen (dup) + 1;
2218 }
2219 return orig;
2220}
2221
2222
2226 const char *section,
2227 const char *option,
2229{
2230 char *tmp;
2232
2234 section,
2235 option,
2236 &tmp);
2238 {
2240 "Failed to retrieve filename\n");
2243 }
2245 tmp);
2251}
2252
2253
2257 const char *section,
2258 const char *option)
2259{
2260 static const char *yesno[] = {
2261 "YES",
2262 "NO",
2263 NULL
2264 };
2267
2270 section,
2271 option,
2272 yesno,
2276 if (
val == yesno[0])
2279}
2280
2281
2282int
2285 const char *section,
2286 const char *option,
2288 void *cb_cls)
2289{
2291 char *pos;
2293 char old;
2295
2298 section,
2299 option,
2301 return 0;
2305 while (1)
2306 {
2307 while (pos[0] == ' ')
2308 pos++;
2309 if (strlen (pos) == 0)
2310 break;
2312 while ((
end[0] !=
' ') && (
end[0] !=
'\0'))
2313 {
2315 {
2317 {
2318 case '\\':
2319 case ' ':
2320 memmove (
end, &
end[1], strlen (&
end[1]) + 1);
2321
2322 case '\0':
2323
2324 break;
2325
2326 default:
2327
2328 break;
2329 }
2330 }
2332 }
2335 if (strlen (pos) > 0)
2336 {
2338 if ( (NULL != cb) &&
2340 pos)))
2341 {
2343 break;
2344 }
2345 }
2346 if (old == '\0')
2347 break;
2349 }
2352}
2353
2354
2361static char *
2363{
2364 char *escaped;
2365 const char *rpos;
2366 char *wpos;
2367
2369 memset (escaped, 0, strlen (
value) * 2 + 1);
2371 wpos = escaped;
2372 while (rpos[0] != '\0')
2373 {
2374 switch (rpos[0])
2375 {
2376 case '\\':
2377 case ' ':
2378 wpos[0] = '\\';
2379 wpos[1] = rpos[0];
2380 wpos += 2;
2381 break;
2382
2383 default:
2384 wpos[0] = rpos[0];
2385 wpos++;
2386 }
2387 rpos++;
2388 }
2389 return escaped;
2390}
2391
2392
2402 const char *fn)
2403{
2404 const char *of = cls;
2405
2406 return (0 == strcmp (of, fn))
2409}
2410
2411
2415 const char *section,
2416 const char *option,
2418{
2419 char *escaped;
2420 char *old;
2421 char *nw;
2422
2425 section,
2426 option,
2435 strcpy (nw, old);
2436 if (strlen (old) > 0)
2437 strcat (nw, " ");
2438 strcat (nw, escaped);
2440 section,
2441 option,
2442 nw);
2447}
2448
2449
2453 const char *section,
2454 const char *option,
2456{
2458 char *pos;
2460 char *match;
2461 char old;
2462
2465 section,
2466 option,
2471 while (1)
2472 {
2473 while (pos[0] == ' ')
2474 pos++;
2475 if (strlen (pos) == 0)
2476 break;
2478 while ((
end[0] !=
' ') && (
end[0] !=
'\0'))
2479 {
2481 {
2483 {
2484 case '\\':
2485 case ' ':
2487 break;
2488
2489 case '\0':
2490
2491 break;
2492
2493 default:
2494
2495 break;
2496 }
2497 }
2499 }
2502 if (0 == strcmp (pos, match))
2503 {
2504 if (old != '\0')
2505 memmove (pos,
2507 strlen (&
end[1]) + 1);
2508 else
2509 {
2511 pos[-1] = '\0';
2512 else
2513 pos[0] = '\0';
2514 }
2516 section,
2517 option,
2522 }
2523 if (old == '\0')
2524 break;
2527 }
2531}
2532
2533
2537 const char *defaults_d)
2538{
2541 .files_length = 0,
2542 };
2544
2548 &files_context))
2550 qsort (files_context.
files,
2552 sizeof (char *),
2554 for (
unsigned int i = 0; i < files_context.
files_length; i++)
2555 {
2556 char *ext;
2558
2559
2561 if ( (NULL == ext) ||
2562 (0 != strcmp (ext,
2563 ".conf")) )
2564 {
2566 "Skipping file `%s'\n",
2569 continue;
2570 }
2574 break;
2575 }
2577 {
2578 for (
size_t i = 0; i < files_context.
files_length; i++)
2582 0);
2583 }
2584 return fun_ret;
2585}
2586
2587
2588char *
2591{
2592 char *cfg_fn;
2593 const char *xdg =
getenv (
"XDG_CONFIG_HOME");
2594
2595 if (NULL != xdg)
2597 "%s%s%s",
2598 xdg,
2601 else
2603
2605 return cfg_fn;
2607
2608
2609
2610
2612 "/etc/%s",
2616 return cfg_fn;
2618
2620 "/etc/%s/%s",
2625 return cfg_fn;
2626
2628 return NULL;
2629}
2630
2631
2636{
2637 char *baseconfig;
2638 const char *base_config_varname;
2639
2641 {
2642
2645 }
2648 {
2651 }
2652
2654
2655 if ((NULL != base_config_varname)
2656 && (NULL != (baseconfig =
getenv (base_config_varname))))
2657 {
2659 }
2660 else
2661 {
2662 char *ipath;
2663
2666 if (NULL == ipath)
2667 {
2670 }
2672 "%s%s",
2673 ipath,
2674 "config.d");
2676 }
2677
2678 {
2680
2682
2688 dname)))
2689 {
2691 "Failed to load base configuration from '%s'\n",
2695 }
2697 }
2702 {
2703
2705 "Failed to load configuration from file '%s'\n",
2708 }
2711 "PATHS",
2712 "DEFAULTCONFIG"))) &&
2715 "PATHS",
2716 "DEFAULTCONFIG",
2719}
2720
2721
2730static void
2732 const char *section,
2733 const char *option,
2735{
2737
2738 char *value_fn;
2739 char *fn;
2740
2743 section,
2744 option,
2745 &value_fn));
2747 if (NULL == fn)
2748 fn = value_fn;
2749 else
2751 fprintf (stdout,
2752 "%s = %s\n",
2753 option,
2754 fn);
2756}
2757
2758
2767static void
2769 const char *section,
2770 const char *option,
2772{
2773 (void) cls;
2774 (void) section;
2775
2776 fprintf (stdout,
2777 "%s = %s\n",
2778 option,
2780}
2781
2782
2789static void
2791 const char *section)
2792{
2793 (void) cls;
2794 fprintf (stdout,
2795 "%s\n",
2796 section);
2797}
2798
2799
2800void
2802 void *cls,
2803 char *const *args,
2804 const char *cfgfile,
2806{
2810
2811 (void) args;
2813 {
2814
2819 cfgfile))
2820 {
2821 fprintf (stderr,
2822 _ (
"Failed to load config file `%s'"),
2823 cfgfile);
2824 return;
2825 }
2827 }
2828
2832 {
2833 fprintf (stderr,
2834 _ (
"The following sections are available:\n"));
2837 NULL);
2838 return;
2839 }
2842 {
2843 char *serialization;
2844
2846 {
2847 fprintf (stderr,
2848 _ (
"%s, %s or %s argument is required\n"),
2849 "--section",
2850 "--list-sections",
2851 "--diagnostics");
2853 return;
2854 }
2856 fprintf (stdout,
2857 "%s",
2858 serialization);
2860 }
2861 else if ( (NULL != cs->
section) &&
2862 (NULL == cs->
value) )
2863 {
2865 {
2873 }
2874 else
2875 {
2877
2879 {
2885 {
2890 return;
2891 }
2892 }
2893 else
2894 {
2900 {
2905 return;
2906 }
2907 }
2908 fprintf (stdout,
2909 "%s\n",
2912 }
2913 }
2915 {
2917 {
2918 fprintf (stderr,
2919 _ (
"--option argument required to set value\n"));
2921 return;
2922 }
2929 }
2931 {
2932 char *cfg_fn = NULL;
2933
2934 if (NULL == out)
2936
2937 if (NULL == cfgfile)
2938 {
2939 const char *xdg =
getenv (
"XDG_CONFIG_HOME");
2940
2941 if (NULL != xdg)
2943 "%s%s%s",
2944 xdg,
2947 else
2949 cfgfile = cfg_fn;
2950 }
2951
2953 {
2955
2959 NULL))
2960 {
2961 fprintf (stderr,
2962 _ (
"failed to load configuration defaults"));
2967 return;
2968 }
2971 out,
2972 cfgfile))
2975 }
2976 else
2977 {
2980 cfgfile))
2982 }
2984 }
2985 if (NULL != out)
2987 if (NULL != ncfg)
2989}
2990
2991
2992void
2995{
2999}
3000
3001
3005{
3007}
3008
3009
3010
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_OS_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 section.
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.