about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2017-07-30 14:15:15 -0400
committerJune McEnroe <june@causal.agency>2017-07-30 14:15:15 -0400
commitf48c10f46eab1c11827516a0610f7cd71d74bdad (patch)
tree5642eaee3da22677b315c89faaf2f60e76478b42
parentAssert stable struct Tile field offsets (diff)
downloadtorus-f48c10f46eab1c11827516a0610f7cd71d74bdad.tar.gz
torus-f48c10f46eab1c11827516a0610f7cd71d74bdad.zip
Add tile create and access timestamps
Diffstat (limited to '')
-rwxr-xr-xserver.c6
-rw-r--r--torus.h4
2 files changed, 7 insertions, 3 deletions
diff --git a/server.c b/server.c
index 7b16f33..e96d3dd 100755
--- a/server.c
+++ b/server.c
@@ -18,6 +18,7 @@ exec cc -Wall -Wextra -pedantic $@ -o server $0
 #include <sys/time.h>
 #include <sys/un.h>
 #include <sysexits.h>
+#include <time.h>
 #include <unistd.h>
 
 #include "torus.h"
@@ -37,11 +38,12 @@ static void tilesMap(void) {
 
 static struct Tile *tileGet(uint32_t tileX, uint32_t tileY) {
     struct Tile *tile = &tiles[tileY * TILE_ROWS + tileX];
-    if (!tile->present) {
+    if (!tile->create) {
         memset(tile->cells, ' ', CELLS_SIZE);
         memset(tile->colors, COLOR_WHITE, CELLS_SIZE);
-        tile->present = true;
+        tile->create = time(NULL);
     }
+    tile->access = time(NULL);
     return tile;
 }
 
diff --git a/torus.h b/torus.h
index bb012f2..968c9f6 100644
--- a/torus.h
+++ b/torus.h
@@ -2,6 +2,7 @@
 #include <stdbool.h>
 #include <stddef.h>
 #include <stdint.h>
+#include <time.h>
 
 #define ALIGNED(x) __attribute__((aligned(x)))
 
@@ -25,7 +26,8 @@ enum {
 #define CELL_INIT_Y (CELL_ROWS / 2)
 
 struct Tile {
-    bool present;
+    time_t create;
+    time_t access;
     char cells[CELL_ROWS][CELL_COLS] ALIGNED(16);
     uint8_t colors[CELL_ROWS][CELL_COLS] ALIGNED(16);
 } ALIGNED(4096);
alid delimiter: The value is a space-separated list of zero or more of the values "tar", "tar.gz", "tar.bz2", "tar.xz" and "zip". Supporting the undocumented delimiters makes the code unnecessarily complex. Remove them. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> 2014-01-10Replace most uses of strncmp() with prefixcmp()Lukas Fleischer This is a preparation for replacing all prefix checks with either strip_prefix() or starts_with() when Git 1.8.6 is released. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> 2014-01-09README: Fix dependenciesLukas Fleischer * Remove the dependency on Git (which can be obtained automatically when building, using either the Git submodule or `make get-git`). * Use proper upstream names of dependencies. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> 2014-01-08README: Spelling and formatting fixesLukas Fleischer * Several small spelling and capitalization fixes. * Use consistent and better-looking formatting that is compatible with AsciiDoc (and partly compatible with RST). Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> 2014-01-08Fix UTF-8 with syntax-highlighting.pyPřemysl Janouch Previously the script tried to encode output from Pygments with the ASCII codec, which failed. Signed-off-by: Přemysl Janouch <p.janouch@gmail.com> 2014-01-08Add a suggestion to the manpagePřemysl Janouch So that people wishing to use "enable-http-clone" don't have to find out the correct settings on their own. Signed-off-by: Přemysl Janouch <p.janouch@gmail.com> 2014-01-08Fix the example configurationPřemysl Janouch "enable-git-clone" doesn't exist, replaced with "enable-http-clone". Signed-off-by: Přemysl Janouch <p.janouch@gmail.com> 2014-01-08Fix about-formatting.shPřemysl Janouch dash failed to parse the script. Signed-off-by: Přemysl Janouch <p.janouch@gmail.com> 2014-01-08Fix some spelling errorsPřemysl Janouch Signed-off-by: Přemysl Janouch <p.janouch@gmail.com> 2014-01-08filters: highlight.sh: add css comments for highlight 2.6 and 3.8Ferry Huberts