File: shell.c

package info (click to toggle)
ng 1.4.3.1-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,540 kB
  • ctags: 3,967
  • sloc: ansic: 40,681; asm: 3,150; cpp: 1,243; makefile: 526; sh: 67
file content (59 lines) | stat: -rw-r--r-- 1,258 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* $Id: shell.c,v 1.1.1.1 2000/06/27 01:47:56 amura Exp $ */
/*
 *		Shell commands.
 * The file contains the command
 * processor, shell-command
 *	written by Kaoru Maeda.
 */

/*
 * $Log: shell.c,v $
 * Revision 1.1.1.1  2000/06/27 01:47:56  amura
 * import to CVS
 *
 */

#include "config.h"	/* 91.01.10  by S.Yoshida */
#include "def.h"

#ifndef NO_SHELL
/*ARGSUSED*/
shellcmnd(f, n)
{
	char	buf[CMDLINELENGTH];
	char	*result;
	extern char *call_process();
	extern int isetmark(),gotobob();
	int	s;
	BUFFER	*bp, *obp;
	WINDOW	*wp, *owp;
	WINDOW	*popbuf();

	s = ereply("Shell command: ", buf, sizeof buf);
	if (s != TRUE)
		return s;
	if ((f & FFARG) == 0) {
		if ((bp = bfind("*Shell Command Output*", TRUE)) == NULL) return FALSE;
		if ((wp = popbuf(bp)) == NULL) return FALSE;
		bp->b_flag &= ~BFCHG;		/* Blow away old.	*/
		if (bclear(bp) != TRUE) return FALSE;
		obp = curbp; owp = curwp;
		curbp = bp; curwp = wp;
	}
	if ((result = call_process(buf, NULL)) == NULL)
		return FALSE;
	isetmark();
	ewprintf(result);
	s = insertfile(result, (char *)NULL);
	if((f & FFARG) == 0) {
		(VOID) gotobob(0, 1);
		bp->b_dotp = wp->w_dotp;
		bp->b_doto = wp->w_doto;
		curbp = obp;
		curwp = owp;
		bp->b_flag &= ~BFCHG;
	}
	unlink(result);
	return s;
}
#endif