rcs_errno = RCS_ERR_ERRNO;
rcs_write(RCSFILE *rfp){	FILE *fp;	char buf[1024], numbuf[64];	struct rcs_access *ap;	struct rcs_sym *symp;	struct rcs_branch *brp;	struct rcs_delta *rdp;	if (rfp->rf_flags & RCS_SYNCED)		return (0);	if ((fp = fopen(rfp->rf_path, "w")) == NULL) {		cvs_log(LP_ERRNO, "failed to open RCS output file `%s'",		    rfp->rf_path);		return (-1);	}	if (rfp->rf_head != NULL)		rcsnum_tostr(rfp->rf_head, numbuf, sizeof(numbuf));	else		numbuf[0] = '\0';	fprintf(fp, "head\t%s;\n", numbuf);	if (rfp->rf_branch != NULL) {		rcsnum_tostr(rfp->rf_branch, numbuf, sizeof(numbuf));		fprintf(fp, "branch\t%s;\n", numbuf);	}	fputs("access", fp);	TAILQ_FOREACH(ap, &(rfp->rf_access), ra_list) {		fprintf(fp, "\n\t%s", ap->ra_name);	}	fputs(";\n", fp);	fprintf(fp, "symbols\n");	TAILQ_FOREACH(symp, &(rfp->rf_symbols), rs_list) {		rcsnum_tostr(symp->rs_num, numbuf, sizeof(numbuf));		snprintf(buf, sizeof(buf), "%s:%s", symp->rs_name, numbuf);		fprintf(fp, "\t%s", buf);		if (symp != TAILQ_LAST(&(rfp->rf_symbols), rcs_slist))			fputc('\n', fp);	}	fprintf(fp, ";\n");	fprintf(fp, "locks;");	if (rfp->rf_flags & RCS_SLOCK)		fprintf(fp, " strict;");	fputc('\n', fp);	if (rfp->rf_comment != NULL) {		fputs("comment\t@", fp);		rcs_strprint(rfp->rf_comment, strlen(rfp->rf_comment), fp);		fputs("@;\n", fp);	}	if (rfp->rf_expand != NULL) {		fputs("expand @", fp);		rcs_strprint(rfp->rf_expand, strlen(rfp->rf_expand), fp);		fputs("@;\n", fp);	}	fputs("\n\n", fp);	TAILQ_FOREACH(rdp, &(rfp->rf_delta), rd_list) {		fprintf(fp, "%s\n", rcsnum_tostr(rdp->rd_num, numbuf,		    sizeof(numbuf)));		fprintf(fp, "date\t%d.%02d.%02d.%02d.%02d.%02d;",		    rdp->rd_date.tm_year + 1900, rdp->rd_date.tm_mon + 1,		    rdp->rd_date.tm_mday, rdp->rd_date.tm_hour,		    rdp->rd_date.tm_min, rdp->rd_date.tm_sec);		fprintf(fp, "\tauthor %s;\tstate %s;\n",		    rdp->rd_author, rdp->rd_state);		fputs("branches", fp);		TAILQ_FOREACH(brp, &(rdp->rd_branches), rb_list) {			fprintf(fp, " %s", rcsnum_tostr(brp->rb_num, numbuf,			    sizeof(numbuf)));		}		fputs(";\n", fp);		fprintf(fp, "next\t%s;\n\n", rcsnum_tostr(rdp->rd_next,		    numbuf, sizeof(numbuf)));	}	fputs("\ndesc\n@", fp);	if (rfp->rf_desc != NULL)		rcs_strprint(rfp->rf_desc, strlen(rfp->rf_desc), fp);	fputs("@\n\n", fp);	/* deltatexts */	TAILQ_FOREACH(rdp, &(rfp->rf_delta), rd_list) {		fprintf(fp, "\n%s\n", rcsnum_tostr(rdp->rd_num, numbuf,		    sizeof(numbuf)));		fputs("log\n@", fp);		rcs_strprint(rdp->rd_log, strlen(rdp->rd_log), fp);		fputs("@\ntext\n@", fp);		rcs_strprint(rdp->rd_text, rdp->rd_tlen, fp);		fputs("@\n\n", fp);	}	fclose(fp);	rfp->rf_flags |= RCS_SYNCED;	return (0);}