xref: /original-bsd/lib/libcurses/addnstr.c (revision f4a18198)
1 /*
2  * Copyright (c) 1993, 1994
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)addnstr.c	8.2 (Berkeley) 05/04/94";
10 #endif	/* not lint */
11 
12 #include <string.h>
13 
14 #include "curses.h"
15 
16 /*
17  * waddnstr --
18  *	Add a string (at most n characters) to the given window
19  *	starting at (_cury, _curx).  If n is negative, add the
20  *	entire string.
21  */
22 int
23 waddnstr(win, s, n)
24 	WINDOW *win;
25 	const char *s;
26 	int n;
27 {
28 	size_t len;
29 	const char *p;
30 
31 	if (n > 0)
32 		for (p = s, len = 0; n-- && *p++; ++len);
33 	else
34 		len = strlen(s);
35 	return (waddbytes(win, s, len));
36 }
37