Kaydet (Commit) d71bd0dd authored tarafından Eilidh McAdam's avatar Eilidh McAdam Kaydeden (comit) Fridrich Štrba

Code tidy up of indentation, comments and debug output.

Change-Id: I966d34205db1825d3aa1d328c03418817bf01bc3
Signed-off-by: 's avatarFridrich Štrba <fridrich.strba@bluewin.ch>
üst 9167f0a1
...@@ -20,11 +20,11 @@ typedef enum DDFLOGLEVEL { DDFLOG_ERR = 1, DDFLOG_WRN, DDFLOG_MSG } DDFLOGLEVEL; ...@@ -20,11 +20,11 @@ typedef enum DDFLOGLEVEL { DDFLOG_ERR = 1, DDFLOG_WRN, DDFLOG_MSG } DDFLOGLEVEL;
typedef struct DDFSRCFILE typedef struct DDFSRCFILE
{ {
char fileName[MAX_PATH]; char fileName[MAX_PATH];
char cabName[DDF_MAX_CABNAME]; char cabName[DDF_MAX_CABNAME];
BOOL extract; BOOL extract;
TCOMP cmpType; TCOMP cmpType;
struct DDFSRCFILE * next; struct DDFSRCFILE * next;
} DDFSRCFILE; } DDFSRCFILE;
unsigned int ParseDdf(char * ddfFile, PCCAB vars, DDFSRCFILE ** srcListH, unsigned int v); unsigned int ParseDdf(char * ddfFile, PCCAB vars, DDFSRCFILE ** srcListH, unsigned int v);
......
...@@ -82,21 +82,17 @@ static BOOL msidbImportStorages(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR storageName ...@@ -82,21 +82,17 @@ static BOOL msidbImportStorages(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR storageName
lstrcatW(storagePath, delim); lstrcatW(storagePath, delim);
lstrcatW(storagePath, storageNames[i]); lstrcatW(storagePath, storageNames[i]);
/* WINE_MESSAGE("Importing from %s\n", wine_dbgstr_w(storagePath)); */
rec = MsiCreateRecord(2); rec = MsiCreateRecord(2);
MsiRecordSetStringW(rec, 1, storageNames[i]); MsiRecordSetStringW(rec, 1, storageNames[i]);
r = MsiRecordSetStreamW(rec, 2, storagePath); r = MsiRecordSetStreamW(rec, 2, storagePath);
if (r != ERROR_SUCCESS) if (r != ERROR_SUCCESS)
{ {
/* WINE_MESSAGE("Error setting storage %d\n", r); */
return FALSE; return FALSE;
} }
r = MsiViewExecute(view, rec); r = MsiViewExecute(view, rec);
if (r != ERROR_SUCCESS) if (r != ERROR_SUCCESS)
{ {
/* WINE_MESSAGE("Unable to update with storage record %d\n", r); */
return FALSE; return FALSE;
} }
...@@ -133,10 +129,9 @@ static BOOL msidbExportStorage(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR storageName) ...@@ -133,10 +129,9 @@ static BOOL msidbExportStorage(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR storageName)
if ((r = MsiRecordReadStream(rec, 2, 0, &dataLen)) != ERROR_SUCCESS) if ((r = MsiRecordReadStream(rec, 2, 0, &dataLen)) != ERROR_SUCCESS)
{ {
/* WINE_MESSAGE("Problem reading stream, error %d %d %d (%d)\n", r, r == ERROR_INVALID_HANDLE, r == ERROR_INVALID_PARAMETER, dataLen ); */
return FALSE; return FALSE;
} }
/* WINE_MESSAGE("Exporting storage %s using query %s\n", storageNameA, queryBuffer); */
if ((dataBuffer = malloc(dataLen)) == NULL) return FALSE; if ((dataBuffer = malloc(dataLen)) == NULL) return FALSE;
if (MsiRecordReadStream(rec, 2, dataBuffer, &dataLen) != ERROR_SUCCESS) return FALSE; if (MsiRecordReadStream(rec, 2, dataBuffer, &dataLen) != ERROR_SUCCESS) return FALSE;
...@@ -195,14 +190,12 @@ static BOOL msidbImportStreams(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR streamNames[ ...@@ -195,14 +190,12 @@ static BOOL msidbImportStreams(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR streamNames[
r = MsiRecordSetStreamW(rec, 2, streamPath); r = MsiRecordSetStreamW(rec, 2, streamPath);
if (r != ERROR_SUCCESS) if (r != ERROR_SUCCESS)
{ {
/* WINE_MESSAGE("Error setting stream %d (%s)\n", r, wine_dbgstr_w(streamNames[i])); */
return FALSE; return FALSE;
} }
r = MsiViewExecute(view, rec); r = MsiViewExecute(view, rec);
if (r != ERROR_SUCCESS) if (r != ERROR_SUCCESS)
{ {
/* WINE_MESSAGE("Unable to update with stream record %d\n", r); */
return FALSE; return FALSE;
} }
...@@ -319,7 +312,6 @@ static BOOL msidbImportTables(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR tables[], BOO ...@@ -319,7 +312,6 @@ static BOOL msidbImportTables(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR tables[], BOO
if (r != ERROR_SUCCESS) if (r != ERROR_SUCCESS)
{ {
/* WINE_MESSAGE("Error while opening db: %d %d %d %d\n", r == ERROR_BAD_PATHNAME, r == ERROR_FUNCTION_FAILED, r == ERROR_INVALID_HANDLE, r == ERROR_INVALID_PARAMETER); */
return FALSE; return FALSE;
} }
...@@ -336,12 +328,6 @@ static BOOL msidbImportTables(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR tables[], BOO ...@@ -336,12 +328,6 @@ static BOOL msidbImportTables(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR tables[], BOO
if (strcmp(fileName, ".") == 0 || strcmp(fileName, "..") == 0) continue; if (strcmp(fileName, ".") == 0 || strcmp(fileName, "..") == 0) continue;
tableFile = strdupAtoW(CP_ACP, fileName); tableFile = strdupAtoW(CP_ACP, fileName);
r = MsiDatabaseImportW(dbhandle, wdir, tableFile); r = MsiDatabaseImportW(dbhandle, wdir, tableFile);
if (r != ERROR_SUCCESS)
{
/* WINE_MESSAGE("Failed to import %s from %s\n", wine_dbgstr_w(tableFile), wine_dbgstr_w(wdir)); */
}
free(tableFile); free(tableFile);
} }
} }
...@@ -360,11 +346,6 @@ static BOOL msidbImportTables(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR tables[], BOO ...@@ -360,11 +346,6 @@ static BOOL msidbImportTables(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR tables[], BOO
lstrcatW(tableFile, ext); lstrcatW(tableFile, ext);
r = MsiDatabaseImportW(dbhandle, wdir, tableFile); r = MsiDatabaseImportW(dbhandle, wdir, tableFile);
if (r != ERROR_SUCCESS)
{
/* WINE_MESSAGE("Error while importing %s: %d %d %d %d\n", wine_dbgstr_w(tableFile), r == ERROR_BAD_PATHNAME, r == ERROR_FUNCTION_FAILED, r == ERROR_INVALID_HANDLE, r == ERROR_INVALID_PARAMETER); */
}
free(tableFile); free(tableFile);
if (r != ERROR_SUCCESS) if (r != ERROR_SUCCESS)
...@@ -426,21 +407,11 @@ static BOOL msidbExportTables(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR tables[]) ...@@ -426,21 +407,11 @@ static BOOL msidbExportTables(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR tables[])
lstrcatW(tableFile, ext); lstrcatW(tableFile, ext);
r = MsiDatabaseExportW(dbhandle, tableName, wdir, tableFile); r = MsiDatabaseExportW(dbhandle, tableName, wdir, tableFile);
#ifdef DEBUG
if (r != ERROR_SUCCESS)
{
/* WINE_MESSAGE("Failed to export %s. Reason: functionfailed(%d) invalidparam(%d) badpath(%d)\n",wine_dbgstr_w(tableFile), r==ERROR_FUNCTION_FAILED, r==ERROR_INVALID_PARAMETER, r==ERROR_BAD_PATHNAME ); */
}
#endif
free(tableFile); free(tableFile);
MsiCloseHandle(rec); MsiCloseHandle(rec);
} }
#ifdef DEBUG
else
{
/* WINE_MESSAGE("Failed with error. Size is now %d. Error: %d %d %d\n", size, r == ERROR_MORE_DATA, r == ERROR_INVALID_HANDLE, r == ERROR_INVALID_PARAMETER); */
}
#endif
r = MsiViewFetch(tableListView, &rec); r = MsiViewFetch(tableListView, &rec);
} }
...@@ -580,10 +551,5 @@ int wmain(int argc, WCHAR *argv[]) ...@@ -580,10 +551,5 @@ int wmain(int argc, WCHAR *argv[])
if (!msidbExportStorage(dbfile, wdir, storageName)) if (!msidbExportStorage(dbfile, wdir, storageName))
return 6; return 6;
/*for (i = 0; i < 10; i++)
{
WINE_MESSAGE("%s\t%s\t%s\t%s\t%s\n", wine_dbgstr_w(iTables[i]), wine_dbgstr_w(oTables[i]), wine_dbgstr_w(streamName), wine_dbgstr_w(streamFiles[i]), wine_dbgstr_w(storageNames[i]));
}*/
return 0; return 0;
} }
...@@ -61,186 +61,193 @@ static const char * commandNames[COMMANDS] = ...@@ -61,186 +61,193 @@ static const char * commandNames[COMMANDS] =
static void parseDate(LPCWSTR value, SYSTEMTIME *time) static void parseDate(LPCWSTR value, SYSTEMTIME *time)
{ {
LPWSTR field; LPWSTR field;
uint len = 4*sizeof(WCHAR); uint len = 4*sizeof(WCHAR);
if (lstrlenW(value) != 19) return; if (lstrlenW(value) != 19) return;
field = malloc(len + sizeof(WCHAR)); field = malloc(len + sizeof(WCHAR));
if (field == NULL) return; if (field == NULL) return;
memcpy(field, value, len); memcpy(field, value, len);
field[4] = L'\0'; field[4] = L'\0';
time->wYear = atoiW(field); time->wYear = atoiW(field);
len = 2 * sizeof(WCHAR); len = 2 * sizeof(WCHAR);
memcpy(field, &(value[5]), len); memcpy(field, &(value[5]), len);
field[2] = '\0'; field[2] = '\0';
time->wMonth = atoiW(field); time->wMonth = atoiW(field);
memcpy(field, &(value[8]), len); memcpy(field, &(value[8]), len);
time->wDay = atoiW(field); time->wDay = atoiW(field);
memcpy(field, &(value[11]), len); memcpy(field, &(value[11]), len);
time->wHour = atoiW(field); time->wHour = atoiW(field);
memcpy(field, &(value[14]), len); memcpy(field, &(value[14]), len);
time->wMinute = atoiW(field); time->wMinute = atoiW(field);
memcpy(field, &(value[17]), len); memcpy(field, &(value[17]), len);
time->wSecond = atoiW(field); time->wSecond = atoiW(field);
free(field); free(field);
} }
static BOOL msiinfoDisplayProperties(LPWSTR dbfile) static BOOL msiinfoDisplayProperties(LPWSTR dbfile)
{ {
MSIHANDLE dbhandle, infohandle; MSIHANDLE dbhandle, infohandle;
uint i, r, dataType; uint i, r, dataType;
INT iVal; INT iVal;
FILETIME ftVal; FILETIME ftVal;
SYSTEMTIME sysTime; SYSTEMTIME sysTime;
LPWSTR szVal = NULL; LPWSTR szVal = NULL;
DWORD size; DWORD size;
r = MsiOpenDatabaseW(dbfile, (LPWSTR) MSIDBOPEN_READONLY, &dbhandle); r = MsiOpenDatabaseW(dbfile, (LPWSTR) MSIDBOPEN_READONLY, &dbhandle);
if (r != ERROR_SUCCESS) if (r != ERROR_SUCCESS)
{
return FALSE;
}
r = MsiGetSummaryInformationW(dbhandle, 0, 0, &infohandle);
if (r != ERROR_SUCCESS)
{
return FALSE;
}
for (i = 0; i < COMMANDS; i++)
{
MsiSummaryInfoGetPropertyW(infohandle, commandMap[i][1], &dataType,
&iVal, &ftVal, szVal, &size);
wprintf(L"%-24s", commandNames[i]);
if (dataType == VT_LPSTR)
{ {
if (szVal!=NULL) wprintf(L"%ls (%d)\n", szVal, lstrlenW(szVal)); return FALSE;
else wprintf(L"\n");
} }
else if (dataType == VT_FILETIME)
r = MsiGetSummaryInformationW(dbhandle, 0, 0, &infohandle);
if (r != ERROR_SUCCESS)
{ {
FileTimeToSystemTime(&ftVal, &sysTime); return FALSE;
wprintf(L"%04d/%02d/%02d %02d:%02d:%02d\n", sysTime.wYear, sysTime.wMonth,
sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
} }
else for (i = 0; i < COMMANDS; i++)
{ {
wprintf(L"%d\n", iVal); MsiSummaryInfoGetPropertyW(infohandle, commandMap[i][1], &dataType,
&iVal, &ftVal, szVal, &size);
wprintf(L"%-24s", commandNames[i]);
if (dataType == VT_LPSTR)
{
if (szVal!=NULL) wprintf(L"%ls (%d)\n", szVal, lstrlenW(szVal));
else wprintf(L"\n");
}
else if (dataType == VT_FILETIME)
{
FileTimeToSystemTime(&ftVal, &sysTime);
wprintf(L"%04d/%02d/%02d %02d:%02d:%02d\n", sysTime.wYear, sysTime.wMonth,
sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
}
else
{
wprintf(L"%d\n", iVal);
}
} }
}
MsiCloseHandle(infohandle); MsiCloseHandle(infohandle);
return TRUE; return TRUE;
} }
static BOOL msiinfoUpdateProperty(MSIHANDLE infoHandle, uint property, uint dataType, LPCWSTR value) static BOOL msiinfoUpdateProperty(MSIHANDLE infoHandle, uint property, uint dataType, LPCWSTR value)
{ {
uint r; uint r;
int iVal = 0; int iVal = 0;
FILETIME ftVal; FILETIME ftVal;
SYSTEMTIME sysTime = {0}; SYSTEMTIME sysTime = {0};
LPCWSTR szVal = NULL; LPCWSTR szVal = NULL;
if (dataType == VT_LPSTR) szVal = value; if (dataType == VT_LPSTR) szVal = value;
else if (dataType == VT_FILETIME) else if (dataType == VT_FILETIME)
{ {
parseDate(value, &sysTime); parseDate(value, &sysTime);
SystemTimeToFileTime(&sysTime, &ftVal); SystemTimeToFileTime(&sysTime, &ftVal);
} }
else else
iVal = atoiW(value); iVal = atoiW(value);
r = MsiSummaryInfoSetPropertyW(infoHandle, property, dataType, iVal, &ftVal, szVal); r = MsiSummaryInfoSetPropertyW(infoHandle, property, dataType, iVal, &ftVal, szVal);
if (r != ERROR_SUCCESS) if (r != ERROR_SUCCESS)
{ {
wprintf(L"Problem updating property: %d %d %d %d\n", r == ERROR_DATATYPE_MISMATCH, r == ERROR_FUNCTION_FAILED, ERROR_UNKNOWN_PROPERTY, ERROR_UNSUPPORTED_TYPE); wprintf(L"Problem updating property: %d %d %d %d\n", r == ERROR_DATATYPE_MISMATCH, r == ERROR_FUNCTION_FAILED, ERROR_UNKNOWN_PROPERTY, ERROR_UNSUPPORTED_TYPE);
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
} }
static void usage(void) static void usage(void)
{ {
WINE_MESSAGE( wprintf(
"Usage: msiinfo {database} [[-b]-d] {options} {data}\n" L"Usage: msiinfo {database} [[-b]-d] {options} {data}\n"
"\nOptions:\n" L"\nOptions:\n"
" -c <cp> Specify codepage\n" L" -c <cp> Specify codepage\n"
" -t <title> Specify title\n" L" -t <title> Specify title\n"
" -j <subject> Specify subject\n" L" -j <subject> Specify subject\n"
" -a <author> Specify author\n" L" -a <author> Specify author\n"
" -k <keywords> Specify keywords\n" L" -k <keywords> Specify keywords\n"
" -o <comment> Specify comments\n" L" -o <comment> Specify comments\n"
" -p <template> Specify template\n" L" -p <template> Specify template\n"
" -l <author> Specify last author\n" L" -l <author> Specify last author\n"
" -v <revno> Specify revision number\n" L" -v <revno> Specify revision number\n"
" -s <date> Specify last printed date\n" L" -s <date> Specify last printed date\n"
" -r <date> Specify creation date\n" L" -r <date> Specify creation date\n"
" -q <date> Specify date of last save\n" L" -q <date> Specify date of last save\n"
" -g <pages> Specify page count\n" L" -g <pages> Specify page count\n"
" -w <words> Specify word count\n" L" -w <words> Specify word count\n"
" -h <chars> Specify character count\n" L" -h <chars> Specify character count\n"
" -n <appname> Specify application which created the database\n" L" -n <appname> Specify application which created the database\n"
" -u <security> Specify security (0: none, 2: read only (rec.) 3: read only (enforced)\n"); L" -u <security> Specify security (0: none, 2: read only (rec.) 3: read only (enforced)\n");
} }
int wmain(int argc, WCHAR *argv[]) int wmain(int argc, WCHAR *argv[])
{ {
WCHAR *dbfile = NULL; WCHAR *dbfile = NULL;
uint i = 0; uint i = 0;
MSIHANDLE dbhandle, infohandle; MSIHANDLE dbhandle, infohandle;
uint r; uint r;
LPWSTR value = 0; LPWSTR value = 0;
static const WCHAR h1[] = {'/', '?', 0};
if (argc > 1) static const WCHAR h2[] = {'-', '?', 0};
{
dbfile = argv[1]; if (argc > 1)
argv++; argc--; {
} dbfile = argv[1];
argv++; argc--;
if (argc == 1) }
{
msiinfoDisplayProperties(dbfile);
return 0;
}
r = MsiOpenDatabaseW(dbfile, (LPWSTR) MSIDBOPEN_TRANSACT, &dbhandle);
if (r != ERROR_SUCCESS) return 1;
r = MsiGetSummaryInformationW(dbhandle, 0, 20, &infohandle);
if (r != ERROR_SUCCESS) return 2;
while (argv[1] && argv[1][0] == '-') if (strcmpW(dbfile, h1) == 0 || strcmpW(dbfile, h2) == 0)
{
switch (argv[1][1])
{ {
case '?': usage();
case 'h': return 0;
usage(); }
return 0; else if (argc == 1)
default:
for (i = 0; i < COMMANDS; i++)
{
if (commandMap[i][0] == argv[1][1])
{ {
argv++; argc--; msiinfoDisplayProperties(dbfile);
value = argv[1]; return 0;
msiinfoUpdateProperty(infohandle, commandMap[i][1], commandMap[i][2], value);
break;
} }
}
break; r = MsiOpenDatabaseW(dbfile, (LPWSTR) MSIDBOPEN_TRANSACT, &dbhandle);
if (r != ERROR_SUCCESS) return 1;
r = MsiGetSummaryInformationW(dbhandle, 0, 20, &infohandle);
if (r != ERROR_SUCCESS) return 2;
while (argv[1] && argv[1][0] == '-')
{
switch (argv[1][1])
{
case '?':
case 'h':
usage();
return 0;
default:
for (i = 0; i < COMMANDS; i++)
{
if (commandMap[i][0] == argv[1][1])
{
argv++; argc--;
value = argv[1];
msiinfoUpdateProperty(infohandle, commandMap[i][1], commandMap[i][2], value);
break;
}
}
break;
}
argv++; argc--;
} }
argv++; argc--;
} MsiSummaryInfoPersist(infohandle);
MsiDatabaseCommit(dbhandle);
MsiSummaryInfoPersist(infohandle); MsiCloseHandle(dbhandle);
MsiDatabaseCommit(dbhandle); msiinfoDisplayProperties(dbfile);
MsiCloseHandle(dbhandle); return 0;
msiinfoDisplayProperties(dbfile);
return 0;
} }
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