winebrowser: convert local file arg
Rein Klazes
wijn at wanadoo.nl
Tue Dec 28 13:52:55 CST 2004
Hi,
Fix for a bug reported in the newsgroup.
Changelog:
programs/winebrowser : main.c
If the argument is a local file, pass its Unix name to the
browser.
Rein.
-------------- next part --------------
--- wine/programs/winebrowser/main.c 2004-03-11 04:52:07.000000000 +0100
+++ mywine/programs/winebrowser/main.c 2004-12-28 20:30:19.000000000 +0100
@@ -32,6 +32,8 @@
#include <stdlib.h>
#include <errno.h>
+typedef LPSTR (*wine_get_unix_file_name_t) ( LPCWSTR dos );
+
/*****************************************************************************
* Main entry point. This is a console application so we have a main() not a
* winmain().
@@ -42,10 +44,34 @@ int main (int argc, char *argv[])
DWORD maxLength;
CHAR szBrowsers[256];
DWORD type;
- CHAR *defaultBrowsers = "mozilla,netscape,konqueror,galeon,opera,dillo";
+ CHAR *defaultBrowsers =
+ "mozilla, firefox, netscape, konqueror, galeon, opera, dillo";
char *browser;
HKEY hkey;
LONG r;
+ CHAR unixpath[ MAX_PATH];
+ wine_get_unix_file_name_t wine_get_unix_file_name_ptr = NULL;
+
+ /* check if the argument is a local file */
+ wine_get_unix_file_name_ptr = (wine_get_unix_file_name_t)
+ GetProcAddress( GetModuleHandle( "KERNEL32"),
+ "wine_get_unix_file_name");
+ if( wine_get_unix_file_name_ptr == NULL) {
+ fprintf( stderr, "%s: cannot get the address of "
+ "'wine_get_unix_file_name'\n", argv[0]);
+ } else {
+ WCHAR dospathW[ MAX_PATH];
+ char *p;
+ MultiByteToWideChar( CP_ACP, 0, argv[1], -1, dospathW, MAX_PATH);
+ if((p = wine_get_unix_file_name_ptr( dospathW))) {
+ struct stat dummy;
+ if( strlen( p) < MAX_PATH && stat( p, &dummy) >= 0 ) {
+ strcpy( unixpath, p);
+ argv[1] = unixpath;
+ }
+ HeapFree( GetProcessHeap(), 0, p );
+ }
+ }
maxLength = sizeof(szBrowsers);
More information about the wine-patches
mailing list