[net.games.emp] empire command args

muller (11/18/82)

A few weeks ago I saw a request on how empire passes arguements to it's
command routines. The information on the arguements are available in two
different forms, an argc format and a raw buffer. To read the raw buffer
and the argc args, just include "empdef.h". The raw command line (including
the command name and args as printed by the user) is in combuf ( an 80
long char array). The command name can be found in argp[0], first arg in
argp[1] etc. Now a problem (to me at least) still exsists on how file
descriptors are passed to the routines. Thus commands like com # >file1
are a problem. Everthing to the right of (and including) the ">" are not
in any of the argp entries. Luckily they are still in the combuf though.
So if you want file data you have to do something like:
		int copy,j;
		FILE *fout;
		copy = 0;
		for(j=0;j<79;j++)
		if(combuf[j] == '>'){
		    if (combuf[j+1] == '>')
		        j++;
		    fout=fopen(&combuf[j+1],"a");
		    fflush(fout);
		    copy = 1;
		    break;
		}
Now the empire command dispatcher prints the combuf before calling the
routine, so your routine just has to take care of it's own data (ie
if copy == 1 the echo the print to the file etc). Make sure you close
fout before exiting your procedure.
Now it makes it very easy to write replacement modules for empire. After
cc -c them, just place them in empcom.a and remake BIN/emp1. All the
necessary info for getting access to any empire data can be found in
empglb.c and empdef.h. The command dispatcher uses info found in empmod.c,
so if you want to add new commands you have to modify the tables in there.
(modify exsisting commands just requires you name them the same as in
the old ones are named ie a routine called coas() in coas.c would replace
coastwatch).
I have tried all this in a version of coastwatch that was inspired by
decvax!utzoo!utcsrgv!dudek. (the difference being that the distance the
ships can be seen varies with their size and the sector they are spotted
from. two threshold either spots the ship only, or if it close gives you
the ship number and country.)
A lot of general purpose routines for doing things are in empsub.a, but I
have yet to figure any of them out (lacking calling specs). Any help?

Keith Muller
Dept EECS
University Of California, San Diego