home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / UUPC11XT.ZIP / RN / LAST.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-21  |  1.6 KB  |  69 lines

  1. /* $Header: E:\SRC\UUPC\RN\RCS/LAST.C 1.1 1992/11/21 06:14:58 ahd Exp $
  2.  *
  3.  * $Log: LAST.C $
  4.  * Revision 1.1  1992/11/21  06:14:58  ahd
  5.  * Initial
  6.  *
  7.  *
  8.  *    Rev 1.0   18 Nov 1990  0:22:28
  9.  * Initial revision.
  10.  * Revision 4.3.2.1  89/12/20  23:23:07  sob
  11.  * .rnlast sometimes is a null file. This gives bogus information when
  12.  * restarting rn following an abnormal termination. This bug was reported
  13.  * by weening@gang-of-four.stanford.edu
  14.  *
  15.  * Revision 4.3  85/05/01  11:42:16  lwall
  16.  * Baseline for release with 4.3bsd.
  17.  *
  18.  */
  19.  
  20. #include "EXTERN.h"
  21. #include "common.h"
  22. #include "rn.h"
  23. #include "util.h"
  24. #include "intrp.h"
  25. #include "INTERN.h"
  26. #include "last.h"
  27.  
  28. char *lastname = Nullch;     /* path name of .rnlast
  29.                               * file */
  30.  
  31. void
  32.   last_init(tcbuf)
  33.    char *tcbuf;
  34. {
  35.    lastname = savestr(filexp(LASTNAME));
  36.    if ((tmpfp = fopen(lastname, "r")) != Nullfp &&
  37.          fgets(tcbuf, 1024, tmpfp) != Nullch)
  38.    {
  39.       tcbuf[strlen(tcbuf) - 1] = '\0';
  40.       lastngname = savestr(tcbuf);
  41.       fgets(tcbuf, 1024, tmpfp);
  42.       lasttime = atol(tcbuf);
  43.       fgets(tcbuf, 1024, tmpfp);
  44.       lastactsiz = atol(tcbuf);
  45.       fclose(tmpfp);
  46.    }
  47.    else
  48.    {
  49.       lastngname = nullstr;
  50.       lasttime = 0;
  51.       lastactsiz = 0;
  52.    }
  53. }
  54.  
  55. /* put out certain values for next run of rn */
  56.  
  57. void
  58.   writelast()
  59. {
  60.    if ((tmpfp = fopen(lastname, "w")) != Nullfp)
  61.    {
  62.       fprintf(tmpfp, "%s\n%ld\n%ld\n",
  63.               (ngname == Nullch ? nullstr : ngname), (long) lasttime, (long) lastactsiz);
  64.       fclose(tmpfp);
  65.    }
  66.    else
  67.       printf(cantcreate, lastname) FLUSH;
  68. }
  69.