contact: Create EF_CONTACT table of struct contactstr

New struct contactstr is basically empty so far.  The next commit will
move contact state from struct natstr to struct contactstr.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2016-10-25 19:33:19 +02:00
parent 7cc34abaca
commit 4b4df53485
24 changed files with 314 additions and 187 deletions

View file

@ -29,7 +29,7 @@
*
* Known contributors to this file:
* Ron Koenderink, 2006
* Markus Armbruster, 2006-2008
* Markus Armbruster, 2006-2016
*/
#include <config.h>
@ -73,6 +73,10 @@ empobj_in_use(int type, void *p)
case EF_NATION:
case EF_COUNTRY:
return ((struct natstr *)p)->nat_stat != STAT_UNUSED;
case EF_CONTACT:
return empobj_in_use(EF_NATION,
ef_ptr(EF_NATION,
((struct ef_typedstr *)p)->uid));
case EF_NEWS:
return ((struct nwsstr *)p)->nws_vrb != 0;
case EF_LOAN:

View file

@ -164,6 +164,9 @@ struct empfile empfile[] = {
{EF_NATION, "nat", "nation", "nation", nat_ca, EF_BAD,
UNMAPPED_CACHE(struct natstr, MAXNOC, EFF_TYPED | EFF_OWNER),
nat_oninit, NULL, NULL, NULL},
{EF_CONTACT, "contact", NULL, "contact", contact_ca, EF_BAD,
UNMAPPED_CACHE(struct contactstr, MAXNOC, EFF_TYPED),
NULL, NULL, NULL, NULL},
{EF_LOAN, "loan", NULL, "loan", loan_ca, EF_BAD,
UNMAPPED_CACHE(struct lonstr, -1, EFF_TYPED),
NULL, NULL, NULL, NULL},

View file

@ -650,6 +650,15 @@ struct castr cou_ca[] = {
struct castr nat_ca[sizeof(cou_ca) / sizeof(*cou_ca)];
/* initialized by nsc_init() */
struct castr contact_ca[] = {
#define CURSTR struct contactstr
{"uid", fldoff(con_uid), NSC_INT, 0, NULL, EF_CONTACT, 0, CA_DUMP},
{"timestamp", fldoff(con_timestamp), NSC_TIME, 0, NULL,
EF_BAD, 0, CA_DUMP_NONE},
{NULL, 0, NSC_NOTYPE, 0, NULL, EF_BAD, 0, CA_DUMP}
#undef CURSTR
};
struct castr realm_ca[] = {
#define CURSTR struct realmstr
/* uid is encoded in cnum, realm */

View file

@ -28,7 +28,7 @@
*
* Known contributors to this file:
* Ron Koenderink, 2005
* Markus Armbruster, 2005-2011
* Markus Armbruster, 2005-2016
*/
#include <config.h>
@ -109,6 +109,7 @@ ef_open_srv(void)
failed |= !ef_open(EF_COMM, 0);
failed |= !ef_open(EF_LOST, 0);
failed |= !ef_open(EF_REALM, EFF_MEM);
failed |= !ef_open(EF_CONTACT, EFF_MEM);
if (!failed)
failed |= ef_open_view(EF_COUNTRY);
if (failed) {
@ -137,4 +138,5 @@ ef_close_srv(void)
ef_close(EF_BMAP);
ef_close(EF_LOST);
ef_close(EF_REALM);
ef_close(EF_CONTACT);
}