Back to index

tetex-bin  3.0
my-snprintf.c
Go to the documentation of this file.
00001 /*------------------------------------------------------------
00002 
00003 Permission is hereby granted, free of charge, to any person obtaining a copy
00004 of this software and associated documentation files (the "Software"), to
00005 deal in the Software without restriction, including without limitation the
00006 rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
00007 sell copies of the Software, and to permit persons to whom the Software is
00008 furnished to do so, subject to the following conditions:
00009 
00010 The above copyright notice and this permission notice shall be included in
00011 all copies or substantial portions of the Software.
00012 
00013 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00014 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00015 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00016 IN NO EVENT SHALL PAUL VOJTA OR ANY OTHER AUTHOR OF THIS SOFTWARE BE
00017 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00018 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00019 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00020 ------------------------------------------------------------*/
00021 
00022 #include <string.h>
00023 #include <stdio.h>
00024 
00025 #include "xdvi-config.h"
00026 #include "xdvi.h"
00027 #include "my-vsnprintf.h"
00028 #include "my-snprintf.h"
00029 
00030 #ifndef HAVE_SNPRINTF
00031 /*------------------------------------------------------------
00032  *  my_snprintf - emulation of glibc2.1 snprintf, use if
00033  *              snprintf is not available 
00034  *
00035  *  Arguments:
00036  *     char *str     - buffer to print <format> string into
00037  *     int size      - print only len characters of <format>
00038  *     char *format  - variable format list
00039  *
00040  *  Returns:
00041  *      int size - number of characters that would have been
00042  *                written if enough space had been available
00043  *
00044  *  Purpose:
00045  *     Implementation of snprintf function, using my_vsnprintf
00046  *     (which see).
00047  *------------------------------------------------------------*/
00048 int my_snprintf(char *str, size_t size, const  char  *format, ...)
00049 {
00050   va_list args;
00051   int retVal;
00052 
00053   va_start(args, format);
00054   retVal = VSNPRINTF(str, size, format, args);
00055   va_end(args);
00056 
00057   return retVal;
00058 }
00059 #endif