Mercurial > blahgd
changeset 16:03eead276f15
story: grab postid from PATH_INFO
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Wed, 04 Feb 2009 02:23:27 -0500 |
parents | d2628fb14ec6 |
children | 37f872a9cd36 |
files | story.c |
diffstat | 1 files changed, 11 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/story.c Wed Feb 04 02:16:03 2009 -0500 +++ b/story.c Wed Feb 04 02:23:27 2009 -0500 @@ -8,6 +8,7 @@ int main(int argc, char **argv) { + char *path_info; struct post post; int ret; @@ -15,9 +16,17 @@ fprintf(post.out, "Content-Type: text/html\n\n"); - ret = load_post(30, &post); + path_info = getenv("PATH_INFO"); + + if (!path_info) { + fprintf(post.out, "Invalid post #\n"); + return 0; + } + + ret = load_post(atoi(path_info+1), &post); if (ret) { - fprintf(post.out, "Gah! %d\n", ret); + fprintf(post.out, "Gah! %d (postid=%d)\n", ret, + atoi(path_info+1)); return 0; }