Skip to content

Commit

Permalink
Need separate wrapper for survexport
Browse files Browse the repository at this point in the history
  • Loading branch information
ojwb committed Dec 23, 2024
1 parent 5a2a923 commit 40fe9fd
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 8 deletions.
8 changes: 5 additions & 3 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ aven_LDADD += avenrc.o
avenrc.o: $(srcdir)/aven.rc ../lib/icons/aven.ico
cd $(srcdir) && `$(WX_CONFIG) --rescomp` --include-dir '$(abs_top_builddir)/lib/icons' -o '$(abs_builddir)/avenrc.o' aven.rc

bin_PROGRAMS += wrapmsw
bin_PROGRAMS += wrapaven wrapsurvexport

wrapmsw_SOURCES = wrapmsw.c
wrapmsw_LDFLAGS = -mwindows -municode
wrapaven_SOURCES = wrapaven.c
wrapaven_LDFLAGS = -mwindows -municode

wrapsurvexport_SOURCES = wrapsurvexport.c
endif

AM_CFLAGS += $(PROJ_CFLAGS)
Expand Down
4 changes: 2 additions & 2 deletions src/wrapmsw.c → src/wrapaven.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* wrapmsw.c
/* wrapaven.c
* Set OPENSSL_MODULES to .exe's directory and run real .exe
*
* Copyright (C) 2002,2010,2014,2024 Olly Betts
Expand Down Expand Up @@ -45,7 +45,7 @@ wWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPWSTR lpCmdLine, int nCmdShow)
size_t e_len;
if (p) {
e_len = p - buf;
} else {
} else {
e_val = L".";
e_len = 1;
}
Expand Down
46 changes: 46 additions & 0 deletions src/wrapsurvexport.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/* wrapsurvexport.c
* Set OPENSSL_MODULES to .exe's directory and run real .exe
*
* Copyright (C) 2002,2010,2014,2024 Olly Betts
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include <process.h>
#include <stdlib.h>
#include <string.h>

int
main(int argc, char **argv)
{
const char *p = strrchr(argv[0], '\\');
const char *e_val = argv[0];
size_t e_len;
(void)argc;
if (p) {
e_len = p - argv[0];
} else {
e_val = ".";
e_len = 1;
}
char *e = malloc(e_len + strlen("OPENSSL_MODULES=") + 1);
if (!e) return 1;
strcpy(e, "OPENSSL_MODULES=");
memcpy(e + strlen("OPENSSL_MODULES="), e_val, e_len);
e[strlen("OPENSSL_MODULES=") + e_len] = '\0';
putenv(e);
argv[0][strlen(argv[0]) - 5] = '_';
return (_execv(argv[0], (const char * const*)argv) == -1) ? 1 : 0;
}
6 changes: 3 additions & 3 deletions survex.iss.in
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ Source: "*.exe"; Excludes: "wrapmsw.exe,aven.exe,survexport.exe"; DestDir: "{app
; Install aven.exe as ave_.exe and survexport.exe as survexpor_.exe.
Source: "aven.exe"; DestDir: "{app}"; DestName: "ave_.exe"
Source: "survexport.exe"; DestDir: "{app}"; DestName: "survexpor_.exe"
; Install wrapmsw.exe as aven.exe and survexport.exe.
Source: "wrapmsw.exe"; DestDir: "{app}"; DestName: "aven.exe"
Source: "wrapmsw.exe"; DestDir: "{app}"; DestName: "survexport.exe"
; Install wrapper versions under real name.
Source: "wrapaven.exe"; DestDir: "{app}"; DestName: "aven.exe"
Source: "wrapsurvexport.exe"; DestDir: "{app}"; DestName: "survexport.exe"
Source: "*.dll"; DestDir: "{app}"; Flags: skipifsourcedoesntexist
Source: "*.svx"; DestDir: "{app}"
Source: "*.ico"; DestDir: "{app}"
Expand Down

0 comments on commit 40fe9fd

Please sign in to comment.