# strnlen.h

Go to the documentation of this file.

    00001 ///
    00002 /// \file       strnlen.h
    00003 ///             Header for strnlen() call, for systems that don't have GNU.
    00004 ///
    00005
    00006 /*
    00007     Copyright (C) 2007-2011, Net Direct Inc. (http://www.netdirect.ca/)
    00008
    00009     This program is free software; you can redistribute it and/or modify
    00010     it under the terms of the GNU General Public License as published by
    00011     the Free Software Foundation; either version 2 of the License, or
    00012     (at your option) any later version.
    00013
    00014     This program is distributed in the hope that it will be useful,
    00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00017
    00018     See the GNU General Public License in the COPYING file at the
    00019     root directory of this project for more details.
    00020 */
    00021
    00022 #ifndef __BARRY_STRNLEN_H__
    00023 #define __BARRY_STRNLEN_H__
    00024
    00025 #include "config.h"
    00026 #include <string.h>
    00027
    00028 // this is always defined by configure, if not, then the autoconf
    00029 // sources changed (likely in /usr/share/autoconf/autoconf/functions.m4)
    00030 // and configure.ac is no longer accurate
    00031 #ifndef HAVE_WORKING_STRNLEN
    00032 #error Configure.ac is not accurate. Read comments in strnlen.h.
    00033 #endif
    00034
    00035 // now, if defined and set to 0, then strnlen() either does not exist at all,
    00036 // or is broken (on AIX)
    00037 #if !HAVE_WORKING_STRNLEN
    00038
    00039 // so define our own version...
    00040 #ifdef __cplusplus
    00041 extern "C" {
    00042 #endif
    00043
    00044 size_t barry_strnlen(const char *s, size_t maxlen);
    00045
    00046 #ifdef __cplusplus
    00047 }
    00048 #endif
    00049
    00050 // and override the system's name so we call our own
    00051 #define strnlen(s,l) barry_strnlen(s,l)
    00052
    00053 #endif  // !HAVE_WORKING_STRNLEN
    00054
    00055 #endif  // __BARRY_STRNLEN_H__
    00056