sacc

sacc(omys), simple console gopher client (mirror)
git clone https://git.parazyd.org/sacc
Log | Files | Refs | LICENSE

commit b9d624f390dec6bfa114e5c46292ab2ee4e0ece7
parent ddf996b8f35253bbb2509bff03e5c4e7cc056010
Author: Christoph Lohmann <20h@r-36.net>
Date:   Fri, 23 Feb 2018 14:45:06 +0100

Add telnet:// and tn3270:// support.

Diffstat:
Msacc.c | 23+++++++++++++++++++++++
Mui_ti.c | 8++++++++
Mui_txt.c | 8++++++++
3 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/sacc.c b/sacc.c @@ -590,6 +590,8 @@ cleanup: static int dig(Item *entry, Item *item) { + char *plumburi = NULL; + if (item->raw) /* already in cache */ return item->type; if (!item->entry) @@ -617,7 +619,24 @@ dig(Item *entry, Item *item) case '9': downloaditem(item); return 0; + case 'T': + if (asprintf(&plumburi, "tn3270://%s@%s:%s", item->selector, + item->host, item->port) < 0) { + return 0; + } + plumb(plumburi); + free(plumburi); + return 0; + case '8': + if (asprintf(&plumburi, "telnet://%s@%s:%s", item->selector, + item->host, item->port) < 0) { + return 0; + } + plumb(plumburi); + free(plumburi); + return 0; case 'g': + return 0; case 'I': plumbitem(item); return 0; @@ -675,6 +694,8 @@ searchitem(Item *entry, Item *item) static void printout(Item *hole) { + char *printuri = NULL; + if (!hole) return; @@ -716,9 +737,11 @@ delve(Item *hole) case '4': case '5': case '6': /* TODO decode? */ + case '8': case '9': case 'g': case 'I': + case 'T': dig(entry, hole); break; case 0: diff --git a/ui_ti.c b/ui_ti.c @@ -208,10 +208,18 @@ displayuri(Item *item) putp(tparm(cursor_address, lines-1, 0)); putp(tparm(enter_standout_mode)); switch (item->type) { + case '8': + n = snprintf(bufout, sizeof(bufout), "telnet://%s@%s:%s", + item->selector, item->host, item->port); + break; case 'h': n = snprintf(bufout, sizeof(bufout), "%s: %s", item->username, item->selector); break; + case 'T': + n = snprintf(bufout, sizeof(bufout), "tn3270://%s@%s:%s", + item->selector, item->host, item->port); + break; default: fmt = strcmp(item->port, "70") ? "%1$s: gopher://%2$s:%5$s/%3$c%4$s" : diff --git a/ui_txt.c b/ui_txt.c @@ -181,6 +181,10 @@ printuri(Item *item, size_t i) switch (item->type) { case 0: return; + case '8': + n = snprintf(bufout, sizeof(bufout), "telnet://%s@%s:%s", + item->selector, item->host, item->port); + break; case 'i': n = snprintf(bufout, sizeof(bufout), "%zu: %s", i, item->username); @@ -189,6 +193,10 @@ printuri(Item *item, size_t i) n = snprintf(bufout, sizeof(bufout), "%zu: %s: %s", i, item->username, item->selector); break; + case 'T': + n = snprintf(bufout, sizeof(bufout), "tn3270://%s@%s:%s", + item->selector, item->host, item->port); + break; default: fmt = strcmp(item->port, "70") ? "%1$zu: %2$s: gopher://%3$s:%6$s/%4$c%5$s" :