From c848e32cfcc8b3c188e42c5672c79dce8d3df1b6 Mon Sep 17 00:00:00 2001
From: David Karoly <david.karoly@outlook.com>
Date: Tue, 2 Nov 2021 20:11:25 +0100
Subject: fix build with glib 2.68


diff --git a/caputils/capture_ifinfo.h b/caputils/capture_ifinfo.h
index 83b020c..989576f 100644
--- a/caputils/capture_ifinfo.h
+++ b/caputils/capture_ifinfo.h
@@ -11,12 +11,12 @@
 #ifndef __CAPTURE_IFINFO_H__
 #define __CAPTURE_IFINFO_H__
 
+#include <glib.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
 
-#include <glib.h>
-
 /*
  * Explicitly set the interface_type enum values as these values are exposed
  * in the preferences gui.interfaces_hidden_types string.
diff --git a/epan/conversation.h b/epan/conversation.h
index cd8d416..cb7c62f 100644
--- a/epan/conversation.h
+++ b/epan/conversation.h
@@ -13,6 +13,8 @@
 
 #include "ws_symbol_export.h"
 
+#include "packet.h"		/* for conversation dissector type */
+
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
@@ -46,8 +48,6 @@ extern "C" {
 /* Flags to handle endpoints */
 #define USE_LAST_ENDPOINT 0x08      /* Use last endpoint created, regardless of type */
 
-#include "packet.h"		/* for conversation dissector type */
-
 /* Types of port numbers Wireshark knows about. */
 typedef enum {
 	ENDPOINT_NONE,			/* no endpoint */
diff --git a/epan/epan.h b/epan/epan.h
index 80d9b6f..66ddd57 100644
--- a/epan/epan.h
+++ b/epan/epan.h
@@ -10,11 +10,12 @@
 #ifndef __EPAN_H__
 #define __EPAN_H__
 
+#include <glib.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
 
-#include <glib.h>
 #include <epan/tvbuff.h>
 #include <epan/prefs.h>
 #include <epan/frame_data.h>
diff --git a/epan/epan_dissect.h b/epan/epan_dissect.h
index 956a147..9279892 100644
--- a/epan/epan_dissect.h
+++ b/epan/epan_dissect.h
@@ -10,11 +10,12 @@
 #ifndef EPAN_DISSECT_H
 #define EPAN_DISSECT_H
 
+#include "epan.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
 
-#include "epan.h"
 #include "tvbuff.h"
 #include "proto.h"
 #include "packet_info.h"
diff --git a/epan/prefs.h b/epan/prefs.h
index 9e31491..fdd7cb7 100644
--- a/epan/prefs.h
+++ b/epan/prefs.h
@@ -11,12 +11,12 @@
 #ifndef __PREFS_H__
 #define __PREFS_H__
 
+#include <glib.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
 
-#include <glib.h>
-
 #include <epan/params.h>
 #include <epan/range.h>
 
diff --git a/ui/recent.h b/ui/recent.h
index 9757dda..47f123f 100644
--- a/ui/recent.h
+++ b/ui/recent.h
@@ -12,11 +12,12 @@
 #ifndef __RECENT_H__
 #define __RECENT_H__
 
+#include <glib.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
 
-#include <glib.h>
 #include <stdio.h>
 #include "epan/timestamp.h"
 #include "ui/ws_ui_util.h"
-- 
2.30.2


From b8639c84fdc28707a6cb52a8178f349a27caff88 Mon Sep 17 00:00:00 2001
From: David Karoly <david.karoly@outlook.com>
Date: Mon, 15 Nov 2021 10:26:33 +0000
Subject: use realpath in init_progfile_dir


diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c
index 2ca9247..96a62cb 100644
--- a/wsutil/filesystem.c
+++ b/wsutil/filesystem.c
@@ -650,6 +650,12 @@ init_progfile_dir(const char *arg0
         }
     }
 
+    static char buffer[PATH_MAX + 1];
+    char *res = realpath(prog_pathname, buffer);
+    if (res != NULL) {
+        prog_pathname = buffer;
+    }
+
     /*
      * OK, we have what we think is the pathname
      * of the program.
-- 
2.30.2


From 9503f602e1c201ebf2e4e35b47aa5701d0066567 Mon Sep 17 00:00:00 2001
From: David Karoly <david.karoly@outlook.com>
Date: Thu, 25 Nov 2021 18:24:45 +0000
Subject: remove prefix from PLUGIN_DIR, EXTCAP_DIR, DATA_DIR as they already
 contain full path


diff --git a/wsutil/CMakeLists.txt b/wsutil/CMakeLists.txt
index 092746f..68fe4f2 100644
--- a/wsutil/CMakeLists.txt
+++ b/wsutil/CMakeLists.txt
@@ -9,9 +9,9 @@
 
 include(UseABICheck)
 
-add_definitions(-DPLUGIN_DIR=\"${CMAKE_INSTALL_PREFIX}/${PLUGIN_INSTALL_LIBDIR}\")
-add_definitions(-DEXTCAP_DIR=\"${CMAKE_INSTALL_PREFIX}/${EXTCAP_INSTALL_LIBDIR}\")
-add_definitions(-DDATA_DIR=\"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}\")
+add_definitions(-DPLUGIN_DIR=\"${PLUGIN_INSTALL_LIBDIR}\")
+add_definitions(-DEXTCAP_DIR=\"${EXTCAP_INSTALL_LIBDIR}\")
+add_definitions(-DDATA_DIR=\"${CMAKE_INSTALL_DATADIR}\")
 
 set(WSUTIL_PUBLIC_HEADERS
 	adler32.h
-- 
2.30.2


From 81d7c16ca46cbdd3d2ace962cec20e09fbca1c6f Mon Sep 17 00:00:00 2001
From: David Karoly <david.karoly@outlook.com>
Date: Thu, 25 Nov 2021 18:41:24 +0000
Subject: adjust get_systemfile_dir for Haiku


diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c
index 96a62cb..802b89f 100644
--- a/wsutil/filesystem.c
+++ b/wsutil/filesystem.c
@@ -1143,6 +1143,8 @@ get_systemfile_dir(void)
 {
 #ifdef _WIN32
     return get_datafile_dir();
+#elif __HAIKU__
+    return "/boot/system/settings/etc";
 #else
     return "/etc";
 #endif
-- 
2.30.2


From 3c9bf86e312c2fd0bcde539490aa41b06a0fbae1 Mon Sep 17 00:00:00 2001
From: David Karoly <david.karoly@outlook.com>
Date: Sun, 5 Dec 2021 21:19:38 +0000
Subject: adjust user dirs for Haiku


diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c
index 802b89f..42d363b 100644
--- a/wsutil/filesystem.c
+++ b/wsutil/filesystem.c
@@ -38,6 +38,10 @@
 #endif
 #include <pwd.h>
 #endif /* _WIN32 */
+#ifdef __HAIKU__
+#include <FindDirectory.h>
+#include <fs_info.h>
+#endif
 
 #include "filesystem.h"
 #include <wsutil/report_message.h>
@@ -985,6 +989,13 @@ init_plugin_pers_dir(void)
 #if defined(HAVE_PLUGINS) || defined(HAVE_LUA)
 #ifdef _WIN32
     plugin_pers_dir = get_persconffile_path(PLUGINS_DIR_NAME, FALSE);
+#elif __HAIKU__
+    plugin_pers_dir = get_persconffile_path(PLUGINS_DIR_NAME, FALSE);
+/*
+	char buffer[B_PATH_NAME_LENGTH+B_FILE_NAME_LENGTH];
+	find_directory(B_USER_DATA_DIRECTORY, dev_for_path("/boot"), false, buffer, sizeof(buffer));
+	plugin_pers_dir = g_build_filename(buffer, "wireshark", PLUGINS_DIR_NAME, (gchar *)NULL);
+*/
 #else
     plugin_pers_dir = g_build_filename(g_get_home_dir(), ".local/lib/wireshark/" PLUGINS_DIR_NAME, (gchar *)NULL);
 #endif
@@ -1292,6 +1303,12 @@ get_persconffile_dir_no_profile(void)
      */
     persconffile_dir = g_build_filename("C:", "Wireshark", NULL);
     return persconffile_dir;
+#elif __HAIKU__
+	//return "/boot/home/config/settings/wireshark/";
+	char buffer[B_PATH_NAME_LENGTH+B_FILE_NAME_LENGTH];
+	find_directory(B_USER_SETTINGS_DIRECTORY, dev_for_path("/boot"), true, buffer, sizeof(buffer));
+	persconffile_dir = g_build_filename(buffer, "wireshark", NULL);
+	return persconffile_dir;
 #else
     char *xdg_path, *path;
     struct passwd *pwd;
-- 
2.30.2

