Re: calling a 4GL routine from C socket server ?
Posted in 1997
On Tue, 25 Nov 1997, Kire Prostizenovski wrote: > How would I be able to call a 4GL program from a C program. In much the same way as you'd call a C program from a C program... > We have a socket server process written in C, and would like to pass > parameters to a 4GL program which will do it's thing and return the > result. Can data be passed to the 4GL program through named pipes, or > am I on the wrong track ? You could use named pipes, but you'd have to arrange for the I4GL program to have its standard input come from the named pipe, and it's standard output go to the return pipe, and no useful information should get lost on stderr. You also have to be concerned lest two people run the program at the same time and use the same names for the named pipes -- the names for the named pipes must be allocated uniquely per process using them. > I was thinking of passing parameters on the command line to the 4GL; > say > fglgo testprog.4go <parm1> <parm2> ... Sounds good to me, especially if there are never any spaces in any of the parameters. And that avoids using a named pipe for the standard input. > But how would I capture the returned result in my C program ? How would you capture the result of running "ls" in your C program? You could use popen() -- it's what I'd do unless there was a compelling reason why it should not be used. Or you could write the code to for and execute the program yourself, using whatever plumbing seems appropriate (probably using plain, old-fashioned anonymous pipes rather than named pipes). Or you could arrange for the output from the I4GL program to go to a file and then read that file into your C program. Or it could place the results in a permanent table ready for the C (ESQL/C) program to collect them. Or ... > Where a heap of data needs to be passed, we would pass the filename of a > named pipe where the data has been written to. Yes, you could do it this way. I wouldn't, but it could be made to work. Yours, Jonathan Leffler (johnl@informix.com) #include <witticism.h>