Use dos.library/CreateNewProc() instead of alib/CreateNewProcTags()
[tangerine.git] / compiler / clib / vsnprintf.c
blob09312faab24a80e3b097c6041fe4109f8f23e27b
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 C function vsnprintf().
6 */
7 /* Original source from libnix */
9 #include <stdio.h>
11 struct data
13 char * str;
14 size_t n;
17 static int _vsnprintf_uc (int c, struct data * data)
19 if (data->n)
21 *(data->str) ++ = c;
22 data->n --;
24 return 1;
27 return EOF;
30 /*****************************************************************************
32 NAME */
33 #include <stdio.h>
34 #include <stdarg.h>
36 int vsnprintf (
38 /* SYNOPSIS */
39 char * str,
40 size_t n,
41 const char * format,
42 va_list args)
44 /* FUNCTION
45 Format a list of arguments and put them into the string str.
46 The function makes sure that no more than n characters (including
47 the terminal 0 byte) are written into str.
49 INPUTS
50 str - The formatted result is stored here
51 n - The size of str
52 format - A printf() format string.
53 args - A list of arguments for the format string.
55 RESULT
56 The number of characters written or -1 if the string was too small.
57 In this case, the string is not 0-terminated.
59 NOTES
60 No check is beeing made that str is large enough to contain
61 the result.
63 EXAMPLE
65 BUGS
67 SEE ALSO
68 printf(), sprintf(), fprintf(), vprintf(), vfprintf(), snprintf(),
69 vsnprintf()
71 INTERNALS
73 ******************************************************************************/
75 int rc;
76 struct data data;
78 data.n = n;
79 data.str = str;
81 rc = __vcformat (&data, (void *)_vsnprintf_uc, format, args);
83 if (data.n)
85 *(data.str) = 0;
87 return (n - data.n);
90 return -1;
91 } /* vsnprintf */