]> gitweb.ps.run Git - ps-cgit/blobdiff - cgit.c
Integrate diffstat with diff
[ps-cgit] / cgit.c
diff --git a/cgit.c b/cgit.c
index b3dd1199c87baa72c5eec2de450f60bc8a90837e..38b0ba5d0616d29f291a9017ec59cac5522cf4ff 100644 (file)
--- a/cgit.c
+++ b/cgit.c
@@ -7,9 +7,14 @@
  */
 
 #include "cgit.h"
  */
 
 #include "cgit.h"
+#include "cache.h"
 #include "cmd.h"
 #include "cmd.h"
+#include "configfile.h"
+#include "html.h"
 #include "ui-shared.h"
 
 #include "ui-shared.h"
 
+const char *cgit_version = CGIT_VERSION;
+
 void config_cb(const char *name, const char *value)
 {
        if (!strcmp(name, "root-title"))
 void config_cb(const char *name, const char *value)
 {
        if (!strcmp(name, "root-title"))
@@ -100,7 +105,7 @@ void config_cb(const char *name, const char *value)
                else
                        ctx.repo->readme = xstrdup(fmt("%s/%s", ctx.repo->path, value));
        } else if (!strcmp(name, "include"))
                else
                        ctx.repo->readme = xstrdup(fmt("%s/%s", ctx.repo->path, value));
        } else if (!strcmp(name, "include"))
-               cgit_read_config(value, config_cb);
+               parse_configfile(value, config_cb);
 }
 
 static void querystring_cb(const char *name, const char *value)
 }
 
 static void querystring_cb(const char *name, const char *value)
@@ -174,12 +179,14 @@ static int cgit_prepare_cache(struct cacheitem *item)
        }
 
        if (!ctx.repo) {
        }
 
        if (!ctx.repo) {
-               item->name = xstrdup(fmt("%s/index.html", ctx.cfg.cache_root));
+               item->name = xstrdup(fmt("%s/index.%s.html",
+                                        ctx.cfg.cache_root,
+                                        cache_safe_filename(ctx.qry.raw)));
                item->ttl = ctx.cfg.cache_root_ttl;
                return 1;
        }
 
                item->ttl = ctx.cfg.cache_root_ttl;
                return 1;
        }
 
-       if (!cgit_cmd) {
+       if (!ctx.qry.page) {
                item->name = xstrdup(fmt("%s/%s/index.%s.html", ctx.cfg.cache_root,
                                         cache_safe_filename(ctx.repo->url),
                                         cache_safe_filename(ctx.qry.raw)));
                item->name = xstrdup(fmt("%s/%s/index.%s.html", ctx.cfg.cache_root,
                                         cache_safe_filename(ctx.repo->url),
                                         cache_safe_filename(ctx.qry.raw)));
@@ -433,14 +440,15 @@ int main(int argc, const char **argv)
        cgit_repolist.count = 0;
        cgit_repolist.repos = NULL;
 
        cgit_repolist.count = 0;
        cgit_repolist.repos = NULL;
 
-       cgit_read_config(cgit_config_env ? cgit_config_env : CGIT_CONFIG,
+       parse_configfile(cgit_config_env ? cgit_config_env : CGIT_CONFIG,
                         config_cb);
                         config_cb);
+       ctx.repo = NULL;
        if (getenv("SCRIPT_NAME"))
                ctx.cfg.script_name = xstrdup(getenv("SCRIPT_NAME"));
        if (getenv("QUERY_STRING"))
                ctx.qry.raw = xstrdup(getenv("QUERY_STRING"));
        cgit_parse_args(argc, argv);
        if (getenv("SCRIPT_NAME"))
                ctx.cfg.script_name = xstrdup(getenv("SCRIPT_NAME"));
        if (getenv("QUERY_STRING"))
                ctx.qry.raw = xstrdup(getenv("QUERY_STRING"));
        cgit_parse_args(argc, argv);
-       cgit_parse_query(ctx.qry.raw, querystring_cb);
+       http_parse_querystring(ctx.qry.raw, querystring_cb);
        if (!cgit_prepare_cache(&item))
                return 0;
        if (ctx.cfg.nocache) {
        if (!cgit_prepare_cache(&item))
                return 0;
        if (ctx.cfg.nocache) {