
Now I can get an idea of what sequence of calls WiX actually expects to use to build an MSI.
123 lines
3.1 KiB
C
123 lines
3.1 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <stdarg.h>
|
|
#include <string.h>
|
|
#include <uchar.h>
|
|
#include <err.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
static char *ascii(const char16_t *wstr, bool translate_slashes)
|
|
{
|
|
size_t len = 0;
|
|
for (const char16_t *wp = wstr; *wp; wp++)
|
|
len++;
|
|
char *ret = malloc(len + 1);
|
|
char *p = ret;
|
|
for (const char16_t *wp = wstr; *wp; wp++)
|
|
*p++ = (*wp == '\\' && translate_slashes ? '/' :
|
|
*wp < 0x80 ? *wp :
|
|
'?');
|
|
*p = '\0';
|
|
return ret;
|
|
}
|
|
|
|
static void c16cpy(char16_t *out, uint32_t *outsize, char *s)
|
|
{
|
|
uint32_t retlen = 0;
|
|
while (retlen < *outsize) {
|
|
char16_t c = (out[retlen] = (unsigned char)*s++);
|
|
if (!c)
|
|
break;
|
|
retlen++;
|
|
}
|
|
*outsize = retlen;
|
|
}
|
|
|
|
uint32_t MsiGetFileVersionW(const char16_t *filename,
|
|
char16_t *version, uint32_t *version_size,
|
|
char16_t *language, uint32_t *language_size)
|
|
{
|
|
warnx("FIXME: MsiGetFileVersion(%s)", ascii(filename, true));
|
|
if (version) {
|
|
c16cpy(version, version_size, "0.1.2.3");
|
|
}
|
|
if (language) {
|
|
c16cpy(language, language_size, "2057");
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
uint32_t MsiOpenDatabaseW(const char16_t *filename,
|
|
const char16_t *persist,
|
|
void **handle)
|
|
{
|
|
char *file = ascii(filename, true);
|
|
warnx("FIXME: MsiOpenDatabaseW(%s,%p)", file, persist);
|
|
close(open(file, O_WRONLY | O_CREAT, 0666));
|
|
*handle = (void *)1;
|
|
return 0;
|
|
}
|
|
|
|
uint32_t MsiCloseHandle(void *handle)
|
|
{
|
|
warnx("FIXME: MsiCloseHandle(%p)", handle);
|
|
return 0;
|
|
}
|
|
|
|
uint32_t MsiDatabaseImportW(void *handle, const char16_t *folder,
|
|
const char16_t *file)
|
|
{
|
|
warnx("FIXME: MsiDatabaseImport(%p,%s,%s)", handle, ascii(folder, true),
|
|
ascii(file, true));
|
|
return 0;
|
|
}
|
|
|
|
uint32_t MsiDatabaseOpenViewW(void *handle, const char16_t *query,
|
|
void **outhandle)
|
|
{
|
|
warnx("FIXME: MsiDatabaseOpenView(%p,%s)", handle, ascii(query, false));
|
|
*outhandle = (void *)2;
|
|
return 0;
|
|
}
|
|
|
|
uint32_t MsiViewExecute(void *handle, void *params)
|
|
{
|
|
warnx("FIXME: MsiViewExecute(%p)", handle);
|
|
return 0;
|
|
}
|
|
|
|
void *MsiCreateRecord(uint32_t nparams)
|
|
{
|
|
warnx("FIXME: MsiCreateRecord(%u)", (unsigned)nparams);
|
|
return (void *)3;
|
|
}
|
|
|
|
uint32_t MsiRecordSetStringW(void *handle, uint32_t field, char16_t *value)
|
|
{
|
|
warnx("FIXME: MsiRecordSetString(%p,%u,%s)", handle, (unsigned)field,
|
|
ascii(value, false));
|
|
return 0;
|
|
}
|
|
|
|
uint32_t MsiRecordSetStreamW(void *handle, uint32_t field, char16_t *path)
|
|
{
|
|
warnx("FIXME: MsiRecordSetStream(%p,%u,%s)", handle, (unsigned)field,
|
|
ascii(path, true));
|
|
return 0;
|
|
}
|
|
|
|
uint32_t MsiViewModify(void *vhandle, uint32_t mode, void *rechandle)
|
|
{
|
|
warnx("FIXME: MsiViewModify(%p,%u,%p)",
|
|
vhandle, (unsigned)mode, rechandle);
|
|
return 0;
|
|
}
|
|
|
|
uint32_t MsiDatabaseCommit(void *handle)
|
|
{
|
|
warnx("FIXME: MsiDatabaseCommit(%p)", handle);
|
|
return 0;
|
|
}
|