[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.66

1.66    ! tobias      1: /*     $OpenBSD: cmd.c,v 1.65 2008/01/10 11:20:29 tobias 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:  */
1.57      otto       26: #include <sys/param.h>
                     27: #include <sys/dirent.h>
1.1       joris      28:
1.57      otto       29: #include <string.h>
1.1       joris      30:
                     31: #include "cvs.h"
1.19      jfb        32:
                     33: struct cvs_cmd *cvs_cdt[] = {
1.45      joris      34:        &cvs_cmd_add,
1.53      xsa        35:        &cvs_cmd_admin,
1.55      xsa        36:        &cvs_cmd_annotate,
1.44      joris      37:        &cvs_cmd_commit,
                     38:        &cvs_cmd_checkout,
                     39:        &cvs_cmd_diff,
1.49      joris      40:        &cvs_cmd_export,
1.58      joris      41:        &cvs_cmd_history,
1.48      joris      42:        &cvs_cmd_import,
1.51      xsa        43:        &cvs_cmd_init,
1.46      joris      44:        &cvs_cmd_log,
1.60      xsa        45:        &cvs_cmd_release,
1.47      joris      46:        &cvs_cmd_remove,
1.59      niallo     47:        &cvs_cmd_rlog,
1.65      tobias     48:        &cvs_cmd_rtag,
1.53      xsa        49:        &cvs_cmd_server,
1.44      joris      50:        &cvs_cmd_status,
1.50      xsa        51:        &cvs_cmd_tag,
                     52:        &cvs_cmd_update,
1.54      xsa        53:        &cvs_cmd_version,
1.44      joris      54: #if 0
1.19      jfb        55:        &cvs_cmd_edit,
                     56:        &cvs_cmd_editors,
                     57:        &cvs_cmd_rdiff,
                     58:        &cvs_cmd_unedit,
                     59:        &cvs_cmd_watch,
                     60:        &cvs_cmd_watchers,
1.44      joris      61: #endif
1.19      jfb        62:        NULL
                     63: };
                     64:
1.32      xsa        65: struct cvs_cmd *
1.19      jfb        66: cvs_findcmd(const char *cmd)
                     67: {
                     68:        int i, j;
1.66    ! tobias     69:        struct cvs_cmd *p;
1.19      jfb        70:
1.66    ! tobias     71:        p = NULL;
        !            72:        for (i = 0; (cvs_cdt[i] != NULL) && (p == NULL); i++) {
1.19      jfb        73:                if (strcmp(cmd, cvs_cdt[i]->cmd_name) == 0)
1.66    ! tobias     74:                        p = cvs_cdt[i];
1.19      jfb        75:                else {
                     76:                        for (j = 0; j < CVS_CMD_MAXALIAS; j++) {
                     77:                                if (strcmp(cmd,
                     78:                                    cvs_cdt[i]->cmd_alias[j]) == 0) {
1.66    ! tobias     79:                                        p = cvs_cdt[i];
1.19      jfb        80:                                        break;
                     81:                                }
                     82:                        }
                     83:                }
                     84:        }
                     85:
1.66    ! tobias     86:        return (p);
1.1       joris      87: }