]> Pileus Git - ~andy/ct/blob - gallery/gallery.c
Adding gallery and reorganizing
[~andy/ct] / gallery / gallery.c
1 #include <glib.h>
2 #include "html.h"
3
4 const gchar *query_string;
5
6 void ct_init()
7 {
8         query_string = g_getenv("QUERY_STRING");
9 }
10
11 GList *read_dir(gchar *dirname)
12 {
13         GDir *dir = g_dir_open(dirname, 0, NULL);
14         const gchar *name = NULL;
15         GList *images = NULL;
16         while ((name = g_dir_read_name(dir)))
17                 images = g_list_prepend(images, (gchar*)name);
18         g_dir_close(dir);
19         return images;
20 }
21
22 int main()
23 {
24         ct_init();
25
26         header();
27         g_print("\n");
28
29         if (query_string == NULL)
30                 frame_index();
31         else if (g_str_equal(query_string, "noframe"))
32                 frame_nav(TRUE, read_dir("images"));
33         else if (g_str_equal(query_string, "nav"))
34                 frame_nav(FALSE, read_dir("images"));
35         else if (g_str_equal(query_string, "head"))
36                 frame_head();
37         else if (g_str_equal(query_string, "content"))
38                 frame_content();
39         else
40                 frame_index();
41 }