mirror of
https://github.com/rfivet/uemacs.git
synced 2024-11-16 09:36:29 -05:00
Spawn commands based on newmlarg (replacement of mlreply).
This commit is contained in:
parent
bcba236265
commit
15453a9d52
174
spawn.c
174
spawn.c
@ -145,51 +145,24 @@ void rtfrmshell(void)
|
||||
* character to be typed, then mark the screen as garbage so a full repaint is
|
||||
* done. Bound to "C-X !".
|
||||
*/
|
||||
int spawn(int f, int n)
|
||||
{
|
||||
int spawn( int f, int n) {
|
||||
int s ;
|
||||
char line[NLINE];
|
||||
char *line ;
|
||||
|
||||
/* don't allow this command if restricted */
|
||||
if( restflag)
|
||||
return resterr();
|
||||
|
||||
#if VMS
|
||||
if ((s = mlreply("!", line, NLINE)) != TRUE)
|
||||
return s;
|
||||
movecursor(term.t_nrow, 0);
|
||||
TTflush();
|
||||
s = sys(line); /* Run the command. */
|
||||
if (clexec == FALSE) {
|
||||
mlwrite("\r\n\n(End)"); /* Pause. */
|
||||
TTflush();
|
||||
tgetc();
|
||||
}
|
||||
sgarbf = TRUE;
|
||||
return s;
|
||||
#endif
|
||||
#if MSDOS
|
||||
if ((s = mlreply("!", line, NLINE)) != TRUE)
|
||||
return s;
|
||||
movecursor(term.t_nrow, 0);
|
||||
TTkclose();
|
||||
shellprog(line);
|
||||
TTkopen();
|
||||
/* if we are interactive, pause here */
|
||||
if (clexec == FALSE) {
|
||||
mlwrite("\r\n(End)");
|
||||
tgetc();
|
||||
}
|
||||
sgarbf = TRUE;
|
||||
return TRUE;
|
||||
#endif
|
||||
#if V7 | USG | BSD
|
||||
if ((s = mlreply("!", line, NLINE)) != TRUE)
|
||||
s = newmlarg( &line, "!", 0) ;
|
||||
if( s != TRUE)
|
||||
return s ;
|
||||
|
||||
TTflush();
|
||||
TTclose(); /* stty to old modes */
|
||||
TTkclose();
|
||||
ue_system( line) ;
|
||||
free( line) ;
|
||||
fflush(stdout); /* to be sure P.K. */
|
||||
TTopen();
|
||||
|
||||
@ -211,51 +184,25 @@ int spawn(int f, int n)
|
||||
* done. Bound to "C-X $".
|
||||
*/
|
||||
|
||||
int execprg(int f, int n)
|
||||
{
|
||||
int execprg( int f, int n) {
|
||||
int s ;
|
||||
char line[NLINE];
|
||||
char *line ;
|
||||
|
||||
/* don't allow this command if restricted */
|
||||
if( restflag)
|
||||
return resterr() ;
|
||||
|
||||
#if VMS
|
||||
if ((s = mlreply("!", line, NLINE)) != TRUE)
|
||||
return s;
|
||||
TTflush();
|
||||
s = sys(line); /* Run the command. */
|
||||
mlwrite("\r\n\n(End)"); /* Pause. */
|
||||
TTflush();
|
||||
tgetc();
|
||||
sgarbf = TRUE;
|
||||
return s;
|
||||
#endif
|
||||
|
||||
#if MSDOS
|
||||
if ((s = mlreply("$", line, NLINE)) != TRUE)
|
||||
return s;
|
||||
movecursor(term.t_nrow, 0);
|
||||
TTkclose();
|
||||
execprog(line);
|
||||
TTkopen();
|
||||
/* if we are interactive, pause here */
|
||||
if (clexec == FALSE) {
|
||||
mlwrite("\r\n(End)");
|
||||
tgetc();
|
||||
}
|
||||
sgarbf = TRUE;
|
||||
return TRUE;
|
||||
#endif
|
||||
|
||||
#if V7 | USG | BSD
|
||||
if ((s = mlreply("!", line, NLINE)) != TRUE)
|
||||
s = newmlarg( &line, "$", 0) ;
|
||||
if( s != TRUE)
|
||||
return s ;
|
||||
|
||||
TTputc('\n'); /* Already have '\r' */
|
||||
TTflush();
|
||||
TTclose(); /* stty to old modes */
|
||||
TTkclose();
|
||||
ue_system( line) ;
|
||||
free( line) ;
|
||||
fflush(stdout); /* to be sure P.K. */
|
||||
TTopen();
|
||||
mlwrite( "(End)") ; /* Pause. */
|
||||
@ -270,49 +217,33 @@ int execprg(int f, int n)
|
||||
* Pipe a one line command into a window
|
||||
* Bound to ^X @
|
||||
*/
|
||||
int pipecmd(int f, int n)
|
||||
{
|
||||
int pipecmd( int f, int n) {
|
||||
int s ; /* return status from CLI */
|
||||
struct window *wp ; /* pointer to new window */
|
||||
struct buffer *bp ; /* pointer to buffer to zot */
|
||||
char line[NLINE]; /* command line send to shell */
|
||||
char *mlarg ;
|
||||
char *line ; /* command line send to shell */
|
||||
static char bname[] = "command" ;
|
||||
|
||||
static char filnam[ NSTRING] = "command" ;
|
||||
|
||||
#if MSDOS
|
||||
char *tmp;
|
||||
FILE *fp;
|
||||
int len;
|
||||
#endif
|
||||
|
||||
/* don't allow this command if restricted */
|
||||
if( restflag)
|
||||
return resterr() ;
|
||||
|
||||
#if MSDOS
|
||||
if ((tmp = getenv("TMP")) == NULL
|
||||
&& (tmp = getenv("TEMP")) == NULL)
|
||||
strcpy(filnam, "command");
|
||||
else {
|
||||
strcpy(filnam, tmp);
|
||||
len = strlen(tmp);
|
||||
if (len <= 0 || filnam[len - 1] != '\\'
|
||||
&& filnam[len - 1] != '/')
|
||||
strcat(filnam, "\\");
|
||||
strcat(filnam, "command");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if VMS
|
||||
mlwrite("Not available under VMS");
|
||||
return FALSE;
|
||||
#endif
|
||||
|
||||
/* get the command to pipe in */
|
||||
if ((s = mlreply("@", line, NLINE)) != TRUE)
|
||||
s = newmlarg( &mlarg, "@", 0) ;
|
||||
if( s != TRUE)
|
||||
return s ;
|
||||
|
||||
line = malloc( strlen( mlarg) + strlen( filnam) + 2) ;
|
||||
if( line == NULL) {
|
||||
free( mlarg) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
strcpy( line, mlarg) ;
|
||||
free( mlarg) ;
|
||||
|
||||
/* get rid of the command output buffer if it exists */
|
||||
if ((bp = bfind(bname, FALSE, 0)) != FALSE) {
|
||||
/* try to make sure we are off screen */
|
||||
@ -332,26 +263,12 @@ int pipecmd(int f, int n)
|
||||
}
|
||||
wp = wp->w_wndp;
|
||||
}
|
||||
if (zotbuf(bp) != TRUE)
|
||||
|
||||
if( zotbuf( bp) != TRUE) {
|
||||
free( line) ;
|
||||
return FALSE ;
|
||||
}
|
||||
#if MSDOS
|
||||
strcat(line, " >>");
|
||||
strcat(line, filnam);
|
||||
movecursor(term.t_nrow, 0);
|
||||
TTkclose();
|
||||
shellprog(line);
|
||||
TTkopen();
|
||||
sgarbf = TRUE;
|
||||
if ((fp = fopen(filnam, "r")) == NULL) {
|
||||
s = FALSE;
|
||||
} else {
|
||||
fclose(fp);
|
||||
s = TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if V7 | USG | BSD
|
||||
TTflush();
|
||||
TTclose(); /* stty to old modes */
|
||||
@ -359,6 +276,7 @@ int pipecmd(int f, int n)
|
||||
strcat( line, ">") ;
|
||||
strcat( line, filnam) ;
|
||||
ue_system( line) ;
|
||||
free( line) ;
|
||||
TTopen();
|
||||
TTkopen();
|
||||
TTflush();
|
||||
@ -394,11 +312,11 @@ int pipecmd(int f, int n)
|
||||
* filter a buffer through an external DOS program
|
||||
* Bound to ^X #
|
||||
*/
|
||||
int filter_buffer(int f, int n)
|
||||
{
|
||||
int filter_buffer( int f, int n) {
|
||||
int s ; /* return status from CLI */
|
||||
struct buffer *bp ; /* pointer to buffer to zot */
|
||||
char line[NLINE]; /* command line send to shell */
|
||||
char *mlarg ;
|
||||
char *line ; /* command line send to shell */
|
||||
fname_t tmpnam ; /* place to store real file name */
|
||||
static char bname1[] = "fltinp" ;
|
||||
|
||||
@ -412,15 +330,20 @@ int filter_buffer(int f, int n)
|
||||
if( curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return rdonly() ; /* we are in read only mode */
|
||||
|
||||
#if VMS
|
||||
mlwrite("Not available under VMS");
|
||||
return FALSE;
|
||||
#endif
|
||||
|
||||
/* get the filter name and its args */
|
||||
if ((s = mlreply("#", line, NLINE)) != TRUE)
|
||||
s = newmlarg( &mlarg, "#", 0) ;
|
||||
if( s != TRUE)
|
||||
return s ;
|
||||
|
||||
line = malloc( strlen( mlarg) + 16 + 1) ;
|
||||
if( line == NULL) {
|
||||
free( mlarg) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
strcpy( line, mlarg) ;
|
||||
free( mlarg) ;
|
||||
|
||||
/* setup the proper file names */
|
||||
bp = curbp;
|
||||
strcpy(tmpnam, bp->b_fname); /* save the original name */
|
||||
@ -430,17 +353,9 @@ int filter_buffer(int f, int n)
|
||||
if( writeout( filnam1) != TRUE) {
|
||||
mlwrite( "(Cannot write filter file)") ;
|
||||
strcpy( bp->b_fname, tmpnam) ;
|
||||
free( line) ;
|
||||
return FALSE ;
|
||||
}
|
||||
#if MSDOS
|
||||
strcat(line, " <fltinp >fltout");
|
||||
movecursor(term.t_nrow - 1, 0);
|
||||
TTkclose();
|
||||
shellprog(line);
|
||||
TTkopen();
|
||||
sgarbf = TRUE;
|
||||
s = TRUE;
|
||||
#endif
|
||||
|
||||
#if V7 | USG | BSD
|
||||
TTputc('\n'); /* Already have '\r' */
|
||||
@ -449,6 +364,7 @@ int filter_buffer(int f, int n)
|
||||
TTkclose();
|
||||
strcat(line, " <fltinp >fltout");
|
||||
ue_system( line) ;
|
||||
free( line) ;
|
||||
TTopen();
|
||||
TTkopen();
|
||||
TTflush();
|
||||
|
Loading…
Reference in New Issue
Block a user