6 * 'fd::<inoutfd>[/<anything>]' Read/write socket pair
8 * 'fd::<infd>,<outfd>[/<anything>]' Read pipe <infd> and write
10 * [foo] indicates 'foo' is optional. <anything> is any string.
12 * The data output to <outfd>/<inoutfd> should be passed unmolested to
13 * git-receive-pack/git-upload-pack/git-upload-archive and output of
14 * git-receive-pack/git-upload-pack/git-upload-archive should be passed
15 * unmolested to <infd>/<inoutfd>.
19 #define MAXCOMMAND 4096
21 static void command_loop(int input_fd, int output_fd)
23 char buffer[MAXCOMMAND];
27 if (!fgets(buffer, MAXCOMMAND - 1, stdin)) {
32 /* Strip end of line characters. */
34 while (i > 0 && isspace(buffer[i - 1]))
37 if (!strcmp(buffer, "capabilities")) {
38 printf("*connect\n\n");
40 } else if (!strncmp(buffer, "connect ", 8)) {
43 if (bidirectional_transfer_loop(input_fd,
45 die("Copying data between file descriptors failed");
48 die("Bad command: %s", buffer);
53 int cmd_remote_fd(int argc, const char **argv, const char *prefix)
60 die("Expected two arguments");
62 input_fd = (int)strtoul(argv[2], &end, 10);
64 if ((end == argv[2]) || (*end != ',' && *end != '/' && *end))
65 die("Bad URL syntax");
67 if (*end == '/' || !*end) {
71 output_fd = (int)strtoul(end + 1, &end2, 10);
73 if ((end2 == end + 1) || (*end2 != '/' && *end2))
74 die("Bad URL syntax");
77 command_loop(input_fd, output_fd);