xref: /reactos/sdk/lib/crt/mbstring/mbsrchr.c (revision c2c66aff)
1 /*
2  * COPYRIGHT:   See COPYING in the top level directory
3  * PROJECT:     ReactOS system libraries
4  * FILE:        lib/sdk/crt/mbstring/mbsrchr.c
5  * PURPOSE:     Searches for a character in reverse
6  * PROGRAMER:   Ariadne
7  * UPDATE HISTORY:
8  *              12/04/99: Created
9  */
10 #include <stdlib.h>
11 #include <mbstring.h>
12 
13 /*
14  * @implemented
15  */
_mbsrchr(const unsigned char * src,unsigned int val)16 unsigned char * _mbsrchr(const unsigned char *src, unsigned int val)
17 {
18   unsigned int c;
19   unsigned char *match = NULL;
20 
21   if (!src)
22     return NULL;
23 
24   while (1)
25   {
26     c = _mbsnextc(src);
27     if (c == val)
28       match = (unsigned char*)src;
29     if (!c)
30       return match;
31     src += (c > 255) ? 2 : 1;
32   }
33 }
34