summaryrefslogtreecommitdiffabout
path: root/ui-shared.c
authorDiego Ongaro <ongardie@gmail.com>2009-06-10 23:09:55 (UTC)
committer Diego Ongaro <ongardie@gmail.com>2009-06-11 05:00:35 (UTC)
commit87a89aed41136d388537b146000c4af6c1135a8c (patch) (side-by-side diff)
tree2c01ff09a613424ce526922cb130540a04f6ce9d /ui-shared.c
parent45e7fcecc1117440e6274ce3c6ab7d893c4986ee (diff)
downloadcgit-87a89aed41136d388537b146000c4af6c1135a8c.zip
cgit-87a89aed41136d388537b146000c4af6c1135a8c.tar.gz
cgit-87a89aed41136d388537b146000c4af6c1135a8c.tar.bz2
add cgit_httpscheme() -> http:// or https://
Diffstat (limited to 'ui-shared.c') (more/less context) (show whitespace changes)
-rw-r--r--ui-shared.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/ui-shared.c b/ui-shared.c
index de77bbf..749ea35 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -21,32 +21,43 @@ static char *http_date(time_t t)
static char month[][4] =
{"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Now", "Dec"};
struct tm *tm = gmtime(&t);
return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm->tm_wday],
tm->tm_mday, month[tm->tm_mon], 1900+tm->tm_year,
tm->tm_hour, tm->tm_min, tm->tm_sec);
}
void cgit_print_error(char *msg)
{
html("<div class='error'>");
html_txt(msg);
html("</div>\n");
}
+char *cgit_httpscheme()
+{
+ char *https;
+
+ https = getenv("HTTPS");
+ if (https != NULL && strcmp(https, "on") == 0)
+ return "https://";
+ else
+ return "http://";
+}
+
char *cgit_hosturl()
{
char *host, *port;
host = getenv("HTTP_HOST");
if (host) {
host = xstrdup(host);
} else {
host = getenv("SERVER_NAME");
if (!host)
return NULL;
port = getenv("SERVER_PORT");
if (port && atoi(port) != 80)
host = xstrdup(fmt("%s:%d", host, atoi(port)));
else
host = xstrdup(host);