/* Copyright (C) 2008 Andreas Baumann This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef WOLF_STDIO_H #define WOLF_STDIO_H /** * @addtogroup wolf_port Porting * @{ */ /** * @file stdio.h * @brief nivelate things found in stdio.h, mostly snprintf's * @author Andreas Baumann */ #include "port/sys.h" #include /* snprintf: a disaster, there are several versions out there. They * differ in: * - what they return: BSD and C99 stipulates the number of character which * would be needed to map the whole string (which is the version we must * stick to). Some other versions return -1 and ERANGE/EOVERFLOW in the * the case of an overflow (notably older GNU C libraries) * - what format string options they support: * - some older Sun snprintf's were famous for being wrong in the floating * point format placeholders * - if they work at all (for instance sprintf_s on Windows 32k happily * crashes the runnig process)! Also some older Solaris versions are * known to have terrible bugs. */ /* TODO: check which features we need in snprintf, make sure the platform one supports it, * otherwise we take the stub */ /* TODO: also clean up mess here with autoconf relicts! */ #if defined _WIN32 /* secure snprintf on Wndows is called differently, but not working * we don't take sprintf_s */ #endif #include /* for va_list */ #include /* for size_t */ #if !defined HAVE_SNPRINTF || defined WOLF_TEST_SNPRINTF int rpl_snprintf( char *str, size_t size, const char *format, ... ); #endif /* !defined HAVE_SNPRINTF || defined TEST_SNPRINTF */ #if !defined HAVE_SNPRINTF /* TODO: with variadic macros, we can define a much better macro here! */ #define snprintf rpl_snprintf #endif /* !defined HAVE_SNPRINTF */ #if !defined HAVE_VSNPRINTF || defined WOLF_TEST_VSNPRINTF int rpl_vsnprintf( char *str, size_t size, const char *format, va_list args ); #endif /* !defined HAVE_VSNPRINTF || defined TEST_VSNPRINTF */ #if !defined HAVE_VSNPRINTF #define vsnprintf( str, size, format, ap ) rpl_vsnprintf( str, size, format, ap ) #endif /* !defined HAVE_VSNPRINTF */ /** @} */ /* @addtogroup wolf_port */ #endif /* ifndef WOLF_STDIO_H */