version 1.1, 2002/09/03 00:41:44 |
version 1.6, 2021/11/16 08:43:16 |
|
|
/* Copyright (c) 1987, 1988 by Software Research Associates, Inc. */ |
/* Copyright (c) 1987, 1988 by Software Research Associates, Inc. */ |
|
|
|
#if defined(ANDROID) |
|
#include <strings.h> |
|
#define index(s,c) strchr(s,c) |
|
#define rindex(s,c) strrchr(s,c) |
|
#endif |
|
|
#ifndef lint |
#ifndef lint |
static char rcsid[]= |
static char rcsid[]= |
"$Header$ (SRA)"; |
"$Header$ (SRA)"; |
#endif /* lint */ |
#endif /* lint */ |
|
|
#include <stdio.h> |
#include <stdio.h> |
|
#include <stdlib.h> |
|
#include <unistd.h> |
|
#include <string.h> |
#include <sys/ioctl.h> |
#include <sys/ioctl.h> |
#ifdef TERMIOS |
#ifdef TERMIOS |
#include <termios.h> |
#include <termios.h> |
Line 22 static char rcsid[]= |
|
Line 31 static char rcsid[]= |
|
#include <sys/file.h> |
#include <sys/file.h> |
#include <sys/stat.h> |
#include <sys/stat.h> |
#include <sys/ioctl.h> |
#include <sys/ioctl.h> |
|
#if defined(sun) |
|
#include <sys/fcntl.h> |
|
#endif |
#include "fep_defs.h" |
#include "fep_defs.h" |
#include "fep_glob.h" |
#include "fep_glob.h" |
#include "fep_funcs.h" |
#include "fep_funcs.h" |
|
|
int max_line; |
int max_line; |
} MORE; |
} MORE; |
MORE *create_more(); |
MORE *create_more(); |
|
int more (MORE *mp); |
|
int showTable (MORE *m, FunctionTableEnt *fnte); |
|
int showVariables (MORE *m); |
|
void destroy_more(MORE *mp); |
|
int showBindingTbl (MORE *m, FUNC ft[], char *prefix); |
|
|
|
#if defined(ANDROID) |
|
#define S_IREAD S_IRUSR |
|
#define S_IWRITE S_IWUSR |
|
#define S_IEXEC S_IXUSR |
|
#endif |
/* |
/* |
* Check command line if it call built-in function or not and execute it |
* Check command line if it call built-in function or not and execute it |
*/ |
*/ |
executeBuiltInFunction (comline, more) |
int executeBuiltInFunction (char *comline, char **more) |
char *comline, **more; |
|
{ |
{ |
register FunctionTableEnt *ftp; |
register FunctionTableEnt *ftp; |
char linebuf[MAXCMDLEN], *line; |
char linebuf[MAXCMDLEN], *line; |
Line 97 executeBuiltInFunction (comline, more) |
|
Line 118 executeBuiltInFunction (comline, more) |
|
return (NOT_PROCESSED); |
return (NOT_PROCESSED); |
} |
} |
|
|
is_same_command (a, b) |
int is_same_command (char *a, char *b) |
register char *a, *b; |
|
{ |
{ |
|
|
while (*a && *b && *a == *b) |
while (*a && *b && *a == *b) |
Line 112 is_same_command (a, b) |
|
Line 132 is_same_command (a, b) |
|
/* |
/* |
* Process 'fep-if' and 'fep-elseif' |
* Process 'fep-if' and 'fep-elseif' |
*/ |
*/ |
fep_if (comline) |
void fep_if (char *comline) |
char *comline; |
|
{ |
{ |
char *argv[MAXARGS]; |
char *argv[MAXARGS]; |
int argc; |
int argc; |
Line 198 fep_if (comline) |
|
Line 217 fep_if (comline) |
|
return; |
return; |
} |
} |
|
|
fep_else () |
void fep_else () |
{ |
{ |
char *err; |
char *err; |
|
|
|
|
return; |
return; |
} |
} |
|
|
fep_endif () |
void fep_endif () |
{ |
{ |
char *err; |
char *err; |
|
|
|
|
return; |
return; |
} |
} |
|
|
bind_to_key (comline) |
void bind_to_key (char *comline) |
char *comline; |
|
{ |
{ |
register FunctionTableEnt *fnte; |
register FunctionTableEnt *fnte; |
char *argv[MAXARGS]; |
char *argv[MAXARGS]; |
Line 260 bind_to_key (comline) |
|
Line 278 bind_to_key (comline) |
|
printf ("%s: no such built-in command\n", argv[1]); |
printf ("%s: no such built-in command\n", argv[1]); |
} |
} |
|
|
alias(comline) |
void alias(char *comline) |
char *comline; |
|
{ |
{ |
char *argv[MAXARGS]; |
char *argv[MAXARGS]; |
int argc; |
int argc; |
|
|
return; |
return; |
} |
} |
|
|
unalias (comline) |
void unalias (char *comline) |
char *comline; |
|
{ |
{ |
char *argv[MAXARGS]; |
char *argv[MAXARGS]; |
int argc; |
int argc; |
Line 302 unalias (comline) |
|
Line 318 unalias (comline) |
|
return; |
return; |
} |
} |
|
|
set (comline) |
void set (char *comline) |
char *comline; |
|
{ |
{ |
char line[MAXCMDLEN]; |
char line[MAXCMDLEN]; |
|
#if defined(ANDROID) |
|
char *cp; |
|
#else |
char *cp, *index(); |
char *cp, *index(); |
|
#endif |
char *argv[MAXARGS]; |
char *argv[MAXARGS]; |
int argc; |
int argc; |
|
|
|
|
} |
} |
} |
} |
|
|
unset(comline) |
void unset(char *comline) |
char *comline; |
|
{ |
{ |
char **vp; |
char **vp; |
char *argv[MAXARGS]; |
char *argv[MAXARGS]; |
Line 367 extern int Through; |
|
Line 385 extern int Through; |
|
#elif defined(TIOCSETN) |
#elif defined(TIOCSETN) |
#define ttystruct sgttyb |
#define ttystruct sgttyb |
#endif |
#endif |
struct ttystruct master_ttymode; /* master tty mode */ |
extern struct ttystruct master_ttymode; /* master tty mode */ |
struct ttystruct slave_ttymode; /* slave tty mode */ |
extern struct ttystruct slave_ttymode; /* slave tty mode */ |
extern int master, slave; |
extern int master, slave; |
extern char slave_tty[]; |
extern char slave_tty[]; |
|
|
Line 379 extern char slave_tty[]; |
|
Line 397 extern char slave_tty[]; |
|
* But this Transparency is set automaticaly by getcharacter() routine, |
* But this Transparency is set automaticaly by getcharacter() routine, |
* if the variable auto-tty-fix is ON. |
* if the variable auto-tty-fix is ON. |
*/ |
*/ |
toggle_through() |
void toggle_through() |
{ |
{ |
int r; |
int r; |
int slave_fd; |
int slave_fd; |
Line 441 toggle_through() |
|
Line 459 toggle_through() |
|
/* |
/* |
* Check tty mode of slave tty and fix stdout tty mode |
* Check tty mode of slave tty and fix stdout tty mode |
*/ |
*/ |
fix_transparency() |
void fix_transparency() |
{ |
{ |
int r; |
int r; |
#ifdef TERMIOS |
#ifdef TERMIOS |
Line 519 fix_transparency() |
|
Line 537 fix_transparency() |
|
} |
} |
} |
} |
|
|
putch (c) |
void putch (int c) |
int c; |
|
{ |
{ |
putchar (c); |
putchar (c); |
fflush (stdout); |
fflush (stdout); |
|
|
int crt, sline; |
int crt, sline; |
*/ |
*/ |
|
|
show_bindings () |
int show_bindings () |
{ |
{ |
MORE *m; |
MORE *m; |
|
|
Line 548 show_bindings () |
|
Line 565 show_bindings () |
|
return (0); |
return (0); |
} |
} |
|
|
showBindingTbl (m, ft, prefix) |
int showBindingTbl (MORE *m, FUNC ft[], char *prefix) |
MORE *m; |
|
FUNC ft[]; |
|
char *prefix; |
|
{ |
{ |
register FunctionTableEnt *fnte; |
register FunctionTableEnt *fnte; |
register int i; |
register int i; |
Line 609 showBindingTbl (m, ft, prefix) |
|
Line 623 showBindingTbl (m, ft, prefix) |
|
return (1); |
return (1); |
} |
} |
|
|
show_help () |
void show_help () |
{ |
{ |
MORE *m; |
MORE *m; |
|
|
|
|
recover_edit_line (1); |
recover_edit_line (1); |
} |
} |
|
|
showTable (m, fnte) |
int showTable (MORE *m, FunctionTableEnt *fnte) |
MORE *m; |
|
FunctionTableEnt *fnte; |
|
{ |
{ |
int i; |
int i; |
|
|
Line 652 showTable (m, fnte) |
|
Line 664 showTable (m, fnte) |
|
return (1); |
return (1); |
} |
} |
|
|
showVariables (m) |
int showVariables (MORE *m) |
MORE *m; |
|
{ |
{ |
extern VAR default_set_vars[], default_unset_vars[]; |
extern VAR default_set_vars[], default_unset_vars[]; |
VAR *vp; |
VAR *vp; |
Line 676 showVariables (m) |
|
Line 687 showVariables (m) |
|
return (1); |
return (1); |
} |
} |
|
|
MORE *create_more(maxline) |
MORE *create_more(int maxline) |
int maxline; |
|
{ |
{ |
MORE *mp; |
MORE *mp; |
|
|
Line 692 MORE *create_more(maxline) |
|
Line 702 MORE *create_more(maxline) |
|
} |
} |
} |
} |
|
|
destroy_more(mp) |
void destroy_more(MORE *mp) |
MORE *mp; |
|
{ |
{ |
if (mp) |
if (mp) |
free (mp); |
free (mp); |
} |
} |
|
|
more (mp) |
int more (MORE *mp) |
MORE *mp; |
|
{ |
{ |
|
|
/* |
/* |
|
|
/* |
/* |
* Change directory |
* Change directory |
*/ |
*/ |
fep_chdir (line) |
void fep_chdir (char *line) |
char *line; |
|
{ |
{ |
char *argv[MAXARGS]; |
char *argv[MAXARGS]; |
int argc; |
int argc; |
|
|
} |
} |
} |
} |
|
|
fep_pwd (line) |
void fep_pwd (char *line) |
char *line; |
|
{ |
{ |
char cwd[MAXPATHLEN]; |
char cwd[MAXPATHLEN]; |
|
|
|
|
printf ("%s\n", cwd); |
printf ("%s\n", cwd); |
} |
} |
|
|
fep_echo (comline) |
void fep_echo (char *comline) |
char *comline; |
|
{ |
{ |
char *argv[MAXARGS]; |
char *argv[MAXARGS]; |
int argc; |
int argc; |
Line 842 fep_echo (comline) |
|
Line 847 fep_echo (comline) |
|
printf ("%c", '\n'); |
printf ("%c", '\n'); |
} |
} |
|
|
fep_command (comline) |
void fep_command (char *comline) |
char *comline; |
|
{ |
{ |
char *argv[MAXARGS]; |
char *argv[MAXARGS]; |
int argc; |
int argc; |
Line 867 fep_command (comline) |
|
Line 871 fep_command (comline) |
|
invoke_command (buf); |
invoke_command (buf); |
} |
} |
|
|
fep_source (comline) |
void fep_source (char *comline) |
char *comline; |
|
{ |
{ |
FILE *fp; |
FILE *fp; |
static char *argv[MAXARGS]; |
static char *argv[MAXARGS]; |
Line 888 fep_source (comline) |
|
Line 891 fep_source (comline) |
|
return; |
return; |
} |
} |
|
|
sourceRcFile () |
void sourceRcFile () |
{ |
{ |
char *home, filename[64], *getenv(); |
char *home, filename[64], *getenv(); |
char line[256]; |
char line[256]; |
|
|
return; |
return; |
} |
} |
|
|
source_file (file) |
void source_file (char *file) |
char *file; |
|
{ |
{ |
FILE *fp; |
FILE *fp; |
char line[512], line2[512]; |
char line[512], line2[512]; |
Line 957 source_file (file) |
|
Line 959 source_file (file) |
|
int condition_stack [MAX_IF_NEST] = {1}; |
int condition_stack [MAX_IF_NEST] = {1}; |
int current_if_stack = 0; |
int current_if_stack = 0; |
|
|
condition () |
int condition () |
{ |
{ |
int cond = 1, i; |
int cond = 1, i; |
|
|
|
|
return (cond & CONDITION_MASK); |
return (cond & CONDITION_MASK); |
} |
} |
|
|
char * |
char * change_condition (int cond) |
change_condition (cond) |
|
int cond; |
|
{ |
{ |
if (debug) |
if (debug) |
printf ("old=0x%x, new=0x%x\n", |
printf ("old=0x%x, new=0x%x\n", |
Line 991 change_condition (cond) |
|
Line 991 change_condition (cond) |
|
return ("Not in if close\n"); |
return ("Not in if close\n"); |
} |
} |
|
|
char * |
char * push_condition (int cond) |
push_condition (cond) |
|
int cond; |
|
{ |
{ |
if (current_if_stack < MAX_IF_NEST){ |
if (current_if_stack < MAX_IF_NEST){ |
++current_if_stack; |
++current_if_stack; |
Line 1006 push_condition (cond) |
|
Line 1004 push_condition (cond) |
|
return ("If stack over flow\n"); |
return ("If stack over flow\n"); |
} |
} |
|
|
char * |
char * pop_condition () |
pop_condition () |
|
{ |
{ |
|
|
if (current_if_stack > 0) { |
if (current_if_stack > 0) { |
Line 1018 pop_condition () |
|
Line 1015 pop_condition () |
|
return ("No more if stack\n"); |
return ("No more if stack\n"); |
} |
} |
|
|
invoke_shell () |
void invoke_shell () |
{ |
{ |
char *shell = "/bin/sh"; |
char *shell = "/bin/sh"; |
|
|
Line 1028 invoke_shell () |
|
Line 1025 invoke_shell () |
|
invoke_command (shell); |
invoke_command (shell); |
} |
} |
|
|
invoke_command (cmd) |
void invoke_command (char *cmd) |
char *cmd; |
|
{ |
{ |
int catchsig(); |
|
int (*func)(); |
int (*func)(); |
|
|
clear_edit_line (); |
clear_edit_line (); |
Line 1051 invoke_command (cmd) |
|
Line 1046 invoke_command (cmd) |
|
FILE *redirect_fp = NULL; |
FILE *redirect_fp = NULL; |
int redirect_line = 0; |
int redirect_line = 0; |
|
|
fep_read_from_file (comline) |
void fep_read_from_file (char *comline) |
char *comline; |
|
{ |
{ |
FILE *fp; |
FILE *fp; |
static char *argv[MAXARGS]; |
static char *argv[MAXARGS]; |
Line 1090 fep_read_from_file (comline) |
|
Line 1084 fep_read_from_file (comline) |
|
*/ |
*/ |
int redirect_pid = 0; |
int redirect_pid = 0; |
|
|
fep_read_from_command (comline) |
void fep_read_from_command (char *comline) |
char *comline; |
|
{ |
{ |
static char *argv[MAXARGS]; |
static char *argv[MAXARGS]; |
char buf[256]; |
char buf[256]; |
Line 1131 fep_read_from_command (comline) |
|
Line 1124 fep_read_from_command (comline) |
|
|
|
char script_file[128]; |
char script_file[128]; |
|
|
fep_start_script (comline) |
void fep_start_script (char *comline) |
char *comline; |
|
{ |
{ |
char *name; |
char *name; |
|
|
Line 1194 fep_start_script (comline) |
|
Line 1186 fep_start_script (comline) |
|
recover_edit_line (1); |
recover_edit_line (1); |
} |
} |
|
|
fep_end_script () |
void fep_end_script () |
{ |
{ |
if (!script_fp) { |
if (!script_fp) { |
clear_edit_line (); |
clear_edit_line (); |
Line 1213 fep_end_script () |
|
Line 1205 fep_end_script () |
|
return; |
return; |
} |
} |
|
|
fep_repaint(comline) |
void fep_repaint(char *comline) |
char *comline; |
|
{ |
{ |
int i; |
int i; |
int line; |
int line; |
Line 1275 fep_repaint(comline) |
|
Line 1266 fep_repaint(comline) |
|
fflush (stdout); |
fflush (stdout); |
} |
} |
|
|
view_buffer (comline) |
int view_buffer (char *comline) |
char *comline; |
|
{ |
{ |
BUFFER *bp = output_buffer; |
BUFFER *bp = output_buffer; |
MORE *m; |
MORE *m; |
Line 1340 struct statistics stat_info[] = { |
|
Line 1330 struct statistics stat_info[] = { |
|
NULL, NULL |
NULL, NULL |
}; |
}; |
|
|
fep_showstat () |
void fep_showstat () |
{ |
{ |
struct statistics *sp = stat_info; |
struct statistics *sp = stat_info; |
BUFFER *bp = output_buffer; |
BUFFER *bp = output_buffer; |