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

Annotation of src/usr.bin/cvs/server.c, Revision 1.69

1.69    ! tobias      1: /*     $OpenBSD: server.c,v 1.68 2007/09/02 12:13:00 tobias Exp $      */
1.1       jfb         2: /*
1.29      joris       3:  * Copyright (c) 2006 Joris Vink <joris@openbsd.org>
1.1       jfb         4:  *
1.29      joris       5:  * Permission to use, copy, modify, and distribute this software for any
                      6:  * purpose with or without fee is hereby granted, provided that the above
                      7:  * copyright notice and this permission notice appear in all copies.
1.1       jfb         8:  *
1.29      joris       9:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     10:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     11:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     12:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     13:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
                     14:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
                     15:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1.1       jfb        16:  */
                     17:
1.55      otto       18: #include <sys/stat.h>
                     19:
                     20: #include <errno.h>
                     21: #include <fcntl.h>
                     22: #include <libgen.h>
1.68      tobias     23: #include <stdio.h>
1.55      otto       24: #include <stdlib.h>
                     25: #include <string.h>
                     26: #include <unistd.h>
1.1       jfb        27:
                     28: #include "cvs.h"
1.29      joris      29: #include "remote.h"
                     30:
                     31: struct cvs_resp cvs_responses[] = {
                     32:        /* this is what our server uses, the client should support it */
                     33:        { "Valid-requests",     1,      cvs_client_validreq, RESP_NEEDED },
                     34:        { "ok",                 0,      cvs_client_ok, RESP_NEEDED},
                     35:        { "error",              0,      cvs_client_error, RESP_NEEDED },
                     36:        { "E",                  0,      cvs_client_e, RESP_NEEDED },
                     37:        { "M",                  0,      cvs_client_m, RESP_NEEDED },
                     38:        { "Checked-in",         0,      cvs_client_checkedin, RESP_NEEDED },
                     39:        { "Updated",            0,      cvs_client_updated, RESP_NEEDED },
                     40:        { "Merged",             0,      cvs_client_merged, RESP_NEEDED },
                     41:        { "Removed",            0,      cvs_client_removed, RESP_NEEDED },
                     42:        { "Remove-entry",       0,      cvs_client_remove_entry, RESP_NEEDED },
1.46      xsa        43:        { "Set-static-directory",       0,      cvs_client_set_static_directory, RESP_NEEDED },
1.45      xsa        44:        { "Clear-static-directory",     0,      cvs_client_clear_static_directory, RESP_NEEDED },
                     45:        { "Set-sticky",         0,      cvs_client_set_sticky, RESP_NEEDED },
                     46:        { "Clear-sticky",       0,      cvs_client_clear_sticky, RESP_NEEDED },
1.29      joris      47:
                     48:        /* unsupported responses until told otherwise */
                     49:        { "New-entry",                  0,      NULL, 0 },
                     50:        { "Created",                    0,      NULL, 0 },
                     51:        { "Update-existing",            0,      NULL, 0 },
                     52:        { "Rcs-diff",                   0,      NULL, 0 },
                     53:        { "Patched",                    0,      NULL, 0 },
                     54:        { "Mode",                       0,      NULL, 0 },
                     55:        { "Mod-time",                   0,      NULL, 0 },
                     56:        { "Checksum",                   0,      NULL, 0 },
                     57:        { "Copy-file",                  0,      NULL, 0 },
                     58:        { "Template",                   0,      NULL, 0 },
                     59:        { "Set-checkin-prog",           0,      NULL, 0 },
                     60:        { "Set-update-prog",            0,      NULL, 0 },
                     61:        { "Notified",                   0,      NULL, 0 },
                     62:        { "Module-expansion",           0,      NULL, 0 },
                     63:        { "Wrapper-rcsOption",          0,      NULL, 0 },
                     64:        { "Mbinary",                    0,      NULL, 0 },
                     65:        { "F",                          0,      NULL, 0 },
                     66:        { "MT",                         0,      NULL, 0 },
                     67:        { "",                           -1,     NULL, 0 }
                     68: };
1.1       jfb        69:
1.29      joris      70: int    cvs_server(int, char **);
                     71: char   *cvs_server_path = NULL;
1.1       jfb        72:
1.29      joris      73: static char *server_currentdir = NULL;
                     74: static char *server_argv[CVS_CMD_MAXARG];
                     75: static int server_argc = 1;
1.8       joris      76:
1.17      jfb        77: struct cvs_cmd cvs_cmd_server = {
1.29      joris      78:        CVS_OP_SERVER, 0, "server", { "", "" },
                     79:        "server mode",
1.17      jfb        80:        NULL,
1.29      joris      81:        NULL,
                     82:        NULL,
                     83:        cvs_server
1.17      jfb        84: };
1.1       jfb        85:
1.14      joris      86:
1.1       jfb        87: int
                     88: cvs_server(int argc, char **argv)
                     89: {
1.29      joris      90:        char *cmd, *data;
                     91:        struct cvs_req *req;
                     92:
1.68      tobias     93:        if (argc > 1)
                     94:                fatal("server does not take any extra arguments");
                     95:
                     96:        setvbuf(stdin, NULL, _IOLBF, 0);
                     97:        setvbuf(stdout, NULL, _IOLBF, 0);
                     98:
                     99:        cvs_server_active = 1;
                    100:
1.29      joris     101:        server_argv[0] = xstrdup("server");
                    102:
1.58      ray       103:        (void)xasprintf(&cvs_server_path, "%s/cvs-serv%d", cvs_tmpdir,
                    104:            getpid());
1.29      joris     105:
                    106:        if (mkdir(cvs_server_path, 0700) == -1)
                    107:                fatal("failed to create temporary server directory: %s, %s",
                    108:                    cvs_server_path, strerror(errno));
                    109:
                    110:        if (chdir(cvs_server_path) == -1)
                    111:                fatal("failed to change directory to '%s'", cvs_server_path);
                    112:
                    113:        for (;;) {
                    114:                cmd = cvs_remote_input();
                    115:
                    116:                if ((data = strchr(cmd, ' ')) != NULL)
                    117:                        (*data++) = '\0';
                    118:
                    119:                req = cvs_remote_get_request_info(cmd);
                    120:                if (req == NULL)
                    121:                        fatal("request '%s' is not supported by our server",
                    122:                            cmd);
                    123:
                    124:                if (req->hdlr == NULL)
                    125:                        fatal("opencvs server does not support '%s'", cmd);
1.63      joris     126:
                    127:                if ((req->flags & REQ_NEEDDIR) && (server_currentdir == NULL))
                    128:                        fatal("`%s' needs a directory to be sent with "
                    129:                            "the `Directory` request first", cmd);
1.29      joris     130:
                    131:                (*req->hdlr)(data);
                    132:                xfree(cmd);
1.14      joris     133:        }
                    134:
1.29      joris     135:        return (0);
                    136: }
                    137:
                    138: void
                    139: cvs_server_send_response(char *fmt, ...)
                    140: {
                    141:        va_list ap;
1.59      ray       142:        char *data;
1.29      joris     143:
                    144:        va_start(ap, fmt);
1.56      ray       145:        if (vasprintf(&data, fmt, ap) == -1)
                    146:                fatal("vasprintf: %s", strerror(errno));
1.29      joris     147:        va_end(ap);
1.14      joris     148:
1.30      joris     149:        cvs_log(LP_TRACE, "%s", data);
1.29      joris     150:        cvs_remote_output(data);
                    151:        xfree(data);
                    152: }
                    153:
                    154: void
                    155: cvs_server_root(char *data)
                    156: {
1.68      tobias    157:        if (data == NULL)
                    158:                fatal("Missing argument for Root");
                    159:
                    160:        if (current_cvsroot != NULL)
                    161:                return;
                    162:
                    163:        if (data[0] != '/' || (current_cvsroot = cvsroot_get(data)) == NULL)
                    164:                fatal("Invalid Root specified!");
1.29      joris     165: }
                    166:
                    167: void
                    168: cvs_server_validresp(char *data)
                    169: {
                    170:        int i;
                    171:        char *sp, *ep;
                    172:        struct cvs_resp *resp;
                    173:
1.57      ray       174:        if ((sp = data) == NULL)
                    175:                fatal("Missing argument for Valid-responses");
                    176:
1.29      joris     177:        do {
                    178:                if ((ep = strchr(sp, ' ')) != NULL)
                    179:                        *ep = '\0';
                    180:
                    181:                resp = cvs_remote_get_response_info(sp);
                    182:                if (resp != NULL)
                    183:                        resp->supported = 1;
                    184:
                    185:                if (ep != NULL)
                    186:                        sp = ep + 1;
                    187:        } while (ep != NULL);
                    188:
                    189:        for (i = 0; cvs_responses[i].supported != -1; i++) {
                    190:                resp = &cvs_responses[i];
                    191:                if ((resp->flags & RESP_NEEDED) &&
                    192:                    resp->supported != 1) {
                    193:                        fatal("client does not support required '%s'",
                    194:                            resp->name);
1.1       jfb       195:                }
1.29      joris     196:        }
                    197: }
1.1       jfb       198:
1.29      joris     199: void
                    200: cvs_server_validreq(char *data)
                    201: {
                    202:        BUF *bp;
                    203:        char *d;
                    204:        int i, first;
                    205:
                    206:        first = 0;
                    207:        bp = cvs_buf_alloc(512, BUF_AUTOEXT);
                    208:        for (i = 0; cvs_requests[i].supported != -1; i++) {
                    209:                if (cvs_requests[i].hdlr == NULL)
1.5       jfb       210:                        continue;
1.1       jfb       211:
1.29      joris     212:                if (first != 0)
                    213:                        cvs_buf_append(bp, " ", 1);
                    214:                else
                    215:                        first++;
                    216:
                    217:                cvs_buf_append(bp, cvs_requests[i].name,
                    218:                    strlen(cvs_requests[i].name));
                    219:        }
                    220:
                    221:        cvs_buf_putc(bp, '\0');
                    222:        d = cvs_buf_release(bp);
                    223:
                    224:        cvs_server_send_response("Valid-requests %s", d);
                    225:        cvs_server_send_response("ok");
                    226:        xfree(d);
1.42      xsa       227: }
                    228:
                    229: void
1.43      xsa       230: cvs_server_static_directory(char *data)
                    231: {
                    232:        FILE *fp;
1.51      otto      233:        char fpath[MAXPATHLEN];
1.43      xsa       234:
1.54      xsa       235:        (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s",
                    236:            server_currentdir, CVS_PATH_STATICENTRIES);
1.43      xsa       237:
                    238:        if ((fp = fopen(fpath, "w+")) == NULL) {
                    239:                cvs_log(LP_ERRNO, "%s", fpath);
1.51      otto      240:                return;
1.43      xsa       241:        }
                    242:        (void)fclose(fp);
                    243: }
                    244:
                    245: void
1.42      xsa       246: cvs_server_sticky(char *data)
                    247: {
                    248:        FILE *fp;
1.51      otto      249:        char tagpath[MAXPATHLEN];
1.42      xsa       250:
1.57      ray       251:        if (data == NULL)
                    252:                fatal("Missing argument for Sticky");
                    253:
1.54      xsa       254:        (void)xsnprintf(tagpath, MAXPATHLEN, "%s/%s",
                    255:            server_currentdir, CVS_PATH_TAG);
1.42      xsa       256:
1.43      xsa       257:        if ((fp = fopen(tagpath, "w+")) == NULL) {
1.42      xsa       258:                cvs_log(LP_ERRNO, "%s", tagpath);
1.51      otto      259:                return;
1.42      xsa       260:        }
                    261:
                    262:        (void)fprintf(fp, "%s\n", data);
                    263:        (void)fclose(fp);
1.29      joris     264: }
                    265:
                    266: void
                    267: cvs_server_globalopt(char *data)
                    268: {
1.57      ray       269:        if (data == NULL)
                    270:                fatal("Missing argument for Global_option");
                    271:
1.38      xsa       272:        if (!strcmp(data, "-l"))
                    273:                cvs_nolog = 1;
1.29      joris     274:
                    275:        if (!strcmp(data, "-n"))
                    276:                cvs_noexec = 1;
1.38      xsa       277:
                    278:        if (!strcmp(data, "-Q"))
                    279:                verbosity = 0;
                    280:
                    281:        if (!strcmp(data, "-r"))
                    282:                cvs_readonly = 1;
                    283:
                    284:        if (!strcmp(data, "-t"))
                    285:                cvs_trace = 1;
1.29      joris     286:
                    287:        if (!strcmp(data, "-V"))
                    288:                verbosity = 2;
1.39      xsa       289: }
                    290:
                    291: void
                    292: cvs_server_set(char *data)
                    293: {
                    294:        char *ep;
                    295:
1.57      ray       296:        if (data == NULL)
                    297:                fatal("Missing argument for Set");
                    298:
1.39      xsa       299:        ep = strchr(data, '=');
                    300:        if (ep == NULL)
                    301:                fatal("no = in variable assignment");
                    302:
                    303:        *(ep++) = '\0';
                    304:        if (cvs_var_set(data, ep) < 0)
                    305:                fatal("cvs_server_set: cvs_var_set failed");
1.29      joris     306: }
1.1       jfb       307:
1.29      joris     308: void
                    309: cvs_server_directory(char *data)
                    310: {
                    311:        CVSENTRIES *entlist;
1.51      otto      312:        char *dir, *repo, *parent, entry[CVS_ENT_MAXLINELEN], *dirn, *p;
1.68      tobias    313:
                    314:        if (current_cvsroot == NULL)
                    315:                fatal("No Root specified for Directory");
1.29      joris     316:
                    317:        dir = cvs_remote_input();
1.49      joris     318:        STRIP_SLASH(dir);
                    319:
                    320:        if (strlen(dir) < strlen(current_cvsroot->cr_dir))
1.29      joris     321:                fatal("cvs_server_directory: bad Directory request");
                    322:
1.49      joris     323:        repo = dir + strlen(current_cvsroot->cr_dir);
                    324:
                    325:        /*
                    326:         * This is somewhat required for checkout, as the
                    327:         * directory request will be:
                    328:         *
                    329:         * Directory .
                    330:         * /path/to/cvs/root
                    331:         */
                    332:        if (repo[0] == '\0')
                    333:                p = xstrdup(".");
                    334:        else
                    335:                p = xstrdup(repo + 1);
                    336:
1.65      joris     337:        cvs_mkpath(p, NULL);
1.29      joris     338:
1.49      joris     339:        if ((dirn = basename(p)) == NULL)
1.29      joris     340:                fatal("cvs_server_directory: %s", strerror(errno));
                    341:
1.49      joris     342:        if ((parent = dirname(p)) == NULL)
1.29      joris     343:                fatal("cvs_server_directory: %s", strerror(errno));
                    344:
                    345:        if (strcmp(parent, ".")) {
                    346:                entlist = cvs_ent_open(parent);
1.53      xsa       347:                (void)xsnprintf(entry, CVS_ENT_MAXLINELEN, "D/%s////", dirn);
1.29      joris     348:
                    349:                cvs_ent_add(entlist, entry);
                    350:                cvs_ent_close(entlist, ENT_SYNC);
1.1       jfb       351:        }
                    352:
1.29      joris     353:        if (server_currentdir != NULL)
                    354:                xfree(server_currentdir);
1.61      ray       355:        server_currentdir = p;
1.29      joris     356:
                    357:        xfree(dir);
                    358: }
                    359:
                    360: void
                    361: cvs_server_entry(char *data)
                    362: {
                    363:        CVSENTRIES *entlist;
                    364:
1.57      ray       365:        if (data == NULL)
                    366:                fatal("Missing argument for Entry");
                    367:
1.29      joris     368:        entlist = cvs_ent_open(server_currentdir);
                    369:        cvs_ent_add(entlist, data);
                    370:        cvs_ent_close(entlist, ENT_SYNC);
                    371: }
                    372:
                    373: void
                    374: cvs_server_modified(char *data)
                    375: {
1.41      xsa       376:        int fd;
1.29      joris     377:        size_t flen;
                    378:        mode_t fmode;
                    379:        const char *errstr;
1.51      otto      380:        char *mode, *len, fpath[MAXPATHLEN];
1.29      joris     381:
1.57      ray       382:        if (data == NULL)
                    383:                fatal("Missing argument for Modified");
                    384:
1.29      joris     385:        mode = cvs_remote_input();
                    386:        len = cvs_remote_input();
                    387:
                    388:        cvs_strtomode(mode, &fmode);
                    389:        xfree(mode);
                    390:
                    391:        flen = strtonum(len, 0, INT_MAX, &errstr);
                    392:        if (errstr != NULL)
                    393:                fatal("cvs_server_modified: %s", errstr);
                    394:        xfree(len);
                    395:
1.54      xsa       396:        (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", server_currentdir, data);
1.29      joris     397:
                    398:        if ((fd = open(fpath, O_WRONLY | O_CREAT | O_TRUNC)) == -1)
                    399:                fatal("cvs_server_modified: %s: %s", fpath, strerror(errno));
                    400:
1.48      joris     401:        cvs_remote_receive_file(fd, flen);
1.29      joris     402:
                    403:        if (fchmod(fd, 0600) == -1)
                    404:                fatal("cvs_server_modified: failed to set file mode");
                    405:
                    406:        (void)close(fd);
                    407: }
                    408:
                    409: void
                    410: cvs_server_useunchanged(char *data)
                    411: {
                    412: }
                    413:
                    414: void
                    415: cvs_server_unchanged(char *data)
                    416: {
1.41      xsa       417:        int fd;
1.51      otto      418:        char fpath[MAXPATHLEN];
1.29      joris     419:        CVSENTRIES *entlist;
                    420:        struct cvs_ent *ent;
                    421:        struct timeval tv[2];
                    422:
1.57      ray       423:        if (data == NULL)
                    424:                fatal("Missing argument for Unchanged");
                    425:
1.54      xsa       426:        (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", server_currentdir, data);
1.29      joris     427:
                    428:        if ((fd = open(fpath, O_RDWR | O_CREAT | O_TRUNC)) == -1)
                    429:                fatal("cvs_server_unchanged: %s: %s", fpath, strerror(errno));
                    430:
                    431:        entlist = cvs_ent_open(server_currentdir);
                    432:        ent = cvs_ent_get(entlist, data);
                    433:        if (ent == NULL)
                    434:                fatal("received Unchanged request for non-existing file");
                    435:        cvs_ent_close(entlist, ENT_NOSYNC);
                    436:
1.52      joris     437:        tv[0].tv_sec = ent->ce_mtime;
1.29      joris     438:        tv[0].tv_usec = 0;
                    439:        tv[1] = tv[0];
                    440:        if (futimes(fd, tv) == -1)
                    441:                fatal("cvs_server_unchanged: failed to set modified time");
                    442:
                    443:        if (fchmod(fd, 0600) == -1)
                    444:                fatal("cvs_server_unchanged: failed to set mode");
                    445:
                    446:        cvs_ent_free(ent);
                    447:        (void)close(fd);
                    448: }
                    449:
                    450: void
                    451: cvs_server_questionable(char *data)
                    452: {
                    453: }
                    454:
                    455: void
                    456: cvs_server_argument(char *data)
                    457: {
1.60      ray       458:        if (server_argc >= CVS_CMD_MAXARG)
1.29      joris     459:                fatal("cvs_server_argument: too many arguments sent");
1.57      ray       460:
                    461:        if (data == NULL)
                    462:                fatal("Missing argument for Argument");
1.29      joris     463:
                    464:        server_argv[server_argc++] = xstrdup(data);
1.37      xsa       465: }
                    466:
                    467: void
                    468: cvs_server_argumentx(char *data)
                    469: {
1.66      joris     470:        int idx;
                    471:        size_t len;
                    472:
                    473:        if (server_argc < 0)
                    474:                fatal("Protocol Error: ArgumentX without previous argument");
                    475:
                    476:        idx = server_argc - 1;
                    477:
                    478:        len = strlen(server_argv[idx]) + strlen(data) + 2;
                    479:        server_argv[idx] = xrealloc(server_argv[idx], len, sizeof(char));
                    480:        strlcat(server_argv[idx], "\n", len);
                    481:        strlcat(server_argv[idx], data, len);
1.44      xsa       482: }
                    483:
                    484: void
                    485: cvs_server_update_patches(char *data)
                    486: {
                    487:        /*
                    488:         * This does not actually do anything.
                    489:         * It is used to tell that the server is able to
                    490:         * generate patches when given an `update' request.
                    491:         * The client must issue the -u argument to `update'
                    492:         * to receive patches.
                    493:         */
1.29      joris     494: }
                    495:
                    496: void
1.31      xsa       497: cvs_server_add(char *data)
                    498: {
                    499:        if (chdir(server_currentdir) == -1)
                    500:                fatal("cvs_server_add: %s", strerror(errno));
                    501:
                    502:        cvs_cmdop = CVS_OP_ADD;
                    503:        cvs_add(server_argc, server_argv);
1.50      joris     504:        cvs_server_send_response("ok");
                    505: }
                    506:
                    507: void
                    508: cvs_server_import(char *data)
                    509: {
                    510:        if (chdir(server_currentdir) == -1)
                    511:                fatal("cvs_server_import: %s", strerror(errno));
                    512:
                    513:        cvs_cmdop = CVS_OP_IMPORT;
                    514:        cvs_import(server_argc, server_argv);
1.31      xsa       515:        cvs_server_send_response("ok");
                    516: }
1.35      xsa       517:
                    518: void
                    519: cvs_server_admin(char *data)
                    520: {
                    521:        if (chdir(server_currentdir) == -1)
                    522:                fatal("cvs_server_admin: %s", strerror(errno));
                    523:
                    524:        cvs_cmdop = CVS_OP_ADMIN;
                    525:        cvs_admin(server_argc, server_argv);
                    526:        cvs_server_send_response("ok");
                    527: }
                    528:
1.40      xsa       529: void
                    530: cvs_server_annotate(char *data)
                    531: {
                    532:        if (chdir(server_currentdir) == -1)
                    533:                fatal("cvs_server_annotate: %s", strerror(errno));
                    534:
                    535:        cvs_cmdop = CVS_OP_ANNOTATE;
                    536:        cvs_annotate(server_argc, server_argv);
                    537:        cvs_server_send_response("ok");
                    538: }
1.31      xsa       539:
                    540: void
1.29      joris     541: cvs_server_commit(char *data)
                    542: {
                    543:        if (chdir(server_currentdir) == -1)
                    544:                fatal("cvs_server_commit: %s", strerror(errno));
                    545:
                    546:        cvs_cmdop = CVS_OP_COMMIT;
                    547:        cvs_commit(server_argc, server_argv);
1.49      joris     548:        cvs_server_send_response("ok");
                    549: }
                    550:
                    551: void
                    552: cvs_server_checkout(char *data)
                    553: {      if (chdir(server_currentdir) == -1)
                    554:                fatal("cvs_server_checkout: %s", strerror(errno));
                    555:
                    556:        cvs_cmdop = CVS_OP_CHECKOUT;
                    557:        cvs_checkout(server_argc, server_argv);
1.29      joris     558:        cvs_server_send_response("ok");
                    559: }
                    560:
                    561: void
                    562: cvs_server_diff(char *data)
                    563: {
                    564:        if (chdir(server_currentdir) == -1)
                    565:                fatal("cvs_server_diff: %s", strerror(errno));
                    566:
                    567:        cvs_cmdop = CVS_OP_DIFF;
                    568:        cvs_diff(server_argc, server_argv);
1.34      xsa       569:        cvs_server_send_response("ok");
                    570: }
                    571:
                    572: void
                    573: cvs_server_init(char *data)
                    574: {
1.69    ! tobias    575:        if (data == NULL)
        !           576:                fatal("Missing argument for init");
        !           577:
        !           578:        if (current_cvsroot != NULL)
        !           579:                fatal("Root in combination with init is not supported");
        !           580:
        !           581:        if ((current_cvsroot = cvsroot_get(data)) == NULL)
        !           582:                fatal("Invalid argument for init");
1.34      xsa       583:
                    584:        cvs_cmdop = CVS_OP_INIT;
                    585:        cvs_init(server_argc, server_argv);
1.64      xsa       586:        cvs_server_send_response("ok");
                    587: }
                    588:
                    589: void
                    590: cvs_server_release(char *data)
                    591: {
                    592:        if (chdir(server_currentdir) == -1)
1.67      xsa       593:                fatal("cvs_server_release: %s", strerror(errno));
1.64      xsa       594:
                    595:        cvs_cmdop = CVS_OP_RELEASE;
                    596:        cvs_release(server_argc, server_argv);
1.31      xsa       597:        cvs_server_send_response("ok");
                    598: }
                    599:
                    600: void
                    601: cvs_server_remove(char *data)
                    602: {
                    603:        if (chdir(server_currentdir) == -1)
                    604:                fatal("cvs_server_remove: %s", strerror(errno));
                    605:
                    606:        cvs_cmdop = CVS_OP_REMOVE;
                    607:        cvs_remove(server_argc, server_argv);
1.29      joris     608:        cvs_server_send_response("ok");
                    609: }
                    610:
                    611: void
                    612: cvs_server_status(char *data)
                    613: {
                    614:        if (chdir(server_currentdir) == -1)
                    615:                fatal("cvs_server_status: %s", strerror(errno));
                    616:
                    617:        cvs_cmdop = CVS_OP_STATUS;
                    618:        cvs_status(server_argc, server_argv);
                    619:        cvs_server_send_response("ok");
                    620: }
                    621:
                    622: void
                    623: cvs_server_log(char *data)
                    624: {
                    625:        if (chdir(server_currentdir) == -1)
                    626:                fatal("cvs_server_log: %s", strerror(errno));
                    627:
                    628:        cvs_cmdop = CVS_OP_LOG;
1.62      niallo    629:        cvs_getlog(server_argc, server_argv);
                    630:        cvs_server_send_response("ok");
                    631: }
                    632:
                    633: void
                    634: cvs_server_rlog(char *data)
                    635: {
                    636:        char fpath[MAXPATHLEN];
                    637:        struct cvsroot *cvsroot;
                    638:
                    639:        cvsroot = cvsroot_get(NULL);
                    640:
                    641:        (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s",
                    642:            cvsroot->cr_dir, server_currentdir);
                    643:
                    644:        if (chdir(fpath) == -1)
1.67      xsa       645:                fatal("cvs_server_rlog: %s", strerror(errno));
1.62      niallo    646:
                    647:        cvs_cmdop = CVS_OP_RLOG;
1.32      xsa       648:        cvs_getlog(server_argc, server_argv);
                    649:        cvs_server_send_response("ok");
                    650: }
                    651:
                    652: void
                    653: cvs_server_tag(char *data)
                    654: {
                    655:        if (chdir(server_currentdir) == -1)
                    656:                fatal("cvs_server_tag: %s", strerror(errno));
                    657:
                    658:        cvs_cmdop = CVS_OP_TAG;
1.33      xsa       659:        cvs_tag(server_argc, server_argv);
1.29      joris     660:        cvs_server_send_response("ok");
                    661: }
                    662:
                    663: void
                    664: cvs_server_update(char *data)
                    665: {
                    666:        if (chdir(server_currentdir) == -1)
                    667:                fatal("cvs_server_update: %s", strerror(errno));
1.14      joris     668:
1.29      joris     669:        cvs_cmdop = CVS_OP_UPDATE;
                    670:        cvs_update(server_argc, server_argv);
1.36      xsa       671:        cvs_server_send_response("ok");
                    672: }
                    673:
                    674: void
                    675: cvs_server_version(char *data)
                    676: {
                    677:        cvs_cmdop = CVS_OP_VERSION;
                    678:        cvs_version(server_argc, server_argv);
1.29      joris     679:        cvs_server_send_response("ok");
1.47      joris     680: }
                    681:
                    682: void
                    683: cvs_server_update_entry(const char *resp, struct cvs_file *cf)
                    684: {
1.58      ray       685:        char *p;
1.65      joris     686:        char repo[MAXPATHLEN], fpath[MAXPATHLEN];
1.47      joris     687:
                    688:        if ((p = strrchr(cf->file_rpath, ',')) != NULL)
                    689:                *p = '\0';
                    690:
1.65      joris     691:        cvs_get_repository_path(cf->file_wd, repo, MAXPATHLEN);
                    692:        (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", repo, cf->file_name);
                    693:
1.58      ray       694:        cvs_server_send_response("%s %s/", resp, cf->file_wd);
1.65      joris     695:        cvs_remote_output(fpath);
1.47      joris     696:
                    697:        if (p != NULL)
                    698:                *p = ',';
1.65      joris     699: }
                    700:
                    701: void
                    702: cvs_server_set_sticky(char *dir, char *tag)
                    703: {
                    704:        char fpath[MAXPATHLEN], tbuf[CVS_ENT_MAXLINELEN];
                    705:
                    706:        (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s",
                    707:            current_cvsroot->cr_dir, dir);
                    708:
                    709:        (void)xsnprintf(tbuf, MAXPATHLEN, "T%s", tag);
                    710:
                    711:        cvs_server_send_response("Set-sticky %s", dir);
                    712:        cvs_remote_output(fpath);
                    713:        cvs_remote_output(tbuf);
                    714: }
                    715:
                    716: void
                    717: cvs_server_clear_sticky(char *dir)
                    718: {
                    719:        char fpath[MAXPATHLEN];
                    720:
                    721:        (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s",
                    722:            current_cvsroot->cr_dir, dir);
                    723:
                    724:        cvs_server_send_response("Clear-sticky %s", dir);
                    725:        cvs_remote_output(fpath);
1.1       jfb       726: }