summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1998-05-13 15:44:04 +0000
committerAndrew Tridgell <tridge@samba.org>1998-05-13 15:44:04 +0000
commit874895d51a4b65e39762f06eea84b7d4a7755a3f (patch)
tree1aaa1061e0f36f4a653c4a75a554cacecc1fdeff /util.c
parentf855d1a309f38301bcd8898e9fbc5c70133d1f98 (diff)
downloadrsync-874895d51a4b65e39762f06eea84b7d4a7755a3f.tar.gz
rsync-874895d51a4b65e39762f06eea84b7d4a7755a3f.tar.bz2
rsync-874895d51a4b65e39762f06eea84b7d4a7755a3f.zip
added globbing support in the rsync daemon. This will allow you to
specify wildcards when grabbing files from a anon rsync daemon.
Diffstat (limited to 'util.c')
-rw-r--r--util.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/util.c b/util.c
index 7d15a8a6..8546e4a7 100644
--- 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
+}