2003-10-16 Theodore A. Roth * include/stdio.h: Add prototypes and dox for vfprintf_P and vfscanf_P. * libc/stdio/Makefile.am (lib_a_c_sources): Add vfprintf_p.c and vfscanf_p.c. * libc/stdio/vfprintf_p.c: New file. * libc/stdio/vfscanf_p.c: New file. Index: include/stdio.h =================================================================== RCS file: /cvsroot/avr-libc/avr-libc/include/stdio.h,v retrieving revision 1.12 diff -u -p -r1.12 stdio.h --- include/stdio.h 30 Sep 2003 23:05:17 -0000 1.12 +++ include/stdio.h 16 Oct 2003 18:17:07 -0000 @@ -362,6 +362,12 @@ extern int fclose(FILE *__stream); extern int vfprintf(FILE *__stream, const char *__fmt, va_list __ap); /** + Variant of \c vfprintf() that uses a \c fmt string that resides + in program memory. +*/ +extern int vfprintf_P(FILE *__stream, const char *__fmt, va_list __ap); + +/** The function \c fputc sends the character \c c (though given as type \c int) to \c stream. It returns the character, or \c EOF in case an error occurred. @@ -718,6 +724,11 @@ extern int ferror(FILE *__stream); that support it is implemented. */ extern int vfscanf(FILE *__stream, const char *__fmt, va_list __ap); + +/** + Variant of vfscanf() using a \c fmt string in program memory. + */ +extern int vfscanf_P(FILE *__stream, const char *__fmt, va_list __ap); /** The function \c fscanf performs formatted input, reading the Index: libc/stdio/Makefile.am =================================================================== RCS file: /cvsroot/avr-libc/avr-libc/libc/stdio/Makefile.am,v retrieving revision 1.9 diff -u -p -r1.9 Makefile.am --- libc/stdio/Makefile.am 7 Jan 2003 22:17:24 -0000 1.9 +++ libc/stdio/Makefile.am 16 Oct 2003 18:17:07 -0000 @@ -64,6 +64,8 @@ lib_a_c_sources = \ sprintf_p.c \ sscanf.c \ sscanf_p.c \ + vfprintf_p.c \ + vfscanf_p.c \ ungetc.c lib_a_asm_sources = \ Index: libc/stdio/vfprintf_p.c =================================================================== RCS file: libc/stdio/vfprintf_p.c diff -N libc/stdio/vfprintf_p.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ libc/stdio/vfprintf_p.c 16 Oct 2003 18:17:07 -0000 @@ -0,0 +1,46 @@ +/* Copyright (c) 2003, Theodore A. Roth + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name of the copyright holders nor the names of + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. */ + +/* $Id$ */ + +#include +#include + +#include "stdio_private.h" + +int +vfprintf_P (FILE *stream, const char *fmt, va_list ap) +{ + int i; + + stream->flags |= __SPGM; + i = vfprintf(stream, fmt, ap); + stream->flags &= ~__SPGM; + + return i; +} Index: libc/stdio/vfscanf_p.c =================================================================== RCS file: libc/stdio/vfscanf_p.c diff -N libc/stdio/vfscanf_p.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ libc/stdio/vfscanf_p.c 16 Oct 2003 18:17:07 -0000 @@ -0,0 +1,46 @@ +/* Copyright (c) 2003, Theodore A. Roth + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name of the copyright holders nor the names of + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. */ + +/* $Id$ */ + +#include +#include + +#include "stdio_private.h" + +int +vfscanf_P(FILE *stream, const char *fmt, va_list ap) +{ + int i; + + stream->flags |= __SPGM; + i = vfscanf(stream, fmt, ap); + stream->flags &= ~__SPGM; + + return i; +}