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: tt_global_env.h /main/5 1995/12/05 09:25:41 rswiston $ */
32 * Copyright (c) 1990 by Sun Microsystems, Inc.
34 #ifndef TT_GLOBAL_ENV_H
35 #define TT_GLOBAL_ENV_H
36 #include "tt_options.h"
37 #include "util/tt_object.h"
38 #include "util/tt_host_utils.h"
39 #include "util/tt_file_system_entry_utils.h"
40 #include "mp/mp_rpc_interface.h"
41 #include "db/tt_db_hostname_redirection_map.h"
44 #include <X11/Xthreads.h>
48 // Global object to hang information needed by various server and
49 // client objects such as a cache of known hosts, and the current xdr
50 // version (see comment in tt_xdr_version.h).
52 class _Tt_global : public _Tt_object {
56 // given a host ip address, return a pointer to a _Tt_host
57 // object which contains more information on the host.
58 int find_host(_Tt_string haddr,
62 // same idea as find_host except a name is given instead
63 int find_host_byname(_Tt_string name,
66 // return in h a pointer to a _Tt_host object representing the
67 // local host. Returns 1 for success and 0 for failure.
68 int get_local_host(_Tt_host_ptr &h);
70 // the name of the X11 session
71 _Tt_string xdisplayname;
73 // the name of the program name
76 // returns maximum number of fds
79 // flag saying whether messages should be printed out.
82 // returns current xdr/rpc version
85 // sets the current xdr version, defaults to the
86 // TT_XDR_VERSION constant.
87 void set_xdr_version(int v = TT_XDR_VERSION);
89 // Utilities for mt-safe-ness
93 // Test-and-set routine -- returns 1 if threading has not yet
94 // been turned on and this is the first TT API call.
95 // Note the assignment (*NOT* comparison test!) with _multithreaded
96 int set_multithreaded() {
97 return _multithreaded = 1 && event_counter == 1;
100 int multithreaded() { return _multithreaded; };
102 // the uid of the process
105 // the gid of the process
108 // DB hostname redirection map
109 _Tt_db_hostname_redirection_map db_hr_map;
111 // Internal cache of mnttab entries.
112 _Tt_file_system_entry_list_ptr fileSystemEntries;
114 // Universal _Tt_string buffer so that _Tt_strings don't
115 // do ridiculous initial allocations until the space is
117 _Tt_string_buf_ptr universal_null_string;
119 // how many "events", typically API calls in libtt and or
120 // RPC calls in ttsession/dbserver, have been called in
121 // the life of this process.
124 // next time that garbage collection should be done.
125 time_t next_garbage_run;
128 xmutex_rec global_mutex;
129 xthread_key_t threadkey;
136 _Tt_host_table_ptr _host_cache;
137 _Tt_host_table_ptr _host_byname_cache;
138 _Tt_host_ptr _local_host;
141 xcondition_rec _proceed;
144 extern _Tt_global *_tt_global;
145 #endif /* TT_GLOBAL_ENV_H */