[PATCH 1/2] winebrowser: Try other browsers on non-zero exit code.

Zebediah Figura zfigura at codeweavers.com
Tue Aug 1 12:00:28 CDT 2017


Use system() rather than exec() in order to do this.

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 include/dsquery.h           | 35 +++++++++++++++++++++++++++++++++++
 programs/winebrowser/main.c | 36 ++++++++++++++++--------------------
 2 files changed, 51 insertions(+), 20 deletions(-)
 create mode 100644 include/dsquery.h

diff --git a/include/dsquery.h b/include/dsquery.h
new file mode 100644
index 00000000000..2db5cff8375
--- /dev/null
+++ b/include/dsquery.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2017 Zebediah Figura for Codeweavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define DSQPF_NOSAVE                    0x00000001
+#define DSQPF_SAVELOCATION              0x00000002
+#define DSQPF_SHOWHIDDENOBJECTS         0x00000004
+#define DSQPF_ENABLEADMINFEATURES       0x00000008
+#define DSQPF_ENABLEADVANCEDFEATURES    0x00000010
+#define DSQPF_HASCREDENTIALS            0x00000020
+#define DSQPF_NOCHOOSECOLUMNS           0x00000040
+
+typedef struct {
+    DWORD   cbStruct;
+    DWORD   dwFlags;
+    LPWSTR  pDefaultScope;
+    LPWSTR  pDefaultSaveLocation;
+    LPWSTR  pUserName;
+    LPWSTR  pPassword;
+    LPWSTR  pServer;
+} DSQUERYINITPARAMS, *LPDSQUERYINITPARAMS;
diff --git a/programs/winebrowser/main.c b/programs/winebrowser/main.c
index 304ac14bbc9..3c4b4a32660 100644
--- a/programs/winebrowser/main.c
+++ b/programs/winebrowser/main.c
@@ -70,35 +70,31 @@ static char *strdup_unixcp( const WCHAR *str )
 }
 
 /* try to launch a unix app from a comma separated string of app names */
-static int launch_app( const WCHAR *candidates, const WCHAR *argv1 )
+static int launch_app( const WCHAR *candidatesW, const WCHAR *urlW )
 {
-    char *cmdline;
-    int i, count;
-    char **argv_new;
+    char *candidate, *url, *cmdline;
 
-    if (!(cmdline = strdup_unixcp( argv1 ))) return 1;
+    if (!(url = strdup_unixcp( urlW ))) return 1;
 
-    while (*candidates)
+    while (*candidatesW)
     {
-        WCHAR **args = CommandLineToArgvW( candidates, &count );
+        if (!(candidate = strdup_unixcp( candidatesW ))) break;
+        if (!(cmdline = HeapAlloc( GetProcessHeap(), 0, strlen( candidate ) + strlen( url ) + 2 ))) break;
 
-        if (!(argv_new = HeapAlloc( GetProcessHeap(), 0, (count + 2) * sizeof(*argv_new) ))) break;
-        for (i = 0; i < count; i++) argv_new[i] = strdup_unixcp( args[i] );
-        argv_new[count] = cmdline;
-        argv_new[count + 1] = NULL;
+        strcpy(cmdline, candidate);
+        strcat(cmdline, " ");
+        strcat(cmdline, url);
 
-        TRACE( "Trying" );
-        for (i = 0; i <= count; i++) TRACE( " %s", wine_dbgstr_a( argv_new[i] ));
-        TRACE( "\n" );
+        TRACE("Trying %s\n", wine_dbgstr_a(cmdline));
+        if (!system(cmdline)) return 0;
 
-        _spawnvp( _P_OVERLAY, argv_new[0], (const char **)argv_new );  /* only returns on error */
-        for (i = 0; i < count; i++) HeapFree( GetProcessHeap(), 0, argv_new[i] );
-        HeapFree( GetProcessHeap(), 0, argv_new );
-        candidates += strlenW( candidates ) + 1;  /* grab the next app */
+        HeapFree( GetProcessHeap(), 0, cmdline );
+        HeapFree( GetProcessHeap(), 0, candidate );
+        candidatesW += strlenW( candidatesW ) + 1;  /* grab the next app */
     }
-    WINE_ERR( "could not find a suitable app to open %s\n", debugstr_w( argv1 ));
+    WINE_ERR( "could not find a suitable app to open %s\n", debugstr_w( urlW ));
 
-    HeapFree( GetProcessHeap(), 0, cmdline );
+    HeapFree( GetProcessHeap(), 0, url );
     return 1;
 }
 
-- 
2.13.3




More information about the wine-patches mailing list