while ((ch = getopt(argc, argv, "dlt:T:u:Uv")) != EOF) {
while ((ch = getopt(argc, argv, argstr)) != EOF) {
static char	*sgetsave __P((char *));static char *curdir(){	static char path[MAXPATHLEN+1+1];	/* path + '/' + '\0' */	if (getcwd(path, sizeof(path)-2) == NULL)		return ("");	if (path[1] != '\0')		/* special case for root dir. */		strcat(path, "/");	/* For guest account, skip / since it's chrooted */	return (guest ? path+1 : path);}intmain(argc, argv, envp)	int argc;	char *argv[];	char **envp;{	int addrlen, ch, on = 1, tos;	char *cp, line[LINE_MAX];	FILE *fd;	/*	 * LOG_NDELAY sets up the logging connection immediately,	 * necessary for anonymous ftp's that chroot and can't do it later.	 */	openlog("ftpd", LOG_PID | LOG_NDELAY, LOG_FTP);	addrlen = sizeof(his_addr);	if (getpeername(0, (struct sockaddr *)&his_addr, &addrlen) < 0) {		syslog(LOG_ERR, "getpeername (%s): %m",argv[0]);		exit(1);	}	addrlen = sizeof(ctrl_addr);	if (getsockname(0, (struct sockaddr *)&ctrl_addr, &addrlen) < 0) {		syslog(LOG_ERR, "getsockname (%s): %m",argv[0]);		exit(1);	}#ifdef IP_TOS	tos = IPTOS_LOWDELAY;	if (setsockopt(0, IPPROTO_IP, IP_TOS, (char *)&tos, sizeof(int)) < 0)		syslog(LOG_WARNING, "setsockopt (IP_TOS): %m");#endif	data_source.sin_port = htons(ntohs(ctrl_addr.sin_port) - 1);	debug = 0;	/* set this here so klogin can use it... */	(void)snprintf(ttyline, sizeof(ttyline), "ftp%d", getpid());	while ((ch = getopt(argc, argv, "dlt:T:u:Uv")) != EOF) {		switch (ch) {		case 'd':			debug = 1;			break;		case 'l':			logging++;	/* > 1 == extra logging */			break;		case 't':			timeout = atoi(optarg);			if (maxtimeout < timeout)				maxtimeout = timeout;			break;		case 'T':			maxtimeout = atoi(optarg);			if (timeout > maxtimeout)				timeout = maxtimeout;			break;		case 'u':		    {			long val = 0;			val = strtol(optarg, &optarg, 8);			if (*optarg != '\0' || val < 0)				warnx("bad value for -u");			else				defumask = val;			break;		    }		case 'U':			doutmp = 1;			break;		case 'v':			debug = 1;			break;		default:			warnx("unknown flag -%c ignored", optopt);			break;		}	}	(void) freopen(_PATH_DEVNULL, "w", stderr);	(void) signal(SIGPIPE, lostconn);	(void) signal(SIGCHLD, SIG_IGN);	if ((long)signal(SIGURG, myoob) < 0)		syslog(LOG_ERR, "signal: %m");	/* Try to handle urgent data inline */#ifdef SO_OOBINLINE	if (setsockopt(0, SOL_SOCKET, SO_OOBINLINE, (char *)&on, sizeof(on)) < 0)		syslog(LOG_ERR, "setsockopt: %m");#endif#ifdef	F_SETOWN	if (fcntl(fileno(stdin), F_SETOWN, getpid()) == -1)		syslog(LOG_ERR, "fcntl F_SETOWN: %m");#endif	dolog(&his_addr);	/*	 * Set up default state	 */	data = -1;	type = TYPE_A;	form = FORM_N;	stru = STRU_F;	mode = MODE_S;	tmpline[0] = '\0';	/* If logins are disabled, print out the message. */	if ((fd = fopen(_PATH_NOLOGIN,"r")) != NULL) {		while (fgets(line, sizeof(line), fd) != NULL) {			if ((cp = strchr(line, '\n')) != NULL)				*cp = '\0';			lreply(530, "%s", line);		}		(void) fflush(stdout);		(void) fclose(fd);		reply(530, "System not available.");		exit(0);	}	if ((fd = fopen(_PATH_FTPWELCOME, "r")) != NULL) {		while (fgets(line, sizeof(line), fd) != NULL) {			if ((cp = strchr(line, '\n')) != NULL)				*cp = '\0';			lreply(220, "%s", line);		}		(void) fflush(stdout);		(void) fclose(fd);		/* reply(220,) must follow */	}	(void) gethostname(hostname, sizeof(hostname));	reply(220, "%s FTP server (%s) ready.", hostname, version);	(void) setjmp(errcatch);	for (;;)		(void) yyparse();	/* NOTREACHED */}static voidlostconn(signo)	int signo;{	if (debug)		syslog(LOG_DEBUG, "lost connection");	dologout(-1);}/* * Helper function for sgetpwnam(). */static char *sgetsave(s)	char *s;{	char *new = malloc((unsigned) strlen(s) + 1);	if (new == NULL) {		perror_reply(421, "Local resource failure: malloc");		dologout(1);		/* NOTREACHED */	}	(void) strcpy(new, s);	return (new);}