Selaa lähdekoodia

Make the Websockets example compile on Mac OS X, along with some other little patches.

Sangwhan Moon 11 vuotta sitten
vanhempi
commit
ee3ef0af4e
1 muutettua tiedostoa jossa 7 lisäystä ja 3 poistoa
  1. 7 3
      examples/websocket/WebSockCallbacks.c

+ 7 - 3
examples/websocket/WebSockCallbacks.c

@@ -3,6 +3,10 @@
 #include <time.h>
 #include <time.h>
 #include "WebSockCallbacks.h"
 #include "WebSockCallbacks.h"
 
 
+#ifdef __APPLE__
+#include <string.h>
+#endif
+
 #ifdef _WIN32
 #ifdef _WIN32
 #include <Windows.h>
 #include <Windows.h>
 typedef HANDLE pthread_mutex_t;
 typedef HANDLE pthread_mutex_t;
@@ -73,7 +77,7 @@ void websocket_ready_handler(struct mg_connection *conn) {
             break;
             break;
         }
         }
     }
     }
-    printf("\nNew websocket attached: %08x:%u\n", rq->remote_ip, rq->remote_port);
+    printf("\nNew websocket attached: %08lx:%u\n", rq->remote_ip, rq->remote_port);
     pthread_mutex_unlock(&sMutex);
     pthread_mutex_unlock(&sMutex);
 }
 }
 
 
@@ -88,7 +92,7 @@ static void websocket_done(tWebSockInfo * wsock) {
                 break;
                 break;
             }
             }
         }
         }
-        printf("\nClose websocket attached: %08x:%u\n", mg_get_request_info(wsock->conn)->remote_ip, mg_get_request_info(wsock->conn)->remote_port);
+        printf("\nClose websocket attached: %08lx:%u\n", mg_get_request_info(wsock->conn)->remote_ip, mg_get_request_info(wsock->conn)->remote_port);
         free(wsock);
         free(wsock);
     }
     }
 }
 }
@@ -107,7 +111,7 @@ int websocket_data_handler(struct mg_connection *conn, int flags, char *data, si
         pthread_mutex_unlock(&sMutex);
         pthread_mutex_unlock(&sMutex);
         return 1;
         return 1;
     }
     }
-    if ((data_len>=5) && (data_len<100) && (flags==129) || (flags==130)) {
+    if (((data_len>=5) && (data_len<100) && (flags==129)) || (flags==130)) {
 
 
         // init command
         // init command
         if ((wsock->webSockState==1) && (!memcmp(data,"init ",5))) {
         if ((wsock->webSockState==1) && (!memcmp(data,"init ",5))) {