ipc: rename COMMAND to RUN_COMMAND for consistency (#2956)

All other message types are verbs, only our first-ever message COMMAND wasn’t.

While we’re here, also change the message type dictionary into a table with
clickable links to the corresponding reply type.

Authors of downstream IPC libraries are encouraged to keep the old name around
so as to not break existing code, but mark it as deprecated.
This commit is contained in:
Michael Stapelberg
2017-09-17 15:25:00 +02:00
committed by GitHub
parent d726d09d49
commit 607e97e651
7 changed files with 44 additions and 47 deletions

View File

@ -113,7 +113,7 @@ void ipc_shutdown(shutdown_reason_t reason) {
* or not (at the moment, always returns true).
*
*/
IPC_HANDLER(command) {
IPC_HANDLER(run_command) {
/* To get a properly terminated buffer, we copy
* message_size bytes out of the buffer */
char *command = scalloc(message_size + 1, 1);
@ -1121,7 +1121,7 @@ IPC_HANDLER(get_config) {
/* The index of each callback function corresponds to the numeric
* value of the message type (see include/i3/ipc.h) */
handler_t handlers[10] = {
handle_command,
handle_run_command,
handle_get_workspaces,
handle_subscribe,
handle_get_outputs,

View File

@ -418,7 +418,7 @@ int main(int argc, char *argv[]) {
if (connect(sockfd, (const struct sockaddr *)&addr, sizeof(struct sockaddr_un)) < 0)
err(EXIT_FAILURE, "Could not connect to i3");
if (ipc_send_message(sockfd, strlen(payload), I3_IPC_MESSAGE_TYPE_COMMAND,
if (ipc_send_message(sockfd, strlen(payload), I3_IPC_MESSAGE_TYPE_RUN_COMMAND,
(uint8_t *)payload) == -1)
err(EXIT_FAILURE, "IPC: write()");
FREE(payload);
@ -432,8 +432,8 @@ int main(int argc, char *argv[]) {
err(EXIT_FAILURE, "IPC: read()");
return 1;
}
if (reply_type != I3_IPC_MESSAGE_TYPE_COMMAND)
errx(EXIT_FAILURE, "IPC: received reply of type %d but expected %d (COMMAND)", reply_type, I3_IPC_MESSAGE_TYPE_COMMAND);
if (reply_type != I3_IPC_REPLY_TYPE_COMMAND)
errx(EXIT_FAILURE, "IPC: received reply of type %d but expected %d (COMMAND)", reply_type, I3_IPC_REPLY_TYPE_COMMAND);
printf("%.*s\n", reply_length, reply);
FREE(reply);
return 0;