remove old tmp files
[unix-history] / usr / src / games / sail / sync.c
index 57e4cf0..251c8ae 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)sync.c      1.2 83/10/14";
+static char *sccsid = "@(#)sync.c      1.6 83/10/28";
 #endif
 
 #include "externs.h"
 #endif
 
 #include "externs.h"
@@ -30,12 +30,23 @@ register struct ship *ship;
        Write(W_SIGNAL, from, 1, (int)message, 0, 0, 0);
 }
 
        Write(W_SIGNAL, from, 1, (int)message, 0, 0, 0);
 }
 
+#include <sys/types.h>
+#include <sys/stat.h>
 sync_exists(game)
 {
        char buf[sizeof sync_file];
 sync_exists(game)
 {
        char buf[sizeof sync_file];
+       struct stat s;
+       time_t t;
 
        (void) sprintf(buf, SF, game);
 
        (void) sprintf(buf, SF, game);
-       return access(buf, 0) >= 0;
+       time(&t);
+       if (stat(buf, &s) < 0)
+               return 0;
+       if (s.st_mtime < t - 60*60*2) {         /* 2 hours */
+               unlink(buf);
+               return 0;
+       } else
+               return 1;
 }
 
 sync_open()
 }
 
 sync_open()
@@ -56,6 +67,7 @@ sync_open()
        if (sync_fp == 0)
                return -1;
        sync_seek == 0;
        if (sync_fp == 0)
                return -1;
        sync_seek == 0;
+       return 0;
 }
 
 sync_close(remove)
 }
 
 sync_close(remove)
@@ -166,15 +178,9 @@ int a, b, c, d;
                break;
                }
        case W_SIGNAL:
                break;
                }
        case W_SIGNAL:
-               /*
-               (void) putchar('\7');
-               */
-               Signal("%s (%c%c): %s", ship, a);
-               /*
-               (void) strncpy(ship->file->signal, (char *)a,
-                       sizeof ship->file->signal - 1);
-               ship->file->signal[sizeof ship->file->signal - 1] = 0;
-               */
+               if (isplayer) {
+                       Signal("\7%s (%c%c): %s", ship, a);
+               }
                break;
        case W_CREW: {
                register struct shipspecs *s = ship->specs;
                break;
        case W_CREW: {
                register struct shipspecs *s = ship->specs;