$ git clone http://tcclient.ion.nu/tc_client.git
commit 2238505b35b9784d48f6fe04acb9bf6bdfde5415
Author: Alicia <...>
Date:   Sat Feb 27 23:50:33 2016 +0100

    Added compatibility code for systems lacking strndup() and made configure test for that and dprintf()

diff --git a/ChangeLog b/ChangeLog
index a32d61c..c040a19 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 0.38:
 Handle multi-line messages.
 Added option --hexcolors to print hex color codes instead of ANSI color escape codes.
+Added compatibility code for systems lacking strndup() and made configure test for that and dprintf()
 Makefile: added missing sourcefiles for the tarball target.
 Makefile: added some foolproofing for building on windows.
 tc_client-gtk: if HOME is not set use "." instead.
diff --git a/Makefile b/Makefile
index ea5a59c..932b1c9 100644
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,7 @@ else
  @echo 'Run ./configure first, make sure tc_client-gtk is enabled.'
   endif
 endif
-OBJ=client.o amfparser.o rtmp.o numlist.o amfwriter.o idlist.o colors.o endian.o media.o
+OBJ=client.o amfparser.o rtmp.o numlist.o amfwriter.o idlist.o colors.o endian.o media.o utilities/compat.o
 IRCHACK_OBJ=utilities/irchack/irchack.o utilities/compat.o
 MODBOT_OBJ=utilities/modbot/modbot.o utilities/list.o utilities/modbot/queue.o
 CAMVIEWER_OBJ=utilities/camviewer/camviewer.o utilities/compat.o libcamera.a
diff --git a/amfparser.c b/amfparser.c
index 4dd9a14..fbcb887 100644
--- a/amfparser.c
+++ b/amfparser.c
@@ -18,6 +18,7 @@
 #include <stdlib.h>
 #include <stdio.h> // For debugging
 #include "endian.h"
+#include "utilities/compat.h"
 #include "amfparser.h"
 
 char amf_comparestrings_c(struct amfstring* a, const char* b)
diff --git a/client.c b/client.c
index e5aabcf..7a839d5 100644
--- a/client.c
+++ b/client.c
@@ -35,6 +35,7 @@
 #include "colors.h"
 #include "media.h"
 #include "amfwriter.h"
+#include "utilities/compat.h"
 
 struct writebuf
 {
diff --git a/configure b/configure
index 783231a..4c5bbfe 100755
--- a/configure
+++ b/configure
@@ -39,6 +39,28 @@ else
 fi
 rm -f iconvtest iconvtest.c
 
+printf 'Checking for strndup... '
+echo '#include <string.h>' > apitest.c
+echo 'int main(){char* x=strndup("abc", 2);}' >> apitest.c
+if "$CC" apitest.c -o apitest > /dev/null 2> /dev/null; then
+  echo yes
+else
+  echo 'CFLAGS+=-DNO_STRNDUP' >> config.mk
+  echo no
+fi
+rm -f apitest apitest.c
+
+printf 'Checking for dprintf... '
+echo '#include <stdio.h>' > apitest.c
+echo 'int main(){dprintf(1,"test");}' >> apitest.c
+if "$CC" apitest.c -o apitest > /dev/null 2> /dev/null; then
+  echo yes
+else
+  echo 'CFLAGS+=-DNO_DPRINTF' >> config.mk
+  echo no
+fi
+rm -f apitest apitest.c
+
 printf 'Checking for gtk+-3.0... '
 libs="`pkg-config --libs gtk+-3.0 2> /dev/null`"
 if [ "x$libs" != "x" ]; then
diff --git a/utilities/compat.c b/utilities/compat.c
index 193c07c..6e7c177 100644
--- a/utilities/compat.c
+++ b/utilities/compat.c
@@ -14,11 +14,12 @@
     You should have received a copy of the GNU Affero General Public License
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
-#if defined(__ANDROID__) || defined(_WIN32)
+#ifdef NO_DPRINTF
 // Android and windows have no dprintf, so we make our own
 #include <stdio.h>
 #include <unistd.h>
 #include <stdarg.h>
+#include <stdlib.h>
 #include "compat.h"
 size_t dprintf(int fd, const char* fmt, ...)
 {
@@ -35,3 +36,17 @@ size_t dprintf(int fd, const char* fmt, ...)
   return len;
 }
 #endif
+
+#ifdef NO_STRNDUP
+char* strndup(const char* in, unsigned int length)
+{
+  char* out=malloc(length+1);
+  unsigned int i;
+  for(i=0; i<length; ++i)
+  {
+    out[i]=in[i];
+  }
+  out[i]=0;
+  return out;
+}
+#endif
diff --git a/utilities/compat.h b/utilities/compat.h
index 2788686..77129fc 100644
--- a/utilities/compat.h
+++ b/utilities/compat.h
@@ -17,9 +17,14 @@
 #if defined(__ANDROID__) || defined(_WIN32)
 #include <stdint.h>
 #include <stddef.h>
-extern size_t dprintf(int fd, const char* fmt, ...);
 #define mbtowc(x,y,z) 1
 #endif
+#ifdef NO_DPRINTF
+  extern size_t dprintf(int fd, const char* fmt, ...);
+#endif
+#ifdef NO_STRNDUP
+  extern char* strndup(const char* in, unsigned int length);
+#endif
 #ifdef _WIN32
   #define prctl(...)
   #define wait(x)
diff --git a/utilities/list.c b/utilities/list.c
index 707a182..1402350 100644
--- a/utilities/list.c
+++ b/utilities/list.c
@@ -20,6 +20,7 @@
 #include <sys/stat.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include "compat.h"
 #include "list.h"
 
 void list_del(struct list* list, const char* item)