xref: /dflybsd-src/contrib/nvi2/ex/ex_put.c (revision 07bc39c2f4bbca56f12568e06d89da17f2eeb965)
1*e0b8e63eSJohn Marino /*-
2*e0b8e63eSJohn Marino  * Copyright (c) 1992, 1993, 1994
3*e0b8e63eSJohn Marino  *	The Regents of the University of California.  All rights reserved.
4*e0b8e63eSJohn Marino  * Copyright (c) 1992, 1993, 1994, 1995, 1996
5*e0b8e63eSJohn Marino  *	Keith Bostic.  All rights reserved.
6*e0b8e63eSJohn Marino  *
7*e0b8e63eSJohn Marino  * See the LICENSE file for redistribution information.
8*e0b8e63eSJohn Marino  */
9*e0b8e63eSJohn Marino 
10*e0b8e63eSJohn Marino #include "config.h"
11*e0b8e63eSJohn Marino 
12*e0b8e63eSJohn Marino #include <sys/types.h>
13*e0b8e63eSJohn Marino #include <sys/queue.h>
14*e0b8e63eSJohn Marino #include <sys/time.h>
15*e0b8e63eSJohn Marino 
16*e0b8e63eSJohn Marino #include <bitstring.h>
17*e0b8e63eSJohn Marino #include <ctype.h>
18*e0b8e63eSJohn Marino #include <limits.h>
19*e0b8e63eSJohn Marino #include <stdio.h>
20*e0b8e63eSJohn Marino #include <string.h>
21*e0b8e63eSJohn Marino 
22*e0b8e63eSJohn Marino #include "../common/common.h"
23*e0b8e63eSJohn Marino 
24*e0b8e63eSJohn Marino /*
25*e0b8e63eSJohn Marino  * ex_put -- [line] pu[t] [buffer]
26*e0b8e63eSJohn Marino  *	Append a cut buffer into the file.
27*e0b8e63eSJohn Marino  *
28*e0b8e63eSJohn Marino  * PUBLIC: int ex_put(SCR *, EXCMD *);
29*e0b8e63eSJohn Marino  */
30*e0b8e63eSJohn Marino int
ex_put(SCR * sp,EXCMD * cmdp)31*e0b8e63eSJohn Marino ex_put(SCR *sp, EXCMD *cmdp)
32*e0b8e63eSJohn Marino {
33*e0b8e63eSJohn Marino 	MARK m;
34*e0b8e63eSJohn Marino 
35*e0b8e63eSJohn Marino 	NEEDFILE(sp, cmdp);
36*e0b8e63eSJohn Marino 
37*e0b8e63eSJohn Marino 	m.lno = sp->lno;
38*e0b8e63eSJohn Marino 	m.cno = sp->cno;
39*e0b8e63eSJohn Marino 	if (put(sp, NULL,
40*e0b8e63eSJohn Marino 	    FL_ISSET(cmdp->iflags, E_C_BUFFER) ? &cmdp->buffer : NULL,
41*e0b8e63eSJohn Marino 	    &cmdp->addr1, &m, 1))
42*e0b8e63eSJohn Marino 		return (1);
43*e0b8e63eSJohn Marino 	sp->lno = m.lno;
44*e0b8e63eSJohn Marino 	sp->cno = m.cno;
45*e0b8e63eSJohn Marino 	return (0);
46*e0b8e63eSJohn Marino }
47