git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1101
7f574dfc-610e-0410-a909-
a81674777703
dnl Some functions
dnl
-AC_CHECK_FUNCS([calloc malloc free popen sysinfo getloadavg memrchr])
+AC_CHECK_FUNCS([calloc malloc free popen sysinfo getloadavg memrchr strndup])
AC_SEARCH_LIBS(clock_gettime, [rt],
[AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if you have clock_gettime()])],
[AC_CHECK_FUNCS([gettimeofday], [], [AC_MSG_ERROR([gettimeofday() not available!])])], [])
#include <sys/time.h>
#include <pthread.h>
+#ifndef HAVE_STRNDUP
+// use our own strndup() if it's not available
+char *strndup(const char *s, size_t n)
+{
+ if (strlen(s) + 1 > n) {
+ char *ret = malloc(n);
+ strncpy(ret, s, n);
+ return ret;
+ } else {
+ return strdup(s);
+ }
+}
+#endif /* HAVE_STRNDUP */
+
void update_uname(void)
{
uname(&info.uname_s);
#include <machine/apmvar.h>
#endif /* __OpenBSD__ */
+#ifndef HAVE_STRNDUP
+// use our own strndup() if it's not available
+char *strndup(const char *s, size_t n);
+#endif /* HAVE_STRNDUP */
+
#ifdef AUDACIOUS
#include "audacious.h"
#endif