2003-06-30 16:44:03 +04:00
|
|
|
/*
|
|
|
|
* This file is part of NetSurf, http://netsurf.sourceforge.net/
|
|
|
|
* 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 19:09:12 +03:00
|
|
|
* Copyright 2004 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>
|
2004-01-05 05:10:59 +03:00
|
|
|
#include "netsurf/utils/config.h"
|
2003-12-28 04:00:58 +03:00
|
|
|
#include "netsurf/content/fetch.h"
|
|
|
|
#include "netsurf/content/fetchcache.h"
|
2002-09-11 18:24:02 +04:00
|
|
|
#include "netsurf/desktop/netsurf.h"
|
|
|
|
#include "netsurf/desktop/browser.h"
|
|
|
|
#include "netsurf/desktop/gui.h"
|
2005-02-07 17:17:35 +03:00
|
|
|
#ifdef riscos
|
|
|
|
#include "netsurf/riscos/buffer.h"
|
|
|
|
#endif
|
2003-02-09 15:58:15 +03:00
|
|
|
#include "netsurf/utils/log.h"
|
2004-03-02 21:02:41 +03:00
|
|
|
#include "netsurf/utils/url.h"
|
2005-07-11 22:10:10 +04:00
|
|
|
#include "netsurf/utils/utf8.h"
|
2003-12-28 05:35:46 +03:00
|
|
|
#include "netsurf/utils/utils.h"
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2003-11-06 22:41:41 +03:00
|
|
|
bool netsurf_quit = 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;
|
|
|
|
|
|
|
|
stdout = stderr;
|
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));
|
|
|
|
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
|
|
|
{
|
2004-06-11 00:41:26 +04:00
|
|
|
content_clean();
|
|
|
|
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)
|
|
|
|
{
|
2004-06-15 22:59:54 +04:00
|
|
|
gui_quit();
|
2004-07-30 20:16:07 +04:00
|
|
|
content_quit();
|
|
|
|
fetch_quit();
|
2005-07-11 22:10:10 +04:00
|
|
|
utf8_finalise();
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|
2004-07-06 00:19:52 +04: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-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
|
|
|
|