1/* 2 * Copyright (c) 2010 Apple Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. Neither the name of Apple Inc. ("Apple") nor the names of its 16 * contributors may be used to endorse or promote products derived from 17 * this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * 30 * Portions of this software have been released under the following terms: 31 * 32 * (c) Copyright 1989-1993 OPEN SOFTWARE FOUNDATION, INC. 33 * (c) Copyright 1989-1993 HEWLETT-PACKARD COMPANY 34 * (c) Copyright 1989-1993 DIGITAL EQUIPMENT CORPORATION 35 * 36 * To anyone who acknowledges that this file is provided "AS IS" 37 * without any express or implied warranty: 38 * permission to use, copy, modify, and distribute this file for any 39 * purpose is hereby granted without fee, provided that the above 40 * copyright notices and this notice appears in all source code copies, 41 * and that none of the names of Open Software Foundation, Inc., Hewlett- 42 * Packard Company or Digital Equipment Corporation be used 43 * in advertising or publicity pertaining to distribution of the software 44 * without specific, written prior permission. Neither Open Software 45 * Foundation, Inc., Hewlett-Packard Company nor Digital 46 * Equipment Corporation makes any representations about the suitability 47 * of this software for any purpose. 48 * 49 * Copyright (c) 2007, Novell, Inc. All rights reserved. 50 * Redistribution and use in source and binary forms, with or without 51 * modification, are permitted provided that the following conditions 52 * are met: 53 * 54 * 1. Redistributions of source code must retain the above copyright 55 * notice, this list of conditions and the following disclaimer. 56 * 2. Redistributions in binary form must reproduce the above copyright 57 * notice, this list of conditions and the following disclaimer in the 58 * documentation and/or other materials provided with the distribution. 59 * 3. Neither the name of Novell Inc. nor the names of its contributors 60 * may be used to endorse or promote products derived from this 61 * this software without specific prior written permission. 62 * 63 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 64 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 65 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 66 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY 67 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 68 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 69 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 70 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 71 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 72 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 73 * 74 * @APPLE_LICENSE_HEADER_END@ 75 */ 76 77/* 78** 79** ndrui5.c 80** 81** FACILITY: 82** 83** Interface Definition Language (IDL) Compiler 84** 85** ABSTRACT: 86** 87** NDR unmarshalling routines for - International characters 88** 89*/ 90#if HAVE_CONFIG_H 91#include <config.h> 92#endif 93 94#include <dce/idlddefs.h> 95#include <ndrui.h> 96#include <lsysdep.h> 97#include <ndrmi.h> 98 99/******************************************************************************/ 100/* */ 101/* Unmarshall the conformance information for a conformant structure when */ 102/* the conformant array field has [cs_char] base type */ 103/* Such an array must be 1-dimensional, fixed lower bound and [size_is] */ 104/* Get the local size of the array. If necessary, allocate the structure */ 105/* Return conversion type and local size */ 106/* */ 107/******************************************************************************/ 108void rpc_ss_ndr_u_conf_cs_struct_hdr 109( 110 idl_byte *struct_defn_ptr, /* [in] Start of structure definition */ 111 idl_byte *array_defn_ptr, /* [in] Points at start of bounds info */ 112 idl_ulong_int *Z_values, /* [in] Unmarshalled Z value */ 113 idl_ulong_int fixed_part_size, /* [in] size of structure excluding 114 conformant array */ 115 idl_boolean type_has_pointers, /* [in] */ 116 idl_ulong_int conf_arr_shadow_index, /* [in] index in shadow of 117 conformant array */ 118 idl_boolean allocate, /* [in] TRUE=>structure must be allocated */ 119 IDL_cs_shadow_elt_t *cs_shadow, 120 /* [out] convert type and local value of [size_is] */ 121 rpc_void_p_t *p_param_addr, /* [out] NULL or where to put address of 122 allocated structure */ 123 IDL_msp_t IDL_msp 124) 125{ 126 idl_ulong_int sz_index; /* Index in shadow of [size_is] item */ 127 idl_ulong_int cs_type_defn_index; 128 idl_byte *cs_type_defn_ptr; 129 idl_ulong_int routine_index; 130 void (**routine_ptr)(); 131 idl_ulong_int l_storage_len; 132 idl_byte *base_type_defn_ptr; /* Pointer to base type of array */ 133 134 /* Skip over lower bound entirely and upper bound kind and type */ 135 array_defn_ptr += IDL_CONF_BOUND_PAIR_WIDTH/2 + 2; 136 IDL_GET_LONG_FROM_VECTOR(sz_index, array_defn_ptr); 137 sz_index--; 138 /* array_defn_ptr is now pointing to the base type, which has [cs_char] */ 139 base_type_defn_ptr = array_defn_ptr; 140 array_defn_ptr += 2; /* IDL_DT_CS_TYPE and properties byte */ 141 IDL_GET_LONG_FROM_VECTOR(cs_type_defn_index, array_defn_ptr); 142 cs_type_defn_ptr = IDL_msp->IDL_type_vec + cs_type_defn_index; 143 IDL_DISCARD_LONG_FROM_VECTOR(cs_type_defn_ptr); /* Size of local type */ 144 IDL_GET_LONG_FROM_VECTOR(routine_index, cs_type_defn_ptr); 145 routine_ptr = IDL_msp->IDL_rtn_vec + routine_index; 146 147 /* Call ..._local_size */ 148 (*(routine_ptr + IDL_RTN_LOCAL_SIZE_INDEX))(IDL_msp->IDL_h, 149 *(IDL_msp->IDL_cs_tags_p->p_unmar_tag), 150 *Z_values, 151 &cs_shadow[conf_arr_shadow_index].IDL_convert_type, 152 &l_storage_len, 153 &(IDL_msp->IDL_status)); 154 if (IDL_msp->IDL_status != error_status_ok) 155 DCETHREAD_RAISE(rpc_x_ss_pipe_comm_error); 156 157 cs_shadow[sz_index].IDL_data.IDL_value = l_storage_len; 158 159 if (allocate) 160 { 161 rpc_ss_ndr_alloc_storage(fixed_part_size, 1, &l_storage_len, 162 base_type_defn_ptr, p_param_addr, IDL_msp); 163 if (type_has_pointers) 164 { 165 rpc_ss_init_new_struct_ptrs(IDL_DT_CONF_STRUCT, struct_defn_ptr, 166 *p_param_addr, &l_storage_len, IDL_msp); 167 } 168 } 169} 170 171/******************************************************************************/ 172/* */ 173/* Unmarshall an array of [cs_char]s */ 174/* */ 175/******************************************************************************/ 176void rpc_ss_ndr_unmar_cs_array 177( 178 rpc_void_p_t array_addr, /* [in] */ 179 IDL_cs_shadow_elt_t *cs_shadow, /* [in] ignored for fixed array */ 180 idl_ulong_int *Z_values, /* [in] ignored if array not conformant */ 181 idl_ulong_int array_shadow_index, /* [in] ignored if array not conformant 182 Position of array in cs-shadow */ 183 idl_byte **p_defn_vec_ptr, /* [in] Points at DT_..._ARRAY 184 [out] Points after array definition */ 185 IDL_msp_t IDL_msp 186) 187{ 188 idl_byte *defn_vec_ptr; 189 idl_byte array_type; 190 idl_boolean conformant; /* TRUE => array is conformant or open */ 191 idl_ulong_int array_defn_index; 192 idl_byte *array_defn_ptr; 193 IDL_bound_pair_t *bounds_list; 194 IDL_bound_pair_t range_data; 195 idl_ulong_int cs_type_defn_index; 196 idl_byte *cs_type_defn_ptr; 197 idl_ulong_int routine_index; 198 idl_ulong_int ln_index; /* Index in shadow of [length_is] item */ 199 idl_ulong_int sz_index; /* Index in shadow of [size_is] item */ 200 void (**routine_ptr)(); 201 /* Parameters for ..._net_size */ 202 idl_ulong_int l_storage_len; 203 idl_ulong_int w_storage_len; 204 idl_cs_convert_t convert_type; 205 /* Parameters for ..._to_netcs */ 206 idl_ulong_int l_data_len; 207 rpc_void_p_t wdata; 208 idl_ulong_int w_data_len; 209 210 defn_vec_ptr = *p_defn_vec_ptr; 211 array_type = *defn_vec_ptr; 212 conformant = ! ((array_type == IDL_DT_FIXED_ARRAY) 213 || (array_type == IDL_DT_VARYING_ARRAY)); 214 defn_vec_ptr += 2; /* Array type and properties byte */ 215 IDL_DISCARD_LONG_FROM_VECTOR(defn_vec_ptr); /* Full array definition */ 216 IDL_GET_LONG_FROM_VECTOR(array_defn_index, defn_vec_ptr); 217 array_defn_ptr = IDL_msp->IDL_type_vec + array_defn_index; 218 array_defn_ptr++; /* dimensionality */ 219 220 if ( ! conformant ) 221 { 222 if (IDL_msp->IDL_type_vec[TVEC_INT_REP_OFFSET] != NDR_LOCAL_INT_REP) 223 rpc_ss_fixed_bounds_from_vector(1, array_defn_ptr, &bounds_list, 224 IDL_msp); 225 else 226 bounds_list = (IDL_bound_pair_t *)array_defn_ptr; 227 array_defn_ptr += IDL_FIXED_BOUND_PAIR_WIDTH; 228 w_storage_len = bounds_list[0].upper - bounds_list[0].lower + 1; 229 l_storage_len = w_storage_len; 230 } 231 else /* Conformant or open */ 232 { 233 /* Skip over lower bound entirely and upper bound kind and type */ 234 array_defn_ptr += IDL_CONF_BOUND_PAIR_WIDTH/2 + 2; 235 IDL_GET_LONG_FROM_VECTOR(sz_index, array_defn_ptr); 236 sz_index--; 237 l_storage_len = cs_shadow[sz_index].IDL_data.IDL_value; 238 w_storage_len = *Z_values; 239 } 240 241 /* Data limit information */ 242 if ((array_type == IDL_DT_VARYING_ARRAY) 243 || (array_type == IDL_DT_OPEN_ARRAY)) 244 { 245 idl_ulong_int lower; 246 /* Skip over lower data limit entirely and upper data limit kind */ 247 array_defn_ptr += IDL_DATA_LIMIT_PAIR_WIDTH/2 + 1; 248 IDL_GET_LONG_FROM_VECTOR(ln_index, array_defn_ptr); 249 ln_index--; 250 IDL_UNMAR_ULONG(&lower); /* A-value */ 251 range_data.lower = lower; 252 /* The B-value is the wire form of [length_is] */ 253 IDL_UNMAR_ULONG(&w_data_len); 254 range_data.upper = range_data.lower + w_data_len; 255 } 256 else 257 w_data_len = w_storage_len; 258 259 /* array_defn_ptr is now pointing to the base type, which has [cs_char] */ 260 array_defn_ptr += 2; /* IDL_DT_CS_TYPE and properties byte */ 261 IDL_GET_LONG_FROM_VECTOR(cs_type_defn_index, array_defn_ptr); 262 cs_type_defn_ptr = IDL_msp->IDL_type_vec + cs_type_defn_index; 263 IDL_DISCARD_LONG_FROM_VECTOR(cs_type_defn_ptr); /* Size of local type */ 264 IDL_GET_LONG_FROM_VECTOR(routine_index, cs_type_defn_ptr); 265 routine_ptr = IDL_msp->IDL_rtn_vec + routine_index; 266 /* cs_type_defn_ptr now pointing at network type definition */ 267 268 if ( conformant ) 269 convert_type = cs_shadow[array_shadow_index].IDL_convert_type; 270 else 271 { 272 /* Call ..._local_size */ 273 (*(routine_ptr + IDL_RTN_LOCAL_SIZE_INDEX))(IDL_msp->IDL_h, 274 *(IDL_msp->IDL_cs_tags_p->p_unmar_tag), 275 w_storage_len, 276 &convert_type, 277 ( ! conformant ) ? NULL : &l_storage_len, 278 &IDL_msp->IDL_status); 279 if (IDL_msp->IDL_status != error_status_ok) 280 DCETHREAD_RAISE(rpc_x_ss_pipe_comm_error); 281 } 282 283 if (convert_type == idl_cs_new_buffer_convert) 284 { 285 wdata = (rpc_void_p_t)rpc_ss_mem_alloc(&IDL_msp->IDL_mem_handle, 286 w_storage_len * rpc_ss_type_size(cs_type_defn_ptr, 287 IDL_msp)); 288 } 289 else 290 wdata = array_addr; 291 292 /* Unmarshall the wire form of the data */ 293 if ((array_type == IDL_DT_FIXED_ARRAY) 294 || (array_type == IDL_DT_CONF_ARRAY)) 295 { 296 rpc_ss_ndr_u_fix_or_conf_arr(1, &w_storage_len, cs_type_defn_ptr, 297 wdata, 0, IDL_msp); 298 w_data_len = w_storage_len; 299 } 300 else /* Varying or open */ 301 { 302 rpc_ss_ndr_u_var_or_open_arr(1, &w_storage_len, cs_type_defn_ptr, 303 wdata, &range_data, 0, IDL_msp); 304 } 305 306 if (convert_type != idl_cs_no_convert) 307 { 308 /* Call ..._from_netcs */ 309 (*(routine_ptr + IDL_RTN_FROM_NETCS_INDEX))(IDL_msp->IDL_h, 310 *(IDL_msp->IDL_cs_tags_p->p_unmar_tag), 311 wdata, 312 w_data_len, 313 l_storage_len, 314 array_addr, 315 ((array_type == IDL_DT_FIXED_ARRAY) 316 || (array_type == IDL_DT_CONF_ARRAY)) ? NULL : &l_data_len, 317 &IDL_msp->IDL_status); 318 if (IDL_msp->IDL_status != error_status_ok) 319 DCETHREAD_RAISE(rpc_x_ss_codeset_conv_error); 320 } 321 else 322 { 323 l_data_len = w_data_len; 324 } 325 326 if ((array_type == IDL_DT_VARYING_ARRAY) 327 || (array_type == IDL_DT_OPEN_ARRAY)) 328 { 329 cs_shadow[ln_index].IDL_data.IDL_value = l_data_len; 330 } 331 332 if (convert_type == idl_cs_new_buffer_convert) 333 { 334 rpc_ss_mem_item_free(&IDL_msp->IDL_mem_handle, wdata); 335 } 336 337 *p_defn_vec_ptr = defn_vec_ptr; 338 if (IDL_msp->IDL_type_vec[TVEC_INT_REP_OFFSET] != NDR_LOCAL_INT_REP) 339 if ( ! conformant ) 340 rpc_ss_mem_item_free(&IDL_msp->IDL_mem_handle, (byte_p_t)bounds_list); 341} 342 343/******************************************************************************/ 344/* */ 345/* Unmarshall a [cs_char] which is not an array element */ 346/* */ 347/******************************************************************************/ 348void rpc_ss_ndr_unmar_cs_char 349( 350 rpc_void_p_t data_addr, /* [in] */ 351 idl_ulong_int cs_type_defn_index, /* [in] */ 352 IDL_msp_t IDL_msp 353) 354{ 355 idl_byte *cs_type_defn_ptr; 356 idl_ulong_int routine_index; 357 void (**routine_ptr)(); 358 /* Parameters for ..._net_size */ 359 idl_ulong_int w_storage_len = 1; 360 idl_cs_convert_t convert_type; 361 /* Parameters for ..._to_netcs */ 362 rpc_void_p_t wdata; 363 364 cs_type_defn_ptr = IDL_msp->IDL_type_vec + cs_type_defn_index; 365 IDL_DISCARD_LONG_FROM_VECTOR(cs_type_defn_ptr); /* Size of local type */ 366 IDL_GET_LONG_FROM_VECTOR(routine_index, cs_type_defn_ptr); 367 routine_ptr = IDL_msp->IDL_rtn_vec + routine_index; 368 369 /* Call ..._local_size */ 370 (*(routine_ptr + IDL_RTN_LOCAL_SIZE_INDEX))(IDL_msp->IDL_h, 371 *(IDL_msp->IDL_cs_tags_p->p_unmar_tag), 372 w_storage_len, 373 &convert_type, 374 NULL, 375 &IDL_msp->IDL_status); 376 if (IDL_msp->IDL_status != error_status_ok) 377 DCETHREAD_RAISE(rpc_x_ss_pipe_comm_error); 378 379 if (convert_type == idl_cs_new_buffer_convert) 380 { 381 /* Allocate a conversion buffer 382 - cs_type_defn_ptr now points at network type */ 383 wdata = (idl_void_p_t)rpc_ss_mem_alloc(&IDL_msp->IDL_mem_handle, 384 rpc_ss_type_size(cs_type_defn_ptr, IDL_msp)); 385 } 386 else 387 wdata = data_addr; 388 389 rpc_ss_ndr_u_fix_or_conf_arr(1, &w_storage_len, cs_type_defn_ptr, 390 wdata, 0, IDL_msp); 391 if (convert_type != idl_cs_no_convert) 392 { 393 /* Call ..._from_netcs */ 394 (*(routine_ptr + IDL_RTN_FROM_NETCS_INDEX))(IDL_msp->IDL_h, 395 *(IDL_msp->IDL_cs_tags_p->p_unmar_tag), 396 wdata, 397 w_storage_len, 398 w_storage_len, 399 data_addr, 400 NULL, 401 &IDL_msp->IDL_status); 402 if (IDL_msp->IDL_status != error_status_ok) 403 DCETHREAD_RAISE(rpc_x_ss_codeset_conv_error); 404 } 405 406 if (convert_type == idl_cs_new_buffer_convert) 407 { 408 /* Release conversion buffer */ 409 rpc_ss_mem_item_free(&IDL_msp->IDL_mem_handle, (byte_p_t)wdata); 410 } 411} 412 413/******************************************************************************/ 414/* */ 415/* Update [length_is] and [size_is] fields associated with arrays of */ 416/* [cs_char] from the cs-shadow for a structure. Then release the cs-shadow */ 417/* */ 418/******************************************************************************/ 419void rpc_ss_ndr_u_struct_cs_shadow 420( 421 rpc_void_p_t struct_addr, /* [in] Address of struct */ 422 idl_byte struct_type ATTRIBUTE_UNUSED, /* [in] FIXED_STRUCT or CONF_STRUCT */ 423 idl_ulong_int offset_index, /* [in] Start of struct's offset vec */ 424 idl_byte *defn_vec_ptr, /* [in] Posn following shadow length */ 425 IDL_cs_shadow_elt_t *cs_shadow, /* [in] Address of cs-shadow */ 426 IDL_msp_t IDL_msp 427) 428{ 429 idl_ulong_int *offset_vec_ptr; 430 idl_byte type_byte; 431 idl_ulong_int shadow_index; /* Index into cs-shadow */ 432 433 offset_vec_ptr = IDL_msp->IDL_offset_vec + offset_index + 1; 434 /* Skip over size at start of offsets */ 435 436 shadow_index = 0; 437 do { 438 type_byte = *defn_vec_ptr; 439 defn_vec_ptr++; 440 switch(type_byte) 441 { 442 case IDL_DT_CS_ATTRIBUTE: 443 /* The local value of the attribute variable is taken from the 444 shadow */ 445 rpc_ss_put_typed_integer( 446 cs_shadow[shadow_index].IDL_data.IDL_value, 447 *defn_vec_ptr, 448 (rpc_void_p_t)((idl_byte *)struct_addr + *offset_vec_ptr)); 449 defn_vec_ptr++; /* attribute type */ 450 shadow_index++; 451 offset_vec_ptr++; 452 break; 453 case IDL_DT_BYTE: 454 case IDL_DT_CHAR: 455 case IDL_DT_BOOLEAN: 456 case IDL_DT_DOUBLE: 457 case IDL_DT_ENUM: 458 case IDL_DT_FLOAT: 459 case IDL_DT_SMALL: 460 case IDL_DT_SHORT: 461 case IDL_DT_LONG: 462 case IDL_DT_HYPER: 463 case IDL_DT_USMALL: 464 case IDL_DT_USHORT: 465 case IDL_DT_ULONG: 466 case IDL_DT_UHYPER: 467 case IDL_DT_IGNORE: 468 case IDL_DT_V1_ENUM: 469 case IDL_DT_ERROR_STATUS: 470 offset_vec_ptr++; 471 shadow_index++; 472 break; 473 case IDL_DT_FIXED_ARRAY: 474 case IDL_DT_VARYING_ARRAY: 475 case IDL_DT_CONF_ARRAY: 476 case IDL_DT_OPEN_ARRAY: 477 /* Properties byte */ 478 defn_vec_ptr++; 479 IDL_DISCARD_LONG_FROM_VECTOR(defn_vec_ptr); 480 /* Full array definition */ 481 IDL_DISCARD_LONG_FROM_VECTOR(defn_vec_ptr); 482 /* Flattened array definition */ 483 offset_vec_ptr++; 484 cs_shadow[shadow_index].IDL_release = idl_false; 485 shadow_index++; 486 break; 487 case IDL_DT_ENC_UNION: 488 case IDL_DT_N_E_UNION: 489 case IDL_DT_FULL_PTR: 490 case IDL_DT_UNIQUE_PTR: 491 case IDL_DT_REF_PTR: 492 case IDL_DT_TRANSMIT_AS: 493 case IDL_DT_REPRESENT_AS: 494 case IDL_DT_CS_TYPE: 495 /* Properties byte */ 496 defn_vec_ptr++; 497 IDL_DISCARD_LONG_FROM_VECTOR(defn_vec_ptr); 498 offset_vec_ptr++; 499 shadow_index++; 500 break; 501 case IDL_DT_RANGE: 502 IDL_DISCARD_LONG_FROM_VECTOR(defn_vec_ptr); 503 IDL_DISCARD_LONG_FROM_VECTOR(defn_vec_ptr); 504 break; 505 case IDL_DT_STRING: 506 case IDL_DT_NDR_ALIGN_2: 507 case IDL_DT_NDR_ALIGN_4: 508 case IDL_DT_NDR_ALIGN_8: 509 case IDL_DT_BEGIN_NESTED_STRUCT: 510 case IDL_DT_END_NESTED_STRUCT: 511 case IDL_DT_V1_ARRAY: 512 case IDL_DT_V1_STRING: 513 case IDL_DT_CS_ARRAY: 514 case IDL_DT_CS_RLSE_SHADOW: 515 case IDL_DT_EOL: 516 break; 517 default: 518#ifdef DEBUG_INTERP 519 printf("rpc_ss_ndr_u_struct_cs_shadow:unrecognized type %d\n", 520 type_byte); 521 exit(0); 522#endif 523 DCETHREAD_RAISE(rpc_x_coding_error); 524 } 525 } while (type_byte != IDL_DT_EOL); 526 527 /* Release the cs-shadow */ 528 rpc_ss_mem_item_free(&IDL_msp->IDL_mem_handle, (byte_p_t)cs_shadow); 529} 530 531/******************************************************************************/ 532/* */ 533/* Update [length_is] and [size_is] fields associated with arrays of */ 534/* [cs_char] from the cs-shadow for a parameter list. Then release the */ 535/* cs-shadow */ 536/* */ 537/******************************************************************************/ 538void rpc_ss_ndr_u_param_cs_shadow 539( 540 idl_ulong_int type_index, /* [in] Index of start of definitions of 541 parameter list */ 542 IDL_cs_shadow_elt_t *cs_shadow, /* [in] Address of cs-shadow */ 543 IDL_msp_t IDL_msp 544) 545{ 546 idl_byte *type_vec_ptr; 547 idl_byte type_byte; 548 idl_ulong_int param_index; 549 550 /* Loop over parameters. Exit when DT_RLSE_SHADOW found */ 551 type_vec_ptr = (IDL_msp->IDL_type_vec) + type_index; 552 for ( ; ; ) 553 { 554 IDL_GET_LONG_FROM_VECTOR(param_index,type_vec_ptr); 555 do { 556 type_byte = *type_vec_ptr; 557 type_vec_ptr++; 558 switch(type_byte) 559 { 560 case IDL_DT_CS_ATTRIBUTE: 561 /* The local value of the attribute variable is taken from 562 the shadow */ 563 rpc_ss_put_typed_integer( 564 cs_shadow[param_index-1].IDL_data.IDL_value, 565 *type_vec_ptr, 566 IDL_msp->IDL_param_vec[param_index]); 567 type_vec_ptr++; /* attribute type */ 568 break; 569 /* For any other parameters we just need to move over them */ 570 case IDL_DT_BYTE: 571 case IDL_DT_CHAR: 572 case IDL_DT_BOOLEAN: 573 case IDL_DT_DOUBLE: 574 case IDL_DT_ENUM: 575 case IDL_DT_FLOAT: 576 case IDL_DT_SMALL: 577 case IDL_DT_SHORT: 578 case IDL_DT_LONG: 579 case IDL_DT_HYPER: 580 case IDL_DT_USMALL: 581 case IDL_DT_USHORT: 582 case IDL_DT_ULONG: 583 case IDL_DT_UHYPER: 584 case IDL_DT_IGNORE: 585 case IDL_DT_V1_ENUM: 586 case IDL_DT_ERROR_STATUS: 587 case IDL_DT_IN_CONTEXT: 588 case IDL_DT_IN_OUT_CONTEXT: 589 case IDL_DT_OUT_CONTEXT: 590 break; 591 case IDL_DT_FIXED_ARRAY: 592 case IDL_DT_VARYING_ARRAY: 593 case IDL_DT_CONF_ARRAY: 594 case IDL_DT_OPEN_ARRAY: 595 /* Properties byte */ 596 type_vec_ptr++; 597 IDL_DISCARD_LONG_FROM_VECTOR(type_vec_ptr); 598 /* Full array definition */ 599 IDL_DISCARD_LONG_FROM_VECTOR(type_vec_ptr); 600 /* Flattened array definition */ 601 break; 602 case IDL_DT_FIXED_STRUCT: 603 case IDL_DT_CONF_STRUCT: 604 case IDL_DT_V1_CONF_STRUCT: 605 case IDL_DT_ENC_UNION: 606 case IDL_DT_N_E_UNION: 607 case IDL_DT_FULL_PTR: 608 case IDL_DT_UNIQUE_PTR: 609 case IDL_DT_REF_PTR: 610 case IDL_DT_TRANSMIT_AS: 611 case IDL_DT_REPRESENT_AS: 612 case IDL_DT_PIPE: 613 case IDL_DT_CS_TYPE: 614 /* Properties byte */ 615 type_vec_ptr++; 616 IDL_DISCARD_LONG_FROM_VECTOR(type_vec_ptr); 617 break; 618 case IDL_DT_ALLOCATE_REF: 619 rpc_ss_discard_allocate_ref(&type_vec_ptr); 620 break; 621 case IDL_DT_CS_SHADOW: 622 case IDL_DT_FREE_REP: 623 IDL_DISCARD_LONG_FROM_VECTOR(type_vec_ptr); 624 break; 625 case IDL_DT_PASSED_BY_REF: 626 case IDL_DT_STRING: 627 case IDL_DT_ALLOCATE: 628 case IDL_DT_V1_ARRAY: 629 case IDL_DT_V1_STRING: 630 case IDL_DT_DELETED_NODES: 631 case IDL_DT_CS_ARRAY: 632 break; 633 case IDL_DT_CS_RLSE_SHADOW: 634 rpc_ss_mem_item_free(&IDL_msp->IDL_mem_handle, 635 (byte_p_t)cs_shadow); 636 return; 637 case IDL_DT_RANGE: 638 IDL_DISCARD_LONG_FROM_VECTOR(type_vec_ptr); 639 IDL_DISCARD_LONG_FROM_VECTOR(type_vec_ptr); 640 break; 641 case IDL_DT_EOL: 642 break; 643 default: 644#ifdef DEBUG_INTERP 645 printf("rpc_ss_ndr_u_param_cs_shadow:unrecognized type %d\n", 646 type_byte); 647 exit(0); 648#endif 649 DCETHREAD_RAISE(rpc_x_coding_error); 650 } 651 } while (type_byte != IDL_DT_EOL); 652 } 653} 654 655/******************************************************************************/ 656/* */ 657/* Do length conversion for conformant array parameter */ 658/* If necessary allocate storage for the parameter */ 659/* */ 660/******************************************************************************/ 661static void rpc_ss_ndr_conf_cs_array_param 662( 663 idl_boolean allocate, /* [in] TRUE => allocate array */ 664 idl_byte array_type, /* [in] Conformant or open */ 665 idl_byte *array_defn_ptr, /* [in] Points after bounds info */ 666 idl_ulong_int Z_value, /* [in] Z-value from wire */ 667 idl_ulong_int *p_l_storage_len, /* [out] converted form of Z-value */ 668 idl_cs_convert_t *p_convert_type, /* [out] */ 669 rpc_void_p_t *p_array_addr, /* [out] allocated array */ 670 IDL_msp_t IDL_msp 671) 672{ 673 idl_ulong_int cs_type_defn_index; 674 idl_byte *cs_type_defn_ptr; 675 idl_ulong_int routine_index; 676 void (**routine_ptr)(); 677 678 if (array_type == IDL_DT_OPEN_ARRAY) 679 { 680 /* Ignore the "varying" information */ 681 array_defn_ptr += IDL_DATA_LIMIT_PAIR_WIDTH; 682 } 683 684 /* array_defn_ptr is now pointing to the base type, which has [cs_char] */ 685 array_defn_ptr += 2; /* IDL_DT_CS_TYPE and properties byte */ 686 IDL_GET_LONG_FROM_VECTOR(cs_type_defn_index, array_defn_ptr); 687 cs_type_defn_ptr = IDL_msp->IDL_type_vec + cs_type_defn_index; 688 IDL_DISCARD_LONG_FROM_VECTOR(cs_type_defn_ptr); /* Size of local type */ 689 IDL_GET_LONG_FROM_VECTOR(routine_index, cs_type_defn_ptr); 690 routine_ptr = IDL_msp->IDL_rtn_vec + routine_index; 691 /* cs_type_defn_ptr now pointing at network type definition */ 692 693 /* Call ..._local_size */ 694 (*(routine_ptr + IDL_RTN_LOCAL_SIZE_INDEX))(IDL_msp->IDL_h, 695 *(IDL_msp->IDL_cs_tags_p->p_unmar_tag), 696 Z_value, 697 p_convert_type, 698 p_l_storage_len, 699 &IDL_msp->IDL_status); 700 if (IDL_msp->IDL_status != error_status_ok) 701 DCETHREAD_RAISE(rpc_x_ss_pipe_comm_error); 702 703 if (allocate) 704 { 705 /* Allocate the array */ 706 rpc_ss_ndr_alloc_storage( 0, 1, p_l_storage_len, cs_type_defn_ptr, 707 p_array_addr, IDL_msp ); 708 } 709} 710 711/******************************************************************************/ 712/* */ 713/* Unmarshall a parameter which is an array of [cs_chars] */ 714/* */ 715/******************************************************************************/ 716void rpc_ss_ndr_u_cs_array_param 717( 718 idl_byte **p_type_vec_ptr, /* [in] Points at IDL_DT_..._ARRAY */ 719 /* [out] Points after array indices */ 720 IDL_cs_shadow_elt_t *param_cs_shadow, /* [in] cs-shadow for param list */ 721 idl_ulong_int param_index, /* [in] Index of parameter in param list */ 722 IDL_msp_t IDL_msp 723) 724{ 725 idl_byte *type_vec_ptr; 726 idl_byte array_type; 727 idl_byte *array_defn_ptr; 728 idl_ulong_int array_defn_index; 729 idl_ulong_int sz_index; /* Index in shadow of [size_is] item */ 730 idl_ulong_int Z_value; 731 idl_ulong_int *Z_values = &Z_value; 732 733 type_vec_ptr = *p_type_vec_ptr; 734 array_type = *type_vec_ptr; 735 if ((array_type == IDL_DT_CONF_ARRAY) 736 || (array_type == IDL_DT_OPEN_ARRAY)) 737 { 738 type_vec_ptr++; /* Properties byte */ 739 IDL_DISCARD_LONG_FROM_VECTOR(type_vec_ptr); 740 /* Discard full array definition */ 741 IDL_GET_LONG_FROM_VECTOR(array_defn_index, type_vec_ptr); 742 array_defn_ptr = IDL_msp->IDL_type_vec + array_defn_index; 743 array_defn_ptr++; /* Dimensionality must be 1 */ 744 745 /* Skip over lower bound entirely and upper bound kind and type */ 746 array_defn_ptr += IDL_CONF_BOUND_PAIR_WIDTH/2 + 2; 747 IDL_GET_LONG_FROM_VECTOR(sz_index, array_defn_ptr); 748 sz_index--; 749 750 rpc_ss_ndr_unmar_Z_values(1, &Z_values, IDL_msp); 751 rpc_ss_ndr_conf_cs_array_param(IDL_msp->IDL_side == IDL_server_side_k, 752 array_type, array_defn_ptr, Z_value, 753 ¶m_cs_shadow[sz_index].IDL_data.IDL_value, 754 ¶m_cs_shadow[param_index-1].IDL_convert_type, 755 &(IDL_msp->IDL_param_vec[param_index]), 756 IDL_msp); 757 } 758 759 rpc_ss_ndr_unmar_cs_array(IDL_msp->IDL_param_vec[param_index], 760 param_cs_shadow, 761 Z_values, param_index-1, p_type_vec_ptr, IDL_msp); 762} 763 764/******************************************************************************/ 765/* */ 766/* Allocate an [out]-only conformant/open array of [cs_char]s */ 767/* */ 768/******************************************************************************/ 769void rpc_ss_alloc_out_cs_conf_array 770( 771 IDL_cs_shadow_elt_t *cs_shadow, /* Converted value of array size written 772 to appropriate element */ 773 idl_byte **p_type_vec_ptr, /* [in] Points at IDL_DT_ALLOCATE 774 [out] Points after array defn indices */ 775 /* [out] */ rpc_void_p_t *p_array_addr, 776 /* Where to return address of allocated array */ 777 IDL_msp_t IDL_msp 778) 779{ 780 idl_byte *type_vec_ptr = *p_type_vec_ptr; 781 idl_byte array_type; /* DT_CONF_ARRAY or DT_OPEN_ARRAY */ 782 idl_ulong_int array_defn_index; 783 idl_byte *array_defn_ptr; 784 idl_ulong_int Z_value; 785 idl_byte sz_type; /* Data type of [size_is] item */ 786 idl_ulong_int szp_index; /* Index in parameter list of [size_is] item */ 787 idl_cs_convert_t convert_type; 788 idl_ulong_int l_storage_len; 789 790 type_vec_ptr++; /* IDL_DT_ALLOCATE */ 791 array_type = *type_vec_ptr; 792 type_vec_ptr += 2; /* IDL_DT_..._ARRAY, properties */ 793 IDL_DISCARD_LONG_FROM_VECTOR(type_vec_ptr); 794 /* Discard full array definition */ 795 IDL_GET_LONG_FROM_VECTOR(array_defn_index,type_vec_ptr); 796 array_defn_ptr = IDL_msp->IDL_type_vec + array_defn_index; 797 array_defn_ptr++; 798 799 /* Skip over lower bound entirely and upper bound kind */ 800 array_defn_ptr += IDL_CONF_BOUND_PAIR_WIDTH/2 + 1; 801 sz_type = *array_defn_ptr; 802 IDL_GET_LONG_FROM_VECTOR(szp_index, array_defn_ptr); 803 /* Get the [size_is] value as it was unmarshalled from the wire */ 804 Z_value = rpc_ss_get_typed_integer(sz_type, 805 IDL_msp->IDL_param_vec[szp_index], IDL_msp); 806 807 rpc_ss_ndr_conf_cs_array_param(idl_true, array_type, array_defn_ptr, 808 Z_value, &l_storage_len, &convert_type, 809 p_array_addr, IDL_msp); 810 811 /* Overrwrite the [size_is] value with its local value */ 812 rpc_ss_put_typed_integer(l_storage_len, sz_type, 813 (rpc_void_p_t)&cs_shadow[szp_index-1].IDL_data); 814 815 *p_type_vec_ptr = type_vec_ptr; 816} 817