next up previous
Next: Librnpl Up: Parameters Previous: FORTRAN Interface

C Interface

The C interface consists of a single routine whose prototype is in librnpl.h.

BBH_V get_param(const BBH_C *p_file, BBH_C *name, BBH_I def,
               BBH_C *type, BBH_I size, BBH_V *p);

This routine takes the file name, parameter name, default flag, parameter type, parameter size (in elements), and a pointer to the parameter. The following code fragment reads several parameters from a file called myparams.

  long len,ar1[3];
  double p,ar2[5];
  char *s,**ar3;
  ar3=(char **)malloc(4*sizeof(char *));

Notice that the addresses of size 1 parameters must be passed. The parameter type is one of the three strings used above. The default flag is set to 1 if the parameter has a default and 0 if not. Storage for each string is allocated by the routine if the default flag is 0. Otherwise existing storage is freed and reallocated. Thus string parameters must be malloced and not taken from the stack.

Robert Marsa
Fri Jul 14 13:58:46 CDT 1995