Command bytarget returns name of target (if defined).
[pazpar2-moved-to-github.git] / src / http_command.c
index 2670b26..ba4b670 100644 (file)
@@ -27,7 +27,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #endif
 #include <stdlib.h>
 #include <string.h>
-#include <ctype.h>
 #if HAVE_SYS_TIME_H
 #include <sys/time.h>
 #endif
@@ -423,6 +422,13 @@ static void cmd_bytarget(struct http_channel *c)
         wrbuf_xmlputs(c->wrbuf, ht[i].id);
         wrbuf_puts(c->wrbuf, "</id>\n");
 
+        if (ht[i].name && ht[i].name[0]) 
+        {
+            wrbuf_puts(c->wrbuf, "<name>");
+            wrbuf_xmlputs(c->wrbuf, ht[i].name);
+            wrbuf_puts(c->wrbuf, "</name>\n");
+        }
+
         wrbuf_printf(c->wrbuf, "<hits>%d</hits>\n", ht[i].hits);
         wrbuf_printf(c->wrbuf, "<diagnostic>%d</diagnostic>\n", ht[i].diagnostic);
         wrbuf_printf(c->wrbuf, "<records>%d</records>\n", ht[i].records);
@@ -486,8 +492,7 @@ static void write_subrecord(struct record *r, WRBUF w,
     wrbuf_xmlputs(w,  *name ? name : "Unknown");
     wrbuf_puts(w, "\">");
 
-    if (show_details)
-        write_metadata(w, service, r->metadata, 1);
+    write_metadata(w, service, r->metadata, show_details);
     wrbuf_puts(w, "</location>\n");
 }