-rw-r--r-- | ui-shared.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/ui-shared.c b/ui-shared.c index cc1ab8b..2eff79d 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -1,25 +1,26 @@ | |||
1 | /* ui-shared.c: common web output functions | 1 | /* ui-shared.c: common web output functions |
2 | * | 2 | * |
3 | * Copyright (C) 2006 Lars Hjemli | 3 | * Copyright (C) 2006 Lars Hjemli |
4 | * | 4 | * |
5 | * Licensed under GNU General Public License v2 | 5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) | 6 | * (see COPYING for full license text) |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "cgit.h" | 9 | #include "cgit.h" |
10 | #include "html.h" | ||
10 | 11 | ||
11 | const char cgit_doctype[] = | 12 | const char cgit_doctype[] = |
12 | "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n" | 13 | "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n" |
13 | " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"; | 14 | " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"; |
14 | 15 | ||
15 | static char *http_date(time_t t) | 16 | static char *http_date(time_t t) |
16 | { | 17 | { |
17 | static char day[][4] = | 18 | static char day[][4] = |
18 | {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; | 19 | {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; |
19 | static char month[][4] = | 20 | static char month[][4] = |
20 | {"Jan", "Feb", "Mar", "Apr", "May", "Jun", | 21 | {"Jan", "Feb", "Mar", "Apr", "May", "Jun", |
21 | "Jul", "Aug", "Sep", "Oct", "Now", "Dec"}; | 22 | "Jul", "Aug", "Sep", "Oct", "Now", "Dec"}; |
22 | struct tm *tm = gmtime(&t); | 23 | struct tm *tm = gmtime(&t); |
23 | return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm->tm_wday], | 24 | return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm->tm_wday], |
24 | tm->tm_mday, month[tm->tm_mon], 1900+tm->tm_year, | 25 | tm->tm_mday, month[tm->tm_mon], 1900+tm->tm_year, |
25 | tm->tm_hour, tm->tm_min, tm->tm_sec); | 26 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
@@ -554,17 +555,32 @@ void cgit_print_pageheader(char *title, int show_search) | |||
554 | 555 | ||
555 | html("<td id='content'>\n"); | 556 | html("<td id='content'>\n"); |
556 | } | 557 | } |
557 | 558 | ||
558 | 559 | ||
559 | void cgit_print_snapshot_start(const char *mimetype, const char *filename, | 560 | void cgit_print_snapshot_start(const char *mimetype, const char *filename, |
560 | struct cacheitem *item) | 561 | struct cacheitem *item) |
561 | { | 562 | { |
562 | htmlf("Content-Type: %s\n", mimetype); | 563 | htmlf("Content-Type: %s\n", mimetype); |
563 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); | 564 | htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); |
564 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); | 565 | htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); |
565 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + | 566 | htmlf("Expires: %s\n", http_date(item->st.st_mtime + |
566 | ttl_seconds(item->ttl))); | 567 | ttl_seconds(item->ttl))); |
567 | html("\n"); | 568 | html("\n"); |
568 | } | 569 | } |
569 | 570 | ||
571 | void cgit_print_filemode(unsigned short mode) | ||
572 | { | ||
573 | if (S_ISDIR(mode)) | ||
574 | html("d"); | ||
575 | else if (S_ISLNK(mode)) | ||
576 | html("l"); | ||
577 | else if (S_ISGITLINK(mode)) | ||
578 | html("m"); | ||
579 | else | ||
580 | html("-"); | ||
581 | html_fileperm(mode >> 6); | ||
582 | html_fileperm(mode >> 3); | ||
583 | html_fileperm(mode); | ||
584 | } | ||
585 | |||
570 | /* vim:set sw=8: */ | 586 | /* vim:set sw=8: */ |