links

lynx-like text mode web browser
git clone anongit@rnpnr.xyz:links.git
Log | Files | Refs | Feed | README | LICENSE

Commit: 02d1ec7ddcdb17a6b305cb77c51d865bbc93da28
Parent: 6c17bd32c92286e23d086bba91ecb2ca1ba72d18
Author: opask
Date:   Fri,  7 Sep 2018 14:23:28 -0600

add usage(); default.c: remove overlength string; update TODO

Diffstat:
MTODO | 2++
Mdefault.c | 436+------------------------------------------------------------------------------
Mlinks.h | 1+
Mmain.c | 25++++++++++++++-----------
4 files changed, 22 insertions(+), 442 deletions(-)

diff --git a/TODO b/TODO @@ -51,3 +51,5 @@ ever worked at all - not necessarily correct, however the code should be simplified to be more understandable. + +- add the most interesting options to usage(); diff --git a/default.c b/default.c @@ -70,13 +70,14 @@ static unsigned char *p_arse_options(int argc, unsigned char *argv[], struct opt if (options[i].rd_cmd && options[i].cmd_name && !casestrcmp(cast_uchar options[i].cmd_name, &argv[-1][1])) { if ((e = options[i].rd_cmd(&options[i], &argv, &argc))) { - if (e[0]) fprintf(stderr, "Error parsing option %s: %s\n", argv[-1], e); + if (e[0]) + usage(); return NULL; } goto found; } uu: - fprintf(stderr, "Unknown option %s\n", argv[-1]); + usage(); return NULL; } else if (!u) u = argv[-1]; else goto uu; @@ -959,435 +960,8 @@ static unsigned char *dump_cmd(struct option *o, unsigned char ***argv, int *arg static unsigned char *printhelp_cmd(struct option *o, unsigned char ***argv, int *argc) { -/* Changed and splited - translation is much easier. - * Print to stdout instead stderr (,,links -help | more'' - * is much better than ,,links -help 2>&1 | more''). - */ -fprintf(stdout, "%s%s%s%s%s%s\n", - -( -"links [options] URL\n" -"\n" -"Options are:\n" -"\n" -" -help\n" -" Prints this help screen\n" -"\n" -" -version\n" -" Prints the links version number and exit.\n" -"\n" -" -lookup <hostname>\n" -" Does name lookup, like command \"host\".\n" -"\n" -" -g\n" -" Run in graphics mode.\n" -"\n" -" -driver <driver name>\n" -" Graphics driver to use. Drivers are: x, svgalib, fb, directfb, pmshell,\n" -" atheos.\n" -" List of drivers will be shown if you give it an unknown driver.\n" -" Available drivers depend on your operating system and available libraries.\n" -"\n" -" -mode <graphics mode>\n" -" Graphics mode. For SVGALIB it is in format COLUMNSxROWSxCOLORS --\n" -" for example 640x480x256, 800x600x64k, 960x720x16M, 1024x768x16M32\n" -" List of modes will be shown if you give it an unknown videomode.\n" -" For framebuffer it is number of pixels in border --- LEFT,TOP,RIGHT,BOTTOM\n" -" other 3 values are optional --- i.e. -mode 10 will set all borders to 10,\n" -" -mode 10,20 will set left & right border to 10 and top & bottom to 20.\n" -" For Xwindow it is size of a window in format WIDTHxHEIGHT.\n" -"\n" -" -display <x-display>\n" -" Set Xwindow display.\n" -"\n" -" -force-html\n" -" Treat files with unknown type as html rather than text.\n" -" (can be toggled with '\\' key)\n" -"\n" -" -source <url>\n" -" Write unformatted data stream to stdout.\n" -"\n" -" -dump <url>\n" -" Write formatted document to stdout.\n" -"\n" -" -width <number>\n" -" For dump, document will be formatted to this screen width (but it can still\n" -" exceed it if lines can't be broken).\n" -"\n" -" -anonymous\n" -" Restrict links so that it can run on an anonymous account.\n" -" No local file browsing. No downloads. Executing viewers\n" -" is allowed, but user can't add or modify entries in\n" -" association table.\n" -"\n" -" -no-connect\n" -" Runs links as a separate instance - instead of connecting to\n" -" existing instance.\n" -"\n" -" -download-dir <path>\n" -" Default download directory.\n" -" (default: actual dir)\n" -"\n" -" -language <language>\n" -" Set user interface language.\n" -"\n" -" -max-connections <max>\n" -" Maximum number of concurrent connections.\n" -" (default: 10)\n" -"\n"),( -" -max-connections-to-host <max>\n" -" Maximum number of concurrent connection to a given host.\n" -" (default: 2)\n" -"\n" -" -retries <retry>\n" -" Number of retries.\n" -" (default: 3)\n" -"\n" -" -receive-timeout <sec>\n" -" Timeout on receive.\n" -" (default: 120)\n" -"\n"),( -" -unrestartable-receive-timeout <sec>\n" -" Timeout on non restartable connections.\n" -" (default: 600)\n" -"\n" -" -timeout-when-trying-multiple-addresses <sec>\n" -" Timeout for connection when trying multiple addresses.\n" -" (default: 3)\n" -"\n" -" -bind-address <ip address>\n" -" Use a specific local IP address.\n" -"\n" -" -bind-address-ipv6 <ipv6 address>\n" -" Use a specific local IPv6 address.\n" -"\n" -" -no-libevent\n" -" Don't use libevent library.\n" -"\n" -" -download-utime <0>/<1>\n" -" Set time of downloaded files to last modification time reported by server.\n" -"\n" -" -format-cache-size <num>\n" -" Number of formatted document pages cached.\n" -" (default: 5)\n" -"\n" -" -memory-cache-size <bytes>\n" -" Cache memory in bytes.\n" -" (default: 1048576)\n" -"\n" -" -image-cache-size <bytes>\n" -" Image cache in bytes.\n" -" (default: 1048576)\n" -"\n" -" -font-cache-size <bytes>\n" -" Font cache in bytes.\n" -" (default: 2097152)\n" -"\n" -" -aggressive-cache <0>/<1>\n" -" (default 1)\n" -" Always cache everything regardless of server's caching recomendations.\n" -" Many servers deny caching even if their content is not changing\n" -" just to get more hits and more money from ads.\n" -"\n"),( -" -address-preference <0>/<1>/<2>/<3>/<4>\n" -" (default 0)\n" -" 0 - use system default.\n" -" 1 - prefer IPv4.\n" -" 2 - prefer IPv6.\n" -" 3 - use only IPv4.\n" -" 4 - use only IPv6.\n" -"\n" -" -http-proxy <host:port>\n" -" Host and port number of the HTTP proxy, or blank.\n" -" (default: blank)\n" -"\n" -" -ftp-proxy <host:port>\n" -" Host and port number of the FTP proxy, or blank.\n" -" (default: blank)\n" -"\n" -" -https-proxy <host:port>\n" -" Host and port number of the HTTPS proxy, or blank.\n" -" (default: blank)\n" -"\n" -" -socks-proxy <user@host:port>\n" -" Userid, host and port of Socks4a, or blank.\n" -" (default: blank)\n" -"\n" -" -append-text-to-dns-lookups <text>\n" -" Append text to dns lookups. It is useful for specifying fixed\n" -" tor exit node.\n" -" (default: blank)\n" -"\n" -" -no-proxy-domains <domain,domain...>\n" -" No proxy for specified domains.\n" -" (default: blank)\n" -"\n" -" -only-proxies <0>/<1>\n" -" (default 0)\n" -" \"1\" causes that Links won't initiate any non-proxy connection.\n" -" It is useful for anonymization with tor or similar networks.\n" -"\n" -" -ssl.certificates <0>/<1>/<2>\n" -" (default 1)\n" -" 0 - ignore invalid certificate\n" -" 1 - warn on invalid certificate\n" -" 2 - reject invalid certificate\n" -"\n" -" -ssl.builtin-certificates <0>/<1>\n" -" (default 0)\n" -" Use built-in certificates instead of system certificates.\n" -"\n" -" -ssl.client-cert-key <filename>\n" -" Name of the PEM encoded file with the user private key\n" -" for client certificate authentication.\n" -"\n" -" -ssl.client-cert-crt <filename>\n" -" Name of the PEM encoded file with the user certificate\n" -" for client certificate authentication.\n" -"\n" -" -ssl.client-cert-password <text>\n" -" Password for the user private key.\n" -"\n"),( -" -http-bugs.http10 <0>/<1>\n" -" (default 0)\n" -" \"1\" forces using only HTTP/1.0 protocol. (useful for buggy servers\n" -" that claim to be HTTP/1.1 compliant but are not)\n" -" \"0\" use both HTTP/1.0 and HTTP/1.1.\n" -"\n" -" -http-bugs.allow-blacklist <0>/<1>\n" -" (default 1)\n" -" \"1\" defaults to using list of servers that have broken HTTP/1.1 support.\n" -" When links finds such server, it will retry the request with HTTP/1.0.\n" -"\n" -" -http-bugs.bug-302-redirect <0>/<1>\n" -" (default 1)\n" -" Process 302 redirect in a way that is incompatible with RFC1945 and RFC2068,\n" -" but the same as Netscape and MSIE. Many pages depend on it.\n" -"\n" -" -http-bugs.bug-post-no-keepalive <0>/<1>\n" -" (default 0)\n" -" No keepalive connection after post requests. For some buggy servers.\n" -"\n" -" -http-bugs.bug-no-accept-charset <0>/<1>\n" -" (default 0)\n" -" Do not send Accept-Charset field of HTTP header. Because it is too long\n" -" some servers will deny the request. Other servers will convert content\n" -" to plain ascii when Accept-Charset is missing.\n" -"\n" -" -http-bugs.no-compression <0>/<1>\n" -" (default 0)\n" -" \"1\" causes that links won't advertise HTTP compression support (but it\n" -" will still accept compressed data). Use it when you communicate with\n" -" server that has broken compression support.\n" -"\n" -" -http-bugs.retry-internal-errors <0>/<1>\n" -" (default 0)\n" -" Retry on internal server errors (50x).\n" -"\n" -" -http.fake-firefox <0>/<1>\n" -" (default 0)\n" -" Fake Firefox in the HTTP header.\n" -"\n" -" -http.fake-referer <string>\n" -" Fake referer value.\n" -"\n" -" -http.fake-user-agent <string>\n" -" Fake user agent value.\n" -"\n" -" -http.extra-header <string>\n" -" Extra string added to HTTP header.\n" -"\n" -" -ftp.anonymous-password <string>\n" -" Password for anonymous ftp access.\n" -"\n" -" -ftp.use-passive <0>/<1>\n" -" Use ftp PASV command to bypass firewalls.\n" -"\n" -" -ftp.use-eprt-epsv <0>/<1>\n" -" Use EPRT and EPSV commands instead of PORT and PASV.\n" -"\n" -" -ftp.fast <0>/<1>\n" -" Send more ftp commands simultaneously. Faster response when\n" -" browsing ftp directories, but it is incompatible with RFC\n" -" and some servers don't like it.\n" -"\n" -" -ftp.set-iptos <0>/<1>\n" -" Set IP Type-of-service to high throughput on ftp connections.\n" -"\n" -" -menu-font-size <size>\n" -" Size of font in menu.\n" -"\n" -" -menu-background-color 0xRRGGBB\n" -" Set menu background color in graphics mode, RRGGBB are hex.\n" -"\n" -" -menu-foreground-color 0xRRGGBB\n" -" Set menu foreground color in graphics mode.\n" -"\n" -" -scroll-bar-area-color 0xRRGGBB\n" -" Set color of scroll bar area.\n" -"\n" -" -scroll-bar-bar-color 0xRRGGBB\n" -" Set color of scroll bar.\n" -"\n" -" -scroll-bar-frame-color 0xRRGGBB\n" -" Set color of scroll bar frame.\n" -"\n" -" -bookmarks-file <file>\n" -" File to store bookmarks.\n" -"\n" -" -save-url-history <0>/<1>\n" -" Save URL history on exit.\n" -"\n" -" -display-red-gamma <fp-value>\n" -" Red gamma of display.\n" -" (default 2.2)\n" -"\n" -" -display-green-gamma <fp-value>\n" -" Green gamma of display.\n" -" (default 2.2)\n" -"\n" -" -display-blue-gamma <fp-value>\n" -" Blue gamma of display.\n" -" (default 2.2)\n" -"\n" -" -user-gamma <fp-value>\n" -" Additional gamma.\n" -" (default 1)\n" -"\n" -" -bfu-aspect <fp-value>\n" -" Display aspect ration.\n" -"\n" -" -dither-letters <0>/<1>\n" -" Do letter dithering.\n" -"\n" -" -dither-images <0>/<1>\n" -" Do image dithering.\n" -"\n" -" -display-optimize <0>/<1>/<2>\n" -" Optimize for CRT (0), LCD RGB (1), LCD BGR (2).\n" -"\n" -" -gamma-correction <0>/<1>/<2>\n" -" Type of gamma correction:\n" -" (default 2)\n" -" 0 - 8-bit (fast).\n" -" 1 - 16-bit (slow).\n" -" 2 - automatically detect according to speed of FPU.\n" -"\n" -" -overwrite-instead-of-scroll <0>/<1>\n" -" Overwrite the screen instead of scrolling it\n" -" (valid for svgalib and framebuffer).\n" -" Overwriting may or may not be faster, depending on hardware.\n" -"\n" -" -html-assume-codepage <codepage>\n" -" If server didn't specify document character set, assume this.\n" -"\n" -" -html-hard-assume <0>/<1>\n" -" Use always character set from \"-html-assume-codepage\" no matter\n" -" what server sent.\n" -"\n" -" -html-tables <0>/<1>\n" -" Render tables. (0) causes tables being rendered like in lynx.\n" -"\n" -" -html-frames <0>/<1>\n" -" Render frames. (0) causes frames rendered like in lynx.\n" -"\n" -" -html-break-long-lines <0>/<1>\n" -" Break long lines in <pre> sections.\n" -"\n" -" -html-images <0>/<1>\n" -" Display links to unnamed images as [IMG].\n" -"\n" -" -html-image-names <0>/<1>\n" -" Display filename of an image instead of [IMG].\n" -"\n" -" -html-display-images <0>/<1>\n" -" Display images in graphics mode.\n" -"\n" -" -html-image-scale <percent>\n" -" Scale images in graphics mode.\n" -"\n" -" -html-bare-image-autoscale <0>/<1>\n" -" Autoscale images displayed on full screen.\n" -"\n" -" -html-numbered-links <0>/<1>\n" -" Number links in text mode. Allow quick link selection by typing\n" -" link number and enter.\n" -"\n" -" -html-table-order <0>/<1>\n" -" In text mode, walk through table by rows (0) or columns (1).\n" -"\n" -" -html-auto-refresh <0>/<1>\n" -" Process refresh to other page (1), or display link to that page (0).\n" -"\n" -" -html-target-in-new-window <0>/<1>\n" -" Allow opening new windows from html.\n" -"\n" -" -html-margin <number of spaces>\n" -" Margin in text mode.\n" -"\n" -" -html-user-font-size <size>\n" -" Size of font on pages in graphics mode.\n" -"\n" -" -html-t-text-color <0>-<15>\n" -" Text color in text mode.\n" -"\n" -" -html-t-link-color <0>-<15>\n" -" Link color in text mode.\n" -"\n" -" -html-t-background-color <0>-<7>\n" -" Background color in text mode.\n" -"\n" -" -html-t-ignore-document-color <0>/<1>\n" -" Ignore colors specified in html document in text mode.\n" -"\n" -" -html-g-text-color 0xRRGGBB\n" -" Text color in graphics mode.\n" -"\n" -" -html-g-link-color 0xRRGGBB\n" -" Link color in graphics mode.\n" -"\n" -" -html-g-background-color 0xRRGGBB\n" -" Background color in graphics mode.\n" -"\n" -" -html-g-ignore-document-color <0>/<1>\n" -" Ignore colors specified in html document in graphics mode.\n" -"\n"),( -"Keys:\n" -" ESC display menu\n" -" ^C quit\n" -" ^P scroll up\n" -" ^N scroll down\n" -" [, ] scroll left, right\n" -" up, down select link\n" -" ->, enter follow link\n" -" <-, z go back\n" -" g go to url\n" -" G go to url based on current url\n" -" ^G go to url based on current link\n" -" ^R reload\n" -" / search\n" -" ? search back\n" -" n find next\n" -" N find previous\n" -" = document info\n" -" \\ document source\n" -" | HTTP header\n" -" * toggle displaying of image links (text mode)\n" -" d download\n" -" s bookmarks\n" -" q quit or close current window\n" -" ^X cut to clipboard\n" -" ^B copy to clipboard\n" -" ^V paste from clipboard\n" -" ^K cut line (in textarea) or text to the end (in field)\n" -" ^U cut all text before cursor\n" -" ^W autocomplete url\n" -" Alt-1 .. Alt-9\n" -" switch virtual screens (svgalib and framebuffer)\n" -)); - - fflush(stdout); - do_exit(RET_OK); + usage(); + /* FIXME: never reached */ return NULL; } diff --git a/links.h b/links.h @@ -137,6 +137,7 @@ extern int F; void die(const char *, ...); void *xmalloc(size_t); void *xrealloc(void *, size_t); +void usage(void); #define internal die #define error die #define fatal_exit die diff --git a/main.c b/main.c @@ -14,8 +14,15 @@ int retval = RET_OK; -static void unhandle_basic_signals(struct terminal *); +static void initialize_all_subsystems(void); +static void initialize_all_subsystems_2(void); static void poll_fg(void *); +static void unhandle_basic_signals(struct terminal *); + +static int init_b = 0; +int g_argc; +unsigned char *path_to_exe; +unsigned char **g_argv; void die(const char *errstr, ...) @@ -28,6 +35,12 @@ die(const char *errstr, ...) exit(1); } +void +usage(void) +{ + die("usage: %s [options] [url]\n", g_argv[0]); +} + void * xmalloc(size_t len) { @@ -300,16 +313,6 @@ static void end_dump(struct object_request *r, void *p) terminate_loop = 1; } -int g_argc; -unsigned char **g_argv; - -unsigned char *path_to_exe; - -static unsigned char init_b = 0; - -static void initialize_all_subsystems(void); -static void initialize_all_subsystems_2(void); - static void fixup_g(void) { if (ggr_drv[0] || ggr_mode[0] || force_g)