summaryrefslogtreecommitdiffstats
path: root/input
diff options
context:
space:
mode:
authorulion <ulion@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-12-11 08:03:47 +0000
committerulion <ulion@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-12-11 08:03:47 +0000
commit38473dd468dd1b5e523d932220de09ccb627e213 (patch)
tree7d128cf5966abf77b2a7f1aa05bf3aa0da5d5154 /input
parent149fd4dac747f926b7376e2d999811cafe074156 (diff)
downloadmpv-38473dd468dd1b5e523d932220de09ccb627e213.tar.bz2
mpv-38473dd468dd1b5e523d932220de09ccb627e213.tar.xz
Add new function for parsing and queueing multi-commands separated by \n or \r.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25347 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'input')
-rw-r--r--input/input.c23
-rw-r--r--input/input.h6
2 files changed, 29 insertions, 0 deletions
diff --git a/input/input.c b/input/input.c
index 21df78b16f..fc3d45cd9e 100644
--- a/input/input.c
+++ b/input/input.c
@@ -21,6 +21,7 @@
#include "osdep/getch2.h"
#include "osdep/keycodes.h"
#include "osdep/timer.h"
+#include "avstring.h"
#include "mp_msg.h"
#include "help_mp.h"
#include "m_config.h"
@@ -707,6 +708,28 @@ void mp_input_rm_event_fd(int fd)
mp_input_rm_key_fd(fd);
}
+int mp_input_parse_and_queue_cmds(const char *str) {
+ int cmd_num = 0;
+
+ while (*str == '\n' || *str == '\r' || *str == ' ')
+ ++str;
+ while (*str) {
+ mp_cmd_t *cmd;
+ size_t len = strcspn(str, "\r\n");
+ char *cmdbuf = malloc(len+1);
+ av_strlcpy(cmdbuf, str, len+1);
+ cmd = mp_input_parse_cmd(cmdbuf);
+ if (cmd) {
+ mp_input_queue_cmd(cmd);
+ ++cmd_num;
+ }
+ str += len;
+ while (*str == '\n' || *str == '\r' || *str == ' ')
+ ++str;
+ free(cmdbuf);
+ }
+ return cmd_num;
+}
mp_cmd_t*
mp_input_parse_cmd(char* str) {
diff --git a/input/input.h b/input/input.h
index 6ed71c4320..780a5d1d88 100644
--- a/input/input.h
+++ b/input/input.h
@@ -255,6 +255,12 @@ mp_input_get_cmd(int time, int paused, int peek_only);
mp_cmd_t*
mp_input_parse_cmd(char* str);
+/**
+ * Parse and queue commands separated by '\n'.
+ * @return count of commands new queued.
+ */
+int mp_input_parse_and_queue_cmds(const char *str);
+
/// These filters allow you to process the command before MPlayer.
/// If a filter returns a true value mp_input_get_cmd will return NULL.
void