Hi Russell,
If you are comfortable with C programming and compiling you can use many of the programs we have as examples for data I/O and write your own. However we can't help you much with that beyond pointing you to a few programs that get you close to what you want.
Another option is to use the matlab or the R APIs which allow you to read and write datasets relatively easily. The matlab API is available
here, and the R API is distributed with the AFNI binaries.
cheers,
Ziad