added globbing support in the rsync daemon. This will allow you to
[rsync/rsync.git] / util.c
diff --git a/util.c b/util.c
index 7d15a8a..8546e4a 100644 (file)
--- a/util.c
+++ b/util.c
@@ -504,3 +504,31 @@ int lock_range(int fd, int offset, int len)
        
        return fcntl(fd,F_SETLK,&lock) == 0;
 }
+
+
+void glob_expand(char **argv, int *argc, int maxargs)
+{
+#ifndef HAVE_GLOB
+       (*argc)++;
+       return;
+#else
+       glob_t globbuf;
+       int i;
+
+       rprintf(FINFO,"glob(%s) -> %d\n", argv[*argc], globbuf.gl_pathc);
+       memset(&globbuf, 0, sizeof(globbuf));
+       glob(argv[*argc], 0, NULL, &globbuf);
+       if (globbuf.gl_pathc == 0) {
+               (*argc)++;
+               globfree(&globbuf);
+               return;
+       }
+       for (i=0; i<(maxargs - (*argc)) && i<globbuf.gl_pathc;i++) {
+               if (i == 0) free(argv[*argc]);
+               argv[(*argc) + i] = strdup(globbuf.gl_pathv[i]);
+               if (!argv[(*argc) + i]) out_of_memory("glob_expand");
+       }
+       globfree(&globbuf);
+       (*argc) += i;
+#endif
+}