The C interface file

To make your C functions visible to the runtime system, you must define all the functions in the C interface file. This is a C source file that defines the usrFunctions array. This array defines C functions that can be called from programs. The last record of each array must be a line with all the elements set to 0, to define the end of the list.

The first member of a usrFunctions element is the runtime name of the function, provided as a character string. The second member is the C function symbol. Therefore, you typically do a forward declaration of the C functions before the usrFunctions array initializer. The third member is the number of parameters passed through the stack to the function. The last member is the number of values returned by the function; you can use -1 to specify a variable number of arguments.

#include <f2c/fglExt.h>

int c_log(int);
int c_cos(int);
int c_sin(int);

UsrFunction usrFunctions[]={
  {"log",c_log,1,1},
  {"cos",c_cos,1,1},
  {"sin",c_sin,1,1},
  {0,0,0,0}
};