root/src/vfs/smbfs/helpers/lib/slprintf.c

/* [previous][next][first][last][top][bottom][index][help]  */

DEFINITIONS

This source file includes following definitions.
  1. vslprintf
  2. slprintf
  3. slprintf

   1 /*
   2    Unix SMB/Netbios implementation.
   3    Version 1.9.
   4    snprintf replacement
   5 
   6    Copyright (C) Andrew Tridgell 1998
   7 
   8    Copyright (C) 2011-2020
   9    Free Software Foundation, Inc.
  10 
  11    This file is part of the Midnight Commander.
  12 
  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.
  17 
  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.
  22 
  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/>.
  25  */
  26 
  27 #include "includes.h"
  28 
  29 extern int DEBUGLEVEL;
  30 
  31 
  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)
     /* [previous][next][first][last][top][bottom][index][help]  */
  37 {
  38     int ret = vsnprintf (str, n, format, ap);
  39     if (ret > n || ret < 0)
  40     {
  41         str[n] = 0;
  42         return -1;
  43     }
  44     str[ret] = 0;
  45     return ret;
  46 }
  47 
  48 #ifdef HAVE_STDARG_H
  49 int
  50 slprintf (char *str, int n, const char *format, ...)
     /* [previous][next][first][last][top][bottom][index][help]  */
  51 {
  52 #else
  53 int
  54 slprintf (va_alist)
     /* [previous][next][first][last][top][bottom][index][help]  */
  55      va_dcl
  56 {
  57     char *str, *format;
  58     int n;
  59 #endif
  60     va_list ap;
  61     int ret;
  62 
  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
  71 
  72     ret = vslprintf (str, n, format, ap);
  73     va_end (ap);
  74     return ret;
  75 }

/* [previous][next][first][last][top][bottom][index][help]  */