+ char *fullpath, *slash;
+ size_t len;
+
+ fullpath = buildpath(base, baselen, path);
+ slash = (fullpath[0] == '/' ? "" : "/");
+ ctx.page.etag = oid_to_hex(oid);
+ cgit_print_http_headers();
+ htmlf("<html><head><title>%s", slash);
+ html_txt(fullpath);
+ htmlf("</title></head>\n<body>\n<h2>%s", slash);
+ html_txt(fullpath);
+ html("</h2>\n<ul>\n");
+ len = strlen(fullpath);
+ if (len > 1) {
+ fullpath[len - 1] = 0;
+ slash = strrchr(fullpath, '/');
+ if (slash)
+ *(slash + 1) = 0;
+ else {
+ free(fullpath);
+ fullpath = NULL;
+ }
+ html("<li>");
+ cgit_plain_link("../", NULL, NULL, ctx.qry.head, ctx.qry.oid,
+ fullpath);
+ html("</li>\n");
+ }
+ free(fullpath);
+}
+
+static void print_dir_entry(const struct object_id *oid, const char *base,
+ int baselen, const char *path, unsigned mode)
+{
+ char *fullpath;
+
+ fullpath = buildpath(base, baselen, path);
+ if (!S_ISDIR(mode) && !S_ISGITLINK(mode))
+ fullpath[strlen(fullpath) - 1] = 0;
+ html(" <li>");
+ if (S_ISGITLINK(mode)) {
+ cgit_submodule_link(NULL, fullpath, oid_to_hex(oid));
+ } else
+ cgit_plain_link(path, NULL, NULL, ctx.qry.head, ctx.qry.oid,
+ fullpath);
+ html("</li>\n");
+ free(fullpath);