home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / trn_12.zip / src / last.c < prev    next >
C/C++ Source or Header  |  1993-12-04  |  2KB  |  83 lines

  1. /* $Id: last.c,v 4.4.3.1 1992/02/01 03:09:32 sob PATCH_3 sob $
  2.  *
  3.  * $Log: last.c,v $
  4.  * Revision 4.4.3.1  1992/02/01  03:09:32  sob
  5.  * Release 4.4 Patchlevel 3
  6.  *
  7.  * Revision 4.4  1991/09/09  20:23:31  sob
  8.  * release 4.4
  9.  *
  10.  *
  11.  * 
  12.  */
  13. /* This software is Copyright 1991 by Stan Barber. 
  14.  *
  15.  * Permission is hereby granted to copy, reproduce, redistribute or otherwise
  16.  * use this software as long as: there is no monetary profit gained
  17.  * specifically from the use or reproduction of this software, it is not
  18.  * sold, rented, traded or otherwise marketed, and this copyright notice is
  19.  * included prominently in any copy made. 
  20.  *
  21.  * The author make no claims as to the fitness or correctness of this software
  22.  * for any use whatsoever, and it is provided as is. Any use of this software
  23.  * is at the user's own risk. 
  24.  */
  25.  
  26. #include "EXTERN.h"
  27. #include "common.h"
  28. #include "rn.h"
  29. #include "util.h"
  30. #include "intrp.h"
  31. #include "INTERN.h"
  32. #include "last.h"
  33.  
  34. char *lastname = Nullch;    /* path name of .rnlast file */
  35.  
  36. void
  37. last_init(tcbuf)
  38. char *tcbuf;
  39. {
  40.     lastname = savestr(filexp(LASTNAME));
  41.     if ((tmpfp = fos2open(lastname,"r")) != Nullfp &&
  42.     fgets(tcbuf,1024,tmpfp) != Nullch) {
  43.     tcbuf[strlen(tcbuf)-1] = '\0';
  44.     lastngname = savestr(tcbuf);
  45.     fgets(tcbuf,1024,tmpfp);
  46.     lasttime = atol(tcbuf);
  47.     fgets(tcbuf,1024,tmpfp);
  48.     lastactsiz = atol(tcbuf);
  49.     if (fgets(tcbuf,1024,tmpfp) != Nullch)
  50.         lastnewtime = atol(tcbuf);
  51.     else
  52.         lastnewtime = (lasttime? lasttime : time(Null(time_t*))-24L*60*60);
  53.     if (fgets(tcbuf,1024,tmpfp) != Nullch)
  54.         lastnewsize = atol(tcbuf);
  55.     else
  56.         lastnewsize = 0;
  57.     fclose(tmpfp);
  58.     }
  59.     else {
  60.     lastngname = nullstr;
  61.     lasttime = 0;
  62.     lastactsiz = 0;
  63.     lastnewsize = 0;
  64.     /* Use yesterday as an initial value for finding new groups. */
  65.     lastnewtime = time(Null(time_t*)) - 24L*60*60;
  66.     }
  67. }
  68.  
  69. /* put out certain values for next run of rn */
  70.  
  71. void
  72. writelast()
  73. {
  74.     if ((tmpfp = fos2open(lastname,"w")) != Nullfp) {
  75.     fprintf(tmpfp,"%s\n%ld\n%ld\n%ld\n%ld\n",
  76.         (ngname==Nullch?nullstr:ngname),(long)lasttime,(long)lastactsiz,
  77.         (long)lastnewtime,(long)lastnewsize);
  78.     fclose(tmpfp);
  79.     }
  80.     else
  81.     printf(cantcreate,lastname) ; FLUSH;
  82. }
  83.