Command Line Options in Dillo

Main
Status | About | Download

Status

Dillo version 0.7.0 has integrated an (internally) improved version of this patch, so it is not needed anymore.

About

These patches are proposals for a simple and extensible command line options support in Dillo.

The patches come with two command line options -v and -h to display version number and a short help message. The options are to be passed before any URL or filename. As a by-product of this patch, it is now possible to call Dillo with more than one URL/filename. In that case, more than one window will be opened.

Download

2002-08-13

This newer patch improves the older in different ways:
  • The patch does not need getopt() anymore. A custom function was created. It aims to be flexible and robust;
  • An option must have two different syntaxes, generally a short and a long variant (resp. DilloCLIOptions.sh_opt and DilloCLIOptions.lg_opt);
  • An option can have any number of arguments. If its arguments are optional (not mandatory), the number of the maximal optional arguments must be included as its opposite (negative) value in DilloCLIOptions.opt_argc;
  • The list of arguments of an options is returned in an array of strings. The list is ended with NULL. This array should be NULL when passed to the parsing function for the first time. This function takes care of the allocation and deallocation of that array;
  • The help text is created automatically: the options structure now includes a help string (DilloCLIOptions.help);
  • The use of "--" to delimit the options arguments from the URL/FILE argument is now supported. This is for the cases where the local file begins with "-";
  • The DilloCLIOptions.opt_flg is now mandatory as it is the value that is returned by the parsing function. This flag is ORed in cli_options to remember all the passed options outside the parse loop;
  • GTK+ is now initialized before the options parsing but it will not abort immediately if it fails. This allows to pass GTK+ options (--gtk-module, --g-fatal-warnings and eventually --gtk-debug). If the display cannot be initialised, a warning is issued then the command options are nevertheless parsed and finally Dillo aborts afterwards. This permits to implement options that do not need the GUI while allowing the parsing of GTK+ options that Dillo does not need to take care of;
The patch is to be found here: dillo-cvs-2002-08-13-cli.patch. The new options are -v, --version, -h and --help.

2002-08-06

This patch is based on the getopt() function found in unistd.h. It supports only short options, as the long options function getopt_long() is a GNU extension and is thus not portable. Though, it could be easily added. The command line options are parsed before any serious initialisation (even before display initialisation). Some #defines define the help message that need to be updated when adding a new option, the string of all known options. Some other define a flag for each option. These flags will be ORed and stored in an integer to remember later all the options found. See the 2002-08-06 patches of local, fullwindow and embeddedable Dillo for their usage. They are not really used in this patch, but they are included for consistency. Get the patch from here: dillo-cvs-2002-08-06-cli.patch

From within dillo directory, apply with patch -p0 < dillo-cvs-2002-08-06-cli.patch. Then build Dillo as usual. The new options are -h and -v and the URLs and file names are to be given after the options.

Valid HTML 4.01!