Mobile API Reference  MicroStrategy 2019
PDCstdlib.h
Go to the documentation of this file.
1 //==============================================================================================
2 // FILENAME : PDCstdlib.h
3 // AUTHOR : Perl Script
4 // CREATION : 6/13/02
5 // Copyright (C) MicroStrategy, Inc. 2002
6 //==============================================================================================
7 #ifndef PDCstdlib_h
8 #define PDCstdlib_h
9 
10 // this must be the *first* file included
11 #include "ProtectedSource/Prolog.h"
12 
13 #include <stdlib.h>
14 #include "PDCerrno.h"
15 
16 #ifndef WIN32
17 #define _gcvt gcvt
18 #endif
19 
20 // for Windows
21 #if !defined(WIN32) && defined(WIN64)
22 
26 inline errno_t mbstowcs_s(size_t *pConvertedChars, wchar_t *wcstr, size_t sizeInWords, const char *mbstr, size_t count)
27 {
28  _VALIDATE_RETURN_ERRCODE(mbstr!=NULL,EINVAL);
29  size_t len=::mbstowcs(NULL,mbstr,count);
30  if(wcstr!=NULL && len>=0)
31  {
32  _VALIDATE_RETURN_ERRCODE(sizeInWords>len,EINVAL);
33  len=::mbstowcs(wcstr,mbstr,count);
34  }
35  if(pConvertedChars!=NULL)
36  *pConvertedChars=len;
37  return 0;
38 }
39 
43 inline errno_t wcstombs_s(size_t *pConvertedChars, char *mbstr, size_t sizeInBytes, const wchar_t *wcstr, size_t count)
44 {
45  _VALIDATE_RETURN_ERRCODE(wcstr!=NULL,EINVAL);
46  size_t len=::wcstombs(NULL,wcstr,count);
47  if(mbstr!=NULL && len>=0)
48  {
49  _VALIDATE_RETURN_ERRCODE(sizeInBytes>len,EINVAL);
50  len=::wcstombs(mbstr,wcstr,count);
51  }
52  if(pConvertedChars!=NULL)
53  *pConvertedChars=len;
54  return 0;
55 }
56 
60 inline errno_t wctomb_s(int *pRetValue, char *mbchar, size_t sizeInBytes, wchar_t wchar)
61 {
62  // todo: size check
63  // need to find out a function in Unix/Linux that can determine the number of
64  // MB characters available in the destination buffer.
65  if(pRetValue==NULL)
66  ::wctomb(mbchar,wchar);
67  else
68  *pRetValue=::wctomb(mbchar,wchar);
69  return 0;
70 }
71 
72 #endif
73 
74 // this must be the *last* file included
75 #include "ProtectedSource/Epilog.h"
76 
77 #endif // PDCstdlib_h
#define _VALIDATE_RETURN_ERRCODE(expr, errorcode)
Definition: PDCerrno.h:21
UINT len
Definition: Msi_bstr.h:37
#define NULL
Definition: Null.h:10