ToolTalk ユーザーズガイド

プロセス型の宣言

型情報は、(アプリケーションのインストール時に) 一度しか指定しません。したがってアプリケーションは、起動するたびに ptype の宣言だけを行う必要があります。

ptype を宣言するには、アプリケーションの ToolTalk 初期化ルーチンで tt_ptype_declare を使用します。ToolTalk サービスは、ptype と指定した ptype を参照する otype に記述されたメッセージパターンを作成します。

ptype を宣言すると作成されるメッセージパターンは、アプリケーションが ToolTalk セッションを終了するまでメモリーに存在します。


注 –

ptype 情報を宣言するときに作成されるメッセージパターンは、tt_pattern_unregister で登録を解除できません。ただし、tt_ptype_undeclare を使用すると、これらのパターンの登録を解除できます。


次にプログラム初期設定時に ptype を登録する方法を示します。

/*
 * Initialize our ToolTalk environment.
 */
int
edit_init_tt()
{
        int     mark;
        char    *procid = tt_open();
        int     ttfd;
        void    edit_receive_tt_message();

        mark = tt_mark();

        if (tt_pointer_error(procid) != TT_OK) {
                return 0;
        }
        if (tt_ptype_declare(“Sun_EditDemo”) != TT_OK) {
                fprintf(stderr,”Sun_EditDemo is not an installed ptype.\n”);
                return 0;
        }
        ttfd = tt_fd();
        tt_session_join(tt_default_session());
        notify_set_input_func(edit_ui_base_window,
                              (Notify_func)edit_receive_tt_message,
                              ttfd);

        /*
         * Note that without tt_mark() and tt_release(), the above
         * combination would leak storage -- tt_default_session() returns
         * a copy owned by the application, but since we don't assign the
         * pointer to a variable we could not free it explicitly.
         */

        tt_release(mark);
        return 1;
}