aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2017-02-16 20:33:01 +0000
committerSimon Tatham <anakin@pobox.com>2017-02-16 20:33:01 +0000
commitabd0e801c055418418120a81de893345c20b5d54 (patch)
tree090dae5d1056dac9eb72539a07b05146e183bfcd
downloadwix-on-linux-abd0e801c055418418120a81de893345c20b5d54.tar.gz
wix-on-linux-abd0e801c055418418120a81de893345c20b5d54.tar.bz2
wix-on-linux-abd0e801c055418418120a81de893345c20b5d54.zip
Fake implementation of winterop.dll.
If I compile this to Linux native code, and then run WiX under Mono, it loads this library and gets past the first CabExtract call, so I can find out what the next problem turns out to be.
-rw-r--r--fake-winterop.c153
-rw-r--r--libwinterop.so.la42
2 files changed, 195 insertions, 0 deletions
diff --git a/fake-winterop.c b/fake-winterop.c
new file mode 100644
index 0000000..828b8fa
--- /dev/null
+++ b/fake-winterop.c
@@ -0,0 +1,153 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <stdint.h>
4#include <stdbool.h>
5#include <stdarg.h>
6#include <string.h>
7#include <uchar.h>
8#include <err.h>
9
10#include <sys/types.h>
11#include <sys/wait.h>
12#include <unistd.h>
13
14static char *ascii(const char16_t *wstr, bool translate_slashes)
15{
16 size_t len = 0;
17 for (const char16_t *wp = wstr; *wp; wp++)
18 len++;
19 char *ret = malloc(len + 1);
20 char *p = ret;
21 for (const char16_t *wp = wstr; *wp; wp++)
22 *p++ = (*wp == '\\' && translate_slashes ? '/' :
23 *wp < 0x80 ? *wp :
24 '?');
25 *p = '\0';
26 return ret;
27}
28
29static void system_argv(const char *cmd, ...)
30{
31 int nargs, nchars;
32 const char *word;
33 va_list ap;
34
35 va_start(ap, cmd);
36 nargs = 1; /* terminating NULL */
37 nchars = 0;
38 for (word = cmd; word; word = va_arg(ap, const char *)) {
39 nargs++;
40 nchars += 1 + strlen(word);
41 }
42 va_end(ap);
43
44 char *args[nargs], chars[nchars];
45 char **argp = args, *charp = chars;
46 va_start(ap, cmd);
47 for (word = cmd; word; word = va_arg(ap, const char *)) {
48 *argp++ = charp;
49 strcpy(charp, word);
50 charp += 1 + strlen(word);
51 }
52 va_end(ap);
53 *argp++ = NULL;
54
55 pid_t pid = fork();
56 if (pid < 0)
57 err(1, "fork");
58
59 if (pid == 0) {
60 execvp(args[0], args);
61 warn("execvp");
62 _exit(127);
63 }
64
65 int status;
66 if (waitpid(pid, &status, 0) != pid)
67 err(1, "waitpid");
68 if (!(WIFEXITED(status) && WEXITSTATUS(status) == 0))
69 errx(1, "subcommand failed");
70}
71
72uint32_t HashPublicKeyInfo(void *pCertContext,
73 void *rgbSubjectKeyIdentifier,
74 uint32_t *pcbSubjectKeyIndentifier)
75{
76 errx(1, "HashPublicKeyInfo NYI");
77}
78
79uint32_t ResetAcls(const char16_t **pwzFiles, uint32_t cFiles)
80{
81 return 0;
82}
83
84uint32_t CreateCabBegin(const char16_t *wzCab, const char16_t *wzCabDir,
85 uint32_t dwMaxFiles, uint32_t dwMaxSize,
86 uint32_t dwMaxThresh, int compression,
87 void **out_ctx)
88{
89 fprintf(stderr, "CreateCabBegin(\"%s\", \"%s\", ...)!\n",
90 ascii(wzCab, true), ascii(wzCabDir, true));
91 return 0;
92}
93
94uint32_t CreateCabAddFile(const char16_t *wzFile, const char16_t *wzToken,
95 void *pmfHash, void *ctx)
96{
97 fprintf(stderr, "CreateCabAddFile!\n");
98 return 0;
99}
100
101uint32_t CreateCabAddFiles(const char16_t *const *pwzFiles,
102 const char16_t *const *pwzTokens,
103 void *pmfHash, uint32_t cFiles, void *hContext)
104{
105 fprintf(stderr, "CreateCabAddFiles!\n");
106 return 0;
107}
108
109uint32_t CreateCabFinish(void *hContext, void *newCabNamesCallBackAddress)
110{
111 /* FIXME: newCabNamesCallBackAddress is actually a fn ptr of some kind */
112 fprintf(stderr, "CabCFinish(%p,%p)!\n",
113 hContext, newCabNamesCallBackAddress);
114 return 0;
115}
116
117void CreateCabCancel(void *hContext)
118{
119 fprintf(stderr, "CabCCancel(%p)!\n", hContext);
120}
121
122uint32_t ExtractCabBegin(void)
123{
124 return 0;
125}
126
127uint32_t ExtractCab(const char16_t *wzCabinet, const char16_t *wzExtractDir)
128{
129 char *cab = ascii(wzCabinet, true), *dir = ascii(wzExtractDir, true);
130 fprintf(stderr, "ExtractCab(\"%s\", \"%s\"\n", cab, dir);
131 system_argv("cabextract", "-d", dir, cab, (const char *)NULL);
132 return 0;
133}
134
135void ExtractCabFinish(void)
136{
137}
138
139uint32_t EnumerateCabBegin(void)
140{
141 return 0;
142}
143
144uint32_t EnumerateCab(const char16_t *wzCabinet, void *pfnNotify)
145{
146 /* FIXME: fpnNotify looks like a fn ptr again */
147 fprintf(stderr, "EnumerateCab!\n");
148 return 0;
149}
150
151void EnumerateCabFinish(void)
152{
153}
diff --git a/libwinterop.so.la b/libwinterop.so.la
new file mode 100644
index 0000000..74b9ccc
--- /dev/null
+++ b/libwinterop.so.la
@@ -0,0 +1,42 @@
1# libsane-u12.la - a libtool library file
2# Generated by libtool (GNU libtool) 2.4.2
3#
4# Please DO NOT delete this file!
5# It is necessary for linking the library.
6
7# The name that we can dlopen(3).
8dlname='libwinterop.so'
9
10# Names of this library.
11library_names='libwinterop.so'
12
13# The name of the static archive.
14old_library='libwinterop.a'
15
16# Linker flags that can not go in dependency_libs.
17inherited_linker_flags=''
18
19# Libraries that this one depends upon.
20dependency_libs=''
21
22# Names of additional weak libraries provided by this library
23weak_library_names=''
24
25# Version information for libwinterop.
26current=1
27age=0
28revision=0
29
30# Is this an already installed library?
31installed=no
32
33# Should we warn about portability when linking against -modules?
34shouldnotlink=no
35
36# Files to dlopen/dlpreopen
37dlopen=''
38dlpreopen=''
39
40# Directory that this library needs to be installed in:
41libdir='/usr/lib/x86_64-linux-gnu'
42