rf = rcs_open(rcspath, RCS_MODE_READ);
rf = rcs_open(rcspath, RCS_READ);
cvs_diff_file(struct cvs_file *cfp, void *arg){	char *dir, *repo, buf[64];	char fpath[MAXPATHLEN], dfpath[MAXPATHLEN], rcspath[MAXPATHLEN];	char path_tmp1[MAXPATHLEN], path_tmp2[MAXPATHLEN];	BUF *b1, *b2;	RCSNUM *r1, *r2;	RCSFILE *rf;	struct diff_arg *dap;	struct cvs_ent *entp;	struct cvsroot *root;	dap = (struct diff_arg *)arg;	if (cfp->cf_type == DT_DIR) {		if (cfp->cf_cvstat == CVS_FST_UNKNOWN) {			root = cfp->cf_parent->cf_ddat->cd_root;			cvs_sendreq(root, CVS_REQ_QUESTIONABLE,			    CVS_FILE_NAME(cfp));		} else {			root = cfp->cf_ddat->cd_root;			if ((cfp->cf_parent == NULL) ||			    (root != cfp->cf_parent->cf_ddat->cd_root)) {				cvs_connect(root);				cvs_diff_sendflags(root, dap);			}			cvs_senddir(root, cfp);		}		return (0);	}	if (cfp->cf_cvstat == CVS_FST_LOST) {		cvs_log(LP_WARN, "cannot find file %s", CVS_FILE_NAME(cfp));		return (0);	}	rf = NULL;	diff_file = cvs_file_getpath(cfp, fpath, sizeof(fpath));	if (cfp->cf_parent != NULL) {		dir = cvs_file_getpath(cfp->cf_parent, dfpath, sizeof(dfpath));		root = cfp->cf_parent->cf_ddat->cd_root;		repo = cfp->cf_parent->cf_ddat->cd_repo;	} else {		dir = ".";		root = NULL;		repo = NULL;	}	if (cfp->cf_cvstat == CVS_FST_UNKNOWN) {		if (root->cr_method == CVS_METHOD_LOCAL)			cvs_log(LP_WARN, "I know nothing about %s", diff_file);		else			cvs_sendreq(root, CVS_REQ_QUESTIONABLE,			    CVS_FILE_NAME(cfp));		return (0);	}	entp = cvs_ent_getent(diff_file);	if (entp == NULL)		return (-1);	if (root->cr_method != CVS_METHOD_LOCAL) {		if (cvs_sendentry(root, entp) < 0) {			cvs_ent_free(entp);			return (-1);		}	}	if (cfp->cf_cvstat == CVS_FST_UPTODATE) {		if (root->cr_method != CVS_METHOD_LOCAL)			cvs_sendreq(root, CVS_REQ_UNCHANGED,			    CVS_FILE_NAME(cfp));		cvs_ent_free(entp);		return (0);	}	/* at this point, the file is modified */	if (root->cr_method != CVS_METHOD_LOCAL) {		cvs_sendreq(root, CVS_REQ_MODIFIED, CVS_FILE_NAME(cfp));		cvs_sendfile(root, diff_file);	} else {		snprintf(rcspath, sizeof(rcspath), "%s/%s/%s%s",		    root->cr_dir, repo, diff_file, RCS_FILE_EXT);		rf = rcs_open(rcspath, RCS_MODE_READ);		if (rf == NULL) {			cvs_ent_free(entp);			return (-1);		}		cvs_printf("Index: %s\n%s\nRCS file: %s\n", diff_file,		    RCS_DIFF_DIV, rcspath);		if (dap->rev1 == NULL)			r1 = entp->ce_rev;		else {			if ((r1 = rcsnum_parse(dap->rev1)) == NULL) {				cvs_ent_free(entp);				return (-1);			}		}		cvs_printf("retrieving revision %s\n",		    rcsnum_tostr(r1, buf, sizeof(buf)));		b1 = rcs_getrev(rf, r1);		if (r1 != entp->ce_rev)			rcsnum_free(r1);		if (dap->rev2 != NULL) {			cvs_printf("retrieving revision %s\n", dap->rev2);			if ((r2 = rcsnum_parse(dap->rev2)) == NULL) {				cvs_ent_free(entp);				return (-1);			}			b2 = rcs_getrev(rf, r2);			rcsnum_free(r2);		} else {			b2 = cvs_buf_load(diff_file, BUF_AUTOEXT);		}		rcs_close(rf);		printf("%s", diffargs);		printf(" -r%s", buf);		if (dap->rev2 != NULL)			printf(" -r%s", dap->rev2);		printf(" %s\n", diff_file);		strlcpy(path_tmp1, "/tmp/diff1.XXXXXXXXXX", sizeof(path_tmp1));		if (cvs_buf_write_stmp(b1, path_tmp1, 0600) == -1) {			cvs_buf_free(b1);			cvs_buf_free(b2);			return (-1);		}		cvs_buf_free(b1);		strlcpy(path_tmp2, "/tmp/diff2.XXXXXXXXXX", sizeof(path_tmp2));		if (cvs_buf_write_stmp(b2, path_tmp2, 0600) == -1) {			cvs_buf_free(b2);			(void)unlink(path_tmp1);			return (-1);		}		cvs_buf_free(b2);		cvs_diffreg(path_tmp1, path_tmp2);		(void)unlink(path_tmp1);		(void)unlink(path_tmp2);	}	cvs_ent_free(entp);	return (0);}