sprintf(logname, "accepting port %s", service);
snprintf(logname, sizeof(logname), "faithd %s", service); snprintf(procname, sizeof(procname), "accepting port %s", service);
main(int argc, char *argv[]){	struct addrinfo hints, *res;	int s_wld, error, i, serverargc, on = 1;	int family = AF_INET6;	int c;#ifdef FAITH_NS	char *ns;#endif /* FAITH_NS */	extern int optind;	extern char *optarg;	/*	 * Initializing stuff	 */	faithdname = strrchr(argv[0], '/');	if (faithdname)		faithdname++;	else		faithdname = argv[0];	while ((c = getopt(argc, argv, "dp46")) != -1) {		switch (c) {		case 'd':			dflag++;			break;		case 'p':			pflag++;			break;#ifdef FAITH4		case '4':			family = AF_INET;			break;		case '6':			family = AF_INET6;			break;#endif		default:			usage();			break;		}	}	argc -= optind;	argv += optind;#ifdef FAITH_NS	if ((ns = getenv(FAITH_NS)) != NULL) {		struct sockaddr_storage ss;		struct addrinfo hints, *res;		char serv[NI_MAXSERV];		memset(&ss, 0, sizeof(ss));		memset(&hints, 0, sizeof(hints));		sprintf(serv, "%u", NAMESERVER_PORT);		hints.ai_flags = AI_NUMERICHOST;		if (getaddrinfo(ns, serv, &hints, &res) ==  0) {			res_init();			memcpy(&_res_ext.nsaddr, res->ai_addr, res->ai_addrlen);			_res.nscount = 1;		}	}#endif /* FAITH_NS */#ifdef USE_ROUTE	grab_myaddrs();#endif	switch (argc) {	case 0:		serverpath = DEFAULT_PATH;		serverarg[0] = DEFAULT_NAME;		serverarg[1] = NULL;		service = DEFAULT_PORT_NAME;		break;	default:		serverargc = argc - NUMARG;		if (serverargc > MAXARGV)			exit_error("too many augments");		serverpath = malloc(strlen(argv[NUMPRG]));		strcpy(serverpath, argv[NUMPRG]);		for (i = 0; i < serverargc; i++) {			serverarg[i] = malloc(strlen(argv[i + NUMARG]));			strcpy(serverarg[i], argv[i + NUMARG]);		}		serverarg[i] = NULL;		/* fall throuth */	case 1:	/* no local service */		service = argv[NUMPRT];		break;	}	/*	 * Opening wild card socket for this service.	 */	memset(&hints, 0, sizeof(hints));	hints.ai_flags = AI_PASSIVE;	hints.ai_family = family;	hints.ai_socktype = SOCK_STREAM;	hints.ai_protocol = 0;	error = getaddrinfo(NULL, service, &hints, &res);	if (error) 		exit_error("getaddrinfo: %s", gai_strerror(error));	s_wld = socket(res->ai_family, res->ai_socktype, res->ai_protocol);	if (s_wld == -1)		exit_error("socket: %s", ERRSTR);#ifdef IPV6_FAITH	if (res->ai_family == AF_INET6) {		error = setsockopt(s_wld, IPPROTO_IPV6, IPV6_FAITH, &on, sizeof(on));		if (error == -1)			exit_error("setsockopt(IPV6_FAITH): %s", ERRSTR);	}#endif#ifdef FAITH4#ifdef IP_FAITH	if (res->ai_family == AF_INET) {		error = setsockopt(s_wld, IPPROTO_IP, IP_FAITH, &on, sizeof(on));		if (error == -1)			exit_error("setsockopt(IP_FAITH): %s", ERRSTR);	}#endif#endif /* FAITH4 */	error = setsockopt(s_wld, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));	if (error == -1)		exit_error("setsockopt(SO_REUSEADDR): %s", ERRSTR);		error = setsockopt(s_wld, SOL_SOCKET, SO_OOBINLINE, &on, sizeof(on));	if (error == -1)		exit_error("setsockopt(SO_OOBINLINE): %s", ERRSTR);	error = bind(s_wld, (struct sockaddr *)res->ai_addr, res->ai_addrlen);	if (error == -1)		exit_error("bind: %s", ERRSTR);	error = listen(s_wld, 5);	if (error == -1)		exit_error("listen: %s", ERRSTR);#ifdef USE_ROUTE	sockfd = socket(PF_ROUTE, SOCK_RAW, PF_UNSPEC);	if (sockfd < 0) {		exit_error("socket(PF_ROUTE): %s", ERRSTR);		/*NOTREACHED*/	}#endif	/*	 * Everything is OK.	 */	start_daemon();	sprintf(logname, "accepting port %s", service);	openlog(logname, LOG_PID | LOG_NOWAIT, LOG_DAEMON);	syslog(LOG_INFO, "Staring faith daemon for %s port", service);	play_service(s_wld);	/*NOTRECHED*/	exit(1);	/*pacify gcc*/}