From 2be78fb328da9e2e6714d73c9b0c90e6751aaa80 Mon Sep 17 00:00:00 2001 From: Julien Blanchard Date: Sun, 27 Dec 2020 15:43:22 +0000 Subject: [PATCH] Handle inputs --- README.md | 1 - castor.c | 34 ++++++++++++++++++++++++++-------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 4fa5dd6..d105bac 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,5 @@ Use the adress bar and right-mouse click to navigate. ## To Do: -- input type - TOFU - client certificates diff --git a/castor.c b/castor.c index 0f0802d..cc8d544 100644 --- a/castor.c +++ b/castor.c @@ -41,6 +41,7 @@ struct Hist int request(Url *u); void gemini_get(Url *u); +void gemini_put(Response *r); void texthit(Panel *p, int b, Rtext *t); void message(char *s, ...); @@ -75,13 +76,14 @@ char *menu3[] = { char* -replace_char(char* str, char find, char replace){ - char *current_pos = strchr(str,find); - while(current_pos){ - *current_pos = replace; - current_pos = strchr(current_pos,find); - } - return str; +replace_char(char* str, char find, char replace) +{ + char *current_pos = strchr(str,find); + while(current_pos){ + *current_pos = replace; + current_pos = strchr(current_pos,find); + } + return str; } char* @@ -389,7 +391,7 @@ gemini_get(Url *url) switch(r->status){ case 10: - message("Input! %s", r->meta); + gemini_put(r); break; case 11: message("Sensitive input! %s", r->meta); @@ -477,6 +479,22 @@ gemini_get(Url *url) } } +void +gemini_put(Response *r) +{ + char buf[1024]; + char *url; + strncpy(buf, "", sizeof(buf)-1); + if(eenter(r->meta, buf, sizeof(buf), mouse) <= 0){ + message("Castor9"); + return; + } + + url = smprint("%s?%s", r->url->raw, buf); + message("Castor9"); + gemini_get(urlparse(nil, url)); +} + void search(void) { -- 2.45.2