master
cc 22 lines 647 Bytes
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 #include "schema_wrapper_utils.h"
4
5 void set_google_timestamp_from_timeval(struct timeval tv, google::protobuf::Timestamp *ts)
6 {
7 ts->set_nanos(tv.tv_usec*1000);
8 ts->set_seconds(tv.tv_sec);
9 }
10
11 void set_timeval_from_google_timestamp(const google::protobuf::Timestamp &ts, struct timeval *tv)
12 {
13 tv->tv_sec = ts.seconds();
14 tv->tv_usec = ts.nanos()/1000;
15 }
16
17 int label_add_to_map_callback(const char *name, const char *value, RRDLABEL_SRC ls __maybe_unused, void *data)
18 {
19 auto map = (google::protobuf::Map<std::string, std::string> *)data;
20 map->insert({name, value});
21 return 1;
22 }