-struct repolist cgit_repolist;
-struct repoinfo *cgit_repo;
-
-char *cgit_root_title = "Git repository browser";
-char *cgit_css = "/cgit.css";
-char *cgit_logo = "/git-logo.png";
-char *cgit_logo_link = "http://www.kernel.org/pub/software/scm/git/docs/";
-char *cgit_module_link = "./?repo=%s&page=commit&id=%s";
-char *cgit_virtual_root = NULL;
-char *cgit_script_name = CGIT_SCRIPT_NAME;
-char *cgit_cache_root = "/var/cache/cgit";
-
-int cgit_nocache = 0;
-int cgit_snapshots = 0;
-int cgit_enable_log_filecount = 0;
-int cgit_enable_log_linecount = 0;
-int cgit_max_lock_attempts = 5;
-int cgit_cache_root_ttl = 5;
-int cgit_cache_repo_ttl = 5;
-int cgit_cache_dynamic_ttl = 5;
-int cgit_cache_static_ttl = -1;
-int cgit_cache_max_create_time = 5;
-
-int cgit_max_msg_len = 60;
-int cgit_max_repodesc_len = 60;
-int cgit_max_commit_count = 50;
-
-int cgit_query_has_symref = 0;
-int cgit_query_has_sha1 = 0;
-
-char *cgit_querystring = NULL;
-char *cgit_query_repo = NULL;
-char *cgit_query_page = NULL;
-char *cgit_query_head = NULL;
-char *cgit_query_search = NULL;
-char *cgit_query_sha1 = NULL;
-char *cgit_query_sha2 = NULL;
-char *cgit_query_path = NULL;
-char *cgit_query_name = NULL;
-int cgit_query_ofs = 0;
-
-int htmlfd = 0;
+struct cgit_repolist cgit_repolist;
+struct cgit_context ctx;
+int cgit_cmd;
+
+const char *cgit_version = CGIT_VERSION;
+
+void cgit_prepare_context(struct cgit_context *ctx)
+{
+ memset(ctx, 0, sizeof(ctx));
+ ctx->cfg.agefile = "info/web/last-modified";
+ ctx->cfg.cache_dynamic_ttl = 5;
+ ctx->cfg.cache_max_create_time = 5;
+ ctx->cfg.cache_repo_ttl = 5;
+ ctx->cfg.cache_root = CGIT_CACHE_ROOT;
+ ctx->cfg.cache_root_ttl = 5;
+ ctx->cfg.cache_static_ttl = -1;
+ ctx->cfg.css = "/cgit.css";
+ ctx->cfg.logo = "/git-logo.png";
+ ctx->cfg.max_commit_count = 50;
+ ctx->cfg.max_lock_attempts = 5;
+ ctx->cfg.max_msg_len = 60;
+ ctx->cfg.max_repodesc_len = 60;
+ ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s";
+ ctx->cfg.renamelimit = -1;
+ ctx->cfg.robots = "index, nofollow";
+ ctx->cfg.root_title = "Git repository browser";
+ ctx->cfg.script_name = CGIT_SCRIPT_NAME;
+ ctx->page.mimetype = "text/html";
+ ctx->page.charset = PAGE_ENCODING;
+ ctx->page.filename = NULL;
+}
+
+int cgit_get_cmd_index(const char *cmd)
+{
+ static char *cmds[] = {"log", "commit", "diff", "tree", "blob",
+ "snapshot", "tag", "refs", "patch", NULL};
+ int i;
+
+ for(i = 0; cmds[i]; i++)
+ if (!strcmp(cmd, cmds[i]))
+ return i + 1;
+ return 0;
+}