From e99a3aca7ec9796973a7e4d93676c5c13483a948 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 9 May 1996 18:02:06 +0000 Subject: Thu May 9 13:54:49 1996 Roland McGrath * GNUmakefile (globfiles): Add AmigaDOS support files. (distfiles): Add $(amigafiles). (amigafiles): New variable. Thu Nov 7 10:18:16 1995 Aaron Digulla * Added Amiga support in commands.c, dir.c, function.c, job.c, main.c, make.h, read.c, remake.c * commands.c: Amiga has neither SIGHUP nor SIGQUIT * dir.c: Amiga has filenames with Upper- and Lowercase, but "FileName" is the same as "filename". Added strieq() which is use to compare filenames. This is like streq() on all other systems. Also there is no such thing as "." under AmigaDOS. * function.c: On Amiga, the environment is not passed as envp, there are no pipes and Amiga can't fork. Use my own function to create a new child. * job.c: default_shell is "" (The system automatically chooses a shell for me). Have to use the same workaround as MSDOS for running batch commands. Added HAVE_SYS_PARAM_H. NOFILE isn't known on Amiga. Cloned code to run children from MSDOS. Own version of sh_chars[] and sh_cmds[]. No dup2() or dup() on Amiga. * main.c: Force stack to 20000 bytes. Read environment from ENV: device. On Amiga, exec_command() does return, so I exit() afterwards. * make.h: Added strieq() to compare filenames. * read.c: Amiga needs special extension to have passwd. Only one include-dir. "Makefile" and "makefile" are the same. Added "SMakefile". Added special code to handle device names (xxx:) and "./" in rules. * remake.c: Only one lib-dir. Amiga link-libs are named "%s.lib" instead of "lib%s.a". * main.c, rule.c, variable.c: Avoid floats at all costs. * vpath.c: Get rid of as many alloca()s as possible. --- job.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 80 insertions(+), 8 deletions(-) (limited to 'job.c') diff --git a/job.c b/job.c index 90ae9d9..098beee 100644 --- a/job.c +++ b/job.c @@ -25,7 +25,12 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include /* Default shell to use. */ +#ifndef _AMIGA char default_shell[] = "/bin/sh"; +#else +char default_shell[] = ""; +extern int MyExecute (char **); +#endif #ifdef __MSDOS__ #include @@ -35,6 +40,13 @@ static char *dos_bname; static char *dos_bename; static int dos_batch_file; #endif /* MSDOS. */ +#ifdef _AMIGA +#include +static int amiga_pid = 123; +static int amiga_status; +static char amiga_bname[32]; +static int amiga_batch_file; +#endif /* Amiga. */ #ifdef VMS #include @@ -300,7 +312,7 @@ reap_children (block, err) } else if (pid == 0) { -#ifndef __MSDOS__ +#if !defined(__MSDOS__) && !defined(_AMIGA) /* No remote children. Check for local children. */ if (any_local) @@ -355,12 +367,21 @@ reap_children (block, err) coredump = WCOREDUMP (status); } #else /* MSDOS. */ +#ifdef __MSDOS__ /* Life is very different on MSDOS. */ pid = dos_pid - 1; status = dos_status; exit_code = dos_status; exit_sig = 0; coredump = 0; +#else + /* Same on Amiga */ + pid = amiga_pid - 1; + status = amiga_status; + exit_code = amiga_status; + exit_sig = 0; + coredump = 0; +#endif #endif /* Not MSDOS. */ } else @@ -572,7 +593,9 @@ static void start_job_command (child) register struct child *child; { +#ifndef _AMIGA static int bad_stdin = -1; +#endif register char *p; int flags; #ifdef VMS @@ -732,11 +755,13 @@ start_job_command (child) child->deleted = 0; +#ifndef _AMIGA /* Set up the environment for the child. */ if (child->environment == 0) child->environment = target_environment (child->file); +#endif -#ifndef __MSDOS__ +#if !defined(__MSDOS__) && !defined(_AMIGA) #ifndef VMS /* start_waiting_job has set CHILD->remote if we can start a remote job. */ @@ -805,8 +830,8 @@ start_job_command (child) #endif /* !VMS */ } -#else /* MSDOS. */ - +#else /* MSDOS or Amiga. */ +#ifdef __MSDOS__ dos_status = spawnvpe (P_WAIT, argv[0], argv, child->environment); ++dead_children; child->pid = dos_pid++; @@ -820,6 +845,17 @@ start_job_command (child) dos_status = 0; remove (dos_bename); } +#else + amiga_status = MyExecute (argv); + + ++dead_children; + child->pid = amiga_pid++; + if (amiga_batch_file) + { + amiga_batch_file = 0; + DeleteFile (amiga_bname); /* Ignore errors. */ + } +#endif /* Not Amiga */ #endif /* Not MSDOS. */ /* We are the parent side. Set the state to @@ -1468,6 +1504,14 @@ construct_command_argv_internal (line, restp, shell, ifs) "mkdir", "path", "pause", "prompt", "rem", "ren", "rename", "set", "shift", "time", "type", "ver", "verify", "vol", ":", 0 }; +#endif +#ifdef _AMIGA + static char sh_chars[] = "#;\"|<>()?*$`"; + static char *sh_cmds[] = { "cd", "eval", "if", "delete", "echo", "copy", + "rename", "set", "setenv", "date", "makedir", + "skip", "else", "endif", "path", "prompt", + "unset", "unsetenv", "version", + 0 }; #else static char sh_chars[] = "#;\"*?[]&|<>(){}$`^"; static char *sh_cmds[] = { "cd", "eval", "exec", "exit", "login", @@ -1715,7 +1759,35 @@ construct_command_argv_internal (line, restp, shell, ifs) new_argv[0] = strdup (dos_bname); new_argv[1] = 0; } -#else /* Not MSDOS. */ +#endif /* MSDOS. */ +#ifdef _AMIGA + { + char *ptr; + char *buffer; + char *dptr; + + buffer = (char *)xmalloc (strlen (line)+1); + + ptr = line; + for (dptr=buffer; *ptr; ) + { + if (*ptr == '\\' && ptr[1] == '\n') + ptr += 2; + else if (*ptr == '@') /* Kludge: multiline commands */ + { + ptr += 2; + *dptr++ = '\n'; + } + else + *dptr++ = *ptr++; + } + *dptr = 0; + + new_argv = (char **) xmalloc(2 * sizeof(char *)); + new_argv[0] = buffer; + new_argv[1] = 0; + } +#else /* Not MSDOS or Amiga */ { /* SHELL may be a multi-word command. Construct a command line "SHELL -c LINE", with all special chars in LINE escaped. @@ -1773,7 +1845,7 @@ construct_command_argv_internal (line, restp, shell, ifs) new_argv = construct_command_argv_internal (new_line, (char **) NULL, (char *) 0, (char *) 0); } -#endif /* MSDOS. */ +#endif /* Not MSDOS nor Amiga. */ return new_argv; } @@ -1819,7 +1891,7 @@ construct_command_argv (line, restp, file) } #endif /* !VMS */ -#ifndef HAVE_DUP2 +#if !defined(HAVE_DUP2) && !defined(_AMIGA) int dup2 (old, new) int old, new; @@ -1837,4 +1909,4 @@ dup2 (old, new) return fd; } -#endif +#endif /* !HAPE_DUP2 && !_AMIGA */ -- cgit v1.2.3