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

Annotation of src/usr.bin/cvs/client.c, Revision 1.9

1.1       jfb         1: /*     $OpenBSD$       */
                      2: /*
1.9     ! joris       3:  * Copyright (c) 2006 Joris Vink <joris@openbsd.org>
1.1       jfb         4:  *
1.9     ! 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.
        !             8:  *
        !             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.9     ! joris      18: #include "includes.h"
1.1       jfb        19:
                     20: #include "cvs.h"
                     21: #include "log.h"
1.9     ! joris      22: #include "diff.h"
        !            23: #include "remote.h"
1.1       jfb        24:
1.9     ! joris      25: struct cvs_req cvs_requests[] = {
        !            26:        /* this is what our client will use, the server should support it */
        !            27:        { "Root",               1,      cvs_server_root, REQ_NEEDED },
        !            28:        { "Valid-responses",    1,      cvs_server_validresp, REQ_NEEDED },
        !            29:        { "valid-requests",     1,      cvs_server_validreq, REQ_NEEDED },
        !            30:        { "Global_option",      0,      cvs_server_globalopt, REQ_NEEDED },
        !            31:        { "Directory",          0,      cvs_server_directory, REQ_NEEDED },
        !            32:        { "Entry",              0,      cvs_server_entry, REQ_NEEDED },
        !            33:        { "Modified",           0,      cvs_server_modified, REQ_NEEDED },
        !            34:        { "UseUnchanged",       0,      cvs_server_useunchanged, REQ_NEEDED },
        !            35:        { "Unchanged",          0,      cvs_server_unchanged, REQ_NEEDED },
        !            36:        { "Questionable",       0,      cvs_server_questionable, REQ_NEEDED },
        !            37:        { "Argument",           0,      cvs_server_argument, REQ_NEEDED },
1.1       jfb        38:
1.9     ! joris      39:        /*
        !            40:         * used to tell the server what is going on in our
        !            41:         * working copy, unsupported until we are told otherwise
        !            42:         */
        !            43:        { "Max-dotdot",                 0,      NULL, 0 },
        !            44:        { "Static-directory",           0,      NULL, 0 },
        !            45:        { "Sticky",                     0,      NULL, 0 },
        !            46:        { "Checkin-prog",               0,      NULL, 0 },
        !            47:        { "Update-prog",                0,      NULL, 0 },
        !            48:        { "Kopt",                       0,      NULL, 0 },
        !            49:        { "Checkin-time",               0,      NULL, 0 },
        !            50:        { "Is-modified",                0,      NULL, 0 },
        !            51:        { "Notify",                     0,      NULL, 0 },
        !            52:        { "Case",                       0,      NULL, 0 },
        !            53:        { "Argumentx",                  0,      NULL, 0 },
        !            54:        { "Gzip-stream",                0,      NULL, 0 },
        !            55:        { "Kerberos-encrypt",           0,      NULL, 0 },
        !            56:        { "Gssapi-encrypt",             0,      NULL, 0 },
        !            57:        { "Gssapi-authenticate",        0,      NULL, 0 },
        !            58:        { "Set",                        0,      NULL, 0 },
        !            59:        { "expand-modules",             0,      NULL, 0 },
        !            60:
        !            61:        /* commands that might be supported */
        !            62:        { "ci",                         0,      cvs_server_commit, 0 },
        !            63:        { "co",                         0,      NULL, 0 },
        !            64:        { "diff",                       0,      cvs_server_diff, 0 },
        !            65:        { "tag",                        0,      NULL, 0 },
        !            66:        { "status",                     0,      cvs_server_status, 0 },
        !            67:        { "admin",                      0,      NULL, 0 },
        !            68:        { "history",                    0,      NULL, 0 },
        !            69:        { "watchers",                   0,      NULL, 0 },
        !            70:        { "editors",                    0,      NULL, 0 },
        !            71:        { "annotate",                   0,      NULL, 0 },
        !            72:        { "log",                        0,      cvs_server_log, 0 },
        !            73:        { "export",                     0,      NULL, 0 },
        !            74:        { "rdiff",                      0,      NULL, 0 },
        !            75:        { "rtag",                       0,      NULL, 0 },
        !            76:        { "init",                       0,      NULL, 0 },
        !            77:        { "update",                     0,      cvs_server_update, 0 },
        !            78:        { "import",                     0,      NULL, 0 },
        !            79:        { "add",                        0,      NULL, 0 },
        !            80:        { "remove",                     0,      NULL, 0 },
        !            81:        { "watch-on",                   0,      NULL, 0 },
        !            82:        { "watch-off",                  0,      NULL, 0 },
        !            83:        { "watch-add",                  0,      NULL, 0 },
        !            84:        { "watch-remove",               0,      NULL, 0 },
        !            85:        { "release",                    0,      NULL, 0 },
        !            86:        { "noop",                       0,      NULL, 0 },
        !            87:        { "update-patches",             0,      NULL, 0 },
        !            88:        { "gzip-file-contents",         0,      NULL, 0 },
        !            89:        { "wrapper-sendme-rcsOptions",  0,      NULL, 0 },
        !            90:        { "",                           -1,     NULL, 0 }
        !            91: };
        !            92:
        !            93: static char *client_get_supported_responses(void);
        !            94: static char *lastdir = NULL;
        !            95: static int end_of_response = 0;
        !            96:
        !            97: static char *
        !            98: client_get_supported_responses(void)
        !            99: {
        !           100:        BUF *bp;
        !           101:        char *d;
        !           102:        int i, first;
        !           103:
        !           104:        first = 0;
        !           105:        bp = cvs_buf_alloc(512, BUF_AUTOEXT);
        !           106:        for (i = 0; cvs_responses[i].supported != -1; i++) {
        !           107:                if (cvs_responses[i].hdlr == NULL)
        !           108:                        continue;
        !           109:
        !           110:                if (first != 0)
        !           111:                        cvs_buf_append(bp, " ", 1);
        !           112:                else
        !           113:                        first++;
        !           114:                cvs_buf_append(bp, cvs_responses[i].name,
        !           115:                    strlen(cvs_responses[i].name));
        !           116:        }
        !           117:
        !           118:        cvs_buf_putc(bp, '\0');
        !           119:        d = cvs_buf_release(bp);
        !           120:        return (d);
        !           121: }
1.1       jfb       122:
1.9     ! joris     123: void
        !           124: cvs_client_connect_to_server(void)
        !           125: {
        !           126:        char *cmd, *argv[9], *resp;
        !           127:        int ifd[2], ofd[2], argc;
1.1       jfb       128:
1.9     ! joris     129:        switch (current_cvsroot->cr_method) {
        !           130:        case CVS_METHOD_PSERVER:
        !           131:        case CVS_METHOD_KSERVER:
        !           132:        case CVS_METHOD_GSERVER:
        !           133:        case CVS_METHOD_FORK:
        !           134:        case CVS_METHOD_EXT:
        !           135:                fatal("the specified connection method is not support");
        !           136:        default:
        !           137:                break;
        !           138:        }
        !           139:
        !           140:        if (pipe(ifd) == -1)
        !           141:                fatal("cvs_client_connect: %s", strerror(errno));
        !           142:        if (pipe(ofd) == -1)
        !           143:                fatal("cvs_client_connect: %s", strerror(errno));
        !           144:
        !           145:        switch (fork()) {
        !           146:        case -1:
        !           147:                fatal("cvs_client_connect: fork failed: %s", strerror(errno));
        !           148:        case 0:
        !           149:                if (dup2(ifd[0], STDIN_FILENO) == -1)
        !           150:                        fatal("cvs_client_connect: %s", strerror(errno));
        !           151:                if (dup2(ofd[1], STDOUT_FILENO) == -1)
        !           152:                        fatal("cvs_client_connect: %s", strerror(errno));
1.1       jfb       153:
1.9     ! joris     154:                close(ifd[1]);
        !           155:                close(ofd[0]);
1.1       jfb       156:
1.9     ! joris     157:                if ((cmd = getenv("CVS_SERVER")) == NULL)
        !           158:                        cmd = CVS_SERVER_DEFAULT;
1.1       jfb       159:
                    160:                argc = 0;
                    161:                argv[argc++] = cvs_rsh;
                    162:
1.9     ! joris     163:                if (current_cvsroot->cr_user != NULL) {
1.1       jfb       164:                        argv[argc++] = "-l";
1.9     ! joris     165:                        argv[argc++] = current_cvsroot->cr_user;
1.1       jfb       166:                }
                    167:
1.9     ! joris     168:                argv[argc++] = current_cvsroot->cr_host;
        !           169:                argv[argc++] = cmd;
1.1       jfb       170:                argv[argc++] = "server";
                    171:                argv[argc] = NULL;
                    172:
1.9     ! joris     173:                cvs_log(LP_TRACE, "connecting to server %s",
        !           174:                    current_cvsroot->cr_host);
        !           175:
1.1       jfb       176:                execvp(argv[0], argv);
1.9     ! joris     177:                fatal("cvs_client_connect: failed to execute cvs server");
        !           178:        default:
        !           179:                break;
1.1       jfb       180:        }
                    181:
1.9     ! joris     182:        close(ifd[0]);
        !           183:        close(ofd[1]);
        !           184:
        !           185:        if ((current_cvsroot->cr_srvin = fdopen(ifd[1], "w")) == NULL)
        !           186:                fatal("cvs_client_connect: %s", strerror(errno));
        !           187:        if ((current_cvsroot->cr_srvout = fdopen(ofd[0], "r")) == NULL)
        !           188:                fatal("cvs_client_connect: %s", strerror(errno));
1.1       jfb       189:
1.9     ! joris     190:        setvbuf(current_cvsroot->cr_srvin, NULL,_IOLBF, 0);
        !           191:        setvbuf(current_cvsroot->cr_srvout, NULL, _IOLBF, 0);
1.1       jfb       192:
1.9     ! joris     193:        cvs_client_send_request("Root %s", current_cvsroot->cr_dir);
1.1       jfb       194:
1.9     ! joris     195:        resp = client_get_supported_responses();
        !           196:        cvs_client_send_request("Valid-responses %s", resp);
        !           197:        xfree(resp);
1.1       jfb       198:
1.9     ! joris     199:        cvs_client_send_request("valid-requests");
        !           200:        cvs_client_get_responses();
1.1       jfb       201:
1.9     ! joris     202:        if (cvs_trace)
        !           203:                cvs_client_send_request("Global_option -t");
1.1       jfb       204:
1.9     ! joris     205:        if (verbosity == 2)
        !           206:                cvs_client_send_request("Global_option -V");
1.1       jfb       207:
1.9     ! joris     208:        cvs_client_send_request("UseUnchanged");
1.1       jfb       209: }
                    210:
1.9     ! joris     211: void
        !           212: cvs_client_send_request(char *fmt, ...)
        !           213: {
        !           214:        va_list ap;
        !           215:        char *data, *s;
        !           216:        struct cvs_req *req;
        !           217:
        !           218:        va_start(ap, fmt);
        !           219:        vasprintf(&data, fmt, ap);
        !           220:        va_end(ap);
1.1       jfb       221:
1.9     ! joris     222:        if ((s = strchr(data, ' ')) != NULL)
        !           223:                *s = '\0';
1.1       jfb       224:
1.9     ! joris     225:        req = cvs_remote_get_request_info(data);
        !           226:        if (req == NULL)
        !           227:                fatal("'%s' is an unknown request", data);
1.1       jfb       228:
1.9     ! joris     229:        if (req->supported != 1)
        !           230:                fatal("remote cvs server does not support '%s'", data);
1.1       jfb       231:
1.9     ! joris     232:        if (s != NULL)
        !           233:                *s = ' ';
1.1       jfb       234:
1.9     ! joris     235:        cvs_remote_output(data);
        !           236:        xfree(data);
        !           237: }
1.1       jfb       238:
1.9     ! joris     239: void
        !           240: cvs_client_read_response(void)
1.1       jfb       241: {
1.9     ! joris     242:        char *cmd, *data;
        !           243:        struct cvs_resp *resp;
1.1       jfb       244:
1.9     ! joris     245:        cmd = cvs_remote_input();
        !           246:        if ((data = strchr(cmd, ' ')) != NULL)
        !           247:                (*data++) = '\0';
1.1       jfb       248:
1.9     ! joris     249:        resp = cvs_remote_get_response_info(cmd);
        !           250:        if (resp == NULL)
        !           251:                fatal("response '%s' is not supported by our client", cmd);
1.1       jfb       252:
1.9     ! joris     253:        if (resp->hdlr == NULL)
        !           254:                fatal("opencvs client does not support '%s'", cmd);
1.1       jfb       255:
1.9     ! joris     256:        (*resp->hdlr)(data);
        !           257:        xfree(cmd);
1.1       jfb       258: }
                    259:
1.9     ! joris     260: void
        !           261: cvs_client_get_responses(void)
        !           262: {
        !           263:        while (end_of_response != 1)
        !           264:                cvs_client_read_response();
1.1       jfb       265:
1.9     ! joris     266:        end_of_response = 0;
        !           267: }
1.1       jfb       268:
1.9     ! joris     269: void
        !           270: cvs_client_senddir(const char *dir)
1.1       jfb       271: {
1.9     ! joris     272:        char *repo;
        !           273:
        !           274:        cvs_log(LP_TRACE, "cvs_client_senddir(%s)", dir);
        !           275:
        !           276:        if (lastdir != NULL && !strcmp(dir, lastdir))
        !           277:                return;
1.1       jfb       278:
1.9     ! joris     279:        cvs_client_send_request("Directory %s", dir);
1.1       jfb       280:
1.9     ! joris     281:        repo = xmalloc(MAXPATHLEN);
        !           282:        cvs_get_repository_path(dir, repo, MAXPATHLEN);
        !           283:        cvs_remote_output(repo);
        !           284:        xfree(repo);
1.1       jfb       285:
1.9     ! joris     286:        if (lastdir != NULL)
        !           287:                xfree(lastdir);
        !           288:        lastdir = xstrdup(dir);
        !           289: }
1.1       jfb       290:
1.9     ! joris     291: void
        !           292: cvs_client_sendfile(struct cvs_file *cf)
1.1       jfb       293: {
1.9     ! joris     294:        int l;
        !           295:        size_t len;
        !           296:        char rev[16], timebuf[64], sticky[32];
1.1       jfb       297:
1.9     ! joris     298:        if (cf->file_type != CVS_FILE)
        !           299:                return;
1.1       jfb       300:
1.9     ! joris     301:        cvs_client_senddir(cf->file_wd);
1.1       jfb       302:
1.9     ! joris     303:        cvs_log(LP_TRACE, "cvs_client_sendfile(%s)", cf->file_path);
        !           304:        cvs_remote_classify_file(cf);
        !           305:
        !           306:        if (cf->file_ent != NULL) {
        !           307:                if (cf->file_status == FILE_ADDED) {
        !           308:                        len = strlcpy(rev, "0", sizeof(rev));
        !           309:                        if (len >= sizeof(rev))
        !           310:                                fatal("cvs_client_sendfile: truncation");
        !           311:
        !           312:                        len = strlcpy(timebuf, "Initial ", sizeof(timebuf));
        !           313:                        if (len >= sizeof(timebuf))
        !           314:                                fatal("cvs_client_sendfile: truncation");
        !           315:
        !           316:                        len = strlcat(timebuf, cf->file_name, sizeof(timebuf));
        !           317:                        if (len >= sizeof(timebuf))
        !           318:                                fatal("cvs_client_sendfile: truncation");
        !           319:                } else {
        !           320:                        rcsnum_tostr(cf->file_ent->ce_rev, rev, sizeof(rev));
        !           321:                        ctime_r(&cf->file_ent->ce_mtime, timebuf);
        !           322:                }
1.1       jfb       323:
1.9     ! joris     324:                if (cf->file_ent->ce_conflict == NULL) {
        !           325:                        if (timebuf[strlen(timebuf) - 1] == '\n')
        !           326:                                timebuf[strlen(timebuf) - 1] = '\0';
        !           327:                } else {
        !           328:                        len = strlcpy(timebuf, cf->file_ent->ce_conflict,
        !           329:                            sizeof(timebuf));
        !           330:                        if (len >= sizeof(timebuf))
        !           331:                                fatal("cvs_client_sendfile: truncation");
        !           332:                }
1.1       jfb       333:
1.9     ! joris     334:                sticky[0] = '\0';
        !           335:                if (cf->file_ent->ce_tag != NULL) {
        !           336:                        l = snprintf(sticky, sizeof(sticky), "T%s",
        !           337:                            cf->file_ent->ce_tag);
        !           338:                        if (l == -1 || l >= (int)sizeof(sticky))
        !           339:                                fatal("cvs_client_sendfile: overflow");
1.1       jfb       340:                }
                    341:
1.9     ! joris     342:                cvs_client_send_request("Entry /%s/%s%s/%s/%s/",
        !           343:                    cf->file_name, (cf->file_status == FILE_REMOVED) ? "-" : "",
        !           344:                   rev, timebuf, sticky);
        !           345:        }
        !           346:
        !           347:        switch (cf->file_status) {
        !           348:        case FILE_UNKNOWN:
        !           349:                if (cf->fd != -1)
        !           350:                        cvs_client_send_request("Questionable %s",
        !           351:                            cf->file_name);
        !           352:                break;
        !           353:        case FILE_ADDED:
        !           354:        case FILE_MODIFIED:
        !           355:                cvs_client_send_request("Modified %s", cf->file_name);
        !           356:                cvs_remote_send_file(cf->file_path);
        !           357:                break;
        !           358:        case FILE_UPTODATE:
        !           359:                cvs_client_send_request("Unchanged %s", cf->file_name);
        !           360:                break;
1.1       jfb       361:        }
1.9     ! joris     362: }
1.1       jfb       363:
1.9     ! joris     364: void
        !           365: cvs_client_send_files(char **argv, int argc)
        !           366: {
        !           367:        int i;
1.1       jfb       368:
1.9     ! joris     369:        for (i = 0; i < argc; i++)
        !           370:                cvs_client_send_request("Argument %s", argv[i]);
        !           371: }
1.1       jfb       372:
1.9     ! joris     373: void
        !           374: cvs_client_ok(char *data)
        !           375: {
        !           376:        cvs_log(LP_TRACE, "cvs_client_ok()");
        !           377:        end_of_response = 1;
1.1       jfb       378: }
                    379:
1.9     ! joris     380: void
        !           381: cvs_client_error(char *data)
        !           382: {
        !           383:        cvs_log(LP_TRACE, "cvs_client_error()");
        !           384:        end_of_response = 1;
        !           385: }
1.1       jfb       386:
1.9     ! joris     387: void
        !           388: cvs_client_validreq(char *data)
1.1       jfb       389: {
1.9     ! joris     390:        int i;
        !           391:        char *sp, *ep;
        !           392:        struct cvs_req *req;
        !           393:
        !           394:        sp = data;
        !           395:        do {
        !           396:                if ((ep = strchr(sp, ' ')) != NULL)
        !           397:                        *ep = '\0';
        !           398:
        !           399:                req = cvs_remote_get_request_info(sp);
        !           400:                if (req != NULL)
        !           401:                        req->supported = 1;
        !           402:
        !           403:                if (ep != NULL)
        !           404:                        sp = ep + 1;
        !           405:        } while (ep != NULL);
        !           406:
        !           407:        for (i = 0; cvs_requests[i].supported != -1; i++) {
        !           408:                req = &cvs_requests[i];
        !           409:                if ((req->flags & REQ_NEEDED) &&
        !           410:                    req->supported != 1) {
        !           411:                        fatal("server does not support required '%s'",
        !           412:                            req->name);
        !           413:                }
1.1       jfb       414:        }
1.9     ! joris     415: }
1.1       jfb       416:
1.9     ! joris     417: void
        !           418: cvs_client_e(char *data)
        !           419: {
        !           420:        cvs_printf("%s\n", data);
        !           421: }
1.1       jfb       422:
1.9     ! joris     423: void
        !           424: cvs_client_m(char *data)
        !           425: {
        !           426:        cvs_printf("%s\n", data);
        !           427: }
1.1       jfb       428:
1.9     ! joris     429: void
        !           430: cvs_client_checkedin(char *data)
        !           431: {
        !           432:        int l;
        !           433:        CVSENTRIES *entlist;
        !           434:        struct cvs_ent *ent, *newent;
        !           435:        char *dir, *entry, rev[16], timebuf[64], sticky[16];
1.1       jfb       436:
1.9     ! joris     437:        cvs_log(LP_TRACE, "cvs_client_checkedin(%s)", data);
1.1       jfb       438:
1.9     ! joris     439:        dir = cvs_remote_input();
        !           440:        entry = cvs_remote_input();
        !           441:        xfree(dir);
1.1       jfb       442:
1.9     ! joris     443:        entlist = cvs_ent_open(data);
        !           444:        newent = cvs_ent_parse(entry);
        !           445:        ent = cvs_ent_get(entlist, newent->ce_name);
        !           446:        xfree(entry);
1.1       jfb       447:
1.9     ! joris     448:        entry = xmalloc(CVS_ENT_MAXLINELEN);
1.1       jfb       449:
1.9     ! joris     450:        rcsnum_tostr(newent->ce_rev, rev, sizeof(rev));
        !           451:        ctime_r(&ent->ce_mtime, timebuf);
        !           452:        if (timebuf[strlen(timebuf) - 1] == '\n')
        !           453:                timebuf[strlen(timebuf) - 1] = '\0';
1.1       jfb       454:
1.9     ! joris     455:        sticky[0] = '\0';
        !           456:        if (ent->ce_tag != NULL) {
        !           457:                l = snprintf(sticky, sizeof(sticky), "T%s", ent->ce_tag);
        !           458:                if (l == -1 || l >= (int)sizeof(sticky))
        !           459:                        fatal("cvs_client_checkedin: overflow");
1.2       jfb       460:        }
1.1       jfb       461:
1.9     ! joris     462:        l = snprintf(entry, CVS_ENT_MAXLINELEN, "/%s/%s/%s//%s/",
        !           463:            newent->ce_name, rev, timebuf, sticky);
        !           464:        if (l == -1 || l >= CVS_ENT_MAXLINELEN)
        !           465:                fatal("cvs_client_checkedin: overflow");
        !           466:
        !           467:        cvs_ent_free(ent);
        !           468:        cvs_ent_free(newent);
        !           469:        cvs_ent_add(entlist, entry);
        !           470:        cvs_ent_close(entlist, ENT_SYNC);
1.1       jfb       471:
1.9     ! joris     472:        xfree(entry);
1.1       jfb       473: }
                    474:
1.9     ! joris     475: void
        !           476: cvs_client_updated(char *data)
        !           477: {
        !           478:        BUF *bp;
        !           479:        int l, fd;
        !           480:        time_t now;
        !           481:        mode_t fmode;
        !           482:        size_t flen;
        !           483:        CVSENTRIES *ent;
        !           484:        struct cvs_ent *e;
        !           485:        const char *errstr;
        !           486:        struct timeval tv[2];
        !           487:        char timebuf[32], *repo, *rpath, *entry, *mode;
        !           488:        char revbuf[32], *len, *fpath, *wdir;
        !           489:
        !           490:        cvs_log(LP_TRACE, "cvs_client_updated(%s)", data);
        !           491:
        !           492:        rpath = cvs_remote_input();
        !           493:        entry = cvs_remote_input();
        !           494:        mode = cvs_remote_input();
        !           495:        len = cvs_remote_input();
        !           496:
        !           497:        repo = xmalloc(MAXPATHLEN);
        !           498:        cvs_get_repository_path(".", repo, MAXPATHLEN);
        !           499:
        !           500:        if (strlen(repo) + 1 > strlen(rpath))
        !           501:                fatal("received a repository path that is too short");
        !           502:
        !           503:        fpath = rpath + strlen(repo) + 1;
        !           504:        if ((wdir = dirname(fpath)) == NULL)
        !           505:                fatal("cvs_client_updated: dirname: %s", strerror(errno));
        !           506:        xfree(repo);
        !           507:
        !           508:        flen = strtonum(len, 0, INT_MAX, &errstr);
        !           509:        if (errstr != NULL)
        !           510:                fatal("cvs_client_updated: %s: %s", len, errstr);
        !           511:        xfree(len);
        !           512:
        !           513:        cvs_strtomode(mode, &fmode);
        !           514:        xfree(mode);
        !           515:
        !           516:        time(&now);
        !           517:        now = cvs_hack_time(now, 0);
        !           518:        ctime_r(&now, timebuf);
        !           519:        if (timebuf[strlen(timebuf) - 1] == '\n')
        !           520:                timebuf[strlen(timebuf) - 1] = '\0';
        !           521:
        !           522:        e = cvs_ent_parse(entry);
        !           523:        xfree(entry);
        !           524:        rcsnum_tostr(e->ce_rev, revbuf, sizeof(revbuf));
        !           525:        entry = xmalloc(CVS_ENT_MAXLINELEN);
        !           526:        l = snprintf(entry, CVS_ENT_MAXLINELEN, "/%s/%s/%s//", e->ce_name,
        !           527:            revbuf, timebuf);
        !           528:        if (l == -1 || l >= CVS_ENT_MAXLINELEN)
        !           529:                fatal("cvs_client_updated: overflow");
        !           530:
        !           531:        cvs_ent_free(e);
        !           532:        ent = cvs_ent_open(wdir);
        !           533:        cvs_ent_add(ent, entry);
        !           534:        cvs_ent_close(ent, ENT_SYNC);
        !           535:        xfree(entry);
        !           536:
        !           537:        bp = cvs_remote_receive_file(flen);
        !           538:        if ((fd = open(fpath, O_CREAT | O_WRONLY | O_TRUNC)) == -1)
        !           539:                fatal("cvs_client_updated: open: %s: %s",
        !           540:                    fpath, strerror(errno));
1.1       jfb       541:
1.9     ! joris     542:        if (cvs_buf_write_fd(bp, fd) == -1)
        !           543:                fatal("cvs_client_updated: cvs_buf_write_fd failed for %s",
        !           544:                    fpath);
1.1       jfb       545:
1.9     ! joris     546:        cvs_buf_free(bp);
1.1       jfb       547:
1.9     ! joris     548:        now = cvs_hack_time(now, 0);
        !           549:        tv[0].tv_sec = now;
        !           550:        tv[0].tv_usec = 0;
        !           551:        tv[1] = tv[0];
1.1       jfb       552:
1.9     ! joris     553:        if (futimes(fd, tv) == -1)
        !           554:                fatal("cvs_client_updated: futimes: %s", strerror(errno));
1.1       jfb       555:
1.9     ! joris     556:        if (fchmod(fd, fmode) == -1)
        !           557:                fatal("cvs_client_updated: fchmod: %s", strerror(errno));
1.1       jfb       558:
1.9     ! joris     559:        (void)close(fd);
1.1       jfb       560:
1.9     ! joris     561:        xfree(rpath);
1.1       jfb       562: }
                    563:
1.9     ! joris     564: void
        !           565: cvs_client_merged(char *data)
        !           566: {
        !           567:        cvs_log(LP_TRACE, "cvs_client_merged(%s)", data);
        !           568: }
1.1       jfb       569:
1.9     ! joris     570: void
        !           571: cvs_client_removed(char *data)
        !           572: {
        !           573:        cvs_log(LP_TRACE, "cvs_client_removed(%s)", data);
        !           574: }
1.1       jfb       575:
1.9     ! joris     576: void
        !           577: cvs_client_remove_entry(char *data)
1.1       jfb       578: {
1.9     ! joris     579:        char *dir;
1.1       jfb       580:
1.9     ! joris     581:        cvs_log(LP_TRACE, "cvs_client_remove_entry(%s)", data);
1.1       jfb       582:
1.9     ! joris     583:        dir = cvs_remote_input();
        !           584:        xfree(dir);
1.1       jfb       585: }