Different code sets use different numbers of bytes to encode a single character. Consequently, there is always the possibility that the converted string can be larger than the original string when converting data from one code set to another. The function of the buffer sizing routines is to calculate the necessary buffer size for code set conversion between local and network code sets and return their findings to the client and server stubs, which call these buffer sizing routines before marshalling and unmarshalling any international character data. The stubs then allocate a new buffer, if necessary, before calling the code set conversion routines.
You must provide the following buffer sizing routines for each local type that you define with the cs_char attribute:
· local_type_name_net_size( ) - Calculates the necessary buffer size for code set conversion from a local code set to a network code set. Client and server stubs call this routine before they marshal any international character data.
· local_type_name_local_size( ) - Calculates the necessary buffer size for code set conversion from a network code set to a local code set. Client and server stubs call this routine before they unmarshal any international character data.
You specify the name for the local data type in the local_type_name portion of the function name and the appropriate suffix name (_net_size or _local_size).
DCE RPC provides buffer sizing routines for the cs_byte and wchar_t data types. The cs_byte data type is equivalent to the byte type, while the wchar_t data type is a platform-dependent data type whose range of values can represent encodings for all members of the largest international character set that exists within the set of character/code sets supported on the host.
The DCE RPC buffer sizing routines are:
· cs_byte_net_size( ) - Calculates the necessary buffer size for code set conversion from a local code set to a network code set when the cs_byte type has been specified as the local data type in the .acf file.
· cs_byte_local_size( ) - Calculates the necessary buffer size for code set conversion from a network code set to a local code set when the cs_byte type has been specified as the local data type in the .acf file.
· wchar_t_net_size( ) - Calculates the necessary buffer size for code set conversion from a local code set to a network code set when the wchar_t data type has been specified as the local data type in the .acf file.
· wchar_t_local_size( ) - Calculates the necessary buffer size for code set conversion from a network code set to a local code set when the wchar_t data type has been specified as the local data type in the .acf file.
If your internationalized RPC application uses either of these data types as the local type in the ACF, it can use these DCE RPC buffer sizing routines; in order to do so, simply link with the DCE library when compiling your application. The example ACF shown earlier in this topic uses the cs_byte type as the local type. Consequently, the client and server stubs will use the cs_byte_ buffer sizing routines. Refer to the cs_byte_*(3rpc) and wchar_t_*(3rpc) reference pages in the OSF DCE Application Development Reference for a description of the cs_byte_ and wchar_t_ routine signatures and functions.
Applications that use data types other than cs_byte or wchar_t as their local data types will need to provide their own buffer sizing routines. User-provided buffer sizing routines must follow the same signature as the DCE RPC-provided buffer sizing routines. See the cs_byte_*(3rpc) and wchar_t_*(3rpc) reference pages in the OSF DCE Application Development Referencefor a description of the cs_byte_ and wchar_t_ for a description of the required routine signatures.