]> rtime.felk.cvut.cz Git - coffee/mt-apps.git/blobdiff - mt_server.h
Use server at localhost
[coffee/mt-apps.git] / mt_server.h
index 80261eab9bbb0f59f9c7aeca273c10c4ce20a429..77d737102d1cf127acfdb660c3744dccb5d9466b 100644 (file)
@@ -4,19 +4,51 @@
 #include <ev.h>
 #include <libwebsockets.h>
 
+// set these two according to your data
+// rx buf size must be >= permessage-deflate rx size
+#define MT_PROTOCOL_RX_BUFFER_SIZE 128
+#define INPUT_LINE_LENGTH          MT_PROTOCOL_RX_BUFFER_SIZE
+
+#if defined(SIM)
+#define HTTP_PORT       8080                    // listen here
+#define HTTP_ORIGIN     "html" // where the html files are
+#else
+#define HTTP_PORT       80                    // listen here
+#define HTTP_ORIGIN     "/usr/share/mtserver" // where the html files are
+#endif
+#define HTTP_MOUNTPOINT "/"                   // mountpoint URL
+#define HTTP_DEFAULT    "index.html"          // default filename
+
+#define JSON_EMPTY "{\"type\":\"empty\"}" // default message
+
+typedef struct node {
+    char *line;
+    struct node *next;
+} node;
+
+typedef struct list {
+    struct node *first;
+    struct node *last;
+} list;
+
 typedef struct ev_io_ws {
-    ev_io w;
+    ev_io w;                     // input watcher
     struct lws_context *context;
-    char *text;
-    char *pos;
+    list *lines;
+    char *text;                  // input buffer pointer
+    char *pos;                   // input buffer current position pointer
 } ev_io_ws;
 
 typedef struct mt_server_t {
     struct lws_context *context;
-    ev_io_ws fd_watcher;
+    ev_io_ws fd_watcher;         // input watcher
 } mt_server_t;
 
+// init self, add it to loop and make it read data from fd
+// return 0 on success, -1 otherwise
 int mt_server_init(mt_server_t *self, struct ev_loop *loop, int fd);
+
+// gett drunc an kil sellf
 void mt_server_deinit(mt_server_t *self);
 
 #endif