modules/logger.cc
/*
	 * Resolve the hostname, and open() an appropriately named file to
	 * write the logs into.
	 */
Resolve the hostname, and open() an appropriately named file to
write the logs into.
Resolve the hostname and open () an appropriately named file to write the logs into .
logtarget(struct in6_addr *src)
	{
		int ret;
		struct sockaddr_in6 sa = {
			.sin6_family = AF_INET6,
			.sin6_port = 0,
		};
		memcpy(&sa.sin6_addr, src, sizeof(*src));
		ret = getnameinfo((const struct sockaddr *)&sa, sizeof(sa),
				hostname, sizeof(hostname) - 1, NULL, 0, NI_NAMEREQD);
		if (ret) {
			const char *ptr;
			fprintf(stderr, "getnameinfo failed: %s\n", gai_strerror(ret));
			ptr = inet_ntop(AF_INET6, src, hostname, INET6_ADDRSTRLEN);
			if (ptr == NULL) {
				fprintf(stderr, "inet_ntop failed: %s\n", strerror(errno));
				snprintf(hostname, 8, "unknown");
			}
		}
		ret = open(hostname, O_TRUNC|O_WRONLY|O_CREAT, 0644);
		if (ret == -1) {
			fprintf(stderr, "FATAL: open() failed: %m\n");
			abort();
		}
		fd = ret;
	}
logtarget ( struct in6_addr * src ) { int ret ; struct sockaddr_in6 sa = { . sin6_family = AF_INET6 , . sin6_port = 0 , } ; memcpy ( & sa . sin6_addr , src , sizeof ( * src ) ) ; ret = getnameinfo ( ( const struct sockaddr * ) & sa , sizeof ( sa ) , hostname , sizeof ( hostname ) - 1 , NULL , 0 , NI_NAMEREQD ) ; if ( ret ) { const char * ptr ; fprintf ( stderr , " \n " , gai_strerror ( ret ) ) ; ptr = inet_ntop ( AF_INET6 , src , hostname , INET6_ADDRSTRLEN ) ; if ( ptr == NULL ) { fprintf ( stderr , " \n " , strerror ( errno ) ) ; snprintf ( hostname , 8 , " " ) ; } } ret = open ( hostname , O_TRUNC | O_WRONLY | O_CREAT , 0644 ) ; if ( ret == -1 ) { fprintf ( stderr , " \n " ) ; abort ( ) ; } fd = ret ; }
Resolve the hostname, and open() an appropriately named file to
 write the logs into.
Resolve the hostname and open () an appropriately named file to write the logs into .