summaryrefslogtreecommitdiffabout
path: root/libical/src/libical/vsnprintf.c
Unidiff
Diffstat (limited to 'libical/src/libical/vsnprintf.c') (more/less context) (ignore whitespace changes)
-rw-r--r--libical/src/libical/vsnprintf.c28
1 files changed, 10 insertions, 18 deletions
diff --git a/libical/src/libical/vsnprintf.c b/libical/src/libical/vsnprintf.c
index 88a8c63..982920b 100644
--- a/libical/src/libical/vsnprintf.c
+++ b/libical/src/libical/vsnprintf.c
@@ -1,51 +1,54 @@
1#ifdef __osf__ 1#ifndef WIN32
2#include "config.h"
3#endif
4#ifndef HAVE_SNPRINTF
2/* 5/*
3 * Revision 12: http://theos.com/~deraadt/snprintf.c 6 * Revision 12: http://theos.com/~deraadt/snprintf.c
4 * 7 *
5 * Copyright (c) 1997 Theo de Raadt 8 * Copyright (c) 1997 Theo de Raadt
6 * 9 *
7 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
9 * are met: 12 * are met:
10 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
15 * 18 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 29 */
27 30
28#include <sys/types.h> 31#ifndef WIN32
29#include <stdio.h>
30
31#include <unistd.h>
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/mman.h> 33#include <sys/mman.h>
34#include <unistd.h>
35#endif
36#include <sys/types.h>
34#include <signal.h> 37#include <signal.h>
35 38#include <stdio.h>
36#include <string.h> 39#include <string.h>
37#if __STDC__ 40#if __STDC__
38#include <stdarg.h> 41#include <stdarg.h>
39#include <stdlib.h> 42#include <stdlib.h>
40#else 43#else
41#include <varargs.h> 44#include <varargs.h>
42#endif 45#endif
43#include <setjmp.h> 46#include <setjmp.h>
44 47
45#ifndef roundup 48#ifndef roundup
46#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) 49#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
47#endif 50#endif
48 51
49static int pgsize; 52static int pgsize;
50static char *curobj; 53static char *curobj;
51static sigjmp_buf bail; 54static sigjmp_buf bail;
@@ -144,37 +147,26 @@ snprintf(str, n, fmt, va_alist)
144 size_t n; 147 size_t n;
145 char *fmt; 148 char *fmt;
146 va_dcl 149 va_dcl
147#endif 150#endif
148{ 151{
149 va_list ap; 152 va_list ap;
150#if __STDC__ 153#if __STDC__
151 va_start(ap, fmt); 154 va_start(ap, fmt);
152#else 155#else
153 va_start(ap); 156 va_start(ap);
154#endif 157#endif
155 158
156 return (vsnprintf(str, n, fmt, ap)); 159 return (vsnprintf(str, n, fmt, ap));
157 va_end(ap); 160 va_end(ap);
158} 161}
159 162
160#elif defined ( _WIN32 )
161
162#include <stdio.h>
163#include <stdarg.h>
164
165int snprintf(char *str, size_t n, char const *fmt, ...)
166{
167 va_list ap;
168 va_start(ap, fmt);
169
170 return _snprintf(str, n, fmt, ap);
171}
172 163
173#else 164#else
165
174/* ANSI C forbids an empty source file... */ 166/* ANSI C forbids an empty source file... */
175 167
176static void vsnprintf_dummy_func() { 168static void vsnprintf_dummy_func() {
177 vsnprintf_dummy_func(); 169 vsnprintf_dummy_func();
178} 170}
179 171
180#endif 172#endif