Use free Windows DDK and compile with latest MinGW releases.
[reactos.git] / reactos / lib / kernel32 / misc / stubs.c
1 /* $Id: stubs.c,v 1.31 2002/09/07 15:12:27 chorns Exp $
2 *
3 * KERNEL32.DLL stubs (unimplemented functions)
4 * Remove from this file, if you implement them.
5 */
6 #include <windows.h>
7
8
9
10 BOOL
11 STDCALL
12 BaseAttachCompleteThunk (VOID)
13 {
14 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
15 return FALSE;
16 }
17
18
19 BOOL
20 STDCALL
21 CmdBatNotification (
22 DWORD Unknown
23 )
24 {
25 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
26 return FALSE;
27 }
28
29
30 int
31 STDCALL
32 CompareStringA (
33 LCID Locale,
34 DWORD dwCmpFlags,
35 LPCSTR lpString1,
36 int cchCount1,
37 LPCSTR lpString2,
38 int cchCount2
39 )
40 {
41 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
42 return 0;
43 }
44
45
46 int
47 STDCALL
48 CompareStringW (
49 LCID Locale,
50 DWORD dwCmpFlags,
51 LPCWSTR lpString1,
52 int cchCount1,
53 LPCWSTR lpString2,
54 int cchCount2
55 )
56 {
57 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
58 return 0;
59 }
60
61
62 LCID
63 STDCALL
64 ConvertDefaultLocale (
65 LCID Locale
66 )
67 {
68 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
69 return 0;
70 }
71
72
73 DWORD
74 STDCALL
75 CreateVirtualBuffer (
76 DWORD Unknown0,
77 DWORD Unknown1,
78 DWORD Unknown2
79 )
80 {
81 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
82 return 0;
83 }
84
85 BOOL
86 STDCALL
87 EnumCalendarInfoW (
88 CALINFO_ENUMPROCW lpCalInfoEnumProc,
89 LCID Locale,
90 CALID Calendar,
91 CALTYPE CalType
92 )
93 {
94 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
95 return FALSE;
96 }
97
98
99
100 BOOL
101 STDCALL
102 EnumCalendarInfoA (
103 CALINFO_ENUMPROCA lpCalInfoEnumProc,
104 LCID Locale,
105 CALID Calendar,
106 CALTYPE CalType
107 )
108 {
109 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
110 return FALSE;
111 }
112
113
114 BOOL
115 STDCALL
116 EnumDateFormatsW (
117 DATEFMT_ENUMPROCW lpDateFmtEnumProc,
118 LCID Locale,
119 DWORD dwFlags
120 )
121 {
122 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
123 return FALSE;
124 }
125
126
127 WINBOOL
128 STDCALL
129 EnumDateFormatsA (
130 DATEFMT_ENUMPROC lpDateFmtEnumProc,
131 LCID Locale,
132 DWORD dwFlags
133 )
134 {
135 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
136 return FALSE;
137 }
138
139
140
141
142 BOOL
143 STDCALL
144 EnumSystemCodePagesW (
145 CODEPAGE_ENUMPROCW lpCodePageEnumProc,
146 DWORD dwFlags
147 )
148 {
149 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
150 return FALSE;
151 }
152
153
154 BOOL
155 STDCALL
156 EnumSystemCodePagesA (
157 CODEPAGE_ENUMPROCA lpCodePageEnumProc,
158 DWORD dwFlags
159 )
160 {
161 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
162 return FALSE;
163 }
164
165
166 BOOL
167 STDCALL
168 EnumSystemLocalesW (
169 LOCALE_ENUMPROCW lpLocaleEnumProc,
170 DWORD dwFlags
171 )
172 {
173 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
174 return FALSE;
175 }
176
177
178 BOOL
179 STDCALL
180 EnumSystemLocalesA (
181 LOCALE_ENUMPROCA lpLocaleEnumProc,
182 DWORD dwFlags
183 )
184 {
185 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
186 return FALSE;
187 }
188
189
190 BOOL
191 STDCALL
192 EnumTimeFormatsW (
193 TIMEFMT_ENUMPROCW lpTimeFmtEnumProc,
194 LCID Locale,
195 DWORD dwFlags
196 )
197 {
198 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
199 return FALSE;
200 }
201
202
203 WINBOOL
204 STDCALL
205 EnumTimeFormatsA (
206 TIMEFMT_ENUMPROC lpTimeFmtEnumProc,
207 LCID Locale,
208 DWORD dwFlags
209 )
210 {
211 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
212 return FALSE;
213 }
214
215
216
217
218
219
220
221 DWORD
222 STDCALL
223 ExitVDM (
224 DWORD Unknown0,
225 DWORD Unknown1
226 )
227 {
228 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
229 return 0;
230 }
231
232
233
234
235 BOOL
236 STDCALL
237 ExtendVirtualBuffer (
238 DWORD Unknown0,
239 DWORD Unknown1
240 )
241 {
242 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
243 return FALSE;
244 }
245
246
247 int
248 STDCALL
249 FoldStringW (
250 DWORD dwMapFlags,
251 LPCWSTR lpSrcStr,
252 int cchSrc,
253 LPWSTR lpDestStr,
254 int cchDest
255 )
256 {
257 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
258 return 0;
259 }
260
261
262 int
263 STDCALL
264 FoldStringA (
265 DWORD dwMapFlags,
266 LPCSTR lpSrcStr,
267 int cchSrc,
268 LPSTR lpDestStr,
269 int cchDest
270 )
271 {
272 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
273 return 0;
274 }
275
276
277 DWORD
278 STDCALL
279 FormatMessageW (
280 DWORD dwFlags,
281 LPCVOID lpSource,
282 DWORD dwMessageId,
283 DWORD dwLanguageId,
284 LPWSTR lpBuffer,
285 DWORD nSize,
286 va_list * Arguments
287 )
288 {
289 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
290 return 0;
291 }
292
293
294 DWORD
295 STDCALL
296 FormatMessageA (
297 DWORD dwFlags,
298 LPCVOID lpSource,
299 DWORD dwMessageId,
300 DWORD dwLanguageId,
301 LPSTR lpBuffer,
302 DWORD nSize,
303 va_list * Arguments
304 )
305 {
306 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
307 return 0;
308 }
309
310
311 BOOL
312 STDCALL
313 FreeVirtualBuffer (
314 HANDLE hVirtualBuffer
315 )
316 {
317 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
318 return FALSE;
319 }
320
321
322 UINT
323 STDCALL
324 GetACP (VOID)
325 {
326 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
327 return 0;
328 }
329
330 WINBOOL
331 STDCALL
332 GetBinaryTypeW (
333 LPCWSTR lpApplicationName,
334 LPDWORD lpBinaryType
335 )
336 {
337 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
338 return FALSE;
339 }
340
341
342 WINBOOL
343 STDCALL
344 GetBinaryTypeA (
345 LPCSTR lpApplicationName,
346 LPDWORD lpBinaryType
347 )
348 {
349 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
350 return FALSE;
351 }
352
353
354 WINBOOL
355 STDCALL
356 GetCPInfo (
357 UINT a0,
358 LPCPINFO a1
359 )
360 {
361 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
362 return 0;
363 }
364
365
366
367
368 WINBOOL
369 STDCALL
370 GetComputerNameW (
371 LPWSTR lpBuffer,
372 LPDWORD nSize
373 )
374 {
375 WCHAR Name [MAX_COMPUTERNAME_LENGTH + 1];
376 DWORD Size = 0;
377
378 /*
379 * FIXME: get the computer's name from
380 * the registry.
381 */
382 lstrcpyW( Name, L"ROSHost" ); /* <-- FIXME -- */
383 Size = lstrlenW(Name) + 1;
384 if (Size > *nSize)
385 {
386 *nSize = Size;
387 SetLastError(ERROR_BUFFER_OVERFLOW);
388 return FALSE;
389 }
390 lstrcpyW( lpBuffer, Name );
391 return TRUE;
392 }
393
394
395 WINBOOL
396 STDCALL
397 GetComputerNameA (
398 LPSTR lpBuffer,
399 LPDWORD nSize
400 )
401 {
402 WCHAR Name [MAX_COMPUTERNAME_LENGTH + 1];
403 int i;
404
405 if (FALSE == GetComputerNameW(
406 Name,
407 nSize
408 ))
409 {
410 return FALSE;
411 }
412 /* FIXME --> */
413 /* Use UNICODE to ANSI */
414 for ( i=0; Name[i]; ++i )
415 {
416 lpBuffer[i] = (CHAR) Name[i];
417 }
418 lpBuffer[i] = '\0';
419 /* FIXME <-- */
420 return TRUE;
421 }
422
423
424
425 int
426 STDCALL
427 GetCurrencyFormatW (
428 LCID Locale,
429 DWORD dwFlags,
430 LPCWSTR lpValue,
431 CONST CURRENCYFMTW * lpFormat,
432 LPWSTR lpCurrencyStr,
433 int cchCurrency
434 )
435 {
436 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
437 return 0;
438 }
439
440
441 int
442 STDCALL
443 GetCurrencyFormatA (
444 LCID Locale,
445 DWORD dwFlags,
446 LPCSTR lpValue,
447 CONST CURRENCYFMTA * lpFormat,
448 LPSTR lpCurrencyStr,
449 int cchCurrency
450 )
451 {
452 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
453 return 0;
454 }
455
456
457
458
459
460 int
461 STDCALL
462 GetDateFormatW (
463 LCID Locale,
464 DWORD dwFlags,
465 CONST SYSTEMTIME * lpDate,
466 LPCWSTR lpFormat,
467 LPWSTR lpDateStr,
468 int cchDate
469 )
470 {
471 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
472 return 0;
473 }
474
475
476 int
477 STDCALL
478 GetDateFormatA (
479 LCID Locale,
480 DWORD dwFlags,
481 CONST SYSTEMTIME * lpDate,
482 LPCSTR lpFormat,
483 LPSTR lpDateStr,
484 int cchDate
485 )
486 {
487 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
488 return 0;
489 }
490
491
492 int
493 STDCALL
494 GetLocaleInfoW (
495 LCID Locale,
496 LCTYPE LCType,
497 LPWSTR lpLCData,
498 int cchData
499 )
500 {
501 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
502 return 0;
503 }
504
505
506 int
507 STDCALL
508 GetLocaleInfoA (
509 LCID Locale,
510 LCTYPE LCType,
511 LPSTR lpLCData,
512 int cchData
513 )
514 {
515 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
516 return 0;
517 }
518
519
520 DWORD
521 STDCALL
522 GetNextVDMCommand (
523 DWORD Unknown0
524 )
525 {
526 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
527 return 0;
528 }
529
530
531 int
532 STDCALL
533 GetNumberFormatW (
534 LCID Locale,
535 DWORD dwFlags,
536 LPCWSTR lpValue,
537 CONST NUMBERFMTW * lpFormat,
538 LPWSTR lpNumberStr,
539 int cchNumber
540 )
541 {
542 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
543 return 0;
544 }
545
546
547 int
548 STDCALL
549 GetNumberFormatA (
550 LCID Locale,
551 DWORD dwFlags,
552 LPCSTR lpValue,
553 CONST NUMBERFMTA * lpFormat,
554 LPSTR lpNumberStr,
555 int cchNumber
556 )
557 {
558 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
559 return 0;
560 }
561
562
563 UINT
564 STDCALL
565 GetOEMCP (VOID)
566 {
567 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
568 return 437; /* FIXME: call csrss.exe */
569 }
570
571
572 WINBOOL
573 STDCALL
574 GetStringTypeExW (
575 LCID Locale,
576 DWORD dwInfoType,
577 LPCWSTR lpSrcStr,
578 int cchSrc,
579 LPWORD lpCharType
580 )
581 {
582 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
583 return FALSE;
584 }
585
586
587 WINBOOL
588 STDCALL
589 GetStringTypeExA (
590 LCID Locale,
591 DWORD dwInfoType,
592 LPCSTR lpSrcStr,
593 int cchSrc,
594 LPWORD lpCharType
595 )
596 {
597 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
598 return FALSE;
599 }
600
601
602 WINBOOL
603 STDCALL
604 GetStringTypeW (
605 DWORD dwInfoType,
606 LPCWSTR lpSrcStr,
607 int cchSrc,
608 LPWORD lpCharType
609 )
610 {
611 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
612 return FALSE;
613 }
614
615
616 WINBOOL
617 STDCALL
618 GetStringTypeA (
619 LCID Locale,
620 DWORD dwInfoType,
621 LPCSTR lpSrcStr,
622 int cchSrc,
623 LPWORD lpCharType
624 )
625 {
626 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
627 return FALSE;
628 }
629
630
631 LCID
632 STDCALL
633 GetSystemDefaultLCID (VOID)
634 {
635 /* FIXME: ??? */
636 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
637 return MAKELCID(
638 LANG_ENGLISH,
639 SORT_DEFAULT
640 );
641 }
642
643
644 LANGID
645 STDCALL
646 GetSystemDefaultLangID (VOID)
647 {
648 /* FIXME: ??? */
649 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
650 return MAKELANGID(
651 LANG_ENGLISH,
652 SUBLANG_ENGLISH_US
653 );
654 }
655
656
657 BOOL
658 STDCALL
659 GetSystemPowerStatus (
660 LPSYSTEM_POWER_STATUS lpSystemPowerStatus
661 )
662 {
663 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
664 return FALSE;
665 }
666
667
668 LCID
669 STDCALL
670 GetThreadLocale (VOID)
671 {
672 /* FIXME: ??? */
673 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
674 return MAKELCID(
675 LANG_ENGLISH,
676 SORT_DEFAULT
677 );
678 }
679
680
681 WINBOOL
682 STDCALL
683 GetThreadSelectorEntry (
684 HANDLE hThread,
685 DWORD dwSelector,
686 LPLDT_ENTRY lpSelectorEntry
687 )
688 {
689 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
690 return FALSE;
691 }
692
693
694 int
695 STDCALL
696 GetTimeFormatW (
697 LCID Locale,
698 DWORD dwFlags,
699 CONST SYSTEMTIME * lpTime,
700 LPCWSTR lpFormat,
701 LPWSTR lpTimeStr,
702 int cchTime
703 )
704 {
705 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
706 return 0;
707 }
708
709
710 int
711 STDCALL
712 GetTimeFormatA (
713 LCID Locale,
714 DWORD dwFlags,
715 CONST SYSTEMTIME * lpTime,
716 LPCSTR lpFormat,
717 LPSTR lpTimeStr,
718 int cchTime
719 )
720 {
721 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
722 return 0;
723 }
724
725
726 LCID
727 STDCALL
728 GetUserDefaultLCID (VOID)
729 {
730 /* FIXME: ??? */
731 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
732 return MAKELCID(
733 LANG_ENGLISH,
734 SORT_DEFAULT
735 );
736 }
737
738
739 LANGID
740 STDCALL
741 GetUserDefaultLangID (VOID)
742 {
743 /* FIXME: ??? */
744 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
745 return MAKELANGID(
746 LANG_ENGLISH,
747 SUBLANG_ENGLISH_US
748 );
749 }
750
751
752 DWORD
753 STDCALL
754 GetVDMCurrentDirectories (
755 DWORD Unknown0,
756 DWORD Unknown1
757 )
758 {
759 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
760 return 0;
761 }
762
763
764 WINBOOL
765 STDCALL
766 IsDBCSLeadByte (
767 BYTE TestChar
768 )
769 {
770 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
771 return FALSE;
772 }
773
774
775 WINBOOL
776 STDCALL
777 IsDBCSLeadByteEx (
778 UINT CodePage,
779 BYTE TestChar
780 )
781 {
782 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
783 return FALSE;
784 }
785
786
787 /**********************************************************************
788 * NAME PRIVATE
789 * IsInstalledCP@4
790 *
791 * RETURN VALUE
792 * TRUE if CodePage is installed in the system.
793 */
794 static
795 BOOL
796 STDCALL
797 IsInstalledCP (
798 UINT CodePage
799 )
800 {
801 /* FIXME */
802 return TRUE;
803 }
804
805
806 WINBOOL
807 STDCALL
808 IsValidCodePage (
809 UINT CodePage
810 )
811 {
812 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
813 return FALSE;
814 }
815
816
817 WINBOOL
818 STDCALL
819 IsValidLocale (
820 LCID Locale,
821 DWORD dwFlags
822 )
823 {
824 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
825 return FALSE;
826 }
827
828
829 int
830 STDCALL
831 LCMapStringA (
832 LCID Locale,
833 DWORD dwMapFlags,
834 LPCSTR lpSrcStr,
835 int cchSrc,
836 LPSTR lpDestStr,
837 int cchDest
838 )
839 {
840 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
841 return 0;
842 }
843
844
845 int
846 STDCALL
847 LCMapStringW (
848 LCID Locale,
849 DWORD dwMapFlags,
850 LPCWSTR lpSrcStr,
851 int cchSrc,
852 LPWSTR lpDestStr,
853 int cchDest
854 )
855 {
856 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
857 return 0;
858 }
859
860
861 DWORD
862 STDCALL
863 LoadModule (
864 LPCSTR lpModuleName,
865 LPVOID lpParameterBlock
866 )
867 {
868 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
869 return 0;
870 }
871
872
873 /***********************************************************************
874 * MulDiv (KERNEL32.@)
875 * RETURNS
876 * Result of multiplication and division
877 * -1: Overflow occurred or Divisor was 0
878 */
879
880 //FIXME! move to correct file
881 INT STDCALL MulDiv(
882 INT nMultiplicand,
883 INT nMultiplier,
884 INT nDivisor)
885 {
886 #if SIZEOF_LONG_LONG >= 8
887 long long ret;
888
889 if (!nDivisor) return -1;
890
891 /* We want to deal with a positive divisor to simplify the logic. */
892 if (nDivisor < 0)
893 {
894 nMultiplicand = - nMultiplicand;
895 nDivisor = -nDivisor;
896 }
897
898 /* If the result is positive, we "add" to round. else, we subtract to round. */
899 if ( ( (nMultiplicand < 0) && (nMultiplier < 0) ) ||
900 ( (nMultiplicand >= 0) && (nMultiplier >= 0) ) )
901 ret = (((long long)nMultiplicand * nMultiplier) + (nDivisor/2)) / nDivisor;
902 else
903 ret = (((long long)nMultiplicand * nMultiplier) - (nDivisor/2)) / nDivisor;
904
905 if ((ret > 2147483647) || (ret < -2147483647)) return -1;
906 return ret;
907 #else
908 if (!nDivisor) return -1;
909
910 /* We want to deal with a positive divisor to simplify the logic. */
911 if (nDivisor < 0)
912 {
913 nMultiplicand = - nMultiplicand;
914 nDivisor = -nDivisor;
915 }
916
917 /* If the result is positive, we "add" to round. else, we subtract to round. */
918 if ( ( (nMultiplicand < 0) && (nMultiplier < 0) ) ||
919 ( (nMultiplicand >= 0) && (nMultiplier >= 0) ) )
920 return ((nMultiplicand * nMultiplier) + (nDivisor/2)) / nDivisor;
921
922 return ((nMultiplicand * nMultiplier) - (nDivisor/2)) / nDivisor;
923
924 #endif
925 }
926
927
928 /**********************************************************************
929 * NAME EXPORTED
930 * MultiByteToWideChar@24
931 *
932 * ARGUMENTS
933 * CodePage
934 * CP_ACP ANSI code page
935 * CP_MACCP Macintosh code page
936 * CP_OEMCP OEM code page
937 * (UINT) Any installed code page
938 *
939 * dwFlags
940 * MB_PRECOMPOSED
941 * MB_COMPOSITE
942 * MB_ERR_INVALID_CHARS
943 * MB_USEGLYPHCHARS
944 *
945 * lpMultiByteStr
946 * Input buffer;
947 *
948 * cchMultiByte
949 * Size of MultiByteStr, or -1 if MultiByteStr is
950 * NULL terminated;
951 *
952 * lpWideCharStr
953 * Output buffer;
954 *
955 * cchWideChar
956 * Size (in WCHAR unit) of WideCharStr, or 0
957 * if the caller just wants to know how large
958 * WideCharStr should be for a successful
959 * conversion.
960 *
961 * RETURN VALUE
962 * 0 on error; otherwise the number of WCHAR written
963 * in the WideCharStr buffer.
964 *
965 * NOTE
966 * A raw converter for now. It assumes lpMultiByteStr is
967 * NEVER multi-byte (that is each input character is
968 * 8-bit ASCII) and is ALWAYS NULL terminated.
969 * FIXME-FIXME-FIXME-FIXME
970 */
971 INT
972 STDCALL
973 MultiByteToWideChar (
974 UINT CodePage,
975 DWORD dwFlags,
976 LPCSTR lpMultiByteStr,
977 int cchMultiByte,
978 LPWSTR lpWideCharStr,
979 int cchWideChar
980 )
981 {
982 int InStringLength = 0;
983 BOOL InIsNullTerminated = TRUE;
984 PCHAR r;
985 PWCHAR w;
986 int cchConverted;
987
988 /*
989 * Check the parameters.
990 */
991 if ( /* --- CODE PAGE --- */
992 ( (CP_ACP != CodePage)
993 && (CP_MACCP != CodePage)
994 && (CP_OEMCP != CodePage)
995 && (FALSE == IsInstalledCP (CodePage))
996 )
997 /* --- FLAGS --- */
998 || (dwFlags ^ ( MB_PRECOMPOSED
999 | MB_COMPOSITE
1000 | MB_ERR_INVALID_CHARS
1001 | MB_USEGLYPHCHARS
1002 )
1003 )
1004 /* --- INPUT BUFFER --- */
1005 || (NULL == lpMultiByteStr)
1006 )
1007 {
1008 SetLastError (ERROR_INVALID_PARAMETER);
1009 return 0;
1010 }
1011 /*
1012 * Compute the input buffer length.
1013 */
1014 if (-1 == cchMultiByte)
1015 {
1016 InStringLength = lstrlen (lpMultiByteStr);
1017 }
1018 else
1019 {
1020 InIsNullTerminated = FALSE;
1021 InStringLength = cchMultiByte;
1022 }
1023 /*
1024 * Does caller query for output
1025 * buffer size?
1026 */
1027 if (0 == cchWideChar)
1028 {
1029 SetLastError (ERROR_SUCCESS);
1030 return InStringLength;
1031 }
1032 /*
1033 * Is space provided for the translated
1034 * string enough?
1035 */
1036 if (cchWideChar < InStringLength)
1037 {
1038 SetLastError (ERROR_INSUFFICIENT_BUFFER);
1039 return 0;
1040 }
1041 /*
1042 * Raw 8- to 16-bit conversion.
1043 */
1044 for ( cchConverted = 0,
1045 r = (PCHAR) lpMultiByteStr,
1046 w = (PWCHAR) lpWideCharStr;
1047
1048 ((*r) && (cchConverted < cchWideChar));
1049
1050 r++,
1051 cchConverted++
1052 )
1053 {
1054 *w = (WCHAR) *r;
1055 }
1056 /*
1057 * Is the input string NULL terminated?
1058 */
1059 if (TRUE == InIsNullTerminated)
1060 {
1061 *w = L'\0';
1062 ++cchConverted;
1063 }
1064 /*
1065 * Return how many characters we
1066 * wrote in the output buffer.
1067 */
1068 SetLastError (ERROR_SUCCESS);
1069 return cchConverted;
1070 }
1071
1072
1073 WINBOOL
1074 STDCALL
1075 QueryPerformanceCounter (
1076 LARGE_INTEGER * lpPerformanceCount
1077 )
1078 {
1079 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1080 return FALSE;
1081 }
1082
1083
1084 WINBOOL
1085 STDCALL
1086 QueryPerformanceFrequency (
1087 LARGE_INTEGER * lpFrequency
1088 )
1089 {
1090 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1091 return FALSE;
1092 }
1093
1094
1095 WINBOOL
1096 STDCALL
1097 RegisterConsoleVDM (
1098 DWORD Unknown0,
1099 DWORD Unknown1,
1100 DWORD Unknown2,
1101 DWORD Unknown3,
1102 DWORD Unknown4,
1103 DWORD Unknown5,
1104 DWORD Unknown6,
1105 DWORD Unknown7,
1106 DWORD Unknown8,
1107 DWORD Unknown9,
1108 DWORD Unknown10
1109 )
1110 {
1111 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1112 return FALSE;
1113 }
1114
1115
1116 WINBOOL
1117 STDCALL
1118 RegisterWowBaseHandlers (
1119 DWORD Unknown0
1120 )
1121 {
1122 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1123 return FALSE;
1124 }
1125
1126
1127 WINBOOL
1128 STDCALL
1129 RegisterWowExec (
1130 DWORD Unknown0
1131 )
1132 {
1133 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1134 return FALSE;
1135 }
1136
1137
1138 WINBOOL
1139 STDCALL
1140 SetComputerNameA (
1141 LPCSTR lpComputerName
1142 )
1143 {
1144 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1145 return FALSE;
1146 }
1147
1148
1149 WINBOOL
1150 STDCALL
1151 SetComputerNameW (
1152 LPCWSTR lpComputerName
1153 )
1154 {
1155 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1156 return FALSE;
1157 }
1158
1159
1160 WINBOOL
1161 STDCALL
1162 SetLocaleInfoA (
1163 LCID Locale,
1164 LCTYPE LCType,
1165 LPCSTR lpLCData
1166 )
1167 {
1168 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1169 return FALSE;
1170 }
1171
1172
1173 WINBOOL
1174 STDCALL
1175 SetLocaleInfoW (
1176 LCID Locale,
1177 LCTYPE LCType,
1178 LPCWSTR lpLCData
1179 )
1180 {
1181 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1182 return FALSE;
1183 }
1184
1185
1186
1187 BOOL
1188 STDCALL
1189 SetSystemPowerState (
1190 BOOL fSuspend,
1191 BOOL fForce
1192 )
1193 {
1194 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1195 return FALSE;
1196 }
1197
1198
1199 WINBOOL
1200 STDCALL
1201 SetThreadLocale (
1202 LCID Locale
1203 )
1204 {
1205 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1206 return FALSE;
1207 }
1208
1209
1210 WINBOOL
1211 STDCALL
1212 SetVDMCurrentDirectories (
1213 DWORD Unknown0,
1214 DWORD Unknown1
1215 )
1216 {
1217 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1218 return FALSE;
1219 }
1220
1221
1222 DWORD
1223 STDCALL
1224 TrimVirtualBuffer (
1225 DWORD Unknown0
1226 )
1227 {
1228 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1229 return 0;
1230 }
1231
1232
1233 DWORD
1234 STDCALL
1235 VDMConsoleOperation (
1236 DWORD Unknown0,
1237 DWORD Unknown1
1238 )
1239 {
1240 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1241 return 0;
1242 }
1243
1244
1245 DWORD
1246 STDCALL
1247 VDMOperationStarted (
1248 DWORD Unknown0
1249 )
1250 {
1251 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1252 return 0;
1253 }
1254
1255
1256 DWORD
1257 STDCALL
1258 VerLanguageNameA (
1259 DWORD wLang,
1260 LPSTR szLang,
1261 DWORD nSize
1262 )
1263 {
1264 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1265 return 0;
1266 }
1267
1268
1269 DWORD
1270 STDCALL
1271 VerLanguageNameW (
1272 DWORD wLang,
1273 LPWSTR szLang,
1274 DWORD nSize
1275 )
1276 {
1277 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1278 return 0;
1279 }
1280
1281
1282 DWORD
1283 STDCALL
1284 VirtualBufferExceptionHandler (
1285 DWORD Unknown0,
1286 DWORD Unknown1,
1287 DWORD Unknown2
1288 )
1289 {
1290 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1291 return 0;
1292 }
1293
1294
1295 /**********************************************************************
1296 * NAME EXPORTED
1297 * MultiByteToWideChar@32
1298 *
1299 * Not yet implemented complete (without NLS so far)
1300 *
1301 * ARGUMENTS
1302 * CodePage
1303 * CP_ACP ANSI code page
1304 * CP_MACCP Macintosh code page
1305 * CP_OEMCP OEM code page
1306 * CP_SYMBOL Symbol code page (42)
1307 * CP_THREAD_ACP Current thread's ANSI code page
1308 * CP_UTF7 Translate using UTF-7
1309 * CP_UTF8 Translate using UTF-8
1310 * (UINT) Any installed code page
1311 *
1312 * dwFlags
1313 * WC_NO_BEST_FIT_CHARS
1314 * WC_COMPOSITECHECK Convert composite characters to precomposed characters.
1315 * WC_DISCARDNS Discard nonspacing characters during conversion.
1316 * WC_SEPCHARS Generate separate characters during conversion. This is the default conversion behavior.
1317 * WC_DEFAULTCHAR Replace exceptions with the default character during conversion.
1318 *
1319 * lpWideCharStr
1320 * Points to the wide-character string to be converted.
1321 *
1322 * cchWideChar
1323 * Size (in WCHAR unit) of WideCharStr, or 0
1324 * if the caller just wants to know how large
1325 * WideCharStr should be for a successful
1326 * conversion.
1327 * lpMultiByteStr
1328 * Points to the buffer to receive the translated string.
1329 * cchMultiByte
1330 * Specifies the size in bytes of the buffer pointed to by the
1331 * lpMultiByteStr parameter. If this value is zero, the function
1332 * returns the number of bytes required for the buffer.
1333 * lpDefaultChar
1334 * Points to the character used if a wide character cannot be
1335 * represented in the specified code page. If this parameter is
1336 * NULL, a system default value is used.
1337 FIXME: ignored
1338 * lpUsedDefaultChar
1339 * Points to a flag that indicates whether a default character was used.
1340 * This parameter may be NULL.
1341 FIXME: allways set to FALSE.
1342 *
1343 *
1344 *
1345 * RETURN VALUE
1346 * 0 on error; otherwise the number of bytes written
1347 * in the lpMultiByteStr buffer. Or the number of
1348 * bytes needed for the lpMultiByteStr buffer if cchMultiByte is zero.
1349 *
1350 * NOTE
1351 * A raw converter for now. It just cuts off the upper 9 Bit.
1352 * So the MBCS-string does not contain any LeadCharacters
1353 * FIXME - FIXME - FIXME - FIXME
1354 */
1355
1356 int
1357 STDCALL
1358 WideCharToMultiByte (
1359 UINT CodePage,
1360 DWORD dwFlags,
1361 LPCWSTR lpWideCharStr,
1362 int cchWideChar,
1363 LPSTR lpMultiByteStr,
1364 int cchMultiByte,
1365 LPCSTR lpDefaultChar,
1366 LPBOOL lpUsedDefaultChar
1367 )
1368 {
1369 int wi, di; // wide counter, dbcs byte count
1370
1371 // for now, make no difference but only convert cut the characters to 7Bit
1372 switch( CodePage )
1373 {
1374 case CP_ACP: //ANSI code page
1375 case CP_MACCP: //Macintosh code page
1376 case CP_OEMCP: //OEM code page
1377 case CP_SYMBOL: //Symbol code page (42)
1378 case CP_THREAD_ACP: //ACP Current thread's ANSI code page
1379 case CP_UTF7: //Translate using UTF-7
1380 case CP_UTF8: //Translate using UTF-8
1381 if( cchWideChar == -1 ) // assume its a 0-terminated str
1382 { // and determine its length
1383 for( cchWideChar=0; lpWideCharStr[cchWideChar]!=0; )
1384 cchWideChar++;
1385 }
1386
1387 // user wants to determine needed space
1388 if( cchMultiByte == 0 )
1389 {
1390 SetLastError(ERROR_SUCCESS);
1391 return cchWideChar; // FIXME: determine correct.
1392 }
1393 // the lpWideCharStr is cchWideChar characters long.
1394 for( wi=0, di=0; wi<cchWideChar && di<cchMultiByte; ++wi)
1395 {
1396 // Flag and a not displayable char FIXME
1397 /*if( (dwFlags&WC_NO_BEST_FIT_CHARS) && (lpWideCharStr[wi] >127) )
1398 {
1399 lpMultiByteStr[di]=
1400 *lpUsedDefaultChar = TRUE;
1401
1402 }*/
1403 // FIXME
1404 // just cut off the upper 9 Bit, since vals>=128 mean LeadByte.
1405 lpMultiByteStr[di] = lpWideCharStr[wi] & 0x007F;
1406 ++di;
1407 }
1408 // has MultiByte exceeded but Wide is still in the string?
1409 if( wi < cchWideChar && di >= cchMultiByte)
1410 {
1411 SetLastError(ERROR_INSUFFICIENT_BUFFER);
1412 return di;
1413 }
1414 // else return # of bytes wirtten to MBCSbuffer (di)
1415 SetLastError(ERROR_SUCCESS);
1416 // FIXME: move that elsewhere
1417 if( lpUsedDefaultChar!=NULL ) *lpUsedDefaultChar=FALSE;
1418 return di;
1419 break;
1420 default:
1421 SetLastError(ERROR_INVALID_PARAMETER);
1422 return FALSE;
1423 break;
1424 }
1425 SetLastError(ERROR_INVALID_PARAMETER);
1426 return FALSE;
1427 }
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439 /* EOF */