diff -pru dillo/src/commands.c dillo-lfx/src/commands.c --- dillo/src/commands.c Tue Aug 6 17:24:05 2002 +++ dillo-lfx/src/commands.c Tue Aug 6 19:18:59 2002 @@ -42,7 +42,7 @@ void a_Commands_new_callback(GtkWidget * BrowserWindow *bw = (BrowserWindow *)client_data; a_Interface_browser_window_new(bw->main_window->allocation.width, - bw->main_window->allocation.height); + bw->main_window->allocation.height, 0); } /* @@ -386,7 +386,7 @@ void a_Commands_open_link_nw_callback(Gt BrowserWindow *newbw; gdk_window_get_size (bw->main_window->window, &width, &height); - newbw = a_Interface_browser_window_new(width, height); + newbw = a_Interface_browser_window_new(width, height, 0); a_Nav_push(newbw, a_Menu_popup_get_url(bw)); } diff -pru dillo/src/dillo.c dillo-lfx/src/dillo.c --- dillo/src/dillo.c Tue Aug 6 18:03:56 2002 +++ dillo-lfx/src/dillo.c Tue Aug 6 19:31:10 2002 @@ -47,13 +47,32 @@ #include "dw_widget.h" #include "cookies.h" +#define DILLO_CLI_HELP_MESSAGE \ + "\nUsage: dillo [OPTIONS] [URL|FILE]...\n" \ + "Options:\n" \ + " -l allow only local host browing.\n" \ + " -f start in full window mode.\n" \ + " -x XID open first Dillo window in an existing GtkSocket which ID is XID.\n" \ + " -h display this help message and exit.\n" \ + " -v display version info and exit.\n" \ + " URL URL to browse.\n" \ + " FILE local FILE to view.\n" + +#define DILLO_CLI_OPTIONS "hvlfx:" + +#define DILLO_CLI_HELP 1 << 0 +#define DILLO_CLI_VERSION 1 << 1 +#define DILLO_CLI_LOCAL 1 << 2 +#define DILLO_CLI_FULLWINDOW 1 << 3 +#define DILLO_CLI_XID 1 << 4 /* * Forward declarations */ static void Dillo_check_home_dir(char *dir); - +static void Dillo_print_help(void); +static void Dillo_print_version(void); /* * ******************************** MAIN ************************************* @@ -63,12 +82,46 @@ gint main(int argc, char *argv[]) gchar *file; DilloUrl *start_url; BrowserWindow *bw; + int c; + guint32 cli_option = 0; + guint32 xid = 0; /* This lets threads in the file module end peacefully when aborted * todo: implement a cleaner mechanism (in file.c) */ signal(SIGPIPE, SIG_IGN); g_print("Setting locale to %s\n", gtk_set_locale()); + + /* Handle command line options */ + while((c = getopt(argc, argv, DILLO_CLI_OPTIONS)) != -1) { + switch (c) { + case 'h': + cli_option |= DILLO_CLI_HELP; + Dillo_print_help(); + return 0; + break; + case 'v': + cli_option |= DILLO_CLI_VERSION; + Dillo_print_version(); + return 0; + break; + case 'l': + cli_option |= DILLO_CLI_LOCAL; + break; + case 'f': + cli_option |= DILLO_CLI_FULLWINDOW; + break; + case 'x': + cli_option |= DILLO_CLI_XID; + xid = strtol(optarg, NULL, 10); + break; + default: + printf("Unknown option.\n"); + Dillo_print_help(); + return 0; + } + } + gtk_init(&argc, &argv); gdk_rgb_init(); @@ -78,7 +131,7 @@ gint main(int argc, char *argv[]) g_free(file); a_Prefs_init(); - a_Dns_init(); + a_Dns_init(cli_option & DILLO_CLI_LOCAL); a_Http_init(); a_Mime_init(); a_Cache_init(); @@ -89,7 +142,12 @@ gint main(int argc, char *argv[]) /* a_Nav_init() has been moved into this call because it needs to be * initialized with the new browser_window structure */ - bw = a_Interface_browser_window_new(prefs.width, prefs.height); + bw = a_Interface_browser_window_new(prefs.width, prefs.height, xid); + if (cli_option & DILLO_CLI_FULLWINDOW) + a_Interface_toggle_panel(bw); + /* Only the first window can be embedded in the GtkSocket, + * thus reset xid now. */ + xid = 0; a_Bookmarks_init(); @@ -98,22 +156,24 @@ gint main(int argc, char *argv[]) a_Nav_push(bw, start_url); a_Url_free(start_url); - if (argc == 2) { - if (access(argv[1], F_OK) == 0) { + for (c = optind; c < argc; c++) { + if (c > optind) + bw = a_Interface_browser_window_new(prefs.width, prefs.height, xid); + if (access(argv[c], F_OK) == 0) { GString *UrlStr = g_string_sized_new(128); - if (argv[1][0] == '/') { - g_string_sprintf(UrlStr, "file:%s", argv[1]); + if (argv[c][0] == '/') { + g_string_sprintf(UrlStr, "file:%s", argv[c]); } else { g_string_sprintf(UrlStr, "file:%s", g_get_current_dir()); if (UrlStr->str[UrlStr->len - 1] != '/') g_string_append(UrlStr, "/"); - g_string_append(UrlStr, argv[1]); + g_string_append(UrlStr, argv[c]); } start_url = a_Url_new(UrlStr->str, NULL, 0, 0); g_string_free(UrlStr, TRUE); } else { - start_url = a_Url_new(argv[1], NULL, 0, 0); + start_url = a_Url_new(argv[c], NULL, 0, 0); } a_Nav_push(bw, start_url); a_Url_free(start_url); @@ -157,3 +217,18 @@ static void Dillo_check_home_dir(char *d } } +/* + * Print a short help text + */ +static void Dillo_print_help(void) +{ + printf(DILLO_CLI_HELP_MESSAGE); +} + +/* + * Print version + */ +static void Dillo_print_version(void) +{ + printf("Dillo %s\n", VERSION); +} diff -pru dillo/src/dns.c dillo-lfx/src/dns.c --- dillo/src/dns.c Tue Aug 6 18:03:56 2002 +++ dillo-lfx/src/dns.c Tue Aug 6 19:16:43 2002 @@ -85,6 +85,7 @@ static gint Dns_timeout_client(gpointer /* * Local Data */ +static gboolean dns_block_non_local; static DnsServer dns_server[G_DNS_MAX_SERVERS]; static gint num_servers; static GDnsCache *dns_cache; @@ -184,11 +185,13 @@ static void Dns_cache_add(char *hostname /* * Initializer function */ -void a_Dns_init(void) +void a_Dns_init(gboolean block_non_local) { gint i; DEBUG_MSG(5, "dillo_dns_init: Here we go!\n"); + dns_block_non_local = block_non_local; + dns_queue_size = 0; dns_queue_size_max = 16; dns_queue = g_new(GDnsQueue, dns_queue_size_max); @@ -247,6 +250,8 @@ static void *Dns_server(void *data) } else { memcpy(&ip_addr, host->h_addr_list[0], sizeof(ip_addr)); ip_addr = ntohl(ip_addr); + if (dns_block_non_local && (ip_addr & 0xff000000) != 0x7f000000) + ip_addr = 0; } /* write hostname to client */ diff -pru dillo/src/dns.h dillo-lfx/src/dns.h --- dillo/src/dns.h Tue Aug 6 18:03:56 2002 +++ dillo-lfx/src/dns.h Tue Aug 6 19:16:43 2002 @@ -8,7 +8,7 @@ extern "C" { #endif /* __cplusplus */ -void a_Dns_init (void); +void a_Dns_init (gboolean block_non_local); void a_Dns_freeall(void); void a_Dns_ccc(int Op, int Br, ChainLink *Info, void *Data, void *ExtraData); diff -pru dillo/src/interface.c dillo-lfx/src/interface.c --- dillo/src/interface.c Tue Aug 6 17:24:42 2002 +++ dillo-lfx/src/interface.c Tue Aug 6 19:18:59 2002 @@ -565,7 +565,8 @@ static int Interface_click_callback(Brow * Create a new browser window and return it. * (the new window is stored in browser_window[]) */ -BrowserWindow *a_Interface_browser_window_new(gint width, gint height) +BrowserWindow *a_Interface_browser_window_new(gint width, gint height, + guint32 xid) { GtkWidget *box1, *box2, *hbox, *progbox, *toolbar, *handlebox, *menubar, *locbox; @@ -574,14 +575,16 @@ BrowserWindow *a_Interface_browser_windo /* We use g_new0() to zero the memory */ bw = g_new0(BrowserWindow, 1); - a_List_add(browser_window, num_bw, num_bw_max); browser_window[num_bw++] = bw; /* initialize nav_stack struct in browser_window struct */ a_Nav_init(bw); - bw->main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + if (!xid) + bw->main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + else + bw->main_window = gtk_plug_new(xid); gtk_window_set_policy(GTK_WINDOW(bw->main_window), TRUE, TRUE, FALSE); gtk_signal_connect(GTK_OBJECT(bw->main_window), "delete_event", diff -pru dillo/src/interface.h dillo-lfx/src/interface.h --- dillo/src/interface.h Tue Aug 6 17:24:42 2002 +++ dillo-lfx/src/interface.h Tue Aug 6 19:18:59 2002 @@ -28,7 +28,8 @@ gchar *a_Interface_get_location_text(Bro void a_Interface_reset_progress_bars(BrowserWindow *bw); void a_Interface_entry_open_url(GtkWidget *widget, BrowserWindow *bw); void a_Interface_set_cursor(BrowserWindow *bw, GdkCursorType CursorType); -BrowserWindow *a_Interface_browser_window_new(gint width, gint height); +BrowserWindow *a_Interface_browser_window_new(gint width, gint height, + guint32 xid); void a_Interface_set_button_sens(BrowserWindow *bw);