ReactOS  0.4.14-dev-50-g13bb5e2
_mbsnlen.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 _mbsnlen
5  * FILE: lib/sdk/crt/string/_mbsnlen.c
6  * PROGRAMMER: Timo Kreuzer
7  */
8 
9 #include <mbstring.h>
10 
12 _CRTIMP
13 size_t
14 __cdecl
16  _In_z_ const unsigned char *pmbstr,
17  _In_ size_t cjMaxLen)
18 {
19  size_t cchCount = 0;
20  unsigned char jMbsByte;
21 
22  /* Loop while we have bytes to process */
23  while (cjMaxLen-- > 0)
24  {
25  /* Get next mb byte */
26  jMbsByte = *pmbstr++;
27 
28  /* If this is 0, we're done */
29  if (jMbsByte == 0) break;
30 
31  /* Don't count lead bytes */
32  if (!_ismbblead(jMbsByte)) cchCount++;
33  }
34 
35  return cchCount;
36 }
#define __cdecl
Definition: accygwin.h:79
#define _CRTIMP
Definition: crtdefs.h:60
#define _Check_return_
Definition: no_sal2.h:13
#define _In_
Definition: no_sal2.h:204
#define _In_z_
Definition: no_sal2.h:239
int __cdecl _ismbblead(unsigned int)
Definition: ismblead.c:20
_Check_return_ _CRTIMP size_t __cdecl _mbsnlen(_In_z_ const unsigned char *pmbstr, _In_ size_t cjMaxLen)
Definition: _mbsnlen.c:15