aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Dessaux2020-06-30 17:32:08 +0200
committerJulien Dessaux2020-06-30 17:32:08 +0200
commit32ec7d91a69c00eafe0a253dce7e07ac8f5a0deb (patch)
tree4da86ee4767d601350145451e0ea10499536f982
parentAdded README (diff)
downloadrocket-cli-client-32ec7d91a69c00eafe0a253dce7e07ac8f5a0deb.tar.gz
rocket-cli-client-32ec7d91a69c00eafe0a253dce7e07ac8f5a0deb.tar.bz2
rocket-cli-client-32ec7d91a69c00eafe0a253dce7e07ac8f5a0deb.zip
Added forgotten files
-rw-r--r--liveapi/stdin.c32
-rw-r--r--liveapi/stdin.h12
-rw-r--r--maar/main.c1
3 files changed, 44 insertions, 1 deletions
diff --git a/liveapi/stdin.c b/liveapi/stdin.c
new file mode 100644
index 0000000..14419fc
--- /dev/null
+++ b/liveapi/stdin.c
@@ -0,0 +1,32 @@
+#include <common/util.h>
+
+#include "stdin.h"
+
+static liveapi_stdin_cb * stdin_cb = NULL;
+
+static void stdin_read_cb(struct ev_loop *loop UNUSED, struct ev_io *w, int revents UNUSED)
+{
+ struct uwsc_client *cl = w->data;
+ char buf[128] = "";
+ int n;
+
+ n = read(w->fd, buf, sizeof(buf));
+ if (n > 1) {
+ buf[n - 1] = 0;
+
+ if (buf[0] == 'q')
+ cl->send_close(cl, UWSC_CLOSE_STATUS_NORMAL, "ByeBye");
+ else
+ cl->send(cl, buf, strlen(buf) + 1, UWSC_OP_TEXT);
+ }
+}
+
+void liveapi_activate_stdin_with_callback(struct uwsc_client *cl, liveapi_stdin_cb * cb)
+{
+ stdin_cb = cb;
+
+ static struct ev_io stdin_watcher;
+ stdin_watcher.data = cl;
+ ev_io_init(&stdin_watcher, stdin_read_cb, STDIN_FILENO, EV_READ);
+ ev_io_start(cl->loop, &stdin_watcher);
+}
diff --git a/liveapi/stdin.h b/liveapi/stdin.h
new file mode 100644
index 0000000..f24d7a0
--- /dev/null
+++ b/liveapi/stdin.h
@@ -0,0 +1,12 @@
+#ifndef LIVEAPI_STDIN_H_
+#define LIVEAPI_STDIN_H_
+
+#include <cjson/cJSON.h>
+#include <features.h>
+#include "libuwsc/uwsc.h"
+
+#include "liveapi.h"
+
+void liveapi_activate_stdin_with_callback(struct uwsc_client *cl, liveapi_stdin_cb * cb);
+
+#endif
diff --git a/maar/main.c b/maar/main.c
index 8ac0225..dc93a86 100644
--- a/maar/main.c
+++ b/maar/main.c
@@ -8,7 +8,6 @@
#include "liveapi/messages.h"
#include "restapi/auth.h"
#include "restapi/subscriptions.h"
-#include "restapi/users.h"
void maar_subscription(const struct subscription* subscription)
{