summaryrefslogtreecommitdiff
path: root/setup_native
diff options
context:
space:
mode:
authorEilidh McAdam <eilidh@lanedo.com>2012-07-06 17:28:59 +0100
committerFridrich Štrba <fridrich.strba@bluewin.ch>2012-07-18 11:00:42 +0200
commitd71bd0dd0b537d3b4558d32073e82714210ab15e (patch)
treea35ee2241d77be328d81f6a3ba7e4a7c7b475e8b /setup_native
parent9167f0a1a89ee2567449e4bd8bd21b02d8316be1 (diff)
Code tidy up of indentation, comments and debug output.
Change-Id: I966d34205db1825d3aa1d328c03418817bf01bc3 Signed-off-by: Fridrich Štrba <fridrich.strba@bluewin.ch>
Diffstat (limited to 'setup_native')
-rw-r--r--setup_native/source/win32/wintools/makecab/makecab.c507
-rw-r--r--setup_native/source/win32/wintools/makecab/parseddf.c540
-rw-r--r--setup_native/source/win32/wintools/makecab/parseddf.h10
-rw-r--r--setup_native/source/win32/wintools/msidb/msidb.c40
-rw-r--r--setup_native/source/win32/wintools/msiinfo/msiinfo.c301
5 files changed, 687 insertions, 711 deletions
diff --git a/setup_native/source/win32/wintools/makecab/makecab.c b/setup_native/source/win32/wintools/makecab/makecab.c
index f4579dab2057..f5621576a905 100644
--- a/setup_native/source/win32/wintools/makecab/makecab.c
+++ b/setup_native/source/win32/wintools/makecab/makecab.c
@@ -37,337 +37,340 @@ static const char * FCI_ERRS[] = {"None", "Error opening source file", "Error re
void cabLog(CABLOGLEVEL lvl, char * msg, ...)
{
- va_list args;
- if (CabVerb < lvl) return;
-
- switch (lvl)
- {
- case CABLOG_WRN: printf("[Warning] "); break;
- case CABLOG_ERR: printf("[Error] "); break;
- }
-
- va_start(args, msg);
- vprintf(msg, args);
- va_end(args);
- printf("\n");
+ va_list args;
+ if (CabVerb < lvl) return;
+
+ switch (lvl)
+ {
+ case CABLOG_WRN: printf("[Warning] "); break;
+ case CABLOG_ERR: printf("[Error] "); break;
+ }
+
+ va_start(args, msg);
+ vprintf(msg, args);
+ va_end(args);
+ printf("\n");
}
void cabLogErr(PERF erf, char * msg)
{
- if (!erf)
- {
- cabLog(CABLOG_ERR, "%s: An unknown problem occurred");
- return;
- }
-
- if (erf->erfOper >= 0)
- {
- if (erf->erfOper < (sizeof(FCI_ERRS)/sizeof(FCI_ERRS[0])))
- cabLog(CABLOG_ERR, "%s: %s", msg, FCI_ERRS[erf->erfOper]);
- else
- cabLog(CABLOG_ERR, "%s: Unknown error", msg);
- }
+ if (!erf)
+ {
+ cabLog(CABLOG_ERR, "%s: An unknown problem occurred");
+ return;
+ }
+
+ if (erf->erfOper >= 0)
+ {
+ if (erf->erfOper < (sizeof(FCI_ERRS)/sizeof(FCI_ERRS[0])))
+ cabLog(CABLOG_ERR, "%s: %s", msg, FCI_ERRS[erf->erfOper]);
+ else
+ cabLog(CABLOG_ERR, "%s: Unknown error", msg);
+ }
}
void cabLogCCAB(PCCAB cc)
{
- cabLog(CABLOG_MSG,
- "cb %ld\n"
- "cbFolderThresh %ld\n"
- "cbReserveCFHeader %d\n"
- "cbReserveCFFolder %d\n"
- "cbReserveCFData %d\n"
- "iCab %d\n"
- "iDisk %d\n"
- "setID %d\n"
- "szDisk %s\n"
- "szCab %s\n"
- "szCabPath %s\n",
- cc->cb, cc->cbFolderThresh, cc->cbReserveCFHeader,
- cc->cbReserveCFFolder, cc->cbReserveCFData, cc->iCab,
- cc->iDisk, cc->setID, cc->szDisk, cc->szCab, cc->szCabPath);
+ cabLog(CABLOG_MSG,
+ "cb %ld\n"
+ "cbFolderThresh %ld\n"
+ "cbReserveCFHeader %d\n"
+ "cbReserveCFFolder %d\n"
+ "cbReserveCFData %d\n"
+ "iCab %d\n"
+ "iDisk %d\n"
+ "setID %d\n"
+ "szDisk %s\n"
+ "szCab %s\n"
+ "szCabPath %s\n",
+ cc->cb, cc->cbFolderThresh, cc->cbReserveCFHeader,
+ cc->cbReserveCFFolder, cc->cbReserveCFData, cc->iCab,
+ cc->iDisk, cc->setID, cc->szDisk, cc->szCab, cc->szCabPath);
}
+/***********************************************************************
+ * Define FCI callbacks
+ **********************************************************************/
FNFCIALLOC (fnMemAlloc) /*(ULONG cb)*/
{
- return malloc(cb);
+ return malloc(cb);
}
FNFCIFREE (fnMemFree) /*(void HUGE *memory)*/
{
- free(memory);
+ free(memory);
}
FNFCIOPEN (fnOpen) /*(char *pszFile, int oflag, int pmode, int *err, void *pv)*/
{
- FILE * f = NULL;
- char * mode = "r+";
- printf("DEBUG: fnOpen file %s\n", pszFile);
- if (oflag & _O_WRONLY) mode = "w";
- else if (oflag & _O_RDWR) mode = "r+";
- else if (oflag & _O_RDONLY) mode = "r";
-
- if (oflag & _O_CREAT && oflag & _O_RDWR) mode = "w+";
-
- f = fopen(pszFile, mode);
- if (f == NULL)
- {
- cabLog(CABLOG_ERR, "Could not get handle to file %s", pszFile);
- *err = -1;
- }
-
- return (INT_PTR) f;
+ FILE * f = NULL;
+ char * mode = "r+";
+ printf("DEBUG: fnOpen file %s\n", pszFile);
+ if (oflag & _O_WRONLY) mode = "w";
+ else if (oflag & _O_RDWR) mode = "r+";
+ else if (oflag & _O_RDONLY) mode = "r";
+
+ if (oflag & _O_CREAT && oflag & _O_RDWR) mode = "w+";
+
+ f = fopen(pszFile, mode);
+ if (f == NULL)
+ {
+ cabLog(CABLOG_ERR, "Could not get handle to file %s", pszFile);
+ *err = -1;
+ }
+
+ return (INT_PTR) f;
}
FNFCIREAD (fnRead) /*(INT_PTR hf, void FAR *memory, UINT cb, int FAR *err, void FAR *pv)*/
{
- FILE * f = (FILE *)hf;
- size_t r = fread(memory, 1, cb, f);
- printf("DEBUG: fnRead\n");
- if (r < cb)
- {
- if (feof(f))
- {
- cabLog(CABLOG_WRN, "Reached EOF while reading file (%d chars remain of %d requested)", r, cb);
- return r;
- }
- else if (ferror(f))
+ FILE * f = (FILE *)hf;
+ size_t r = fread(memory, 1, cb, f);
+ printf("DEBUG: fnRead\n");
+ if (r < cb)
{
- cabLog(CABLOG_ERR, "Error while reading file");
+ if (feof(f))
+ {
+ cabLog(CABLOG_WRN, "Reached EOF while reading file (%d chars remain of %d requested)", r, cb);
+ return r;
+ }
+ else if (ferror(f))
+ {
+ cabLog(CABLOG_ERR, "Error while reading file");
+ }
+ *err = -1;
+ return -1;
}
- *err = -1;
- return -1;
- }
- return r;
+ return r;
}
FNFCIWRITE (fnWrite) /*(INT_PTR hf, void FAR *memory, UINT cb, int FAR *err, void FAR *pv)*/
{
- unsigned int c;
- printf("DEBUG: fnWrite\n");
- if ( !(hf && (c = fwrite(memory, 1, sizeof(memory), (FILE *)hf))) )
- {
- if(c < cb)
+ unsigned int c;
+ printf("DEBUG: fnWrite\n");
+ if ( !(hf && (c = fwrite(memory, 1, sizeof(memory), (FILE *)hf))) )
{
- *err = -1;
- return -1;
+ if(c < cb)
+ {
+ *err = -1;
+ return -1;
+ }
}
- }
- return cb;
+ return cb;
}
FNFCICLOSE (fnClose) /*(INT_PTR hf, int FAR *err, void FAR *pv)*/
{
- printf("DEBUG: fnClose\n");
- if ( !(hf && fclose((FILE *)hf) != EOF) )
- {
- *err = -1;
- return -1;
- }
- return 0;
+ printf("DEBUG: fnClose\n");
+ if ( !(hf && fclose((FILE *)hf) != EOF) )
+ {
+ *err = -1;
+ return -1;
+ }
+ return 0;
}
FNFCISEEK (fnSeek) /*(INT_PTR hf, long dist, int seektype, int FAR *err, void FAR *pv)*/
{
- printf("DEBUG: fnSeek\n");
- if (fseek((FILE *)hf, dist, seektype) != 0)
- {
- *err = -1;
- return -1;
- }
- return 0;
+ printf("DEBUG: fnSeek\n");
+ if (fseek((FILE *)hf, dist, seektype) != 0)
+ {
+ *err = -1;
+ return -1;
+ }
+ return 0;
}
FNFCIDELETE (fnDelete) /*(LPSTR pszFile, int FAR *err, void FAR *pv)*/
{
- printf("DEBUG: fnDelete\n");
- if (remove(pszFile) != 0)
- {
- *err = -1;
- return -1;
- }
- return 0;
+ printf("DEBUG: fnDelete\n");
+ if (remove(pszFile) != 0)
+ {
+ *err = -1;
+ return -1;
+ }
+ return 0;
}
FNFCIGETTEMPFILE (fnGetTempFile) /*(char *pszTempName[bcount(cbTempName)], int cbTempName[range(>=, MAX_PATH)], void FAR *pv)*/
{
- BOOL success = FALSE;
- CHAR tempPath[L_tmpnam];
- char * r;
- printf("DEBUG: fnGetTempFile\n");
- r = tmpnam(tempPath);
- if (r != NULL)
- {
- success = TRUE;
- strcpy(pszTempName, tempPath);
- cbTempName = strlen(pszTempName);
- }
- return success;
+ BOOL success = FALSE;
+ CHAR tempPath[L_tmpnam];
+ char * r;
+ printf("DEBUG: fnGetTempFile\n");
+ r = tmpnam(tempPath);
+ if (r != NULL)
+ {
+ success = TRUE;
+ strcpy(pszTempName, tempPath);
+ cbTempName = strlen(pszTempName);
+ }
+ return success;
}
FNFCIFILEPLACED (fnFilePlaced) /*(PCCAB *pccab, LPSTR pszFile, long cbFile, BOOL fContinuation, void FAR *pv)*/
{
- printf("DEBUG: fnFilePlaced\n");
- if (fContinuation == FALSE)
- cabLog(CABLOG_MSG, "%s (%d b) has been added to %s", pszFile, cbFile, pccab->szCab);
+ printf("DEBUG: fnFilePlaced\n");
+ if (fContinuation == FALSE)
+ cabLog(CABLOG_MSG, "%s (%d b) has been added to %s", pszFile, cbFile, pccab->szCab);
- return 0;
+ return 0;
}
-FNFCIGETNEXTCABINET(fnGetNextCab)/*(PCCAB pccab, ULONG cbPrevCab, void FAR *pv)*/
+FNFCIGETNEXTCABINET(fnGetNextCab) /*(PCCAB pccab, ULONG cbPrevCab, void FAR *pv)*/
{
- printf("DEBUG: fnGetNextCab\n");
- return TRUE;
+ printf("DEBUG: fnGetNextCab\n");
+ return TRUE;
}
-FNFCISTATUS(fnStatus)/*(UINT typeStatus, ULONG cb1, ULONG cb2, void FAR *pv)*/
+FNFCISTATUS(fnStatus) /*(UINT typeStatus, ULONG cb1, ULONG cb2, void FAR *pv)*/
{
- switch (typeStatus)
- {
- case statusFile:
- printf("\rCompressing source file (%d bytes compressed from %d)", cb1, cb2);
- break;
- case statusFolder:
- printf("\rCopying data into cabinet (%d of %d)", cb1, cb2);
- break;
- case statusCabinet:
- printf("\rWriting cabinet file (%d of approx. %d bytes)", cb1, cb2);
- return cb2;
- break;
- }
-
- return 0;
+ switch (typeStatus)
+ {
+ case statusFile:
+ printf("\rCompressing source file (%d bytes compressed from %d)", cb1, cb2);
+ break;
+ case statusFolder:
+ printf("\rCopying data into cabinet (%d of %d)", cb1, cb2);
+ break;
+ case statusCabinet:
+ printf("\rWriting cabinet file (%d of approx. %d bytes)", cb1, cb2);
+ return cb2;
+ break;
+ }
+
+ return 0;
}
-FNFCIGETOPENINFO(fnGetOpenInfo)/*(LPSTR pszName, USHORT *pdate, USHORT *ptime, USHORT *pattribs, int FAR *err, void FAR *pv)*/
+FNFCIGETOPENINFO(fnGetOpenInfo) /*(LPSTR pszName, USHORT *pdate, USHORT *ptime, USHORT *pattribs, int FAR *err, void FAR *pv)*/
{
- /* pdate: dddddmmmmyyyyyyy - d [1-31] m [1-12] y offset from 1980 */
- /* ptime: sssssmmmmhhhhhhh = s [second/2] m [0-59] h [0-23] */
- struct stat s;
- struct tm * time;
- FILE * f = NULL;
- if (stat(pszName, &s) != -1)
- {
- time = gmtime(&s.st_mtime);
- *pdate = 0;
- *ptime = 0;
-
- /* Note: tm_year is years since 1900 */
- *pdate = (time->tm_mday << 11) | ((time->tm_mon+1) << 7) | (time->tm_year-80);
- *ptime = ((time->tm_sec / 2) << 11) | (time->tm_min << 6) | (time->tm_hour);
- f = (FILE *) fnOpen(pszName, _O_RDONLY, 0, err, pv);
- }
-
- if (!f)
- {
- cabLog(CABLOG_ERR, "Could not access file information: %s", pszName);
- return -1;
- }
- return (INT_PTR) f;
+ /* pdate: dddddmmmmyyyyyyy - d [1-31] m [1-12] y offset from 1980 */
+ /* ptime: sssssmmmmhhhhhhh = s [second/2] m [0-59] h [0-23] */
+ struct stat s;
+ struct tm * time;
+ FILE * f = NULL;
+ if (stat(pszName, &s) != -1)
+ {
+ time = gmtime(&s.st_mtime);
+ *pdate = 0;
+ *ptime = 0;
+
+ /* Note: tm_year is years since 1900 */
+ *pdate = (time->tm_mday << 11) | ((time->tm_mon+1) << 7) | (time->tm_year-80);
+ *ptime = ((time->tm_sec / 2) << 11) | (time->tm_min << 6) | (time->tm_hour);
+ f = (FILE *) fnOpen(pszName, _O_RDONLY, 0, err, pv);
+ }
+
+ if (!f)
+ {
+ cabLog(CABLOG_ERR, "Could not access file information: %s", pszName);
+ return -1;
+ }
+ return (INT_PTR) f;
}
/*
-MAKECAB [/V[n]] [/D var=value ...] [/L dir] source [destination]
-MAKECAB [/V[n]] [/D var=value ...] /F directive_file [...]
-source - File to compress.
-destination - File name to give compressed file. If omitted, the
-last character of the source file name is replaced
-with an underscore (_) and used as the destination.
-/F directives - A file with MakeCAB directives (may be repeated).
-/D var=value - Defines variable with specified value.
-/L dir - Location to place destination (default is current directory).
-/V[n] - Verbosity level (1..3)
+ MAKECAB [/V[n]] [/D var=value ...] [/L dir] source [destination]
+ MAKECAB [/V[n]] [/D var=value ...] /F directive_file [...]
+ source - File to compress.
+ destination - File name to give compressed file. If omitted, the
+ last character of the source file name is replaced
+ with an underscore (_) and used as the destination.
+ /F directives - A file with MakeCAB directives (may be repeated).
+ /D var=value - Defines variable with specified value.
+ /L dir - Location to place destination (default is current directory).
+ /V[n] - Verbosity level (1..3)
*/
void usage(void)
{
- printf(
- "Usage: makecab [/V[n]] /F directive_file\n"
- "\nOptions:\n"
- "/F directives - A file with MakeCAB directives.\n"
- "/V[n] - Verbosity level (1..3)\n");
+ printf(
+ "Usage: makecab [/V[n]] /F directive_file\n"
+ "\nOptions:\n"
+ "/F directives - A file with MakeCAB directives.\n"
+ "/V[n] - Verbosity level (1..3)\n");
}
int main(int argc, char *argv[])
{
- int v = 0;
- char * ddfFile = NULL;
- CCAB ddfVars;
- DDFSRCFILE *srcList = NULL;
- DDFSRCFILE *srcListCurr = NULL;
- HFCI fci = NULL;
- ERF erf;
-
- while (argv[1] && (argv[1][0] == '-' || argv[1][0] == '/'))
- {
- switch(tolower(argv[1][1]))
+ int v = 0;
+ char * ddfFile = NULL;
+ CCAB ddfVars;
+ DDFSRCFILE *srcList = NULL;
+ DDFSRCFILE *srcListCurr = NULL;
+ HFCI fci = NULL;
+ ERF erf;
+
+ while (argv[1] && (argv[1][0] == '-' || argv[1][0] == '/'))
{
- case 'f': /* Directive file specified */
- argv++; argc--;
- ddfFile = argv[1];
- break;
- case 'v': /* Verbosity [0-3] */
- switch(argv[1][2])
- {
- case '0': v = 0; break;
- case '1': v = 1; break;
- case '2': v = 2; break;
- case '3': v = 3; break;
- }
- break;
- case '?':
- usage();
- return 0;
+ switch(tolower(argv[1][1]))
+ {
+ case 'f': /* Directive file specified */
+ argv++; argc--;
+ ddfFile = argv[1];
+ break;
+ case 'v': /* Verbosity [0-3] */
+ switch(argv[1][2])
+ {
+ case '0': v = 0; break;
+ case '1': v = 1; break;
+ case '2': v = 2; break;
+ case '3': v = 3; break;
+ }
+ break;
+ case '?':
+ usage();
+ return 0;
+ }
+ argv++; argc--;
}
- argv++; argc--;
- }
- CabVerb = v;
-
- srcList = srcListCurr;
- if (ddfFile != NULL)
- {
- cabLog(CABLOG_MSG, "=== Parsing directive file \"%s\"===", ddfFile);
- switch(ParseDdf(ddfFile, &ddfVars, &srcListCurr, v))
+ CabVerb = v;
+
+ srcList = srcListCurr;
+ if (ddfFile != NULL)
{
- case DDFERR_UNREAD: cabLog(CABLOG_ERR, "Could not open directive file."); break;
+ cabLog(CABLOG_MSG, "=== Parsing directive file \"%s\"===", ddfFile);
+ switch(ParseDdf(ddfFile, &ddfVars, &srcListCurr, v))
+ {
+ case DDFERR_UNREAD: cabLog(CABLOG_ERR, "Could not open directive file."); break;
+ }
+ getcwd(ddfVars.szCabPath, MAX_PATH-1);
+ strcat(ddfVars.szCabPath, "/");
}
- getcwd(ddfVars.szCabPath, MAX_PATH-1);
- strcat(ddfVars.szCabPath, "/");
- }
- if (srcListCurr != NULL)
- {
- cabLogCCAB(&ddfVars);
- fci = FCICreate(&erf, fnFilePlaced, fnMemAlloc, fnMemFree, fnOpen, fnRead,
- fnWrite, fnClose, fnSeek, fnDelete, fnGetTempFile, &ddfVars, NULL);
-
- if (fci != NULL)
+ if (srcListCurr != NULL)
{
- cabLog(CABLOG_MSG, "=== Adding files to cabinet ===");
- for (;srcListCurr != NULL; srcListCurr = srcListCurr->next)
- {
- cabLog(CABLOG_MSG, "Adding file: %s%s (%s)", ddfVars.szCabPath, srcListCurr->fileName, srcListCurr->cabName);
- if (!FCIAddFile(fci, srcListCurr->fileName, srcListCurr->cabName, srcListCurr->extract, fnGetNextCab, fnStatus, fnGetOpenInfo, srcListCurr->cmpType))
- cabLogErr(&erf, "A problem occurred while adding a file");
- }
-
- cabLog(CABLOG_MSG, "=== Flushing the cabinet ===");
- if (!FCIFlushCabinet(fci, FALSE, fnGetNextCab, fnStatus))
- cabLogErr(&erf, "A problem occurred while flushing the cabinet");
- FCIDestroy(fci);
+ cabLogCCAB(&ddfVars);
+ fci = FCICreate(&erf, fnFilePlaced, fnMemAlloc, fnMemFree, fnOpen, fnRead,
+ fnWrite, fnClose, fnSeek, fnDelete, fnGetTempFile, &ddfVars, NULL);
+
+ if (fci != NULL)
+ {
+ cabLog(CABLOG_MSG, "=== Adding files to cabinet ===");
+ for (;srcListCurr != NULL; srcListCurr = srcListCurr->next)
+ {
+ cabLog(CABLOG_MSG, "Adding file: %s%s (%s)", ddfVars.szCabPath, srcListCurr->fileName, srcListCurr->cabName);
+ if (!FCIAddFile(fci, srcListCurr->fileName, srcListCurr->cabName, srcListCurr->extract, fnGetNextCab, fnStatus, fnGetOpenInfo, srcListCurr->cmpType))
+ cabLogErr(&erf, "A problem occurred while adding a file");
+ }
+
+ cabLog(CABLOG_MSG, "=== Flushing the cabinet ===");
+ if (!FCIFlushCabinet(fci, FALSE, fnGetNextCab, fnStatus))
+ cabLogErr(&erf, "A problem occurred while flushing the cabinet");
+ FCIDestroy(fci);
+ }
+ else
+ {
+ cabLogErr(&erf, "Could not get FCI context");
+ }
}
- else
+
+ cabLog(CABLOG_MSG, "=== Cleaning up resources ===");
+ /* Free list of cab source files */
+ for (srcListCurr = srcList; srcListCurr != NULL; )
{
- cabLogErr(&erf, "Could not get FCI context");
+ struct DDFSRCFILE *const next = srcListCurr->next;
+ free(srcListCurr);
+ srcListCurr = next;
}
- }
-
- cabLog(CABLOG_MSG, "=== Cleaning up resources ===");
- /* Free list of cab source files */
- for (srcListCurr = srcList; srcListCurr != NULL; )
- {
- struct DDFSRCFILE *const next = srcListCurr->next;
- free(srcListCurr);
- srcListCurr = next;
- }
- return 0;
+ return 0;
}
diff --git a/setup_native/source/win32/wintools/makecab/parseddf.c b/setup_native/source/win32/wintools/makecab/parseddf.c
index 6c1aa29f0c69..4d4a0c39cbd4 100644
--- a/setup_native/source/win32/wintools/makecab/parseddf.c
+++ b/setup_native/source/win32/wintools/makecab/parseddf.c
@@ -15,99 +15,99 @@ static unsigned int DdfVerb = 0;
/* Trim leading whitespace from a null terminated string */
void ltrim(char * str)
{
- unsigned int i = 0;
- while (isspace(str[i]) && str[i] != '\0') i++;
- if (i > 0) memmove(str, str+i, strlen(str)+1-i);
+ unsigned int i = 0;
+ while (isspace(str[i]) && str[i] != '\0') i++;
+ if (i > 0) memmove(str, str+i, strlen(str)+1-i);
}
/* Trim trailing whitespace from a null terminated string */
void rtrim(char * str)
{
- unsigned int i = strlen(str) - 1;
- while (isspace(str[i]) && i > 0) i--;
- if (i) i++;
- str[i] = '\0';
+ unsigned int i = strlen(str) - 1;
+ while (isspace(str[i]) && i > 0) i--;
+ if (i) i++;
+ str[i] = '\0';
}
/* Trim trailing and leading whitespace from a null terminated string */
void trim(char * str)
{
- ltrim(str);
- rtrim(str);
+ ltrim(str);
+ rtrim(str);
}
void ddfLogProgress(DDFLOGLEVEL lvl, char * desc, unsigned int progress)
{
- if (DdfVerb < lvl) return;
- if (progress == 0) printf(" %s: %3d%%", desc, progress);
- else if (progress > 0 && progress < 100) printf("\r %s: %3d%%", desc, progress);
- else if (progress == 100) printf("\r %s: 100%%\n", desc);
- fflush(stdout);
+ if (DdfVerb < lvl) return;
+ if (progress == 0) printf(" %s: %3d%%", desc, progress);
+ else if (progress > 0 && progress < 100) printf("\r %s: %3d%%", desc, progress);
+ else if (progress == 100) printf("\r %s: 100%%\n", desc);
+ fflush(stdout);
}
void ddfLog(DDFLOGLEVEL lvl, char * msg, ...)
{
- va_list args;
- if (DdfVerb < lvl) return;
-
- switch (lvl)
- {
- case DDFLOG_WRN: printf("[Warning] "); break;
- case DDFLOG_ERR: printf("[Error] "); break;
- }
-
- va_start(args, msg);
- vprintf(msg, args);
- va_end(args);
- printf("\n");
+ va_list args;
+ if (DdfVerb < lvl) return;
+
+ switch (lvl)
+ {
+ case DDFLOG_WRN: printf("[Warning] "); break;
+ case DDFLOG_ERR: printf("[Error] "); break;
+ }
+
+ va_start(args, msg);
+ vprintf(msg, args);
+ va_end(args);
+ printf("\n");
}
void ddfPrintState(DDFLOGLEVEL lvl, PCCAB ccab, DDFSRCFILE * srcList)
{
- static const unsigned int SIZE = 2048;
- char msg[SIZE];
- char srcLine[DDF_MAX_CHARS];
- unsigned int len;
- DDFSRCFILE * srcListCurr;
-
- if (ccab)
- {
- len = sprintf(msg,
- "=== Directive file state table ===\n"
- "CabinetName %s\n"
- "ReservePerCabinetSize %d\n"
- "MaxDiskSize %d\n"
- "Compress %d\n"
- "CompressionMemory %d\n"
- "Cabinet %d\n"
- "DiskDirectoryTemplate %s",
- ccab->szCab,
- ccab->cbReserveCFHeader,
- ccab->iDisk,
- 1,
- CompMemory,
- 1,
- ccab->szCabPath);
- }
- else
- {
- msg[0] = '\0';
- }
- if (!srcList) printf("DEBUG: No list!\n");
-
- for (srcListCurr = srcList;
- srcListCurr != NULL && (len = strlen(msg)) < SIZE;
- srcListCurr = srcListCurr->next)
- {
- sprintf(srcLine, "\nsrc: %s (%s) extract? %d MSZIP? %d LZX? %d",
- srcListCurr->fileName, srcListCurr->cabName,
- srcListCurr->extract, (srcListCurr->cmpType == tcompTYPE_MSZIP),
- (srcListCurr->cmpType != tcompTYPE_MSZIP));
- strncat(msg, srcLine, SIZE-strlen(srcLine)-1);
- }
- if (msg[SIZE-1] != '\0') msg[SIZE-1] = '\0';
-
- ddfLog(lvl, msg);
+ static const unsigned int SIZE = 2048;
+ char msg[SIZE];
+ char srcLine[DDF_MAX_CHARS];
+ unsigned int len;
+ DDFSRCFILE * srcListCurr;
+
+ if (ccab)
+ {
+ len = sprintf(msg,
+ "=== Directive file state table ===\n"
+ "CabinetName %s\n"
+ "ReservePerCabinetSize %d\n"
+ "MaxDiskSize %d\n"
+ "Compress %d\n"
+ "CompressionMemory %d\n"
+ "Cabinet %d\n"
+ "DiskDirectoryTemplate %s",
+ ccab->szCab,
+ ccab->cbReserveCFHeader,
+ ccab->iDisk,
+ 1,
+ CompMemory,
+ 1,
+ ccab->szCabPath);
+ }
+ else
+ {
+ msg[0] = '\0';
+ }
+ if (!srcList) printf("DEBUG: No list!\n");
+
+ for (srcListCurr = srcList;
+ srcListCurr != NULL && (len = strlen(msg)) < SIZE;
+ srcListCurr = srcListCurr->next)
+ {
+ sprintf(srcLine, "\nsrc: %s (%s) extract? %d MSZIP? %d LZX? %d",
+ srcListCurr->fileName, srcListCurr->cabName,
+ srcListCurr->extract, (srcListCurr->cmpType == tcompTYPE_MSZIP),
+ (srcListCurr->cmpType != tcompTYPE_MSZIP));
+ strncat(msg, srcLine, SIZE-strlen(srcLine)-1);
+ }
+ if (msg[SIZE-1] != '\0') msg[SIZE-1] = '\0';
+
+ ddfLog(lvl, msg);
}
/* Moves the next DDF token from the beginning of *line into *token.
@@ -126,249 +126,249 @@ void ddfPrintState(DDFLOGLEVEL lvl, PCCAB ccab, DDFSRCFILE * srcList)
*/
DDFERR nextToken(char * token, char * line)
{
- unsigned int i = 0;
- unsigned int r = DDF_OK;
- unsigned int offset = 0;
- int c;
- BOOL esc = FALSE;
-
- ltrim(line);
- if (line[0] == '\0' || line[0] == ';') return DDFERR_NO_MORE_TOKENS;
- if (line[0] == '=')
- {
- memmove(line, line+1, strlen(line));
- trim(line);
- }
-
- for (i = 0; i < DDF_MAX_CHARS-1 && i < strlen(line); i++)
- {
- /* Chomp delimiting tokens unless they're escaped */
- c = line[i];
- if (c == '\"')
+ unsigned int i = 0;
+ unsigned int r = DDF_OK;
+ unsigned int offset = 0;
+ int c;
+ BOOL esc = FALSE;
+
+ ltrim(line);
+ if (line[0] == '\0' || line[0] == ';') return DDFERR_NO_MORE_TOKENS;
+ if (line[0] == '=')
{
- esc = !esc;
- offset++;
- /* Compress "" to ", otherwise don't add quote to token*/
- if (i > 0 && line[i-1] != '\"') continue;
- }
- else if (c == '\r' || c == '\n')
- {
- r = DDFERR_INVALID_ENDL;
- break;
- }
- else if(!esc)
- {
- if (isspace(c) || c == '=') { r = DDF_OK; break; }
- else if (c == ';') { r = DDFERR_NO_MORE_TOKENS; break; }
+ memmove(line, line+1, strlen(line));
+ trim(line);
}
- token[i - offset] = c;
+ for (i = 0; i < DDF_MAX_CHARS-1 && i < strlen(line); i++)
+ {
+ /* Chomp delimiting tokens unless they're escaped */
+ c = line[i];
+ if (c == '\"')
+ {
+ esc = !esc;
+ offset++;
+ /* Compress "" to ", otherwise don't add quote to token*/
+ if (i > 0 && line[i-1] != '\"') continue;
+ }
+ else if (c == '\r' || c == '\n')
+ {
+ r = DDFERR_INVALID_ENDL;
+ break;
+ }
+ else if(!esc)
+ {
+ if (isspace(c) || c == '=') { r = DDF_OK; break; }
+ else if (c == ';') { r = DDFERR_NO_MORE_TOKENS; break; }
+ }
+
+ token[i - offset] = c;
- }
- token[i - offset] = '\0';
- memmove(line, line+i, strlen(line)+1-i);
- return r;
+ }
+ token[i - offset] = '\0';
+ memmove(line, line+i, strlen(line)+1-i);
+ return r;
}
DDFERR setVar(DDFVAR key, PCCAB ccab, char * value)
{
- int i = 0;
- char * cp = NULL;
-
- ddfLog(DDFLOG_MSG, "Setting variable %s=%s...", VARS[key], value);
-
- switch (key)
- {
- case DDF_CABNAME:
- strncpy(ccab->szCab, value, 255);
- break;
- case DDF_RESERVEPERCAB:
- i = atoi(value);
- if (i < 0) i = 0;
- if (i > DDF_MAX_CABRESERVE) i = DDF_MAX_CABRESERVE;
- if (i % 4 != 0) i -= (i % 4);
- ccab->cbReserveCFHeader = i;
- break;
- case DDF_MAXDISK:
- i = atoi(value);
- ccab->cb = i;
- break;
- case DDF_COMPTYPE:
- if (strcmp(value, "LZX") == 0)
+ int i = 0;
+ char * cp = NULL;
+
+ ddfLog(DDFLOG_MSG, "Setting variable %s=%s...", VARS[key], value);
+
+ switch (key)
{
+ case DDF_CABNAME:
+ strncpy(ccab->szCab, value, 255);
+ break;
+ case DDF_RESERVEPERCAB:
+ i = atoi(value);
+ if (i < 0) i = 0;
+ if (i > DDF_MAX_CABRESERVE) i = DDF_MAX_CABRESERVE;
+ if (i % 4 != 0) i -= (i % 4);
+ ccab->cbReserveCFHeader = i;
+ break;
+ case DDF_MAXDISK:
+ i = atoi(value);
+ ccab->cb = i;
+ break;
+ case DDF_COMPTYPE:
+ if (strcmp(value, "LZX") == 0)
+ {
/* if (CompMemory) CompType = TCOMPfromLZXWindow(CompMemory);
- else CompType = tcompTYPE_LZX;*/
+ else CompType = tcompTYPE_LZX;*/
/*TODO: LZX not yet supported in Wine */
- CompType = tcompTYPE_MSZIP;
- }
- else
- {
- if (strcmp(value, "MSZIP") != 0)
- ddfLog(DDFLOG_WRN, "Invalid compression type \"%s\", reverting to MSZIP.", value);
- CompType = tcompTYPE_MSZIP;
+ CompType = tcompTYPE_MSZIP;
+ }
+ else
+ {
+ if (strcmp(value, "MSZIP") != 0)
+ ddfLog(DDFLOG_WRN, "Invalid compression type \"%s\", reverting to MSZIP.", value);
+ CompType = tcompTYPE_MSZIP;
+ }
+ break;
+ case DDF_COMPRESS:
+ break;
+ case DDF_COMPMEM:
+ i = atoi(value);
+ if (i < 15) i = 15;
+ if (i > 21) i = 21;
+ CompMemory = i;
+ if (CompType == tcompTYPE_LZX) CompType = TCOMPfromLZXWindow(CompMemory);
+ break;
+ case DDF_CABINET:
+ break;
+ case DDF_DISKDIRTEMPLATE:
+ while ((cp = strchr(value, '*')) != '\0') *cp = '1';
+ strncpy(ccab->szCabPath, value, 255);
+ break;
}
- break;
- case DDF_COMPRESS:
- break;
- case DDF_COMPMEM:
- i = atoi(value);
- if (i < 15) i = 15;
- if (i > 21) i = 21;
- CompMemory = i;
- if (CompType == tcompTYPE_LZX) CompType = TCOMPfromLZXWindow(CompMemory);
- break;
- case DDF_CABINET:
- break;
- case DDF_DISKDIRTEMPLATE:
- while ((cp = strchr(value, '*')) != '\0') *cp = '1';
- strncpy(ccab->szCabPath, value, 255);
- break;
- }
-
- return DDF_OK;
+
+ return DDF_OK;
}
DDFERR parseCmd(char * line, PCCAB ccab, char * token)
{
- unsigned int r, i;
- char *p;
- for (p = token ; *p; ++p) *p = tolower(*p);
-
- /* Set command checks lower case token representing var name
- against known variables. If found, the next token is used as
- the value to assign */
- if (strcmp(token, ".set") == 0)
- {
- r = nextToken(token, line);
- if (r != DDF_OK) return DDFERR_FUNC_FAILED;
-
+ unsigned int r, i;
+ char *p;
for (p = token ; *p; ++p) *p = tolower(*p);
- if (isdigit(token[strlen(token)-1])) token[strlen(token)-1] = '\0';
- for (i = 0; i < (sizeof(VARS)/sizeof(VARS[0])); i++)
+
+ /* Set command checks lower case token representing var name
+ against known variables. If found, the next token is used as
+ the value to assign */
+ if (strcmp(token, ".set") == 0)
{
- if (strcmp(token, VARS[i]) == 0)
- {
- r = nextToken(token, line);
- if (r != DDF_OK) return DDFERR_FUNC_FAILED;
- setVar(i, ccab, token);
- break;
- }
+ r = nextToken(token, line);
+ if (r != DDF_OK) return DDFERR_FUNC_FAILED;
+
+ for (p = token ; *p; ++p) *p = tolower(*p);
+ if (isdigit(token[strlen(token)-1])) token[strlen(token)-1] = '\0';
+ for (i = 0; i < (sizeof(VARS)/sizeof(VARS[0])); i++)
+ {
+ if (strcmp(token, VARS[i]) == 0)
+ {
+ r = nextToken(token, line);
+ if (r != DDF_OK) return DDFERR_FUNC_FAILED;
+ setVar(i, ccab, token);
+ break;
+ }
+ }
}
- }
- return DDF_OK;
+ return DDF_OK;
}
char * getCabName(char * name)
{
- char * cName;
- if ((cName = strrchr(name, '/')) || (cName = strrchr(name, '\\')))
- cName++;
- else
- cName = name;
- return cName;
+ char * cName;
+ if ((cName = strrchr(name, '/')) || (cName = strrchr(name, '\\')))
+ cName++;
+ else
+ cName = name;
+ return cName;
}
DDFERR parseSrc(char * line, DDFSRCFILE ** srcFileList, char * token)
{
- unsigned int r;
- struct stat s;
- DDFSRCFILE * tmpSrcFile;
-
- /* Check file exists before allocating DDFSRCFILE */
- if (stat(token, &s) == -1 && errno == ENOENT)
- {
- ddfLog(DDFLOG_WRN, "Could not find file \"%s\"", token);
- return DDFERR_SRC_SKIPPED;
- }
-
- tmpSrcFile = (DDFSRCFILE *) malloc(sizeof(DDFSRCFILE));
- if (!tmpSrcFile) return DDFERR_FUNC_FAILED;
- if (!(*srcFileList))
- {
- *srcFileList = tmpSrcFile;
- }
- else
- {
- while ((*srcFileList)->next != NULL) *srcFileList = (*srcFileList)->next;
- (*srcFileList)->next = tmpSrcFile;
- }
-
- strncpy(tmpSrcFile->fileName, token, MAX_PATH);
- /* Get cabinet file name or construct from src path if unspecified */
- r = nextToken(token, line);
- if (r != DDF_OK || token[0] == '/')
- {
- strncpy(tmpSrcFile->cabName, getCabName(tmpSrcFile->fileName), DDF_MAX_CABNAME-1);
- }
- else
- {
- strncpy(tmpSrcFile->cabName, token, DDF_MAX_CABNAME-1);
- }
-
- tmpSrcFile->cabName[DDF_MAX_CABNAME-1] = '\0';
- tmpSrcFile->extract = FALSE;
- tmpSrcFile->cmpType = CompType;
- tmpSrcFile->next = NULL;
-
- return DDF_OK;
-}
-
-DDFERR parseDdfLine(char * line, PCCAB ccab, DDFSRCFILE ** srcList)
-{
- unsigned int r;
- char token[DDF_MAX_CHARS];
+ unsigned int r;
+ struct stat s;
+ DDFSRCFILE * tmpSrcFile;
- if (line[0] == '\0') return DDF_OK;
+ /* Check file exists before allocating DDFSRCFILE */
+ if (stat(token, &s) == -1 && errno == ENOENT)
+ {
+ ddfLog(DDFLOG_WRN, "Could not find file \"%s\"", token);
+ return DDFERR_SRC_SKIPPED;
+ }
- ddfLog(DDFLOG_MSG, "Parsing line \"%s\"", line);
+ tmpSrcFile = (DDFSRCFILE *) malloc(sizeof(DDFSRCFILE));
+ if (!tmpSrcFile) return DDFERR_FUNC_FAILED;
+ if (!(*srcFileList))
+ {
+ *srcFileList = tmpSrcFile;
+ }
+ else
+ {
+ while ((*srcFileList)->next != NULL) *srcFileList = (*srcFileList)->next;
+ (*srcFileList)->next = tmpSrcFile;
+ }
- r = nextToken(token,line);
- if (r == DDF_OK)
- {
- if (token[0] == '.')
+ strncpy(tmpSrcFile->fileName, token, MAX_PATH);
+ /* Get cabinet file name or construct from src path if unspecified */
+ r = nextToken(token, line);
+ if (r != DDF_OK || token[0] == '/')
{
- r = parseCmd(line, ccab, token);
- if (r != DDF_OK) ddfLog(DDFLOG_ERR, "Invalid command line skipped: %s%s", token, line);
+ strncpy(tmpSrcFile->cabName, getCabName(tmpSrcFile->fileName), DDF_MAX_CABNAME-1);
}
else
{
- r = parseSrc(line, srcList, token);
+ strncpy(tmpSrcFile->cabName, token, DDF_MAX_CABNAME-1);
+ }
- if (r == DDFERR_SRC_SKIPPED)
- ddfLog(DDFLOG_ERR, "Source file command \"%s%s\" couldn't be read - skipped", token, line);
- else if (r == DDFERR_FUNC_FAILED)
- ddfLog(DDFLOG_WRN, "Could not parse command correctly, \"%s\" remains", line);
+ tmpSrcFile->cabName[DDF_MAX_CABNAME-1] = '\0';
+ tmpSrcFile->extract = FALSE;
+ tmpSrcFile->cmpType = CompType;
+ tmpSrcFile->next = NULL;
+
+ return DDF_OK;
+}
+
+DDFERR parseDdfLine(char * line, PCCAB ccab, DDFSRCFILE ** srcList)
+{
+ unsigned int r;
+ char token[DDF_MAX_CHARS];
+
+ if (line[0] == '\0') return DDF_OK;
+
+ ddfLog(DDFLOG_MSG, "Parsing line \"%s\"", line);
+
+ r = nextToken(token,line);
+ if (r == DDF_OK)
+ {
+ if (token[0] == '.')
+ {
+ r = parseCmd(line, ccab, token);
+ if (r != DDF_OK) ddfLog(DDFLOG_ERR, "Invalid command line skipped: %s%s", token, line);
+ }
+ else
+ {
+ r = parseSrc(line, srcList, token);
+
+ if (r == DDFERR_SRC_SKIPPED)
+ ddfLog(DDFLOG_ERR, "Source file command \"%s%s\" couldn't be read - skipped", token, line);
+ else if (r == DDFERR_FUNC_FAILED)
+ ddfLog(DDFLOG_WRN, "Could not parse command correctly, \"%s\" remains", line);
+ }
}
- }
- return r;
+ return r;
}
DDFERR ParseDdf(char* ddfFile, PCCAB ccab, DDFSRCFILE ** srcListH, unsigned int v)
{
- char fLine[DDF_MAX_CHARS];
- FILE *ddf = NULL;
- unsigned int i = 0;
- DDFSRCFILE * srcListCurr = NULL;
-
- ddf = fopen(ddfFile, "r");
- if (ddf == NULL) return DDFERR_UNREAD;
-
- DdfVerb = v;
- for (; i < DDF_MAX_LINES && fgets(fLine, sizeof fLine, ddf); i++)
- {
- fLine[strlen(fLine)-1] = '\0';
- parseDdfLine(fLine, ccab, &srcListCurr);
- if (srcListCurr && !(*srcListH))
+ char fLine[DDF_MAX_CHARS];
+ FILE *ddf = NULL;
+ unsigned int i = 0;
+ DDFSRCFILE * srcListCurr = NULL;
+
+ ddf = fopen(ddfFile, "r");
+ if (ddf == NULL) return DDFERR_UNREAD;
+
+ DdfVerb = v;
+ for (; i < DDF_MAX_LINES && fgets(fLine, sizeof fLine, ddf); i++)
{
- *srcListH = srcListCurr;
+ fLine[strlen(fLine)-1] = '\0';
+ parseDdfLine(fLine, ccab, &srcListCurr);
+ if (srcListCurr && !(*srcListH))
+ {
+ *srcListH = srcListCurr;
+ }
}
- }
- ddfPrintState(DDFLOG_MSG, ccab, *srcListH);
- ccab->cbFolderThresh = ccab->cb;
- ccab->iDisk = 0;
+ ddfPrintState(DDFLOG_MSG, ccab, *srcListH);
+ ccab->cbFolderThresh = ccab->cb;
+ ccab->iDisk = 0;
- return DDF_OK;
+ return DDF_OK;
}
diff --git a/setup_native/source/win32/wintools/makecab/parseddf.h b/setup_native/source/win32/wintools/makecab/parseddf.h
index 6a46541dc297..6b233dbe5880 100644
--- a/setup_native/source/win32/wintools/makecab/parseddf.h
+++ b/setup_native/source/win32/wintools/makecab/parseddf.h
@@ -20,11 +20,11 @@ typedef enum DDFLOGLEVEL { DDFLOG_ERR = 1, DDFLOG_WRN, DDFLOG_MSG } DDFLOGLEVEL;
typedef struct DDFSRCFILE
{
- char fileName[MAX_PATH];
- char cabName[DDF_MAX_CABNAME];
- BOOL extract;
- TCOMP cmpType;
- struct DDFSRCFILE * next;
+ char fileName[MAX_PATH];
+ char cabName[DDF_MAX_CABNAME];
+ BOOL extract;
+ TCOMP cmpType;
+ struct DDFSRCFILE * next;
} DDFSRCFILE;
unsigned int ParseDdf(char * ddfFile, PCCAB vars, DDFSRCFILE ** srcListH, unsigned int v);
diff --git a/setup_native/source/win32/wintools/msidb/msidb.c b/setup_native/source/win32/wintools/msidb/msidb.c
index c8d9c6f5dbfc..41b4dfde6eff 100644
--- a/setup_native/source/win32/wintools/msidb/msidb.c
+++ b/setup_native/source/win32/wintools/msidb/msidb.c
@@ -82,21 +82,17 @@ static BOOL msidbImportStorages(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR storageName
lstrcatW(storagePath, delim);
lstrcatW(storagePath, storageNames[i]);
- /* WINE_MESSAGE("Importing from %s\n", wine_dbgstr_w(storagePath)); */
-
rec = MsiCreateRecord(2);
MsiRecordSetStringW(rec, 1, storageNames[i]);
r = MsiRecordSetStreamW(rec, 2, storagePath);
if (r != ERROR_SUCCESS)
{
- /* WINE_MESSAGE("Error setting storage %d\n", r); */
return FALSE;
}
r = MsiViewExecute(view, rec);
if (r != ERROR_SUCCESS)
{
- /* WINE_MESSAGE("Unable to update with storage record %d\n", r); */
return FALSE;
}
@@ -133,10 +129,9 @@ static BOOL msidbExportStorage(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR storageName)
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;
}
- /* WINE_MESSAGE("Exporting storage %s using query %s\n", storageNameA, queryBuffer); */
+
if ((dataBuffer = malloc(dataLen)) == NULL) 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[
r = MsiRecordSetStreamW(rec, 2, streamPath);
if (r != ERROR_SUCCESS)
{
- /* WINE_MESSAGE("Error setting stream %d (%s)\n", r, wine_dbgstr_w(streamNames[i])); */
return FALSE;
}
r = MsiViewExecute(view, rec);
if (r != ERROR_SUCCESS)
{
- /* WINE_MESSAGE("Unable to update with stream record %d\n", r); */
return FALSE;
}
@@ -319,7 +312,6 @@ static BOOL msidbImportTables(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR tables[], BOO
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;
}
@@ -336,12 +328,6 @@ static BOOL msidbImportTables(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR tables[], BOO
if (strcmp(fileName, ".") == 0 || strcmp(fileName, "..") == 0) continue;
tableFile = strdupAtoW(CP_ACP, fileName);
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);
}
}
@@ -360,11 +346,6 @@ static BOOL msidbImportTables(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR tables[], BOO
lstrcatW(tableFile, ext);
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);
if (r != ERROR_SUCCESS)
@@ -426,21 +407,11 @@ static BOOL msidbExportTables(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR tables[])
lstrcatW(tableFile, ext);
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);
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);
}
@@ -580,10 +551,5 @@ int wmain(int argc, WCHAR *argv[])
if (!msidbExportStorage(dbfile, wdir, storageName))
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;
}
diff --git a/setup_native/source/win32/wintools/msiinfo/msiinfo.c b/setup_native/source/win32/wintools/msiinfo/msiinfo.c
index 932477fe9e6a..06d76bda18ee 100644
--- a/setup_native/source/win32/wintools/msiinfo/msiinfo.c
+++ b/setup_native/source/win32/wintools/msiinfo/msiinfo.c
@@ -61,186 +61,193 @@ static const char * commandNames[COMMANDS] =
static void parseDate(LPCWSTR value, SYSTEMTIME *time)
{
- LPWSTR field;
- uint len = 4*sizeof(WCHAR);
+ LPWSTR field;
+ uint len = 4*sizeof(WCHAR);
- if (lstrlenW(value) != 19) return;
- field = malloc(len + sizeof(WCHAR));
- if (field == NULL) return;
- memcpy(field, value, len);
- field[4] = L'\0';
- time->wYear = atoiW(field);
+ if (lstrlenW(value) != 19) return;
+ field = malloc(len + sizeof(WCHAR));
+ if (field == NULL) return;
+ memcpy(field, value, len);
+ field[4] = L'\0';
+ time->wYear = atoiW(field);
- len = 2 * sizeof(WCHAR);
- memcpy(field, &(value[5]), len);
- field[2] = '\0';
- time->wMonth = atoiW(field);
+ len = 2 * sizeof(WCHAR);
+ memcpy(field, &(value[5]), len);
+ field[2] = '\0';
+ time->wMonth = atoiW(field);
- memcpy(field, &(value[8]), len);
- time->wDay = atoiW(field);
+ memcpy(field, &(value[8]), len);
+ time->wDay = atoiW(field);
- memcpy(field, &(value[11]), len);
- time->wHour = atoiW(field);
+ memcpy(field, &(value[11]), len);
+ time->wHour = atoiW(field);
- memcpy(field, &(value[14]), len);
- time->wMinute = atoiW(field);
+ memcpy(field, &(value[14]), len);
+ time->wMinute = atoiW(field);
- memcpy(field, &(value[17]), len);
- time->wSecond = atoiW(field);
+ memcpy(field, &(value[17]), len);
+ time->wSecond = atoiW(field);
- free(field);
+ free(field);
}
static BOOL msiinfoDisplayProperties(LPWSTR dbfile)
{
- MSIHANDLE dbhandle, infohandle;
- uint i, r, dataType;
- INT iVal;
- FILETIME ftVal;
- SYSTEMTIME sysTime;
- LPWSTR szVal = NULL;
- DWORD size;
- r = MsiOpenDatabaseW(dbfile, (LPWSTR) MSIDBOPEN_READONLY, &dbhandle);
- 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)
+ MSIHANDLE dbhandle, infohandle;
+ uint i, r, dataType;
+ INT iVal;
+ FILETIME ftVal;
+ SYSTEMTIME sysTime;
+ LPWSTR szVal = NULL;
+ DWORD size;
+ r = MsiOpenDatabaseW(dbfile, (LPWSTR) MSIDBOPEN_READONLY, &dbhandle);
+ if (r != ERROR_SUCCESS)
{
- if (szVal!=NULL) wprintf(L"%ls (%d)\n", szVal, lstrlenW(szVal));
- else wprintf(L"\n");
+ return FALSE;
}
- else if (dataType == VT_FILETIME)
+
+ r = MsiGetSummaryInformationW(dbhandle, 0, 0, &infohandle);
+ if (r != ERROR_SUCCESS)
{
- FileTimeToSystemTime(&ftVal, &sysTime);
- wprintf(L"%04d/%02d/%02d %02d:%02d:%02d\n", sysTime.wYear, sysTime.wMonth,
- sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
+ return FALSE;
}
- 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);
- return TRUE;
+ MsiCloseHandle(infohandle);
+ return TRUE;
}
static BOOL msiinfoUpdateProperty(MSIHANDLE infoHandle, uint property, uint dataType, LPCWSTR value)
{
- uint r;
- int iVal = 0;
- FILETIME ftVal;
- SYSTEMTIME sysTime = {0};
- LPCWSTR szVal = NULL;
-
- if (dataType == VT_LPSTR) szVal = value;
- else if (dataType == VT_FILETIME)
- {
- parseDate(value, &sysTime);
- SystemTimeToFileTime(&sysTime, &ftVal);
- }
- else
- iVal = atoiW(value);
-
- r = MsiSummaryInfoSetPropertyW(infoHandle, property, dataType, iVal, &ftVal, szVal);
- 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);
- return FALSE;
- }
-
- return TRUE;
+ uint r;
+ int iVal = 0;
+ FILETIME ftVal;
+ SYSTEMTIME sysTime = {0};
+ LPCWSTR szVal = NULL;
+
+ if (dataType == VT_LPSTR) szVal = value;
+ else if (dataType == VT_FILETIME)
+ {
+ parseDate(value, &sysTime);
+ SystemTimeToFileTime(&sysTime, &ftVal);
+ }
+ else
+ iVal = atoiW(value);
+
+ r = MsiSummaryInfoSetPropertyW(infoHandle, property, dataType, iVal, &ftVal, szVal);
+ 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);
+ return FALSE;
+ }
+
+ return TRUE;
}
static void usage(void)
{
- WINE_MESSAGE(
- "Usage: msiinfo {database} [[-b]-d] {options} {data}\n"
- "\nOptions:\n"
- " -c <cp> Specify codepage\n"
- " -t <title> Specify title\n"
- " -j <subject> Specify subject\n"
- " -a <author> Specify author\n"
- " -k <keywords> Specify keywords\n"
- " -o <comment> Specify comments\n"
- " -p <template> Specify template\n"
- " -l <author> Specify last author\n"
- " -v <revno> Specify revision number\n"
- " -s <date> Specify last printed date\n"
- " -r <date> Specify creation date\n"
- " -q <date> Specify date of last save\n"
- " -g <pages> Specify page count\n"
- " -w <words> Specify word count\n"
- " -h <chars> Specify character count\n"
- " -n <appname> Specify application which created the database\n"
- " -u <security> Specify security (0: none, 2: read only (rec.) 3: read only (enforced)\n");
+ wprintf(
+ L"Usage: msiinfo {database} [[-b]-d] {options} {data}\n"
+ L"\nOptions:\n"
+ L" -c <cp> Specify codepage\n"
+ L" -t <title> Specify title\n"
+ L" -j <subject> Specify subject\n"
+ L" -a <author> Specify author\n"
+ L" -k <keywords> Specify keywords\n"
+ L" -o <comment> Specify comments\n"
+ L" -p <template> Specify template\n"
+ L" -l <author> Specify last author\n"
+ L" -v <revno> Specify revision number\n"
+ L" -s <date> Specify last printed date\n"
+ L" -r <date> Specify creation date\n"
+ L" -q <date> Specify date of last save\n"
+ L" -g <pages> Specify page count\n"
+ L" -w <words> Specify word count\n"
+ L" -h <chars> Specify character count\n"
+ L" -n <appname> Specify application which created the database\n"
+ L" -u <security> Specify security (0: none, 2: read only (rec.) 3: read only (enforced)\n");
}
int wmain(int argc, WCHAR *argv[])
{
- WCHAR *dbfile = NULL;
- uint i = 0;
- MSIHANDLE dbhandle, infohandle;
- uint r;
- LPWSTR value = 0;
-
- if (argc > 1)
- {
- 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;
+ WCHAR *dbfile = NULL;
+ uint i = 0;
+ MSIHANDLE dbhandle, infohandle;
+ uint r;
+ LPWSTR value = 0;
+ static const WCHAR h1[] = {'/', '?', 0};
+ static const WCHAR h2[] = {'-', '?', 0};
+
+ if (argc > 1)
+ {
+ dbfile = argv[1];
+ argv++; argc--;
+ }
- while (argv[1] && argv[1][0] == '-')
- {
- switch (argv[1][1])
+ if (strcmpW(dbfile, h1) == 0 || strcmpW(dbfile, h2) == 0)
{
- case '?':
- case 'h':
- usage();
- return 0;
- default:
- for (i = 0; i < COMMANDS; i++)
- {
- if (commandMap[i][0] == argv[1][1])
+ usage();
+ return 0;
+ }
+ else if (argc == 1)
{
- argv++; argc--;
- value = argv[1];
- msiinfoUpdateProperty(infohandle, commandMap[i][1], commandMap[i][2], value);
- break;
+ msiinfoDisplayProperties(dbfile);
+ return 0;
}
- }
- 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);
- MsiCloseHandle(dbhandle);
- msiinfoDisplayProperties(dbfile);
- return 0;
+
+ MsiSummaryInfoPersist(infohandle);
+ MsiDatabaseCommit(dbhandle);
+ MsiCloseHandle(dbhandle);
+ msiinfoDisplayProperties(dbfile);
+ return 0;
}