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

Annotation of src/usr.bin/cvs/edit.c, Revision 1.1

1.1     ! jfb         1: /*     $OpenBSD$       */
        !             2: /*
        !             3:  * Copyright (c) 2005 Jean-Francois Brousseau <jfb@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:
        !            27: #include <sys/types.h>
        !            28:
        !            29: #include <errno.h>
        !            30: #include <fcntl.h>
        !            31: #include <stdio.h>
        !            32: #include <stdlib.h>
        !            33: #include <string.h>
        !            34: #include <libgen.h>
        !            35: #include <sysexits.h>
        !            36: #include <unistd.h>
        !            37:
        !            38: #include "cvs.h"
        !            39: #include "log.h"
        !            40: #include "proto.h"
        !            41:
        !            42:
        !            43:
        !            44: static int cvs_edit_init   (struct cvs_cmd *, int, char **, int *);
        !            45: static int cvs_edit_remote (CVSFILE *, void *);
        !            46: static int cvs_edit_local  (CVSFILE *, void *);
        !            47:
        !            48:
        !            49: struct cvs_cmd cvs_cmd_edit = {
        !            50:        CVS_OP_EDIT, CVS_REQ_NOOP, "edit",
        !            51:        { },
        !            52:        "Mark a file as being edited",
        !            53:        "[-lR] [-a action ...",
        !            54:        "a:lR",
        !            55:        NULL,
        !            56:        CF_SORT | CF_RECURSE,
        !            57:        cvs_edit_init,
        !            58:        NULL,
        !            59:        cvs_edit_remote,
        !            60:        cvs_edit_local,
        !            61:        NULL,
        !            62:        NULL,
        !            63:        0
        !            64: };
        !            65:
        !            66: struct cvs_cmd cvs_cmd_editors = {
        !            67:        CVS_OP_EDITORS, CVS_REQ_EDITORS, "editors",
        !            68:        { },
        !            69:        "List editors on a file",
        !            70:        "",
        !            71:        "",
        !            72:        NULL,
        !            73:        0,
        !            74:        cvs_edit_init,
        !            75:        NULL,
        !            76:        cvs_edit_remote,
        !            77:        cvs_edit_local,
        !            78:        NULL,
        !            79:        NULL,
        !            80:        0
        !            81: };
        !            82:
        !            83:
        !            84: struct cvs_cmd cvs_cmd_unedit = {
        !            85:        CVS_OP_UNEDIT, CVS_REQ_NOOP, "unedit",
        !            86:        { },
        !            87:        "Undo an edit command",
        !            88:        "[-lR] ...",
        !            89:        "lR",
        !            90:        NULL,
        !            91:        CF_SORT | CF_RECURSE,
        !            92:        cvs_edit_init,
        !            93:        NULL,
        !            94:        cvs_edit_remote,
        !            95:        cvs_edit_local,
        !            96:        NULL,
        !            97:        NULL,
        !            98:        0
        !            99: };
        !           100:
        !           101:
        !           102:
        !           103: static int
        !           104: cvs_edit_init(struct cvs_cmd *cmd, int argc, char **argv, int *arg)
        !           105: {
        !           106:        int i, ch, dflag, mod_count;
        !           107:        struct cvsroot *root;
        !           108:
        !           109:        dflag = 0;
        !           110:        mod_count = 0;
        !           111:
        !           112:        while ((ch = getopt(argc, argv, cmd->cmd_opts)) != -1) {
        !           113:                switch (ch) {
        !           114:                case 'a':
        !           115:                        if (cvs_cmdop != CVS_OP_EDIT)
        !           116:                                return (CVS_EX_USAGE);
        !           117:                        break;
        !           118:                case 'l':
        !           119:                        cmd->file_flags &= ~CF_RECURSE;
        !           120:                        break;
        !           121:                case 'R':
        !           122:                        cmd->file_flags |= CF_RECURSE;
        !           123:                        break;
        !           124:                default:
        !           125:                        return (CVS_EX_USAGE);
        !           126:                }
        !           127:        }
        !           128:
        !           129:        *arg = optind;
        !           130:        return (CVS_EX_OK);
        !           131: }
        !           132:
        !           133:
        !           134: /*
        !           135:  * cvs_edit_remote()
        !           136:  *
        !           137:  */
        !           138: static int
        !           139: cvs_edit_remote(CVSFILE *file, void *arg)
        !           140: {
        !           141:        int *mod_count;
        !           142:
        !           143:        mod_count = (int *)arg;
        !           144:
        !           145:        return (CVS_EX_OK);
        !           146: }
        !           147:
        !           148:
        !           149: /*
        !           150:  * cvs_edit_local()
        !           151:  *
        !           152:  */
        !           153: static int
        !           154: cvs_edit_local(CVSFILE *file, void *arg)
        !           155: {
        !           156:        int *mod_count;
        !           157:
        !           158:        mod_count = (int *)arg;
        !           159:
        !           160:        return (CVS_EX_OK);
        !           161: }