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