home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 19.ddi / GENINC32.PAK / RPCNDR.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  13.0 KB  |  510 lines

  1. /*++
  2.  
  3. Copyright (c) 1992 Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     rpcndr.h
  8.  
  9. Abstract:
  10.  
  11.     Float and double conversion routines.
  12.  
  13. Author:
  14.  
  15.     DonnaLi (01-01-91)
  16.  
  17. Environment:
  18.  
  19.     This code should execute in all environments supported by RPC
  20.     (DOS, Win 3.X, and Win/NT as well as OS2).
  21.  
  22. Revision History:
  23.  
  24.    DONNALI  08-29-91     Start recording history
  25.    donnali  09-11-91     change conversion macros
  26.    donnali  09-18-91     check in files for moving
  27.    STEVEZ   10-15-91     Merge with NT tree
  28.    donnali  10-28-91     add prototype
  29.    donnali  11-19-91     bugfix for strings
  30.    MIKEMON  12-17-91     DCE runtime API conversion
  31.    donnali  03-24-92     change rpc public header f
  32.    STEVEZ   04-04-92     add nsi include
  33.    mikemon  04-18-92     security support and misc
  34.    DovhH    04-24-24     Changed signature of <int>_from_ndr
  35.                          (to unsigned <int>)
  36.                          Added <base_type>_array_from_ndr routines
  37.  
  38. --*/
  39.  
  40. #ifndef __RPCNDR_H__
  41. #define __RPCNDR_H__
  42.  
  43. // Set the packing level for RPC structures for Dos and Windows.
  44.  
  45. #if defined(__RPC_DOS__) || defined(__RPC_WIN16__)
  46. #pragma pack(2)
  47. #endif
  48.  
  49. #ifdef __RPC_WIN32__
  50. #ifndef RC_INVOKED
  51. #pragma pack(4)
  52. #endif /* RC_INVOKED */
  53. #endif /* __RPC_WIN32__ */
  54.  
  55. #include "rpcnsip.h"
  56.  
  57. #ifdef __RPC_WIN32__
  58. #ifndef RC_INVOKED
  59. #pragma pack(4)
  60. #endif /* RC_INVOKED */
  61. #endif /* __RPC_WIN32__ */
  62.  
  63. #ifdef __cplusplus
  64. extern "C" {
  65. #endif
  66.  
  67. /*
  68.  
  69.      Network Computing Architecture (NCA) definition:
  70.  
  71.      Network Data Representation: (NDR) Label format:
  72.      An unsigned long (32 bits) with the following layout:
  73.  
  74.      3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  75.      1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  76.     +---------------+---------------+---------------+-------+-------+
  77.     |   Reserved    |   Reserved    |Floating point | Int   | Char  |
  78.     |               |               |Representation | Rep.  | Rep.  |
  79.     +---------------+---------------+---------------+-------+-------+
  80.  
  81.      Where
  82.  
  83.          Reserved:
  84.  
  85.              Must be zero (0) for NCA 1.5 and NCA 2.0.
  86.  
  87.          Floating point Representation is:
  88.  
  89.              0 - IEEE
  90.              1 - VAX
  91.              2 - Cray
  92.              3 - IBM
  93.  
  94.          Int Rep. is Integer Representation:
  95.  
  96.              0 - Big Endian
  97.              1 - Little Endian
  98.  
  99.          Char Rep. is Character Representation:
  100.  
  101.              0 - ASCII
  102.              1 - EBCDIC
  103.  
  104.      The Microsoft Local Data Representation (for all platforms which are
  105.      of interest currently is edefined below:
  106.  
  107. */
  108.  
  109. #define NDR_CHAR_REP_MASK               (unsigned long)0X0000000FL
  110. #define NDR_INT_REP_MASK                (unsigned long)0X000000F0L
  111. #define NDR_FLOAT_REP_MASK              (unsigned long)0X0000FF00L
  112.  
  113. #define NDR_LITTLE_ENDIAN               (unsigned long)0X00000010L
  114. #define NDR_BIG_ENDIAN                  (unsigned long)0X00000000L
  115.  
  116. #define NDR_IEEE_FLOAT                  (unsigned long)0X00000000L
  117. #define NDR_VAX_FLOAT                   (unsigned long)0X00000100L
  118.  
  119. #define NDR_ASCII_CHAR                  (unsigned long)0X00000000L
  120. #define NDR_EBCDIC_CHAR                 (unsigned long)0X00000001L
  121.  
  122. #define NDR_LOCAL_DATA_REPRESENTATION   (unsigned long)0X00000010L
  123.  
  124. /*
  125.  *  Other MIDL base types / predefined types:
  126.  */
  127.  
  128. typedef unsigned char byte;
  129. typedef unsigned char boolean;
  130.  
  131. #ifndef _WCHAR_T_DEFINED
  132. typedef unsigned short wchar_t;
  133. #define _WCHAR_T_DEFINED
  134. #endif
  135.  
  136. #ifndef _SIZE_T_DEFINED
  137. typedef unsigned int size_t;
  138. #define _SIZE_T_DEFINED
  139. #endif
  140.  
  141. #ifdef __RPC_DOS__
  142. #define __RPC_CALLEE       __far __pascal
  143. #endif
  144.  
  145. #ifdef __RPC_WIN16__
  146. #define __RPC_CALLEE       __far __pascal __export
  147. #endif
  148.  
  149. #ifdef __RPC_WIN32__
  150. #if   (_MSC_VER >= 800)
  151. #define __RPC_CALLEE       __stdcall
  152. #else
  153. #define __RPC_CALLEE
  154. #endif
  155. #endif
  156.  
  157. #ifdef __RPC_OS2_1X__
  158. #define __RPC_CALLEE_STUB  __far __pascal __loadds
  159. #endif
  160.  
  161. #ifndef __MIDL_USER_DEFINED
  162. #define midl_user_allocate MIDL_user_allocate
  163. #define midl_user_free     MIDL_user_free
  164. #define __MIDL_USER_DEFINED
  165. #endif
  166.  
  167.  
  168. /*
  169.  * Context related definitions:
  170.  *
  171.  * Client and Server Contexts.  Just enough of the structure is exposed
  172.  * to allow access to some public fields
  173.  *
  174.  */
  175.  
  176. typedef void __RPC_FAR * NDR_CCONTEXT;
  177. typedef struct {void * pad[2]; void * userContext; } * NDR_SCONTEXT;
  178.  
  179. #define NDRSContextValue(hContext) (&(hContext)->userContext)
  180.  
  181. #define cbNDRContext 20         /* size of context on WIRE */
  182.  
  183. typedef void (__RPC_USER __RPC_FAR * NDR_RUNDOWN)(void __RPC_FAR * context);
  184.  
  185. RPC_BINDING_HANDLE RPC_ENTRY
  186. NDRCContextBinding (
  187.     IN NDR_CCONTEXT CContext
  188.     );
  189.  
  190. void RPC_ENTRY
  191. NDRCContextMarshall (
  192.         IN  NDR_CCONTEXT CContext,
  193.         OUT void __RPC_FAR *pBuff
  194.         );
  195.  
  196. void RPC_ENTRY
  197. NDRCContextUnmarshall (
  198.         OUT NDR_CCONTEXT __RPC_FAR *pCContext,
  199.         IN  RPC_BINDING_HANDLE hBinding,
  200.         IN  void __RPC_FAR *pBuff,
  201.         IN  unsigned long DataRepresentation
  202.         );
  203.  
  204. void RPC_ENTRY
  205. NDRSContextMarshall (
  206.         IN  NDR_SCONTEXT CContext,
  207.         OUT void __RPC_FAR *pBuff,
  208.         IN  NDR_RUNDOWN userRunDownIn
  209.         );
  210.  
  211. NDR_SCONTEXT RPC_ENTRY
  212. NDRSContextUnmarshall (
  213.     IN  void __RPC_FAR *pBuff,
  214.     IN  unsigned long DataRepresentation
  215.     );
  216.  
  217. void RPC_ENTRY
  218. NDRcopy (
  219.     IN void __RPC_FAR *pTarget,
  220.     IN void __RPC_FAR *pSource,
  221.     IN unsigned int size
  222.     );
  223.  
  224.  
  225. /*
  226.  *
  227.  *  Base type conversion macros:
  228.  *
  229.  */
  230.  
  231. #define byte_from_ndr(source, target) \
  232.     { \
  233.     *target = *(*(char __RPC_FAR * __RPC_FAR *)&source->Buffer)++; \
  234.     }
  235.  
  236. #define byte_array_from_ndr(Source, LowerIndex, UpperIndex, Target) \
  237.     { \
  238.     NDRcopy ( \
  239.         (((char __RPC_FAR *)Target)+LowerIndex), \
  240.         Source->Buffer, \
  241.         (unsigned int)(UpperIndex-LowerIndex)); \
  242.     *(unsigned long __RPC_FAR *)&Source->Buffer += (UpperIndex-LowerIndex); \
  243.     }
  244.  
  245. #define boolean_from_ndr(source, target) \
  246.     { \
  247.     *target = *(*(char __RPC_FAR * __RPC_FAR *)&source->Buffer)++; \
  248.     }
  249.  
  250. #define boolean_array_from_ndr(Source, LowerIndex, UpperIndex, Target) \
  251.     { \
  252.     NDRcopy ( \
  253.         (((char __RPC_FAR *)Target)+LowerIndex), \
  254.         Source->Buffer, \
  255.         (unsigned int)(UpperIndex-LowerIndex)); \
  256.     *(unsigned long __RPC_FAR *)&Source->Buffer += (UpperIndex-LowerIndex); \
  257.     }
  258.  
  259. #define small_from_ndr(source, target) \
  260.     { \
  261.     *target = *(*(char __RPC_FAR * __RPC_FAR *)&source->Buffer)++; \
  262.     }
  263.  
  264. #define small_from_ndr_temp(source, target, format) \
  265.     { \
  266.     *target = *(*(char __RPC_FAR * __RPC_FAR *)source)++; \
  267.     }
  268.  
  269. #define small_array_from_ndr(Source, LowerIndex, UpperIndex, Target) \
  270.     { \
  271.     NDRcopy ( \
  272.         (((char __RPC_FAR *)Target)+LowerIndex), \
  273.         Source->Buffer, \
  274.         (unsigned int)(UpperIndex-LowerIndex)); \
  275.     *(unsigned long __RPC_FAR *)&Source->Buffer += (UpperIndex-LowerIndex); \
  276.     }
  277.  
  278. /*
  279.  *
  280.  *  Character and string support routines:
  281.  *
  282.  */
  283.  
  284. int RPC_ENTRY
  285. MIDL_wchar_strlen (
  286.     IN wchar_t __RPC_FAR *   s
  287.     );
  288.  
  289. void RPC_ENTRY
  290. MIDL_wchar_strcpy (
  291.     OUT void __RPC_FAR *     t,
  292.     IN wchar_t __RPC_FAR *   s
  293.     );
  294.  
  295. /*
  296.  *
  297.  *  Base type conversion routines:
  298.  *
  299.  */
  300.  
  301. void RPC_ENTRY
  302. char_from_ndr (
  303.     IN OUT PRPC_MESSAGE                           SourceMessage,
  304.     OUT unsigned char __RPC_FAR *                 Target
  305.     );
  306.  
  307. void RPC_ENTRY
  308. char_array_from_ndr (
  309.     IN OUT PRPC_MESSAGE                           SourceMessage,
  310.     IN unsigned long                              LowerIndex,
  311.     IN unsigned long                              UpperIndex,
  312.     OUT unsigned char __RPC_FAR *                 Target
  313.     );
  314.  
  315. void RPC_ENTRY
  316. short_from_ndr (
  317.     IN OUT PRPC_MESSAGE                           source,
  318.     OUT unsigned short __RPC_FAR *                target
  319.     );
  320.  
  321. void RPC_ENTRY
  322. short_array_from_ndr(
  323.     IN OUT PRPC_MESSAGE                           SourceMessage,
  324.     IN unsigned long                              LowerIndex,
  325.     IN unsigned long                              UpperIndex,
  326.     OUT unsigned short __RPC_FAR *                Target
  327.     );
  328.  
  329. void RPC_ENTRY
  330. short_from_ndr_temp (
  331.     IN OUT unsigned char __RPC_FAR * __RPC_FAR *  source,
  332.     OUT unsigned short __RPC_FAR *                target,
  333.     IN unsigned long                              format
  334.     );
  335.  
  336. void RPC_ENTRY
  337. long_from_ndr (
  338.     IN OUT PRPC_MESSAGE                           source,
  339.     OUT unsigned long __RPC_FAR *                 target
  340.     );
  341.  
  342. void RPC_ENTRY
  343. long_array_from_ndr(
  344.     IN OUT PRPC_MESSAGE                           SourceMessage,
  345.     IN unsigned long                              LowerIndex,
  346.     IN unsigned long                              UpperIndex,
  347.     OUT unsigned long __RPC_FAR *                 Target
  348.     );
  349.  
  350. void RPC_ENTRY
  351. long_from_ndr_temp (
  352.     IN OUT unsigned char __RPC_FAR * __RPC_FAR *  source,
  353.     OUT unsigned long __RPC_FAR *                 target,
  354.     IN unsigned long                              format
  355.     );
  356.  
  357. void RPC_ENTRY
  358. enum_from_ndr(
  359.     IN OUT PRPC_MESSAGE                           SourceMessage,
  360.     OUT unsigned int __RPC_FAR *                  Target
  361.     );
  362.  
  363. void RPC_ENTRY
  364. float_from_ndr (
  365.     IN OUT PRPC_MESSAGE                           SourceMessage,
  366.     OUT void __RPC_FAR *                          Target
  367.     );
  368.  
  369. void RPC_ENTRY
  370. float_array_from_ndr (
  371.     IN OUT PRPC_MESSAGE                           SourceMessage,
  372.     IN unsigned long                              LowerIndex,
  373.     IN unsigned long                              UpperIndex,
  374.     OUT void __RPC_FAR *                          Target
  375.     );
  376.  
  377. void RPC_ENTRY
  378. double_from_ndr (
  379.     IN OUT PRPC_MESSAGE                           SourceMessage,
  380.     OUT void __RPC_FAR *                          Target
  381.     );
  382.  
  383. void RPC_ENTRY
  384. double_array_from_ndr (
  385.     IN OUT PRPC_MESSAGE                           SourceMessage,
  386.     IN unsigned long                              LowerIndex,
  387.     IN unsigned long                              UpperIndex,
  388.     OUT void __RPC_FAR *                          Target
  389.     );
  390.  
  391. /*
  392.  *
  393.  *  Other data conversion / unmarshalling routines:
  394.  *
  395.  */
  396.  
  397. void RPC_ENTRY
  398. data_from_ndr (
  399.     PRPC_MESSAGE                                  source,
  400.     void __RPC_FAR *                              target,
  401.     char __RPC_FAR *                              format,
  402.     unsigned char                                 MscPak
  403.     );
  404.  
  405. void RPC_ENTRY
  406. data_into_ndr (
  407.     void __RPC_FAR *                              source,
  408.     PRPC_MESSAGE                                  target,
  409.     char __RPC_FAR *                              format,
  410.     unsigned char                                 MscPak
  411.     );
  412.  
  413. void RPC_ENTRY
  414. tree_into_ndr (
  415.     void __RPC_FAR *                              source,
  416.     PRPC_MESSAGE                                  target,
  417.     char __RPC_FAR *                              format,
  418.     unsigned char                                 MscPak
  419.     );
  420.  
  421. void RPC_ENTRY
  422. data_size_ndr (
  423.     void __RPC_FAR *                              source,
  424.     PRPC_MESSAGE                                  target,
  425.     char __RPC_FAR *                              format,
  426.     unsigned char                                 MscPak
  427.     );
  428.  
  429. void RPC_ENTRY
  430. tree_size_ndr (
  431.     void __RPC_FAR *                              source,
  432.     PRPC_MESSAGE                                  target,
  433.     char __RPC_FAR *                              format,
  434.     unsigned char                                 MscPak
  435.     );
  436.  
  437. void RPC_ENTRY
  438. tree_peek_ndr (
  439.     PRPC_MESSAGE                                  source,
  440.     unsigned char __RPC_FAR * __RPC_FAR *         buffer,
  441.     char __RPC_FAR *                              format,
  442.     unsigned char                                 MscPak
  443.     );
  444.  
  445. void __RPC_FAR * RPC_ENTRY
  446. midl_allocate (
  447.     size_t      size
  448.     );
  449.  
  450. #ifdef __RPC_DOS__
  451. #define MIDL_ascii_strlen(string) \
  452.     _fstrlen(string)
  453. #define MIDL_ascii_strcpy(target,source) \
  454.     _fstrcpy(target,source)
  455. #define MIDL_memset(s,c,n) \
  456.     _fmemset(s,c,n)
  457. #endif
  458.  
  459. #ifdef __RPC_WIN16__
  460. #define MIDL_ascii_strlen(string) \
  461.     _fstrlen(string)
  462. #define MIDL_ascii_strcpy(target,source) \
  463.     _fstrcpy(target,source)
  464. #define MIDL_memset(s,c,n) \
  465.     _fmemset(s,c,n)
  466. #endif
  467.  
  468. #ifdef __RPC_WIN32__
  469. #define MIDL_ascii_strlen(string) \
  470.     strlen(string)
  471. #define MIDL_ascii_strcpy(target,source) \
  472.     strcpy(target,source)
  473. #define MIDL_memset(s,c,n) \
  474.     memset(s,c,n)
  475. #endif
  476.  
  477. #ifdef __RPC_OS2_1X__
  478. #define MIDL_ascii_strlen(string) \
  479.     _fstrlen(string)
  480. #define MIDL_ascii_strcpy(target,source) \
  481.     _fstrcpy(target,source)
  482. #define MIDL_memset(s,c,n) \
  483.     _fmemset(s,c,n)
  484. #endif
  485.  
  486.  
  487. void RPC_ENTRY
  488. RpcSsDestroyClientContext (
  489.     IN void __RPC_FAR * __RPC_FAR * ContextHandle
  490.     );
  491.  
  492. #ifdef __cplusplus
  493. }
  494. #endif
  495.  
  496. // Reset the packing level for DOS and Windows.
  497.  
  498. #if defined(__RPC_DOS__) || defined(__RPC_WIN16__)
  499. #pragma pack()
  500. #endif
  501.  
  502. #ifdef __RPC_WIN32__
  503. #ifndef RC_INVOKED
  504. #pragma pack()
  505. #endif /* RC_INVOKED */
  506. #endif /* __RPC_WIN32__ */
  507.  
  508. #endif /* __RPCNDR_H__ */
  509. 
  510.