002f6699dccd4e4f33527b37fdbc50a0029c200a
[oweals/cde.git] / cde / lib / tt / lib / mp / mp_xdr_functions.C
1  //%%  (c) Copyright 1993, 1994 Hewlett-Packard Company                 
2 //%%  (c) Copyright 1993, 1994 International Business Machines Corp.    
3 //%%  (c) Copyright 1993, 1994 Sun Microsystems, Inc.                   
4 //%%  (c) Copyright 1993, 1994 Novell, Inc.                             
5 //%%  $TOG: mp_xdr_functions.C /main/4 1999/08/30 11:00:02 mgreess $                                                    
6 /*
7  *
8  * @(#)mp_xdr_functions.C       1.14 93/07/30
9  *
10  * Tool Talk Message Passer (MP) - mp_xdr_functions.cc
11  *
12  * Copyright (c) 1990 by Sun Microsystems, Inc.
13  */
14 #include <string.h>
15 #include "mp/mp_xdr_functions.h"
16
17 /*
18  * XDR function to de/encode args when TT_AUTH_ICEAUTH authorization is
19  * in effect.
20  */
21 bool_t
22 tt_xdr_auth_iceauth_args(XDR *xdrs, _Tt_auth_iceauth_args *args)
23 {
24         return(args->auth_cookie.xdr(xdrs) && args->inproc(xdrs, args->inargs));
25 }
26
27 /* 
28  * XDR encodes/decodes a null terminated string.
29  */
30 bool_t
31 tt_xdr_bstring(XDR *xdrs, char **sp)
32 {
33         int             length;
34
35         if (xdrs->x_op == XDR_ENCODE) {
36                 length = ((sp && *sp) ? strlen(*sp) : 0);
37         }
38         if (!xdr_int(xdrs, &length)) return 0;
39         if (0==length) {
40                 if (xdrs->x_op == XDR_DECODE) {
41                         *sp = (char *)0;
42                 }
43                 return(1);
44         }
45         if (xdrs->x_op == XDR_DECODE) {
46                 *sp = (char *)malloc(length+1);
47         }
48         if (!xdr_string(xdrs, sp, length)) return 0;
49         if (xdrs->x_op == XDR_FREE) {
50                 free((MALLOCTYPE *) *sp);
51         }
52         return(1);
53 }
54
55
56 /* 
57  * XDR function to encode args to declare_ptype operation.
58  */
59 bool_t
60 tt_xdr_declare_ptype_args(XDR *xdrs, _Tt_declare_ptype_args *args)
61 {
62         return(args->procid.xdr(xdrs) && args->ptid.xdr(xdrs));
63 }
64
65
66 /* 
67  * XDR function to encode args to join_file operation.
68  */
69 bool_t
70 tt_xdr_file_join_args(XDR *xdrs, _Tt_file_join_args *args)
71 {
72         return(args->procid.xdr(xdrs) && args->path.xdr(xdrs));
73 }
74
75
76 /* 
77  * XDR function to encode args identifying a <context,procID> pair
78  */
79 bool_t
80 tt_xdr_context_join_args(XDR *xdrs, _Tt_context_join_args *args)
81 {
82         return args->procid.xdr(xdrs) && args->context.xdr(xdrs);
83 }
84
85
86 /* 
87  * XDR encodes/decodes a _Tt_fd_args structure.
88  */
89 bool_t
90 tt_xdr_fd_args(XDR *xdrs, _Tt_fd_args *args)
91 {
92         return(args->procid.xdr(xdrs)
93                && xdr_int(xdrs, &args->fd)
94                && args->start_token.xdr(xdrs));
95 }
96
97
98 bool_t
99 tt_xdr_add_pattern_args(XDR *xdrs,_Tt_add_pattern_args *args)
100 {
101         return(args->procid.xdr(xdrs) && args->pattern.xdr(xdrs));
102 }
103
104
105 bool_t
106 tt_xdr_del_pattern_args(XDR *xdrs,_Tt_del_pattern_args *args)
107 {
108         return(args->procid.xdr(xdrs) && args->pattern_id.xdr(xdrs));
109 }
110
111
112 /* 
113  * XDR function to encode/decode property values
114  */
115 bool_t
116 tt_xdr_prop_args(XDR *xdrs, _Tt_prop_args *args)
117 {
118         return(args->prop.xdr(xdrs) && args->value.xdr(xdrs) &&
119                xdr_int(xdrs, &args->num));
120 }
121
122 /* 
123  * XDR function to encode/decode otype query values
124  */
125 bool_t
126 tt_xdr_otype_args(XDR *xdrs, _Tt_otype_args *args)
127 {
128         return(args->derived_otid.xdr(xdrs) &&
129                args->base_otid.xdr(xdrs) &&
130                xdr_int(xdrs, &args->num) &&
131                xdr_int(xdrs, &args->num2));
132 }
133
134 /* 
135  * XDR function to encode/decode the result of a session property request
136  * or a otype query request.
137  */
138 bool_t
139 tt_xdr_rpc_result(XDR *xdrs, _Tt_rpc_result *args)
140 {
141         return(xdr_int(xdrs, (int *)&args->status) && args->str_val.xdr(xdrs)
142                && xdr_int(xdrs, &args->int_val));
143 }
144
145
146 bool_t
147 tt_xdr_update_args(XDR *xdrs, _Tt_update_args *args)
148 {
149         return( xdr_int(xdrs, (int *)&args->newstate) &&
150                args->message.xdr(xdrs));
151 }
152
153
154 bool_t
155 tt_xdr_next_message_args(XDR *xdrs, _Tt_next_message_args *args)
156 {
157         return(args->msgs.xdr(xdrs) &&
158                xdr_int(xdrs, (int *)&args->clear_signal));
159 }
160         
161 bool_t
162 tt_xdr_dispatch_reply_args(XDR *xdrs, _Tt_dispatch_reply_args *args)
163 {
164         return(xdr_int(xdrs, (int *)&args->status) &&
165                args->qmsg_info.xdr(xdrs));
166 }
167
168 bool_t
169 tt_xdr_load_types_args(XDR *xdrs,_Tt_load_types_args *args)
170 {
171         return(args->xdrtypes.xdr(xdrs));
172 }