home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / MISC / LO241SRV.ZIP / UPDATE.C < prev    next >
C/C++ Source or Header  |  1998-05-17  |  2KB  |  62 lines

  1.  
  2. // LoraBBS Version 2.41 Free Edition
  3. // Copyright (C) 1987-98 Marco Maccaferri
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation; either version 2 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. // GNU General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program; if not, write to the Free Software
  17. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19. #include <stdio.h>
  20. #include <io.h>
  21. #include <fcntl.h>
  22. #include <time.h>
  23.  
  24. #include <cxl\cxlvid.h>
  25.  
  26. #include "lsetup.h"
  27. #include "sched.h"
  28. #include "msgapi.h"
  29. #include "externs.h"
  30. #include "prototyp.h"
  31.  
  32. void update_last_caller()
  33. {
  34.    int fd, fdb;
  35.    char filename[80], backup[80];
  36.    long stamp;
  37.    struct _lastcall lc;
  38.  
  39.    stamp = time (NULL);
  40.    memset ((char *)&lastcall, 0, sizeof (struct _lastcall));
  41.  
  42.    sprintf (backup, "%sLASTCALL.BAK", config.sys_path);
  43.    sprintf (filename, "%sLASTCALL.BBS", config.sys_path);
  44.    unlink (backup);
  45.    rename (filename, backup);
  46.  
  47.    fdb = shopen (backup, O_RDONLY|O_BINARY);
  48.    if (fdb == -1)
  49.       return;
  50.  
  51.    fd = cshopen (filename, O_RDONLY|O_BINARY|O_CREAT, S_IREAD|S_IWRITE);
  52.  
  53.    while (read(fdo, (char *)&lc, sizeof(struct _lastcall)) == sizeof(struct _lastcall)) {
  54.       if (stamp - lc.timestamp < 86400L)
  55.          write (fd, (char *)&lc, sizeof (struct _lastcall));
  56.    }
  57.  
  58.    close (fd);
  59.    close (fdo);
  60. }
  61.  
  62.