summaryrefslogtreecommitdiffabout
path: root/shared.c
authorLars Hjemli <hjemli@gmail.com>2008-02-23 21:45:33 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2008-03-18 07:13:10 (UTC)
commitb1f9b9c1459cb9a30ebf80721aff6ef788d1f891 (patch) (unidiff)
tree05796a741faef90c12aadd3a5c92b702ec870c48 /shared.c
parentb88fb016d0209f7041ac7d3b4d2c077318407a4d (diff)
downloadcgit-b1f9b9c1459cb9a30ebf80721aff6ef788d1f891.zip
cgit-b1f9b9c1459cb9a30ebf80721aff6ef788d1f891.tar.gz
cgit-b1f9b9c1459cb9a30ebf80721aff6ef788d1f891.tar.bz2
Introduce html.h
All html-functions can be quite easily separated from the rest of cgit, so lets do it; the only issue was html_filemode which uses some git-defined macros so the function is moved into ui-shared.c::cgit_print_filemode(). Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'shared.c') (more/less context) (ignore whitespace changes)
-rw-r--r--shared.c2
1 files changed, 0 insertions, 2 deletions
diff --git a/shared.c b/shared.c
index 808e674..76e10d0 100644
--- a/shared.c
+++ b/shared.c
@@ -1,82 +1,80 @@
1/* shared.c: global vars + some callback functions 1/* shared.c: global vars + some callback 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 10
11struct cgit_repolist cgit_repolist; 11struct cgit_repolist cgit_repolist;
12struct cgit_context ctx; 12struct cgit_context ctx;
13int cgit_cmd; 13int cgit_cmd;
14 14
15const char *cgit_version = CGIT_VERSION; 15const char *cgit_version = CGIT_VERSION;
16 16
17int htmlfd = 0;
18
19void cgit_prepare_context(struct cgit_context *ctx) 17void cgit_prepare_context(struct cgit_context *ctx)
20{ 18{
21 memset(ctx, 0, sizeof(ctx)); 19 memset(ctx, 0, sizeof(ctx));
22 ctx->cfg.agefile = "info/web/last-modified"; 20 ctx->cfg.agefile = "info/web/last-modified";
23 ctx->cfg.cache_dynamic_ttl = 5; 21 ctx->cfg.cache_dynamic_ttl = 5;
24 ctx->cfg.cache_max_create_time = 5; 22 ctx->cfg.cache_max_create_time = 5;
25 ctx->cfg.cache_repo_ttl = 5; 23 ctx->cfg.cache_repo_ttl = 5;
26 ctx->cfg.cache_root = CGIT_CACHE_ROOT; 24 ctx->cfg.cache_root = CGIT_CACHE_ROOT;
27 ctx->cfg.cache_root_ttl = 5; 25 ctx->cfg.cache_root_ttl = 5;
28 ctx->cfg.cache_static_ttl = -1; 26 ctx->cfg.cache_static_ttl = -1;
29 ctx->cfg.css = "/cgit.css"; 27 ctx->cfg.css = "/cgit.css";
30 ctx->cfg.logo = "/git-logo.png"; 28 ctx->cfg.logo = "/git-logo.png";
31 ctx->cfg.max_commit_count = 50; 29 ctx->cfg.max_commit_count = 50;
32 ctx->cfg.max_lock_attempts = 5; 30 ctx->cfg.max_lock_attempts = 5;
33 ctx->cfg.max_msg_len = 60; 31 ctx->cfg.max_msg_len = 60;
34 ctx->cfg.max_repodesc_len = 60; 32 ctx->cfg.max_repodesc_len = 60;
35 ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s"; 33 ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s";
36 ctx->cfg.renamelimit = -1; 34 ctx->cfg.renamelimit = -1;
37 ctx->cfg.robots = "index, nofollow"; 35 ctx->cfg.robots = "index, nofollow";
38 ctx->cfg.root_title = "Git repository browser"; 36 ctx->cfg.root_title = "Git repository browser";
39 ctx->cfg.script_name = CGIT_SCRIPT_NAME; 37 ctx->cfg.script_name = CGIT_SCRIPT_NAME;
40} 38}
41 39
42int cgit_get_cmd_index(const char *cmd) 40int cgit_get_cmd_index(const char *cmd)
43{ 41{
44 static char *cmds[] = {"log", "commit", "diff", "tree", "blob", 42 static char *cmds[] = {"log", "commit", "diff", "tree", "blob",
45 "snapshot", "tag", "refs", "patch", NULL}; 43 "snapshot", "tag", "refs", "patch", NULL};
46 int i; 44 int i;
47 45
48 for(i = 0; cmds[i]; i++) 46 for(i = 0; cmds[i]; i++)
49 if (!strcmp(cmd, cmds[i])) 47 if (!strcmp(cmd, cmds[i]))
50 return i + 1; 48 return i + 1;
51 return 0; 49 return 0;
52} 50}
53 51
54int chk_zero(int result, char *msg) 52int chk_zero(int result, char *msg)
55{ 53{
56 if (result != 0) 54 if (result != 0)
57 die("%s: %s", msg, strerror(errno)); 55 die("%s: %s", msg, strerror(errno));
58 return result; 56 return result;
59} 57}
60 58
61int chk_positive(int result, char *msg) 59int chk_positive(int result, char *msg)
62{ 60{
63 if (result <= 0) 61 if (result <= 0)
64 die("%s: %s", msg, strerror(errno)); 62 die("%s: %s", msg, strerror(errno));
65 return result; 63 return result;
66} 64}
67 65
68int chk_non_negative(int result, char *msg) 66int chk_non_negative(int result, char *msg)
69{ 67{
70 if (result < 0) 68 if (result < 0)
71 die("%s: %s",msg, strerror(errno)); 69 die("%s: %s",msg, strerror(errno));
72 return result; 70 return result;
73} 71}
74 72
75struct cgit_repo *add_repo(const char *url) 73struct cgit_repo *add_repo(const char *url)
76{ 74{
77 struct cgit_repo *ret; 75 struct cgit_repo *ret;
78 76
79 if (++cgit_repolist.count > cgit_repolist.length) { 77 if (++cgit_repolist.count > cgit_repolist.length) {
80 if (cgit_repolist.length == 0) 78 if (cgit_repolist.length == 0)
81 cgit_repolist.length = 8; 79 cgit_repolist.length = 8;
82 else 80 else