00001 /* 00002 * $Id: vsnprintf.h,v 1.2 2003/01/09 16:14:32 laza2000 Exp $ 00003 * 00004 * Extended Fast Light Toolkit (EFLTK) 00005 * Copyright (C) 2002-2003 by EDE-Team 00006 * WWW: http://www.sourceforge.net/projects/ede 00007 * 00008 * Fast Light Toolkit (FLTK) 00009 * Copyright (C) 1998-2003 by Bill Spitzak and others. 00010 * WWW: http://www.fltk.org 00011 * 00012 * This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE 00013 * version 2. See COPYING for details. 00014 * 00015 * Author : Mikko Lahteenmaki 00016 * Email : mikko@fltk.net 00017 * 00018 * Please report all bugs and problems to "efltk-bugs@fltk.net" 00019 * 00020 */ 00021 00022 #ifndef _FL_VSNPRINTF_H_ 00023 #define _FL_VSNPRINTF_H_ 00024 00025 /* 00026 * vsnprintf() function for the Fast Light Tool Kit (FLTK). 00027 * 00028 * Include this file instead of stdio.h to get the snprintf and vsnprintf 00029 * functions on systems that lack it (pretty much everything except glibc 00030 * systems). PLEASE FIX FOR SYSTEMS THAT HAVE THESE FUNCTIONS! 00031 * 00032 * KNOWN BUGS: 00033 * Field width & Precision is ignored for %%, %c, and %s. 00034 * 00035 * A malicious user who manages to create a %-fmt string that prints 00036 * more than 99 characters can still overflow the temporary buffer. 00037 * For instance %110f will overflow. 00038 * 00039 * Only handles formats that are both documented in the glibc man page 00040 * for printf and also handled by your system's sprintf(). 00041 */ 00042 00043 #include <stdio.h> 00044 #include <stdarg.h> 00045 00046 #ifdef _WIN32 00047 # define vsnprintf _vsnprintf 00048 # define snprintf _snprintf 00049 00050 #elif defined(__linux) 00051 /* linux has vsnprintf */ 00052 00053 #elif _COMPILER_VERSION>=730 00054 /* newer SGI compilers have vsnprintf */ 00055 00056 #else 00057 /* all other machines need our emulation function: */ 00058 00059 # define need_fl_vsnprintf 1 /* make the function compile */ 00060 00061 # ifdef __cplusplus 00062 extern "C" { 00063 # endif 00064 00065 # include <sys/types.h> 00066 int fl_vsnprintf(char* str, size_t size, const char* fmt, va_list ap); 00067 int fl_snprintf(char* str, size_t size, const char* fmt, ...); 00068 # define vsnprintf fl_vsnprintf 00069 # define snprintf fl_snprintf 00070 00071 # ifdef __cplusplus 00072 }; 00073 # endif 00074 00075 #endif 00076 00077 #endif