Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
939ebca8
Commit
939ebca8
authored
Jan 03, 2003
by
Dimitrie O. Paun
Committed by
Alexandre Julliard
Jan 03, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify the code for the generated wrapper.
Miscellaneous small cleanups.
parent
cef5961d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
74 deletions
+30
-74
winewrap.c
tools/winewrap.c
+30
-74
No files found.
tools/winewrap.c
View file @
939ebca8
...
@@ -87,15 +87,15 @@ static const char *app_loader_script =
...
@@ -87,15 +87,15 @@ static const char *app_loader_script =
"if [ ! -x
\"
$WINELOADER
\"
]; then WINELOADER=
\"
wine
\"
; fi
\n
"
"if [ ! -x
\"
$WINELOADER
\"
]; then WINELOADER=
\"
wine
\"
; fi
\n
"
"
\n
"
"
\n
"
"# and try to start the app
\n
"
"# and try to start the app
\n
"
"exec
\"
$WINELOADER
\"
$debugmsg $dll
\"
$apppath
\"
--
\"
$@
\"\n
"
"exec
\"
$WINELOADER
\"
$debugmsg $dll
--
\"
$apppath
\"
\"
$@
\"\n
"
;
;
static
const
char
*
app_gui_spec
=
static
const
char
*
app_gui_spec
=
"@ stdcall WinMain(ptr long ptr) WinMain
\n
"
"@ stdcall WinMain(ptr long ptr
long
) WinMain
\n
"
;
;
static
const
char
*
app_cui_spec
=
static
const
char
*
app_cui_spec
=
"@ stdcall main(long ptr) main
\n
"
"@ stdcall main(long ptr
ptr
) main
\n
"
;
;
static
const
char
*
wrapper_code
=
static
const
char
*
wrapper_code
=
...
@@ -104,15 +104,10 @@ static const char *wrapper_code =
...
@@ -104,15 +104,10 @@ static const char *wrapper_code =
" * Copyright 2002 Dimitrie O. Paun <dpaun@rogers.com>
\n
"
" * Copyright 2002 Dimitrie O. Paun <dpaun@rogers.com>
\n
"
" */
\n
"
" */
\n
"
"
\n
"
"
\n
"
"#ifndef STRICT
\n
"
"#define STRICT
\n
"
"#endif
\n
"
"
\n
"
"#include <dlfcn.h>
\n
"
"#include <dlfcn.h>
\n
"
"#include <windows.h>
\n
"
"#include <windows.h>
\n
"
"
\n
"
"
\n
"
"
\n
"
"
\n
"
"
\n
"
"/*
\n
"
"/*
\n
"
" * Describe the wrapped application
\n
"
" * Describe the wrapped application
\n
"
" */
\n
"
" */
\n
"
...
@@ -155,10 +150,18 @@ static const char *wrapper_code =
...
@@ -155,10 +150,18 @@ static const char *wrapper_code =
"static char* mfcModule = NULL;
\n
"
"static char* mfcModule = NULL;
\n
"
"
\n
"
"
\n
"
"
\n
"
"
\n
"
"void error(const char *format, ...)
\n
"
"{
\n
"
" va_list ap;
\n
"
" char msg[4096];
\n
"
"
\n
"
" va_start(ap, format);
\n
"
" vsnprintf(msg, sizeof(msg), format, ap);
\n
"
" MessageBox(NULL, msg,
\"
Error
\"
, MB_OK);
\n
"
" va_end(ap);
\n
"
" exit(1);
\n
"
"}
\n
"
"
\n
"
"
\n
"
"/*
\n
"
" * Implement the main.
\n
"
" */
\n
"
"
\n
"
"
\n
"
"#if GUIEXE
\n
"
"#if GUIEXE
\n
"
"typedef int WINAPI (*WinMainFunc)(HINSTANCE hInstance, HINSTANCE hPrevInstance,
\n
"
"typedef int WINAPI (*WinMainFunc)(HINSTANCE hInstance, HINSTANCE hPrevInstance,
\n
"
...
@@ -191,91 +194,44 @@ static const char *wrapper_code =
...
@@ -191,91 +194,44 @@ static const char *wrapper_code =
" sprintf(libName,
\"
%%s.so
\"
,appName);
\n
"
" sprintf(libName,
\"
%%s.so
\"
,appName);
\n
"
" appLibrary=dlopen(libName,RTLD_NOW);
\n
"
" appLibrary=dlopen(libName,RTLD_NOW);
\n
"
" }
\n
"
" }
\n
"
" if (appLibrary==NULL) {
\n
"
" if (!appLibrary) error(
\"
Could not load the %%s library: %%s
\"
, libName, dlerror());
\n
"
" char format[]=
\"
Could not load the %%s library: %%s
\"
;
\n
"
" char* error;
\n
"
" char* msg;
\n
"
"
\n
"
" error=dlerror();
\n
"
" msg=(char*)malloc(strlen(format)+strlen(libName)+strlen(error));
\n
"
" sprintf(msg,format,libName,error);
\n
"
" MessageBox(NULL,msg,
\"
dlopen error
\"
,MB_OK);
\n
"
" free(msg);
\n
"
" return 1;
\n
"
" }
\n
"
"
\n
"
"
\n
"
" /* Then if this application is MFC based, load the MFC module */
\n
"
" /* Then if this application is MFC based, load the MFC module */
\n
"
" /* FIXME: I'm not sure this is really necessary */
\n
"
" /* FIXME: I'm not sure this is really necessary */
\n
"
" if (mfcModule!=NULL) {
\n
"
" if (mfcModule) {
\n
"
" hMFC=LoadLibrary(mfcModule);
\n
"
" hMFC = LoadLibrary(mfcModule);
\n
"
" if (hMFC==NULL) {
\n
"
" if (!hMFC) error(
\"
Could not load the MFC module %%s (%%d)
\"
, mfcModule, GetLastError());
\n
"
" char format[]=
\"
Could not load the MFC module %%s (%%d)
\"
;
\n
"
" char* msg;
\n
"
"
\n
"
" msg=(char*)malloc(strlen(format)+strlen(mfcModule)+11);
\n
"
" sprintf(msg,format,mfcModule,GetLastError());
\n
"
" MessageBox(NULL,msg,
\"
LoadLibrary error
\"
,MB_OK);
\n
"
" free(msg);
\n
"
" return 1;
\n
"
" }
\n
"
" /* MFC is a special case: the WinMain is in the MFC library,
\n
"
" /* MFC is a special case: the WinMain is in the MFC library,
\n
"
" * instead of the application's library.
\n
"
" * instead of the application's library.
\n
"
" */
\n
"
" */
\n
"
" hMain=hMFC;
\n
"
" hMain = hMFC;
\n
"
" } else {
\n
"
" hMFC=NULL;
\n
"
" }
\n
"
" }
\n
"
"
\n
"
"
\n
"
" /* Load the application's module */
\n
"
" /* Load the application's module */
\n
"
" if (appModule==NULL) {
\n
"
" if (!appModule) appModule = appName;
\n
"
" appModule=appName;
\n
"
" hApp = LoadLibrary(appModule);
\n
"
" }
\n
"
" if (!hApp) error(
\"
Could not load the application's module %%s (%%d)
\"
, appModule, GetLastError());
\n
"
" hApp=LoadLibrary(appModule);
\n
"
" if (!hMain) hMain = hApp;
\n
"
" if (hApp==NULL) {
\n
"
" char format[]=
\"
Could not load the application's module %%s (%%d)
\"
;
\n
"
" char* msg;
\n
"
"
\n
"
" msg=(char*)malloc(strlen(format)+strlen(appModule)+11);
\n
"
" sprintf(msg,format,appModule,GetLastError());
\n
"
" MessageBox(NULL,msg,
\"
LoadLibrary error
\"
,MB_OK);
\n
"
" free(msg);
\n
"
" return 1;
\n
"
" } else if (hMain==NULL) {
\n
"
" hMain=hApp;
\n
"
" }
\n
"
"
\n
"
"
\n
"
" /* Get the address of the application's entry point */
\n
"
" /* Get the address of the application's entry point */
\n
"
" appMain=GetProcAddress(hMain, appInit);
\n
"
" appMain = GetProcAddress(hMain, appInit);
\n
"
" if (appMain==NULL) {
\n
"
" if (!appMain) error(
\"
Could not get the address of %%s (%%d)
\"
, appInit, GetLastError());
\n
"
" char format[]=
\"
Could not get the address of %%s (%%d)
\"
;
\n
"
" char* msg;
\n
"
"
\n
"
" msg=(char*)malloc(strlen(format)+strlen(appInit)+11);
\n
"
" sprintf(msg,format,appInit,GetLastError());
\n
"
" MessageBox(NULL,msg,
\"
GetProcAddress error
\"
,MB_OK);
\n
"
" free(msg);
\n
"
" return 1;
\n
"
" }
\n
"
"
\n
"
"
\n
"
" /* And finally invoke the application's entry point */
\n
"
" /* And finally invoke the application's entry point */
\n
"
"#if GUIEXE
\n
"
"#if GUIEXE
\n
"
" retcode
=(*((WinMainFunc)appMain))(hApp,hPrevInstance,szCmdLine,
iCmdShow);
\n
"
" retcode
= (*((WinMainFunc)appMain))(hApp, hPrevInstance, szCmdLine,
iCmdShow);
\n
"
"#else
\n
"
"#else
\n
"
" retcode
=(*((MainFunc)appMain))(argc,argv,
envp);
\n
"
" retcode
= (*((MainFunc)appMain))(argc, argv,
envp);
\n
"
"#endif
\n
"
"#endif
\n
"
"
\n
"
"
\n
"
" /* Cleanup and done */
\n
"
" /* Cleanup and done */
\n
"
" FreeLibrary(hApp);
\n
"
" FreeLibrary(hApp);
\n
"
" if (hMFC!=NULL) {
\n
"
" FreeLibrary(hMFC);
\n
"
" FreeLibrary(hMFC);
\n
"
" }
\n
"
" dlclose(appLibrary);
\n
"
" dlclose(appLibrary);
\n
"
" free(libName);
\n
"
" free(libName);
\n
"
"
\n
"
"
\n
"
" return retcode;
\n
"
" return retcode;
\n
"
"}
\n
"
"}
\n
"
#if 0
#endif
;
;
static
char
*
output_name
;
static
char
*
output_name
;
...
@@ -477,7 +433,7 @@ int main(int argc, char **argv)
...
@@ -477,7 +433,7 @@ int main(int argc, char **argv)
if
(
argv
[
i
][
2
]
==
0
)
verbose
=
1
;
if
(
argv
[
i
][
2
]
==
0
)
verbose
=
1
;
break
;
break
;
case
'V'
:
case
'V'
:
printf
(
"winewrap v0.
31
\n
"
);
printf
(
"winewrap v0.
40
\n
"
);
exit
(
0
);
exit
(
0
);
break
;
break
;
case
'C'
:
case
'C'
:
...
@@ -663,7 +619,7 @@ int main(int argc, char **argv)
...
@@ -663,7 +619,7 @@ int main(int argc, char **argv)
/* create the loader script */
/* create the loader script */
create_file
(
base_file
,
app_loader_script
,
base_name
);
create_file
(
base_file
,
app_loader_script
,
base_name
);
chmod
(
base_
nam
e
,
S_IRUSR
|
S_IWUSR
|
S_IXUSR
|
S_IRGRP
|
S_IXGRP
|
S_IROTH
|
S_IXOTH
);
chmod
(
base_
fil
e
,
S_IRUSR
|
S_IWUSR
|
S_IXUSR
|
S_IRGRP
|
S_IXGRP
|
S_IROTH
|
S_IXOTH
);
return
0
;
return
0
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment