[BACK]Return to fep_com.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / fep

Diff for /OpenXM_contrib2/fep/fep_com.c between version 1.3 and 1.6

version 1.3, 2010/04/23 05:34:05 version 1.6, 2021/11/16 08:43:16
Line 1 
Line 1 
 /*      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)";
Line 7  static char rcsid[]=
Line 13  static char rcsid[]=
   
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
   #include <unistd.h>
 #include <string.h>  #include <string.h>
 #include <sys/ioctl.h>  #include <sys/ioctl.h>
 #ifdef TERMIOS  #ifdef TERMIOS
Line 38  typedef struct {
Line 45  typedef struct {
         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 102  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 117  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 203  fep_if (comline)
Line 217  fep_if (comline)
     return;      return;
 }  }
   
 fep_else ()  void fep_else ()
 {  {
     char *err;      char *err;
   
Line 213  fep_else ()
Line 227  fep_else ()
     return;      return;
 }  }
   
 fep_endif ()  void fep_endif ()
 {  {
     char *err;      char *err;
   
Line 223  fep_endif ()
Line 237  fep_endif ()
     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 265  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;
Line 292  alias(comline)
Line 304  alias(comline)
     return;      return;
 }  }
   
 unalias (comline)  void unalias (char *comline)
     char *comline;  
 {  {
     char *argv[MAXARGS];      char *argv[MAXARGS];
     int argc;      int argc;
Line 307  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;
   
Line 347  set (comline)
Line 361  set (comline)
     }      }
 }  }
   
 unset(comline)  void unset(char *comline)
     char *comline;  
 {  {
     char **vp;      char **vp;
     char *argv[MAXARGS];      char *argv[MAXARGS];
Line 372  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 384  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 446  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 524  fix_transparency()
Line 537  fix_transparency()
     }      }
 }  }
   
 putch (c)  void putch (int c)
     int c;  
 {  {
     putchar (c);      putchar (c);
     fflush (stdout);      fflush (stdout);
Line 535  putch (c)
Line 547  putch (c)
 int crt, sline;  int crt, sline;
 */  */
   
 show_bindings ()  int show_bindings ()
 {  {
     MORE *m;      MORE *m;
   
Line 553  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 614  showBindingTbl (m, ft, prefix)
Line 623  showBindingTbl (m, ft, prefix)
     return (1);      return (1);
 }  }
   
 show_help ()  void show_help ()
 {  {
     MORE *m;      MORE *m;
   
Line 639  show_help ()
Line 648  show_help ()
     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 657  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 681  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 697  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;  
 {  {
   
     /*      /*
Line 747  more (mp)
Line 750  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;
Line 798  char *line;
Line 800  char *line;
     }      }
 }  }
   
 fep_pwd (line)  void fep_pwd (char *line)
     char *line;  
 {  {
     char cwd[MAXPATHLEN];      char cwd[MAXPATHLEN];
   
Line 807  fep_pwd (line)
Line 808  fep_pwd (line)
     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 847  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 872  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 893  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];
Line 921  sourceRcFile ()
Line 919  sourceRcFile ()
     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 962  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;
   
Line 975  condition ()
Line 972  condition ()
     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 996  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 1011  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 1023  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 1033  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 1056  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 1095  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 1136  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 1199  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 1218  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 1280  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 1345  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;

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.6

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>