Refactoring to enable community flooding. Partially tested.
[trust_router.git] / common / tr_name.c
index 4480a6a..eacef63 100644 (file)
@@ -34,6 +34,7 @@
 
 #include <stdlib.h>
 #include <string.h>
+#include <jansson.h>
 
 #include <trust_router/tr_name.h>
 
@@ -123,6 +124,15 @@ char * tr_name_strdup(TR_NAME *src)
   return s;
 }
 
+json_t *tr_name_to_json_string(TR_NAME *src)
+{
+  char *s=tr_name_strdup(src);
+  json_t *js=json_string(s);
+  if (s!=NULL)
+    free(s);
+  return js;
+}
+
 TR_NAME *tr_name_cat(TR_NAME *n1, TR_NAME *n2)
 {
   char *s=malloc(n1->len+n2->len+1);