MCPcopy Index your code
hub / github.com/RsyncProject/rsync / glob_expand

Function glob_expand

util1.c:755–801  ·  view source on GitHub ↗

This routine performs wild-card expansion of the pathname in "arg". Any * daemon-excluded files/dirs will not be matched by the wildcards. Returns 0 * if a wild-card string is the only returned item (due to matching nothing). */

Source from the content-addressed store, hash-verified

753 * daemon-excluded files/dirs will not be matched by the wildcards. Returns 0
754 * if a wild-card string is the only returned item (due to matching nothing). */
755int glob_expand(const char *arg, char ***argv_p, int *argc_p, int *maxargs_p)
756{
757 int ret, save_argc;
758 char *s;
759
760 if (!arg) {
761 if (glob.filt_buf)
762 free(glob.filt_buf);
763 free(glob.arg_buf);
764 memset(&glob, 0, sizeof glob);
765 return -1;
766 }
767
768 if (sanitize_paths)
769 s = sanitize_path(NULL, arg, "", 0, SP_KEEP_DOT_DIRS);
770 else {
771 s = strdup(arg);
772 clean_fname(s, CFN_KEEP_DOT_DIRS | CFN_KEEP_TRAILING_SLASH | CFN_COLLAPSE_DOT_DOT_DIRS);
773 }
774
775 ENSURE_MEMSPACE(glob.arg_buf, char, glob.absize, MAXPATHLEN);
776 *glob.arg_buf = '\0';
777
778 glob.argc = save_argc = *argc_p;
779 glob.argv = *argv_p;
780 glob.maxargs = *maxargs_p;
781
782 ENSURE_MEMSPACE(glob.argv, char *, glob.maxargs, 100);
783
784 glob_match(s, 0, -1);
785
786 /* The arg didn't match anything, so add the failed arg to the list. */
787 if (glob.argc == save_argc) {
788 ENSURE_MEMSPACE(glob.argv, char *, glob.maxargs, glob.argc + 1);
789 glob.argv[glob.argc++] = s;
790 ret = 0;
791 } else {
792 free(s);
793 ret = 1;
794 }
795
796 *maxargs_p = glob.maxargs;
797 *argv_p = glob.argv;
798 *argc_p = glob.argc;
799
800 return ret;
801}
802
803/* This routine is only used in daemon mode. */
804void glob_expand_module(char *base1, char *arg, char ***argv_p, int *argc_p, int *maxargs_p)

Callers 2

glob_expand_moduleFunction · 0.85
read_argsFunction · 0.85

Calls 3

sanitize_pathFunction · 0.85
clean_fnameFunction · 0.85
glob_matchFunction · 0.85

Tested by

no test coverage detected