ReactOS
0.4.15-dev-6656-gbbb33a6
_mbstrnlen.c
Go to the documentation of this file.
1
/*
2
* COPYRIGHT: See COPYING in the top level directory
3
* PROJECT: ReactOS CRT
4
* PURPOSE: Implementation of _mbstrnlen
5
* FILE: lib/sdk/crt/string/_mbstrnlen.c
6
* PROGRAMMER: Timo Kreuzer
7
*/
8
9
#include <precomp.h>
10
#include <
mbctype.h
>
11
#include <
specstrings.h
>
12
13
_Success_
(
return
>0)
14
_Check_return_
15
_CRTIMP
16
size_t
17
__cdecl
18
_mbstrnlen(
19
_In_z_
const
char
*pmbstr,
20
_In_
size_t
cjMaxLen)
21
{
22
size_t
cchCount = 0;
23
unsigned
char
jMbsByte;
24
25
/* Check parameters */
26
if
(!
MSVCRT_CHECK_PMT
((pmbstr != 0)) && (cjMaxLen <=
INT_MAX
))
27
{
28
_set_errno
(
EINVAL
);
29
return
-1;
30
}
31
32
/* Loop while we have bytes to process */
33
while
(cjMaxLen-- > 0)
34
{
35
/* Get next mb byte */
36
jMbsByte = *pmbstr++;
37
38
/* If this is 0, we're done */
39
if
(jMbsByte == 0)
break
;
40
41
/* if this is a lead byte, continue with next char */
42
if
(
_ismbblead
(jMbsByte))
43
{
44
// FIXME: check if this is a valid char.
45
continue
;
46
}
47
48
/* Count this character */
49
cchCount++;
50
}
51
52
return
cchCount;
53
}
54
EINVAL
#define EINVAL
Definition:
acclib.h:90
__cdecl
#define __cdecl
Definition:
accygwin.h:79
_CRTIMP
#define _CRTIMP
Definition:
crtdefs.h:72
INT_MAX
#define INT_MAX
Definition:
limits.h:40
mbctype.h
MSVCRT_CHECK_PMT
#define MSVCRT_CHECK_PMT(x)
Definition:
mbstowcs_s.c:26
_ismbblead
int __cdecl _ismbblead(unsigned int)
Definition:
ismblead.c:20
_Success_
#define _Success_(expr)
Definition:
ms_sal.h:259
_In_z_
#define _In_z_
Definition:
ms_sal.h:313
_Check_return_
#define _Check_return_
Definition:
ms_sal.h:557
_In_
#define _In_
Definition:
ms_sal.h:308
_set_errno
errno_t __cdecl _set_errno(_In_ int _Value)
specstrings.h
const
#define const
Definition:
zconf.h:233
sdk
lib
crt
string
_mbstrnlen.c
Generated on Fri Sep 22 2023 06:12:32 for ReactOS by
1.9.6