summaryrefslogtreecommitdiffabout
path: root/cmd.c
authorLars Hjemli <hjemli@gmail.com>2008-03-24 15:38:47 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2008-03-24 15:38:47 (UTC)
commitc5984a9896b39748e61daf6e620483749654b102 (patch) (unidiff)
tree5576deee2c5bcc92ae85ab07af215295c52d4143 /cmd.c
parentf34478cbe0214a201e7ecef3e79ed6c957b7beee (diff)
downloadcgit-c5984a9896b39748e61daf6e620483749654b102.zip
cgit-c5984a9896b39748e61daf6e620483749654b102.tar.gz
cgit-c5984a9896b39748e61daf6e620483749654b102.tar.bz2
Add separate header-files for each page/view
Yet another step towards removing cgit.h. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'cmd.c') (more/less context) (ignore whitespace changes)
-rw-r--r--cmd.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/cmd.c b/cmd.c
index 489a11c..e0eacbe 100644
--- a/cmd.c
+++ b/cmd.c
@@ -1,101 +1,112 @@
1/* cmd.c: the cgit command dispatcher 1/* cmd.c: the cgit command dispatcher
2 * 2 *
3 * Copyright (C) 2008 Lars Hjemli 3 * Copyright (C) 2008 Lars Hjemli
4 * 4 *
5 * Licensed under GNU General Public License v2 5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text) 6 * (see COPYING for full license text)
7 */ 7 */
8 8
9#include "cgit.h" 9#include "cgit.h"
10#include "cmd.h" 10#include "cmd.h"
11#include "ui-blob.h"
12#include "ui-commit.h"
13#include "ui-diff.h"
14#include "ui-log.h"
15#include "ui-patch.h"
16#include "ui-refs.h"
17#include "ui-repolist.h"
18#include "ui-snapshot.h"
19#include "ui-summary.h"
20#include "ui-tag.h"
21#include "ui-tree.h"
11 22
12static void blob_fn(struct cgit_context *ctx) 23static void blob_fn(struct cgit_context *ctx)
13{ 24{
14 cgit_print_blob(ctx->qry.sha1, ctx->qry.path); 25 cgit_print_blob(ctx->qry.sha1, ctx->qry.path);
15} 26}
16 27
17static void commit_fn(struct cgit_context *ctx) 28static void commit_fn(struct cgit_context *ctx)
18{ 29{
19 cgit_print_commit(ctx->qry.sha1); 30 cgit_print_commit(ctx->qry.sha1);
20} 31}
21 32
22static void diff_fn(struct cgit_context *ctx) 33static void diff_fn(struct cgit_context *ctx)
23{ 34{
24 cgit_print_diff(ctx->qry.sha1, ctx->qry.sha2, ctx->qry.path); 35 cgit_print_diff(ctx->qry.sha1, ctx->qry.sha2, ctx->qry.path);
25} 36}
26 37
27static void repolist_fn(struct cgit_context *ctx) 38static void repolist_fn(struct cgit_context *ctx)
28{ 39{
29 cgit_print_repolist(); 40 cgit_print_repolist();
30} 41}
31 42
32static void log_fn(struct cgit_context *ctx) 43static void log_fn(struct cgit_context *ctx)
33{ 44{
34 cgit_print_log(ctx->qry.sha1, ctx->qry.ofs, ctx->cfg.max_commit_count, 45 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); 46 ctx->qry.grep, ctx->qry.search, ctx->qry.path, 1);
36} 47}
37 48
38static void patch_fn(struct cgit_context *ctx) 49static void patch_fn(struct cgit_context *ctx)
39{ 50{
40 cgit_print_patch(ctx->qry.sha1); 51 cgit_print_patch(ctx->qry.sha1);
41} 52}
42 53
43static void refs_fn(struct cgit_context *ctx) 54static void refs_fn(struct cgit_context *ctx)
44{ 55{
45 cgit_print_refs(); 56 cgit_print_refs();
46} 57}
47 58
48static void snapshot_fn(struct cgit_context *ctx) 59static void snapshot_fn(struct cgit_context *ctx)
49{ 60{
50 cgit_print_snapshot(ctx->qry.head, ctx->qry.sha1, 61 cgit_print_snapshot(ctx->qry.head, ctx->qry.sha1,
51 cgit_repobasename(ctx->repo->url), ctx->qry.path, 62 cgit_repobasename(ctx->repo->url), ctx->qry.path,
52 ctx->repo->snapshots); 63 ctx->repo->snapshots);
53} 64}
54 65
55static void summary_fn(struct cgit_context *ctx) 66static void summary_fn(struct cgit_context *ctx)
56{ 67{
57 cgit_print_summary(); 68 cgit_print_summary();
58} 69}
59 70
60static void tag_fn(struct cgit_context *ctx) 71static void tag_fn(struct cgit_context *ctx)
61{ 72{
62 cgit_print_tag(ctx->qry.sha1); 73 cgit_print_tag(ctx->qry.sha1);
63} 74}
64 75
65static void tree_fn(struct cgit_context *ctx) 76static void tree_fn(struct cgit_context *ctx)
66{ 77{
67 cgit_print_tree(ctx->qry.sha1, ctx->qry.path); 78 cgit_print_tree(ctx->qry.sha1, ctx->qry.path);
68} 79}
69 80
70#define def_cmd(name, want_repo, want_layout) \ 81#define def_cmd(name, want_repo, want_layout) \
71 {#name, name##_fn, want_repo, want_layout} 82 {#name, name##_fn, want_repo, want_layout}
72 83
73struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx) 84struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx)
74{ 85{
75 static struct cgit_cmd cmds[] = { 86 static struct cgit_cmd cmds[] = {
76 def_cmd(blob, 1, 0), 87 def_cmd(blob, 1, 0),
77 def_cmd(commit, 1, 1), 88 def_cmd(commit, 1, 1),
78 def_cmd(diff, 1, 1), 89 def_cmd(diff, 1, 1),
79 def_cmd(log, 1, 1), 90 def_cmd(log, 1, 1),
80 def_cmd(patch, 1, 0), 91 def_cmd(patch, 1, 0),
81 def_cmd(refs, 1, 1), 92 def_cmd(refs, 1, 1),
82 def_cmd(repolist, 0, 0), 93 def_cmd(repolist, 0, 0),
83 def_cmd(snapshot, 1, 0), 94 def_cmd(snapshot, 1, 0),
84 def_cmd(summary, 1, 1), 95 def_cmd(summary, 1, 1),
85 def_cmd(tag, 1, 1), 96 def_cmd(tag, 1, 1),
86 def_cmd(tree, 1, 1), 97 def_cmd(tree, 1, 1),
87 }; 98 };
88 int i; 99 int i;
89 100
90 if (ctx->qry.page == NULL) { 101 if (ctx->qry.page == NULL) {
91 if (ctx->repo) 102 if (ctx->repo)
92 ctx->qry.page = "summary"; 103 ctx->qry.page = "summary";
93 else 104 else
94 ctx->qry.page = "repolist"; 105 ctx->qry.page = "repolist";
95 } 106 }
96 107
97 for(i = 0; i < sizeof(cmds)/sizeof(*cmds); i++) 108 for(i = 0; i < sizeof(cmds)/sizeof(*cmds); i++)
98 if (!strcmp(ctx->qry.page, cmds[i].name)) 109 if (!strcmp(ctx->qry.page, cmds[i].name))
99 return &cmds[i]; 110 return &cmds[i];
100 return NULL; 111 return NULL;
101} 112}