getchar.c revision 178778
10SN/A/*- 23909SN/A * Copyright (c) 1990, 1993 30SN/A * The Regents of the University of California. All rights reserved. 40SN/A * 50SN/A * This code is derived from software contributed to Berkeley by 60SN/A * Chris Torek. 72362SN/A * 80SN/A * Redistribution and use in source and binary forms, with or without 92362SN/A * modification, are permitted provided that the following conditions 100SN/A * are met: 110SN/A * 1. Redistributions of source code must retain the above copyright 120SN/A * notice, this list of conditions and the following disclaimer. 130SN/A * 2. Redistributions in binary form must reproduce the above copyright 140SN/A * notice, this list of conditions and the following disclaimer in the 150SN/A * documentation and/or other materials provided with the distribution. 160SN/A * 4. Neither the name of the University nor the names of its contributors 170SN/A * may be used to endorse or promote products derived from this software 180SN/A * without specific prior written permission. 190SN/A * 200SN/A * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 212362SN/A * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 222362SN/A * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 232362SN/A * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 240SN/A * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 250SN/A * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 260SN/A * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 270SN/A * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 280SN/A * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 290SN/A * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 300SN/A * SUCH DAMAGE. 310SN/A */ 320SN/A 330SN/A#if defined(LIBC_SCCS) && !defined(lint) 341118SN/Astatic char sccsid[] = "@(#)getchar.c 8.1 (Berkeley) 6/4/93"; 350SN/A#endif /* LIBC_SCCS and not lint */ 360SN/A#include <sys/cdefs.h> 370SN/A__FBSDID("$FreeBSD: head/lib/libc/stdio/getchar.c 178778 2008-05-05 16:03:52Z jhb $"); 380SN/A 390SN/A/* 400SN/A * A subroutine version of the macro getchar. 410SN/A */ 420SN/A#include "namespace.h" 430SN/A#include <stdio.h> 440SN/A#include "un-namespace.h" 450SN/A#include "local.h" 460SN/A#include "libc_private.h" 470SN/A 480SN/A#undef getchar 490SN/A#undef getchar_unlocked 500SN/A 510SN/Aint 520SN/Agetchar() 530SN/A{ 540SN/A int retval; 550SN/A FLOCKFILE(stdin); 560SN/A /* Orientation set by __sgetc() when buffer is empty. */ 570SN/A /* ORIENT(stdin, -1); */ 580SN/A retval = __sgetc(stdin); 590SN/A FUNLOCKFILE(stdin); 600SN/A return (retval); 610SN/A} 620SN/A 630SN/Aint 640SN/Agetchar_unlocked(void) 650SN/A{ 660SN/A 670SN/A return (__sgetc(stdin)); 680SN/A} 690SN/A