aboutsummaryrefslogtreecommitdiff
path: root/src/dillo.cc
diff options
context:
space:
mode:
authorjcid <devnull@localhost>2007-10-07 00:36:34 +0200
committerjcid <devnull@localhost>2007-10-07 00:36:34 +0200
commit93715c46a99c96d6c866968312691ec9ab0f6a03 (patch)
tree573f19ec6aa740844f53a7c0eb7114f04096bf64 /src/dillo.cc
Initial revision
Diffstat (limited to 'src/dillo.cc')
-rw-r--r--src/dillo.cc108
1 files changed, 108 insertions, 0 deletions
diff --git a/src/dillo.cc b/src/dillo.cc
new file mode 100644
index 00000000..bd8ceeb8
--- /dev/null
+++ b/src/dillo.cc
@@ -0,0 +1,108 @@
+/*
+ * Dillo web browser
+ *
+ * Copyright 1999-2006 Jorge Arellano Cid <jcid@dillo.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+
+#include <fltk/Window.h>
+#include <fltk/run.h>
+
+#include "dir.h"
+#include "uicmd.hh"
+
+#include "msg.h"
+#include "bw.h"
+#include "bookmark.h"
+#include "misc.h"
+#include "nav.h"
+
+#include "dns.h"
+#include "web.hh"
+#include "IO/Url.h"
+#include "IO/mime.h"
+#include "capi.h"
+#include "dicache.h"
+#include "cookies.h"
+
+
+/*
+ * Given a command line argument, build a DilloUrl for it.
+ */
+static DilloUrl *Dillo_make_start_url(char *str)
+{
+ char *url_str, *p;
+ DilloUrl *start_url;
+ int is_file = FALSE;
+
+ /* Relative path to a local file? */
+ p = (*str == '/') ? dStrdup(str) : dStrconcat(a_Dir_get_owd(),"/",str,NULL);
+
+ if (access(p, F_OK) == 0) {
+ /* absolute path may have non-URL characters */
+ url_str = a_Misc_escape_chars(p, "% ");
+ is_file = TRUE;
+ } else {
+ /* Not a file, filter URL string */
+ url_str = a_Url_string_strip_delimiters(str);
+ }
+ dFree(p);
+
+ if (is_file) {
+ start_url = a_Url_new(url_str + 1, "file:/", 0, 0, 0);
+ } else {
+ start_url = a_Url_new(url_str, NULL, 0, 0, 0);
+ }
+ dFree(url_str);
+
+ return start_url;
+}
+
+/*
+ * MAIN
+ */
+int main(int argc, char **argv)
+{
+ // Initialize internal modules
+ a_Dir_init();
+ a_Prefs_init();
+ a_Dpi_init();
+ a_Dns_init();
+ a_Web_init();
+ a_Http_init();
+ a_Mime_init();
+ a_Capi_init();
+ a_Dicache_init();
+ a_Bw_init();
+ a_Cookies_init();
+
+ // Create a new UI/bw pair
+ BrowserWindow *bw = a_UIcmd_browser_window_new(0, 0);
+
+ if (argc == 2) {
+ DilloUrl *url = Dillo_make_start_url(argv[1]);
+ a_UIcmd_open_urlstr(bw, URL_STR(url));
+ a_Url_free(url);
+ } else {
+ /* Send startup screen */
+ //a_Nav_push(bw, prefs.start_page);
+ }
+
+ return fltk::run();
+}