Extensions to Analysis specification syntax to support mainlib (internal) analysis # add user-specified name/value pair for analysis macro expansion set LIB $HOME/lib # xtype: for backward compatibility, default has type=external, # i.e. execute current sh -c "cmd" menu menu xtype=external # internal uses mainlib, requires package name and (maybe) shared object name menu xtype=internal package=funtools source=static menu xtype=internal package=funtools source=$LIB/libfuntoolsMainLib.dylib bind x xtype=internal package=funtools source=static bind x xtype=internal package=funtools source=$LIB/libfuntoolsMainLib.dylib Notes: 1. set name val Add user-specified name and value to the macro expansion. Not specific to internal processing but will help with shared object pathnames. 2. xtype=internal Execute a mainlib action by performing macro subsititution, generating an in-memory FITS file if necessary, and then calling: set result [mainlib "command"] Question: what triggers generation of in-memory FITS? Is it $file or a new keyword? 3. source=static package= Valid for xtype=internal only. Assumes that a routine named MainLibInit() is linked into ds9. The name and entry point will have to be pre-loaded into a table so that the entry point for the routine can be looked up and executed. Calling sequence: int nameMainLibInit(void) returns 1 on success, 0 on failure. 4. source= package= Valid for xtype=internal only. ds9 must call: int MainLibLoad(char *name, char *source, void **dl, char **ermsg) or the Tcl equivalent: set dl [mainlibload name source] to load shared object and call the init routine. This can be done either when processing the analysis specification or just before executing the command for the first time. The returned dl is the handle from dlopen and can be used with dlclose(), if desired. 5. ds9 will link libfuntools.a into the executable, as usual. To access the mainlib support, we can either: a. link libfuntoolsMainLib.a into the executable and use source=static in the analysis menu. In this case, the static library is created using: make mainlib and requires --enable-mainlib=yes on the configure command line. b. we can load libfuntoolsMainLib.[so,dylib] and use source= in the analysis menu. In this case, the dynamic library is created using: make shmainlib and requires --enable-mainlib=shared on the configure command line. Probably the static method is preferable so that funtools is part of a single execuable? 6. The LD_LIBRARY_PATH is critical for loading shared libraries. How will we deal with this? One possibility is to add an argument to MainLibLoad() to specify a directory which gets added to LD_LIBRARY_PATH before the call to dlopen()???