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 libraries 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_c++.C /main/3 1995/11/06 17:14:22 rswiston $
38 char *string = tt_status_message( status );
42 char *tab = strchr( string, '\t' );
52 Tt_status status2Print
55 char *string = tt_status_string( status2Print );
69 case TT_SCOPE_NONE: string = "TT_SCOPE_NONE"; break;
70 case TT_SESSION: string = "TT_SESSION"; break;
71 case TT_FILE: string = "TT_FILE"; break;
72 case TT_BOTH: string = "TT_BOTH"; break;
73 case TT_FILE_IN_SESSION: string = "TT_FILE_IN_SESSION"; break;
78 sink << "(Tt_scope)" << (int)scope;
91 case TT_CLASS_UNDEFINED: string = "TT_CLASS_UNDEFINED"; break;
92 case TT_NOTICE: string = "TT_NOTICE"; break;
93 case TT_REQUEST: string = "TT_REQUEST"; break;
94 case TT_OFFER: string = "TT_OFFER"; break;
99 sink << "(Tt_class)" << (int)_class;
112 case TT_MODE_UNDEFINED: string = "TT_MODE_UNDEFINED"; break;
113 case TT_IN: string = "TT_IN"; break;
114 case TT_OUT: string = "TT_OUT"; break;
115 case TT_INOUT: string = "TT_INOUT"; break;
120 sink << "(Tt_mode)" << (int)mode;
133 case TT_PROCEDURE: string = "TT_PROCEDURE"; break;
134 case TT_OBJECT: string = "TT_OBJECT"; break;
135 case TT_HANDLER: string = "TT_HANDLER"; break;
136 case TT_OTYPE: string = "TT_OTYPE"; break;
141 sink << "(Tt_address)" << (int)address;
149 Tt_callback_action action
154 case TT_CALLBACK_CONTINUE: string = "TT_CALLBACK_CONTINUE";break;
155 case TT_CALLBACK_PROCESSED: string = "TT_CALLBACK_PROCESSED";break;
160 sink << "(Tt_callback_action)" << (int)action;
170 if (tt_ptr_error( msg1 ) != TT_OK) {
173 Tt_message msg2 = tt_message_create();
174 Tt_status status = tt_ptr_error( msg2 );
175 if (tt_ptr_error( msg2 ) != TT_OK) {
178 int contexts = tt_message_contexts_count( msg1 );
179 status = tt_int_error( contexts );
180 if (status != TT_OK) {
181 tt_message_destroy( msg2 );
182 return (Tt_message)tt_error_pointer( status );
184 for (int context = 0; context < contexts; context++) {
185 char *slot = tt_message_context_slotname( msg1, context );
187 status = tt_message_context_ival( msg1, slot, &ival );
192 tt_message_icontext_set( msg2, slot, ival );
195 tt_message_context_bval( msg1, slot, &bval, &len );
196 tt_message_bcontext_set( msg2, slot, bval, len );
197 tt_free( (caddr_t)bval );
202 int args = tt_message_args_count( msg1 );
203 status = tt_int_error( args );
204 if (status != TT_OK) {
205 tt_message_destroy( msg2 );
206 return (Tt_message)tt_error_pointer( status );
208 for (int arg = 0; arg < args; arg++) {
209 Tt_mode mode = tt_message_arg_mode( msg1, arg );
210 char *vtype = tt_message_arg_type( msg1, arg );
212 status = tt_message_arg_ival( msg1, arg, &ival );
217 tt_message_iarg_add( msg2, mode, vtype, ival );
220 tt_message_arg_bval( msg1, arg, &bval, &len );
221 tt_message_barg_add( msg2, mode, vtype, bval, len );
222 tt_free( (caddr_t)bval );
228 tt_message_class_set( msg2, tt_message_class( msg1 ));
230 char *file = tt_message_file( msg1 );
231 if ((tt_ptr_error( file ) == TT_OK) && (file != 0)) {
232 tt_message_file_set( msg2, file );
236 char *object = tt_message_object( msg1 );
237 if ((tt_ptr_error( object ) == TT_OK) && (object != 0)) {
238 tt_message_object_set( msg2, object );
242 char *op = tt_message_op( msg1 );
243 if ((tt_ptr_error( op ) == TT_OK) && (op != 0)) {
244 tt_message_op_set( msg2, op );
248 char *otype = tt_message_otype( msg1 );
249 if ((tt_ptr_error( otype ) == TT_OK) && (otype != 0)) {
250 tt_message_otype_set( msg2, otype );
254 tt_message_address_set( msg2, tt_message_address( msg1 ));
256 // XXX skip handler, handler_ptype, sender
258 tt_message_scope_set( msg2, tt_message_scope( msg1 ));
260 char *sender_ptype = tt_message_sender_ptype( msg1 );
261 if ((tt_ptr_error( sender_ptype ) == TT_OK) && (sender_ptype != 0)) {
262 tt_message_sender_ptype_set( msg2, sender_ptype );
263 tt_free( sender_ptype );
266 char *session = tt_message_session( msg1 );
267 if ((tt_ptr_error( session ) == TT_OK) && (session != 0)) {
268 tt_message_session_set( msg2, session );
272 tt_message_status_set( msg2, tt_message_status( msg1 ));
274 char *status_string = tt_message_status_string( msg1 );
275 if ((tt_ptr_error( status_string ) == TT_OK) && (status_string != 0)) {
276 tt_message_status_string_set( msg2, status_string );
277 tt_free( status_string );
288 Tttk_op op = tttk_string_op( optext );
292 theClass = TT_REQUEST;
303 theClass = TT_NOTICE;
317 case TTDT_GET_MODIFIED:
323 Tt_message msg = tttk_message_create( 0, theClass, scope,
325 Tt_mode mode = TT_INOUT;
330 tt_message_arg_add( msg, TT_IN, Tttk_file, 0 );
337 case TTDT_GET_MODIFIED:
340 tt_message_arg_add( msg, TT_IN, Tttk_file, 0 );
342 case TTDT_GET_SYSINFO:
343 tt_message_arg_add( msg, TT_OUT, Tttk_string, 0 );
345 case TTDT_GET_STATUS:
346 tt_message_arg_add( msg, TT_OUT, Tttk_string, 0 );
347 tt_message_arg_add( msg, TT_OUT, Tttk_string, 0 );
348 tt_message_arg_add( msg, TT_OUT, Tttk_string, 0 );
349 tt_message_arg_add( msg, TT_OUT, Tttk_string, 0 );
352 tt_message_arg_add( msg, TT_IN, Tttk_string, 0 );
356 tt_message_arg_add( msg, TT_IN, Tttk_string, 0 );
357 tt_message_arg_add( msg, TT_IN, Tttk_string, 0 );
358 tt_message_arg_add( msg, TT_IN, Tttk_string, 0 );
360 case TTDT_GET_ICONIFIED:
361 case TTDT_GET_MAPPED:
362 tt_message_arg_add( msg, TT_OUT, Tttk_boolean, 0 );
365 tt_message_arg_add( msg, TT_IN, Tttk_boolean, 0 );
367 case TTDT_SET_MAPPED:
368 case TTDT_SET_ICONIFIED:
369 tt_message_arg_add( msg, TT_IN, Tttk_boolean, 0 );
371 case TTDT_GET_GEOMETRY:
373 case TTDT_SET_GEOMETRY:
374 tt_message_arg_add( msg, mode, Tttk_width, 0 );
375 tt_message_arg_add( msg, mode, Tttk_height, 0 );
376 tt_message_arg_add( msg, mode, Tttk_xoffset, 0 );
377 tt_message_arg_add( msg, mode, Tttk_yoffset, 0 );
380 tt_message_arg_add( msg, TT_OUT, Tttk_string, 0 );
381 tt_message_arg_add( msg, TT_OUT, Tttk_string, 0 );
382 tt_message_arg_add( msg, TT_OUT, Tttk_integer, 0 );
384 case TTDT_GET_SITUATION:
385 tt_message_arg_add( msg, TT_OUT, Tttk_string, 0 );
388 case TTDT_SET_SITUATION:
389 tt_message_arg_add( msg, TT_IN, Tttk_string, 0 );
391 case TTDT_DO_COMMAND:
392 case TTDT_GET_ENVIRONMENT:
393 case TTDT_GET_LOCALE:
394 tt_message_arg_add( msg, TT_IN, Tttk_string, 0 );
395 tt_message_arg_add( msg, TT_OUT, Tttk_string, 0 );
397 case TTDT_SET_LOCALE:
398 case TTDT_SET_ENVIRONMENT:
399 tt_message_arg_add( msg, TT_IN, Tttk_string, 0 );
400 tt_message_arg_add( msg, TT_IN, Tttk_string, 0 );
411 char *defaultProcid = tt_default_procid();
412 tt_default_procid_set( procid );
413 int val2return = tt_fd();
414 if (! tt_is_err( tt_ptr_error( defaultProcid ))) {
415 tt_default_procid_set( defaultProcid );