aboutsummaryrefslogtreecommitdiff
path: root/ctl.c
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-09-18 01:52:04 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-09-18 01:52:04 +0200
commit24bf14f6653ebf1c1ba79b9f212d35417bb6acbf (patch)
tree913a0f1bebf835a1109652b1c61d363972ee9a28 /ctl.c
parente25f56cbe86041d4ab19e474e38032fa7e681ac7 (diff)
downloadcforum-24bf14f6653ebf1c1ba79b9f212d35417bb6acbf.tar.gz
Implement attachments
Diffstat (limited to 'ctl.c')
-rw-r--r--ctl.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/ctl.c b/ctl.c
index fbc9e63..51809db 100644
--- a/ctl.c
+++ b/ctl.c
@@ -19,6 +19,20 @@ printdate(int timestamp)
}
void
+showattachment(id)
+{
+ struct attachment *attachment;
+
+ if(!(attachment = getattachment(byid("attachments", id), 1))){
+ srverr("Could not retrieve attachment");
+ return;
+ }
+
+ printf("Content-Type: %s\n\n", attachment->mime);
+ printf("%.*s", attachment->bytes, attachment->data);
+}
+
+void
showfront()
{
char *title;
@@ -42,6 +56,7 @@ showpost(int id)
char *title;
struct post *post;
struct user *user;
+ sqlite3_stmt *stmt;
if(!(post = getpost(byid("posts", id), 1))){
srverr("Could not retrieve post");
@@ -53,6 +68,8 @@ showpost(int id)
return;
}
+ stmt = byid("attachments", id);
+
title = site.name;
printf("Content-Type: text/html\n\n");
#include "t/post.tc"