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: api_mp_otype.C /main/4 1995/11/21 19:34:39 cde-sun $
32 * Copyright (c) 1990 by Sun Microsystems, Inc.
34 * This file contains API functions related to the MP. For
35 * each API function named tt_<name> there is a _tt_<name> function in
36 * some file named api_mp_*.cc.
40 #include "mp/mp_rpc_interface.h"
41 #include "api/c/tt_c.h"
42 #include "api/c/api_api.h"
43 #include "api/c/api_mp.h"
44 #include "api/c/api_handle.h"
45 #include "util/tt_audit.h"
48 * These functions differ from the usual layering in the API/MP interface.
49 * Usually, we would realize the _Tt_otype and _Tt_otype_table objects on
50 * the client side, with the methods split up so the client side makes
51 * RPC calls and the server side does the work. In this case, this would
52 * end up caching most of the otype information in the client side, which
53 * would give us cache-coherency problems we don't have time to deal with
54 * right now. So we have a simpler interface of the API routines just
55 * making RPC calls to the server. RFM 11/7/90.
58 extern _Tt_c_mp *_tt_c_mp;
62 tt_otype_deriveds_count(const char *otype)
65 Tt_status status = audit.entry("o", TT_OTYPE_DERIVEDS_COUNT, otype);
68 if (status != TT_OK) {
69 audit.exit(error_int(status));
70 return error_int(status);
73 result = _tt_otype_deriveds_count(otype);
81 tt_otype_derived(const char *otype, int i)
84 Tt_status status = audit.entry("oi", TT_OTYPE_DERIVED, otype, i);
87 if (status != TT_OK) {
88 audit.exit((char *)error_pointer(status));
89 return (char *)error_pointer(status);
92 result = _tt_otype_derived(otype, i);
100 tt_otype_base(const char *otype)
103 Tt_status status = audit.entry("o", TT_OTYPE_BASE, otype);
106 if (status != TT_OK) {
107 audit.exit((char *)error_pointer(status));
108 return (char *)error_pointer(status);
111 result = _tt_otype_base(otype);
119 tt_otype_is_derived(const char *derivedotype, const char *baseotype)
122 Tt_status status = audit.entry("oo", TT_OTYPE_IS_DERIVED,
123 derivedotype, baseotype);
126 if (status != TT_OK) {
127 audit.exit(error_int(status));
128 return error_int(status);
131 result = _tt_otype_is_derived(derivedotype, baseotype);
139 tt_otype_osig_count(const char *otype)
142 Tt_status status = audit.entry("o", TT_OTYPE_OSIG_COUNT, otype);
145 if (status != TT_OK) {
146 audit.exit(error_int(status));
147 return error_int(status);
150 result = _tt_otype_osig_count(otype);
158 tt_otype_hsig_count(const char *otype)
161 Tt_status status = audit.entry("o", TT_OTYPE_HSIG_COUNT, otype);
164 if (status != TT_OK) {
165 audit.exit(error_int(status));
166 return error_int(status);
169 result = _tt_otype_hsig_count(otype);
177 tt_otype_osig_op(const char *otype, int sig)
180 Tt_status status = audit.entry("oi", TT_OTYPE_OSIG_OP, otype, sig);
183 if (status != TT_OK) {
184 audit.exit((char *)error_pointer(status));
185 return (char *)error_pointer(status);
188 result = _tt_otype_osig_op(otype, sig);
196 tt_otype_hsig_op(const char *otype, int sig)
199 Tt_status status = audit.entry("oi", TT_OTYPE_HSIG_OP, otype, sig);
202 if (status != TT_OK) {
203 audit.exit((char *)error_pointer(status));
204 return (char *)error_pointer(status);
207 result = _tt_otype_hsig_op(otype, sig);
215 tt_otype_osig_args_count(const char *otype, int sig)
218 Tt_status status = audit.entry("oi", TT_OTYPE_OSIG_ARGS_COUNT, otype, sig);
221 if (status != TT_OK) {
222 audit.exit(error_int(status));
223 return error_int(status);
226 result = _tt_otype_osig_args_count(otype, sig);
234 tt_otype_hsig_args_count(const char *otype, int sig)
237 Tt_status status = audit.entry("oi", TT_OTYPE_HSIG_ARGS_COUNT, otype, sig);
240 if (status != TT_OK) {
241 audit.exit(error_int(status));
242 return error_int(status);
245 result = _tt_otype_hsig_args_count(otype, sig);
253 tt_otype_osig_arg_mode(const char *otype, int sig, int arg)
256 Tt_status status = audit.entry("oii", TT_OTYPE_OSIG_ARG_MODE, otype, sig, arg);
259 if (status != TT_OK) {
260 audit.exit((Tt_mode)error_int(status));
261 return (Tt_mode) error_int(status);
264 result = _tt_otype_osig_arg_mode(otype, sig, arg);
272 tt_otype_hsig_arg_mode(const char *otype, int sig, int arg)
275 Tt_status status = audit.entry("oii", TT_OTYPE_HSIG_ARG_MODE, otype, sig, arg);
278 if (status != TT_OK) {
279 audit.exit((Tt_mode)error_int(status));
280 return (Tt_mode)error_int(status);
283 result = _tt_otype_hsig_arg_mode(otype, sig, arg);
291 tt_otype_osig_arg_type(const char *otype, int sig, int arg)
294 Tt_status status = audit.entry("oii", TT_OTYPE_OSIG_ARG_TYPE, otype, sig, arg);
297 if (status != TT_OK) {
298 audit.exit((char *)error_pointer(status));
299 return (char *)error_pointer(status);
302 result = _tt_otype_osig_arg_type(otype, sig, arg);
310 tt_otype_hsig_arg_type(const char *otype, int sig, int arg)
313 Tt_status status = audit.entry("oii", TT_OTYPE_HSIG_ARG_TYPE, otype, sig, arg);
316 if (status != TT_OK) {
317 audit.exit((char *)error_pointer(status));
318 return (char *)error_pointer(status);
321 result = _tt_otype_hsig_arg_type(otype, sig, arg);
329 * otype retrieval functions
333 _tt_otype_deriveds_count(const char * otype)
336 _Tt_rpc_result result;
337 _Tt_c_session *d_session;
339 d_session = _tt_c_mp->default_c_procid()->default_session().c_pointer();
341 args.base_otid = otype;
342 d_session->call(TT_RPC_OTYPE_DERIVEDS_COUNT,
343 (xdrproc_t)tt_xdr_otype_args,
345 (xdrproc_t)tt_xdr_rpc_result,
347 if (result.status!=TT_OK) {
348 return error_int(result.status);
350 return result.int_val;
356 _tt_otype_derived(const char * otype, int i)
359 _Tt_rpc_result result;
360 _Tt_c_session *d_session;
362 d_session = _tt_c_mp->default_c_procid()->default_session().c_pointer();
364 args.base_otid = otype;
366 d_session->call(TT_RPC_OTYPE_DERIVED,
367 (xdrproc_t)tt_xdr_otype_args,
369 (xdrproc_t)tt_xdr_rpc_result,
371 if (result.status!=TT_OK) {
372 return (char *)error_pointer(result.status);
374 return _tt_strdup(result.str_val);
379 _tt_otype_base(const char *otype)
382 _Tt_rpc_result result;
383 _Tt_c_session *d_session = _tt_c_mp->default_c_procid()->default_session().c_pointer();
385 args.derived_otid = otype;
386 d_session->call(TT_RPC_OTYPE_BASE,
387 (xdrproc_t)tt_xdr_otype_args,
389 (xdrproc_t)tt_xdr_rpc_result,
391 if (result.status!=TT_OK) {
392 return (char *)error_pointer(result.status);
394 return _tt_strdup(result.str_val);
400 _tt_otype_is_derived(const char *derivedotype,
401 const char *baseotype)
404 _Tt_rpc_result result;
405 _Tt_c_session *d_session = _tt_c_mp->default_c_procid()->default_session().c_pointer();
408 args.derived_otid = derivedotype;
409 args.base_otid = baseotype;
411 d_session->call(TT_RPC_OTYPE_IS_DERIVED,
412 (xdrproc_t)tt_xdr_otype_args,
414 (xdrproc_t)tt_xdr_rpc_result,
416 if (result.status!=TT_OK) {
417 return 0; // Predicates that return failure are a pain
419 return result.int_val;
425 _tt_otype_osig_count(const char *otype)
428 _Tt_rpc_result result;
429 _Tt_c_session *d_session = _tt_c_mp->default_c_procid()->default_session().c_pointer();
431 args.base_otid = otype;
433 d_session->call(TT_RPC_OTYPE_OSIG_COUNT,
434 (xdrproc_t)tt_xdr_otype_args,
436 (xdrproc_t)tt_xdr_rpc_result,
438 if (result.status!=TT_OK) {
439 return error_int(result.status);
441 return result.int_val;
447 _tt_otype_hsig_count(const char *otype)
450 _Tt_rpc_result result;
451 _Tt_c_session *d_session = _tt_c_mp->default_c_procid()->default_session().c_pointer();
453 args.base_otid = otype;
455 d_session->call(TT_RPC_OTYPE_HSIG_COUNT,
456 (xdrproc_t)tt_xdr_otype_args,
458 (xdrproc_t)tt_xdr_rpc_result,
460 if (result.status!=TT_OK) {
461 return error_int(result.status);
463 return result.int_val;
469 _tt_otype_osig_op(const char *otype, int sig)
472 _Tt_rpc_result result;
473 _Tt_c_session *d_session = _tt_c_mp->default_c_procid()->default_session().c_pointer();
475 args.base_otid = otype;
478 d_session->call(TT_RPC_OTYPE_OSIG_OP,
479 (xdrproc_t)tt_xdr_otype_args,
481 (xdrproc_t)tt_xdr_rpc_result,
483 if (result.status!=TT_OK) {
484 return (char *)error_pointer(result.status);
486 return _tt_strdup(result.str_val);
492 _tt_otype_hsig_op(const char *otype, int sig)
495 _Tt_rpc_result result;
496 _Tt_c_session *d_session = _tt_c_mp->default_c_procid()->default_session().c_pointer();
498 args.base_otid = otype;
501 d_session->call(TT_RPC_OTYPE_HSIG_OP,
502 (xdrproc_t)tt_xdr_otype_args,
504 (xdrproc_t)tt_xdr_rpc_result,
506 if (result.status!=TT_OK) {
507 return (char *)error_pointer(result.status);
509 return _tt_strdup(result.str_val);
515 _tt_otype_osig_args_count(const char *otype, int sig)
518 _Tt_rpc_result result;
519 _Tt_c_session *d_session = _tt_c_mp->default_c_procid()->default_session().c_pointer();
521 args.base_otid = otype;
524 d_session->call(TT_RPC_OTYPE_OSIG_ARGS_COUNT,
525 (xdrproc_t)tt_xdr_otype_args,
527 (xdrproc_t)tt_xdr_rpc_result,
529 if (result.status!=TT_OK) {
530 return error_int(result.status);
532 return result.int_val;
538 _tt_otype_hsig_args_count(const char *otype, int sig)
541 _Tt_rpc_result result;
542 _Tt_c_session *d_session;
544 d_session = _tt_c_mp->default_c_procid()->default_session().c_pointer();
546 args.base_otid = otype;
549 d_session->call(TT_RPC_OTYPE_HSIG_ARGS_COUNT,
550 (xdrproc_t)tt_xdr_otype_args,
552 (xdrproc_t)tt_xdr_rpc_result,
554 if (result.status!=TT_OK) {
555 return error_int(result.status);
557 return result.int_val;
563 _tt_otype_osig_arg_mode(const char *otype, int sig, int arg)
566 _Tt_rpc_result result;
567 _Tt_c_session *d_session = _tt_c_mp->default_c_procid()->default_session().c_pointer();
569 args.base_otid = otype;
573 d_session->call(TT_RPC_OTYPE_OSIG_ARG_MODE,
574 (xdrproc_t)tt_xdr_otype_args,
576 (xdrproc_t)tt_xdr_rpc_result,
578 if (result.status!=TT_OK) {
579 return (Tt_mode)error_int(result.status);
581 return (Tt_mode)result.int_val;
587 _tt_otype_hsig_arg_mode(const char *otype, int sig, int arg)
590 _Tt_rpc_result result;
591 _Tt_c_session *d_session;
593 d_session = _tt_c_mp->default_c_procid()->default_session().c_pointer();
595 args.base_otid = otype;
599 d_session->call(TT_RPC_OTYPE_HSIG_ARG_MODE,
600 (xdrproc_t)tt_xdr_otype_args,
602 (xdrproc_t)tt_xdr_rpc_result,
604 if (result.status!=TT_OK) {
605 return (Tt_mode)error_int(result.status);
607 return (Tt_mode)result.int_val;
613 _tt_otype_osig_arg_type(const char *otype, int sig, int arg)
616 _Tt_rpc_result result;
617 _Tt_c_session *d_session = _tt_c_mp->default_c_procid()->default_session().c_pointer();
619 args.base_otid = otype;
623 d_session->call(TT_RPC_OTYPE_OSIG_ARG_TYPE,
624 (xdrproc_t)tt_xdr_otype_args,
626 (xdrproc_t)tt_xdr_rpc_result,
628 if (result.status!=TT_OK) {
629 return (char *)error_pointer(result.status);
631 return _tt_strdup(result.str_val);
637 _tt_otype_hsig_arg_type(const char *otype, int sig, int arg)
640 _Tt_rpc_result result;
641 _Tt_c_session *d_session = _tt_c_mp->default_c_procid()->default_session().c_pointer();
643 args.base_otid = otype;
647 d_session->call(TT_RPC_OTYPE_HSIG_ARG_TYPE,
648 (xdrproc_t)tt_xdr_otype_args,
650 (xdrproc_t)tt_xdr_rpc_result,
652 if (result.status!=TT_OK) {
653 return (char *)error_pointer(result.status);
655 return _tt_strdup(result.str_val);
660 * Check to see if the given typename is a valid otype by getting its
661 * base class. If the otype doesn't exist, an error will be returned.
664 _tt_valid_otype(const char *otype)
667 _Tt_rpc_result result;
668 _Tt_c_session *d_session;
670 d_session = _tt_c_mp->default_c_procid()->default_session().c_pointer();
672 args.derived_otid = otype;
673 d_session->call(TT_RPC_OTYPE_BASE,
674 (xdrproc_t)tt_xdr_otype_args,
676 (xdrproc_t)tt_xdr_rpc_result,
678 return result.status;