summaryrefslogtreecommitdiffabout
path: root/ui-shared.c
Unidiff
Diffstat (limited to 'ui-shared.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-shared.c16
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,21 +1,22 @@
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
11const char cgit_doctype[] = 12const 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
15static char *http_date(time_t t) 16static 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"};
@@ -558,13 +559,28 @@ void cgit_print_pageheader(char *title, int show_search)
558 559
559void cgit_print_snapshot_start(const char *mimetype, const char *filename, 560void 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
571void 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: */