On Mon, Jan 19, 2004 at 05:44:20PM -0800, Wayne Davison wrote:
> I'll append my util.c patch to this email.

Or perhaps to this one...

..wayne..
--- util.c      2 Jan 2004 07:31:02 -0000       1.123
+++ util.c      20 Jan 2004 01:14:34 -0000
@@ -553,6 +553,36 @@ void strlower(char *s)
        }
 }
 
+/* Join any number of strings together, putting them in "dest".  The return
+ * value is the length of all the strings, regardless of whether they fit in
+ * destsize or not.  Just NULL-terminate the list of strings.  This function
+ * is _much_ faster than a comparable snprintf() call. */
+size_t stringjoin(char *dest, size_t destsize, ...)
+{
+       va_list ap;  
+       size_t len, ret = 0;
+       const char *src;
+
+       va_start(ap, destsize);
+       while (1) {
+               if (!(src = va_arg(ap, const char *)))
+                       break;
+               len = strlen(src);
+               ret += len;
+               if (destsize > 1) {
+                       if (len >= destsize)
+                               len = destsize - 1;
+                       memcpy(dest, src, len);
+                       destsize -= len;
+                       dest += len;
+               }
+       }
+       *dest = '\0';
+       va_end(ap);
+
+       return ret;
+}
+
 void clean_fname(char *name)
 {
        char *p;
-- 
To unsubscribe or change options: http://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html

Reply via email to