]> git.pond.sub.org Git - empserver/blobdiff - include/file.h
Update known contributors comments
[empserver] / include / file.h
index d73ee6cd84b913bf42e1066f47dd71c7a9cb097d..f66dd3ba5ddcb45163bfab387ae3805afadc33f3 100644 (file)
@@ -1,11 +1,11 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
- *                           Ken Stevens, Steve McClure
+ *  Copyright (C) 1986-2011, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *                Ken Stevens, Steve McClure, Markus Armbruster
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  Empire is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation, either version 3 of the License, or
  *  (at your option) any later version.
  *
  *  This program is distributed in the hope that it will be useful,
@@ -14,8 +14,7 @@
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  *  ---
  *
@@ -26,9 +25,9 @@
  *  ---
  *
  *  file.h: Describes Empire tables (`files' for historical reasons)
- * 
+ *
  *  Known contributors to this file:
- *     Markus Armbruster, 2005-2008
+ *     Markus Armbruster, 2005-2010
  */
 
 #ifndef FILE_H
@@ -60,6 +59,10 @@ struct empfile {
     /* flags bit EFF_CUSTOM also varies */
 
     /* User callbacks, may all be null */
+    /*
+     * Called after element initialization.  ELT is the element.
+     */
+    void (*oninit)(void *elt);
     /*
      * Called after read.  ID is the element id, and ELT is the
      * element read.  May modify the element.  Modifications are
@@ -67,18 +70,24 @@ struct empfile {
      */
     void (*postread)(int id, void *elt);
     /*
-     * Called before write.  ID is the element id, and ELT is the
-     * element being written.  May modify the element.  Modifications
-     * will be visible to caller of ef_write() and are written to the
-     * file.
+     * Called before write.  ID is the element id, OLD is the element
+     * being updated (null unless it is cached) and ELT is the element
+     * being written.  May modify the element.  Modifications will be
+     * visible to caller of ef_write() and are written to the file.
+     */
+    void (*prewrite)(int id, void *old, void *elt);
+    /*
+     * Called after table size changed, with file type as argument.
+     * Return -1 and set errno to make the operation fail.
      */
-    void (*prewrite)(int id, void *elt);
+    int (*onresize)(int type);
 };
 
 struct emptypedstr {
-    short ef_type;
-    short uid;
-    unsigned seqno;
+    signed ef_type: 8;
+    unsigned seqno: 12;
+    unsigned generation: 12;
+    int uid;
     time_t timestamp;
 };
 
@@ -89,7 +98,7 @@ struct emptypedstr {
  */
 /* Immutable flags, fixed at compile-time */
 /* Dereferencing entry address cast to struct emptypedstr * is safe */
-#define EFF_TYPED      bit(0)
+#define EFF_TYPED      bit(0)
 /*
  * EFF_XY / EFF_OWNER / EFF_GROUP assert that coordinates / owner /
  * group of such a table's entries can be safely obtained by
@@ -194,6 +203,8 @@ enum {
 
 extern struct castr *ef_cadef(int);
 extern int ef_read(int, int, void *);
+extern void ef_make_stale(void);
+extern void ef_mark_fresh(int, void *);
 extern void *ef_ptr(int, int);
 extern char *ef_nameof(int);
 extern time_t ef_mtime(int);