1 /* $OpenBSD: cmd.c,v 1.69 2015/01/16 06:40:07 deraadt Exp $ */
2 /*
3 * Copyright (c) 2005 Joris Vink <joris@openbsd.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. The name of the author may not be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
16 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
17 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
18 * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #include <sys/types.h>
27 #include <sys/dirent.h>
28
29 #include <string.h>
30
31 #include "cvs.h"
32
33 struct cvs_cmd *cvs_cdt[] = {
34 &cvs_cmd_add,
35 &cvs_cmd_admin,
36 &cvs_cmd_annotate,
37 &cvs_cmd_commit,
38 &cvs_cmd_checkout,
39 &cvs_cmd_diff,
40 &cvs_cmd_export,
41 &cvs_cmd_history,
42 &cvs_cmd_import,
43 &cvs_cmd_init,
44 &cvs_cmd_log,
45 &cvs_cmd_rannotate,
46 &cvs_cmd_rdiff,
47 &cvs_cmd_release,
48 &cvs_cmd_remove,
49 &cvs_cmd_rlog,
50 &cvs_cmd_rtag,
51 &cvs_cmd_server,
52 &cvs_cmd_status,
53 &cvs_cmd_tag,
54 &cvs_cmd_update,
55 &cvs_cmd_version,
56 #if 0
57 &cvs_cmd_edit,
58 &cvs_cmd_editors,
59 &cvs_cmd_unedit,
60 &cvs_cmd_watch,
61 &cvs_cmd_watchers,
62 #endif
63 NULL
64 };
65
66 struct cvs_cmd *
cvs_findcmd(const char * cmd)67 cvs_findcmd(const char *cmd)
68 {
69 int i, j;
70 struct cvs_cmd *p;
71
72 p = NULL;
73 for (i = 0; (cvs_cdt[i] != NULL) && (p == NULL); i++) {
74 if (strcmp(cmd, cvs_cdt[i]->cmd_name) == 0)
75 p = cvs_cdt[i];
76 else {
77 for (j = 0; j < CVS_CMD_MAXALIAS; j++) {
78 if (strcmp(cmd,
79 cvs_cdt[i]->cmd_alias[j]) == 0) {
80 p = cvs_cdt[i];
81 break;
82 }
83 }
84 }
85 }
86
87 return (p);
88 }
89