]> rtime.felk.cvut.cz Git - coffee/mt-apps.git/blobdiff - mt_server.c
mt_server: Use "%s" format string in syslog()
[coffee/mt-apps.git] / mt_server.c
index c683c7528f1cdac93738b6868c3f40d5cd54b131..3b617bd68eea29d53d2b6b353337e4f3ec7ec3d4 100644 (file)
@@ -193,34 +193,15 @@ static int callback_merica_terminal(struct lws *wsi,
                     lws_callback_on_writable_all_protocol(context,
                         &protocols[PROTOCOL_MERICA_TERMINAL]);
                 }
-            } else {
-                line = copy_line(JSON_EMPTY);
-                if (line) {
-                    n = strlen(line);
-                    m = lws_write(wsi, (unsigned char *)line, n, LWS_WRITE_TEXT);
-                    free_line(line);
-                } else {
+                if (m < n) {
+                    fprintf(stderr, "ERROR %d writing to di socket\n", n);
                     return -1;
                 }
             }
-            if (m < n) {
-                fprintf(stderr, "ERROR %d writing to di socket\n", n);
-                return -1;
-            }
             break;
 
         case LWS_CALLBACK_RECEIVE:
-            if (strcmp((const char *)in, "reset") == 0) {
-                line = copy_line(JSON_EMPTY);
-                if (line) {
-                    if (list_add(lines, line) == 0) {
-                        lws_callback_on_writable_all_protocol(context,
-                            &protocols[PROTOCOL_MERICA_TERMINAL]);
-                    } else {
-                        free_line(line);
-                    }
-                }
-            } else if (strcmp((const char *)in, "close") == 0) {
+            if (strcmp((const char *)in, "close") == 0) {
                 fprintf(stderr, "closing websocket\n");
                 lws_close_reason(wsi, LWS_CLOSE_STATUS_GOINGAWAY,
                                  (unsigned char *)"seeya", 5);
@@ -248,7 +229,7 @@ static void fd_cb(EV_P_ ev_io *w_, int revents)
        mt_blank_wake();
 #endif
         *pos = 0;
-       syslog(LOG_INFO, w->text);
+       syslog(LOG_INFO, "%s", w->text);
         char *line = new_line();
         if (line) {
             if (list_add(w->lines, w->text) == 0) {