/* io for second unix cmd buffer 'plusbuffer' added - PLS UMIST 22/12/82 */ /* io for tab size and overtype flag added - PLS UMIST 28/2/84 */ #include "ded.h" #include "char.h" /************************************************************************ * * * copyright Richard Bornat 1981 * * * ************************************************************************/ /* procedures to open an old .dlog file and to create a new one. * The .dlog file contains information which enables ded to * return to precisely the same editing position on restart - * note that in order to do this ded must always return to 'input' * mode after each 'w' or 'reallywrite' command, which sets up * the new .dlog file */ int do_dlog(name, startfn, iomode, iofn, amax) char *name; int (*startfn)(); int iomode; int (*iofn)(); int *amax; { register int dlog; extern int esaveright; /* see map.c */ /* this read split into several parts because of restrictions inside the * appalling C compiler */ /* variables */ if ((dlog = (*startfn)(name, iomode)) == -1 || (*iofn)(dlog, &topl, sizeof topl) != sizeof topl || (*iofn)(dlog, amax, sizeof *amax) != sizeof *amax || (*iofn)(dlog, &in_c, sizeof in_c) != sizeof in_c || (*iofn)(dlog, &edit_c, sizeof edit_c) != sizeof edit_c || (*iofn)(dlog, &editright, sizeof editright) != sizeof editright || (*iofn)(dlog, &esaveright, sizeof esaveright) != sizeof esaveright) return(-1); else /* arrays and structures */ if ((*iofn)(dlog, erow, sizeof erow) != sizeof erow || (*iofn)(dlog, old_search, sizeof old_search) != sizeof old_search || (*iofn)(dlog, old_pat, sizeof old_search) != sizeof old_pat || (*iofn)(dlog, unixbuffer, sizeof unixbuffer) != sizeof unixbuffer || (*iofn)(dlog, plusbuffer, sizeof plusbuffer) != sizeof plusbuffer || (*iofn)(dlog, b_range, sizeof b_range) != sizeof b_range || (*iofn)(dlog, e_range, sizeof e_range) != sizeof e_range) return(-1); else /* more variables */ if ((*iofn)(dlog, &txin, sizeof txin) != sizeof txin || (*iofn)(dlog, &ringing, sizeof ringing) != sizeof ringing || (*iofn)(dlog, &tbout, sizeof tbout) != sizeof tbout || (*iofn)(dlog, &c_MODIFY, sizeof c_MODIFY) != sizeof c_MODIFY || (*iofn)(dlog, &tabsiz, sizeof tabsiz) != sizeof tabsiz || (*iofn)(dlog, &overtype, sizeof overtype) != sizeof overtype) return(-1); else return(dlog); } extern int read(), write(), open(), creat(); int open_dlog(name) char *name; { register int dlog; int oldmaxl; if ((dlog = do_dlog(name, open, 2, read, &oldmaxl)) != -1) while (oldmaxl > maxl) inc_maxl(); return(dlog); } int creat_dlog(name) char *name; { return(do_dlog(name, creat, 0666, write, &maxl)); }