1From 9d7fd73efaf1c5a0a0fdc085af7015fd2978d495 Mon Sep 17 00:00:00 2001
2From: begasus <begasus@gmail.com>
3Date: Sun, 30 Apr 2017 16:59:12 +0200
4Subject: [PATCH] Add check for <sys/select.h> and use it
5
6POSIX says it's required for 'fd_set', and Haiku needs it.
7---
8 config.h.in  | 3 +++
9 configure.in | 2 +-
10 src/mms.c    | 3 +++
11 src/mmsh.c   | 3 +++
12 4 files changed, 10 insertions(+), 1 deletion(-)
13
14diff --git a/config.h.in b/config.h.in
15index 8a8fc8f..7cf91ce 100644
16--- a/config.h.in
17+++ b/config.h.in
18@@ -30,6 +30,9 @@
19 /* Define to 1 if you have the <string.h> header file. */
20 #undef HAVE_STRING_H
21 
22+/* Define to 1 if you have the <sys/select.h> header file. */
23+#undef HAVE_SYS_SELECT_H
24+
25 /* Define to 1 if you have the <sys/socket.h> header file. */
26 #undef HAVE_SYS_SOCKET_H
27 
28diff --git a/configure.in b/configure.in
29index 86b0e08..9dccc63 100755
30--- a/configure.in
31+++ b/configure.in
32@@ -13,7 +13,7 @@ AC_PROG_LIBTOOL
33 AC_PROG_INSTALL
34 
35 dnl Checks for header files.
36-AC_CHECK_HEADERS([sys/socket.h netinet/in.h netdb.h windows.h winsock2.h])
37+AC_CHECK_HEADERS([sys/select.h sys/socket.h netinet/in.h netdb.h windows.h winsock2.h])
38 
39 case $host in
40     *beos*)
41diff --git a/src/mms.c b/src/mms.c
42index c1dbc29..1a0aff7 100644
43--- a/src/mms.c
44+++ b/src/mms.c
45@@ -52,6 +52,9 @@
46 #endif
47 #include <string.h>
48 #include <sys/types.h>
49+#ifdef HAVE_SYS_SELECT_H
50+#include <sys/select.h>
51+#endif
52 #include <sys/stat.h>
53 #include <fcntl.h>
54 #include <errno.h>
55diff --git a/src/mmsh.c b/src/mmsh.c
56index a019f05..6562ce2 100755
57--- a/src/mmsh.c
58+++ b/src/mmsh.c
59@@ -55,6 +55,9 @@
60 #endif
61 #include <string.h>
62 #include <sys/types.h>
63+#ifdef HAVE_SYS_SELECT_H
64+#include <sys/select.h>
65+#endif
66 #include <sys/stat.h>
67 #include <fcntl.h>
68 #include <errno.h>
69-- 
702.19.1
71
72From a9f692323e597324e6f01263c12b6f4290d5b56f Mon Sep 17 00:00:00 2001
73From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
74Date: Wed, 27 Mar 2019 02:14:37 +0100
75Subject: [PATCH 2/2] C89 fixes for Haiku
76
77---
78 src/mms-common-funcs.h | 14 +++++++++-----
79 1 file changed, 9 insertions(+), 5 deletions(-)
80
81diff --git a/src/mms-common-funcs.h b/src/mms-common-funcs.h
82index 9e3c21d..f273756 100644
83--- a/src/mms-common-funcs.h
84+++ b/src/mms-common-funcs.h
85@@ -205,12 +205,14 @@ static void interp_asf_header(TYPE *this)
86 
87       case GUID_ASF_HEADER_EXTENSION:
88         {
89+          int size;
90+          int j = 24 + 18 + 4;
91+          int l;
92+
93           if ((24 + 18 + 4) > length)
94             break;
95 
96-          int size = LE_32(this->asf_header + i + 24 + 18);
97-          int j = 24 + 18 + 4;
98-          int l;
99+          size = LE_32(this->asf_header + i + 24 + 18);
100           lprintf("Extension header data size: %d\n", size);
101 
102           while ((j + 24) <= length) {
103@@ -249,16 +251,18 @@ static void interp_asf_header(TYPE *this)
104 
105                   // Loop through the number of extension system info
106                   for (x = 0; x < ext_count && (ext_j + 22) <= l; x++) {
107+                    int len;
108                     ext_j += 18;
109-                    int len = LE_16(this->asf_header + i + j + ext_j);
110+                    len = LE_16(this->asf_header + i + j + ext_j);
111                     ext_j += 4 + len;
112                   }
113 
114                   lprintf("ext_j: %d\n", ext_j);
115                   // Finally, we arrive at the interesting point: The optional Stream Property Object
116                   if ((ext_j + 24) <= l) {
117+                    int len;
118                     guid = get_guid(this->asf_header, i + j + ext_j);
119-                    int len = LE_64(this->asf_header + i + j + ext_j + 16);
120+                    len = LE_64(this->asf_header + i + j + ext_j + 16);
121                     if (guid == GUID_ASF_STREAM_PROPERTIES &&
122                         (ext_j + len) <= l) {
123                       interp_stream_properties(this, i + j + ext_j + 24);
124-- 
1252.19.1
126
127