There are a number of tasks every ToolTalk-aware application needs to perform, including:
Initializing the toolkit
Joining a ToolTalk session and registering patterns
Adding the ToolTalk service to its event loop
This section provides examples of the ToolTalk code you need to include in your application so that it can perform these tasks.
The code snippets used in this section are taken from the CoEd.C file. This file contains the general commands any application needs to perform that are not specific to any particular application. See Appendix B, The CoEd Demonstration Program for the detailed source code.
Your application needs to initialize and register with the initial ToolTalk session. To do so, it first needs to obtain a process identifier (procid). The following code snippet shows how to obtain a procid and how to initialize the toolkit.
// Obtain process identifier int myTtFd; // Initialize toolkit and create a ToolTalk communication endpoint char *myProcID = ttdt_open( &myTtFd, ToolName, "SunSoft", "%I", 1 );
Your application must call ttdt_open before any other calls are made; otherwise, errors may occur.
Before your application can receive messages, it must join a ToolTalk session and register the message patterns that are to be matched.
// Join a ToolTalk session and register patterns and default callbacks sessPats = ttdt_session_join( 0, 0, session_shell, this, 1 ); }
Your application also needs to add the ToolTalk service to its event loop.
// Process ToolTalk events for Xt Clients XtAppAddInput( myContext, myTtFd, (XtPointer)XtInputReadMask, tk_Xt_input_handler, myProcID );