aboutsummaryrefslogtreecommitdiff
path: root/ctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'ctl.c')
-rw-r--r--ctl.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/ctl.c b/ctl.c
index 773e4f6..fbc9e63 100644
--- a/ctl.c
+++ b/ctl.c
@@ -22,12 +22,18 @@ void
showfront()
{
char *title;
+ sqlite3_stmt *stmt;
+
+ if(sqlite3_prepare(db,
+ "SELECT oid, * from posts ORDER BY created DESC",
+ -1, &stmt, 0) != SQLITE_OK){
+ srverr("Could not retrieve posts");
+ return;
+ }
title = site.name;
printf("Content-Type: text/html\n\n");
- #include "t/head.tc"
#include "t/front.tc"
- #include "t/foot.tc"
}
void
@@ -37,21 +43,19 @@ showpost(int id)
struct post *post;
struct user *user;
- if(!(post = getpost(id))){
+ if(!(post = getpost(byid("posts", id), 1))){
srverr("Could not retrieve post");
return;
}
- if(!(user = getuser(post->user))){
+ if(!(user = getuser(byid("users", post->user), 1))){
srverr("Could not retrieve post author");
return;
}
title = site.name;
printf("Content-Type: text/html\n\n");
- #include "t/head.tc"
#include "t/post.tc"
- #include "t/foot.tc"
}
void
@@ -60,15 +64,13 @@ showuser(int id)
char s[128], *title;
struct user *user;
- if(!(user = getuser(id))){
+ if(!(user = getuser(byid("users", id), 1))){
srverr("Could not retrieve user");
return;
}
title = site.name;
printf("Content-Type: text/html\n\n");
- #include "t/head.tc"
#include "t/user.tc"
- #include "t/foot.tc"
free(user);
} \ No newline at end of file