aan@cacs.usl.edu (Anand Narasimhan) (08/05/90)
Hello !
I am working on a project in which I need a routine to read input from
the standard input and create multiple independent windows and perform some
operations using the input obtained from the stdin. I wrote an example
program to see how XtAddInput works. I am facing certain difficulties in
reading the input from stdin. I would appreciate if somebody can help me in
solving those problems.
A part of the code is given below.
top = XtAppCreateShell(app_con,"Addinp",applicationShellWidgetClass,dpy,
NULL,0);
............
XtAppAddInput(app_con,fileno(stdin),XtInputReadMask,get_input,top);
XtRealizeWidget(top);
XtAppMainLoop(app_con); /* End of Main */
get_input(w,fid,id)
Widget w;
int *fid;
XtInput *id;
{
int nbytes;
char in[2];
.........
nbytes = read(*fid,in,1);
..............
}
The problem I am faced with is that whenever I type an input in the stdin
the callback procedure is invoked but the input is not read. Instead it
waits for me to type another character. If I use fsacnf or fgets a "\0"
is read. Can anyone please tell me how to do this? Kindly send your
suggestions to me at aan@swamp.cacs.usl.edu or anand@gator.cacs.usl.edu.
Thanks
Anand