1 /* cmd.c: the cgit command dispatcher
3 * Copyright (C) 2008 Lars Hjemli
5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text)
12 #include "ui-commit.h"
17 #include "ui-repolist.h"
18 #include "ui-snapshot.h"
19 #include "ui-summary.h"
23 static void about_fn(struct cgit_context *ctx)
26 cgit_print_repo_readme();
28 cgit_print_site_readme();
31 static void blob_fn(struct cgit_context *ctx)
33 cgit_print_blob(ctx->qry.sha1, ctx->qry.path);
36 static void commit_fn(struct cgit_context *ctx)
38 cgit_print_commit(ctx->qry.sha1);
41 static void diff_fn(struct cgit_context *ctx)
43 cgit_print_diff(ctx->qry.sha1, ctx->qry.sha2, ctx->qry.path);
46 static void repolist_fn(struct cgit_context *ctx)
48 cgit_print_repolist();
51 static void log_fn(struct cgit_context *ctx)
53 cgit_print_log(ctx->qry.sha1, ctx->qry.ofs, ctx->cfg.max_commit_count,
54 ctx->qry.grep, ctx->qry.search, ctx->qry.path, 1);
57 static void patch_fn(struct cgit_context *ctx)
59 cgit_print_patch(ctx->qry.sha1);
62 static void refs_fn(struct cgit_context *ctx)
67 static void snapshot_fn(struct cgit_context *ctx)
69 cgit_print_snapshot(ctx->qry.head, ctx->qry.sha1,
70 cgit_repobasename(ctx->repo->url), ctx->qry.path,
71 ctx->repo->snapshots);
74 static void summary_fn(struct cgit_context *ctx)
79 static void tag_fn(struct cgit_context *ctx)
81 cgit_print_tag(ctx->qry.sha1);
84 static void tree_fn(struct cgit_context *ctx)
86 cgit_print_tree(ctx->qry.sha1, ctx->qry.path);
89 #define def_cmd(name, want_repo, want_layout) \
90 {#name, name##_fn, want_repo, want_layout}
92 struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx)
94 static struct cgit_cmd cmds[] = {
97 def_cmd(commit, 1, 1),
100 def_cmd(patch, 1, 0),
102 def_cmd(repolist, 0, 0),
103 def_cmd(snapshot, 1, 0),
104 def_cmd(summary, 1, 1),
110 if (ctx->qry.page == NULL) {
112 ctx->qry.page = "summary";
114 ctx->qry.page = "repolist";
117 for(i = 0; i < sizeof(cmds)/sizeof(*cmds); i++)
118 if (!strcmp(ctx->qry.page, cmds[i].name))