Code indentation.
[midnight-commander.git] / src / vfs / smbfs / helpers / lib / slprintf.c
blob28a2804b3dd234aab3f23995dd77c8118bb4c154
1 /*
2 Unix SMB/Netbios implementation.
3 Version 1.9.
4 snprintf replacement
6 Copyright (C) Andrew Tridgell 1998
8 Copyright (C) 2011
9 The Free Software Foundation, Inc.
11 This file is part of the Midnight Commander.
13 The Midnight Commander is free software: you can redistribute it
14 and/or modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation, either version 3 of the License,
16 or (at your option) any later version.
18 The Midnight Commander is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program. If not, see <http://www.gnu.org/licenses/>.
27 #include "includes.h"
29 extern int DEBUGLEVEL;
32 /* this is like vsnprintf but the 'n' limit does not include
33 the terminating null. So if you have a 1024 byte buffer then
34 pass 1023 for n */
35 int
36 vslprintf (char *str, int n, const char *format, va_list ap)
38 int ret = vsnprintf (str, n, format, ap);
39 if (ret > n || ret < 0)
41 str[n] = 0;
42 return -1;
44 str[ret] = 0;
45 return ret;
48 #ifdef HAVE_STDARG_H
49 int
50 slprintf (char *str, int n, const char *format, ...)
52 #else
53 int
54 slprintf (va_alist)
55 va_dcl
57 char *str, *format;
58 int n;
59 #endif
60 va_list ap;
61 int ret;
63 #ifdef HAVE_STDARG_H
64 va_start (ap, format);
65 #else
66 va_start (ap);
67 str = va_arg (ap, char *);
68 n = va_arg (ap, int);
69 format = va_arg (ap, char *);
70 #endif
72 ret = vslprintf (str, n, format, ap);
73 va_end (ap);
74 return ret;