/dcerpc/idl_lib/eebyte.c

https://github.com/BeyondTrust/pbis-open · C · 136 lines · 84 code · 12 blank · 40 comment · 26 complexity · 16e2a2e86c269feeb3e7599645d108a6 MD5 · raw file

  1. /*
  2. *
  3. * (c) Copyright 1990 OPEN SOFTWARE FOUNDATION, INC.
  4. * (c) Copyright 1990 HEWLETT-PACKARD COMPANY
  5. * (c) Copyright 1990 DIGITAL EQUIPMENT CORPORATION
  6. * To anyone who acknowledges that this file is provided "AS IS"
  7. * without any express or implied warranty:
  8. * permission to use, copy, modify, and distribute this
  9. * file for any purpose is hereby granted without fee, provided that
  10. * the above copyright notices and this notice appears in all source
  11. * code copies, and that none of the names of Open Software
  12. * Foundation, Inc., Hewlett-Packard Company, or Digital Equipment
  13. * Corporation be used in advertising or publicity pertaining to
  14. * distribution of the software without specific, written prior
  15. * permission. Neither Open Software Foundation, Inc., Hewlett-
  16. * Packard Company, nor Digital Equipment Corporation makes any
  17. * representations about the suitability of this software for any
  18. * purpose.
  19. *
  20. */
  21. /*
  22. */
  23. /*
  24. **
  25. ** NAME:
  26. **
  27. ** eebyte.c
  28. **
  29. ** FACILITY:
  30. **
  31. ** IDL Stub Runtime Support
  32. **
  33. ** ABSTRACT:
  34. **
  35. ** Callee marshalling and unmarshalling of pointed_at byte's
  36. **
  37. ** VERSION: DCE 1.0
  38. **
  39. */
  40. #if HAVE_CONFIG_H
  41. #include <config.h>
  42. #endif
  43. /* The ordering of the following 3 includes should NOT be changed! */
  44. #include <dce/rpc.h>
  45. #include <dce/stubbase.h>
  46. #include <lsysdep.h>
  47. void
  48. rpc_ss_me_byte
  49. (
  50. idl_byte *p_node,
  51. rpc_ss_node_type_k_t NIDL_node_type,
  52. rpc_ss_marsh_state_t *NIDL_msp
  53. )
  54. {
  55. long NIDL_already_marshalled;
  56. unsigned long space_for_node;
  57. rpc_mp_t mp;
  58. rpc_op_t op;
  59. if(p_node==NULL)return;
  60. if (NIDL_node_type == rpc_ss_mutable_node_k) {
  61. rpc_ss_register_node(NIDL_msp->node_table,(byte_p_t)p_node,idl_true,&NIDL_already_marshalled);
  62. if(NIDL_already_marshalled)return;
  63. }
  64. space_for_node=((1))+7;
  65. if (space_for_node > NIDL_msp->space_in_buff)
  66. {
  67. rpc_ss_marsh_change_buff(NIDL_msp,space_for_node);
  68. }
  69. mp = NIDL_msp->mp;
  70. op = NIDL_msp->op;
  71. rpc_marshall_byte(mp, (*p_node));
  72. rpc_advance_mop(mp, op, 1);
  73. NIDL_msp->space_in_buff -= (op - NIDL_msp->op);
  74. NIDL_msp->mp = mp;
  75. NIDL_msp->op = op;
  76. }
  77. void
  78. rpc_ss_ue_byte
  79. (
  80. idl_byte **p_referred_to_by,
  81. rpc_ss_node_type_k_t NIDL_node_type,
  82. rpc_ss_marsh_state_t *p_unmar_params
  83. )
  84. {
  85. idl_byte *p_node = NULL;
  86. long NIDL_already_unmarshalled = 0;
  87. unsigned long node_size;
  88. unsigned long node_number = 0;
  89. if ( NIDL_node_type == rpc_ss_unique_node_k )
  90. {
  91. if (*p_referred_to_by == NULL) return;
  92. else if (*p_referred_to_by != (idl_byte *)RPC_SS_NEW_UNIQUE_NODE) p_node = *p_referred_to_by;
  93. }
  94. if ( NIDL_node_type == rpc_ss_mutable_node_k )
  95. {
  96. node_number = (unsigned long)*p_referred_to_by;
  97. if(node_number==0)return;
  98. }
  99. if ( NIDL_node_type == rpc_ss_old_ref_node_k )
  100. p_node = *p_referred_to_by;
  101. else if ( p_node == NULL )
  102. {
  103. node_size = sizeof(idl_byte );
  104. if (NIDL_node_type == rpc_ss_mutable_node_k)
  105. p_node = (idl_byte *)rpc_ss_return_pointer_to_node(
  106. p_unmar_params->node_table, node_number, node_size,
  107. NULL, &NIDL_already_unmarshalled, (long *)NULL);
  108. else
  109. p_node = (idl_byte *)rpc_ss_mem_alloc(
  110. p_unmar_params->p_mem_h, node_size );
  111. *p_referred_to_by = p_node;
  112. if (NIDL_already_unmarshalled) return;
  113. }
  114. if ( NIDL_node_type == rpc_ss_alloc_ref_node_k )
  115. {
  116. return;
  117. }
  118. if ((unsigned32)((byte_p_t)p_unmar_params->mp - p_unmar_params->p_rcvd_data->data_addr) >= p_unmar_params->p_rcvd_data->data_len)
  119. {
  120. rpc_ss_new_recv_buff(p_unmar_params->p_rcvd_data, p_unmar_params->call_h, &(p_unmar_params->mp), &(*p_unmar_params->p_st));
  121. }
  122. rpc_convert_byte(p_unmar_params->src_drep, ndr_g_local_drep, p_unmar_params->mp, (*p_node));
  123. rpc_advance_mop(p_unmar_params->mp, p_unmar_params->op, 1);
  124. }