| 1 | /* Running commands on Amiga
|
|---|
| 2 | Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
|---|
| 3 | This file is part of GNU Make.
|
|---|
| 4 |
|
|---|
| 5 | GNU Make is free software; you can redistribute it and/or modify
|
|---|
| 6 | it under the terms of the GNU General Public License as published by
|
|---|
| 7 | the Free Software Foundation; either version 2, or (at your option)
|
|---|
| 8 | any later version.
|
|---|
| 9 |
|
|---|
| 10 | GNU Make is distributed in the hope that it will be useful,
|
|---|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 13 | GNU General Public License for more details.
|
|---|
| 14 |
|
|---|
| 15 | You should have received a copy of the GNU General Public License
|
|---|
| 16 | along with GNU Make; see the file COPYING. If not, write to
|
|---|
| 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
|---|
| 18 | MA 02111-1307, USA. */
|
|---|
| 19 |
|
|---|
| 20 | #include "make.h"
|
|---|
| 21 | #include "variable.h"
|
|---|
| 22 | #include "amiga.h"
|
|---|
| 23 | #include <assert.h>
|
|---|
| 24 | #include <exec/memory.h>
|
|---|
| 25 | #include <dos/dostags.h>
|
|---|
| 26 | #include <proto/exec.h>
|
|---|
| 27 | #include <proto/dos.h>
|
|---|
| 28 |
|
|---|
| 29 | static const char Amiga_version[] = "$VER: Make 3.74.3 (12.05.96) \n"
|
|---|
| 30 | "Amiga Port by A. Digulla (digulla@home.lake.de)";
|
|---|
| 31 |
|
|---|
| 32 | int
|
|---|
| 33 | MyExecute (char **argv)
|
|---|
| 34 | {
|
|---|
| 35 | char * buffer, * ptr;
|
|---|
| 36 | char ** aptr;
|
|---|
| 37 | int len = 0;
|
|---|
| 38 | int status;
|
|---|
| 39 |
|
|---|
| 40 | for (aptr=argv; *aptr; aptr++)
|
|---|
| 41 | {
|
|---|
| 42 | len += strlen (*aptr) + 4;
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | buffer = AllocMem (len, MEMF_ANY);
|
|---|
| 46 |
|
|---|
| 47 | if (!buffer)
|
|---|
| 48 | fatal (NILF, "MyExecute: Cannot allocate space for calling a command");
|
|---|
| 49 |
|
|---|
| 50 | ptr = buffer;
|
|---|
| 51 |
|
|---|
| 52 | for (aptr=argv; *aptr; aptr++)
|
|---|
| 53 | {
|
|---|
| 54 | if (((*aptr)[0] == ';' && !(*aptr)[1]))
|
|---|
| 55 | {
|
|---|
| 56 | *ptr ++ = '"';
|
|---|
| 57 | strcpy (ptr, *aptr);
|
|---|
| 58 | ptr += strlen (ptr);
|
|---|
| 59 | *ptr ++ = '"';
|
|---|
| 60 | }
|
|---|
| 61 | else if ((*aptr)[0] == '@' && (*aptr)[1] == '@' && !(*aptr)[2])
|
|---|
| 62 | {
|
|---|
| 63 | *ptr ++ = '\n';
|
|---|
| 64 | continue;
|
|---|
| 65 | }
|
|---|
| 66 | else
|
|---|
| 67 | {
|
|---|
| 68 | strcpy (ptr, *aptr);
|
|---|
| 69 | ptr += strlen (ptr);
|
|---|
| 70 | }
|
|---|
| 71 | *ptr ++ = ' ';
|
|---|
| 72 | *ptr = 0;
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|
| 75 | ptr[-1] = '\n';
|
|---|
| 76 |
|
|---|
| 77 | status = SystemTags (buffer,
|
|---|
| 78 | SYS_UserShell, TRUE,
|
|---|
| 79 | TAG_END);
|
|---|
| 80 |
|
|---|
| 81 | FreeMem (buffer, len);
|
|---|
| 82 |
|
|---|
| 83 | if (SetSignal(0L,0L) & SIGBREAKF_CTRL_C)
|
|---|
| 84 | status = 20;
|
|---|
| 85 |
|
|---|
| 86 | /* Warnings don't count */
|
|---|
| 87 | if (status == 5)
|
|---|
| 88 | status = 0;
|
|---|
| 89 |
|
|---|
| 90 | return status;
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | char *
|
|---|
| 94 | wildcard_expansion (char *wc, char *o)
|
|---|
| 95 | {
|
|---|
| 96 | # define PATH_SIZE 1024
|
|---|
| 97 | struct AnchorPath * apath;
|
|---|
| 98 |
|
|---|
| 99 | if ( (apath = AllocMem (sizeof (struct AnchorPath) + PATH_SIZE,
|
|---|
| 100 | MEMF_CLEAR))
|
|---|
| 101 | )
|
|---|
| 102 | {
|
|---|
| 103 | apath->ap_Strlen = PATH_SIZE;
|
|---|
| 104 |
|
|---|
| 105 | if (MatchFirst (wc, apath) == 0)
|
|---|
| 106 | {
|
|---|
| 107 | do
|
|---|
| 108 | {
|
|---|
| 109 | o = variable_buffer_output (o, apath->ap_Buf,
|
|---|
| 110 | strlen (apath->ap_Buf));
|
|---|
| 111 | o = variable_buffer_output (o, " ",1);
|
|---|
| 112 | } while (MatchNext (apath) == 0);
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | MatchEnd (apath);
|
|---|
| 116 | FreeMem (apath, sizeof (struct AnchorPath) + PATH_SIZE);
|
|---|
| 117 | }
|
|---|
| 118 |
|
|---|
| 119 | return o;
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|