free(envdup);
cvs_initlog(void){	int l;	u_int i;	char *env, *envdup, buf[MAXPATHLEN], fpath[MAXPATHLEN];	char rpath[MAXPATHLEN], *s;	struct stat st;	time_t now;	struct passwd *pwd;	/* avoid doing it more than once */	if (cvs_server_logon)		return (0);	env = getenv("CVS_CLIENT_LOG");	if (env == NULL)		return (0);	if ((envdup = strdup(env)) == NULL)		return (-1);	if ((s = strchr(envdup, '%')) != NULL)		*s = '\0';	strlcpy(buf, env, sizeof(buf));	strlcpy(rpath, envdup, sizeof(rpath));	s = buf;	while ((s = strchr(s, '%')) != NULL) {		*s++;		switch (*s) {		case 'c':			strlcpy(fpath, cvs_command, sizeof(fpath));			break;		case 'd':			time(&now);			strlcpy(fpath, ctime(&now), sizeof(fpath));			break;		case 'p':			snprintf(fpath, sizeof(fpath), "%d", getpid());			break;		case 'u':			if ((pwd = getpwuid(getuid())) != NULL)				strlcpy(fpath, pwd->pw_name, sizeof(fpath));			else				fpath[0] = '\0';			endpwent();			break;		default:			fpath[0] = '\0';			break;		}		if (fpath[0] != '\0') {			strlcat(rpath, "-", sizeof(rpath));			strlcat(rpath, fpath, sizeof(rpath));		}	}	for (i = 0; i < UINT_MAX; i++) {		l = snprintf(fpath, sizeof(fpath), "%s-%d.in", rpath, i);		if (l == -1 || l >= (int)sizeof(fpath)) {			errno = ENAMETOOLONG;			cvs_log(LP_ERRNO, "%s", fpath);			return (-1);		}		if (stat(fpath, &st) != -1)			continue;		if (errno != ENOENT)			return (-1);		break;	}	cvs_server_inlog = fopen(fpath, "w");	if (cvs_server_inlog == NULL) {		cvs_log(LP_ERRNO, "failed to open server input log `%s'",		    fpath);		return (-1);	}	for (i = 0; i < UINT_MAX; i++) {		l = snprintf(fpath, sizeof(fpath), "%s-%d.out", rpath, i);		if (l == -1 || l >= (int)sizeof(fpath)) {			errno = ENAMETOOLONG;			cvs_log(LP_ERRNO, "%s", fpath);			return (-1);		}		if (stat(fpath, &st) != -1)			continue;		if (errno != ENOENT)			return (-1);		break;	}	cvs_server_outlog = fopen(fpath, "w");	if (cvs_server_outlog == NULL) {		cvs_log(LP_ERRNO, "failed to open server output log `%s'",		    fpath);		return (-1);	}	/* make the streams line-buffered */	setvbuf(cvs_server_inlog, NULL, _IOLBF, 0);	setvbuf(cvs_server_outlog, NULL, _IOLBF, 0);	cvs_server_logon = 1;	return (0);}