for (i = 0; i <= MAX_CLIENT; i++) {
for (i = 0; i < MAX_CLIENT; i++) {
main(int argc, char **argv){	int		c;	int		i, maxfd;	extern char	*optarg;	m_debug = DEFAULT_DEBUG_MASK;	l_debug = DEFAULT_LOGGING_LEVEL;	while ((c = getopt(argc, argv, "f:vDdl:")) != -1) {		switch (c) {		case 'f':			altqconfigfile = optarg;			break;		case 'D':	/* -D => dummy mode */			Debug_mode = 1;			printf("Debug mode set.\n");			break;		case 'v':			l_debug = LOG_DEBUG;			m_debug |= DEBUG_ALTQ;			daemonize = 0;			break;		case 'd':			daemonize = 0;			break;		case 'l':			l_debug = atoi(optarg);			break;		default:			usage();		}	}	signal(SIGINT, sig_int);	signal(SIGTERM, sig_term);	signal(SIGHUP, sig_hup);	signal(SIGPIPE, sig_pipe);	if (daemonize)		openlog("altqd", LOG_PID, LOG_DAEMON);	if (qcmd_init() != 0) {		if (daemonize)			closelog();		exit(1);	}	/*	 * open a unix domain socket for altqd clients	 */	if ((altqd_socket = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0)		LOG(LOG_ERR, errno, "can't open unix domain socket");	else {		struct sockaddr_un addr;		bzero(&addr, sizeof(addr));		addr.sun_family = AF_LOCAL;		strlcpy(addr.sun_path, QUIP_PATH, sizeof(addr.sun_path));		unlink(QUIP_PATH);		if (bind(altqd_socket, (struct sockaddr *)&addr,		    sizeof(addr)) < 0) {			LOG(LOG_ERR, errno, "can't bind to %s", QUIP_PATH);			close(altqd_socket);			altqd_socket = -1;		}		chmod(QUIP_PATH, 0666);		if (listen(altqd_socket, SOMAXCONN) < 0) {			LOG(LOG_ERR, errno, "can't listen to %s", QUIP_PATH);			close(altqd_socket);			altqd_socket = -1;		}	}	if (daemonize) {		FILE *fp;		daemon(0, 0);		/* save pid to the pid file (/var/tmp/altqd.pid) */		if ((fp = fopen(ALTQD_PID_FILE, "w")) != NULL) {			fprintf(fp, "%d\n", getpid());			fclose(fp);		} else			warn("can't open pid file: %s: %s",			    ALTQD_PID_FILE, strerror(errno));	} else {		/* interactive mode */		if (infile) {			if ((infp = fopen(infile, "r")) == NULL) {				perror("Cannot open input file");				exit(1);			}		} else {			infp = stdin;			printf("\nEnter ? or command:\n");			printf("altqd %s> ", cur_ifname());		}		fflush(stdout);	}	/*	 * go into the command mode.	 * the code below is taken from rtap of rsvpd.	 */	FD_ZERO(&fds);	maxfd = 0;	if (infp != NULL) {		FD_SET(fileno(infp), &fds);		maxfd = MAX(maxfd, fileno(infp) + 1);	}	if (altqd_socket >= 0) {		FD_SET(altqd_socket, &fds);		maxfd = MAX(maxfd, altqd_socket + 1);	}	while (1) {		int rc;		if (gotsig_hup) {			qcmd_destroyall();			gotsig_hup = 0;			printf("reinitializing altqd...\n");			qcmd_init();		}		if (gotsig_term) {			fprintf(stderr, "Exiting on signal %d\n", SIGTERM);			qcmd_destroyall();			/* if we have a pid file, remove it */			if (daemonize) {				unlink(ALTQD_PID_FILE);				closelog();			}			exit(0);		}		if (gotsig_int) {			fprintf(stderr, "Exiting on signal %d\n", SIGINT);			qcmd_destroyall();			/* if we have a pid file, remove it */			if (daemonize) {				unlink(ALTQD_PID_FILE);				closelog();			}			exit(0);		}		FD_COPY(&fds, &t_fds);		rc = select(maxfd, &t_fds, NULL, NULL, NULL);		if (rc < 0) {			if (errno != EINTR) {				perror("select");				exit(1);			}			continue;		}		/*		 * If there is control input, read the input line,		 * parse it, and execute.		 */		if (infp && FD_ISSET(fileno(infp), &t_fds)) {			rc = DoCommand(infile, infp);			if (rc == 0) {				/*				 * EOF on input.  If reading from file,				 * go to stdin; else exit.				 */				if (infile) {					infp = stdin;					infile = NULL;					printf("\nEnter ? or command:\n");					FD_SET(fileno(infp), &fds);				} else {					LOG(LOG_INFO, 0, "Exiting.");					(void) qcmd_destroyall();					exit(0);				}			} else if (infp == stdin)				printf("altqd %s> ", cur_ifname());			fflush(stdout);		} else if (altqd_socket >= 0 && FD_ISSET(altqd_socket, &t_fds)) {			/*			 * quip connection request from client via unix			 * domain socket; get a new socket for this			 * connection and add it to the select list.			 */			int newsock = accept(altqd_socket, NULL, NULL);			if (newsock == -1) {				LOG(LOG_ERR, errno, "accept");				continue;			}			FD_SET(newsock, &fds);			for (i = 0; i < MAX_CLIENT; i++)				if (client[i] == NULL) {					client[i] = fdopen(newsock, "r+");					break;				}			maxfd = MAX(maxfd, newsock + 1);		} else {			/*			 * check input from a client via unix domain socket			 */			for (i = 0; i <= MAX_CLIENT; i++) {				int fd;				if (client[i] == NULL)					continue;				fd = fileno(client[i]);				if (FD_ISSET(fd, &t_fds)) {					if (quip_input(client[i]) != 0 ||					    fflush(client[i]) != 0) {						/* connection closed */						fclose(client[i]);						client[i] = NULL;						FD_CLR(fd, &fds);					}				}			}		}	}}