Beispiel #1
0
void cmd_chmod(int argc, char **argv)
{
	int i;
	list *gl;
	listitem *li;

	OPT_HELP("Change permissions on remote file.  Usage:\n"
			 "  chmod [options] <mode> <file>\n"
			 "Options:\n"
			 "  -h, --help    show this help\n"
			 "<mode> is the permission mode, in octal (ex 644)\n");

	minargs(optind + 1);
	need_connected();
	need_loggedin();

	gl = rglob_create();
	for(i=optind+1; i<argc; i++) {
		stripslash(argv[i]);
		rglob_glob(gl, argv[i], true, true, NODOTDIRS);
	}

	for(li=gl->first; li; li=li->next) {
		if(ftp_chmod(((rfile *)li->data)->path, argv[optind]) != 0)
			printf("%s: %s\n", ((rfile *)li->data)->path, ftp_getreply(false));
	}
	rglob_destroy(gl);
}
Beispiel #2
0
void cmd_url(int argc, char **argv)
{
	int c;
	struct option longopts[] = {
		{"no-encoding", no_argument, 0, 'e'},
		{"help", no_argument, 0, 'h'},
		{0, 0, 0, 0}
	};
	bool no_encoding = false;

	optind = 0;
	while((c = getopt_long(argc, argv, "eh", longopts, 0)) != EOF) {
		switch(c) {
		  case 'h':
        show_help(_("Print the current URL."), "url [options]",
            _("  -e, --no-encoding    don't encode URL as RFC1738 says\n"));
			return;
		  case 'e':
			no_encoding = true;
			break;
		  case '?':
			return;
		}
	}

	maxargs(optind - 1);
	need_connected();
	need_loggedin();

	printf("ftp://");

	if(no_encoding) {
		printf("%s@%s", ftp->url->username, ftp->url->hostname);
		if(ftp->url->port != 21)
			printf(":%d", ftp->url->port);
		printf("/%s\n", ftp->curdir);
		return;
	}

	if(!url_isanon(ftp->url)) {
		char *e = encode_url_username(ftp->url->username);
		printf("%s@", e);
		free(e);
	}
	printf("%s", ftp->url->hostname);
	if(ftp->url->port != 21)
		printf(":%u", ftp->url->port);
	if(strcmp(ftp->curdir, ftp->homedir) != 0) {
		char *d;
		char *e = ftp->curdir;
#if 0
		if(strncmp(ftp->curdir, ftp->homedir, strlen(ftp->homedir)) == 0)
			e = ftp->curdir + strlen(ftp->homedir) + 1;
#endif
		d = encode_url_directory(e);
		printf("/%s", d);
		free(d);
	}
	printf("\n");
}
Beispiel #3
0
void cmd_cd(int argc, char **argv)
{
	char *e;
#if 0
	OPT_HELP("Change working directory.  Usage:\n"
			 "  cd [options] [directory]\n"
			 "Options:\n"
			 "  -h, --help    show this help\n"
			 "if [directory] is '-', cd changes to the previous working"
			 " directory\n"
			 "if omitted, changes to home directory\n");

	maxargs(optind);
#endif

	maxargs_nohelp(1);
	need_connected();
	need_loggedin();

	if(argc <= 1)
		e = ftp->homedir;
	else if(strcmp(argv[1], "-") == 0) {
		e = ftp->prevdir;
		if(e == 0) /* no previous directory */
			return;
	} else
		e = argv[1];
	e = tilde_expand_home(e, ftp->homedir);
	ftp_chdir(e);
	free(e);
}
Beispiel #4
0
void cmd_cat(int argc, char **argv)
{
	int i;
	struct option longopts[] = {
		{"type", required_argument, 0, 't'},
		{"help", no_argument, 0, 'h'},
		{0, 0, 0, 0}
	};
	int c;
	transfer_mode_t mode = tmAscii;

	optind = 0;
	while((c = getopt_long(argc, argv, "t:h", longopts, 0)) != EOF) {
		switch(c) {
		case 't':
			if(strncmp(optarg, "ascii", strlen(optarg)) == 0)
				mode = tmAscii;
			else if(strncmp(optarg, "binary", strlen(optarg)) == 0)
				mode = tmBinary;
			else {
				fprintf(stderr,
						_("Invalid option argument --type=%s\n"), optarg);
				return;
			}
			break;
		case 'h':
			fprintf(stderr, "Print file(s) on standard output.  Usage:\n"
					"  cat [options] <file>...\n"
					"Options:\n"
					"  -t, --type=TYPE    set transfer TYPE to ascii"
					" or binary\n"
					"  -h, --help         show this help\n");
			return;
		case '?':
			optind = -1;
			return;
		}
	}

	minargs(optind);
	need_connected();
	need_loggedin();

	for(i = optind; i < argc; i++) {
		listitem *gli;
		list *gl = rglob_create();
		stripslash(argv[i]);
		if(rglob_glob(gl, argv[i], true, false, 0) == -1)
			fprintf(stderr, _("%s: no matches found\n"), argv[i]);
		for(gli = gl->first; gli; gli=gli->next) {
			rfile *rf = (rfile *)gli->data;
			const char *fn = base_name_ptr(rf->path);
			if(strcmp(fn, ".") != 0 && strcmp(fn, "..") != 0) {
				ftp_receive(rf->path, stdout, mode, 0);
				fflush(stdout);
			}
		}
		rglob_destroy(gl);
	}
}
Beispiel #5
0
void cmd_nop(int argc, char **argv)
{
	OPT_HELP_NEW(_("Do nothing (send a NOOP command)."), "nop [options]", NULL);
	maxargs(optind - 1);
	need_connected();

	ftp_noop();
}
Beispiel #6
0
void cmd_cdup(int argc, char **argv)
{
	OPT_HELP_NEW(_("Change to parent working directory."), "cdup [options]", NULL);

  maxargs(optind - 1);
	need_connected();
	need_loggedin();
	ftp_cdup();
}
Beispiel #7
0
void cmd_pwd(int argc, char **argv)
{
  OPT_HELP_NEW(_("Print the current working directory."), "pwd [options]", NULL);

	maxargs(optind - 1);
	need_connected();
	need_loggedin();

	ftp_pwd();
}
Beispiel #8
0
void cmd_cache(int argc, char **argv)
{
	int c;
	struct option longopts[] = {
		{"clear", no_argument, 0, 'c'},
		{"list", no_argument, 0, 'l'},
		{"touch", no_argument, 0, 't'},
		{"help", no_argument, 0, 'h'},
		{0, 0, 0, 0}
	};
	bool touch = false;

	optind = 0;
	while((c = getopt_long(argc, argv, "clt::h", longopts, 0)) != EOF) {
		switch(c) {
		  case 'c':
			ftp_cache_clear();
			return;
		  case 'l':
			ftp_cache_list_contents();
			return;
		  case 't':
			  touch = true;
			  break;
		  case 'h':
			printf(_("Control the directory cache.  Usage:\n"
					 "  cache [option] [directories]\n"
					 "Options:\n"
					 "  -c, --clear        clear whole directory cache\n"
					 "  -l, --list         list contents of cache\n"
					 "  -t, --touch        remove directories from cache\n"
					 "                     if none given, remove current"
					 " directory\n"
					 "  -h, --help         show this help\n"));
			return;
		  case '?':
			return;
		}
	}

	need_connected();
	need_loggedin();

	if(touch) {
		if(optind < argc) {
			int i;
			for(i = optind; i < argc; i++)
				ftp_cache_flush_mark(argv[i]);
		} else
			ftp_cache_flush_mark(ftp->curdir);
	} else {
		minargs(1);
		maxargs(0);
	}
}
Beispiel #9
0
void cmd_cdup(int argc, char **argv)
{
	OPT_HELP("Change to parent working directory.  Usage:\n"
			 "  cdup [options]\n"
			 "Options:\n"
			 "  -h, --help    show this help\n");
	maxargs(optind - 1);
	need_connected();
	need_loggedin();
	ftp_cdup();
}
Beispiel #10
0
void cmd_nop(int argc, char **argv)
{
	OPT_HELP("Do nothing (send a NOOP command).  Usage:\n"
			 "  nop [options]\n"
			 "Options:\n"
			 "  -h, --help    show this help\n");
	maxargs(optind - 1);
	need_connected();

	ftp_noop();
}
Beispiel #11
0
void cmd_rmdir(int argc, char **argv)
{
	int i;
	OPT_HELP_NEW(_("Remove directory."), "rmdir [options]", NULL);
	minargs(optind);
	need_connected();
	need_loggedin();

	for(i=optind; i<argc; i++)
		ftp_rmdir(argv[i]);
}
Beispiel #12
0
void cmd_pwd(int argc, char **argv)
{
	OPT_HELP("Print the current working directory.  Usage:\n"
			 "  pwd [options]\n"
			 "Options:\n"
			 "  -h, --help     show this help\n");

	maxargs(optind - 1);
	need_connected();
	need_loggedin();

	ftp_pwd();
}
Beispiel #13
0
void cmd_mv(int argc, char **argv)
{
	OPT_HELP_NEW(_("Rename or move a file."), "mv [options] <src> <dest>", NULL);

	minargs(optind + 1);
	maxargs(optind + 1);
	need_connected();
	need_loggedin();

	ftp_set_tmp_verbosity(vbError);
	if(ftp_rename(argv[optind], argv[optind + 1]) == 0)
		printf("%s -> %s\n", argv[optind], argv[optind + 1]);
}
Beispiel #14
0
void cmd_idle(int argc, char **argv)
{
	OPT_HELP_NEW(_("Get or set idle timeout."), "idle [options] [timeout]",
	  _("Without the timeout option, print the current idle timeout\n"));
	maxargs(optind);
	need_connected();
	need_loggedin();

	if(argc - 1 == optind)
		ftp_idle(argv[optind]);
	else
		ftp_idle(0);
}
Beispiel #15
0
void cmd_rmdir(int argc, char **argv)
{
	int i;
	OPT_HELP("Remove directory.  Usage:\n"
			 "  rmdir [options]\n"
			 "Options:\n"
			 "  -h, --help    show this help\n");
	minargs(optind);
	need_connected();
	need_loggedin();

	for(i=optind; i<argc; i++)
		ftp_rmdir(argv[i]);
}
Beispiel #16
0
void cmd_rstatus(int argc, char **argv)
{
	OPT_HELP_NEW(_("Show status of remote host."), "rstatus [options]", NULL);
	maxargs(optind - 1);
	need_connected();

#ifdef HAVE_LIBSSH
	if(ftp->session) {
		printf("No status for SSH connection\n");
		return;
	}
#endif

	ftp_set_tmp_verbosity(vbCommand);
	ftp_cmd("STAT");
}
Beispiel #17
0
void cmd_nlist(int argc, char **argv)
{
	OPT_HELP_NEW(_("Simple file list."), "nlist [options] [file]", NULL);
	need_connected();
	need_loggedin();

	if(argc == optind + 1)
		ftp_list("NLST", 0, stdout);
	else {
		char *args;

		args = args_cat(argc, argv, optind);
		ftp_list("NLST", args, stdout);
		free(args);
	}
}
Beispiel #18
0
void cmd_idle(int argc, char **argv)
{
	OPT_HELP("Get or set idle timeout.  Usage:\n"
			 "  idle [options] [timeout]\n"
			 "Options:\n"
			 "  -h, --help    show this help\n"
			 "Without the timeout option, print the current idle timeout\n");
	maxargs(optind);
	need_connected();
	need_loggedin();

	if(argc - 1 == optind)
		ftp_idle(argv[optind]);
	else
		ftp_idle(0);
}
Beispiel #19
0
void cmd_mv(int argc, char **argv)
{
	OPT_HELP("Rename or move a file.  Usage:\n"
			 "  mv [options] <src> <dest>\n"
			 "Options:\n"
			 "  -h, --help    show this help\n");

	minargs(optind + 1);
	maxargs(optind + 1);
	need_connected();
	need_loggedin();

	ftp_set_tmp_verbosity(vbError);
	if(ftp_rename(argv[optind], argv[optind + 1]) == 0)
		printf("%s -> %s\n", argv[optind], argv[optind + 1]);
}
Beispiel #20
0
void cmd_filetime(int argc, char **argv)
{
	int i;

	OPT_HELP_NEW(_("Show modification time of remote file."), "filetime [options] <file>...", NULL);
	minargs(optind);
	need_connected();
	need_loggedin();

	for(i=optind;i<argc;i++) {
		time_t t = ftp_filetime(argv[i], true);
		if(t != (time_t) -1)
			printf("%s: %s", argv[i], ctime(&t));
		else
			printf("%s\n", ftp_getreply(false));
	}
}
Beispiel #21
0
void cmd_site(int argc, char **argv)
{
	char *e;

	minargs_nohelp(1);
	need_connected();

	if(ftp->ssh_pid) {
		printf("SITE commands not available in SSH connections\n");
		return;
	}

	e = args_cat(argc, argv, 1);
	ftp_set_tmp_verbosity(vbCommand);
	ftp_cmd("SITE %s", e);
	free(e);
}
Beispiel #22
0
void cmd_rstatus(int argc, char **argv)
{
	OPT_HELP("Show status of remote host.  Usage:\n"
			 "  rstatus [options]\n"
			 "Options:\n"
			 "  -h, --help    show this help\n");

	maxargs(optind - 1);
	need_connected();

	if(ftp->ssh_pid) {
		printf("No status for SSH connection\n");
		return;
	}

	ftp_set_tmp_verbosity(vbCommand);
	ftp_cmd("STAT");
}
Beispiel #23
0
void cmd_nlist(int argc, char **argv)
{
	OPT_HELP("Simple file list.  Usage:\n"
			 "  nlist [options] [file]\n"
			 "Options:\n"
			 "  -h, --help    show this help\n");
	need_connected();
	need_loggedin();

	if(argc == optind + 1)
		ftp_list("NLST", 0, stdout);
	else {
		char *args;

		args = args_cat(argc, argv, optind);
		ftp_list("NLST", args, stdout);
		free(args);
	}
}
Beispiel #24
0
void cmd_cd(int argc, char **argv)
{
	char *e;

	maxargs_nohelp(1);
	need_connected();
	need_loggedin();

	if(argc <= 1)
		e = ftp->homedir;
	else if(strcmp(argv[1], "-") == 0) {
		e = ftp->prevdir;
		if(e == 0) /* no previous directory */
			return;
	} else
		e = argv[1];
	e = tilde_expand_home(e, ftp->homedir);
	ftp_chdir(e);
	free(e);
}
Beispiel #25
0
void cmd_filetime(int argc, char **argv)
{
	int i;

	OPT_HELP("Show modification time of remote file.  Usage:\n"
			 "  filetime [options] <file>...\n"
			 "Options:\n"
			 "  -h, --help    show this help\n");

	minargs(optind);
	need_connected();
	need_loggedin();

	for(i=optind;i<argc;i++) {
		time_t t = ftp_filetime(argv[i]);
		if(t != (time_t) -1)
			printf("%s: %s", argv[i], ctime(&t));
		else
			printf("%s\n", ftp_getreply(false));
	}
}
Beispiel #26
0
void cmd_quote(int argc, char **argv)
{
	char *e;

	OPT_HELP_NEW(_("Send arbitrary FTP command."), "quote [options] <commands>", NULL);

	minargs(optind);
	need_connected();

#ifdef HAVE_LIBSSH
	if(ftp->session) {
		printf("Command not available in SSH connection\n");
		return;
	}
#endif

	e = args_cat(argc, argv, optind);
	ftp_set_tmp_verbosity(vbDebug);
	ftp_cmd("%s", e);
	free(e);
}
Beispiel #27
0
void cmd_quote(int argc, char **argv)
{
	char *e;

	OPT_HELP("Send arbitrary FTP command.  Usage:\n"
			 "  quote [options] <commands>\n"
			 "Options:\n"
			 "  -h, --help    show this help\n");

	minargs(optind);
	need_connected();

	if(ftp->ssh_pid) {
		printf("Command not available in SSH connection\n");
		return;
	}

	e = args_cat(argc, argv, optind);
	ftp_set_tmp_verbosity(vbDebug);
	ftp_cmd("%s", e);
	free(e);
}
Beispiel #28
0
void cmd_system(int argc, char **argv)
{
	if(argv) {
		OPT_HELP_NEW(_("Show type of remote system."), "system [options]\n", NULL);

		maxargs(optind - 1);
	}
	need_connected();
	need_loggedin();

#ifdef HAVE_LIBSSH
	if(ftp->session) {
		fprintf(stderr, "remote system: SSH (version %d)\n", ftp->ssh_version);
		return;
	}
#endif

	if(ftp_get_verbosity() != vbDebug)
		fprintf(stderr, _("remote system: "));
	ftp_set_tmp_verbosity(vbCommand);
	ftp_cmd("SYST");
}
Beispiel #29
0
void cmd_system(int argc, char **argv)
{
	if(argv) {
		OPT_HELP("Show type of remote system.  Usage:\n"
				 "  system [options]\n"
				 "Options:\n"
				 "  -h, --help    show this help\n");

		maxargs(optind - 1);
	}
	need_connected();
	need_loggedin();

	if(ftp->ssh_pid) {
		fprintf(stderr, "remote system: SSH (version %d)\n", ftp->ssh_version);
		return;
	}

	if(ftp_get_verbosity() != vbDebug)
		fprintf(stderr, _("remote system: "));
	ftp_set_tmp_verbosity(vbCommand);
	ftp_cmd("SYST");
}
Beispiel #30
0
void cmd_get(int argc, char **argv)
{
    list *gl;
    int opt=GET_VERBOSE, c;
    char *logfile = 0;
    pid_t pid;
    struct group *grp;
    char *get_output = 0;
    int stat_thresh = gvStatsThreshold;
#ifdef HAVE_REGEX
    int ret;
    char get_rx_errbuf[129];
#endif
    struct option longopts[] = {
        {"append", no_argument, 0, 'a'},
        {"chmod", required_argument, 0, 'c'},
        {"chgrp", required_argument, 0, '2'},
        {"no-dereference", no_argument, 0, 'd'},
        {"delete-after", no_argument, 0, 'D'},
        {"dir-mask", required_argument, 0, '3'},
#ifdef HAVE_REGEX
        {"dir-rx-mask", required_argument, 0, '4'},
#endif
        {"interactive", no_argument, 0, 'i'},
        {"skip-empty", no_argument, 0, 'e'},
        {"force", no_argument, 0, 'f'},
        {"force-newer", no_argument, 0, 'F'},
        {"logfile", required_argument, 0, 'L'},
        {"mask", required_argument, 0, 'm'},
#ifdef HAVE_REGEX
        {"rx-mask", required_argument, 0, 'M'},
#endif
        {"newer", no_argument, 0, 'n'},
        {"nohup", no_argument, 0, 'H'},
        {"verbose", no_argument, 0, 'v'},
        {"preserve", no_argument, 0, 'p'},
        {"parents", no_argument, 0, 'P'},
        {"quiet", no_argument, 0, 'q'},
        {"recursive", no_argument, 0, 'r'},
        {"resume", no_argument, 0, 'R'},
        {"skip-existing", no_argument, 0, 's'},
        {"stats", optional_argument, 0, 'S'},
        {"tagged", no_argument, 0, 't'},
        {"type", required_argument, 0, '1'},
        {"unique", no_argument, 0, 'u'},
        {"output", required_argument, 0, 'o'},
        {"help", no_argument, 0, 'h'},
        {0, 0, 0, 0},
    };

    if(cmod) {
        mode_free(cmod);
        cmod = 0;
    }

    if(get_glob_mask) {
        free(get_glob_mask);
        get_glob_mask = 0;
    }
    if(get_dir_glob_mask) {
        free(get_dir_glob_mask);
        get_dir_glob_mask = 0;
    }
#ifdef HAVE_REGEX
    if(get_rx_mask_set) {
        regfree(&get_rx_mask);
        get_rx_mask_set = 0;
    }
    if(get_dir_rx_mask_set) {
        regfree(&get_dir_rx_mask);
        get_dir_rx_mask_set = 0;
    }
#endif

    get_skip_empty = false;

    optind = 0; /* force getopt() to re-initialize */
    while((c=getopt_long(argc, argv, "abHc:dDeio:fFL:tnpPvqrRsuT:m:M:",
                         longopts, 0)) != EOF)
    {
        switch(c) {
          case 'a':
            opt |= GET_APPEND;
            break;
          case 'c':
            cmod = mode_compile(optarg, MODE_MASK_ALL);
            if(cmod == NULL) {
                fprintf(stderr, _("Invalid mode for --chmod: %s\n"), optarg);
                return;
            }
            opt |= GET_CHMOD;
            break;
        case '2': /* --chgrp */
            grp = getgrnam(optarg);
            if(grp == 0) {
                fprintf(stderr, _("%s is not a valid group name\n"), optarg);
                return;
            }
            {
                int i;
                for(i=0; grp->gr_mem && grp->gr_mem[i]; i++) {
                    if(strcmp(gvUsername, grp->gr_mem[i]) == 0)
                        break;
                }
                if(!grp->gr_mem[i]) {
                    fprintf(stderr,
                            _("you are not a member of group %s\n"), optarg);
                    return;
                }
            }
            group_change = grp->gr_gid;
            opt |= GET_CHGRP;
            break;
          case 'D':
            opt |= GET_DELETE_AFTER;
            break;
          case 'd':
            opt |= GET_NO_DEREFERENCE;
            break;
           case 'e':
              opt |= GET_SKIP_EMPTY;
              get_skip_empty = true;
              break;
        case '3': /* --dir-mask=GLOB */
            free(get_dir_glob_mask);
            get_dir_glob_mask = xstrdup(optarg);
            unquote(get_dir_glob_mask);
            break;
#ifdef HAVE_REGEX
        case '4': /* --dir-rx-mask=REGEXP */
            if(get_dir_rx_mask_set) {
                regfree(&get_dir_rx_mask);
                get_dir_rx_mask_set = false;
            }
            unquote(optarg);
            ret = regcomp(&get_dir_rx_mask, optarg, REG_EXTENDED);
            if(ret != 0) {
                regerror(ret, &get_dir_rx_mask, get_rx_errbuf, sizeof(get_rx_errbuf) - 1);
                ftp_err(_("Regexp '%s' failed: %s\n"), optarg, get_rx_errbuf);
                return;
            } else
                get_dir_rx_mask_set = true;
            break;
#endif
          case 'i':
            opt |= GET_INTERACTIVE;
            break;
          case 'f':
            opt |= GET_FORCE;
            break;
          case 'F':
            opt |= GET_FORCE_NEWER;
            break;
        case 'm': /* --mask */
            free(get_glob_mask);
            get_glob_mask = xstrdup(optarg);
            unquote(get_glob_mask);
            break;
#ifdef HAVE_REGEX
        case 'M': /* --rx-mask */
            if(get_rx_mask_set) {
                regfree(&get_rx_mask);
                get_rx_mask_set = false;
            }
            unquote(optarg);
            ret = regcomp(&get_rx_mask, optarg, REG_EXTENDED);
            if(ret != 0) {
                regerror(ret, &get_rx_mask, get_rx_errbuf, sizeof(get_rx_errbuf) - 1);
                ftp_err(_("Regexp '%s' failed: %s\n"), optarg, get_rx_errbuf);
                return;
            } else
                get_rx_mask_set = true;
            break;
#endif
          case 'o':
            get_output = tilde_expand_home(optarg, gvLocalHomeDir);
            /*stripslash(get_output);*/
            unquote(get_output);
            break;
          case 'v':
            opt |= GET_VERBOSE;
            break;
          case 'p':
            opt |= GET_PRESERVE;
            break;
          case 'P':
            opt |= GET_PARENTS;
            break;
          case 'H':
            opt |= GET_NOHUP;
            break;
          case 'q':
            opt &= ~GET_VERBOSE;
            break;
          case 'r':
            opt |= GET_RECURSIVE;
            break;
          case 's':
            opt |= GET_SKIP_EXISTING;
            break;
          case 'S':
            stat_thresh = optarg ? atoi(optarg) : 0;
            break;
          case 'R':
            opt |= GET_RESUME;
            break;
          case '1':
            if(strncmp(optarg, "ascii", strlen(optarg)) == 0)
                opt |= GET_ASCII;
            else if(strncmp(optarg, "binary", strlen(optarg)) == 0)
                opt |= GET_BINARY;
            else {
                printf(_("Invalid option argument --type=%s\n"), optarg);
                return;
            }
            break;
          case 'u':
            opt |= GET_UNIQUE;
            break;
          case 'L':
              free(logfile);
              logfile = xstrdup(optarg);
              unquote(logfile);
              break;
          case 't':
            opt |= GET_TAGGED;
            break;
          case 'n':
            opt |= GET_NEWER;
            break;
          case 'h':
            print_get_syntax();
            return;
          case '?':
            return;
        }
    }
    if(optind>=argc && !test(opt, GET_TAGGED)) {
        minargs(optind);
        return;
    }

    need_connected();
    need_loggedin();

    gl = rglob_create();
    while(optind < argc) {
        stripslash(argv[optind]);
        if(rglob_glob(gl, argv[optind], true, true, get_exclude_func) == -1)
            fprintf(stderr, _("%s: no matches found\n"), argv[optind]);
        optind++;
    }
    if(list_numitem(gl) == 0 && !test(opt, GET_TAGGED)) {
        rglob_destroy(gl);
        return;
    }
    if(test(opt, GET_TAGGED)
       && (!ftp->taglist || list_numitem(ftp->taglist)==0))
    {
        printf(_("no tagged files\n"));
        if(list_numitem(gl) == 0) {
            rglob_destroy(gl);
            return;
        }
    }

    get_quit = false;
    get_batch = get_owbatch = get_delbatch = test(opt, GET_FORCE);
    if(test(opt, GET_FORCE))
        opt &= ~GET_INTERACTIVE;

    if(get_output && !test(opt, GET_RECURSIVE) && list_numitem(gl) +
       (test(opt, GET_TAGGED) ? list_numitem(ftp->taglist) : 0) == 1)
        {
            /* if the argument to --output ends with a slash, we assume the
             * user wants the destination to be a directory
             */
            char *e = strrchr(get_output, 0);
            if(e && e[-1] != '/')
                opt |= GET_OUTPUT_FILE;
        }

    stats_reset(gvStatsTransfer);

    gvInTransfer = true;
    gvInterrupted = false;

    if(test(opt, GET_NOHUP)) {
        int r = 0;
        pid = fork();

        if(pid == 0) {
            r = transfer_init_nohup(logfile);
            if(r != 0)
                exit(0);
        }

        if(r != 0)
            return;

        if(pid == 0) { /* child process */
            transfer_begin_nohup(argc, argv);

            if(!test(opt, GET_FORCE) && !test(opt, GET_RESUME))
                opt |= GET_UNIQUE;
            opt |= GET_FORCE;

            if(list_numitem(gl))
                getfiles(gl, opt, get_output);
            rglob_destroy(gl);
            if(ftp->taglist && test(opt, GET_TAGGED))
                getfiles(ftp->taglist, opt, get_output);
            free(get_output);

            transfer_end_nohup();
        }
        if(pid == -1) {
            perror("fork()");
            return;
        }
        /* parent process */
        sleep(1);
        printf("%d\n", pid);
        input_save_history();
        gvars_destroy();
        reset_xterm_title();
        exit(0);
    }

    if(list_numitem(gl))
        getfiles(gl, opt, get_output);
    rglob_destroy(gl);
    if(ftp->taglist && test(opt, GET_TAGGED))
        getfiles(ftp->taglist, opt, get_output);
    free(get_output);
    mode_free(cmod);
    cmod = 0;
    gvInTransfer = false;

    stats_display(gvStatsTransfer, stat_thresh);
}