ref: 2be78fb328da9e2e6714d73c9b0c90e6751aaa80
parent: 877421a1d364851d0a58e5e57b6e13b059db9e5d
author: Julien Blanchard <[email protected]>
date: Sun Dec 27 10:43:22 EST 2020
Handle inputs
--- a/README.md
+++ b/README.md
@@ -21,6 +21,5 @@
## To Do:
-- input type
- TOFU
- client certificates
--- a/castor.c
+++ b/castor.c
@@ -41,6 +41,7 @@
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*
-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 @@
switch(r->status){
case 10:
- message("Input! %s", r->meta);
+ gemini_put(r);
break;
case 11:
message("Sensitive input! %s", r->meta);
@@ -475,6 +477,22 @@
// message("Unknown status code %d!", status);
// break;
}
+}
+
+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