From 7ca09485272828cbc8e021c3158e20165745052c Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Sat, 13 Feb 1999 21:39:18 +0000 Subject: [PATCH] OS/2 portability changes by Ilya --- pc/util_os2.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++---- src/boxes.c | 7 +++++-- src/color.c | 2 +- src/main.c | 4 +++- src/subshell.c | 9 +++++++++ vfs/direntry.c | 1 + vfs/mcfs.c | 1 + vfs/mcserv.c | 5 +++++ vfs/vfs.c | 5 ++++- 9 files changed, 80 insertions(+), 9 deletions(-) diff --git a/pc/util_os2.c b/pc/util_os2.c index 17b73a7eb..a6d64f162 100644 --- a/pc/util_os2.c +++ b/pc/util_os2.c @@ -49,6 +49,13 @@ #include "../src/util.h" #include "../src/dialog.h" +#ifdef get_default_editor +#undef get_default_editor +#endif + +char *get_default_shell(); + + #ifndef ENOTEMPTY #define ENOTEMPTY ERROR_DIR_NOT_EMPTY #endif @@ -167,9 +174,21 @@ my_system (int as_shell_command, const char *shell, const char *command) char *parm; /* This is the parameter (can be more than one) */ register int length, i; char temp[4096]; /* That's enough! */ + char *t, *t1; sh = get_default_shell(); - if (strcmp(sh, shell)) { + if (!strcmp("/bin/sh", shell)) { /* Translate "/bin/sh" to "sh" */ + return spawnlp(P_WAIT, "sh", shell, "-c", command, NULL); + } else if (( (t = strrchr(shell,'/')) /* Specialcase Bourne */ + || (t = strrchr(shell,'\\'))) + && (t1 = strchr(t, '.')) + && ( + ((t1 - t == 4) && strncmp("bash", t, 4)) + || ((t1 - t == 3) && strncmp("ksh", t, 3)) + || ((t1 - t == 2) && strncmp("sh", t, 2)) + )) { + return spawnlp(P_WAIT, shell, shell, "-c", command, NULL); + } else if (strcmp(sh, shell)) { /* Not equal -- That means: shell is the program and command is the parameter @@ -524,6 +543,7 @@ my_statfs (struct my_statfs *myfs_stats, char *path) free(pFsInfo); } +#ifndef __EMX__ int gettimeofday (struct timeval* tvp, void *p) { @@ -540,6 +560,7 @@ gettimeofday (struct timeval* tvp, void *p) tvp->tv_sec = tvp->tv_usec * 1000 + pdt.hundredths * 10; return 0; } +#endif /* FAKE functions */ @@ -634,7 +655,7 @@ init_uid_gid_cache (void) int mc_doublepopen (int inhandle, int inlen, pid_t *the_pid, char *command, ...) { - return 0; + return -1; } int @@ -643,12 +664,14 @@ mc_doublepclose (int pipe, pid_t pid) return 0; } +#ifndef HAVE_VFS /*hacks to get it compile, remove these after vfs works */ char * vfs_get_current_dir (void) { return NULL; } +#endif int vfs_current_is_extfs (void) @@ -656,6 +679,7 @@ vfs_current_is_extfs (void) return 0; } +#ifndef HAVE_VFS int vfs_file_is_ftp (char *filename) { @@ -674,14 +698,34 @@ extfs_run (char *file) { return; } +#endif + +void * +getgrent(void) { return NULL; } + +void +setgrent(void) {} + +void +endgrent(void) {} int -geteuid(void) +setreuid(uid_t ruid, uid_t euid) { return -1; } + +pid_t +setsid(void) { return (pid_t)-1; } + +int +mkfifo(const char *path, mode_t mode) { return -1; } + +int +socketpair(int i, int i1, int i2, int *i3) { - return 0; + return -1; } +#ifndef HAVE_VFS int mc_chdir(char *pathname) { @@ -711,6 +755,7 @@ mc_chmod(char *pathName, int unxmode) int os2Mode = unxmode & 0x0FFF; return chmod(pathName, os2Mode); } +#endif static int conv_os2_unx_rc(int os2rc) @@ -738,6 +783,7 @@ conv_os2_unx_rc(int os2rc) return errCode; } +#ifndef HAVE_VFS int mc_open (char *file, int flags, int pmode) { @@ -768,6 +814,7 @@ mc_unlink(char *pathName) return -1; } } +#endif char * get_default_editor (void) diff --git a/src/boxes.c b/src/boxes.c index a114242d7..2cd991d06 100644 --- a/src/boxes.c +++ b/src/boxes.c @@ -847,7 +847,7 @@ static int task_cb (int action, void *ignored) { TaskList *tl; - int sig; + int sig = 0; if (!bg_list->list) return 0; @@ -855,13 +855,16 @@ task_cb (int action, void *ignored) /* Get this instance information */ tl = (TaskList *) bg_list->current->data; +# ifdef SIGTSTP if (action == B_STOP){ sig = SIGSTOP; tl->state = Task_Stopped; } else if (action == B_RESUME){ sig = SIGCONT; tl->state = Task_Running; - } else if (action == B_KILL){ + } else +# endif + if (action == B_KILL){ sig = SIGKILL; } diff --git a/src/color.c b/src/color.c index d96b6cd40..029590a6d 100644 --- a/src/color.c +++ b/src/color.c @@ -241,7 +241,7 @@ static void configure_colors (void) } #ifndef HAVE_SLANG -#define MAX_PAIRS 34 +#define MAX_PAIRS 64 int attr_pairs [MAX_PAIRS]; #endif diff --git a/src/main.c b/src/main.c index 51e4bc345..5651bc9f7 100644 --- a/src/main.c +++ b/src/main.c @@ -1631,7 +1631,7 @@ static void do_suspend_cmd (void) if (console_flag && !use_subshell) restore_console (); -#ifndef OS2_NT +#ifdef SIGTSTP { struct sigaction sigtstp_action; @@ -2372,9 +2372,11 @@ sigchld_handler_no_subshell (int sig) if (pid == cons_saver_pid){ /* {{{ Someone has stopped or killed cons.saver; restart it */ +# ifdef SIGTSTP if (WIFSTOPPED (status)) kill (pid, SIGCONT); else +# endif { handle_console (CONSOLE_DONE); handle_console (CONSOLE_INIT); diff --git a/src/subshell.c b/src/subshell.c index 75d038730..bd221f20e 100644 --- a/src/subshell.c +++ b/src/subshell.c @@ -818,6 +818,7 @@ void sigchld_handler (int sig) if (pid == subshell_pid) { /* {{{ Figure out what has happened to the subshell */ +# ifdef SIGTSTP if (WIFSTOPPED (status)) { if (WSTOPSIG (status) == SIGTSTP) @@ -828,6 +829,7 @@ void sigchld_handler (int sig) subshell_stopped = TRUE; } else /* The subshell has either exited normally or been killed */ +# endif { subshell_alive = FALSE; if (WIFEXITED (status) && WEXITSTATUS (status) != FORK_FAILURE) @@ -844,9 +846,11 @@ void sigchld_handler (int sig) if (pid == cons_saver_pid) { /* {{{ Someone has stopped or killed cons.saver; restart it */ +# ifdef SIGTSTP if (WIFSTOPPED (status)) kill (pid, SIGCONT); else +# endif { handle_console (CONSOLE_DONE); handle_console (CONSOLE_INIT); @@ -860,6 +864,9 @@ void sigchld_handler (int sig) #endif /* ! SCO_FLAVOR */ #endif /* ! HAVE_X */ /* If we get here, some other child exited; ignore it */ +# ifdef __EMX__ /* Need to report */ + pid = wait(&status); +# endif } /* }}} */ @@ -1007,7 +1014,9 @@ static void synchronize (void) while (subshell_alive && !subshell_stopped) sigsuspend (&old_mask); subshell_stopped = FALSE; +# ifdef SIGTSTP kill (subshell_pid, SIGCONT); +# endif sigprocmask (SIG_SETMASK, &old_mask, NULL); /* We can't do any better without modifying the shell(s) */ diff --git a/vfs/direntry.c b/vfs/direntry.c index b40e9c043..8ac044e58 100644 --- a/vfs/direntry.c +++ b/vfs/direntry.c @@ -28,6 +28,7 @@ static volatile int total_inodes = 0, total_entries = 0; #include "utilvfs.h" #include "xdirentry.h" +#include "../src/tty.h" #define CALL(x) if (MEDATA->x) MEDATA->x diff --git a/vfs/mcfs.c b/vfs/mcfs.c index 6b3ce7ef1..80ac1df30 100644 --- a/vfs/mcfs.c +++ b/vfs/mcfs.c @@ -31,6 +31,7 @@ #include #include #include +#include /* POSIX-required by sys/socket.h and netdb.h */ #include /* struct hostent */ #include /* AF_INET */ #include /* struct in_addr */ diff --git a/vfs/mcserv.c b/vfs/mcserv.c index ee5db0040..3ff554dc4 100644 --- a/vfs/mcserv.c +++ b/vfs/mcserv.c @@ -1095,6 +1095,7 @@ char *get_client (int portnum) struct hostent *hp; char hostname [255]; int yes = 1; + char *me; if ((sock = socket (AF_INET, SOCK_STREAM, 0)) < 0) return "Can't create socket"; @@ -1106,6 +1107,10 @@ char *get_client (int portnum) gethostname (hostname, 255); if (verbose) printf ("hostname=%s\n", hostname); hp = gethostbyname (hostname); +#ifdef __EMX__ + if (hp == 0 && (me = getenv("HOSTNAME")) && (0 == strcmp(hostname, me))) + hp = gethostbyname ("localhost"); +#endif if (hp == 0) return "hp = 0!"; diff --git a/vfs/vfs.c b/vfs/vfs.c index d9bb122d4..b7895ce78 100644 --- a/vfs/vfs.c +++ b/vfs/vfs.c @@ -28,7 +28,10 @@ #include -#include +#ifndef NO_SYSLOG_H +# include +#endif + #include #include /* For atol() */ #include