2 Unix SMB/Netbios implementation.
5 Copyright (C) Andrew Tridgell 1998
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 extern int DEBUGLEVEL;
26 int vslprintf(char *str, int n, char *format, va_list ap)
29 int ret = vsnprintf(str, n, format, ap);
30 if (ret >= 0) str[ret] = 0;
38 if (!len || !buf || (len-pagesize) < n) {
39 pagesize = getpagesize();
40 len = (2+(n/pagesize))*pagesize;
41 /* note: we don't free the old memory (if any) as we don't
42 want a malloc lib to reuse the memory as it will
43 have the wrong permissions */
44 buf = memalign(pagesize, len);
46 if (mprotect(buf+(len-pagesize), pagesize, PROT_READ) != 0) {
57 ret = vsprintf(str, format, ap);
58 /* we will have got a seg fault here if we overflowed the buffer */
64 int slprintf(char *str, int n, char *format, ...)
67 int slprintf(va_alist)
80 str = va_arg(ap,char *);
82 format = va_arg(ap,char *);
85 ret = vslprintf(str,n,format,ap);