Commit 30e388af authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

Use strdup, implement MsiDatabaseImportA.

parent 852fc5f1
...@@ -608,21 +608,17 @@ UINT WINAPI MsiGetProductInfoA(LPCSTR szProduct, LPCSTR szAttribute, ...@@ -608,21 +608,17 @@ UINT WINAPI MsiGetProductInfoA(LPCSTR szProduct, LPCSTR szAttribute,
LPSTR szBuffer, DWORD *pcchValueBuf) LPSTR szBuffer, DWORD *pcchValueBuf)
{ {
LPWSTR szwProduct = NULL, szwAttribute = NULL, szwBuffer = NULL; 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); szBuffer, pcchValueBuf);
if( NULL != szBuffer && NULL == pcchValueBuf )
return ERROR_INVALID_PARAMETER;
if( szProduct ) if( szProduct )
{ {
szwProduct = strdupAtoW( szProduct ); szwProduct = strdupAtoW( szProduct );
if( !szwProduct ) if( !szwProduct )
goto end; goto end;
} }
else
return ERROR_INVALID_PARAMETER;
if( szAttribute ) if( szAttribute )
{ {
...@@ -630,11 +626,6 @@ UINT WINAPI MsiGetProductInfoA(LPCSTR szProduct, LPCSTR szAttribute, ...@@ -630,11 +626,6 @@ UINT WINAPI MsiGetProductInfoA(LPCSTR szProduct, LPCSTR szAttribute,
if( !szwAttribute ) if( !szwAttribute )
goto end; goto end;
} }
else
{
hr = ERROR_INVALID_PARAMETER;
goto end;
}
if( szBuffer ) if( szBuffer )
{ {
...@@ -679,40 +670,59 @@ UINT WINAPI MsiGetProductInfoW(LPCWSTR szProduct, LPCWSTR szAttribute, ...@@ -679,40 +670,59 @@ UINT WINAPI MsiGetProductInfoW(LPCWSTR szProduct, LPCWSTR szAttribute,
return hr; 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; 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)); LPWSTR path = NULL, file = NULL;
return ERROR_CALL_NOT_IMPLEMENTED; 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) UINT WINAPI MsiEnableLogA(DWORD dwLogMode, LPCSTR szLogFile, DWORD attributes)
{ {
LPWSTR szwLogFile = NULL; 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 ) if( szLogFile )
{ {
szwLogFile = strdupAtoW( szLogFile ); szwLogFile = strdupAtoW( szLogFile );
if( !szwLogFile ) if( !szwLogFile )
goto end; return ERROR_OUTOFMEMORY;
} }
else r = MsiEnableLogW( dwLogMode, szwLogFile, attributes );
return ERROR_INVALID_PARAMETER;
hr = MsiEnableLogW( dwLogMode, szwLogFile, attributes );
end:
HeapFree( GetProcessHeap(), 0, szwLogFile ); HeapFree( GetProcessHeap(), 0, szwLogFile );
return r;
return hr;
} }
UINT WINAPI MsiEnableLogW(DWORD dwLogMode, LPCWSTR szLogFile, DWORD attributes) UINT WINAPI MsiEnableLogW(DWORD dwLogMode, LPCWSTR szLogFile, DWORD attributes)
...@@ -721,7 +731,7 @@ UINT WINAPI MsiEnableLogW(DWORD dwLogMode, LPCWSTR szLogFile, DWORD attributes) ...@@ -721,7 +731,7 @@ UINT WINAPI MsiEnableLogW(DWORD dwLogMode, LPCWSTR szLogFile, DWORD attributes)
TRACE("%08lx %s %08lx\n", dwLogMode, debugstr_w(szLogFile), attributes); TRACE("%08lx %s %08lx\n", dwLogMode, debugstr_w(szLogFile), attributes);
strcpyW(gszLogFile,szLogFile); lstrcpyW(gszLogFile,szLogFile);
if (!(attributes & INSTALLLOGATTRIBUTES_APPEND)) if (!(attributes & INSTALLLOGATTRIBUTES_APPEND))
DeleteFileW(szLogFile); DeleteFileW(szLogFile);
file = CreateFileW(szLogFile, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, file = CreateFileW(szLogFile, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS,
......
...@@ -448,7 +448,6 @@ UINT WINAPI MsiRecordDataSize(MSIHANDLE handle, unsigned int iField) ...@@ -448,7 +448,6 @@ UINT WINAPI MsiRecordDataSize(MSIHANDLE handle, unsigned int iField)
UINT MSI_RecordSetStringA( MSIRECORD *rec, unsigned int iField, LPCSTR szValue ) UINT MSI_RecordSetStringA( MSIRECORD *rec, unsigned int iField, LPCSTR szValue )
{ {
LPWSTR str; LPWSTR str;
UINT len;
TRACE("%p %d %s\n", rec, iField, debugstr_a(szValue)); TRACE("%p %d %s\n", rec, iField, debugstr_a(szValue));
...@@ -458,9 +457,7 @@ UINT MSI_RecordSetStringA( MSIRECORD *rec, unsigned int iField, LPCSTR szValue ) ...@@ -458,9 +457,7 @@ UINT MSI_RecordSetStringA( MSIRECORD *rec, unsigned int iField, LPCSTR szValue )
MSI_FreeField( &rec->fields[iField] ); MSI_FreeField( &rec->fields[iField] );
if( szValue && szValue[0] ) if( szValue && szValue[0] )
{ {
len = MultiByteToWideChar( CP_ACP, 0, szValue, -1, NULL, 0 ); str = strdupAtoW( szValue );
str = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, szValue, -1, str, len );
rec->fields[iField].type = MSIFIELD_WSTR; rec->fields[iField].type = MSIFIELD_WSTR;
rec->fields[iField].u.szwVal = str; rec->fields[iField].u.szwVal = str;
} }
...@@ -493,7 +490,6 @@ UINT WINAPI MsiRecordSetStringA( MSIHANDLE handle, unsigned int iField, LPCSTR s ...@@ -493,7 +490,6 @@ UINT WINAPI MsiRecordSetStringA( MSIHANDLE handle, unsigned int iField, LPCSTR s
UINT MSI_RecordSetStringW( MSIRECORD *rec, unsigned int iField, LPCWSTR szValue ) UINT MSI_RecordSetStringW( MSIRECORD *rec, unsigned int iField, LPCWSTR szValue )
{ {
LPWSTR str; LPWSTR str;
UINT len;
TRACE("%p %d %s\n", rec, iField, debugstr_w(szValue)); TRACE("%p %d %s\n", rec, iField, debugstr_w(szValue));
...@@ -504,10 +500,7 @@ UINT MSI_RecordSetStringW( MSIRECORD *rec, unsigned int iField, LPCWSTR szValue ...@@ -504,10 +500,7 @@ UINT MSI_RecordSetStringW( MSIRECORD *rec, unsigned int iField, LPCWSTR szValue
if( szValue && szValue[0] ) if( szValue && szValue[0] )
{ {
len = lstrlenW(szValue) + 1; str = strdupW( szValue );
str = HeapAlloc( GetProcessHeap(), 0, len*sizeof (WCHAR));
lstrcpyW( str, szValue );
rec->fields[iField].type = MSIFIELD_WSTR; rec->fields[iField].type = MSIFIELD_WSTR;
rec->fields[iField].u.szwVal = str; rec->fields[iField].u.szwVal = str;
} }
...@@ -633,15 +626,15 @@ UINT MSI_RecordSetStreamW(MSIRECORD *rec, unsigned int iField, LPCWSTR szFilenam ...@@ -633,15 +626,15 @@ UINT MSI_RecordSetStreamW(MSIRECORD *rec, unsigned int iField, LPCWSTR szFilenam
UINT WINAPI MsiRecordSetStreamA(MSIHANDLE hRecord, unsigned int iField, LPCSTR szFilename) UINT WINAPI MsiRecordSetStreamA(MSIHANDLE hRecord, unsigned int iField, LPCSTR szFilename)
{ {
LPWSTR wstr = NULL; LPWSTR wstr = NULL;
UINT ret, len; UINT ret;
TRACE("%ld %d %s\n", hRecord, iField, debugstr_a(szFilename)); TRACE("%ld %d %s\n", hRecord, iField, debugstr_a(szFilename));
if( szFilename ) if( szFilename )
{ {
len = MultiByteToWideChar(CP_ACP,0,szFilename,-1,NULL,0); wstr = strdupAtoW( szFilename );
wstr = HeapAlloc(GetProcessHeap(),0,len*sizeof(WCHAR)); if( !wstr )
MultiByteToWideChar(CP_ACP,0,szFilename,-1,wstr,len); return ERROR_OUTOFMEMORY;
} }
ret = MsiRecordSetStreamW(hRecord, iField, wstr); ret = MsiRecordSetStreamW(hRecord, iField, wstr);
HeapFree(GetProcessHeap(),0,wstr); HeapFree(GetProcessHeap(),0,wstr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment