Changeset View
Changeset View
Standalone View
Standalone View
contrib/less/lsystem.c
Show All 32 Lines | |||||
#if HAVE_SYSTEM | #if HAVE_SYSTEM | ||||
/* | /* | ||||
* Pass the specified command to a shell to be executed. | * Pass the specified command to a shell to be executed. | ||||
* Like plain "system()", but handles resetting terminal modes, etc. | * Like plain "system()", but handles resetting terminal modes, etc. | ||||
*/ | */ | ||||
public void | public void | ||||
lsystem(cmd, donemsg) | lsystem(char *cmd, char *donemsg) | ||||
char *cmd; | |||||
char *donemsg; | |||||
{ | { | ||||
register int inp; | register int inp; | ||||
#if HAVE_SHELL | #if HAVE_SHELL | ||||
register char *shell; | register char *shell; | ||||
register char *p; | register char *p; | ||||
#endif | #endif | ||||
IFILE save_ifile; | IFILE save_ifile; | ||||
#if MSDOS_COMPILER && MSDOS_COMPILER!=WIN32C | #if MSDOS_COMPILER && MSDOS_COMPILER!=WIN32C | ||||
▲ Show 20 Lines • Show All 193 Lines • ▼ Show 20 Lines | |||||
* If the mark is after the current screen, the section between | * If the mark is after the current screen, the section between | ||||
* the top line displayed and the mark is piped. | * the top line displayed and the mark is piped. | ||||
* If the mark is before the current screen, the section between | * If the mark is before the current screen, the section between | ||||
* the mark and the bottom line displayed is piped. | * the mark and the bottom line displayed is piped. | ||||
* If the mark is on the current screen, or if the mark is ".", | * If the mark is on the current screen, or if the mark is ".", | ||||
* the whole current screen is piped. | * the whole current screen is piped. | ||||
*/ | */ | ||||
public int | public int | ||||
pipe_mark(c, cmd) | pipe_mark(int c, char *cmd) | ||||
int c; | |||||
char *cmd; | |||||
{ | { | ||||
POSITION mpos, tpos, bpos; | POSITION mpos, tpos, bpos; | ||||
/* | /* | ||||
* mpos = the marked position. | * mpos = the marked position. | ||||
* tpos = top of screen. | * tpos = top of screen. | ||||
* bpos = bottom of screen. | * bpos = bottom of screen. | ||||
*/ | */ | ||||
Show All 15 Lines | else | ||||
return (pipe_data(cmd, tpos, mpos)); | return (pipe_data(cmd, tpos, mpos)); | ||||
} | } | ||||
/* | /* | ||||
* Create a pipe to the given shell command. | * Create a pipe to the given shell command. | ||||
* Feed it the file contents between the positions spos and epos. | * Feed it the file contents between the positions spos and epos. | ||||
*/ | */ | ||||
public int | public int | ||||
pipe_data(cmd, spos, epos) | pipe_data(char *cmd, POSITION spos, POSITION epos) | ||||
char *cmd; | |||||
POSITION spos; | |||||
POSITION epos; | |||||
{ | { | ||||
register FILE *f; | register FILE *f; | ||||
register int c; | register int c; | ||||
extern FILE *popen(); | extern FILE *popen(); | ||||
/* | /* | ||||
* This is structured much like lsystem(). | * This is structured much like lsystem(). | ||||
* Since we're running a shell program, we must be careful | * Since we're running a shell program, we must be careful | ||||
▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines |