2 #include "git-compat-util.h"
5 #ifdef GIT_WINDOWS_NATIVE
6 static const char *usage_string = "<pipe-filename>";
8 #define TEST_BUFSIZE (4096)
10 int cmd__windows_named_pipe(int argc, const char **argv)
13 struct strbuf pathname = STRBUF_INIT;
17 char buf[TEST_BUFSIZE + 1];
22 if (strchr(filename, '/') || strchr(filename, '\\'))
24 strbuf_addf(&pathname, "//./pipe/%s", filename);
27 * Create a single instance of the server side of the named pipe.
28 * This will allow exactly one client instance to connect to it.
32 PIPE_ACCESS_INBOUND | FILE_FLAG_FIRST_PIPE_INSTANCE,
33 PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
34 PIPE_UNLIMITED_INSTANCES,
35 TEST_BUFSIZE, TEST_BUFSIZE, 0, NULL);
36 if (h == INVALID_HANDLE_VALUE) {
37 err = err_win_to_posix(GetLastError());
38 fprintf(stderr, "CreateNamedPipe failed: %s\n",
43 connected = ConnectNamedPipe(h, NULL)
45 : (GetLastError() == ERROR_PIPE_CONNECTED);
47 err = err_win_to_posix(GetLastError());
48 fprintf(stderr, "ConnectNamedPipe failed: %s\n",
56 BOOL success = ReadFile(h, buf, TEST_BUFSIZE, &nbr, NULL);
57 if (!success || nbr == 0)
64 DisconnectNamedPipe(h);
69 fprintf(stderr, "usage: %s %s\n", argv[0], usage_string);