ReactOS 0.4.16-dev-814-g656a5dc
mbsset_s_l.cpp File Reference
Include dependency graph for mbsset_s_l.cpp:

Go to the source code of this file.

Functions

errno_t __cdecl _mbsset_s_l (unsigned char *_Dst, size_t _SizeInBytes, unsigned int _Value, _LOCALE_ARG_DECL)
 

Function Documentation

◆ _mbsset_s_l()

errno_t __cdecl _mbsset_s_l ( unsigned char _Dst,
size_t  _SizeInBytes,
unsigned int  _Value,
_LOCALE_ARG_DECL   
)

Definition at line 17 of file mbsset_s_l.cpp.

18{
19 int mbcs_error = 0;
20 unsigned char *p;
21 size_t available;
22 unsigned char highval, lowval;
23
24 /* validation section */
26
29 {
30 return _strset_s((char *)_Dst, _SizeInBytes, (int)_Value);
31 }
32
33 p = _Dst;
35 highval = (unsigned char)(_Value >> 8);
36 lowval = (unsigned char)(_Value & 0x00ff);
37
38 /* ensure _Value is a valid mbchar */
39 if ((highval != 0 && (lowval == 0 || !_ISMBBLEAD(highval))) ||
40 (highval == 0 && _ISMBBLEAD(lowval)))
41 {
44 }
45
46 if (highval != 0)
47 {
48 while (*p != 0 && --available > 0)
49 {
50 if (p[1] == 0)
51 {
52 /* do not orphan leadbyte */
53 *p = 0;
54 ++available;
55 mbcs_error = 1;
56 break;
57 }
58 *p++ = highval;
59 if (--available == 0)
60 {
61 break;
62 }
63 *p++ = lowval;
64 }
65 }
66 else
67 {
68 while (*p != 0 && --available > 0)
69 {
70 *p++ = lowval;
71 }
72 }
73
74 if (available == 0)
75 {
78 }
80
81 if (mbcs_error)
82 {
84 }
85 else
86 {
88 }
89}
#define _RETURN_DEST_NOT_NULL_TERMINATED(_String, _Size)
#define _FILL_STRING
#define _LOCALE_SHORTCUT_TEST
#define _RESET_STRING(_String, _Size)
#define _RETURN_NO_ERROR
#define _LOCALE_UPDATE
#define _RETURN_MBCS_ERROR
#define _ISMBBLEAD(_Character)
#define _VALIDATE_STRING(_String, _Size)
_In_ _Value
static WCHAR available[MAX_STRING_RESOURCE_LEN]
Definition: object.c:2336
_Check_return_wat_ _CRTIMP errno_t __cdecl _strset_s(_Inout_updates_z_(size) char *dst, _In_ size_t size, _In_ int val)
Definition: stubs.c:660
unsigned char
Definition: typeof.h:29
GLfloat GLfloat p
Definition: glext.h:8902
_In_ size_t _SizeInBytes
Definition: time.h:146