From c100b1371c350bc7bf8577a2989570a466e650e7 Mon Sep 17 00:00:00 2001 From: Themaister Date: Sun, 17 Mar 2013 11:11:14 +0100 Subject: [PATCH] Update command interface. Use ';' to split args instead of ':' to avoid breaking Windows path handling. --- command.c | 16 ++++++++++------ docs/retroarch.1 | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/command.c b/command.c index 87e99f3a92..ce82275d77 100644 --- a/command.c +++ b/command.c @@ -201,6 +201,10 @@ static const struct cmd_map map[] = { { "SLOWMOTION", RARCH_SLOWMOTION }, { "VOLUME_UP", RARCH_VOLUME_UP }, { "VOLUME_DOWN", RARCH_VOLUME_DOWN }, + { "OVERLAY_NEXT", RARCH_OVERLAY_NEXT }, + { "DISK_EJECT_TOGGLE", RARCH_DISK_EJECT_TOGGLE }, + { "DISK_NEXT", RARCH_DISK_NEXT }, + { "MENU_TOGGLE", RARCH_MENU_TOGGLE }, }; static bool cmd_set_shader(const char *arg) @@ -224,7 +228,7 @@ static bool cmd_set_shader(const char *arg) msg_queue_clear(g_extern.msg_queue); - char msg[512]; + char msg[PATH_MAX]; snprintf(msg, sizeof(msg), "Shader: \"%s\"", arg); msg_queue_push(g_extern.msg_queue, msg, 1, 120); RARCH_LOG("Applying shader \"%s\".\n", arg); @@ -238,7 +242,7 @@ static const struct cmd_action_map action_map[] = { static bool command_get_arg(const char *tok, const char **arg, unsigned *index) { - for (unsigned i = 0; i < sizeof(map) / sizeof(map[0]); i++) + for (unsigned i = 0; i < ARRAY_SIZE(map); i++) { if (strcmp(tok, map[i].str) == 0) { @@ -252,7 +256,7 @@ static bool command_get_arg(const char *tok, const char **arg, unsigned *index) } } - for (unsigned i = 0; i < sizeof(action_map) / sizeof(action_map[0]); i++) + for (unsigned i = 0; i < ARRAY_SIZE(action_map); i++) { const char *str = strstr(tok, action_map[i].str); if (str == tok) @@ -581,11 +585,11 @@ bool network_cmd_send(const char *cmd_) uint16_t port = DEFAULT_NETWORK_CMD_PORT; char *save; - cmd = strtok_r(command, ":", &save); + cmd = strtok_r(command, ";", &save); if (cmd) - host = strtok_r(NULL, ":", &save); + host = strtok_r(NULL, ";", &save); if (host) - port_ = strtok_r(NULL, ":", &save); + port_ = strtok_r(NULL, ";", &save); if (!host) { diff --git a/docs/retroarch.1 b/docs/retroarch.1 index 4f7661c38d..c9f27a9ae7 100644 --- a/docs/retroarch.1 +++ b/docs/retroarch.1 @@ -199,8 +199,8 @@ For spectating mode to work, both host and clients will need to use this flag. .TP \fB--command CMD\fR Sends a command over UDP to an already running RetroArch application, and exit. -The command is formatted as "COMMAND:HOST:PORT". -HOST and PORT are both optional. "COMMAND:HOST" will set PORT to +The command is formatted as "COMMAND;HOST;PORT". +HOST and PORT are both optional. "COMMAND;HOST" will set PORT to "network_cmd_port" default setting. If only "COMMAND" is used, HOST and PORT will be assumed to be "localhost" and "network_cmd_port" respectively.