use_editline = 1;
main(argc, argv)	int argc;	char *argv[];{	struct servent *sp;	int ch, top, port, rval;	struct passwd *pw = NULL;	char *cp, homedir[MAXPATHLEN];	sp = getservbyname("ftp", "tcp");	if (sp == 0)		ftpport = htons(FTP_PORT);	/* good fallback */	else		ftpport = sp->s_port;	sp = getservbyname("http", "tcp");	if (sp == 0)		httpport = htons(HTTP_PORT);	/* good fallback */	else		httpport = sp->s_port;	doglob = 1;	interactive = 1;	autologin = 1;	passivemode = 0;	preserve = 1;	verbose = 0;	progress = 0;	mark = HASHBYTES;	marg_sl = sl_init();	use_editline = 1;	/* use editline if possible */	cp = strrchr(argv[0], '/');	cp = (cp == NULL) ? argv[0] : cp + 1;	if (strcmp(cp, "pftp") == 0)		passivemode = 1;	fromatty = isatty(fileno(stdin));	if (fromatty)		verbose = 1;		/* verbose if from a tty */	while ((ch = getopt(argc, argv, "adeginpPr:tvV")) != -1) {		switch (ch) {		case 'a':			anonftp = 1;			break;		case 'd':			options |= SO_DEBUG;			debug++;			break;		case 'e':			use_editline = 0;			break;		case 'g':			doglob = 0;			break;		case 'i':			interactive = 0;			break;		case 'n':			autologin = 0;			break;		case 'p':			passivemode = 1;			break;		case 'P':			port = atoi(optarg);			if (port <= 0)				warnx("bad port number: %s (ignored)", optarg);			else				ftpport = htons(port);			break;		case 'r':			if (isdigit(*optarg))				retry_connect = atoi(optarg);			else				errx(1, "-r requires numeric argument");			break;		case 't':			trace = 1;			break;		case 'v':			verbose = 1;			break;		case 'V':			verbose = 0;			break;		default:			usage();		}	}	argc -= optind;	argv += optind;	cpend = 0;	/* no pending replies */	proxy = 0;	/* proxy not active */	crflag = 1;	/* strip c.r. on ascii gets */	sendport = -1;	/* not using ports */	/*	 * Set up the home directory in case we're globbing.	 */	cp = getlogin();	if (cp != NULL) {		pw = getpwnam(cp);	}	if (pw == NULL)		pw = getpwuid(getuid());	if (pw != NULL) {		home = homedir;		(void)strcpy(home, pw->pw_dir);	}#ifndef SMALLFTP	editing = 0;			/* command line editing off */	if (fromatty && use_editline) {		editing = 1;		/* editing mode on if a tty */		el = el_init(__progname, stdin, stdout); /* init editline */		hist = history_init();		/* init the builtin history */		history(hist, H_EVENT, 100);	/* remember 100 events */		el_set(el, EL_HIST, history, hist);	/* use history */		el_set(el, EL_EDITOR, "emacs");	/* default editor is emacs */		el_set(el, EL_PROMPT, prompt);	/* set the prompt function */		/* add local file completion, bind to TAB */		el_set(el, EL_ADDFN, "ftp-complete",		    "Context sensitive argument completion",		    complete);		el_set(el, EL_BIND, "^I", "ftp-complete", NULL);		el_source(el, NULL);	/* read ~/.editrc */	}#endif /* !SMALLFTP */	setttywidth(0);	(void)signal(SIGWINCH, setttywidth);	if (argc > 0) {		if (strchr(argv[0], ':') != NULL) {			anonftp = 1;	/* Handle "automatic" transfers. */			rval = auto_fetch(argc, argv);			if (rval >= 0)		/* -1 == connected and cd-ed */				exit(rval);		} else {			char *xargv[5];			if (setjmp(toplevel))				exit(0);			(void)signal(SIGINT, (sig_t)intr);			(void)signal(SIGPIPE, (sig_t)lostpeer);			xargv[0] = __progname;			xargv[1] = argv[0];			xargv[2] = argv[1];			xargv[3] = argv[2];			xargv[4] = NULL;			do {				setpeer(argc+1, xargv);				if (!retry_connect)					break;				if (!connected) {					macnum = 0;					puts("Retrying...");					sleep(retry_connect);				}			} while (!connected);		}	}	top = setjmp(toplevel) == 0;	if (top) {		(void)signal(SIGINT, (sig_t)intr);		(void)signal(SIGPIPE, (sig_t)lostpeer);	}	for (;;) {		cmdscanner(top);		top = 1;	}}