From e18b362dd2b30d7a1a41b074920a182d5f4f99c1 Mon Sep 17 00:00:00 2001 From: mbays Date: Sun, 7 Mar 2021 00:00:00 +0000 Subject: [PATCH] implement !restart, !nolink --- main.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 26daa9e..f30b419 100644 --- a/main.c +++ b/main.c @@ -31,6 +31,7 @@ typedef struct Child { pid_t pid; int in; int out; + bool nolink; } Child; typedef struct State { @@ -214,9 +215,28 @@ void respond(void *object, const Request_Info *request_info, int socket) put("\r\n"); put("# gemrepl meta commands\r\n"); put("=> ?!help !help: This help\r\n"); + put("=> ?!restart !restart: kill process and start again\r\n"); + put("=> ?!nolink !nolink: suppress input link\r\n"); + put("=> ?!showlink !showlink: show input link\r\n"); put("=> ?!? !?: Prompt for input\r\n"); put("=> ?!! !!: Literal '!'\r\n"); return; + } else if (0 == strncmp(q, "restart", strlen(q))) { + kill(child->pid, SIGKILL); + } else if (0 == strncmp(q, "nolink", strlen(q))) { + // TODO: might be better to have this be a permanent option + // attached to the cert rather than the child. + child->nolink = true; + put("20 text/gemini\r\n"); + put("Input links disabled.\r\n"); + put("=> ?!showlink re-enable\r\n"); + return; + } else if (0 == strncmp(q, "showlink", strlen(q))) { + child->nolink = false; + put("20 text/gemini\r\n"); + put("Input links enabled.\r\n"); + put("=> ?!? Input command\r\n"); + return; } else if (*q != '!') { put("40 Unknown gemrepl meta-command (use '!!' for a literal '!')\r\n"); return; @@ -224,7 +244,7 @@ void respond(void *object, const Request_Info *request_info, int socket) } put("20 text/gemini\r\n"); - put("=> ?!? Input command\r\n"); + if (!child->nolink) put("=> ?!? Input command\r\n"); kill(child->pid, SIGCONT); -- 2.11.4.GIT