simple-ipc: preparations for supporting binary messages.
commita3e2033e04ae06ac4f1cda582ac83944df29830d
authorJeff Hostetler <jeffhost@microsoft.com>
Mon, 20 Sep 2021 15:36:13 +0000 (20 15:36 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 20 Sep 2021 15:57:58 +0000 (20 08:57 -0700)
tree39f5235ded09296fda28bf705eaa2b905033d264
parent64bc75244b5bdc26112cf7b8533a832b692a5fda
simple-ipc: preparations for supporting binary messages.

Add `command_len` argument to the Simple IPC API.

In my original Simple IPC API, I assumed that the request would always
be a null-terminated string of text characters.  The `command`
argument was just a `const char *`.

I found a caller that would like to pass a binary command to the
daemon, so I am amending the Simple IPC API to receive `const char
*command, size_t command_len` arguments.

I considered changing the `command` argument to be a `void *`, but the
IPC layer simply passes it to the pkt-line layer which takes a `const
char *`, so to avoid confusion I left it as is.

Note, the response side has always been a `struct strbuf` which
includes the buffer and length, so we already support returning a
binary answer.  (Yes, it feels a little weird returning a binary
buffer in a `strbuf`, but it works.)

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/simple-ipc/ipc-unix-socket.c
compat/simple-ipc/ipc-win32.c
simple-ipc.h
t/helper/test-simple-ipc.c