]> git.pond.sub.org Git - empserver/blob - include/file.h
Indented with src/scripts/indent-emp.
[empserver] / include / file.h
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
4  *                           Ken Stevens, Steve McClure
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  *  ---
21  *
22  *  See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23  *  related information and legal notices. It is expected that any future
24  *  projects/authors will amend these files as needed.
25  *
26  *  ---
27  *
28  *  file.h: Describes Empire files and their contents
29  * 
30  *  Known contributors to this file:
31  *    
32  */
33
34 #ifndef _FILE_H_
35 #define _FILE_H_
36
37 struct empfile {
38     s_char *name;               /* file name (e.g., "treaty") */
39     s_char *file;               /* file path */
40     int flags;                  /* misc stuff */
41     int mode;                   /* O_flags */
42     int size;                   /* size of object */
43     void (*init) (int, s_char *);       /* call this when object is created */
44     int (*postread) (int, s_char *);    /* specific massage routines for items */
45     int (*prewrite) (int, s_char *);
46     int varoffs[3];             /* struct offs for nv, vtype, vamt */
47     int maxvars;                /* max # vars for type */
48     int fd;                     /* file descriptor */
49     int baseid;                 /* starting item in cache */
50     int cids;                   /* # ids in cache */
51     int csize;                  /* size of cache in bytes */
52     caddr_t cache;              /* pointer to cache */
53     int fids;                   /* # of ids in file */
54     struct castr *cadef;        /* ca defs selection list */
55 };
56
57 #define EFF_COM         bit(0)  /* item has commodities attached */
58 #define EFF_XY          bit(1)  /* has location */
59 #define EFF_MEM         bit(2)  /* stored entirely in-memory */
60 #define EFF_OWNER       bit(3)  /* has concept of owner */
61 #define EFF_GROUP       bit(4)  /* has concept of group */
62
63 #define EF_BAD          -1      /* illegal file type */
64 #define EF_SECTOR       0
65 #define EF_SHIP         1
66 #define EF_PLANE        2
67 #define EF_LAND         3
68 #define EF_NUKE         4
69 #define EF_NEWS         5
70 #define EF_TREATY       6
71 #define EF_TRADE        7
72 #define EF_POWER        8
73 #define EF_NATION       9
74 #define EF_LOAN         10
75 #define EF_MAP          11
76 #define EF_BMAP         12
77 #define EF_COMM         13
78 #define EF_LOST         14
79 #define EF_MAX          15
80
81 #define EF_NMAP         222     /* Kinda bogus, but used to describe a newdesmap
82                                    instead of bmap or map. */
83
84 typedef void (*ef_fileinit) (int, s_char *);
85
86 struct fileinit {
87     void (*init) (int, s_char *);
88     int (*postread) (int, s_char *);
89     int (*prewrite) (int, s_char *);
90     struct castr *cadef;
91 };
92
93
94 extern struct castr *ef_cadef(int);
95 extern int ef_read(int, int, caddr_t);
96 extern s_char *ef_ptr(int, int);
97 extern s_char *ef_nameof(int);
98 extern time_t ef_mtime(int);
99 extern int ef_open(int, int, int);
100 extern int ef_check(int);
101 extern int ef_close(int);
102 extern int ef_flush(int);
103 extern int ef_write(int, int, caddr_t);
104 extern int ef_extend(int, int);
105 extern void ef_zapcache(int);
106 extern int ef_nelem(int);
107 extern int ef_flags(int);
108 extern int ef_lock(int);
109 extern int ef_unlock(int);
110 extern int ef_vars(int, register s_char *, u_char **,
111                    u_char **, u_short **);
112 extern int ef_byname(s_char *);
113
114 extern int ef_nbread();
115 extern struct empfile empfile[];
116
117 #endif /* _FILE_H_ */