36#define LOG(kind, ...) GNUNET_log_from (kind, "util-strings", __VA_ARGS__)
38#define LOG_STRERROR(kind, syscall) \
39 GNUNET_log_from_strerror (kind, "util-strings", syscall)
45 unsigned int count, ...)
54 const char *s = va_arg (ap,
const char *);
55 size_t slen = strlen (s) + 1;
85 r = va_arg (ap,
const char **);
88 while ((needed <
size) && (buffer[needed] !=
'\0'))
107 const char *unit =
"b";
145 memcpy (dst, src, slen);
182 unsigned long long *output)
184 unsigned long long ret;
187 unsigned long long last;
194 for (tok = strtok_r (in,
" ", &sptr);
196 tok = strtok_r (NULL,
" ", &sptr))
205 last *=
table[i].value;
213 last = strtoull (tok, &endptr, 10);
214 if ((0 != errno) || (endptr == tok))
219 if (
'\0' == endptr[0])
236 unsigned long long *
size)
242 {
"MiB", 1024 * 1024 },
243 {
"MB", 1000 * 1000 },
244 {
"GiB", 1024 * 1024 * 1024 },
245 {
"GB", 1000 * 1000 * 1000 },
246 {
"TiB", 1024LL * 1024LL * 1024LL * 1024LL },
247 {
"TB", 1000LL * 1000LL * 1000LL * 1024LL },
248 {
"PiB", 1024LL * 1024LL * 1024LL * 1024LL * 1024LL },
249 {
"PB", 1000LL * 1000LL * 1000LL * 1024LL * 1000LL },
250 {
"EiB", 1024LL * 1024LL * 1024LL * 1024LL * 1024LL * 1024LL },
251 {
"EB", 1000LL * 1000LL * 1000LL * 1024LL * 1000LL * 1000LL },
265 {
"s", 1000 * 1000LL },
266 {
"second", 1000 * 1000LL },
267 {
"seconds", 1000 * 1000LL },
268 {
"\"", 1000 * 1000LL },
269 {
"m", 60 * 1000 * 1000LL },
270 {
"min", 60 * 1000 * 1000LL },
271 {
"minute", 60 * 1000 * 1000LL },
272 {
"minutes", 60 * 1000 * 1000LL },
273 {
"'", 60 * 1000 * 1000LL },
274 {
"h", 60 * 60 * 1000 * 1000LL },
275 {
"hour", 60 * 60 * 1000 * 1000LL },
276 {
"hours", 60 * 60 * 1000 * 1000LL },
277 {
"d", 24 * 60 * 60 * 1000LL * 1000LL },
278 {
"day", 24 * 60 * 60 * 1000LL * 1000LL },
279 {
"days", 24 * 60 * 60 * 1000LL * 1000LL },
280 {
"w", 7 * 24 * 60 * 60 * 1000LL * 1000LL },
281 {
"week", 7 * 24 * 60 * 60 * 1000LL * 1000LL },
282 {
"weeks", 7 * 24 * 60 * 60 * 1000LL * 1000LL },
283 {
"year", 31536000000000LL },
284 {
"years", 31536000000000LL },
285 {
"y", 31536000000000LL },
286 {
"a", 31536000000000LL },
289 unsigned long long val;
291 if (0 == strcasecmp (
"forever", fancy_time))
309 unsigned long long l;
312 if (0 == strcasecmp (
"end of time",
318 if ( (1 == sscanf (fancy_time,
328 eos = &fancy_time[strlen (fancy_time)];
329 memset (&tv, 0,
sizeof(tv));
330 if ((eos != strptime (fancy_time,
"%a %b %d %H:%M:%S %Y", &tv)) &&
331 (eos != strptime (fancy_time,
"%c", &tv)) &&
332 (eos != strptime (fancy_time,
"%Ec", &tv)) &&
333 (eos != strptime (fancy_time,
"%Y-%m-%d %H:%M:%S", &tv)) &&
334 (eos != strptime (fancy_time,
"%Y-%m-%d %H:%M", &tv)) &&
335 (eos != strptime (fancy_time,
"%x", &tv)) &&
336 (eos != strptime (fancy_time,
"%Ex", &tv)) &&
337 (eos != strptime (fancy_time,
"%Y-%m-%d", &tv)) &&
338 (eos != strptime (fancy_time,
"%Y-%m", &tv)) &&
339 (eos != strptime (fancy_time,
"%Y", &tv)))
342 if (((time_t) -1) ==
t)
376 const char *input_charset,
377 const char *output_charset)
381 char *encoded_string;
382 size_t u8_string_length;
383 size_t encoded_string_length;
385 u8_string = u8_conv_from_encoding (input_charset,
392 if (NULL == u8_string)
397 if (0 == strcmp (output_charset,
"UTF-8"))
401 ret[u8_string_length] =
'\0';
405 encoded_string = u8_conv_to_encoding (output_charset,
411 &encoded_string_length);
413 if (NULL == encoded_string)
420 ret[encoded_string_length] =
'\0';
421 free (encoded_string);
425 _ (
"Character sets requested were `%s'->`%s'\n"),
465 tmp = u8_normalize (UNINORM_NFC,
467 strlen ((
char*) input),
487 tmp_in = u8_tolower ((uint8_t *) input,
488 strlen ((
char *) input),
512 tmp_in = u8_toupper ((uint8_t *) input,
513 strlen ((
char *) input),
550 _ (
"Failed to expand `$HOME': environment variable `HOME' not set"));
570 if (NULL != getcwd (buffer,
576 if ( (errno == ERANGE) &&
577 (len < 1024 * 1024 * 4) )
614 const char *unit =
"µs";
651 (
unsigned long long) dval, unit);
678 return "end of time";
679 tt =
t.abs_value_us / 1000LL / 1000LL;
680 tp = localtime (&
tt);
687 strftime (buf,
sizeof(buf),
"%a %b %d %H:%M:%S %Y", tp);
740 if ((a >=
'0') && (a <=
'9'))
742 if ((a >=
'a') && (a <=
'z'))
746 if ((a >=
'A') && (a <=
'Z'))
756 return(a -
'A' + 10 -
dec);
771 static const char *encTable__ =
"0123456789ABCDEFGHJKMNPQRSTVWXYZ";
776 const unsigned char *udata;
780 if (out_size < (
size * 8 + 4) / 5)
789 while ((rpos <
size) || (vbit > 0))
791 if ((rpos <
size) && (vbit < 5))
793 bits = (bits << 8) | udata[rpos++];
802 if (wpos >= out_size)
807 out[wpos++] = encTable__[(bits >> (vbit - 5)) & 31];
821 size_t len =
size * 8;
864 encoded_len = out_size * 8;
868 if ((encoded_len % 5) > 0)
870 vbit = encoded_len % 5;
880 if ((encoded_len + shift) / 5 != enclen)
897 uout[--wpos] = (
unsigned char) bits;
902 if ((0 != rpos) || (0 != vbit))
918 size = (enclen * 5) / 8;
953 const char **path_part)
959 const char *post_scheme_part = NULL;
962 for (
end = 0, i = 0; !
end && i < len; i++)
967 if ((path[i] ==
':') && (i > 0))
972 if (! (((path[i] >=
'A') && (path[i] <=
'Z') ) ||
973 ((path[i] >=
'a') && (path[i] <=
'z') ) ||
974 ((path[i] >=
'0') && (path[i] <=
'9') ) || (path[i] ==
'+') ||
975 (path[i] ==
'-') || (path[i] ==
'.')))
990 post_scheme_part = &path[i];
998 if (post_scheme_part == NULL)
1003 post_scheme_part - path);
1006 *path_part = post_scheme_part;
1015 char **r_uri_scheme)
1017 const char *post_scheme_path;
1033 *r_uri_scheme =
uri;
1077 if (! S_ISDIR (
st.st_mode))
1089 struct sockaddr_in6 *r_buf)
1097 char zbuf[addrlen + 1];
1107 _ (
"IPv6 address did not start with `['\n"));
1110 zbuf[addrlen] =
'\0';
1111 port_colon = strrchr (zbuf,
':');
1112 if (NULL == port_colon)
1115 _ (
"IPv6 address did contain ':' to separate port number\n"));
1118 if (
']' != *(port_colon - 1))
1123 "IPv6 address did contain ']' before ':' to separate port number\n"));
1127 if ((1 !=
ret) || (
port > 65535))
1132 "IPv6 address did contain a valid port number after the last ':'\n"));
1135 *(port_colon - 1) =
'\0';
1136 memset (r_buf, 0,
sizeof(
struct sockaddr_in6));
1137 ret = inet_pton (AF_INET6, &zbuf[1], &r_buf->sin6_addr);
1141 _ (
"Invalid IPv6 address `%s': %s\n"),
1146 r_buf->sin6_port = htons (
port);
1147 r_buf->sin6_family = AF_INET6;
1148#if HAVE_SOCKADDR_IN_SIN_LEN
1149 r_buf->sin6_len = (u_char)
sizeof(
struct sockaddr_in6);
1159 struct sockaddr_in *r_buf)
1161 unsigned int temps[4];
1168 cnt = sscanf (zt_addr,
1169 "%u.%u.%u.%u:%u%1s",
1178 for (cnt = 0; cnt < 4; cnt++)
1179 if (temps[cnt] > 0xFF)
1183 r_buf->sin_family = AF_INET;
1184 r_buf->sin_port = htons (
port);
1185 r_buf->sin_addr.s_addr =
1186 htonl ((temps[0] << 24) + (temps[1] << 16) + (temps[2] << 8) + temps[3]);
1187#if HAVE_SOCKADDR_IN_SIN_LEN
1188 r_buf->sin_len = (u_char)
sizeof(
struct sockaddr_in);
1197 struct sockaddr_storage *r_buf)
1202 (
struct sockaddr_in6 *) r_buf);
1205 (
struct sockaddr_in *) r_buf);
1212 struct sockaddr **sa)
1222 (
struct sockaddr_in6 *) *sa))
1229 return sizeof(
struct sockaddr_in6);
1238 (
struct sockaddr_in *) *sa))
1245 return sizeof(
struct sockaddr_in);
1274 if (2 == sscanf (pos,
"%u-%u%1s", &s, &e, eol))
1276 if ((0 == s) || (s > 0xFFFF) || (e < s) || (e > 0xFFFF))
1285 if (1 == sscanf (pos,
"%u%1s", &s, eol))
1287 if ((0 == s) || (s > 0xFFFF))
1298 _ (
"Malformed port policy `%s'\n"),
1310 unsigned int temps[8];
1314 if (NULL == routeListX)
1316 len = strlen (routeListX);
1321 for (
size_t i = 0; i < len; i++)
1322 if (routeList[i] ==
';')
1328 for (
size_t i = 0; i < count; i++)
1334 for (colon = pos;
':' != routeList[colon]; colon++)
1335 if ((
';' == routeList[colon]) || (
'\0' == routeList[colon]))
1337 for (
end = colon;
';' != routeList[
end];
end++)
1338 if (
'\0' == routeList[
end])
1340 if (
'\0' == routeList[
end])
1342 routeList[
end] =
'\0';
1343 if (
':' == routeList[colon])
1345 routeList[colon] =
'\0';
1350 sscanf (&routeList[pos],
1351 "%u.%u.%u.%u/%u.%u.%u.%u%c",
1362 for (
unsigned int j = 0; j < 8; j++)
1363 if (temps[j] > 0xFF)
1366 _ (
"Invalid format for IP: `%s'\n"),
1372 result[i].network.s_addr = htonl ((temps[0] << 24) + (temps[1] << 16)
1373 + (temps[2] << 8) + temps[3]);
1374 result[i].netmask.s_addr = htonl ((temps[4] << 24) + (temps[5] << 16)
1375 + (temps[6] << 8) + temps[7]);
1385 sscanf (&routeList[pos],
1394 for (
unsigned int j = 0; j < 4; j++)
1395 if (temps[j] > 0xFF)
1398 _ (
"Invalid format for IP: `%s'\n"),
1404 result[i].network.s_addr = htonl ((temps[0] << 24) + (temps[1] << 16)
1405 + (temps[2] << 8) + temps[3]);
1408 result[i].netmask.s_addr = 0;
1411 result[i].netmask.s_addr =
1412 (
result[i].netmask.s_addr >> 1) + 0x80000000;
1423 "Invalid network notation ('/%d' is not legal in IPv4 CIDR)."),
1434 sscanf (&routeList[pos],
1442 for (
unsigned int j = 0; j < 4; j++)
1443 if (temps[j] > 0xFF)
1446 _ (
"Invalid format for IP: `%s'\n"),
1452 result[i].network.s_addr = htonl ((temps[0] << 24) + (temps[1] << 16)
1453 + (temps[2] << 8) + temps[3]);
1454 result[i].netmask.s_addr = htonl (0xffffffff);
1459 _ (
"Invalid format for IP: `%s'\n"),
1465 if (pos < strlen (routeList))
1468 _ (
"Invalid format: `%s'\n"),
1490 if (NULL == routeListX)
1492 len = strlen (routeListX);
1497 for (
size_t j = 0; j < len; j++)
1498 if (
';' == routeList[j])
1500 if (
';' != routeList[len - 1])
1503 _ (
"Invalid network notation (does not end with ';': `%s')\n"),
1512 for (
size_t i = 0; i < count; i++)
1518 while (
';' != routeList[pos])
1521 while ( (slash >
start) &&
1522 (routeList[slash] !=
'/') )
1528 sizeof(
struct in6_addr));
1535 routeList[pos] =
'\0';
1536 for (colon = pos;
':' != routeList[colon]; colon--)
1537 if (
'/' == routeList[colon])
1539 if (
':' == routeList[colon])
1541 routeList[colon] =
'\0';
1551 ret = inet_pton (AF_INET6,
1552 &routeList[slash + 1],
1560 if ( (1 != sscanf (&routeList[slash + 1],
1569 _ (
"Wrong format `%s' for netmask\n"),
1585 result[i].netmask.s6_addr[off++] = 0xFF;
1590 result[i].netmask.s6_addr[off] =
1591 (
result[i].netmask.s6_addr[off] >> 1) + 0x80;
1596 routeList[slash] =
'\0';
1597 ret = inet_pton (AF_INET6,
1604 _ (
"Wrong format `%s' for network\n"),
1605 &routeList[slash + 1]);
1623static const char *
cvt =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
1624 "abcdefghijklmnopqrstuvwxyz"
1633 const unsigned char *
data = in;
1640 for (
size_t i = 0; i < len; ++i)
1644 c = (
data[i] >> 2) & 0x3f;
1645 opt[
ret++] =
cvt[(int) c];
1646 c = (
data[i] << 4) & 0x3f;
1648 c |= (
data[i] >> 4) & 0x0f;
1649 opt[
ret++] =
cvt[(int) c];
1652 c = (
data[i] << 2) & 0x3f;
1654 c |= (
data[i] >> 6) & 0x03;
1655 opt[
ret++] =
cvt[(int) c];
1665 opt[
ret++] =
cvt[(int) c];
1691 while (
'\0' !=
enc[pos])
1693 if (
'+' ==
enc[pos])
1695 if (
'/' ==
enc[pos])
1697 if (
'=' ==
enc[pos])
1704 return strlen (
enc);
1709 ((((a) >= 'A') && ((a) <= 'Z')) \
1711 : (((a) >= 'a') && ((a) <= 'z')) \
1713 : (((a) >= '0') && ((a) <= '9')) \
1715 : ((a) == '+') ? 62 : ((a) == '/') ? 63 : -1)
1719 while ( (data[i] == '\r') || (data[i] == '\n') ) \
1721 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, \
1722 "ignoring CR/LF\n"); \
1735 unsigned char *output;
1741 "base64_decode decoding len=%d\n",
1743 for (
size_t i = 0; i < len; ++i)
1755 c = (c << 2) | ((c1 >> 4) & 0x3);
1763 c = (
unsigned char)
cvtfind (c);
1764 c1 = ((c1 << 4) & 0xf0) | ((c >> 2) & 0xf);
1774 c1 = (
unsigned char)
cvtfind (c1);
1775 c = ((c << 6) & 0xc0) | c1;
1803 for (
size_t i = 0; i < strlen (s); i++)
1842 const char *rpos =
data;
1848 while ( (
'\0' != *rpos) &&
1849 (
data + len != rpos) )
1855 if (rpos + 3 >
data + len)
1861 if (1 != sscanf (rpos + 1,
1873 *wpos = (char) ((
unsigned char) num);
1894 const char data[
static len],
1898 const uint8_t *i8 = (uint8_t *)
data;
1899 const uint8_t *
end = (uint8_t *) (
data + len);
1910 if (0 == (0x80 & *i8))
1913 if (isalnum (*i8) ||
1921 else if (*i8 ==
' ')
1933 if (0x80 + 0x40 == ((0x80 + 0x40 + 0x20) & *i8))
1956 if (0x80 + 0x40 + 0x20 == ((0x80 + 0x40 + 0x20 + 0x10) & *i8))
1959 for (
unsigned int i = 0; i<3; i++)
1977 if (0x80 + 0x40 + 0x20 + 0x10 == ((0x80 + 0x40 + 0x20 + 0x10 + 0x08) & *i8))
1980 for (
unsigned int i = 0; i<4; i++)
1998 if (0x80 + 0x40 + 0x20 + 0x10 + 0x08 == ((0x80 + 0x40 + 0x20 + 0x10 + 0x08
2002 for (
unsigned int i = 0; i<5; i++)
2020 if (0x80 + 0x40 + 0x20 + 0x10 + 0x08 + 0x04 == ((0x80 + 0x40 + 0x20 + 0x10
2021 + 0x08 + 0x04 + 0x02)
2025 for (
unsigned int i = 0; i<6; i++)
2049 return strlen (*out);
2072 ret = strrchr (argv0,
'_');
static size_t strnlen(const char *s, size_t n)
static int start
Set if we are to start default services (including ARM).
static int ret
Final status code.
static int end
Set if we are to shutdown all services (including ARM).
static uint16_t port
Port number.
static struct GNUNET_SCHEDULER_Task * st
The shutdown task.
@ END
We're done processing.
static struct GNUNET_SCHEDULER_Task * tt
Task scheduled to handle timeout.
static char * data
The data to insert into the dht.
static OpusDecoder * dec
OPUS decoder.
static OpusEncoder * enc
OPUS encoder.
static struct in_addr dummy
Target "dummy" address of the packet we pretend to respond to.
static char * name
Name (label) of the records to list.
static struct GNUNET_SCHEDULER_Task * t
Main task.
static char * res
Currently read line or NULL on EOF.
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
static int result
Global testing status.
static void do_round(void *cls)
Send out PUSHes and PULLs, possibly update #view, samplers.
static void save()
Write persistent statistics to disk.
#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(struct GNUNET_Buffer *buf, const char *data, size_t len)
Write bytes to the buffer.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
void GNUNET_buffer_clear(struct GNUNET_Buffer *buf)
Free the backing memory of the given buffer.
GNUNET_GenericReturnValue
Named constants for return values.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#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.
#define GNUNET_log_strerror(level, cmd)
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_MAX_MALLOC_CHECKED
Maximum allocation with GNUNET_malloc macro.
#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_malloc(size)
Wrapper around malloc.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_string_to_data_alloc(const char *enc, size_t enclen, void **out, size_t *out_size)
Convert CrockfordBase32 encoding back to data.
size_t GNUNET_STRINGS_urlencode(size_t len, const char data[static len], char **out)
url/percent encode (RFC3986).
size_t GNUNET_STRINGS_base64url_decode(const char *data, size_t len, void **out)
Decode from Base64url.
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.
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 CrockfordBase32.
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...
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
struct GNUNET_STRINGS_IPv6NetworkPolicy * GNUNET_STRINGS_parse_ipv6_policy(const char *routeListX)
Parse an IPv6 network 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 ...
enum GNUNET_GenericReturnValue 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.
char * GNUNET_STRINGS_byte_size_fancy(unsigned long long size)
Convert a given filesize into a fancy human-readable format.
GNUNET_STRINGS_FilenameCheck
Flags for what we should check a file for.
char * GNUNET_STRINGS_utf8_toupper(const char *input)
Convert the utf-8 input string to upper case.
char * GNUNET_STRINGS_filename_expand(const char *fil)
Complete filename (a la shell) from abbrevition.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_to_address_ipv6(const char *zt_addr, size_t addrlen, struct sockaddr_in6 *r_buf)
Tries to convert zt_addr string to an IPv6 address.
size_t GNUNET_STRINGS_urldecode(const char *data, size_t len, char **out)
url/percent encode (RFC3986).
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.
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 ...
enum GNUNET_GenericReturnValue 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.
size_t GNUNET_STRINGS_base64url_encode(const void *in, size_t len, char **output)
Encode into Base64url.
struct GNUNET_STRINGS_IPv4NetworkPolicy * GNUNET_STRINGS_parse_ipv4_policy(const char *routeListX)
Parse an IPv4 network policy.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_parse_uri(const char *path, char **scheme_part, const char **path_part)
Parse a path that might be an URI.
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).
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.
size_t GNUNET_STRINGS_base64_decode(const char *data, size_t len, void **out)
Decode from Base64.
char * GNUNET_STRINGS_utf8_tolower(const char *input)
Convert the utf-8 input string to lower case.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_to_address_ipv4(const char *zt_addr, size_t addrlen, struct sockaddr_in *r_buf)
Tries to convert zt_addr string to an IPv4 address.
size_t GNUNET_STRINGS_base64_encode(const void *in, size_t len, char **output)
Encode into Base64.
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.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_check_filename(const char *filename, enum GNUNET_STRINGS_FilenameCheck checks)
Perform checks on filename.
char * GNUNET_STRINGS_get_suffix_from_binary_name(const char *argv0)
Sometimes we use the binary name to determine which specific test to run.
char * GNUNET_STRINGS_utf8_normalize(const char *input)
Normalize the utf-8 input string to NFC.
size_t GNUNET_strlcpy(char *dst, const char *src, size_t n)
Like strlcpy but portable.
const char * GNUNET_STRINGS_get_short_name(const char *filename)
"man basename" Returns a pointer to a part of filename (allocates nothing)!
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.
@ GNUNET_STRINGS_CHECK_IS_ABSOLUTE
Check that the path is an absolute path.
@ GNUNET_STRINGS_CHECK_IS_DIRECTORY
Check that it is a directory.
@ GNUNET_STRINGS_CHECK_EXISTS
Check that it exists.
@ GNUNET_STRINGS_CHECK_IS_LINK
Check that it is a link.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_fancy_time_to_timestamp(const char *fancy_time, struct GNUNET_TIME_Timestamp *atime)
Convert a given fancy human-readable time to our internal representation.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_from_s(uint64_t s_after_epoch)
Convert seconds after the UNIX epoch to absolute time.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
bool GNUNET_TIME_absolute_is_never(struct GNUNET_TIME_Absolute abs)
Test if abs is never.
#define GNUNET_TIME_UNIT_FOREVER_TS
Constant used to specify "forever".
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
const char * GNUNET_STRINGS_timestamp_to_string(struct GNUNET_TIME_Timestamp t)
Like asctime, except for GNUnet time.
enum GNUNET_GenericReturnValue 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 PeerEntry ** table
Table with our interned peer IDs.
static unsigned int size
Size of the "table".
static struct GNUNET_TIME_Relative delta
static enum GNUNET_GenericReturnValue parse_port_policy(const char *port_policy, struct GNUNET_STRINGS_PortPolicy *pp)
Parse the given port policy.
static enum GNUNET_GenericReturnValue 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 ...
#define FILLCHAR
******************** Base64 encoding
static unsigned int getValue__(unsigned char a)
Get the decoded value corresponding to a character according to Crockford Base32 encoding.
#define LOG_STRERROR(kind, syscall)
Unit conversion table entry for 'convert_with_table'.
const char * name
Name of the unit (or NULL for end of table).
unsigned long long value
Factor to apply for this unit.
Dynamically growing buffer.
IPV4 network in CIDR notation.
struct GNUNET_STRINGS_PortPolicy pp
Policy for port access.
struct in_addr netmask
IPv4 netmask.
network in CIDR notation for IPV6.
struct GNUNET_STRINGS_PortPolicy pp
Policy for port access.
struct in6_addr network
IPv6 address.
struct in6_addr netmask
IPv6 netmask.
uint16_t start_port
Starting port range (0 if none given).
int negate_portrange
GNUNET_YES if the port range should be negated ("!" in policy).
uint16_t end_port
End of port range (0 if none given).
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
Time for timestamps used by GNUnet, in microseconds rounded to seconds.
struct GNUNET_TIME_Absolute abs_time
The actual value.