Debian Codegraph @

texk/xdvik/my-snprintf.c

raw
1 /*------------------------------------------------------------
2
3 Permission is hereby granted, free of charge, to any person obtaining a copy
4 of this software and associated documentation files (the "Software"), to
5 deal in the Software without restriction, including without limitation the
6 rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 sell copies of the Software, and to permit persons to whom the Software is
8 furnished to do so, subject to the following conditions:
9
10 The above copyright notice and this permission notice shall be included in
11 all copies or substantial portions of the Software.
12
13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16 IN NO EVENT SHALL PAUL VOJTA OR ANY OTHER AUTHOR OF THIS SOFTWARE BE
17 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
18 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 ------------------------------------------------------------*/
21
22 #include "xdvi-config.h"
23
24 #include <string.h>
25 #include <stdio.h>
26
27 #include "xdvi.h"
28 #include "my-vsnprintf.h"
29 #include "my-snprintf.h"
30
31 #ifndef HAVE_SNPRINTF
32 /*------------------------------------------------------------
33 * my_snprintf - emulation of glibc2.1 snprintf, use if
34 * snprintf is not available
35 *
36 * Arguments:
37 * char *str - buffer to print <format> string into
38 * int size - print only len characters of <format>
39 * char *format - variable format list
40 *
41 * Returns:
42 * int size - number of characters that would have been
43 * written if enough space had been available
44 *
45 * Purpose:
46 * Implementation of snprintf function, using my_vsnprintf
47 * (which see).
48 *------------------------------------------------------------*/
49 int my_snprintf(char *str, size_t size, const char *format, ...)
50 {
51 va_list args;
52 int retVal;
53
54 va_start(args, format);
55 retVal = VSNPRINTF(str, size, format, args);
56 va_end(args);
57
58 return retVal;
59 }
60 #endif