38 #define LOG(kind, ...) GNUNET_log_from (kind, "util-strings", __VA_ARGS__) 40 #define LOG_STRERROR(kind, syscall) \ 41 GNUNET_log_from_strerror (kind, "util-strings", syscall) 68 unsigned int count, ...)
77 const char *s = va_arg (ap,
const char *);
78 size_t slen = strlen (s) + 1;
102 unsigned int num_pids)
106 size_t plen = num_pids * 5 + 1;
111 for (
unsigned int i = 0; i < num_pids; i++)
117 (i == num_pids - 1) ?
"" :
"-");
148 va_start (ap, count);
151 r = va_arg (ap,
const char **);
154 while ((needed < size) && (buffer[needed] !=
'\0'))
179 const char *unit =
"b";
227 memcpy (dst, src, slen);
264 unsigned long long *output)
266 unsigned long long ret;
269 unsigned long long last;
276 for (tok = strtok_r (in,
" ", &sptr);
278 tok = strtok_r (NULL,
" ", &sptr))
283 while ((table[i].
name != NULL) && (0 != strcasecmp (table[i].
name, tok)))
285 if (table[i].name != NULL)
287 last *= table[i].
value;
295 last = strtoull (tok, &endptr, 10);
296 if ((0 != errno) || (endptr == tok))
301 if (
'\0' == endptr[0])
325 unsigned long long *
size)
331 {
"MiB", 1024 * 1024 },
332 {
"MB", 1000 * 1000 },
333 {
"GiB", 1024 * 1024 * 1024 },
334 {
"GB", 1000 * 1000 * 1000 },
335 {
"TiB", 1024LL * 1024LL * 1024LL * 1024LL },
336 {
"TB", 1000LL * 1000LL * 1000LL * 1024LL },
337 {
"PiB", 1024LL * 1024LL * 1024LL * 1024LL * 1024LL },
338 {
"PB", 1000LL * 1000LL * 1000LL * 1024LL * 1000LL },
339 {
"EiB", 1024LL * 1024LL * 1024LL * 1024LL * 1024LL * 1024LL },
340 {
"EB", 1000LL * 1000LL * 1000LL * 1024LL * 1000LL * 1000LL },
362 {
"s", 1000 * 1000LL },
363 {
"second", 1000 * 1000LL },
364 {
"seconds", 1000 * 1000LL },
365 {
"\"", 1000 * 1000LL },
366 {
"m", 60 * 1000 * 1000LL },
367 {
"min", 60 * 1000 * 1000LL },
368 {
"minute", 60 * 1000 * 1000LL },
369 {
"minutes", 60 * 1000 * 1000LL },
370 {
"'", 60 * 1000 * 1000LL },
371 {
"h", 60 * 60 * 1000 * 1000LL },
372 {
"hour", 60 * 60 * 1000 * 1000LL },
373 {
"hours", 60 * 60 * 1000 * 1000LL },
374 {
"d", 24 * 60 * 60 * 1000LL * 1000LL },
375 {
"day", 24 * 60 * 60 * 1000LL * 1000LL },
376 {
"days", 24 * 60 * 60 * 1000LL * 1000LL },
377 {
"week", 7 * 24 * 60 * 60 * 1000LL * 1000LL },
378 {
"weeks", 7 * 24 * 60 * 60 * 1000LL * 1000LL },
379 {
"year", 31536000000000LL },
380 {
"years", 31536000000000LL },
381 {
"a", 31536000000000LL },
384 unsigned long long val;
386 if (0 == strcasecmp (
"forever", fancy_time))
414 if (0 == strcasecmp (
"end of time", fancy_time))
419 eos = &fancy_time[strlen (fancy_time)];
420 memset (&tv, 0,
sizeof(tv));
421 if ((eos != strptime (fancy_time,
"%a %b %d %H:%M:%S %Y", &tv)) &&
422 (eos != strptime (fancy_time,
"%c", &tv)) &&
423 (eos != strptime (fancy_time,
"%Ec", &tv)) &&
424 (eos != strptime (fancy_time,
"%Y-%m-%d %H:%M:%S", &tv)) &&
425 (eos != strptime (fancy_time,
"%Y-%m-%d %H:%M", &tv)) &&
426 (eos != strptime (fancy_time,
"%x", &tv)) &&
427 (eos != strptime (fancy_time,
"%Ex", &tv)) &&
428 (eos != strptime (fancy_time,
"%Y-%m-%d", &tv)) &&
429 (eos != strptime (fancy_time,
"%Y-%m", &tv)) &&
430 (eos != strptime (fancy_time,
"%Y", &tv)))
433 atime->
abs_value_us = (uint64_t) ((uint64_t) t * 1000LL * 1000LL);
454 const char *input_charset,
455 const char *output_charset)
459 char *encoded_string;
460 size_t u8_string_length;
461 size_t encoded_string_length;
463 u8_string = u8_conv_from_encoding (input_charset,
470 if (NULL == u8_string)
475 if (0 == strcmp (output_charset,
"UTF-8"))
479 ret[u8_string_length] =
'\0';
483 encoded_string = u8_conv_to_encoding (output_charset,
489 &encoded_string_length);
491 if (NULL == encoded_string)
498 ret[encoded_string_length] =
'\0';
499 free (encoded_string);
503 _ (
"Character sets requested were `%s'->`%s'\n"),
573 tmp_in = u8_tolower ((uint8_t *) input,
574 strlen ((
char *) input),
598 tmp_in = u8_toupper ((uint8_t *) input,
599 strlen ((
char *) input),
637 _ (
"Failed to expand `$HOME': environment variable `HOME' not set"));
657 if (getcwd (buffer, len) != NULL)
662 if ((errno == ERANGE) && (len < 1024 * 1024 * 4))
706 const char *unit =
"µs";
713 if (((
GNUNET_YES == do_round) && (dval > 5 * 1000)) || (0 == (dval % 1000)))
717 if (((
GNUNET_YES == do_round) && (dval > 5 * 1000)) || (0 == (dval % 1000)))
721 if (((
GNUNET_YES == do_round) && (dval > 5 * 60)) || (0 == (dval % 60)))
725 if (((
GNUNET_YES == do_round) && (dval > 5 * 60)) || (0 == (dval % 60)))
729 if (((
GNUNET_YES == do_round) && (dval > 5 * 24)) ||
743 (
unsigned long long) dval, unit);
765 return "end of time";
767 tp = localtime (&tt);
773 strftime (buf,
sizeof(buf),
"%a %b %d %H:%M:%S %Y", tp);
837 if ((a >=
'0') && (a <=
'9'))
839 if ((a >=
'a') && (a <=
'z'))
843 if ((a >=
'A') && (a <=
'Z'))
853 return(a -
'A' + 10 - dec);
880 static char *encTable__ =
"0123456789ABCDEFGHJKMNPQRSTVWXYZ";
885 const unsigned char *udata;
889 if (out_size < (size * 8 + 4) / 5)
898 while ((rpos < size) || (vbit > 0))
900 if ((rpos < size) && (vbit < 5))
902 bits = (bits << 8) | udata[rpos++];
911 if (wpos >= out_size)
916 out[wpos++] = encTable__[(bits >> (vbit - 5)) & 31];
940 size_t len = size * 8;
993 encoded_len = out_size * 8;
997 if ((encoded_len % 5) > 0)
999 vbit = encoded_len % 5;
1001 bits = (ret =
getValue__ (enc[--rpos])) >> shift;
1009 if ((encoded_len + shift) / 5 != enclen)
1020 bits = ((ret =
getValue__ (enc[--rpos])) << vbit) | bits;
1026 uout[--wpos] = (
unsigned char) bits;
1031 if ((0 != rpos) || (0 != vbit))
1056 const char **path_part)
1062 const char *post_scheme_part = NULL;
1064 len = strlen (path);
1065 for (end = 0, i = 0; ! end && i <
len; i++)
1070 if ((path[i] ==
':') && (i > 0))
1075 if (! (((path[i] >=
'A') && (path[i] <=
'Z') ) ||
1076 ((path[i] >=
'a') && (path[i] <=
'z') ) ||
1077 ((path[i] >=
'0') && (path[i] <=
'9') ) || (path[i] ==
'+') ||
1078 (path[i] ==
'-') || (path[i] ==
'.')))
1093 post_scheme_part = &path[i];
1101 if (post_scheme_part == NULL)
1106 GNUNET_memcpy (*scheme_part, path, post_scheme_part - path);
1107 (*scheme_part)[post_scheme_part - path] =
'\0';
1110 *path_part = post_scheme_part;
1133 char **r_uri_scheme)
1135 const char *post_scheme_path;
1141 if (filename[0] ==
'/')
1151 *r_uri_scheme =
uri;
1185 if ((NULL == filename) || (filename[0] ==
'\0'))
1194 if (0 != lstat (filename, &st))
1203 if (! S_ISDIR (st.st_mode))
1227 struct sockaddr_in6 *r_buf)
1229 char zbuf[addrlen + 1];
1241 _ (
"IPv6 address did not start with `['\n"));
1244 zbuf[addrlen] =
'\0';
1245 port_colon = strrchr (zbuf,
':');
1246 if (NULL == port_colon)
1249 _ (
"IPv6 address did contain ':' to separate port number\n"));
1252 if (
']' != *(port_colon - 1))
1256 _ (
"IPv6 address did contain ']' before ':' to separate port number\n"));
1259 ret = sscanf (port_colon,
":%u%1s", &port, dummy);
1260 if ((1 != ret) || (port > 65535))
1264 _ (
"IPv6 address did contain a valid port number after the last ':'\n"));
1267 *(port_colon - 1) =
'\0';
1268 memset (r_buf, 0,
sizeof(
struct sockaddr_in6));
1269 ret = inet_pton (AF_INET6, &zbuf[1], &r_buf->sin6_addr);
1273 _ (
"Invalid IPv6 address `%s': %s\n"),
1278 r_buf->sin6_port = htons (port);
1279 r_buf->sin6_family = AF_INET6;
1280 #if HAVE_SOCKADDR_IN_SIN_LEN 1281 r_buf->sin6_len = (u_char)
sizeof(
struct sockaddr_in6);
1301 struct sockaddr_in *r_buf)
1303 unsigned int temps[4];
1310 cnt = sscanf (zt_addr,
1311 "%u.%u.%u.%u:%u%1s",
1320 for (cnt = 0; cnt < 4; cnt++)
1321 if (temps[cnt] > 0xFF)
1325 r_buf->sin_family = AF_INET;
1326 r_buf->sin_port = htons (port);
1327 r_buf->sin_addr.s_addr =
1328 htonl ((temps[0] << 24) + (temps[1] << 16) + (temps[2] << 8) + temps[3]);
1329 #if HAVE_SOCKADDR_IN_SIN_LEN 1330 r_buf->sin_len = (u_char)
sizeof(
struct sockaddr_in);
1350 struct sockaddr_storage *r_buf)
1355 (
struct sockaddr_in6 *) r_buf);
1358 (
struct sockaddr_in *) r_buf);
1374 struct sockaddr **sa)
1386 (
struct sockaddr_in6 *) *sa))
1395 return sizeof(
struct sockaddr_in6);
1404 (
struct sockaddr_in *) *sa))
1413 return sizeof(
struct sockaddr_in);
1422 static char *
const *
1425 size_t argvsize = 0;
1429 for (
int i = 0; i < argc; i++)
1430 argvsize += strlen (argv[i]) + 1 +
sizeof(
char *);
1432 p = (
char *) &new_argv[argc + 1];
1433 for (
int i = 0; i < argc; i++)
1436 strcpy (p, argv[i]);
1437 p += strlen (argv[i]) + 1;
1439 new_argv[argc] = NULL;
1440 return (
char *
const *) new_argv;
1462 char *
const **u8argv)
1464 char *
const *new_argv =
1496 if (2 == sscanf (pos,
"%u-%u%1s", &s, &e, eol))
1498 if ((0 == s) || (s > 0xFFFF) || (e < s) || (e > 0xFFFF))
1507 if (1 == sscanf (pos,
"%u%1s", &s, eol))
1509 if ((0 == s) || (s > 0xFFFF))
1520 _ (
"Malformed port policy `%s'\n"),
1547 unsigned int temps[8];
1555 if (NULL == routeListX)
1557 len = strlen (routeListX);
1562 for (i = 0; i <
len; i++)
1563 if (routeList[i] ==
';')
1571 for (colon = pos;
':' != routeList[colon]; colon++)
1572 if ((
';' == routeList[colon]) || (
'\0' == routeList[colon]))
1574 for (end = colon;
';' != routeList[
end]; end++)
1575 if (
'\0' == routeList[end])
1577 if (
'\0' == routeList[end])
1579 routeList[
end] =
'\0';
1580 if (
':' == routeList[colon])
1582 routeList[colon] =
'\0';
1586 cnt = sscanf (&routeList[pos],
1587 "%u.%u.%u.%u/%u.%u.%u.%u%1s",
1599 for (j = 0; j < 8; j++)
1600 if (temps[j] > 0xFF)
1603 _ (
"Invalid format for IP: `%s'\n"),
1609 result[i].
network.s_addr = htonl ((temps[0] << 24) + (temps[1] << 16)
1610 + (temps[2] << 8) + temps[3]);
1611 result[i].
netmask.s_addr = htonl ((temps[4] << 24) + (temps[5] << 16)
1612 + (temps[6] << 8) + temps[7]);
1618 cnt = sscanf (&routeList[pos],
1619 "%u.%u.%u.%u/%u%1s",
1628 for (j = 0; j < 4; j++)
1629 if (temps[j] > 0xFF)
1632 _ (
"Invalid format for IP: `%s'\n"),
1638 result[i].
network.s_addr = htonl ((temps[0] << 24) + (temps[1] << 16)
1639 + (temps[2] << 8) + temps[3]);
1640 if ((slash <= 32) && (slash >= 0))
1646 (result[i].
netmask.s_addr >> 1) + 0x80000000;
1657 _ (
"Invalid network notation ('/%d' is not legal in IPv4 CIDR)."),
1666 cnt = sscanf (&routeList[pos],
1675 for (j = 0; j < 4; j++)
1676 if (temps[j] > 0xFF)
1679 _ (
"Invalid format for IP: `%s'\n"),
1685 result[i].
network.s_addr = htonl ((temps[0] << 24) + (temps[1] << 16)
1686 + (temps[2] << 8) + temps[3]);
1690 result[i].
netmask.s_addr = (result[i].
netmask.s_addr >> 1) + 0x80000000;
1699 _ (
"Invalid format for IP: `%s'\n"),
1705 if (pos < strlen (routeList))
1708 _ (
"Invalid format: `%s'\n"),
1748 if (NULL == routeListX)
1750 len = strlen (routeListX);
1755 for (i = 0; i <
len; i++)
1756 if (
';' == routeList[i])
1758 if (
';' != routeList[len - 1])
1761 _ (
"Invalid network notation (does not end with ';': `%s')\n"),
1774 while (
';' != routeList[pos])
1777 while ((slash >= start) && (routeList[slash] !=
'/'))
1782 memset (&result[i].
netmask, 0xFF,
sizeof(
struct in6_addr));
1787 routeList[pos] =
'\0';
1788 for (colon = pos;
':' != routeList[colon]; colon--)
1789 if (
'/' == routeList[colon])
1791 if (
':' == routeList[colon])
1793 routeList[colon] =
'\0';
1802 ret = inet_pton (AF_INET6, &routeList[slash + 1], &result[i].
netmask);
1806 if ((1 != sscanf (&routeList[slash + 1],
"%u%1s", &bits, dummy)) ||
1811 _ (
"Wrong format `%s' for netmask\n"),
1812 &routeList[slash + 1]);
1825 result[i].
netmask.s6_addr[off++] = 0xFF;
1830 result[i].
netmask.s6_addr[off] =
1831 (result[i].
netmask.s6_addr[off] >> 1) + 0x80;
1836 routeList[slash] =
'\0';
1837 ret = inet_pton (AF_INET6, &routeList[start], &result[i].
network);
1842 _ (
"Wrong format `%s' for network\n"),
1843 &routeList[slash + 1]);
1860 #define FILLCHAR '=' 1861 static char *
cvt =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" 1862 "abcdefghijklmnopqrstuvwxyz" 1878 const char *
data = in;
1885 for (
size_t i = 0; i <
len; ++i)
1889 c = (data[i] >> 2) & 0x3f;
1890 opt[ret++] =
cvt[(int) c];
1891 c = (data[i] << 4) & 0x3f;
1893 c |= (data[i] >> 4) & 0x0f;
1894 opt[ret++] =
cvt[(int) c];
1897 c = (data[i] << 2) & 0x3f;
1899 c |= (data[i] >> 6) & 0x03;
1900 opt[ret++] =
cvt[(int) c];
1910 opt[ret++] =
cvt[(int) c];
1941 while (
'\0' != enc[pos])
1943 if (
'+' == enc[pos])
1945 if (
'/' == enc[pos])
1947 if (
'=' == enc[pos])
1954 return strlen (enc);
1958 #define cvtfind(a) \ 1959 ((((a) >= 'A') && ((a) <= 'Z')) \ 1961 : (((a) >= 'a') && ((a) <= 'z')) \ 1963 : (((a) >= '0') && ((a) <= '9')) \ 1965 : ((a) == '+') ? 62 : ((a) == '/') ? 63 : -1) 1983 #define CHECK_CRLF \ 1984 while (data[i] == '\r' || data[i] == '\n') \ 1986 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, \ 1987 "ignoring CR/LF\n"); \ 1996 "base64_decode decoding len=%d\n",
1998 for (
size_t i = 0; i <
len; ++i)
2009 c1 = (char)
cvtfind (data[i]);
2010 c = (c << 2) | ((c1 >> 4) & 0x3);
2019 c1 = ((c1 << 4) & 0xf0) | ((c >> 2) & 0xf);
2030 c = ((c << 6) & 0xc0) | c1;
2059 memcpy (s, data, len);
2061 for (
int i = 0; i < strlen (s); i++)
2105 const char *rpos =
data;
2110 while (
'\0' != *rpos)
2116 if (1 != sscanf (rpos + 1,
"%2x", &num))
2118 *wpos = (char) ((
unsigned char) num);
2150 const uint8_t *i8 = (uint8_t *) data;
2154 if (0 == (0x80 & *i8))
2157 if (isalnum (*i8) || (*i8 ==
'-') || (*i8 ==
'_') || (*i8 ==
'.') ||
2160 else if (*i8 ==
' ')
2170 if (0x80 + 0x40 == ((0x80 + 0x40 + 0x20) & *i8))
2185 if (0x80 + 0x40 + 0x20 == ((0x80 + 0x40 + 0x20 + 0x10) & *i8))
2188 for (
unsigned int i = 0; i<3; i++)
2198 if (0x80 + 0x40 + 0x20 + 0x10 == ((0x80 + 0x40 + 0x20 + 0x10 + 0x08) & *i8))
2201 for (
unsigned int i = 0; i<4; i++)
2211 if (0x80 + 0x40 + 0x20 + 0x10 + 0x08 == ((0x80 + 0x40 + 0x20 + 0x10 + 0x08
2215 for (
unsigned int i = 0; i<5; i++)
2225 if (0x80 + 0x40 + 0x20 + 0x10 + 0x08 + 0x04 == ((0x80 + 0x40 + 0x20 + 0x10
2226 + 0x08 + 0x04 + 0x02)
2230 for (
unsigned int i = 0; i<6; i++)
2246 return strlen (*out);
static void do_round(void *cls)
Send out PUSHes and PULLs, possibly update #view, samplers.
unsigned long long value
Factor to apply for this unit.
struct GNUNET_STRINGS_IPv4NetworkPolicy * GNUNET_STRINGS_parse_ipv4_policy(const char *routeListX)
Parse an IPv4 network policy.
size_t GNUNET_STRINGS_urldecode(const char *data, size_t len, char **out)
url/percent encode (RFC3986).
#define FILLCHAR
******************** Base64 encoding
uint64_t rel_value_us
The actual value.
static struct GNUNET_TIME_Relative delta
static int parse_port_policy(const char *port_policy, struct GNUNET_STRINGS_PortPolicy *pp)
Parse the given port policy.
char * GNUNET_STRINGS_conv(const char *input, size_t len, const char *input_charset, const char *output_charset)
Convert the len characters long character sequence given in input that is in the given input charset ...
static int end
Set if we are to shutdown all services (including ARM).
int GNUNET_STRINGS_parse_uri(const char *path, char **scheme_part, const char **path_part)
Parse a path that might be an URI.
struct GNUNET_STRINGS_PortPolicy pp
Policy for port access.
static struct GNUNET_SCHEDULER_Task * tt
Task scheduled to handle timeout.
char * GNUNET_STRINGS_byte_size_fancy(unsigned long long size)
Convert a given filesize into a fancy human-readable format.
uint16_t start_port
Starting port range (0 if none given).
static int convert_with_table(const char *input, const struct ConversionTable *table, unsigned long long *output)
Convert a string of the form "4 X 5 Y" into a numeric value by interpreting "X" and "Y" as units and ...
struct GNUNET_STRINGS_IPv6NetworkPolicy * GNUNET_STRINGS_parse_ipv6_policy(const char *routeListX)
Parse an IPv6 network policy.
static int start
Set if we are to start default services (including ARM).
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
int GNUNET_STRINGS_path_is_absolute(const char *filename, int can_be_uri, int *r_is_uri, char **r_uri_scheme)
Check whether filename is absolute or not, and if it's an URI.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
char * GNUNET_buffer_reap_str(struct GNUNET_Buffer *buf)
Clear the buffer and return the string it contained.
int 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.
Check that the path is an absolute path.
network in CIDR notation for IPV6.
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.
int negate_portrange
GNUNET_YES if the port range should be negated ("!" in policy).
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
void GNUNET_buffer_write(struct GNUNET_Buffer *buf, const char *data, size_t len)
Write bytes to the buffer.
static int ret
Return value of the commandline.
int GNUNET_STRINGS_fancy_time_to_absolute(const char *fancy_time, struct GNUNET_TIME_Absolute *atime)
Convert a given fancy human-readable time to our internal representation.
static struct Experiment * e
struct in_addr netmask
IPv4 netmask.
We're done processing.
int GNUNET_STRINGS_fancy_size_to_bytes(const char *fancy_size, unsigned long long *size)
Convert a given fancy human-readable size to bytes.
static char *const * _make_continuous_arg_copy(int argc, char *const *argv)
Makes a copy of argv that consists of a single memory chunk that can be freed with a single call to G...
static struct GNUNET_SCHEDULER_Task * t
Main task.
static void save()
Write persistent statistics to disk.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct in6_addr netmask
IPv6 netmask.
uint64_t abs_value_us
The actual value.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
size_t GNUNET_STRINGS_base64url_encode(const void *in, size_t len, char **output)
Encode into Base64url.
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
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.
struct in_addr network
IPv4 address.
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
int GNUNET_STRINGS_to_address_ipv4(const char *zt_addr, uint16_t addrlen, struct sockaddr_in *r_buf)
Tries to convert 'zt_addr' string to an IPv4 address.
unsigned int GNUNET_STRINGS_buffer_tokenize(const char *buffer, size_t size, unsigned int count,...)
Given a buffer of a given size, find "count" 0-terminated strings in the buffer and assign the count ...
cryptographic primitives for GNUnet
void GNUNET_STRINGS_utf8_toupper(const char *input, char *output)
Convert the utf-8 input string to uppercase.
static struct GNUNET_OS_Process * p
Helper process we started.
static struct PeerEntry ** table
Table with our interned peer IDs.
char * GNUNET_STRINGS_pp2s(const struct GNUNET_PeerIdentity *pids, unsigned int num_pids)
Convert a peer path to a human-readable string.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
IPV4 network in CIDR notation.
static int result
Global testing status.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
char * GNUNET_STRINGS_from_utf8(const char *input, size_t len, const char *charset)
Convert the len bytes-long UTF-8 string given in input to the given charset.
size_t GNUNET_STRINGS_buffer_fill(char *buffer, size_t size, unsigned int count,...)
Fill a buffer of the given size with count 0-terminated strings (given as varargs).
Unit conversion table entry for 'convert_with_table'.
size_t GNUNET_STRINGS_parse_socket_addr(const char *addr, uint8_t *af, struct sockaddr **sa)
Parse an address given as a string into a struct sockaddr.
static OpusDecoder * dec
OPUS decoder.
static unsigned int getValue__(unsigned char a)
Get the decoded value corresponding to a character according to Crockford Base32 encoding.
size_t GNUNET_STRINGS_base64_decode(const char *data, size_t len, void **out)
Decode from Base64.
size_t GNUNET_STRINGS_base64_encode(const void *in, size_t len, char **output)
Encode into Base64.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
const char * GNUNET_STRINGS_get_short_name(const char *filename)
"man basename" Returns a pointer to a part of filename (allocates nothing)!
static unsigned int size
Size of the "table".
size_t GNUNET_STRINGS_urlencode(const char *data, size_t len, char **out)
url/percent encode (RFC3986).
int GNUNET_STRINGS_check_filename(const char *filename, enum GNUNET_STRINGS_FilenameCheck checks)
Perform checks on filename.
char * GNUNET_STRINGS_filename_expand(const char *fil)
Complete filename (a la shell) from abbrevition.
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
The identity of the host (wraps the signing key of the peer).
uint16_t end_port
End of port range (0 if none given).
#define LOG_STRERROR(kind, syscall)
static uint16_t port
Port number.
static OpusEncoder * enc
OPUS encoder.
int GNUNET_STRINGS_to_address_ipv6(const char *zt_addr, uint16_t addrlen, struct sockaddr_in6 *r_buf)
Tries to convert zt_addr string to an IPv6 address.
#define GNUNET_log(kind,...)
GNUNET_STRINGS_FilenameCheck
Flags for what we should check a file for.
char * GNUNET_STRINGS_to_utf8(const char *input, size_t len, const char *charset)
Convert the len characters long character sequence given in input that is in the given charset to UTF...
void GNUNET_buffer_clear(struct GNUNET_Buffer *buf)
Free the backing memory of the given buffer.
struct GNUNET_STRINGS_PortPolicy pp
Policy for port access.
struct in6_addr network
IPv6 address.
Time for absolute times used by GNUnet, in microseconds.
Common buffer management functions.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
"asctime", except for GNUnet time.
uint32_t data
The data value.
size_t GNUNET_strlcpy(char *dst, const char *src, size_t n)
Like strlcpy but portable.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
const char * name
Name of the unit (or NULL for end of table).
static size_t strnlen(const char *s, size_t n)
int GNUNET_STRINGS_to_address_ip(const char *addr, uint16_t addrlen, struct sockaddr_storage *r_buf)
Tries to convert addr string to an IP (v4 or v6) address.
size_t GNUNET_STRINGS_base64url_decode(const char *data, size_t len, void **out)
Decode from Base64url.
#define GNUNET_malloc(size)
Wrapper around malloc.
int GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert Crockford Base32hex encoding back to data.
char * GNUNET_STRINGS_data_to_string(const void *data, size_t size, char *out, size_t out_size)
Convert binary data to ASCII encoding using Crockford Base32 encoding.
Check that it is a directory.
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
void GNUNET_STRINGS_utf8_tolower(const char *input, char *output)
Convert the utf-8 input string to lowercase.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...