File: vsnprintf.c

package info (click to toggle)
wu-ftpd 2.6.2-30
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 2,692 kB
  • ctags: 1,360
  • sloc: ansic: 18,114; sh: 3,354; yacc: 1,742; perl: 650; makefile: 224
file content (51 lines) | stat: -rw-r--r-- 1,809 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/****************************************************************************  
 
  Copyright (c) 1999,2000 WU-FTPD Development Group.  
  All rights reserved.
  
  Portions Copyright (c) 1980, 1985, 1988, 1989, 1990, 1991, 1993, 1994
    The Regents of the University of California.
  Portions Copyright (c) 1993, 1994 Washington University in Saint Louis.
  Portions Copyright (c) 1996, 1998 Berkeley Software Design, Inc.
  Portions Copyright (c) 1989 Massachusetts Institute of Technology.
  Portions Copyright (c) 1998 Sendmail, Inc.
  Portions Copyright (c) 1983, 1995, 1996, 1997 Eric P.  Allman.
  Portions Copyright (c) 1997 by Stan Barber.
  Portions Copyright (c) 1997 by Kent Landfield.
  Portions Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997
    Free Software Foundation, Inc.  
 
  Use and distribution of this software and its source code are governed 
  by the terms and conditions of the WU-FTPD Software License ("LICENSE").
 
  If you did not receive a copy of the license, it may be obtained online
  at http://www.wu-ftpd.org/license.html.
 
  $Id: vsnprintf.c,v 1.5 2000/07/01 18:36:29 wuftpd Exp $
 
****************************************************************************/
/*
 * vsnprintf hack 
 * better than raw vsprintf, but only just barely....
 */
#include <stdio.h>
#include <varargs.h>

int vsnprintf(char *str, size_t size, const char *format, va_list ap)
{
    char *str;
    int status;
    if (bufsize < 1)
	return (EOF);
    /* we need to verify that the actual length of the buf is greater than
       or equal to the bufsize argument */
    if ((str = (char *) calloc(bufsize + 1)) != NULL) {
	strncpy(str, buf, bufsize);
	status = vsprintf(str, fmt, ap);
	strcpy(buf, str);
	free(str);
    }
    else
	status = vsprintf(buf, fmt, ap);
    return status;
}