[BACK]Return to cmd.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / cvs

Annotation of src/usr.bin/cvs/cmd.c, Revision 1.45

1.45    ! joris       1: /*     $OpenBSD: cmd.c,v 1.44 2006/05/27 03:30:30 joris Exp $  */
1.1       joris       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:
1.42      xsa        27: #include "includes.h"
1.1       joris      28:
                     29: #include "cvs.h"
                     30: #include "log.h"
                     31:
1.38      joris      32: extern char *cvs_rootstr;
1.19      jfb        33:
                     34: struct cvs_cmd *cvs_cdt[] = {
1.45    ! joris      35:        &cvs_cmd_add,
1.44      joris      36:        &cvs_cmd_commit,
                     37:        &cvs_cmd_checkout,
                     38:        &cvs_cmd_diff,
                     39:        &cvs_cmd_update,
                     40:        &cvs_cmd_status,
                     41: #if 0
1.19      jfb        42:        &cvs_cmd_admin,
                     43:        &cvs_cmd_annotate,
                     44:        &cvs_cmd_checkout,
                     45:        &cvs_cmd_edit,
                     46:        &cvs_cmd_editors,
                     47:        &cvs_cmd_export,
                     48:        &cvs_cmd_history,
                     49:        &cvs_cmd_import,
                     50:        &cvs_cmd_init,
                     51: #if 0
                     52:        &cvs_cmd_login,
                     53:        &cvs_cmd_logout,
                     54: #endif
                     55:        &cvs_cmd_rdiff,
                     56:        &cvs_cmd_release,
                     57:        &cvs_cmd_remove,
                     58:        &cvs_cmd_rlog,
                     59:        &cvs_cmd_rtag,
                     60:        &cvs_cmd_server,
                     61:        &cvs_cmd_tag,
                     62:        &cvs_cmd_unedit,
                     63:        &cvs_cmd_update,
                     64:        &cvs_cmd_version,
                     65:        &cvs_cmd_watch,
                     66:        &cvs_cmd_watchers,
1.44      joris      67: #endif
1.19      jfb        68:        NULL
                     69: };
                     70:
1.32      xsa        71: struct cvs_cmd *
1.19      jfb        72: cvs_findcmd(const char *cmd)
                     73: {
                     74:        int i, j;
                     75:        struct cvs_cmd *cmdp;
                     76:
                     77:        cmdp = NULL;
                     78:
                     79:        for (i = 0; (cvs_cdt[i] != NULL) && (cmdp == NULL); i++) {
                     80:                if (strcmp(cmd, cvs_cdt[i]->cmd_name) == 0)
                     81:                        cmdp = cvs_cdt[i];
                     82:                else {
                     83:                        for (j = 0; j < CVS_CMD_MAXALIAS; j++) {
                     84:                                if (strcmp(cmd,
                     85:                                    cvs_cdt[i]->cmd_alias[j]) == 0) {
                     86:                                        cmdp = cvs_cdt[i];
                     87:                                        break;
                     88:                                }
                     89:                        }
                     90:                }
                     91:        }
                     92:
                     93:        return (cmdp);
                     94: }
                     95:
1.32      xsa        96: struct cvs_cmd *
1.19      jfb        97: cvs_findcmdbyreq(int reqid)
                     98: {
                     99:        int i;
                    100:        struct cvs_cmd *cmdp;
                    101:
                    102:        cmdp = NULL;
                    103:        for (i = 0; cvs_cdt[i] != NULL; i++)
                    104:                if (cvs_cdt[i]->cmd_req == reqid) {
                    105:                        cmdp = cvs_cdt[i];
                    106:                        break;
                    107:                }
                    108:
                    109:        return (cmdp);
1.1       joris     110: }