summaryrefslogtreecommitdiffstats
path: root/lib/libncurses/lib_addstr.c
blob: d9cb30aae2fb96039ea23670b83cad8f73fe206c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for   *
*  details. If they are missing then this copy is in violation of    *
*  the copyright conditions.                                        */

/*
**	lib_addstr.c
*
**	The routines waddnstr(), waddchnstr().
**
*/

#include "curses.priv.h"

int
waddnstr(WINDOW *win, char *str, int n)
{
	T(("waddnstr(%x,\"%s\",%d) called", win, visbuf(str), n));

	if (str == NULL)
		return ERR;

	if (n < 0) {
		while (*str != '\0') {
		    if (waddch(win, (chtype)(unsigned char)*str++) == ERR)
			return(ERR);
		}
		return OK;
	}

	while((n-- > 0) && (*str != '\0')) {
		if (waddch(win, (chtype)(unsigned char)*str++) == ERR)
			return ERR;
	}
	return OK;
}

int
waddchnstr(WINDOW *win, chtype *str, int n)
{
	T(("waddchnstr(%x,%x,%d) called", win, str, n));

	if (n < 0) {
		while (*str) {
		    if (waddch(win, (chtype)(unsigned char)*str++) == ERR)
			return(ERR);
		}
		return OK;
	}

	while(n-- > 0) {
		if (waddch(win, (chtype)(unsigned char)*str++) == ERR)
			return ERR;
	}
	return OK;
}
OpenPOWER on IntegriCloud