Index: filter.c
===================================================================
--- filter.c	(revision 37eab7f7cd2720c3f612c28783d596910005f4bf)
+++ filter.c	(revision e3d9c770754b0e7f7af5e9cee8c40c352c998d00)
@@ -70,5 +70,5 @@
 	  !strcasecmp(argv[i], "hostname") ||
 	  !strcasecmp(argv[i], "login")) {
-	regexstr=owl_util_substitute(argv[i+1], "%me%", owl_zephyr_get_sender());
+	regexstr=owl_text_substitute(argv[i+1], "%me%", owl_zephyr_get_sender());
 	owl_filterelement_create_re(fe, argv[i], regexstr);
 	owl_free(regexstr);
Index: functions.c
===================================================================
--- functions.c	(revision eec69e17b355bc2a25298cd2a52d62e246b1574b)
+++ functions.c	(revision e3d9c770754b0e7f7af5e9cee8c40c352c998d00)
@@ -1955,5 +1955,5 @@
 	  if (owl_global_is_smartstrip(&g)) {
 	    tmp2=tmp;
-	    tmp=owl_util_smartstripped_user(tmp2);
+	    tmp=owl_zephyr_smartstripped_user(tmp2);
 	    owl_free(tmp2);
 	  }
@@ -2395,5 +2395,5 @@
   downstr(filtname);
   /* turn spaces into hyphens */
-  owl_util_tr(filtname, ' ', '.');
+  owl_text_tr(filtname, ' ', '.');
   
   /* if it already exists then go with it.  This lets users override */
@@ -2405,8 +2405,8 @@
   argbuff=owl_malloc(len+20);
   tmpclass=owl_strdup(class);
-  owl_util_tr(tmpclass, ' ', '.');
+  owl_text_tr(tmpclass, ' ', '.');
   if (instance) {
     tmpinstance=owl_strdup(instance);
-    owl_util_tr(tmpinstance, ' ', '.');
+    owl_text_tr(tmpinstance, ' ', '.');
   }
   sprintf(argbuff, "( class ^%s$ )", tmpclass);
Index: logging.c
===================================================================
--- logging.c	(revision eec69e17b355bc2a25298cd2a52d62e246b1574b)
+++ logging.c	(revision e3d9c770754b0e7f7af5e9cee8c40c352c998d00)
@@ -23,5 +23,5 @@
 
   /* expand ~ in path names */
-  logpath = owl_util_substitute(owl_global_get_logpath(&g), "~", 
+  logpath = owl_text_substitute(owl_global_get_logpath(&g), "~", 
 				owl_global_get_homedir(&g));
 
@@ -64,5 +64,5 @@
 
   /* expand ~ in path names */
-  logpath = owl_util_substitute(owl_global_get_logpath(&g), "~", 
+  logpath = owl_text_substitute(owl_global_get_logpath(&g), "~", 
 				owl_global_get_homedir(&g));
 
@@ -105,5 +105,5 @@
 
   /* expand ~ in path names */
-  logpath = owl_util_substitute(owl_global_get_logpath(&g), "~", 
+  logpath = owl_text_substitute(owl_global_get_logpath(&g), "~", 
 				owl_global_get_homedir(&g));
 
@@ -210,5 +210,5 @@
   /* create the filename (expanding ~ in path names) */
   if (personal) {
-    logpath = owl_util_substitute(owl_global_get_logpath(&g), "~", 
+    logpath = owl_text_substitute(owl_global_get_logpath(&g), "~", 
 				  owl_global_get_homedir(&g));
     snprintf(filename, MAXPATHLEN, "%s/%s", logpath, from);
@@ -216,5 +216,5 @@
 
   } else {
-    logpath = owl_util_substitute(owl_global_get_classlogpath(&g), "~", 
+    logpath = owl_text_substitute(owl_global_get_classlogpath(&g), "~", 
 				owl_global_get_homedir(&g));
 
Index: stylefunc.c
===================================================================
--- stylefunc.c	(revision 25dd31a596b2ff4128555174743727bed7d6ca3a)
+++ stylefunc.c	(revision e3d9c770754b0e7f7af5e9cee8c40c352c998d00)
@@ -528,5 +528,5 @@
       
       tmp=owl_strdup(owl_message_get_body(m));
-      owl_util_tr(tmp, '\n', ' ');
+      owl_text_tr(tmp, '\n', ' ');
       owl_fmtext_append_ztext(fm, tmp);
       owl_fmtext_append_normal(fm, "\n");
@@ -568,5 +568,5 @@
       
       tmp=owl_strdup(owl_message_get_body(m));
-      owl_util_tr(tmp, '\n', ' ');
+      owl_text_tr(tmp, '\n', ' ');
       owl_fmtext_append_normal(fm, tmp);
       owl_fmtext_append_normal(fm, "\n");
@@ -583,5 +583,5 @@
     
     tmp=owl_strdup(owl_message_get_body(m));
-    owl_util_tr(tmp, '\n', ' ');
+    owl_text_tr(tmp, '\n', ' ');
     owl_fmtext_append_normal(fm, tmp);
     owl_fmtext_append_normal(fm, "\n");
@@ -592,5 +592,5 @@
     
     tmp=owl_strdup(owl_message_get_body(m));
-    owl_util_tr(tmp, '\n', ' ');
+    owl_text_tr(tmp, '\n', ' ');
     owl_fmtext_append_normal(fm, tmp);
     owl_fmtext_append_normal(fm, "\n");
Index: text.c
===================================================================
--- text.c	(revision 8d2469623e3fc5381028b91d544c0e522f1409d9)
+++ text.c	(revision e3d9c770754b0e7f7af5e9cee8c40c352c998d00)
@@ -115,5 +115,4 @@
 }
 
-
 int owl_text_num_lines(char *in)
 {
@@ -190,21 +189,21 @@
   }
 
-  out2=owl_util_substitute(out, "&lt;", "<");
-  owl_free(out);
-  out=owl_util_substitute(out2, "&gt;", ">");
+  out2=owl_text_substitute(out, "&lt;", "<");
+  owl_free(out);
+  out=owl_text_substitute(out2, "&gt;", ">");
   owl_free(out2);
-  out2=owl_util_substitute(out, "&amp;", "&");
-  owl_free(out);
-  out=owl_util_substitute(out2, "&quot;", "\"");
+  out2=owl_text_substitute(out, "&amp;", "&");
+  owl_free(out);
+  out=owl_text_substitute(out2, "&quot;", "\"");
   owl_free(out2);
-  out2=owl_util_substitute(out, "&nbsp;", " ");
-  owl_free(out);
-  out=owl_util_substitute(out2, "&ensp;", "  ");
+  out2=owl_text_substitute(out, "&nbsp;", " ");
+  owl_free(out);
+  out=owl_text_substitute(out2, "&ensp;", "  ");
   owl_free(out2);
-  out2=owl_util_substitute(out, "&emsp;", "   ");
-  owl_free(out);
-  out=owl_util_substitute(out2, "&endash;", "--");
+  out2=owl_text_substitute(out, "&emsp;", "   ");
+  owl_free(out);
+  out=owl_text_substitute(out2, "&endash;", "--");
   owl_free(out2);
-  out2=owl_util_substitute(out, "&emdash;", "---");
+  out2=owl_text_substitute(out, "&emdash;", "---");
   owl_free(out);
 
@@ -257,2 +256,129 @@
   return(out);
 }
+
+/* exactly like strstr but case insensitive */
+char *stristr(char *a, char *b)
+{
+  char *x, *y, *ret;
+
+  if ((x=owl_strdup(a))==NULL) return(NULL);
+  if ((y=owl_strdup(b))==NULL) return(NULL);
+  downstr(x);
+  downstr(y);
+  ret=strstr(x, y);
+  if (ret==NULL) {
+    owl_free(x);
+    owl_free(y);
+    return(NULL);
+  }
+  ret=ret-x+a;
+  owl_free(x);
+  owl_free(y);
+  return(ret);
+}
+
+/* return 1 if a string is only whitespace, otherwise 0 */
+int only_whitespace(char *s)
+{
+  int i;
+  for (i=0; s[i]; i++) {
+    if (!isspace((int) s[i])) return(0);
+  }
+  return(1);
+}
+
+char *owl_getquoting(char *line)
+{
+  if (line[0]=='\0') return("'");
+  if (strchr(line, '\'')) return("\"");
+  if (strchr(line, '"')) return("'");
+  if (strchr(line, ' ')) return("'");
+  return("");
+}
+
+/* Return a string with any occurances of 'from' replaced with 'to'.
+ * Does not currently handle backslash quoting, but may in the future.
+ * Caller must free returned string.
+ */
+char *owl_text_substitute(char *in, char *from, char *to)
+{
+  
+  char *out;
+  int   outlen, tolen, fromlen, inpos=0, outpos=0;
+
+  if (!*from) return owl_strdup(in);
+
+  outlen = strlen(in)+1;
+  tolen  = strlen(to);
+  fromlen  = strlen(from);
+  out = malloc(outlen);
+
+  while (in[inpos]) {
+    if (!strncmp(in+inpos, from, fromlen)) {
+      outlen += tolen;
+      out = owl_realloc(out, outlen);
+      strcpy(out+outpos, to);
+      inpos += fromlen;
+      outpos += tolen;
+    } else {
+      out[outpos] = in[inpos];
+      inpos++; outpos++;
+    }
+  }
+  out[outpos] = '\0';
+  return(out);
+}
+
+/* replace all instances of character a in buff with the character
+ * b.  buff must be null terminated.
+ */
+void owl_text_tr(char *buff, char a, char b)
+{
+  int i;
+
+  owl_function_debugmsg("In: %s", buff);
+  for (i=0; buff[i]!='\0'; i++) {
+    if (buff[i]==a) buff[i]=b;
+  }
+  owl_function_debugmsg("Out: %s", buff);
+}
+
+/* Return a string which is like 'in' except that every instance of
+ * any character in 'toquote' found in 'in' is preceeded by the string
+ * 'quotestr'.  For example, owl_text_quote(in, "+*.", "\") would
+ * place a backslash before every '+', '*' or '.' in 'in'.  It is
+ * permissable for a character in 'quotestr' to be in 'toquote'.
+ * On success returns the string, on error returns NULL.
+ */
+char *owl_text_quote(char *in, char *toquote, char *quotestr)
+{
+  int i, x, r, place;
+  int in_len, toquote_len, quotestr_len;
+  char *out;
+
+  in_len=strlen(in);
+  toquote_len=strlen(toquote);
+  quotestr_len=strlen(quotestr);
+  out=owl_malloc((in_len*quotestr_len)+30);
+  place=0;
+  for (i=0; i<in_len; i++) {
+
+    /* check if it's a character that needs quoting */
+    for (x=0; x<toquote_len; x++) {
+      if (in[i]==toquote[x]) {
+	/* quote it */
+	for (r=0; r<quotestr_len; r++) {
+	  out[place+r]=quotestr[r];
+	}
+	place+=quotestr_len;
+	break;
+      }
+    }
+
+    /* either way, we now copy over the character */
+    out[place]=in[i];
+    place++;
+  }
+  out[place]='\0';
+  return(out);
+}
Index: util.c
===================================================================
--- util.c	(revision c15bbfbec9886b3e0a445c8f20e749643b2c6733)
+++ util.c	(revision e3d9c770754b0e7f7af5e9cee8c40c352c998d00)
@@ -2,5 +2,4 @@
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 #include <unistd.h>
 #include <ctype.h>
@@ -306,5 +305,4 @@
 }
 
-
 /* return the index of the last char before a change from the first one */
 int owl_util_find_trans(char *in, int len)
@@ -317,5 +315,4 @@
 }
 
-
 /* downcase the string 'foo' */
 void downstr(char *foo)
@@ -325,25 +322,4 @@
     foo[i]=tolower(foo[i]);
   }
-}
-
-/* exactly like strstr but case insensitive */
-char *stristr(char *a, char *b)
-{
-  char *x, *y, *ret;
-
-  if ((x=owl_strdup(a))==NULL) return(NULL);
-  if ((y=owl_strdup(b))==NULL) return(NULL);
-  downstr(x);
-  downstr(y);
-  ret=strstr(x, y);
-  if (ret==NULL) {
-    owl_free(x);
-    owl_free(y);
-    return(NULL);
-  }
-  ret=ret-x+a;
-  owl_free(x);
-  owl_free(y);
-  return(ret);
 }
 
@@ -382,14 +358,4 @@
 }
 
-/* return 1 if a string is only whitespace, otherwise 0 */
-int only_whitespace(char *s)
-{
-  int i;
-  for (i=0; s[i]; i++) {
-    if (!isspace((int) s[i])) return(0);
-  }
-  return(1);
-}
-
 /* hooks for doing memory allocation et. al. in owl */
 
@@ -413,5 +379,4 @@
   return(realloc(ptr, size));
 }
-
 
 /* allocates memory and returns the string or null.
@@ -443,137 +408,4 @@
 }
 
-/* Strip a local realm fron the zephyr user name.
- * The caller must free the return
- */
-char *short_zuser(char *in)
-{
-  char *out, *ptr;
-
-  out=owl_strdup(in);
-  ptr=strchr(out, '@');
-  if (ptr) {
-    if (!strcasecmp(ptr+1, owl_zephyr_get_realm())) {
-      *ptr='\0';
-    }
-  }
-  return(out);
-}
-
-/* Append a local realm to the zephyr user name if necessary.
- * The caller must free the return.
- */
-char *long_zuser(char *in)
-{
-  char *ptr;
-
-  if (NULL != (ptr=strchr(in, '@'))) {
-    return owl_strdup(in);
-  } else {
-    return owl_sprintf("%s@%s", in, owl_zephyr_get_realm());
-  }
-}
-
-
-/* strip out the instance from a zsender's principal.  Preserves the
- * realm if present.  daemon.webzephyr is a special case.  The
- * caller must free the return
- */
-char *owl_util_smartstripped_user(char *in)
-{
-  char *ptr, *realm, *out;
-
-  out=owl_strdup(in);
-
-  /* bail immeaditly if we don't have to do any work */
-  ptr=strchr(in, '.');
-  if (!strchr(in, '/') && !ptr) {
-    /* no '/' and no '.' */
-    return(out);
-  }
-  if (ptr && strchr(in, '@') && (ptr > strchr(in, '@'))) {
-    /* There's a '.' but it's in the realm */
-    return(out);
-  }
-  if (!strncasecmp(in, OWL_WEBZEPHYR_PRINCIPAL, strlen(OWL_WEBZEPHYR_PRINCIPAL))) {
-    return(out);
-  }
-
-  /* remove the realm from ptr, but hold on to it */
-  realm=strchr(out, '@');
-  if (realm) realm[0]='\0';
-
-  /* strip */
-  ptr=strchr(out, '.');
-  if (!ptr) ptr=strchr(out, '/');
-  ptr[0]='\0';
-
-  /* reattach the realm if we had one */
-  if (realm) {
-    strcat(out, "@");
-    strcat(out, realm+1);
-  }
-
-  return(out);
-}
-
-char *owl_getquoting(char *line)
-{
-  if (line[0]=='\0') return("'");
-  if (strchr(line, '\'')) return("\"");
-  if (strchr(line, '"')) return("'");
-  if (strchr(line, ' ')) return("'");
-  return("");
-}
-
-
-
-/* Return a string with any occurances of 'from' replaced with 'to'.
- * Does not currently handle backslash quoting, but may in the future.
- * Caller must free returned string.
- */
-char *owl_util_substitute(char *in, char *from, char *to)
-{
-  
-  char *out;
-  int   outlen, tolen, fromlen, inpos=0, outpos=0;
-
-  if (!*from) return owl_strdup(in);
-
-  outlen = strlen(in)+1;
-  tolen  = strlen(to);
-  fromlen  = strlen(from);
-  out = malloc(outlen);
-
-  while (in[inpos]) {
-    if (!strncmp(in+inpos, from, fromlen)) {
-      outlen += tolen;
-      out = owl_realloc(out, outlen);
-      strcpy(out+outpos, to);
-      inpos += fromlen;
-      outpos += tolen;
-    } else {
-      out[outpos] = in[inpos];
-      inpos++; outpos++;
-    }
-  }
-  out[outpos] = '\0';
-  return(out);
-}
-
-/* replace all instances of character a in buff with the character
- * b.  buff must be null terminated.
- */
-void owl_util_tr(char *buff, char a, char b)
-{
-  int i;
-
-  owl_function_debugmsg("In: %s", buff);
-  for (i=0; buff[i]!='\0'; i++) {
-    if (buff[i]==a) buff[i]=b;
-  }
-  owl_function_debugmsg("Out: %s", buff);
-}
-
-
 /* Return the owl color associated with the named color */
 int owl_util_string_to_color(char *color)
@@ -805,11 +637,11 @@
 
   FAIL_UNLESS("owl_util_substitute 1",
-	      !strcmp("foo", owl_util_substitute("foo", "", "Y")));
-  FAIL_UNLESS("owl_util_substitute 2",
-	      !strcmp("fYZYZ", owl_util_substitute("foo", "o", "YZ")));
-  FAIL_UNLESS("owl_util_substitute 3",
-	      !strcmp("foo", owl_util_substitute("fYZYZ", "YZ", "o")));
-  FAIL_UNLESS("owl_util_substitute 4",
-	      !strcmp("/u/foo/meep", owl_util_substitute("~/meep", "~", "/u/foo")));
+	      !strcmp("foo", owl_text_substitute("foo", "", "Y")));
+  FAIL_UNLESS("owl_text_substitute 2",
+	      !strcmp("fYZYZ", owl_text_substitute("foo", "o", "YZ")));
+  FAIL_UNLESS("owl_text_substitute 3",
+	      !strcmp("foo", owl_text_substitute("fYZYZ", "YZ", "o")));
+  FAIL_UNLESS("owl_text_substitute 4",
+	      !strcmp("/u/foo/meep", owl_text_substitute("~/meep", "~", "/u/foo")));
 
   FAIL_UNLESS("skiptokens 1", 
Index: zephyr.c
===================================================================
--- zephyr.c	(revision 269ed344ab73e113b7c213ac137a03221deb4317)
+++ zephyr.c	(revision e3d9c770754b0e7f7af5e9cee8c40c352c998d00)
@@ -485,5 +485,5 @@
 
   if (owl_global_is_smartstrip(&g)) {
-    to=owl_util_smartstripped_user(owl_message_get_sender(m));
+    to=owl_zephyr_smartstripped_user(owl_message_get_sender(m));
   } else {
     to=owl_strdup(owl_message_get_sender(m));
@@ -794,2 +794,77 @@
 }
   
+
+
+/* Strip a local realm fron the zephyr user name.
+ * The caller must free the return
+ */
+char *short_zuser(char *in)
+{
+  char *out, *ptr;
+
+  out=owl_strdup(in);
+  ptr=strchr(out, '@');
+  if (ptr) {
+    if (!strcasecmp(ptr+1, owl_zephyr_get_realm())) {
+      *ptr='\0';
+    }
+  }
+  return(out);
+}
+
+/* Append a local realm to the zephyr user name if necessary.
+ * The caller must free the return.
+ */
+char *long_zuser(char *in)
+{
+  char *ptr;
+
+  if (NULL != (ptr=strchr(in, '@'))) {
+    return owl_strdup(in);
+  } else {
+    return owl_sprintf("%s@%s", in, owl_zephyr_get_realm());
+  }
+}
+
+
+/* strip out the instance from a zsender's principal.  Preserves the
+ * realm if present.  daemon.webzephyr is a special case.  The
+ * caller must free the return
+ */
+char *owl_zephyr_smartstripped_user(char *in)
+{
+  char *ptr, *realm, *out;
+
+  out=owl_strdup(in);
+
+  /* bail immeaditly if we don't have to do any work */
+  ptr=strchr(in, '.');
+  if (!strchr(in, '/') && !ptr) {
+    /* no '/' and no '.' */
+    return(out);
+  }
+  if (ptr && strchr(in, '@') && (ptr > strchr(in, '@'))) {
+    /* There's a '.' but it's in the realm */
+    return(out);
+  }
+  if (!strncasecmp(in, OWL_WEBZEPHYR_PRINCIPAL, strlen(OWL_WEBZEPHYR_PRINCIPAL))) {
+    return(out);
+  }
+
+  /* remove the realm from ptr, but hold on to it */
+  realm=strchr(out, '@');
+  if (realm) realm[0]='\0';
+
+  /* strip */
+  ptr=strchr(out, '.');
+  if (!ptr) ptr=strchr(out, '/');
+  ptr[0]='\0';
+
+  /* reattach the realm if we had one */
+  if (realm) {
+    strcat(out, "@");
+    strcat(out, realm+1);
+  }
+
+  return(out);
+}
