Add dillo as a browser to search for.
[wine.git] / programs / winebrowser / main.c
blob57eef3a119a9e696a1ac43482987608639713504
1 /*
2 * winebrowser - winelib app to launch native OS browser
4 * Copyright (C) 2004 Chris Morgan
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * NOTES:
21 * Winebrowser is a winelib application that will start the appropriate
22 * native browser up for a wine installation that lacks a windows browser.
23 * Thus you will be able to open urls via native mozilla if no browser
24 * has yet been installed in wine.
27 #include "config.h"
28 #include "wine/port.h"
30 #include <windows.h>
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <errno.h>
35 /*****************************************************************************
36 * Main entry point. This is a console application so we have a main() not a
37 * winmain().
39 int main (int argc, char *argv[])
41 const char *argv_new[3];
42 DWORD maxLength;
43 CHAR szBrowsers[256];
44 DWORD type;
45 CHAR *defaultBrowsers = "mozilla,netscape,konqueror,galeon,opera,dillo";
46 char *browser;
47 HKEY hkey;
48 LONG r;
50 /* ensure that mozilla or other browsers don't think the */
51 /* temp directory is "E:\\" */
52 unsetenv("TEMP");
53 unsetenv("TMP");
55 maxLength = sizeof(szBrowsers);
57 if(RegCreateKeyEx( HKEY_CURRENT_USER,
58 "Software\\Wine\\WineBrowser", 0, NULL,
59 REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
60 &hkey, NULL))
62 fprintf( stderr, "winebrowser: cannot create config key\n" );
63 return 1;
66 r = RegQueryValueExA( hkey, "Browsers", 0, &type, szBrowsers, &maxLength);
67 if(r != ERROR_SUCCESS)
69 /* set value to the default */
70 RegSetValueExA(hkey, "Browsers", 0, REG_SZ,
71 (LPBYTE)defaultBrowsers, lstrlen(defaultBrowsers) + 1);
72 strcpy( szBrowsers, defaultBrowsers );
75 RegCloseKey(hkey);
78 /* now go through the list of browsers until we run out or we find one that */
79 /* works */
80 browser = strtok(szBrowsers, ",");
82 while(browser)
84 argv_new[0] = browser;
85 argv_new[1] = argv[1];
86 argv_new[2] = NULL;
88 spawnvp(_P_OVERLAY, browser, argv_new); /* only returns on error */
90 browser = strtok(NULL, ","); /* grab the next browser */
92 fprintf( stderr, "winebrowser: could not find a browser to run\n" );
93 return 1;