orca-robotics INTRODUCTION Overview Download and Install Documentation REPOSITORY Interfaces Drivers Libraries Utilities Software Map DEVELOPER Dashboard PEOPLE Contributors Users Project Download Mailing lists
|
strnlen.h00001 /* 00002 * Orca-Robotics Project: Components for robotics 00003 * http://orca-robotics.sf.net/ 00004 * Copyright (c) 2004-2008 Alex Brooks, Christopher Brooks 00005 * 00006 * This distribution is licensed to you under the terms described in 00007 * the LICENSE file included in this distribution. 00008 * 00009 */ 00010 #ifndef HYDRO_PORTABILITY_STRNLEN_H 00011 #define HYDRO_PORTABILITY_STRNLEN_H 00012 00013 // this defines HAVE_STRNLEN 00014 // #include <config.h> 00015 00016 // eg. Solaris doesn't define strnlen in string.h, so define it here. 00017 #if !HAVE_STRNLEN 00018 00019 #include <cstring> 00020 00021 // inline the fucker to guard against multiple inclusion, without the 00022 // hassle of a special lib. 00023 inline size_t strnlen(const char *s, size_t maxlen) 00024 { 00025 char *p; 00026 if (s == NULL) { 00027 return maxlen; 00028 } 00029 p = (char *)memchr(s, 0, maxlen); 00030 if (p == NULL) { 00031 return maxlen; 00032 } 00033 return ((p - s) + 1); 00034 } 00035 #endif 00036 00037 #endif |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)