OS/2 portability changes by Ilya

This commit is contained in:
Miguel de Icaza 1999-02-13 21:39:18 +00:00
parent 11a4f1fd61
commit 7ca0948527
9 changed files with 80 additions and 9 deletions

View File

@ -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)

View File

@ -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;
}

View File

@ -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

View File

@ -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);

View File

@ -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) */

View File

@ -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

View File

@ -31,6 +31,7 @@
#include <stdarg.h>
#include <fcntl.h>
#include <pwd.h>
#include <sys/types.h> /* POSIX-required by sys/socket.h and netdb.h */
#include <netdb.h> /* struct hostent */
#include <sys/socket.h> /* AF_INET */
#include <netinet/in.h> /* struct in_addr */

View File

@ -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!";

View File

@ -28,7 +28,10 @@
#include <config.h>
#include <syslog.h>
#ifndef NO_SYSLOG_H
# include <syslog.h>
#endif
#include <stdio.h>
#include <stdlib.h> /* For atol() */
#include <stdarg.h>