summaryrefslogtreecommitdiff
path: root/blog.c
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-07-17 21:25:15 -0400
committerJakob Kaivo <jkk@ung.org>2019-07-17 21:25:15 -0400
commit4de3158c80864aa130ac6f701f4c28a2aa7bbf20 (patch)
tree649e2a229576d36ad56d9602a4a9dfdeab1cc29a /blog.c
parent2bc5ce287a9f15af8e299138f85e2a286708313b (diff)
move HTTP POST handling to separate file
Diffstat (limited to 'blog.c')
-rw-r--r--blog.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/blog.c b/blog.c
index d3c8e49..4c7f3db 100644
--- a/blog.c
+++ b/blog.c
@@ -1,14 +1,34 @@
+#define _XOPEN_SOURCE 700
#include <stdio.h>
#include <stdlib.h>
-#include <errno.h>
#include <string.h>
+#include "blog.h"
extern char **environ;
+int verify_creds(const char *username, const char *password)
+{
+ printf("verifying '%s'/'%s'\n", username ? username : "", password ? password : "");
+ return 1;
+}
+
int handle_post(void)
{
- printf("Status: 301 Found\r\n");
- printf("Location: http%s://%s%s\r\n\r\n", getenv("HTTPS") ? "s" : "", getenv("HTTP_HOST"), getenv("DOCUMENT_URI"));
+
+ //printf("Status: 301 Found\r\n");
+ //printf("Location: http%s://%s%s\r\n\r\n", getenv("HTTPS") ? "s" : "", getenv("HTTP_HOST"), getenv("DOCUMENT_URI"));
+
+ printf("Status: 200 OK\r\n");
+ printf("Content-Type: text/plain\r\n\r\n");
+
+ read_post_data();
+ if (!verify_creds(find_post_data("username"), find_post_data("password"))) {
+ // handle invalid login
+ }
+
+ for (char **e = environ; e && *e; e++) {
+ puts(*e);
+ }
return 0;
}
@@ -51,11 +71,11 @@ int main(void)
puts("<input type=\"submit\">");
puts("</form>");
- puts("<pre>");
+ puts("<!--");
for (char **e = environ; e && *e; e++) {
puts(*e);
}
- puts("</pre>");
+ puts("-->");
puts("</body>");
puts("</html>");