952, 954: Add ecmascript_{detach,moved}_form_state stubs
[elinks.git] / src / config / cmdline.c
blobff84dc5864e3e92e14083bb9f8a3e0265fd475fd
1 /* Command line processing */
3 #ifdef HAVE_CONFIG_H
4 #include "config.h"
5 #endif
7 #include <stdio.h>
8 #include <string.h>
9 #include <sys/types.h>
10 #ifdef HAVE_SYS_SOCKET_H
11 #include <sys/socket.h> /* OS/2 needs this after sys/types.h */
12 #endif
13 #include <sys/stat.h> /* OS/2 needs this after sys/types.h */
14 #ifdef HAVE_NETDB_H
15 #include <netdb.h>
16 #endif
18 /* We need to have it here. Stupid BSD. */
19 #ifdef HAVE_NETINET_IN_H
20 #include <netinet/in.h>
21 #endif
22 #ifdef HAVE_ARPA_INET_H
23 #include <arpa/inet.h>
24 #endif
26 #include "elinks.h"
28 #include "config/cmdline.h"
29 #include "config/conf.h"
30 #include "config/options.h"
31 #include "config/opttypes.h"
32 #include "intl/gettext/libintl.h"
33 #include "network/dns.h"
34 #include "protocol/uri.h"
35 #include "session/session.h"
36 #include "util/error.h"
37 #include "util/file.h"
38 #include "util/lists.h"
39 #include "util/memory.h"
40 #include "util/string.h"
43 /* Hack to handle URL extraction for -remote commands */
44 static unsigned char *remote_url;
46 static enum retval
47 parse_options_(int argc, unsigned char *argv[], struct option *opt,
48 LIST_OF(struct string_list_item) *url_list)
50 while (argc) {
51 argv++, argc--;
53 if (argv[-1][0] == '-' && argv[-1][1]) {
54 struct option *option;
55 unsigned char *argname = &argv[-1][1];
56 unsigned char *oname = stracpy(argname);
57 unsigned char *err;
59 if (!oname) continue;
61 /* Treat --foo same as -foo. */
62 if (argname[0] == '-') argname++;
64 option = get_opt_rec(opt, argname);
65 if (!option) option = get_opt_rec(opt, oname);
66 if (!option) {
67 unsigned char *pos;
69 oname++; /* the '-' */
70 /* Substitute '-' by '_'. This helps
71 * compatibility with that very wicked browser
72 * called 'lynx'. */
73 for (pos = strchr(oname, '_'); pos;
74 pos = strchr(pos, '_'))
75 *pos = '-';
76 option = get_opt_rec(opt, oname);
77 oname--;
80 mem_free(oname);
82 if (!option) goto unknown_option;
84 if (!option_types[option->type].cmdline)
85 goto unknown_option;
87 err = option_types[option->type].cmdline(option, &argv, &argc);
89 if (err) {
90 if (err[0]) {
91 usrerror(gettext("Cannot parse option %s: %s"), argv[-1], err);
93 return RET_SYNTAX;
96 /* XXX: Empty strings means all is well and have
97 * a cup of shut the fsck up. */
98 return RET_COMMAND;
100 } else if (remote_url) {
101 if (url_list) add_to_string_list(url_list, remote_url, -1);
102 mem_free(remote_url);
103 remote_url = NULL;
106 } else if (url_list) {
107 add_to_string_list(url_list, argv[-1], -1);
111 return RET_OK;
113 unknown_option:
114 usrerror(gettext("Unknown option %s"), argv[-1]);
115 return RET_SYNTAX;
118 enum retval
119 parse_options(int argc, unsigned char *argv[],
120 LIST_OF(struct string_list_item) *url_list)
122 return parse_options_(argc, argv, cmdline_options, url_list);
126 /**********************************************************************
127 Options handlers
128 **********************************************************************/
130 static unsigned char *
131 eval_cmd(struct option *o, unsigned char ***argv, int *argc)
133 if (*argc < 1) return gettext("Parameter expected");
135 (*argv)++; (*argc)--; /* Consume next argument */
137 parse_config_file(config_options, "-eval", *(*argv - 1), NULL, 0);
139 fflush(stdout);
141 return NULL;
144 static unsigned char *
145 forcehtml_cmd(struct option *o, unsigned char ***argv, int *argc)
147 safe_strncpy(get_opt_str("mime.default_type"), "text/html", MAX_STR_LEN);
148 return NULL;
151 static unsigned char *
152 lookup_cmd(struct option *o, unsigned char ***argv, int *argc)
154 struct sockaddr_storage *addrs = NULL;
155 int addrno, i;
157 if (!*argc) return gettext("Parameter expected");
158 if (*argc > 1) return gettext("Too many parameters");
160 (*argv)++; (*argc)--;
161 if (do_real_lookup(*(*argv - 1), &addrs, &addrno, 0) == DNS_ERROR) {
162 #ifdef HAVE_HERROR
163 herror(gettext("error"));
164 #else
165 usrerror(gettext("Host not found"));
166 #endif
167 return "";
170 for (i = 0; i < addrno; i++) {
171 #ifdef CONFIG_IPV6
172 struct sockaddr_in6 addr = *((struct sockaddr_in6 *) &(addrs)[i]);
173 unsigned char p[INET6_ADDRSTRLEN];
175 if (! inet_ntop(addr.sin6_family,
176 (addr.sin6_family == AF_INET6 ? (void *) &addr.sin6_addr
177 : (void *) &((struct sockaddr_in *) &addr)->sin_addr),
178 p, INET6_ADDRSTRLEN))
179 ERROR(gettext("Resolver error"));
180 else
181 printf("%s\n", p);
182 #else
183 struct sockaddr_in addr = *((struct sockaddr_in *) &(addrs)[i]);
184 unsigned char *p = (unsigned char *) &addr.sin_addr.s_addr;
186 printf("%d.%d.%d.%d\n", (int) p[0], (int) p[1],
187 (int) p[2], (int) p[3]);
188 #endif
191 mem_free_if(addrs);
193 fflush(stdout);
195 return "";
198 #define skipback_whitespace(start, S) \
199 while ((start) < (S) && isspace((S)[-1])) (S)--;
201 static unsigned char *
202 remote_cmd(struct option *o, unsigned char ***argv, int *argc)
204 struct {
205 unsigned char *name;
206 enum {
207 REMOTE_METHOD_OPENURL,
208 REMOTE_METHOD_PING,
209 REMOTE_METHOD_XFEDOCOMMAND,
210 REMOTE_METHOD_ADDBOOKMARK,
211 REMOTE_METHOD_INFOBOX,
212 REMOTE_METHOD_NOT_SUPPORTED,
213 } type;
214 } remote_methods[] = {
215 { "openURL", REMOTE_METHOD_OPENURL },
216 { "ping", REMOTE_METHOD_PING },
217 { "addBookmark", REMOTE_METHOD_ADDBOOKMARK },
218 { "infoBox", REMOTE_METHOD_INFOBOX },
219 { "xfeDoCommand", REMOTE_METHOD_XFEDOCOMMAND },
220 { NULL, REMOTE_METHOD_NOT_SUPPORTED },
222 unsigned char *command, *arg, *argend, *argstring;
223 int method, len = 0;
224 unsigned char *remote_argv[10];
225 int remote_argc;
227 if (*argc < 1) return gettext("Parameter expected");
229 command = *(*argv);
231 while (isasciialpha(command[len]))
232 len++;
234 /* Find the begining and end of the argument list. */
236 arg = command + len;
237 skip_space(arg);
239 argend = arg + strlen(arg);
240 skipback_whitespace(arg, argend);
241 if (argend > arg)
242 argend--;
244 /* Decide whether to use the "extended" --remote format where
245 * all URLs following should be opened in tabs. */
246 if (len == 0 || *arg != '(' || *argend != ')') {
247 /* Just open any passed URLs in new tabs */
248 remote_session_flags |= SES_REMOTE_NEW_TAB;
249 return NULL;
252 arg++;
254 arg = argstring = memacpy(arg, argend - arg);
255 if (!argstring)
256 return gettext("Out of memory");
258 remote_argc = 0;
259 do {
260 unsigned char *start, *end;
262 if (remote_argc > sizeof_array(remote_argv)) {
263 mem_free(argstring);
264 return gettext("Too many arguments");
267 /* Skip parenthesis, comma, and surrounding whitespace. */
268 skip_space(arg);
269 start = arg;
271 if (*start == '"') {
272 end = ++start;
273 while ((end = strchr(end, '"'))) {
274 /* Treat "" inside quoted arg as ". */
275 if (end[1] != '"')
276 break;
278 end += 2;
281 if (!end)
282 return gettext("Mismatched ending argument quoting");
284 arg = end + 1;
285 skip_space(arg);
286 if (*arg && *arg != ',')
287 return gettext("Garbage after quoted argument");
289 remote_argv[remote_argc++] = start;
290 *end = 0;
292 /* Unescape "" to ". */
293 for (end = start; *end; start++, end++) {
294 *start = *end;
295 if (*end == '"')
296 end++;
298 *start = 0;
300 } else {
301 end = strchr(start, ',');
302 if (!end) {
303 end = start + strlen(start);
304 arg = end;
305 } else {
306 arg = end + 1;
308 skipback_whitespace(start, end);
310 if (start != end)
311 remote_argv[remote_argc++] = start;
312 *end = 0;
315 if (*arg == ',')
316 arg++;
317 } while (*arg);
319 for (method = 0; remote_methods[method].name; method++) {
320 unsigned char *name = remote_methods[method].name;
322 if (!strlcasecmp(command, len, name, -1))
323 break;
326 switch (remote_methods[method].type) {
327 case REMOTE_METHOD_OPENURL:
328 if (remote_argc < 1) {
329 /* Prompt for a URL with a dialog box */
330 remote_session_flags |= SES_REMOTE_PROMPT_URL;
331 break;
334 if (remote_argc == 2) {
335 unsigned char *where = remote_argv[1];
337 if (strstr(where, "new-window")) {
338 remote_session_flags |= SES_REMOTE_NEW_WINDOW;
340 } else if (strstr(where, "new-tab")) {
341 remote_session_flags |= SES_REMOTE_NEW_TAB;
343 } else {
344 /* Bail out when getting unknown parameter */
345 /* TODO: new-screen */
346 break;
349 } else {
350 remote_session_flags |= SES_REMOTE_CURRENT_TAB;
353 remote_url = stracpy(remote_argv[0]);
354 break;
356 case REMOTE_METHOD_XFEDOCOMMAND:
357 if (remote_argc < 1)
358 break;
360 if (!strcasecmp(remote_argv[0], "openBrowser")) {
361 remote_session_flags = SES_REMOTE_NEW_WINDOW;
363 break;
365 case REMOTE_METHOD_PING:
366 remote_session_flags = SES_REMOTE_PING;
367 break;
369 case REMOTE_METHOD_ADDBOOKMARK:
370 if (remote_argc < 1)
371 break;
372 remote_url = stracpy(remote_argv[0]);
373 remote_session_flags = SES_REMOTE_ADD_BOOKMARK;
374 break;
376 case REMOTE_METHOD_INFOBOX:
377 if (remote_argc < 1)
378 break;
379 remote_url = stracpy(remote_argv[0]);
380 if (remote_url)
381 insert_in_string(&remote_url, 0, "about:", 6);
382 remote_session_flags = SES_REMOTE_INFO_BOX;
383 break;
385 case REMOTE_METHOD_NOT_SUPPORTED:
386 break;
389 mem_free(argstring);
391 /* If no flags was applied it can only mean we are dealing with
392 * unknown method. */
393 if (!remote_session_flags)
394 return gettext("Remote method not supported");
396 (*argv)++; (*argc)--; /* Consume next argument */
398 return NULL;
401 static unsigned char *
402 version_cmd(struct option *o, unsigned char ***argv, int *argc)
404 printf("%s\n", full_static_version);
405 fflush(stdout);
406 return "";
410 /* Below we handle help usage printing.
412 * We're trying to achieve several goals here:
414 * - Genericly define a function to print option trees iteratively.
415 * - Make output parsable for various doc tools (to make manpages).
416 * - Do some non generic fancy stuff like printing semi-aliased
417 * options (like: -?, -h and -help) on one line when printing
418 * short help. */
420 #define gettext_nonempty(x) (*(x) ? gettext(x) : (x))
422 static void print_full_help_outer(struct option *tree, unsigned char *path);
424 static void
425 print_full_help_inner(struct option *tree, unsigned char *path,
426 int trees)
428 struct option *option;
429 unsigned char saved[MAX_STR_LEN];
430 unsigned char *savedpos = saved;
432 *savedpos = 0;
434 foreach (option, *tree->value.tree) {
435 enum option_type type = option->type;
436 unsigned char *help;
437 unsigned char *capt = option->capt;
438 unsigned char *desc = (option->desc && *option->desc)
439 ? (unsigned char *) gettext(option->desc)
440 : (unsigned char *) "N/A";
442 if (trees != (type == OPT_TREE))
443 continue;
445 /* Don't print deprecated aliases (if we don't walk command
446 * line options which use aliases for legitimate options). */
447 if ((type == OPT_ALIAS && tree != cmdline_options)
448 || (option->flags & OPT_HIDDEN))
449 continue;
451 if (!capt && !strncasecmp(option->name, "_template_", 10))
452 capt = (unsigned char *) N_("Template option folder");
454 if (!capt) {
455 int len = strlen(option->name);
456 int max = MAX_STR_LEN - (savedpos - saved);
458 safe_strncpy(savedpos, option->name, max);
459 safe_strncpy(savedpos + len, ", -", max - len);
460 savedpos += len + 3;
461 continue;
464 help = gettext_nonempty(option_types[option->type].help_str);
466 if (type != OPT_TREE)
467 printf(" %s%s%s %s ",
468 path, saved, option->name, help);
470 /* Print the 'title' of each option type. */
471 switch (type) {
472 case OPT_BOOL:
473 case OPT_INT:
474 case OPT_LONG:
475 printf(gettext("(default: %ld)"),
476 type == OPT_LONG
477 ? option->value.big_number
478 : (long) option->value.number);
479 break;
481 case OPT_STRING:
482 printf(gettext("(default: \"%s\")"),
483 option->value.string);
484 break;
486 case OPT_ALIAS:
487 printf(gettext("(alias for %s)"),
488 option->value.string);
489 break;
491 case OPT_CODEPAGE:
492 printf(gettext("(default: %s)"),
493 get_cp_name(option->value.number));
494 break;
496 case OPT_COLOR:
498 color_T color = option->value.color;
499 unsigned char hexcolor[8];
501 printf(gettext("(default: %s)"),
502 get_color_string(color, hexcolor));
503 break;
506 case OPT_COMMAND:
507 break;
509 case OPT_LANGUAGE:
510 #ifdef CONFIG_NLS
511 printf(gettext("(default: \"%s\")"),
512 language_to_name(option->value.number));
513 #endif
514 break;
516 case OPT_TREE:
518 int pathlen = strlen(path);
519 int namelen = strlen(option->name);
521 if (pathlen + namelen + 2 > MAX_STR_LEN)
522 continue;
524 /* Append option name to path */
525 if (pathlen > 0) {
526 memcpy(saved, path, pathlen);
527 savedpos = saved + pathlen;
528 } else {
529 savedpos = saved;
531 memcpy(savedpos, option->name, namelen + 1);
532 savedpos += namelen;
534 capt = gettext_nonempty(capt);
535 printf(" %s: (%s)", capt, saved);
536 break;
540 printf("\n %8s", "");
542 int l = strlen(desc);
543 int i;
545 for (i = 0; i < l; i++) {
546 putchar(desc[i]);
548 if (desc[i] == '\n')
549 printf(" %8s", "");
552 printf("\n\n");
554 if (option->type == OPT_TREE) {
555 memcpy(savedpos, ".", 2);
556 print_full_help_outer(option, saved);
559 savedpos = saved;
560 *savedpos = 0;
564 static void
565 print_full_help_outer(struct option *tree, unsigned char *path)
567 print_full_help_inner(tree, path, 0);
568 print_full_help_inner(tree, path, 1);
571 static void
572 print_short_help(void)
574 #define ALIGN_WIDTH 20
575 struct option *option;
576 struct string string = NULL_STRING;
577 struct string *saved = NULL;
578 unsigned char align[ALIGN_WIDTH];
580 /* Initialize @space used to align captions. */
581 memset(align, ' ', sizeof(align) - 1);
582 align[sizeof(align) - 1] = 0;
584 foreach (option, *cmdline_options->value.tree) {
585 unsigned char *capt;
586 unsigned char *help;
587 unsigned char *info = saved ? saved->source
588 : (unsigned char *) "";
589 int len = strlen(option->name);
591 /* Avoid printing compatibility options */
592 if (option->flags & OPT_HIDDEN)
593 continue;
595 /* When no caption is available the option name is 'stacked'
596 * and the caption is shared with next options that has one. */
597 if (!option->capt) {
598 if (!saved) {
599 if (!init_string(&string))
600 continue;
602 saved = &string;
605 add_to_string(saved, option->name);
606 add_to_string(saved, ", -");
607 continue;
610 capt = gettext_nonempty(option->capt);
611 help = gettext_nonempty(option_types[option->type].help_str);
613 /* When @help string is non empty align at least one space. */
614 len = ALIGN_WIDTH - len - strlen(help);
615 len -= (saved ? saved->length : 0);
616 len = (len < 0) ? !!(*help) : len;
618 align[len] = '\0';
619 printf(" -%s%s %s%s%s\n",
620 info, option->name, help, align, capt);
621 align[len] = ' ';
622 if (saved) {
623 done_string(saved);
624 saved = NULL;
627 #undef ALIGN_WIDTH
630 #undef gettext_nonempty
632 static unsigned char *
633 printhelp_cmd(struct option *option, unsigned char ***argv, int *argc)
635 unsigned char *lineend = strchr(full_static_version, '\n');
637 if (lineend) *lineend = '\0';
639 printf("%s\n\n", full_static_version);
641 if (!strcmp(option->name, "config-help")) {
642 printf("%s:\n", gettext("Configuration options"));
643 print_full_help_outer(config_options, "");
644 } else {
645 printf("%s\n\n%s:\n",
646 gettext("Usage: elinks [OPTION]... [URL]..."),
647 gettext("Options"));
648 if (!strcmp(option->name, "long-help")) {
649 print_full_help_outer(cmdline_options, "-");
650 } else {
651 print_short_help();
655 fflush(stdout);
656 return "";
659 static unsigned char *
660 redir_cmd(struct option *option, unsigned char ***argv, int *argc)
662 unsigned char *target;
664 /* I can't get any dirtier. --pasky */
666 if (!strcmp(option->name, "confdir")) {
667 target = "config-dir";
668 } else if (!strcmp(option->name, "conffile")) {
669 target = "config-file";
670 } else if (!strcmp(option->name, "stdin")) {
671 static int complained;
673 if (complained)
674 return NULL;
675 complained = 1;
677 /* Emulate bool option, possibly eating following 0/1. */
678 if ((*argv)[0]
679 && ((*argv)[0][0] == '0' || (*argv)[0][0] == '1')
680 && !(*argv)[0][1])
681 (*argv)++, (*argc)--;
682 fprintf(stderr, "Warning: Deprecated option -stdin used!\n");
683 fprintf(stderr, "ELinks now determines the -stdin option value automatically.\n");
684 fprintf(stderr, "In the future versions ELinks will report error when you will\n");
685 fprintf(stderr, "continue to use this option.\a\n");
686 return NULL;
688 } else {
689 return gettext("Internal consistency error");
692 option = get_opt_rec(cmdline_options, target);
693 assert(option);
694 option_types[option->type].cmdline(option, argv, argc);
695 return NULL;
698 static unsigned char *
699 printconfigdump_cmd(struct option *option, unsigned char ***argv, int *argc)
701 unsigned char *config_string;
703 /* Print all. */
704 get_opt_int("config.saving_style") = 2;
706 config_string = create_config_string("", "", config_options);
707 if (config_string) {
708 printf("%s", config_string);
709 mem_free(config_string);
712 fflush(stdout);
713 return "";
717 /**********************************************************************
718 Options values
719 **********************************************************************/
721 /* Keep options in alphabetical order. */
723 struct option_info cmdline_options_info[] = {
724 /* [gettext_accelerator_context(IGNORE)] */
725 INIT_OPT_BOOL("", N_("Restrict to anonymous mode"),
726 "anonymous", 0, 0,
727 N_("Restricts ELinks so it can run on an anonymous account.\n"
728 "Local file browsing, downloads, and modification of options\n"
729 "will be disabled. Execution of viewers is allowed, but entries\n"
730 "in the association table can't be added or modified.")),
732 INIT_OPT_BOOL("", N_("Autosubmit first form"),
733 "auto-submit", 0, 0,
734 N_("Automatically submit the first form in the given URLs.")),
736 INIT_OPT_INT("", N_("Clone internal session with given ID"),
737 "base-session", 0, 0, INT_MAX, 0,
738 N_("Used internally when opening ELinks instances in new windows.\n"
739 "The ID maps to information that will be used when creating the\n"
740 "new instance. You don't want to use it.")),
742 INIT_OPT_COMMAND("", NULL, "confdir", OPT_HIDDEN, redir_cmd, NULL),
744 INIT_OPT_STRING("", N_("Name of directory with configuration file"),
745 "config-dir", 0, "",
746 N_("Path of the directory ELinks will read and write its\n"
747 "config and runtime state files to instead of ~/.elinks.\n"
748 "If the path does not begin with a '/' it is assumed to be\n"
749 "relative to your HOME directory.")),
751 INIT_OPT_COMMAND("", N_("Print default configuration file to stdout"),
752 "config-dump", 0, printconfigdump_cmd,
753 N_("Print a configuration file with options set to the built-in\n"
754 "defaults to stdout.")),
756 INIT_OPT_COMMAND("", NULL, "conffile", OPT_HIDDEN, redir_cmd, NULL),
758 INIT_OPT_STRING("", N_("Name of configuration file"),
759 "config-file", 0, "elinks.conf",
760 N_("Name of the configuration file that all configuration\n"
761 "options will be read from and written to. It should be\n"
762 "relative to config-dir.")),
764 INIT_OPT_COMMAND("", N_("Print help for configuration options"),
765 "config-help", 0, printhelp_cmd,
766 N_("Print help for configuration options and exit.")),
768 INIT_OPT_CMDALIAS("", N_("MIME type assumed for unknown document types"),
769 "default-mime-type", 0, "mime.default_type",
770 N_("The default MIME type used for documents of unknown type.")),
772 INIT_OPT_BOOL("", N_("Ignore user-defined keybindings"),
773 "default-keys", 0, 0,
774 N_("When set, all keybindings from configuration files will be\n"
775 "ignored. It forces use of default keybindings and will reset\n"
776 "user-defined ones on save.")),
778 INIT_OPT_BOOL("", N_("Print formatted versions of given URLs to stdout"),
779 "dump", 0, 0,
780 N_("Print formatted plain-text versions of given URLs to stdout.")),
782 INIT_OPT_CMDALIAS("", N_("Codepage to use with -dump"),
783 "dump-charset", 0, "document.dump.codepage",
784 N_("Codepage used when formatting dump output.")),
786 INIT_OPT_CMDALIAS("", N_("Color mode used with -dump"),
787 "dump-color-mode", 0, "document.dump.color_mode",
788 N_("Color mode used with -dump.")),
790 INIT_OPT_CMDALIAS("", N_("Width of document formatted with -dump"),
791 "dump-width", 0, "document.dump.width",
792 N_("Width of the dump output.")),
794 INIT_OPT_COMMAND("", N_("Evaluate configuration file directive"),
795 "eval", 0, eval_cmd,
796 N_("Specify configuration file directives on the command-line\n"
797 "which will be evaluated after all configuration files has been\n"
798 "read. Example usage:\n"
799 "\t-eval 'set protocol.file.allow_special_files = 1'")),
801 /* lynx compatibility */
802 INIT_OPT_COMMAND("", N_("Interpret documents of unknown types as HTML"),
803 "force-html", 0, forcehtml_cmd,
804 N_("Makes ELinks assume documents of unknown types are HTML.\n"
805 "Useful when using ELinks as an external viewer from MUAs.\n"
806 "This is equivalent to -default-mime-type text/html.")),
808 /* XXX: -?, -h and -help share the same caption and should be kept in
809 * the current order for usage help printing to be ok */
810 INIT_OPT_COMMAND("", NULL, "?", 0, printhelp_cmd, NULL),
812 INIT_OPT_COMMAND("", NULL, "h", 0, printhelp_cmd, NULL),
814 INIT_OPT_COMMAND("", N_("Print usage help and exit"),
815 "help", 0, printhelp_cmd,
816 N_("Print usage help and exit.")),
818 INIT_OPT_BOOL("", N_("Only permit local connections"),
819 "localhost", 0, 0,
820 N_("Restricts ELinks to work offline and only connect to servers\n"
821 "with local addresses (ie. 127.0.0.1). No connections to remote\n"
822 "servers will be permitted.")),
824 INIT_OPT_COMMAND("", N_("Print detailed usage help and exit"),
825 "long-help", 0, printhelp_cmd,
826 N_("Print detailed usage help and exit.")),
828 INIT_OPT_COMMAND("", N_("Look up specified host"),
829 "lookup", 0, lookup_cmd,
830 N_("Look up specified host and print all DNS resolved IP addresses.")),
832 INIT_OPT_BOOL("", N_("Run as separate instance"),
833 "no-connect", 0, 0,
834 N_("Run ELinks as a separate instance instead of connecting to an\n"
835 "existing instance. Note that normally no runtime state files\n"
836 "(bookmarks, history, etc.) are written to the disk when this\n"
837 "option is used. See also -touch-files.")),
839 INIT_OPT_BOOL("", N_("Disable use of files in ~/.elinks"),
840 "no-home", 0, 0,
841 N_("Disables creation and use of files in the user specific home\n"
842 "configuration directory (~/.elinks). It forces default configuration\n"
843 "values to be used and disables saving of runtime state files.")),
845 INIT_OPT_CMDALIAS("", N_("Disable link numbering in dump output"),
846 "no-numbering", OPT_ALIAS_NEGATE, "document.dump.numbering",
847 N_("Prevents printing of link number in dump output.\n"
848 "Note that this really affects only -dump, nothing else.")),
850 INIT_OPT_CMDALIAS("", N_("Disable printing of link references in dump output"),
851 "no-references", OPT_ALIAS_NEGATE, "document.dump.references",
852 N_("Prevents printing of references (URIs) of document links\n"
853 "in dump output.\n"
854 "Note that this really affects only -dump, nothing else.")),
856 INIT_OPT_COMMAND("", N_("Control an already running ELinks"),
857 "remote", 0, remote_cmd,
858 N_("Control a remote ELinks instance by passing commands to it.\n"
859 "The option takes an additional argument containing the method\n"
860 "which should be invoked and any parameters that should be passed\n"
861 "to it. For ease of use, the additional method argument can be\n"
862 "omitted in which case any URL arguments will be opened in new\n"
863 "tabs in the remote instance.\n"
864 "Following is a list of the supported methods:\n"
865 "\tping() : look for a remote instance\n"
866 "\topenURL() : prompt URL in current tab\n"
867 "\topenURL(URL) : open URL in current tab\n"
868 "\topenURL(URL, new-tab) : open URL in new tab\n"
869 "\topenURL(URL, new-window) : open URL in new window\n"
870 "\taddBookmark(URL) : bookmark URL\n"
871 "\tinfoBox(text) : show text in a message box\n"
872 "\txfeDoCommand(openBrowser) : open new window")),
874 INIT_OPT_INT("", N_("Connect to session ring with given ID"),
875 "session-ring", 0, 0, INT_MAX, 0,
876 N_("ID of session ring this ELinks session should connect to. ELinks\n"
877 "works in so-called session rings, whereby all instances of ELinks\n"
878 "are interconnected and share state (cache, bookmarks, cookies,\n"
879 "and so on). By default, all ELinks instances connect to session\n"
880 "ring 0. You can change that behaviour with this switch and form as\n"
881 "many session rings as you want. Obviously, if the session-ring with\n"
882 "this number doesn't exist yet, it's created and this ELinks instance\n"
883 "will become the master instance (that usually doesn't matter for you\n"
884 "as a user much). Note that you usually don't want to use this unless\n"
885 "you're a developer and you want to do some testing - if you want the\n"
886 "ELinks instances each running standalone, rather use the -no-connect\n"
887 "command-line option. Also note that normally no runtime state files\n"
888 "are written to the disk when this option is used. See also\n"
889 "-touch-files.")),
891 INIT_OPT_BOOL("", N_("Print the source of given URLs to stdout"),
892 "source", 0, 0,
893 N_("Print given URLs in source form to stdout.")),
895 INIT_OPT_COMMAND("", NULL, "stdin", OPT_HIDDEN, redir_cmd, NULL),
897 INIT_OPT_BOOL("", N_("Touch files in ~/.elinks when running with -no-connect/-session-ring"),
898 "touch-files", 0, 0,
899 N_("When enabled, runtime state files (bookmarks, history, etc.) are\n"
900 "written to disk, even when -no-connect or -session-ring is used.\n"
901 "The option has no effect if not used in conjunction with any of\n"
902 "these options.")),
904 INIT_OPT_INT("", N_("Verbose level"),
905 "verbose", 0, 0, VERBOSE_LEVELS - 1, VERBOSE_WARNINGS,
906 N_("The verbose level controls what messages are shown at\n"
907 "start up and while running:\n"
908 "\t0 means only show serious errors\n"
909 "\t1 means show serious errors and warnings\n"
910 "\t2 means show all messages")),
912 INIT_OPT_COMMAND("", N_("Print version information and exit"),
913 "version", 0, version_cmd,
914 N_("Print ELinks version information and exit.")),
916 NULL_OPTION_INFO,