Index: ChangeLog
===================================================================
--- ChangeLog	(revision 5601)
+++ ChangeLog	(revision 5602)
@@ -14,4 +14,5 @@
 	  arguments) (Closes: #276)
 	* Updated manpages.
+	* moved strselcmp() and strseltok() to libroar (Closes: #285) (pr1)
 
 v. 1.0beta3 - Sun Jul 15 2012 26:08 CEST
Index: include/libroar/memmgr.h
===================================================================
--- include/libroar/memmgr.h	(revision 5381)
+++ include/libroar/memmgr.h	(revision 5602)
@@ -158,4 +158,9 @@
 #endif
 
+
+// Selector parsing.
+int roar_mm_strselcmp(const char *s1, const char *s2);
+ssize_t roar_mm_strseltok(const char *s1, char *s2, char ** tok, size_t toks);
+
 #endif
 
Index: include/libroar/roarfeatures.h
===================================================================
--- include/libroar/roarfeatures.h	(revision 5576)
+++ include/libroar/roarfeatures.h	(revision 5602)
@@ -61,4 +61,5 @@
 #define ROAR_FT_FEATURE_UUID         /* see #230 */
 #define ROAR_FT_FEATURE_COMMON_PROTO /* see #257 */
+#define ROAR_FT_FEATURE_SELECTOR_HANDLING /* see #285 */
 
 // libroar2 features:
Index: libroar/memmgr.c
===================================================================
--- libroar/memmgr.c	(revision 5381)
+++ libroar/memmgr.c	(revision 5602)
@@ -416,3 +416,85 @@
 #endif
 
+int roar_mm_strselcmp(const char *s1, const char *s2) {
+ register char a, b;
+
+ if ( s1 == s2 )
+  return 0;
+
+ if ( s1 == NULL || s2 == NULL )
+  return -1;
+
+ for (; ; s1++, s2++) {
+  a = *s1;
+  b = *s2;
+
+  if ( a == '*' ) {
+   s1++;
+   a = *s1;
+   if ( a == 0 ) {
+    if ( b == 0 ) {
+     return 1; // no match! ('*' does not mach no-chars)
+    } else {
+     return 0; // match! (string ends with '*' and something not EOS is in b)
+    }
+   } else {
+    for (; *s2 != 0 && *s2 != a; s2++);
+    if ( a != *s2 )
+     return 1; // no match! (did not find correct char)
+   }
+  } else if ( a == 0 || b == 0 ) {
+   if ( a == b ) {
+    return 0; // match!
+   } else {
+    return 1; // no match! (dffrent length)
+   }
+  } else if ( a != b ) {
+   return 1; // no match! (diffrent chars)
+  }
+ }
+
+ return -1;
+}
+
+ssize_t roar_mm_strseltok(const char *s1, char *s2, char ** tok, size_t toks) {
+ register char a, b;
+ size_t idx = 0;
+
+ if ( s1 == NULL || s2 == NULL )
+  return -1;
+
+ for (; ; s1++, s2++) {
+  a = *s1;
+  b = *s2;
+
+  if ( a == 0 || b == 0 ) {
+   if ( a == b ) {
+    return idx;
+   } else {
+    return -1;
+   }
+  } else if ( a == '*' ) {
+   s1++;
+   a = *s1;
+   if ( idx == toks )
+    return -1;
+
+   tok[idx] = s2;
+   idx++;
+
+   for (; *s2 != 0 && *s2 != a; s2++);
+
+   if ( a == 0 )
+    return idx;
+
+   if ( *s1 == 0 )
+    return -1;
+
+   *s2 = 0;
+  }
+ }
+
+ return -1;
+}
+
 //ll
Index: plugins/roard/protocol-gopher.c
===================================================================
--- plugins/roard/protocol-gopher.c	(revision 5381)
+++ plugins/roard/protocol-gopher.c	(revision 5602)
@@ -90,7 +90,4 @@
 };
 
-static int strselcmp(const char *s1, const char *s2);
-static ssize_t strseltok(const char *s1, char *s2, char ** tok, size_t toks);
-
 static char * _aprintf(size_t sizehint, const char * format, ...);
 
@@ -141,5 +138,5 @@
  size_t len;
 
- toks = strseltok(sitem->selector, selector, &tok, 1);
+ toks = roar_mm_strseltok(sitem->selector, selector, &tok, 1);
 
  if ( toks == -1 )
@@ -286,5 +283,5 @@
  memset(items, 0, sizeof(items));
 
- toks = strseltok(sitem->selector, selector, &tok, 1);
+ toks = roar_mm_strseltok(sitem->selector, selector, &tok, 1);
  if ( toks == -1 )
   return -1;
@@ -361,5 +358,5 @@
  memset(items, 0, sizeof(items));
 
- toks = strseltok(sitem->selector, selector, &tok, 1);
+ toks = roar_mm_strseltok(sitem->selector, selector, &tok, 1);
  if ( toks == -1 )
   return -1;
@@ -475,5 +472,5 @@
  int stream = -1;
 
- toks = strseltok(sitem->selector, selector, tok, 5);
+ toks = roar_mm_strseltok(sitem->selector, selector, tok, 5);
 
  if ( toks != 5 )
@@ -545,86 +542,4 @@
 
  return 0;
-}
-
-static int strselcmp(const char *s1, const char *s2) {
- register char a, b;
-
- if ( s1 == s2 )
-  return 0;
-
- if ( s1 == NULL || s2 == NULL )
-  return -1;
-
- for (; ; s1++, s2++) {
-  a = *s1;
-  b = *s2;
-
-  if ( a == '*' ) {
-   s1++;
-   a = *s1;
-   if ( a == 0 ) {
-    if ( b == 0 ) {
-     return 1; // no match! ('*' does not mach no-chars)
-    } else {
-     return 0; // match! (string ends with '*' and something not EOS is in b)
-    }
-   } else {
-    for (; *s2 != 0 && *s2 != a; s2++);
-    if ( a != *s2 )
-     return 1; // no match! (did not find correct char)
-   }
-  } else if ( a == 0 || b == 0 ) {
-   if ( a == b ) {
-    return 0; // match!
-   } else {
-    return 1; // no match! (dffrent length)
-   }
-  } else if ( a != b ) {
-   return 1; // no match! (diffrent chars)
-  }
- }
-
- return -1;
-}
-
-static ssize_t strseltok(const char *s1, char *s2, char ** tok, size_t toks) {
- register char a, b;
- size_t idx = 0;
-
- if ( s1 == NULL || s2 == NULL )
-  return -1;
-
- for (; ; s1++, s2++) {
-  a = *s1;
-  b = *s2;
-
-  if ( a == 0 || b == 0 ) {
-   if ( a == b ) {
-    return idx;
-   } else {
-    return -1;
-   }
-  } else if ( a == '*' ) {
-   s1++;
-   a = *s1;
-   if ( idx == toks )
-    return -1;
-
-   tok[idx] = s2;
-   idx++;
-
-   for (; *s2 != 0 && *s2 != a; s2++);
-
-   if ( a == 0 )
-    return idx;
-
-   if ( *s1 == 0 )
-    return -1;
-
-   *s2 = 0;
-  }
- }
-
- return -1;
 }
 
@@ -796,6 +711,6 @@
 
  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) ) {
+//  if ( !roar_mm_strselcmp(g_gopher_items[i].selector, inbuf) ) {
+  if ( !roar_mm_strselcmp(g_gopher_items[i].selector, inbuf) ) {
    c = &(g_gopher_items[i]);
    break;
