aboutsummaryrefslogtreecommitdiffstats
path: root/cmd.c
diff options
context:
space:
mode:
authorGravatar Lukas Fleischer <cgit@cryptocrack.de>2014-01-16 05:53:15 (JST)
committerGravatar Jason A. Donenfeld <Jason@zx2c4.com>2014-01-17 08:44:54 (JST)
commitf60ffa143cca61e9729ac71033e1a556cf422871 (patch)
treeff9122fef2779ddea8e37806cc66dc67b63df99f /cmd.c
parenta431326e8fab8153905fbde036dd3c9fb4cc8eaa (diff)
downloadcgit-f60ffa143cca61e9729ac71033e1a556cf422871.zip
cgit-f60ffa143cca61e9729ac71033e1a556cf422871.tar.gz
Switch to exclusively using global ctx
Drop the context parameter from the following functions (and all static helpers used by them) and use the global context instead: * cgit_print_http_headers() * cgit_print_docstart() * cgit_print_pageheader() Remove context parameter from all commands Drop the context parameter from the following functions (and all static helpers used by them) and use the global context instead: * cgit_get_cmd() * All cgit command functions. * cgit_clone_info() * cgit_clone_objects() * cgit_clone_head() * cgit_print_plain() * cgit_show_stats() In initialization routines, use the global context variable instead of passing a pointer around locally. Remove callback data parameter for cache slots This is no longer needed since the context is always read from the global context variable. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
Diffstat (limited to 'cmd.c')
-rw-r--r--cmd.c102
1 files changed, 51 insertions, 51 deletions
diff --git a/cmd.c b/cmd.c
index 420b3b1..cbd235c 100644
--- a/cmd.c
+++ b/cmd.c
@@ -26,120 +26,120 @@
26#include "ui-tag.h" 26#include "ui-tag.h"
27#include "ui-tree.h" 27#include "ui-tree.h"
28 28
29static void HEAD_fn(struct cgit_context *ctx) 29static void HEAD_fn(void)
30{ 30{
31 cgit_clone_head(ctx); 31 cgit_clone_head();
32} 32}
33 33
34static void atom_fn(struct cgit_context *ctx) 34static void atom_fn(void)
35{ 35{
36 cgit_print_atom(ctx->qry.head, ctx->qry.path, ctx->cfg.max_atom_items); 36 cgit_print_atom(ctx.qry.head, ctx.qry.path, ctx.cfg.max_atom_items);
37} 37}
38 38
39static void about_fn(struct cgit_context *ctx) 39static void about_fn(void)
40{ 40{
41 if (ctx->repo) 41 if (ctx.repo)
42 cgit_print_repo_readme(ctx->qry.path); 42 cgit_print_repo_readme(ctx.qry.path);
43 else 43 else
44 cgit_print_site_readme(); 44 cgit_print_site_readme();
45} 45}
46 46
47static void blob_fn(struct cgit_context *ctx) 47static void blob_fn(void)
48{ 48{
49 cgit_print_blob(ctx->qry.sha1, ctx->qry.path, ctx->qry.head, 0); 49 cgit_print_blob(ctx.qry.sha1, ctx.qry.path, ctx.qry.head, 0);
50} 50}
51 51
52static void commit_fn(struct cgit_context *ctx) 52static void commit_fn(void)
53{ 53{
54 cgit_print_commit(ctx->qry.sha1, ctx->qry.path); 54 cgit_print_commit(ctx.qry.sha1, ctx.qry.path);
55} 55}
56 56
57static void diff_fn(struct cgit_context *ctx) 57static void diff_fn(void)
58{ 58{
59 cgit_print_diff(ctx->qry.sha1, ctx->qry.sha2, ctx->qry.path, 1, 0); 59 cgit_print_diff(ctx.qry.sha1, ctx.qry.sha2, ctx.qry.path, 1, 0);
60} 60}
61 61
62static void rawdiff_fn(struct cgit_context *ctx) 62static void rawdiff_fn(void)
63{ 63{
64 cgit_print_diff(ctx->qry.sha1, ctx->qry.sha2, ctx->qry.path, 1, 1); 64 cgit_print_diff(ctx.qry.sha1, ctx.qry.sha2, ctx.qry.path, 1, 1);
65} 65}
66 66
67static void info_fn(struct cgit_context *ctx) 67static void info_fn(void)
68{ 68{
69 cgit_clone_info(ctx); 69 cgit_clone_info();
70} 70}
71 71
72static void log_fn(struct cgit_context *ctx) 72static void log_fn(void)
73{ 73{
74 cgit_print_log(ctx->qry.sha1, ctx->qry.ofs, ctx->cfg.max_commit_count, 74 cgit_print_log(ctx.qry.sha1, ctx.qry.ofs, ctx.cfg.max_commit_count,
75 ctx->qry.grep, ctx->qry.search, ctx->qry.path, 1, 75 ctx.qry.grep, ctx.qry.search, ctx.qry.path, 1,
76 ctx->repo->enable_commit_graph, 76 ctx.repo->enable_commit_graph,
77 ctx->repo->commit_sort); 77 ctx.repo->commit_sort);
78} 78}
79 79
80static void ls_cache_fn(struct cgit_context *ctx) 80static void ls_cache_fn(void)
81{ 81{
82 ctx->page.mimetype = "text/plain"; 82 ctx.page.mimetype = "text/plain";
83 ctx->page.filename = "ls-cache.txt"; 83 ctx.page.filename = "ls-cache.txt";
84 cgit_print_http_headers(ctx); 84 cgit_print_http_headers();
85 cache_ls(ctx->cfg.cache_root); 85 cache_ls(ctx.cfg.cache_root);
86} 86}
87 87
88static void objects_fn(struct cgit_context *ctx) 88static void objects_fn(void)
89{ 89{
90 cgit_clone_objects(ctx); 90 cgit_clone_objects();
91} 91}
92 92
93static void repolist_fn(struct cgit_context *ctx) 93static void repolist_fn(void)
94{ 94{
95 cgit_print_repolist(); 95 cgit_print_repolist();
96} 96}
97 97
98static void patch_fn(struct cgit_context *ctx) 98static void patch_fn(void)
99{ 99{
100 cgit_print_patch(ctx->qry.sha1, ctx->qry.sha2, ctx->qry.path); 100 cgit_print_patch(ctx.qry.sha1, ctx.qry.sha2, ctx.qry.path);
101} 101}
102 102
103static void plain_fn(struct cgit_context *ctx) 103static void plain_fn(void)
104{ 104{
105 cgit_print_plain(ctx); 105 cgit_print_plain();
106} 106}
107 107
108static void refs_fn(struct cgit_context *ctx) 108static void refs_fn(void)
109{ 109{
110 cgit_print_refs(); 110 cgit_print_refs();
111} 111}
112 112
113static void snapshot_fn(struct cgit_context *ctx) 113static void snapshot_fn(void)
114{ 114{
115 cgit_print_snapshot(ctx->qry.head, ctx->qry.sha1, ctx->qry.path, 115 cgit_print_snapshot(ctx.qry.head, ctx.qry.sha1, ctx.qry.path,
116 ctx->repo->snapshots, ctx->qry.nohead); 116 ctx.repo->snapshots, ctx.qry.nohead);
117} 117}
118 118
119static void stats_fn(struct cgit_context *ctx) 119static void stats_fn(void)
120{ 120{
121 cgit_show_stats(ctx); 121 cgit_show_stats();
122} 122}
123 123
124static void summary_fn(struct cgit_context *ctx) 124static void summary_fn(void)
125{ 125{
126 cgit_print_summary(); 126 cgit_print_summary();
127} 127}
128 128
129static void tag_fn(struct cgit_context *ctx) 129static void tag_fn(void)
130{ 130{
131 cgit_print_tag(ctx->qry.sha1); 131 cgit_print_tag(ctx.qry.sha1);
132} 132}
133 133
134static void tree_fn(struct cgit_context *ctx) 134static void tree_fn(void)
135{ 135{
136 cgit_print_tree(ctx->qry.sha1, ctx->qry.path); 136 cgit_print_tree(ctx.qry.sha1, ctx.qry.path);
137} 137}
138 138
139#define def_cmd(name, want_repo, want_layout, want_vpath, is_clone) \ 139#define def_cmd(name, want_repo, want_layout, want_vpath, is_clone) \
140 {#name, name##_fn, want_repo, want_layout, want_vpath, is_clone} 140 {#name, name##_fn, want_repo, want_layout, want_vpath, is_clone}
141 141
142struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx) 142struct cgit_cmd *cgit_get_cmd(void)
143{ 143{
144 static struct cgit_cmd cmds[] = { 144 static struct cgit_cmd cmds[] = {
145 def_cmd(HEAD, 1, 0, 0, 1), 145 def_cmd(HEAD, 1, 0, 0, 1),
@@ -165,15 +165,15 @@ struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx)
165 }; 165 };
166 int i; 166 int i;
167 167
168 if (ctx->qry.page == NULL) { 168 if (ctx.qry.page == NULL) {
169 if (ctx->repo) 169 if (ctx.repo)
170 ctx->qry.page = "summary"; 170 ctx.qry.page = "summary";
171 else 171 else
172 ctx->qry.page = "repolist"; 172 ctx.qry.page = "repolist";
173 } 173 }
174 174
175 for (i = 0; i < sizeof(cmds)/sizeof(*cmds); i++) 175 for (i = 0; i < sizeof(cmds)/sizeof(*cmds); i++)
176 if (!strcmp(ctx->qry.page, cmds[i].name)) 176 if (!strcmp(ctx.qry.page, cmds[i].name))
177 return &cmds[i]; 177 return &cmds[i];
178 return NULL; 178 return NULL;
179} 179}