sl@0: /* PUTCHAR.C sl@0: * sl@0: * Portions Copyright (c) 1990-2006 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: */ sl@0: sl@0: /* sl@0: * Copyright (c) 1990 The Regents of the University of California. sl@0: * All rights reserved. sl@0: * sl@0: * Redistribution and use in source and binary forms are permitted sl@0: * provided that the above copyright notice and this paragraph are sl@0: * duplicated in all such forms and that any documentation, sl@0: * advertising materials, and other materials related to such sl@0: * distribution and use acknowledge that the software was developed sl@0: * by the University of California, Berkeley. The name of the sl@0: * University may not be used to endorse or promote products derived sl@0: * from this software without specific prior written permission. sl@0: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR sl@0: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED sl@0: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. sl@0: */ sl@0: sl@0: /* sl@0: FUNCTION sl@0: <>---write a character (macro) sl@0: sl@0: INDEX sl@0: putchar sl@0: INDEX sl@0: _putchar_r sl@0: sl@0: ANSI_SYNOPSIS sl@0: #include sl@0: int putchar(int <[ch]>); sl@0: sl@0: int _putchar_r(void *<[reent]>, int <[ch]>); sl@0: sl@0: TRAD_SYNOPSIS sl@0: #include sl@0: int putchar(<[ch]>) sl@0: int <[ch]>; sl@0: sl@0: int _putchar_r(<[reent]>, <[ch]>) sl@0: char *<[reent]>; sl@0: int <[ch]>; sl@0: sl@0: DESCRIPTION sl@0: <> is a macro, defined in <>. <> sl@0: writes its argument to the standard output stream, sl@0: after converting it from an <> to an <>. sl@0: sl@0: The alternate function <<_putchar_r>> is a reentrant version. The sl@0: extra argument <[reent]> is a pointer to a reentrancy structure. sl@0: sl@0: RETURNS sl@0: If successful, <> returns its argument <[ch]>. If an error sl@0: intervenes, the result is <>. You can use `<>' to sl@0: query for errors. sl@0: sl@0: PORTABILITY sl@0: ANSI C requires <>; it suggests, but does not require, that sl@0: <> be implemented as a macro. sl@0: sl@0: Supporting OS subroutines required: <>, <>, <>, sl@0: <>, <>, <>, <>. sl@0: */ sl@0: sl@0: /* sl@0: * A subroutine version of the macro putchar sl@0: */ sl@0: sl@0: #include sl@0: #include "LOCAL.H" sl@0: sl@0: #undef putchar sl@0: sl@0: /** sl@0: A reentrant version of putchar(). sl@0: */ sl@0: EXPORT_C int sl@0: _putchar_r (struct _reent *ptr,int c) sl@0: { sl@0: return __sputc ((unsigned char)c, _stdout_r (ptr)); sl@0: } sl@0: sl@0: #ifndef _REENT_ONLY sl@0: sl@0: #undef putchar sl@0: /** sl@0: Write character to standard output. sl@0: Writes character to the current position in the standard output sl@0: and increases the file pointer to point to next character. sl@0: This routine cooresponds to: putc(character,stdout). sl@0: sl@0: @param c Character to be written. sl@0: sl@0: @return On Success, returns the written character. sl@0: On Failure, EOF is returned and errno may be set. sl@0: */ sl@0: EXPORT_C int sl@0: putchar (int c) sl@0: { sl@0: /* CHECK_INIT is (eventually) called by __swbuf. */ sl@0: struct _reent *r = _REENT2; sl@0: if (!r) sl@0: return EOF; // Memory for library globals is not allocated (errno not set). sl@0: return(_putchar_r (r, c)); sl@0: } sl@0: sl@0: #endif