Re: C function from Informix 4GL
Posted in 1999
Milton Santos wrote: > > Anyone knows how I can call C function from Informix 4GL? Assuming compiled 4GL you need to write a wrapper function in C that will translate the 4GL calling convention (ie arguments on the 4GL stack and number of args passed as the only real parameter) to C calling conventions. For RDS or D4GL this wrapper needs to be linked into the pcode runner. Example of mapping the getenv function: in 4GL call: LET informixdir = fgl_getenv( "INFORMIXDIR" ) in C write: int fgl_getenv( int nargs ) { char string[1024], var[256]; int i; if (nargs != 1) return -1; /* Get the variable name off the stack. */ popvchar( var, 256 ); strcpy( string, getenv( var ) ); pushquote( string, strlen( string ) ); return 1; /* Return number of return values pushed to the stack */ } Art S. Kagel