diff options
author | John Ankarström <john@ankarstrom.se> | 2021-09-18 01:52:04 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-09-18 01:52:04 +0200 |
commit | 24bf14f6653ebf1c1ba79b9f212d35417bb6acbf (patch) | |
tree | 913a0f1bebf835a1109652b1c61d363972ee9a28 /ctl.c | |
parent | e25f56cbe86041d4ab19e474e38032fa7e681ac7 (diff) | |
download | cforum-24bf14f6653ebf1c1ba79b9f212d35417bb6acbf.tar.gz |
Implement attachments
Diffstat (limited to 'ctl.c')
-rw-r--r-- | ctl.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -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" |