dnl CF_CGETENT version: 7 updated: 2023/02/18 17:41:25
dnl ----------
dnl Check if the terminal-capability database functions are available.  If not,
dnl ncurses has a much-reduced version.
AC_DEFUN([CF_CGETENT],[
AC_CACHE_CHECK(for terminal-capability database functions,cf_cv_cgetent,[
AC_TRY_LINK([
$ac_includes_default],[
	char temp[128];
	char *buf = temp;
	char *db_array = temp;
	cgetent(&buf, &db_array, "vt100");
	cgetcap(buf, "tc", '=');
	cgetmatch(buf, "tc");
	],
	[cf_cv_cgetent=yes],
	[cf_cv_cgetent=no])
])

if test "$cf_cv_cgetent" = yes
then
	AC_DEFINE(HAVE_BSD_CGETENT,1,[Define to 1 if we have BSD cgetent])
AC_CACHE_CHECK(if cgetent uses const parameter,cf_cv_cgetent_const,[
AC_TRY_LINK([
#pragma GCC diagnostic error "-Wincompatible-pointer-types-discards-qualifiers"
$ac_includes_default],[
	char temp[128];
	char *buf = temp;
#ifndef _NETBSD_SOURCE			/* given, since April 2004 in stdlib.h */
	const char *db_array = temp;
	cgetent(&buf, &db_array, "vt100");
#endif
	cgetcap(buf, "tc", '=');
	cgetmatch(buf, "tc");
	],
	[cf_cv_cgetent_const=yes],
	[cf_cv_cgetent_const=no])
])
	if test "$cf_cv_cgetent_const" = yes
	then
		AC_DEFINE_UNQUOTED(CGETENT_CONST,const,[Define to const if needed for some BSD cgetent variations])
	fi
fi
])dnl
