diff options
Diffstat (limited to 'ctl.c')
-rw-r--r-- | ctl.c | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -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 |