home *** CD-ROM | disk | FTP | other *** search
- /* $Header: last.c,v 4.3.3.1 91/01/16 02:47:15 davison Trn $
- *
- * $Log: last.c,v $
- * Revision 4.3.3.1 91/01/16 02:47:15 davison
- * Integrated rn patches 48-54.
- *
- * 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;
- }
-