I am trying to intergrate SUNs ToolTalk library into pop11. This should allow
pop11 and other process to talk to each other without having to know too much
about each other.
When you open a ToolTalk conection you get back a file descriptor which is used
for passing messages. This is okay because the library contains all the code
for sending a receiving messages. But the one thing you need to do is setup
an async alerting method so you know when to receive a message. The recomended
version of application using the Xtoolkit is :-
void TT_InputCallback( XtPointer /* closure */, int *source,
XtInputId * /* id */ )
{
Tt_message *message;
message = tt_message_receive();
;;;messages handled by callbacks
}
main()
{
int TT_fd;
char *procid;
...
procid = tt_open();
TT_fd = tt_fd();
....
inputID = XtAppAddInput( app, TT_fd,
(XtPointer)( XtInputReadMask
| XtInputExceptMask ),
TT_InputCallback, 0 );
....
XtAppMainLoop(app);
}
The problem is that the pop11 version of XtAppAddInput (XptAppAddInout) expects
a device and not a file descriptor.
So I thought I would use XtAddInput from xt_r2compat as this uses a file descriptor
instead of a device. However when pop11 is sent a message my input handler does
not get called. If I call tt_message_receive by hand then I recieve the message.
What im I doing wrong or is ther another way of calling a pop11 procedure
when data arrives on a file descriptor?
(I know I could write some C code to do this but that would be cheating).
Anthony.Worrall@Reading.ac.uk
define pop_receive_tt_message(data,dev,id);
lvars data,dev,id,message;
exacc tt_message_receive() -> message;
if message.is_null_external_ptr then
;;;warning(0,'Null tooltalk mesasge recieved');
return();
endif;
if exacc tt_pointer_error(message) = TT_ERR_NOMP then
warning(0,'Tooltalk server is down');
return();
endif;
;;;handle messages via callbacks
enddefine;
include xt_constants;
define handle_tt_messages(app,tt_fd,data);
lvars dev tt_fd app data;
;;;make a fake device for tt_fd;
consdevice('Tooltalk', 'ToolTalk', true, 0,
{%
{% erasenum(%3%), identfn, erase %},
false, false, false
%}
) -> dev;
XtAddInput(tt_fd, XtInputReadMask || XtInputExceptMask,
pop_receive_tt_message, data);
enddefine;
handle_tt_messages(false,tt_fd,"handle_tt_messages") -> ptr;
is_null_external_ptr(ptr) =>
** false
|