diff options
Diffstat (limited to 'source/cmd.c')
| -rw-r--r-- | source/cmd.c | 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 10 insertions, 6 deletions
diff --git a/source/cmd.c b/source/cmd.c index a19aa50..38fe596 100644 --- a/source/cmd.c +++ b/source/cmd.c @@ -208,19 +208,23 @@ static const struct cgit_cmd commands[] = { { .name = "tree", .fn = tree_fn, .want_repo = 1, .want_vpath = 1 }, }; -const struct cgit_cmd *cgit_get_cmd(void) +const struct cgit_cmd *cgit_find_cmd(const char *name) { size_t i; + for (i = 0; i < ARRAY_SIZE(commands); i++) + if (!strcmp(name, commands[i].name)) + return &commands[i]; + return NULL; +} + +const struct cgit_cmd *cgit_get_cmd(void) +{ if (!ctx.qry.page) { if (ctx.repo) ctx.qry.page = "summary"; else ctx.qry.page = "repolist"; } - - for (i = 0; i < ARRAY_SIZE(commands); i++) - if (!strcmp(ctx.qry.page, commands[i].name)) - return &commands[i]; - return NULL; + return cgit_find_cmd(ctx.qry.page); } |
