Move view open/close into src/lib/common/file.c
Really belongs there, because it manipulates empfile[]. New ef_open_view() to replace ef_init_view(). Make ef_close() cope with views, and remove ef_fina_view(). Make ef_extend() and ef_truncate() oops on views.
This commit is contained in:
parent
d929aa8b82
commit
62076fbed7
3 changed files with 50 additions and 37 deletions
|
@ -55,8 +55,6 @@ static struct fileinit fileinit[] = {
|
|||
|
||||
static void ef_open_srv(void);
|
||||
static void ef_close_srv(void);
|
||||
static int ef_init_view(int, int);
|
||||
static void ef_fina_view(int);
|
||||
|
||||
/*
|
||||
* Initialize empfile for full server operations.
|
||||
|
@ -107,7 +105,7 @@ ef_open_srv(void)
|
|||
failed |= !ef_open(EF_LOST, 0, -1);
|
||||
failed |= !ef_open(EF_REALM, EFF_MEM, MAXNOC * MAXNOR);
|
||||
if (!failed)
|
||||
failed |= ef_init_view(EF_COUNTRY, EF_NATION);
|
||||
failed |= ef_open_view(EF_COUNTRY, EF_NATION);
|
||||
if (failed) {
|
||||
logerror("Missing files, giving up");
|
||||
exit(EXIT_FAILURE);
|
||||
|
@ -117,7 +115,7 @@ ef_open_srv(void)
|
|||
static void
|
||||
ef_close_srv(void)
|
||||
{
|
||||
ef_fina_view(EF_COUNTRY);
|
||||
ef_close(EF_COUNTRY);
|
||||
ef_close(EF_NATION);
|
||||
ef_close(EF_SECTOR);
|
||||
ef_close(EF_SHIP);
|
||||
|
@ -136,23 +134,3 @@ ef_close_srv(void)
|
|||
ef_close(EF_LOST);
|
||||
ef_close(EF_REALM);
|
||||
}
|
||||
|
||||
static int
|
||||
ef_init_view(int type, int base)
|
||||
{
|
||||
if (CANT_HAPPEN(!(empfile[base].flags & EFF_MEM)))
|
||||
return -1;
|
||||
empfile[type].cache = empfile[base].cache;
|
||||
empfile[type].csize = empfile[base].csize;
|
||||
empfile[type].flags |= EFF_MEM;
|
||||
empfile[type].baseid = empfile[base].baseid;
|
||||
empfile[type].cids = empfile[base].cids;
|
||||
empfile[type].fids = empfile[base].fids;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
ef_fina_view(int type)
|
||||
{
|
||||
empfile[type].cache = NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue