slibc
stdio_templates_.hpp
Go to the documentation of this file.
00001 /* Copyright (C) 2011-2012 SBA Research gGmbh
00002 
00003    This file is part of the Slibc Library.
00004 
00005    The Slibc Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The Slibc library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the Slibc Library; if not, see
00017    <http://www.gnu.org/licenses/>.  
00018 */
00027 #ifndef SLIBC_STDIO_TEMPLATES_HPP
00028 #define SLIBC_STDIO_TEMPLATES_HPP
00029 
00030 #include "./stdio.h"
00031 #include <stdarg.h>
00032 
00048 template<rsize_t n> int sprintf_s(char (&s1)[n], 
00049                                                                   const char * restrict format, ...) 
00050 {
00051   va_list arg;
00052   va_start(arg, format);
00053   int r = vsprintf_s(s1, n, format, arg);
00054   va_end(arg);
00055   return r; 
00056 }
00057 
00058 
00075 template<rsize_t n> int snprintf_s(char (&s1)[n], 
00076                                                                   const char * restrict format, ...) 
00077 {
00078   va_list arg;
00079   va_start(arg, format);
00080   int r = vsnprintf_s(s1, n, format, arg);
00081   va_end(arg);
00082   return r; 
00083 }
00084 
00085 #endif