7 #include "run-command.h"
11 static struct remote
*remote
;
12 static const char *url
; /* always ends with a trailing slash */
17 unsigned progress
: 1,
22 static struct options options
;
24 static int set_option(const char *name
, const char *value
)
26 if (!strcmp(name
, "verbosity")) {
28 int v
= strtol(value
, &end
, 10);
29 if (value
== end
|| *end
)
31 options
.verbosity
= v
;
34 else if (!strcmp(name
, "progress")) {
35 if (!strcmp(value
, "true"))
37 else if (!strcmp(value
, "false"))
43 else if (!strcmp(name
, "depth")) {
45 unsigned long v
= strtoul(value
, &end
, 10);
46 if (value
== end
|| *end
)
51 else if (!strcmp(name
, "followtags")) {
52 if (!strcmp(value
, "true"))
53 options
.followtags
= 1;
54 else if (!strcmp(value
, "false"))
55 options
.followtags
= 0;
60 else if (!strcmp(name
, "dry-run")) {
61 if (!strcmp(value
, "true"))
63 else if (!strcmp(value
, "false"))
70 return 1 /* unsupported */;
80 unsigned proto_git
: 1;
82 static struct discovery
*last_discovery
;
84 static struct ref
*parse_git_refs(struct discovery
*heads
, int for_push
)
86 struct ref
*list
= NULL
;
87 get_remote_heads(-1, heads
->buf
, heads
->len
, &list
,
88 for_push
? REF_NORMAL
: 0, NULL
);
92 static struct ref
*parse_info_refs(struct discovery
*heads
)
94 char *data
, *start
, *mid
;
98 struct ref
*refs
= NULL
;
99 struct ref
*ref
= NULL
;
100 struct ref
*last_ref
= NULL
;
105 while (i
< heads
->len
) {
111 if (data
[i
] == '\n') {
112 if (mid
- start
!= 40)
113 die("%sinfo/refs not valid: is this a git repository?", url
);
116 ref
= xmalloc(sizeof(struct ref
) +
117 strlen(ref_name
) + 1);
118 memset(ref
, 0, sizeof(struct ref
));
119 strcpy(ref
->name
, ref_name
);
120 get_sha1_hex(start
, ref
->old_sha1
);
124 last_ref
->next
= ref
;
131 ref
= alloc_ref("HEAD");
132 if (!http_fetch_ref(url
, ref
) &&
133 !resolve_remote_symref(ref
, refs
)) {
143 static void free_discovery(struct discovery
*d
)
146 if (d
== last_discovery
)
147 last_discovery
= NULL
;
154 static int show_http_message(struct strbuf
*type
, struct strbuf
*msg
)
159 * We only show text/plain parts, as other types are likely
160 * to be ugly to look at on the user's terminal.
162 * TODO should handle "; charset=XXX", and re-encode into
165 if (strcasecmp(type
->buf
, "text/plain"))
174 eol
= strchrnul(p
, '\n');
175 fprintf(stderr
, "remote: %.*s\n", (int)(eol
- p
), p
);
181 static struct discovery
* discover_refs(const char *service
, int for_push
)
183 struct strbuf exp
= STRBUF_INIT
;
184 struct strbuf type
= STRBUF_INIT
;
185 struct strbuf buffer
= STRBUF_INIT
;
186 struct discovery
*last
= last_discovery
;
188 int http_ret
, maybe_smart
= 0;
190 if (last
&& !strcmp(service
, last
->service
))
192 free_discovery(last
);
194 strbuf_addf(&buffer
, "%sinfo/refs", url
);
195 if ((!prefixcmp(url
, "http://") || !prefixcmp(url
, "https://")) &&
196 git_env_bool("GIT_SMART_HTTP", 1)) {
198 if (!strchr(url
, '?'))
199 strbuf_addch(&buffer
, '?');
201 strbuf_addch(&buffer
, '&');
202 strbuf_addf(&buffer
, "service=%s", service
);
204 refs_url
= strbuf_detach(&buffer
, NULL
);
206 http_ret
= http_get_strbuf(refs_url
, &type
, &buffer
,
207 HTTP_NO_CACHE
| HTTP_KEEP_ERROR
);
211 case HTTP_MISSING_TARGET
:
212 show_http_message(&type
, &buffer
);
213 die("repository '%s' not found", url
);
215 show_http_message(&type
, &buffer
);
216 die("Authentication failed for '%s'", url
);
218 show_http_message(&type
, &buffer
);
219 die("unable to access '%s': %s", url
, curl_errorstr
);
222 last
= xcalloc(1, sizeof(*last_discovery
));
223 last
->service
= service
;
224 last
->buf_alloc
= strbuf_detach(&buffer
, &last
->len
);
225 last
->buf
= last
->buf_alloc
;
227 strbuf_addf(&exp
, "application/x-%s-advertisement", service
);
229 (5 <= last
->len
&& last
->buf
[4] == '#') &&
230 !strbuf_cmp(&exp
, &type
)) {
234 * smart HTTP response; validate that the service
235 * pkt-line matches our request.
237 line
= packet_read_line_buf(&last
->buf
, &last
->len
, NULL
);
240 strbuf_addf(&exp
, "# service=%s", service
);
241 if (strcmp(line
, exp
.buf
))
242 die("invalid server response; got '%s'", line
);
243 strbuf_release(&exp
);
245 /* The header can include additional metadata lines, up
246 * until a packet flush marker. Ignore these now, but
247 * in the future we might start to scan them.
249 while (packet_read_line_buf(&last
->buf
, &last
->len
, NULL
))
256 last
->refs
= parse_git_refs(last
, for_push
);
258 last
->refs
= parse_info_refs(last
);
261 strbuf_release(&exp
);
262 strbuf_release(&type
);
263 strbuf_release(&buffer
);
264 last_discovery
= last
;
268 static struct ref
*get_refs(int for_push
)
270 struct discovery
*heads
;
273 heads
= discover_refs("git-receive-pack", for_push
);
275 heads
= discover_refs("git-upload-pack", for_push
);
280 static void output_refs(struct ref
*refs
)
283 for (posn
= refs
; posn
; posn
= posn
->next
) {
285 printf("@%s %s\n", posn
->symref
, posn
->name
);
287 printf("%s %s\n", sha1_to_hex(posn
->old_sha1
), posn
->name
);
294 const char *service_name
;
296 struct strbuf
*stdin_preamble
;
298 char *hdr_content_type
;
306 struct strbuf result
;
307 unsigned gzip_request
: 1;
308 unsigned initial_buffer
: 1;
311 static size_t rpc_out(void *ptr
, size_t eltsize
,
312 size_t nmemb
, void *buffer_
)
314 size_t max
= eltsize
* nmemb
;
315 struct rpc_state
*rpc
= buffer_
;
316 size_t avail
= rpc
->len
- rpc
->pos
;
319 rpc
->initial_buffer
= 0;
320 avail
= packet_read(rpc
->out
, NULL
, NULL
, rpc
->buf
, rpc
->alloc
, 0);
329 memcpy(ptr
, rpc
->buf
+ rpc
->pos
, avail
);
334 #ifndef NO_CURL_IOCTL
335 static curlioerr
rpc_ioctl(CURL
*handle
, int cmd
, void *clientp
)
337 struct rpc_state
*rpc
= clientp
;
343 case CURLIOCMD_RESTARTREAD
:
344 if (rpc
->initial_buffer
) {
348 fprintf(stderr
, "Unable to rewind rpc post data - try increasing http.postBuffer\n");
349 return CURLIOE_FAILRESTART
;
352 return CURLIOE_UNKNOWNCMD
;
357 static size_t rpc_in(char *ptr
, size_t eltsize
,
358 size_t nmemb
, void *buffer_
)
360 size_t size
= eltsize
* nmemb
;
361 struct rpc_state
*rpc
= buffer_
;
362 write_or_die(rpc
->in
, ptr
, size
);
366 static int run_slot(struct active_request_slot
*slot
)
369 struct slot_results results
;
371 slot
->results
= &results
;
372 slot
->curl_result
= curl_easy_perform(slot
->curl
);
373 finish_active_slot(slot
);
375 err
= handle_curl_result(&results
);
376 if (err
!= HTTP_OK
&& err
!= HTTP_REAUTH
) {
377 error("RPC failed; result=%d, HTTP code = %ld",
378 results
.curl_result
, results
.http_code
);
384 static int probe_rpc(struct rpc_state
*rpc
)
386 struct active_request_slot
*slot
;
387 struct curl_slist
*headers
= NULL
;
388 struct strbuf buf
= STRBUF_INIT
;
391 slot
= get_active_slot();
393 headers
= curl_slist_append(headers
, rpc
->hdr_content_type
);
394 headers
= curl_slist_append(headers
, rpc
->hdr_accept
);
396 curl_easy_setopt(slot
->curl
, CURLOPT_NOBODY
, 0);
397 curl_easy_setopt(slot
->curl
, CURLOPT_POST
, 1);
398 curl_easy_setopt(slot
->curl
, CURLOPT_URL
, rpc
->service_url
);
399 curl_easy_setopt(slot
->curl
, CURLOPT_ENCODING
, NULL
);
400 curl_easy_setopt(slot
->curl
, CURLOPT_POSTFIELDS
, "0000");
401 curl_easy_setopt(slot
->curl
, CURLOPT_POSTFIELDSIZE
, 4);
402 curl_easy_setopt(slot
->curl
, CURLOPT_HTTPHEADER
, headers
);
403 curl_easy_setopt(slot
->curl
, CURLOPT_WRITEFUNCTION
, fwrite_buffer
);
404 curl_easy_setopt(slot
->curl
, CURLOPT_FILE
, &buf
);
406 err
= run_slot(slot
);
408 curl_slist_free_all(headers
);
409 strbuf_release(&buf
);
413 static int post_rpc(struct rpc_state
*rpc
)
415 struct active_request_slot
*slot
;
416 struct curl_slist
*headers
= NULL
;
417 int use_gzip
= rpc
->gzip_request
;
418 char *gzip_body
= NULL
;
419 size_t gzip_size
= 0;
420 int err
, large_request
= 0;
422 /* Try to load the entire request, if we can fit it into the
423 * allocated buffer space we can use HTTP/1.0 and avoid the
424 * chunked encoding mess.
427 size_t left
= rpc
->alloc
- rpc
->len
;
428 char *buf
= rpc
->buf
+ rpc
->len
;
431 if (left
< LARGE_PACKET_MAX
) {
437 n
= packet_read(rpc
->out
, NULL
, NULL
, buf
, left
, 0);
445 err
= probe_rpc(rpc
);
446 } while (err
== HTTP_REAUTH
);
451 headers
= curl_slist_append(headers
, rpc
->hdr_content_type
);
452 headers
= curl_slist_append(headers
, rpc
->hdr_accept
);
453 headers
= curl_slist_append(headers
, "Expect:");
456 slot
= get_active_slot();
458 curl_easy_setopt(slot
->curl
, CURLOPT_NOBODY
, 0);
459 curl_easy_setopt(slot
->curl
, CURLOPT_POST
, 1);
460 curl_easy_setopt(slot
->curl
, CURLOPT_URL
, rpc
->service_url
);
461 curl_easy_setopt(slot
->curl
, CURLOPT_ENCODING
, "gzip");
464 /* The request body is large and the size cannot be predicted.
465 * We must use chunked encoding to send it.
467 headers
= curl_slist_append(headers
, "Transfer-Encoding: chunked");
468 rpc
->initial_buffer
= 1;
469 curl_easy_setopt(slot
->curl
, CURLOPT_READFUNCTION
, rpc_out
);
470 curl_easy_setopt(slot
->curl
, CURLOPT_INFILE
, rpc
);
471 #ifndef NO_CURL_IOCTL
472 curl_easy_setopt(slot
->curl
, CURLOPT_IOCTLFUNCTION
, rpc_ioctl
);
473 curl_easy_setopt(slot
->curl
, CURLOPT_IOCTLDATA
, rpc
);
475 if (options
.verbosity
> 1) {
476 fprintf(stderr
, "POST %s (chunked)\n", rpc
->service_name
);
480 } else if (gzip_body
) {
482 * If we are looping to retry authentication, then the previous
483 * run will have set up the headers and gzip buffer already,
484 * and we just need to send it.
486 curl_easy_setopt(slot
->curl
, CURLOPT_POSTFIELDS
, gzip_body
);
487 curl_easy_setopt(slot
->curl
, CURLOPT_POSTFIELDSIZE
, gzip_size
);
489 } else if (use_gzip
&& 1024 < rpc
->len
) {
490 /* The client backend isn't giving us compressed data so
491 * we can try to deflate it ourselves, this may save on.
497 memset(&stream
, 0, sizeof(stream
));
498 git_deflate_init_gzip(&stream
, Z_BEST_COMPRESSION
);
499 gzip_size
= git_deflate_bound(&stream
, rpc
->len
);
500 gzip_body
= xmalloc(gzip_size
);
502 stream
.next_in
= (unsigned char *)rpc
->buf
;
503 stream
.avail_in
= rpc
->len
;
504 stream
.next_out
= (unsigned char *)gzip_body
;
505 stream
.avail_out
= gzip_size
;
507 ret
= git_deflate(&stream
, Z_FINISH
);
508 if (ret
!= Z_STREAM_END
)
509 die("cannot deflate request; zlib deflate error %d", ret
);
511 ret
= git_deflate_end_gently(&stream
);
513 die("cannot deflate request; zlib end error %d", ret
);
515 gzip_size
= stream
.total_out
;
517 headers
= curl_slist_append(headers
, "Content-Encoding: gzip");
518 curl_easy_setopt(slot
->curl
, CURLOPT_POSTFIELDS
, gzip_body
);
519 curl_easy_setopt(slot
->curl
, CURLOPT_POSTFIELDSIZE
, gzip_size
);
521 if (options
.verbosity
> 1) {
522 fprintf(stderr
, "POST %s (gzip %lu to %lu bytes)\n",
524 (unsigned long)rpc
->len
, (unsigned long)gzip_size
);
528 /* We know the complete request size in advance, use the
529 * more normal Content-Length approach.
531 curl_easy_setopt(slot
->curl
, CURLOPT_POSTFIELDS
, rpc
->buf
);
532 curl_easy_setopt(slot
->curl
, CURLOPT_POSTFIELDSIZE
, rpc
->len
);
533 if (options
.verbosity
> 1) {
534 fprintf(stderr
, "POST %s (%lu bytes)\n",
535 rpc
->service_name
, (unsigned long)rpc
->len
);
540 curl_easy_setopt(slot
->curl
, CURLOPT_HTTPHEADER
, headers
);
541 curl_easy_setopt(slot
->curl
, CURLOPT_WRITEFUNCTION
, rpc_in
);
542 curl_easy_setopt(slot
->curl
, CURLOPT_FILE
, rpc
);
544 err
= run_slot(slot
);
545 if (err
== HTTP_REAUTH
&& !large_request
)
550 curl_slist_free_all(headers
);
555 static int rpc_service(struct rpc_state
*rpc
, struct discovery
*heads
)
557 const char *svc
= rpc
->service_name
;
558 struct strbuf buf
= STRBUF_INIT
;
559 struct strbuf
*preamble
= rpc
->stdin_preamble
;
560 struct child_process client
;
563 memset(&client
, 0, sizeof(client
));
567 client
.argv
= rpc
->argv
;
568 if (start_command(&client
))
571 write_or_die(client
.in
, preamble
->buf
, preamble
->len
);
573 write_or_die(client
.in
, heads
->buf
, heads
->len
);
575 rpc
->alloc
= http_post_buffer
;
576 rpc
->buf
= xmalloc(rpc
->alloc
);
578 rpc
->out
= client
.out
;
579 strbuf_init(&rpc
->result
, 0);
581 strbuf_addf(&buf
, "%s%s", url
, svc
);
582 rpc
->service_url
= strbuf_detach(&buf
, NULL
);
584 strbuf_addf(&buf
, "Content-Type: application/x-%s-request", svc
);
585 rpc
->hdr_content_type
= strbuf_detach(&buf
, NULL
);
587 strbuf_addf(&buf
, "Accept: application/x-%s-result", svc
);
588 rpc
->hdr_accept
= strbuf_detach(&buf
, NULL
);
591 int n
= packet_read(rpc
->out
, NULL
, NULL
, rpc
->buf
, rpc
->alloc
, 0);
596 err
|= post_rpc(rpc
);
602 strbuf_read(&rpc
->result
, client
.out
, 0);
606 if (xread(client
.out
, buf
, sizeof(buf
)) <= 0)
613 err
|= finish_command(&client
);
614 free(rpc
->service_url
);
615 free(rpc
->hdr_content_type
);
616 free(rpc
->hdr_accept
);
618 strbuf_release(&buf
);
622 static int fetch_dumb(int nr_heads
, struct ref
**to_fetch
)
624 struct walker
*walker
;
625 char **targets
= xmalloc(nr_heads
* sizeof(char*));
629 die("dumb http transport does not support --depth");
630 for (i
= 0; i
< nr_heads
; i
++)
631 targets
[i
] = xstrdup(sha1_to_hex(to_fetch
[i
]->old_sha1
));
633 walker
= get_http_walker(url
);
635 walker
->get_tree
= 1;
636 walker
->get_history
= 1;
637 walker
->get_verbosely
= options
.verbosity
>= 3;
638 walker
->get_recover
= 0;
639 ret
= walker_fetch(walker
, nr_heads
, targets
, NULL
, NULL
);
642 for (i
= 0; i
< nr_heads
; i
++)
646 return ret
? error("Fetch failed.") : 0;
649 static int fetch_git(struct discovery
*heads
,
650 int nr_heads
, struct ref
**to_fetch
)
652 struct rpc_state rpc
;
653 struct strbuf preamble
= STRBUF_INIT
;
654 char *depth_arg
= NULL
;
655 int argc
= 0, i
, err
;
656 const char *argv
[15];
658 argv
[argc
++] = "fetch-pack";
659 argv
[argc
++] = "--stateless-rpc";
660 argv
[argc
++] = "--stdin";
661 argv
[argc
++] = "--lock-pack";
662 if (options
.followtags
)
663 argv
[argc
++] = "--include-tag";
665 argv
[argc
++] = "--thin";
666 if (options
.verbosity
>= 3) {
670 if (!options
.progress
)
671 argv
[argc
++] = "--no-progress";
673 struct strbuf buf
= STRBUF_INIT
;
674 strbuf_addf(&buf
, "--depth=%lu", options
.depth
);
675 depth_arg
= strbuf_detach(&buf
, NULL
);
676 argv
[argc
++] = depth_arg
;
681 for (i
= 0; i
< nr_heads
; i
++) {
682 struct ref
*ref
= to_fetch
[i
];
683 if (!ref
->name
|| !*ref
->name
)
684 die("cannot fetch by sha1 over smart http");
685 packet_buf_write(&preamble
, "%s\n", ref
->name
);
687 packet_buf_flush(&preamble
);
689 memset(&rpc
, 0, sizeof(rpc
));
690 rpc
.service_name
= "git-upload-pack",
692 rpc
.stdin_preamble
= &preamble
;
693 rpc
.gzip_request
= 1;
695 err
= rpc_service(&rpc
, heads
);
697 write_or_die(1, rpc
.result
.buf
, rpc
.result
.len
);
698 strbuf_release(&rpc
.result
);
699 strbuf_release(&preamble
);
704 static int fetch(int nr_heads
, struct ref
**to_fetch
)
706 struct discovery
*d
= discover_refs("git-upload-pack", 0);
708 return fetch_git(d
, nr_heads
, to_fetch
);
710 return fetch_dumb(nr_heads
, to_fetch
);
713 static void parse_fetch(struct strbuf
*buf
)
715 struct ref
**to_fetch
= NULL
;
716 struct ref
*list_head
= NULL
;
717 struct ref
**list
= &list_head
;
718 int alloc_heads
= 0, nr_heads
= 0;
721 if (!prefixcmp(buf
->buf
, "fetch ")) {
722 char *p
= buf
->buf
+ strlen("fetch ");
725 unsigned char old_sha1
[20];
727 if (strlen(p
) < 40 || get_sha1_hex(p
, old_sha1
))
728 die("protocol error: expected sha/ref, got %s'", p
);
734 die("protocol error: expected sha/ref, got %s'", p
);
736 ref
= alloc_ref(name
);
737 hashcpy(ref
->old_sha1
, old_sha1
);
742 ALLOC_GROW(to_fetch
, nr_heads
+ 1, alloc_heads
);
743 to_fetch
[nr_heads
++] = ref
;
746 die("http transport does not support %s", buf
->buf
);
749 if (strbuf_getline(buf
, stdin
, '\n') == EOF
)
755 if (fetch(nr_heads
, to_fetch
))
756 exit(128); /* error already reported */
757 free_refs(list_head
);
765 static int push_dav(int nr_spec
, char **specs
)
767 const char **argv
= xmalloc((10 + nr_spec
) * sizeof(char*));
770 argv
[argc
++] = "http-push";
771 argv
[argc
++] = "--helper-status";
773 argv
[argc
++] = "--dry-run";
774 if (options
.verbosity
> 1)
775 argv
[argc
++] = "--verbose";
777 for (i
= 0; i
< nr_spec
; i
++)
778 argv
[argc
++] = specs
[i
];
781 if (run_command_v_opt(argv
, RUN_GIT_CMD
))
782 die("git-%s failed", argv
[0]);
787 static int push_git(struct discovery
*heads
, int nr_spec
, char **specs
)
789 struct rpc_state rpc
;
791 int argc
= 0, i
, err
;
793 argv
= xmalloc((10 + nr_spec
) * sizeof(char*));
794 argv
[argc
++] = "send-pack";
795 argv
[argc
++] = "--stateless-rpc";
796 argv
[argc
++] = "--helper-status";
798 argv
[argc
++] = "--thin";
800 argv
[argc
++] = "--dry-run";
801 if (options
.verbosity
== 0)
802 argv
[argc
++] = "--quiet";
803 else if (options
.verbosity
> 1)
804 argv
[argc
++] = "--verbose";
805 argv
[argc
++] = options
.progress
? "--progress" : "--no-progress";
807 for (i
= 0; i
< nr_spec
; i
++)
808 argv
[argc
++] = specs
[i
];
811 memset(&rpc
, 0, sizeof(rpc
));
812 rpc
.service_name
= "git-receive-pack",
815 err
= rpc_service(&rpc
, heads
);
817 write_or_die(1, rpc
.result
.buf
, rpc
.result
.len
);
818 strbuf_release(&rpc
.result
);
823 static int push(int nr_spec
, char **specs
)
825 struct discovery
*heads
= discover_refs("git-receive-pack", 1);
828 if (heads
->proto_git
)
829 ret
= push_git(heads
, nr_spec
, specs
);
831 ret
= push_dav(nr_spec
, specs
);
832 free_discovery(heads
);
836 static void parse_push(struct strbuf
*buf
)
839 int alloc_spec
= 0, nr_spec
= 0, i
, ret
;
842 if (!prefixcmp(buf
->buf
, "push ")) {
843 ALLOC_GROW(specs
, nr_spec
+ 1, alloc_spec
);
844 specs
[nr_spec
++] = xstrdup(buf
->buf
+ 5);
847 die("http transport does not support %s", buf
->buf
);
850 if (strbuf_getline(buf
, stdin
, '\n') == EOF
)
856 ret
= push(nr_spec
, specs
);
861 exit(128); /* error already reported */
864 for (i
= 0; i
< nr_spec
; i
++)
869 int main(int argc
, const char **argv
)
871 struct strbuf buf
= STRBUF_INIT
;
874 git_extract_argv0_path(argv
[0]);
875 setup_git_directory_gently(&nongit
);
877 fprintf(stderr
, "Remote needed\n");
881 options
.verbosity
= 1;
882 options
.progress
= !!isatty(2);
885 remote
= remote_get(argv
[1]);
888 end_url_with_slash(&buf
, argv
[2]);
890 end_url_with_slash(&buf
, remote
->url
[0]);
893 url
= strbuf_detach(&buf
, NULL
);
895 http_init(remote
, url
, 0);
898 if (strbuf_getline(&buf
, stdin
, '\n') == EOF
) {
900 fprintf(stderr
, "Error reading command stream\n");
902 fprintf(stderr
, "Unexpected end of command stream\n");
907 if (!prefixcmp(buf
.buf
, "fetch ")) {
909 die("Fetch attempted without a local repo");
912 } else if (!strcmp(buf
.buf
, "list") || !prefixcmp(buf
.buf
, "list ")) {
913 int for_push
= !!strstr(buf
.buf
+ 4, "for-push");
914 output_refs(get_refs(for_push
));
916 } else if (!prefixcmp(buf
.buf
, "push ")) {
919 } else if (!prefixcmp(buf
.buf
, "option ")) {
920 char *name
= buf
.buf
+ strlen("option ");
921 char *value
= strchr(name
, ' ');
929 result
= set_option(name
, value
);
933 printf("error invalid value\n");
935 printf("unsupported\n");
938 } else if (!strcmp(buf
.buf
, "capabilities")) {
945 fprintf(stderr
, "Unknown command '%s'\n", buf
.buf
);