#include <tr_gss_names.h>
#include <trp_peer.h>
#include <tr_util.h>
+#include <tr_json_util.h>
char *trp_peer_to_str(TALLOC_CTX *memctx, TRP_PEER *peer, const char *sep)
{
char *s = NULL;
json_t *jstr = NULL;
- if (tr_cmp_timespec(trp_peer_get_last_conn_attempt(peer), &ts_zero) == 0) {
- s = strdup("");
- } else {
+ if (tr_cmp_timespec(trp_peer_get_last_conn_attempt(peer), &ts_zero) > 0) {
s = timespec_to_str(trp_peer_get_last_conn_attempt(peer));
- }
- if (s) {
- jstr = json_string(s);
- free(s);
+ if (s) {
+ jstr = json_string(s);
+ free(s);
+ }
}
return jstr;
}
-/* helper for below */
-#define OBJECT_SET_OR_FAIL(jobj, key, val) \
-do { \
- if (val) \
- json_object_set_new((jobj),(key),(val)); \
- else \
- goto cleanup; \
-} while (0)
-
json_t *trp_peer_to_json(TRP_PEER *peer)
{
json_t *peer_json = NULL;