From 15fe9df35deee50d5ba82453978d850218588955 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Fri, 29 Aug 2014 14:04:57 +0200
Subject: Fix build on Haiku.

* Missing includes
* No support for procfs

diff --git a/latex.cpp b/latex.cpp
index f7179a4..2e42a13 100644
--- a/latex.cpp
+++ b/latex.cpp
@@ -12,6 +12,7 @@ published by the Free Software Foundation. */
 
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <sys/wait.h>
 
 #include <SDL/SDL.h>
 #include <SDL/SDL_image.h>
diff --git a/multitalk.cpp b/multitalk.cpp
index 32ea719..e4dd805 100644
--- a/multitalk.cpp
+++ b/multitalk.cpp
@@ -28,6 +28,10 @@ published by the Free Software Foundation. */
 #include "datatype.h"
 #include "multitalk.h"
 
+#ifdef __HAIKU__
+#include <OS.h>
+#endif
+
 slidevector *talk;
 slidevector *render_list;
 
@@ -523,6 +527,7 @@ void warp_down()
 		warp_to_slide(nearest);
 }
 
+#ifdef __linux__
 int check_memory()
 {
 	int pid, fd, bytes, spaces;
@@ -573,9 +578,17 @@ int check_memory()
 	printf("Maximum rss = %ld, others %ld, %ld, %ld.\n", bytes,
 			bytes1, bytes2, bytes3);
 	*/
-	
+
 	return mem;
 }
+#elif defined __HAIKU__
+int check_memory()
+{
+	system_info info;
+	get_system_info(&info);
+	return info.used_pages;
+}
+#endif
 
 void copy_radar_to_screen()
 {
diff --git a/web.cpp b/web.cpp
index 6854162..360ffe0 100644
--- a/web.cpp
+++ b/web.cpp
@@ -12,6 +12,7 @@ published by the Free Software Foundation. */
 
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <sys/wait.h>
 
 #include <SDL/SDL_image.h>
 #include <SDL/SDL_ttf.h>
-- 
1.8.3.4


From 5b718cebf525a4e0757e84e700c3feb18bb1a5f7 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Fri, 29 Aug 2014 14:11:43 +0200
Subject: Use PathFinder to find resources.


diff --git a/files.cpp b/files.cpp
index 0286df6..b93ecc8 100644
--- a/files.cpp
+++ b/files.cpp
@@ -28,6 +28,11 @@ published by the Free Software Foundation. */
 #include "datatype.h"
 #include "multitalk.h"
 
+#ifdef __HAIKU__
+#include <PathFinder.h>
+#include <Path.h>
+#endif
+
 extern Config *config;
 
 // Prototypes:
@@ -260,7 +265,14 @@ int absolute_path(char *s)
 Config *init_paths(const char *talk_ref)
 {
 	Config *config = new Config();
+#ifdef __HAIKU__
+	BPathFinder finder;
+	BPath path;
+	finder.FindPath(B_FIND_PATH_DATA_DIRECTORY, NULL, path);
+	const char* sys_prefix = path.Path();
+#else
 	const char *sys_prefix = "/usr/local/share";
+#endif
 	
 	config->talk_path = replace_extension(talk_ref, "talk");
 	config->graph_path = replace_extension(talk_ref, "graph");
-- 
1.8.3.4

