next up previous contents
Next: Function: avg_spec() Up: GRASP Routines: General purpose Previous: Functions: GR_start_error(), GR_report_error(), GR_end_error()   Contents


Function: grasp_open()

0 FILE* grasp_open(const char *environment_variable,const char *shortpath,const char *mode)

This routine provides a simple mechanism for obtaining the pointer to a data or parameter file. It is called with two character strings. One of these is the name of an environment variable, for example GRASP_DATAPATH or GRASP_PARAMETERS. The second argument is the ``tail end" of a path name. The routine then constructs a path name whose leading component is determined by the environment variable and whose tail end is determined by the short path name. grasp_open() opens the file (printing useful error messages if this is problematic) and returns a pointer to the file.

The arguments are:

environment_variable: Input. Pointer to a character string containing the name of the environment variable.
shortpath: Input. Pointer to a character string containing the remainder of the path to the file.
mode: Input. File mode. Pointer to a character string containing "r" if you want to read the file, "w" if you want to write to the file, and so on. A list of the possible modes is:
     r or rb            open file for reading
     w or wb            truncate to zero length or create file for
                        writing
     a or ab            append; open or create file for writing at
                        end-of-file
     r+ or rb+ or r+b   open file for update (reading and writing)
     w+ or wb+ or w+b   truncate to zero length or create file for
                        update
     a+ or ab+ or a+b   append; open or create file for update,
                        writing at end-of-file

As a simple example, if the environment variable GRASP_PARAMETERS is set to
/usr/local/data/14nov94.2
and one calls
grasp_open("GRASP_PARAMETERS","channel.0","r")
then the routine opens the file
/usr/local/data/14nov94.2/channel.0
for reading and returns a pointer to it.


next up previous contents
Next: Function: avg_spec() Up: GRASP Routines: General purpose Previous: Functions: GR_start_error(), GR_report_error(), GR_end_error()   Contents
Bruce Allen 2000-11-19