xref: /original-bsd/lib/libcurses/addnstr.c (revision abb2de7b)
1 /*
2  * Copyright (c) 1993
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.1 (Berkeley) 06/04/93";
10 #endif	/* not lint */
11 
12 #include <curses.h>
13 #include <string.h>
14 
15 /*
16  * waddnstr --
17  *	Add a string (at most n characters) to the given window
18  *	starting at (_cury, _curx).  If n is negative, add the
19  *	entire string.
20  */
21 int
22 waddnstr(win, s, n)
23 	WINDOW *win;
24 	const char *s;
25 	int n;
26 {
27 	size_t len;
28 	const char *p;
29 
30 	if (n > 0)
31 		for (p = s, len = 0; n-- && *p++; ++len);
32 	else
33 		len = strlen(s);
34 	return (waddbytes(win, s, len));
35 }
36