2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License, Version 1.0 only
2N/A * (the "License"). You may not use this file except in compliance
2N/A * with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 1995, by Sun Microsystems, Inc.
2N/A * All rights reserved.
2N/A */
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A/*
2N/A * tputs.c
2N/A *
2N/A * XCurses Library
2N/A *
2N/A * Copyright 1990, 1995 by Mortice Kern Systems Inc. All rights reserved.
2N/A *
2N/A */
2N/A
2N/A#ifdef M_RCSID
2N/A#ifndef lint
2N/Astatic char rcsID[] = "$Header: /rd/src/libc/xcurses/rcs/tputs.c 1.4 1995/07/19 12:44:45 ant Exp $";
2N/A#endif
2N/A#endif
2N/A
2N/A#include <private.h>
2N/A#include <ctype.h>
2N/A#include <string.h>
2N/A#include <stdlib.h>
2N/A
2N/Aint
2N/A__m_putchar(byte)
2N/Aint byte;
2N/A{
2N/A return putchar(byte);
2N/A}
2N/A
2N/Aint
2N/A(putp)(const char *s)
2N/A{
2N/A int code;
2N/A
2N/A#ifdef M_CURSES_TRACE
2N/A __m_trace("putp(%p = \"%s\")", s, s);
2N/A#endif
2N/A
2N/A code = tputs(s, 1, __m_putchar);
2N/A
2N/A return __m_return_code("putp", code);
2N/A}
2N/A
2N/A/*f
2N/A * Apply padding information to a string and write it out.
2N/A * Note the '/' option is not supported.
2N/A */
2N/Aint
2N/Atputs(string, affcnt, putout)
2N/Aconst char *string;
2N/Aint affcnt;
2N/Aint (*putout)(int);
2N/A{
2N/A char *mark;
2N/A int i, baud, len, null, number;
2N/A
2N/A#ifdef M_CURSES_TRACE
2N/A __m_trace("tputs(%p = \"%s\", %d, %p)", string, string, affcnt, putout);
2N/A#endif
2N/A
2N/A baud = baudrate();
2N/A null = pad_char == (char *) 0 ? '\0' : pad_char[0];
2N/A
2N/A for (len = 0; *string; ++string){
2N/A /* Look for "$<num.????>" */
2N/A if (*string == '$'
2N/A && string[1] == '<'
2N/A && (isdigit(string[2]) || string[2] == '.')
2N/A && (mark = strchr(string, '>'))){
2N/A number = atoi(string+2) * 10;
2N/A if ((string = strchr(string, '.')) != (char *) 0)
2N/A number += *++string-'0';
2N/A string = mark;
2N/A if (*--mark == '*')
2N/A number *= affcnt;
2N/A if (padding_baud_rate && baud >= padding_baud_rate
2N/A && !xon_xoff) {
2N/A number = (baud/10 * number)/1000;
2N/A len += number;
2N/A if (putout != (int (*)(int)) 0) {
2N/A for (i=0; i < number; i++)
2N/A (void) (*putout)(null);
2N/A }
2N/A }
2N/A } else {
2N/A ++len;
2N/A if (putout != (int (*)(int)) 0)
2N/A (void) (*putout)(*string);
2N/A }
2N/A }
2N/A
2N/A return __m_return_int("tputs", len);
2N/A}
2N/A
2N/A