From 5e7d6dc8d32f0189a3385cb824030cb6c500e869 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Tue, 20 May 2014 16:30:21 +0000
Subject: haiku patch


diff --git a/configure.ac b/configure.ac
index c487d18..80bf8da 100644
--- a/configure.ac
+++ b/configure.ac
@@ -139,7 +139,7 @@ else
 fi
 
 # Checks for libraries.
-AC_SEARCH_LIBS([recvfrom], [socket])
+AC_SEARCH_LIBS([recvfrom], [socket network])
 AC_CHECK_FUNC([log], [], [AC_CHECK_LIB([m],[log])])
 AC_CHECK_FUNCS([getifaddrs])
 
-- 
1.8.3.4


From dcc0e8c2cbd9453252c3dbed013683f3573ad384 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Tue, 20 May 2014 16:51:04 +0000
Subject: check getifaddrs


diff --git a/lo/lo_cpp.h b/lo/lo_cpp.h
index 79db0b6..7675380 100644
--- a/lo/lo_cpp.h
+++ b/lo/lo_cpp.h
@@ -184,12 +184,19 @@ namespace lo {
 
         std::string url() const
           { return std::string(lo_address_get_url(address)?:""); }
-
+#ifdef HAVE_GETIFADDRS
         std::string iface() const
           { return std::string(lo_address_get_iface(address)?:""); }
 
         void set_iface(const string_type &iface, const string_type &ip)
           { lo_address_set_iface(address, iface._s?:0, ip._s?:0); }
+#else
+		std::string iface() const
+          { return std::string(""); }
+
+        void set_iface(const string_type &iface, const string_type &ip)
+          { }
+#endif
 
         int set_tcp_nodelay(int enable)
           { return lo_address_set_tcp_nodelay(address, enable); }
-- 
1.8.3.4


From 4e66b251cb3f6c37418e413476082efddfd0710b Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Tue, 20 May 2014 22:09:52 +0000
Subject: gcc2 build fix


diff --git a/examples/example_tcp_echo_server.c b/examples/example_tcp_echo_server.c
index 93af99b..b675e92 100644
--- a/examples/example_tcp_echo_server.c
+++ b/examples/example_tcp_echo_server.c
@@ -46,6 +46,9 @@ void ctrlc(int sig)
 
 int main(int argc, char *argv[])
 {
+    lo_server_thread st;
+    lo_server s;
+    lo_address a = 0;
     const char *port = "7770";
     int do_send = 0;
 
@@ -55,13 +58,13 @@ int main(int argc, char *argv[])
     }
 
     /* start a new server on port 7770 */
-    lo_server_thread st = lo_server_thread_new_with_proto(port, LO_TCP, error);
+    st = lo_server_thread_new_with_proto(port, LO_TCP, error);
     if (!st) {
         printf("Could not create server thread.\n");
         exit(1);
     }
 
-    lo_server s = lo_server_thread_get_server(st);
+    s = lo_server_thread_get_server(st);
 
     /* add method that will match the path /quit with no args */
     lo_server_thread_add_method(st, "/quit", "", quit_handler, NULL);
@@ -75,14 +78,14 @@ int main(int argc, char *argv[])
 
     printf("Listening on TCP port %s\n", port);
 
-    lo_address a = 0;
     if (do_send) {
+        int r;
         a = lo_address_new_with_proto(LO_TCP, "localhost", "7770");
         if (!a) {
             printf("Error creating destination address.\n");
             exit(1);
         }
-        int r = lo_send_from(a, s, LO_TT_IMMEDIATE, "/test", "ifs",
+        r = lo_send_from(a, s, LO_TT_IMMEDIATE, "/test", "ifs",
                              1, 2.0f, "3");
         if (r < 0)
             printf("Error sending initial message.\n");
@@ -115,6 +118,7 @@ int echo_handler(const char *path, const char *types, lo_arg ** argv,
                     int argc, void *data, void *user_data)
 {
     int i;
+    int r;
     lo_message m = (lo_message)data;
     lo_address a = lo_message_get_source(m);
     lo_server s = (lo_server)user_data;
@@ -142,7 +146,7 @@ int echo_handler(const char *path, const char *types, lo_arg ** argv,
         return 0;
     }
 
-    int r = lo_send_message_from(a, s, path, m);
+    r = lo_send_message_from(a, s, path, m);
     if (r < 0)
         printf("Error sending back message, socket may have closed.\n");
     else
diff --git a/src/message.c b/src/message.c
index 7980ccf..28a2bd5 100644
--- a/src/message.c
+++ b/src/message.c
@@ -259,6 +259,7 @@ int lo_message_add_varargs_internal(lo_message msg, const char *types,
         }
     }
 #ifndef USE_ANSI_C
+{
     void *i = va_arg(ap, void *);
     if (((unsigned long)i & 0xFFFFFFFFUL)
 	!= ((unsigned long)LO_MARKER_A & 0xFFFFFFFFUL))
@@ -281,6 +282,7 @@ int lo_message_add_varargs_internal(lo_message msg, const char *types,
                 "mismatching types and data at\n%s:%d, exiting.\n", file,
                 line);
     }
+}
 #endif
     va_end(ap);
 
diff --git a/src/server.c b/src/server.c
index 3d01e88..0521bfc 100644
--- a/src/server.c
+++ b/src/server.c
@@ -1275,6 +1275,7 @@ int lo_server_wait(lo_server s, int timeout)
     {
         if (s->protocol == LO_TCP)
         {
+            double diff;
             int sock = accept(s->sockets[0].fd,
                               (struct sockaddr *) &addr, &addr_len);
 
@@ -1286,7 +1287,7 @@ int lo_server_wait(lo_server s, int timeout)
 
             lo_timetag_now(&now);
 
-            double diff = lo_timetag_diff(now, then);
+            diff = lo_timetag_diff(now, then);
 
             sched_timeout = lo_server_next_event_delay(s) * 1000;
             timeout -= (int)(diff*1000);
diff --git a/src/test_bidirectional_tcp.c b/src/test_bidirectional_tcp.c
index 0408df3..226595e 100644
--- a/src/test_bidirectional_tcp.c
+++ b/src/test_bidirectional_tcp.c
@@ -28,6 +28,7 @@ int generic_handler(const char *path, const char *types, lo_arg ** argv,
 
 void *sendthread(void *arg)
 {
+    lo_address a;
     lo_server s = lo_server_new_with_proto("7772", LO_TCP, 0);
     if (!s) { printf("no server2\n"); exit(1); }
 
@@ -35,7 +36,7 @@ void *sendthread(void *arg)
 
     lo_server_add_method(s, 0, 0, generic_handler, s);
 
-    lo_address a = lo_address_new_with_proto(LO_TCP, "localhost", "7771");
+    a = lo_address_new_with_proto(LO_TCP, "localhost", "7771");
 
     lo_send_from(a, s, LO_TT_IMMEDIATE, "/test", 0);
 
@@ -55,6 +56,7 @@ void *sendthread(void *arg)
 
 int main()
 {
+    pthread_t thr;
     /* start a new server on port 7770 */
     lo_server s = lo_server_new_with_proto("7771", LO_TCP, 0);
     if (!s) { printf("no server\n"); exit(1); }
@@ -64,7 +66,6 @@ int main()
 
     printf("%p.server fd: %d\n", s, lo_server_get_socket_fd(s));
 
-    pthread_t thr;
     pthread_create(&thr, 0, sendthread, s);
 
     printf("%p.receiving1..\n", s);
-- 
1.8.3.4

