cgo

[Fork] Gopher Client
git clone https://git.jojolepro.com/cgo.git
Log | Files | Refs | README | LICENSE

commit ee23ccb8de8bdd076dbe2c742a442823f711f85f
parent afd214694740f54904ffec2a37daa3458c6fe689
Author: Sebastian Steinhauer <s.steinhauer@yahoo.de>
Date:   Tue, 21 Oct 2014 00:05:23 +0200

Added telnet session pointer selector type

Diffstat:
Mcgo.c | 29+++++++++++++++++++++++++----
1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/cgo.c b/cgo.c @@ -33,6 +33,7 @@ #define CMD_IMAGE "display" #define CMD_BROWSER "firefox" #define CMD_PLAYER "mplayer" +#define CMD_TELNET "telnet" #define COLOR_PROMPT "1;34" #define COLOR_SELECTOR "1;32" #define HEAD_CHECK_LEN 5 @@ -377,6 +378,7 @@ void handle_directory_line(char *line) case '1': case '5': case '7': + case '8': case '9': case 'g': case 'I': @@ -401,6 +403,7 @@ int is_valid_directory_entry(const char *line) case '1': case '5': case '7': + case '8': case '9': case 'g': case 'I': @@ -469,6 +472,8 @@ void view_file(const char *cmd, const char *host, int status, i, j; char buffer[1024], *argv[32], *p; + printf("h(%s) p(%s) s(%s)\n", host, port, selector); + if (! download_temp(host, port, selector)) return; @@ -490,15 +495,28 @@ void view_file(const char *cmd, const char *host, pid = fork(); if (pid == 0) { if (execvp(argv[0], argv) == -1) - puts("error: execlp() failed!"); - } else if (pid == -1) { - puts("error: fork() failed"); - } + puts("error: execvp() failed!"); + } else if (pid == -1) puts("error: fork() failed"); sleep(1); /* to wait for browsers etc. that return immediatly */ waitpid(pid, &status, 0); unlink(tmpfilename); } +void view_telnet(const char *host, const char *port) +{ + pid_t pid; + int status; + + printf("executing: %s %s %s\n", CMD_TELNET, host, port); + pid = fork(); + if (pid == 0) { + if (execlp(CMD_TELNET, CMD_TELNET, host, port, NULL) == -1) + puts("error: execlp() failed!"); + } else if (pid == -1) puts("error: fork() failed!"); + waitpid(pid, &status, 0); + puts("(done)"); +} + void view_download(const char *host, const char *port, const char *selector) { int fd; @@ -615,6 +633,9 @@ int follow_link(int key) case '9': view_download(link->host, link->port, link->selector); break; + case '8': + view_telnet(link->host, link->port); + break; case 'g': case 'I': case 'p':