Index: plugins/roard/protocol-gopher.c
===================================================================
--- plugins/roard/protocol-gopher.c	(revision 4712)
+++ plugins/roard/protocol-gopher.c	(revision 4714)
@@ -34,9 +34,10 @@
 #define _SOUND ROAR_GOPHER_TYPE_SOUND
 
-static struct item;
-
-static int scb_status_txt (int client, struct roar_vio_calls * vio, const char * selector, char ** text, struct item * sitem);
-static int scb_clients    (int client, struct roar_vio_calls * vio, const char * selector, char ** text, struct item * sitem);
-static int scb_streams    (int client, struct roar_vio_calls * vio, const char * selector, char ** text, struct item * sitem);
+struct item;
+
+static int scb_status_txt (int client, struct roar_vio_calls * vio, char * selector, char ** text, struct item * sitem);
+static int scb_test       (int client, struct roar_vio_calls * vio, char * selector, char ** text, struct item * sitem);
+static int scb_clients    (int client, struct roar_vio_calls * vio, char * selector, char ** text, struct item * sitem);
+static int scb_streams    (int client, struct roar_vio_calls * vio, char * selector, char ** text, struct item * sitem);
 
 static struct roar_gopher_menu_item g_gopher_root_menu[] = {
@@ -55,5 +56,5 @@
  int dir;
  const char * text;
- int (*cb)(int client, struct roar_vio_calls * vio, const char * selector, char ** text, struct item * sitem);
+ int (*cb)(int client, struct roar_vio_calls * vio, char * selector, char ** text, struct item * sitem);
 } g_gopher_items[] = {
  {.selector = "", .type = _DIR,
@@ -68,4 +69,5 @@
  {.selector = "/info.txt",   .type = _FILE, .text = "Some\nText.", .cb = NULL},
  {.selector = "/status.txt", .type = _FILE, .cb = scb_status_txt},
+ {.selector = "/test/*",     .type = _FILE, .cb = scb_test},
  {.selector = "/clients/",   .type = _DIR,  .cb = scb_clients},
  {.selector = "/streams/",   .type = _DIR,  .cb = scb_streams}
@@ -80,5 +82,5 @@
 
 // SCBs:
-static int scb_status_txt (int client, struct roar_vio_calls * vio, const char * selector, char ** text, struct item * sitem) {
+static int scb_status_txt (int client, struct roar_vio_calls * vio, char * selector, char ** text, struct item * sitem) {
  const size_t len = 1024;
  const char * server_version = NULL;
@@ -90,5 +92,5 @@
  }
 
- *text = roar_mm_malloc(1024);
+ *text = roar_mm_malloc(len);
  if ( *text == NULL )
   return -1;
@@ -113,5 +115,31 @@
 }
 
-static int scb_clients    (int client, struct roar_vio_calls * vio, const char * selector, char ** text, struct item * sitem) {
+static int scb_test(int client, struct roar_vio_calls * vio, char * selector, char ** text, struct item * sitem) {
+ ssize_t toks;
+ char * tok;
+ size_t len;
+
+ toks = strseltok(sitem->selector, selector, &tok, 1);
+
+ if ( toks == -1 )
+  return -1;
+
+ len  = strlen(tok);
+ len += 64;
+
+ *text = roar_mm_malloc(1024);
+ if ( *text == NULL )
+  return -1;
+
+ **text = 0;
+
+ snprintf(*text, len, "Your text was: %s", tok);
+
+ (*text)[len-1] = 0;
+
+ return 0;
+}
+
+static int scb_clients    (int client, struct roar_vio_calls * vio, char * selector, char ** text, struct item * sitem) {
  struct roar_gopher_menu_item items[ROAR_CLIENTS_MAX];
  struct roar_gopher_menu menu = {.flags = 0, .items = items, .items_len = 0};
@@ -167,5 +195,5 @@
 }
 
-static int scb_streams    (int client, struct roar_vio_calls * vio, const char * selector, char ** text, struct item * sitem) {
+static int scb_streams    (int client, struct roar_vio_calls * vio, char * selector, char ** text, struct item * sitem) {
  struct roar_gopher_menu_item items[ROAR_STREAMS_MAX];
  struct roar_gopher_menu menu = {.flags = 0, .items = items, .items_len = 0};
@@ -394,8 +422,12 @@
  char * text;
 
+ ROAR_DBG("emul_gopher_check_client(client=%i, vio=%p) = ?", client, vio);
+
  if ( clients_get_server(client, &cs) == -1 ) {
   clients_delete(client);
   return -1;
  }
+
+ ROAR_DBG("emul_gopher_check_client(client=%i, vio=%p) = ?", client, vio);
 
  if ( vio == NULL ) {
@@ -403,4 +435,6 @@
   roar_vio_open_fh_socket(vio, clients_get_fh(client));
  }
+
+ ROAR_DBG("emul_gopher_check_client(client=%i, vio=%p) = ?", client, vio);
 
  if ( cs->inbuf != NULL ) {
@@ -424,7 +458,10 @@
  }
 
+ ROAR_DBG("emul_gopher_check_client(client=%i, vio=%p) = ?", client, vio);
+
  ret = roar_vio_read(vio, inbuf+len, sizeof(inbuf)-len-1);
  if ( ret < 1 ) {
   clients_delete(client);
+  ROAR_DBG("emul_gopher_check_client(client=%i, vio=%p) = -1", client, vio);
   return -1;
  }
@@ -433,16 +470,25 @@
 
  inbuf[ret] = 0;
+
+ ROAR_DBG("emul_gopher_check_client(client=%i, vio=%p) = ?", client, vio);
 
  if ( !strip_nl(inbuf) ) {
   if ( roar_buffer_new_data(&(cs->inbuf), ret, &data) == -1 ) {
    clients_delete(client);
+   ROAR_DBG("emul_gopher_check_client(client=%i, vio=%p) = -1", client, vio);
    return -1;
   }
 
   memcpy(data, inbuf, ret);
+
+  ROAR_DBG("emul_gopher_check_client(client=%i, vio=%p) = 0", client, vio);
+
   return 0;
  }
 
+ ROAR_DBG("emul_gopher_check_client(client=%i, vio=%p) = ?", client, vio);
+
  for (i = 0; i < sizeof(g_gopher_items)/sizeof(*g_gopher_items); i++) {
+//  if ( !strselcmp(g_gopher_items[i].selector, inbuf) ) {
   if ( !strselcmp(g_gopher_items[i].selector, inbuf) ) {
    c = &(g_gopher_items[i]);
@@ -453,6 +499,9 @@
  if ( c == NULL ) {
   clients_delete(client);
-  return -1;
- }
+  ROAR_DBG("emul_gopher_check_client(client=%i, vio=%p) = -1", client, vio);
+  return -1;
+ }
+
+ ROAR_DBG("emul_gopher_check_client(client=%i, vio=%p) = ?", client, vio);
 
  if ( c->cb != NULL ) {
@@ -479,8 +528,13 @@
  }
 
+ ROAR_DBG("emul_gopher_check_client(client=%i, vio=%p) = ?", client, vio);
+
  if ( funcret == -1 ) {
   clients_delete(client);
-  return -1;
- }
+  ROAR_DBG("emul_gopher_check_client(client=%i, vio=%p) = -1", client, vio);
+  return -1;
+ }
+
+ ROAR_DBG("emul_gopher_check_client(client=%i, vio=%p) = 0", client, vio);
 
  return 0;
@@ -488,4 +542,6 @@
 
 int emul_gopher_flushed_client(int client, struct roar_vio_calls * vio) {
+ ROAR_DBG("emul_gopher_flushed_client(client=%i, vio=%p) = ?", client, vio);
+
  return clients_delete(client);
 }
