- Implement CaptureStringArg and CaptureAndConvertAnsiArg.
authorEric Kohl <eric.kohl@reactos.org>
Wed, 16 Feb 2005 15:44:34 +0000 (15:44 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Wed, 16 Feb 2005 15:44:34 +0000 (15:44 +0000)
- FileExists: Restore error mode.
- Move configuration manager functions to a separate file.
- Add cfgmgr32.h.

svn path=/trunk/; revision=13595

reactos/include/wine/cfgmgr32.h [new file with mode: 0644]
reactos/lib/setupapi/Makefile.in
reactos/lib/setupapi/cfgmgr.c [new file with mode: 0644]
reactos/lib/setupapi/misc.c
reactos/lib/setupapi/setupapi.spec
reactos/lib/setupapi/stubs.c

diff --git a/reactos/include/wine/cfgmgr32.h b/reactos/include/wine/cfgmgr32.h
new file mode 100644 (file)
index 0000000..2c3792e
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2005 Mike McCormack
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef _CFGMGR32_H_
+#define _CFGMGR32_H_
+
+typedef DWORD CONFIGRET;
+typedef HANDLE HMACHINE;
+typedef HMACHINE *PHMACHINE;
+
+#define CR_SUCCESS       0x00000000
+#define CR_INVALID_DATA  0x0000001F
+#define CR_ACCESS_DENIED 0x00000033
+
+
+CONFIGRET WINAPI CM_Connect_MachineA( PCSTR, PHMACHINE );
+CONFIGRET WINAPI CM_Connect_MachineW( PCWSTR, PHMACHINE );
+#define     CM_Connect_Machine WINELIB_NAME_AW(CM_Connect_Machine)
+
+CONFIGRET WINAPI CM_Disconnect_Machine( HMACHINE );
+
+CONFIGRET WINAPI CM_Get_Device_ID_ListA( PCSTR, PCHAR, ULONG, ULONG );
+CONFIGRET WINAPI CM_Get_Device_ID_ListW( PCWSTR, PWCHAR, ULONG, ULONG );
+#define     CM_Get_Device_ID_List WINELIB_NAME_AW(CM_Get_Device_ID_List)
+CONFIGRET WINAPI CM_Get_Device_ID_List_ExA( PCSTR, PCHAR, ULONG, ULONG, HMACHINE );
+CONFIGRET WINAPI CM_Get_Device_ID_List_ExW( PCWSTR, PWCHAR, ULONG, ULONG, HMACHINE );
+#define     CM_Get_Device_ID_List_Ex WINELIB_NAME_AW(CM_Get_Device_ID_List_Ex)
+CONFIGRET WINAPI CM_Get_Device_ID_List_SizeA( PULONG, PCSTR, ULONG );
+CONFIGRET WINAPI CM_Get_Device_ID_List_SizeW( PULONG, PCWSTR, ULONG );
+#define     CM_Get_Device_ID_List_Size WINELIB_NAME_AW(CM_Get_Device_ID_List_Size)
+CONFIGRET WINAPI CM_Get_Device_ID_List_Size_ExA( PULONG, PCSTR, ULONG, HMACHINE );
+CONFIGRET WINAPI CM_Get_Device_ID_List_Size_ExW( PULONG, PCWSTR, ULONG, HMACHINE );
+#define     CM_Get_Device_ID_List_Size_Ex WINELIB_NAME_AW(CM_Get_Device_ID_List_Size_Ex)
+
+#endif /* _CFGMGR32_H_ */
index b3444fb..e502e29 100644 (file)
@@ -9,6 +9,7 @@ DELAYIMPORTS = shell32
 EXTRALIBS = $(LIBUNICODE)
 
 C_SRCS = \
+       cfgmgr.c \
        devinst.c \
        dirid.c \
        diskspace.c \
diff --git a/reactos/lib/setupapi/cfgmgr.c b/reactos/lib/setupapi/cfgmgr.c
new file mode 100644 (file)
index 0000000..91021b5
--- /dev/null
@@ -0,0 +1,183 @@
+/*\r
+ * Configuration manager functions\r
+ *\r
+ * Copyright 2000 James Hatheway\r
+ * Copyright 2005 Eric Kohl\r
+ *\r
+ * This library is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU Lesser General Public\r
+ * License as published by the Free Software Foundation; either\r
+ * version 2.1 of the License, or (at your option) any later version.\r
+ *\r
+ * This library is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+ * Lesser General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU Lesser General Public\r
+ * License along with this library; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ */\r
+\r
+#include <stdarg.h>\r
+\r
+#include "windef.h"\r
+#include "winbase.h"\r
+#include "wingdi.h"\r
+#include "winuser.h"\r
+#include "winnls.h"\r
+#include "winreg.h"\r
+#include "setupapi.h"\r
+#include "cfgmgr32.h"\r
+\r
+#include "wine/debug.h"\r
+\r
+WINE_DEFAULT_DEBUG_CHANNEL(setupapi);\r
+\r
+\r
+/***********************************************************************\r
+ * CM_Connect_MachineA [SETUPAPI.@]\r
+ */\r
+CONFIGRET WINAPI CM_Connect_MachineA(PCSTR UNCServerName, PHMACHINE phMachine)\r
+{\r
+    PWSTR pServerNameW;\r
+    CONFIGRET ret;\r
+\r
+    TRACE("%s %p\n", UNCServerName, phMachine);\r
+\r
+    if (UNCServerName == NULL || *UNCServerName == 0)\r
+    {\r
+        return CM_Connect_MachineW(NULL, phMachine);\r
+    }\r
+\r
+    if (CaptureAndConvertAnsiArg(UNCServerName, &pServerNameW))\r
+    {\r
+        return CR_INVALID_DATA;\r
+    }\r
+\r
+    ret = CM_Connect_MachineW(pServerNameW, phMachine);\r
+\r
+    MyFree(pServerNameW);\r
+\r
+    return ret;\r
+}\r
+\r
+\r
+/***********************************************************************\r
+ * CM_Connect_MachineW [SETUPAPI.@]\r
+ */\r
+CONFIGRET WINAPI CM_Connect_MachineW(PCWSTR UNCServerName, PHMACHINE phMachine)\r
+{\r
+    FIXME("%s %p\n", debugstr_w(UNCServerName), phMachine);\r
+    return CR_ACCESS_DENIED;\r
+}\r
+\r
+\r
+/***********************************************************************\r
+ * CM_Disconnect_Machine [SETUPAPI.@]\r
+ */\r
+CONFIGRET WINAPI CM_Disconnect_Machine(HMACHINE hMachine)\r
+{\r
+    FIXME("%lx\n", hMachine);\r
+    return CR_SUCCESS;\r
+}\r
+\r
+\r
+/***********************************************************************\r
+ * CM_Get_Device_ID_ListA [SETUPAPI.@]\r
+ */\r
+CONFIGRET WINAPI CM_Get_Device_ID_ListA(\r
+    PCSTR pszFilter, PCHAR Buffer, ULONG BufferLen, ULONG ulFlags )\r
+{\r
+    FIXME("%p %p %ld %ld\n", pszFilter, Buffer, BufferLen, ulFlags);\r
+    memset(Buffer,0,2);\r
+    return CR_SUCCESS;\r
+}\r
+\r
+\r
+/***********************************************************************\r
+ * CM_Get_Device_ID_ListW [SETUPAPI.@]\r
+ */\r
+CONFIGRET WINAPI CM_Get_Device_ID_ListW(\r
+    PCWSTR pszFilter, PWCHAR Buffer, ULONG BufferLen, ULONG ulFlags )\r
+{\r
+    TRACE("%p %p %ld %ld\n", pszFilter, Buffer, BufferLen, ulFlags);\r
+    return CM_Get_Device_ID_List_ExW(pszFilter, Buffer, BufferLen,\r
+                                     ulFlags, NULL);\r
+}\r
+\r
+\r
+/***********************************************************************\r
+ * CM_Get_Device_ID_List_ExA [SETUPAPI.@]\r
+ */\r
+CONFIGRET WINAPI CM_Get_Device_ID_List_ExA(\r
+    PCSTR pszFilter, PCHAR Buffer, ULONG BufferLen, ULONG ulFlags,\r
+    HMACHINE hMachine )\r
+{\r
+    FIXME("%p %p %ld %ld %lx\n",\r
+          pszFilter, Buffer, BufferLen, ulFlags, hMachine);\r
+    memset(Buffer,0,2);\r
+    return CR_SUCCESS;\r
+}\r
+\r
+\r
+/***********************************************************************\r
+ * CM_Get_Device_ID_List_ExW [SETUPAPI.@]\r
+ */\r
+CONFIGRET WINAPI CM_Get_Device_ID_List_ExW(\r
+    PCWSTR pszFilter, PWCHAR Buffer, ULONG BufferLen, ULONG ulFlags,\r
+    HMACHINE hMachine )\r
+{\r
+    FIXME("%p %p %ld %ld %lx\n",\r
+          pszFilter, Buffer, BufferLen, ulFlags, hMachine);\r
+    memset(Buffer,0,2);\r
+    return CR_SUCCESS;\r
+}\r
+\r
+\r
+/***********************************************************************\r
+ * CM_Get_Device_ID_List_SizeA [SETUPAPI.@]\r
+ */\r
+CONFIGRET WINAPI CM_Get_Device_ID_List_SizeA(\r
+    PULONG pulLen, PCSTR pszFilter, ULONG ulFlags)\r
+{\r
+    FIXME("%p %s %ld\n", pulLen, pszFilter, ulFlags);\r
+    *pulLen = 2;\r
+    return CR_SUCCESS;\r
+}\r
+\r
+\r
+/***********************************************************************\r
+ * CM_Get_Device_ID_List_SizeW [SETUPAPI.@]\r
+ */\r
+CONFIGRET WINAPI CM_Get_Device_ID_List_SizeW(\r
+    PULONG pulLen, PCWSTR pszFilter, ULONG ulFlags)\r
+{\r
+    FIXME("%p %s %ld\n", pulLen, debugstr_w(pszFilter), ulFlags);\r
+    *pulLen = 2;\r
+    return CR_SUCCESS;\r
+}\r
+\r
+\r
+/***********************************************************************\r
+ * CM_Get_Device_ID_List_Size_ExA [SETUPAPI.@]\r
+ */\r
+CONFIGRET WINAPI CM_Get_Device_ID_List_Size_ExA(\r
+    PULONG pulLen, PCSTR pszFilter, ULONG ulFlags, HMACHINE hMachine)\r
+{\r
+    FIXME("%p %s %ld %lx\n", pulLen, pszFilter, ulFlags, hMachine);\r
+    *pulLen = 2;\r
+    return CR_SUCCESS;\r
+}\r
+\r
+\r
+/***********************************************************************\r
+ * CM_Get_Device_ID_List_Size_ExW [SETUPAPI.@]\r
+ */\r
+CONFIGRET WINAPI CM_Get_Device_ID_List_Size_ExW(\r
+    PULONG pulLen, PCWSTR pszFilter, ULONG ulFlags, HMACHINE hMachine)\r
+{\r
+    FIXME("%p %s %ld %lx\n", pulLen, debugstr_w(pszFilter), ulFlags, hMachine);\r
+    *pulLen = 2;\r
+    return CR_SUCCESS;\r
+}\r
index 218da19..89601f0 100644 (file)
@@ -463,6 +463,19 @@ BOOL WINAPI EnablePrivilege(LPCWSTR lpPrivilegeName, BOOL bEnable)
 }
 
 
+/**************************************************************************
+ * DelayedMove [SETUPAPI.@]
+ *
+ * Moves a file upon the next reboot.
+ *
+ * PARAMS
+ *     lpExistingFileName  [I] Current file name
+ *     lpNewFileName       [I] New file name
+ *
+ * RETURNS
+ *     Success: TRUE
+ *     Failure: FALSE
+ */
 BOOL WINAPI DelayedMove(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName)
 {
     if (OsVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT)
@@ -476,6 +489,19 @@ BOOL WINAPI DelayedMove(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName)
 }
 
 
+/**************************************************************************
+ * FileExists [SETUPAPI.@]
+ *
+ * Checks whether a file exists.
+ *
+ * PARAMS
+ *     lpFileName     [I] Name of the file to check
+ *     lpNewFileName  [O] Optional information about the existing file
+ *
+ * RETURNS
+ *     Success: TRUE
+ *     Failure: FALSE
+ */
 BOOL WINAPI FileExists(LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFileFindData)
 {
     WIN32_FIND_DATAW FindData;
@@ -499,5 +525,61 @@ BOOL WINAPI FileExists(LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFileFindData)
     if (lpFileFindData)
         memcpy(lpFileFindData, &FindData, sizeof(WIN32_FIND_DATAW));
 
+    SetErrorMode(uErrorMode);
+
     return TRUE;
 }
+
+
+/**************************************************************************
+ * CaptureStringArg [SETUPAPI.@]
+ *
+ * Captures a UNICODE string.
+ *
+ * PARAMS
+ *     lpSrc  [I] UNICODE string to be captured
+ *     lpDst  [O] Pointer to the captured UNICODE string
+ *
+ * RETURNS
+ *     Success: ERROR_SUCCESS
+ *     Failure: ERROR_INVALID_PARAMETER
+ *
+ * NOTE
+ *     Call MyFree to release the captured UNICODE string.
+ */
+DWORD WINAPI CaptureStringArg(LPCWSTR pSrc, LPWSTR *pDst)
+{
+  if (pDst == NULL)
+    return ERROR_INVALID_PARAMETER;
+
+  *pDst = DuplicateString(pSrc);
+
+  return ERROR_SUCCESS;
+}
+
+
+/**************************************************************************
+ * CaptureAndConvertAnsiArg [SETUPAPI.@]
+ *
+ * Captures an ANSI string and converts it to a UNICODE string.
+ *
+ * PARAMS
+ *     lpSrc  [I] ANSI string to be captured
+ *     lpDst  [O] Pointer to the captured UNICODE string
+ *
+ * RETURNS
+ *     Success: ERROR_SUCCESS
+ *     Failure: ERROR_INVALID_PARAMETER
+ *
+ * NOTE
+ *     Call MyFree to release the captured UNICODE string.
+ */
+DWORD WINAPI CaptureAndConvertAnsiArg(LPCSTR pSrc, LPWSTR *pDst)
+{
+  if (pDst == NULL)
+    return ERROR_INVALID_PARAMETER;
+
+  *pDst = MultiByteToUnicode(pSrc, CP_ACP);
+
+  return ERROR_SUCCESS;
+}
index 10ed72a..262f457 100644 (file)
@@ -18,7 +18,7 @@
 @ stub CM_Add_Range
 @ stub CM_Add_Res_Des
 @ stub CM_Add_Res_Des_Ex
-@ stub CM_Connect_MachineA
+@ stdcall CM_Connect_MachineA(str ptr)
 @ stdcall CM_Connect_MachineW(wstr ptr)
 @ stub CM_Create_DevNodeA
 @ stub CM_Create_DevNodeW
 @ stub CM_Get_Device_IDW
 @ stub CM_Get_Device_ID_ExA
 @ stub CM_Get_Device_ID_ExW
-@ stdcall CM_Get_Device_ID_ListA(ptr ptr long long)
-@ stub CM_Get_Device_ID_ListW
-@ stub CM_Get_Device_ID_List_ExA
-@ stub CM_Get_Device_ID_List_ExW
-@ stub CM_Get_Device_ID_List_SizeA
-@ stub CM_Get_Device_ID_List_SizeW
-@ stub CM_Get_Device_ID_List_Size_ExA
-@ stub CM_Get_Device_ID_List_Size_ExW
+@ stdcall CM_Get_Device_ID_ListA(str str long long)
+@ stdcall CM_Get_Device_ID_ListW(wstr wstr long long)
+@ stdcall CM_Get_Device_ID_List_ExA(str str long long long)
+@ stdcall CM_Get_Device_ID_List_ExW(wstr wstr long long long)
+@ stdcall CM_Get_Device_ID_List_SizeA(ptr str long)
+@ stdcall CM_Get_Device_ID_List_SizeW(ptr wstr long)
+@ stdcall CM_Get_Device_ID_List_Size_ExA(ptr str long long)
+@ stdcall CM_Get_Device_ID_List_Size_ExW(ptr wstr long long)
 @ stub CM_Get_Device_ID_Size
 @ stub CM_Get_Device_ID_Size_Ex
 @ stub CM_Get_Device_Interface_AliasA
 @ stub CM_Unregister_Device_InterfaceW
 @ stub CM_Unregister_Device_Interface_ExA
 @ stub CM_Unregister_Device_Interface_ExW
-@ stub CaptureAndConvertAnsiArg
-@ stub CaptureStringArg
+@ stdcall CaptureAndConvertAnsiArg(str ptr)
+@ stdcall CaptureStringArg(wstr ptr)
 @ stub CenterWindowRelativeToParent
 @ stub ConcatenatePaths
 @ stdcall DelayedMove(wstr wstr)
index f722a0c..f0ab6e2 100644 (file)
@@ -90,39 +90,6 @@ HDEVINFO WINAPI SetupDiGetClassDevsExW(const GUID *class, PCWSTR filter, HWND pa
   return FALSE;
 }
 
-/***********************************************************************
- *             CM_Connect_MachineW  (SETUPAPI.@)
- */
-DWORD WINAPI CM_Connect_MachineW(LPCWSTR name, void * machine)
-{
-#define  CR_SUCCESS       0x00000000
-#define  CR_ACCESS_DENIED 0x00000033
-  FIXME("\n");
-  return  CR_ACCESS_DENIED;
-}
-
-/***********************************************************************
- *             CM_Disconnect_Machine  (SETUPAPI.@)
- */
-DWORD WINAPI CM_Disconnect_Machine(DWORD handle)
-{
-  FIXME("\n");
-  return  CR_SUCCESS;
-
-}
-
-/***********************************************************************
- *             CM_Get_Device_ID_ListA  (SETUPAPI.@)
- */
-
-DWORD WINAPI CM_Get_Device_ID_ListA(
-    PCSTR pszFilter, PCHAR Buffer, ULONG BufferLen, ULONG ulFlags )
-{
-    FIXME("%p %p %ld %ld\n", pszFilter, Buffer, BufferLen, ulFlags );
-    memset(Buffer,0,2);
-    return CR_SUCCESS;
-}
-
 
 /***********************************************************************
  *             SetupCopyOEMInfA  (SETUPAPI.@)