clear.c revision 174993
155682Smarkm/****************************************************************************
255682Smarkm * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc.              *
355682Smarkm *                                                                          *
455682Smarkm * Permission is hereby granted, free of charge, to any person obtaining a  *
555682Smarkm * copy of this software and associated documentation files (the            *
655682Smarkm * "Software"), to deal in the Software without restriction, including      *
755682Smarkm * without limitation the rights to use, copy, modify, merge, publish,      *
855682Smarkm * distribute, distribute with modifications, sublicense, and/or sell       *
955682Smarkm * copies of the Software, and to permit persons to whom the Software is    *
1055682Smarkm * furnished to do so, subject to the following conditions:                 *
1155682Smarkm *                                                                          *
1255682Smarkm * The above copyright notice and this permission notice shall be included  *
1355682Smarkm * in all copies or substantial portions of the Software.                   *
1455682Smarkm *                                                                          *
1555682Smarkm * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
1655682Smarkm * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
1755682Smarkm * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
1855682Smarkm * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
1955682Smarkm * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
2055682Smarkm * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
2155682Smarkm * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
2255682Smarkm *                                                                          *
2355682Smarkm * Except as contained in this notice, the name(s) of the above copyright   *
2455682Smarkm * holders shall not be used in advertising or otherwise to promote the     *
2555682Smarkm * sale, use or other dealings in this Software without prior written       *
2655682Smarkm * authorization.                                                           *
2755682Smarkm ****************************************************************************/
2855682Smarkm
2955682Smarkm/****************************************************************************
3055682Smarkm *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
3155682Smarkm *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
3255682Smarkm *     and: Thomas E. Dickey                        1996-on                 *
3355682Smarkm ****************************************************************************/
3455682Smarkm
3555682Smarkm/*
3655682Smarkm * clear.c --  clears the terminal's screen
3755682Smarkm */
3855682Smarkm
3955682Smarkm#define USE_LIBTINFO
4055682Smarkm#include <progs.priv.h>
4155682Smarkm
4255682SmarkmMODULE_ID("$Id: clear.c,v 1.11 2007/10/13 22:16:02 tom Exp $")
4355682Smarkm
4455682Smarkmstatic int
4555682Smarkmputch(int c)
4655682Smarkm{
4755682Smarkm    return putchar(c);
4855682Smarkm}
4955682Smarkm
5055682Smarkmint
5155682Smarkmmain(
5255682Smarkm	int argc GCC_UNUSED,
5355682Smarkm	char *argv[]GCC_UNUSED)
5455682Smarkm{
5555682Smarkm    setupterm((char *) 0, STDOUT_FILENO, (int *) 0);
5655682Smarkm    ExitProgram((tputs(clear_screen, lines > 0 ? lines : 1, putch) == ERR)
5755682Smarkm		? EXIT_FAILURE
58		: EXIT_SUCCESS);
59}
60