00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #if 0
00021 <lalVerbatim file="LALStdCV">
00022 $Id: LALStd.c,v 1.4 2007/06/08 14:41:53 bema Exp $
00023 </lalVerbatim>
00024
00025 <lalLaTeX>
00026 \subsection{Module \texttt{LALStd.c}}
00027
00028 LAL replacement routines for standard C functions. At present, this
00029 just includes replacements for \texttt{snprintf}.
00030
00031 \subsection*{Prototypes}
00032 \begin{verbatim}
00033 int LALSnprintf( char *str, size_t size, const char *fmt, ... );
00034 int LALVsnprintf( char *str, size_t size, const char *fmt, va_list ap );
00035 \end{verbatim}
00036 \idx{LALSnprintf()}
00037 \idx{LALVsnprintf()}
00038
00039 \subsection*{Description}
00040
00041 The routines \verb+LALSnprintf()+ and \verb+LALVsnprintf()+ are
00042 wrappers for \verb+snprintf()+ and \verb+vsnprintf()+, if these functions
00043 are available, otherwise they are simply sprintf() or vsprintf().
00044 It is strongly recommended that \verb+LALSnprintf()+ and \verb+LALVsnprintf()+
00045 be used rather than \verb+sprintf()+ and \verb+vsprintf()+ as the latter are
00046 prone to buffer-overflow problems.
00047
00048 \vfill{\footnotesize\input{LALStdCV}}
00049
00050 </lalLaTeX>
00051 #endif
00052
00053
00054 #include <config.h>
00055 #include <stdlib.h>
00056 #include <stdarg.h>
00057
00058 #include <lal/LALRCSID.h>
00059 NRCSID (LALSTDC,"$Id: LALStd.c,v 1.4 2007/06/08 14:41:53 bema Exp $");
00060
00061 #ifdef HAVE_VSNPRINTF
00062 int vsnprintf( char *str, size_t size, const char *fmt, va_list ap );
00063 #else
00064 int vsprintf( char *str, const char *fmt, va_list ap );
00065 #define vsnprintf( s, n, f, a ) vsprintf( s, f, a );
00066 #endif
00067
00068 int LALSnprintf( char *str, size_t size, const char *fmt, ... );
00069 int LALVsnprintf( char *str, size_t size, const char *fmt, va_list ap );
00070 int LALSnprintf( char *str, size_t size, const char *fmt, ... )
00071 {
00072 int n;
00073 va_list ap;
00074 va_start( ap, fmt );
00075 n = vsnprintf( str, size, fmt, ap );
00076 va_end( ap );
00077 return n;
00078 }
00079 int LALVsnprintf( char *str, size_t size, const char *fmt, va_list ap )
00080 {
00081 return vsnprintf( str, size, fmt, ap );
00082 }
00083
00084
00085
00086
00087
00088 #if defined(NDEBUG) || defined(LAL_NDEBUG)
00089 const int lalNoDebug = 1;
00090 #else
00091 const int lalNoDebug = 0;
00092 #endif