Mirror of git://git.busybox.net/busybox with our patches on top
Source
/* vi: set sw=4 ts=4: */
/*
* *printf implementations for busybox
*
* Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/* Mar 12, 2003 Manuel Novoa III
*
* While fwrite(), fputc(), fputs(), etc. all set the stream error flag
* on failure, the *printf functions are unique in that they can fail
* for reasons not related to the actual output itself. Among the possible
* reasons for failure which don't set the streams error indicator,
* SUSv3 lists EILSEQ, EINVAL, and ENOMEM.
*
* In some cases, it would be desirable to have a group of *printf()
* functions available that _always_ set the stream error indicator on
* failure. That would allow us to defer error checking until applet
* exit. Unfortunately, there is no standard way of setting a streams
* error indicator... even though we can clear it with clearerr().
*
* Therefore, we have to resort to implementation dependent code. Feel
* free to send patches for stdio implementations where the following
* fails.
*
* NOTE: None of this is thread safe. As busybox is a non-threaded app,
* that isn't currently an issue.
*/
/* Using my newer stdio implementation. Unlocked macros are:
* #define __CLEARERR(stream) \
((stream)->modeflags &= ~(__FLAG_EOF|__FLAG_ERROR), (void)0)
* #define __FEOF(stream) ((stream)->modeflags & __FLAG_EOF)
* #define __FERROR(stream) ((stream)->modeflags & __FLAG_ERROR)
*/