add a missing section header table index conversion
[tangerine.git] / compiler / clib / snprintf.c
blob14c77c3913a631036feaca84a9b318f1f57f7003
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
5 ANSI C function snprintf().
6 */
8 /*****************************************************************************
10 NAME */
11 #include <stdio.h>
13 int snprintf (
15 /* SYNOPSIS */
16 char * str,
17 size_t n,
18 const char * format,
19 ...)
21 /* FUNCTION
22 Formats a list of arguments and writes them into the string str.
24 INPUTS
25 str - The formatted string is written into this variable. You
26 must make sure that it is large enough to contain the
27 result.
28 n - At most n characters are written into the string. This
29 includes the final 0.
30 format - Format string as described above
31 ... - Arguments for the format string
33 RESULT
34 The number of characters written into the string. If this is
35 -1, then there was not enough room. The 0 byte at the end is not
36 included.
38 NOTES
40 EXAMPLE
42 BUGS
44 SEE ALSO
45 fprintf(), vprintf(), vfprintf(), snprintf(), vsprintf(),
46 vnsprintf()
48 INTERNALS
50 ******************************************************************************/
52 int retval;
53 va_list args;
55 va_start (args, format);
57 retval = vsnprintf (str, n, format, args);
59 va_end (args);
61 return retval;
62 } /* snprintf */
64 #ifdef TEST
65 #include <stdio.h>
67 int main (int argc, char ** argv)
69 char buffer[11];
70 int rc;
72 printf ("snprintf test\n");
74 rc = snprintf (buffer, sizeof (buffer), "%10d", 5);
76 if (rc < sizeof (buffer))
77 printf ("rc=%d, buffer=\"%s\"\n", rc, buffer);
78 else
79 printf ("rc=%d\n", rc);
81 rc = snprintf (buffer, sizeof (buffer), "%11d", 5);
83 if (rc < sizeof (buffer))
84 printf ("rc=%d, buffer=\"%s\"\n", rc, buffer);
85 else
86 printf ("rc=%d\n", rc);
88 return 0;
89 } /* main */
91 #endif /* TEST */