/* * This function performs the details of file writing. Uses the file * management routines in the "fileio.c" package. The number of lines written * is displayed. Sadly, it looks inside a LINE; provide a macro for this. Most * of the grief is error checking of some sort. */ int writeout(char *fn) { LINE *lp; int nline, s; if ((s = ffwopen(fn)) != FIOSUC) /* Open writes message */ return (FALSE); mlwrite("[Writing]"); /* tell us were writing */ lp = lforw(curbp->b_linep); /* First line */ nline = 0; /* Number of lines */ while (lp != curbp->b_linep) { if ((s = ffputline(&lp->l_text[0], llength(lp))) != FIOSUC) break; ++nline; lp = lforw(lp); } if (s == FIOSUC) { /* No write error */ s = ffclose(); if (s == FIOSUC) { /* No close error */ if (nline != 1) mlwrite("[Wrote %d lines]", nline); else mlwrite("[Wrote 1 line]"); } } else /* ignore close error */ ffclose(); /* if a write error */ if (s != FIOSUC) /* some sort of error */ return (FALSE); return (TRUE); }
/* * This function performs the details of file * writing. Uses the file management routines in the * "fileio.c" package. The number of lines written is * displayed. Sadly, it looks inside a struct line; provide * a macro for this. Most of the grief is error * checking of some sort. */ int writeout(char *fn) { int s; struct line *lp; int nline; #if CRYPT s = resetkey(); if (s != TRUE) return s; #endif if ((s = ffwopen(fn)) != FIOSUC) { /* Open writes message. */ return FALSE; } mlwrite("(Writing...)"); /* tell us were writing */ lp = lforw(curbp->b_linep); /* First line. */ nline = 0; /* Number of lines. */ while (lp != curbp->b_linep) { if ((s = ffputline(&lp->l_text[0], llength(lp))) != FIOSUC) break; ++nline; lp = lforw(lp); } if (s == FIOSUC) { /* No write error. */ s = ffclose(); if (s == FIOSUC) { /* No close error. */ if (nline == 1) mlwrite("(Wrote 1 line)"); else mlwrite("(Wrote %d lines)", nline); } } else /* Ignore close error */ ffclose(); /* if a write error. */ if (s != FIOSUC) /* Some sort of error. */ return FALSE; return TRUE; }