members.
(empfile): Reorder members for clearer documentation.
(EFF_IMMUTABLE): New.
(EFF_OPEN): Remove, use ~EFF_IMMUTABLE.
(empfile): Don't initialize member size to a useless value for EF_MAP
and EF_BMAP. ef_init() writes the real value.
(empfile): Correctly initialize members cids, csize, fids for all
EFF_STATIC tables except EF_SHIP_CHR, EF_PLANE_CHR, EF_LAND_CHR,
EF_NUKE_CHR, EF_META and the symbol tables.
of laziness. The assumption is true on any sane machine, due to
alignment constraints. But the function doesn't provide enough value
to make me fix or document this. Remove it.
(lookup): Replace it.
one of its prefixes. src/lib/global/file.c rev. 1.18 added such table
entries, and file.h rev. 1.34 made them visible to ef_byname().
Simply use stmtch(). This also rejects ambiguous abbreviations: "s"
used to return EF_SECTOR, it now returns M_NOTUNIQUE.
(xdump, main): Use it.
(EF_MAX): Change to largest table ID + 1. This is now possible
because the changes above get rid of the assumption that
empfile[0..EF_MAX-1] is only game state. Code can now work on any
table using the advertized empfile interface, not just on game state.
(my_ef_byname): Remove, use ef_byname().
(set, mission, multifire, fuel, cons_choose, cede): Use it instead of
ef_byname(). Remove the hacks to map unwanted results to wanted
results. The hacks in set() were broken: bad input made the code cast
arbitrary items to union trdgenstr, with potentially disastrous
consequences. Closes#906483 and #906486.
(set): Less cryptic prompt and diagnostics.
Problems with the old code:
* Insufficient error checking.
* It used TIOCNOTTY (obsolete BSDism) to get rid of the controlling
tty, except for hpux || Rel4, where it attempted to use the POSIX
way, but screwed up.
* It left file descriptors 0, 1, 2 in a somewhat weird state.
(ef_read): Used to get the file size again some circumstances; doesn't
make sense, as no other process may be writing this file.
(ef_write): Don't refuse to write beyond record 65536. This module
can cope with that. Some users have trouble long before that (short
record numbers), but that should be handled there.
(ef_write): Catch table not file-backed.
Catch negative count; used to have no effect with EFF_MEM, and
confusion otherwise. Try to recover from partially successful
extension. Need help from ef_write() to do a better job; to be done.
file descriptors.
(ef_flush, ef_close): Rely on negative fd instead of null cache to
detect unopened file. This is more logical and consistent with the
use of cache by the new tables that are not file-backed (rev. 1.22).
Use CANT_HAPPEN().
(ef_close): Failed to report cash flush failure.
(ef_close): Clear all EFF_OPEN flags. Should have been done in
rev. 1.27.
(ef_flush, ef_write): Use it. Old code couldn't cope with interrupted
or short writes (mostly harmless, as disk reads commonly complete).
(ef_write): Use CANT_HAPPEN() for catching unimplemented table
extensions.
couldn't cope with interrupted or short reads (mostly harmless, as
disk reads commonly complete), and left an empty cache after a failed
read.
(ef_open): Use fillcache() instead of read().
(ef_read): Fail if fillcache() fails to read at least one element.
Old version copied garbage to its caller and claimed success.
(really open flags, not mode) by new flags EFF_RDONLY, EFF_CREATE.
Open flags were needlessly general. Callers changed.
(empfile): Member mode now unused, remove.