Writing or reading files is supported with two functions:
works like fopen, it opens the file filename for writing (if mode is omWrite) or reading (if mode is omRead) and returns the pointer to the XDR stream created for this file. A file created by g_xdr_open_file is closed byXDR *g_xdr_open_file(char *filename, OPEN_MODE mode)
The functions return NULL resp. FALSE if they fail.int g_xdr_close_file(XDR *xdrp)
With these functions writing an GRAPE XDR file is as simple as writing a normal file. The code to write the instance inst to the file filename is (to read the instance just replace omWrite by omRead)
if((xdrp = g_xdr_open_file(filename, omWrite))) { if(!g_xdr_instance(xdrp, &inst)) fprintf(stderr, "error writing instance\n"); g_xdr_close_file(xdrp); } else fprintf(stderr, "error opening file\n");
Of course you can write any kind of data to the file, you just have to replace the g_xdr_instance function by the appropriate XDR functions.
Copyright © by the Sonderforschungsbereich 256 at the Institut für Angewandte Mathematik, Universität Bonn.