The union of the color and the node_number in the struct screen_char.
[elinks.git] / src / config / cmdline.c
blob3891b767898c97c538ca2f7b36b5ac456b58976b
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", NULL), "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 struct remote_method {
202 unsigned char *name;
203 enum {
204 REMOTE_METHOD_OPENURL,
205 REMOTE_METHOD_PING,
206 REMOTE_METHOD_XFEDOCOMMAND,
207 REMOTE_METHOD_ADDBOOKMARK,
208 REMOTE_METHOD_INFOBOX,
209 REMOTE_METHOD_NOT_SUPPORTED,
210 } type;
213 static unsigned char *
214 remote_cmd(struct option *o, unsigned char ***argv, int *argc)
216 struct remote_method remote_methods[] = {
217 { "openURL", REMOTE_METHOD_OPENURL },
218 { "ping", REMOTE_METHOD_PING },
219 { "addBookmark", REMOTE_METHOD_ADDBOOKMARK },
220 { "infoBox", REMOTE_METHOD_INFOBOX },
221 { "xfeDoCommand", REMOTE_METHOD_XFEDOCOMMAND },
222 { NULL, REMOTE_METHOD_NOT_SUPPORTED },
224 unsigned char *command, *arg, *argend, *argstring;
225 int method, len = 0;
226 unsigned char *remote_argv[10];
227 int remote_argc;
229 if (*argc < 1) return gettext("Parameter expected");
231 command = *(*argv);
233 while (isasciialpha(command[len]))
234 len++;
236 /* Find the begining and end of the argument list. */
238 arg = command + len;
239 skip_space(arg);
241 argend = arg + strlen(arg);
242 skipback_whitespace(arg, argend);
243 if (argend > arg)
244 argend--;
246 /* Decide whether to use the "extended" --remote format where
247 * all URLs following should be opened in tabs. */
248 if (len == 0 || *arg != '(' || *argend != ')') {
249 /* Just open any passed URLs in new tabs */
250 remote_session_flags |= SES_REMOTE_NEW_TAB;
251 return NULL;
254 arg++;
256 arg = argstring = memacpy(arg, argend - arg);
257 if (!argstring)
258 return gettext("Out of memory");
260 remote_argc = 0;
261 do {
262 unsigned char *start, *end;
264 if (remote_argc > sizeof_array(remote_argv)) {
265 mem_free(argstring);
266 return gettext("Too many arguments");
269 /* Skip parenthesis, comma, and surrounding whitespace. */
270 skip_space(arg);
271 start = arg;
273 if (*start == '"') {
274 end = ++start;
275 while ((end = strchr(end, '"'))) {
276 /* Treat "" inside quoted arg as ". */
277 if (end[1] != '"')
278 break;
280 end += 2;
283 if (!end)
284 return gettext("Mismatched ending argument quoting");
286 arg = end + 1;
287 skip_space(arg);
288 if (*arg && *arg != ',')
289 return gettext("Garbage after quoted argument");
291 remote_argv[remote_argc++] = start;
292 *end = 0;
294 /* Unescape "" to ". */
295 for (end = start; *end; start++, end++) {
296 *start = *end;
297 if (*end == '"')
298 end++;
300 *start = 0;
302 } else {
303 end = strchr(start, ',');
304 if (!end) {
305 end = start + strlen(start);
306 arg = end;
307 } else {
308 arg = end + 1;
310 skipback_whitespace(start, end);
312 if (start != end)
313 remote_argv[remote_argc++] = start;
314 *end = 0;
317 if (*arg == ',')
318 arg++;
319 } while (*arg);
321 for (method = 0; remote_methods[method].name; method++) {
322 unsigned char *name = remote_methods[method].name;
324 if (!c_strlcasecmp(command, len, name, -1))
325 break;
328 switch (remote_methods[method].type) {
329 case REMOTE_METHOD_OPENURL:
330 if (remote_argc < 1) {
331 /* Prompt for a URL with a dialog box */
332 remote_session_flags |= SES_REMOTE_PROMPT_URL;
333 break;
336 if (remote_argc == 2) {
337 unsigned char *where = remote_argv[1];
339 if (strstr(where, "new-window")) {
340 remote_session_flags |= SES_REMOTE_NEW_WINDOW;
342 } else if (strstr(where, "new-tab")) {
343 remote_session_flags |= SES_REMOTE_NEW_TAB;
345 } else {
346 /* Bail out when getting unknown parameter */
347 /* TODO: new-screen */
348 break;
351 } else {
352 remote_session_flags |= SES_REMOTE_CURRENT_TAB;
355 remote_url = stracpy(remote_argv[0]);
356 break;
358 case REMOTE_METHOD_XFEDOCOMMAND:
359 if (remote_argc < 1)
360 break;
362 if (!c_strcasecmp(remote_argv[0], "openBrowser")) {
363 remote_session_flags = SES_REMOTE_NEW_WINDOW;
365 break;
367 case REMOTE_METHOD_PING:
368 remote_session_flags = SES_REMOTE_PING;
369 break;
371 case REMOTE_METHOD_ADDBOOKMARK:
372 if (remote_argc < 1)
373 break;
374 remote_url = stracpy(remote_argv[0]);
375 remote_session_flags = SES_REMOTE_ADD_BOOKMARK;
376 break;
378 case REMOTE_METHOD_INFOBOX:
379 if (remote_argc < 1)
380 break;
381 remote_url = stracpy(remote_argv[0]);
382 if (remote_url)
383 insert_in_string(&remote_url, 0, "about:", 6);
384 remote_session_flags = SES_REMOTE_INFO_BOX;
385 break;
387 case REMOTE_METHOD_NOT_SUPPORTED:
388 break;
391 mem_free(argstring);
393 /* If no flags was applied it can only mean we are dealing with
394 * unknown method. */
395 if (!remote_session_flags)
396 return gettext("Remote method not supported");
398 (*argv)++; (*argc)--; /* Consume next argument */
400 return NULL;
403 static unsigned char *
404 version_cmd(struct option *o, unsigned char ***argv, int *argc)
406 printf("%s\n", full_static_version);
407 fflush(stdout);
408 return "";
412 /* Below we handle help usage printing.
414 * We're trying to achieve several goals here:
416 * - Genericly define a function to print option trees iteratively.
417 * - Make output parsable for various doc tools (to make manpages).
418 * - Do some non generic fancy stuff like printing semi-aliased
419 * options (like: -?, -h and -help) on one line when printing
420 * short help. */
422 #define gettext_nonempty(x) (*(x) ? gettext(x) : (x))
424 static void print_option_desc(const unsigned char *desc)
426 struct string wrapped;
427 static const struct string indent = INIT_STRING(" ", 12);
429 if (init_string(&wrapped)
430 && wrap_option_desc(&wrapped, desc, &indent, 79 - indent.length)) {
431 /* struct string could in principle contain null
432 * characters, so don't use printf() or fputs(). */
433 fwrite(wrapped.source, 1, wrapped.length, stdout);
434 } else {
435 /* Write the error to stderr so it appears on the
436 * screen even if stdout is being parsed by a script
437 * that reformats it to HTML or such. */
438 fprintf(stderr, "%12s%s\n", "",
439 gettext("Out of memory formatting option documentation"));
442 /* done_string() is safe even if init_string() failed. */
443 done_string(&wrapped);
446 static void print_full_help_outer(struct option *tree, unsigned char *path);
448 static void
449 print_full_help_inner(struct option *tree, unsigned char *path,
450 int trees)
452 struct option *option;
453 unsigned char saved[MAX_STR_LEN];
454 unsigned char *savedpos = saved;
456 *savedpos = 0;
458 foreach (option, *tree->value.tree) {
459 enum option_type type = option->type;
460 unsigned char *help;
461 unsigned char *capt = option->capt;
462 unsigned char *desc = (option->desc && *option->desc)
463 ? (unsigned char *) gettext(option->desc)
464 : (unsigned char *) "N/A";
466 if (trees != (type == OPT_TREE))
467 continue;
469 /* Don't print deprecated aliases (if we don't walk command
470 * line options which use aliases for legitimate options). */
471 if ((type == OPT_ALIAS && tree != cmdline_options)
472 || (option->flags & OPT_HIDDEN))
473 continue;
475 if (!capt && !c_strncasecmp(option->name, "_template_", 10))
476 capt = (unsigned char *) N_("Template option folder");
478 if (!capt) {
479 int len = strlen(option->name);
480 int max = MAX_STR_LEN - (savedpos - saved);
482 safe_strncpy(savedpos, option->name, max);
483 safe_strncpy(savedpos + len, ", -", max - len);
484 savedpos += len + 3;
485 continue;
488 help = gettext_nonempty(option_types[option->type].help_str);
490 if (type != OPT_TREE)
491 printf(" %s%s%s %s ",
492 path, saved, option->name, help);
494 /* Print the 'title' of each option type. */
495 switch (type) {
496 case OPT_BOOL:
497 case OPT_INT:
498 case OPT_LONG:
499 printf(gettext("(default: %ld)"),
500 type == OPT_LONG
501 ? option->value.big_number
502 : (long) option->value.number);
503 break;
505 case OPT_STRING:
506 printf(gettext("(default: \"%s\")"),
507 option->value.string);
508 break;
510 case OPT_ALIAS:
511 printf(gettext("(alias for %s)"),
512 option->value.string);
513 break;
515 case OPT_CODEPAGE:
516 printf(gettext("(default: %s)"),
517 get_cp_name(option->value.number));
518 break;
520 case OPT_COLOR:
522 color_T color = option->value.color;
523 unsigned char hexcolor[8];
525 printf(gettext("(default: %s)"),
526 get_color_string(color, hexcolor));
527 break;
530 case OPT_COMMAND:
531 break;
533 case OPT_LANGUAGE:
534 #ifdef CONFIG_NLS
535 printf(gettext("(default: \"%s\")"),
536 language_to_name(option->value.number));
537 #endif
538 break;
540 case OPT_TREE:
542 int pathlen = strlen(path);
543 int namelen = strlen(option->name);
545 if (pathlen + namelen + 2 > MAX_STR_LEN)
546 continue;
548 /* Append option name to path */
549 if (pathlen > 0) {
550 memcpy(saved, path, pathlen);
551 savedpos = saved + pathlen;
552 } else {
553 savedpos = saved;
555 memcpy(savedpos, option->name, namelen + 1);
556 savedpos += namelen;
558 capt = gettext_nonempty(capt);
559 printf(" %s: (%s)", capt, saved);
560 break;
564 putchar('\n');
565 print_option_desc(desc);
566 putchar('\n');
568 if (option->type == OPT_TREE) {
569 memcpy(savedpos, ".", 2);
570 print_full_help_outer(option, saved);
573 savedpos = saved;
574 *savedpos = 0;
578 static void
579 print_full_help_outer(struct option *tree, unsigned char *path)
581 print_full_help_inner(tree, path, 0);
582 print_full_help_inner(tree, path, 1);
585 static void
586 print_short_help(void)
588 #define ALIGN_WIDTH 20
589 struct option *option;
590 struct string string = NULL_STRING;
591 struct string *saved = NULL;
592 unsigned char align[ALIGN_WIDTH];
594 /* Initialize @space used to align captions. */
595 memset(align, ' ', sizeof(align) - 1);
596 align[sizeof(align) - 1] = 0;
598 foreach (option, *cmdline_options->value.tree) {
599 unsigned char *capt;
600 unsigned char *help;
601 unsigned char *info = saved ? saved->source
602 : (unsigned char *) "";
603 int len = strlen(option->name);
605 /* Avoid printing compatibility options */
606 if (option->flags & OPT_HIDDEN)
607 continue;
609 /* When no caption is available the option name is 'stacked'
610 * and the caption is shared with next options that has one. */
611 if (!option->capt) {
612 if (!saved) {
613 if (!init_string(&string))
614 continue;
616 saved = &string;
619 add_to_string(saved, option->name);
620 add_to_string(saved, ", -");
621 continue;
624 capt = gettext_nonempty(option->capt);
625 help = gettext_nonempty(option_types[option->type].help_str);
627 /* When @help string is non empty align at least one space. */
628 len = ALIGN_WIDTH - len - strlen(help);
629 len -= (saved ? saved->length : 0);
630 len = (len < 0) ? !!(*help) : len;
632 align[len] = '\0';
633 printf(" -%s%s %s%s%s\n",
634 info, option->name, help, align, capt);
635 align[len] = ' ';
636 if (saved) {
637 done_string(saved);
638 saved = NULL;
641 #undef ALIGN_WIDTH
644 #undef gettext_nonempty
646 static unsigned char *
647 printhelp_cmd(struct option *option, unsigned char ***argv, int *argc)
649 unsigned char *lineend = strchr(full_static_version, '\n');
651 if (lineend) *lineend = '\0';
653 printf("%s\n\n", full_static_version);
655 if (!strcmp(option->name, "config-help")) {
656 printf("%s:\n", gettext("Configuration options"));
657 print_full_help_outer(config_options, "");
658 } else {
659 printf("%s\n\n%s:\n",
660 gettext("Usage: elinks [OPTION]... [URL]..."),
661 gettext("Options"));
662 if (!strcmp(option->name, "long-help")) {
663 print_full_help_outer(cmdline_options, "-");
664 } else {
665 print_short_help();
669 fflush(stdout);
670 return "";
673 static unsigned char *
674 redir_cmd(struct option *option, unsigned char ***argv, int *argc)
676 unsigned char *target;
678 /* I can't get any dirtier. --pasky */
680 if (!strcmp(option->name, "confdir")) {
681 target = "config-dir";
682 } else if (!strcmp(option->name, "conffile")) {
683 target = "config-file";
684 } else if (!strcmp(option->name, "stdin")) {
685 static int complained;
687 if (complained)
688 return NULL;
689 complained = 1;
691 /* Emulate bool option, possibly eating following 0/1. */
692 if ((*argv)[0]
693 && ((*argv)[0][0] == '0' || (*argv)[0][0] == '1')
694 && !(*argv)[0][1])
695 (*argv)++, (*argc)--;
696 fprintf(stderr, "Warning: Deprecated option -stdin used!\n");
697 fprintf(stderr, "ELinks now determines the -stdin option value automatically.\n");
698 fprintf(stderr, "In the future versions ELinks will report error when you will\n");
699 fprintf(stderr, "continue to use this option.\a\n");
700 return NULL;
702 } else {
703 return gettext("Internal consistency error");
706 option = get_opt_rec(cmdline_options, target);
707 assert(option);
708 option_types[option->type].cmdline(option, argv, argc);
709 return NULL;
712 static unsigned char *
713 printconfigdump_cmd(struct option *option, unsigned char ***argv, int *argc)
715 unsigned char *config_string;
717 /* Print all. */
718 get_opt_int("config.saving_style", NULL) = 2;
720 config_string = create_config_string("", "");
721 if (config_string) {
722 printf("%s", config_string);
723 mem_free(config_string);
726 fflush(stdout);
727 return "";
731 /**********************************************************************
732 Options values
733 **********************************************************************/
735 /* Keep options in alphabetical order. */
737 struct option_info cmdline_options_info[] = {
738 /* [gettext_accelerator_context(IGNORE)] */
739 INIT_OPT_BOOL("", N_("Restrict to anonymous mode"),
740 "anonymous", 0, 0,
741 N_("Restricts ELinks so it can run on an anonymous account. "
742 "Local file browsing, downloads, and modification of options "
743 "will be disabled. Execution of viewers is allowed, but "
744 "entries in the association table can't be added or "
745 "modified.")),
747 INIT_OPT_BOOL("", N_("Autosubmit first form"),
748 "auto-submit", 0, 0,
749 N_("Automatically submit the first form in the given URLs.")),
751 INIT_OPT_INT("", N_("Clone internal session with given ID"),
752 "base-session", 0, 0, INT_MAX, 0,
753 N_("Used internally when opening ELinks instances in new "
754 "windows. The ID maps to information that will be used when "
755 "creating the new instance. You don't want to use it.")),
757 INIT_OPT_COMMAND("", NULL, "confdir", OPT_HIDDEN, redir_cmd, NULL),
759 INIT_OPT_STRING("", N_("Name of directory with configuration file"),
760 "config-dir", 0, "",
761 N_("Path of the directory ELinks will read and write its "
762 "config and runtime state files to instead of ~/.elinks. "
763 "If the path does not begin with a '/' it is assumed to be "
764 "relative to your HOME directory.")),
766 INIT_OPT_COMMAND("", N_("Print default configuration file to stdout"),
767 "config-dump", 0, printconfigdump_cmd,
768 N_("Print a configuration file with options set to the "
769 "built-in defaults to stdout.")),
771 INIT_OPT_COMMAND("", NULL, "conffile", OPT_HIDDEN, redir_cmd, NULL),
773 INIT_OPT_STRING("", N_("Name of configuration file"),
774 "config-file", 0, "elinks.conf",
775 N_("Name of the configuration file that all configuration "
776 "options will be read from and written to. It should be "
777 "relative to config-dir.")),
779 INIT_OPT_COMMAND("", N_("Print help for configuration options"),
780 "config-help", 0, printhelp_cmd,
781 N_("Print help for configuration options and exit.")),
783 INIT_OPT_CMDALIAS("", N_("MIME type assumed for unknown document types"),
784 "default-mime-type", 0, "mime.default_type",
785 N_("The default MIME type used for documents of unknown "
786 "type.")),
788 INIT_OPT_BOOL("", N_("Ignore user-defined keybindings"),
789 "default-keys", 0, 0,
790 N_("When set, all keybindings from configuration files will "
791 "be ignored. It forces use of default keybindings and will "
792 "reset user-defined ones on save.")),
794 INIT_OPT_BOOL("", N_("Print formatted versions of given URLs to stdout"),
795 "dump", 0, 0,
796 N_("Print formatted plain-text versions of given URLs to "
797 "stdout.")),
799 INIT_OPT_CMDALIAS("", N_("Codepage to use with -dump"),
800 "dump-charset", 0, "document.dump.codepage",
801 N_("Codepage used when formatting dump output.")),
803 INIT_OPT_CMDALIAS("", N_("Color mode used with -dump"),
804 "dump-color-mode", 0, "document.dump.color_mode",
805 N_("Color mode used with -dump.")),
807 INIT_OPT_CMDALIAS("", N_("Width of document formatted with -dump"),
808 "dump-width", 0, "document.dump.width",
809 N_("Width of the dump output.")),
811 INIT_OPT_COMMAND("", N_("Evaluate configuration file directive"),
812 "eval", 0, eval_cmd,
813 N_("Specify configuration file directives on the command-line "
814 "which will be evaluated after all configuration files has "
815 "been read. Example usage:\n"
816 "\t-eval 'set protocol.file.allow_special_files = 1'")),
818 /* lynx compatibility */
819 INIT_OPT_COMMAND("", N_("Interpret documents of unknown types as HTML"),
820 "force-html", 0, forcehtml_cmd,
821 N_("Makes ELinks assume documents of unknown types are HTML. "
822 "Useful when using ELinks as an external viewer from MUAs. "
823 "This is equivalent to -default-mime-type text/html.")),
825 /* XXX: -?, -h and -help share the same caption and should be kept in
826 * the current order for usage help printing to be ok */
827 INIT_OPT_COMMAND("", NULL, "?", 0, printhelp_cmd, NULL),
829 INIT_OPT_COMMAND("", NULL, "h", 0, printhelp_cmd, NULL),
831 INIT_OPT_COMMAND("", N_("Print usage help and exit"),
832 "help", 0, printhelp_cmd,
833 N_("Print usage help and exit.")),
835 INIT_OPT_BOOL("", N_("Only permit local connections"),
836 "localhost", 0, 0,
837 N_("Restricts ELinks to work offline and only connect to "
838 "servers with local addresses (ie. 127.0.0.1). No connections "
839 "to remote servers will be permitted.")),
841 INIT_OPT_COMMAND("", N_("Print detailed usage help and exit"),
842 "long-help", 0, printhelp_cmd,
843 N_("Print detailed usage help and exit.")),
845 INIT_OPT_COMMAND("", N_("Look up specified host"),
846 "lookup", 0, lookup_cmd,
847 N_("Look up specified host and print all DNS resolved IP "
848 "addresses.")),
850 INIT_OPT_BOOL("", N_("Run as separate instance"),
851 "no-connect", 0, 0,
852 N_("Run ELinks as a separate instance instead of connecting "
853 "to an existing instance. Note that normally no runtime state "
854 "files (bookmarks, history, etc.) are written to the disk "
855 "when this option is used. See also -touch-files.")),
857 INIT_OPT_BOOL("", N_("Disable use of files in ~/.elinks"),
858 "no-home", 0, 0,
859 N_("Disables creation and use of files in the user specific "
860 "home configuration directory (~/.elinks). It forces default "
861 "configuration values to be used and disables saving of "
862 "runtime state files.")),
864 INIT_OPT_CMDALIAS("", N_("Disable link numbering in dump output"),
865 "no-numbering", OPT_ALIAS_NEGATE, "document.dump.numbering",
866 N_("Prevents printing of link number in dump output.\n"
867 "\n"
868 "Note that this really affects only -dump, nothing else.")),
870 INIT_OPT_CMDALIAS("", N_("Disable printing of link references in dump output"),
871 "no-references", OPT_ALIAS_NEGATE, "document.dump.references",
872 N_("Prevents printing of references (URIs) of document links "
873 "in dump output.\n"
874 "\n"
875 "Note that this really affects only -dump, nothing else.")),
877 INIT_OPT_COMMAND("", N_("Control an already running ELinks"),
878 "remote", 0, remote_cmd,
879 N_("Control a remote ELinks instance by passing commands to "
880 "it. The option takes an additional argument containing the "
881 "method which should be invoked and any parameters that "
882 "should be passed to it. For ease of use, the additional "
883 "method argument can be omitted in which case any URL "
884 "arguments will be opened in new tabs in the remote "
885 "instance.\n"
886 "\n"
887 "Following is a list of the supported methods:\n"
888 "\tping() : look for a remote instance\n"
889 "\topenURL() : prompt URL in current tab\n"
890 "\topenURL(URL) : open URL in current tab\n"
891 "\topenURL(URL, new-tab) : open URL in new tab\n"
892 "\topenURL(URL, new-window) : open URL in new window\n"
893 "\taddBookmark(URL) : bookmark URL\n"
894 "\tinfoBox(text) : show text in a message box\n"
895 "\txfeDoCommand(openBrowser) : open new window")),
897 INIT_OPT_INT("", N_("Connect to session ring with given ID"),
898 "session-ring", 0, 0, INT_MAX, 0,
899 N_("ID of session ring this ELinks session should connect to. "
900 "ELinks works in so-called session rings, whereby all "
901 "instances of ELinks are interconnected and share state "
902 "(cache, bookmarks, cookies, and so on). By default, all "
903 "ELinks instances connect to session ring 0. You can change "
904 "that behaviour with this switch and form as many session "
905 "rings as you want. Obviously, if the session-ring with this "
906 "number doesn't exist yet, it's created and this ELinks "
907 "instance will become the master instance (that usually "
908 "doesn't matter for you as a user much).\n"
909 "\n"
910 "Note that you usually don't want to use this unless you're a "
911 "developer and you want to do some testing - if you want the "
912 "ELinks instances each running standalone, rather use the "
913 "-no-connect command-line option. Also note that normally no "
914 "runtime state files are written to the disk when this option "
915 "is used. See also -touch-files.")),
917 INIT_OPT_BOOL("", N_("Print the source of given URLs to stdout"),
918 "source", 0, 0,
919 N_("Print given URLs in source form to stdout.")),
921 INIT_OPT_COMMAND("", NULL, "stdin", OPT_HIDDEN, redir_cmd, NULL),
923 INIT_OPT_BOOL("", N_("Touch files in ~/.elinks when running with -no-connect/-session-ring"),
924 "touch-files", 0, 0,
925 N_("When enabled, runtime state files (bookmarks, history, "
926 "etc.) are written to disk, even when -no-connect or "
927 "-session-ring is used. The option has no effect if not used "
928 "in conjunction with any of these options.")),
930 INIT_OPT_INT("", N_("Verbose level"),
931 "verbose", 0, 0, VERBOSE_LEVELS - 1, VERBOSE_WARNINGS,
932 N_("The verbose level controls what messages are shown at "
933 "start up and while running:\n"
934 "\t0 means only show serious errors\n"
935 "\t1 means show serious errors and warnings\n"
936 "\t2 means show all messages")),
938 INIT_OPT_COMMAND("", N_("Print version information and exit"),
939 "version", 0, version_cmd,
940 N_("Print ELinks version information and exit.")),
942 NULL_OPTION_INFO,