diff options
Diffstat (limited to 'fake-msi.c')
-rw-r--r-- | fake-msi.c | 110 |
1 files changed, 109 insertions, 1 deletions
@@ -7,9 +7,117 @@ | |||
7 | #include <uchar.h> | 7 | #include <uchar.h> |
8 | #include <err.h> | 8 | #include <err.h> |
9 | 9 | ||
10 | #include <fcntl.h> | ||
11 | |||
12 | static char *ascii(const char16_t *wstr, bool translate_slashes) | ||
13 | { | ||
14 | size_t len = 0; | ||
15 | for (const char16_t *wp = wstr; *wp; wp++) | ||
16 | len++; | ||
17 | char *ret = malloc(len + 1); | ||
18 | char *p = ret; | ||
19 | for (const char16_t *wp = wstr; *wp; wp++) | ||
20 | *p++ = (*wp == '\\' && translate_slashes ? '/' : | ||
21 | *wp < 0x80 ? *wp : | ||
22 | '?'); | ||
23 | *p = '\0'; | ||
24 | return ret; | ||
25 | } | ||
26 | |||
27 | static void c16cpy(char16_t *out, uint32_t *outsize, char *s) | ||
28 | { | ||
29 | uint32_t retlen = 0; | ||
30 | while (retlen < *outsize) { | ||
31 | char16_t c = (out[retlen] = (unsigned char)*s++); | ||
32 | if (!c) | ||
33 | break; | ||
34 | retlen++; | ||
35 | } | ||
36 | *outsize = retlen; | ||
37 | } | ||
38 | |||
10 | uint32_t MsiGetFileVersionW(const char16_t *filename, | 39 | uint32_t MsiGetFileVersionW(const char16_t *filename, |
11 | char16_t *version, uint32_t *version_size, | 40 | char16_t *version, uint32_t *version_size, |
12 | char16_t *language, uint32_t *language_size) | 41 | char16_t *language, uint32_t *language_size) |
13 | { | 42 | { |
14 | errx(1, "NYI: MsiGetFileVersion"); | 43 | warnx("FIXME: MsiGetFileVersion(%s)", ascii(filename, true)); |
44 | if (version) { | ||
45 | c16cpy(version, version_size, "0.1.2.3"); | ||
46 | } | ||
47 | if (language) { | ||
48 | c16cpy(language, language_size, "2057"); | ||
49 | } | ||
50 | return 0; | ||
51 | } | ||
52 | |||
53 | uint32_t MsiOpenDatabaseW(const char16_t *filename, | ||
54 | const char16_t *persist, | ||
55 | void **handle) | ||
56 | { | ||
57 | char *file = ascii(filename, true); | ||
58 | warnx("FIXME: MsiOpenDatabaseW(%s,%p)", file, persist); | ||
59 | close(open(file, O_WRONLY | O_CREAT, 0666)); | ||
60 | *handle = (void *)1; | ||
61 | return 0; | ||
62 | } | ||
63 | |||
64 | uint32_t MsiCloseHandle(void *handle) | ||
65 | { | ||
66 | warnx("FIXME: MsiCloseHandle(%p)", handle); | ||
67 | return 0; | ||
68 | } | ||
69 | |||
70 | uint32_t MsiDatabaseImportW(void *handle, const char16_t *folder, | ||
71 | const char16_t *file) | ||
72 | { | ||
73 | warnx("FIXME: MsiDatabaseImport(%p,%s,%s)", handle, ascii(folder, true), | ||
74 | ascii(file, true)); | ||
75 | return 0; | ||
76 | } | ||
77 | |||
78 | uint32_t MsiDatabaseOpenViewW(void *handle, const char16_t *query, | ||
79 | void **outhandle) | ||
80 | { | ||
81 | warnx("FIXME: MsiDatabaseOpenView(%p,%s)", handle, ascii(query, false)); | ||
82 | *outhandle = (void *)2; | ||
83 | return 0; | ||
84 | } | ||
85 | |||
86 | uint32_t MsiViewExecute(void *handle, void *params) | ||
87 | { | ||
88 | warnx("FIXME: MsiViewExecute(%p)", handle); | ||
89 | return 0; | ||
90 | } | ||
91 | |||
92 | void *MsiCreateRecord(uint32_t nparams) | ||
93 | { | ||
94 | warnx("FIXME: MsiCreateRecord(%u)", (unsigned)nparams); | ||
95 | return (void *)3; | ||
96 | } | ||
97 | |||
98 | uint32_t MsiRecordSetStringW(void *handle, uint32_t field, char16_t *value) | ||
99 | { | ||
100 | warnx("FIXME: MsiRecordSetString(%p,%u,%s)", handle, (unsigned)field, | ||
101 | ascii(value, false)); | ||
102 | return 0; | ||
103 | } | ||
104 | |||
105 | uint32_t MsiRecordSetStreamW(void *handle, uint32_t field, char16_t *path) | ||
106 | { | ||
107 | warnx("FIXME: MsiRecordSetStream(%p,%u,%s)", handle, (unsigned)field, | ||
108 | ascii(path, true)); | ||
109 | return 0; | ||
110 | } | ||
111 | |||
112 | uint32_t MsiViewModify(void *vhandle, uint32_t mode, void *rechandle) | ||
113 | { | ||
114 | warnx("FIXME: MsiViewModify(%p,%u,%p)", | ||
115 | vhandle, (unsigned)mode, rechandle); | ||
116 | return 0; | ||
117 | } | ||
118 | |||
119 | uint32_t MsiDatabaseCommit(void *handle) | ||
120 | { | ||
121 | warnx("FIXME: MsiDatabaseCommit(%p)", handle); | ||
122 | return 0; | ||
15 | } | 123 | } |