home *** CD-ROM | disk | FTP | other *** search
/ ftp.update.uu.se / ftp.update.uu.se.2014.03.zip / ftp.update.uu.se / pub / rainbow / cpm / emacs / emacssrc.lzh / ovwrit34.c < prev    next >
C/C++ Source or Header  |  1992-03-11  |  1KB  |  54 lines

  1. #include "stdio.h"
  2. #include "ed.h"
  3.  
  4. extern FILE * ffp;
  5. extern int ovreq, ovreq2, ovsub, ovsub2;
  6. extern char Argbuf[128];
  7.  
  8. /*
  9.  * This function performs the details of file
  10.  * writing. Sadly, it looks inside a LINE; Most of the grief is error
  11.  * checking of some sort.
  12.  * fopen() is in overlay 33! Too big!
  13.  */
  14. ovmain()
  15. {
  16.     register WINDOW * wp;
  17.     register int    s;
  18.     register LINE    *lp;
  19.     register int    nline;
  20.     char backname[NFILEN];
  21.  
  22.     s = TRUE;
  23.     if ( ffp == NULL) return (ctrlg());
  24.  
  25.     lp = lforw(curbp->b_linep);        /* First line.        */
  26.     nline = 0;                /* Number of lines.    */
  27.     while (lp != curbp->b_linep)
  28.     {    if ( fwrite( &lp->l_text[0], 1,
  29.             llength(lp), ffp) != llength(lp)
  30.         || putc( '\r', ffp ) == EOF
  31.         || putc( '\n', ffp ) == EOF )
  32.         {    s = FALSE;
  33.             mlwrite("Write I/O error");
  34.             break;
  35.         }
  36.         ++nline;
  37.         lp = lforw(lp);
  38.     }
  39.     putc( ('z'&0x1f), ffp );
  40.     fclose( ffp );
  41.     if (s == TRUE)
  42.     {    /* No write error. */
  43.         mlwrite("[Wrote %d lines]", nline);
  44.         curbp->b_flag &= ~BFCHG;
  45.         wp = wheadp;            /* Update mode lines.    */
  46.         while (wp != NULL)
  47.         {    if (wp->w_bufp == curbp)
  48.                 wp->w_flag |= WFMODE;
  49.             wp = wp->w_wndp;
  50.         }
  51.     }
  52.     return ( s );
  53. }
  54.