get(2, xargv);
if (dirhasglob || filehasglob) { int ointeractive;
auto_fetch(argc, argv)	int argc;	char *argv[];{	static char lasthost[MAXHOSTNAMELEN];	char *xargv[5];	char *cp, *line, *host, *dir, *file, *portnum;	int rval, xargc, argpos;	argpos = 0;	if (setjmp(toplevel)) {		if (connected)			disconnect(0, NULL);		return (argpos + 1);	}	(void)signal(SIGINT, (sig_t)intr);	(void)signal(SIGPIPE, (sig_t)lostpeer);	/*	 * Loop through as long as there's files to fetch.	 */	for (rval = 0; (rval == 0) && (argpos < argc); free(line), argpos++) {		if (strchr(argv[argpos], ':') == NULL)			break;		host = dir = file = portnum = NULL;		/*		 * We muck with the string, so we make a copy.		 */		line = strdup(argv[argpos]);		if (line == NULL)			errx(1, "Can't allocate memory for auto-fetch.");		/*		 * Try HTTP URL-style arguments first.		 */		if (strncmp(line, HTTP_URL, sizeof(HTTP_URL) - 1) == 0) {			if (http_get(line) == -1)				rval = argpos + 1;			continue;		}		/*		 * Try FTP URL-style arguments next, then host:file.		 */		host = line;		if (strncmp(line, FTP_URL, sizeof(FTP_URL) - 1) == 0) {			host += sizeof(FTP_URL) - 1;			cp = strchr(host, '/');			/* Look for a port number after the host name. */			portnum = strchr(host, ':');			if (portnum != NULL)				*portnum++ = '\0';		} else				/* classic style `host:file' */			cp = strchr(host, ':');		if (EMPTYSTRING(host)) {			rval = argpos + 1;			continue;		}		/*		 * If cp is NULL, the file wasn't specified		 * (URL looked something like ftp://host)		 */		if (cp != NULL)			*cp++ = '\0';		/*		 * Extract the file and (if present) directory name.		 */		dir = cp;		if (! EMPTYSTRING(dir)) {			cp = strrchr(cp, '/');			if (cp != NULL) {				*cp++ = '\0';				file = cp;			} else {				file = dir;				dir = NULL;			}		}		if (debug)			printf("host '%s', dir '%s', file '%s'\n",			    host, dir, file);		/*		 * Set up the connection if we don't have one.		 */		if (strcmp(host, lasthost) != 0) {			strcpy(lasthost, host);			if (connected)				disconnect(0, NULL);			xargv[0] = __progname;			xargv[1] = host;			xargv[2] = NULL;			xargc = 2;			if (portnum != NULL) {				xargv[2] = portnum;				xargv[3] = NULL;				xargc = 3;			}			setpeer(xargc, xargv);			if (connected == 0) {				warnx("Can't connect to host `%s'", host);				rval = argpos + 1;				continue;			}			/* Always use binary transfers. */			setbinary(0, NULL);		}		else	/* already have connection, cd back to '/' */		{			xargv[0] = "cd";			xargv[1] = "/";			xargv[2] = NULL;			cd(2, xargv);			if (! dirchange) {				rval = argpos + 1;				continue;			}		}		/* Change directories, if necessary. */		if (! EMPTYSTRING(dir)) {			xargv[0] = "cd";			xargv[1] = dir;			xargv[2] = NULL;			cd(2, xargv);			if (! dirchange) {				rval = argpos + 1;				continue;			}		}		if (EMPTYSTRING(file)) {			rval = -1;			continue;		}		if (!verbose)			printf("Retrieving %s/%s\n", dir ? dir : "", file);		/* Fetch the file. */		xargv[0] = "get";		xargv[1] = file;		xargv[2] = NULL;		get(2, xargv);		if ((code / 100) != COMPLETE)	/* XXX: is this valid? */			rval = argpos + 1;	}	if (connected && rval != -1)		disconnect(0, NULL);	return (rval);}