branch update for HEAD-2003091401
[reactos.git] / lib / ntdll / stdlib / mbstowcs.c
1 /* $Id$
2  *
3  * COPYRIGHT:       See COPYING in the top level directory
4  * PROJECT:         ReactOS kernel
5  * FILE:            lib/ntdll/stdlib/mbstowcs.c
6  * PURPOSE:         converts a multi byte string to a unicode string
7  */
8
9 #include <ddk/ntddk.h>
10 #include <stdlib.h>
11 #include <string.h>
12
13 /*
14  * @implemented
15  */
16 size_t mbstowcs (wchar_t *wcstr, const char *mbstr, size_t count)
17 {
18         NTSTATUS Status;
19         ULONG Size;
20         ULONG Length;
21
22         Length = strlen (mbstr);
23
24         if (wcstr == NULL)
25         {
26                 RtlMultiByteToUnicodeSize (&Size,
27                                            (char *)mbstr,
28                                            Length);
29
30                 return (size_t)Size;
31         }
32
33         Status = RtlMultiByteToUnicodeN (wcstr,
34                                          count,
35                                          &Size,
36                                          (char *)mbstr,
37                                          Length);
38         if (!NT_SUCCESS(Status))
39                 return -1;
40
41         return (size_t)Size;
42 }
43
44 /* EOF */