From 17a6ffa834729ea51001decf5b09d351ca02f51f Mon Sep 17 00:00:00 2001
From: Oliver Heidmann <oliver.heidmann@mpimet.mpg.de>
Date: Wed, 5 Feb 2025 13:32:41 +0100
Subject: [PATCH] added feature functions to remove reliance on ifdefs in other
 libraries

---
 src/cdi.h     |  3 +++
 src/cdi_int.c | 18 ++++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/src/cdi.h b/src/cdi.h
index 89fa33561..76bd6168f 100644
--- a/src/cdi.h
+++ b/src/cdi.h
@@ -1447,6 +1447,9 @@ extern int (*proj_stere_to_lonlat_func)(struct CDI_GridProjParams gpp, double, d
 // Used on CDO remap_scrip_io.cc
 void cdf_def_var_filter(int ncid, int ncvarID, const char *filterSpec);
 
+int cdi_has_dap();
+int cdi_has_cgribex();
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/cdi_int.c b/src/cdi_int.c
index 188d8a431..716501764 100644
--- a/src/cdi_int.c
+++ b/src/cdi_int.c
@@ -584,6 +584,24 @@ stream_def_accesstype(stream_t *s, int type)
     Error("Changing access type from %s not allowed!", s->accesstype == TYPE_REC ? "REC to VAR" : "VAR to REC");
 }
 
+int
+cdi_has_dap()
+{
+#ifdef HAVE_LIBNC_DAP
+  return 1;
+#endif
+  return 0;
+}
+
+int
+cdi_has_cgribex()
+{
+#ifdef HAVE_LIBCGRIBEX
+  return 1;
+#endif
+  return 0;
+}
+
 /*
  * Local Variables:
  * c-file-style: "Java"
-- 
GitLab