From 9dfa196fff4d0ba2290f5d29b952ecbbd3f612fe Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Mon, 17 Nov 2008 09:52:31 +0100 Subject: [PATCH] Try to be compatible with older versions of NetSNMP --- configure.ac | 6 ++++++ src/agent_priv.c | 16 +++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index b9dd1a49..62e3df4d 100644 --- a/configure.ac +++ b/configure.ac @@ -47,6 +47,12 @@ AC_CHECK_DECLS([ETHERTYPE_VLAN],[],[],[[#include ]]) # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_CHECK_TYPES([int16_t, u_int16_t, int8_t, u_int8_t, int32_t, u_int32_t],[],[AC_MSG_ERROR([mandatory type not found])]) +AC_CHECK_MEMBERS([netsnmp_tdomain.f_create_from_tstring_new],,, + [ +#include +#include +#include +]) # Checks for library functions. AC_REPLACE_FUNCS([strlcpy]) diff --git a/src/agent_priv.c b/src/agent_priv.c index 90140b9b..caf7cea6 100644 --- a/src/agent_priv.c +++ b/src/agent_priv.c @@ -170,14 +170,20 @@ agent_priv_unix_transport(const char *string, int len, int local) } netsnmp_transport * -agent_priv_unix_create_tstring(const char *string, int local, - const char *default_target) +#if !HAVE_NETSNMP_TDOMAIN_F_CREATE_FROM_TSTRING_NEW +agent_priv_unix_create_tstring(const char *string, int local) +#else +agent_priv_unix_create_tstring(const char *string, int local, char *default_target) +#endif { +#if HAVE_NETSNMP_TDOMAIN_F_CREATE_FROM_TSTRING_NEW if ((!string || *string == '\0') && default_target && *default_target != '\0') { string = default_target; } - +#endif + if (!string) + return NULL; return agent_priv_unix_transport(string, strlen(string), local); } @@ -194,7 +200,11 @@ agent_priv_register_domain() unixDomain.name_length = sizeof(netsnmp_UnixDomain) / sizeof(oid); unixDomain.prefix = (const char**)calloc(2, sizeof(char *)); unixDomain.prefix[0] = "unix"; +#if !HAVE_NETSNMP_TDOMAIN_F_CREATE_FROM_TSTRING_NEW + unixDomain.f_create_from_tstring = agent_priv_unix_create_tstring; +#else unixDomain.f_create_from_tstring_new = agent_priv_unix_create_tstring; +#endif unixDomain.f_create_from_ostring = agent_priv_unix_create_ostring; netsnmp_tdomain_register(&unixDomain); } -- 2.39.5