diff options
author | Lukas Fleischer | 2014-01-15 21:53:15 +0100 |
---|---|---|
committer | Jason A. Donenfeld | 2014-01-17 00:44:54 +0100 |
commit | f60ffa143cca61e9729ac71033e1a556cf422871 (patch) | |
tree | ff9122fef2779ddea8e37806cc66dc67b63df99f /cmd.c | |
parent | a431326e8fab8153905fbde036dd3c9fb4cc8eaa (diff) | |
download | cgit-f60ffa143cca61e9729ac71033e1a556cf422871.tar.gz cgit-f60ffa143cca61e9729ac71033e1a556cf422871.tar.bz2 cgit-f60ffa143cca61e9729ac71033e1a556cf422871.zip |
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.c | 102 |
1 files changed, 51 insertions, 51 deletions
@@ -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 | ||
29 | static void HEAD_fn(struct cgit_context *ctx) | 29 | static void HEAD_fn(void) |
30 | { | 30 | { |
31 | cgit_clone_head(ctx); | 31 | cgit_clone_head(); |
32 | } | 32 | } |
33 | 33 | ||
34 | static void atom_fn(struct cgit_context *ctx) | 34 | static 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 | ||
39 | static void about_fn(struct cgit_context *ctx) | 39 | static 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 | ||
47 | static void blob_fn(struct cgit_context *ctx) | 47 | static 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 | ||
52 | static void commit_fn(struct cgit_context *ctx) | 52 | static 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 | ||
57 | static void diff_fn(struct cgit_context *ctx) | 57 | static 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 | ||
62 | static void rawdiff_fn(struct cgit_context *ctx) | 62 | static 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 | ||
67 | static void info_fn(struct cgit_context *ctx) | 67 | static void info_fn(void) |
68 | { | 68 | { |
69 | cgit_clone_info(ctx); | 69 | cgit_clone_info(); |
70 | } | 70 | } |
71 | 71 | ||
72 | static void log_fn(struct cgit_context *ctx) | 72 | static 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 | ||
80 | static void ls_cache_fn(struct cgit_context *ctx) | 80 | static 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 | ||
88 | static void objects_fn(struct cgit_context *ctx) | 88 | static void objects_fn(void) |
89 | { | 89 | { |
90 | cgit_clone_objects(ctx); | 90 | cgit_clone_objects(); |
91 | } | 91 | } |
92 | 92 | ||
93 | static void repolist_fn(struct cgit_context *ctx) | 93 | static void repolist_fn(void) |
94 | { | 94 | { |
95 | cgit_print_repolist(); | 95 | cgit_print_repolist(); |
96 | } | 96 | } |
97 | 97 | ||
98 | static void patch_fn(struct cgit_context *ctx) | 98 | static 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 | ||
103 | static void plain_fn(struct cgit_context *ctx) | 103 | static void plain_fn(void) |
104 | { | 104 | { |
105 | cgit_print_plain(ctx); | 105 | cgit_print_plain(); |
106 | } | 106 | } |
107 | 107 | ||
108 | static void refs_fn(struct cgit_context *ctx) | 108 | static void refs_fn(void) |
109 | { | 109 | { |
110 | cgit_print_refs(); | 110 | cgit_print_refs(); |
111 | } | 111 | } |
112 | 112 | ||
113 | static void snapshot_fn(struct cgit_context *ctx) | 113 | static 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 | ||
119 | static void stats_fn(struct cgit_context *ctx) | 119 | static void stats_fn(void) |
120 | { | 120 | { |
121 | cgit_show_stats(ctx); | 121 | cgit_show_stats(); |
122 | } | 122 | } |
123 | 123 | ||
124 | static void summary_fn(struct cgit_context *ctx) | 124 | static void summary_fn(void) |
125 | { | 125 | { |
126 | cgit_print_summary(); | 126 | cgit_print_summary(); |
127 | } | 127 | } |
128 | 128 | ||
129 | static void tag_fn(struct cgit_context *ctx) | 129 | static void tag_fn(void) |
130 | { | 130 | { |
131 | cgit_print_tag(ctx->qry.sha1); | 131 | cgit_print_tag(ctx.qry.sha1); |
132 | } | 132 | } |
133 | 133 | ||
134 | static void tree_fn(struct cgit_context *ctx) | 134 | static 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 | ||
142 | struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx) | 142 | struct 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 | } |