home *** CD-ROM | disk | FTP | other *** search
- /* $Header: E:\SRC\UUPC\RN\RCS/LAST.C 1.1 1992/11/21 06:14:58 ahd Exp $
- *
- * $Log: LAST.C $
- * Revision 1.1 1992/11/21 06:14:58 ahd
- * Initial
- *
- *
- * Rev 1.0 18 Nov 1990 0:22:28
- * Initial revision.
- * Revision 4.3.2.1 89/12/20 23:23:07 sob
- * .rnlast sometimes is a null file. This gives bogus information when
- * restarting rn following an abnormal termination. This bug was reported
- * by weening@gang-of-four.stanford.edu
- *
- * Revision 4.3 85/05/01 11:42:16 lwall
- * Baseline for release with 4.3bsd.
- *
- */
-
- #include "EXTERN.h"
- #include "common.h"
- #include "rn.h"
- #include "util.h"
- #include "intrp.h"
- #include "INTERN.h"
- #include "last.h"
-
- char *lastname = Nullch; /* path name of .rnlast
- * file */
-
- void
- last_init(tcbuf)
- char *tcbuf;
- {
- lastname = savestr(filexp(LASTNAME));
- if ((tmpfp = fopen(lastname, "r")) != Nullfp &&
- fgets(tcbuf, 1024, tmpfp) != Nullch)
- {
- tcbuf[strlen(tcbuf) - 1] = '\0';
- lastngname = savestr(tcbuf);
- fgets(tcbuf, 1024, tmpfp);
- lasttime = atol(tcbuf);
- fgets(tcbuf, 1024, tmpfp);
- lastactsiz = atol(tcbuf);
- fclose(tmpfp);
- }
- else
- {
- lastngname = nullstr;
- lasttime = 0;
- lastactsiz = 0;
- }
- }
-
- /* put out certain values for next run of rn */
-
- void
- writelast()
- {
- if ((tmpfp = fopen(lastname, "w")) != Nullfp)
- {
- fprintf(tmpfp, "%s\n%ld\n%ld\n",
- (ngname == Nullch ? nullstr : ngname), (long) lasttime, (long) lastactsiz);
- fclose(tmpfp);
- }
- else
- printf(cantcreate, lastname) FLUSH;
- }
-