Before writing your own import and export utilities, you should consider using standard ones that already exist. For example, the KAPPA package (SUN/95) contains a general purpose ``fitsimp'' command that can be used to build a specialist NDF extension by importing information from a FITS extension. It is driven by a keyword translation table stored in a text file, so can easily be adapted for different needs. For example, it might be used in an NDF import command as follows:
setenv NDF_IMP_MINE 'fitsimp ndf=^ndf xname=MINE table=$HOME/mine.imp'
Here, mine.imp is the table that drives the importation process. This could be different for each format if necessary. An equivalent extension export utility ``fitsexp'' is also available.
If you find that you must write your own software for this purpose, then the IMG library (SUN/160) provides a convenient programming interface for accessing items of NDF extension information (including individual items within the FITS extension) and should make most import and export utilities straightforward to write. With a little more effort, you can, of course, also use the NDF and HDS libraries, which allow you to construct any form of extension you want.