MSI: use strdup, implement MsiDatabaseImportA

Mike McCormack mike at codeweavers.com
Fri Mar 25 10:08:25 CST 2005


ChangeLog:
* use strdup, implement MsiDatabaseImportA
-------------- next part --------------
? dlls/msi/version.res
Index: dlls/msi/msi.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/msi.c,v
retrieving revision 1.69
diff -u -p -r1.69 msi.c
--- dlls/msi/msi.c	24 Mar 2005 19:04:06 -0000	1.69
+++ dlls/msi/msi.c	25 Mar 2005 16:03:54 -0000
@@ -608,21 +608,17 @@ UINT WINAPI MsiGetProductInfoA(LPCSTR sz
                  LPSTR szBuffer, DWORD *pcchValueBuf)
 {
     LPWSTR szwProduct = NULL, szwAttribute = NULL, szwBuffer = NULL;
-    UINT hr = ERROR_INSTALL_FAILURE;
+    UINT hr = ERROR_OUTOFMEMORY;
 
-    FIXME("%s %s %p %p\n",debugstr_a(szProduct), debugstr_a(szAttribute),
+    TRACE("%s %s %p %p\n", debugstr_a(szProduct), debugstr_a(szAttribute),
           szBuffer, pcchValueBuf);
 
-    if( NULL != szBuffer && NULL == pcchValueBuf )
-        return ERROR_INVALID_PARAMETER;
     if( szProduct )
     {
         szwProduct = strdupAtoW( szProduct );
         if( !szwProduct )
             goto end;
     }
-    else
-        return ERROR_INVALID_PARAMETER;
     
     if( szAttribute )
     {
@@ -630,11 +626,6 @@ UINT WINAPI MsiGetProductInfoA(LPCSTR sz
         if( !szwAttribute )
             goto end;
     }
-    else
-    {
-        hr = ERROR_INVALID_PARAMETER;
-        goto end;
-    }
 
     if( szBuffer )
     {
@@ -679,40 +670,59 @@ UINT WINAPI MsiGetProductInfoW(LPCWSTR s
     return hr;
 }
 
-UINT WINAPI MsiDatabaseImportA(MSIHANDLE handle, LPCSTR szFolderPath, LPCSTR szFilename)
+UINT WINAPI MsiDatabaseImportW(MSIHANDLE handle, LPCWSTR szFolderPath, LPCWSTR szFilename)
 {
-    FIXME("%lx %s %s\n",handle,debugstr_a(szFolderPath), debugstr_a(szFilename));
+    FIXME("%lx %s %s\n",handle,debugstr_w(szFolderPath), debugstr_w(szFilename));
     return ERROR_CALL_NOT_IMPLEMENTED;
 }
 
-UINT WINAPI MsiDatabaseImportW(MSIHANDLE handle, LPCWSTR szFolderPath, LPCWSTR szFilename)
+UINT WINAPI MsiDatabaseImportA( MSIHANDLE handle,
+               LPCSTR szFolderPath, LPCSTR szFilename )
 {
-    FIXME("%lx %s %s\n",handle,debugstr_w(szFolderPath), debugstr_w(szFilename));
-    return ERROR_CALL_NOT_IMPLEMENTED;
+    LPWSTR path = NULL, file = NULL;
+    UINT r = ERROR_OUTOFMEMORY;
+
+    TRACE("%lx %s %s\n", handle, debugstr_a(szFolderPath), debugstr_a(szFilename));
+
+    if( szFolderPath )
+    {
+        path = strdupAtoW( szFolderPath );
+        if( !path )
+            goto end;
+    }
+
+    if( szFilename )
+    {
+        file = strdupAtoW( szFilename );
+        if( !file )
+            goto end;
+    }
+
+    r = MsiDatabaseImportW( handle, path, file );
+
+end:
+    HeapFree( GetProcessHeap(), 0, path );
+    HeapFree( GetProcessHeap(), 0, file );
+
+    return r;
 }
 
 UINT WINAPI MsiEnableLogA(DWORD dwLogMode, LPCSTR szLogFile, DWORD attributes)
 {
     LPWSTR szwLogFile = NULL;
-    UINT hr = ERROR_INSTALL_FAILURE;
+    UINT r;
 
-    FIXME("%08lx %s %08lx\n", dwLogMode, debugstr_a(szLogFile), attributes);
+    TRACE("%08lx %s %08lx\n", dwLogMode, debugstr_a(szLogFile), attributes);
 
     if( szLogFile )
     {
         szwLogFile = strdupAtoW( szLogFile );
         if( !szwLogFile )
-            goto end;
+            return ERROR_OUTOFMEMORY;
     }
-    else
-        return ERROR_INVALID_PARAMETER;
-
-    hr = MsiEnableLogW( dwLogMode, szwLogFile, attributes );
-
-end:
+    r = MsiEnableLogW( dwLogMode, szwLogFile, attributes );
     HeapFree( GetProcessHeap(), 0, szwLogFile );
-
-    return hr;
+    return r;
 }
 
 UINT WINAPI MsiEnableLogW(DWORD dwLogMode, LPCWSTR szLogFile, DWORD attributes)
@@ -721,7 +731,7 @@ UINT WINAPI MsiEnableLogW(DWORD dwLogMod
 
     TRACE("%08lx %s %08lx\n", dwLogMode, debugstr_w(szLogFile), attributes);
 
-    strcpyW(gszLogFile,szLogFile);
+    lstrcpyW(gszLogFile,szLogFile);
     if (!(attributes & INSTALLLOGATTRIBUTES_APPEND))
         DeleteFileW(szLogFile);
     file = CreateFileW(szLogFile, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS,
Index: dlls/msi/record.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/record.c,v
retrieving revision 1.23
diff -u -p -r1.23 record.c
--- dlls/msi/record.c	10 Mar 2005 11:15:40 -0000	1.23
+++ dlls/msi/record.c	25 Mar 2005 16:03:54 -0000
@@ -448,7 +448,6 @@ UINT WINAPI MsiRecordDataSize(MSIHANDLE 
 UINT MSI_RecordSetStringA( MSIRECORD *rec, unsigned int iField, LPCSTR szValue )
 {
     LPWSTR str;
-    UINT len;
 
     TRACE("%p %d %s\n", rec, iField, debugstr_a(szValue));
 
@@ -458,9 +457,7 @@ UINT MSI_RecordSetStringA( MSIRECORD *re
     MSI_FreeField( &rec->fields[iField] );
     if( szValue && szValue[0] )
     {
-        len = MultiByteToWideChar( CP_ACP, 0, szValue, -1, NULL, 0 );
-        str = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
-        MultiByteToWideChar( CP_ACP, 0, szValue, -1, str, len );
+        str = strdupAtoW( szValue );
         rec->fields[iField].type = MSIFIELD_WSTR;
         rec->fields[iField].u.szwVal = str;
     }
@@ -493,7 +490,6 @@ UINT WINAPI MsiRecordSetStringA( MSIHAND
 UINT MSI_RecordSetStringW( MSIRECORD *rec, unsigned int iField, LPCWSTR szValue )
 {
     LPWSTR str;
-    UINT len;
 
     TRACE("%p %d %s\n", rec, iField, debugstr_w(szValue));
 
@@ -504,10 +500,7 @@ UINT MSI_RecordSetStringW( MSIRECORD *re
 
     if( szValue && szValue[0] )
     {
-        len = lstrlenW(szValue) + 1;
-        str = HeapAlloc( GetProcessHeap(), 0, len*sizeof (WCHAR));
-        lstrcpyW( str, szValue );
-
+        str = strdupW( szValue );
         rec->fields[iField].type = MSIFIELD_WSTR;
         rec->fields[iField].u.szwVal = str;
     }
@@ -633,15 +626,15 @@ UINT MSI_RecordSetStreamW(MSIRECORD *rec
 UINT WINAPI MsiRecordSetStreamA(MSIHANDLE hRecord, unsigned int iField, LPCSTR szFilename)
 {
     LPWSTR wstr = NULL;
-    UINT ret, len;
+    UINT ret;
 
     TRACE("%ld %d %s\n", hRecord, iField, debugstr_a(szFilename));
 
     if( szFilename )
     {
-        len = MultiByteToWideChar(CP_ACP,0,szFilename,-1,NULL,0);
-        wstr = HeapAlloc(GetProcessHeap(),0,len*sizeof(WCHAR));
-        MultiByteToWideChar(CP_ACP,0,szFilename,-1,wstr,len);
+        wstr = strdupAtoW( szFilename );
+        if( !wstr )
+             return ERROR_OUTOFMEMORY;
     }
     ret = MsiRecordSetStreamW(hRecord, iField, wstr);
     HeapFree(GetProcessHeap(),0,wstr);


More information about the wine-patches mailing list