weaker search for strnlen() as it is not standard-C99

This commit is contained in:
Olaf Bergmann committed 2012-03-08 13:23:37 +01:00
1 parent 3712bcf30a
commit 2a749707e3
3 files changed
+12 -11

No files matched your search

+3 -3
View File
@@ -58,9 +58,6 @@
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the `strnlen' function. */
#undef HAVE_STRNLEN
/* Define to 1 if you have the `strrchr' function. */
#undef HAVE_STRRCHR
@@ -76,6 +73,9 @@
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <sys/unistd.h> header file. */
#undef HAVE_SYS_UNISTD_H
/* Define to 1 if you have the <time.h> header file. */
#undef HAVE_TIME_H
+4 -3
View File
@@ -1,7 +1,7 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
#
# Copyright (C) 2010,2011 Olaf Bergmann <bergmann@tzi.org>
# Copyright (C) 2010--2012 Olaf Bergmann <bergmann@tzi.org>
#
# This file is part of the CoAP library libcoap. Please see
# README for terms of use.
@@ -46,7 +46,7 @@ AC_ARG_WITH(async,
[])
# Checks for header files.
AC_CHECK_HEADERS([assert.h arpa/inet.h limits.h netdb.h netinet/in.h stdlib.h string.h strings.h sys/socket.h sys/time.h time.h unistd.h])
AC_CHECK_HEADERS([assert.h arpa/inet.h limits.h netdb.h netinet/in.h stdlib.h string.h strings.h sys/socket.h sys/time.h time.h unistd.h sys/unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T
@@ -54,7 +54,8 @@ AC_TYPE_SSIZE_T
# Checks for library functions.
AC_FUNC_MALLOC
AC_CHECK_FUNCS([memset select socket strcasecmp strrchr getaddrinfo strnlen])
AC_CHECK_FUNCS([memset select socket strcasecmp strrchr getaddrinfo])
AC_SEARCH_LIBS(strnlen, c)
AC_CONFIG_HEADERS([config.h])
+5 -5
View File
@@ -1,6 +1,6 @@
/* debug.c -- debug utilities
*
* Copyright (C) 2010,2011 Olaf Bergmann <bergmann@tzi.org>
* Copyright (C) 2010--2012 Olaf Bergmann <bergmann@tzi.org>
*
* This file is part of the CoAP library libcoap. Please see
* README for terms of use.
@@ -14,6 +14,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#ifdef HAVE_ARPA_INET_H
@@ -89,7 +90,7 @@ print_timestamp(char *s, size_t len, coap_tick_t t) {
* @return The length of @p s.
*/
static inline size_t
strnlen(unsigned char *s, size_t maxlen) {
strnlen(const char *s, size_t maxlen) {
size_t n = 0;
while(*s++ && n < maxlen)
++n;
@@ -160,7 +161,7 @@ coap_print_addr(const struct __coap_address_t *addr, unsigned char *buf, size_t
return 0;
}
p += strnlen(p, len);
p += strnlen((char *)p, len);
if (addr->addr.sa.sa_family == AF_INET6) {
if (p < buf + len) {
@@ -175,8 +176,7 @@ coap_print_addr(const struct __coap_address_t *addr, unsigned char *buf, size_t
#else /* HAVE_ARPA_INET_H */
# if WITH_CONTIKI
unsigned char *p = buf;
uint8_t i;\
uint16_t port;
uint8_t i;
# if WITH_UIP6
const unsigned char hex[] = "0123456789ABCDEF";