=================================================================== RCS file: /home/cvs/OpenXM_contrib2/fep/fep_com.c,v retrieving revision 1.3 retrieving revision 1.6 diff -u -p -r1.3 -r1.6 --- OpenXM_contrib2/fep/fep_com.c 2010/04/23 05:34:05 1.3 +++ OpenXM_contrib2/fep/fep_com.c 2021/11/16 08:43:16 1.6 @@ -1,12 +1,19 @@ /* Copyright (c) 1987, 1988 by Software Research Associates, Inc. */ +#if defined(ANDROID) +#include +#define index(s,c) strchr(s,c) +#define rindex(s,c) strrchr(s,c) +#endif + #ifndef lint static char rcsid[]= -"$Header: /home/cvs/OpenXM_contrib2/fep/fep_com.c,v 1.3 2010/04/23 05:34:05 ohara Exp $ (SRA)"; +"$Header: /home/cvs/OpenXM_contrib2/fep/fep_com.c,v 1.6 2021/11/16 08:43:16 noro Exp $ (SRA)"; #endif /* lint */ #include #include +#include #include #include #ifdef TERMIOS @@ -38,12 +45,21 @@ typedef struct { int max_line; } 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 */ -executeBuiltInFunction (comline, more) - char *comline, **more; +int executeBuiltInFunction (char *comline, char **more) { register FunctionTableEnt *ftp; char linebuf[MAXCMDLEN], *line; @@ -102,8 +118,7 @@ executeBuiltInFunction (comline, more) return (NOT_PROCESSED); } -is_same_command (a, b) - register char *a, *b; +int is_same_command (char *a, char *b) { while (*a && *b && *a == *b) @@ -117,8 +132,7 @@ is_same_command (a, b) /* * Process 'fep-if' and 'fep-elseif' */ -fep_if (comline) - char *comline; +void fep_if (char *comline) { char *argv[MAXARGS]; int argc; @@ -203,7 +217,7 @@ fep_if (comline) return; } -fep_else () +void fep_else () { char *err; @@ -213,7 +227,7 @@ fep_else () return; } -fep_endif () +void fep_endif () { char *err; @@ -223,8 +237,7 @@ fep_endif () return; } -bind_to_key (comline) - char *comline; +void bind_to_key (char *comline) { register FunctionTableEnt *fnte; char *argv[MAXARGS]; @@ -265,8 +278,7 @@ bind_to_key (comline) printf ("%s: no such built-in command\n", argv[1]); } -alias(comline) - char *comline; +void alias(char *comline) { char *argv[MAXARGS]; int argc; @@ -292,8 +304,7 @@ alias(comline) return; } -unalias (comline) - char *comline; +void unalias (char *comline) { char *argv[MAXARGS]; int argc; @@ -307,11 +318,14 @@ unalias (comline) return; } -set (comline) - char *comline; +void set (char *comline) { char line[MAXCMDLEN]; +#if defined(ANDROID) + char *cp; +#else char *cp, *index(); +#endif char *argv[MAXARGS]; int argc; @@ -347,8 +361,7 @@ set (comline) } } -unset(comline) - char *comline; +void unset(char *comline) { char **vp; char *argv[MAXARGS]; @@ -372,8 +385,8 @@ extern int Through; #elif defined(TIOCSETN) #define ttystruct sgttyb #endif -struct ttystruct master_ttymode; /* master tty mode */ -struct ttystruct slave_ttymode; /* slave tty mode */ +extern struct ttystruct master_ttymode; /* master tty mode */ +extern struct ttystruct slave_ttymode; /* slave tty mode */ extern int master, slave; extern char slave_tty[]; @@ -384,7 +397,7 @@ extern char slave_tty[]; * But this Transparency is set automaticaly by getcharacter() routine, * if the variable auto-tty-fix is ON. */ -toggle_through() +void toggle_through() { int r; int slave_fd; @@ -446,7 +459,7 @@ toggle_through() /* * Check tty mode of slave tty and fix stdout tty mode */ -fix_transparency() +void fix_transparency() { int r; #ifdef TERMIOS @@ -524,8 +537,7 @@ fix_transparency() } } -putch (c) - int c; +void putch (int c) { putchar (c); fflush (stdout); @@ -535,7 +547,7 @@ putch (c) int crt, sline; */ -show_bindings () +int show_bindings () { MORE *m; @@ -553,10 +565,7 @@ show_bindings () return (0); } -showBindingTbl (m, ft, prefix) - MORE *m; - FUNC ft[]; - char *prefix; +int showBindingTbl (MORE *m, FUNC ft[], char *prefix) { register FunctionTableEnt *fnte; register int i; @@ -614,7 +623,7 @@ showBindingTbl (m, ft, prefix) return (1); } -show_help () +void show_help () { MORE *m; @@ -639,9 +648,7 @@ show_help () recover_edit_line (1); } -showTable (m, fnte) - MORE *m; - FunctionTableEnt *fnte; +int showTable (MORE *m, FunctionTableEnt *fnte) { int i; @@ -657,8 +664,7 @@ showTable (m, fnte) return (1); } -showVariables (m) - MORE *m; +int showVariables (MORE *m) { extern VAR default_set_vars[], default_unset_vars[]; VAR *vp; @@ -681,8 +687,7 @@ showVariables (m) return (1); } -MORE *create_more(maxline) - int maxline; +MORE *create_more(int maxline) { MORE *mp; @@ -697,15 +702,13 @@ MORE *create_more(maxline) } } -destroy_more(mp) - MORE *mp; +void destroy_more(MORE *mp) { if (mp) free (mp); } -more (mp) - MORE *mp; +int more (MORE *mp) { /* @@ -747,8 +750,7 @@ more (mp) /* * Change directory */ -fep_chdir (line) -char *line; +void fep_chdir (char *line) { char *argv[MAXARGS]; int argc; @@ -798,8 +800,7 @@ char *line; } } -fep_pwd (line) - char *line; +void fep_pwd (char *line) { char cwd[MAXPATHLEN]; @@ -807,8 +808,7 @@ fep_pwd (line) printf ("%s\n", cwd); } -fep_echo (comline) - char *comline; +void fep_echo (char *comline) { char *argv[MAXARGS]; int argc; @@ -847,8 +847,7 @@ fep_echo (comline) printf ("%c", '\n'); } -fep_command (comline) - char *comline; +void fep_command (char *comline) { char *argv[MAXARGS]; int argc; @@ -872,8 +871,7 @@ fep_command (comline) invoke_command (buf); } -fep_source (comline) - char *comline; +void fep_source (char *comline) { FILE *fp; static char *argv[MAXARGS]; @@ -893,7 +891,7 @@ fep_source (comline) return; } -sourceRcFile () +void sourceRcFile () { char *home, filename[64], *getenv(); char line[256]; @@ -921,8 +919,7 @@ sourceRcFile () return; } -source_file (file) - char *file; +void source_file (char *file) { FILE *fp; char line[512], line2[512]; @@ -962,7 +959,7 @@ source_file (file) int condition_stack [MAX_IF_NEST] = {1}; int current_if_stack = 0; -condition () +int condition () { int cond = 1, i; @@ -975,9 +972,7 @@ condition () return (cond & CONDITION_MASK); } -char * -change_condition (cond) - int cond; +char * change_condition (int cond) { if (debug) printf ("old=0x%x, new=0x%x\n", @@ -996,9 +991,7 @@ change_condition (cond) return ("Not in if close\n"); } -char * -push_condition (cond) - int cond; +char * push_condition (int cond) { if (current_if_stack < MAX_IF_NEST){ ++current_if_stack; @@ -1011,8 +1004,7 @@ push_condition (cond) return ("If stack over flow\n"); } -char * -pop_condition () +char * pop_condition () { if (current_if_stack > 0) { @@ -1023,7 +1015,7 @@ pop_condition () return ("No more if stack\n"); } -invoke_shell () +void invoke_shell () { char *shell = "/bin/sh"; @@ -1033,10 +1025,8 @@ invoke_shell () invoke_command (shell); } -invoke_command (cmd) - char *cmd; +void invoke_command (char *cmd) { - int catchsig(); int (*func)(); clear_edit_line (); @@ -1056,8 +1046,7 @@ invoke_command (cmd) FILE *redirect_fp = NULL; int redirect_line = 0; -fep_read_from_file (comline) - char *comline; +void fep_read_from_file (char *comline) { FILE *fp; static char *argv[MAXARGS]; @@ -1095,8 +1084,7 @@ fep_read_from_file (comline) */ int redirect_pid = 0; -fep_read_from_command (comline) - char *comline; +void fep_read_from_command (char *comline) { static char *argv[MAXARGS]; char buf[256]; @@ -1136,8 +1124,7 @@ fep_read_from_command (comline) char script_file[128]; -fep_start_script (comline) - char *comline; +void fep_start_script (char *comline) { char *name; @@ -1199,7 +1186,7 @@ fep_start_script (comline) recover_edit_line (1); } -fep_end_script () +void fep_end_script () { if (!script_fp) { clear_edit_line (); @@ -1218,8 +1205,7 @@ fep_end_script () return; } -fep_repaint(comline) - char *comline; +void fep_repaint(char *comline) { int i; int line; @@ -1280,8 +1266,7 @@ fep_repaint(comline) fflush (stdout); } -view_buffer (comline) - char *comline; +int view_buffer (char *comline) { BUFFER *bp = output_buffer; MORE *m; @@ -1345,7 +1330,7 @@ struct statistics stat_info[] = { NULL, NULL }; -fep_showstat () +void fep_showstat () { struct statistics *sp = stat_info; BUFFER *bp = output_buffer;