Added some stubbs for the WINE kernel32 regression test
[reactos.git] / reactos / lib / kernel32 / misc / stubs.c
index 1ba1107..2335995 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: stubs.c,v 1.26 2001/03/31 01:17:29 dwelch Exp $
+/* $Id: stubs.c,v 1.33 2002/09/23 19:20:34 sedwards Exp $
  *
  * KERNEL32.DLL stubs (unimplemented functions)
  * Remove from this file, if you implement them.
@@ -16,18 +16,6 @@ BaseAttachCompleteThunk (VOID)
 }
 
 
-
-
-
-
-
-
-
-
-
-
-
-
 BOOL
 STDCALL
 CmdBatNotification (
@@ -39,9 +27,6 @@ CmdBatNotification (
 }
 
 
-
-
-
 int
 STDCALL
 CompareStringA (
@@ -74,7 +59,6 @@ CompareStringW (
 }
 
 
-
 LCID
 STDCALL
 ConvertDefaultLocale (
@@ -86,11 +70,6 @@ ConvertDefaultLocale (
 }
 
 
-
-
-
-
-
 DWORD
 STDCALL
 CreateVirtualBuffer (
@@ -104,13 +83,6 @@ CreateVirtualBuffer (
 }
 
 
-
-
-
-
-
-
-
 WINBOOL
 STDCALL
 EnumCalendarInfoW (
@@ -403,7 +375,7 @@ GetComputerNameW (
 {
        WCHAR   Name [MAX_COMPUTERNAME_LENGTH + 1];
        DWORD   Size = 0;
-       
+
        /*
         * FIXME: get the computer's name from
         * the registry.
@@ -519,8 +491,6 @@ GetDateFormatA (
 }
 
 
-
-
 int
 STDCALL
 GetLocaleInfoW (
@@ -549,10 +519,6 @@ GetLocaleInfoA (
 }
 
 
-
-
-
-
 DWORD
 STDCALL
 GetNextVDMCommand (
@@ -596,9 +562,6 @@ GetNumberFormatA (
 }
 
 
-
-
-
 UINT
 STDCALL
 GetOEMCP (VOID)
@@ -608,11 +571,6 @@ GetOEMCP (VOID)
 }
 
 
-
-
-
-
-
 WINBOOL
 STDCALL
 GetStringTypeExW (
@@ -709,8 +667,6 @@ GetSystemPowerStatus (
 }
 
 
-
-
 LCID
 STDCALL
 GetThreadLocale (VOID)
@@ -723,6 +679,17 @@ GetThreadLocale (VOID)
                );
 }
 
+WINBOOL
+STDCALL
+GetThreadPriorityBoost (
+       HANDLE          hThread,
+       DWORD           dwSelector,
+       LPLDT_ENTRY     lpSelectorEntry
+       )
+{
+       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+       return FALSE;
+}
 
 WINBOOL
 STDCALL
@@ -806,237 +773,11 @@ GetVDMCurrentDirectories (
        return 0;
 }
 
-/*
-HGLOBAL
-STDCALL
-GlobalAlloc (
-       UINT    uFlags,
-       DWORD   dwBytes
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return 0;
-}
-*/
-
-UINT
-STDCALL
-GlobalCompact (
-       DWORD   dwMinFree
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return 0;
-}
-
-VOID
-STDCALL
-GlobalFix (
-       HGLOBAL hMem
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-}
-
-
-UINT
-STDCALL
-GlobalFlags (
-       HGLOBAL hMem
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return 0;
-}
-
-
-/*
-HGLOBAL
-STDCALL
-GlobalFree (
-       HGLOBAL hMem
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return hMem;
-}
-*/
-
-HGLOBAL
-STDCALL
-GlobalHandle (
-       LPCVOID pMem
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return 0;
-}
-
-
-LPVOID
-STDCALL
-GlobalLock (
-       HGLOBAL hMem
-       )
-{
-       /* In Win32 GlobalAlloc returns LPVOID? */
-       return hMem;
-}
-
-
-VOID
-STDCALL
-GlobalMemoryStatus (
-       LPMEMORYSTATUS  lpBuffer
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-}
-
-
-HGLOBAL
-STDCALL
-GlobalReAlloc (
-       HGLOBAL hMem,
-       DWORD   dwBytes,
-       UINT    uFlags
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return 0;
-}
-
-/*
-DWORD
-STDCALL
-GlobalSize (
-       HGLOBAL hMem
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return 0;
-}
-*/
-
-WINBOOL
-STDCALL
-GlobalUnWire (
-       HGLOBAL hMem
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return FALSE;
-}
-
-
-VOID
-STDCALL
-GlobalUnfix (
-       HGLOBAL hMem
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-}
-
-
-WINBOOL
-STDCALL
-GlobalUnlock (
-       HGLOBAL hMem
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return FALSE;
-}
-
-
-LPVOID
-STDCALL
-GlobalWire (
-       HGLOBAL hMem
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return NULL; /* ? */
-}
-
-
-DWORD
-STDCALL
-HeapCreateTagsW (
-       DWORD   Unknown0,
-       DWORD   Unknown1,
-       DWORD   Unknown2,
-       DWORD   Unknown3
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return 0;
-}
-
-
-DWORD
-STDCALL
-HeapExtend (
-       DWORD   Unknown0,
-       DWORD   Unknown1,
-       DWORD   Unknown2,
-       DWORD   Unknown3
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return 0;
-}
-
-
-DWORD
-STDCALL
-HeapQueryTagW (
-       DWORD   Unknown0,
-       DWORD   Unknown1,
-       DWORD   Unknown2,
-       DWORD   Unknown3,
-       DWORD   Unknown4
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return 0;
-}
-
-
-DWORD
-STDCALL
-HeapSummary (
-       DWORD   Unknown0,
-       DWORD   Unknown1,
-       DWORD   Unknown2
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return 0;
-}
-
-
-DWORD
-STDCALL
-HeapUsage (
-       DWORD   Unknown0,
-       DWORD   Unknown1,
-       DWORD   Unknown2,
-       DWORD   Unknown3,
-       DWORD   Unknown4
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return 0;
-}
-
 
 WINBOOL
 STDCALL
-HeapWalk (
-       HANDLE                  hHeap,
-       LPPROCESS_HEAP_ENTRY    lpEntry
+IsDBCSLeadByte (
+       BYTE    TestChar
        )
 {
        SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
@@ -1044,11 +785,10 @@ HeapWalk (
 }
 
 
-
-
 WINBOOL
 STDCALL
-IsDBCSLeadByte (
+IsDBCSLeadByteEx (
+       UINT    CodePage,
        BYTE    TestChar
        )
 {
@@ -1057,15 +797,22 @@ IsDBCSLeadByte (
 }
 
 
-WINBOOL
+/**********************************************************************
+ * NAME                                                        PRIVATE
+ *     IsInstalledCP@4
+ *
+ * RETURN VALUE
+ *     TRUE if CodePage is installed in the system.
+ */
+static
+BOOL
 STDCALL
-IsDBCSLeadByteEx (
-       UINT    CodePage,
-       BYTE    TestChar
+IsInstalledCP (
+       UINT    CodePage
        )
 {
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return FALSE;
+       /* FIXME */
+       return TRUE;
 }
 
 
@@ -1136,152 +883,58 @@ LoadModule (
 }
 
 
+/***********************************************************************
+ *           MulDiv   (KERNEL32.@)
+ * RETURNS
+ *     Result of multiplication and division
+ *     -1: Overflow occurred or Divisor was 0
+ */
 
-
-
-HLOCAL
-STDCALL
-LocalAlloc (
-       UINT    uFlags,
-       UINT    uBytes
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return 0;
-}
-
-
-UINT
-STDCALL
-LocalCompact (
-       UINT    uMinFree
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return 0;
-}
-
-
-UINT
-STDCALL
-LocalFlags (
-       HLOCAL  hMem
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return 0;
-}
-
-
-HLOCAL
-STDCALL
-LocalFree (
-       HLOCAL  hMem
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return hMem;
-}
-
-
-HLOCAL
-STDCALL
-LocalHandle (
-       LPCVOID pMem
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return 0;
-}
-
-
-LPVOID
-STDCALL
-LocalLock (
-       HLOCAL  hMem
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return NULL;
-}
-
-
-HLOCAL
-STDCALL
-LocalReAlloc (
-       HLOCAL  hMem,
-       UINT    uBytes,
-       UINT    uFlags
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return 0;
-}
-
-
-UINT
-STDCALL
-LocalShrink (
-       HLOCAL  hMem,
-       UINT    cbNewSize
-       )
+//FIXME! move to correct file
+INT STDCALL MulDiv(
+            INT nMultiplicand,
+            INT nMultiplier,
+            INT nDivisor)
 {
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return 0;
-}
+#if SIZEOF_LONG_LONG >= 8
+    long long ret;
 
+    if (!nDivisor) return -1;
 
-UINT
-STDCALL
-LocalSize (
-       HLOCAL  hMem
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return 0;
-}
+    /* We want to deal with a positive divisor to simplify the logic. */
+    if (nDivisor < 0)
+    {
+      nMultiplicand = - nMultiplicand;
+      nDivisor = -nDivisor;
+    }
 
+    /* If the result is positive, we "add" to round. else, we subtract to round. */
+    if ( ( (nMultiplicand <  0) && (nMultiplier <  0) ) ||
+        ( (nMultiplicand >= 0) && (nMultiplier >= 0) ) )
+      ret = (((long long)nMultiplicand * nMultiplier) + (nDivisor/2)) / nDivisor;
+    else
+      ret = (((long long)nMultiplicand * nMultiplier) - (nDivisor/2)) / nDivisor;
 
-WINBOOL
-STDCALL
-LocalUnlock (
-       HLOCAL  hMem
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return FALSE;
-}
+    if ((ret > 2147483647) || (ret < -2147483647)) return -1;
+    return ret;
+#else
+    if (!nDivisor) return -1;
 
+    /* We want to deal with a positive divisor to simplify the logic. */
+    if (nDivisor < 0)
+    {
+      nMultiplicand = - nMultiplicand;
+      nDivisor = -nDivisor;
+    }
 
-int
-STDCALL
-MulDiv (
-       int     nNumber,
-       int     nNumerator,
-       int     nDenominator
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return 0;
-}
+    /* If the result is positive, we "add" to round. else, we subtract to round. */
+    if ( ( (nMultiplicand <  0) && (nMultiplier <  0) ) ||
+        ( (nMultiplicand >= 0) && (nMultiplier >= 0) ) )
+      return ((nMultiplicand * nMultiplier) + (nDivisor/2)) / nDivisor;
 
+    return ((nMultiplicand * nMultiplier) - (nDivisor/2)) / nDivisor;
 
-/**********************************************************************
- * NAME                                                        PRIVATE
- *     IsInstalledCP@4
- *
- * RETURN VALUE
- *     TRUE if CodePage is installed in the system.
- */
-static
-BOOL
-STDCALL
-IsInstalledCP (
-       UINT    CodePage
-       )
-{
-       /* FIXME */
-       return TRUE;
+#endif
 }
 
 
@@ -1301,17 +954,17 @@ IsInstalledCP (
  *             MB_COMPOSITE
  *             MB_ERR_INVALID_CHARS
  *             MB_USEGLYPHCHARS
- *             
+ *
  *     lpMultiByteStr
  *             Input buffer;
- *             
+ *
  *     cchMultiByte
  *             Size of MultiByteStr, or -1 if MultiByteStr is
  *             NULL terminated;
- *             
+ *
  *     lpWideCharStr
  *             Output buffer;
- *             
+ *
  *     cchWideChar
  *             Size (in WCHAR unit) of WideCharStr, or 0
  *             if the caller just wants to know how large
@@ -1324,7 +977,7 @@ IsInstalledCP (
  *
  * NOTE
  *     A raw converter for now. It assumes lpMultiByteStr is
- *     NEVER multi-byte (that is each input character is 
+ *     NEVER multi-byte (that is each input character is
  *     8-bit ASCII) and is ALWAYS NULL terminated.
  *     FIXME-FIXME-FIXME-FIXME
  */
@@ -1404,7 +1057,7 @@ MultiByteToWideChar (
        for (   cchConverted = 0,
                r = (PCHAR) lpMultiByteStr,
                w = (PWCHAR) lpWideCharStr;
-               
+
                ((*r) && (cchConverted < cchWideChar));
 
                r++,
@@ -1430,13 +1083,6 @@ MultiByteToWideChar (
 }
 
 
-
-
-
-
-
-
-
 WINBOOL
 STDCALL
 QueryPerformanceCounter (
@@ -1459,11 +1105,6 @@ QueryPerformanceFrequency (
 }
 
 
-
-
-
-
-
 WINBOOL
 STDCALL
 RegisterConsoleVDM (
@@ -1507,8 +1148,6 @@ RegisterWowExec (
 }
 
 
-
-
 WINBOOL
 STDCALL
 SetComputerNameA (
@@ -1531,14 +1170,6 @@ SetComputerNameW (
 }
 
 
-
-
-
-
-
-
-
-
 WINBOOL
 STDCALL
 SetLocaleInfoA (
@@ -1565,11 +1196,6 @@ SetLocaleInfoW (
 }
 
 
-
-
-
-
-
 WINBOOL
 STDCALL
 SetSystemPowerState (
@@ -1581,8 +1207,13 @@ SetSystemPowerState (
        return FALSE;
 }
 
-
-
+WINBOOL
+STDCALL
+SetThreadIdealProcessor(VOID)
+{
+       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+       return 0;
+}
 
 WINBOOL
 STDCALL
@@ -1594,6 +1225,13 @@ SetThreadLocale (
        return FALSE;
 }
 
+WINBOOL
+STDCALL
+SetThreadPriorityBoost(VOID)
+{
+       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+       return 0;
+}
 
 WINBOOL
 STDCALL
@@ -1607,24 +1245,6 @@ SetVDMCurrentDirectories (
 }
 
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 DWORD
 STDCALL
 TrimVirtualBuffer (
@@ -1636,8 +1256,6 @@ TrimVirtualBuffer (
 }
 
 
-
-
 DWORD
 STDCALL
 VDMConsoleOperation (
@@ -1687,9 +1305,6 @@ VerLanguageNameW (
 }
 
 
-
-
-
 DWORD
 STDCALL
 VirtualBufferExceptionHandler (
@@ -1703,8 +1318,66 @@ VirtualBufferExceptionHandler (
 }
 
 
-
-
+/**********************************************************************
+ * NAME                                                        EXPORTED
+ *     MultiByteToWideChar@32
+ * 
+ *     Not yet implemented complete (without NLS so far)
+ *
+ * ARGUMENTS
+ *     CodePage
+ *             CP_ACP ANSI code page 
+ *             CP_MACCP Macintosh code page 
+ *             CP_OEMCP OEM code page 
+ *             CP_SYMBOL Symbol code page (42) 
+ *             CP_THREAD_ACP Current thread's ANSI code page 
+ *             CP_UTF7 Translate using UTF-7 
+ *             CP_UTF8 Translate using UTF-8 
+ *             (UINT)          Any installed code page
+ *
+ *     dwFlags
+ *             WC_NO_BEST_FIT_CHARS    
+ *             WC_COMPOSITECHECK Convert composite characters to precomposed characters. 
+ *             WC_DISCARDNS Discard nonspacing characters during conversion. 
+ *             WC_SEPCHARS Generate separate characters during conversion. This is the default conversion behavior. 
+ *             WC_DEFAULTCHAR Replace exceptions with the default character during conversion. 
+ *
+ *     lpWideCharStr 
+ *             Points to the wide-character string to be converted. 
+ *
+ *     cchWideChar
+ *             Size (in WCHAR unit) of WideCharStr, or 0
+ *             if the caller just wants to know how large
+ *             WideCharStr should be for a successful
+ *             conversion.
+ *     lpMultiByteStr 
+ *             Points to the buffer to receive the translated string. 
+ *     cchMultiByte 
+ *             Specifies the size in bytes of the buffer pointed to by the 
+ *             lpMultiByteStr parameter. If this value is zero, the function 
+ *             returns the number of bytes required for the buffer. 
+ *     lpDefaultChar 
+ *             Points to the character used if a wide character cannot be 
+ *             represented in the specified code page. If this parameter is 
+ *             NULL, a system default value is used. 
+               FIXME: ignored
+ *     lpUsedDefaultChar 
+ *             Points to a flag that indicates whether a default character was used. 
+ *             This parameter may be NULL. 
+               FIXME: allways set to FALSE.
+ *
+ *
+ *
+ * RETURN VALUE
+ *     0 on error; otherwise the number of bytes written
+ *     in the lpMultiByteStr buffer. Or the number of
+ *     bytes needed for the lpMultiByteStr buffer if cchMultiByte is zero.
+ *
+ * NOTE
+ *     A raw converter for now. It just cuts off the upper 9 Bit.
+ *     So the MBCS-string does not contain any LeadCharacters
+ *     FIXME - FIXME - FIXME - FIXME
+ */
 
 int
 STDCALL
@@ -1719,7 +1392,63 @@ WideCharToMultiByte (
        LPBOOL  lpUsedDefaultChar
        )
 {
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+       int wi, di;  // wide counter, dbcs byte count
+
+       // for now, make no difference but only convert cut the characters to 7Bit
+       switch( CodePage )
+       {
+       case CP_ACP:            //ANSI code page         
+       case CP_MACCP:                  //Macintosh code page 
+       case CP_OEMCP:                  //OEM code page 
+       case CP_SYMBOL:                 //Symbol code page (42) 
+       case CP_THREAD_ACP:             //ACP Current thread's ANSI code page 
+       case CP_UTF7:                   //Translate using UTF-7 
+       case CP_UTF8:                   //Translate using UTF-8 
+               if( cchWideChar == -1 ) // assume its a 0-terminated str
+               {                                               // and determine its length
+                       for( cchWideChar=0; lpWideCharStr[cchWideChar]!=0; )
+                               cchWideChar++;
+               }
+
+               // user wants to determine needed space
+               if( cchMultiByte == 0 ) 
+               {
+                       SetLastError(ERROR_SUCCESS);
+                       return cchWideChar;                     // FIXME: determine correct.
+               }
+               // the lpWideCharStr is cchWideChar characters long.
+               for( wi=0, di=0; wi<cchWideChar && di<cchMultiByte; ++wi)
+               {
+                       // Flag and a not displayable char    FIXME
+                       /*if( (dwFlags&WC_NO_BEST_FIT_CHARS) && (lpWideCharStr[wi] >127) ) 
+                       {
+                               lpMultiByteStr[di]=
+                               *lpUsedDefaultChar = TRUE;
+
+                       }*/
+                       // FIXME
+                       // just cut off the upper 9 Bit, since vals>=128 mean LeadByte.
+                       lpMultiByteStr[di] = lpWideCharStr[wi] & 0x007F;
+                       ++di;
+               }
+               // has MultiByte exceeded but Wide is still in the string?
+               if( wi < cchWideChar && di >= cchMultiByte)
+               {
+                       SetLastError(ERROR_INSUFFICIENT_BUFFER);
+                       return di;
+               }
+               // else return # of bytes wirtten to MBCSbuffer (di)
+               SetLastError(ERROR_SUCCESS);
+                               // FIXME: move that elsewhere
+                               if( lpUsedDefaultChar!=NULL ) *lpUsedDefaultChar=FALSE; 
+               return di;
+               break;
+       default:
+               SetLastError(ERROR_INVALID_PARAMETER);
+               return FALSE;
+               break;
+       }
+       SetLastError(ERROR_INVALID_PARAMETER);
        return FALSE;
 }
 
@@ -1731,4 +1460,6 @@ WideCharToMultiByte (
 
 
 
+
+
 /* EOF */