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 static void blob_fn(struct cgit_context *ctx)
14 cgit_print_blob(ctx->qry.sha1, ctx->qry.path);
17 static void commit_fn(struct cgit_context *ctx)
19 cgit_print_commit(ctx->qry.sha1);
22 static void diff_fn(struct cgit_context *ctx)
24 cgit_print_diff(ctx->qry.sha1, ctx->qry.sha2, ctx->qry.path);
27 static void repolist_fn(struct cgit_context *ctx)
29 cgit_print_repolist();
32 static void log_fn(struct cgit_context *ctx)
34 cgit_print_log(ctx->qry.sha1, ctx->qry.ofs, ctx->cfg.max_commit_count,
35 ctx->qry.grep, ctx->qry.search, ctx->qry.path, 1);
38 static void patch_fn(struct cgit_context *ctx)
40 cgit_print_patch(ctx->qry.sha1);
43 static void refs_fn(struct cgit_context *ctx)
48 static void snapshot_fn(struct cgit_context *ctx)
50 cgit_print_snapshot(ctx->qry.head, ctx->qry.sha1,
51 cgit_repobasename(ctx->repo->url), ctx->qry.path,
52 ctx->repo->snapshots);
55 static void summary_fn(struct cgit_context *ctx)
60 static void tag_fn(struct cgit_context *ctx)
62 cgit_print_tag(ctx->qry.sha1);
65 static void tree_fn(struct cgit_context *ctx)
67 cgit_print_tree(ctx->qry.sha1, ctx->qry.path);
70 #define def_cmd(name, want_repo, want_layout) \
71 {#name, name##_fn, want_repo, want_layout}
73 struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx)
75 static struct cgit_cmd cmds[] = {
77 def_cmd(commit, 1, 1),
82 def_cmd(repolist, 0, 0),
83 def_cmd(snapshot, 1, 0),
84 def_cmd(summary, 1, 1),
90 if (ctx->qry.page == NULL) {
92 ctx->qry.page = "summary";
94 ctx->qry.page = "repolist";
97 for(i = 0; i < sizeof(cmds)/sizeof(*cmds); i++)
98 if (!strcmp(ctx->qry.page, cmds[i].name))