how to catch stdout

1999-08-24 Thread David Chen

Hi all,

I have a general Java question.

I was asked to make a Java GUI interface for a pre-developed project which
was written in C.  The C programs provided a set of APIs.  I constructed the
GUI using swing and made the jni program.  It's functionlly working.

In the pre-developed project there are a lot of printf functions.  Now I
have to show the outputs of printf in a swing text fileld.  The question is
how can I do this without touching the pre-written C programs?

My first reaction is to use System.setOut().  It redirected all the
System.out in Java but not a single printf in C.

Can any one help me?


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



RE: how to catch stdout

1999-08-24 Thread David Chen

Thanks for all the replies to my question.

Most of suggestions focus on starting the C program as a separate process
then using pipes to communicate between the C and the Java program.

I have to add 3 conditions here which I didn't clearly explained in my
previous mail.

Condition 1:

I am using RedHat 6.0 and egcs and Blackdown Java 1.2 pre2

Condition 2:

The C program is just a set of API and doesn't have a main() function.  The
functions in C APIs are called from a JNI program which itself is called
from the Java program. So the C program runs in the same process space as
the Java program.

Conditon 3:

In this set of APIs, there is a function called "init".  It's arguments are:

extern int init(int argc, char* argv[], FILE* stdin, FILE* stdout, FILE*
stderr);

Users of the API can define the stdin, stdout and stderr here (or use NULL
for standard ones).  Once defined, in the rest of the API,  the output will
be printed to the specified FILEs.

The problem here is how can I pass a FILE structure from the Java program?
Once I can do this, the rest should be easy enouth.

Thanks again.


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]