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