]> diplodocus.org Git - nmh/blob - docs/historical/mh-jun-1982/Extras/libh/getl.c
Replaced use of snprintf() with memcpy()/memmove().
[nmh] / docs / historical / mh-jun-1982 / Extras / libh / getl.c
1 #ifdef COMMENT
2 Proprietary Rand Corporation, 1981.
3 Further distribution of this software
4 subject to the terms of the Rand
5 license agreement.
6 #endif
7
8 #include "../h/iobuf.h"
9 /* return one line using getc, caller must supply iobuf pointer, */
10 /* line buffer, and max. count */
11 /* returns actual char count */
12
13 getl(bufp,line,cnt)
14 struct iobuf *bufp;
15 char line[];
16 int cnt;
17 {
18 register char *lp;
19 register c, cc;
20
21 lp = line;
22 cc = cnt;
23 while ((c = getc(bufp)) >= 0) {
24 *lp++ = c;
25 if (--cc <= 0 || c == '\n') break;
26 }
27 return(cnt-cc);
28 }