=================================================================== RCS file: /home/cvs/OpenXM_contrib2/fep/fep_main.c,v retrieving revision 1.3 retrieving revision 1.11 diff -u -p -r1.3 -r1.11 --- OpenXM_contrib2/fep/fep_main.c 2002/09/18 10:03:28 1.3 +++ OpenXM_contrib2/fep/fep_main.c 2019/12/13 15:41:36 1.11 @@ -1,11 +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[]= -"$Id: fep_main.c,v 1.3 2002/09/18 10:03:28 noro Exp $ (SRA)"; +"$Id: fep_main.c,v 1.11 2019/12/13 15:41:36 fujimoto Exp $ (SRA)"; #endif /* lint */ #include +#include +#include #include #include #include @@ -246,7 +254,11 @@ DEFAULT: * Set variable of command name. */ { +#if defined(ANDROID) + char *cp = argv[1]; +#else char *cp = argv[1], *rindex(); +#endif if (any ('/', cp)) cp = rindex (cp, '/') + 1; @@ -257,7 +269,11 @@ DEFAULT: commandv = &argv[1]; if (! isatty (0)) { +#if defined(__INTERIX) + execvp (*commandv, commandv); +#else execvp (*commandv, commandv, 0); +#endif perror (*commandv); exit (1); } @@ -335,7 +351,7 @@ recover_signal () input_handler() { char *inputline; - char *getline (); + char *mygetline (); /* * Get slave tty descriptor for auto-tty-fix @@ -343,7 +359,7 @@ input_handler() if ((slave = open (slave_tty, O_RDONLY)) < 0) perror ("open"); - while (inputline = getline ()) { + while (inputline = mygetline ()) { /* * XXX: nbyte should be greater than 0 only for ^@ input in emacs. * This solution is very ugly.. but it will takes a half day @@ -359,7 +375,7 @@ input_handler() /* * NOTE: - * Saving command line to output buffer is done in getline(). + * Saving command line to output buffer is done in mygetline(). * Because inputline here is converted by alias. */ @@ -541,7 +557,7 @@ int set_buffer (bp, size) BUFFER *bp; int size; { - char *newbuf, *malloc(), *realloc(); + char *newbuf; if (bp->b_buf) newbuf = (char *) realloc (bp->b_buf, size); @@ -673,6 +689,10 @@ swallow_output() #include #endif +#if defined(__INTERIX) +#define wait3(s,opt,rp) (waitpid((-1),(s),(opt))) +#endif + void catchsig(n) int n; @@ -702,7 +722,7 @@ exec_to_command(argv) */ t = open ("/dev/tty", 2); if (t >= 0) { -#ifndef __CYGWIN32__ +#if !defined(__CYGWIN32__) && !defined(__INTERIX) ioctl (t, TIOCNOTTY, (char *) 0); #endif (void) close (t); @@ -721,7 +741,11 @@ exec_to_command(argv) #elif defined(TIOCSETN) ioctl (0, TIOCSETN, (char *) & slave_ttymode); #endif +#if defined(__INTERIX) + execvp (*argv, argv); +#else execvp (*argv, argv, 0); +#endif perror (*argv); exit (1); } @@ -854,16 +878,34 @@ get_pty_master() master = 1; return; } -#ifdef __CYGWIN32__ +#if defined(__CYGWIN32__) || defined(__linux__) || defined(__APPLE__) sprintf (master_tty, "/dev/ptmx"); master = open (master_tty, O_RDWR); if (master >= 0) { +#if defined(__linux__) + char name[BUFSIZ]; + grantpt(master); + unlockpt(master); + if ( !ptsname_r(master,name,sizeof(name)) ) { + strcpy(slave_tty, name); + goto FOUND; + } +#elif defined(__APPLE__) + char *name; + grantpt(master); + unlockpt(master); + if ( name = (char *)ptsname(master) ) { + strcpy(slave_tty, name); + goto FOUND; + } +#else char *name; name = (char *)ptsname(master); if ( name != 0 ) { strcpy(slave_tty, name); goto FOUND; } +#endif } #else for (c = 'p'; c <= 's'; c++) { @@ -1049,8 +1091,9 @@ usageAndExit() /* * Propagate window size changes to the slave tty. */ -sigwinch() +void sigwinch(int dummy) { + char *itoa(int i); #ifdef TIOCGWINSZ /* 4.3BSD */ struct winsize win;