xref: /freebsd/contrib/nvi/ex/ex_stop.c (revision 7899f917b1c0ea178f1d2be0cfb452086d079d23)
1 /*-
2  * Copyright (c) 1993, 1994
3  *	The Regents of the University of California.  All rights reserved.
4  * Copyright (c) 1992, 1993, 1994, 1995, 1996
5  *	Keith Bostic.  All rights reserved.
6  *
7  * See the LICENSE file for redistribution information.
8  */
9 
10 #include "config.h"
11 
12 #include <sys/types.h>
13 #include <sys/queue.h>
14 #include <sys/time.h>
15 
16 #include <bitstring.h>
17 #include <errno.h>
18 #include <limits.h>
19 #include <stdio.h>
20 #include <string.h>
21 #include <unistd.h>
22 
23 #include "../common/common.h"
24 
25 /*
26  * ex_stop -- :stop[!]
27  *	      :suspend[!]
28  *	Suspend execution.
29  *
30  * PUBLIC: int ex_stop(SCR *, EXCMD *);
31  */
32 int
33 ex_stop(SCR *sp, EXCMD *cmdp)
34 {
35 	int allowed;
36 
37 	/* For some strange reason, the force flag turns off autowrite. */
38 	if (!FL_ISSET(cmdp->iflags, E_C_FORCE) && file_aw(sp, FS_ALL))
39 		return (1);
40 
41 	if (sp->gp->scr_suspend(sp, &allowed))
42 		return (1);
43 	if (!allowed)
44 		ex_emsg(sp, NULL, EXM_NOSUSPEND);
45 	return (0);
46 }
47