X-Git-Url: http://pileus.org/git/?p=~andy%2Faweather-web;a=blobdiff_plain;f=index.c;h=543b53eb729c5d0d7a7e17f070b7de705accc1aa;hp=b4a23af409fd1ffe7c67975dc2a6c820e04ddaf2;hb=2a1b9e35299ad8d2bb54882bcd5786953179af38;hpb=409fd833e63bde6da22bcf3a7eb4f16bb15d0fb1 diff --git a/index.c b/index.c index b4a23af..543b53e 100644 --- a/index.c +++ b/index.c @@ -1,4 +1,6 @@ -#include +#include +#include +#include #include "html.h" const char desc[] = @@ -10,6 +12,7 @@ const char desc[] = page_t header[] = { {"about", "About", print_about, 0.7, NULL}, {"news", "News", print_news, 0.3, NULL}, + {"manual", "Manual", print_manual, 0.5, NULL}, {"screenshots", "Screenshots", print_screenshots, 0.5, NULL}, {"download", "Download", print_download, 0.7, NULL}, {"development", "Development", print_development, 0.3, NULL}, @@ -26,19 +29,31 @@ page_t footer[] = { }; page_t special[] = { {"", NULL, print_index, 1.0, desc}, + {"oldnews", "Old News", print_oldnews, 0.2, NULL}, {NULL, "Not found", print_notfound, -1.0, NULL}, {NULL, NULL, NULL, 0.0, NULL}, }; const page_t *everything[] = {header, other, footer, special, NULL}; const page_t *index = &special[0]; -const page_t *notfound = &special[1]; +const page_t *notfound = &special[2]; + +/* Helper functions */ +void print_file(char *file) +{ + char data[512]; + FILE *fd = fopen(file, "r"); + while (!feof(fd)) { + size_t size = fread(data, 1, sizeof(data), fd); + fwrite(data, 1, size, stdout); + } +} /* Main */ int main(int argc, char **argv) { print_header(); - const gchar *name = g_getenv("PATH_INFO"); + const char *name = getenv("PATH_INFO"); if (name == NULL || name[0] == '\0' || name[1] == '\0') return print_page(index), 0; @@ -46,12 +61,12 @@ int main(int argc, char **argv) for (int i = 0; everything[i]; i++) for (int j = 0; everything[i][j].link; j++) { const page_t *page = &everything[i][j]; - if (g_str_equal(name+1, page->link)) + if (!strcmp(name+1, page->link)) return print_page(page), 0; } /* Print sitemap by itself */ - if (g_str_equal(name+1, "sitemap.xml")) + if (!strcmp(name+1, "sitemap.xml")) return print_sitemap(everything), 0; /* 404 */