summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Klausner <wiz@danbala.tuwien.ac.at>2011-03-28 10:56:23 +0100
committerWill Thompson <will.thompson@collabora.co.uk>2011-03-28 10:57:08 +0100
commitdbc99e7d39fe024e60ce91db0b87f3b44c1df370 (patch)
treefac8d44a0ddc4661706c040aca46ef2831fbd38d
parent33cfd01e5832c953ac85c19648988f3cf6bf42a0 (diff)
Check for strnlen, and define it if missing.
It doesn't exist on, for instance, NetBSD-5.1. (Patch modified slightly to add a configure check.) Signed-off-by: Will Thompson <will.thompson@collabora.co.uk>
-rw-r--r--configure.ac2
-rw-r--r--src/idle-parser.c15
2 files changed, 17 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 4fd6300..2b2b3fe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -131,6 +131,8 @@ DBUS_SERVICES_DIR="$DATADIR/dbus-1/services"
AC_SUBST(DBUS_SERVICES_DIR)
AC_DEFINE_UNQUOTED(DBUS_SERVICES_DIR, "$DBUS_SERVICES_DIR", [DBus services directory])
+AC_CHECK_FUNCS(strnlen)
+
AC_OUTPUT( Makefile \
data/Makefile \
extensions/Makefile \
diff --git a/src/idle-parser.c b/src/idle-parser.c
index 962e2c3..cff40b4 100644
--- a/src/idle-parser.c
+++ b/src/idle-parser.c
@@ -22,6 +22,7 @@
#define _GNU_SOURCE
#include "idle-parser.h"
+#include "config.h"
#include "idle-connection.h"
#include "idle-muc-channel.h"
@@ -198,6 +199,20 @@ static void _parse_message(IdleParser *parser, const gchar *split_msg);
static void _parse_and_forward_one(IdleParser *parser, gchar **tokens, IdleParserMessageCode code, const gchar *format);
static gboolean _parse_atom(IdleParser *parser, GValueArray *arr, char atom, const gchar *token, TpHandleSet *contact_reffed, TpHandleSet *room_reffed);
+#ifndef HAVE_STRNLEN
+static size_t
+strnlen(const char *msg, size_t maxlen)
+{
+ size_t i;
+
+ for (i=0; i<maxlen; i++)
+ if (msg[i] == '\0')
+ break;
+
+ return i;
+}
+#endif
+
void idle_parser_receive(IdleParser *parser, const gchar *msg) {
IdleParserPrivate *priv = IDLE_PARSER_GET_PRIVATE(parser);
guint i;