36#include <FL/Fl_Window.H>
38#include <FL/fl_draw.H>
99 " -f, --fullwindow Start in full window mode: hide address bar,\n"
100 " navigation buttons, menu, and status bar."},
102 " -g, -geometry GEO Set initial window position where GEO is\n"
105 " -h, --help Display this help text and exit."},
107 " -l, --local Don't load images or stylesheets, or follow\n"
108 " redirections, for these FILEs or URLs."},
110 " -v, --version Display version info and exit."},
112 " -x, --xid XID Open first Dillo window in an existing\n"
113 " window whose window ID is XID."},
138 pid = waitpid(-1, &status, WNOHANG);
140 if (WIFEXITED(status))
141 printf(
"[dpid]: terminated normally (%d)\n", WEXITSTATUS(status));
142 else if (WIFSIGNALED(status))
143 printf(
"[dpid]: terminated by signal %d\n", WTERMSIG(status));
144 }
else if (pid == 0 || errno == ECHILD) {
170 struct sigaction sigact;
173 (void) sigemptyset(&set);
175 sigact.sa_mask = set;
176 sigact.sa_flags = SA_NOCLDSTOP;
177 if (sigaction(SIGCHLD, &sigact, NULL) == -1) {
183 perror(
"signal failed");
192 perror(
"signal failed");
202static void printHelp(
const char *cmdname,
const CLI_options *options)
204 printf(
"Usage: %s [OPTION]... [--] [URL|FILE]...\n"
205 "Options:\n", cmdname);
206 while (options && options->help) {
207 printf(
"%s\n", options->help);
210 printf(
" URL URL to browse.\n"
211 " FILE Local FILE to view.\n"
222 for (i = 0, max = 0; options[i].shortopt; i++)
223 if (abs(options[i].opt_argc) > max)
224 max = abs(options[i].opt_argc);
232 char **opt_argv,
int *idx)
234 typedef enum { O_SEARCH, O_FOUND, O_NOTFOUND, O_DONE } State;
237 State state = O_SEARCH;
243 for (i = 0; options[i].shortopt; i++) {
244 if (strcmp(options[i].shortopt, argv[*idx]) == 0 ||
245 strcmp(options[i].longopt, argv[*idx]) == 0) {
252 if (state == O_FOUND) {
253 int n_arg = options[i].opt_argc;
254 opt_id = options[i].id;
256 for (i = 0; *idx < argc && i < abs(n_arg) && argv[*idx][0] !=
'-'; i++)
257 opt_argv[i] = argv[(*idx)++];
262 fprintf(stderr,
"Option %s requires %d argument%s\n",
263 argv[*idx-i-1], n_arg, (n_arg == 1) ?
"" :
"s");
267 if (state == O_NOTFOUND) {
268 if (strcmp(argv[*idx],
"--") == 0)
270 else if (argv[*idx][0] ==
'-') {
271 fprintf(stderr,
"Command line option \"%s\" not recognized.\n",
286 const int interpret_symbols = 0;
288 fl_draw_shortcut = 0;
289 fl_font(o->font, o->size);
290 fl_color((Fl_Color)o->color);
291 fl_draw(o->value, X, Y, W,
H, align, o->image, interpret_symbols);
296 const int interpret_symbols = 0;
298 fl_draw_shortcut = 0;
299 fl_font(o->font, o->size);
300 fl_measure(o->value, W,
H, interpret_symbols);
306 const int interpret_symbols = 0;
308 fl_draw_shortcut = 1;
309 fl_font(o->font, o->size);
310 fl_color((Fl_Color)o->color);
311 fl_draw(o->value, X, Y, W,
H, align, o->image, interpret_symbols);
316 const int interpret_symbols = 0;
318 fl_draw_shortcut = 1;
319 fl_font(o->font, o->size);
320 fl_measure(o->value, W,
H, interpret_symbols);
326static void checkFont(
const char *name,
const char *type)
329 MSG_WARN(
"preferred %s font \"%s\" not found.\n", type, name);
348 Fl::set_color(idx, color << 8);
349 else if (default_val != 0xFFFFFFFF)
350 Fl::set_color(idx, default_val);
364 Fl::background(r, g, b);
370 fl_contrast(FL_SELECTION_COLOR, FL_BACKGROUND2_COLOR));
373 fl_lighter(FL_BACKGROUND_COLOR));
375 Fl::get_color(FL_BACKGROUND2_COLOR));
377 Fl::get_color(FL_BACKGROUND_COLOR));
379 Fl::get_color(FL_FOREGROUND_COLOR));
381 Fl::get_color(FL_FOREGROUND_COLOR));
393 p = (*str ==
'/') ?
dStrdup(str) :
396 if (access(p, F_OK) == 0) {
399 start_url =
a_Url_new(url_str + 1,
"file:/");
429 srand((
uint_t)(time(0) ^ getpid()));
432 signal(SIGPIPE, SIG_IGN);
439 options_got |= opt_id;
447 xid = strtol(opt_argv[0], &end, 0);
449 fprintf(stderr,
"XID argument \"%s\" not valid.\n",opt_argv[0]);
456 fprintf(stderr,
"geometry argument \"%s\" not valid. Must be of "
457 "the form WxH[{+-}X{+-}Y].\n", opt_argv[0]);
485 PrefsParser::parse(fp);
538 Fl_Window::default_xclass(
"dillo");
548 Fl::option(Fl::OPTION_SHOW_TOOLTIPS,
false);
561 Fl::set_font(FL_HELVETICA, defaultFont);
565 fl_message_title_default(
"Dillo: Message");
574 ((Fl_Widget *)bw->
ui)->window()->make_current();
582 MSG_WARN(
"Not using proxy authentication.\n");
599 for (
int i = idx; i < argc; i++) {
621 while (Fl::wait() > 0) {
654 MSG(
"Dillo: normal exit!\n");
void a_Actions_init(void)
void a_Auth_init(void)
Initialize the auth module.
void a_Bw_init(void)
Initialize global data.
void a_Cache_freeall(void)
Memory deallocator (only called at exit time)
void a_Capi_init(void)
Initialize capi&cache data.
static void parse(FILE *fp)
Parse the keysrc.
static void init()
Initialize the bindings list.
static void free()
Free data.
static void genAboutKeys(void)
static char * getOldWorkingDir(void)
Return the initial current working directory in a string.
static void init(void)
Changes current working directory to /tmp and creates ~/.dillo if not exists.
static FILE * getPrefsFP(const char *rcFile)
Examines the path for "rcFile" and assign its file pointer to "fp".
static void free(void)
Free memory.
static void init()
Create the user agent style.
static void setAdjustTableMinWidth(bool adjustTableMinWidth)
static void setStretchabilityFactor(int stretchabilityFactor)
static void setPenaltyHyphen(int penaltyHyphen)
static void setPenaltyEmDashLeft(int penaltyLeftEmDash)
static void setPenaltyHyphen2(int penaltyHyphen2)
static void setPenaltyEmDashRight2(int penaltyRightEmDash2)
static void setPenaltyEmDashRight(int penaltyRightEmDash)
static bool fontExists(const char *name)
static Fl_Font get(const char *name, int attrs)
void a_Dicache_init(void)
Initialize dicache data.
void a_Dicache_freeall(void)
Deallocate memory used by dicache module (Call this one at exit time, with no cache clients queued)
static void custLabelMeasure(const Fl_Label *o, int &W, int &H)
static volatile sig_atomic_t sig_exit
static void raw_sigchld2(int signum)
Avoid our children (Dpid) to become zombies.
static void est_sigchld(void)
Establish SIGCHLD handler.
static OptID getCmdOption(const CLI_options *options, int argc, char **argv, char **opt_argv, int *idx)
Get next command line option.
static const CLI_options Options[]
static void custLabelDraw(const Fl_Label *o, int X, int Y, int W, int H, Fl_Align align)
Set FL_NORMAL_LABEL to interpret neither symbols (@) nor shortcuts (&), and FL_FREE_LABELTYPE to inte...
static void handler_usr1(int signum)
static DilloUrl * makeStartUrl(char *str, bool local)
Given a command line argument, build a DilloUrl for it.
OptID
Command line options structure.
static void checkPreferredFonts()
static void printHelp(const char *cmdname, const CLI_options *options)
Print help text generated from the options structure.
static void checkFont(const char *name, const char *type)
Tell the user if default/pref fonts can't be found.
static void setUIColorWdef(Fl_Color idx, int32_t color, Fl_Color default_val)
Set UI color.
static volatile sig_atomic_t sig_reload
static void custMenuLabelMeasure(const Fl_Label *o, int &W, int &H)
static void custMenuLabelDraw(const Fl_Label *o, int X, int Y, int W, int H, Fl_Align align)
static void handler_usr2(int signum)
static int numOptions(const CLI_options *options)
Return the maximum number of option arguments.
char * dStrconcat(const char *s1,...)
Concatenate a NULL-terminated list of strings.
int dStrAsciiCasecmp(const char *s1, const char *s2)
void dLib_show_messages(bool_t show)
char * dStrdup(const char *s)
#define dNew0(type, count)
void a_Dns_init(void)
Initializer function.
void a_Dns_freeall(void)
Dns memory-deallocation.
void a_Domain_freeall(void)
void a_Domain_parse(FILE *fp)
Parse domainrc.
void a_History_freeall(void)
Free all the memory used by this module.
void a_Hsts_freeall(void)
void a_Hsts_init(FILE *preload_file)
void a_Http_set_proxy_passwd(const char *str)
Activate entered proxy password for HTTP.
int a_Http_init(void)
Initialize proxy vars and Accept-Language header.
void a_Http_freeall(void)
Deallocate memory used by http module.
int a_Http_proxy_auth(void)
Tell whether the proxy auth is already set (user:password).
void a_Mime_init(void)
Initializes Mime module and, sets the supported Mime types.
int a_Misc_parse_geometry(char *str, int *x, int *y, int *w, int *h)
Parse a geometry string.
char * a_Misc_escape_chars(const char *str, const char *esc_set)
Escape characters as XX sequences.
#define PATHS_HSTS_PRELOAD
DilloPrefs prefs
Global Data.
void a_Prefs_freeall(void)
memory-deallocation.
void a_Prefs_init(void)
Sets the default settings.
#define PREFS_GEOMETRY_DEFAULT_XPOS
#define PREFS_GEOMETRY_DEFAULT_YPOS
#define PREFS_GEOMETRY_DEFAULT_WIDTH
#define PREFS_UI_TAB_ACTIVE_BG_COLOR
#define PREFS_UI_TAB_ACTIVE_FG_COLOR
#define PREFS_UI_TAB_FG_COLOR
#define PREFS_UI_TAB_BG_COLOR
#define PREFS_UI_BUTTON_HIGHLIGHT_COLOR
#define PREFS_GEOMETRY_DEFAULT_HEIGHT
void a_Cookies_init(void)
Initialize the cookies module (The 'disabled' variable is writable only within a_Cookies_init)
void a_Cookies_freeall(void)
Flush cookies to disk and free all the memory allocated.
Contains the specific data for a single window.
void * ui
Pointer to the UI object this bw belongs to.
int32_t ui_button_highlight_color
int32_t ui_tab_active_bg_color
int32_t ui_selection_color
int penalty_em_dash_right
int32_t ui_tab_active_fg_color
bool_t adjust_table_min_width
int penalty_em_dash_right_2
int stretchability_factor
bool_t middle_click_opens_new_tab
void a_Tls_init(void)
Initialize TLS library.
void a_Tls_freeall(void)
Clean up the TLS library.
const char * a_UIcmd_get_passwd(const char *user)
void a_UIcmd_reload_all_active()
BrowserWindow * a_UIcmd_browser_window_new(int ww, int wh, uint32_t xid, const void *vbw)
void a_UIcmd_open_url_nw(BrowserWindow *bw, const DilloUrl *url)
void a_UIcmd_close_all_bw(void *force)
void a_UIcmd_open_url(BrowserWindow *bw, const DilloUrl *url)
void a_UIcmd_set_location_text(void *vbw, const char *text)
void a_UIcmd_open_url_nt(void *vbw, const DilloUrl *url, int focus)
char * a_Url_string_strip_delimiters(const char *str)
RFC-3986 suggests this stripping when "importing" URLs from other media.
void a_Url_set_flags(DilloUrl *u, int flags)
Set DilloUrl flags.
void a_Url_free(DilloUrl *url)
Free a DilloUrl.
DilloUrl * a_Url_new(const char *url_str, const char *base_url)
Transform (and resolve) an URL string into the respective DilloURL.
void a_Version_print_info(void)