2003-06-30 16:44:03 +04:00
|
|
|
/*
|
2006-11-27 18:35:18 +03:00
|
|
|
* This file is part of NetSurf, http://netsurf-browser.org/
|
2003-06-30 16:44:03 +04:00
|
|
|
* Licensed under the GNU General Public License,
|
|
|
|
* http://www.opensource.org/licenses/gpl-license
|
|
|
|
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
|
2007-05-06 10:11:00 +04:00
|
|
|
* Copyright 2007 James Bursa <bursa@users.sourceforge.net>
|
2004-07-27 00:13:45 +04:00
|
|
|
* Copyright 2004 Andrew Timmins <atimmins@blueyonder.co.uk>
|
2002-09-11 18:24:02 +04:00
|
|
|
*/
|
|
|
|
|
2004-03-15 01:50:28 +03:00
|
|
|
#include <locale.h>
|
2003-11-06 22:41:41 +03:00
|
|
|
#include <stdbool.h>
|
2004-09-27 09:21:00 +04:00
|
|
|
#include <stdio.h>
|
2003-11-06 22:41:41 +03:00
|
|
|
#include <stdlib.h>
|
2004-06-06 15:47:23 +04:00
|
|
|
#include <sys/utsname.h>
|
2007-05-06 10:11:00 +04:00
|
|
|
#include <libxml/encoding.h>
|
|
|
|
#include <libxml/globals.h>
|
|
|
|
#include <libxml/xmlversion.h>
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "utils/config.h"
|
|
|
|
#include "content/fetch.h"
|
|
|
|
#include "content/fetchcache.h"
|
|
|
|
#include "content/urldb.h"
|
|
|
|
#include "desktop/netsurf.h"
|
|
|
|
#include "desktop/browser.h"
|
|
|
|
#include "desktop/gui.h"
|
2005-02-07 17:17:35 +03:00
|
|
|
#ifdef riscos
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "riscos/buffer.h"
|
2005-02-07 17:17:35 +03:00
|
|
|
#endif
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/url.h"
|
|
|
|
#include "utils/utf8.h"
|
|
|
|
#include "utils/utils.h"
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2003-11-06 22:41:41 +03:00
|
|
|
bool netsurf_quit = false;
|
2007-05-31 02:27:58 +04:00
|
|
|
bool verbose_log = false;
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2003-03-04 14:59:36 +03:00
|
|
|
static void netsurf_init(int argc, char** argv);
|
2003-11-06 22:41:41 +03:00
|
|
|
static void netsurf_poll(void);
|
2003-03-04 14:59:36 +03:00
|
|
|
static void netsurf_exit(void);
|
2004-07-06 00:19:52 +04:00
|
|
|
static void lib_init(void);
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2004-06-11 02:39:56 +04:00
|
|
|
|
2003-11-06 22:41:41 +03:00
|
|
|
/**
|
|
|
|
* Gui NetSurf main().
|
|
|
|
*/
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
2002-09-11 18:24:02 +04:00
|
|
|
{
|
2004-09-27 09:21:00 +04:00
|
|
|
setbuf(stderr, NULL);
|
2004-07-29 03:07:52 +04:00
|
|
|
netsurf_init(argc, argv);
|
2004-07-27 00:13:45 +04:00
|
|
|
|
2004-06-15 22:59:54 +04:00
|
|
|
while (!netsurf_quit)
|
|
|
|
netsurf_poll();
|
2003-11-06 22:41:41 +03:00
|
|
|
|
2004-06-15 22:59:54 +04:00
|
|
|
netsurf_exit();
|
2003-11-06 22:41:41 +03:00
|
|
|
|
2004-06-15 22:59:54 +04:00
|
|
|
return EXIT_SUCCESS;
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-06 22:41:41 +03:00
|
|
|
/**
|
|
|
|
* Initialise components used by gui NetSurf.
|
|
|
|
*/
|
|
|
|
|
2002-09-11 18:24:02 +04:00
|
|
|
void netsurf_init(int argc, char** argv)
|
|
|
|
{
|
2004-06-15 22:59:54 +04:00
|
|
|
struct utsname utsname;
|
|
|
|
|
2007-06-16 02:07:11 +04:00
|
|
|
#if !(defined(__SVR4) && defined(__sun))
|
2004-06-15 22:59:54 +04:00
|
|
|
stdout = stderr;
|
2007-06-16 02:07:11 +04:00
|
|
|
#endif
|
2004-07-29 02:38:17 +04:00
|
|
|
|
2007-05-31 02:27:58 +04:00
|
|
|
if ((argc > 1) && (argv[1][0] == '-') && (argv[1][1] == 'v') && (argv[1][2] == 0)) {
|
|
|
|
int argcmv;
|
|
|
|
verbose_log = true;
|
|
|
|
for (argcmv = 2; argcmv < argc; argcmv++) {
|
|
|
|
argv[argcmv - 1] = argv[argcmv];
|
|
|
|
}
|
|
|
|
argc--;
|
|
|
|
}
|
|
|
|
|
2004-07-29 02:38:17 +04:00
|
|
|
#ifdef _MEMDEBUG_H_
|
|
|
|
memdebug_memdebug("memdump");
|
|
|
|
#endif
|
2004-06-15 22:59:54 +04:00
|
|
|
|
|
|
|
LOG(("version '%s'", netsurf_version));
|
2007-06-16 02:07:11 +04:00
|
|
|
if (uname(&utsname) < 0)
|
2004-07-29 03:07:52 +04:00
|
|
|
LOG(("Failed to extract machine information"));
|
2004-06-15 22:59:54 +04:00
|
|
|
else
|
|
|
|
LOG(("NetSurf on <%s>, node <%s>, release <%s>, version <%s>, "
|
2004-07-29 02:38:17 +04:00
|
|
|
"machine <%s>", utsname.sysname,
|
2004-06-15 22:59:54 +04:00
|
|
|
utsname.nodename, utsname.release,
|
|
|
|
utsname.version, utsname.machine));
|
2005-07-11 22:10:10 +04:00
|
|
|
|
2004-07-06 00:19:52 +04:00
|
|
|
lib_init();
|
2004-07-09 21:03:35 +04:00
|
|
|
url_init();
|
2004-06-15 22:59:54 +04:00
|
|
|
gui_init(argc, argv);
|
|
|
|
setlocale(LC_ALL, "");
|
|
|
|
fetch_init();
|
|
|
|
fetchcache_init();
|
2004-09-27 09:21:00 +04:00
|
|
|
gui_init2(argc, argv);
|
2002-11-03 12:39:53 +03:00
|
|
|
}
|
|
|
|
|
2003-11-06 22:41:41 +03:00
|
|
|
/**
|
|
|
|
* Poll components which require it.
|
|
|
|
*/
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2003-11-06 22:41:41 +03:00
|
|
|
void netsurf_poll(void)
|
2002-09-11 18:24:02 +04:00
|
|
|
{
|
2007-01-31 03:02:38 +03:00
|
|
|
content_clean();
|
2004-06-11 00:41:26 +04:00
|
|
|
gui_poll(fetch_active);
|
|
|
|
fetch_poll();
|
2003-11-06 22:41:41 +03:00
|
|
|
}
|
2002-09-11 18:24:02 +04:00
|
|
|
|
|
|
|
|
2003-11-06 22:41:41 +03:00
|
|
|
/**
|
|
|
|
* Clean up components used by gui NetSurf.
|
|
|
|
*/
|
2002-10-15 14:41:12 +04:00
|
|
|
|
2003-11-06 22:41:41 +03:00
|
|
|
void netsurf_exit(void)
|
|
|
|
{
|
2006-09-02 19:52:41 +04:00
|
|
|
LOG(("Closing GUI"));
|
2004-06-15 22:59:54 +04:00
|
|
|
gui_quit();
|
2006-09-02 19:52:41 +04:00
|
|
|
LOG(("Closing content"));
|
2004-07-30 20:16:07 +04:00
|
|
|
content_quit();
|
2006-09-02 19:52:41 +04:00
|
|
|
LOG(("Closing fetches"));
|
2004-07-30 20:16:07 +04:00
|
|
|
fetch_quit();
|
2006-09-02 19:52:41 +04:00
|
|
|
LOG(("Closing utf8"));
|
2005-07-11 22:10:10 +04:00
|
|
|
utf8_finalise();
|
2006-12-09 01:38:46 +03:00
|
|
|
LOG(("Destroying URLdb"));
|
|
|
|
urldb_destroy();
|
2006-09-02 19:52:41 +04:00
|
|
|
LOG(("Exited successfully"));
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
2004-07-06 00:19:52 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialises the libraries used in NetSurf.
|
|
|
|
*/
|
2007-05-06 10:11:00 +04:00
|
|
|
void lib_init(void)
|
2004-07-06 00:19:52 +04:00
|
|
|
{
|
2007-05-06 10:11:00 +04:00
|
|
|
LOG(("xmlParserVersion %s, LIBXML_VERSION_STRING %s",
|
|
|
|
xmlParserVersion, LIBXML_VERSION_STRING));
|
|
|
|
|
2004-07-06 00:19:52 +04:00
|
|
|
/* Using encoding "X-SJIS" (unknown to libxmp2/iconv) instead as
|
|
|
|
* "Shift-JIS" is rather popular.
|
|
|
|
*/
|
2007-05-06 10:11:00 +04:00
|
|
|
if (xmlAddEncodingAlias(xmlGetCharEncodingName(
|
|
|
|
XML_CHAR_ENCODING_SHIFT_JIS), "X-SJIS") != 0)
|
2004-08-27 02:59:02 +04:00
|
|
|
die("Failed to add encoding alias");
|
2004-07-06 00:19:52 +04:00
|
|
|
}
|
2005-02-07 17:17:35 +03:00
|
|
|
|
2005-02-08 02:00:09 +03:00
|
|
|
|