check_function_exists(malloc_trim HAVE_MALLOC_TRIM)
check_function_exists(memrchr HAVE_MEMRCHR)
check_function_exists(sigaction HAVE_SIGACTION)
+check_function_exists(basename_r HAVE_BASENAME_R)
check_cxx_source_compiles(
"
/* Define to 1 if you have the GNU form of the `strerror_r' function. */
#cmakedefine HAVE_GNU_STRERROR_R 1
+/* Define 1 if you have basename_r function for freebsd < 12.0.0 */
+#cmakedefine HAVE_BASENAME_R 1
/* Available compiler options */
// Alternatively, conflicts between reload may be avoided if a new lua state is
// created separately, then swapped and free old state.
char detectorName[MAX_LUA_DETECTOR_FILENAME_LEN];
+#ifdef HAVE_BASENAME_R
+ char detector_res[MAX_LUA_DETECTOR_FILENAME_LEN];
+ snprintf(detectorName, MAX_LUA_DETECTOR_FILENAME_LEN, "%s_%s",
+ (isCustom ? "custom" : "odp"), basename_r(detector_filename, detector_res));
+#else
snprintf(detectorName, MAX_LUA_DETECTOR_FILENAME_LEN, "%s_%s",
(isCustom ? "custom" : "odp"), basename(detector_filename));
+#endif
// create a new function environment and store it in the registry
lua_newtable(L); // create _ENV tables