ReactOS 0.4.15-dev-7842-g558ab78
_mbstrnlen.c File Reference
#include <precomp.h>
#include <mbctype.h>
#include <specstrings.h>
Include dependency graph for _mbstrnlen.c:

Go to the source code of this file.

Functions

 _Success_ (return, 0)
 

Function Documentation

◆ _Success_()

_Success_ ( return  ,
 
)

Definition at line 13 of file _mbstrnlen.c.

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 {
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}
#define EINVAL
Definition: acclib.h:90
#define INT_MAX
Definition: limits.h:40
#define MSVCRT_CHECK_PMT(x)
Definition: mbstowcs_s.c:26
int __cdecl _ismbblead(unsigned int)
Definition: ismblead.c:20
errno_t __cdecl _set_errno(_In_ int _Value)