2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
24 /*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
25 /*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
26 /*%% (c) Copyright 1993, 1994 Novell, Inc. */
27 /*%% $XConsortium: mp_procid.h /main/3 1995/10/23 10:27:28 rswiston $ */
31 * Copyright (c) 1990 by Sun Microsystems, Inc.
33 * This file contains the implementation of _Tt_procid which is an object
34 * that represents an active process communicating with a message server.
35 * There are two instances of this object depending on whether the object
36 * is in client or server mode. The client instance is basically just a
37 * handle on it's id. The server instance maintains information such as
38 * what patterns are registered for a process, what signalling channel is
39 * used, and also what messages are waiting to be delivered to the client
40 * instance of the procid.
45 #include "util/tt_table.h"
46 #include "util/tt_host_utils.h"
47 #include "mp/mp_global.h"
48 #include "mp/mp_stream_socket_utils.h"
49 #include "mp/mp_session_utils.h"
50 #include "mp/mp_message_utils.h"
51 #include "mp/mp_pattern_utils.h"
52 #include "mp/mp_procid_utils.h"
53 #include "mp_xdr_functions.h"
54 #define _TT_MESSAGE_TIMEOUT 300 /* default message timeout in seconds */
57 #ifdef OPT_ADDMSG_DIRECT
59 * if this option is turned on then TT_ADDMSG_VERS should be set to
60 * the version number at which addmsg_direct is used. The code assumes
61 * that all versions later than this version also support this
64 * XXX: This should probably be changed to a mechanism that allows
65 * clients to tell their session that they would like this optimization
66 * to be used. The session can then deny their request meaning it doesn't
67 * support the optimization.
69 # define TT_ADDMSG_VERS 3
72 * defining this as -1 assures that no code will make use of it
74 # define TT_ADDMSG_VERS -1
78 enum _Tt_procid_flagbits {
79 _TT_PROC_ACTIVE, /* is an active proc */
80 _TT_PROC_FD_CHANNEL_ON, /* fd channel is valid */
81 _TT_PROC_COMMITTED, /* committed to default session */
82 _TT_PROC_IS_LOCAL, /* is local to server's machine */
83 _TT_PROC_SIGNALLED, /* has been signalled about new msgs */
84 _TT_PROC_MSGSENT /* msg sent directly to proc */
87 class _Tt_procid : public _Tt_object {
90 virtual ~_Tt_procid();
91 void add_joined_file(_Tt_string fpath);
92 void del_joined_file(_Tt_string fpath);
94 const _Tt_string &id() const;
95 int is_equal(const _Tt_procid_ptr &p) {
96 return(_id == p->_id);
98 int is_equal(_Tt_string &id);
99 int joined_to_file(_Tt_string fpath);
100 int processing(const _Tt_message &m);
101 _Tt_pattern_list_ptr &patterns() {
108 void print(const _Tt_ostream &os) const;
109 _Tt_host_ptr &proc_host() {
112 int program() const {
115 void set_start_token(const _Tt_string &token) {
116 _start_token = token;
118 _Tt_string &start_token() {
121 int version() const {
124 _Tt_string &proc_host_ipaddr() {
125 return _proc_host_ipaddr;
127 _Tt_string_list_ptr &ptypes() {
128 return _declared_ptypes;
130 bool_t xdr(XDR *xdrs);
139 _Tt_string _start_token;
140 _Tt_string _proc_host_ipaddr;
141 _Tt_string_list_ptr _joined_files;
142 _Tt_string_list_ptr _declared_ptypes;
143 _Tt_pattern_list_ptr _patterns;
144 _Tt_host_ptr _proc_host;
145 _Tt_stream_socket_ptr _socket;
149 _Tt_string _tt_procid_id(_Tt_object_ptr &o);
150 bool_t tt_xdr_procid(XDR *xdrs, _Tt_procid_ptr *patp);
151 bool_t tt_xdr_message_list(XDR *xdrs, _Tt_message_list_ptr *mptr);
153 #ifdef OPT_ADDMSG_DIRECT
154 int _tt_xdr_readit(char *iohandle, char *buf, int nbytes);
155 int _tt_xdr_writeit(char *iohandle, char *buf, int nbytes);
156 #endif /* OPT_ADDMSG_DIRECT */
157 #endif /* MP_PROCID_H */