1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#include "config.h"
#include <gnunet/platform.h>
#include <gnunet/gnunet_common.h>
#include <gnunet/gnunet_strings_lib.h>
#include "gnunet_time_dbus_lib.h"
DBusMessage *
GNUNET_TIME_DBUS_pop_absolute (
DBusMessage *message,
DBusMessageIter *iter,
const char *arg_name,
struct GNUNET_TIME_Absolute *value)
{
DBusMessageIter iter_sub;
DBusMessage *ret = GNUNET_DBUS_pop_enter_variant (message, iter, &iter_sub, arg_name);
if (ret)
return ret;
int arg_type = dbus_message_iter_get_arg_type (&iter_sub);
switch (arg_type)
{
case DBUS_TYPE_STRING: {
const char *time;
dbus_message_iter_get_basic (&iter_sub, &time);
int err = GNUNET_STRINGS_fancy_time_to_absolute (time, value);
if (GNUNET_OK != err)
{
return dbus_message_new_error_printf (
message,
DBUS_ERROR_INVALID_ARGS,
"Bad argument for '%s'. Malformed time string. GNUNET_STRINGS_fancy_time_to_absolute returned %d",
arg_name,
err);
};
return NULL;
};
case DBUS_TYPE_UINT64:
dbus_message_iter_get_basic (&iter_sub, &value->abs_value_us);
return NULL;
default:
return dbus_message_new_error_printf (
message,
DBUS_ERROR_INVALID_ARGS,
"Bad argument for '%s'. Variant must contain a time encoded as a human readable string or a uint64 representing the number of microseconds since epoch. Contains %s.",
arg_name,
GNUNET_DBUS_signature_typecode_to_string (arg_type));
};
};
|