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

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

1.1     ! jfb         1: /*     $OpenBSD$       */
        !             2: /*
        !             3:  * Copyright (c) 2004 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:
        !            28: #include <sys/types.h>
        !            29: #include <sys/stat.h>
        !            30:
        !            31: #include <fcntl.h>
        !            32: #include <stdio.h>
        !            33: #include <errno.h>
        !            34: #include <stdlib.h>
        !            35: #include <unistd.h>
        !            36: #include <signal.h>
        !            37: #include <string.h>
        !            38: #include <sysexits.h>
        !            39: #ifdef CVS_ZLIB
        !            40: #include <zlib.h>
        !            41: #endif
        !            42:
        !            43: #include "buf.h"
        !            44: #include "cvs.h"
        !            45: #include "log.h"
        !            46: #include "file.h"
        !            47: #include "proto.h"
        !            48:
        !            49:
        !            50: extern int   verbosity;
        !            51: extern int   cvs_compress;
        !            52: extern char *cvs_rsh;
        !            53: extern int   cvs_trace;
        !            54: extern int   cvs_nolog;
        !            55: extern int   cvs_readonly;
        !            56:
        !            57:
        !            58: static int  cvs_req_root       (int, char *);
        !            59: static int  cvs_req_directory  (int, char *);
        !            60: static int  cvs_req_version    (int, char *);
        !            61:
        !            62:
        !            63: struct cvs_reqhdlr {
        !            64:        int (*hdlr)(int, char *);
        !            65: } cvs_req_swtab[CVS_REQ_MAX + 1] = {
        !            66:        { NULL               },
        !            67:        { cvs_req_root       },
        !            68:        { NULL               },
        !            69:        { NULL               },
        !            70:        { cvs_req_directory  },
        !            71:        { NULL               },
        !            72:        { NULL               },
        !            73:        { NULL               },
        !            74:        { NULL               },
        !            75:        { NULL               },
        !            76:        { NULL               }, /* 10 */
        !            77:        { NULL               },
        !            78:        { NULL               },
        !            79:        { NULL               },
        !            80:        { NULL               },
        !            81:        { NULL               },
        !            82:        { NULL               },
        !            83:        { NULL               },
        !            84:        { NULL               },
        !            85:        { NULL               },
        !            86:        { NULL               }, /* 20 */
        !            87:        { NULL               },
        !            88:        { NULL               },
        !            89:        { NULL               },
        !            90:        { NULL               },
        !            91:        { NULL               },
        !            92:        { NULL               },
        !            93:        { NULL               },
        !            94:        { NULL               },
        !            95:        { NULL               },
        !            96:        { NULL               }, /* 30 */
        !            97:        { NULL               },
        !            98:        { NULL               },
        !            99:        { NULL               },
        !           100:        { NULL               },
        !           101:        { NULL               },
        !           102:        { NULL               },
        !           103:        { NULL               },
        !           104:        { NULL               },
        !           105:        { NULL               },
        !           106:        { NULL               }, /* 40 */
        !           107:        { NULL               },
        !           108:        { NULL               },
        !           109:        { NULL               },
        !           110:        { NULL               },
        !           111:        { NULL               },
        !           112:        { NULL               },
        !           113:        { NULL               },
        !           114:        { NULL               },
        !           115:        { NULL               },
        !           116:        { NULL               }, /* 50 */
        !           117:        { NULL               },
        !           118:        { NULL               },
        !           119:        { NULL               },
        !           120:        { NULL               },
        !           121:        { NULL               },
        !           122:        { NULL               },
        !           123:        { NULL               },
        !           124:        { NULL               },
        !           125:        { NULL               },
        !           126:        { NULL               }, /* 60 */
        !           127:        { NULL               },
        !           128:        { NULL               },
        !           129:        { NULL               },
        !           130:        { NULL               },
        !           131:        { NULL               },
        !           132:        { NULL               },
        !           133:        { NULL               },
        !           134:        { NULL               },
        !           135:        { cvs_req_version    },
        !           136: };
        !           137:
        !           138:
        !           139:
        !           140: /*
        !           141:  * cvs_req_handle()
        !           142:  *
        !           143:  * Generic request handler dispatcher.  The handler expects the first line
        !           144:  * of the command as single argument.
        !           145:  * Returns the return value of the command on success, or -1 on failure.
        !           146:  */
        !           147:
        !           148: int
        !           149: cvs_req_handle(char *line)
        !           150: {
        !           151:        char *cp, *cmd;
        !           152:        struct cvs_req *req;
        !           153:
        !           154:        cmd = line;
        !           155:
        !           156:        cp = strchr(cmd, ' ');
        !           157:        if (cp != NULL)
        !           158:                *(cp++) = '\0';
        !           159:
        !           160:        req = cvs_req_getbyname(cmd);
        !           161:        if (req == NULL)
        !           162:                return (-1);
        !           163:        else if (cvs_req_swtab[req->req_id].hdlr == NULL) {
        !           164:                cvs_log(LP_ERRNO, "handler for `%s' not implemented", cmd);
        !           165:                return (-1);
        !           166:        }
        !           167:
        !           168:        return (*cvs_req_swtab[req->req_id].hdlr)(req->req_id, cp);
        !           169: }
        !           170:
        !           171:
        !           172:
        !           173: static int
        !           174: cvs_req_root(int reqid, char *line)
        !           175: {
        !           176:
        !           177:
        !           178:
        !           179:        return (0);
        !           180: }
        !           181:
        !           182: static int
        !           183: cvs_req_directory(int reqid, char *line)
        !           184: {
        !           185:
        !           186:
        !           187:
        !           188:        return (0);
        !           189: }
        !           190:
        !           191:
        !           192: static int
        !           193: cvs_req_version(int reqid, char *line)
        !           194: {
        !           195:        cvs_printf("%s\n", CVS_VERSION);
        !           196:        return (0);
        !           197: }