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