:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[reactos.git] / tools / wmc / misc.c
1 #ifdef __unix__
2 #include <string.h>
3 #include <stdlib.h>
4 #include <wchar.h>
5
6 typedef unsigned short UINT;
7 typedef unsigned int DWORD;
8 typedef const unsigned char* LPCSTR;
9 typedef wchar_t* LPWSTR;
10 typedef unsigned char* LPSTR;
11 typedef const wchar_t* LPCWSTR;
12 typedef unsigned int* LPBOOL;
13
14 int
15 stricmp(const char* s1, const char* s2)
16 {
17   return(strcasecmp(s1, s2));
18 }
19
20 int
21 WideCharToMultiByte(
22     UINT     CodePage,
23     DWORD    dwFlags,
24     LPCWSTR  lpWideCharStr,
25     int      cchWideChar,
26     LPSTR    lpMultiByteStr,
27     int      cchMultiByte,
28     LPCSTR   lpDefaultChar,
29     LPBOOL   lpUsedDefaultChar)
30 {
31   unsigned int i = 0;
32   if (cchWideChar == -1)
33     {
34       while(*lpWideCharStr != 0)
35         {
36           wctomb(lpMultiByteStr, *lpWideCharStr);
37           lpMultiByteStr++;
38           lpWideCharStr++;
39           i++;
40         }
41     }
42   else
43     {
44       while(i < cchWideChar)
45         {
46           wctomb(lpMultiByteStr, *lpWideCharStr);
47           lpMultiByteStr++;
48           lpWideCharStr++;
49           i++;
50         }
51     }
52   return(i);
53 }
54
55 int
56 MultiByteToWideChar(
57     UINT     CodePage,
58     DWORD    dwFlags,
59     LPCSTR   lpMultiByteStr,
60     int      cchMultiByte,
61     LPWSTR   lpWideCharStr,
62     int      cchWideChar)
63 {
64   int i, j;
65   
66   i = j = 0;
67   while (i < cchMultiByte && lpMultiByteStr[i] != 0)
68     {
69       i = i + mbtowc(&lpWideCharStr[j], &lpMultiByteStr[i], 
70                      cchMultiByte - i);
71       j++;
72     }
73   lpWideCharStr[j] = 0;
74   j++;
75   return(j);
76 }
77 #endif